URL
https://opencores.org/ocsvn/or1k/or1k/trunk
Subversion Repositories or1k
Compare Revisions
- This comparison shows the changes necessary to convert path
/
- from Rev 1388 to Rev 1389
- ↔ Reverse comparison
Rev 1388 → Rev 1389
/trunk/or1ksim/sim-cmd.c
134,6 → 134,7
PRINTF("dv <fromaddr> [<toaddr>] [<modname>] - dumps memory as verilog (use redirect)\n"); |
PRINTF("dh <fromaddr> [<toaddr>] - dumps memory as hex code (use redirect)\n"); |
PRINTF("<cmd> > <filename> - redirect simulator stdout to <filename> (and not emulated PRINTF)\n"); |
PRINTF("setdbch - toggles debug channels on/off\n"); |
PRINTF("set <section> <item> = <param> - set configuration. See sim.cfg for more information.\n"); |
PRINTF("debug - toggles simulator debug mode\n"); |
mp_help (); |
423,6 → 424,16
return 0; |
} |
|
static int sim_cmd_setdbch(int argc, char **argv) /* Toggle debug channel on/off */ |
{ |
if(argc != 2) { |
PRINTF("setdbch <channel>\n"); |
return 0; |
} |
parse_dbchs(argv[1]); |
return 0; |
} |
|
static int sim_cmd_debug(int argc, char **argv) /* debug mode */ |
{ |
config.sim.debug ^= 1; |
485,6 → 496,7
{ "stats", sim_cmd_stats }, |
{ "info", sim_cmd_info }, |
{ "run", sim_cmd_run }, |
{ "setdbch", sim_cmd_setdbch }, |
{ "debug", sim_cmd_debug }, |
{ "profile", sim_cmd_profile }, |
{ "mprofile", sim_cmd_mprofile }, |
/trunk/or1ksim/sim-config.c
227,6 → 227,10
if (strcmp(*argv, "--output-cfg") == 0) { |
runtime.sim.output_cfg = 1; |
argv++; argc--; |
} else |
if (strcmp(*argv, "-d") == 0) { |
parse_dbchs(*(++argv)); |
argv++; argc -= 2; |
} else { |
fprintf(stderr, "Unknown option: %s\n", *argv); |
return 1; |
/trunk/or1ksim/support/debug.c
0,0 → 1,123
/* debug.c -- Debug channel support code |
|
|
This file is part of OpenRISC 1000 Architectural Simulator. |
|
This program is free software; you can redistribute it and/or modify |
it under the terms of the GNU General Public License as published by |
the Free Software Foundation; either version 2 of the License, or |
(at your option) any later version. |
|
This program is distributed in the hope that it will be useful, |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
GNU General Public License for more details. |
|
You should have received a copy of the GNU General Public License |
along with this program; if not, write to the Free Software |
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ |
|
#include <stdio.h> |
#include <stdarg.h> |
#include <string.h> |
|
#define __ORSIM_NO_DEC_DBCH |
#include "debug.h" |
|
#define DECLARE_DEBUG_CHANNEL(dbch) char __orsim_dbch_##dbch[] = "\0"#dbch; |
#include "dbchs.h" |
#undef DECLARE_DEBUG_CHANNEL |
|
#define DECLARE_DEBUG_CHANNEL(dbch) __orsim_dbch_##dbch, |
static char *__orsim_dbchs[] = { |
#include "dbchs.h" |
NULL }; |
#undef DECLARE_DEBUG_CHANNEL |
|
static const char *debug_classes[] = { "trace", "fixme", "warn", "err" }; |
|
void orsim_dbg_log(enum __ORSIM_DEBUG_CLASS dbcl, const char *dbch, |
const char *function, const char *format, ...) |
{ |
va_list ap; |
static int last_lf = 1; /* There *has* to be a better way */ |
|
if(!(dbch[0] & (1 << dbcl))) |
return; |
|
if(last_lf) |
fprintf(stderr, "%s:%s:%s: ", debug_classes[dbcl], dbch + 1, function); |
last_lf = format[strlen(format) - 1] == '\n'; /* This is wrong... */ |
va_start(ap, format); |
vfprintf(stderr, format, ap); |
va_end(ap); |
} |
|
void orsim_dbcl_set(enum __ORSIM_DEBUG_CLASS dbcl, char *dbch, int on) |
{ |
if(on) |
dbch[0] |= 1 << dbcl; |
else |
dbch[0] &= ~(1 << dbcl); |
} |
|
void orsim_dbcl_set_name(enum __ORSIM_DEBUG_CLASS dbcl, const char *dbch, int on) |
{ |
char **dbchs = __orsim_dbchs; |
|
for(dbchs = __orsim_dbchs; *dbchs; dbchs++) { |
if(!strcmp(*dbchs + 1, dbch)) { |
orsim_dbcl_set(dbcl, *dbchs, on); |
break; |
} |
} |
} |
|
void parse_dbchs(const char *str) |
{ |
enum __ORSIM_DEBUG_CLASS dbcl; |
int i; |
int disen; |
int all; |
const char *cend; |
|
while(*str) { |
cend = strpbrk(str, "+-"); |
if(cend == str) { |
all = 1; |
} else { |
for(i = 0; i < 5; i++) { |
if(!strncmp(str, debug_classes[i], cend - str)) { |
dbcl = i; |
break; |
} |
} |
if(i > 4) |
fprintf(stderr, "Unknown class specified\n"); |
all = 0; |
} |
disen = *cend == '+' ? 1 : 0; |
str = cend + 1; |
cend = strchr(str, ','); |
if(!cend) |
cend = str + strlen(str); |
for(i = 0; __orsim_dbchs[i]; i++) |
if(!strncmp(str, __orsim_dbchs[i] + 1, cend - str)) |
break; |
|
if(!__orsim_dbchs[i]) |
fprintf(stderr, "Unknown channel specified\n"); |
|
if(all) { |
orsim_dbcl_set(__ORSIM_DBCL_TRACE, __orsim_dbchs[i], disen); |
orsim_dbcl_set(__ORSIM_DBCL_FIXME, __orsim_dbchs[i], disen); |
orsim_dbcl_set(__ORSIM_DBCL_WARN, __orsim_dbchs[i], disen); |
orsim_dbcl_set(__ORSIM_DBCL_ERR, __orsim_dbchs[i], disen); |
} else |
orsim_dbcl_set(dbcl, __orsim_dbchs[i], disen); |
if(*cend) |
str = cend + 1; |
else |
str = cend; |
} |
} |
/trunk/or1ksim/support/Makefile.am
19,4 → 19,4
# |
|
noinst_LIBRARIES = libsupport.a |
libsupport_a_SOURCES = simprintf.c dumpverilog.c profile.c sched.c |
libsupport_a_SOURCES = simprintf.c dumpverilog.c profile.c sched.c debug.c |
/trunk/or1ksim/support/dbchs.h
0,0 → 1,21
/* dbchs.h -- Debug channel declarations |
|
|
This file is part of OpenRISC 1000 Architectural Simulator. |
|
This program is free software; you can redistribute it and/or modify |
it under the terms of the GNU General Public License as published by |
the Free Software Foundation; either version 2 of the License, or |
(at your option) any later version. |
|
This program is distributed in the hope that it will be useful, |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
GNU General Public License for more details. |
|
You should have received a copy of the GNU General Public License |
along with this program; if not, write to the Free Software |
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ |
|
|
/* Declatrations of all debug channels */ |
/trunk/or1ksim/support/debug.h
0,0 → 1,70
/* debug.h -- Trace function declarations |
Copyright 1999 Patrik Stridvall (for the wine project: www.winehq.com) |
|
|
This file is part of OpenRISC 1000 Architectural Simulator. |
(Most of it is ripped from the wine project's wine/include/wine/debug.h) |
|
This program is free software; you can redistribute it and/or modify |
it under the terms of the GNU General Public License as published by |
the Free Software Foundation; either version 2 of the License, or |
(at your option) any later version. |
|
This program is distributed in the hope that it will be useful, |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
GNU General Public License for more details. |
|
You should have received a copy of the GNU General Public License |
along with this program; if not, write to the Free Software |
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ |
|
#ifndef __DEBUG_H_INCLUDED |
#define __DEBUG_H_INCLUDED |
|
enum __ORSIM_DEBUG_CLASS { |
__ORSIM_DBCL_TRACE, |
__ORSIM_DBCL_FIXME, |
__ORSIM_DBCL_WARN, |
__ORSIM_DBCL_ERR, |
}; |
|
void orsim_dbg_log(enum __ORSIM_DEBUG_CLASS dbcl, const char *dbch, |
const char *function, const char *format, ...) |
__attribute__((format(printf, 4, 5))); |
void orsim_dbcl_set_name(enum __ORSIM_DEBUG_CLASS dbcl, const char *dbch, int on); |
void parse_dbchs(const char *str); |
|
#ifndef __ORSIM_DBG_USE_FUNC |
#define __ORSIM_DBG_USE_FUNC __FUNCTION__ |
#endif |
|
#define __ORSIM_DPRINTF(dbcl, dbch) \ |
do { const char * const __dbch = dbch; \ |
const enum __ORSIM_DEBUG_CLASS __dbcl = __ORSIM_DBCL_##dbcl; \ |
__ORSIM_DEBUG_LOG |
|
#define __ORSIM_DEBUG_LOG(args...) \ |
orsim_dbg_log(__dbcl, __dbch, __ORSIM_DBG_USE_FUNC, args); } while(0) |
|
#define TRACE_(ch) __ORSIM_DPRINTF(TRACE, __orsim_dbch_##ch) |
#define FIXME_(ch) __ORSIM_DPRINTF(FIXME, __orsim_dbch_##ch) |
#define WARN_(ch) __ORSIM_DPRINTF(WARN, __orsim_dbch_##ch) |
#define ERR_(ch) __ORSIM_DPRINTF(ERR, __orsim_dbch_##ch) |
|
#define TRACE __ORSIM_DPRINTF(TRACE, __orsim_dbch___default) |
#define FIXME __ORSIM_DPRINTF(FIXME, __orsim_dbch___default) |
#define WARN __ORSIM_DPRINTF(WARN, __orsim_dbch___default) |
#define ERR __ORSIM_DPRINTF(ERR, __orsim_dbch___default) |
|
#define DEFAULT_DEBUG_CHANNEL(dbch) \ |
extern char __orsim_dbch_##dbch[]; \ |
static char * const __orsim_dbch___default = __orsim_dbch_##dbch; |
|
#ifndef __ORSIM_NO_DEC_DBCH |
#define DECLARE_DEBUG_CHANNEL(dbch) extern char __orsim_dbch_##dbch[]; |
#endif |
|
void debug(int level, const char *format,...) __attribute__((format(printf, 2, 3))); |
|
#endif |