Debugging freeorion with gdb

Questions, problems and discussion about compiling FreeOrion.

Moderators: Oberlus, Oberlus

Post Reply
Message
Author
User avatar
Rydra
Space Squid
Posts: 55
Joined: Fri Jun 28, 2013 6:15 pm

Debugging freeorion with gdb

#1 Post by Rydra » Fri Sep 27, 2013 11:50 pm

(Not sure if this subforum is the right place)

Hi there,

I'm trying to debug freeorion with GDB (across kdevelop), and I have several questions relating to it:

1- gdb takes up to 1 minute by charging symbols before start debugging. Is it normal? I think it's way too much (my company has a way bigger project than freeorion and takes about 7 seconds to charge symbols...)
2- It seems OIS grabs the mouse. When gdb stops at a breakpoint, I can't change the window, nor even with alt+tab, forcing me to kill gdb from another TTY. One workaround I found to this is by executing freeorion on a different X session in TTY8 (with xinit), but... I wonder if there is another possibility.
3- What debuggers do you use?
4- gdb stays almost always while debugging at 100% cpu, using a very high amount of RAM (I have 6 GB and gdb attached to freeorion has been taking 60% of it...). Also, stepping through the code, line by line, is extremely slow. Doing for example an i++ takes about 1 minute. Is someone experiencing these issues?

Those who use gdb, are you experiencing the same issues?

Thank you and greetings.

User avatar
Dilvish
AI Lead, Programmer
Posts: 4768
Joined: Sat Sep 22, 2012 6:25 pm

Re: Debugging freeorion with gdb

#2 Post by Dilvish » Sat Sep 28, 2013 12:09 am

Have you changed your OIS settings? The values in the standard FO OISInput.cfg have

Code: Select all

x11_mouse_grab=false
and for me it does not grab the mouse (but if I change that value to true then it does). If you have a preinstalled OIS it could be that it has it's own settings someplace overriding the FO cfg file. Regardless, Here's a suggestion from an OGRE forum on a possible workaround.

Or, you might want to try starting up FO first, getting it to the state you want to debug, and then attach the debugger to it, that would at least help reduce the hassle of slow stepping.
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0

User avatar
Rydra
Space Squid
Posts: 55
Joined: Fri Jun 28, 2013 6:15 pm

Re: Debugging freeorion with gdb

#3 Post by Rydra » Sat Sep 28, 2013 1:19 am

Dilvish wrote:Have you changed your OIS settings? The values in the standard FO OISInput.cfg have

Code: Select all

x11_mouse_grab=false
and for me it does not grab the mouse (but if I change that value to true then it does). If you have a preinstalled OIS it could be that it has it's own settings someplace overriding the FO cfg file. Regardless, Here's a suggestion from an OGRE forum on a possible workaround.

Or, you might want to try starting up FO first, getting it to the state you want to debug, and then attach the debugger to it, that would at least help reduce the hassle of slow stepping.
I'll try setting up the xorg option later and post the results. I don't know if the OISInput works for the executable I've generated with Kdevelop (the executable is generated on another folder called "build" which does not contain the OISInput.cfg. May that be the issue?).

With your last paragraph, do you mean that this horribly slow stepping is normal and happens to you too?

User avatar
Dilvish
AI Lead, Programmer
Posts: 4768
Joined: Sat Sep 22, 2012 6:25 pm

Re: Debugging freeorion with gdb

#4 Post by Dilvish » Sat Sep 28, 2013 5:40 am

Rydra wrote:I'll try setting up the xorg option later and post the results. I don't know if the OISInput works for the executable I've generated with Kdevelop (the executable is generated on another folder called "build" which does not contain the OISInput.cfg. May that be the issue?).
Ah, try copying OISInput.cfg into your build directory right away & see if that clears it up -- the default values that are built into the actual OIS code do turn on mousegrab and need to be overridden by the cfg file. Also, FYI, although KDevelop's default prompts for a CMake project specify a separate build directory, you don't need to actually go with that, you can just delete the '/build' and it can work with the main directory as the build directory.
With your last paragraph, do you mean that this horribly slow stepping is normal and happens to you too?
No, I was just referring to your description of it as slow -- it's been so long since I tried that I don't recall what about it I didn't like. Quite possibly it was too slow. I do periodically run with valgrind to help track down crashes, and that's about as slow as I can take, I expect gdb makes it much slower.
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0

User avatar
Rydra
Space Squid
Posts: 55
Joined: Fri Jun 28, 2013 6:15 pm

Re: Debugging freeorion with gdb

#5 Post by Rydra » Sat Sep 28, 2013 9:10 am

Dilvish wrote:
Rydra wrote:I'll try setting up the xorg option later and post the results. I don't know if the OISInput works for the executable I've generated with Kdevelop (the executable is generated on another folder called "build" which does not contain the OISInput.cfg. May that be the issue?).
Ah, try copying OISInput.cfg into your build directory right away & see if that clears it up -- the default values that are built into the actual OIS code do turn on mousegrab and need to be overridden by the cfg file. Also, FYI, although KDevelop's default prompts for a CMake project specify a separate build directory, you don't need to actually go with that, you can just delete the '/build' and it can work with the main directory as the build directory.
With your last paragraph, do you mean that this horribly slow stepping is normal and happens to you too?
No, I was just referring to your description of it as slow -- it's been so long since I tried that I don't recall what about it I didn't like. Quite possibly it was too slow. I do periodically run with valgrind to help track down crashes, and that's about as slow as I can take, I expect gdb makes it much slower.
Amazing. Moving OISInput.cfg to the build folder where the executable is located not only allowed for moving my mouse around windows freely, but also sped up the debugging stepping by around 20 times. Weird.

How do you use the root directory of FreeOrion as build target in Kdevelop? When I try to assign it at the Configure Project window, it says "the selected build directory is not empty".

Thank you. Your help is much appreciated.

User avatar
Dilvish
AI Lead, Programmer
Posts: 4768
Joined: Sat Sep 22, 2012 6:25 pm

Re: Debugging freeorion with gdb

#6 Post by Dilvish » Sat Sep 28, 2013 10:25 pm

Rydra wrote:How do you use the root directory of FreeOrion as build target in Kdevelop? When I try to assign it at the Configure Project window, it says "the selected build directory is not empty".
I do it at project creation. I can recall that message temporarily appearing during the project creation process. I kind of had it in my head that it disappeared when I finish deleting the final '/' in the build path, but that isn't happening when I run a quick test. What does seem to work in a quick test, & which I suspect I did during project setup, is to just cancel out the 'setup build directory' popup that appears right after you create/import the cmake project. Sorry I can't remember for sure what I did there.
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0

User avatar
Rydra
Space Squid
Posts: 55
Joined: Fri Jun 28, 2013 6:15 pm

Re: Debugging freeorion with gdb

#7 Post by Rydra » Sun Sep 29, 2013 8:15 am

Dilvish wrote:
Rydra wrote:How do you use the root directory of FreeOrion as build target in Kdevelop? When I try to assign it at the Configure Project window, it says "the selected build directory is not empty".
I do it at project creation. I can recall that message temporarily appearing during the project creation process. I kind of had it in my head that it disappeared when I finish deleting the final '/' in the build path, but that isn't happening when I run a quick test. What does seem to work in a quick test, & which I suspect I did during project setup, is to just cancel out the 'setup build directory' popup that appears right after you create/import the cmake project. Sorry I can't remember for sure what I did there.
Maybe you used another version? in Kdevelop 4.4 this doesn't seem possible, even removing the "/" in the build path (message keeps appearing).

Meh, anyway, I think it's ok that the compilation result is kept away from code on a separate folder. However in order to make it somewhat more user-friendly some build configuration should be made in a way that OISInput.cfg and the "default" folder are also copied in the build folder. (I had to ln -s those files).

Thank you and greetings, at least now I'm able to work, test and debug code :D

User avatar
Dilvish
AI Lead, Programmer
Posts: 4768
Joined: Sat Sep 22, 2012 6:25 pm

Re: Debugging freeorion with gdb

#8 Post by Dilvish » Sun Sep 29, 2013 7:08 pm

I'm using KDevelop4.5
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0

User avatar
Rydra
Space Squid
Posts: 55
Joined: Fri Jun 28, 2013 6:15 pm

Re: Debugging freeorion with gdb

#9 Post by Rydra » Mon Sep 30, 2013 6:55 pm

Dilvish wrote:I'm using KDevelop4.5
I wonder when Ubuntu will update kdevelop 4.5 (not feeling like compiling it tbh). I miss archlinux... yet it has become a worse distribution every year it passes...

Post Reply