无法通过gdb设置观察点到本地矢量变量

时间:2012-05-02 07:05:10

标签: c++ gdb watchpoint

以下是我想设置代码的部分:

void *sync(void *ptr) {
  vector<short> gen = generate_sygnal();

我使用debug标志构建我的程序,这是我在gdb中所做的:

(gdb) break daemon.cxx:sync
break daemon.cxx:sync
Breakpoint 1 at 0x804d080: file /home/username/projects/armd/complex/daemon/daemon.cxx, line 160.
(gdb) watch gen
watch gen
No symbol "gen" in current context.
(gdb) run
run
Starting program: /home/username/projects/armd/complex/build/daemon/daemon 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/libthread_db.so.1".
2012/05/02 11:00:32 error: Cannot open configuration file /home/username/projects/armd/complex/build/daemon/armd.conf
[New Thread 0xb7fe7b40 (LWP 4329)]
2012/05/02 11:00:32 info: Listening on port 2000
/dev/ttyS0 port opened!
[New Thread 0xb77e6b40 (LWP 4330)]
[Switching to Thread 0xb77e6b40 (LWP 4330)]
Breakpoint 1, sync (ptr=0x8055108)
    at /home/username/projects/armd/complex/daemon/daemon.cxx:160
160 void *sync(void *ptr) {
(gdb) watch gen
watch gen
No symbol "gen" in current context.
(gdb) 

那么如何用gdb检查我的gen值?即使我需要完整的矢量值堆栈。

1 个答案:

答案 0 :(得分:1)

再向sync()行添加一行,这样变量实际上就在范围内(使用GDB的next命令)。