diff options
author | Frank Ch. Eigler <fche@elastic.org> | 2009-08-24 10:34:45 -0400 |
---|---|---|
committer | Frank Ch. Eigler <fche@elastic.org> | 2009-08-24 10:37:38 -0400 |
commit | 1392896dcda33324d43392f8e99fed240cf5fb9b (patch) | |
tree | c3546b8e377aa31fbf49a45b00940e017c425812 | |
parent | 5a77d0116da4bc1d5b41df3172ad78c537eff51a (diff) | |
download | systemtap-steved-1392896dcda33324d43392f8e99fed240cf5fb9b.tar.gz systemtap-steved-1392896dcda33324d43392f8e99fed240cf5fb9b.tar.xz systemtap-steved-1392896dcda33324d43392f8e99fed240cf5fb9b.zip |
PR4186: cross-architecture probe building
* main.cxx (main): Add 'a:' and 'B:' options.
* session.h (kbuildflags): New place to store -B args.
* testsuite/systemtap.base/cmd_parse.exp: Test them lightly.
* buildrun.cxx (run_make_cmd): Use "--no-print-directory"
rather than ">/dev/null" in kbuild invocations. Pass
'-a' and '-B' flags along.
* hash.cxx (find_script_hash): Add them.
* NEWS, stap.1.in: Mention this.
-rw-r--r-- | NEWS | 9 | ||||
-rw-r--r-- | buildrun.cxx | 17 | ||||
-rw-r--r-- | hash.cxx | 3 | ||||
-rw-r--r-- | main.cxx | 14 | ||||
-rw-r--r-- | session.h | 1 | ||||
-rw-r--r-- | stap.1.in | 4 | ||||
-rw-r--r-- | testsuite/systemtap.base/cmd_parse.exp | 28 |
7 files changed, 69 insertions, 7 deletions
@@ -1,5 +1,14 @@ * What's new +- It is now possible to cross-compile systemtap scripts for foreign + architectures, using the new '-a ARCH' and '-B OPT=VALUE' flags. + For example, put arm-linux-gcc etc. into your $PATH, and point + systemtap at the target kernel build tree with: + stap -a arm -B CROSS_COMPILE=arm-linux- -r /build/tree [...] + The -B option is passed to kbuild make. -r identifies the already + configured/built kernel tree and -a its architecture (kbuild ARCH=...). + Systemtap will infer -p4. + - It is now possible to define multiple probe aliases with the same name. A probe will expand to all matching aliases. probe foo = bar { } diff --git a/buildrun.cxx b/buildrun.cxx index 1820002d..69cc5a66 100644 --- a/buildrun.cxx +++ b/buildrun.cxx @@ -59,9 +59,9 @@ run_make_cmd(systemtap_session& s, string& make_cmd) if (s.verbose > 2) make_cmd += " V=1"; else if (s.verbose > 1) - make_cmd += " >/dev/null"; + make_cmd += " --no-print-directory"; else - make_cmd += " -s >/dev/null"; + make_cmd += " -s --no-print-directory"; return stap_system (s.verbose, make_cmd); } @@ -222,8 +222,17 @@ compile_pass (systemtap_session& s) // Run make string make_cmd = string("make") - + string (" -C \"") + module_dir + string("\""); - make_cmd += string(" M=\"") + s.tmpdir + string("\" modules"); + + string (" -C \"") + module_dir + string("\""); // XXX: lex_cast_qstring? + make_cmd += string(" M=\"") + s.tmpdir + string("\""); + + // Add architecture + make_cmd += string(" ARCH=") + lex_cast_qstring(s.architecture); + + // Add any custom kbuild flags + for (unsigned k=0; k<s.kbuildflags.size(); k++) + make_cmd += string(" ") + lex_cast_qstring(s.kbuildflags[k]); + + make_cmd += string (" modules"); rc = run_make_cmd(s, make_cmd); @@ -190,6 +190,9 @@ find_script_hash (systemtap_session& s, const string& script, const hash &base) for (unsigned i = 0; i < s.macros.size(); i++) h.add(s.macros[i]); + for (unsigned i = 0; i < s.kbuildflags.size(); i++) + h.add(s.kbuildflags[i]); + // -d MODULE for (set<string>::iterator it = s.unwindsym_modules.begin(); it != s.unwindsym_modules.end(); @@ -106,11 +106,13 @@ usage (systemtap_session& s, int exitcode) clog << " " << s.include_path[i] << endl; clog << " -D NM=VAL emit macro definition into generated C code" << endl + << " -B NM=VAL pass option to kbuild make" << endl << " -R DIR look in DIR for runtime, instead of" << endl << " " << s.runtime_path << endl << " -r DIR cross-compile to kernel with given build tree; or else" << endl << " -r RELEASE cross-compile to kernel /lib/modules/RELEASE/build, instead of" << endl << " " << s.kernel_build_tree << endl + << " -a ARCH cross-compile to given architecture, instead of " << s.architecture << endl << " -m MODULE set probe module name, instead of " << endl << " " << s.module_name << endl << " -o FILE send script output to file, instead of stdout. This supports" << endl @@ -590,8 +592,8 @@ main (int argc, char * const argv []) { "unprivileged", 0, &long_opt, LONG_OPT_UNPRIVILEGED }, { NULL, 0, NULL, 0 } }; - int grc = getopt_long (argc, argv, "hVMvtp:I:e:o:R:r:m:kgPc:x:D:bs:uqwl:d:L:FS:", - long_options, NULL); + int grc = getopt_long (argc, argv, "hVMvtp:I:e:o:R:r:a:m:kgPc:x:D:bs:uqwl:d:L:FS:B:", + long_options, NULL); if (grc < 0) break; switch (grc) @@ -711,6 +713,10 @@ main (int argc, char * const argv []) setup_kernel_release(s, optarg); break; + case 'a': + s.architecture = string(optarg); + break; + case 'k': s.keep_tmpdir = true; s.use_cache = false; /* User wants to keep a usable build tree. */ @@ -792,6 +798,10 @@ main (int argc, char * const argv []) s.load_only = true; break; + case 'B': + s.kbuildflags.push_back (string (optarg)); + break; + case 0: switch (long_opt) { @@ -83,6 +83,7 @@ struct systemtap_session std::vector<std::string> include_path; std::vector<std::string> macros; std::vector<std::string> args; + std::vector<std::string> kbuildflags; std::string kernel_release; std::string kernel_base_release; std::string kernel_build_tree; @@ -153,6 +153,10 @@ description of pass 2 for details. Add the given C preprocessor directive to the module Makefile. These can be used to override limit parameters described below. .TP +.BI \-B " NAME=VALUE" +Add the given make directive to the kernel module build's make invocation. +These can be used to add or override kconfig options. +.TP .BI \-R " DIR" Look for the systemtap runtime sources in the given directory. .TP diff --git a/testsuite/systemtap.base/cmd_parse.exp b/testsuite/systemtap.base/cmd_parse.exp index 7f5f70d9..8824e6c4 100644 --- a/testsuite/systemtap.base/cmd_parse.exp +++ b/testsuite/systemtap.base/cmd_parse.exp @@ -1,5 +1,5 @@ if {![installtest_p]} { - for {set i 0} { $i < 8} {incr i} { + for {set i 0} { $i < 16} {incr i} { untested cmd_parse$i } return @@ -129,3 +129,29 @@ expect { eof { fail "cmd_parse14: eof" } } wait;catch {close} + +set uname [exec uname -r] +spawn sh -c "stap -m do_not_cache_me -B kernelrelease -p4 -e 'probe begin {exit()}'" +# the \r below is meant to match the "kernelrelease" output, as distinct from +# any possible auxiliary make verbosity. +expect { + -re "$uname\r" { pass "cmd_parse15" } + timeout { fail "cmd_parse15: timeout" } + eof { fail "cmd_parse15: eof" } +} +wait;catch {close} + +set uname [exec uname -m] +spawn sh -c "stap -m do_not_cache_me -a $uname -p4 -e 'probe begin {exit()}'" +# the \r below is meant to match the "kernelrelease" output, as distinct from +# any possible auxiliary make verbosity. +expect { + -re "do_not_cache_me.ko\r" { pass "cmd_parse16" } + timeout { fail "cmd_parse16: timeout" } + eof { fail "cmd_parse16: eof" } +} +wait;catch {close} + + +# NB: when adding extra tests here, increment the ![installtest_p] +# loop count too at the top. |