Rational Developer for System z, Version 7.6

Debugging a disassembled program

To debug programs that have been compiled or assembled without debug information, you can use the disassembly view. When you use the disassembly view, symbolic information from the original source program (program variables, labels, and other symbolic references to a section of memory ) is not available. The DYNDEBUG switch must be ON before you use the disassembly view.

If you are not familiar with the program that you are debugging, we recommend that you have a copy of the listing that was created by the compiler or High Level Assembler (HLASM) available while you debug the program. There are no special assembly or compile requirements that the program must comply with to use the disassembly view.

The SET ASSEMBLER and SET DISASSEMBLY commands

The SET ASSEMBLER ON and SET DISASSEMBLY ON commands enable some of the same functions. However, you must consider which type of CUs that you will be debugging (assembler, disassembly, or both) before deciding which command to use. The following guidelines can help you decide which command to use:

If you are debugging an assembler CU and later decide you want to debug a disassembly CU, you can enter the SET DISASSEMBLY ON command after you enter the SET ASSEMBLER ON command.

Capabilities of the disassembly view

When you use the disassembly view, you can do the following tasks:

Starting the disassembly view

To start the disassembly view:

  1. Enter the SET DISASSEMBLY ON command
  2. Open the program that does not contain debug data. Debug Tool then changes the language setting to Disassem and the Source window displays the assembler code.

If you enter a program that does contain debug data, the language setting does not change and the Source window does not display disassembly code.

The disassembly view

When you debug a program through the disassembly view, the Source window displays the disassembly instructions. The language area of the Debug Tool screen (upper left corner) displays the word Disassem. The Debug Tool screen appears as follows:

Disassem LOCATION: MAIN initialization
Command ===>                                                   Scroll ===> PAGE
MONITOR --+----1----+----2----+----3----+----4----+----5----+----6 LINE: 0 OF 0
******************************* TOP OF MONITOR ********************************
****************************** BOTTOM OF MONITOR ******************************



SOURCE: MAIN +----1----+----2----+----3----+----4----+----5----+ LINE: 1 OF 160
      0 1950C770    47F0 F014       BC    15,20(,R15)                         .
    A 4 1950C774    00C3            ????                                      .
      6 1950C776 B  C5C5            ????                                      .
      8 1950C778    0000            ????                                      .
      A 1950C77A    0080 C          ????                                      .
      C 1950C77C    0000            ????                                      .
      E 1950C77E    00C4            ???? D                                    .
     10 1950C780    47F0 F001       BC    15,1(,R15)                          .
     14 1950C784    90EC D00C       STM   R14,R12,12(R13)                     .
     18 1950C788    18BF            LR    R11,R15   E                         .
     1A 1950C78A    5820 B130       L     R2,304(,R11)                        .
     1E 1950C78E    58F0 B134       L     R15,308(,R11)                       .
     22 1950C792    05EF            BALR  R14,R15                             .
     24 1950C794    1821            LR    R2,R1                               .
     26 1950C796    58E0 C2F0       L     R14,752(,R12)                       .
     2A 1950C79A    9680 E008       OI    8(R14),128                          .
     2E 1950C79E    05B0            BALR  R11,0                               .
LOG 0----+----1----+----2----+----3----+----4----+----5----+----6- LINE: 1 OF 5
********************************* TOP OF LOG **********************************
0001 IBM Debug Tool Version 9 Release 1 Mod 0
0002 10/03/2008 4:11:41 PM
0003 5655-U27: Copyright IBM Corp. 1992, 2008
0004 EQA1872E An error occurred while opening file: INSPPREF. The file may not
0005          exist, or is not accessible.
0006 SET DISASSEMBLY ON ;
PF  1:?           2:STEP       3:QUIT       4:LIST       5:FIND      6:AT/CLEAR
PF  7:UP          8:DOWN       9:GO        10:ZOOM      11:ZOOM LOG 12:RETRIEVE
 A  Prefix Area
Displays the offset from the start of the CU or CSECT.
 B  Columns 1-8
Displays the address of the machine instruction in memory.
 C  Columns 13-26
Displays the machine instruction in memory.
 D  Columns 29-32
Displays the op-code mnemonic or ???? if the op-code is not valid.
 E  Columns 35-70
Displays the disassembled machine instruction.

When you use the disassembly view, the disassembly instructions displayed in the source area are not guaranteed to be accurate because it is not always possible to distinguish data from instructions. Because of the possible inaccuracies, we recommend that you have a copy of the listing that was created by the compiler or by HLASM. Debug Tool keeps the disassembly view as accurate as possible by refreshing the Source window whenever it processes the machine code, for example, after a STEP command.

Performing single-step operations in the disassembly view

Use the STEP command to single-step through your program. In the disassembly view, you step from one disassembly instruction to the next. Debug Tool highlights the instruction that it runs next.

If you try to step back into the program that called your program, set a breakpoint at the instruction to which you return in the calling program. If you try to step over another program, set a breakpoint immediately after the instruction that calls another program. When you try to step out of your program, Debug Tool displays a warning message and lets you set the appropriate breakpoints. Then you can do the step.

Debug Tool refreshes the disassembly view whenever it determines that the disassembly instructions that are displayed are no longer correct. This refresh can happen while you are stepping through your program.

Setting breakpoints in the disassembly view

You can use a special breakpoint when you debug your program through the disassembly view. AT OFFSET sets a breakpoint at the point that is calculated from the start of the entry point address of the CSECT. You can set a breakpoint by entering the AT OFFSET command on the command line or by placing the cursor in the prefix area of the line where you want to set a breakpoint and press the AT function key or type AT in the prefix area.

Debug Tool lets you set breakpoints anywhere within the starting and ending address range of the CU or CSECT provided that the address appears to be a valid op-code and is an even number offset. To avoid setting breakpoints at the wrong offset, we recommend that you verify the offset by referring to a copy of the listing that was created by the compiler or by HLASM.

Restrictions for debugging self-modifying code

Debug Tool cannot debug self-modifying code. If your program contains self-modifying code that modifies an instruction while the containing compilation unit is being debugged, the result can be unpredictable, including an abnormal termination (ABEND) of Debug Tool. If your program contains self-modifying code that completely replaces an instruction while the containing compilation unit is being debugged, the result might not be an ABEND. However, Debug Tool might miss a breakpoint on that instruction or display a message indicating an invalid hook address at delete.

The following coding techniques can be used to minimize problems debugging self-modifying code:

  1. Do not modify part of an instruction. Instead, replace an instruction. The following table compares coding techniques:
    Coding that modifies an instructions Coding that replaces an instruction
    ModInst  BC 0,Target
       ...
       MVI ModInst+1,X'F0'
    ModInst  BC 0,Target
       ...
       MVC ModInst(4),NewInst
       ...
    NewInst  BC 15,Target
  2. Define instructions to be modified by using DC instructions instead of executable instructions. For example, use the instruction ModInst DC X'4700',S(Target) instead of the instruction MVC ModInst(4),NewInst.

Displaying and modifying registers in the disassembly view

You can display the contents of all the registers by using the LIST REGISTERS command. To display the contents of an individual register, use the LIST Rx command, where x is the individual register number. You can also display the contents of an individual register by placing the cursor on the register and pressing the LIST function key. The default LIST function key is PF4. You can modify the contents of a register by using the assembler assignment statement.

Displaying and modifying storage in the disassembly view

You can display the contents of storage by using the LIST STORAGE command. You can modify the contents of storage by using the STORAGE command.

You can also use assembler statements to display and modify storage. For example, to set the four bytes located by the address in register 2 to zero, enter the following command:

R2-> <4>=0

To verify that the four bytes are set to zero, enter the following command:

LIST R2->

Changing the program displayed in the disassembly view

You can use the SET QUALIFY command to change the program that is displayed in the disassembly view. Suppose you are debugging program ABC and you need to set a breakpoint in program BCD.

  1. Enter the command SET QUALIFY CU BCD on the command line. Debug Tool changes the Source window to display the disassembly instructions for program BCD.
  2. Scroll through the Source window until you find the instruction where want to set a breakpoint.
  3. To return to program ABC, at the point where the next instruction is to run, issue the SET QUALIFY RESET command.

Restrictions for the disassembly view

When you debug a disassembled program, the following restrictions apply:

When you debug a program through the disassembly view, Debug Tool cannot stop the application in any of the following situations:

The application runs until Debug Tool encounters a valid save area backchain.


Terms of use | Feedback

This information center is powered by Eclipse technology. (http://www.eclipse.org)