diff options
-rw-r--r-- | ChangeLog | 15 | ||||
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | elaborate.cxx | 3 | ||||
-rw-r--r-- | elaborate.h | 1 | ||||
-rw-r--r-- | main.cxx | 80 | ||||
-rw-r--r-- | staptree.h | 2 | ||||
-rw-r--r-- | tapsets.cxx | 17 |
7 files changed, 91 insertions, 29 deletions
@@ -1,3 +1,15 @@ +2005-07-28 Frank Ch. Eigler <fche@redhat.com> + + translator/1120 + translator/1123 + * elaborate.cxx (semantic_pass_symbols): Print a more helpful + error message around exceptions. + * elaborate.h (systemtap_session): Add guru_mode field. + * main.cxx (main): Initialize it to false. Add version-sensitive + script library searching. Add more failure messages. + * tapsets.cxx (dwflpp_assert): Add a decorative text parameter. + Update callers. + 2005-07-28 Martin Hunt <hunt@redhat.com> * Makefile.am (install-data-local): Add runtime/transport. @@ -17,7 +29,8 @@ 2005-07-26 Martin Hunt <hunt@redhat.com> * Makefile.am (stpd_LDFLAGS): Set rpath correclty because otherwise - automake doesn't seem to get it right when binaries are in libexec subdirs. + automake doesn't seem to get it right when binaries are in libexec + subdirs. (AM_CPPFLAGS): revert. * systemtap.spec.in (LDFLAGS): Set libexecdir here instead. diff --git a/configure.ac b/configure.ac index 40447955..00411023 100644 --- a/configure.ac +++ b/configure.ac @@ -22,7 +22,7 @@ AC_PROG_MAKE_SET AC_SUBST(CFLAGS) AC_SUBST(CXXFLAGS) -dnl Need elfutils 0.102+ from <drepper@redhat.com> +dnl Need libdwfl-capable elfutils 0.102+ from <drepper@redhat.com> AC_CHECK_HEADERS([libelf.h elfutils/libdw.h elfutils/libdwfl.h]) AC_CHECK_LIB(dw, dwarf_begin) AC_CHECK_LIB(elf, elf_begin) diff --git a/elaborate.cxx b/elaborate.cxx index f1f0cede..ca5237df 100644 --- a/elaborate.cxx +++ b/elaborate.cxx @@ -617,6 +617,9 @@ semantic_pass_symbols (systemtap_session& s) } catch (const semantic_error& e) { + cerr << "while resolving probe point list:" << endl; + for (unsigned k=0; k<p->locations.size(); k++) + cerr << " " << *p->locations[k] << endl; s.print_error (e); // dps.erase (dps.begin(), dps.end()); } diff --git a/elaborate.h b/elaborate.h index 599bc230..4b42e0be 100644 --- a/elaborate.h +++ b/elaborate.h @@ -206,6 +206,7 @@ struct systemtap_session bool test_mode; bool verbose; bool keep_tmpdir; + bool guru_mode; // temporary directory for module builds etc. // hazardous - it is "rm -rf"'d at exit @@ -49,8 +49,8 @@ usage (systemtap_session& s) << " -- no more options after this" << endl << " -v verbose" << (s.verbose ? " [set]" : "") << endl - << " -t test mode" << (s.test_mode ? " [set]" : "") - << endl + << " -t test mode" << (s.test_mode ? " [set]" : "") << endl + << " -g guru mode" << (s.guru_mode ? " [set]" : "") << endl << " -p NUM stop after pass NUM 1-5" << endl << " (parse, elaborate, translate, compile, run)" << endl << " -I DIR look in DIR for additional .stp script files"; @@ -107,14 +107,16 @@ main (int argc, char * const argv []) s.kernel_release = string (buf.release); s.verbose = false; s.test_mode = false; + s.guru_mode = false; s.last_pass = 5; s.runtime_path = string(PKGDATADIR) + "/runtime"; s.module_name = "stap_" + stringify(getuid()) + "_" + stringify(time(0)); s.keep_tmpdir = false; + s.include_path.push_back (string(PKGDATADIR) + "/tapsets"); while (true) { - int grc = getopt (argc, argv, "vp:I:e:o:tR:r:m:k"); + int grc = getopt (argc, argv, "vp:I:e:o:tR:r:m:kg"); if (grc < 0) break; switch (grc) @@ -167,6 +169,10 @@ main (int argc, char * const argv []) s.keep_tmpdir = true; break; + case 'g': + s.guru_mode = true; + break; + case '?': case 'h': default: @@ -228,27 +234,57 @@ main (int argc, char * const argv []) if (s.user_file == 0) // syntax errors already printed rc ++; + else + s.user_file->privileged = s.guru_mode; + + // Construct kernel-versioning search path + vector<string> version_suffixes; + const string& kvr = s.kernel_release; + // add full kernel-version-release (2.6.NN-FOOBAR) + version_suffixes.push_back ("/" + kvr); + // add kernel version (2.6.NN) + string::size_type dash_rindex = kvr.rfind ('-'); + if (dash_rindex > 0 && dash_rindex != string::npos) + version_suffixes.push_back ("/" + kvr.substr (0, dash_rindex)); + // add kernel family (2.6) + string::size_type dot_index = kvr.find ('.'); + string::size_type dot2_index = kvr.find ('.', dot_index+1); + if (dot2_index > 0 && dot2_index != string::npos) + version_suffixes.push_back ("/" + kvr.substr (0, dot2_index)); + // add empty string as last element + version_suffixes.push_back (""); // PASS 1b: PARSING LIBRARY SCRIPTS for (unsigned i=0; i<s.include_path.size(); i++) { - glob_t globbuf; - string dir = s.include_path[i] + "/*.stp"; - int r = glob(dir.c_str (), 0, NULL, & globbuf); - if (r == GLOB_NOSPACE || r == GLOB_ABORTED) - rc ++; - // GLOB_NOMATCH is acceptable - - for (unsigned j=0; j<globbuf.gl_pathc; j++) + // now iterate upon it + for (unsigned k=0; k<version_suffixes.size(); k++) { - stapfile* f = parser::parse (globbuf.gl_pathv[j]); - if (f == 0) + glob_t globbuf; + string dir = s.include_path[i] + version_suffixes[k] + "/*.stp"; + int r = glob(dir.c_str (), 0, NULL, & globbuf); + if (r == GLOB_NOSPACE || r == GLOB_ABORTED) rc ++; - else - s.library_files.push_back (f); - } + // GLOB_NOMATCH is acceptable + + if (s.verbose) + clog << "Searched '" << dir << "', " + << "match count " << globbuf.gl_pathc << endl; - globfree (& globbuf); + for (unsigned j=0; j<globbuf.gl_pathc; j++) + { + stapfile* f = parser::parse (globbuf.gl_pathv[j]); + if (f == 0) + rc ++; + else + { + f->privileged = true; // XXX only for /usr/share/systemtap? + s.library_files.push_back (f); + } + } + + globfree (& globbuf); + } } if (rc == 0 && s.last_pass == 1) @@ -326,7 +362,10 @@ main (int argc, char * const argv []) << s.functions.size() << " function(s), " << s.globals.size() << " global(s)." << endl; - // semantic errors, if any, are already printed + if (rc) + cerr << "Pass 2: analysis failed. " + << "Try again with '-v' (verbose) option." << endl; + if (rc || s.last_pass == 2) goto cleanup; // PASS 3: TRANSLATION @@ -343,7 +382,10 @@ main (int argc, char * const argv []) << s.translated_source << "\"" << endl; - // translation errors, if any, are already printed + if (rc) + cerr << "Pass 2: translation failed. " + << "Try again with '-v' (verbose) option." << endl; + if (rc || s.last_pass == 3) goto cleanup; // PASS 4: COMPILATION @@ -375,6 +375,8 @@ struct stapfile std::vector<functiondecl*> functions; std::vector<vardecl*> globals; std::vector<embeddedcode*> embeds; + bool privileged; + stapfile (): privileged (false) {} void print (std::ostream& o); }; diff --git a/tapsets.cxx b/tapsets.cxx index 43d50fb5..0d51d8f0 100644 --- a/tapsets.cxx +++ b/tapsets.cxx @@ -302,10 +302,11 @@ dwflpp return t; } - void dwflpp_assert(int rc) + void dwflpp_assert(string desc, int rc) { if (rc != 0) - throw semantic_error(string("dwfl failure: ") + dwfl_errmsg(rc)); + throw semantic_error("dwfl failure (" + desc + "): " + + dwfl_errmsg(rc)); } dwflpp(systemtap_session & sess) @@ -343,8 +344,8 @@ dwflpp if (!dwfl) throw semantic_error("cannot open dwfl"); dwfl_report_begin(dwfl); - dwflpp_assert(dwfl_linux_kernel_report_kernel(dwfl)); - dwflpp_assert(dwfl_linux_kernel_report_modules(dwfl)); + dwflpp_assert("report_kernel", dwfl_linux_kernel_report_kernel(dwfl)); + dwflpp_assert("report_modules", dwfl_linux_kernel_report_modules(dwfl)); } else { @@ -355,7 +356,7 @@ dwflpp // XXX: Find pids or processes, do userspace stuff. } - dwflpp_assert(dwfl_report_end(dwfl, NULL, NULL)); + dwflpp_assert("report_end", dwfl_report_end(dwfl, NULL, NULL)); } void iterate_over_modules(int (* callback)(Dwfl_Module *, void **, @@ -373,7 +374,7 @@ dwflpp while (off > 0); if (sess.verbose) clog << "finished iterating over modules" << endl; - dwflpp_assert(off); + dwflpp_assert("getdwarf", off); } void iterate_over_cus (int (*callback)(Dwarf_Die * die, void * arg), @@ -462,9 +463,9 @@ dwflpp assert(module); assert(cu); - dwflpp_assert(dwarf_getsrclines(cu, &lines, &nlines)); + dwflpp_assert("getsrclines", dwarf_getsrclines(cu, &lines, &nlines)); linep = dwarf_onesrcline(lines, line); - dwflpp_assert(dwarf_lineaddr(linep, &addr)); + dwflpp_assert("lineaddr", dwarf_lineaddr(linep, &addr)); if (sess.verbose) clog << "line " << line << " of cu " << cu_name |