kernelwernel / VMAware

VM detection library and tool
GNU General Public License v3.0
331 stars 30 forks source link

Defining debug mode leads to compiler errors #38

Closed greenozon closed 6 months ago

greenozon commented 6 months ago

If all of a sudden you decided to see the matrix deep sea :) by defining

#define __VMAWARE_DEBUG__ 

you'll hit something interesting ,eg:

image

that's cause currently the debug() routine is living inside the VM::util space, but used outside... what was the original intention - to keep it inside util or inside VM scope?

greenozon commented 6 months ago

I"ve got another debug related idea... for the moment it's a bit hard to read the code as it has dozens (hundreds?) of patterns like for example

#ifdef __VMAWARE_DEBUG__
        debug("LOADED_DLLS:", "caught error, returned false");
#endif

the idea is to simplify/refactor approach above into something like

        debug("LOADED_DLLS:", "caught error, returned false");

meaning hide the #ifdef/endif wrapper over the debug() construction somehow

from my past experience I"ve implemented it like

#ifdef __VMAWARE_DEBUG__
#define debug() ...    // here we call the original routine passing all the params, etc
#else
#define debug()      // empty -> no code generated at all if no DEBUG mode
#endif

Let me know if you like this idea so I could take of it but first lets solve the original issue in the previous message Thank you

kernelwernel commented 6 months ago

the __VMAWARE_DEBUG__ macro is supposed to be defined based on the cmake build type. I designed it for development purposes without the intention of being used by anybody besides myself for internal debugging.

I sorta wanted the lib to not be verbose or output anything extra, that macro was meant to be undocumented, so yeah.

About the #ifdef/#endif preprocessors, you're right that it looks messy and there should be a far better solution to what I implemented. I'll try to work on it today if I have the time :)

greenozon commented 6 months ago

a try: https://github.com/kernelwernel/VMAware/pull/39

greenozon commented 6 months ago

BTW, well this is actually another topic, but I"m just curious - are these escape symbols working only under Linux console?

I"m asking cause on Windows I'm observing pretty much funny pic, eg:

image

greenozon commented 6 months ago

Maybe (another improvement) it worth to put those escapes into Linux (Mac?) only #ifdef, what do you think

kernelwernel commented 6 months ago

BTW, well this is actually another topic, but I"m just curious - are these escape symbols working only under Linux console?

I"m asking cause on Windows I'm observing pretty much funny pic, eg:

image

uhhhh.... not sure about that one. I haven't made a debug build on Windows yet so that's new to me. I'll remove the escape character sequences in the next commit. And yeah I'll only add them only for Linux and MacOS for now

kernelwernel commented 6 months ago

merged and fixed! :+1: