Author Topic: Debugging on Linux?  (Read 8500 times)

agent86

  • Guest
Debugging on Linux?
« on: November 24, 2006, 04:47:45 pm »
For many months now I have been tracking CodeBlocks' development.  I like almost everything about it, but I still can't use it for the following reason:  Debugging doesn't seem to work on my Linux systems.  Linux systems being 2 versions of Ubuntu, Debian Etch, and Fedora Core 6.  On Ubuntu I used Gnome, on the others its KDE.  The symptom is the same on all. 

First, I download the head of the svn repository, build and install CodeBlocks.  My installation is done to a directory that I own, so I don't need "root" to install. (I set the prefix= appropriately when configuring)

Build a simple C or C++ program with GCC including the -g option for debugging symbols.  Builds fine.

Go to Debug menu and say Start.  Some lines in the console output say that the debugger has started and the menu items for next, etc. are enabled.   Nothing happens in the edit window.  I would expect a highlighted line somewhere near the beginning of main().

Clicking on "Next Line" button in the toolbar or selecting that in the menu produces no output anywhere.  All I can do is select or click on "Continue" and the program terminates "normally", and the debugger ends.

Because of this situation, I currently use jEdit to write code, commandline and makefiles to build, and kdbg (a debugger using the KDE desktop) to debug it. Sometimes I use Eclipse for larger projects.  I'd really like to use CodeBlocks, but I want that debugging ability; it's how I verify that the code is doing what I want.

This issue was mentioned somewhere around svn version 1940, I believe.  From what I read, it sounded like it would be addressed soon.  So every once in a while, I update my code from the repository, rebuild Codeblocks and check debugging.  Still the same.  Its been a long time now so this time I thought I'd write and see if someone knows the story.  Surely somebody uses CodeBlocks and does debugging on Linux successfully.   Am I doing something wrong or am I not doing something I should?







Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4315
    • Code::Blocks IDE
Re: Debugging on Linux?
« Reply #1 on: November 24, 2006, 05:43:16 pm »
Quote
Am I doing something wrong or am I not doing something I should?

You 're not doing something you should: give us details about your project or (even better) provide a step-by-step procedure for reproducing this using a minimal sample :).
All I can say for now (until you provide more info) is that debugging works in linux, contrary to what you say.
Besides, I debug C::B in linux using C::B itself ;). And keep in mind that C::B is a complex project, with a mix of static/dynamic libraries and executables. Still, I 'm able to debug it just fine.
Be patient!
This bug will be fixed soon...

Offline feisal

  • Single posting newcomer
  • *
  • Posts: 5
Re: Debugging on Linux?
« Reply #2 on: November 24, 2006, 06:56:00 pm »
Stupid question?  Did you set a breakpoint?

agent86

  • Guest
Re: Debugging on Linux?
« Reply #3 on: November 24, 2006, 09:10:06 pm »
It's nice to hear that it can be done.  I guess that somewhere I goofed.  Here is the scenario...

Checked out svn version 3256

set up wxGTK wx-config & wxwin.m4

./bootstrap
./configure --prefix=/d/linux/programs/cb --enable-contrib
I own /d

In this current case, Fedora Core 6, wxGTK 2.6.3, gcc 4.1.1 Linux/ANSI

make
make install

All seems to complete nicely.  This is true of all 3+ distros I have used.

Start it up.
Get the opening banner.

3 error dialogs in sequence...
Failed to display HTML document in ISO-8859-1 encoding 
This has always happened.

Tip of the Day

Create a New Project (from the Welcome screen)

Pick any directory, select C++ and take the template offered...
#include <iostream>

int main()
{
   std::cout << "Hello world!" << std::endl;
   return 0;
}

At this point, I can open files, edit, save, close...All the things that you would expect.

Build, then
Debug->Start

Console output
--------------------------
Building to ensure sources are up-to-date
Build succeeded
Selecting target: Debug
Adding source dir: /d/workspace/misc/proj/
Adding source dir: /d/workspace/misc/proj/
Adding file: ./proj
Starting debugger: done
Registered new type: wxString
Registered new type: STL String
Registered new type: STL Vector
Setting breakpoints
Debugger name and version: GNU gdb Red Hat Linux (6.5-13.fc6rh)
------------------------------------------

At this point, select Next Line or F7 key => nothing.

Select Step Out or Continue and something happens in the console output.  The following is added.
---------------------------------------------------
Continuing...
No line 10 in file "main.cpp".
Program exited normally.
Debugger finished with status 0
------------------------------------------------

Didn't get to debug anything.


agent86

  • Guest
Re: Debugging on Linux?
« Reply #4 on: November 24, 2006, 09:12:23 pm »
re: stupid question.

Yes and it blows right by it.  The breakpoint is shown in the "breakpoints" window but Run just ignores it.

I rebuilt and re-installed and the only new thing is that "run to cursor" seems to work, then I can F7 my way thru the program.


Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4315
    • Code::Blocks IDE
Re: Debugging on Linux?
« Reply #5 on: November 24, 2006, 09:25:12 pm »
Have a read please.
Be patient!
This bug will be fixed soon...

agent86

  • Guest
Re: Debugging on Linux?
« Reply #6 on: November 24, 2006, 09:56:13 pm »
Yes, I can set breakpoints and I know about -g.  The file built with CodeBlocks debugs just fine with kdbg.  The debugging with CodeBlocks is intermittent.  The note above about "run to cursor" working...well sometimes it does, sometimes it doesnt.  Breakpoints never do.

It must be something with my build or wxGTK configuration.  The same thing has happened with ubuntu 5.10, 6.06, Debian Etch, and now FC6.  Different clean distros.  Default GCCs, libs, etc.  I installed wxGTK in its own directory in a place that I own and have built several apps using it (not with CodeBlocks).

After the new build of CodeBlocks, when I fired it up, it went looking into system space for the welcome/start-up screen, images, etc. It couldn't find anything there  in  /usr/loca/share/codeblocks directory, because all that stuff was where it should have been, in /d/linux/programs/cb/share/codeblocks where I set the prefix= to during configure after a make clean.  Why would it decide to look somewhere else all of a sudden? 

And to further annoy, now when I restart CodeBlocks, it asks again for the default compiler.  When I click on GCC, the dialog freezes and I have to kill the process.

It really should not be this difficult.  Something is just hosed.  If I must, I'll go back to eclipse.  Maybe try again in a year or so...

Thanks anyway


Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4315
    • Code::Blocks IDE
Re: Debugging on Linux?
« Reply #7 on: November 24, 2006, 10:17:07 pm »
Quote
After the new build of CodeBlocks, when I fired it up, it went looking into system space for the welcome/start-up screen, images, etc. It couldn't find anything there  in  /usr/loca/share/codeblocks directory, because all that stuff was where it should have been, in /d/linux/programs/cb/share/codeblocks where I set the prefix= to during configure after a make clean.  Why would it decide to look somewhere else all of a sudden?

It's a bug which appeared the last couple of days. I will commit the fix for it in a while.

Quote
It really should not be this difficult.  Something is just hosed.

It usually isn't difficult.

Quote
If I must, I'll go back to eclipse.

If you must, then please do so.
Be patient!
This bug will be fixed soon...

agent86

  • Guest
Re: Debugging on Linux?
« Reply #8 on: November 27, 2006, 08:25:07 am »
I found the problem.  I wrote a nice long description but when I pressed on Post it all disappeared.  So the short form is:

If a breakpoint is placed at the first executable statement of  main(), then it is not properly placed into the executable (my assumption) and it is thus ignored.  (That is where I put the breakpoints to see if degugging worked.  It didn't...there).

I'm happy now.

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4315
    • Code::Blocks IDE
Re: Debugging on Linux?
« Reply #9 on: November 27, 2006, 08:49:55 am »
Quote
I'm happy now.

I 'm glad you sorted it out :).
Be patient!
This bug will be fixed soon...