From eaa15b047688175a94e3ae796529785a3a0af208 Mon Sep 17 00:00:00 2001 From: Stan Cox Date: Thu, 30 Sep 2021 16:11:29 -0400 Subject: [PATCH] PR27829: Support floating point values passed through sdt.h markers Add the type to the individual arg entries in the .notes.stapsdt section; currently SP@A, where S is optional '-' sign, P is precision of type and A is address. Revised format is SPT@A where T is optional 'f' for float variables. Add x8664 float registers xmm8 - xmm15 and aarch64 float registers v8 - v31. Parse the type field; result is currently ignored. asm statements are restricted to 30 arguments; sdt probes can have up to 12 arguments. To fit this into a single asm statement, precision and type are encoded into a single field: 0xSSTT where SS is the precision and TT is the type as encoded by __builtin_classify_type. The sign S, precision P, and type T are decoded by _SDT_SIGN, _SDT_SIZE, and _SDT_TYPE. Test that the revised .notes.stapsdt section interacts correctly with eu-elfutils and gdb. --- includes/sys/sdt.h | 89 ++++++++++++++++++++------ main.cxx | 1 + runtime/loc2c-runtime.h | 37 ++++++++++- tapsets.cxx | 37 ++++++++++- testsuite/systemtap.base/sdt_notes.exp | 70 ++++++++++++++++++++ 5 files changed, 212 insertions(+), 22 deletions(-) create mode 100644 testsuite/systemtap.base/sdt_notes.exp diff --git a/includes/sys/sdt.h b/includes/sys/sdt.h index 97766e710..f757a46a1 100644 --- a/includes/sys/sdt.h +++ b/includes/sys/sdt.h @@ -43,13 +43,14 @@ #ifdef __ASSEMBLER__ # define _SDT_PROBE(provider, name, n, arglist) \ - _SDT_ASM_BODY(provider, name, _SDT_ASM_STRING_1, (_SDT_DEPAREN_##n arglist)) \ + _SDT_ASM_BODY(provider, name, _SDT_ASM_SUBSTR_1, (_SDT_DEPAREN_##n arglist)) \ _SDT_ASM_BASE # define _SDT_ASM_1(x) x; # define _SDT_ASM_2(a, b) a,b; # define _SDT_ASM_3(a, b, c) a,b,c; # define _SDT_ASM_5(a, b, c, d, e) a,b,c,d,e; # define _SDT_ASM_STRING_1(x) .asciz #x; +# define _SDT_ASM_SUBSTR_1(x) .ascii #x; # define _SDT_DEPAREN_0() /* empty */ # define _SDT_DEPAREN_1(a) a # define _SDT_DEPAREN_2(a,b) a b @@ -86,14 +87,23 @@ # define _SDT_ASM_5(a, b, c, d, e) _SDT_S(a) "," _SDT_S(b) "," \ _SDT_S(c) "," _SDT_S(d) "," \ _SDT_S(e) "\n" -# define _SDT_ASM_ARGS(n) _SDT_ASM_STRING(_SDT_ASM_TEMPLATE_##n) +# define _SDT_ASM_ARGS(n) _SDT_ASM_TEMPLATE_##n # define _SDT_ASM_STRING_1(x) _SDT_ASM_1(.asciz #x) +# define _SDT_ASM_SUBSTR_1(x) _SDT_ASM_1(.ascii #x) + +# define _SDT_ARGFMT(no) _SDT_ASM_1(_SDT_SIGN %n[_SDT_S##no]) \ + _SDT_ASM_1(_SDT_SIZE %n[_SDT_S##no]) \ + _SDT_ASM_1(_SDT_TYPE %n[_SDT_S##no]) \ + _SDT_ASM_SUBSTR(_SDT_ARGTMPL(_SDT_A##no)) -# define _SDT_ARGFMT(no) %n[_SDT_S##no]@_SDT_ARGTMPL(_SDT_A##no) # ifndef STAP_SDT_ARG_CONSTRAINT # if defined __powerpc__ # define STAP_SDT_ARG_CONSTRAINT nZr +# elif defined __x86_64__ +# define STAP_SDT_ARG_CONSTRAINT norfxy +# elif defined __aarch64__ +# define STAP_SDT_ARG_CONSTRAINT norw # else # define STAP_SDT_ARG_CONSTRAINT nor # endif @@ -101,11 +111,14 @@ # define _SDT_STRINGIFY(x) #x # define _SDT_ARG_CONSTRAINT_STRING(x) _SDT_STRINGIFY(x) -# define _SDT_ARG(n, x) \ - [_SDT_S##n] "n" ((_SDT_ARGSIGNED (x) ? 1 : -1) * (int) _SDT_ARGSIZE (x)), \ +/* _SDT_S encodes the size and type as 0xSSTT which is decoded by the assembler + macros _SDT_SIZE and _SDT_TYPE */ +# define _SDT_ARG(n, x) \ + [_SDT_S##n] "n" ((_SDT_ARGSIGNED (x) ? (int)-1 : 1) * (-(((int) _SDT_ARGSIZE (x)) << 8) + (-(0x7f & __builtin_classify_type (x))))), \ [_SDT_A##n] _SDT_ARG_CONSTRAINT_STRING (STAP_SDT_ARG_CONSTRAINT) (_SDT_ARGVAL (x)) #endif #define _SDT_ASM_STRING(x) _SDT_ASM_STRING_1(x) +#define _SDT_ASM_SUBSTR(x) _SDT_ASM_SUBSTR_1(x) #define _SDT_ARGARRAY(x) (__builtin_classify_type (x) == 14 \ || __builtin_classify_type (x) == 5) @@ -237,7 +250,44 @@ __extension__ extern unsigned long long __sdt_unsp; # define _SDT_ASM_AUTOGROUP "" #endif +#define _SDT_DEF_MACROS \ + _SDT_ASM_1(.altmacro) \ + _SDT_ASM_1(.macro _SDT_SIGN x) \ + _SDT_ASM_3(.pushsection .note.stapsdt,"","note") \ + _SDT_ASM_1(.iflt \\x) \ + _SDT_ASM_1(.ascii "-") \ + _SDT_ASM_1(.endif) \ + _SDT_ASM_1(.popsection) \ + _SDT_ASM_1(.endm) \ + _SDT_ASM_1(.macro _SDT_SIZE_ x) \ + _SDT_ASM_3(.pushsection .note.stapsdt,"","note") \ + _SDT_ASM_1(.ascii "\x") \ + _SDT_ASM_1(.popsection) \ + _SDT_ASM_1(.endm) \ + _SDT_ASM_1(.macro _SDT_SIZE x) \ + _SDT_ASM_1(_SDT_SIZE_ %%((-(-\\x*((-\\x>0)-(-\\x<0))))>>8)) \ + _SDT_ASM_1(.endm) \ + _SDT_ASM_1(.macro _SDT_TYPE_ x) \ + _SDT_ASM_3(.pushsection .note.stapsdt,"","note") \ + _SDT_ASM_2(.ifc 8,\\x) \ + _SDT_ASM_1(.ascii "f") \ + _SDT_ASM_1(.endif) \ + _SDT_ASM_1(.ascii "@") \ + _SDT_ASM_1(.popsection) \ + _SDT_ASM_1(.endm) \ + _SDT_ASM_1(.macro _SDT_TYPE x) \ + _SDT_ASM_1(_SDT_TYPE_ %%((\\x)&(0xff))) \ + _SDT_ASM_1(.endm) + +#define _SDT_UNDEF_MACROS \ + _SDT_ASM_1(.purgem _SDT_SIGN) \ + _SDT_ASM_1(.purgem _SDT_SIZE_) \ + _SDT_ASM_1(.purgem _SDT_SIZE) \ + _SDT_ASM_1(.purgem _SDT_TYPE_) \ + _SDT_ASM_1(.purgem _SDT_TYPE) + #define _SDT_ASM_BODY(provider, name, pack_args, args) \ + _SDT_DEF_MACROS \ _SDT_ASM_1(990: _SDT_NOP) \ _SDT_ASM_3( .pushsection .note.stapsdt,_SDT_ASM_AUTOGROUP,"note") \ _SDT_ASM_1( .balign 4) \ @@ -250,6 +300,8 @@ __extension__ extern unsigned long long __sdt_unsp; _SDT_ASM_STRING(provider) \ _SDT_ASM_STRING(name) \ pack_args args \ + _SDT_ASM_SUBSTR(\x00) \ + _SDT_UNDEF_MACROS \ _SDT_ASM_1(994: .balign 4) \ _SDT_ASM_1( .popsection) @@ -271,19 +323,20 @@ __extension__ extern unsigned long long __sdt_unsp; #define _SDT_SEMAPHORE(p,n) _SDT_ASM_1( _SDT_ASM_ADDR 0) #endif +#define _SDT_ASM_BLANK _SDT_ASM_SUBSTR(\x20) #define _SDT_ASM_TEMPLATE_0 /* no arguments */ #define _SDT_ASM_TEMPLATE_1 _SDT_ARGFMT(1) -#define _SDT_ASM_TEMPLATE_2 _SDT_ASM_TEMPLATE_1 _SDT_ARGFMT(2) -#define _SDT_ASM_TEMPLATE_3 _SDT_ASM_TEMPLATE_2 _SDT_ARGFMT(3) -#define _SDT_ASM_TEMPLATE_4 _SDT_ASM_TEMPLATE_3 _SDT_ARGFMT(4) -#define _SDT_ASM_TEMPLATE_5 _SDT_ASM_TEMPLATE_4 _SDT_ARGFMT(5) -#define _SDT_ASM_TEMPLATE_6 _SDT_ASM_TEMPLATE_5 _SDT_ARGFMT(6) -#define _SDT_ASM_TEMPLATE_7 _SDT_ASM_TEMPLATE_6 _SDT_ARGFMT(7) -#define _SDT_ASM_TEMPLATE_8 _SDT_ASM_TEMPLATE_7 _SDT_ARGFMT(8) -#define _SDT_ASM_TEMPLATE_9 _SDT_ASM_TEMPLATE_8 _SDT_ARGFMT(9) -#define _SDT_ASM_TEMPLATE_10 _SDT_ASM_TEMPLATE_9 _SDT_ARGFMT(10) -#define _SDT_ASM_TEMPLATE_11 _SDT_ASM_TEMPLATE_10 _SDT_ARGFMT(11) -#define _SDT_ASM_TEMPLATE_12 _SDT_ASM_TEMPLATE_11 _SDT_ARGFMT(12) +#define _SDT_ASM_TEMPLATE_2 _SDT_ASM_TEMPLATE_1 _SDT_ASM_BLANK _SDT_ARGFMT(2) +#define _SDT_ASM_TEMPLATE_3 _SDT_ASM_TEMPLATE_2 _SDT_ASM_BLANK _SDT_ARGFMT(3) +#define _SDT_ASM_TEMPLATE_4 _SDT_ASM_TEMPLATE_3 _SDT_ASM_BLANK _SDT_ARGFMT(4) +#define _SDT_ASM_TEMPLATE_5 _SDT_ASM_TEMPLATE_4 _SDT_ASM_BLANK _SDT_ARGFMT(5) +#define _SDT_ASM_TEMPLATE_6 _SDT_ASM_TEMPLATE_5 _SDT_ASM_BLANK _SDT_ARGFMT(6) +#define _SDT_ASM_TEMPLATE_7 _SDT_ASM_TEMPLATE_6 _SDT_ASM_BLANK _SDT_ARGFMT(7) +#define _SDT_ASM_TEMPLATE_8 _SDT_ASM_TEMPLATE_7 _SDT_ASM_BLANK _SDT_ARGFMT(8) +#define _SDT_ASM_TEMPLATE_9 _SDT_ASM_TEMPLATE_8 _SDT_ASM_BLANK _SDT_ARGFMT(9) +#define _SDT_ASM_TEMPLATE_10 _SDT_ASM_TEMPLATE_9 _SDT_ASM_BLANK _SDT_ARGFMT(10) +#define _SDT_ASM_TEMPLATE_11 _SDT_ASM_TEMPLATE_10 _SDT_ASM_BLANK _SDT_ARGFMT(11) +#define _SDT_ASM_TEMPLATE_12 _SDT_ASM_TEMPLATE_11 _SDT_ASM_BLANK _SDT_ARGFMT(12) #define _SDT_ASM_OPERANDS_0() [__sdt_dummy] "g" (0) #define _SDT_ASM_OPERANDS_1(arg1) _SDT_ARG(1, arg1) #define _SDT_ASM_OPERANDS_2(arg1, arg2) \ @@ -413,12 +466,12 @@ __extension__ extern unsigned long long __sdt_unsp; #if __STDC_VERSION__ >= 199901L # define STAP_PROBE_ASM(provider, name, ...) \ - _SDT_ASM_BODY(provider, name, _SDT_ASM_STRING, (__VA_ARGS__)) \ + _SDT_ASM_BODY(provider, name, /*_SDT_ASM_STRING */, __VA_ARGS__) \ _SDT_ASM_BASE # define STAP_PROBE_ASM_OPERANDS(n, ...) _SDT_ASM_OPERANDS_##n(__VA_ARGS__) #else # define STAP_PROBE_ASM(provider, name, args) \ - _SDT_ASM_BODY(provider, name, _SDT_ASM_STRING, (args)) \ + _SDT_ASM_BODY(provider, name, /* _SDT_ASM_STRING */, (args)) \ _SDT_ASM_BASE #endif #define STAP_PROBE_ASM_TEMPLATE(n) _SDT_ASM_TEMPLATE_##n diff --git a/main.cxx b/main.cxx index bc004b61b..9c164b57d 100644 --- a/main.cxx +++ b/main.cxx @@ -382,6 +382,7 @@ sdt_benchmark_thread(unsigned long i, double fp1, float fp2) fp2 += 0.0; double fp_local1 = 1.01; float fp_local2 = 2.02; + PROBE2(stap, benchmark__fp, fp1+fp_local1, fp2+fp_local2); double fp_local3 = 3.03; double fp_local4 = 4.04; double fp_local5 = 5.05; diff --git a/runtime/loc2c-runtime.h b/runtime/loc2c-runtime.h index 33463c394..163954e01 100644 --- a/runtime/loc2c-runtime.h +++ b/runtime/loc2c-runtime.h @@ -106,7 +106,16 @@ #define pt_dwarf_register_22(regs) ({uint64_t v; __asm__ __volatile__("movq %%xmm5, %0" : "=r"(v)); v;}) #define pt_dwarf_register_23(regs) ({uint64_t v; __asm__ __volatile__("movq %%xmm6, %0" : "=r"(v)); v;}) #define pt_dwarf_register_24(regs) ({uint64_t v; __asm__ __volatile__("movq %%xmm7, %0" : "=r"(v)); v;}) -#define pt_regs_maxno 24 +#define pt_dwarf_register_25(regs) ({uint64_t v; __asm__ __volatile__("movq %%xmm8, %0" : "=r"(v)); v;}) +#define pt_dwarf_register_26(regs) ({uint64_t v; __asm__ __volatile__("movq %%xmm9, %0" : "=r"(v)); v;}) +#define pt_dwarf_register_27(regs) ({uint64_t v; __asm__ __volatile__("movq %%xmm10, %0" : "=r"(v)); v;}) +#define pt_dwarf_register_28(regs) ({uint64_t v; __asm__ __volatile__("movq %%xmm11, %0" : "=r"(v)); v;}) +#define pt_dwarf_register_29(regs) ({uint64_t v; __asm__ __volatile__("movq %%xmm12, %0" : "=r"(v)); v;}) +#define pt_dwarf_register_30(regs) ({uint64_t v; __asm__ __volatile__("movq %%xmm13, %0" : "=r"(v)); v;}) +#define pt_dwarf_register_31(regs) ({uint64_t v; __asm__ __volatile__("movq %%xmm14, %0" : "=r"(v)); v;}) +#define pt_dwarf_register_32(regs) ({uint64_t v; __asm__ __volatile__("movq %%xmm15, %0" : "=r"(v)); v;}) + +#define pt_regs_maxno 32 #elif defined __i386__ @@ -259,7 +268,31 @@ #define pt_dwarf_register_69(regs) ({uint64_t v; __asm__ __volatile__("mov %0, v5.d[0]" : "=r"(v)); v;}) #define pt_dwarf_register_70(regs) ({uint64_t v; __asm__ __volatile__("mov %0, v6.d[0]" : "=r"(v)); v;}) #define pt_dwarf_register_71(regs) ({uint64_t v; __asm__ __volatile__("mov %0, v7.d[0]" : "=r"(v)); v;}) -#define pt_regs_maxno 71 +#define pt_dwarf_register_72(regs) ({uint64_t v; __asm__ __volatile__("mov %0, v8.d[0]" : "=r"(v)); v;}) +#define pt_dwarf_register_73(regs) ({uint64_t v; __asm__ __volatile__("mov %0, v9.d[0]" : "=r"(v)); v;}) +#define pt_dwarf_register_74(regs) ({uint64_t v; __asm__ __volatile__("mov %0, v10.d[0]" : "=r"(v)); v;}) +#define pt_dwarf_register_75(regs) ({uint64_t v; __asm__ __volatile__("mov %0, v11.d[0]" : "=r"(v)); v;}) +#define pt_dwarf_register_76(regs) ({uint64_t v; __asm__ __volatile__("mov %0, v12.d[0]" : "=r"(v)); v;}) +#define pt_dwarf_register_77(regs) ({uint64_t v; __asm__ __volatile__("mov %0, v13.d[0]" : "=r"(v)); v;}) +#define pt_dwarf_register_78(regs) ({uint64_t v; __asm__ __volatile__("mov %0, v14.d[0]" : "=r"(v)); v;}) +#define pt_dwarf_register_79(regs) ({uint64_t v; __asm__ __volatile__("mov %0, v15.d[0]" : "=r"(v)); v;}) +#define pt_dwarf_register_80(regs) ({uint64_t v; __asm__ __volatile__("mov %0, v16.d[0]" : "=r"(v)); v;}) +#define pt_dwarf_register_81(regs) ({uint64_t v; __asm__ __volatile__("mov %0, v17.d[0]" : "=r"(v)); v;}) +#define pt_dwarf_register_82(regs) ({uint64_t v; __asm__ __volatile__("mov %0, v18.d[0]" : "=r"(v)); v;}) +#define pt_dwarf_register_83(regs) ({uint64_t v; __asm__ __volatile__("mov %0, v19.d[0]" : "=r"(v)); v;}) +#define pt_dwarf_register_84(regs) ({uint64_t v; __asm__ __volatile__("mov %0, v20.d[0]" : "=r"(v)); v;}) +#define pt_dwarf_register_85(regs) ({uint64_t v; __asm__ __volatile__("mov %0, v21.d[0]" : "=r"(v)); v;}) +#define pt_dwarf_register_86(regs) ({uint64_t v; __asm__ __volatile__("mov %0, v22.d[0]" : "=r"(v)); v;}) +#define pt_dwarf_register_87(regs) ({uint64_t v; __asm__ __volatile__("mov %0, v23.d[0]" : "=r"(v)); v;}) +#define pt_dwarf_register_88(regs) ({uint64_t v; __asm__ __volatile__("mov %0, v24.d[0]" : "=r"(v)); v;}) +#define pt_dwarf_register_89(regs) ({uint64_t v; __asm__ __volatile__("mov %0, v25.d[0]" : "=r"(v)); v;}) +#define pt_dwarf_register_90(regs) ({uint64_t v; __asm__ __volatile__("mov %0, v26.d[0]" : "=r"(v)); v;}) +#define pt_dwarf_register_91(regs) ({uint64_t v; __asm__ __volatile__("mov %0, v27.d[0]" : "=r"(v)); v;}) +#define pt_dwarf_register_92(regs) ({uint64_t v; __asm__ __volatile__("mov %0, v28.d[0]" : "=r"(v)); v;}) +#define pt_dwarf_register_93(regs) ({uint64_t v; __asm__ __volatile__("mov %0, v29.d[0]" : "=r"(v)); v;}) +#define pt_dwarf_register_94(regs) ({uint64_t v; __asm__ __volatile__("mov %0, v30.d[0]" : "=r"(v)); v;}) +#define pt_dwarf_register_95(regs) ({uint64_t v; __asm__ __volatile__("mov %0, v31.d[0]" : "=r"(v)); v;}) +#define pt_regs_maxno 95 #elif defined (__arm__) diff --git a/tapsets.cxx b/tapsets.cxx index 2776d622c..30352a7e9 100644 --- a/tapsets.cxx +++ b/tapsets.cxx @@ -6538,6 +6538,7 @@ struct sdt_uprobe_var_expanding_visitor: public var_expanding_visitor void visit_target_symbol (target_symbol* e); unsigned get_target_symbol_argno_and_validate (target_symbol* e); long parse_out_arg_precision(string& asmarg); + char parse_out_arg_type(string& asmarg); expression* try_parse_arg_literal (target_symbol *e, const string& asmarg, long precision); @@ -6604,6 +6605,12 @@ sdt_uprobe_var_expanding_visitor::build_dwarf_registers () DRI ("%r15", 15, DI); DRI ("%r15d", 15, SI); DRI ("%r15w", 15, HI); DRI ("%r15b", 15, QI); DRI ("%rip", 16, DI); DRI ("%eip", 16, SI); DRI ("%ip", 16, HI); + DRI ("%xmm0", 17, DI); DRI ("%xmm1", 18, DI); DRI ("%xmm2", 19, DI); DRI ("%xmm3", 20, DI); + DRI ("%xmm4", 21, DI); DRI ("%xmm5", 22, DI); DRI ("%xmm6", 23, DI); DRI ("%xmm7", 24, DI); + DRI ("%xmm8", 25, DI); DRI ("%xmm9", 26, DI); DRI ("%xmm10", 27, DI); DRI ("%xmm11", 28, DI); + DRI ("%xmm12", 29, DI); DRI ("%xmm13", 30, DI); DRI ("%xmm14", 31, DI); DRI ("%xmm15", 32, DI); + DRI ("%st0", 33, DI); DRI ("%st1", 34, DI); DRI ("%st2", 35, DI); DRI ("%st3", 36, DI); + DRI ("%st4", 37, DI); DRI ("%st5", 38, DI); DRI ("%st6", 39, DI); DRI ("%st7", 40, DI); } else if (elf_machine == EM_386) { DRI ("%eax", 0, SI); DRI ("%ax", 0, HI); DRI ("%al", 0, QI); DRI ("%ah", 0, QIh); @@ -6750,6 +6757,14 @@ sdt_uprobe_var_expanding_visitor::build_dwarf_registers () DRI ("x29", 29, DI); DRI ("w29", 29, SI); DRI ("x30", 30, DI); DRI ("w30", 30, SI); DRI ("sp", 31, DI); + DRI ("v0", 64, DI); DRI ("v1", 65, DI); DRI ("v2", 66, DI); DRI ("v3", 67, DI); + DRI ("v4", 68, DI); DRI ("v5", 69, DI); DRI ("v6", 70, DI); DRI ("v7", 71, DI); + DRI ("v8", 72, DI); DRI ("v9", 73, DI); DRI ("v10", 74, DI); DRI ("v11", 75, DI); + DRI ("v12", 76, DI); DRI ("v13", 77, DI); DRI ("v14", 78, DI); DRI ("v15", 79, DI); + DRI ("v16", 80, DI); DRI ("v17", 81, DI); DRI ("v18", 82, DI); DRI ("v19", 83, DI); + DRI ("v20", 84, DI); DRI ("v21", 85, DI); DRI ("v22", 86, DI); DRI ("v23", 87, DI); + DRI ("v24", 88, DI); DRI ("25", 89, DI); DRI ("v26", 90, DI); DRI ("v27", 91, DI); + DRI ("v28", 92, DI); DRI ("v29", 93, DI); DRI ("v30", 94, DI); DRI ("v31", 95, DI); } else if (elf_machine == EM_RISCV) { Dwarf_Addr bias; Elf* elf = (dwfl_module_getelf (dw.mod_info->mod, &bias)); @@ -6981,8 +6996,9 @@ sdt_uprobe_var_expanding_visitor::parse_out_arg_precision(string& asmarg) long precision; if (asmarg.find('@') != string::npos) { - precision = lex_cast(asmarg.substr(0, asmarg.find('@'))); - asmarg = asmarg.substr(asmarg.find('@')+1); + long at_or_type = asmarg.find_first_of("@f"); + precision = lex_cast(asmarg.substr(0, at_or_type)); + asmarg = asmarg.substr(at_or_type); } else { @@ -6996,6 +7012,21 @@ sdt_uprobe_var_expanding_visitor::parse_out_arg_precision(string& asmarg) return precision; } +char +sdt_uprobe_var_expanding_visitor::parse_out_arg_type(string& asmarg) +{ + // Reference: __builtin_classify_type + char type; + if (asmarg.find('@') != string::npos) + { + type = asmarg[0]; + asmarg = asmarg.substr(asmarg.find('@')+1); + } + else + type = 'i'; + return type; +} + expression* sdt_uprobe_var_expanding_visitor::try_parse_arg_literal (target_symbol *e, const string& asmarg, @@ -7451,6 +7482,8 @@ sdt_uprobe_var_expanding_visitor::visit_target_symbol_arg (target_symbol *e) // Parse (and remove from asmarg) the leading length long precision = parse_out_arg_precision(asmarg); + char type __attribute__ ((unused)); + type = parse_out_arg_type(asmarg); try { diff --git a/testsuite/systemtap.base/sdt_notes.exp b/testsuite/systemtap.base/sdt_notes.exp new file mode 100644 index 000000000..5fbb2abe0 --- /dev/null +++ b/testsuite/systemtap.base/sdt_notes.exp @@ -0,0 +1,70 @@ +set test "sdt_notes" + +# Test layout of .note.stapsdt section and interaction with eu-readelf and gdb + +set res [target_compile $srcdir/$subdir/sdt_types.c \ + sdt_types.x executable additional_flags=-O2] +if { $res != "" } { + verbose "target_compile failed: $res" 2 + untested "$test compiling types" +} else { + pass "$test compiling types" +} + +set elfutils_ok 0 +# Does elfutils support stapsdt notes? +eval spawn "rpm -q elfutils" +expect { + -re {elfutils-0.17} { incr elfutils_ok } + -re {elfutils-0.18} { incr elfutils_ok } + -re {elfutils-0.19} { incr elfutils_ok } +} + +if { $elfutils_ok > 0 } { +set ok 0 +# not all eu-readelf versions support --notes=.note.stapsdt +set cmd "bash -c {eu-readelf --notes ./sdt_types.x |& grep '\@' |& sed 's/.\[0-9\]\@/\\n&/g'}" +eval spawn $cmd +expect { + -timeout 180 + -re {[1248]@} { incr ok; exp_continue } + eof { } +} +if { $ok == 106} { + pass "$test eu-readelf" +} else { + fail "$test eu-readelf $ok" +} +# $elfutils_ok +} else { + untested "$test eu-readelf (failed elfutils version check)" +} + +# Does gdb support -probe-stap? +set gdb_ok 0 +eval spawn "rpm -q gdb" +expect { + -re {gdb-7.[3456789]} { incr gdb_ok } + -re {gdb-8} { incr gdb_ok } + -re {gdb-1[0-9]} { incr gdb_ok } +} + +if { $gdb_ok > 0 } { +set ok 0 +set cmd "gdb -batch -q -ex \"info probes stap provider ptr_int_var\" -ex \"b -probe-stap provider:ptr_int_var\" -ex run -ex \"print/x {\\\$_probe_arg2}\" ./sdt_types.x" +eval spawn $cmd +expect { + -timeout 180 + -re {1 = .0x7fffffff} { incr ok; exp_continue } + eof { } +} +if { $ok == 0} { + fail "$test gdb probe-stap" +} else { + pass "$test gdb probe-stap" +} +# $gdb_ok +} else { + untested "$test gdb (failed gdb version check)" +} + -- 2.43.5