* 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.
* 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 { }
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);
}
// 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);
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();
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
{ "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)
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. */
s.load_only = true;
break;
+ case 'B':
+ s.kbuildflags.push_back (string (optarg));
+ break;
+
case 0:
switch (long_opt)
{
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;
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
if {![installtest_p]} {
- for {set i 0} { $i < 8} {incr i} {
+ for {set i 0} { $i < 16} {incr i} {
untested cmd_parse$i
}
return
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.