gdb vs. dbx: commands mapping and feature comparison

GDB and DBX usage reference. very useful when debug program on Linux and AIX

Gdb vs. dbx feature comparison


gdbdbx

Invocation

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 foundautomatically)

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

Exiting

quit
Ctrl-d
exit

Executing shell commands

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

Logging

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 theiroutput)
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 TabNo auto-completion
Command repeat with RetCommand repeat with '!' and UpArrow Ret

Built-in help

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

Debugging information support

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

Starting a program

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

Program environment

set args argsrunargs args
show argsdebug
path dirPATH=dir:$PATH
show pathsecho $PATH
set environment varname [=value ]varname=value
unset environment varnameunset varname
cd directorycd directory
pwdpwd
-any other ksh command (with certainlimitations; see “help ksh differences”)

Attaching

attach pidattach pid
debug program pid
debug - pid
detachdetach
-detach -stop

Killing the child process

killkill (builtin)
/usr/bin/kill

Debugging Multithreaded Applications

info threadsthreads
thread threadnothread threadid
-thread -info [threadid]
-thread -blocks [threadid]thread -blockedby [threadid]
-syncs
(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 tospecified value)
-OpenMP support.

Debugging Programs with Multiple Processes

set follow-fork-mode parentdbxenv follow_fork_mode parent
set follow-fork-mode childdbxenv 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

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

Breakpoints

break functionstop in function
break +offset
break -offset
stop at $[$lineno+offset]
stop at $[$linenooffset]
Note: you can define helper function in .dbxrc thatwill save you from typing all that stuff.
break [filename:]linenumstop at [filename:]linenum
break filename:function-
break \*addressstopi at address
stop at address -instr
break
(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 argsstop ... -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 stopstop stop
-stop attachstop 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]
finish
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 modestop access mode addr-expr [ , byte-size-expr
rwatch <expr>
awatch <expr>
Note: need to re-enable manually, doen't work on Solaris andLinux.
-
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 countstop ... -count count
handler -count count bnum
break linespec thread threadnostop ... -thread tid
-stop ... -lwp lwpid
hbreak args
thbreak args
-
rbreak regex-
Note: need to use funcs command and manually set breakpointswith “stop in”
info breakpoints [n]
info watchpoints [n]
status [n]
clear
clear linenum
clear filename:linenum
clear
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 -loadlib” and set breakpoints after that or run yourprogram once without any breakpoints so that dbx become aware ofall 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 ...
end
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 ]
cont
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 currentor specified location).
-
advance locationcont at line

Signals

info signalsinfo handlecatch, ignore
handle signal stopcatch signal
handle signal nostopignore signal
handle signal printwhen 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 afterstopping 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 ]
unhide
(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 limitdbxenv 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]
framewhere 1
info frame-
info localsdump
info catchwhocatches type

Examining Source Files

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

(view or set current file)
edit
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 regexpbsearch [string]

Specifying Source Directories

directory dirname ...
dir dirname ...
directory
use [dirname]
Note: “use” is deprecated and replaced withpathmap.
set substitute-path from topathmap 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 exprprint -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 ownrendition of anexpressions value through a function call, see “helpprettyprint”).
x/nfu addrx addr [/nf]
examine addr [/nf]

Note: unit size is governed by format, 'f'
display[/fmt] exprdisplay [-f fmt] expr
undisplay dnums ...
delete display dnums ...
undisplay dnums ...
disable display dnums ...
enable display dnums ...
-
displaydisplay
-watch
(same as display, but expression is re-parsed at each stoppingpoint)
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/offprint -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 convenienceset
init-if-undefined $variable = expression-
info registersregs
info all-registersregs -f | -F
info registers regname ...print $regname
info float
(floating point registers only)
-
info vector-
info udot-
info auxv-
cache
nocache
(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 addrwhereis -a addr
Note: with 'check -memuse', showsallocation stack for heap-allocated memory region.
whatis argwhatis [-e] arg
ptype argwhatis [-e] arg
info types [regexp]whatis -t [typename]
info scope location-
info sourcemodule -v
file
Note: dwarf info is not displayed correctly for object files.
info sourcesmodules -v
files
info functions regexpfuncs regexp
info variables
(All global and static variable names, or those matching REGEXP)
-

Altering execution

set var=valueassign var=value
assign $reg=valueassign $reg=value
jump linespeccont at linespec
jump \*addressassign $pc=address; cont
signal signalcont -sig signal
returnpop
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 directorydbxenv debug_file_directory directory
show debug-file-directorydbxenv debug_file_directory

Miscellaneous

set prompt newpromptPS1=newprompt
PS2=secondprompt
There's similar table in built-in dbxhelp. Use “help FAQ” and navigate to seciton A.1.
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
资源包主要包含以下内容: ASP项目源码:每个资源包中都包含完整的ASP项目源码,这些源码采用了经典的ASP技术开发,结构清晰、注释详细,帮助用户轻松理解整个项目的逻辑和实现方式。通过这些源码,用户可以学习到ASP的基本语法、服务器端脚本编写方法、数据库操作、用户权限管理等关键技术。 数据库设计文件:为了方便用户更好地理解系统的后台逻辑,每个项目中都附带了完整的数据库设计文件。这些文件通常包括数据库结构图、数据表设计文档,以及示例数据SQL脚本。用户可以通过这些文件快速搭建项目所需的数据库环境,并了解各个数据表之间的关系和作用。 详细的开发文档:每个资源包都附有详细的开发文档,文档内容包括项目背景介绍、功能模块说明、系统流程图、用户界面设计以及关键代码解析等。这些文档为用户提供了深入的学习材料,使得即便是从零开始的开发者也能逐步掌握项目开发的全过程。 项目演示与使用指南:为帮助用户更好地理解和使用这些ASP项目,每个资源包中都包含项目的演示文件和使用指南。演示文件通常以视频或图文形式展示项目的主要功能和操作流程,使用指南则详细说明了如何配置开发环境、部署项目以及常见问题的解决方法。 毕业设计参考:对于正在准备毕业设计的学生来说,这些资源包是绝佳的参考材料。每个项目不仅功能完善、结构清晰,还符合常见的毕业设计要求和标准。通过这些项目,学生可以学习到如何从零开始构建一个完整的Web系统,并积累丰富的项目经验。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值