Hard Light Productions Forums

Modding, Mission Design, and Coding => FS2 Open Coding - The Source Code Project (SCP) => Topic started by: z64555 on December 12, 2013, 05:53:15 am

Title: The enigmatic Debug console and Debug window
Post by: z64555 on December 12, 2013, 05:53:15 am
So, I've been wondering about this dev tool flag, -debug_window, and if it was of any particular use. I tried setting it in the launcher - nothing happens. I tried setting it in a debug instance via MSVC - nothing happens.

So, then I go code hunting, and eventually find this:


Code: [Select]
void outwnd_init(int display_under_freespace_window)
{
if (outwnd_inited)
return;
/*
if (Cmdline_debug_window) {
  hOutputThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)outwnd_thread, (LPVOID)display_under_freespace_window, 0, &OutputThreadID);
//SetThreadPriority(hOutputThread, THREAD_PRIORITY_TIME_CRITICAL);
#ifndef NMONO
// set up the monochrome drivers
    if ( (mono_driver = CreateFile("\\\\.\\MONO", GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)) == ((HANDLE)-1)) {
outwnd_printf2("Cannot get handle to monochrome driver.\n");
mono_init();
}

atexit(close_mono);
#endif
}
*/
outwnd.cpp:1182

Wondering why the entirety of the debug window initialization is blocked out, I further hunt. First on the forums to no avail, and finally to the svn logs themselves. It turns out that taylor was the one who initially put the /* */ block there, and I don't really see why he did since it works on Windows perfectly. (Other systems might have trouble, but this I haven't been able to test this yet).

At any rate, I don't find the debug window's usage particularly helpful, all it does is just spit out the fs2_log.txt in nearly real-time. However, seeing as the SCP is gradually getting more in-game debugging tools, I was wondering if it would be viable to reuse the window for something... such as a debug console that can do some nifty things like value watching, or maybe just hold other debug spew info instead of cluttering up the game screen?
Title: Re: The enigmatic -debug_window
Post by: The E on December 12, 2013, 06:00:26 am
While I have used the debug window in the past, I wouldn't mind making it more useful by using it as an output possibility for other data. The thing is though, the debug window as it is now is incredibly useful when you're doing scripting, getting debug info live without having to reload the log in an external text editor is very nice.

Title: Re: The enigmatic -debug_window
Post by: z64555 on December 12, 2013, 06:11:12 am
What about the comment block, then? It's not very useful if you have to uncomment the block and rebuild before you can use the window.

Can we possibly tuck it into a #ifndef NDEBUG block to limit it to debug builds?
Title: Re: The enigmatic -debug_window
Post by: The E on December 12, 2013, 06:13:04 am
I am not sure what's up with that, honestly. The debug window has always just worked for me, without having to make alterations to that part.
Title: Re: The enigmatic -debug_window
Post by: z64555 on December 12, 2013, 02:23:10 pm
We figured out over IRC that the debug_window initialization was removed sometime during the SDL code (currently in antipodes). Trunk still has this, thankfully.

Unfortunately that doesn't solve my problem of needing a way to monitor variable data in real-time... I can perhaps look into improving the debug window to allow this, or possibly spew the data onto the game screen (if I can find the gr functions for it).
Title: Re: The enigmatic -debug_window
Post by: niffiwan on December 12, 2013, 06:05:12 pm
To punt data to the in-mission screen, I think "gr_string" is all you need.  There's a few examples in freespace.cpp, e.g. for the FPS counter.
Title: Re: The enigmatic -debug_window
Post by: Admiral MS on December 12, 2013, 06:57:27 pm
Please don't remove the debug window (though I would be happy with enhancements) or at least keep it easily accessible. It's really useful for scripting as I can read the relevant debugging information while running FSO in window mode next to it.
Title: The enigmatic Debug console and Debug window
Post by: z64555 on December 13, 2013, 11:27:09 am
Some more poking around has led me to discover the Debug Console, a defunct (more or less) console tool that can be accessed in-game via Shift+Enter, and allows you to do a couple of things. I don't see anything of vital importance, except maybe a command that would allow you to set the medals and rank of a pilot (Would've been handy for some pilot data issues we had some time back...) and a command to run sexp's and, through extension, lua scripts.

It would be useful, if it had a better interface akin to bash and the like, and if adding new debug commands were a bit more straightforward. Since I need some way of watching a particular set of values in real-time (mouse and joystick input data, at the moment), I'll be looking into improving the Debug console, and maybe also the Debug window as well.

What are some possible commands and capabilities you'd like to see?
Title: Re: The enigmatic Debug console and Debug window
Post by: jr2 on December 15, 2013, 01:24:29 am
Load / unload mods?
Title: Re: The enigmatic Debug console and Debug window
Post by: The E on December 15, 2013, 02:07:47 am
Not going to happen. That sort of functionality would require a lot of work to make work.
Title: Re: The enigmatic Debug console and Debug window
Post by: z64555 on December 20, 2013, 04:31:19 pm
Hhnnnnnnnnng.  :hopping:

console.cpp:377; void dc_do_command(char*)
Code: [Select]


if (setjmp(dc_bad_arg) ) {
return;
}


console.cpp:351; void dc_get_arg(uint)
Code: [Select]


if ( !(Dc_arg_type&type) ) {
if ( (Dc_arg_type & ARG_NONE) && !(type & ARG_NONE) ) {
dc_printf( "Error: Not enough parameters.\n" );
} else {
dc_printf( "Error: '%s' invalid type\n", Dc_arg );
longjmp(dc_bad_arg,1);
}
}


I'm going to have to look around to see if I can make a Sensible Sane method of error handling for the arguments. It just won't do to be jmp'ing anywhere.