开发者

How to print out registers in Linux kernel?

I want to print out values of a couple of registers from the linux kernel code running on ARM. Particularly I have the following assembly in linux -

e3c52007        bic     r2, r5, #7      ; 0x7
e1520003        cmp     r2, r3
0a000003        beq     c011fa60 <smem_find+0x40>

How do I print out the values of r2, r3 and r5 in kmsg? I do not want to use the variable na开发者_开发百科mes and want to get the values from registers.


I'm not that familiar with kernel development and easy ways to debug, but this would do the job I guess.

size_t r2, r3, r5;

asm ("str r2, %[r2]\n"
     "str r3, %[r3]\n"
     "str r5, %[r5]\n"
 : [r2]"=m" (r2), [r3]"=m" (r3), [r5]"=m" (r5));
 printk("r2=%u r3=%u r4=%u\n", r2, r3, r5);

Edit: Now with ARM assembly instead of x86 :p


You can call show_regs(struct pt_regs * regs). This function will diplay all the registrs on the pt_regs structure.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜