1
gdbでwatch
を使用中に問題が発生しました。私は を変数m
で私のコードで監視しています。しかし何らかの理由で私は次のメッセージを受け取っています no symbol m in current context
。私はmの範囲がわかるように7行目にブレークポイントを置いています。以下は設定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?を見てきました。しかし、それは非常に私を助けていませんでした。誰かがあなたのプログラムがまだ実行されていないデバッガにロードすると、私の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
はい、1) 'break' 7; 2) '実行'(デバッガはメインで停止する); 3)「時計m」。 4) 'cont'(デバッガは' m = 11'の後に停止します) – pwes
break文の後にプログラムを実行し、変数の監視を続けて成功しました – Invictus