From 9109f487c1eb8806e8361ceb5c6cc48385fdb5fe Mon Sep 17 00:00:00 2001 From: Stan Cox Date: Tue, 21 Sep 2010 22:24:51 -0400 Subject: [PATCH] Disambiguate asm operand parsing for v3 sdt.h * tapsets.cxx (sdt_uprobe_var_expanding_visitor): Add probe_loc. (sdt_uprobe_var_expanding_visitor::visit_target_symbol): Support i as literal prefix so register names are unambiguous. * sdt_misc.exp (pbype_mssgs): Reorder --- tapsets.cxx | 18 ++++++++++++++---- testsuite/systemtap.base/sdt_misc.exp | 11 +++++------ 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/tapsets.cxx b/tapsets.cxx index 817693578..43b00b998 100644 --- a/tapsets.cxx +++ b/tapsets.cxx @@ -4611,10 +4611,12 @@ struct sdt_uprobe_var_expanding_visitor: public var_expanding_visitor const string & process_name, const string & provider_name, const string & probe_name, + int probe_loc, const string & arg_string, int ac): session (s), process_name (process_name), - provider_name (provider_name), probe_name (probe_name), arg_count ((unsigned) ac) + provider_name (provider_name), probe_name (probe_name), + probe_loc ((probe_loc_t)probe_loc), arg_count ((unsigned) ac) { /* Register name mapping table depends on the elf machine of this particular probe target process/file, not upon the host. So we can't just @@ -4683,6 +4685,8 @@ struct sdt_uprobe_var_expanding_visitor: public var_expanding_visitor const string & process_name; const string & provider_name; const string & probe_name; + typedef enum {probe_section=0, note_section=1} probe_loc_t; + probe_loc_t probe_loc; unsigned arg_count; vector arg_tokens; map dwarf_regs; @@ -4772,7 +4776,7 @@ sdt_uprobe_var_expanding_visitor::visit_target_symbol (target_symbol *e) // anyway. With -mregnames, we could, if gcc somehow // communicated to us the presence of that option, but alas it // doesn't. http://gcc.gnu.org/PR44995. - rc = regexp_match (asmarg, "^\\$[-]?[0-9][0-9]*$", matches); + rc = regexp_match (asmarg, "^[i\\$][-]?[0-9][0-9]*$", matches); if (! rc) { literal_number* ln = new literal_number(lex_cast(matches[0].substr(1))); // assume decimal @@ -4798,7 +4802,12 @@ sdt_uprobe_var_expanding_visitor::visit_target_symbol (target_symbol *e) // test for REGISTER // NB: Because PR11821, we must use percent_regnames here. - rc = regexp_match (asmarg, string("^(")+percent_regnames+string(")$"), matches); + if (probe_loc == probe_section) + rc = regexp_match (asmarg, string("^(")+percent_regnames+string(")$"), matches); + else if (probe_loc == note_section) + rc = regexp_match (asmarg, string("^(")+regnames+string(")$"), matches); + else + rc = 1; if (! rc) { string regname = matches[1]; @@ -5042,7 +5051,7 @@ struct sdt_query : public base_query private: stap_sdt_probe_type probe_type; - enum {probe_section, note_section} probe_loc; + enum {probe_section=0, note_section=1} probe_loc; probe * base_probe; probe_point * base_loc; literal_map_t const & params; @@ -5173,6 +5182,7 @@ sdt_query::handle_probe_entry() module_val, provider_name, probe_name, + probe_loc, arg_string, arg_count); svv.replace (new_base->body); diff --git a/testsuite/systemtap.base/sdt_misc.exp b/testsuite/systemtap.base/sdt_misc.exp index be4aab4c1..000e256df 100644 --- a/testsuite/systemtap.base/sdt_misc.exp +++ b/testsuite/systemtap.base/sdt_misc.exp @@ -9,20 +9,19 @@ set test "sdt_misc" # 6. Test .mark probe wildcard matching # 7. Test types defined in sdt_misc_.d. This requires -g -set v_flags {{-DSTAP_SDT_V2} {-DSTAP_SDT_V2} {-DSTAP_SDT_V1} {-DSTAP_SDT_V3}} -set pbtype_mssgs {{V2_uprobe} {V2_kprobe} {V1_uprobe} {V3_uprobe}} -set pbtype_flags {{}} +set v_flags {{-DSTAP_SDT_V1} {-DSTAP_SDT_V2} {-DSTAP_SDT_V2} {-DSTAP_SDT_V3}} +set pbtype_mssgs {{V1_uprobe} {V2_kprobe} {V2_uprobe} {V3_uprobe}} +set pbtype_flags {{additional_flags=-g} {additional_flags=-DEXPERIMENTAL_KPROBE_SDT}} switch -regexp $::tcl_platform(machine) { ^(x86_64|i.86)$ { lappend pbtype_flags {} + lappend pbtype_flags {} } default { lappend pbtype_flags {additional_flags=-g} + lappend pbtype_flags {additional_flags=-g} } } -lappend pbtype_flags {additional_flags=-DEXPERIMENTAL_KPROBE_SDT} -lappend pbtype_flags {additional_flags=-g} -lappend pbtype_flags {} proc cleanup_handler { verbose } { global pbtype_mssgs -- 2.43.5