|
Message
From: =?unknown-8bit?Q?Gy=F6rgy?= 'nog' Jeney<nog@s...>
Date: Sat Mar 26 11:45:27 CET 2005
Subject: [openrisc] [or1ksim #67] Add traces to the config file parsing
routines
Hi,I spend a large amount of time trying to figure out why the debug section in my config file never got parsed (I neglected to terminate a comment), so I came up with this. Others will probably find it usefull aswell.
ChangeLog: * Add traces to the config file parsing routines.
nog. -------------- next part -------------- --- support/dbchs.h 2005-03-22 18:58:56.000000000 +0100 +++ /home/nog/or1ksim-split/support/dbchs.h 2005-03-26 11:38:14.000000000 +0100 @@ -25,3 +25,4 @@ DECLARE_DEBUG_CHANNEL(pic) DECLARE_DEBUG_CHANNEL(tick) DECLARE_DEBUG_CHANNEL(uart) +DECLARE_DEBUG_CHANNEL(config) diff -urp --unidirectional-new-file /home/nog/or1ksim-split/sim-config.c ./sim-config.c --- /home/nog/or1ksim-split/sim-config.c 2005-03-26 11:40:25.000000000 +0100 +++ ./sim-config.c 2005-03-26 11:39:46.000000000 +0100 @@ -49,6 +49,8 @@ Foundation, Inc., 675 Mass Ave, Cambridg #include "debug.h" +DEFAULT_DEBUG_CHANNEL(config); + #define WARNING(s) fprintf (stderr, "WARNING: config.%s: %s\n", cur_section->name, (s)) #define MERROR(s) {fprintf (stderr, "ERROR: %s\n", s); if (runtime.sim.init) exit (1);} @@ -617,12 +619,33 @@ void reg_config_secs(void) reg_test_sec(); } +/* Returns a user friendly string of type */ +static char *get_paramt_str(enum param_t type) +{ + switch(type) { + case paramt_int: + return "integer"; + case paramt_addr: + return "address"; + case paramt_str: + return "string"; + case paramt_word: + return "word"; + case paramt_none: + return "none"; + } + return ""; +} + void reg_config_param(struct config_section *sec, const char *param, enum param_t type, void (*param_cb)(union param_val, void *)) { struct config_param *new = malloc(sizeof(struct config_param)); + TRACE("Registering config param `%s' to section `%s', type %s\n", param, + sec->name, get_paramt_str(type)); + if(!new) { fprintf(stderr, "Out-of-memory\n"); exit(1); @@ -646,6 +669,8 @@ struct config_section *reg_config_sec(co { struct config_section *new = malloc(sizeof(struct config_section)); + TRACE("Registering config section `%s'\n", section); + if(!new) { fprintf(stderr, "Out-of-memory\n"); exit(1); @@ -751,6 +776,7 @@ void read_script_file (char *filename) fprintf (stderr, "%s: ERROR: Section name required.\n", local ? filename : ctmp); exit (1); } + TRACE("Came across section `%s'\n", param); for (cur = sections; cur; cur = cur->next) if (strcmp (cur->name, param) == 0) { cur_section = cur; @@ -782,6 +808,8 @@ void read_script_file (char *filename) } else { struct config_param *cur_param; char *cur_p; + TRACE("Came across parameter `%s' in section `%s'\n", param, + cur_section->name); for (cur_param = cur_section->params; cur_param; cur_param = cur_param->next) if (strcmp (cur_param->name, param) == 0) { break;
|
 |