首先介绍一下ptrace:

ptrace提供了一种使父进程得以监视和控制其它进程的方式,它还能够改变子进程中的寄存器和内核映像,因而可以实现断点调试和系统调用的跟踪。
使用ptrace,你可以在用户层拦截和修改系统调用(sys call)

我们以一个实例为例:

[cpp] view plain copy  print?
  1. #include <sys/ptrace.h>
  2. #include <sys/types.h>
  3. #include <sys/wait.h>
  4. #include <unistd.h>
  5. #include <linux/user.h> /* For constants
  6. ORIG_EAX etc */
  7. int main()
  8. {
  9. pid_t child;
  10. long orig_eax;
  11. child = fork();
  12. if(child == 0) {
  13. ptrace(PTRACE_TRACEME, 0, NULL, NULL);
  14. execl("/bin/ls", "ls", NULL);
  15. }
  16. else {
  17. wait(NULL);
  18. orig_eax = ptrace(PTRACE_PEEKUSER,
  19. child, 4 * ORIG_EAX,
  20. NULL);
  21. printf("The child made a "
  22. "system call %ld ", orig_eax);
  23. ptrace(PTRACE_CONT, child, NULL, NULL);
  24. }
  25. return 0;
  26. }

运行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 错误的解决方法相关推荐

  1. win7 64位 VS2010调试提示“ORA-12154: TNS: 无法解析指定的连接标识符”的解决方法

    win7 64位 VS2010调试提示"ORA-12154: TNS: 无法解析指定的连接标识符"的解决方法 参考文章: (1)win7 64位 VS2010调试提示"O ...

  2. Linux中常见的几种错误和解决方法

    1.Linux中常见的错误有四种: ping: unknown host:主机找不到错误 timeout:请求超时 permission denied: 权限被拒绝 Connection refuse ...

  3. m1Mac上下载安装并运行gprMax中几个错误的解决方法

    问题出现前提:已安装homebrew和anaconda,在终端中 $brew update $brew upgrade $ conda update conda $ conda install git ...

  4. linux系统重启网络delaying initialization错误的解决方法

    在我们重启网卡时如果报错如下: device "eth0" does not seem to be present, delaying initialization 说明     ...

  5. QGC编译报错error C2220: 警告被视为错误 最佳解决方法

    前面搜了一下,试过各种方法依然报错,先整理别人的解决方法 目录 一.重新保存文件 二,更改编码方式 三.最终解决方案:修改配置文件 一.重新保存文件 注意这里的配置"Wx/WX-" ...

  6. Kali Linux中Unable to locate package错误的解决方法2-1

    1 错误产生原因 在使用apt-get指令从源服务器的仓库中安装软件时,有时会产生Unable to locate package的错误,如图1所示. 图1 安装软件错误 该错误的意思是"不 ...

  7. 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 是找不到包含文 ...

  8. 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 ...

  9. linux shell脚本 报错dirname:无效选项 -- b 错误原因 解决方法

    今天在写一个Shell脚本的时候,发现调试的时候会报一个错 [oracle@smidb11 autoawrrpt]$ . a.sh dirname:无效选项 -- b 请尝试执行"dirna ...

  10. linux下Qt cannot find -lGL错误的解决方法

    在linux下使用Qt 编译时候遇上了cannot find -lGL错误 因为缺少相关包,可以使用下列命令安装 sudo apt-get install libqt4-dev

最新文章

  1. 优化问题都需要哪些数学基础?
  2. 《剑指offer》-- 树的子结构、二叉树的镜像、二叉树的深度、平衡二叉树
  3. Java笔记-AnnotationConfigApplicationContext在Spring中的例子
  4. mysql设置空值显示null_mysql的空值与NULL的区别
  5. python word自动化_python操作word,自动化办公
  6. Python numpy学习笔记(一)
  7. URL vs URI
  8. 终于有人做了一款新时代的搜索引擎
  9. 【Spring-Cached】Cached之Caffeine
  10. cocos2dx 手游luac 解密 文件的key
  11. 物联网通信-期末复习
  12. 讯飞语音转写json结果格式化,提取文字(基于python)
  13. Laravel Eloquent 数据查询结果中日期的格式化
  14. 上海会计师事务所选哪家?
  15. 1800 Flying to the Mars 大数 最多不上升序列 简化题意
  16. 【本人秃顶程序员】过年了,给亲朋好友解释“啥是程序员”
  17. STL——SET操作与并交差
  18. 微信小程序之微票前后端简易版+五天实训总结
  19. 到底「美图秀秀」是艺术家,还是会 P 图的姑娘算艺术家?
  20. 《CMake 进阶之路》第四章 安装Installing 及 测试Testing

热门文章

  1. Kafka Simple Consumer
  2. 仿51 job 省市二级联动
  3. Microsoft Dynamic CRM 自定义重复检测功能
  4. 使用WUCDCreator将SCSI、RAID、SATA、SAS驱动程序集成到光盘中
  5. springboot生成包含特定数字_关于Spring Boot 这可能是全网最好的知识点总结
  6. jsp的知识略解,只作为笔记,不作为知识参考,谢谢
  7. ila数据导入matlab,MATLAB读取Xilinx ILA核保存的.ila文件中的两列数据,并输出到文件保存...
  8. php添加开机启动脚本_php-fpm开机自动启动Shell脚本
  9. 【转(比较全面)】CSS3弹性盒模型之Flexbox是布局模块box-sizing box-orient box-direction box-ordinal-group
  10. Scale-up and Scale-out