Find program counter of process in kernel

梦想的初衷 提交于 2019-12-10 21:29:00

问题


I'm trying to track the value of the PC of a particular process within the kernel.
To do this, I looked at the kernel source and figured out that the pc is being stored inside task_struct->stack and that to make sense of the stack, I need to type cast it into struct thread_info *.
Therefore, in in gdb, I set a breakpoint b scheduler_tick (called every 10ms). However, when I printed out p/x ((struct thread_info *)curr->stack)->cpu_context.pc, I received the value as $4 = 0x804d19d8.

I expected the PC to be below 0x80000000 given that addresses above 0x80000000 are configured to be kernel-space in my kernel. Upon looking at the objdump output of the kernel, I see that the pc was pointing to __schedule.

Isn't the PC supposed to be pointing to user-space instructions for a process that I started from user-space?
My understanding was that, when an interrupt is triggered, the register state is saved, the interrupt is serviced, and then the register state is restored so the program continues as though 'nothing' happened.

来源:https://stackoverflow.com/questions/26030910/find-program-counter-of-process-in-kernel

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!