Prevent PLT (procedure linkage table) breakpoints in GDB

后端 未结 4 1167
悲哀的现实
悲哀的现实 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:11

    add these lines to your ~/.gdbinit file and call disaplts to disable all @plt breakpoints:

    define disaplts
      python
    import gdb
    from StringIO import StringIO
    lines=gdb.execute("info break", True, True)
    for l in StringIO(lines).readlines():
      if "@plt" in l:
        bp=l.split()[0]
        gdb.execute("disa {0}".format(bp))
        print("disabling {0}".format(bp))
      end
    end
    # disable on library load
    catch load mylibrarywithplt disaplt
    

    Note: mind the spacing in python code. I recommend you use cat to paste the content. EDIT: added "execute on library load" per @WallStProg

提交回复
热议问题