简体   繁体   English

在gdb调试器中,能否将函数获取到源文件映射?

[英]In the gdb debugger, is it possible to get the function to source file mapping?

When stepping through code with gdb, the source file of the function currently executed is automatically presented. 使用gdb单步执行代码时,会自动显示当前执行的函数的源文件。 I would like to automate a certain debugging task (using the gdb python API) that will step into functions that are located in a user specified source path while next-ing over others (such as printf, etc..). 我想自动化某些调试任务(使用gdb python API),该任务将逐步进入位于用户指定的源路径中的功能,而接下来是其他功能(例如printf等)。 Is there a way to access the data structure in which gdb keeps the function-to-source mapping? 有没有一种方法可以访问gdb保留函数到源映射的数据结构?

I think the closest you may get to is examining the variable or using the symbol table information with GDB. 我认为可能最接近的是检查变量或在GDB中使用符号表信息。 Some of the functions that are useful are: 一些有用的功能是:

1) info symbol addr: You can use it to find out the name of a variable or a function given its address. 1)info symbol addr:您可以使用它来查找变量或函数的名称(给定其地址)。 keep an array of dynamically linked library and decide if you want to step in or next ing the function. 保留一个动态链接库的数组,并决定是要进入功能还是下一步。

2) You may @ init load all the functions in the symbol table and based on some parameters ie externally linked libraries or internal function want to set breakpoints on them. 2)您可以@init初始化符号表中的所有函数,并基于某些参数,例如,外部链接库或内部函数要在其上设置断点。 Dumping the frame and stack @ each instance. 转储框架并堆叠@每个实例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM