summaryrefslogtreecommitdiffstats
path: root/buildrun.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'buildrun.cxx')
-rw-r--r--buildrun.cxx88
1 files changed, 65 insertions, 23 deletions
diff --git a/buildrun.cxx b/buildrun.cxx
index e1663d6e..77ce283c 100644
--- a/buildrun.cxx
+++ b/buildrun.cxx
@@ -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;
}