我正在嘗試開發一個簡單的基於文本的用戶界面,該界面運行一些gdb命令。 我希望用戶能夠在代碼的某個區域設置和斷開/跟蹤點並運行一些調試命令。查看/打印GDB中的功能代碼
我想讓用戶輸入需要調試的功能。然後我使用該函數名稱並打印該函數的源代碼,然後要求用戶選擇哪一行代碼來設置中斷/跟蹤點。目前,使用反彙編命令我可以打印出用戶的內存地址,但我想打印實際的源代碼。
這可以在gdb中完成嗎?
目前:
Dump of assembler code for function test_function:
0x03800f70 <test_function+0>: push %ebp
0x03800f71 <test_function+1>: mov %esp,%ebp
0x03800f73 <test_function+3>: sub $0x48,%esp
我想要什麼:
void main()
{
printf("Hello World\n");
}
謝謝!
編輯: 我得到這個:
(gdb) list myFunction
941 directory/directory_etc/sourcefile.c: No such file or directory.
in directory/directory_etc/sourcefile.c
然後我試圖指定LINENUM:
(gdb) list directory/directory_etc/sourcefile.c:941
936 in directory/directory_etc/sourcefile.c
所以行爲類似於你所描述的,但「清單文件名:LINENUM 「仍然沒有工作
謝謝!
當前功能:http://stackoverflow.com/questions/12824251/gdb-list-source-of-current-function-without-typing-its-name – 2015-07-27 11:52:22