bt subcommand
The bt subcommand traces each a specified address each time it is run.
Format
bt [-p | -v] [address [script]]
Parameters
Item | Description |
---|---|
-p | Indicates that the trace address is a physical or real address. |
-v | Indicates that the trace address is an effective or virtual address. |
address | Specifies the address of the trace point. Symbols, hexadecimal values, or hexadecimal expressions can be used to specify an address. |
script | Lists subcommands to be run each time the indicated trace point is run. The script is delimited by quote (") characters and commands within the script are delimited by semicolons (;). |
Each time a trace point is encountered, a message is displayed indicating that the trace point was encountered. The displayed message indicates the first entry from the stack. However, this can be changed by using the script parameter.
If the bt subcommand is invoked with no parameters, the current list of break and trace points is displayed. The number of combined active trace and break points is limited to 32.
It is possible to specify whether the trace address is a physical or a virtual address with the -p and -v options respectively. By default, the KDB kernel debugger chooses the current state of the machine. If the subcommand is entered before VMM initialization, the address is the physical or real address. If the subcommand is entered after VMM initialization, the address is the effective or virtual address.
The segment id (sid) is always used to identify a trace point because effective or virtual addresses can have multiple translations in several virtual spaces. When debugging is resumed after a trace point is encountered, kdb must reinstall the correct instruction. During this time (one step if no interrupt is encountered), it is possible to miss the trace on other processors.
The script parameter allows a set of kdb subcommands to run when a trace point is reached. The set of subcommands comprising the script must be delimited by double quote characters ("). Individual subcommands within the script must be ended by a semicolon (;). One of the most useful subcommands that can be used in a script is the test subcommand. If this subcommand is included in the script, each time the trace point is reached the condition of the test subcommand is checked by the KDB kernel debugger. If the condition is true, a break occurs.
Other
No aliases.
Examples
The following is an example of how to use the bt subcommand:
KDB(0)> bt open //enable trace on open()
KDB(0)> bt //display current active traces
0: .open+000000 (sid:00000000) trace {hit: 0}
KDB(0)> e //exit debugger
...
open+00000000 (2FF7FF2B, 00000000, DEADBEEF)
open+00000000 (2FF7FF2F, 00000000, DEADBEEF)
open+00000000 (2FF7FF33, 00000000, DEADBEEF)
open+00000000 (2FF7FF37, 00000000, DEADBEEF)
open+00000000 (2FF7FF3B, 00000000, DEADBEEF)
...
KDB(0)> bt //display current active traces
0: .open+000000 (sid:00000000) trace {hit: 5}
KDB(0)>
Open routine is traced with a script to display iar and lr registers
and to show what is pointed to by the first parameter (r3
).
KDB(0)> bt open "dr iar; dr lr; d @r3" //enable trace on open()
KDB(0)> bt //display current active traces
0: .open+000000 (sid:00000000) trace {hit: 0} {script: dr iar; dr lr;d @r3}
KDB(0)> e //exit debugger
iar : 001C5BA0
.open+000000 mflr r0 <.svc_flih+00011C>
lr : 00003B34
.svc_flih+00011C lwz toc,4108(0) toc=TOC,4108=g_toc
2FF7FF3F: 7362 696E 0074 6D70 0074 6F74 6F00 7500 sbin.tmp.toto.u.
KDB(0)> bt //display current active traces
0: .open+000000 (sid:00000000) trace {hit: 1} {script: dr iar; dr lr;d @r3}
KDB(0)> ct open //clear trace on open
KDB(0)>
This example shows how to trace and stop when a condition is true. For example, when global data is greater than the specified value, and 923 hits were necessary to reach this condition.
KDB(0)> bt sys_timer "[ @time >= 2b8c8c00 ] " //enable trace on sys_timer()
KDB(0)> e //exit debugger
...
Enter kdb [ @time >= 2b8c8c00 ]
KDB(0) bt //display current active traces
0: .sys_timer+000000 (sid:00000000) trace {hit: 923} {script: [ @time >= 2b8c8c00 ] }
KDB(0)> cat //clear all traces