Author Topic: breakpoints not working  (Read 9980 times)

Offline bootstrap

  • Multiple posting newcomer
  • *
  • Posts: 64
breakpoints not working
« on: January 17, 2009, 11:59:10 am »
I just installed CodeBlocks on linux (ubuntu 8.04) and got my application to compile.  Unfortunately, when I run the code it gets a segment violation in the strlen() function for some reason.  I'm sure this will be easy to debug, but now I find that CodeBlocks is ignoring the breakpoints I set in the code.  What gives?

I set the -g compiler option, and am running the debug (not release) version of the code.  I'm sure I must be missing something totally trivial, but so far it eludes me.  Okay, what am I missing?  Thanks in advance for your help.

Offline jens

  • Administrator
  • Lives here!
  • *****
  • Posts: 7253
    • Jens' unofficial debian-repository for the Code::Blocks - IDE
Re: breakpoints not working
« Reply #1 on: January 17, 2009, 12:10:24 pm »
Please change "Settings -> Compiler and debugger... -> Global compiler settings -> <the comiler you use> -> Other settings (rightmost tab) -> Compiler logging" to "Full command line" and post the build log.
In addition you can turn on the debuggers debug log: just check "Settings -> Compiler and debugger... -> Debugger settings -> Display debugger's log".

Offline bootstrap

  • Multiple posting newcomer
  • *
  • Posts: 64
re: breakpoints not working
« Reply #2 on: January 17, 2009, 01:25:44 pm »
Well, I will do what you ask if you still need it for some reason, but I suspect you won't.

I noticed that "somehow" a couple of my .h header and .cpp source files were owned by "root" instead of my username.  I am not sure how that happened, but apparently I launched CodeBlocks from a root terminal window before the session that had problems.

For your information... for future reference when people have similar problems... I did a few quick tests and found that breakpoints do not work (for me anyway) if any of the files in the project belong to anyone except the user who launched CodeBlocks.  I find this a bit strange, especially in the case where the root super-user launches CodeBlocks, but cannot get breakpoints to work because some of the files do not belong to "root"!!!  I am a bit rusty on Linux, but I did not expect this - I though "root" could pretty much "do anything", and therefore any application it launched would also be able to pretty much "do anything".  Thus, I am surprised to find this problem in this particular situation.

Frankly, I am not sure why CodeBlocks has a problem in either direction!  If it can read all the .h and .cpp files in a project to display in the IDE window (which it does for me in every situation), and can compile an executable that runs (which it does for me in every situation), I do not quite understand why it cannot set breakpoints in the executable file that *it* (CodeBlocks) created.

Anyway, that was my problem, apparently, because I can hit breakpoints now.  But I might suggest you have CodeBlocks read the owner of all the project files, and refuse to compile or execute or debug (or something) if any of those files belong to some other user.  That would prevent driving poor programmers crazy when the accidentally do something stupid like I did.

PS:  So for CodeBlocks is looking good to me.  I ported my 3D game/simulation engine to Linux on eclipse, but eclipse has been driving me totally freaking *nuts* with its peculiarities and slower than snot performance.  The final straw was their refusal to add (after months of saying they would) an option to the editor to disable automatic indenting (which was driving me crazy!!!).  Anyhow, I have high hopes for CodeBlocks.  Oh, but I just noticed something.  I am at a breakpoint right now, and I cannot seem to find a way to see the value of variables.  Pausing the mouse cursor over the variable in the code window just displays the data-type of the variable, not the value, and I cannot find any "variables window".  Am I missing something?  Or is this very fundamental capability "missing in action"?

Offline jens

  • Administrator
  • Lives here!
  • *****
  • Posts: 7253
    • Jens' unofficial debian-repository for the Code::Blocks - IDE
Re: re: breakpoints not working
« Reply #3 on: January 17, 2009, 02:43:32 pm »
Pausing the mouse cursor over the variable in the code window just displays the data-type of the variable, not the value, and I cannot find any "variables window". 

"Settings -> Compiler and debugger... -> Debugger settings -> Evaluate expression under cursor"
"Debug -> Debugging windows -> Watches"

Offline bootstrap

  • Multiple posting newcomer
  • *
  • Posts: 64
Re: breakpoints not working
« Reply #4 on: January 17, 2009, 03:29:10 pm »
Thanks!!!  Looking good so far...

Offline jens

  • Administrator
  • Lives here!
  • *****
  • Posts: 7253
    • Jens' unofficial debian-repository for the Code::Blocks - IDE
Re: re: breakpoints not working
« Reply #5 on: January 17, 2009, 10:07:31 pm »
I noticed that "somehow" a couple of my .h header and .cpp source files were owned by "root" instead of my username.  I am not sure how that happened, but apparently I launched CodeBlocks from a root terminal window before the session that had problems.

For your information... for future reference when people have similar problems... I did a few quick tests and found that breakpoints do not work (for me anyway) if any of the files in the project belong to anyone except the user who launched CodeBlocks.  I find this a bit strange, especially in the case where the root super-user launches CodeBlocks, but cannot get breakpoints to work because some of the files do not belong to "root"!!!

I can set breakpoints as root in files not belonging me, and as no-root user in root's files, without any problems.

About the other problem, wrong ownership and/or access rights: which version of C::B do you use ?

Offline bootstrap

  • Multiple posting newcomer
  • *
  • Posts: 64
re: breakpoints not working
« Reply #6 on: January 17, 2009, 11:56:50 pm »
I have the 20080228 binary build.  I guess my Linux skills and expertise are just too rusty, because repeated attempts to install the most recent "nightly build" failed.  I found supposedly complete instructions a couple places, but could not make them work.  I did notice, however, they are pretty old instructions that refer to previous versions of ubuntu... and mine isn't even the most recent (mine is ubuntu 8.04).

Which raises a question, can us wimps get perhaps 2 to 4 binary builds per year (or even one)?  Or is the policy "hey fools, learn how to install the nightly builds and stop complaining?".  If so, maybe I can find someone with ubuntu 8.04 to lead me through real slow and careful like.  Any takers?  Just don't expect me to know anything about installing deb packages!

Offline jens

  • Administrator
  • Lives here!
  • *****
  • Posts: 7253
    • Jens' unofficial debian-repository for the Code::Blocks - IDE
Re: breakpoints not working
« Reply #7 on: January 18, 2009, 01:15:27 am »
There was a bug leading to wrong file-permissions fixed in svn r5104 (the 8.02 release is older) that may also cause the wrong user used for a saved file.

If you use ubuntu, you should be able to use my repo (see signature) via synaptic, or whatever (apt-based) package-manager you prefer.

There are also repos especially build for ubuntu, just look in the actual threads anouncing the new nightlies in the Nightly builds forum .