From charlesreid1

No edit summary
Line 1: Line 1:
=Installing=
==Mac OS X==
Install using homebrew:
<pre>
$ brew install gdb
</pre>
Then, you have to give gdb permission to control other processes:
<pre>
$ open /Applications/Utilities/Keychain\ Access.app
</pre>
Now create a new certificate for gdb by opening the menu item Keychain Access > Certificate Assistant > Create a Certificate
Call it something like <code>gdb-cert</code>
Set Identity Type to Self-Signed Root
Set Certificate Type to Code Signing
Select the "Let me override defaults" option
Most of the other settings can remain the default
Specify the location for the certificate to System (not login)
=Simple Disassembly Example=
=Simple Disassembly Example=



Revision as of 05:37, 24 April 2017

Installing

Mac OS X

Install using homebrew:

$ brew install gdb

Then, you have to give gdb permission to control other processes:

$ open /Applications/Utilities/Keychain\ Access.app

Now create a new certificate for gdb by opening the menu item Keychain Access > Certificate Assistant > Create a Certificate

Call it something like gdb-cert

Set Identity Type to Self-Signed Root

Set Certificate Type to Code Signing

Select the "Let me override defaults" option

Most of the other settings can remain the default

Specify the location for the certificate to System (not login)

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