From b63617a7a9881e8688e13edf27cfe71d425cf354 Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: Tue, 2 Nov 2021 07:36:00 -0400 Subject: [PATCH] import systemtap-4.5-8.el9_b --- SOURCES/rhbz1985124.patch | 237 ++++++++++++++++++++++++++++++++++++++ SPECS/systemtap.spec | 5 +- 2 files changed, 241 insertions(+), 1 deletion(-) diff --git a/SOURCES/rhbz1985124.patch b/SOURCES/rhbz1985124.patch index 081bdf3..22ef5a0 100644 --- a/SOURCES/rhbz1985124.patch +++ b/SOURCES/rhbz1985124.patch @@ -852,3 +852,240 @@ index 40dc3e2e0..d47462513 100644 spin_unlock(&files->file_lock); } +commit e6a1b008b822ed211b8f9c15fda565f8d51e512d +Author: Stan Cox +Date: Thu Aug 26 09:46:20 2021 -0400 + + Shorten function names that will exceed the kernel's objtool limit of 128 + + translate.cxx (c_unparser::emit_global_init_type,emit_function) Shorten + (c_unparser::c_funcname) Add funcname_shortened parm, shorten + name if length limit exceeded + + testsuite/systemtap.base/func_definition.{exp,stp} Add shorten funcname test. + +diff --git a/testsuite/systemtap.base/func_definition.exp b/testsuite/systemtap.base/func_definition.exp +index 6598aeea5..0aeab4c70 100644 +--- a/testsuite/systemtap.base/func_definition.exp ++++ b/testsuite/systemtap.base/func_definition.exp +@@ -5,9 +5,25 @@ if {![installtest_p]} { untested "$test"; return } + + foreach runtime [get_runtime_list] { + if {$runtime != ""} { +- stap_run $test no_load (${all_pass_string}){5} \ ++ stap_run $test no_load (${all_pass_string}){6} \ + --runtime=$runtime $srcdir/$subdir/$test.stp + } else { +- stap_run $test no_load (${all_pass_string}){5} $srcdir/$subdir/$test.stp ++ stap_run $test no_load (${all_pass_string}){6} $srcdir/$subdir/$test.stp + } + } ++ ++set ok 0 ++set cmd "bash -c {$env(SYSTEMTAP_PATH)/stap --runtime=$runtime -v -v -p3 $srcdir/$subdir/$test.stp |& grep -A 1 'function_names_over_128'}" ++eval spawn $cmd ++expect { ++ -timeout 180 ++ # Match shortened function declaration, definition, and reference ++ -re { function_[0-9] } { incr ok; exp_continue } ++ eof { } ++} ++ ++if {$ok == 3} { ++ pass "$test function name shorten" ++} else { ++ fail "$test function name shorten ($ok!=3)" ++} +diff --git a/testsuite/systemtap.base/func_definition.stp b/testsuite/systemtap.base/func_definition.stp +index eaa8d94c5..7ed938eb9 100644 +--- a/testsuite/systemtap.base/func_definition.stp ++++ b/testsuite/systemtap.base/func_definition.stp +@@ -39,6 +39,11 @@ function f5() + println("systemtap test success") + } + ++function function_names_over_128_characters_exceed_MAX_NAME_LEN_in_linux_objtool_which_is_invoked_by_kbuild_and_are_therefore_shortened() ++{ ++ return 2021 ++} ++ + probe end { + println("systemtap ending probe") + +@@ -57,4 +62,7 @@ probe end { + printf("systemtap test failure - return_value of f4:%d != 2015\n", f4()) + + f5() ++ ++ if (function_names_over_128_characters_exceed_MAX_NAME_LEN_in_linux_objtool_which_is_invoked_by_kbuild_and_are_therefore_shortened() == 2021) ++ println("systemtap test success") + } +diff --git a/translate.cxx b/translate.cxx +index 59fa2e4a0..beb7d7acd 100644 +--- a/translate.cxx ++++ b/translate.cxx +@@ -58,6 +58,9 @@ extern "C" { + #define STAP_T_06 _("\"empty aggregate\";") + #define STAP_T_07 _("\"histogram index out of range\";") + ++// This matches MAX_NAME_LEN in linux objtool/elf.c used by kbuild ++#define MAX_NAME_LEN 128 ++ + using namespace std; + + class var; +@@ -183,6 +186,7 @@ struct c_unparser: public unparser, public visitor + virtual string c_localname (const string& e, bool mangle_oldstyle = false); + virtual string c_globalname (const string &e); + virtual string c_funcname (const string &e); ++ virtual string c_funcname (const string &e, bool &funcname_shortened); + + string c_arg_define (const string& e); + string c_arg_undef (const string& e); +@@ -1755,7 +1759,11 @@ c_unparser::emit_global_init_type (vardecl *v) + void + c_unparser::emit_functionsig (functiondecl* v) + { +- o->newline() << "static void " << c_funcname(v->name) ++ bool funcname_shortened; ++ string funcname = c_funcname (v->name, funcname_shortened); ++ if (funcname_shortened) ++ o->newline() << "/* " << v->name << " */"; ++ o->newline() << "static void " << funcname + << " (struct context * __restrict__ c);"; + } + +@@ -2520,7 +2528,11 @@ c_tmpcounter::emit_function (functiondecl* fd) + // indent the dummy output as if we were already in a block + this->o->indent (1); + +- o->newline() << "struct " << c_funcname (fd->name) << "_locals {"; ++ bool funcname_shortened; ++ string funcname = c_funcname (fd->name, funcname_shortened); ++ if (funcname_shortened) ++ o->newline() << "/* " << fd->name << " */"; ++ o->newline() << "struct " << funcname << "_locals {"; + o->indent(1); + + for (unsigned j=0; jlocals.size(); j++) +@@ -2615,7 +2627,11 @@ c_unparser::emit_function (functiondecl* v) + this->action_counter = 0; + this->already_checked_action_count = false; + +- o->newline() << "static void " << c_funcname (v->name) ++ bool funcname_shortened; ++ string funcname = c_funcname (v->name, funcname_shortened); ++ if (funcname_shortened) ++ o->newline() << "/* " << v->name << " */"; ++ o->newline() << "static void " << funcname + << " (struct context* __restrict__ c) {"; + o->indent(1); + +@@ -3385,11 +3401,41 @@ c_unparser::c_globalname (const string& e) + + + string +-c_unparser::c_funcname (const string& e) ++c_unparser::c_funcname (const string& e, bool& funcname_shortened) + { ++ const string function_prefix = "function_"; + // XXX uncomment to test custom mangling: +- // return "function_" + e + "_" + lex_cast(do_hash(e.c_str())); +- return "function_" + e; ++ // return function_prefix + e + "_" + lex_cast(do_hash(e.c_str())); ++ ++ // The kernel objtool used by kbuild has a hardcoded function length limit ++ if (e.length() > MAX_NAME_LEN - function_prefix.length()) ++ { ++ int function_index = 0; ++ for (map::iterator it = session->functions.begin(); ++ it != session->functions.end(); it++) ++ { ++ if (it->first == e) ++ { ++ funcname_shortened = true; ++ return function_prefix + to_string(function_index); ++ } ++ function_index += 1; ++ } ++ throw SEMANTIC_ERROR (_("unresolved symbol: ") + e); // should not happen ++ } ++ else ++ { ++ funcname_shortened = false; ++ return function_prefix + e; ++ } ++} ++ ++ ++string ++c_unparser::c_funcname (const string& e) ++{ ++ bool funcname_shortened; ++ return c_funcname (e, funcname_shortened); + } + + + +commit 3bca174698360389fbf2c28e8eaaacc0b7cbbdb0 +Author: Stan Cox +Date: Mon Aug 30 16:53:51 2021 -0400 + + Use lex_cast instead of to_string when shortening function names. + +diff --git a/testsuite/systemtap.base/func_definition.exp b/testsuite/systemtap.base/func_definition.exp +index 0aeab4c70..721900f98 100644 +--- a/testsuite/systemtap.base/func_definition.exp ++++ b/testsuite/systemtap.base/func_definition.exp +@@ -13,7 +13,7 @@ foreach runtime [get_runtime_list] { + } + + set ok 0 +-set cmd "bash -c {$env(SYSTEMTAP_PATH)/stap --runtime=$runtime -v -v -p3 $srcdir/$subdir/$test.stp |& grep -A 1 'function_names_over_128'}" ++set cmd "bash -c {$env(SYSTEMTAP_PATH)/stap -v -v -p3 $srcdir/$subdir/$test.stp |& grep -A 1 'function_names_over_128'}" + eval spawn $cmd + expect { + -timeout 180 +diff --git a/translate.cxx b/translate.cxx +index beb7d7acd..312fd0801 100644 +--- a/translate.cxx ++++ b/translate.cxx +@@ -3410,14 +3410,14 @@ c_unparser::c_funcname (const string& e, bool& funcname_shortened) + // The kernel objtool used by kbuild has a hardcoded function length limit + if (e.length() > MAX_NAME_LEN - function_prefix.length()) + { +- int function_index = 0; ++ long function_index = 0; + for (map::iterator it = session->functions.begin(); + it != session->functions.end(); it++) + { + if (it->first == e) + { + funcname_shortened = true; +- return function_prefix + to_string(function_index); ++ return function_prefix + lex_cast (function_index); + } + function_index += 1; + } +commit 4996a29c6b5dd891aeaf31df1a50058bd785621b +Author: Frank Ch. Eigler +Date: Thu Sep 9 21:22:31 2021 -0400 + + tapset: start adopting kernel netif_* tracepoints in netdev.* tapset + + Start with netdev.receive. + +diff --git a/tapset/linux/networking.stp b/tapset/linux/networking.stp +index 0b52cbc50..bf9cabfd5 100644 +--- a/tapset/linux/networking.stp ++++ b/tapset/linux/networking.stp +@@ -117,7 +117,8 @@ function get_netdev_name:string (addr:long) { + /// + // Main device receive routine, be called when packet arrives on network device + probe netdev.receive +- = kernel.function("netif_receive_skb_internal") !, ++ = kernel.trace("netif_receive_skb") !, ++ kernel.function("netif_receive_skb_internal") !, + kernel.function("netif_receive_skb") + { + try { dev_name = get_netdev_name($skb->dev) } catch { } diff --git a/SPECS/systemtap.spec b/SPECS/systemtap.spec index 7147aef..0c6d205 100644 --- a/SPECS/systemtap.spec +++ b/SPECS/systemtap.spec @@ -90,7 +90,7 @@ Name: systemtap Version: 4.5 -Release: 7%{?release_override}%{?dist} +Release: 8%{?release_override}%{?dist} # for version, see also configure.ac @@ -1221,6 +1221,9 @@ exit 0 # PRERELEASE %changelog +* Thu Sep 09 2021 Frank Ch. Eigler - 4.5-8 +- rhbz1985124: Kernel 5.14 compatibility omnibus cont'd. + * Thu Aug 12 2021 Frank Ch. Eigler - 4.5-7 - rhbz1985124: Kernel 5.14 compatibility omnibus.