Variable not Showing in Debugger

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Arcticool

    Variable not Showing in Debugger

    Can anyone tell me why j never shows up in my locals window? 32 is
    printed to console so I know the assignment is working. I was under the
    impression that I could see everything as it happens by setting a
    breakpoint then F11 on through the code. Kind of disturbing that j never
    shows up, (regardless of where I set my breakpoint) as it makes me
    wonder what else I'm not seeing. Is there a 'show everything' debugger
    option or something I'm missing? BTW, I'm using the 'Express' version of
    Visual Studio.

    public class Tester
    {
    * static int j = 32;
    static void Main()
    * {
    Console.WriteLi ne(j);
    Time t1 = new Time( currentTime );
    t1.DisplayCurre ntTime();

    Time t2 = new Time( 2007, 9, 18, 11, 45 );
    t2.DisplayCurre ntTime();

    Time t3 = new Time();
    t3.DisplayCurre ntTime();
    }
    }

    //* = breakpoints

    Thanks in advance,

    Jack
  • Pavel Minaev

    #2
    Re: Variable not Showing in Debugger

    On Aug 13, 12:04 pm, Arcticool <arctic...@hotm ail.comwrote:
    Can anyone tell me why j never shows up in my locals window?
    ...
    public class Tester
    {
    * static int j = 32;
    Because it's not a local variable. Local variables are those declared
    within a method, and "j" here is a static field. You can type
    "Tester.j" in the Watch window to observe it.

    Comment

    • Peter Duniho

      #3
      Re: Variable not Showing in Debugger

      On Wed, 13 Aug 2008 01:04:35 -0700, Arcticool <arcticool@hotm ail.com>
      wrote:
      Can anyone tell me why j never shows up in my locals window?
      The static field j isn't a local variable.
      32 is printed to console so I know the assignment is working. I was
      under the impression that I could see everything as it happens by
      setting a breakpoint then F11 on through the code. Kind of disturbing
      that j never shows up,
      You might try the "Autos" window. It will only show the static field j
      when it's present in the previous and current line of code as you step
      through in the debugger. But at least you'll see it then. :)

      Pete

      Comment

      • =?Utf-8?B?U2ltb24gVGFtbWFu?=

        #4
        Re: Variable not Showing in Debugger

        It's worth noting that in some scenarios some values won't ever appear in the
        debugger, even in the watch window. I think it's either static readonly or
        consts in certain scenarios.

        "Peter Duniho" wrote:
        On Wed, 13 Aug 2008 01:04:35 -0700, Arcticool <arcticool@hotm ail.com>
        wrote:
        >
        Can anyone tell me why j never shows up in my locals window?
        >
        The static field j isn't a local variable.
        >
        32 is printed to console so I know the assignment is working. I was
        under the impression that I could see everything as it happens by
        setting a breakpoint then F11 on through the code. Kind of disturbing
        that j never shows up,
        >
        You might try the "Autos" window. It will only show the static field j
        when it's present in the previous and current line of code as you step
        through in the debugger. But at least you'll see it then. :)
        >
        Pete
        >

        Comment

        • Peter Duniho

          #5
          Re: Variable not Showing in Debugger

          On Wed, 13 Aug 2008 08:25:01 -0700, Simon Tamman
          <SimonTamman@di scussions.micro soft.comwrote:
          It's worth noting that in some scenarios some values won't ever appear
          in the
          debugger, even in the watch window. I think it's either static readonly
          or
          consts in certain scenarios.
          I don't have the complete enumeration. But I would say the general rule
          is probably that a variable won't show up when it's not really a
          variable. Certainly "const" would fall into that category, maybe "static
          readonly", and also variables that have been optimized out in a Release
          build. Maybe there are other examples too that I haven't thought of.

          Pete

          Comment

          • Arcticool

            #6
            Re: Variable not Showing in Debugger

            Peter Duniho wrote:
            On Wed, 13 Aug 2008 08:25:01 -0700, Simon Tamman
            <SimonTamman@di scussions.micro soft.comwrote:
            >
            >It's worth noting that in some scenarios some values won't ever appear
            >in the
            >debugger, even in the watch window. I think it's either static
            >readonly or
            >consts in certain scenarios.
            >
            I don't have the complete enumeration. But I would say the general rule
            is probably that a variable won't show up when it's not really a
            variable. Certainly "const" would fall into that category, maybe
            "static readonly", and also variables that have been optimized out in a
            Release build. Maybe there are other examples too that I haven't
            thought of.
            >
            Pete
            Hmm, I've looked everywhere that I can think of and I do not see an
            'Autos' window. I have Error List, Output, Locals, and Watch. In another
            pane I have Call Stack and Immediate. But no Autos.

            Also, maybe I'm missing something but it sure seems lame that the
            debugger won't show me what's going on automatically. After all isn't
            that its job? Having to type Tester.j in the watch window does work, but
            what if there are a ton of those, then I have to manually type them all
            (?) Just seems like a glaring omission of functionality to me. Can
            anyone think of a reason for this. I'm sure I must be missing something.

            Jack

            Comment

            • Peter Duniho

              #7
              Re: Variable not Showing in Debugger

              On Wed, 13 Aug 2008 13:08:50 -0700, Arcticool <arcticool@hotm ail.com>
              wrote:
              Hmm, I've looked everywhere that I can think of and I do not see an
              'Autos' window. I have Error List, Output, Locals, and Watch. In another
              pane I have Call Stack and Immediate. But no Autos.
              I don't have an Express version installed on any of my computers right
              now, but it would surprise me very much if that was one of the
              "retail-only" features.

              Are you sure you're looking at the "Debug/Window ->" menu when you're
              actually debugging a project. The "Autos" window is only available then.

              If all else fails, try typing Ctrl-D, followed immedately by A. That
              should show the window.
              Also, maybe I'm missing something but it sure seems lame that the
              debugger won't show me what's going on automatically.
              Your comment doesn't make any sense to me. The debugger has a variety of
              ways for you to monitor data automatically, including the "Autos" window.
              After all isn't that its job? Having to type Tester.j in the watch
              window does work, but what if there are a ton of those, then I have to
              manually type them all (?)
              If you feel that at every program statement, you have so many different
              variables that you need to keep an eye on it's actually problematic for
              you to configure the debugger to show you those variables, you probably
              have something wrong either with your program's design or your debugging
              technique.

              Pete

              Comment

              • Arcticool

                #8
                Re: Variable not Showing in Debugger

                Peter Duniho wrote:
                On Wed, 13 Aug 2008 13:08:50 -0700, Arcticool <arcticool@hotm ail.com>
                wrote:
                >
                >Hmm, I've looked everywhere that I can think of and I do not see an
                >'Autos' window. I have Error List, Output, Locals, and Watch. In
                >another pane I have Call Stack and Immediate. But no Autos.
                >
                I don't have an Express version installed on any of my computers right
                now, but it would surprise me very much if that was one of the
                "retail-only" features.
                >
                Are you sure you're looking at the "Debug/Window ->" menu when you're
                actually debugging a project. The "Autos" window is only available then.
                Yep, the Debug/Window only has Output, Locals, Watch, Immediate, and
                Call Stack, no Autos present.
                If all else fails, try typing Ctrl-D, followed immedately by A. That
                should show the window.
                No go. Maybe this is where the 'Express' version falls short and you get
                what you pay for...
                >Also, maybe I'm missing something but it sure seems lame that the
                >debugger won't show me what's going on automatically.
                >
                Your comment doesn't make any sense to me. The debugger has a variety
                of ways for you to monitor data automatically, including the "Autos"
                window.
                Unless it doesn't :)
                >After all isn't that its job? Having to type Tester.j in the watch
                >window does work, but what if there are a ton of those, then I have to
                >manually type them all (?)
                >
                If you feel that at every program statement, you have so many different
                variables that you need to keep an eye on it's actually problematic for
                you to configure the debugger to show you those variables, you probably
                have something wrong either with your program's design or your debugging
                technique.
                >
                Pete
                I just thought that the debugger could show everything that's happening
                in the code as you step through. If it is only selectively showing me
                information, I wonder what else I'm *not* seeing. Now I'm also wondering
                if 'Express' is as good of a learning tool as the other versions...

                Jack

                Comment

                • viepia@nospam.com

                  #9
                  Re: Variable not Showing in Debugger

                  In my installation VS Team System 2008 3.5 SP1 the auto Window shortcut is Ctrl+Alt+V,A.
                  If Express can't show the call stack that would make it unusable for me.


                  On Wed, 13 Aug 2008 16:34:37 -0700, Arcticool <arcticool@hotm ail.comwrote:
                  >Peter Duniho wrote:
                  >On Wed, 13 Aug 2008 13:08:50 -0700, Arcticool <arcticool@hotm ail.com>
                  >wrote:
                  >>
                  >>Hmm, I've looked everywhere that I can think of and I do not see an
                  >>'Autos' window. I have Error List, Output, Locals, and Watch. In
                  >>another pane I have Call Stack and Immediate. But no Autos.
                  >>
                  >I don't have an Express version installed on any of my computers right
                  >now, but it would surprise me very much if that was one of the
                  >"retail-only" features.
                  >>
                  >Are you sure you're looking at the "Debug/Window ->" menu when you're
                  >actually debugging a project. The "Autos" window is only available then.
                  >
                  >Yep, the Debug/Window only has Output, Locals, Watch, Immediate, and
                  >Call Stack, no Autos present.
                  >
                  >If all else fails, try typing Ctrl-D, followed immedately by A. That
                  >should show the window.
                  >
                  >No go. Maybe this is where the 'Express' version falls short and you get
                  >what you pay for...
                  >
                  >>Also, maybe I'm missing something but it sure seems lame that the
                  >>debugger won't show me what's going on automatically.
                  >>
                  >Your comment doesn't make any sense to me. The debugger has a variety
                  >of ways for you to monitor data automatically, including the "Autos"
                  >window.
                  >
                  >Unless it doesn't :)
                  >
                  >>After all isn't that its job? Having to type Tester.j in the watch
                  >>window does work, but what if there are a ton of those, then I have to
                  >>manually type them all (?)
                  >>
                  >If you feel that at every program statement, you have so many different
                  >variables that you need to keep an eye on it's actually problematic for
                  >you to configure the debugger to show you those variables, you probably
                  >have something wrong either with your program's design or your debugging
                  >technique.
                  >>
                  >Pete
                  >
                  >I just thought that the debugger could show everything that's happening
                  >in the code as you step through. If it is only selectively showing me
                  >information, I wonder what else I'm *not* seeing. Now I'm also wondering
                  >if 'Express' is as good of a learning tool as the other versions...
                  >
                  >Jack

                  Comment

                  • Peter Duniho

                    #10
                    Re: Variable not Showing in Debugger

                    On Wed, 13 Aug 2008 16:34:37 -0700, Arcticool <arcticool@hotm ail.com>
                    wrote:
                    [...]
                    I just thought that the debugger could show everything that's happening
                    in the code as you step through. If it is only selectively showing me
                    information, I wonder what else I'm *not* seeing.
                    Well, one other obvious thing missing from Express is the lack of threaded
                    debugging. That is, you can debug any thread in Express, but it has no UI
                    for switching your view from one thread to another.

                    Express is a limited version of Visual Studio. It stands to reason that
                    there will be things it doesn't show you.
                    Now I'm also wondering if 'Express' is as good of a learning tool as the
                    other versions...
                    If the Express version had all of the features that the retail versions
                    had, there wouldn't be much point in the retail versions, would there?
                    And surely the determining factor for what features make it into the
                    Express version and what features don't is not strictly "which ones
                    support the IDE as a learning tool?" That is, obviously given that some
                    features are missing in the Express version, some of the missing features
                    would be ones that are useful for learning.

                    In other words, I have no idea why you would expect that the free version
                    of Visual Studio be every bit as effective a "learning tool" as the retail
                    version, at least with respect to your apparent implication that features
                    in the IDE equate to it being a "learning tool" (personally, I think that
                    one of the things that may help the Express version be a good learning
                    tool is the relative simplicity, leaving out features that could confuse a
                    beginning programmer).

                    Now, all that said...I'm still surprised that it doesn't have the "Autos"
                    window. I've used the Express version in the past, and that's the sort of
                    feature that I'd think I'd notice if it were missing. But I guess I'll
                    take your word for it that that's one of the features that's been left out
                    of the Express version (I definitely don't care enough to install the
                    thing now just to check :p ).

                    But surely this is not a critical feature for being able to use the
                    debugger as a "learning tool". It's really only a matter of slight
                    inconvenience. It's not like the debugger won't let you see whatever
                    variables you want to see. You just need to be a bit more explicit about
                    it.

                    Pete

                    Comment

                    • Arcticool

                      #11
                      Re: Variable not Showing in Debugger

                      Peter Duniho wrote:
                      On Wed, 13 Aug 2008 16:34:37 -0700, Arcticool <arcticool@hotm ail.com>
                      wrote:
                      >
                      >[...]
                      >I just thought that the debugger could show everything that's
                      >happening in the code as you step through. If it is only selectively
                      >showing me information, I wonder what else I'm *not* seeing.
                      >
                      Well, one other obvious thing missing from Express is the lack of
                      threaded debugging. That is, you can debug any thread in Express, but
                      it has no UI for switching your view from one thread to another.
                      >
                      Express is a limited version of Visual Studio. It stands to reason that
                      there will be things it doesn't show you.
                      >
                      >Now I'm also wondering if 'Express' is as good of a learning tool as
                      >the other versions...
                      >
                      If the Express version had all of the features that the retail versions
                      had, there wouldn't be much point in the retail versions, would there?
                      And surely the determining factor for what features make it into the
                      Express version and what features don't is not strictly "which ones
                      support the IDE as a learning tool?" That is, obviously given that some
                      features are missing in the Express version, some of the missing
                      features would be ones that are useful for learning.
                      >
                      In other words, I have no idea why you would expect that the free
                      version of Visual Studio be every bit as effective a "learning tool" as
                      the retail version, at least with respect to your apparent implication
                      that features in the IDE equate to it being a "learning tool"
                      (personally, I think that one of the things that may help the Express
                      version be a good learning tool is the relative simplicity, leaving out
                      features that could confuse a beginning programmer).
                      >
                      Now, all that said...I'm still surprised that it doesn't have the
                      "Autos" window. I've used the Express version in the past, and that's
                      the sort of feature that I'd think I'd notice if it were missing. But I
                      guess I'll take your word for it that that's one of the features that's
                      been left out of the Express version (I definitely don't care enough to
                      install the thing now just to check :p ).
                      >
                      But surely this is not a critical feature for being able to use the
                      debugger as a "learning tool". It's really only a matter of slight
                      inconvenience. It's not like the debugger won't let you see whatever
                      variables you want to see. You just need to be a bit more explicit
                      about it.
                      >
                      Pete
                      Well free is free so I guess I can't complain, just a little surprised
                      this feature is missing. Apparently there is quite a bit more missing as
                      well:
                      Visual Studio dev tools & services make app development easy for any developer, on any platform & language. Develop with our code editor or IDE anywhere for free.



                      It looks like the 2005 Express was missing the Watch window, but had
                      Autos, now in the 2008 edition its reversed.
                      Anyway, the good news is that items added to the Watch window are saved
                      with the project. If I close VS then re-open the Watched items
                      previously added are still there.

                      Jack

                      Comment

                      • Pavel Minaev

                        #12
                        Re: Variable not Showing in Debugger

                        On Aug 14, 3:34 am, Arcticool <arctic...@hotm ail.comwrote:
                        I just thought that the debugger could show everything that's happening
                        in the code as you step through.
                        For one thing, the code sample you've posted doesn't even use the
                        variable you're interested in, so why should the debugger bother
                        showing it? I doubt it would be displayed even if you could enable the
                        "Autos" window. If you at least had an instance of your class, and
                        called a method on it, then "this" would've show in "Locals", and you
                        could expand it and see the static variables in a separate node
                        under it.

                        And, of course, the debugger cannot just show you all values of all
                        static variables in a program at all times - for anything above
                        HelloWorld, it would quickly become unwieldy.

                        Comment

                        • Arcticool

                          #13
                          Re: Variable not Showing in Debugger

                          Pavel Minaev wrote:
                          On Aug 14, 3:34 am, Arcticool <arctic...@hotm ail.comwrote:
                          >I just thought that the debugger could show everything that's happening
                          >in the code as you step through.
                          >
                          For one thing, the code sample you've posted doesn't even use the
                          variable you're interested in, so why should the debugger bother
                          showing it? I doubt it would be displayed even if you could enable the
                          "Autos" window. If you at least had an instance of your class, and
                          called a method on it, then "this" would've show in "Locals", and you
                          could expand it and see the static variables in a separate node
                          under it.
                          When you say the variable J is not 'used' you mean the variable isn't
                          modified? J is assigned to 32. Also it is used on Console.Writeli ne(J);
                          So 'stuff' is happening with J, but not much I guess...
                          And, of course, the debugger cannot just show you all values of all
                          static variables in a program at all times - for anything above
                          HelloWorld, it would quickly become unwieldy.
                          I don't really want to see everything at once, just what is happening as
                          it happens. If something changes ( J gets assigned to 32 or J is written
                          out ) I'd like the debugger to show me what's happening as I hit F11.

                          But I think the real issue is that I'm using the Express version of VS
                          which has no Autos window, which would have shown me these things. I've
                          done a bit of searching however and haven't seen anything better than VS
                          Express (not Windows based anyway) so I'm wondering now if I would be
                          better off with an older (full retail) of VS 2003? With the patches and
                          updates will I be better off or worse?
                          Thanks,

                          Jack

                          Comment

                          Working...