public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 0/3] ppc64le: Fix multiple issues with ppc64le
@ 2016-07-21 13:17 Ravi Bangoria
  2016-07-21 13:17 ` [PATCH 1/3] ppc64le: Store correct function entry address in symbol_table Ravi Bangoria
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Ravi Bangoria @ 2016-07-21 13:17 UTC (permalink / raw)
  To: systemtap; +Cc: hemant, mjw, atrajeev, Ravi Bangoria

Commit b4c6a4b1cd00 ("Prioritize symbol table lookup for ppc64le")
sets probe on Local Entry Point instead of Global Entry Point for
ppc64le. But this patch has few regression effects.

For example, when recording argument of userspace function which
is compiled without optimization, we should probe after prologue.
But above patch forces prologue on LEP and we record garbage value
of function parameter.

This patchset modifies the approach to resolve such issues.

Ravi Bangoria (3):
  ppc64le: Store correct function entry address in symbol_table
  ppc64le: Use LEP for probe location
  ppc64le: Fix record argument of shared library function

 tapsets.cxx | 116 ++++++++++++++++++++++++++++--------------------------------
 1 file changed, 55 insertions(+), 61 deletions(-)

-- 
2.1.4

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 2/3] ppc64le: Use LEP for probe location
  2016-07-21 13:17 [PATCH 0/3] ppc64le: Fix multiple issues with ppc64le Ravi Bangoria
  2016-07-21 13:17 ` [PATCH 1/3] ppc64le: Store correct function entry address in symbol_table Ravi Bangoria
@ 2016-07-21 13:17 ` Ravi Bangoria
  2016-07-26 15:58   ` Ravi Bangoria
  2016-07-21 13:17 ` [PATCH 3/3] ppc64le: Fix record argument of shared library function Ravi Bangoria
  2 siblings, 1 reply; 7+ messages in thread
From: Ravi Bangoria @ 2016-07-21 13:17 UTC (permalink / raw)
  To: systemtap; +Cc: hemant, mjw, atrajeev, Ravi Bangoria

PPC64 ELF ABI v2 has a Global Entry Point and a Local Entry Point for
the functions. Debuginfo of ELF contains GEP which is same as entrypc.
While symbol table contains GEP and offset, from which we can calculate
LEP. LEP is used to call function within single CU, when TOC pointer
update is not required. So it's guaranteed that LEP will hit wherever
function is called but GEP may not.

Before Applying patch:

  $ vim uprobe_test.c
    #include <stdio.h>

    void doit(int i)
    {
        printf("i : %d\n", i);
    }

    int main(int argc, char *argv[])
    {
        doit(42);
        return 0;
    }

  $ gcc uprobe_test.c -g -o uprobe_test

  $ sudo ./stap -e 'probe process("uprobe_test").function("doit") \
        {printf("hit %d\n", $i)}' -c ./uprobe_test
    i : 42
    hit 0

After Applying patch:

  $ sudo ./stap -e 'probe process("uprobe_test").function("doit") \
        {printf("hit %d\n", $i)}' -c ./uprobe_test
    i : 42
    hit 42

Fixes: Commit b4c6a4b1cd00 ("Prioritize symbol table lookup for ppc64le")
Signed-off-by: Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com>
---
 tapsets.cxx | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 50 insertions(+)

diff --git a/tapsets.cxx b/tapsets.cxx
index e7be711..1b3a1ea 100644
--- a/tapsets.cxx
+++ b/tapsets.cxx
@@ -1391,6 +1391,55 @@ string path_remove_sysroot(const systemtap_session& sess, const string& path)
   return retval;
 }
 
+/*
+ * Convert 'Global Entry Point' to 'Local Entry Point'.
+ *
+ * if @gep contains next address after prologue, don't change it.
+ *
+ * For ELF ABI v2 on PPC64 LE, we need to adjust sym.st_value corresponding
+ * to the bits of sym.st_other. These bits will tell us what's the offset
+ * of the local entry point from the global entry point.
+ *
+ * st_other field is currently only used with ABIv2 on ppc64
+ */
+static Dwarf_Addr
+get_lep(dwarf_query *q, Dwarf_Addr gep)
+{
+  Dwarf_Addr bias;
+  Dwfl_Module *mod = q->dw.module;
+  Elf* elf = (dwarf_getelf (dwfl_module_getdwarf (mod, &bias))
+             ?: dwfl_module_getelf (mod, &bias));
+
+  GElf_Ehdr ehdr_mem;
+  GElf_Ehdr* em = gelf_getehdr (elf, &ehdr_mem);
+  if (em == NULL)
+    throw SEMANTIC_ERROR (_("Couldn't get elf header"));
+
+  if (!(em->e_machine == EM_PPC64) || !((em->e_flags & EF_PPC64_ABI) == 2))
+    return gep;
+
+  int syments = dwfl_module_getsymtab(mod);
+  for (int i = 1; i < syments; ++i)
+    {
+      GElf_Sym sym;
+      GElf_Word section;
+      GElf_Addr addr;
+
+#if _ELFUTILS_PREREQ (0, 158)
+      dwfl_module_getsym_info (mod, i, &sym, &addr, &section, NULL, NULL);
+#else
+      dwfl_module_getsym (mod, i, &sym, &section);
+      addr = sym.st_value;
+#endif
+
+      if (addr == gep && (GELF_ST_TYPE(sym.st_info) == STT_FUNC)
+          && sym.st_other)
+        return gep + PPC64_LOCAL_ENTRY_OFFSET(sym.st_other);
+    }
+
+  return gep;
+}
+
 void
 dwarf_query::add_probe_point(interned_string dw_funcname,
 			     interned_string filename,
@@ -1405,6 +1454,7 @@ dwarf_query::add_probe_point(interned_string dw_funcname,
 
   assert (! has_absolute); // already handled in dwarf_builder::build()
 
+  addr = get_lep(this, addr);
   reloc_addr = dw.relocate_address(addr, reloc_section);
 
   // If we originally used the linkage name, then let's call it that way
-- 
2.1.4

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 3/3] ppc64le: Fix record argument of shared library function
  2016-07-21 13:17 [PATCH 0/3] ppc64le: Fix multiple issues with ppc64le Ravi Bangoria
  2016-07-21 13:17 ` [PATCH 1/3] ppc64le: Store correct function entry address in symbol_table Ravi Bangoria
  2016-07-21 13:17 ` [PATCH 2/3] ppc64le: Use LEP for probe location Ravi Bangoria
@ 2016-07-21 13:17 ` Ravi Bangoria
  2016-07-26 15:59   ` Ravi Bangoria
  2 siblings, 1 reply; 7+ messages in thread
From: Ravi Bangoria @ 2016-07-21 13:17 UTC (permalink / raw)
  To: systemtap; +Cc: hemant, mjw, atrajeev, Ravi Bangoria

Symbol table contains module_bias + offset while debuginfo contains
only offset(entrypc). Subtract module_bias from symbol table entry
to compare it with entrypc while converting it to local entry point.

Example:

  $ vim shared.c
    #include "shared.h"
    #include "sys/sdt.h"
    unsigned int add(unsigned int a, unsigned int b)
    {
        STAP_PROBE1(test, func_count, b);
        int c;
        c = a+b;
        printf("c is %d\n", c);
        return (a+b);
    }
  $ vim shared.h
    #include<stdio.h>
    extern unsigned int add(unsigned int a, unsigned int b);
  $ vim app.c
    #include <stdio.h>
    #include "shared.h"
    #include <sys/sdt.h>
    #include "shared.h"
    #include "sys/sdt.h"
    unsigned int subs(unsigned int a, unsigned int b)
    {
        STAP_PROBE1(test, func_count1, a);
        int c;
        printf("\n Inside subs()\n");
        c = a+b+a;
        printf("c is %d\n", c);
        return (a+b+a);
    }
    int main(void)
    {
        unsigned int a = 1;
        unsigned int b = 2;
        STAP_PROBE1(test, func_count1, b);
        unsigned int result = 0;

        result = add(a,b);
        result = subs(a,b);
        printf("\n The result is [%u]\n",result);
        return 0;
    }

  $ gcc -c -Wall -Werror -fPIC -g -O3 shared.c
  $ gcc -shared -o libshared.so shared.o
  $ gcc -Wall app.c -o main -g -O3 -lshared -L/root
  $ export LD_LIBRARY_PATH="/root":$LD_LIBRARY_PATH

  $ ./stap -w --ldd -ve 'probe process(@2).function("add") \
        {printf("Input probe hit and value = %d\n", $b); }' \
        /root/libshared.so -c /root/main

    semantic error: while processing probe process("/root/libshared.so")...

    semantic error: not accessible at this address (pc: 0x107f8)...
        dieoffset: 0x2c0 from /root/libshared.so
        function: <unknown> at unknown source
        alternative locations: [0x7f8,0x827], [0x827,0x86c]
        source: probe process(@2).function("add") {printf("Input pr...

After applying patch:

  $ ./stap -w --ldd -ve 'probe process(@2).function("add") \
        {printf("Input probe hit and value = %d\n", $b); }' \
        /root/libshared.so -c /root/main
    c is 3

    Inside subs()
    c is 4

    The result is [4]
    Input probe hit and value = 2

Reported-by: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Signed-off-by: Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com>
---
 tapsets.cxx | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/tapsets.cxx b/tapsets.cxx
index 1b3a1ea..581a97e 100644
--- a/tapsets.cxx
+++ b/tapsets.cxx
@@ -1432,7 +1432,11 @@ gep_to_lep(dwarf_query *q, Dwarf_Addr gep)
       addr = sym.st_value;
 #endif
 
-      if (addr == gep && (GELF_ST_TYPE(sym.st_info) == STT_FUNC)
+      /*
+       * Symbol table contains module_bias + offset. Substract module_bias
+       * to compare offset with gep.
+       */
+      if ((addr - bias) == gep && (GELF_ST_TYPE(sym.st_info) == STT_FUNC)
           && sym.st_other)
         return gep + PPC64_LOCAL_ENTRY_OFFSET(sym.st_other);
     }
-- 
2.1.4

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/3] ppc64le: Store correct function entry address in symbol_table
  2016-07-21 13:17 [PATCH 0/3] ppc64le: Fix multiple issues with ppc64le Ravi Bangoria
@ 2016-07-21 13:17 ` Ravi Bangoria
  2016-07-21 13:17 ` [PATCH 2/3] ppc64le: Use LEP for probe location Ravi Bangoria
  2016-07-21 13:17 ` [PATCH 3/3] ppc64le: Fix record argument of shared library function Ravi Bangoria
  2 siblings, 0 replies; 7+ messages in thread
From: Ravi Bangoria @ 2016-07-21 13:17 UTC (permalink / raw)
  To: systemtap; +Cc: hemant, mjw, atrajeev, Ravi Bangoria

symbol_table::get_from_elf() calculates Local Entry Point and stores it
in symbol_table for ppc64le. LEP is required only at a time of probing
and not elsewhere. So no need to store it in symbol table.

No need to prioritize symbol table as well because debuginfo and symbol
table both will contain Global Entry Point.

Signed-off-by: Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com>
---
 tapsets.cxx | 62 +------------------------------------------------------------
 1 file changed, 1 insertion(+), 61 deletions(-)

diff --git a/tapsets.cxx b/tapsets.cxx
index 6d82069..e7be711 100644
--- a/tapsets.cxx
+++ b/tapsets.cxx
@@ -2142,18 +2142,6 @@ query_dwarf_inline_instance (Dwarf_Die * die, dwarf_query * q)
     }
 }
 
-static bool
-is_filtered_func_exists (func_info_map_t const& filtered, func_info *fi)
-{
-  for (unsigned i = 0; i < filtered.size(); i++)
-    {
-      if ((filtered[i].entrypc == fi->entrypc) && (filtered[i].name == fi->name))
-        return true;
-    }
-
-  return false;
-}
-
 static int
 query_dwarf_func (Dwarf_Die * func, dwarf_query * q)
 {
@@ -2206,37 +2194,7 @@ query_dwarf_func (Dwarf_Die * func, dwarf_query * q)
           q->dw.function_line (&func.decl_line);
 
           Dwarf_Addr entrypc;
-
-          func.entrypc = 0;
-          Dwarf_Addr bias;
-          Dwfl_Module *mod = q->dw.module;
-          Elf* elf = (dwarf_getelf (dwfl_module_getdwarf (mod, &bias))
-                     ?: dwfl_module_getelf (mod, &bias));
-
-          GElf_Ehdr ehdr_mem;
-          GElf_Ehdr* em = gelf_getehdr (elf, &ehdr_mem);
-          if (em == NULL) throw SEMANTIC_ERROR (_("Couldn't get elf header"));
-
-          /* Giving priority to sym_table for ppc64*/
-          if ((em->e_machine == EM_PPC64) && ((em->e_flags & EF_PPC64_ABI) == 2)
-              && (q->dw.mod_info->sym_table))
-            {
-              /* The linkage name is the best match for the symbol table. */
-              const string& linkage_name = dwarf_linkage_name(&func.die)
-                ?: dwarf_diename(&func.die) ?: (string)func.name;
-
-              const auto& fis = q->dw.mod_info->sym_table->lookup_symbol(linkage_name);
-              for (auto it=fis.begin(); it!=fis.end() ; ++it)
-                {
-                  func.entrypc = (*it)->entrypc;
-                  if (is_filtered_func_exists(q->filtered_functions, &func))
-                    continue;
-                  q->filtered_functions.push_back(func);
-                }
-            }
-
-          /* If not ppc64 or not found in sym_table, try it directly. */
-          if (!func.entrypc && q->dw.function_entrypc (&entrypc))
+          if (q->dw.function_entrypc (&entrypc))
             {
               func.entrypc = entrypc;
               q->filtered_functions.push_back (func);
@@ -8462,13 +8420,6 @@ symbol_table::get_from_elf()
   int syments = dwfl_module_getsymtab(mod);
   assert(syments);
   prepare_section_rejection(mod);
-  Dwarf_Addr bias;
-  Elf* elf = (dwarf_getelf (dwfl_module_getdwarf (mod, &bias))
-              ?: dwfl_module_getelf (mod, &bias));
-
-  GElf_Ehdr ehdr_mem;
-  GElf_Ehdr* em = gelf_getehdr (elf, &ehdr_mem);
-  if (em == NULL) throw SEMANTIC_ERROR (_("Couldn't get elf header"));
 
   for (int i = 1; i < syments; ++i)
     {
@@ -8501,18 +8452,7 @@ symbol_table::get_from_elf()
         continue;
       interned_string name = n;
 
-     /*
-      * For ELF ABI v2 on PPC64 LE, we need to adjust sym.st_value corresponding
-      * to the bits of sym.st_other. These bits will tell us what's the offset
-      * of the local entry point from the global entry point.
-      *
-      * st_other field is currently only used with ABIv2 on ppc64
-      */
       Dwarf_Addr entrypc = addr;
-      if ((em->e_machine == EM_PPC64) && ((em->e_flags & EF_PPC64_ABI) == 2)
-          && (GELF_ST_TYPE(sym.st_info) == STT_FUNC) && sym.st_other)
-        entrypc += PPC64_LOCAL_ENTRY_OFFSET(sym.st_other);
-
       if (GELF_ST_TYPE(sym.st_info) == STT_FUNC)
         add_symbol(name, (GELF_ST_BIND(sym.st_info) == STB_WEAK),
                    reject, addr, entrypc);
-- 
2.1.4

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 2/3] ppc64le: Use LEP for probe location
  2016-07-21 13:17 ` [PATCH 2/3] ppc64le: Use LEP for probe location Ravi Bangoria
@ 2016-07-26 15:58   ` Ravi Bangoria
  2016-07-26 16:22     ` David Smith
  0 siblings, 1 reply; 7+ messages in thread
From: Ravi Bangoria @ 2016-07-26 15:58 UTC (permalink / raw)
  To: mjw, fche; +Cc: systemtap, hemant, atrajeev, Ravi Bangoria

Hi Frank, Mark,

I found test case at_var.exp. But it does not test uprobe with target 
program
compiled without optimization. So I added this:

$ git diff
diff --git a/testsuite/systemtap.base/at_var.exp 
b/testsuite/systemtap.base/at_var.exp
index fd681a7..42f83d9 100644
--- a/testsuite/systemtap.base/at_var.exp
+++ b/testsuite/systemtap.base/at_var.exp
@@ -45,5 +45,14 @@ if { $res != "" } {

  stap_run3 $test $srcdir/$subdir/$test.stp -c ./${test}

+# Test for target program compiled without optimization
+set res [target_compile ${testpath}/${test}.c ${test} executable 
"additional_flags=-g"]
+if { $res != "" } {
+    verbose "target_compile failed: $res" 2
+    fail "unable to compile ${test}.c"
+}
+
+stap_run3 $test $srcdir/$subdir/$test.stp -c ./${test}
+
  # Cleanup
  if { $verbose == 0 } { catch { exec rm -f $test } }


Here is the result before and after applying patch.

Before applying patch:
   $ make verbose=1 installcheck RUNTESTFLAGS='at_var.exp -v --debug'
     ...
     Running 
/home/ravi/Workspace/systemtap/testsuite/systemtap.base/at_var.exp ...
     PASS: at_var
     FAIL: at_var

             === systemtap Summary ===

     # of expected passes        1
     # of unexpected failures    1

   $ less testsuite/systemtap.log
     ...
     executing: stap 
/home/ravi/Workspace/systemtap/testsuite/systemtap.base/at_var.stp -c 
./at_var
     FAIL: at_var
     line 1: expected "$argc: 1"
     Got "ERROR: read fault [man error::fault] at 0x          (null) 
(addr) near identifier '$argv' at 
/home/ravi/Workspace/systemtap/testsuite/systemtap.base/at_var.stp:6:53"
         "WARNING: Number of errors: 1, skipped probes: 0"
         "WARNING: /home/ravi/stap-git/bin/staprun exited with status: 1"
         "Pass 5: run failed.  [man error::pass5]"


After applying patch:
   $ make verbose=1 installcheck RUNTESTFLAGS='at_var.exp -v --debug'
     ...
     Running 
/home/ravi/Workspace/systemtap/testsuite/systemtap.base/at_var.exp ...
     PASS: at_var
     PASS: at_var

             === systemtap Summary ===

     # of expected passes        2


Please review patch. Please let me know if I need to resend v2 for this 
patchset.

Regards,
Ravi

On Thursday 21 July 2016 06:47 PM, Ravi Bangoria wrote:
> PPC64 ELF ABI v2 has a Global Entry Point and a Local Entry Point for
> the functions. Debuginfo of ELF contains GEP which is same as entrypc.
> While symbol table contains GEP and offset, from which we can calculate
> LEP. LEP is used to call function within single CU, when TOC pointer
> update is not required. So it's guaranteed that LEP will hit wherever
> function is called but GEP may not.
>
> Before Applying patch:
>
>    $ vim uprobe_test.c
>      #include <stdio.h>
>
>      void doit(int i)
>      {
>          printf("i : %d\n", i);
>      }
>
>      int main(int argc, char *argv[])
>      {
>          doit(42);
>          return 0;
>      }
>
>    $ gcc uprobe_test.c -g -o uprobe_test
>
>    $ sudo ./stap -e 'probe process("uprobe_test").function("doit") \
>          {printf("hit %d\n", $i)}' -c ./uprobe_test
>      i : 42
>      hit 0
>
> After Applying patch:
>
>    $ sudo ./stap -e 'probe process("uprobe_test").function("doit") \
>          {printf("hit %d\n", $i)}' -c ./uprobe_test
>      i : 42
>      hit 42
>
> Fixes: Commit b4c6a4b1cd00 ("Prioritize symbol table lookup for ppc64le")
> Signed-off-by: Ravi Bangoria<ravi.bangoria@linux.vnet.ibm.com>
> ---
>   tapsets.cxx | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
>   1 file changed, 50 insertions(+)
>
> diff --git a/tapsets.cxx b/tapsets.cxx
> index e7be711..1b3a1ea 100644
> --- a/tapsets.cxx
> +++ b/tapsets.cxx
> @@ -1391,6 +1391,55 @@ string path_remove_sysroot(const systemtap_session& sess, const string& path)
>     return retval;
>   }
>
> +/*
> + * Convert 'Global Entry Point' to 'Local Entry Point'.
> + *
> + * if @gep contains next address after prologue, don't change it.
> + *
> + * For ELF ABI v2 on PPC64 LE, we need to adjust sym.st_value corresponding
> + * to the bits of sym.st_other. These bits will tell us what's the offset
> + * of the local entry point from the global entry point.
> + *
> + * st_other field is currently only used with ABIv2 on ppc64
> + */
> +static Dwarf_Addr
> +get_lep(dwarf_query *q, Dwarf_Addr gep)
> +{
> +  Dwarf_Addr bias;
> +  Dwfl_Module *mod = q->dw.module;
> +  Elf* elf = (dwarf_getelf (dwfl_module_getdwarf (mod, &bias))
> +             ?: dwfl_module_getelf (mod, &bias));
> +
> +  GElf_Ehdr ehdr_mem;
> +  GElf_Ehdr* em = gelf_getehdr (elf, &ehdr_mem);
> +  if (em == NULL)
> +    throw SEMANTIC_ERROR (_("Couldn't get elf header"));
> +
> +  if (!(em->e_machine == EM_PPC64) || !((em->e_flags & EF_PPC64_ABI) == 2))
> +    return gep;
> +
> +  int syments = dwfl_module_getsymtab(mod);
> +  for (int i = 1; i < syments; ++i)
> +    {
> +      GElf_Sym sym;
> +      GElf_Word section;
> +      GElf_Addr addr;
> +
> +#if _ELFUTILS_PREREQ (0, 158)
> +      dwfl_module_getsym_info (mod, i, &sym, &addr, &section, NULL, NULL);
> +#else
> +      dwfl_module_getsym (mod, i, &sym, &section);
> +      addr = sym.st_value;
> +#endif
> +
> +      if (addr == gep && (GELF_ST_TYPE(sym.st_info) == STT_FUNC)
> +          && sym.st_other)
> +        return gep + PPC64_LOCAL_ENTRY_OFFSET(sym.st_other);
> +    }
> +
> +  return gep;
> +}
> +
>   void
>   dwarf_query::add_probe_point(interned_string dw_funcname,
>   			     interned_string filename,
> @@ -1405,6 +1454,7 @@ dwarf_query::add_probe_point(interned_string dw_funcname,
>
>     assert (! has_absolute); // already handled in dwarf_builder::build()
>
> +  addr = get_lep(this, addr);
>     reloc_addr = dw.relocate_address(addr, reloc_section);
>
>     // If we originally used the linkage name, then let's call it that way

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 3/3] ppc64le: Fix record argument of shared library function
  2016-07-21 13:17 ` [PATCH 3/3] ppc64le: Fix record argument of shared library function Ravi Bangoria
@ 2016-07-26 15:59   ` Ravi Bangoria
  0 siblings, 0 replies; 7+ messages in thread
From: Ravi Bangoria @ 2016-07-26 15:59 UTC (permalink / raw)
  To: mjw, fche; +Cc: systemtap, hemant, atrajeev, Ravi Bangoria

Hi Frank, Mark,

We already have test cases for probing in shared library.

Before applying patch:
   $ make verbose=1 installcheck RUNTESTFLAGS='exelib.exp -v --debug'

             === systemtap Summary ===

     # of expected passes        10
     # of unexpected failures    64


After applying patch:
   $ make verbose=1 installcheck RUNTESTFLAGS='exelib.exp -v --debug'

             === systemtap Summary ===

     # of expected passes        74


Please review patch.

Regards,
Ravi

On Thursday 21 July 2016 06:47 PM, Ravi Bangoria wrote:
> Symbol table contains module_bias + offset while debuginfo contains
> only offset(entrypc). Subtract module_bias from symbol table entry
> to compare it with entrypc while converting it to local entry point.
>
> Example:
>
>    $ vim shared.c
>      #include "shared.h"
>      #include "sys/sdt.h"
>      unsigned int add(unsigned int a, unsigned int b)
>      {
>          STAP_PROBE1(test, func_count, b);
>          int c;
>          c = a+b;
>          printf("c is %d\n", c);
>          return (a+b);
>      }
>    $ vim shared.h
>      #include<stdio.h>
>      extern unsigned int add(unsigned int a, unsigned int b);
>    $ vim app.c
>      #include <stdio.h>
>      #include "shared.h"
>      #include <sys/sdt.h>
>      #include "shared.h"
>      #include "sys/sdt.h"
>      unsigned int subs(unsigned int a, unsigned int b)
>      {
>          STAP_PROBE1(test, func_count1, a);
>          int c;
>          printf("\n Inside subs()\n");
>          c = a+b+a;
>          printf("c is %d\n", c);
>          return (a+b+a);
>      }
>      int main(void)
>      {
>          unsigned int a = 1;
>          unsigned int b = 2;
>          STAP_PROBE1(test, func_count1, b);
>          unsigned int result = 0;
>
>          result = add(a,b);
>          result = subs(a,b);
>          printf("\n The result is [%u]\n",result);
>          return 0;
>      }
>
>    $ gcc -c -Wall -Werror -fPIC -g -O3 shared.c
>    $ gcc -shared -o libshared.so shared.o
>    $ gcc -Wall app.c -o main -g -O3 -lshared -L/root
>    $ export LD_LIBRARY_PATH="/root":$LD_LIBRARY_PATH
>
>    $ ./stap -w --ldd -ve 'probe process(@2).function("add") \
>          {printf("Input probe hit and value = %d\n", $b); }' \
>          /root/libshared.so -c /root/main
>
>      semantic error: while processing probe process("/root/libshared.so")...
>
>      semantic error: not accessible at this address (pc: 0x107f8)...
>          dieoffset: 0x2c0 from /root/libshared.so
>          function: <unknown> at unknown source
>          alternative locations: [0x7f8,0x827], [0x827,0x86c]
>          source: probe process(@2).function("add") {printf("Input pr...
>
> After applying patch:
>
>    $ ./stap -w --ldd -ve 'probe process(@2).function("add") \
>          {printf("Input probe hit and value = %d\n", $b); }' \
>          /root/libshared.so -c /root/main
>      c is 3
>
>      Inside subs()
>      c is 4
>
>      The result is [4]
>      Input probe hit and value = 2
>
> Reported-by: Athira Rajeev<atrajeev@linux.vnet.ibm.com>
> Signed-off-by: Ravi Bangoria<ravi.bangoria@linux.vnet.ibm.com>
> ---
>   tapsets.cxx | 6 +++++-
>   1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/tapsets.cxx b/tapsets.cxx
> index 1b3a1ea..581a97e 100644
> --- a/tapsets.cxx
> +++ b/tapsets.cxx
> @@ -1432,7 +1432,11 @@ gep_to_lep(dwarf_query *q, Dwarf_Addr gep)
>         addr = sym.st_value;
>   #endif
>
> -      if (addr == gep && (GELF_ST_TYPE(sym.st_info) == STT_FUNC)
> +      /*
> +       * Symbol table contains module_bias + offset. Substract module_bias
> +       * to compare offset with gep.
> +       */
> +      if ((addr - bias) == gep && (GELF_ST_TYPE(sym.st_info) == STT_FUNC)
>             && sym.st_other)
>           return gep + PPC64_LOCAL_ENTRY_OFFSET(sym.st_other);
>       }

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 2/3] ppc64le: Use LEP for probe location
  2016-07-26 15:58   ` Ravi Bangoria
@ 2016-07-26 16:22     ` David Smith
  0 siblings, 0 replies; 7+ messages in thread
From: David Smith @ 2016-07-26 16:22 UTC (permalink / raw)
  To: Ravi Bangoria, mjw, fche; +Cc: systemtap, hemant, atrajeev

On 07/26/2016 10:58 AM, Ravi Bangoria wrote:
> Hi Frank, Mark,
> 
> I found test case at_var.exp. But it does not test uprobe with target
> program
> compiled without optimization. So I added this:

... stuff deleted ...

I don't know much about ppc64le, but your test case patch looked fine. I
checked it in as commit d4d3c3d. I did tweak your patch to differentiate
between the optimized test and non-optimized test.

Thanks for the patch.

-- 
David Smith
dsmith@redhat.com
Red Hat
http://www.redhat.com
256.217.0141 (direct)
256.837.0057 (fax)

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2016-07-26 16:22 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-21 13:17 [PATCH 0/3] ppc64le: Fix multiple issues with ppc64le Ravi Bangoria
2016-07-21 13:17 ` [PATCH 1/3] ppc64le: Store correct function entry address in symbol_table Ravi Bangoria
2016-07-21 13:17 ` [PATCH 2/3] ppc64le: Use LEP for probe location Ravi Bangoria
2016-07-26 15:58   ` Ravi Bangoria
2016-07-26 16:22     ` David Smith
2016-07-21 13:17 ` [PATCH 3/3] ppc64le: Fix record argument of shared library function Ravi Bangoria
2016-07-26 15:59   ` Ravi Bangoria

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).