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?