13 Şubat 2011 Pazar

Here is a basic process on GDB to see the Sys. Assemble codes executed with your C Program's "main" func..

There are the input strings to your terminal in sequence. Follow the order;


gcc demo.c // it compiles and gives a.out.
gdb a.out //it starts the debugger gdb.
break main //it puts a break point to your code's main function.
run //it runs the program up to main func.
disassemble //it gives the system assemble codes.


Here is the process overview from my terminal.


erogol@ubuntu:~/Desktop/01-um-getpid$ gcc demo.c
erogol@ubuntu:~/Desktop/01-um-getpid$ gdb a.out
GNU gdb (GDB) 7.2-ubuntu
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
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 "x86_64-linux-gnu".
For bug reporting instructions, please see:
...
Reading symbols from /home/erogol/Desktop/01-um-getpid/a.out...(no debugging symbols found)...done.
(gdb) break main
Breakpoint 1 at 0x4004f8
(gdb) run
Starting program: /home/erogol/Desktop/01-um-getpid/a.out

Breakpoint 1, 0x00000000004004f8 in main ()
(gdb) disassemble
Dump of assembler code for function main:
0x00000000004004f4 <+0>: push %rbp
0x00000000004004f5 <+1>: mov %rsp,%rbp
=> 0x00000000004004f8 <+4>: mov $0x0,%eax
0x00000000004004fd <+9>: callq 0x400400
0x0000000000400502 <+14>: mov $0x0,%eax
0x0000000000400507 <+19>: leaveq
0x0000000000400508 <+20>: retq
End of assembler dump.
(gdb) ^CQuit
(gdb)

Hiç yorum yok:

Yorum Gönder