I was bored and decided to fix gdbinit to support 64bits binaries. I had tried it before but the solution was a piece of crap (not that this one is much better). I was testing the registers to see if the binary was 32 or 64bits. Now there is a default setting to 32bits (change it if you want to default to 64bits) and two commands, 32bits and 64bits to change between the two types of targets. If you have 32bits by default and debug a 64bits target, the first time gdb breaks you will get an error; just issue the 64bits command to change and you can issue the context command to get the correct display and continue your debug session. I remember I couldn’t find a better way to detect the type of binary inside gdbinit, since there’s no support for regex and all that kind of tools. If you have an elegant method feel free to tell me about or patch this version and send it back
I have patched too the 64bits mode to have available the 32 and 16bits registers versions. The ObjectiveC messages display and the stepo command still need to be fixed to 64bits. The calls are different in 64bits so I need to rework that part. Everything else seems to be working; please report if not!
Can’t remember anything else to say about this one.
As usual, have fun!
fG!
Grab it here: gdbinit73 (SHA1(gdbinit73)= c4da85f3ba6e8cfa311fb63c2ab5d606df6b837c)
The latest version can always be found here.
Tags: gdbinit
-
Welcome back… good to see you posting again
-
Thanks for the update i was really needing this!
ould you please also update Onyx The Black Cat to work with Snow Leo? Thanks! -
“Onyx The Black Cat”—PLS…
i tried to compile it myself…nogood…
hope u get time publish it soon…cheers
-
hi fG!
I don’t know how else to talk to you hence why i’m writing here, i hope you read it.I’m desperate to learn RE on macOSX and find your way of showing how its done by tutorials excellent. Following your SlidePad tutorial i learnt a fair bit but i don’t think my skill are up to scratch and i am desperate for more tutorial or a resource you can direct me to to learn more. I know there are “Crackme” tutorials out there but they’re mostly very old (not even intel mac) and i could hardly apply the skills on snowLeopard.
My intention isn’t to become a cracker , i just find RE exciting . To me you’re like a god in mac RE field ,Please show me where i can learn more , something like your slidepad tutorials where everything is up-to-date and explanations on what to do with gdb , otool and class-dump are clear instead of assumed knowledge.
-
great blog dude!,
loving gdbinit.
-
hawkesays thanks for the crackme file, i hope it means new tutorials by fG!
may i also use this section to ask two questions?
1) what do i do with the gdbinit file that seems to be popular amongst the folks here? is it useful? what does it do? How is it applied?
2) what is the equivalent command line command for otx that can produces the same output as when done through otx itself, when i do “otool -vt …” the output is not as clean and readable as when done though otx , reason why i need it is because sometimes otx doesn’t recognize the programs i write in c saying “No mach-o file” even for something as simple as the “Hello world” in fG! tutorial, but command line otool has no problems with it.
3) The reason to why the hexadecimal values i see on my machine have extra zeros is because i’m using a 64bit machine (snow leopard) where as the tutorials were written on 32bit?
ie : fG!’s tutorial outout (shell$ vmmap -allSplitLibs 303 | grep xprogram
__TEXT 00036000-00051000)compared to my out put(vmmap -allSplitLibs 1860 | grep xprogram
__TEXT 0000000100243000-000000010024c000)or am i wrong?
-
Thanks fG! i’ll look into that.
also when you get a chance can you please look at this post (tinyurl.com/2cnb83d) i made about my problems trying to debug the “Hello world” program in gdb. I think the problem might be with the gdbinit (but what do i know so is possibly wrong). Thanks in advance
-
Is it possible to debug 32-bit binaries in a 64-bit OS?
If I set a file via exec-file and then run it, it’s the 64-bit binary that opens.It is very appreciated that you make tutorials for RE on the Mac.

The first one you made (I don’t think it exists on this site anymore) was very helpful in getting to know GDB.Thanks for sharing so much information ^^
25 comments
Comments feed for this article
Trackback link: http://reverse.put.as/2010/04/16/gdbinit-v7-3/trackback/