开发者

Using GNU Debugger, how can I step through __asm__ statements?

开发者 https://www.devze.com 2023-02-22 16:09 出处:网络
__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 the
  __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).

0

精彩评论

暂无评论...
验证码 换一张
取 消