debug.c

来自「早期freebsd实现」· C语言 代码 · 共 159 行

C
159
字号
/* * Copyright (c) 1983 The Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright *    notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright *    notice, this list of conditions and the following disclaimer in the *    documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software *    must display the following acknowledgement: *	This product includes software developed by the University of *	California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors *    may be used to endorse or promote products derived from this software *    without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */#ifndef lintstatic char sccsid[] = "@(#)debug.c	5.3 (Berkeley) 6/1/90";#endif /* not lint *//* *  Debug routines */#include "defs.h"#include "tree.h"#include "operators.h"#include "eval.h"#include "events.h"#include "symbols.h"#include "scanner.h"#include "source.h"#include "object.h"#include "main.h"#include "mappings.h"#include "process.h"#include "machine.h"#include "debug.h"#include <signal.h>public boolean tracetree;	/* trace building of parse trees */public boolean traceeval;	/* trace tree evaluation *//* * Dynamically turn on/off a debug flag, or display some information. */public debug (p)Node p;{    int code;    code = p->value.lcon;    switch (code) {	case 0:	    puts("debugging flags:");	    puts("    1        trace scanner return values");	    puts("    2        trace breakpoints");	    puts("    3        trace execution");	    puts("    4        trace tree building");	    puts("    5        trace tree evaluation");	    puts("   -[12345]  turns off corresponding flag");	    puts("    6        dump function table");	    break;	case 1:	case -1:#           ifdef LEXDEBUG		lexdebug = (boolean) (code > 0);#           else		error("can't debug scanner (not compiled with LEXDEBUG)");#           endif	    break;	case 2:	case -2:	    tracebpts = (boolean) (code > 0);	    break;	case 3:	case -3:	    traceexec = (boolean) (code > 0);	    break;	case 4:	case -4:	    tracetree = (boolean) (code > 0);	    break;	case 5:	case -5:	    traceeval = (boolean) (code > 0);	    break;	case 6:	    dumpfunctab();	    break;	default:	    error("unknown debug flag");	    break;    }}private String leafname[] = {    "nop", "name", "sym", "lcon", "fcon", "scon", "rval", "index"};public String opname (op)Operator op;{    String s;    static char buf[100];    switch (op) {	case O_ITOF:	    s = "itof";	    break;	case O_ENDX:	    s = "endx";	    break;	case O_QLINE:	    s = "qline";	    break;	default:	    if (ord(op) <= ord(O_INDEX)) {		s = leafname[ord(op)];	    } else {		s = opinfo[ord(op)].opstring;		if (s == nil) {		    sprintf(buf, "[op %d]", op);		    s = buf;		}	    }	    break;    }    return s;}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?