English 中文(简体)
GDB不为我工作
原标题:setting Watch in GDB not working for me
  • 时间:2012-04-19 18:38:03
  •  标签:
  • gdb
  • watch

I am facing problem While using watch in gdb . I am trying to keep a watch on variable m in my code . But for some reason i am getting the following message no symbol m in current context. I have kept a break point at line 7 so that scope of m is known .

    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;
    }

我也看到。 我如何使用“监视”的银? 但是,这无助于我。 一个人能够解释这一问题,即它正面临的问题。 以下是与我方联会有关的资料

    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.
最佳回答

当你把方案装上夸张时,它还没有运行。 但是,你试图看到一个文号,该编号将开始在职能中“有效”——<代码>main()功能——并将在你从该职能返回时“消失”。

例如,在本法典中

void func() {
  int b = 1;
  ++b;
  cout << b << endl;
}

int main() {
  int a = 1;
  func();
  cout << a << endl;
}

在开始执行一项方案之前,可在<条码>a上查询,并在执行项目进入<条码>/条码>之前对<条码>b的价值进行观察。

问题回答

暂无回答




相关问题
tell gdb to disassemble "unknown" code

is it possible to configure gdb in order to debug assembly code when there are no debug symbols or no sources available ? I mean showing assembly instruction by assembly instruction when performing a ...

C++ Netbeans debugging issues

I installed netbeans6.7.1 ide for c/c++ also i have mingw/msys cygwin installed and i have given C:Msysin as environment variable path.It has gdb7 version.However wheni run dbugging thru netbeans ...

setting strings in gdb

c++: int main() { string a = "a"; ... ... } when i debug in gdb: (gdb) set var a = "ok" Invalid cast I run the program and pause at a break point after string a has been ...

How to debug programms written in fasm under linux using gdb?

I wrote simple "hello, world" in fasm, and its works, but how i can generate debug info for gdb and edb (Evan s Debugger)? Fasm compiler could only produce debugging symbols in its specific format - "...

How can I display Unicode strings while debugging on linux?

I have been working for some years now as C++ Developer using MS Visual Studio as working platform. Since I privately prefer to use linux, I recently took the chance to move my working environment to ...

Continue to debug after failed assertion on Linux?

When an assertion fails with Visual C++ on Windows, the debugger stops, displays the message, and then lets you continue (or, if no debugging session is running, offers to launch visual studio for you)...

热门标签