]> sourceware.org Git - systemtap.git/commitdiff
2005-07-14 Frank Ch. Eigler <fche@redhat.com>
authorfche <fche>
Thu, 14 Jul 2005 21:09:33 +0000 (21:09 +0000)
committerfche <fche>
Thu, 14 Jul 2005 21:09:33 +0000 (21:09 +0000)
* buildrun.cxx (compile_pass, run_pass): Get closer to a working
test_mode.
* translate.cxx (emit_module_init, emit_common_header): Ditto.
(translate_pass): Ditto.

ChangeLog
buildrun.cxx
translate.cxx

index 44bfae976f8ebda06bcde488a10bd576437e1101..1a59d04ab87068b1a6c410484c1d5913972b4c81 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2005-07-14  Frank Ch. Eigler  <fche@redhat.com>
+
+       * buildrun.cxx (compile_pass, run_pass): Get closer to a working
+       test_mode.
+       * translate.cxx (emit_module_init, emit_common_header): Ditto.
+       (translate_pass): Ditto.
+
 2005-07-14  Frank Ch. Eigler  <fche@redhat.com>
 
        * Makefile.am (stpd): Install in $pkglibdir.
index e1663d6e57830f2e53419bb7c77a4cd979d23000..77ce283c8ce143e83355819cbf4e08ae0d6874f1 100644 (file)
@@ -25,34 +25,67 @@ int
 compile_pass (systemtap_session& s)
 {
   // fill in a quick Makefile
-  if (1)
+  string makefile_nm = s.tmpdir + "/Makefile";
+  ofstream o (makefile_nm.c_str());
+  int rc = 0;
+
+  // Create makefile
+  if (s.test_mode)
+    {
+      string module_dir = string("/lib/modules/")
+        + s.kernel_release + "/build";
+      o << "CFLAGS += -I \"" << module_dir << "/include\"" << endl;
+      o << "CFLAGS += -I \"" << s.runtime_path << "/user\"" << endl;
+      o << "CFLAGS += -I \"" << s.runtime_path << "\"" << endl;
+      o << "CFLAGS += -I \"" << module_dir << "/include/asm/mach-default\"" << endl;
+      o << s.module_name << ": " << s.translated_source << endl;
+      o << "\t$(CC) $(CFLAGS) -o " << s.module_name
+        << " " << s.translated_source << endl;
+      o.close ();
+    }
+  else
     {
       // Assumes linux 2.6 kbuild
-      string makefile_nm = s.tmpdir + "/Makefile";
-      ofstream o (makefile_nm.c_str());
       o << "CFLAGS += -Werror" << endl;
-      if (s.test_mode)
-        o << "CFLAGS += -I \"" << s.runtime_path << "/user\"" << endl;
-      o << "CFLAGS += -I \"" << s.runtime_path << "\"" << endl;
       o << "CFLAGS += -I \"" << s.runtime_path << "/relayfs\"" << endl;
       o << "obj-m := " << s.module_name << ".o" << endl;
+      o.close ();
     }
 
-  // run module make
-  string module_dir = string("/lib/modules/") + s.kernel_release + "/build";
-  string make_cmd = string("make")
-    + string (" -C \"") + module_dir + string("\"");
-  make_cmd += string(" M=\"") + s.tmpdir + string("\" modules");
-  if (! s.verbose)
-    make_cmd += " -s >/dev/null 2>&1";
-
-  if (s.verbose) clog << "Running " << make_cmd << endl;
-  int rc = system (make_cmd.c_str());
-
+  // Run make
+  if (s.test_mode)
+    {
+      string make_cmd = string("/usr/bin/make -C \"") + s.tmpdir + "\"";
 
-  if (s.verbose) clog << "Pass 4: compiled into \""
-                      << s.module_name << ".ko"
-                      << "\"" << endl;
+      if (! s.verbose)
+        make_cmd += " -s >/dev/null 2>&1";
+      
+      if (s.verbose) clog << "Running " << make_cmd << endl;
+      rc = system (make_cmd.c_str());
+      
+      if (s.verbose) clog << "Pass 4: compiled into \""
+                          << s.module_name
+                          << "\"" << endl;
+    }
+  else
+    {
+      string module_dir = string("/lib/modules/")
+        + s.kernel_release + "/build";
+      string make_cmd = string("/usr/bin/make")
+        + string (" -C \"") + module_dir + string("\"");
+      make_cmd += string(" M=\"") + s.tmpdir + string("\" modules");
+
+      if (! s.verbose)
+        make_cmd += " -s >/dev/null 2>&1";
+      
+      if (s.verbose) clog << "Running " << make_cmd << endl;
+      rc = system (make_cmd.c_str());
+      
+      
+      if (s.verbose) clog << "Pass 4: compiled into \""
+                          << s.module_name << ".ko"
+                          << "\"" << endl;
+    }
 
   return rc;
 }
@@ -62,8 +95,15 @@ compile_pass (systemtap_session& s)
 int
 run_pass (systemtap_session& s)
 {
+  int rc = 0;
+
   if (s.test_mode)
-    return 1; // XXX: don't know how to do this yet
+    {
+      string run_cmd = s.tmpdir + "/" + s.module_name;
+
+      if (s.verbose) clog << "Running " << run_cmd << endl;
+      rc = system (run_cmd.c_str ());
+    }
   else // real run
     {
       // leave parent process alone
@@ -74,10 +114,12 @@ run_pass (systemtap_session& s)
         + string(PKGLIBDIR) + "/stpd "
         + (s.verbose ? "" : "-q ")
         + s.tmpdir + "/" + s.module_name + ".ko";
+
       if (s.verbose) clog << "Running " << stpd_cmd << endl;
-      int rc = system (stpd_cmd.c_str ());
+      rc = system (stpd_cmd.c_str ());
       
       signal (SIGINT, oldsig);
-      return rc;
     }      
+
+  return rc;
 }
index 52d370f8156ac7f77e045394ab3a126369479539..30bff04b329589644960d247695130a39f27a7ee 100644 (file)
@@ -223,7 +223,6 @@ hookup_builtins(systemtap_session *session,
 void
 c_unparser::emit_common_header ()
 {
-  o->newline() << "#include <linux/string.h>";
   // XXX: tapsets.cxx should be able to add additional definitions
 
   o->newline() << "#define NR_CPU 1"; 
@@ -329,7 +328,9 @@ c_unparser::emit_module_init ()
   o->newline() << "int rc;";
 
   // XXX: yuck runtime
+  o->newline() << "#if !TEST_MODE";
   o->newline() << "TRANSPORT_OPEN;";
+  o->newline() << "#endif";
 
   for (unsigned i=0; i<session->globals.size(); i++)
     {
@@ -386,7 +387,13 @@ c_unparser::emit_module_exit ()
       o->newline() << "anyrc |= rc;";
     }
   // XXX: uninitialize globals
+
+
+  // XXX: yuck runtime
+  o->newline() << "#if !TEST_MODE";
   o->newline() << "_stp_transport_close ();";
+  o->newline() << "#endif";
+
   // XXX: if anyrc, log badness
   o->newline(-1) << "}" << endl;
 }
@@ -1490,7 +1497,13 @@ translate_pass (systemtap_session& s)
   try
     {
       s.op->line() << "#define TEST_MODE " << (s.test_mode ? 1 : 0) << endl;
+
+      s.op->newline() << "#if TEST_MODE";
+      s.op->newline() << "#include \"runtime.h\"";
+      s.op->newline() << "#else";
       s.op->newline() << "#include \"runtime.h\"";
+      s.op->newline() << "#include <linux/string.h>";
+      s.op->newline() << "#endif";
 
       s.up->emit_common_header ();
 
@@ -1521,7 +1534,7 @@ translate_pass (systemtap_session& s)
       s.op->newline() << "/* test mode mainline */";
       s.op->newline() << "int main () {";
       s.op->newline(1) << "int rc = systemtap_module_init ();";
-      s.op->newline() << "if (!rc) rc = systemtap_module_exit ();";
+      s.op->newline() << "if (!rc) systemtap_module_exit ();";
       s.op->newline() << "return rc;";
       s.op->newline(-1) << "}";
 
This page took 0.038485 seconds and 5 git commands to generate.