Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/67.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C 在内核中查找进程的程序计数器_C_Linux_Linux Kernel_Arm_Program Counter - Fatal编程技术网

C 在内核中查找进程的程序计数器

C 在内核中查找进程的程序计数器,c,linux,linux-kernel,arm,program-counter,C,Linux,Linux Kernel,Arm,Program Counter,我正在尝试跟踪内核中特定进程的PC值。 为此,我查看了内核源代码,发现pc存储在task\u struct->stack中,为了理解堆栈,我需要在struct thread\u info*中键入cast 因此,在gdb中,我设置了一个断点b scheduler\u tick(每10毫秒调用一次)。 但是,当我打印出p/x((struct thread\u info*)curr->stack)->cpu\u context.pc时,我收到的值是$4=0x804d19d8 考虑到0x8000000以

我正在尝试跟踪内核中特定进程的PC值。
为此,我查看了内核源代码,发现pc存储在
task\u struct->stack
中,为了理解堆栈,我需要在
struct thread\u info*
中键入cast 因此,在gdb中,我设置了一个断点
b scheduler\u tick
(每10毫秒调用一次)。 但是,当我打印出
p/x((struct thread\u info*)curr->stack)->cpu\u context.pc
时,我收到的值是
$4=0x804d19d8

考虑到
0x8000000
以上的地址被配置为内核中的内核空间,我希望PC低于
0x8000000
。在查看内核的
objdump
输出时,我看到pc指向
\u schedule

对于我从用户空间开始的进程,PC不应该指向用户空间指令吗?

我的理解是,当一个中断被触发时,寄存器状态被保存,中断被服务,然后寄存器状态被恢复,因此程序继续运行,就好像什么也没发生一样。

看看ptrace是怎么做的,有多个
PC
值。您正在查看的是内核
PC
。用户空间在
struct task\u struct*task
中。使用Auslen的链接,
task\u pt\u regs((struct thread\u info*)(curr)->task)->uregs[ARM\u pc]
应该可以得到它。