微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

在SIGTRAP上是否有任何不可知的获取指令指针的方法?

我正在寻找一个与arch不可知的方式,从ptrace跟踪器的angular度来获取SIGTRAP生成的最后一个尝试指令(或者一个过去的指令)的指令指针(AKA程序计数器)。

依赖拱的方法是使用PTRACE_GETREGS并select例如PTRACE_GETREGS ,x86_64上的RIP ,ARM上的PC等。

我已经尝试使用siginfo.si_addr以及从PTRACE_GETSIGINFO返回的PTRACE_GETSIGINFO返回结构,但这些值显示完全错误(4个hex数字而不是8,甚至没有类似的真实地址),所以他们似乎不成为我所需要的。

在Linux中,我还尝试使用/proc/<pid>/task/<tid>/stat的第30个字段,内核填充fs/proc/array.c:do_task_stat()和KSTK_EIP(task)尽pipe它被命名为以x86为中心,但对于许多其他体系结构而言却是如此)。 但由于某种原因,在我的ARMv6 Linux 4.9.28 +(Raspbian 8)我得到零和程序计数器和堆栈指针。

SIGKILL信号处理程序

在Linux中使用Signal发送信息

Boost.asio和UNIX信号处理

虽然信号没有收到?

SIGSTOP不能在c程序中工作

那么,是否有任何独立于脚本的方式来确定POSIX定义的当前/下一个地址,或者至less可以在Linux中使用?

在linux上使用信号的IPC

如何在不杀死Linux的情况下给应用程序发信号?

什么键盘信号除了Ctrl-C可以捕捉?

即使在Cygwin上,Python信号也不起作用?

Windows相当于SIGPROF

你可以使用/proc/[pid]/syscall 。

mark@ubuntu:~$ gdb python ... ... ... Program received signal SIGINT,Interrupt. 0x00007ffff78ed573 in __select_nocancel () at ../sysdeps/unix/syscall-template.S:84 84 ../sysdeps/unix/syscall-template.S: No such file or directory. (gdb) mark@ubuntu:~/$ ps aux | grep python mark 77858 0.2 0.7 90216 37780 pts/2 S+ 15:13 0:00 gdb python mark 77860 0.0 0.1 38416 6424 pts/2 t 15:13 0:00 /usr/bin/python

(见77860被77860 – t )

mark@ubuntu:~/$ sudo cat /proc/77860/syscall 23 0x1 0x7fffffffd980 0x0 0x0 0x0 0x7ffff7fdb700 0x7fffffffd958 0x7ffff78ed573

0x7fffffffd958是sp , 0x7ffff78ed573是程序计数器。

我找不到任何帮助这里的ptrace电话。

http://man7.org/linux/man-pages/man5/proc.5.html

/proc/[pid]/syscall (since Linux 2.6.27) This file exposes the system call number and argument regis‐ ters for the system call currently being executed by the process,followed by the values of the stack pointer and pro‐ gram counter registers. The values of all six argument regis‐ ters are exposed,although most system calls use fewer regis‐ ters. If the process is blocked,but not in a system call,then the file displays -1 in place of the system call number,followed by just the values of the stack pointer and program counter. If process is not blocked,then the file contains just the string "running".

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐