Prevent PLT (procedure linkage table) breakpoints in GDB

后端 未结 4 1166
悲哀的现实
悲哀的现实 2021-02-04 06:00

In recent versions of GDB, setting a breakpoint on a library function call results in multiple actual breakpoints:

  1. Call into the procedure linkage table (PLT)
4条回答
  •  太阳男子
    2021-02-04 06:26

    Here's a command, rdelete, that is like delete in the same way that rbreak is like break - it deletes breakpoints based on a regexp argument.

    $ cat rdelete.py
    import gdb
    import re
    
    class RDelete(gdb.Command):
      """Delete breakpoints for all locations matching REGEXP."""
    
      def __init__(self):
        super (RDelete, self).__init__ ("rdelete", gdb.COMMAND_BREAKPOINTS, gdb.COMPLETE_LOCATION)
    
      def invoke(self, argstr, from_tty):
        bppat = re.compile(argstr)
        for bp in gdb.breakpoints():
          if bppat.search(bp.location):
            print("Deleting breakpoint {} at {}".format(bp.number, bp.location))
            bp.delete()
    
    RDelete()
    
    
    $ gdb -q hoist
    (gdb) rbreak .*
    ...
    (gdb) i b
    Num     Type           Disp Enb Address            What
    1       breakpoint     keep y   0x0000000000000580 in main at hoist.c:6
    2       breakpoint     keep y   0x00000000000007a0 in x at hoist.c:4
    3       breakpoint     keep y   0x0000000000000530 <_init>
    4       breakpoint     keep y   0x0000000000000560 
    5       breakpoint     keep y   0x00000000000007b0 <__libc_csu_init>
    6       breakpoint     keep y   0x0000000000000820 <__libc_csu_fini>
    7       breakpoint     keep y   0x0000000000000824 <_fini>
    (gdb) source rdelete.py
    (gdb) rdelete @plt
    Deleting breakpoint 4 at printf@plt
    

提交回复
热议问题