Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7832187
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T12:04:57+00:00 2026-06-02T12:04:57+00:00

I am facing problem While using watch in gdb . I am trying to

  • 0

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

Below is my program :-

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

I have also seen How can I use "watch" GDB? But it did not help me much . Can someone explain this problem i am facing.Below are information related to my 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.
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T12:04:59+00:00Added an answer on June 2, 2026 at 12:04 pm

    When you load your program into a debugger it is not being run yet. However, you try to watch a symbol, which will start to “live” in a function — main() function — and will “disappear” when you return from the function.

    For example, in this code

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

    you can’t set a watch of the value of a before start executing a program, and a watch on the value of b until the execution enters func().

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

While using some regex in C#, I'm facing the following problem : Consider this
I am facing some problem while returning data from web services. I am using
Hi guys I am using entity framework, I am facing some problem while checking
I get an orientation problem while using the following to code to display a
I'm facing a typical problem while am getting the Unique list using XSLT 1.0.
I am new to Android development and facing a problem while using AndEngine. I
Am facing a problem, while creating components through TOM API using .NET/COM Interop. Actual
I am learning OpenCV using Learning OpenCV book. One problem I am facing while
I am facing a problem while using Russian locale, Time Zone part of the
While using method Arrays.deepToString(Object [] a) I am facing this problem which I can

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.