<br><br><div class="gmail_quote">On Tue, Apr 26, 2011 at 6:21 AM, Igor Stasenko <span dir="ltr">&lt;<a href="mailto:siguctua@gmail.com">siguctua@gmail.com</a>&gt;</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 &lt;<a href="mailto:eliot.miranda@gmail.com">eliot.miranda@gmail.com</a>&gt; wrote:<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; On Mon, Apr 25, 2011 at 6:39 PM, Igor Stasenko &lt;<a href="mailto:siguctua@gmail.com">siguctua@gmail.com</a>&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt; On 26 April 2011 03:05, Mariano Martinez Peck &lt;<a href="mailto:marianopeck@gmail.com">marianopeck@gmail.com</a>&gt; wrote:<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; Hi guys. I don&#39;t know why but with CMakeVMMaker the asserts are not working.  I can see the flags are being set correct in CmakeList.txt:<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; 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>

&gt;&gt; &gt;<br>
&gt;&gt;<br>
&gt;&gt; AFAIK, code checks<br>
&gt;&gt;<br>
&gt;&gt; #ifdef NDEBUG<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; which means<br>
&gt;&gt; &#39;if defined NDEBUG&#39;<br>
&gt;&gt;<br>
&gt;&gt; and so it doesn&#39;t matters if it = 1 or = 0<br>
&gt;&gt; because it is defined, but don&#39;t cares which value.<br>
&gt;&gt;<br>
&gt;&gt; Also,<br>
&gt;&gt; NDEBUG and DEBUGVM should be mutually exclusive?<br>
&gt;<br>
&gt; 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>

&gt; DEBUGVM includes some extra code that allows break-pointing jumping from the interpreter into machien code.  Arguably it could be eliminated but it&#39;ll be useful when we port to new ISAs.<br>
&gt; 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&#39;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&#39;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>
&gt;&gt; cat a.c<br>
<br>
#include &lt;stdio.h&gt;<br>
<br>
int main()<br>
{<br>
<br>
#ifdef NDEBUG<br>
printf (&quot;NDEBUG defined\n&quot;);<br>
#endif<br>
<br>
return 0;<br>
<br>
}<br>
<br>
Now see what happens:<br>
<br>
gcc a.c<br>
./a.out<br>
&lt;no output&gt;<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>
&gt; best,<br>
&gt; Eliot<br>
&gt;&gt;<br>
&gt;&gt; If first stands for &#39;no-debug&#39;  and second stands for &#39;debug vm&#39;..<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; &gt; I modified the StackInterpreter to this:<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; lookupMethodInClass: class<br>
&gt;&gt; &gt;     | currentClass dictionary found |<br>
&gt;&gt; &gt;     &lt;inline: false&gt;<br>
&gt;&gt; &gt;     self asserta: &#39;42&#39; = &#39;cuarenta y tres&#39;.<br>
&gt;&gt; &gt;     self assert: &#39;mariano&#39; = &#39;esta perdido&#39;.<br>
&gt;&gt; &gt;     self print: &#39;grrrr&#39;; cr.<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; .....<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; and only &#39;grrr&#39; is printed. The TWO previous assert are ignored.<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; I may be doing something very stupid...<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; thanks in advance,<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; Mariano<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; On Wed, Apr 13, 2011 at 8:06 PM, Igor Stasenko &lt;<a href="mailto:siguctua@gmail.com">siguctua@gmail.com</a>&gt; wrote:<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; On 13 April 2011 19:13, Mariano Martinez Peck &lt;<a href="mailto:marianopeck@gmail.com">marianopeck@gmail.com</a>&gt; wrote:<br>
&gt;&gt; &gt;&gt; &gt; I&#39;ve just commited the fix, but not the comment ;)<br>
&gt;&gt; &gt;&gt; &gt;<br>
&gt;&gt; &gt;&gt; &gt; Seriously, I don&#39;t know how we can document this kind of things.<br>
&gt;&gt; &gt;&gt; &gt; Putting such comments in #compilerFlagsRelease  or #compilerFlagsRelease<br>
&gt;&gt; &gt;&gt; &gt; doesn&#39;t make sense because they are aprox. 12 implementaions...I don&#39;t want<br>
&gt;&gt; &gt;&gt; &gt; to copy paste to all of them. Only in one? it doesn&#39;t make sense because<br>
&gt;&gt; &gt;&gt; &gt; people won&#39;t see it. So..how we document this kind of things?  I have no<br>
&gt;&gt; &gt;&gt; &gt; idea.<br>
&gt;&gt; &gt;&gt; &gt;<br>
&gt;&gt; &gt;&gt; &gt; The same with class comments. There are so many classes that copy pasting or<br>
&gt;&gt; &gt;&gt; &gt; documenting only one doesn&#39;t make sense.<br>
&gt;&gt; &gt;&gt; &gt;<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; The root class is enough.<br>
&gt;&gt; &gt;&gt; A subclasses should just say something like &#39;i am special for<br>
&gt;&gt; &gt;&gt; ___that__ and do things differently because i want __that__&#39;.<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; &gt; The only thing I though is doing something like this:<br>
&gt;&gt; &gt;&gt; &gt;<br>
&gt;&gt; &gt;&gt; &gt;<br>
&gt;&gt; &gt;&gt; &gt; compilerFlagsRelease<br>
&gt;&gt; &gt;&gt; &gt;     ^#(&#39;-g3&#39; &#39;-Os&#39; &#39;-fvisibility=hidden&#39; &#39;-funroll-loops&#39; &#39;-fasm-blocks&#39;<br>
&gt;&gt; &gt;&gt; &gt; &#39;-finline-functions&#39; &#39;-mfpmath=sse&#39; &#39;-fomit-frame-pointer&#39;<br>
&gt;&gt; &gt;&gt; &gt; &#39;-march=pentium-m&#39; &#39;-mtune=prescott&#39; &#39;-falign-functions=16&#39; &#39;-fno-gcse&#39;<br>
&gt;&gt; &gt;&gt; &gt; &#39;-fno-cse-follow-jumps&#39; &#39;-std=gnu99&#39; &#39;-DBUILD_FOR_OSX&#39;<br>
&gt;&gt; &gt;&gt; &gt; &#39;-DUSE_INLINE_MEMORY_ACCESSORS&#39; &#39;-DLSB_FIRST&#39;<br>
&gt;&gt; &gt;&gt; &gt; &#39;-DUSE_INLINE_MEMORY_ACCESSORS&#39; &#39;-DHAVE_SYS_TIME_H&#39; &#39;-DHAVE_NANOSLEEP&#39;<br>
&gt;&gt; &gt;&gt; &gt; &#39;-DNDEBUG=0&#39; , self debugVMFlag: true,  &#39;-DCOGMTVM=0&#39;<br>
&gt;&gt; &gt;&gt; &gt; &#39;-DUSE_GLOBAL_STRUCT=0&#39; &#39;-DBASE_HEADER_SIZE=4&#39;)<br>
&gt;&gt; &gt;&gt; &gt;<br>
&gt;&gt; &gt;&gt; &gt;&gt;&gt;debugVMFlagEnable: boolean<br>
&gt;&gt; &gt;&gt; &gt; &quot;THIS flag is blagh...blh...&quot;<br>
&gt;&gt; &gt;&gt; &gt; ^ &#39;-DDEBUGVM=&#39;, boolean asNumber asString<br>
&gt;&gt; &gt;&gt; &gt;<br>
&gt;&gt; &gt;&gt; &gt; or something like that...<br>
&gt;&gt; &gt;&gt; &gt;<br>
&gt;&gt; &gt;&gt; &gt;<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; This knowledge is important. It of course a question where to put that,<br>
&gt;&gt; &gt;&gt; but that&#39;s exactly why i didn&#39;t wanted to use autoconf to generate<br>
&gt;&gt; &gt;&gt; config.h file, which contains like 50 various flags,<br>
&gt;&gt; &gt;&gt; without any clues, where these flags being used, and in what<br>
&gt;&gt; &gt;&gt; situations they should be turned on or off..<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; So, later we could step over every flag and properly document them,<br>
&gt;&gt; &gt;&gt; and like that, for people who will come later, we will have an idea<br>
&gt;&gt; &gt;&gt; what are need to deal with and why.<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; &gt; cheers<br>
&gt;&gt; &gt;&gt; &gt;<br>
&gt;&gt; &gt;&gt; &gt; Mariano<br>
&gt;&gt; &gt;&gt; &gt;<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; --<br>
&gt;&gt; &gt;&gt; Best regards,<br>
&gt;&gt; &gt;&gt; Igor Stasenko AKA sig.<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; --<br>
&gt;&gt; &gt; Mariano<br>
&gt;&gt; &gt; <a href="http://marianopeck.wordpress.com" target="_blank">http://marianopeck.wordpress.com</a><br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; --<br>
&gt;&gt; Best regards,<br>
&gt;&gt; Igor Stasenko AKA sig.<br>
&gt;<br>
&gt;<br>
&gt;<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>