Author Topic: GDB problem (yes, i've used the search)  (Read 12344 times)

Offline astorga

  • Multiple posting newcomer
  • *
  • Posts: 14
GDB problem (yes, i've used the search)
« on: July 18, 2012, 04:20:30 pm »
I'm having a VERY strange problem with C::B and GDB.

I'm trying to set a breakpoint to a very simple program (just the auto-generated code from project template):

Code: [Select]
#include <stdio.h>
#include <stdlib.h>

int main()
{
    printf("Hello world!\n");
    return 0;
}

I put a breakpoint in "printf" line and start debug, it doesn't stop at breakpoint.

here's the full GDB log:

Code: [Select]
PATH=.;C:\Program Files\CodeBlocks\MinGW\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\Efl\bin;C:\Program Files\doxygen\bin;C:\Program Files\GtkSharp\2.12\bin;C:\PROGRA~1\PICC;C:\Program Files\QuickTime\QTSystem\;C:\Program Files\TortoiseSVN\bin;C:\Program Files\Microsoft Visual Studio\Common\Tools\WinNT;C:\Program Files\Microsoft Visual Studio\Common\MSDev98\Bin;C:\Program Files\Microsoft Visual Studio\Common\Tools;C:\Program Files\Microsoft Visual Studio\VC98\bin;C:\Dev-Cpp\bin
Command-line: C:\Program Files\CodeBlocks\MinGW\bin\gdb.exe -nx -fullname  -quiet -args bin/Debug/wordwrap.exe
Working dir : C:\prjs\wordwrap\
> set prompt >>>>>>cb_gdb:
(gdb) >>>>>>cb_gdb:
> show version
GNU gdb 6.8
Copyright (C) 2008 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-pc-mingw32".
>>>>>>cb_gdb:
> set confirm off
>>>>>>cb_gdb:
> set width 0
>>>>>>cb_gdb:
> set height 0
>>>>>>cb_gdb:
> set breakpoint pending on
>>>>>>cb_gdb:
> set print asm-demangle on
>>>>>>cb_gdb:
> set unwindonsignal on
>>>>>>cb_gdb:
> set debugevents on
>>>>>>cb_gdb:
> set new-console on
>>>>>>cb_gdb:
> set disassembly-flavor att
>>>>>>cb_gdb:
> catch throw
Function "__cxa_throw" not defined in loaded symbols.
>>>>>>cb_gdb:
> source C:\Program Files\CodeBlocks\share\codeblocks/scripts/stl-views-1.0.3.gdb
>>>>>>cb_gdb:
> directory C:/prjs/wordwrap/
>>>>>>cb_gdb:
> break "C:/prjs/wordwrap/main.c:6"
No source file named C:/prjs/wordwrap/main.c in loaded symbols.
Breakpoint 1 ("C:/prjs/wordwrap/main.c:6) pending.
>>>>>>cb_gdb:
> run
gdb: win32_init_thread_list
[New thread 2268.0x450]
Program exited normally.
>>>>>>cb_gdb:
> set debugevents off
>>>>>>cb_gdb:
> quit

Yes, project is with -g flag marked and with "debug" chosen as build target.
Yes, "Use Full Paths for source files (GDB Workaround)" is marked (tried with it unmarked, no difference)

I'm using release 10.05 installed with mingw, Win xp sp3

Last thing that I tried was a uninstall, reboot, install, test... no success.  :(

The most weird thing is that i already succeeded to use GDB before...

Any idea?

zabzonk

  • Guest
Re: GDB problem (yes, i've used the search)
« Reply #1 on: July 18, 2012, 04:39:39 pm »
This:

No source file named C:/prjs/wordwrap/main.c in loaded symbols.

is the message you get if you try to debug an executable that doesn't contain debug info. Check in Project|Build Options that you have "Produce debugging symbols" checked, and that you are not trying to debug a release build.


Offline astorga

  • Multiple posting newcomer
  • *
  • Posts: 14
Re: GDB problem (yes, i've used the search)
« Reply #2 on: July 18, 2012, 04:44:48 pm »
This:

No source file named C:/prjs/wordwrap/main.c in loaded symbols.

is the message you get if you try to debug an executable that doesn't contain debug info. Check in Project|Build Options that you have "Produce debugging symbols" checked, and that you are not trying to debug a release build.

Quote
Yes, project is with -g flag marked and with "debug" chosen as build target.
-g = "Produce debugging symbols"
Double-checked this, it is marked... still nothing :(

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 12810
    • Travis build status
Re: GDB problem (yes, i've used the search)
« Reply #3 on: July 18, 2012, 04:46:18 pm »
http://wiki.codeblocks.org/index.php?title=Debugging_with_Code::Blocks

There is another magic flag used for stripping the symbols from the executables (-s).
(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 astorga

  • Multiple posting newcomer
  • *
  • Posts: 14
Re: GDB problem (yes, i've used the search)
« Reply #4 on: July 18, 2012, 04:49:00 pm »
http://wiki.codeblocks.org/index.php?title=Debugging_with_Code::Blocks

There is another magic flag used for stripping the symbols from the executables (-s).
Checked now, was already unticked...

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 12810
    • Travis build status
Re: GDB problem (yes, i've used the search)
« Reply #5 on: July 18, 2012, 04:51:52 pm »
(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 astorga

  • Multiple posting newcomer
  • *
  • Posts: 14
Re: GDB problem (yes, i've used the search)
« Reply #6 on: July 18, 2012, 04:57:21 pm »
Have you checked this in you full build log?

See here how to enable it: http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28errors%29#Q:_How_do_I_troubleshoot_a_compiler_problem.3F

here's the full build log:
Code: [Select]
-------------- Build: Debug in wordwrap ---------------

mingw32-gcc.exe  -IC:/prjs/wordwrap -c main.c -o obj/Debug/main.o
mingw32-g++.exe  -o bin/Debug/wordwrap.exe obj/Debug/main.o   
Output size is 24,54 KB
Process terminated with status 0 (0 minutes, 7 seconds)
0 errors, 0 warnings
 

Should the flag appear here? Why is it not appearing?

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 12810
    • Travis build status
Re: GDB problem (yes, i've used the search)
« Reply #7 on: July 18, 2012, 05:03:50 pm »
If you have set it, but you should verify that the policy of the target is correct.
(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 astorga

  • Multiple posting newcomer
  • *
  • Posts: 14
Re: GDB problem (yes, i've used the search)
« Reply #8 on: July 18, 2012, 05:19:21 pm »
If you have set it, but you should verify that the policy of the target is correct.
It is. Here's a screenshot: http://img515.imageshack.us/img515/4171/problemey.jpg

edit: no, there aren't two instances running. Just an image edit problem :P

Offline astorga

  • Multiple posting newcomer
  • *
  • Posts: 14
Re: GDB problem (yes, i've used the search)
« Reply #9 on: July 23, 2012, 04:47:59 pm »
Anyone?  :(

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9597
Re: GDB problem (yes, i've used the search)
« Reply #10 on: July 23, 2012, 05:23:53 pm »
Anyone?  :(
Provide a sample project to reproduce.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline astorga

  • Multiple posting newcomer
  • *
  • Posts: 14
Re: GDB problem (yes, i've used the search)
« Reply #11 on: July 23, 2012, 05:28:18 pm »
Attached a project sample. A breakpoint on line 6 doesn't stop the program.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9597
Re: GDB problem (yes, i've used the search)
« Reply #12 on: July 23, 2012, 05:33:46 pm »
Attached a project sample. A breakpoint on line 6 doesn't stop the program.
Well I don't know how you managed to do this, but the executable under the Debug folder has no debug symbols in it. If I do a simple re-build of the project, the BP's work.

I assume you once compiled a release target into the same output folder. As long as the executable is newer than the sources, a normal debug build won't do anything. If you change target options like release/debug you have to re-compile.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline astorga

  • Multiple posting newcomer
  • *
  • Posts: 14
Re: GDB problem (yes, i've used the search)
« Reply #13 on: July 23, 2012, 05:37:41 pm »
It's a fresh project, I created it just to show that it happens. I don't hit build button with release configuration. What could cause it?

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9597
Re: GDB problem (yes, i've used the search)
« Reply #14 on: July 23, 2012, 05:40:01 pm »
It's a fresh project [...]
A fresh project doesn't have an executable. ??? Did you create the project in an existing folder?
What are the exact steps you did to come to this project, including the executable? Did you use the wizards, what did you do next?!
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline astorga

  • Multiple posting newcomer
  • *
  • Posts: 14
Re: GDB problem (yes, i've used the search)
« Reply #15 on: July 23, 2012, 05:52:38 pm »
Open C::B;
In start page, I clicked "Create a new project";
I choose "Console Application", clicked "Go";
In wizard:
I clicked "next";
selected "C", clicked "next";
in "Folder to create project in:" field, I put "C:\", in Project title, I put "crash_test" (the project folder don't exist yet), clicked "Next";
clicked "Next" again;

Project created.

Then I clicked the gear icon to build the executable. When it finish building the program, I set a breakpoint on line 6 of main.c "printf("Hello world!\n");", clicked "Debug" menu, and then "Start".

The program runs until it ends, the breakpoint is ignored.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9597
Re: GDB problem (yes, i've used the search)
« Reply #16 on: July 24, 2012, 06:26:18 am »
Open C::B;
[...]
Well if I do it exactly the way you described it works fine here. ???

However - what you didn't tell: Did a full re-build solve your problem?
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline astorga

  • Multiple posting newcomer
  • *
  • Posts: 14
Re: GDB problem (yes, i've used the search)
« Reply #17 on: July 24, 2012, 02:24:46 pm »
Neither "rebuild" nor "clean and build" works. Same result.  :-\

Kesitem

  • Guest
Re: GDB problem (yes, i've used the search)
« Reply #18 on: August 17, 2012, 09:04:57 am »
Hello,

I just have the same problem.
After set my project on a new computer, Code::Blocks was not stopping on break point.
The problem was my project path have an accent.

What is your project path? Is there any space or accent?

Hope it can help!

(Sorry for my bad english)

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5237
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: GDB problem (yes, i've used the search)
« Reply #19 on: August 17, 2012, 09:21:18 am »
The problem was my project path have an accent.
This may cause the gdb problem, so avoid using space or other non-alphabetic chars in the path.

Neither "rebuild" nor "clean and build" works. Same result.  :-\
Please give us (post) the full debug log here.
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 astorga

  • Multiple posting newcomer
  • *
  • Posts: 14
Re: GDB problem (yes, i've used the search)
« Reply #20 on: August 17, 2012, 07:18:13 pm »
Please give us (post) the full debug log here.
It's in the first post:
here's the full GDB log:

Code: [Select]
PATH=.;C:\Program Files\CodeBlocks\MinGW\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\Efl\bin;C:\Program Files\doxygen\bin;C:\Program Files\GtkSharp\2.12\bin;C:\PROGRA~1\PICC;C:\Program Files\QuickTime\QTSystem\;C:\Program Files\TortoiseSVN\bin;C:\Program Files\Microsoft Visual Studio\Common\Tools\WinNT;C:\Program Files\Microsoft Visual Studio\Common\MSDev98\Bin;C:\Program Files\Microsoft Visual Studio\Common\Tools;C:\Program Files\Microsoft Visual Studio\VC98\bin;C:\Dev-Cpp\bin
Command-line: C:\Program Files\CodeBlocks\MinGW\bin\gdb.exe -nx -fullname  -quiet -args bin/Debug/wordwrap.exe
Working dir : C:\prjs\wordwrap\
> set prompt >>>>>>cb_gdb:
(gdb) >>>>>>cb_gdb:
> show version
GNU gdb 6.8
Copyright (C) 2008 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-pc-mingw32".
>>>>>>cb_gdb:
> set confirm off
>>>>>>cb_gdb:
> set width 0
>>>>>>cb_gdb:
> set height 0
>>>>>>cb_gdb:
> set breakpoint pending on
>>>>>>cb_gdb:
> set print asm-demangle on
>>>>>>cb_gdb:
> set unwindonsignal on
>>>>>>cb_gdb:
> set debugevents on
>>>>>>cb_gdb:
> set new-console on
>>>>>>cb_gdb:
> set disassembly-flavor att
>>>>>>cb_gdb:
> catch throw
Function "__cxa_throw" not defined in loaded symbols.
>>>>>>cb_gdb:
> source C:\Program Files\CodeBlocks\share\codeblocks/scripts/stl-views-1.0.3.gdb
>>>>>>cb_gdb:
> directory C:/prjs/wordwrap/
>>>>>>cb_gdb:
> break "C:/prjs/wordwrap/main.c:6"
No source file named C:/prjs/wordwrap/main.c in loaded symbols.
Breakpoint 1 ("C:/prjs/wordwrap/main.c:6) pending.
>>>>>>cb_gdb:
> run
gdb: win32_init_thread_list
[New thread 2268.0x450]
Program exited normally.
>>>>>>cb_gdb:
> set debugevents off
>>>>>>cb_gdb:
> quit

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5237
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
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 astorga

  • Multiple posting newcomer
  • *
  • Posts: 14
Re: GDB problem (yes, i've used the search)
« Reply #22 on: August 18, 2012, 07:10:23 pm »
Please give us (post) the full debug log here.
It's in the first post:
Can you show me the whole "full build log", see:
http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28errors%29#Q:_How_do_I_troubleshoot_a_compiler_problem.3F

Already posted too:
Have you checked this in you full build log?

See here how to enable it: http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28errors%29#Q:_How_do_I_troubleshoot_a_compiler_problem.3F

here's the full build log:
Code: [Select]
-------------- Build: Debug in wordwrap ---------------

mingw32-gcc.exe  -IC:/prjs/wordwrap -c main.c -o obj/Debug/main.o
mingw32-g++.exe  -o bin/Debug/wordwrap.exe obj/Debug/main.o   
Output size is 24,54 KB
Process terminated with status 0 (0 minutes, 7 seconds)
0 errors, 0 warnings
 

Should the flag appear here? Why is it not appearing?

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5237
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: GDB problem (yes, i've used the search)
« Reply #23 on: August 19, 2012, 10:09:19 am »
Quote
mingw32-gcc.exe  -IC:/prjs/wordwrap -c main.c -o obj/Debug/main.o
This log message is wrong, it should have -g option. So, you need to adjust the build options. Or, you can create a simple "hello world" project from the project wizard and test again.
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 astorga

  • Multiple posting newcomer
  • *
  • Posts: 14
Re: GDB problem (yes, i've used the search)
« Reply #24 on: August 19, 2012, 06:43:34 pm »
Quote
mingw32-gcc.exe  -IC:/prjs/wordwrap -c main.c -o obj/Debug/main.o
This log message is wrong, it should have -g option. So, you need to adjust the build options. Or, you can create a simple "hello world" project from the project wizard and test again.
Did you read the entire topic? All the things you asked are already posted (including this step) o.o

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5237
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: GDB problem (yes, i've used the search)
« Reply #25 on: August 20, 2012, 02:46:56 am »
I can't find ways to help you because you are the only guy who has such strange issue. :)
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.