如何设置最早的可能断点 [英] How to set earliest possible breakpoint

查看:127
本文介绍了如何设置最早的可能断点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在模块加载到gdb之后立即停止。让我们假设二进制文件完全从所有符号信息中除去,所以没有main。

I'm trying to stop right after the module is loaded in gdb. Let's assume that the binary is completely stripped out of all symbol informations, so there's no main.

理想情况下,我会在入口点设置断点,但是这个想法会中断由于重定位:

Ideally I'd set the breakpoint on the entry point, but that idea breaks down due to relocations:

(gdb) info target
Symbols from "./application".
Local exec file:
    `./application', file type elf64-x86-64.
    Entry point: 0xc154
...
(gdb) break *0xc154
Breakpoint 1 at 0xc154
(gdb) r
Starting program: ./application 
Warning:
Cannot insert breakpoint 1.
Error accessing memory address 0xc154: Input/output error.

(gdb) info target
Symbols from "./application".
Unix child process:
    Using the running image of child process 22835.
    While running this, GDB does not access memory from...
Local exec file:
    `./application', file type elf64-x86-64.
    Entry point: 0x555555560154

即使那种作品(我可以设置一个新的新地址上的断点并禁用原始地址),它不能通过gdb脚本/批处理模式轻松执行,因为它在中间有一个失败的指令。

Even though that kind-of works (I could set a new breakpoint on the new address and disable the original), it cannot be easily executed via gdb script / batch mode, because it has a failing instruction in the middle.

一个方法来做到这一点?理想情况下,像运行单一指令,而不是运行将是有用的。

Is there a way to do that? Ideally something like "run single instruction", rather than "run" would be useful.

推荐答案


入口点:0xc154

Entry point: 0xc154

这是一个动态链接的,与位置无关的(PIE)二进制文件。

This is a dynamically-linked, position-independent (PIE) binary.

您希望在二进制文件被加载并重新定位之后,但在它执行任何操作之前,停止在动态链接器中。

You want to stop in the dynamic linker after that binary is loaded and relocated, but before it executed anything.

(gdb) set stop-on-solib-events 1
(gdb) run
Starting program: /tmp/a.out 
Stopped due to shared library event (no libraries added or removed)
(gdb) info target
Symbols from "/tmp/a.out".
Unix child process:
        Using the running image of child process 13746.
        While running this, GDB does not access memory from...
Local exec file:
        `/tmp/a.out', file type elf64-x86-64.
        Entry point: 0x5555555545f0
        ...

(gdb) bt
#0  __GI__dl_debug_state () at dl-debug.c:77
#1  0x00007ffff7ddd488 in dl_main (phdr=<optimized out>, phnum=<optimized out>, user_entry=<optimized out>, auxv=0x7ffff7ffe870) at rtld.c:1678
#2  0x00007ffff7defb24 in _dl_sysdep_start (start_argptr=<optimized out>, dl_main=0x7ffff7ddc6e0 <dl_main>) at ../elf/dl-sysdep.c:244
#3  0x00007ffff7ddf365 in _dl_start_final (arg=0x7fffffffe440) at rtld.c:338
#4  _dl_start (arg=0x7fffffffe440) at rtld.c:564
#5  0x00007ffff7ddb6b8 in _start () from /lib64/ld-linux-x86-64.so.2

这篇关于如何设置最早的可能断点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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