Prevent PLT (procedure linkage table) breakpoints in GDB

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

    Yup, it can be done.

    To simply place breakpoints on all functions, use command:

    1. rbreak .*

    So, this will place breakpoints on all the functions including PLT.

    Now type:

    1. save breakpoints filename

    This will save a list of all breakpoints in a file called as filename.

    1. Now open the file in normal text editor like gedit, and remove all the PLT lines given at the end of the file. And then save the file with only the required functions on which you want to place breakpoints.

    or

    1. Remove all the @plt from the function names using the command:

    sed 's/@plt//g' filename > newfilename

    1. After this, exit gdb (to unlink gdb from useless PLT breakpoints, added before) and execute gdb again.

    Now type command:

    1. source filename

    or

    1. source newfilename (in case you used sed command)

    At this point, gdb will put breakpoints only on the functions mentioned in the file called as "filename" or "newfilename" (if used sed).

    Note: To filter functions more in the file "filename", one can use grep also according to the requirements. :)

提交回复
热议问题