diff options
27 files changed, 227 insertions, 118 deletions
@@ -1,3 +1,74 @@ +2006-05-16 David Smith <dsmith@redhat.com> + + * parse.cxx (parser::parser): Added initializer for 'context' + member variable. + (tt2str): Added support for new tok_keyword type. + (operator <<): Ignores keyword content when outputting error + message. + (lexer::scan): Recognizes keywords, such as 'probe', 'global', + 'function', etc. and classifies them as type 'tok_keyword'. This + causes keywords to become reserved so they cannot be used for + function names, variable names, etc. + (parser::parse): Changed tok_identifier to tok_keyword when looking + for "probe", "global", or "function". Also sets context member + variable which remembers if we're in probe, global, function, or + embedded context. + (parser::parse_probe, parser::parse_statement) + (parser::parse_global, parser::parse_functiondecl) + (parser::parse_if_statement, parser::parse_delete_statement) + (parser::parse_break_statement, parser::parse_continue_statement) + (parser::parse_for_loop, parser::parse_while_loop) + (parser::parse_foreach_loop, parser::parse_array_in): Looks for + tok_keyword instead of tok_identifier. + (parser::parse_probe_point): Allows keywords as part of a probe + name, since "return" and "function" are keywords. + (parser::parse_return_statement): Looks for tok_keyword instead of + tok_identifier. Make sure we're in function context. + (parser::parse_next_statement): Looks for tok_keyword instead of + tok_identifier. Make sure we're in probe context. + * parse.h: Added parse_context enum. Added 'tok_keyword' to + token_type enum. Added parse_context 'context' member variable to + parser class. + * stap.1.in: Because the string() function has been removed, + the 'string()' function reference has been changed to a 'sprint()' + function reference. + * stapex.5.in: Ditto. + * stapfuncs.5.in: The description of the string() and hexstring() + functions has been removed. + * testsuite/buildok/context_test.stp: Calls to the string() + function were converted to sprint() function calls. + * testsuite/buildok/fifteen.stp: Ditto. + * testsuite/buildok/nineteen.stp: Ditto. + * testsuite/buildok/process_test.stp: Ditto. + * testsuite/buildok/task_test.stp: Ditto. + * testsuite/buildok/timestamp.stp: Ditto. + * testsuite/buildok/twentyone.stp: Ditto. + * testsuite/semok/args.stp: Ditto. + * testsuite/semok/seven.stp: Ditto. + + * testsuite/buildok/fourteen.stp: Calls to log()/string() were + converted to a call to printf(). + * testsuite/buildok/sixteen.stp: Ditto. + * testsuite/buildok/thirteen.stp: Ditto. + * testsuite/buildok/twentythree.stp: Ditto. + * testsuite/buildok/twentytwo.stp: Ditto. + + * testsuite/buildok/seven.stp: Calls to the string() + function were converted to sprint() calls. Calls to the + hexstring() function were converted to sprintf() calls. + * testsuite/semok/eleven.stp: Ditto. + + * testsuite/buildok/seventeen.stp: Calls to log()/hexstring() were + converted to a call to printf(). + * testsuite/semko/nineteen.stp: Ditto. + + * testsuite/parseok/three.stp: Because keywords are reserved, a + variable named 'string' was renamed to 'str'. + + * testsuite/parseok/two.stp: Because keywords are reserved, a + variable named 'global' was renamed to 'gbl'. + + 2006-05-15 Frank Ch. Eigler <fche@elastic.org> * tapsets.cxx, translator.cxx (*): Designate more emitted @@ -30,14 +30,14 @@ parser::parser (systemtap_session& s, istream& i, bool p): session (s), input_name ("<input>"), free_input (0), input (i, input_name, s), privileged (p), - last_t (0), next_t (0), num_errors (0) + context(con_unknown), last_t (0), next_t (0), num_errors (0) { } parser::parser (systemtap_session& s, const string& fn, bool p): session (s), input_name (fn), free_input (new ifstream (input_name.c_str(), ios::in)), input (* free_input, input_name, s), privileged (p), - last_t (0), next_t (0), num_errors (0) + context(con_unknown), last_t (0), next_t (0), num_errors (0) { } parser::~parser() @@ -72,6 +72,7 @@ tt2str(token_type tt) case tok_string: return "string"; case tok_number: return "number"; case tok_embedded: return "embedded-code"; + case tok_keyword: return "keyword"; } return "unknown token"; } @@ -91,7 +92,7 @@ operator << (ostream& o, const token& t) { o << tt2str(t.type); - if (t.type != tok_embedded) // XXX: other types? + if (t.type != tok_embedded && t.type != tok_keyword) // XXX: other types? { o << " '"; for (unsigned i=0; i<t.content.length(); i++) @@ -505,6 +506,26 @@ lexer::scan () n->content = arg; } } + else + { + if (n->content == "probe" + || n->content == "global" + || n->content == "function" + || n->content == "if" + || n->content == "else" + || n->content == "for" + || n->content == "foreach" + || n->content == "in" + || n->content == "return" + || n->content == "delete" + || n->content == "while" + || n->content == "break" + || n->content == "continue" + || n->content == "next" + || n->content == "string" + || n->content == "long") + n->type = tok_keyword; + } return n; } @@ -725,16 +746,31 @@ parser::parse () break; empty = false; - if (t->type == tok_identifier && t->content == "probe") - parse_probe (f->probes, f->aliases); - else if (t->type == tok_identifier && t->content == "global") - parse_global (f->globals); - else if (t->type == tok_identifier && t->content == "function") - parse_functiondecl (f->functions); + if (t->type == tok_keyword && t->content == "probe") + { + context = con_probe; + parse_probe (f->probes, f->aliases); + } + else if (t->type == tok_keyword && t->content == "global") + { + context = con_global; + parse_global (f->globals); + } + else if (t->type == tok_keyword && t->content == "function") + { + context = con_function; + parse_functiondecl (f->functions); + } else if (t->type == tok_embedded) - f->embeds.push_back (parse_embeddedcode ()); + { + context = con_embedded; + f->embeds.push_back (parse_embeddedcode ()); + } else - throw parse_error ("expected 'probe', 'global', 'function', or '%{'"); + { + context = con_unknown; + throw parse_error ("expected 'probe', 'global', 'function', or '%{'"); + } } catch (parse_error& pe) { @@ -782,7 +818,7 @@ parser::parse_probe (std::vector<probe *> & probe_ret, std::vector<probe_alias *> & alias_ret) { const token* t0 = next (); - if (! (t0->type == tok_identifier && t0->content == "probe")) + if (! (t0->type == tok_keyword && t0->content == "probe")) throw parse_error ("expected 'probe'"); vector<probe_point *> aliases; @@ -926,23 +962,23 @@ parser::parse_statement () } else if (t && t->type == tok_operator && t->content == "{") return parse_stmt_block (); - else if (t && t->type == tok_identifier && t->content == "if") + else if (t && t->type == tok_keyword && t->content == "if") return parse_if_statement (); - else if (t && t->type == tok_identifier && t->content == "for") + else if (t && t->type == tok_keyword && t->content == "for") return parse_for_loop (); - else if (t && t->type == tok_identifier && t->content == "foreach") + else if (t && t->type == tok_keyword && t->content == "foreach") return parse_foreach_loop (); - else if (t && t->type == tok_identifier && t->content == "return") + else if (t && t->type == tok_keyword && t->content == "return") return parse_return_statement (); - else if (t && t->type == tok_identifier && t->content == "delete") + else if (t && t->type == tok_keyword && t->content == "delete") return parse_delete_statement (); - else if (t && t->type == tok_identifier && t->content == "while") + else if (t && t->type == tok_keyword && t->content == "while") return parse_while_loop (); - else if (t && t->type == tok_identifier && t->content == "break") + else if (t && t->type == tok_keyword && t->content == "break") return parse_break_statement (); - else if (t && t->type == tok_identifier && t->content == "continue") + else if (t && t->type == tok_keyword && t->content == "continue") return parse_continue_statement (); - else if (t && t->type == tok_identifier && t->content == "next") + else if (t && t->type == tok_keyword && t->content == "next") return parse_next_statement (); // XXX: "do/while" statement? else if (t && (t->type == tok_operator || // expressions are flexible @@ -960,7 +996,7 @@ void parser::parse_global (vector <vardecl*>& globals) { const token* t0 = next (); - if (! (t0->type == tok_identifier && t0->content == "global")) + if (! (t0->type == tok_keyword && t0->content == "global")) throw parse_error ("expected 'global'"); while (1) @@ -994,12 +1030,14 @@ void parser::parse_functiondecl (std::vector<functiondecl*>& functions) { const token* t = next (); - if (! (t->type == tok_identifier && t->content == "function")) + if (! (t->type == tok_keyword && t->content == "function")) throw parse_error ("expected 'function'"); t = next (); - if (! (t->type == tok_identifier)) + if (! (t->type == tok_identifier) + && ! (t->type == tok_keyword + && (t->content == "string" || t->content == "long"))) throw parse_error ("expected identifier"); for (unsigned i=0; i<functions.size(); i++) @@ -1014,9 +1052,9 @@ parser::parse_functiondecl (std::vector<functiondecl*>& functions) if (t->type == tok_operator && t->content == ":") { t = next (); - if (t->type == tok_identifier && t->content == "string") + if (t->type == tok_keyword && t->content == "string") fd->type = pe_string; - else if (t->type == tok_identifier && t->content == "long") + else if (t->type == tok_keyword && t->content == "long") fd->type = pe_long; else throw parse_error ("expected 'string' or 'long'"); @@ -1044,9 +1082,9 @@ parser::parse_functiondecl (std::vector<functiondecl*>& functions) if (t->type == tok_operator && t->content == ":") { t = next (); - if (t->type == tok_identifier && t->content == "string") + if (t->type == tok_keyword && t->content == "string") vd->type = pe_string; - else if (t->type == tok_identifier && t->content == "long") + else if (t->type == tok_keyword && t->content == "long") vd->type = pe_long; else throw parse_error ("expected 'string' or 'long'"); @@ -1078,8 +1116,10 @@ parser::parse_probe_point () while (1) { const token* t = next (); - if (! (t->type == tok_identifier || - (t->type == tok_operator && t->content == "*"))) + if (! (t->type == tok_identifier + // we must allow ".return" and ".function", which are keywords + || t->type == tok_keyword + || (t->type == tok_operator && t->content == "*"))) throw parse_error ("expected identifier or '*'"); if (pl->tok == 0) pl->tok = t; @@ -1160,7 +1200,7 @@ if_statement* parser::parse_if_statement () { const token* t = next (); - if (! (t->type == tok_identifier && t->content == "if")) + if (! (t->type == tok_keyword && t->content == "if")) throw parse_error ("expected 'if'"); if_statement* s = new if_statement; s->tok = t; @@ -1178,7 +1218,7 @@ parser::parse_if_statement () s->thenblock = parse_statement (); t = peek (); - if (t && t->type == tok_identifier && t->content == "else") + if (t && t->type == tok_keyword && t->content == "else") { next (); s->elseblock = parse_statement (); @@ -1205,8 +1245,10 @@ return_statement* parser::parse_return_statement () { const token* t = next (); - if (! (t->type == tok_identifier && t->content == "return")) + if (! (t->type == tok_keyword && t->content == "return")) throw parse_error ("expected 'return'"); + if (context != con_function) + throw parse_error ("found 'return' not in function context"); return_statement* s = new return_statement; s->tok = t; s->value = parse_expression (); @@ -1218,7 +1260,7 @@ delete_statement* parser::parse_delete_statement () { const token* t = next (); - if (! (t->type == tok_identifier && t->content == "delete")) + if (! (t->type == tok_keyword && t->content == "delete")) throw parse_error ("expected 'delete'"); delete_statement* s = new delete_statement; s->tok = t; @@ -1231,8 +1273,10 @@ next_statement* parser::parse_next_statement () { const token* t = next (); - if (! (t->type == tok_identifier && t->content == "next")) + if (! (t->type == tok_keyword && t->content == "next")) throw parse_error ("expected 'next'"); + if (context != con_probe) + throw parse_error ("found 'next' not in probe context"); next_statement* s = new next_statement; s->tok = t; return s; @@ -1243,7 +1287,7 @@ break_statement* parser::parse_break_statement () { const token* t = next (); - if (! (t->type == tok_identifier && t->content == "break")) + if (! (t->type == tok_keyword && t->content == "break")) throw parse_error ("expected 'break'"); break_statement* s = new break_statement; s->tok = t; @@ -1255,7 +1299,7 @@ continue_statement* parser::parse_continue_statement () { const token* t = next (); - if (! (t->type == tok_identifier && t->content == "continue")) + if (! (t->type == tok_keyword && t->content == "continue")) throw parse_error ("expected 'continue'"); continue_statement* s = new continue_statement; s->tok = t; @@ -1267,7 +1311,7 @@ for_loop* parser::parse_for_loop () { const token* t = next (); - if (! (t->type == tok_identifier && t->content == "for")) + if (! (t->type == tok_keyword && t->content == "for")) throw parse_error ("expected 'for'"); for_loop* s = new for_loop; s->tok = t; @@ -1333,7 +1377,7 @@ for_loop* parser::parse_while_loop () { const token* t = next (); - if (! (t->type == tok_identifier && t->content == "while")) + if (! (t->type == tok_keyword && t->content == "while")) throw parse_error ("expected 'while'"); for_loop* s = new for_loop; s->tok = t; @@ -1364,7 +1408,7 @@ foreach_loop* parser::parse_foreach_loop () { const token* t = next (); - if (! (t->type == tok_identifier && t->content == "foreach")) + if (! (t->type == tok_keyword && t->content == "foreach")) throw parse_error ("expected 'foreach'"); foreach_loop* s = new foreach_loop; s->tok = t; @@ -1426,7 +1470,7 @@ parser::parse_foreach_loop () } t = next (); - if (! (t->type == tok_identifier && t->content == "in")) + if (! (t->type == tok_keyword && t->content == "in")) throw parse_error ("expected 'in'"); s->base = parse_indexable(); @@ -1672,7 +1716,7 @@ parser::parse_array_in () } t = peek (); - if (t && t->type == tok_identifier && t->content == "in") + if (t && t->type == tok_keyword && t->content == "in") { array_in *e = new array_in; e->tok = t; @@ -26,11 +26,16 @@ struct source_loc std::ostream& operator << (std::ostream& o, const source_loc& loc); +enum parse_context + { + con_unknown, con_probe, con_global, con_function, con_embedded + }; + + enum token_type { tok_junk, tok_identifier, tok_operator, tok_string, tok_number, - tok_embedded - // XXX: add tok_keyword throughout + tok_embedded, tok_keyword }; @@ -90,6 +95,7 @@ private: std::istream* free_input; lexer input; bool privileged; + parse_context context; // preprocessing subordinate std::vector<const token*> enqueued_pp; @@ -464,7 +464,7 @@ functions. In the following example, the type inference engine need only infer type type of arg2 (a string). .SAMPLE function thatfn:string (arg1:long, arg2) { - return string(arg1) . arg2 + return sprint(arg1) . arg2 } .ESAMPLE Functions may call others or themselves diff --git a/stapex.5.in b/stapex.5.in index c95592c5..42c4e4d8 100644 --- a/stapex.5.in +++ b/stapex.5.in @@ -36,10 +36,10 @@ probe begin { probe end { foreach (x+ in odds) { - log("odds[" . string(x) . "] = " . string(odds[x])) + log("odds[" . sprint(x) . "] = " . sprint(odds[x])) } foreach (x in evens-) { - log("evens[" . string(x) . "] = " . string(evens[x])) + log("evens[" . sprint(x) . "] = " . sprint(evens[x])) } } .ESAMPLE @@ -72,7 +72,7 @@ function isprime (x) { } probe begin { for (i=0; i<50; i++) - if (isprime (i)) log (string(i)) + if (isprime (i)) log (sprint(i)) exit() } .ESAMPLE @@ -87,7 +87,7 @@ function fibonacci(i) { return fibonacci (i-1) + fibonacci (i-2) } probe begin { - log ("11th fibonacci number: " . string (fibonacci (11))) + log ("11th fibonacci number: " . sprint (fibonacci (11))) exit () } .ESAMPLE diff --git a/stapfuncs.5.in b/stapfuncs.5.in index ba6018ae..7a4cfafc 100644 --- a/stapfuncs.5.in +++ b/stapfuncs.5.in @@ -66,13 +66,6 @@ will shortly respond to the request and initiate an orderly shutdown. .SS CONVERSIONS .TP -hexstring:string (num:long) -Return a hexadecimal string representation of the given integer, including -the leading "0x". -.TP -string:string (num:long) -Return a decimal string representation of the given integer. -.TP kernel_string:string (addr:long) Copy a string from kernel space at given address. The validation of this address is only partial at present. diff --git a/testsuite/buildok/context_test.stp b/testsuite/buildok/context_test.stp index c732999d..36bf8ca6 100755 --- a/testsuite/buildok/context_test.stp +++ b/testsuite/buildok/context_test.stp @@ -9,14 +9,14 @@ function print_stuff () { print_stack(bt) print("\n\n") log("execname is \"" . execname() . "\"") - log("pid is " . string(pid())) - log("tid is " . string(tid())) + log("pid is " . sprint(pid())) + log("tid is " . sprint(tid())) log("pexecname is \"" . pexecname() . "\"") - log("ppid is " . string(ppid())) - log("uid is " . string(uid())) - log("euid is " . string(euid())) - log("gid is " . string(gid())) - log("egid is " . string(egid())) + log("ppid is " . sprint(ppid())) + log("uid is " . sprint(uid())) + log("euid is " . sprint(euid())) + log("gid is " . sprint(gid())) + log("egid is " . sprint(egid())) log("pp is '" . pp() . "'") } diff --git a/testsuite/buildok/fifteen.stp b/testsuite/buildok/fifteen.stp index bf4e0af3..cda79805 100755 --- a/testsuite/buildok/fifteen.stp +++ b/testsuite/buildok/fifteen.stp @@ -24,8 +24,8 @@ probe kernel.function("schedule") probe end { log("systemtap ending probe") - log("count = " . string(count)); - log("count2 = " . string(count)); + log("count = " . sprint(count)); + log("count2 = " . sprint(count)); if ( count == count2) { if ( (count-1) == count2 ) { log("systemtap test failure"); diff --git a/testsuite/buildok/fourteen.stp b/testsuite/buildok/fourteen.stp index b7f68afe..8eab2480 100755 --- a/testsuite/buildok/fourteen.stp +++ b/testsuite/buildok/fourteen.stp @@ -6,4 +6,4 @@ probe timer.jiffies(100).randomize(100) { j++ } probe timer.ms(100) { i++ } probe timer.ms(100).randomize(100) { j++ } probe timer.profile { i++ } -probe end { log ("i=" . string(i) . " j=" . string(j)) } +probe end { printf("i=%d j=%d\n", i, j) } diff --git a/testsuite/buildok/nineteen.stp b/testsuite/buildok/nineteen.stp index be12b6f7..2019e209 100755 --- a/testsuite/buildok/nineteen.stp +++ b/testsuite/buildok/nineteen.stp @@ -9,13 +9,13 @@ function msg2 (x,y) { probe begin { msg1("55"); - msg1(string(55)) + msg1(sprint(55)) msg2("100", "GOOD") - msg2("GOOD", string(100)) + msg2("GOOD", sprint(100)) # the next line caused a compile failure when uncommented; PR 1335 - msg2(string(100), "GOOD") + msg2(sprint(100), "GOOD") exit() } diff --git a/testsuite/buildok/process_test.stp b/testsuite/buildok/process_test.stp index c925980d..8da45378 100755 --- a/testsuite/buildok/process_test.stp +++ b/testsuite/buildok/process_test.stp @@ -2,7 +2,7 @@ probe process.create { log(pp()) - log(string(task)) + log(sprint(task)) } probe process.start { @@ -16,25 +16,25 @@ probe process.exec { probe process.exec.complete { log(pp()) - log(string(errno)) - log(string(success)) + log(sprint(errno)) + log(sprint(success)) } probe process.exit { log(pp()) - log(string(code)) + log(sprint(code)) } probe process.release { log(pp()) - log(string(task)) + log(sprint(task)) } probe process.signal.send { log(pp()) - log(string(signal)) + log(sprint(signal)) log(signal_name) - log(string(task)) - log(string(shared)) + log(sprint(task)) + log(sprint(shared)) } diff --git a/testsuite/buildok/seven.stp b/testsuite/buildok/seven.stp index 2ac6bcd7..25508b61 100755 --- a/testsuite/buildok/seven.stp +++ b/testsuite/buildok/seven.stp @@ -8,16 +8,16 @@ probe kernel.function("find_pid") { - log ("find_pid (" . string($type) . "," - . string($nr) . ")") + log ("find_pid (" . sprint($type) . "," + . sprint($nr) . ")") } # second: opaque pointers and enums probe kernel.function("detach_pid") { - log ("detach_pid (" . hexstring($task) . "," - . string($type) . ")") + log ("detach_pid (" . sprintf("0x%x", $task) . "," + . sprint($type) . ")") } diff --git a/testsuite/buildok/seventeen.stp b/testsuite/buildok/seventeen.stp index 6ac87815..9adffa48 100755 --- a/testsuite/buildok/seventeen.stp +++ b/testsuite/buildok/seventeen.stp @@ -5,5 +5,5 @@ probe kernel.function("pipe_write") { - log (hexstring ($write_fifo_fops->llseek)) + printf("0x%x\n", $write_fifo_fops->llseek) } diff --git a/testsuite/buildok/sixteen.stp b/testsuite/buildok/sixteen.stp index 26932b8e..0e313fa8 100755 --- a/testsuite/buildok/sixteen.stp +++ b/testsuite/buildok/sixteen.stp @@ -13,7 +13,7 @@ probe begin { foreach (k in a) { log (a[k]) for (i=0; i<10; i++) { - log ("k=" . string(k) . " i=" . string(i)) + printf("k=%d i=%d\n", k, i) if (k % (i+1)) break else continue } if (k % 3) { foo() ; next } diff --git a/testsuite/buildok/task_test.stp b/testsuite/buildok/task_test.stp index 692745f7..17fa7fb3 100755 --- a/testsuite/buildok/task_test.stp +++ b/testsuite/buildok/task_test.stp @@ -2,17 +2,17 @@ probe begin { c = task_current() - log(string(task_parent(c))) - log(string(task_state(c))) + log(sprint(task_parent(c))) + log(sprint(task_state(c))) log(task_execname(c)) - log(string(task_pid(c))) - log(string(task_tid(c))) - log(string(task_gid(c))) - log(string(task_egid(c))) - log(string(task_uid(c))) - log(string(task_euid(c))) - log(string(task_prio(c))) - log(string(task_nice(c))) - log(string(task_cpu(c))) + log(sprint(task_pid(c))) + log(sprint(task_tid(c))) + log(sprint(task_gid(c))) + log(sprint(task_egid(c))) + log(sprint(task_uid(c))) + log(sprint(task_euid(c))) + log(sprint(task_prio(c))) + log(sprint(task_nice(c))) + log(sprint(task_cpu(c))) exit() } diff --git a/testsuite/buildok/thirteen.stp b/testsuite/buildok/thirteen.stp index 1113913e..4dffc4b9 100755 --- a/testsuite/buildok/thirteen.stp +++ b/testsuite/buildok/thirteen.stp @@ -2,5 +2,5 @@ probe kernel.function("sys_read") { - log ("count=" . string($count)) + printf ("count=%d\n", $count) } diff --git a/testsuite/buildok/timestamp.stp b/testsuite/buildok/timestamp.stp index f273262f..e071e781 100755 --- a/testsuite/buildok/timestamp.stp +++ b/testsuite/buildok/timestamp.stp @@ -1,6 +1,6 @@ #! stap -p4 probe begin { - log(string(get_cycles() + gettimeofday_us() + + log(sprint(get_cycles() + gettimeofday_us() + gettimeofday_ms() + gettimeofday_s())) } diff --git a/testsuite/buildok/twentyone.stp b/testsuite/buildok/twentyone.stp index 052c3a17..367dfe73 100755 --- a/testsuite/buildok/twentyone.stp +++ b/testsuite/buildok/twentyone.stp @@ -14,14 +14,14 @@ probe begin { probe end { log ("x+ in a") - foreach (x+ in a) log ("a[" . string(x) . "]=" . string(a[x])) + foreach (x+ in a) log ("a[" . sprint(x) . "]=" . sprint(a[x])) log ("x- in a") - foreach (x- in a) log ("a[" . string(x) . "]=" . string(a[x])) + foreach (x- in a) log ("a[" . sprint(x) . "]=" . sprint(a[x])) log ("x in a+") - foreach (x in a+) log ("a[" . string(x) . "]=" . string(a[x])) + foreach (x in a+) log ("a[" . sprint(x) . "]=" . sprint(a[x])) log ("x in a-") - foreach (x in a-) log ("a[" . string(x) . "]=" . string(a[x])) + foreach (x in a-) log ("a[" . sprint(x) . "]=" . sprint(a[x])) } diff --git a/testsuite/buildok/twentythree.stp b/testsuite/buildok/twentythree.stp index 95a6f071..4aebe7bc 100755 --- a/testsuite/buildok/twentythree.stp +++ b/testsuite/buildok/twentythree.stp @@ -5,5 +5,5 @@ probe kernel.function("free_task") { $tsk->timestamp = 22; - log("set to 22 => " . string($tsk->timestamp)); + printf("set to 22 => %d\n", $tsk->timestamp); } diff --git a/testsuite/buildok/twentytwo.stp b/testsuite/buildok/twentytwo.stp index fa45f312..88a0b57b 100755 --- a/testsuite/buildok/twentytwo.stp +++ b/testsuite/buildok/twentytwo.stp @@ -4,10 +4,10 @@ probe kernel.function("free_task") { - log("timestamp " . string($tsk->timestamp)) + printf("timestamp %d\n", $tsk->timestamp) } probe kernel.function("vfs_llseek") { - log("offset " . string($offset)) + printf("offset %d\n", $offset) } diff --git a/testsuite/parseok/three.stp b/testsuite/parseok/three.stp index a1992b5e..e1158fea 100755 --- a/testsuite/parseok/three.stp +++ b/testsuite/parseok/three.stp @@ -3,6 +3,6 @@ probe syscall ("foo") { $a = a$a = a$a$ = 0; - string = "a" . $a . "b"; + str = "a" . $a . "b"; } diff --git a/testsuite/parseok/two.stp b/testsuite/parseok/two.stp index d18dd3e3..884e285d 100755 --- a/testsuite/parseok/two.stp +++ b/testsuite/parseok/two.stp @@ -3,7 +3,7 @@ probe syscall (231) { array[idx] <<< value; - if (global > 5) { global -- } else ; + if (gbl > 5) { gbl -- } else ; } function foo () { diff --git a/testsuite/semko/nineteen.stp b/testsuite/semko/nineteen.stp index bd8a4129..8f95d76b 100755 --- a/testsuite/semko/nineteen.stp +++ b/testsuite/semko/nineteen.stp @@ -4,5 +4,5 @@ # the inlines. probe kernel.function("context_switch") { - log ("switch from=" . hexstring($prev) . " to=" . hexstring($next)) + printf("switch from=0x%x to=0x%x\n", $prev, $next) } diff --git a/testsuite/semok/args.stp b/testsuite/semok/args.stp index 00475625..98112088 100755 --- a/testsuite/semok/args.stp +++ b/testsuite/semok/args.stp @@ -1,3 +1,3 @@ #! /bin/sh -./stap -p2 -e 'probe begin { log (@1 . string($2)) }' hello 0xdeadbeef +./stap -p2 -e 'probe begin { log (@1 . sprint($2)) }' hello 0xdeadbeef diff --git a/testsuite/semok/eleven.stp b/testsuite/semok/eleven.stp index e5e3c01c..93550bd5 100755 --- a/testsuite/semok/eleven.stp +++ b/testsuite/semok/eleven.stp @@ -3,8 +3,6 @@ global entry_time, my_count, my_fd, read_times # future built-ins -function string (v) { return "" } -function hexstring (v) { return "" } function trace (s) { return 0 } global tid @@ -16,8 +14,8 @@ probe begin /* kernel.function("read") */ { entry_time[tid] = timestamp # "macro" variable my_count[tid] = count # function argument my_fd[tid] = fd # function argument - trace ("my_count = " . string(my_count[tid]) . - "my_fd = " . string(my_fd[tid])) + trace ("my_count = " . sprint(my_count[tid]) . + "my_fd = " . sprint(my_fd[tid])) } probe end /* kernel.function("read").return */ { @@ -30,13 +28,13 @@ probe end /* kernel.function("read").return */ { } trace ("syscall " . (syscall_name) . " return value = " . - hexstring (retvalue)) # function pseudo-argument + sprintf ("0x%x", retvalue)) # function pseudo-argument } probe end { foreach (syscall in read_times) { trace ("syscall " . syscall . - " total-time=" . string (read_times[syscall])) + " total-time=" . sprint (read_times[syscall])) } } diff --git a/testsuite/semok/seven.stp b/testsuite/semok/seven.stp index f0b248bd..2ceed4e8 100755 --- a/testsuite/semok/seven.stp +++ b/testsuite/semok/seven.stp @@ -2,7 +2,6 @@ global ar1, ar2 -function string:string (v:long) { } # to become a built-in function printk (s:string) { return 0 } # to become a built-in function search (key) @@ -18,7 +17,7 @@ probe begin /* syscall("zamboni") */ tgid=0 pid=0 tid=0 - ar2[tid] = string (tgid); + ar2[tid] = sprint (tgid); search (pid) } @@ -26,5 +25,5 @@ probe end { # for (key in ar2) if (key in ar2) - printk ("this: " . string (key) . " was " . ar2[key]) + printk ("this: " . sprint (key) . " was " . ar2[key]) } diff --git a/testsuite/transko/two.stp b/testsuite/transko/two.stp index 5185281a..1ada54a3 100755 --- a/testsuite/transko/two.stp +++ b/testsuite/transko/two.stp @@ -1,7 +1,6 @@ #! stap -p3 function bar () { - next return 0 } @@ -9,5 +8,4 @@ probe end { break for (a=0; a<10; a=a+1) for (b=0; b<10; b=b+1) ; continue - return 0 } |