Debuggers

15
Debuggers • A program needed when writing any type of code • Displays the contents of memory • Lets you view registers and variables and see how they change • Allows tracing (stepping through a program one line at a time)

description

Debuggers. A program needed when writing any type of code Displays the contents of memory Lets you view registers and variables and see how they change Allows tracing (stepping through a program one line at a time). Debug. A debugger supplied with both DOS and Windows Debug.exe - PowerPoint PPT Presentation

Transcript of Debuggers

Page 1: Debuggers

Debuggers

• A program needed when writing any type of code

• Displays the contents of memory

• Lets you view registers and variables and see how they change

• Allows tracing (stepping through a program one line at a time)

Page 2: Debuggers

Debug

• A debugger supplied with both DOS and Windows

• Debug.exe• Found in \Windows\command• Command line driven• A precursor of Microsoft Codeview,

Borland Turbo Debugger, Visual Studio Debuggers, Periscope, Atron, SYMDEB, Codesmith-86, Advanced-Trace-86

Page 3: Debuggers

Assembly Level Debugger

• Debug is an assembly level debugger– Displays only assembly mnemonics and

machine instructions.

C> debug sample.exe

Debug.exe

Sample.exe

DOS0000

Page 4: Debuggers

Debugging Functions

• Assemble short programs• View a program’s source code along with its machine

language• View the CPU registers and flags• Trace or execute a program, watching variables for

changes• Enter new values into memory• Search for binary or ASCII values in memory• Move a block of memory from one location to another• Fill a block of memory• Load and write disk files and sectors

Page 5: Debuggers

Debug Commands

• Can be divided into four categories– Program creation/debugging– Memory manipulation– Miscellaneous– Input-output

Page 6: Debuggers

Command Parameters

• Addresses– can be given as either a complete segment-

offset or just an offset– Segment portion may be a hex number or a

register name• F000:100 segment, offset• DS:200 segment register, offset• 0AF5 offset

Page 7: Debuggers

Command Parameters

• Address Ranges– Format 1: address [.address]

• 100, 500• CS:200, 300• 200

– Format 2: address L [value]• 100 L 20 (20h bytes starting at location 100h)

Page 8: Debuggers

Command Parameters

• Strings – a sequence of characters enclosed in single or double quotes.

• ‘command’• “File can not be opened.”

• Filespec – • B:prog1.com• C:\asm\progs\test.com• File1

• Values – consists of 1- to 4-character hex number.

Page 9: Debuggers

Example commands

• -D (Dump)– Displays memory on the screen as single

bytes in both hex and ASCIINo range given => dumps 128 bytes from last

referenced location-d 0-200 => dumps offsets 0-200 from DS-d SS:0 5 => dumps the bytes at offsets 0-5

from SS.-d 915:0 => dumps 128 bytes from segment

0915h

Page 10: Debuggers

Example Commands

• -R (Registers)-r =>display the contents of all registers

-r IP => display the contents of IP and prompt for a new value

-r CX => display the contents of CX and prompt for a new value

-r F => display all flags and prompt for a new flag value.

Page 11: Debuggers

Flags

Set• OV = Overflow• DN = Direction Down• EI = Interrupts enabled• NG = Sign Flag negative• ZR = Zero• AC = Auxiliary Carry• PO = Odd Parity• CY= Carry

Clear• NV = No Overflow• UP = Direction Up• DI = Interrupts Disabled• PL = Sign Flag Positive• NZ = Not Zero• NA = No Auxiliary Carry• PE = Even Parity• NC = No Carry

Page 12: Debuggers

Example Commands

• A (Assemble)– Assemble a program into machine language

• A 100 => assemble at CS:100• A => assemble from the current location• A DS:2000 => Assemble at DS:2000h

– Pressing enter at the end of a line, returns a prompt for the next line of input. To terminate input, press the Enter key on a blank line.

-a 1005514:0100 mov ah, 25514:0102 mov dl, 415514:0104 int 215514:0106

Page 13: Debuggers

Example Commands

• -T (Trace) executes one or more instructions starting at either the current CS:IP location or at an optional address.-t => trace the next instruction

-t 5 => trace the next five instructions

-t =105 10 => trace 16 instructions starting at CS:105

Page 14: Debuggers

Segment Defaults

Command Description Default Segment

A Assemble CS

D Dump DS

E Enter DS

F Fill CS

G Go(execute) CS

L Load DS

M Move DS

P Procedure Trace CS

S Search DS

T Trace CS

U Unassemble CS

W Write CS

Page 15: Debuggers

Lab #1 and Lab #2

• First two labs will allow you to explore using Debug.