Page 1 of 3
Debug question!
Posted: Wed Oct 01, 2008 11:13 am
by srod
Hi,
a really daft question, -but well, I am allowed at least one a week!

Although I reckon on that score I've exhausted my quota for the next 10 years or so!
Am I correct in saying that, for example, with the statement
that none of this will ever make it into an executable? In particular none of the string handling a$ + ... etc. will be included to slow things down?
I won't bore you with the reasons why this is important to me as that is a little too involved for such a simple question!
Thanks.
Posted: Wed Oct 01, 2008 11:35 am
by idle
I certainly hope they don't, my debug statements are often flowery depending how irritated I've become.

Posted: Wed Oct 01, 2008 11:42 am
by djes

It's also why so much are pushing open source: to have a good laugh!
Posted: Wed Oct 01, 2008 11:44 am
by netmaestro
Hm, you may be disappointed. I wrote a one-liner: Debug WindowFromPoint_(100,100), compiled it to an exe and pulled the exe up in FileViewer. 'WindowFromPoint' does show up in the exe, which it wouldn't if it were dumped.
Posted: Wed Oct 01, 2008 11:54 am
by srod
Well, it's nothing about wishing to mask any embarrassing debug comments as such.
I am working on a hugely complex and speed-critical routine which can fail for a number of reasons which are outside of the control of the library (closed source dll) of which the routine is a part. To help the user in these circumstances I wish to create a log file, except that such a file will slow down the routine in question and that is something I wish to avoid at all costs. My options are a separate 'debug build' of the library which can be achieved through conditional compilation without impacting my work and which can provide the user with a log-file, or, alternatively, a simple bunch of 'Debug's which leave the onus of investigating any problems with myself (rather than the user of the library) but remove the need for a separate debug build providing the Debug statements do not impact the final dll.
Now common sense suggests that I go for the debug build method, but my naturally inquisitive mind has subsequently wondered about the Debug statements!
I am sure it is a question with an obvious answer, but I have simply not thought about this at all - until now.
Posted: Wed Oct 01, 2008 11:59 am
by srod
netmaestro wrote:Hm, you may be disappointed. I wrote a one-liner: Debug WindowFromPoint_(100,100), compiled it to an exe and pulled the exe up in FileViewer. 'WindowFromPoint' does show up in the exe, which it wouldn't if it were dumped.
Ah, yes, a good idea indeed!
However, has the debug info simply been tagged into a debug section of the exe which is nevertheless never executed? It is obviously inflating the size of the exe and I wonder if the resulting code section(s) have the ubiquitous NOPs inserted ready for the debugger? Must admit that I have very little knoweldge of debugging!

Posted: Wed Oct 01, 2008 11:59 am
by PB
@netmaestro: Yes, that is weird. Fred has always said that Debug commands
are not included, and even the manual says that. Oh well, I guess they're in
there for a reason.
Here is a workaround for now that truly doesn't include them:
Code: Select all
Macro MyDebug(code)
CompilerIf #PB_Compiler_Debugger
Debug code
CompilerEndIf
EndMacro
MyDebug(WindowFromPoint_(100,100))
Posted: Wed Oct 01, 2008 12:02 pm
by idle

Just as well I go through and nuke them before release then.
So what would be the effect of using a macro like this. It'll get rid of the debug statements alright, though will the compiler ignore the macro?
Posted: Wed Oct 01, 2008 12:08 pm
by PB
Try it... :roll:

Posted: Wed Oct 01, 2008 12:09 pm
by idle
srod wrote: Must admit that I have very little knoweldge of debugging!


Posted: Wed Oct 01, 2008 12:11 pm
by PB
Actually, this should be classed as a bug because the manual specifically says
that the commands after the Debug are NOT compiled, but evidently they are.
Posted: Wed Oct 01, 2008 12:14 pm
by freak
There is no code generated for them. As to why the API function still ends up being imported, i don't know.
Posted: Wed Oct 01, 2008 12:16 pm
by PB
Will the import be stripped, then? I guess Fred has to answer that? Otherwise
I'll have to switch to using my macro in future as I wasn't aware of the imports
adding unused data to my final exes.
Posted: Wed Oct 01, 2008 12:19 pm
by djes
Maybe you could use
DbgPrint and DebugView (
http://technet.microsoft.com/fr-fr/sysi ... n-us).aspx) to do that, of just a console output...?
Posted: Wed Oct 01, 2008 12:30 pm
by srod
idle wrote:srod wrote: Must admit that I have very little knoweldge of debugging!


Ah, no pun was intended; I actually meant that I have little knowledge of how debuggers work etc!
