Debug Tool

This chapter describes the debug tools provided by OpenFrame ASM (hereinafter "OFASM").

1. ofadbg

ofadbg is a tool for tracing code executed by OpenFrame Assembler and displaying related information.

The following shows how to use ofadbg:

ofadbg <port number>

ofadbg debugging is only available in the ofasm debug binary.

  • Code Modification

    The OFADBGREG 220 command must be inserted at the point where debugging is to be performed. When the command is executed, a socket server for debugging is created and enters a waiting state for socket connections.

    TESTASM  CSECT
             LR 12,15
             USING TESTASM,12
             ST    14,SAVEAREA
             OFADBGREG 220
             L     2,0(1)
             L     3,4(1)
             MVC   P1(4),0(2)
             MVC   P2(4),0(3)
             CALL  TESTCOB,(P1,P2),VL
             L     14,SAVEAREA
             BR    14
    *
    SAVEAREA DS    F
    P1       DS    CL4
    P2       DS    CL4
             END

    When the OFADBGREG 220 command is executed, the following message is displayed. Execute the command according to the message.

    OFASM: OFADBGREG[220], CONNECT DEBUGGER
    Please run this command "ofadbg 41353", Port is "41353"
  • Compilation

    To use ofadbg, compile the program using ofasm -g to generate the asmo object code that contains debugging information.

    ofasm TESTASM.asm -g
  • Tool Execution

    Start debugging using the ofadbg tool. When a connection is established to the socket server in waiting state, the code of the currently running asmi file is displayed.

    ofadbg 41353
  • Console Output

    When the ofadbg tool is successfully executed, the following console screen is displayed.

    ofadbg console
    ofadbg Console Screen

1.1. Commands

ofadbg supports various commands for code tracing and information output. The following describes each command.

Command Description

break(b) [<entry>:]<line_number>

Sets a breakpoint. When setting a breakpoint, an entry can be specified. If not specified, the breakpoint is set for the currently running entry. Afterwards, use the continue(c) and run(r) command to move to the breakpoint.

  • b 10: Sets a breakpoint at the 10th line of the current entry.

  • b TESTASM:10: Sets a breakpoint in the 10th line of the TESTASM entry.

break(b) list

Displays a list of all breakpoints set so far.

delete(d)

Deletes a breakpoint by specifying its index.

  • d 2: Deletes the second breakpoint.

display(dis) <symbol>|<address> [[offset:][length]]

Registers a specific symbol or address as a value-tracking item. The offset is valid only when a symbol is specified. If the length is not set, it defaults to the allocated size for a symbol, or 4 bytes for an address.

  • dis P1 2:8: Registers 8 bytes of the symbol P1 starting from the second byte as a value-tracking item.

  • dis P1: Registers the Symbol P1 as a value-tracking item. The length is determined by the size allocated to P1.

  • dis 0x1f3240 8: Registers the value at the address 0x1f3240 as a value-tracking item. The length is set to 8 bytes.

  • dis 0x1f3240: Registers the value of the address 0x1f3240 as a value-tracking item. The length is set to 4 bytes.

display(dis) list

Displays the value-tracking items for symbols registered so far.

display(dis) remove(rm) <index>

Removes the value-tracking item corresponding to a specific index.

  • dis rm 1: Removes the first item from the value-tracking items.

set register(reg) <register_num> <hex>|<decimal>

Assigns a value to a specific register. The value can be either an integer or a hexadecimal value.

  • set reg 2 0x41414141: Assigns the hexadecimal value 0x41414141 to register 2.

  • set reg 2 10000: Assigns the value 10000 to the register 2.

set variable(var) <symbol_name> <hex>|<string>

Assigns a value to a specific symbol. The value can be either a string or a hexadecimal value.

  • set var P1 AAAA: Assigns the string value "AAAA" to the symbol P1.

  • set var P1 0x41414141: Assigns the hexadecimal value 0x41414141 to the symbol P1.

set address(addr) <address> <hex>|<decimal>

Assigns a value to a specific address. The value can be either an integer or a hexadecimal value.

  • set addr 12543 0x41414141: Assigns the hexadecimal value 0x41414141 to the address corresponding to the value 12543.

  • set addr 0x1f654 10000: Assigns the value 10000 at the address 0x1f654.

print(p) <symbol> [[offset:][length]]

Prints the value of a specific symbol. The offset and length can be specified. If omitted, the length is set to the size of the symbol.

  • p P1: Prints the value of the symbol P1. The length is determined by the assigned size to P1.

  • p P1 2:8: Prints 8 bytes of the symbol P1 starting from the second byte.

print(p) <address> [length]

Prints the value for a specific address. If the length is not set, it defaults to 4 bytes. The address value can be either an integer or a hexadecimal value.

  • p 12453 4: Prints 4 bytes of the value at address 12453.

  • p 0x1f324 4: Prints 4 bytes of the value at address 0x1f324.

print(p) <d(x,b)> [length]

Prints the value at the address determined by the specified register format. If the length is not set, it defaults to 4 bytes.

  • p 10(4,12) 8: Prints 8 bytes of the value at address 10 (4,12).

  • p 10(4,12): Prints the value at address 10 (4,12) for the default length of 4 bytes.

set listsize <value>

Sets the number of code lines displayed in console mode. This command is valid only in console mode.

  • set listsize 30: Restricts the number of code lines displayed in console mode to 30.

tui

Switches from console mode to TUI (Text User Interface) mode.

1.2. TUI (Text user interface) Mode

Switches to the user interface screen provided by ofadbg. This mode is activated by entering 'tui' at the console command prompt.

  • SOURCE CODE: Prints the code being traced and displays the running ASM programs sequentially.

  • REGISTER INFO: Prints the current values of registers R0 through R15, as well as the Condition code (CC) and Program counter (PC) values.

  • SYMBOL LIST: Prints the values of symbols registered in the value-tracking list.

  • MEMORY LIST: Prints the values of addresses registered in the value-tracking list.

  • CONSOLE: Displays the status and messages of the debug tool and provides a command input window.

ofadbg tui
ofadbg TUI Mode