I'm looking for an arch-agnostic way to obtain the instruction pointer (AKA program counter) of the last attempted instruction (or one past it) on which SIGTRAP was generated, from the perspective of a ptrace tracer.
An arch-dependent way is to use PTRACE_GETREGS and pick e.g. EIP on i386, RIP on x86_64, PC on ARM etc..
I've tried using siginfo.si_addr as well as siginfo.si_ptr from PTRACE_GETSIGINFO-returned struct, but these values appear completely wrong (4 hex digits instead of 8, and not even similar to the true address), so they don't seem to be what I need.
In Linux I've also tried making use of 30th field of /proc/<pid>/task/<tid>/stat, which the kernel fills in fs/proc/array.c:do_task_stat() with KSTK_EIP(task) (which, despite being named x86-centric, appears defined for many other architectures). But for some reason on my ARMv6 Linux 4.9.28+ (Raspbian 8) I get zeros for both program counter and stack pointer.
So, is there any arch-independent way of determining the current/next address defined by POSIX or at least available in Linux?