Main Page | Data Structures | File List | Data Fields | Globals

tracesyms.c

Go to the documentation of this file.
00001 /*
00002  *                     OpenBIOS - free your system!
00003  *                         ( FCode tokenizer )
00004  *
00005  *  This program is part of a free implementation of the IEEE 1275-1994
00006  *  Standard for Boot (Initialization Configuration) Firmware.
00007  *
00008  *  Copyright (C) 2001-2005 Stefan Reinauer, <stepan@openbios.org>
00009  *
00010  *  This program is free software; you can redistribute it and/or modify
00011  *  it under the terms of the GNU General Public License as published by
00012  *  the Free Software Foundation; version 2 of the License.
00013  *
00014  *  This program is distributed in the hope that it will be useful,
00015  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  *  GNU General Public License for more details.
00018  *
00019  *  You should have received a copy of the GNU General Public License
00020  *  along with this program; if not, write to the Free Software
00021  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA, 02110-1301 USA
00022  *
00023  */
00024 
00025 /* **************************************************************************
00026  *
00027  *      Support routines for "Trace-Symbols" debugging feature
00028  *
00029  *      (C) Copyright 2006 IBM Corporation.  All Rights Reserved.
00030  *      Module Author:  David L. Paktor    dlpaktor@us.ibm.com
00031  *
00032  **************************************************************************** */
00033 
00034 /* **************************************************************************
00035  *
00036  *      Functions Exported:
00037  *          add_to_trace_list         Add the given name to the Trace List
00038  *          show_initial_traces       Show pre-defined names the user
00039  *                                        asked to Trace (if any)
00040  *          is_on_trace_list          Indicate whether the given name is
00041  *                                        on the Trace List
00042  *
00043  **************************************************************************** */
00044 
00045 #include <string.h>
00046 
00047 #include "tracesyms.h"
00048 #include "errhandler.h"
00049 
00050 
00051 /* **************************************************************************
00052  *
00053  *          Internal Static Variables
00054  *     trace_list     Pointer to last entry in the Trace List linked-list
00055  *                        data structure
00056  *              
00057  *              
00058  *
00059  **************************************************************************** */
00060 
00061 /* **************************************************************************
00062  *
00063  *      Internal (Static) Structures:
00064  *          trace_entry_t           Linked-list of entries in the Trace List
00065  *
00066  *   Fields:
00067  *       tracee              Name of the symbol to be traced
00068  *       prev                Pointer to previous entry in the linked-list
00069  *
00070  **************************************************************************** */
00071 
00072 typedef struct trace_entry {
00073       char *tracee;
00074       struct trace_entry *prev;
00075 } trace_entry_t;
00076 
00077 static trace_entry_t *trace_list = NULL;
00078 
00079 
00080 
00081 /* **************************************************************************
00082  *
00083  *      Function name:  add_to_trace_list
00084  *      Synopsis:       Add the given name to the Trace List
00085  *                      
00086  *
00087  *      Inputs:
00088  *         Parameters:
00089  *             trace_symb            Name of the symbol to be added
00090  *         Local Static Variables:
00091  *             trace_list           Pointer to the Trace List
00092  *
00093  *      Outputs:
00094  *         Returned Value:          NONE
00095  *         Local Static Variables:
00096  *             trace_list           Points to new entry in Trace List
00097  *         Memory Allocated
00098  *             For Trace List entry
00099  *             For copy of Symbol Name
00100  *         When Freed?
00101  *             Never.  Well, only on termination of the program.  Trace-list
00102  *                 endures for the entire batch of tokenizations.
00103  *
00104  *      Error Detection:
00105  *          Memory allocation failure is a FATAL error.
00106  *
00107  **************************************************************************** */
00108 
00109 void add_to_trace_list( char *trace_symb)
00110 {
00111     trace_entry_t *new_t_l_entry = safe_malloc( sizeof( trace_entry_t),
00112         "adding to trace-list");
00113     new_t_l_entry->tracee = strdup( trace_symb);
00114     new_t_l_entry->prev = trace_list;
00115 
00116     trace_list = new_t_l_entry;
00117 }
00118 
00119 
00120 /* **************************************************************************
00121  *
00122  *      Function name:  is_on_trace_list
00123  *      Synopsis:       Indicate whether the given name is on the Trace List
00124  *
00125  *      Inputs:
00126  *         Parameters:
00127  *             symb_name            Symbol-name to test
00128  *         Local Static Variables:
00129  *             trace_list           Pointer to the Trace List
00130  *
00131  *      Outputs:
00132  *         Returned Value:          TRUE if Symbol-name is on the Trace List
00133  *
00134  **************************************************************************** */
00135 
00136 bool is_on_trace_list( char *symb_name)
00137 {
00138     bool retval = FALSE;
00139     trace_entry_t *test_entry = trace_list;
00140     while ( test_entry != NULL )
00141     {
00142         if ( strcasecmp( symb_name, test_entry->tracee) == 0 )
00143         {
00144             retval = TRUE;
00145             break;
00146         }
00147         test_entry = test_entry->prev;
00148     }
00149     return ( retval );
00150 }
00151 
00152 
00153 /* **************************************************************************
00154  *
00155  *      Still to be done:
00156  *          Implement a function -- name it  show_initial_traces  --
00157  *              that will show any pre-defined names the user asked
00158  *              to Trace.  That is, if any of the names the user asked
00159  *              to Trace belongs to a pre-defined function, macro or
00160  *              directive, then, at the beginning of the output, issue 
00161  *              Advisory Messages identifying the scope of those names.
00162  * 
00163  *          E.g, if the user had  -T 3DUP  -T SWAP   the function would
00164  *              issue Messages like:
00165  *          3DUP is pre-defined as a Macro with Global scope
00166  *          SWAP is pre-defined with Global scope
00167  *          SWAP is pre-defined in Tokenizer-Escape mode
00168  * 
00169  *          The names would, of course, remain on the Trace List and
00170  *              any re-definitions of them would be reported.
00171  *
00172  **************************************************************************** */

Generated on Fri Aug 18 14:03:39 2006 for Toke1.0 by  doxygen 1.4.4