This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 3/3] ppc64le: Fix record argument of shared library function


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);
      }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]