Commit f301750d authored by Antoine Kaufmann's avatar Antoine Kaufmann
Browse files

sims/e1000_gem5: support enabling debug messages dynamically

parent 3f25a60d
...@@ -387,12 +387,15 @@ class I40eNIC(NICSim): ...@@ -387,12 +387,15 @@ class I40eNIC(NICSim):
return self.basic_run_cmd(env, '/i40e_bm/i40e_bm') return self.basic_run_cmd(env, '/i40e_bm/i40e_bm')
class E1000NIC(NICSim): class E1000NIC(NICSim):
debug = False
def __init__(self): def __init__(self):
super().__init__() super().__init__()
def run_cmd(self, env): def run_cmd(self, env):
#return 'valgrind -v -v -v ' + self.basic_run_cmd(env, '/e1000_gem5/e1000_gem5') cmd = self.basic_run_cmd(env, '/e1000_gem5/e1000_gem5')
return self.basic_run_cmd(env, '/e1000_gem5/e1000_gem5') if self.debug:
cmd = 'env E1000_DEBUG=1 ' + cmd
return cmd
class MultiSubNIC(NICSim): class MultiSubNIC(NICSim):
name = '' name = ''
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include "sims/nic/e1000_gem5/i8254xGBe.h" #include "sims/nic/e1000_gem5/i8254xGBe.h"
static nicbm::Runner *runner; static nicbm::Runner *runner;
static bool debug_enable = false;
class Gem5DMAOp : public nicbm::DMAOp, public nicbm::TimedEvent { class Gem5DMAOp : public nicbm::DMAOp, public nicbm::TimedEvent {
public: public:
...@@ -195,19 +196,38 @@ void panic(const char *fmt, ...) ...@@ -195,19 +196,38 @@ void panic(const char *fmt, ...)
abort(); abort();
} }
static void debug_init()
{
#ifdef DEBUG_E1000
char *debug_env = getenv("E1000_DEBUG");
if (debug_env &&
(!strcmp(debug_env, "1") ||
!strcmp(debug_env, "y") ||
!strcmp(debug_env, "Y")))
{
warn("enabling debug messages because E1000_DEBUG envar set\n");
debug_enable = true;
}
#endif
}
void debug_printf(const char *fmt, ...) void debug_printf(const char *fmt, ...)
{ {
if (debug_enable) {
va_list val; va_list val;
va_start(val, fmt); va_start(val, fmt);
fprintf(stderr, "%lu: ", runner->TimePs()); fprintf(stderr, "%lu: ", runner->TimePs());
vfprintf(stderr, fmt, val); vfprintf(stderr, fmt, val);
va_end(val); va_end(val);
}
} }
/******************************************************************************/ /******************************************************************************/
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
debug_init();
IGbEParams params; IGbEParams params;
params.rx_fifo_size = 384 * 1024; params.rx_fifo_size = 384 * 1024;
params.tx_fifo_size = 384 * 1024; params.tx_fifo_size = 384 * 1024;
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
void debug_printf(const char *fmt, ...); void debug_printf(const char *fmt, ...);
//#define DEBUG_E1000 #define DEBUG_E1000
#ifdef DEBUG_E1000 #ifdef DEBUG_E1000
# define DPRINTF(x,y...) debug_printf(#x ": " y) # define DPRINTF(x,y...) debug_printf(#x ": " y)
#else #else
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment