From owner-freebsd-bugs Thu Jan 28 09:10:08 1999 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id JAA12422 for freebsd-bugs-outgoing; Thu, 28 Jan 1999 09:10:08 -0800 (PST) (envelope-from owner-freebsd-bugs@FreeBSD.ORG) Received: from freefall.freebsd.org (freefall.FreeBSD.ORG [204.216.27.21]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id JAA12335 for ; Thu, 28 Jan 1999 09:10:01 -0800 (PST) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.9.2/8.9.2) id JAA72490; Thu, 28 Jan 1999 09:10:00 -0800 (PST) (envelope-from gnats@FreeBSD.org) Received: from peach.ocn.ne.jp (peach.ocn.ne.jp [210.145.254.87]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id JAA12164 for ; Thu, 28 Jan 1999 09:09:11 -0800 (PST) (envelope-from dcs@newsguy.com) Received: from daniel.sobral by peach.ocn.ne.jp (8.9.1a/OCN) id CAA20570; Fri, 29 Jan 1999 02:09:05 +0900 (JST) Received: (from root@localhost) by daniel.sobral (8.9.1/8.9.2) id CAA00423; Fri, 29 Jan 1999 02:08:28 +0900 (JST) (envelope-from root) Message-Id: <199901281708.CAA00423@daniel.sobral> Date: Fri, 29 Jan 1999 02:08:28 +0900 (JST) From: dcs@newsguy.com Reply-To: dcs@newsguy.com To: FreeBSD-gnats-submit@FreeBSD.ORG X-Send-Pr-Version: 3.2 Subject: bin/9756: ficl trace facilities hopelessly buggy Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org >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