跳过导航链接 | |
退出打印视图 | |
Oracle Solaris Studio 12.3:使用 dbx 调试程序 Oracle Solaris Studio 12.3 Information Library (简体中文) |
inmember function inmethod function
inclass classname [-recurse | -norecurse]
inobject object-expression [-recurse | -norecurse]
access mode address-expression [, byte-size-expression ]
dlopen [ lib-path ] dlclose [ lib-path ]
以下是设置事件处理程序的一些示例。
要在 array[99] 设置数据更改断点,请键入:
(dbx) stop access w &array[99] (2) stop access w &array[99], 4 (dbx) run Running: watch.x2 watchpoint array[99] (0x2ca88[4]) at line 22 in file "watch.c" 22 array[i] = i;
(dbx) when step { echo at line $lineno; }
要在函数内时启用处理程序,请键入:
<dbx> trace step -in foo
它等效于:
# create handler in disabled state when step -disable { echo Stepped to $line; } t=$newhandlerid # remember handler id when in foo { # when entered foo enable the trace handler -enable "$t" # arrange so that upon returning from foo, # the trace is disabled. when returns { handler -disable "$t"; }; }
要了解在小程序中已执行了多少行,请键入:
(dbx) stop step -count infinity # step and stop when count=inf (2) stop step -count 0/infinity (dbx) run ... (dbx) status (2) stop step -count 133/infinity
程序永远不会停止,程序只会终止。执行的行数为 133。此进程速度非常慢。它对多次调用的函数中的断点用处最大。
要计算一行代码执行了多少个指令,请键入:
(dbx) ... # get to the line in question (dbx) stop step -instr -count infinity (dbx) step ... (dbx) status (3) stop step -count 48/infinity # 48 instructions were executed
如果步过的行进行函数调用,则该函数中的行也计入在内。可以使用 next 事件而非 step 计算指令数(不包括被调用函数)。
只在另一事件发生后启用断点。例如,如果程序的执行在函数 hash 中开始不正常,但只是发生在第 1300 次符号查找后,可键入:
(dbx) when in lookup -count 1300 { stop in hash hash_bpt=$newhandlerid when proc_gone -temp { delete $hash_bpt; } }
注 - $newhandlerid 是指刚执行的 stop in 命令。
如果应用程序处理需要在 replay 期间重置的文件,可以编写一个处理程序,在每次运行程序时执行该操作:
(dbx) when sync { sh regen ./database; } (dbx) run < ./database... # during which database gets clobbered (dbx) save ... # implies a RUN, which implies the SYNC event which (dbx) restore # causes regen to run
要快速查看程序运行时的位置,请键入:
(dbx) ignore sigint (dbx) when sig sigint { where; cancel; }
然后键入 ^C 在不停止程序的情况下查看程序的堆栈跟踪。
这基本上是收集器人工示例模式的任务(还有更多)。可使用 SIGQUIT (^\) 在 ^C 已用尽的情况下中断程序。
(dbx) ignore FPE # turn off default handler (dbx) help signals | grep FPE # can’t remember the subcode name ... (dbx) stop sig fpe FPE_FLTUND ...