gdb vs. dbx: commands mapping and feature comparison

Gdb vs. dbx feature comparison



gdb program
gdb program core
gdb program pid
dbx progam
dbx program core
dbx program pid
gdb -c core
gdb -p pid
Note: need to specify program explicitly
dbx - core
dbx - pid
(program is found automatically)

Note: dbx cannot debug core files and live processes without access to program file, i.e. a.out
gdb -s file
(read symbols from file)
gdb -x file
dbx ... < file
dbx -s file ...
-tty device
(Run using device for your program’s standard input and output)
dbxenv run_io pty
dbxenv run_pty device
(open executable and core file for writing)



Executing shell commands

shell command ksh command
/bin/sh command
Note: you can use any ksh command, including function definition. See “help ksh differences” for limitations.


set logging
show logging
dbxenv session_log_file_name file
dbxenv session_log_file_name
dbxenv output_log_file_name file
dbxenv output_log_file_name

(logs only commands, not their output)
set logging redirect [on|off] -
Note: equivalent to off
set logging overwrite [on|off] -
Note: equivalent to on

Commands (general)

Abbreviation - automatic (can use 's' instead of 'step') Need to use ksh 'alias' command to define aliases
Auto-completion with Tab No auto-completion
Command repeat with Ret Command repeat with '!' and UpArrow Ret

Built-in help

help [command] help [command]
apropos keyword help -k keyword

Debugging information support

stabs (GNU), dwarf2, -g -O stabs (SUN), dwarf2, -g -O
Macro support (-g3) Macro support (-g3); Sun Studio compilers don't generate debug info for macros, though.
(status unknown) .ldynsym support (symbols in stripped loadobject)

Starting a program

run [arguments][ < input_file] [ > output_file run [arguments][ < input_file] [ > output_file]
(run and stop in “main”)
Note: only available in GUI mode when used from Sun Studio IDE

Program environment

set args args runargs args
show args debug
path dir PATH=dir:$PATH
show paths echo $PATH
set environment varname [=value ] varname=value
unset environment varname unset varname
cd directory cd directory
pwd pwd
- any other ksh command (with certain limitations; see “help ksh differences”)


attach pid attach pid
debug program pid
debug - pid
detach detach
detach -stop

Killing the child process

kill kill (builtin)

Debugging Multithreaded Applications

info threads threads
thread threadno thread threadid
thread -info [threadid]
thread -blocks [threadid] thread -blockedby [threadid]
(list all synchronization objects).
Note: available on Solaris only.
sync -info addr
(show information about the synchronization object).
Note: available on Solaris only.
thread apply [threadno] [all] command -
- lwps
- lwp lwpid
- lwp [lwpid] -info
(displays the name, home, and masked signals)
- lwp [lwpid] -setfp addr
lwp [lwpid] -resetfp
(temporarily set frame pointer to specified value)
- OpenMP support.

Debugging Programs with Multiple Processes

set follow-fork-mode parent dbxenv follow_fork_mode parent
set follow-fork-mode child dbxenv follow_fork_mode child
dbxenv follow_fork_mode ask
set detach-on-fork on/off -
Note: always detaches; it is possible to debug both processes, but only using Sun Studio IDE
info forks
fork fork-id
detach fork fork-id
delete fork fork-id

Process snapshots

info checkpoints
restart checkpoint-id
delete checkpoint checkpoint-id
Note: dbx has different mechanism for that; see “help save/restore/replace” commands for more information.


break function stop in function
break +offset
break -offset
stop at $[$lineno+offset]
stop at $[$linenooffset]
Note: you can define helper function in .dbxrc that will save you from typing all that stuff.
break [filename:]linenum stop at [filename:]linenum
break filename:function -
break \*address stopi at address
stop at address -instr
(stop on next instruction in current stack frame)
Note: Can use “stopi at $npc”, but on sparc only
break ... if cond
condition bnum expression
stop ... -if cond
condition bnum
(removes condition)
tbreak args stop ... -temp
- stop inmethod func
stop inmember func
stop infunction func
stop inclass classname [ -recurse | -norecurse ]
inobject object_address [ -recurse | -norecurse ]
step; cont
next; cont
stop step
stop next
catch signal [signame ] stop sig signal [code]
- stop fault <fault>
catch throw [ exceptname]
Note: not very useful since stop after exception is thrown; doesn't work in code called from gdb
intercept [-all] [-x] [-set] [typename]
stop throw [-unhandled] [-unexpected] [typename]
catch catch [exceptname] -
Note: use “whocatches” command
catch stop stop stop
- stop attach stop detach
- stop sync
- stop syncrtld
- stop lastrites (Solaris only)
catch load [ lib-path ]
catch unload [ lib-path ]
Note: unavailable on Linux and Solaris
stop dlopen [ lib-path ]
stop dlclose [ lib-path ]
- stop exit [ exitcode ]
catch fork
catch vfork
catch exec
Note: no other system calls are supported
stop sysin [sysin code|name]
stop sysout [sysin code|name]
Note: can't specify function to catch return from
stop returns [func]
Note: has bug(s), still unresolved.
- stop lwp_exit (Solaris only)
catch exit
catch start
Note: not implemented on Linux and Solaris
stop proc_gone
stop prog_new
tcatch ... stop ... -temp
- stop timer seconds
watch variable
Note: need to re-enable manually
stop change variable
watch expr
Note: need to re-enable manually
stop if expr
stop cond expr
mem addr-expr addr-expr mode stop access mode addr-expr [ , byte-size-expr
rwatch <expr>
awatch <expr>
Note: need to re-enable manually, doen't work on Solaris and Linux.
catch thread_start
catch thread_exit
stop thr_exit [-thread tid]
stop thr_create [ tid ]
catch thread_join -
- stop ... -resumeone
(when evaluating stop condition, resume only one thread).
- stop ... -in func
ignore bnum count stop ... -count count
handler -count count bnum
break linespec thread threadno stop ... -thread tid
- stop ... -lwp lwpid
hbreak args
thbreak args
rbreak regex -
Note: need to use funcs command and manually set breakpoints with “stop in”
info breakpoints [n]
info watchpoints [n]
status [n]
clear linenum
clear filename:linenum
clear linenum
clear filename:linenum
clear function
clear filename:function
delete [breakpoints] [range ...] delete [breakpoints]
delete all
Pending breakpoints -
Note: you can load shared library with “loadobject -load lib” and set breakpoints after that or run your program once without any breakpoints so that dbx become aware of all libraries.
set breakpoint auto-hw on/off -
disable [breakpoints] [range ...] handler -disable [breakpoints]
enable [breakpoints] [range ...] handler -enable [breakpoints]
enable [breakpoints] once range ...
enable [breakpoints] delete range ...
commands [bnum ]
... command-list ...
when ... { cmd; }
wheni ... { cmd; }
- trace next
trace at lineno
trace in func
trace modify addr-expr [ , byte-size-expr ]
trace ...

Continuing and Stepping

continue [ignore-count ]
fg [ignore-count ]
step [count] step [count] [tid | lwpid]
next [count] next [count] [tid | lwpid]
set step-mode on
stepi [count]
stepi [count] [tid | lwpid]
nexti [count] nexti [count] [tid | lwpid]
- step to [func]
- step ... -sig signal
until [location]
(Execute until the program reaches a source line greater than the current or specified location).
advance location cont at line


info signals info handle catch, ignore
handle signal stop catch signal
handle signal nostop ignore signal
handle signal print when sig signal { print $signal; print $sigstr; }
trace sig signal
handle signal noprint -
Note: no information is printed about ignored signals
handle signal pass
handle signal noignore
ignore signal
handle signal nopass
handle signal ignore
Note: use cont with no -sig to cancel current signal after stopping because of it

Examining the Stack

backtrace [n]
bt [n]
where [n]
backtrace [-n]
bt [-n]
backtrace full [n] -
set backtrace past-main on/off -
set backtrace past-entry on/off -
hide [ regular_expression ]
unhide [ number | regular_expression ]
(hide stack frames in “where” command output)
set backtrace limit n
set backtrace limit 0
(default is unlimited)
dbxenv stack_max_size n

Note: default is 100; no “unlimited” option
show backtrace limit dbxenv stack_max_size
echo $DBX_stack_max_size
frame [args] frame [n]
Note: can't use address to identify stack frame
select-frame [args] > /dev/null frame [n]
up [n]
down [n]
up [n]
down [n]
up-silently [n]
down-silently [n]
> /dev/null up [n]
> /dev/null down [n]
frame where 1
info frame -
info locals dump
info catch whocatches type

Examining Source Files

list linenum list -w linenum
list function list function
list -a function
(lists entire function)
list list
list - list -10
set listsize count
show listsize
dbxenv output_list_size count
dbxenv output_list_size
list first,last list first,last
list ,last list last, - [n]
list first, list first,+[n]
list + list [+N]
list - list - [N]
list \*address -
- file [filename]

(view or set current file)
edit number
edit function
edit filename:number
edit filename:function
edit \*address
$EDITOR filename

Note: need to find source file manually with 'whereis [-a]' command.
forward-search regexp
search regexp
search [string]
reverse-search regexp bsearch [string]

Specifying Source Directories

directory dirname ...
dir dirname ...
use [dirname]
Note: “use” is deprecated and replaced with pathmap.
set substitute-path from to pathmap from to
unset substitute-path [path] pathmap -d [path]
show substitute-path [path] pathmap

Source and Machine Code

info line linespec -
Note: need to look at “list -i linespec” output
disassemble [addr] dis [addr]
- dis -a [addr]
(disassemble entire function)
- list -i [linespec]
(intermix source lines and assembly code)

Examining Data

print /f expr print -f expr
print /f -
- > FILE print ...
(print to a file)
Artifcial arrays (p \*array@len) -
- Array slicing (p array[2..5])
- Pretty-printing (allows an application to provide it's own rendition of an expressions value through a function call, see “help prettyprint”).
x/nfu addr x addr [/nf]
examine addr [/nf]

Note: unit size is governed by format, 'f'
display[/fmt] expr display [-f fmt] expr
undisplay dnums ...
delete display dnums ...
undisplay dnums ...
disable display dnums ...
enable display dnums ...
display display
- watch
(same as display, but expression is re-parsed at each stopping point)
set print address on/off -
set print symbol-filename on/off -
set print max-symbolic-offset max-offset -
set print array on/off -
(equivalent to off)
set print array-indexes on/off -
(equivalent to off)
set print elements number-of-elements -
set print repeats -
set print null-stop -
set print pretty on/off -
Note: equivalent to “on”
set print sevenbit-strings on/off -
set print union on/off -
set print demangle on/off
set print asm-demangle on/off
Note: usually both forms are displayed
set print object on/off print -d ...
Note: equivalent to “on”
set print static-members on/off -
set print vtbl on/off -
(previously printed expression)
show values
(values history)
Convenience variables
Example: set $foo = \*object_ptr
Note: these variables are typed.
Environment variables
Example: foo=$[\*object_ptr]
Note: type of expression is not recorded in the variable.
show convenience set
init-if-undefined $variable = expression -
info registers regs
info all-registers regs -f | -F
info registers regname ... print $regname
info float
(floating point registers only)
info vector -
info udot -
info auxv -
(cache target memory)

Memory access checking

set mem inaccessible-by-default [on|off] -
- check -access
- check -memuse
- check -leaks

C Preprocessor Macros

macro expand expression
macro exp expression
macro expand-once expression -
info macro macro -
macro define macro [(arglist)] replacement-list
macro undef macro
macro list -

Examining the Symbol Table

info address symbol -
Note: “print &symbol” should suffice.
info symbol addr whereis -a addr
Note: with 'check -memuse', shows allocation stack for heap-allocated memory region.
whatis arg whatis [-e] arg
ptype arg whatis [-e] arg
info types [regexp] whatis -t [typename]
info scope location -
info source module -v
Note: dwarf info is not displayed correctly for object files.
info sources modules -v
info functions regexp funcs regexp
info variables
(All global and static variable names, or those matching REGEXP)

Altering execution

set var=value assign var=value
assign $reg=value assign $reg=value
jump linespec cont at linespec
jump \*address assign $pc=address; cont
signal signal cont -sig signal
return pop
return expression -
print expr
call expr
Note: abnormal termination affects debuggee
print expr
call expr
Note: abnormal termination doesn't affect debuggee; use “pop -c” to “cancel” call.
set unwindonsignal -
Note: equivalent to off
set write on/off
(open executable or core for writing)
Note: equivalent to off
- fix

Debugging Information in Separate Files

set debug-file-directory directory dbxenv debug_file_directory directory
show debug-file-directory dbxenv debug_file_directory


set prompt newprompt PS1=newprompt

There's similar table in built-in dbx help. Use “help FAQ” and navigate to seciton A.1.


А не было бы проще убить dbx синтакс и заменить его полностью gdb синтаксом?

Если бы еще это щасце поддерживало редактирование коммандной строки - то им бы еще и можно было бы пользоваться для реальных задач.

А если бы еще и SunStutio была бы на нормальном нетормозном языке программирования написана - то Словарис бы в плотную приблизился по отладке к почти совершенному Линуху. А так... в текущем ее состоянии dbx есть красивая бесполезная игрушка для мазохистов.

опубликовал Игорь Филиппов Декабрь 07, 2007 at 08:56 AM MSK #

> А не было бы проще убить dbx синтакс и заменить его полностью gdb синтаксом?

Смотря для кого. У dbx есть режим поддержки команд gdb (не полный, разумеется; включается "gdb on"), а есть ли аналогичный режим у gdb?

> Если бы еще это щасце поддерживало редактирование коммандной строки - то им бы еще и можно было бы пользоваться для реальных задач.

Вот это правда, редактирование командной строки - больная тема.

> ... Словарис бы в плотную приблизился по отладке к почти совершенному Линуху

О, Солярис-то далеко впереди по возможностям отладки - см. тот же dtrace, rtld_db, thread_db и проч. Дело, однако, не в ОС, а в отладчике.

Gdb на Солярисе тоже есть, однако пользоваться им для отладки чего-то близко стоящего к ОС (например, dbx или чего-нибудь многопоточного) неудобно. Все-таки надо признать, что базовая система для gdb - это Linux, а для dbx - Solaris и хоть они и работают на других, но в той или иной степени хуже.

опубликовал Максим Карташев Декабрь 07, 2007 at 09:10 AM MSK #

>> Если бы еще это щасце поддерживало редактирование коммандной строки - то им бы еще и можно было бы пользоваться для реальных задач.
> Вот это правда, редактирование командной строки - больная тема.

Вообще гворя редактирование командной строки есть.
Просто по умолчанию там режим vi. Просто нажми ESC.

опубликовал Александр Горшенев Август 28, 2009 at 04:00 PM MSD #

Опубликовать комментарий:
  • HTML Syntax: Отключен

Articles, news, notes on dbx, the Sun Studio debugger and other stuff.


« Октябрь 2015