问题
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