Netra Data Plane Software Suite 1.1 User's Guide
|
  
|
This chapter summarizes using the debugger. Topics include:
CMT Debugger Overview
The CMT Debugger runs on the target and enables users to:
- Set, clear, and display breakpoints
- Set and display memory
- Display registers
- Display stack trace
- Manage thread focus
- Step to the next assembly instruction
The debugger is not symbolic. Symbol resolution is performed separately using a host-based tool called dbg_helper.pl. See Resolving Symbols.
All the debugger commands use gdb style syntax.
Debugging Configuration Code
As seen in tejacc Compiler Configuration, tejacc gets information about hardware architecture, software architecture, and mapping by executing the configuration code compiled into dynamic libraries.
The code is written in C and might contain errors causing tejacc to crash. Upon crashing, you are presented with a Java
Hotspot exception, as tejacc is internally implemented in Java. The information reported in the exception requires knowledgeable interpretation.
An alternative version of tejacc.sh called tejacc_dbg.sh is provided to assist debugging configuration code. This program runs tejacc inside the default host debugger (dbx for Solaris hosts), stopping the execution immediately after the configuration libraries have been loaded. You then can continue execution to reach the instruction that causes the problem and verify its location. Alternatively, you can set breakpoints on the configuration functions, step through code, or use any other functionality provided by the host debugger.
To use tejacc_dbg.sh, replace the invocation of tejacc.sh in the makefile with tejacc_dbg.sh.
Entering the Debugger
The application program calls the debugger when any of the following conditions occur:
- At start time - If the application was compiled without the -O option, the application calls the debugger at start time. Applications compiled with the -O option start normally.
- At a breakpoint - If the application was compiled without the -O option and while running encounters a breakpoint, the application calls the debugger. Applications compiled with the -O option cannot set breakpoints.
- In a crash - If the application crashes, it calls the debugger. The debugger is called regardless of whether the application was compiled with or without the -O option.
- Typing Ctrl-C - If the application calls the teja_debugger_check_ctrl_c() function and you type the Ctrl-C key sequence, the debugger is also called. The debugger is called regardless of whether the application was compiled with or without the -O option.
Note - A call to the debugger stops all threads.
|
Note - The teja_check_ctrl_c() function must be executed periodically by at least one of the threads in order for Ctrl-C functionality to work. If the thread calling the teja_check_ctrl_c() function crashes or goes into a deadlock, the Ctrl-C key sequence stops working.
|
Debugger CommandsDisplaying Help
help command or
h command
Description
Displays help for a command. If the command variable is absent, a general help page is displayed.
Example
dbg>help
break <address> - set breakpoint
not available for all instructions (see docs)
b <address> - set breakpoint
not available for all instructions (see docs)
bt n - display stack trace
delete breakpoint <bpid> - clear breakpoint
d breakpoint <bpid> - clear breakpoint
info - display info help
i - display info help
help [cmd] - display help
h [cmd] - display help
? [cmd] - display help
cont - resume execution
c - resume execution
step - step to next Assembly instruction
not available for all instructions (see docs)
s - step to next Assembly instruction
not available for all instructions (see docs)
x/nfu <address> - display memory:
n (count)
u = {b|h|w|g} (unit)
f = {x|d|u|o|t|a|f|s|i} (format)
thread <thdid> - switch thread focus
w/u addr value - set memory
u = {b|h|w|g} (unit)
|
Managing Breakpoints
Setting breakpoints is only supported in non-optimized mode and means the application must be built without the -O option to tejacc.
break address Command or
b address Command
Description
Sets a breakpoint, where address is the hexadecimal address at which to break. The breakpoint is set only in regions of code that are characterized by sequential execution and not affected by control flow changes. The easiest way to set a proper breakpoint is to use the dbg_helper script. See Resolving Symbols.
Example
dbg>break 50b188
Breakpoint set at 0x50b188
|
info break Command or
i break Command
Description
Displays a list of active breakpoints.
Example
dbg>info break
breakpoint [1] set at 0x50b188
|
In this example, only one breakpoint exists. It has an ID of 1. When more than one breakpoint is set, each breakpoint receives a consecutive ID.
delete breakpoint ID Command or
d breakpoint ID Command
Description
Deletes a breakpoint, where ID is the ID of the breakpoint.
Example:
dbg>delete breakpoint [1]
|
Managing Program Execution
cont Command or
c Command
Description
Continues execution of the application.
Example
step Command or
s Command
Description
Steps to the next assembly instruction within the application.
Example
Note - The step command can only be used in regions of code that are characterized by sequential execution and not affected by control flow changes.
|
Displaying and Setting Memory
x/nfu address Command
Description
Displays memory contents where:
- n - Number of memory units to display.
- f - The display format. The only supported value is x, for hexadecimal format.
- u - The size of the unit. Supported values are:
- b - byte
- h - 2-byte half-word
- w - 4-byte word
- g - 8-byte long word
- address - The starting address in hexadecimal.
Example:
dbg>x/8xw 10000000
count = 8; format = HEX; unitsize = 4
[10000000] : 00000100 000000cd 00000001 00000114 00000100 000000ce 00000001 00518a44
|
w/u address value Command
Description
Sets memory where:
- u - The size of the unit. Supported values are:
- b - byte
- h - 2-byte half-word
- w - 4-byte word
- g - 8-byte long word
- address - The starting address in hexadecimal.
- value - The value to write in hexadecimal.
Example
dbg>w/w 10000000 00518a44
|
Managing Threads
info threads Command or
i threads Command
Description
Displays a list of the active threads. The thread that has the focus is shown with an F symbol. Similarly, if a thread has crashed, it is shown with an F symbol.
Example
dbg>info threads
: generatorthread: Teja thread id 0, strand id 0
F : classifierthread: Teja thread id 1, strand id 1
|
thread ID Command
Description
Changes the thread focus to the thread with the Teja thread ID of ID.
Example
dbg>thread 0
Thread focus changed to 0
|
In the previous example, the focus (F) was on classifierthread, with Teja ID of 1. In this example, the focus has been moved to generatorthread.
Displaying Registers
info reg Command or
i reg Command
Description
Displays the register contents for the thread in focus.
Example
dbg>info reg
Registers of strand 0:
G registers:
g[0] : 0000000000000000 0000000000000000 0000000000500000 0000000000000000
g[4] : 0000000000000000 0000000000615fa0 0000000000000000 0000000000000000
I registers:
i[0] : 000000000000006e ffffffffef1fe8d4 0000000000520c30 0000000010e01bc8
i[4] : 0000000000000000 0000000000000000 0000000010e00d91 000000000051458c
O registers:
o[0] : 000000000000006e 0000000000520c30 0000000010e01bc8 0000000000000000
o[4] : 0000000000600000 0000000000000061 0000000010e00cd1 0000000000514a18
L registers:
l[0] : 000000000000006e 0000000010e0172c 000000000051e8f0 ffffffffef1fe8d4
l[4] : 0000000000520c30 0000000000000000 0000000000000000 0000000000000000
gl : 0000000000000001
tl : 0000000000000001
tt : 000000000000007c
tpc : 0000000000508c88
tnpc : 0000000000508c8c
tstate : 0000009914001600
pstate : 0000000000000014
tick : 000001884f873558
tba : 0000000000500000
asi : 0000000000000014
|
Displaying Stack Trace
bt frame_count Command
Description
Displays the stack trace for the thread in focus for frame_count number of frames.
Example
dbg>bt 4
frame 1, sp 0x10e03580, call instruction at 0x50e888:
l[0] : 0000000000000001 00000000111606a8 0000000011160600 0000000000000000
l[4] : 00000000006170d8 0000000000001000 0000000000010000 0000000000000150
i[0] : 0000000000000800 0000000010e036f0 0000000010e036e8 0000000010e036e4
i[4] : 0000000000002000 0000000019ae8ec8 0000000010e02e31 000000000050e888
frame 2, sp 0x10e03630, call instruction at 0x50fcc4:
l[0] : 0000000000000001 00000000111606a8 0000000011160600 0000000000000000
l[4] : 00000000006170d8 0000000000001000 0000000000010000 0000000000000150
i[0] : 0000000000000800 0000000000000001 0000000019d8c148 0000000000000800
i[4] : 0000000019d8c140 0000000019d8c000 0000000010e02f01 000000000050fcc4
frame 3, sp 0x10e03700, call instruction at 0x50fbd8:
l[0] : 0000000000000001 00000000111606a8 0000000011160600 0000000000000000
l[4] : 00000000006170d8 0000000000001000 0000000000010000 0000000000000150
i[0] : 00000000111000e0 0000000000000015 0000000000010000 0000000011160580
i[4] : 0000000000002000 0000000019ae8ec8 0000000010e02fd1 000000000050fbd8
frame 4, sp 0x10e037d0, call instruction at 0x50e104:
l[0] : ffffffffffffffd8 ffffffffffffffba 0000000000000003 0000000000000000
l[4] : 00000000006170d8 0000000000617000 0000000000000617 0000000000000400
i[0] : 00000000111000e0 000000000000792d 000000000000792d 0000000011100180
i[4] : 000000000000792d 0000000000000000 0000000010e03081 000000000050e104
|
Resolving Symbols
The dbg_helper.pl script is used to resolve symbols to set breakpoints in the correct places. The script is located in the Teja installation, under the /bin directory.
-h Option
Description
Displays help information.
-f function_name Option
Description
Prints a debugger command to set a breakpoint at the given function_name. This option does not work for static functions. To set a breakpoint inside of a static function, use the -l file_name:line_number option.
Example
$ dbghelper.pl -f classifier ./main
b 50b17c
|
-g global_variable Option
Description
Prints a debugger command to display the contents of the given global_variable. The size of the memory displayed is fixed and does not consider the actual size of the global_variable. You might need to increase the size of the memory.
Example
$ dbghelper.pl -g stats ./main
x/1wx 13000640
|
-l file_name:line_number Option
Description
Prints a debugger command to set a breakpoint at the provided file_name:line_number. The file_name and line_number refer to your source code.
Example
$ dbghelper.pl -l src/classifier.c:57 ./main
b 50b188
|
Netra Data Plane Software Suite 1.1 User's Guide
|
820-2374-10
|
  
|
Copyright © 2007, Sun Microsystems, Inc. All Rights Reserved.