Friday, October 30, 2015

Setting gdb's Assembly Code as Intel or AT&T Style

When debugging with gdb, one often looks at the assembly code of the binary file. Here, I will show how to do this and change the output as either 'intel' or 'att' format.

I have a simple helloworld program a.out that I'd like to debug. To do this, enter
$ gdb -q a.out

To read the assembly code of the function main, I would type in
(gdb) disass main

However, the default is in the 'att' format, which isn't my taste. To switch to 'intel' format, I'd type in
(gdb) set disassembly-flavor intel

If you'd like to make this change permanent, simply create a file .gdbinit in your home directory with the command that you want gdb to run every time it initialises.
$ echo "set disassembly-flavor intel" > ~/.gdbinit

That's it! Obviously, you may replace 'intel' with 'att' if you want to switch back to 'att' format.

No comments:

Post a Comment