gdb 常用内容
gdb exe
gdb exe core
gdb -p
info m TAB
^関数の先頭
info b
^list the breakpoint
set args -a test
^引数設定
show args
^引数表示
path directory
(‘:’ on Unix, ‘;’on MS-DOS and MS-Windows).
^パス設定
show path
show environment [varname]
set environment varname [=value]
unset environment varname
^環境変数 表示 設定 削除
info terminal
^端末の情報
r > outfile
^出力redirect
attach process-id
gdb -p と同じ
kill pid
info inferiors
^表示子process
inferios infno
^切り替えpid
add-inferior [ -copies n ] [ -exec executable ]
^追加process
clone-inferior [ -copies n ] [ infno ]
^copy目前process
remove-inferior infno
^削除情報
detach inferior infno
^cancel debug
kill inferior infno
^停止情報
set print inferior-events on|off <- 表示inferior情報
show print inferior-events
set detach-on-fork on|off <- forkのときdetach発生
show detach-on-fork
set follow-fork-mode parent|child <- on forkのとき親に追いつけ
show follow-fork-mode
set follow-exec-mode new same
set schedule-multiple on|off<- onのときスレッド同時実行
show schedule-multiple
detach
info threads
^list all threads
thread thread-id
thread apply [thread-id or all] command
^実行comand on thread
checkpoint
^set a check point to save the runtime info
info checkpoints
restart checkpoint-id
^restart the check point
delete checkpoint checkpoint-id
break ... if cond
disable breakpoint
enable breakpoint
save breakpoints
next
step
finish <-finish function
bt
debug macro
Now, we compile the program using the gnu C compiler, gcc. We pass the ‘-gdwarf-2’1
and ‘-g3’ flags to ensure the compiler includes information about preprocessor macros in
the debugging information.
$ gcc -gdwarf-2 -g3 sample.
info macro Add
macro expand Add(2)
no used
info signals
info handle
Print a table of all the kinds of signals and how gdb has been told to handle
each one. You can use this to see the signal numbers of all the defined types of
signals.
info signals sig
Similar, but print information only about the specified signal number.
info handle is an alias for info signals.
catch signal [signal... | ‘all’]
Set a catchpoint for the indicated signals. See Section 5.1.3 [Set Catchpoints],
page 54, for details about this command.
handle signal [keywords...]
Change the way gdb handles signal signal. The signal can be the number of a
signal or its name (with or without the ‘SIG’ at the beginning); a list of signal
numbers of the form ‘low-high’; or the word ‘all’, meaning all the known
signals. Optional arguments keywords, described below, say what change to
make.
The keywords allowed by the handle command can be abbreviated. Their full names
are:
nostop gdb should not stop your program when this signal happens. It may still print
a message telling you that the signal has come in.
stop gdb should stop your program when this signal happens. This implies the
print keyword as well.
print gdb should print a message when this signal happens.
noprint gdb should not mention the occurrence of the signal at all. This implies the
nostop keyword as well.
pass
noignore gdb should allow your program to see this signal; your program can handle the
signal, or else it may terminate if the signal is fatal and not handled. pass and
noignore are synonyms.
nopass
ignore gdb should not allow your program to see this signal. nopass and ignore are
synonyms.
When a signal stops y
91pdf