2010-04-03 2 views
1

Я скомпилировал GDB 7 в системе Mac OS X Leopard. Когда вы переходите через программу C, GDB не может выполнить инструкции 'printf()', которые, вероятно, не имеют связанной информации об отладке, и начинает печать «Не удается найти ограничения текущей функции».GDB не пропускает функции без отладочной информации

Вот некоторые результаты:

$ /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 

Любая идея, что происходит?

Алан

ответ

0

ли вы компилируете с параметром -g, чтобы включить отладочную информацию?

Вот моя сессия:

[email protected]:~$ 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) 
+0

Да, программа была скомпилирована с опцией -g; иначе ни одна из этих хороших отладочных данных не была бы отображена. Стандарт GDB 6.3.50, который поставляется вместе с моим Mac, работает так же, как и ваш вывод, но у меня проблема с GDB 7, скомпилированным из исходного кода. Если это какая-либо помощь, я загрузил источники GDB 7.1 из http://ftp.gnu.org/gnu/gdb/ и скомпилировал их с помощью следующих инструкций: http://chenkaie.blogspot.com/2009/11/macsnow -leopard-билд-GDB-v70-from.html. – aparkerlue

Смежные вопросы