I'm trying to read the instruction pointer / pc register of a process/thread on an arm Aarch64 linux which is stuck within a system call ( = kernel land ) via this C++ code:
ptrace( PTRACE_GETREGSET, threadProcessId, NULL, ®s );
printf( "Register dump: %lx\n", regs.pc );
However, the address printed out is not the same as the function address from the top of the stack returned by /proc/threadProcessId/stack. It doesn't even seem to be in kernel space.
Am I doing something wrong? Can I access the kernel part pcs at all this way?
PTRACE_GETREGSETand/proc/pid/stack. One is the process and the other is kernel space. The kernel and process have seperateSPvalues as determined by the mode. The GETREGSET should be where user space called into the kernel and theproc/pid/stackis where the kernel is processing the user request. - artless noise