|
GnuDebugger picks wrong source file |
Edgar Reynaldo
Major Reynaldo
May 2007
|
Has anyone else ever had any problems with running their progams in GnuDebugger and then gdb picks the wrong source file? It's really frustrating because I can't set any breakpoints and it's only useful if my program quits suddenly and then I can use a backtrace (bt full) to find out where it was. And why does that work anyway if it is picking the wrong source file? I've been developing the same program for a while now and gdb has been picking the correct source file for a while now until a few weeks ago it started picking wrong source files! I think it was about the same time I added #include<fstream> and #include<iostream> For a while gdb would pick allegro's inline - wait a minute, I remember it started happening as soon as I added my settings class. That's when gdb started picking allegro's inline file as source. I was using the settings from memory and then I added file save functions to my code. Then gdb started picking fstream as it's source file. Here are my compiler settings. I get the same results if I use -g instead of -ggdb. I've tried setting the default directory to search for source files (in gdb) #include <allegro.h> #include <string.h> #include <stdio.h> #include <math.h> #include <iostream> #include <fstream> //using std::cout; using std::endl; using std::ostream; using std::fstream; using std::ofstream; using std::ios; Does anyone know how to fix this? My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
ImLeftFooted
Member #3,935
October 2003
|
I add -g3 -ggdb to all my commands as well as include all the same headers as you and have had no problems ever |
Thomas Fjellstrom
Member #476
June 2000
|
Dustin, that -ggdb will override the -g3. -g args do not "stack". Just like -O. Personally, I use -ggdb3, or -gstabs+ for c++ (though I'm not sure thats necessary anymore) -- |
Edgar Reynaldo
Major Reynaldo
May 2007
|
Sorry dudes no luck with -ggdb3 or -gstabs+ , By the way I am using GDB 5.2.1 My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
ImLeftFooted
Member #3,935
October 2003
|
Did you do a total-recompile? |
CGamesPlay
Member #2,559
July 2002
|
Why don't you post a gdb transcript? You know you can change the source file, right? -- Ryan Patterson - <http://cgamesplay.com/> |
BAF
Member #2,981
December 2002
|
You probably might want to use cmath instead of math.h, cstring instead of string.h, and cstdio instead of stdio.h, if you want everything to be nice and tidy in the std namespace. |
Edgar Reynaldo
Major Reynaldo
May 2007
|
Dustin - deleted object and executable files and recompiled, no change. CGamesPlay - Here's a copy of what happens in gdb. I've looked for how to change the source file but I don't know how to do that in gdb. All I've been able to find are commands that change the search path for source files and that doesn't help even after unloading the executable and changing the source path search directory by using
BAF - I touched up my include files , thanks for the tip. Any suggestions? My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
CGamesPlay
Member #2,559
July 2002
|
Try break main. Or break main.c:102. Or help break... -- Ryan Patterson - <http://cgamesplay.com/> |
Edgar Reynaldo
Major Reynaldo
May 2007
|
CGamesPlay - At least now I can set breakpoints again. Thanks. Edit 1 My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
CGamesPlay
Member #2,559
July 2002
|
Well, gdb isn't a source browser. I don't think there's any problem -- Ryan Patterson - <http://cgamesplay.com/> |
Thomas Fjellstrom
Member #476
June 2000
|
I would like so see the full output of one of these sessions where its giving the wrong info. -- |
CGamesPlay
Member #2,559
July 2002
|
-- Ryan Patterson - <http://cgamesplay.com/> |
Thomas Fjellstrom
Member #476
June 2000
|
Har. So I missed it. But yeah, I don't think thats the right way to be using gdb... cd /path/to/program gdb ./program gdb> run <arguments> ... (wait for crash) gdb> bt ... (backtrace here) I'd like to see that, instead of that odd mess that I saw above. Or set proper breakpoints, and watches, and then "run". None of that other stuff should be necessary. how can you expect it to give a valid "list" if its not even started running? -- |
CGamesPlay
Member #2,559
July 2002
|
Well, I can see a good argument for having it show the main function as that is the next line about the be executed -- Ryan Patterson - <http://cgamesplay.com/> |
Thomas Fjellstrom
Member #476
June 2000
|
Quote: Well, I can see a good argument for having it show the main function as that is the next line about the be executed Could be, but the actual first line is in crt0.o, some init code that eventually calls main(). -- |
Edgar Reynaldo
Major Reynaldo
May 2007
|
Thomas - I included the output from the help commands within gdb in case I had missed something that would help me set the source file that was being read from. This excerpt should show you better what happens when I use gdb to debug my program. I put in a line with pound signs to highlight what happens.
P.S. The progam has never had to be running for me to use list to view source code. Edit 1 - If gdb is listing the wrong file , that's where the breakpoints get set (in the wrong file). CGamesPlay gave me a workaround by using My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
BAF
Member #2,981
December 2002
|
What? That looks fine to me. You do understand how #include works, right? |
Edgar Reynaldo
Major Reynaldo
May 2007
|
BAF - Not really , no. At least not in the way the compiler puts everything together. And I've used plenty of #includes before and until recently they've never made gdb read in the wrong source file. Like I said , it started happening as soon as I added my settings class (basically just data storage and retrieval and an << operator function so I can put it into a text file nicely. That's when gdb started selecting some allegro inline file as my main source file. Then I added #include<fstream> and #include<iostream> and that's when gdb started picking fstream.tcc as my source file. Look at my last post - in the transcript window at these three lines Edgar Reynaldo said:
// ############ Look here ######################################################
Until CGamesPlay showed me how to set a breakpoint by using the file name My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
Thomas Fjellstrom
Member #476
June 2000
|
.tcc? Isn't that a precompiled header? Maybe that has something to do with the oddities? -- |
Edgar Reynaldo
Major Reynaldo
May 2007
|
I haven't the slightest clue , so I'm going to try updating gdb (6.6 is out now) My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
ImLeftFooted
Member #3,935
October 2003
|
If .tcc is a precompiled header I think its safe to just delete it. Try renaming / deleting it and see if that fixes it. Is there a settings.tcc as well? On second thought, I think .pch is the precompiled header extension... hm... |
Edgar Reynaldo
Major Reynaldo
May 2007
|
fstream.tcc is a bunch of templates which I don't understand yet anyway. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
ImLeftFooted
Member #3,935
October 2003
|
Quote: But I won't be deleting anything. Don't want to reinstall Mingw. The trick is to rename it which is effectively the same yet can be easily undone. |
Edgar Reynaldo
Major Reynaldo
May 2007
|
I knew this would cause trouble but I didn't know how. Did it for fun anyway. fstream contains these lines #ifdef _GLIBCPP_NO_TEMPLATE_EXPORT # define export #endif #ifdef _GLIBCPP_FULLY_COMPLIANT_HEADERS # include <bits/fstream.tcc> #endif #endif
And as such the program would never compile without it. Dustin - no , there's no settings.tcc in my compiler directory. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
|