<br><br><div class="gmail_quote">On Tue, Apr 26, 2011 at 6:21 AM, Igor Stasenko <span dir="ltr"><<a href="mailto:siguctua@gmail.com">siguctua@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im"><br>
On 26 April 2011 04:03, Eliot Miranda <<a href="mailto:eliot.miranda@gmail.com">eliot.miranda@gmail.com</a>> wrote:<br>
><br>
><br>
><br>
> On Mon, Apr 25, 2011 at 6:39 PM, Igor Stasenko <<a href="mailto:siguctua@gmail.com">siguctua@gmail.com</a>> wrote:<br>
>><br>
>> On 26 April 2011 03:05, Mariano Martinez Peck <<a href="mailto:marianopeck@gmail.com">marianopeck@gmail.com</a>> wrote:<br>
>> ><br>
>> > Hi guys. I don't know why but with CMakeVMMaker the asserts are not working. I can see the flags are being set correct in CmakeList.txt:<br>
>> ><br>
>> > add_definitions(-arch i386 -mmacosx-version-min=10.5 -g3 -O0 -msse3 -funroll-loops -fasm-blocks -finline-functions -mfpmath=sse -march=pentium-m -falign-functions=16 -fno-gcse -fno-cse-follow-jumps -std=gnu99 -DBUILD_FOR_OSX -DUSE_INLINE_MEMORY_ACCESSORS -DLSB_FIRST -DHAVE_SYS_TIME_H -DHAVE_NANOSLEEP -DNDEBUG=1 -DDEBUGVM=1 -DCOGMTVM=1 -DUSE_GLOBAL_STRUCT=0 -DBASE_HEADER_SIZE=4 -DCOGVM)<br>
>> ><br>
>><br>
>> AFAIK, code checks<br>
>><br>
>> #ifdef NDEBUG<br>
>><br>
>><br>
>> which means<br>
>> 'if defined NDEBUG'<br>
>><br>
>> and so it doesn't matters if it = 1 or = 0<br>
>> because it is defined, but don't cares which value.<br>
>><br>
>> Also,<br>
>> NDEBUG and DEBUGVM should be mutually exclusive?<br>
><br>
> NO!! NO!! NO!! [ :) ]. I said earlier, NDEBUG is a linux-ism for enabling asserts. See /usr/include/assert.h. So if defined(NDEBUG) assert(foo) does nothing, but if !defined(NDEBUG) assert(foo) prints a warning and in unix/linux aborts, but in Cog continues.<br>
> DEBUGVM includes some extra code that allows break-pointing jumping from the interpreter into machien code. Arguably it could be eliminated but it'll be useful when we port to new ISAs.<br>
> I said all this last week. Please take note this time :)<br>
<br>
<br>
</div>But hey, i insist that they are mutually exclusive. </blockquote><div><br></div><div>You can insist all you like but you're wrong. NDEBUG controls assertions and these are orthogonal to the enilopmart debugging introduced by using DEBUGVM. Simple as that. They are *not* mutually exclusive.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">See, if i want to<br>
build a debug version of VM, i should use<br>
-DDEBUGVM=1<br>
but should not use<br>
-DNDEBUG<br>
because otherwise all assertions will be suppressed, which is not what<br>
i would want in debug version of VM.<br>
<br>
<br>
AFAIK, windows also using NDEBUG,<br>
but my main comment was about that it is used wrongly.<br>
<br>
The check<br>
<br>
if defined(NDEBUG)<br>
<br>
will always pass whether you use -DNDEBUG=1 or -DNDEBUG=0<br>
<br>
because it checks if given symbol are defined, it doesn't cares about<br>
its value!!!<br>
<br>
So, a proper use would be to either omit -DNDEBUG at all, or<br>
include it. But not like currently, changing its value between 0 or 1.<br>
<br>
<br>
Here the code from assert.h:<br>
<br>
#ifdef NDEBUG<br>
#define assert(e) ((void)0)<br>
#else<br>
....<br>
<br>
<br>
And here the sample code for testing it:<br>
<br>
>> cat a.c<br>
<br>
#include <stdio.h><br>
<br>
int main()<br>
{<br>
<br>
#ifdef NDEBUG<br>
printf ("NDEBUG defined\n");<br>
#endif<br>
<br>
return 0;<br>
<br>
}<br>
<br>
Now see what happens:<br>
<br>
gcc a.c<br>
./a.out<br>
<no output><br>
<br>
gcc -DNDEBUG=0 a.c<br>
./a.out<br>
NDEBUG defined<br>
<br>
gcc -DNDEBUG=1 a.c<br>
./a.out<br>
NDEBUG defined<br>
<br>
gcc -DNDEBUG=1 a.c<br>
./a.out<br>
NDEBUG defined<br>
<br>
gcc -DNDEBUG=ZORK a.c<br>
./a.out<br>
NDEBUG defined<br>
<div><div></div><div class="h5"><br>
<br>
> best,<br>
> Eliot<br>
>><br>
>> If first stands for 'no-debug' and second stands for 'debug vm'..<br>
>><br>
>><br>
>> > I modified the StackInterpreter to this:<br>
>> ><br>
>> > lookupMethodInClass: class<br>
>> > | currentClass dictionary found |<br>
>> > <inline: false><br>
>> > self asserta: '42' = 'cuarenta y tres'.<br>
>> > self assert: 'mariano' = 'esta perdido'.<br>
>> > self print: 'grrrr'; cr.<br>
>> ><br>
>> > .....<br>
>> ><br>
>> > and only 'grrr' is printed. The TWO previous assert are ignored.<br>
>> ><br>
>> > I may be doing something very stupid...<br>
>> ><br>
>> > thanks in advance,<br>
>> ><br>
>> > Mariano<br>
>> ><br>
>> ><br>
>> ><br>
>> > On Wed, Apr 13, 2011 at 8:06 PM, Igor Stasenko <<a href="mailto:siguctua@gmail.com">siguctua@gmail.com</a>> wrote:<br>
>> >><br>
>> >> On 13 April 2011 19:13, Mariano Martinez Peck <<a href="mailto:marianopeck@gmail.com">marianopeck@gmail.com</a>> wrote:<br>
>> >> > I've just commited the fix, but not the comment ;)<br>
>> >> ><br>
>> >> > Seriously, I don't know how we can document this kind of things.<br>
>> >> > Putting such comments in #compilerFlagsRelease or #compilerFlagsRelease<br>
>> >> > doesn't make sense because they are aprox. 12 implementaions...I don't want<br>
>> >> > to copy paste to all of them. Only in one? it doesn't make sense because<br>
>> >> > people won't see it. So..how we document this kind of things? I have no<br>
>> >> > idea.<br>
>> >> ><br>
>> >> > The same with class comments. There are so many classes that copy pasting or<br>
>> >> > documenting only one doesn't make sense.<br>
>> >> ><br>
>> >><br>
>> >> The root class is enough.<br>
>> >> A subclasses should just say something like 'i am special for<br>
>> >> ___that__ and do things differently because i want __that__'.<br>
>> >><br>
>> >><br>
>> >> > The only thing I though is doing something like this:<br>
>> >> ><br>
>> >> ><br>
>> >> > compilerFlagsRelease<br>
>> >> > ^#('-g3' '-Os' '-fvisibility=hidden' '-funroll-loops' '-fasm-blocks'<br>
>> >> > '-finline-functions' '-mfpmath=sse' '-fomit-frame-pointer'<br>
>> >> > '-march=pentium-m' '-mtune=prescott' '-falign-functions=16' '-fno-gcse'<br>
>> >> > '-fno-cse-follow-jumps' '-std=gnu99' '-DBUILD_FOR_OSX'<br>
>> >> > '-DUSE_INLINE_MEMORY_ACCESSORS' '-DLSB_FIRST'<br>
>> >> > '-DUSE_INLINE_MEMORY_ACCESSORS' '-DHAVE_SYS_TIME_H' '-DHAVE_NANOSLEEP'<br>
>> >> > '-DNDEBUG=0' , self debugVMFlag: true, '-DCOGMTVM=0'<br>
>> >> > '-DUSE_GLOBAL_STRUCT=0' '-DBASE_HEADER_SIZE=4')<br>
>> >> ><br>
>> >> >>>debugVMFlagEnable: boolean<br>
>> >> > "THIS flag is blagh...blh..."<br>
>> >> > ^ '-DDEBUGVM=', boolean asNumber asString<br>
>> >> ><br>
>> >> > or something like that...<br>
>> >> ><br>
>> >> ><br>
>> >><br>
>> >> This knowledge is important. It of course a question where to put that,<br>
>> >> but that's exactly why i didn't wanted to use autoconf to generate<br>
>> >> config.h file, which contains like 50 various flags,<br>
>> >> without any clues, where these flags being used, and in what<br>
>> >> situations they should be turned on or off..<br>
>> >><br>
>> >> So, later we could step over every flag and properly document them,<br>
>> >> and like that, for people who will come later, we will have an idea<br>
>> >> what are need to deal with and why.<br>
>> >><br>
>> >> > cheers<br>
>> >> ><br>
>> >> > Mariano<br>
>> >> ><br>
>> >><br>
>> >> --<br>
>> >> Best regards,<br>
>> >> Igor Stasenko AKA sig.<br>
>> ><br>
>> ><br>
>> ><br>
>> > --<br>
>> > Mariano<br>
>> > <a href="http://marianopeck.wordpress.com" target="_blank">http://marianopeck.wordpress.com</a><br>
>> ><br>
>> ><br>
>> ><br>
>><br>
>><br>
>><br>
>> --<br>
>> Best regards,<br>
>> Igor Stasenko AKA sig.<br>
><br>
><br>
><br>
<br>
<br>
<br>
</div></div>--<br>
<div><div></div><div class="h5">Best regards,<br>
Igor Stasenko AKA sig.<br>
</div></div></blockquote></div><br>