Page 1 of 1

debugging AI with breakpoints

Posted: 11 Oct 2009, 20:53
by jepperc
Hi.
Does anyone have a small guide on how to use breakpoints in AI's for Spring?
I am looking in to doing this, but having some issues. I was thinking this has be done in "GDB", which is also suggested on the Spring development WIKI, and have downloaded Version 7.

When trying to set a breakpoint to the main function of spring, I get an error when I try to run spring:

Code: Select all

warning: (Internal error: pc 0x87bd59 in read in psymtab, but not in symtab.)
Spring never launches.
This even happens on a debug compiled version of spring.
When trying to set a breakpoint in my AI, i get that i cannot find the function, but it can look for it in a later loaded DLL (which it is), answering yes doesnt help (the breakpoint doesnt work).
Also trying to load the AI dll as a shared symbol file allows me to find the functions, but when launching spring, it comes with an error:

Code: Select all

warning: (Internal error: pc 0x68d8f416 in read in psymtab, but not in symtab.)
Warning:
Cannot insert breakpoint 1.
Error accessing memory address 0x68d8f416: Input/output error.
I have a feeling I am doing something completely wrong? :)

Re: debugging AI with breakpoints

Posted: 12 Oct 2009, 11:24
by hoijui
you should give more info. eg, what kind of AI is it? (using the LegacyCpp interface, hte new C++ one?), what OS (i guess windows)?
how exactly did you compile spring? how did you set the breakpoints? how much experience do you hav ewith C++/debugging? ... and anything else you think could be usefull.

Re: debugging AI with breakpoints

Posted: 12 Oct 2009, 12:34
by jepperc
It's the new CPP interface, on windows 7(don't know if that is a problem for gdb).
Compiled spring(and AI) using Cmake and MINGW with gcc 4.4, and setting the breakpoints in GDB using fx. "break main" for the main function, or more generally: break 'namespace::class:function()'.

Now my c++ debugging experience with GDB is 0, which was why I was hoping for a small guide to debug spring with GDB :)

I can backtrace crashes, but get a lot of the earlier mentioned symtab warnings doing it, which is really annoying.

Re: debugging AI with breakpoints

Posted: 12 Oct 2009, 13:03
by hoijui
hmm.. i think i use the same GCC on windows, but i use an older GDB (not ansolutely sure though). best is if you get one that fits the compiler you use, am notan expert for this either though -> can not tell you which one is; you might find out on the DL page.
i dont knof if setting a breakpoint works the way you did it, but what i usually do is setting it like this:

Code: Select all

> break SourceFile.cpp:123
you cna specfy the source file with the full path (eg: rts/Game/Game.cpp) or just as i did in the example above, if there is one one wiht that name. you also should make sure to specify a line number that contains code that actually does something in the CPU, empty lines, comments, preprocesor instructions and function declarations will not work/be jumped over, for example.