如何在每次地址不同时使用strace -i进行调试 [英] How to debug with strace -i when everytime address is different

查看:150
本文介绍了如何在每次地址不同时使用strace -i进行调试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

[b77d0424] open(etc / shadow,0_RDONLY)= -1 EACCESS(Permission denied)

每次运行[b77d0424]改为另一个地址



我不能使用gdb b * 0xb77d0424然后c找到lib64 / libc.so.6

它看起来不像在Linux编程书中提到的那样在使用虚拟盒子的ubuntu 13.04之后

解决方案


每次运行[b77d0424]改为另一个地址


正在发生是因为地址空间布局随机化,您可以使用 setarch禁用setarch -R 命令。



GDB 也会在默认情况下禁用地址随机化,但是,因为两个工具下的执行环境差异很大,所以在GDB中, strace NT。您实际上并不需要来查找 strace 下的地址,您可以在GDB中找到它:




  • catch系统调用open

  • run

    您现在正在查看打开的系统调用之一你的程序呢。使用继续,直到您停在感兴趣的那个位置。现在使用 info registers 来查找第一个参数,并在该地址上设置一个观察点。


    [b77d0424] open("etc/shadow",0_RDONLY) = -1 EACCESS (Permission denied)

    every time i run [b77d0424] changed to another address

    i can not use gdb b *0xb77d0424 and then c to find lib64/libc.so.6

    it seems not the same mentioned in a linux programming book

    after running ubuntu 13.04 in virtual box

    解决方案

    every time i run [b77d0424] changed to another address

    This is happening because of address space layout randomization, which you can disable with setarch -R command.

    GDB also disables address randomization by default, but the chance that the same address you'll get in GDB and under strace is quite small, as the execution environment under the two tools is quite different. You don't actually need to find the address under strace, you can find it in GDB:

    • catch syscall open
    • run

    You are now looking at one of the open system calls your program does. Use continue until you stop at the one you are interested in. Now use info registers to find the address of the first parameter, and set a watchpoint on that address.

    这篇关于如何在每次地址不同时使用strace -i进行调试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆