HPlogo HP/DDE Debugger User's Guide: HP 9000 Series 700/800 Computers > Chapter 8 Debugging in Special Situations

Assembly Level Debugging

» 

Technical documentation

Complete book in PDF

 » Table of Contents

 » Glossary

 » Index

Although HP/DDE is intended as a high-level (source language) debugging tool, it also supports low-level (assembly language) debugging by using the machine code generated by the compiler.

You can examine the machine code produced by the compiler for your program, and step your program at the assembly code level. You can set breakpoints on individual machine instructions, and you can also monitor virtual address ranges.

Assembly level debugging is particularly useful for debugging optimized code. See “Debugging Optimized Code ”.

Using the Assembly Instructions Dialog Box

The Show:Assembly Instructions menu choice brings up the Assembly Instructions dialog box. (See Figure 8-3 “Assembly Instructions Dialog Box ”.) This dialog box contains a scrollable view of the assembly language code for the current procedure of your program. The format of the code depends on the system on which you are running. The window normally shows the following:

  • Source line number

  • Memory address

  • Disassembly listing of the actual machine code

To set a breakpoint at the assembly level:

  1. Select the address (in the Assembly Instructions dialog box). This copies the address into the ( ): Input Box.

  2. Choose Break:Set At Hex Address ( ).

You can also click the left mouse button in the Annotation Margin of the Assembly Instructions dialog box, or press the right mouse button on the desired assembly line, to set or clear breakpoints.

Figure 8-3 Assembly Instructions Dialog Box

[Assembly Instructions Dialog Box]

Use the Step Instruction button to step through your program one assembly instruction at a time. Use Step Over Instruction to step over routines called from the assembly code.

The Assembly Tracing Active button enables updating of the Assembly Instructions window. If assembly tracing is disabled until you need it, your program might run faster.

Using Debugger Commands

You can display ranges of memory with the dump command and watch a virtual address range with the watchpoint command. Refer to the dump and watchpoint command descriptions in the online command reference for details. The dump command remembers the last location that was dumped and continues dumping from the next address when you issue another dump command using * as the -from address. The dump command also prints the previously specified number of bits by default.

For example:

dump -from 2260 -to 227E -bits 16 -hex
00002260: 6BD8 3F29 2B7F FFFF 4821 0F58 8C20 2012
00002270: E800 0148 0800 025C E800 0122 23E1 0000

dump -from * -to 2284 -binary
00002280: 1110011111100000 0010011010101000 0000100000011111

The target manager startup file defines aliases that dump the state of the machine registers and that monitor registers for changes. See the "Startup File" section in Appendix C “Target Managers ”.

You can use the debugger's `va reserved identifier to print the contents of any machine location or to store a value to any machine location. This function takes a machine address (in hexadecimal format) or register name as an argument and acts like an untyped variable at that address. You can use `va in combination with type casting to print in any format. For example:

print(long)`va(2F5A)

Prints the contents of 2F5A as a long integer (C syntax).

print integer(`va(2F5A))

Prints the contents of 2F5A as a long integer (Pascal syntax).

print (my_struct)`va(2F5A)

Prints the value starting at 2F5A as a record (C syntax).

set integer32(`va(31CF450)):=99

Assigns a long integer to an address (Pascal syntax).

watch (long)`va(2F5A)

Watches the contents of 2F5A as a long integer (C syntax).

You can use the `va function to refer to a specific code location in any command that calls for a location specifier. Consider the following examples:

break `va(00001FCC)

Sets a breakpoint on a specific machine address.

goto `va(1FCC)

Transfers control to a specific machine address.

You can also use the describe command with the `va function. For example:

describe -location `va(1FCC)

Finds the source statement that corresponds to a code location.

Saving Assembly Code in a File

To save assembly code in a file for printing or viewing, redirect output of the dump command using the following syntax:

dump -from address -to address -instruction >filename

You can determine address values from the Assembly Display window.