Author Topic: VC2005+ callstack symbols  (Read 2538 times)

0 Members and 1 Guest are viewing this topic.

VC2005+ callstack symbols
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:


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 or this guy 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.
« Last Edit: June 21, 2009, 10:43:44 am by portej05 »
STRONGTEA. Why can't the x86 be sane?

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: VC2005+ callstack symbols
Seems to work just fine for me so far.
Karajorma's Freespace FAQ. It's almost like asking me yourself.

[ Diaspora ] - [ Seeds Of Rebellion ] - [ Mind Games ]

 
Re: VC2005+ callstack symbols
I'm getting a Error 4   error LNK2001: unresolved external symbol ""void __cdecl Error(char *,int,char const *,...)" (?Error@@YAXPADHPBDZZ)".   freespace.obj

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: VC2005+ callstack symbols
In 2008?
Karajorma's Freespace FAQ. It's almost like asking me yourself.

[ Diaspora ] - [ Seeds Of Rebellion ] - [ Mind Games ]

 
Re: VC2005+ callstack symbols
Yes

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: VC2005+ callstack symbols
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.
Karajorma's Freespace FAQ. It's almost like asking me yourself.

[ Diaspora ] - [ Seeds Of Rebellion ] - [ Mind Games ]

 
Re: VC2005+ callstack symbols
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.
« Last Edit: June 21, 2009, 06:02:17 pm by KeldorKatarn »

 

Offline taylor

  • Super SCP/Linux Guru
  • Moderator
  • 212
    • http://www.icculus.org/~taylor
Re: VC2005+ callstack symbols
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.

  
Re: VC2005+ callstack symbols
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.
STRONGTEA. Why can't the x86 be sane?