gdb条件断点,找不到字符串全局变量的符号?

时间:2016-10-24 09:42:09

标签: c++ string gdb global symbols

我有一个简短的计划:

#include<string>
using namespace std;
int i=0;
string s="a";
void f()
{
  ++i;//I wish to break here based on the value of "s"
}
int main()
{
  f();
  s+="b";
  f();
  s+="c";
  f();
  s+="d";
  f();
  return 0;
}

我编译并运行,打破主要&#39;,输入程序,并尝试设置另一个点&#34; f&#34;:

(gdb) b main
Breakpoint 1 at 0x4009c0: file 1.cpp, line 11.
(gdb) r
Starting program: /home/dev/a.out 

Breakpoint 1, main () at 1.cpp:11
11    f();
(gdb) n
12    s+="b";
(gdb) b 6 if strcmp(s.c_str(),"abc")==0
No symbol "s" in current context.

如果失败了,但作为&#34; s&#34;它是一个全局变量,它应该被各种背景所看到,对吗?

为什么gdb说没有符号&#34; s&#34;?

0 个答案:

没有答案