PR27940 - The /* pc=0x... */ is no longer printed by "stap -v -L 'kernel.function("*")'

Message ID CAN-Pu7SAidL1z1=tFOP0aARoE5XHuOk4xOSxPCV_t1U+4Qi=eg@mail.gmail.com
State Not applicable
Headers
Series PR27940 - The /* pc=0x... */ is no longer printed by "stap -v -L 'kernel.function("*")' |

Commit Message

Di Chen Sept. 10, 2021, 3:22 p.m. UTC
  >From a98718a1b97357e53cef966ed9826c69e159f46e Mon Sep 17 00:00:00 2001
From: Di Chen <dichen@redhat.com>
Date: Thu, 2 Sep 2021 12:52:47 +0800
Subject: [PATCH] The /* pc=0x... */ is no longer printed by "stap -v -L
 'kernel.function("*")'

The disappeared /* pc=0x... */ resulted from the missing implementation
of the function "dwarf_derived_probe::printsig_nonest".
Which makes "p->printsig_nonest(sig)" in main.cxx end up calling
"derived_probe::printsig_nonest", and the type of "p" is

(gdb) ptype /m p
type = /* real type = dwarf_derived_probe * */

This patch added "dwarf_derived_probe::printsig_nonest" for PC value
print.

https://sourceware.org/bugzilla/show_bug.cgi?id=27940

Signed-off-by: Di Chen <dichen@redhat.com>
---
 elaborate.h |  2 +-
 tapsets.cxx | 11 +++++++++++
 2 files changed, 12 insertions(+), 1 deletion(-)

   void getargs(std::list<std::string> &arg_set) const;
@@ -5386,6 +5387,16 @@ dwarf_derived_probe::printsig (ostream& o) const
 }


+void
+dwarf_derived_probe::printsig_nonest (ostream& o) const
+{
+  sole_location()->print (o);
+  if (symbol_name != "")
+    o << " /* pc=<" << symbol_name << "+" << offset << "> */";
+  else
+    o << " /* pc=" << section << "+0x" << hex << addr << dec << " */";
+}
+

 void
 dwarf_derived_probe::join_group (systemtap_session& s)
  

Patch

diff --git a/elaborate.h b/elaborate.h
index 9817172a7..baa29e67c 100644
--- a/elaborate.h
+++ b/elaborate.h
@@ -204,7 +204,7 @@  struct derived_probe: public probe
   virtual probe_point* sole_location () const;
   virtual probe_point* script_location () const;
   virtual void printsig (std::ostream &o) const cxx_override;
-  void printsig_nonest (std::ostream &o) const;
+  virtual void printsig_nonest (std::ostream &o) const;
   // return arguments of probe if there
   virtual void getargs (std::list<std::string> &) const {}
   void printsig_nested (std::ostream &o) const;
diff --git a/tapsets.cxx b/tapsets.cxx
index 68b75610e..27d8995ce 100644
--- a/tapsets.cxx
+++ b/tapsets.cxx
@@ -560,6 +560,7 @@  struct dwarf_derived_probe: public
generic_kprobe_derived_probe
   bool access_vars;

   void printsig (std::ostream &o) const;
+  void printsig_nonest (std::ostream &o) const;
   virtual void join_group (systemtap_session& s);
   void emit_probe_local_init(systemtap_session& s, translator_output * o);