debugging inline assembly

Christos xristos.tsop@gmail.com
Fri Aug 9 23:42:00 GMT 2013


On 08/09/2013 11:23 PM, David Daney wrote:
> 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.

Yes, this works with a potential improvement finally...

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

Yes I did use i r from the beginning but it didn't help a lot.

> 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"

Here comes the improvement I said before. To make ni or si more
meaningful you had better set in the gdb environment the
disassemble-next-line on, so that you do realize which instruction you
follow at any step, without it you just get the address of the running
instruction at the beginning of the line (it's not so intuitive). I
thing this is better that a whole disassembling.

> It is also helpful to have an ISA manual for the processor in question
> close at hand.
Exactly because finally it came up that the first instruction was
touching a register that you can only touch if you are root (cr0).

Solved, thanks a lot

-- 
Christos Tsopokis



More information about the Gcc-help mailing list