Gdb: Difference between revisions
From charlesreid1
No edit summary |
No edit summary |
||
| Line 1: | Line 1: | ||
{ | =Simple Disassembly Example= | ||
Starting with a simple hello world program: | |||
<pre> | |||
#include <stdio.h> | |||
int main(void) | |||
{ | |||
printf("Hello world! This is C.\n"); | |||
return 0; | |||
} | |||
</pre> | |||
Now compile the program with debug flags: | |||
<pre> | |||
$ gcc -g hello_world.c -o hello_from_c.x | |||
</pre> | |||
and load it up into gdb: | |||
<pre> | |||
$ gdb hello_from_c.x | |||
</pre> | |||
Now you can run the program like normal: | |||
<pre> | |||
(gdb) run | |||
</pre> | |||
and to disassemble the binary into its assembly level instructions, | |||
<pre> | |||
(gdb) disassemble main | |||
</pre> | |||
=References= | =References= | ||
Revision as of 04:41, 24 April 2017
Simple Disassembly Example
Starting with a simple hello world program:
#include <stdio.h>
int main(void)
{
printf("Hello world! This is C.\n");
return 0;
}
Now compile the program with debug flags:
$ gcc -g hello_world.c -o hello_from_c.x
and load it up into gdb:
$ gdb hello_from_c.x
Now you can run the program like normal:
(gdb) run
and to disassemble the binary into its assembly level instructions,
(gdb) disassemble main
References
http://www.ibm.com/developerworks/aix/library/au-gdb.html?ca=dgr-lnxw16GDB2
http://www.ibm.com/developerworks/aix/library/au-unix-strace.html
http://stackoverflow.com/questions/1585308/debugging-disassembled-libraries-with-gdb
| GNU/Linux/Unix the concrete that makes the foundations of the internet.
Compiling Software · Upgrading Software Category:Build Tools · Make · Cmake · Gdb Bash Bash · Bash/Quick (Quick Reference) · Bash Math Text Editors Text Manipulation Command Line Utilities Aptitude · Diff · Make · Patch · Subversion · Xargs Security SSH (Secure Shell) · Gpg (Gnu Privacy Guard) · Category:Security Networking Linux/SSH · Linux/Networking · Linux/File Server Web Servers
|