【问题标题】:GDB Not Skipping Functions without Debug InfoGDB 不跳过没有调试信息的函数
【发布时间】:2010-04-03 07:15:23
【问题描述】:

我在 Mac OS X Leopard 系统上编译了 GDB 7。单步执行 C 程序时,GDB 无法单步执行可能没有相关调试信息的“printf()”语句,并开始打印“找不到当前函数的边界”。

这是一些输出:

$ /usr/local/bin/gdb try1
GNU gdb (GDB) 7.1
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-apple-darwin10".
(gdb) list
1   #include <stdio.h>
2   static void display(int i, int *ptr);
3   
4   int main(void) {
5      int x = 5;
6       int *xptr = &x;
7       printf("In main():\n");
8      printf("   x is %d and is stored at %p.\n", x, &x);
9      printf("   xptr holds %p and points to %d.\n", xptr, *xptr);
10     display(x, xptr);
(gdb) b 6
Breakpoint 1 at 0x1e8e: file try1.c, line 6.
(gdb) r
Starting program: /tmp/try1 

Breakpoint 1, main () at try1.c:6
6       int *xptr = &x;
(gdb) n
7       printf("In main():\n");
(gdb) n
0x0000300a in ?? ()
(gdb) n
Cannot find bounds of current function
(gdb) n
Cannot find bounds of current function

知道发生了什么吗?

艾伦

【问题讨论】:

    标签: c macos gdb


    【解决方案1】:

    您是否使用 -g 进行编译以启用调试信息?

    这是我的会话:

    epronk@godiva:~$ gdb a.out
    GNU gdb 6.8-debian
    Copyright (C) 2008 Free Software Foundation, Inc.
    License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
    This is free software: you are free to change and redistribute it.
    There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
    and "show warranty" for details.
    This GDB was configured as "x86_64-linux-gnu"...
    (gdb) list
    1   #include <stdio.h>
    2     
    3   int main(void) {
    4     int x = 5;
    5     int *xptr = &x;
    6     printf("In main():\n");
    7     printf("   x is %d and is stored at %p.\n", x, &x);
    8     printf("   xptr holds %p and points to %d.\n", xptr, *xptr);
    9     return 0;
    10  }
    (gdb) b 6
    Breakpoint 1 at 0x400533: file d.c, line 6.
    (gdb) r
    Starting program: /home/epronk/a.out 
    
    Breakpoint 1, main () at d.c:6
    6     printf("In main():\n");
    (gdb) n
    In main():
    7     printf("   x is %d and is stored at %p.\n", x, &x);
    (gdb) n
       x is 5 and is stored at 0x7fff0f3177c4.
    8     printf("   xptr holds %p and points to %d.\n", xptr, *xptr);
    (gdb) n
       xptr holds 0x7fff0f3177c4 and points to 5.
    9     return 0;
    (gdb) n
    10  }
    (gdb)
    

    【讨论】:

    • 是的,程序是用-g选项编译的;否则不会显示任何好的调试信息。我的 Mac 附带的标准 GDB 6.3.50 和你的输出一样好用,但是我从源代码编译的 GDB 7 有问题。如果有任何帮助,我从ftp.gnu.org/gnu/gdb 下载了 GDB 7.1 源代码并使用以下说明进行编译:chenkaie.blogspot.com/2009/11/…
    猜你喜欢
    • 1970-01-01
    • 2015-03-01
    • 1970-01-01
    • 2021-08-31
    • 1970-01-01
    • 2015-03-23
    • 2012-05-27
    • 2012-09-08
    相关资源
    最近更新 更多