From ed10c6397cc27ad161c7fcd5242c38efd89dc5ee Mon Sep 17 00:00:00 2001 From: fche Date: Wed, 28 Sep 2005 21:23:12 +0000 Subject: 2005-09-28 Frank Ch. Eigler 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 PR 1182. * systemtap.samples/control_limits.*: New test. --- ChangeLog | 11 +++++++++++ buildrun.cxx | 29 +++++++++++++++++++++++++++-- elaborate.h | 1 + main.cxx | 7 ++++++- parse.cxx | 2 ++ stap.1.in | 27 ++++++++++++++++++++++++++- translate.cxx | 13 +++++++++++-- 7 files changed, 84 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8e8d1e7d..16bd913a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2005-09-28 Frank Ch. Eigler + + 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-27 Frank Ch. Eigler * tapsets.cxx (query_cu_containing_global_address): Tolerate 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 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 include_path; + std::vector macros; std::vector args; std::string kernel_release; std::string runtime_path; diff --git a/main.cxx b/main.cxx index dcdf67f5..860e18b0 100644 --- a/main.cxx +++ b/main.cxx @@ -71,6 +71,7 @@ usage (systemtap_session& s) for (unsigned i=0; ielseblock = parse_statement (); } + else + s->elseblock = 0; // in case not otherwise initialized return s; } diff --git a/stap.1.in b/stap.1.in index 0a0fb33d..b6922108 100644 --- a/stap.1.in +++ b/stap.1.in @@ -100,6 +100,10 @@ section for details. Add the given directory to the tapset search directory. See the description of pass 2 for details. .TP +.BI \-D " NAME=VALUE" +Add the given preprocessor directive to the module Makefile. These can +be used to override limit parameters described below. +.TP .BI \-R " DIR" Look for the systemtap runtime sources in the given directory. .TP @@ -471,7 +475,6 @@ See the .IR stapex (5) manual page for a collection of samples. - .SH SAFETY AND SECURITY Systemtap is an administrative tool. It exposes kernel internal data structures and potentially private user information. It acquires root @@ -496,6 +499,28 @@ kernel. Use of script global variables is suitably locked to protect against manipulation by concurrent probe handlers. Use of guru mode constructs such as embedded C can violate these constraints, leading to kernel crash or data corruption. +.PP +The resource use limits are set by macros in the generated C code. +These may be overridden with the +.R -D +flag. A selection of these is as follows: +.TP +MAXNESTING +Maximum number of recursive function call levels. +.TP +MAXSTRINGLEN +Maximum length of strings. +.TP +MAXTRYLOCK +Maximum number of iterations to wait for locks on global variables +before declaring possible deadlock. +.TP +MAXACTION +Maximum number of statements to execute during any single probe hit. +.TP +MAXMAPENTRIES +Maximum number of rows in any single global array. + .PP In case something goes wrong with .IR stap " or " stpd diff --git a/translate.cxx b/translate.cxx index cc4b58c5..a7caf0bd 100644 --- a/translate.cxx +++ b/translate.cxx @@ -670,7 +670,7 @@ c_unparser::emit_common_header () o->newline(-1) << "} function_" << c_varname (fd->name) << ";"; } o->newline(-1) << "} locals [MAXNESTING];"; - o->newline(-1) << "} contexts [MAXCONCURRENCY];" << endl; + o->newline(-1) << "} contexts [NR_CPUS];" << endl; emit_map_type_instantiations (); } @@ -2376,12 +2376,21 @@ translate_pass (systemtap_session& s) // This is at the very top of the file. s.op->line() << "#define TEST_MODE " << (s.test_mode ? 1 : 0) << endl; + s.op->newline() << "#ifndef MAXNESTING"; s.op->newline() << "#define MAXNESTING 30"; - s.op->newline() << "#define MAXCONCURRENCY NR_CPUS"; + s.op->newline() << "#endif"; + s.op->newline() << "#ifndef MAXSTRINGLEN"; s.op->newline() << "#define MAXSTRINGLEN 128"; + s.op->newline() << "#endif"; + s.op->newline() << "#ifndef MAXTRYLOCK"; s.op->newline() << "#define MAXTRYLOCK 20"; + s.op->newline() << "#endif"; + s.op->newline() << "#ifndef MAXACTION"; s.op->newline() << "#define MAXACTION 1000"; + s.op->newline() << "#endif"; + s.op->newline() << "#ifndef MAXMAPENTRIES"; s.op->newline() << "#define MAXMAPENTRIES 2048"; + s.op->newline() << "#endif"; // impedance mismatch s.op->newline() << "#define STP_STRING_SIZE MAXSTRINGLEN"; -- cgit