debugging inline assembly

David Daney
Fri Aug 9 22:23:00 GMT 2013

On 08/09/2013 12:55 PM, Christos wrote:
> Hi all,
> I know that there is an old thread about that but I just found only the
> question.
> Is it possible to debug inlined assembly.


> It causes seg fault and I
> don't know why...

You do it much like "normal assembly".  Run your program under gdb, 
place a breakpoint before the statement you are interested in, then use 
gdb's "si" and "ni" commands to step instruction by instruction through 
the code.

Follow along with what is happening by looking at the register and 
memory state ("info reg" and "x...").

You should be able to get a dissassembly of the code either with the gdb 
"xi" command, or the stand-alone objdump program with "objdump -d"

It is also helpful to have an ISA manual for the processor in question 
close at hand.

David Daney

More information about the Gcc-help mailing list