Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 29 Jan 1999 02:08:28 +0900 (JST)
From:      dcs@newsguy.com
To:        FreeBSD-gnats-submit@FreeBSD.ORG
Subject:   bin/9756: ficl trace facilities hopelessly buggy
Message-ID:  <199901281708.CAA00423@daniel.sobral>

next in thread | raw e-mail | index | archive | help

>Number:         9756
>Category:       bin
>Synopsis:       ficl trace facility is full of bugs
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Jan 28 09:10:00 PST 1999
>Closed-Date:
>Last-Modified:
>Originator:     Daniel C. Sobral
>Release:        FreeBSD 4.0-CURRENT i386
>Organization:
>Environment:

	Current, since trace facilities were added (not sure if RELENG_3
has them or not, though).

>Description:

	When cutting&pasting from "see" into ficlExec(), a variable
used by almost the whole trace code was left unitialized. It was not
caught because I'm incredibly lucky (or unlucky) in that no code I
traced ever exercized (sp?) these parts of the code.

	Also, the whole code was badly idented.

>How-To-Repeat:

	: example if then ;
	1 trace! example

>Fix:
	
	Apply the following fix:

	
--- src/sys/boot/ficl/ficl.c	1999/01/28 06:34:15	1.11
+++ src/sys/boot/ficl/ficl.c	1999/01/28 16:54:34
@@ -209,88 +209,87 @@
         for (;;)
         {
 #ifdef FICL_TRACE
-        char buffer[40];
-	CELL *pc;
+	    CELL c;
+            char buffer[40];
 #endif
             tempFW = *pVM->ip++;
 #ifdef FICL_TRACE
-        if (ficl_trace && isAFiclWord(tempFW))
-        {
-	extern void literalParen(FICL_VM*);
-	extern void stringLit(FICL_VM*);
-	extern void ifParen(FICL_VM*);
-	extern void branchParen(FICL_VM*);
-	extern void qDoParen(FICL_VM*);
-	extern void doParen(FICL_VM*);
-	extern void loopParen(FICL_VM*);
-	extern void plusLoopParen(FICL_VM*);
-
-            if      (tempFW->code == literalParen)
+            if (ficl_trace && isAFiclWord(tempFW))
             {
-                CELL v = *++pc;
-                if (isAFiclWord(v.p))
+	        extern void literalParen(FICL_VM*);
+	        extern void stringLit(FICL_VM*);
+	        extern void ifParen(FICL_VM*);
+	        extern void branchParen(FICL_VM*);
+	        extern void qDoParen(FICL_VM*);
+	        extern void doParen(FICL_VM*);
+	        extern void loopParen(FICL_VM*);
+	        extern void plusLoopParen(FICL_VM*);
+    
+                if      (tempFW->code == literalParen)
                 {
-                    FICL_WORD *pLit = (FICL_WORD *)v.p;
-                    sprintf(buffer, "    literal %.*s (%#lx)",
-                        pLit->nName, pLit->name, v.u);
+               	    c = *(pVM->ip);
+               	    if (isAFiclWord(c.p))
+               	    {
+                   	    FICL_WORD *pLit = (FICL_WORD *)c.p;
+                   	    sprintf(buffer, "    literal %.*s (%#lx)",
+                       	    pLit->nName, pLit->name, c.u);
+               	    }
+               	    else
+                   	    sprintf(buffer, "    literal %ld (%#lx)", c.i, c.u);
                 }
-                else
-                    sprintf(buffer, "    literal %ld (%#lx)", v.i, v.u);
-            }
-            else if (tempFW->code == stringLit)
-            {
-                FICL_STRING *sp = (FICL_STRING *)(void *)++pc;
-                pc = (CELL *)alignPtr(sp->text + sp->count + 1) - 1;
-                sprintf(buffer, "    s\" %.*s\"", sp->count, sp->text);
-            }
-            else if (tempFW->code == ifParen)
-            {
-                CELL c = *++pc;
-                if (c.i > 0)
-                    sprintf(buffer, "    if / while (branch rel %ld)", c.i);
-                else
-                    sprintf(buffer, "    until (branch rel %ld)", c.i);
-            }
-            else if (tempFW->code == branchParen)
-            {
-                CELL c = *++pc;
-                if (c.i > 0)
-                    sprintf(buffer, "    else (branch rel %ld)", c.i);
-                else
-                    sprintf(buffer, "    repeat (branch rel %ld)", c.i);
-            }
-            else if (tempFW->code == qDoParen)
-            {
-                CELL c = *++pc;
-                sprintf(buffer, "    ?do (leave abs %#lx)", c.u);
-            }
-            else if (tempFW->code == doParen)
-            {
-                CELL c = *++pc;
-                sprintf(buffer, "    do (leave abs %#lx)", c.u);
-            }
-            else if (tempFW->code == loopParen)
-            {
-                CELL c = *++pc;
-                sprintf(buffer, "    loop (branch rel %#ld)", c.i);
-            }
-            else if (tempFW->code == plusLoopParen)
-            {
-                CELL c = *++pc;
-                sprintf(buffer, "    +loop (branch rel %#ld)", c.i);
+                else if (tempFW->code == stringLit)
+                {
+               	    FICL_STRING *sp = (FICL_STRING *)(void *)pVM->ip;
+               	    sprintf(buffer, "    s\" %.*s\"", sp->count, sp->text);
+                }
+                else if (tempFW->code == ifParen)
+                {
+               	    c = *pVM->ip;
+               	    if (c.i > 0)
+                   	    sprintf(buffer, "    if / while (branch rel %ld)", c.i);
+               	    else
+                   	    sprintf(buffer, "    until (branch rel %ld)", c.i);
+                }
+                else if (tempFW->code == branchParen)
+                {
+               	    c = *pVM->ip;
+               	    if (c.i > 0)
+                   	    sprintf(buffer, "    else (branch rel %ld)", c.i);
+               	    else
+                   	    sprintf(buffer, "    repeat (branch rel %ld)", c.i);
+                }
+                else if (tempFW->code == qDoParen)
+                {
+               	    c = *pVM->ip;
+               	    sprintf(buffer, "    ?do (leave abs %#lx)", c.u);
+                }
+                else if (tempFW->code == doParen)
+                {
+               	    c = *pVM->ip;
+               	    sprintf(buffer, "    do (leave abs %#lx)", c.u);
+                }
+                else if (tempFW->code == loopParen)
+                {
+               	    c = *pVM->ip;
+               	    sprintf(buffer, "    loop (branch rel %#ld)", c.i);
+                }
+                else if (tempFW->code == plusLoopParen)
+                {
+               	    c = *pVM->ip;
+               	    sprintf(buffer, "    +loop (branch rel %#ld)", c.i);
+                }
+                else /* default: print word's name */
+                {
+               	    sprintf(buffer, "    %.*s", tempFW->nName, tempFW->name);
+                }
+    
+                vmTextOut(pVM, buffer, 1);
             }
-            else /* default: print word's name */
+            else if (ficl_trace) /* probably not a word - punt and print value */
             {
-                sprintf(buffer, "    %.*s", tempFW->nName, tempFW->name);
+           	    sprintf(buffer, "    %ld (%#lx)", ((CELL*)pVM->ip)->i, ((CELL*)pVM->ip)->u);
+           	    vmTextOut(pVM, buffer, 1);
             }
-
-            vmTextOut(pVM, buffer, 1);
-        }
-        else if (ficl_trace) /* probably not a word - punt and print value */
-        {
-            sprintf(buffer, "    %ld (%#lx)", pc->i, pc->u);
-            vmTextOut(pVM, buffer, 1);
-        }
 #endif FICL_TRACE
             /*
             ** inline code for
>Release-Note:
>Audit-Trail:
>Unformatted:

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199901281708.CAA00423>