看某個位址的值是否被改變
ex: int test = 0; // global變數, 假設位址是0x66333
disp *(uint64 *)0x66333 // 程式每執行一行就會印出結果
watch *(uint64 *)0x66333 // 變數改變時會印出來
segmentation fault debug
先設定core file size成unlimited: ulimit -c unlimited
./application //發生segmentation fault時會產生core file
gdb ./application core.xxx
可能會用到的指令: down, p *this, list
r arg1 arg2 arg3 ( = ./a.out arg1 arg2 arg3)
where
l
p /x [parameter] 印出該參數的memory address
x/x [memory address]
x/100x [memory address] 印出target memory address之後100bye的memory address
gdb ras (parent process)
gdb ras processID (attach child process)
b breakpoint
b [functionName]
b [lineNumber] (lineNumber is the line of fork)
b [fileName]:[line]
ex: b test.cc:5
n next (it will skip funciton)
s stepinto (it will go into function)
c contiinue
w where (print the current stack)
p print
list [filename] (list the content of the file)
list [lineNumber]
list (list current file content)
help [command] (ex. help list)
p [parameter] (print parameter)
watch [parameter] (when the parameter changed, it will show)
detach
attach
r run
backtrace
bt: 列出每個frame的function name
frame [number]: 回到該frame的function
留言列表