Hard Light Productions Forums

Modding, Mission Design, and Coding => FS2 Open Coding - The Source Code Project (SCP) => Topic started by: portej05 on June 21, 2009, 10:04:16 am

Title: VC2005+ callstack symbols
Post by: portej05 on June 21, 2009, 10:04:16 am
If you've never compiled FS_Open, look away now.

I've added in the code required to get the callstacks out of FS builds done using VC2005 or VC2008 (I'm not sure that this will work with anything else). Since the majority of coders use one of these two, this should be useful.

What major improvement will this herald?
Non-VC6 users will finally be able to get this:
(http://porteous.no-ip.org/temp/scpstackwalk.jpg)

A note on how it works:
When you call SCP_DumpStack( - ), the calling thread is suspended and another thread launched which actually does the stack walking (this is the MS recommended way of doing things). This uses the DbgHelp API.
Here's the kicker: You need the platform SDK. I've developed this against the Vista PSDK (you shouldn't be compiling against anything earlier), and tested this against that PSDK.

In order to use, you define PDB_DEBUGGING globally (although, curiously enough, I've not had to copy the PDBs into the FS directory for this to work - note that this should also work with release builds if the PDBs are built also - there may be a reference to the build directory in the search path. I'm not sure.).
The normal behaviour is observed if this isn't defined (includes are also within the PDB_DEBUGGING ifdef, so nobody should notice any changes there).
There is the catch that whoever is using !VC2008 will have to add mspdb_callstack.[cpp/h] to the project (stick it in globalincs). Only windows users need to worry about this, and only if you're interested in trying out PDB_DEBUGGING.

In order to get this to work correctly (and neatly, I might add), I've had to change a few lines of constness in clean_filename and dump_to_clipboard - this has not caused any problems.

If you get compile errors, report them below, and I'll look into them ASAP - there shouldn't be any!
If you've got any comments/suggestions, report them below.
If the code disappears without a trace, PM this guy (http://www.hard-light.net/forums/index.php?action=profile;u=340) or this guy (http://www.hard-light.net/forums/index.php?action=profile;u=561) or myself.

Above all, ENJOY - SCP is supposed to be an enjoyable team effort :D


portej05

EDIT: NOTE: This is not enabled by default. You need to manually define PDB_DEBUGGING in the preprocessor pages of 'code' options.
Title: Re: VC2005+ callstack symbols
Post by: karajorma on June 21, 2009, 11:53:05 am
Seems to work just fine for me so far.
Title: Re: VC2005+ callstack symbols
Post by: KeldorKatarn on June 21, 2009, 05:29:48 pm
I'm getting a Error 4   error LNK2001: unresolved external symbol ""void __cdecl Error(char *,int,char const *,...)" (?Error@@YAXPADHPBDZZ)".   freespace.obj
Title: Re: VC2005+ callstack symbols
Post by: karajorma on June 21, 2009, 05:35:20 pm
In 2008?
Title: Re: VC2005+ callstack symbols
Post by: KeldorKatarn on June 21, 2009, 05:36:45 pm
Yes
Title: Re: VC2005+ callstack symbols
Post by: karajorma on June 21, 2009, 05:41:04 pm
Try a clean build if you haven't already. It's probably VC playing at silly buggers and deciding that you don't actually need to compile any of the files that have changed.
Title: Re: VC2005+ callstack symbols
Post by: KeldorKatarn on June 21, 2009, 05:44:43 pm
k, I'll try that. Although it seemed it already started a complete rebuild. But I'll try.

Edit: Nope. Didn't help. Still getting the linker error. Doesn't matter wheter I add the define or not.
Title: Re: VC2005+ callstack symbols
Post by: taylor on June 21, 2009, 07:12:50 pm
Looks like Error() was renamed to Just() in windebug.cpp for some reason (probably search&replace mishap) in one of the recent commits.  Change it back and it will probably fix the problem.
Title: Re: VC2005+ callstack symbols
Post by: portej05 on June 22, 2009, 01:36:12 am
Happened in 5359 - I wasn't compiling stuff so I wouldn't have picked this up (safestrings doesn't affect windows builds atm). Good catch! Sorry! Fixed in trunk.