summaryrefslogtreecommitdiffstats
path: root/parse.cxx
Commit message (Collapse)AuthorAgeFilesLines
* PR11343: backward compatibility option/conditionalFrank Ch. Eigler2010-04-081-6/+13
| | | | | | | | * main.cxx: Add "--compatible=VERSION" option. * session.h (compatible): Store it. * parse.cxx (eval_pp_conditional): Look at it as %( systemtap_v CMP VALUE ... %) * stap.1.in: Document it. * testsuite/parseko/preprocess17.stp, parseok/twenty.stp: Test it.
* PR10913: Fix error messages when unable to close certain tokensCharley Wang2010-03-231-4/+3
|
* Add startswith/endswith helpersJosh Stone2010-03-111-4/+4
| | | | | Inspired by the Python equivalents, these new utility functions just make it a little cleaner to match at the beginning or end of a string.
* PR11004: try / catch error-handling script syntaxFrank Ch. Eigler2010-03-031-2/+40
| | | | | | | | | | | | | | | * parse.h (try_block): New class. Update basic visitors. * staptree.cxx: Implement basic visitors. * parse.cxx (expect_kw): Fix to actually look for keywords. (parse_try_block): New function. (lexer ctor): Designate 'try' and 'catch' as keywords. * elaborate.cxx (dead_assignment_remover, dead_statmtexpr_remover): Optimize. (other visitors): Implement. * translate.cxx (c_unparser): Implement via super-handy __local__ labels. (emit_probe, emit_function): Make outer out: label also __local__. * testsuite/buildok/fortyone.stp, semko/fortynine.stp, systemtap.base/trycatch.exp: Test it. * NEWS, doc/langref.txt, stap.1.in: Document it.
* Permit chained unary operatorsJosh Stone2010-02-241-1/+1
| | | | | | | | The operand of a unary may be yet another unary. This is useful for things like boolean normalization, !!x. * parse.cxx (parser::parse_unary): Recurse the operand. * testsuite/parseok/eleven.stp: Add chained unary operators.
* Merge branch 'master' of ssh://sources.redhat.com/git/systemtapFrank Ch. Eigler2010-02-231-5/+1
|\ | | | | | | | | | | | | | | | | | | | | | | * 'master' of ssh://sources.redhat.com/git/systemtap: PR10719 part 1: Partial constant folding Simplify null_statement construction Fixed PR 11269 by properly handling mmap syscall 'fd' argument. Removed rvalue operator check. PR 10690 (partial fix). Handle '.=' operator in procfs probes. Conflicts: tapsets.h
| * Simplify null_statement constructionJosh Stone2010-02-231-5/+1
| | | | | | | | It only needs a token*, so build that into the constructor.
* | PR11005: @defined($tvar) predicate, part 1Frank Ch. Eigler2010-02-231-51/+66
|/ | | | | | | | | | | | | | | | | | * staptree.h (defined_op): New class. * all files: Extend all visitors as appropriate, mostly dummy/pass-through implementation. * parse.cxx (parse_target_symbol): New function, factored out of parse_symbol(). (parse_define_op): New function. * NEWS: Mention it. * parse.h: Corresponding changes. * tapsets.cxx (var_expanding_visitor::visit_defined_op): Implement @defined() semantics. (dwarf_var_expanding_visitor::visit_target_symbol): Adjust. * tapset-utrace.c (visit_target_symbol_arg): Avoid crashes on $argZZZ. * tapsets.cxx (sdt_var_expanding_visitor): Ditto. * semok/thirtysix.stp: New test.
* PR11208: glue adjacent string literals together.Frank Ch. Eigler2010-02-191-0/+14
| | | | | * parse.cxx (lexer::scan): Glue adjacent strings together. * testsuite/parseko/twentyseven.stp, semok/thirtyfive.stp: New tests.
* Allow CONFIG_foo COMPARISON-OP CONFIG_bar in preprocessor conditionals.Mark Wielaard2010-02-191-2/+26
| | | | | | | * parse.cxx (eval_pp_conditional): If rhs and lhs are both CONFIG_... identifiers try to convert them both to numbers or otherwise threat them both as strings for eval_comparison. * testsuite/semok/config_config.stp: New test.
* Allow CONFIG_foo COMPARISON-OP number in preprocessor conditionals.Mark Wielaard2010-02-191-12/+31
| | | | | | * parse.cxx (eval_pp_conditional): Handle r->type == tok_number when l->type == tok_identifier. * testsuite/semok/config_number.stp: New test.
* PR11195: Prevent all nested argument substitutionJosh Stone2010-01-191-30/+36
| | | | | | | | | | | Our existing protection only made sure that the first token in a substitution wasn't a nested substitution. That's not sufficient when there could be multiple tokens involved. This patch makes sure that no nested tokens are ever allowed to be argument substitutions. This also adds a cursor_suspended_line/column and resets the main cursor_line/column to the beginning of the substitution, so errors will point a little closer to the right place.
* PR10747: check invalid preprocessor constructWenji Huang2010-01-121-2/+18
| | | | | * parse.cxx (scan_pp): Match '%(' and '%?'. * testsuite/semko/conditional.stp: New test.
* PR11038 Trailing semicolon as null-statement confusing.Mark Wielaard2009-12-211-13/+22
| | | | | | * parse.cxx (parser::parse_statement): Squash semicolon after non-block-like statements. * testsuite/buildok/semicolon.stp: New test.
* PR10877: Give token* to each component instead of each probe_pointCharley Wang2009-11-101-4/+4
|
* Consolidate print_format creationJosh Stone2009-10-131-12/+1
| | | | | | | | | | | | | | | | | | We almost had a factory in print_format::parse_print, so let's take that the rest of the way. This way we don't have so much duplication in initializing the print flags. * staptree.cxx (print_format::parse_print): Replaced with... (print_format::create): New factory to parse and create print_formats. * elaborate.cxx (add_global_var_display): Use this factory. * parse.cxx (parser::parse_symbol): Ditto. * tapset-mark.cxx (mark_var_expanding_visitor::visit_target_symbol_context): Ditto. * tapset-utrace.cxx (utrace_var_expanding_visitor::visit_target_symbol_arg): Ditto. * tapsets.cxx (dwarf_var_expanding_visitor::visit_target_symbol_context): Ditto. (tracepoint_var_expanding_visitor::visit_target_symbol_context) Ditto.
* PR10257: Add support for sprint[ln](@hist_*).Przemyslaw Pawelczyk2009-10-131-1/+2
| | | | | | | | * parse.cxx (parser::parse_symbol): Add sprint[ln] to @hist_* hack. * runtime/stat-common.c: Replace reprint with new reprint_buf, add more generic _stp_stat_print_histogram_buf and call it from the older one. Also correct some formatting issues. * translate.cxx (c_unparser::visit_print_format): Add sprint case.
* parse: fix CONFIG_ matching typoFrank Ch. Eigler2009-10-131-1/+1
| | | | * parse.cxx (eval_pp_conditional): Flip rhs and lhs args for fnmatch().
* PR10702: preprocessor conditional for kernel CONFIG_fooFrank Ch. Eigler2009-10-081-3/+20
| | | | | | | | * session.h (kernel_config[]): New session field. * main.cxx (parse_kernel_config): Populate it. * parse.cxx (eval_comparison): Use it. * testsuite/buildok/utrace.stp, testsuite/parseok/kconfig.stp: New tests. * NEWS, stap.1.in, doc/langref.tex: Mention it.
* Unify lex_cast* and avoid string copiesJosh Stone2009-09-021-3/+2
| | | | | | | | | | | | | | | We always use lex_cast either to string or from string, so I made that explicit, and got rid of some string copies in the process. There was also stringify(), which was redundant to lex_cast<string>. We also always used lex_cast_hex to string, so that's now hard-coded and again eliminated a string copy. For lex_cast_qstring<string>, there's no need to write the streamify the input, so a specialization now operates directly on the input. Hopefully this is a bit cleaner, and I do measure it to be a little faster on scripts with many probes.
* Support || and && in preprocessor's conditions.Przemyslaw Pawelczyk2009-08-281-16/+30
| | | | | | | | | | * parse.cxx (parser::scan_pp): Add || and &&. * stap.1.in: Document || and && in PREPROCESSING. * testsuite/parseok/twenty.stp: Test case. * testsuite/parseko/preprocess14.stp: Ditto. * testsuite/parseko/preprocess15.stp: Ditto. Signed-off-by: Josh Stone <jistone@redhat.com>
* PR2049: support arbitrary $target-array indexingJosh Stone2009-08-031-3/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Rather than just numeric literals, we can now support arbitrary expressions for the index value. Note that loc2c won't allow this for noncontiguous arrays, as the access methods need to be statically computed, but for contiguous arrays and pointers-as-arrays it works just fine. * staptree.h (target_symbol::component): Add expression_array_index. * staptree.cxx (target_symbol::visit_components): New helper. (target_symbol::assert_no_components): Recognize new array type. (target_symbol::component::print): Print subexpressions. (traversing_visitor::visit_target_symbol, visit_cast_op): Visit the indexing components too. (varuse_collecting_visitor::visit_target_symbol): Ditto. (update_visitor::visit_target_symbol, visit_cast_op): Ditto. * elaborate.cxx (void_statement_reducer::visit_target_symbol): New. (void_statement_reducer::visit_cast_op): Save indexes too. * parse.cxx (parser::parse_target_symbol_components): Parse expressions. * tapsets.cxx (dwarf_var_expanding_visitor::visit_target_symbol): Pass expression-indexes as parameters (indexN) to the dwarf function. (dwarf_cast_expanding_visitor::visit_cast_op): Ditto. (tracepoint_var_expanding_visitor::visit_target_symbol_arg): Ditto. (sdt_var_expanding_visitor::visit_target_symbol): Visit the new @cast. * dwflpp.cxx (dwflpp::translate_components): Use THIS->indexN. * translate.cxx (c_unparser::visit_target_symbol): Correct error msg. * testsuite/systemtap.base/pointer_array.stp: Use a simple index.
* Make a real type for target_symbol->componentsJosh Stone2009-07-311-9/+8
| | | | | | | | | | | | | | | | | | | | Now the dereferences on target_symbol and cast_op are tracked with a struct instead of just a generic pair. The first immediate benefit is that we can track the token for more exact error reporting. * staptree.h (target_symbol): Add a new component type. * staptree.cxx (target_symbol::component::print): New. (operator<<(ostream&, target_symbol::component&): New. (target_symbol::print): Adapt component printing. (cast_op::print): Ditto. * parse.cxx (parser::parse_target_symbol_components): Adapt to the new component construction. * dwflpp.cxx (dwflpp::find_struct_member): take the component as a parameter for a better token in error messages (dwflpp::translate_components): Adapt to the new component type. * tapsets.cxx (dwarf_var_expanding_visitor::visit_target_symbol): Don't overwrite the token in target_symbol saved errors. (tracepoint_var_expanding_visitor::visit_target_symbol_arg): Ditto.
* Refactor parser for target_symbol->componentsJosh Stone2009-07-311-42/+30
| | | | | | | | The components were being parsed for both target_symbols and cast_ops, so this change refactors that code into a single function. * parse.cxx (parser::parse_target_symbol_components): New. (parser::parse_symbol): Use the new function.
* PR5930: Address-op for $target and @cast membersJosh Stone2009-07-151-0/+12
| | | | | | | | | | | | | | | | This allows the '&' operator to get the address of @cast and $target variable expressions. * staptree.h (target_symbol): add addressof field * staptree.cxx (target_symbol::print): print '&' for addressof (cast_op::print): ditto * parse.cxx (parser::parse_value): allow '&' prefix on $target/@cast * dwflpp.cxx (dwflpp::translate_final_fetch_or_store): allow taking the computed address without actually doing a final fetch. * tapset* (*::visit_target_symbol): throw errors for $vars w/o addresses * testsuite/systemtap.base/cast.stp: add &@cast test * testsuite/semok/target_addr.stp: test '&' on different member types * testsuite/semko/target_addr?.stp: test failure on bitfields/registers
* Fix source_loc ostream operator << representation.Mark Wielaard2009-07-101-1/+1
| | | | * parse.cxx (operator << (ostream&,const source_loc&)): Add loc.file->name.
* Remove the filename copy from token->locationJosh Stone2009-07-091-17/+11
| | | | | The location already has a pointer to a stapfile with the filename, so there's no need to keep an extra copy.
* Optimize string usage in the lexerJosh Stone2009-07-091-108/+95
| | | | | This speeds up the parsing stage >2x, mostly by minimizing string construction and comparison where char comparison will do.
* Allow @cast on "struct " and "union " (by ignoring them).Mark Wielaard2009-03-191-0/+6
| | | | | * parse.cxx (parser::parse_symbol): Strip off "struct " or "union " from cop->type.
* Bump copyright years to 2009Josh Stone2009-02-181-1/+1
|
* Add high-level support for @cast()ingJosh Stone2009-02-181-1/+48
| | | | | | | | | | | | | | | | | | This handles all of the parsing, traversal, and optimization. It doesn't actually resolve the cast yet though. * staptree.h (struct cast_op, visitor::visit_cast_op): New. * staptree.cxx (cast_op::print/visit, various visitor::visit_cast_op's): Incorporate cast_op into the basic tree operations. * parse.cxx (parser::parse_symbol): Parse @cast operator with an expression operand, type string, and optional module string. * translate.cxx (c_unparser::visit_cast_op): Error out if a @cast survives to translation. * elaborate.cxx (typeresolution_info::visit_cast_op): Error out if a @cast survives to type resolution. (symbol_fetcher::visit_cast_op): treat @casts as a symbol target (void_statement_reducer::visit_cast_op): unused @casts can be discarded, but the operand should still be evaluated.
* Add Vim modelines for GNU style in stapJosh Stone2009-01-281-0/+1
|
* PR5376: probe alias parsing tweaksFrank Ch. Eigler2008-11-281-0/+4
|
* Display source context for error and warning messages (6701)Rajan Arora2008-10-091-3/+27
|
* parser/scanner speedupFrank Ch. Eigler2008-09-101-16/+19
|
* trailing whitespace removal, as approved by emacsFrank Ch. Eigler2008-08-281-81/+81
| | | | (add-hook 'before-save-hook 'delete-trailing-whitespace)
* PR6470: new argv[] tapset, docs, test casesFrank Ch. Eigler2008-06-101-13/+9
|
* PR6470: fix preprocessor construct nesting/expansion logicFrank Ch. Eigler2008-06-101-46/+78
|
* PR6470: fix %( number OP number %? .... %) logicFrank Ch. Eigler2008-06-101-30/+38
|
* PR 5955 - Accept ; terminated globalsAnanth N Mavinakayanahalli2008-05-141-0/+3
|
* PR5792: wildcard support for %( kernel/arch %) preprocessor operandsfche2008-02-261-16/+40
| | | | | | | | | | | | | | 2008-02-25 Frank Ch. Eigler <fche@elastic.org> PR5792. * parse.cxx (eval_pp_conditional): Support wildcards in %( kernel_v/kernel_vr/arch ==/!= "*foo?" %) operands. * NEWS, stap.1.in: Document this. 2008-02-25 Frank Ch. Eigler <fche@elastic.org> PR5792. * systemtap.base/preprocessor.exp: New test.
* 2007-12-12 Wenji Huang <wenji.huang@oracle.com>wenji2007-12-121-2/+2
| | | | | PR 5470 * parse.cxx (parser::parse_probe_point): Add checking pointer t.
* 2007-12-03 Masami Hiramatsu <mhiramat@redhat.com>hiramatu2007-12-031-37/+18
| | | | | | | | | | | | | PR 5376 * parse.cxx (lexer::scan): Treat '*' as an alphabet if the wildcard flag is true. (parser::parse_probe_point): Call parser::next() with wildcard = true. (parser::scan_pp): Add wildcard flag and pass it to lexer::scan. (parser::next): Ditto. (parser::peek): Ditto. * parse.h : Ditto. * testsuites/perseko/twentytwo.stp: Change testcase to the wildcarded probe points with spaces.
* 2007-11-20 Masami Hiramatsu <mhiramat@redhat.com>hiramatu2007-11-201-0/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | PR 4935. * parse.cxx (parser::parse_probe_point): Parse "if" condition following probe point. * staptree.h (probe_point): Add "condition" field. (probe): Add "condition" field and "add_condition" method. (deep_copy_visitor): Add "deep_copy" method for the expression. * staptree.cxx (probe_point::probe_point): Initalize it. (probe::add_condition): Implement it. (probe::print): Output "condition" field. (probe::str): Ditto. (deep_copy_visitor::deep_copy): Implement it. * elaborate.h (derived_probe): Add "insert_condition_statement" method. * elaborate.cxx (derived_probe::derived_probe): Initialize "condition" field, and insert a condition check routine on the top of body. (derived_probe::insert_condition_statement): Implement it. (alias_expansion_builder::build): Pass the condition from the alias referer to new alias. * tapsets.cxx (be_derived_probe): Remove unused constructor. (dwarf_derived_probe::dwarf_derived_probe): Insert a condition check routine on the top of body. (mark_derived_probe::mark_derived_probe): Ditto. (mark_builder::build): Pass the base location to mark_derived_probe.
* PR 3887: sufficient+optional probe pointsfche2007-11-201-3/+5
| | | | | | | | | | | | | | | | 2007-11-19 Frank Ch. Eigler <fche@elastic.org> PR 3887. * staptree.h (probe_point): Add "sufficient" field. * staptree.cxx: Initialize it, print it. * parse.cxx (parse_probe_point): Parse it. * elaborate.cxx (derive_probes): Implement it. * stapprobes.5.in: Document it. * NEWS: Gloat about it. * parseok/five.stp, semok/twentyseven.stp: Test "!" probe point flag. * iostat-scsi.stp: Adopt "!" probe point flag.
* 2007-11-12 Martin Hunt <hunt@redhat.com>hunt2007-11-121-2/+3
| | | | | | | | | | | | | * translate.cxx (visit_print_format): Strings without a format or formatted with "%s" or "%s\n" should be printed with calls to _stp_print(). Call _stp_print_char() if printing a char. * staptree.cxx (parse_print): Check for "print_char". * staptree.h (struct print_format): Add print_char. (parse_print): Update prototype. * parse.cxx (parse_symbol): Set print_char bool in print_format.
* 2007-09-12 Frank Ch. Eigler <fche@elastic.org>fche2007-09-131-1/+1
| | | | | | | | * parse.cxx (parse_symbol): Accept println(@hist*()). 2007-09-12 Frank Ch. Eigler <fche@elastic.org> * buildok/print_histograms.stp: Test println(@hist*()).
* 2007-09-12 Martin Hunt <hunt@redhat.com>hunt2007-09-121-22/+30
| | | | | | | | | | | | | | PR 5019 * elaborate.cxx (visit_hist_op): Remove log histogram param. * translate.cxx (assert_hist_compatible): Ditto. * staptree.cxx (hist_op::print): Ditto. * session.h (statistic_decl): Ditto. * parse.cxx (expect_number): Allow negative numbers. Also validate that input is really numeric. This is used by histograms to get the parameters. (parse_hist_op_or_bare_name): Remove code to get parameter for log histograms.
* 2007-08-16 Josh Stone <joshua.i.stone@intel.com>jistone2007-08-171-29/+46
| | | | | | | | | | | | | | | | | | | | | | | | | | PR 4591 * parse.cxx (parser::parse_symbol): Tweak 'print' matching to allow all the new variants with printd and println. * staptree.h (struct print_format): Add fields for the new print variants, and parse_print() to help matching. * staptree.cxx (print_format::parse_print): New static method to match the print variants and determine their properties. (print_format::print): Handle the new print types. (deep_copy_visitor::visit_print_format): Copy the new fields. * translate.cxx (c_unparser::visit_print_format): Insert delims and newlines where appropriate for new print functions. * stap1.in: Document the new print functions. testsuite/ * lib/stap_run.exp: Make sure to match the entire output, in case there are multiple pass/fail messages. * buildok/printf.stp: Add lines for new print variants. * parseko/printd01.stp: Make sure that bad printd calls are handled. * parseko/printd02.stp: Ditto. * parseko/printd03.stp: Ditto. * parseko/printd04.stp: Ditto. * systemtap.base/print.stp: Try a bunch of different print calls. * systemtap.base/print.exp: Driver for above.
* 2007-08-07 Frank Ch. Eigler <fche@redhat.com>fche2007-08-081-81/+111
| | | | | | | | | | | | | | | | PR 4846 * parse.cxx (input_put): New function, sort of like stdio ungetc. (input_get): Skip cursor position changing for input_put strings. (scan): Rework $.../@... substitution into character pasting. * parse.h: Corresponding changes. * util.h (lex_cast_qstring): Octal-quote unprintable characters. * stap.1.in, NEWS: Document new behaviour. 2007-08-07 Frank Ch. Eigler <fche@redhat.com> PR 4846 * parseko/preprocess13.stp, parseok/nineteen.stp, semok/twentyfive.stp: New tests.