diff --git a/sdt-regtable.patch b/sdt-regtable.patch new file mode 100644 index 0000000..d65ddac --- /dev/null +++ b/sdt-regtable.patch @@ -0,0 +1,365 @@ +commit 46a94997388279d381e38a675411b99a202f339d +Author: Stan Cox +Date: Wed Jan 19 07:09:01 2011 -0500 + + Switch to using a register width table instead of heuristic code. + + * tapsets.cxx (sdt_uprobe_var_expanding_visitor): Add DRI and regwidths. + Change dwarf_regs to be a regname/regwidth pair. Change initializer. + * (sdt_uprobe_var_expanding_visitor::visit_target_symbol): Use it. + + +commit 9920f642a45f6425959bdf857543c90f2fcfd1e3 +Author: Stan Cox +Date: Wed Jan 19 15:52:14 2011 -0500 + + Allow sdt to avoid application defined min/max macros. + + * sdt.h: Surround limits inclusion with push_macro and pop_macro. + + +commit ae1418f00b0bd242fbf169813be5800609d36892 +Author: Frank Ch. Eigler +Date: Wed Jan 19 08:20:22 2011 -0500 + + PR12411 cont'd: use enum type decl + + * tapsets.cxx (sdt_uprobe_var_expanding_visitor): Make regwidths + an enum type decl, not an anonymous-enum-typed variable. Move + DRI macro #define/#undef just around its use. + + +diff --git a/tapsets.cxx b/tapsets.cxx +index 23a5df2..b141921 100644 +--- a/tapsets.cxx ++++ b/tapsets.cxx +@@ -4650,6 +4650,7 @@ struct sdt_kprobe_var_expanding_visitor: public var_expanding_visitor + + struct sdt_uprobe_var_expanding_visitor: public var_expanding_visitor + { ++ enum regwidths {QI, QIh, HI, SI, DI}; + sdt_uprobe_var_expanding_visitor(systemtap_session& s, + int elf_machine, + const string & process_name, +@@ -4665,66 +4666,139 @@ struct sdt_uprobe_var_expanding_visitor: public var_expanding_visitor + /* 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 + #ifdef _i686_ etc. */ ++ ++#define DRI(name,num,width) dwarf_regs[name]=make_pair(num,width) + if (elf_machine == EM_X86_64) { +- dwarf_regs["%rax"] = dwarf_regs["%eax"] = dwarf_regs["%ax"] = dwarf_regs["%al"] = dwarf_regs["%ah"] = 0; +- dwarf_regs["%rdx"] = dwarf_regs["%edx"] = dwarf_regs["%dx"] = dwarf_regs["%dl"] = dwarf_regs["%dh"] = 1; +- dwarf_regs["%rcx"] = dwarf_regs["%ecx"] = dwarf_regs["%cx"] = dwarf_regs["%cl"] = dwarf_regs["%ch"] = 2; +- dwarf_regs["%rbx"] = dwarf_regs["%ebx"] = dwarf_regs["%bx"] = dwarf_regs["%bl"] = dwarf_regs["%bh"] = 3; +- dwarf_regs["%rsi"] = dwarf_regs["%esi"] = dwarf_regs["%si"] = dwarf_regs["%sil"] = 4; +- dwarf_regs["%rdi"] = dwarf_regs["%edi"] = dwarf_regs["%di"] = dwarf_regs["%dil"] = 5; +- dwarf_regs["%rbp"] = dwarf_regs["%ebp"] = dwarf_regs["%bp"] = 6; +- dwarf_regs["%rsp"] = dwarf_regs["%esp"] = dwarf_regs["%sp"] = 7; +- dwarf_regs["%r8"] = dwarf_regs["%r8d"] = dwarf_regs["%r8w"] = dwarf_regs["%r8b"] = 8; +- dwarf_regs["%r9"] = dwarf_regs["%r9d"] = dwarf_regs["%r9w"] = dwarf_regs["%r9b"] = 9; +- dwarf_regs["%r10"] = dwarf_regs["%r10d"] = dwarf_regs["%r10w"] = dwarf_regs["%r10b"] = 10; +- dwarf_regs["%r11"] = dwarf_regs["%r11d"] = dwarf_regs["%r11w"] = dwarf_regs["%r11b"] = 11; +- dwarf_regs["%r12"] = dwarf_regs["%r12d"] = dwarf_regs["%r12w"] = dwarf_regs["%r12b"] = 12; +- dwarf_regs["%r13"] = dwarf_regs["%r13d"] = dwarf_regs["%r13w"] = dwarf_regs["%r13b"] = 13; +- dwarf_regs["%r14"] = dwarf_regs["%r14d"] = dwarf_regs["%r14w"] = dwarf_regs["%r14b"] = 14; +- dwarf_regs["%r15"] = dwarf_regs["%r15d"] = dwarf_regs["%r15w"] = dwarf_regs["%r15b"] = 15; ++ DRI ("%rax", 0, DI); DRI ("%eax", 0, SI); DRI ("%ax", 0, HI); ++ DRI ("%al", 0, QI); DRI ("%ah", 0, QIh); ++ DRI ("%rdx", 1, DI); DRI ("%edx", 1, SI); DRI ("%dx", 1, HI); ++ DRI ("%dl", 1, QI); DRI ("%dh", 1, QIh); ++ DRI ("%rcx", 2, DI); DRI ("%ecx", 2, SI); DRI ("%cx", 2, HI); ++ DRI ("%cl", 2, QI); DRI ("%ch", 2, QIh); ++ DRI ("%rbx", 3, DI); DRI ("%ebx", 3, SI); DRI ("%bx", 3, HI); ++ DRI ("%bl", 3, QI); DRI ("%bh", 3, QIh); ++ DRI ("%rsi", 4, DI); DRI ("%esi", 4, SI); DRI ("%si", 4, HI); ++ DRI ("%sil", 4, QI); ++ DRI ("%rdi", 5, DI); DRI ("%edi", 5, SI); DRI ("%di", 5, HI); ++ DRI ("%dil", 5, QI); ++ DRI ("%rbp", 6, DI); DRI ("%ebp", 6, SI); DRI ("%bp", 6, HI); ++ DRI ("%rsp", 7, DI); DRI ("%esp", 7, SI); DRI ("%sp", 7, HI); ++ DRI ("%r8", 8, DI); DRI ("%r8d", 8, SI); DRI ("%r8w", 8, HI); ++ DRI ("%r8b", 8, QI); ++ DRI ("%r9", 9, DI); DRI ("%r9d", 9, SI); DRI ("%r9w", 9, HI); ++ DRI ("%r9b", 9, QI); ++ DRI ("%r10", 10, DI); DRI ("%r10d", 10, SI); DRI ("%r10w", 10, HI); ++ DRI ("%r10b", 10, QI); ++ DRI ("%r11", 11, DI); DRI ("%r11d", 11, SI); DRI ("%r11w", 11, HI); ++ DRI ("%r11b", 11, QI); ++ DRI ("%r12", 12, DI); DRI ("%r12d", 12, SI); DRI ("%r12w", 12, HI); ++ DRI ("%r12b", 12, QI); ++ DRI ("%r13", 13, DI); DRI ("%r13d", 13, SI); DRI ("%r13w", 13, HI); ++ DRI ("%r13b", 13, QI); ++ DRI ("%r14", 14, DI); DRI ("%r14d", 14, SI); DRI ("%r14w", 14, HI); ++ DRI ("%r14b", 14, QI); ++ DRI ("%r15", 15, DI); DRI ("%r15d", 15, SI); DRI ("%r15w", 15, HI); ++ DRI ("%r15b", 15, QI); + } else if (elf_machine == EM_386) { +- dwarf_regs["%eax"] = dwarf_regs["%ax"] = dwarf_regs["%al"] = dwarf_regs["%ah"] = 0; +- dwarf_regs["%ecx"] = dwarf_regs["%cx"] = dwarf_regs["%cl"] = dwarf_regs["%ch"] = 1; +- dwarf_regs["%edx"] = dwarf_regs["%dx"] = dwarf_regs["%dl"] = dwarf_regs["%dh"] = 2; +- dwarf_regs["%ebx"] = dwarf_regs["%bx"] = dwarf_regs["%bl"] = dwarf_regs["%bh"] = 3; +- dwarf_regs["%esp"] = dwarf_regs["%sp"] = 4; +- dwarf_regs["%ebp"] = dwarf_regs["%bp"] = 5; +- dwarf_regs["%esi"] = dwarf_regs["%si"] = dwarf_regs["%sil"] = 6; +- dwarf_regs["%edi"] = dwarf_regs["%di"] = dwarf_regs["%dil"] = 7; ++ DRI ("%eax", 0, SI); DRI ("%ax", 0, HI); DRI ("%al", 0, QI); ++ DRI ("%ah", 0, QIh); ++ DRI ("%ecx", 1, SI); DRI ("%cx", 1, HI); DRI ("%cl", 1, QI); ++ DRI ("%ch", 1, QIh); ++ DRI ("%edx", 2, SI); DRI ("%dx", 2, HI); DRI ("%dl", 2, QI); ++ DRI ("%dh", 2, QIh); ++ DRI ("%ebx", 3, SI); DRI ("%bx", 3, HI); DRI ("%bl", 3, QI); ++ DRI ("%bh", 3, QIh); ++ DRI ("%esp", 4, SI); DRI ("%sp", 4, HI); ++ DRI ("%ebp", 5, SI); DRI ("%bp", 5, HI); ++ DRI ("%esi", 6, SI); DRI ("%si", 6, HI); DRI ("%sil", 6, QI); ++ DRI ("%edi", 7, SI); DRI ("%di", 7, HI); DRI ("%dil", 7, QI); + } else if (elf_machine == EM_PPC || elf_machine == EM_PPC64) { +- dwarf_regs["%r0"] = 0; dwarf_regs["%r1"] = 1; dwarf_regs["%r2"] = 2; +- dwarf_regs["%r3"] = 3; dwarf_regs["%r4"] = 4; dwarf_regs["%r5"] = 5; +- dwarf_regs["%r6"] = 6; dwarf_regs["%r7"] = 7; dwarf_regs["%r8"] = 8; +- dwarf_regs["%r9"] = 9; dwarf_regs["%r10"] = 10; dwarf_regs["%r11"] = 11; +- dwarf_regs["%r12"] = 12; dwarf_regs["%r13"] = 13; dwarf_regs["%r14"] = 14; +- dwarf_regs["%r15"] = 15; dwarf_regs["%r16"] = 16; dwarf_regs["%r17"] = 17; +- dwarf_regs["%r18"] = 18; dwarf_regs["%r19"] = 19; dwarf_regs["%r20"] = 20; +- dwarf_regs["%r21"] = 21; dwarf_regs["%r22"] = 22; dwarf_regs["%r23"] = 23; +- dwarf_regs["%r24"] = 24; dwarf_regs["%r25"] = 25; dwarf_regs["%r26"] = 26; +- dwarf_regs["%r27"] = 27; dwarf_regs["%r28"] = 28; dwarf_regs["%r29"] = 29; +- dwarf_regs["%r30"] = 30; dwarf_regs["%r31"] = 31; ++ DRI ("%r0", 0, DI); ++ DRI ("%r1", 1, DI); ++ DRI ("%r2", 2, DI); ++ DRI ("%r3", 3, DI); ++ DRI ("%r4", 4, DI); ++ DRI ("%r5", 5, DI); ++ DRI ("%r6", 6, DI); ++ DRI ("%r7", 7, DI); ++ DRI ("%r8", 8, DI); ++ DRI ("%r9", 9, DI); ++ DRI ("%r10", 10, DI); ++ DRI ("%r11", 11, DI); ++ DRI ("%r12", 12, DI); ++ DRI ("%r13", 13, DI); ++ DRI ("%r14", 14, DI); ++ DRI ("%r15", 15, DI); ++ DRI ("%r16", 16, DI); ++ DRI ("%r17", 17, DI); ++ DRI ("%r18", 18, DI); ++ DRI ("%r19", 19, DI); ++ DRI ("%r20", 20, DI); ++ DRI ("%r21", 21, DI); ++ DRI ("%r22", 22, DI); ++ DRI ("%r23", 23, DI); ++ DRI ("%r24", 24, DI); ++ DRI ("%r25", 25, DI); ++ DRI ("%r26", 26, DI); ++ DRI ("%r27", 27, DI); ++ DRI ("%r28", 28, DI); ++ DRI ("%r29", 29, DI); ++ DRI ("%r30", 30, DI); ++ DRI ("%r31", 31, DI); + // PR11821: unadorned register "names" without -mregnames +- dwarf_regs["0"] = 0; dwarf_regs["1"] = 1; dwarf_regs["2"] = 2; +- dwarf_regs["3"] = 3; dwarf_regs["4"] = 4; dwarf_regs["5"] = 5; +- dwarf_regs["6"] = 6; dwarf_regs["7"] = 7; dwarf_regs["8"] = 8; +- dwarf_regs["9"] = 9; dwarf_regs["10"] = 10; dwarf_regs["11"] = 11; +- dwarf_regs["12"] = 12; dwarf_regs["13"] = 13; dwarf_regs["14"] = 14; +- dwarf_regs["15"] = 15; dwarf_regs["16"] = 16; dwarf_regs["17"] = 17; +- dwarf_regs["18"] = 18; dwarf_regs["19"] = 19; dwarf_regs["20"] = 20; +- dwarf_regs["21"] = 21; dwarf_regs["22"] = 22; dwarf_regs["23"] = 23; +- dwarf_regs["24"] = 24; dwarf_regs["25"] = 25; dwarf_regs["26"] = 26; +- dwarf_regs["27"] = 27; dwarf_regs["28"] = 28; dwarf_regs["29"] = 29; +- dwarf_regs["30"] = 30; dwarf_regs["31"] = 31; ++ DRI ("0", 0, DI); ++ DRI ("1", 1, DI); ++ DRI ("2", 2, DI); ++ DRI ("3", 3, DI); ++ DRI ("4", 4, DI); ++ DRI ("5", 5, DI); ++ DRI ("6", 6, DI); ++ DRI ("7", 7, DI); ++ DRI ("8", 8, DI); ++ DRI ("9", 9, DI); ++ DRI ("10", 10, DI); ++ DRI ("11", 11, DI); ++ DRI ("12", 12, DI); ++ DRI ("13", 13, DI); ++ DRI ("14", 14, DI); ++ DRI ("15", 15, DI); ++ DRI ("16", 16, DI); ++ DRI ("17", 17, DI); ++ DRI ("18", 18, DI); ++ DRI ("19", 19, DI); ++ DRI ("20", 20, DI); ++ DRI ("21", 21, DI); ++ DRI ("22", 22, DI); ++ DRI ("23", 23, DI); ++ DRI ("24", 24, DI); ++ DRI ("25", 25, DI); ++ DRI ("26", 26, DI); ++ DRI ("27", 27, DI); ++ DRI ("28", 28, DI); ++ DRI ("29", 29, DI); ++ DRI ("30", 30, DI); ++ DRI ("31", 31, DI); + } else if (elf_machine == EM_S390) { +- dwarf_regs["%r0"] = 0; dwarf_regs["%r1"] = 1; dwarf_regs["%r2"] = 2; +- dwarf_regs["%r3"] = 3; dwarf_regs["%r4"] = 4; dwarf_regs["%r5"] = 5; +- dwarf_regs["%r6"] = 6; dwarf_regs["%r7"] = 7; dwarf_regs["%r8"] = 8; +- dwarf_regs["%r9"] = 9; dwarf_regs["%r10"] = 10; dwarf_regs["%r11"] = 11; +- dwarf_regs["%r12"] = 12; dwarf_regs["%r13"] = 13; dwarf_regs["%r14"] = 14; +- dwarf_regs["%r15"] = 15; ++ DRI ("%r0", 0, DI); ++ DRI ("%r1", 1, DI); ++ DRI ("%r2", 2, DI); ++ DRI ("%r3", 3, DI); ++ DRI ("%r4", 4, DI); ++ DRI ("%r5", 5, DI); ++ DRI ("%r6", 6, DI); ++ DRI ("%r7", 7, DI); ++ DRI ("%r8", 8, DI); ++ DRI ("%r9", 9, DI); ++ DRI ("%r10", 10, DI); ++ DRI ("%r11", 11, DI); ++ DRI ("%r12", 12, DI); ++ DRI ("%r13", 13, DI); ++ DRI ("%r14", 14, DI); ++ DRI ("%r15", 15, DI); + } else if (arg_count) { + /* permit this case; just fall back to dwarf */ + } ++#undef DRI + + need_debug_info = false; + tokenize(arg_string, arg_tokens, " "); +@@ -4739,11 +4813,10 @@ struct sdt_uprobe_var_expanding_visitor: public var_expanding_visitor + stap_sdt_probe_type probe_type; + unsigned arg_count; + vector arg_tokens; +- map dwarf_regs; ++ map > dwarf_regs; + bool need_debug_info; + + void visit_target_symbol (target_symbol* e); +- __uint64_t get_register_width (string); + }; + + +@@ -4884,7 +4957,7 @@ sdt_uprobe_var_expanding_visitor::visit_target_symbol (target_symbol *e) + // Build regex pieces out of the known dwarf_regs. We keep two separate + // lists: ones with the % prefix (and thus unambigiuous even despite PR11821), + // and ones with no prefix (and thus only usable in unambiguous contexts). +- for (map::iterator ri = dwarf_regs.begin(); ri != dwarf_regs.end(); ri++) ++ for (map >::iterator ri = dwarf_regs.begin(); ri != dwarf_regs.end(); ri++) + { + string regname = ri->first; + assert (regname != ""); +@@ -4905,15 +4978,16 @@ sdt_uprobe_var_expanding_visitor::visit_target_symbol (target_symbol *e) + if (! rc) + { + string regname = matches[1]; +- if (dwarf_regs.find (regname) != dwarf_regs.end()) // known register ++ map >::iterator ri = dwarf_regs.find (regname); ++ if (ri != dwarf_regs.end()) // known register + { + embedded_expr *get_arg1 = new embedded_expr; + string width_adjust; +- switch (get_register_width (regname)) ++ switch (ri->second.second) + { +- case 0xff: width_adjust = ") & 0xff"; break; +- case 0xff00: width_adjust = ">>8) & 0xff"; break; +- case 0xffff: ++ case QI: width_adjust = ") & 0xff"; break; ++ case QIh: width_adjust = ">>8) & 0xff"; break; ++ case HI: + // preserve 16 bit register signness + width_adjust = (precision > 0) ? ") & 0xffff" : ")"; + break; +@@ -4927,7 +5001,7 @@ sdt_uprobe_var_expanding_visitor::visit_target_symbol (target_symbol *e) + + (is_user_module (process_name) + ? string("u_fetch_register(") + : string("k_fetch_register(")) +- + lex_cast(dwarf_regs[regname]) + string("))") ++ + lex_cast(dwarf_regs[regname].first) + string("))") + + width_adjust; + argexpr = get_arg1; + goto matched; +@@ -4968,7 +5042,7 @@ sdt_uprobe_var_expanding_visitor::visit_target_symbol (target_symbol *e) + + (is_user_module (process_name) + ? string("u_fetch_register(") + : string("k_fetch_register(")) +- + lex_cast(dwarf_regs[regname]) + string(")"); ++ + lex_cast(dwarf_regs[regname].first) + string(")"); + // XXX: may we ever need to cast that to a narrower type? + + literal_number* inc = new literal_number(disp); +@@ -5051,31 +5125,6 @@ sdt_uprobe_var_expanding_visitor::visit_target_symbol (target_symbol *e) + } + + +-__uint64_t +-sdt_uprobe_var_expanding_visitor::get_register_width (string regname) +-{ +- if (elf_machine == EM_X86_64 || elf_machine == EM_386) { +- int regno = dwarf_regs.find (regname)->second; +- // al,bl,cl,dl +- if (regno < 4 && regname[2] == 'l') return 0xff; +- // ah,bh,ch,dh +- else if (regno < 4 && regname[2] == 'h') return 0xff00; +- // ax,bx,cx,dx +- else if (regno < 4 && regname[2] == 'x') return 0xffff; +- // sil,dil,bpl,spl +- else if (regno < 8 && regname.rfind('l') != regname.npos) return 0xff; // sil +- // si,di,bp,sp +- else if (regno < 8 && regname.length() == 3) return 0xffff; // si +- // r8b-r15b +- else if (regno < 16 && regname.rfind('b') != regname.npos) return 0xff; // r8b +- // r8w-r15w +- else if (regno < 16 && regname.rfind('w') != regname.npos) return 0xffff; // r8w +- else return 0xffffffff; +- } +- else return 0xffffffff; +-} +- +- + void + sdt_kprobe_var_expanding_visitor::visit_target_symbol (target_symbol *e) + { +diff --git a/includes/sys/sdt.h b/includes/sys/sdt.h +index e878e17..d6eff49 100644 +--- a/includes/sys/sdt.h ++++ b/includes/sys/sdt.h +@@ -1,5 +1,5 @@ + /* - Systemtap static probe definition macros. +- Copyright (C) 2010 Red Hat Inc. ++ Copyright (C) 2010-2011 Red Hat Inc. + + This file is part of systemtap, and is free software in the public domain. + */ +@@ -61,9 +61,24 @@ + ? sizeof (void *) : sizeof (x)) + # define _SDT_ARGVAL(x) (x) + ++/* The C++ header uses the names 'min' and 'max' and conflicts ++ with any application-defined macros by these names. In GCC 4.3 and ++ later, we can hack around this problem with new #pragma magic. */ ++# if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) ++ #pragma push_macro("min") ++ #pragma push_macro("max") ++# undef min ++# undef max ++# endif ++ + # include + # include + ++# if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) ++ #pragma pop_macro("min") ++ #pragma pop_macro("max") ++# endif ++ + template + struct __sdt_type + { diff --git a/systemtap.spec b/systemtap.spec index bb13246..c9b8fb6 100644 --- a/systemtap.spec +++ b/systemtap.spec @@ -16,7 +16,7 @@ Name: systemtap Version: 1.4 -Release: 1%{?dist} +Release: 2%{?dist} # for version, see also configure.ac Summary: Instrumentation System Group: Development/System @@ -56,6 +56,7 @@ BuildRequires: m4 %else BuildRequires: elfutils-devel >= %{elfutils_version} %endif +Patch2: sdt-regtable.patch %if %{with_docs} BuildRequires: /usr/bin/latex /usr/bin/dvips /usr/bin/ps2pdf latex2html @@ -180,6 +181,8 @@ data from SystemTap instrumentation scripts. %prep %setup -q %{?setup_elfutils} +%patch2 -p1 + %if %{with_bundled_elfutils} cd elfutils-%{elfutils_version} %patch1 -p1 @@ -514,6 +517,9 @@ exit 0 %changelog +* Mon Jan 19 2011 Stan Cox - 1.4-2 +- sdt fixes + * Mon Jan 17 2011 Frank Ch. Eigler - 1.4-1 - Upstream release.