diff options
author | fche <fche> | 2005-09-28 21:23:12 +0000 |
---|---|---|
committer | fche <fche> | 2005-09-28 21:23:12 +0000 |
commit | ed10c6397cc27ad161c7fcd5242c38efd89dc5ee (patch) | |
tree | 26eb4a7e8d7176e93e6bcde03599c8e96abc7828 /buildrun.cxx | |
parent | e0d31311729955985b3142c1c7d08cf461192469 (diff) | |
download | systemtap-steved-ed10c6397cc27ad161c7fcd5242c38efd89dc5ee.tar.gz systemtap-steved-ed10c6397cc27ad161c7fcd5242c38efd89dc5ee.tar.xz systemtap-steved-ed10c6397cc27ad161c7fcd5242c38efd89dc5ee.zip |
2005-09-28 Frank Ch. Eigler <fche@elastic.org>
PR 1182.
* main.cxx (main): Support -D macro-setting option.
* stap.1.in: Document it and related macros.
* buildrun.cxx (compile_pass): Emit macro definitions.
* translate.cxx (translate_pass): Guard limit macros with #ifdef.
Eliminate MAXCONCURRENCY macro.
* elaborate.h (systemtap_session): Add "macros" field.
* parse.cxx (parse_if_statement): Clear "elseblock" if needed.
2005-09-28 Frank Ch. Eigler <fche@elastic.org>
PR 1182.
* systemtap.samples/control_limits.*: New test.
Diffstat (limited to 'buildrun.cxx')
-rw-r--r-- | buildrun.cxx | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/buildrun.cxx b/buildrun.cxx index 130f4a1b..598d7110 100644 --- a/buildrun.cxx +++ b/buildrun.cxx @@ -20,6 +20,26 @@ extern "C" { using namespace std; +// return as quoted string, with at least '"' backslash-escaped +template <typename IN> inline string +lex_cast_qstring(IN const & in) +{ + stringstream ss; + string out, out2; + if (!(ss << in)) + throw runtime_error("bad lexical cast"); + out = ss.str(); + out2 += '"'; + for (unsigned i=0; i<out.length(); i++) + { + if (out[i] == '"') // XXX others? + out2 += '\\'; + out2 += out[i]; + } + out2 += '"'; + return out2; +} + int compile_pass (systemtap_session& s) @@ -30,10 +50,15 @@ compile_pass (systemtap_session& s) int rc = 0; // Create makefile + + for (unsigned i=0; i<s.macros.size(); i++) + o << "CFLAGS += -D " << lex_cast_qstring(s.macros[i]) << endl; + 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; @@ -41,7 +66,6 @@ compile_pass (systemtap_session& s) o << s.module_name << ": " << s.translated_source << endl; o << "\t$(CC) $(CFLAGS) -o " << s.module_name << " " << s.translated_source << endl; - o.close (); } else { @@ -50,9 +74,10 @@ compile_pass (systemtap_session& s) 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 (); } + o.close (); + // Run make if (s.test_mode) { |