Author Topic: The enigmatic Debug console and Debug window  (Read 2588 times)

0 Members and 1 Guest are viewing this topic.

Offline z64555

  • 210
  • Self-proclaimed controls expert
    • Steam
The enigmatic Debug console and Debug window
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?
« Last Edit: December 13, 2013, 11:30:10 am by z64555 »
Secure the Source, Contain the Code, Protect the Project
chief1983

------------
funtapaz: Hunchon University biologists prove mankind is evolving to new, higher form of life, known as Homopithecus Juche.
z64555: s/J/Do
BotenAlfred: <funtapaz> Hunchon University biologists prove mankind is evolving to new, higher form of life, known as Homopithecus Douche.

 

Offline The E

  • He's Ebeneezer Goode
  • Moderator
  • 213
  • Nothing personal, just tech support.
    • Steam
    • Twitter
Re: The enigmatic -debug_window
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.

If I'm just aching this can't go on
I came from chasing dreams to feel alone
There must be changes, miss to feel strong
I really need lifе to touch me
--Evergrey, Where August Mourns

 

Offline z64555

  • 210
  • Self-proclaimed controls expert
    • Steam
Re: The enigmatic -debug_window
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?
Secure the Source, Contain the Code, Protect the Project
chief1983

------------
funtapaz: Hunchon University biologists prove mankind is evolving to new, higher form of life, known as Homopithecus Juche.
z64555: s/J/Do
BotenAlfred: <funtapaz> Hunchon University biologists prove mankind is evolving to new, higher form of life, known as Homopithecus Douche.

 

Offline The E

  • He's Ebeneezer Goode
  • Moderator
  • 213
  • Nothing personal, just tech support.
    • Steam
    • Twitter
Re: The enigmatic -debug_window
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.
If I'm just aching this can't go on
I came from chasing dreams to feel alone
There must be changes, miss to feel strong
I really need lifе to touch me
--Evergrey, Where August Mourns

 

Offline z64555

  • 210
  • Self-proclaimed controls expert
    • Steam
Re: The enigmatic -debug_window
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).
Secure the Source, Contain the Code, Protect the Project
chief1983

------------
funtapaz: Hunchon University biologists prove mankind is evolving to new, higher form of life, known as Homopithecus Juche.
z64555: s/J/Do
BotenAlfred: <funtapaz> Hunchon University biologists prove mankind is evolving to new, higher form of life, known as Homopithecus Douche.

 

Offline niffiwan

  • 211
  • Eluder Class
Re: The enigmatic -debug_window
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.
Creating a fs2_open.log | Red Alert Bug = Hex Edit | MediaVPs 2014: Bigger HUD gauges | 32bit libs for 64bit Ubuntu
----
Debian Packages (testing/unstable): Freespace2 | wxLauncher
----
m|m: I think I'm suffering from Stockholm syndrome. Bmpman is starting to make sense and it's actually written reasonably well...

 
Re: The enigmatic -debug_window
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.
Here goes scripting and copy paste coding
Freespace RTS Mod
Checkpoint/Shipsaveload script

 

Offline z64555

  • 210
  • Self-proclaimed controls expert
    • Steam
The enigmatic Debug console and Debug window
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?
Secure the Source, Contain the Code, Protect the Project
chief1983

------------
funtapaz: Hunchon University biologists prove mankind is evolving to new, higher form of life, known as Homopithecus Juche.
z64555: s/J/Do
BotenAlfred: <funtapaz> Hunchon University biologists prove mankind is evolving to new, higher form of life, known as Homopithecus Douche.

 

Offline jr2

  • The Mail Man
  • 212
  • It's prounounced jayartoo 0x6A7232
    • Steam
Re: The enigmatic Debug console and Debug window
Load / unload mods?

 

Offline The E

  • He's Ebeneezer Goode
  • Moderator
  • 213
  • Nothing personal, just tech support.
    • Steam
    • Twitter
Re: The enigmatic Debug console and Debug window
Not going to happen. That sort of functionality would require a lot of work to make work.
If I'm just aching this can't go on
I came from chasing dreams to feel alone
There must be changes, miss to feel strong
I really need lifе to touch me
--Evergrey, Where August Mourns

  

Offline z64555

  • 210
  • Self-proclaimed controls expert
    • Steam
Re: The enigmatic Debug console and Debug window
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.
Secure the Source, Contain the Code, Protect the Project
chief1983

------------
funtapaz: Hunchon University biologists prove mankind is evolving to new, higher form of life, known as Homopithecus Juche.
z64555: s/J/Do
BotenAlfred: <funtapaz> Hunchon University biologists prove mankind is evolving to new, higher form of life, known as Homopithecus Douche.