GNU gdb how to show source file name and lines of a symbol

早过忘川 提交于 2019-12-04 19:13:21

问题


when use GNU gdb to debug a c process.

list command will print the lines but not telling me the file name.

set breakpoints can display all the line and file info I want but I don't want to set a breakpoint and have to disable or delete it.

(gdb) b oyss_funtion
Breakpoint 13 at 0x8049130: file main.c, line 119.

Is there a gdb command or settings can show me the file line info of a function(symbol) without setting a breakpoint there?


回答1:


Use info line command.

info line oyss_function

For example, assume the file test.c contains:

#include <stdio.h>

int main(void)
{
    printf("\n");
    return 0;
}

Then, invoking info line main in GDB gets:

(gdb) info line main
Line 4 of "test.c" starts at address 0x400498 <main> and ends at 0x40049c <main+4>.


来源:https://stackoverflow.com/questions/20771012/gnu-gdb-how-to-show-source-file-name-and-lines-of-a-symbol

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!