Author Topic: Show local variables in the debugger  (Read 37643 times)

Offline alexchen

  • Multiple posting newcomer
  • *
  • Posts: 84
Show local variables in the debugger
« on: July 30, 2013, 12:22:41 am »
How do I get the debugger to show local variables?  I can only find a debugger 'watch' window that allows me to enter a variable in a function to see its content.  But I cannot find any other way to have the debugger automatically fills in all local variables in a function, or the content of 'this' in a class method when execution steps into the function.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Show local variables in the debugger
« Reply #1 on: July 30, 2013, 12:57:42 am »
You can't find it because it is not available at the moment...
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline alexchen

  • Multiple posting newcomer
  • *
  • Posts: 84
Re: Show local variables in the debugger
« Reply #2 on: July 30, 2013, 06:18:25 am »
Is there is timetable when this functionality will be available?  This is a very important feature supported by Windows Visual Studio, MacOS Xcode, and Eclipse C++.  It makes life so much easier to debug at source code level.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Show local variables in the debugger
« Reply #3 on: July 30, 2013, 07:46:09 am »
Is there is timetable when this functionality will be available?  This is a very important feature supported by Windows Visual Studio, MacOS Xcode, and Eclipse C++.  It makes life so much easier to debug at source code level.
I think I posted a patch that restores this functionality some times back to this forums. You could apply it yourself.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Show local variables in the debugger
« Reply #4 on: July 30, 2013, 08:46:43 am »
Is there is timetable when this functionality will be available?  This is a very important feature supported by Windows Visual Studio, MacOS Xcode, and Eclipse C++.  It makes life so much easier to debug at source code level.
No
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline alexchen

  • Multiple posting newcomer
  • *
  • Posts: 84
Re: Show local variables in the debugger
« Reply #5 on: July 30, 2013, 06:19:59 pm »
Is there is timetable when this functionality will be available?  This is a very important feature supported by Windows Visual Studio, MacOS Xcode, and Eclipse C++.  It makes life so much easier to debug at source code level.
I think I posted a patch that restores this functionality some times back to this forums. You could apply it yourself.
Where can I find the patch?  I assume it requires a rebuild of Codeblocks from source?

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Show local variables in the debugger
« Reply #6 on: August 01, 2013, 08:56:33 am »
Where can I find the patch?  I assume it requires a rebuild of Codeblocks from source?
For the original version, please search the forums.

However, I believe meanwhile its outdated as we continued work in trunk. So I need to update it anyways. So please stay tuned... I'll post here.

And yes, it requires you to self-compile C::B which is easy.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline alexchen

  • Multiple posting newcomer
  • *
  • Posts: 84
Re: Show local variables in the debugger
« Reply #7 on: August 02, 2013, 09:08:55 pm »
Thank you sooooo much!  This will be a life saver to anyone who is serious in source code level debugging.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Show local variables in the debugger
« Reply #8 on: August 02, 2013, 09:16:28 pm »
This will be a life saver to anyone who is serious in source code level debugging.
I doubt it, in the current implementation this will cause only slowness and random crashes...
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline alexchen

  • Multiple posting newcomer
  • *
  • Posts: 84
Re: Show local variables in the debugger
« Reply #9 on: August 02, 2013, 10:09:04 pm »
At least we have something to work on.  Bugs can be fixed, but lack of functionality needed for a debugger to be useful will cripple the IDE and render it an editor and code compiler, not a debugger.  I was frustrated by lack of local variable display window I ended up using gdb directly.  Although it is not better but at lease I can go very low level and get the work done.

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: Show local variables in the debugger
« Reply #10 on: August 02, 2013, 11:02:48 pm »
At least we have something to work on.  Bugs can be fixed, but lack of functionality needed for a debugger to be useful will cripple the IDE and render it an editor and code compiler, not a debugger.  I was frustrated by lack of local variable display window I ended up using gdb directly.  Although it is not better but at lease I can go very low level and get the work done.

If I remember correctly the  crashes came from gdb, if it tries to access not initialized variables.
If this in not fixed in gdb sources, there is no way for the IDE to fix this or even work around it easily.

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5501
Re: Show local variables in the debugger
« Reply #11 on: August 03, 2013, 09:45:37 am »
Quote
If I remember correctly the  crashes came from gdb, if it tries to access not initialized variables.
If this in not fixed in gdb sources, there is no way for the IDE to fix this or even work around it easily.

If this really is the case, then we should bring the feature back. People might say, hey CB crashes, while it was actually GDB, but then that same remark goes for eg Eclipse and other IDE's.

Next to that, from a programmers view, not initializing your variables, all hell should go loose upon you ;-)

As said, if that is the cause, the good programmers should not be punished.


I will try the patch when updated too, do we have an example code on how to reproduce such crash, will ask a colleague who uses eclipse to reproduce the crash too.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Show local variables in the debugger
« Reply #12 on: August 03, 2013, 09:48:55 am »
If this really is the case, then we should bring the feature back. People might say, hey CB crashes, while it was actually GDB, but then that same remark goes for eg Eclipse and other IDE's.
This is not the case.

Next to that, from a programmers view, not initializing your variables, all hell should go loose upon you ;-)
std::vector is always initialized, but after the constructor is called. If you inspect it before the constructor it is not.

Next to that, from a programmers view, not initializing your variables, all hell should go
I will try the patch when updated too, do we have an example code on how to reproduce such crash, will ask a colleague who uses eclipse to reproduce the crash too.
Won't happen in Eclipse, they use GDB/mi and probably aren't evaluating all elements, but have limits.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5927
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Show local variables in the debugger
« Reply #13 on: August 03, 2013, 10:39:48 am »
The bug report and my patch is posted here: GDB crash under Windows, I don't have GDB crash now.  :), but GDB devs seems are not interested to fix bugs under Windows. :(
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5501
Re: Show local variables in the debugger
« Reply #14 on: August 03, 2013, 11:37:44 am »
it only occurs on windows ? or also on linux ?