gdb如何除錯沒有符號表(未加-g選項的編譯)的程式
阿新 • • 發佈:2019-01-10
[email protected]:~$ gdb a.out
GNU gdb (GDB) 7.5.91.20130417-cvs-ubuntu
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "i686-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from a.out...(no debugging symbols found)...done.
(gdb) l
沒有符號表被讀取。請使用 "file" 命令。
(gdb) disassemble main
Dump of assembler code for function main:
0x0804841c <+0>: push %ebp
0x0804841d <+1>: mov %esp,%ebp
0x0804841f <+3>: and $0xfffffff0,%esp
0x08048422 <+6>: sub $0x20,%esp
0x08048425 <+9>: movl $0x0,0x14(%esp)
0x0804842d <+17>: movl $0x9,0x18(%esp)
0x08048435 <+25>: mov 0x18(%esp),%eax
0x08048439 <+29>: mov 0x14(%esp),%edx
0x0804843d <+33>: add %edx,%eax
0x0804843f <+35>: mov %eax,0x1c(%esp)
0x08048443 <+39>: mov 0x1c(%esp),%eax
0x08048447 <+43>: mov %eax,0x4(%esp)
0x0804844b <+47>: movl $0x8048540,(%esp)
0x08048452 <+54>: call 0x80482f0 < [email protected]>
0x08048457 <+59>: mov 0x18(%esp),%eax
0x0804845b <+63>: mov 0x1c(%esp),%edx
0x0804845f <+67>: add %edx,%eax
0x08048461 <+69>: mov %eax,0x14(%esp)
0x08048465 <+73>: mov 0x14(%esp),%eax
0x08048469 <+77>: mov %eax,0x4(%esp)
0x0804846d <+81>: movl $0x8048549,(%esp)
0x08048474 <+88>: call 0x80482f0 < [email protected]>
0x08048479 <+93>: mov 0x18(%esp),%eax
0x0804847d <+97>: mov 0x14(%esp),%edx
0x08048481 <+101>: mov %edx,%ecx
0x08048483 <+103>: sub %eax,%ecx
0x08048485 <+105>: mov %ecx,%eax
0x08048487 <+107>: mov %eax,0x18(%esp)
0x0804848b <+111>: mov 0x18(%esp),%eax
0x0804848f <+115>: mov %eax,0x4(%esp)
0x08048493 <+119>: movl $0x8048552,(%esp)
0x0804849a <+126>: call 0x80482f0 < [email protected]>
0x0804849f <+131>: mov $0x0,%eax
0x080484a4 <+136>: leave
0x080484a5 <+137>: ret
End of assembler dump.
(gdb) b *0x08048452
Breakpoint 1 at 0x8048452
(gdb) b *0x08048474
Breakpoint 2 at 0x8048474
(gdb) b *0x0804849a
Breakpoint 3 at 0x804849a
(gdb) info b
Num Type Disp Enb Address What
1 breakpoint keep y 0x08048452 <main+54>
2 breakpoint keep y 0x08048474 <main+88>
3 breakpoint keep y 0x0804849a <main+126>
(gdb) r
Starting program: a.out
Breakpoint 1, 0x08048452 in main ()
(gdb) c
Continuing.
k is 9
Breakpoint 2, 0x08048474 in main ()
(gdb) c
Continuing.
m is 18
Breakpoint 3, 0x0804849a in main ()
(gdb) c
Continuing.
n is 9
[Inferior 1 (process 19933) exited normally]
GNU gdb (GDB) 7.5.91.20130417-cvs-ubuntu
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "i686-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from a.out...(no debugging symbols found)...done.
(gdb) l
沒有符號表被讀取。請使用 "file" 命令。
(gdb) disassemble main
Dump of assembler code for function main:
0x0804841c <+0>: push %ebp
0x0804841d <+1>: mov %esp,%ebp
0x0804841f <+3>: and $0xfffffff0,%esp
0x08048422 <+6>: sub $0x20,%esp
0x08048425 <+9>: movl $0x0,0x14(%esp)
0x0804842d <+17>: movl $0x9,0x18(%esp)
0x08048435 <+25>: mov 0x18(%esp),%eax
0x08048439 <+29>: mov 0x14(%esp),%edx
0x0804843d <+33>: add %edx,%eax
0x0804843f <+35>: mov %eax,0x1c(%esp)
0x08048443 <+39>: mov 0x1c(%esp),%eax
0x08048447 <+43>: mov %eax,0x4(%esp)
0x0804844b <+47>: movl $0x8048540,(%esp)
0x08048452 <+54>: call 0x80482f0 <
0x08048457 <+59>: mov 0x18(%esp),%eax
0x0804845b <+63>: mov 0x1c(%esp),%edx
0x0804845f <+67>: add %edx,%eax
0x08048461 <+69>: mov %eax,0x14(%esp)
0x08048465 <+73>: mov 0x14(%esp),%eax
0x08048469 <+77>: mov %eax,0x4(%esp)
0x0804846d <+81>: movl $0x8048549,(%esp)
0x08048474 <+88>: call 0x80482f0 <
0x08048479 <+93>: mov 0x18(%esp),%eax
0x0804847d <+97>: mov 0x14(%esp),%edx
0x08048481 <+101>: mov %edx,%ecx
0x08048483 <+103>: sub %eax,%ecx
0x08048485 <+105>: mov %ecx,%eax
0x08048487 <+107>: mov %eax,0x18(%esp)
0x0804848b <+111>: mov 0x18(%esp),%eax
0x0804848f <+115>: mov %eax,0x4(%esp)
0x08048493 <+119>: movl $0x8048552,(%esp)
0x0804849a <+126>: call 0x80482f0 <
0x0804849f <+131>: mov $0x0,%eax
0x080484a4 <+136>: leave
0x080484a5 <+137>: ret
End of assembler dump.
(gdb) b *0x08048452
Breakpoint 1 at 0x8048452
(gdb) b *0x08048474
Breakpoint 2 at 0x8048474
(gdb) b *0x0804849a
Breakpoint 3 at 0x804849a
(gdb) info b
Num Type Disp Enb Address What
1 breakpoint keep y 0x08048452 <main+54>
2 breakpoint keep y 0x08048474 <main+88>
3 breakpoint keep y 0x0804849a <main+126>
(gdb) r
Starting program: a.out
Breakpoint 1, 0x08048452 in main ()
(gdb) c
Continuing.
k is 9
Breakpoint 2, 0x08048474 in main ()
(gdb) c
Continuing.
m is 18
Breakpoint 3, 0x0804849a in main ()
(gdb) c
Continuing.
n is 9
[Inferior 1 (process 19933) exited normally]