OSDN Git Service

2003-06-10 Dave Brolley <brolley@redhat.com>
authorbrolley <brolley>
Tue, 10 Jun 2003 18:29:51 +0000 (18:29 +0000)
committerbrolley <brolley>
Tue, 10 Jun 2003 18:29:51 +0000 (18:29 +0000)
        * mainDynamic.cxx (usage): Document --ulog-* options.
        (try_add_memory): Don't make the base of the mapping zero by default.
        (Defs): New members: ulog_level, ulog_mode, ulog_file.
        (option_num): New members: opt_ulog_level, opt_ulog_mode,
        opt_ulog_file.
        (long_options): Add ulog-*.
        (main): Provide defaults for ulog-*. Handle opt_ulog_*.
        * commonCfg.h (struct UlogCfg): New struct.
        (SessionCfg): Now inherits UlogCfg.
        (add_ulog_file): New method of SessionCfg.
        (ulog_map): New member of SessionCfg.
        (BoardCfg): Now inherits UlogCfg.
        * commonCfg.cxx (SessionCfg): Add a ulog mapping for "-" to ulog_map.
        (add_ulog_file): New method of SeessionCfg.
        (BoardCfg): Initialize UlogCfg.
        (add_memory): Set the base for the mapping to 0.

sid/main/dynamic/ChangeLog
sid/main/dynamic/commonCfg.cxx
sid/main/dynamic/commonCfg.h
sid/main/dynamic/mainDynamic.cxx

index 3b70e21..793a10b 100644 (file)
@@ -1,3 +1,22 @@
+2003-06-10  Dave Brolley  <brolley@redhat.com>
+
+       * mainDynamic.cxx (usage): Document --ulog-* options.
+       (try_add_memory): Don't make the base of the mapping zero by default.
+       (Defs): New members: ulog_level, ulog_mode, ulog_file.
+       (option_num): New members: opt_ulog_level, opt_ulog_mode,
+       opt_ulog_file.
+       (long_options): Add ulog-*.
+       (main): Provide defaults for ulog-*. Handle opt_ulog_*.
+       * commonCfg.h (struct UlogCfg): New struct.
+       (SessionCfg): Now inherits UlogCfg.
+       (add_ulog_file): New method of SessionCfg.
+       (ulog_map): New member of SessionCfg.
+       (BoardCfg): Now inherits UlogCfg.
+       * commonCfg.cxx (SessionCfg): Add a ulog mapping for "-" to ulog_map.
+       (add_ulog_file): New method of SeessionCfg.
+       (BoardCfg): Initialize UlogCfg.
+       (add_memory): Set the base for the mapping to 0.
+
 2003-04-16  Dave Brolley  <brolley@redhat.com>
 
        * commonCfg.cxx (final_insn_count): Set cpu attribute 'final-insn-count'.
index 117698c..3e0a6e2 100644 (file)
@@ -545,6 +545,29 @@ SessionCfg::SessionCfg (const string name)
   conn_pin (main_obj, "stopping", shutdown_seq, "input");
   yield_net->add_output (0, host_sched, "yield");
   init_seq->add_output (0, reset_net, "input");
+
+  AtomicCfg *ulog = new AtomicCfg ("ulog-*",
+                                  "libconsoles.la", 
+                                  "console_component_library", 
+                                  "sid-io-stdio");
+  ulog_map["*"] = ulog;
+  add_child (ulog);
+}
+
+void
+SessionCfg::add_ulog_file (const string name)
+{
+  if (ulog_map.find (name) != ulog_map.end ())
+    return; // already there
+
+  // There is no existing logger for this file, so add a new one.
+  AtomicCfg *ulog = new AtomicCfg ("ulog-" + name, 
+                                  "libconsoles.la", 
+                                  "console_component_library", 
+                                  "sid-io-stdio");
+  set (ulog, "filename", name);
+  ulog_map[name] = ulog;
+  add_child (ulog);
 }
 
 void SessionCfg::use_no_stdio ()
@@ -830,6 +853,7 @@ BoardCfg::BoardCfg (const string name,
                    bool with_cpu_main_mem_connect) :
   ComponentCfg (name),
   AggregateCfg (name),
+  UlogCfg (),
   cache_flush_net (NULL),
   z_packet (with_z_packet),
   sess (s),
@@ -1078,7 +1102,10 @@ void BoardCfg::add_icache (const string type)
 void BoardCfg::add_memory (const Mapping &m)
 {
   if (main_mapper)
-    main_mapper->map (m);
+    {
+      Mapping map(m);
+      main_mapper->map (map.base(0));
+    }
 }
 
 
index a97868b..55d0f7a 100644 (file)
@@ -166,10 +166,24 @@ class GlueSeqCfg :
   int n;
 };
 
+// Configs which support logging should inherit this
+struct UlogCfg
+{
+  UlogCfg (sid::host_int_4 l = 0, const string m = "less", const string f = "-")
+    : ulog_level (l), ulog_mode (m), ulog_file (f)
+  {}
+  virtual void set_ulog_level (sid::host_int_4 l) { ulog_level = l; }
+  virtual void set_ulog_mode (const string m) { ulog_mode = m; }
+  virtual void set_ulog_file (const string f) { ulog_file = f; }
+  sid::host_int_4 ulog_level;
+  string ulog_mode;
+  string ulog_file;
+};
+
 // you should really only make one of these, with an empty name,
 // unless you want some crazy multi-session support.
 struct SessionCfg :
-  virtual public AggregateCfg
+  virtual public AggregateCfg, public UlogCfg
 {
   SessionCfg (const string name);
   virtual ~SessionCfg ();  
@@ -194,6 +208,8 @@ struct SessionCfg :
   AtomicCfg *tcl_bridge;
   bool verbose;
   bool use_stdio;
+  void add_ulog_file (const string filename);
+  map<const string, AtomicCfg *> ulog_map;
 };
 
 class CpuCfg :
@@ -278,7 +294,7 @@ class GdbCfg :
 };
 
 class BoardCfg :
-  virtual public AggregateCfg
+virtual public AggregateCfg, public UlogCfg
 {
 public:
   BoardCfg (const string name,
@@ -307,6 +323,7 @@ public:
   virtual void trace_disassemble ();
   virtual void trace_core ();
   virtual void write_config (Writer &w);
+
   virtual ~BoardCfg ();
 
   GlueSeqCfg *cache_flush_net;
index e95f19c..01d6315 100644 (file)
@@ -1,6 +1,6 @@
 // mainDynamic.cxx - high-tech mainline.  -*- C++ -*-
 
-// Copyright (C) 1999, 2000, 2001, 2002 Red Hat.
+// Copyright (C) 1999, 2000, 2001, 2002, 2003 Red Hat.
 // This file is part of SID and is licensed under the GPL.
 // See the file COPYING.SID for conditions for redistribution.
 
@@ -120,6 +120,10 @@ usage ()
        << "                         mmap         Memory map given file" << endl
        << "                         latency=r:w  Set read, write latencies [0:0]" << endl
        << "                         latency=rw   Set both latencies [0]" << endl;
+  cout << "--ulog-level=LEVEL    Set the logging level for the current board" << endl;
+  cout << "--ulog-mode=less|match|equal" << endl
+       << "                      Set the logging mode for the current board" << endl;
+  cout << "--ulog-file=*|FILE    Set the log file name" << endl;
   cout << endl
        << " note: most board-specific options can be used in board-neutral position " << endl
        << " where they are interpreted as session-specific or default settings. " << endl;
@@ -381,10 +385,10 @@ void try_add_memory (const string memspec,
        i != bases.end(); ++i)
     {
       Mapping m = Mapping()
-       .slave(mem).bus(port).base(0)
+       .slave(mem).bus(port)
        .low(*i).high((*i) + size - 1);
       if (map)
-       map->map (m);
+       map->map (m.base(0));
       else if (board)
        board->add_memory (m);
       else
@@ -462,6 +466,9 @@ struct Defs {
            trace_disassemble (false),
            trace_counter (false),
            trace_core (false),
+           ulog_level (0),
+           ulog_mode ("less"),
+           ulog_file ("-"),
            step_insn_count ("10000")
   {}
   string cpu;
@@ -472,6 +479,9 @@ struct Defs {
   bool trace_disassemble;
   bool trace_counter;
   bool trace_core;
+  sid::host_int_4 ulog_level;
+  string ulog_mode;
+  string ulog_file;
   string step_insn_count;
 };
   
@@ -514,7 +524,8 @@ main(int argc, char* argv[])
                    opt_insn_count, opt_load, opt_icache, opt_dcache, 
                    opt_memory_region, opt_trace_extract, opt_trace_semantics,
                    opt_trace_disassemble, opt_trace_counter, opt_trace_core,
-                   opt_final_insn_count, opt_eb, opt_el, opt_gprof };
+                   opt_final_insn_count, opt_eb, opt_el, opt_gprof,
+                   opt_ulog_level, opt_ulog_mode, opt_ulog_file };
                    
   int curr_opt;
 
@@ -559,6 +570,9 @@ main(int argc, char* argv[])
     {"final-insn-count",  no_argument, & curr_opt, opt_final_insn_count },
     {"EB",                no_argument, & curr_opt, opt_eb },
     {"EL",                no_argument, & curr_opt, opt_el },
+    {"ulog-level",        required_argument, &curr_opt, opt_ulog_level },
+    {"ulog-mode",         required_argument, &curr_opt, opt_ulog_mode },
+    {"ulog-file",         required_argument, &curr_opt, opt_ulog_file },
     { 0, 0, NULL, 0 }
  };
   
@@ -632,6 +646,9 @@ main(int argc, char* argv[])
                          curr_board->trace_core();
                        if (defaults.enable_warnings)
                          curr_board->enable_warnings();
+                       curr_board->set_ulog_level (defaults.ulog_level);
+                       curr_board->set_ulog_mode (defaults.ulog_mode);
+                       curr_board->set_ulog_file (defaults.ulog_file);
                        if (defaults.step_insn_count != "10000")
                          curr_board->set_step_insn_count(defaults.step_insn_count);
                        break;
@@ -816,6 +833,40 @@ main(int argc, char* argv[])
                  }
              }
              break;
+
+           case opt_ulog_level:
+             if (curr_board)
+               curr_board->set_ulog_level (optaddr ("ulog-level"));
+             else
+               {
+                 defaults.ulog_level = optaddr ("ulog-level");
+                 need_sess (sess);
+                 sess->set_ulog_level (optaddr ("ulog-level"));
+               }
+             break;
+
+           case opt_ulog_mode:
+             if (curr_board)
+               curr_board->set_ulog_mode (optstring ());
+             else
+               {
+                 defaults.ulog_mode = optstring ();
+                 need_sess (sess);
+                 sess->set_ulog_mode (optstring ());
+               }
+             break;
+
+           case opt_ulog_file:
+             need_sess (sess);
+             sess->add_ulog_file (optstring ());
+             if (curr_board)
+               curr_board->set_ulog_file (optstring ());
+             else
+               {
+                 defaults.ulog_file = optstring ();
+                 sess->set_ulog_file (optstring ());
+               }
+             break;
            }
          break;