1. 程式人生 > >gdb在Ubuntu下單的terminal下的使用

gdb在Ubuntu下單的terminal下的使用

先sudo啟動gdb
attach the_pid_num_you_want_to_attach //attach到你要除錯的程序

info threads //檢視當前要除錯的程式含有哪些thread
help info //如果不知道info這個命令怎麼用。
help info threads //如果不知道info threads這個命令怎麼用。

c //讓程式繼續執行

thread the_num_of_one_threads //從1開始,選擇進入哪個thread

ctrl+c //在程式沒有斷點時,暫停程式的執行

你可以不離開gdb,直接執行shell命令,比如:

(gdb) shell ls

(gdb) !ls
這裡,"!"和命令之間不需要有空格(即,有也成)。