1
我面临问题在gdb中使用watch
。我正试图在我的代码中保留一个 监视变量m
。但由于某种原因,我收到以下消息 no symbol m in current context
。我在第7行保留了一个断点,以便m的范围是已知的。设置观看GDB不工作对我
steps performed by me :-
1>g++ -g a.cpp
2>gdb a.out
3>(gdb)break 7
4>(gdb)watch m
下面是我的程序: -
# include<iostream>
# include<stdio.h>
using namespace std;
int main()
{
int m=10;
char *abc = (char *)"ritesh";
cout << abc << endl ;
m=11;
m=13;
abc=NULL;
cout << *abc <<endl;
return 0;
}
我也看到How can I use "watch" GDB?但它并没有帮助我很多。有人可以解释这个问题我facing.Below是当你加载程序到它没有被尚未运行调试器与我的GNU
[email protected]:~$ gdb a.out
GNU gdb (Ubuntu/Linaro 7.3-0ubuntu2) 7.3-2011.08
Copyright (C) 2011 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 "i686-linux-gnu".
For bug reporting instructions, please see:
<http://bugs.launchpad.net/gdb-linaro/>...
Reading symbols from /home/ritesh/a.out...done.
所以我应该运行它像(mdb)运行,我应该什么时候执行它? – Invictus 2012-04-19 18:54:47
是的,1)“break”7; 2)'run'(调试器停在main中); 3)'看m'; 4)'cont'(调试器将在'm = 11'后停止) – pwes 2012-04-19 18:56:16
完成我在break语句之后运行程序并保存变量的值班,并且非常感谢 – Invictus 2012-04-19 18:57:02