News:

The new Release 25.03 is out! You can download binaries for Windows and many major Linux distros here .

Main Menu

Debug problem with header files

Started by rhf, September 30, 2008, 10:40:47 PM

Previous topic - Next topic

nenin

#15
Quote from: rhf on April 10, 2009, 06:05:50 PM
Quote from: TDragon on April 10, 2009, 05:38:33 PM
I really need a reproducible test case to work with here, folks.
I know, and it is frustrating that I can't come up with a test case as I did for the previous problem. I am currently working on a fairly large program; and every now and then, when I set a break in a header file, the debugger fails. <***>
I confirm the same problem. I have a project with headers placed in root project folder and some subfolders. I can not enter breakpoint  in headers from start, and now I found that gdb kind of hung in template function, if I enter it by step and than place a new breakpoint inside. WinXP SP3, last TDM gcc.   :(

RJP Computing

#16
I can work on an example, but do the inline templates of the example I posted have anything to do with that? I should also mention that the header is in a sub-directory that is three levels down. (<proj_root>\wxtools\wx\serialization\combobox.h)

Quote from: TDragon on April 10, 2009, 05:38:33 PMI shouldn't need to ask this, but are you sure you're compiling without any optimization flags and with debugging info turned on?
Yes I have them on.
- Ryan

Ubuntu/WinXP, AMD Athlon 64 3000+, 1000MB RAM, AC 97 Audio, ATI Radeon 9600XT 256MB

ollydbg

I have the interests for testing, if you can supply a test case. :D
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.

RJP Computing

Alright I wrote a small example that shows the bug. I attached the source to this post. Just make a new console project and add the files to the project.

Here are some things I found:

  • Only set a breakpoint in the file wxtools\wx\serialization\combobox.h. It will not set the breakpoint.
  • If you set a breakpoint in a cpp (headerbrk.cpp) that includes the header then it will set the breakpoint properly.

[attachment deleted by admin]
- Ryan

Ubuntu/WinXP, AMD Athlon 64 3000+, 1000MB RAM, AC 97 Audio, ATI Radeon 9600XT 256MB

TDragon

Sorry, works fine for me. GCC 4.3.3 TDM-1, GDB 6.8-mingw-3. Screenshot attached.

[attachment deleted by admin]
[url="https://jmeubank.github.io/tdm-gcc/"]https://jmeubank.github.io/tdm-gcc/[/url] - TDM-GCC compiler suite for Windows (GCC 9.2.0 2020-03-08, 32/64-bit, no extra DLLs)

RJP Computing

I am trying this using 'gdb.exe' and can't get it to stop. I tried in C::B and sure enough it is breaking like it should. So... I am assuming C::B is doing something right that I am not. Sorry for my noise, but I am trying to continue to use gdb so I would like some help. Can you use MSys or something and use just the 'gdb.exe'.

Also I understand that this is not a C::B related issue so should it be moved to a different forum/email/something?
- Ryan

Ubuntu/WinXP, AMD Athlon 64 3000+, 1000MB RAM, AC 97 Audio, ATI Radeon 9600XT 256MB

TDragon

Before trying it in C::B, I tried it from command-line gdb with

break template_headerbrk.h:12

which worked fine for me, as did

break "C:\path\to\headerbrk\wxtools\wx\serialization\template_headerbrk.h":12


So I have no idea what the problem on your end is.

And, yes, unless you come up with a scenario that breaks in C::B, I suspect this has gone off-topic.
[url="https://jmeubank.github.io/tdm-gcc/"]https://jmeubank.github.io/tdm-gcc/[/url] - TDM-GCC compiler suite for Windows (GCC 9.2.0 2020-03-08, 32/64-bit, no extra DLLs)

RJP Computing

Quote from: TDragon on April 14, 2009, 12:54:03 AM
Before trying it in C::B, I tried it from command-line gdb with

break template_headerbrk.h:12

which worked fine for me, as did

break "C:\path\to\headerbrk\wxtools\wx\serialization\template_headerbrk.h":12


So I have no idea what the problem on your end is.
Thanks. I had tried a few sytax's and now that works. I am not very familiar with gdb.exe so I was trying to follow the earlier post in this thread that was using gdb.exe. I will let my issues rest. Again thanks for your patience and understanding.

Quote from: TDragon on April 14, 2009, 12:54:03 AM
And, yes, unless you come up with a scenario that breaks in C::B, I suspect this has gone off-topic.
Correct. And sorry for the noise.
- Ryan

Ubuntu/WinXP, AMD Athlon 64 3000+, 1000MB RAM, AC 97 Audio, ATI Radeon 9600XT 256MB

nenin

Quote<***> So I have no idea what the problem on your end is. <***>
I figured out  a case (at least, my case). I have a complicated project structure, with sources in the set of folders.
C::B sets breakpoint as:
"c:/MinGW/run/prj_root/template_header.hpp:13
But in gdb console path to this line looks like:
At c:/MinGW/run/prj_root/v01/../template_header.hpp:13
"v01" is a folder, where template from "template_header.hpp" was instated.
So, if I send to gdb
break c:/MinGW/run/prj_root/v01/../template_header.hpp:13
it works. But C::B  can not set a breakpoint properly.  :(

ollydbg

Quote from: nenin on April 15, 2009, 10:39:12 AM
Quote<***> So I have no idea what the problem on your end is. <***>
I figured out  a case (at least, my case). I have a complicated project structure, with sources in the set of folders.
C::B sets breakpoint as:
"c:/MinGW/run/prj_root/template_header.hpp:13
But in gdb console path to this line looks like:
At c:/MinGW/run/prj_root/v01/../template_header.hpp:13
"v01" is a folder, where template from "template_header.hpp" was instated.
So, if I send to gdb
break c:/MinGW/run/prj_root/v01/../template_header.hpp:13
it works. But C::B  can not set a breakpoint properly.  :(

Maybe, this is the issue that cb treat differently with relative path and absolute path. I encountered this kind of problem when I want to debug into the wxWidgets source(at that time, I use wxPack), but it failed.

See the post:
http://forums.next.codeblocks.org/index.php/topic,9744.0.html

But no body replied there. :(
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.

TDragon

Quote from: ollydbg on April 15, 2009, 11:56:25 AM
See the post:
http://forums.next.codeblocks.org/index.php/topic,9744.0.html

But no body replied there. :(
That might be because your issue there is almost entirely unrelated.

Quote from: nenin on April 15, 2009, 10:39:12 AM
But in gdb console path to this line looks like:
At c:/MinGW/run/prj_root/v01/../template_header.hpp:13
"v01" is a folder, where template from "template_header.hpp" was instated.
So, if I send to gdb
break c:/MinGW/run/prj_root/v01/../template_header.hpp:13
it works. But C::B  can not set a breakpoint properly.  :(
If verified, this appears to be a bug in GDB.
[url="https://jmeubank.github.io/tdm-gcc/"]https://jmeubank.github.io/tdm-gcc/[/url] - TDM-GCC compiler suite for Windows (GCC 9.2.0 2020-03-08, 32/64-bit, no extra DLLs)

ollydbg

Quote from: rhf on April 10, 2009, 06:05:50 PM
I know, and it is frustrating that I can't come up with a test case as I did for the previous problem. I am currently working on a fairly large program; and every now and then, when I set a break in a header file, the debugger fails. I keep wondering if it is perhaps a problem with the project search directories, but I have not been able to identify anything obvious. Thanks again for your good work.
@rhf

I meet the same problem when I'm include an inline function header in many CPP files, then setting brekpoints may fails.

But I have solved the problem by adding GCC options. You can see this post, maybe, it's the cause of your problem.

http://forums.next.codeblocks.org/index.php/topic,10508.msg73723.html#msg73723

:D
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.

rhf

Quote from: ollydbg on June 25, 2009, 06:53:09 PM
@rhf
I meet the same problem when I'm include an inline function header in many CPP files, then setting brekpoints may fails.
But I have solved the problem by adding GCC options. You can see this post, maybe, it's the cause of your problem.
http://forums.next.codeblocks.org/index.php/topic,10508.msg73723.html#msg73723
I have been following that thread. The next time I have the problem, which seems to occur only with my larger, more complicated projects, I will definitely try the compiler options. Thanks very much!