Debug question!

Everything else that doesn't fall into one of the other PB categories.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Debug question!

Post by srod »

Hi,

a really daft question, -but well, I am allowed at least one a week! :wink: 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

Code: Select all

Debug a$ + "  " + b$
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.
I may look like a mule, but I'm not a complete ass.
User avatar
idle
Always Here
Always Here
Posts: 6238
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Post by idle »

I certainly hope they don't, my debug statements are often flowery depending how irritated I've become.
:lol:
User avatar
djes
Addict
Addict
Posts: 1806
Joined: Sat Feb 19, 2005 2:46 pm
Location: Pas-de-Calais, France

Post by djes »

:lol:
It's also why so much are pushing open source: to have a good laugh!
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8453
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post 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.
BERESHEIT
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post 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.
I may look like a mule, but I'm not a complete ass.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post 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! :wink:

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! :)
I may look like a mule, but I'm not a complete ass.
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post 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))
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
User avatar
idle
Always Here
Always Here
Posts: 6238
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Post by idle »

:lol: 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?
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post by PB »

Try it... :roll: ;)
Last edited by PB on Wed Oct 01, 2008 12:09 pm, edited 1 time in total.
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
User avatar
idle
Always Here
Always Here
Posts: 6238
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Post by idle »

srod wrote: Must admit that I have very little knoweldge of debugging! :)
:lol:
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post 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.
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
freak
PureBasic Team
PureBasic Team
Posts: 5962
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Post by freak »

There is no code generated for them. As to why the API function still ends up being imported, i don't know.
quidquid Latine dictum sit altum videtur
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post 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.
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
User avatar
djes
Addict
Addict
Posts: 1806
Joined: Sat Feb 19, 2005 2:46 pm
Location: Pas-de-Calais, France

Post 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...?
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

idle wrote:
srod wrote: Must admit that I have very little knoweldge of debugging! :)
:lol:
Ah, no pun was intended; I actually meant that I have little knowledge of how debuggers work etc! :)
I may look like a mule, but I'm not a complete ass.
Post Reply