【发布时间】:2012-04-20 02:50:54
【问题描述】:
在 gdb 中使用 watch 时遇到问题。我试图保持一个
在我的代码中观察变量m。但由于某种原因,我收到以下消息
no symbol m in current context。我在第 7 行保留了一个断点,以便知道 m 的范围。
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?,但对我帮助不大。谁能解释我面临的这个问题。以下是与我的 GNU 相关的信息
ritesh@ubuntu:~$ 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.
【问题讨论】: