关于64位CentOS上ptrace报linux/user.h no such file 错误的解决方法
首先介绍一下ptrace:
ptrace提供了一种使父进程得以监视和控制其它进程的方式,它还能够改变子进程中的寄存器和内核映像,因而可以实现断点调试和系统调用的跟踪。
使用ptrace,你可以在用户层拦截和修改系统调用(sys call)
我们以一个实例为例:
- #include <sys/ptrace.h>
- #include <sys/types.h>
- #include <sys/wait.h>
- #include <unistd.h>
- #include <linux/user.h> /* For constants
- ORIG_EAX etc */
- int main()
- {
- pid_t child;
- long orig_eax;
- child = fork();
- if(child == 0) {
- ptrace(PTRACE_TRACEME, 0, NULL, NULL);
- execl("/bin/ls", "ls", NULL);
- }
- else {
- wait(NULL);
- orig_eax = ptrace(PTRACE_PEEKUSER,
- child, 4 * ORIG_EAX,
- NULL);
- printf("The child made a "
- "system call %ld ", orig_eax);
- ptrace(PTRACE_CONT, child, NULL, NULL);
- }
- return 0;
- }
运行gcc -o xxxx xxxx.c 之后报<linux/user.h> no such file...这个错误提示。
错误形成的原因是因为内核结构的变化使得原先/usr/include/linux/user.h消失而是变为了/usr/include/sys/reg.h
因此,调试的时候需要将 #include linux/user.h> 这句变为 #include <sys/reg.h>
当然修改之后还是会报错,原因是因为64位的寄存器结构和32位不同,解决方法是将 ORIG_EAX改为ORIG_RAX 便可以运行成功。
关于64位CentOS上ptrace报linux/user.h no such file 错误的解决方法相关推荐
- win7 64位 VS2010调试提示“ORA-12154: TNS: 无法解析指定的连接标识符”的解决方法
win7 64位 VS2010调试提示"ORA-12154: TNS: 无法解析指定的连接标识符"的解决方法 参考文章: (1)win7 64位 VS2010调试提示"O ...
- Linux中常见的几种错误和解决方法
1.Linux中常见的错误有四种: ping: unknown host:主机找不到错误 timeout:请求超时 permission denied: 权限被拒绝 Connection refuse ...
- m1Mac上下载安装并运行gprMax中几个错误的解决方法
问题出现前提:已安装homebrew和anaconda,在终端中 $brew update $brew upgrade $ conda update conda $ conda install git ...
- linux系统重启网络delaying initialization错误的解决方法
在我们重启网卡时如果报错如下: device "eth0" does not seem to be present, delaying initialization 说明 ...
- QGC编译报错error C2220: 警告被视为错误 最佳解决方法
前面搜了一下,试过各种方法依然报错,先整理别人的解决方法 目录 一.重新保存文件 二,更改编码方式 三.最终解决方案:修改配置文件 一.重新保存文件 注意这里的配置"Wx/WX-" ...
- Kali Linux中Unable to locate package错误的解决方法2-1
1 错误产生原因 在使用apt-get指令从源服务器的仓库中安装软件时,有时会产生Unable to locate package的错误,如图1所示. 图1 安装软件错误 该错误的意思是"不 ...
- 02_Keil5报错 error: #5: cannot open source input file “XXX.h”: No such file or directory解决方法
Keil5 error: #5: cannot open source input file "led.h": No such file or directory 是找不到包含文 ...
- Redis 安装报错 error: jemalloc/jemalloc.h: No such file or directory解决方法
错误描述 安装Redis 2.8.18时报错: zmalloc.h:50:31: error: jemalloc/jemalloc.h: No such file or directory zmall ...
- linux shell脚本 报错dirname:无效选项 -- b 错误原因 解决方法
今天在写一个Shell脚本的时候,发现调试的时候会报一个错 [oracle@smidb11 autoawrrpt]$ . a.sh dirname:无效选项 -- b 请尝试执行"dirna ...
- linux下Qt cannot find -lGL错误的解决方法
在linux下使用Qt 编译时候遇上了cannot find -lGL错误 因为缺少相关包,可以使用下列命令安装 sudo apt-get install libqt4-dev
最新文章
- 优化问题都需要哪些数学基础?
- 《剑指offer》-- 树的子结构、二叉树的镜像、二叉树的深度、平衡二叉树
- Java笔记-AnnotationConfigApplicationContext在Spring中的例子
- mysql设置空值显示null_mysql的空值与NULL的区别
- python word自动化_python操作word,自动化办公
- Python numpy学习笔记(一)
- URL vs URI
- 终于有人做了一款新时代的搜索引擎
- 【Spring-Cached】Cached之Caffeine
- cocos2dx 手游luac 解密 文件的key
- 物联网通信-期末复习
- 讯飞语音转写json结果格式化,提取文字(基于python)
- Laravel Eloquent 数据查询结果中日期的格式化
- 上海会计师事务所选哪家?
- 1800 Flying to the Mars 大数 最多不上升序列 简化题意
- 【本人秃顶程序员】过年了,给亲朋好友解释“啥是程序员”
- STL——SET操作与并交差
- 微信小程序之微票前后端简易版+五天实训总结
- 到底「美图秀秀」是艺术家,还是会 P 图的姑娘算艺术家?
- 《CMake 进阶之路》第四章 安装Installing 及 测试Testing
热门文章
- Kafka Simple Consumer
- 仿51 job 省市二级联动
- Microsoft Dynamic CRM 自定义重复检测功能
- 使用WUCDCreator将SCSI、RAID、SATA、SAS驱动程序集成到光盘中
- springboot生成包含特定数字_关于Spring Boot 这可能是全网最好的知识点总结
- jsp的知识略解,只作为笔记,不作为知识参考,谢谢
- ila数据导入matlab,MATLAB读取Xilinx ILA核保存的.ila文件中的两列数据,并输出到文件保存...
- php添加开机启动脚本_php-fpm开机自动启动Shell脚本
- 【转(比较全面)】CSS3弹性盒模型之Flexbox是布局模块box-sizing box-orient box-direction box-ordinal-group
- Scale-up and Scale-out