Table 13.13. GDB-to-MDB Migration
GDB | MDB | Description |
---|
Starting Up | | |
gdb program | mdb path mdb -p pid | Start debugging a command or running process. GDB will treat numeric arguments as pids, while MDB explicitly requires the -p option. |
gdb program core | mdb [ program ] core | Debug a corefile associated with program. For MDB, the program is optional and is generally unnecessary given the corefile enhancements made during Solaris 10. |
Exiting | | |
| | |
quit | ::quit | Both programs also exit on Ctrl-D. |
Getting Help | | |
help | | |
help command | ::help ::help dcmd ::dcmds ::walkers | List all the available walkers or dcmds, as well as get help on a specific dcmd (MDB). Another useful trick is ::dmods -l module, which lists walkers and dcmds provided by a specific module. |
Running Programs | | |
run arglist | ::run arglist | Run the program with the given arguments. If the target is currently running or is a corefile, MDB will restart the program if possible. |
kill | ::kill | Forcibly kill and release target. |
show env | ::getenv | Display current environment. |
set env var string | ::setenv var=string | Set an environment variable. |
get env var | ::getenv var | Get a specific environment variable. |
Shell Commands | | |
shell cmd | ! cmd | Execute the given shell command. |
Breakpoints and Watchpoints | | |
break func | | |
break *addr | addr::bp | Set a breakpoint at the given address or function. |
break file:line | | Break at the given line of the file. MDB does not support source-level debugging. |
break ... if expr | | Set a conditional breakpoint. MDB doesn't support conditional breakpoints, though you can get a close approximation with the -c option (though its complicated enough to warrant its own post). |
watch expr | addr::wp -rwx [-L size] | Set a watchpoint on the given region of memory. |
info break | | |
info watch | ::events | Display active watchpoints and breakpoints. MDB shows you signal events as well. |
delete [n] | ::delete n | Delete the given breakpoint or watchpoints. |
Program Stack | | |
backtrace n | ::stack $C | Display stack backtrace for the current thread. |
| thread:: findstack -v | Display a stack for a given thread. In the kernel, thread is the address of ktHRead_t. In userland, it's the thread identifier. |
info ... | | Display information about the current frame. MDB doesn't support the debugging data necessary to maintain the frame abstraction. |
Execution Control | | |
continue | | |
c | :c | Continue target. |
stepi | | |
si | ::step ] | Step to the next machine instruction. MDB does not support stepping by source lines. |
nexti ni | ::step over [ | Step over the next machine instruction, skipping any function calls. |
finish | ::step out | Continue until returning from the current frame. |
jump *address | address>reg | Jump to the given location. In MDB, reg depends on your platform. For SPARC it's pc, for i386 its eip, and for amd64 it's rip. |
Display | | |
print expr | addr::print expr | Print the given expression. In GDB you can specify variable names as well as addresses. For MDB, you give a particular address and then specify the type to display (which can include dereferencing of members, etc.). |
print /f | addr/f | Print data in a precise format. See ::formats for a list of MDB formats. |
disassem addr | addr::dis | Disassemble text at the given address or the current PC if no address is specified. |