Line 1... |
Line 1... |
/* debug.c -- Debug channel support code
|
/* debug.c -- Debug channel support code
|
|
|
Copyright (C) 2005 György `nog' Jeney, nog@sdf.lonestar.org
|
Copyright (C) 2005 György `nog' Jeney, nog@sdf.lonestar.org
|
|
Copyright (C) 2008 Embecosm Limited
|
|
|
This file is part of OpenRISC 1000 Architectural Simulator.
|
Contributor Jeremy Bennett <jeremy.bennett@embecosm.com>
|
|
|
This program is free software; you can redistribute it and/or modify
|
This file is part of Or1ksim, the OpenRISC 1000 Architectural Simulator.
|
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>
|
This program is free software; you can redistribute it and/or modify it
|
#include <stdarg.h>
|
under the terms of the GNU General Public License as published by the Free
|
#include <string.h>
|
Software Foundation; either version 3 of the License, or (at your option)
|
|
any later version.
|
|
|
#include "config.h"
|
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, see <http://www.gnu.org/licenses/>. */
|
|
|
|
/* This program is commented throughout in a fashion suitable for processing
|
|
with Doxygen. */
|
|
|
#ifdef HAVE_INTTYPES_H
|
|
#include <inttypes.h>
|
|
#endif
|
|
|
|
|
/* Autoconf and/or portability configuration */
|
|
#include "config.h"
|
#include "port.h"
|
#include "port.h"
|
|
|
|
/* System includes */
|
|
#include <stdlib.h>
|
|
#include <stdio.h>
|
|
#include <stdarg.h>
|
|
|
|
/* Package includes */
|
#include "arch.h"
|
#include "arch.h"
|
#include "sim-config.h"
|
#include "sim-config.h"
|
|
|
#define __ORSIM_NO_DEC_DBCH
|
#define __ORSIM_NO_DEC_DBCH
|
#include "debug.h"
|
#include "debug.h"
|
Line 44... |
Line 50... |
NULL };
|
NULL };
|
#undef DECLARE_DEBUG_CHANNEL
|
#undef DECLARE_DEBUG_CHANNEL
|
|
|
static const char *debug_classes[] = { "trace", "fixme", "warn", "err" };
|
static const char *debug_classes[] = { "trace", "fixme", "warn", "err" };
|
|
|
|
|
void orsim_dbg_log(enum __ORSIM_DEBUG_CLASS dbcl, const char *dbch,
|
void orsim_dbg_log(enum __ORSIM_DEBUG_CLASS dbcl, const char *dbch,
|
const char *function, const char *format, ...)
|
const char *function, const char *format, ...)
|
{
|
{
|
va_list ap;
|
va_list ap;
|
static int last_lf = 1; /* There *has* to be a better way */
|
static int last_lf = 1; /* There *has* to be a better way */
|
Line 139... |
Line 146... |
else
|
else
|
str = chan_end;
|
str = chan_end;
|
}
|
}
|
}
|
}
|
|
|
No newline at end of file
|
No newline at end of file
|
|
|
|
/*---------------------------------------------------------------------------*/
|
|
/*!Internal debug function
|
|
|
|
Print the message if the level is greater than or equal to that specified
|
|
in the configuration.
|
|
|
|
@param[in] level The debug level of this message
|
|
@param[in] format Varargs format string
|
|
@param[in] ... The varargs required by the string */
|
|
/*---------------------------------------------------------------------------*/
|
|
void
|
|
debug (int level,
|
|
const char *format,
|
|
...)
|
|
{
|
|
if (config.sim.debug >= level)
|
|
{
|
|
va_list ap;
|
|
|
|
va_start (ap, format);
|
|
vfprintf (runtime.sim.fout, format, ap);
|
|
fflush (runtime.sim.fout);
|
|
}
|
|
} /* debug() */
|
|
|
|
|
|
|
No newline at end of file
|
No newline at end of file
|