linux-newbie.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Tracking process program counter in kernel
@ 2014-09-25  5:49 Guru Prasad
  0 siblings, 0 replies; only message in thread
From: Guru Prasad @ 2014-09-25  5:49 UTC (permalink / raw)
  To: linux-newbie

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.

Correct me if I'm wrong, but 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.

How can I find the current instruction that is being executed in user-space?
--
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2014-09-25  5:49 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-25  5:49 Tracking process program counter in kernel Guru Prasad

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).