Using GNU Debugger, how can I step through __asm__ statements?
__asm__("\n\
movl $1, %eax\n\
");
How can I step through 开发者_开发问答__asm__
so I can print the registers to see what they are storing? Right now, I put a break on the __asm__
line and then I tried pressing stepi
or si
and it's not stepping into the movl
line. What am I doing wrong?
The si
is stepping over the movl
instruction (you can verify this by typing display/i $pc
and observing how the output changes.
What isn't happening (and what likely confused you) is update to the source. That's because your code inside asm() does not have any line-number annotations, so GDB can't tell which line(s) it should be displaying.
Normally, the compiler puts such annotations into the assembly. But here you've bypassed the compiler. If you want line numbers to be correct, you'll have to add these annotations yourself (which usually isn't worth the trouble).
精彩评论