]> sourceware.org Git - systemtap.git/commitdiff
Merge _stp_vma_module_name functionality into _stp_umod_lookup.
authorMark Wielaard <mjw@redhat.com>
Tue, 29 Jun 2010 10:02:48 +0000 (12:02 +0200)
committerMark Wielaard <mjw@redhat.com>
Tue, 29 Jun 2010 12:03:41 +0000 (14:03 +0200)
This also includes the fix for 32bit signed values in 64bit longs issue
which was missing from _stp_umod_lookup. Better to have the lookup and
fix/workaround all in one place.

* runtime/vma.c (_stp_vma_module_name): Removed.
* runtime/sym.c (_stp_umod_lookup): Include module name lookup.
  (_stp_kallsyms_lookup): Get name directly when available throug umodule.
* runtime/unwind.c (unwind): Adjust _stp_umod_lookup call.
* tapset/ucontext.stp (umodname): Use _stp_umod_lookup.

runtime/sym.c
runtime/unwind.c
runtime/vma.c
tapset/ucontext.stp

index 775483ab1bb82fd529d636fd47c0390a77757266..04432a22ed331caea1f0888f7677a28934a6881f 100644 (file)
@@ -120,20 +120,31 @@ static struct _stp_module *_stp_kmod_sec_lookup(unsigned long addr,
 
 /* Return (user) module in which the the given addr falls.  Returns
    NULL when no module can be found that contains the addr.  Fills in
-   vm_start (addr where module is mapped in) when given.  Note
-   that user modules always have exactly one section. */
+   vm_start (addr where module is mapped in) and (base) name of module
+   when given.  Note that user modules always have exactly one section
+   (.dynamic or .absolute). */
 static struct _stp_module *_stp_umod_lookup(unsigned long addr,
                                            struct task_struct *task,
+                                           const char **name,
                                            unsigned long *vm_start)
 {
   void *user = NULL;
+  struct dentry *dentry = NULL;
+#ifdef CONFIG_COMPAT
+        /* Handle 32bit signed values in 64bit longs, chop off top bits. */
+        if (test_tsk_thread_flag(task, TIF_32BIT))
+          addr &= ((compat_ulong_t) ~0);
+#endif
   if (stap_find_vma_map_info(task->group_leader, addr,
-                            vm_start, NULL, NULL, &user) == 0)
+                            vm_start, NULL, &dentry, &user) == 0)
+
+    if (dentry != NULL && name != NULL)
+      *name = dentry->d_name.name;
+
     if (user != NULL)
       {
        struct _stp_module *m = (struct _stp_module *)user;
-       dbug_sym(1, "found section %s in module %s at 0x%lx\n",
-                m->sections[0].name, m->name, vm_start);
+       dbug_sym(1, "found module %s at 0x%lx\n", dentry->dname.name, vm_start);
        return m;
       }
   return NULL;
@@ -160,7 +171,7 @@ static const char *_stp_kallsyms_lookup(unsigned long addr,
            if (test_tsk_thread_flag(task, TIF_32BIT))
              addr &= ((compat_ulong_t) ~0);
 #endif
-           m = _stp_umod_lookup(addr, task, &vm_start);
+           m = _stp_umod_lookup(addr, task, modname, &vm_start);
            if (m)
              {
                sec = &m->sections[0];
@@ -175,7 +186,11 @@ static const char *_stp_kallsyms_lookup(unsigned long addr,
          {
            m = _stp_kmod_sec_lookup(addr, &sec);
            if (m)
-             rel_addr = addr - sec->static_addr;
+             {
+               rel_addr = addr - sec->static_addr;
+               if (modname)
+                 *modname = m->name;
+             }
          }
 
         if (unlikely (m == NULL || sec == NULL))
@@ -199,8 +214,6 @@ static const char *_stp_kallsyms_lookup(unsigned long addr,
        if (likely(addr >= s->addr)) {
                if (offset)
                        *offset = addr - s->addr;
-               if (modname)
-                       *modname = m->name;
                 /* We could also pass sec->name here. */
                if (symbolsize) {
                        if ((begin + 1) < sec->num_symbols)
@@ -429,7 +442,7 @@ static void _stp_func_print(unsigned long address, int flags,
 static void _stp_symbol_snprint(char *str, size_t len, unsigned long address,
                         struct task_struct *task, int add_mod)
 {
-       const char *modname;
+       const char *modname = NULL;
        const char *name;
        unsigned long offset, size;
 
index 23a3e0aaf8651f9df3b4e28079cab2757d143a2d..647df79228944a90a20f5721a9b55f8044cc972c 100644 (file)
@@ -950,7 +950,7 @@ static int unwind(struct unwind_frame_info *frame, struct task_struct *tsk)
 
        if (tsk)
          {
-           m = _stp_umod_lookup (pc, tsk, NULL);
+           m = _stp_umod_lookup (pc, tsk, NULL, NULL);
            if (m)
              s = &m->sections[0];
          }
index f97f3ebf4f573347d8afeca600c22e5aab359735..f2201897ea2ba586ff022ebc74baf3328b29b18d 100644 (file)
@@ -110,26 +110,6 @@ static int _stp_vma_munmap_cb(struct stap_task_finder_target *tgt,
        return 0;
 }
 
-/* Provides name of the vma that an address is in for a given task,
- * or NULL if not found.
- */
-static const char *_stp_vma_module_name(struct task_struct *tsk,
-                                       unsigned long addr)
-{
-       struct dentry *dentry = NULL;
-#ifdef CONFIG_COMPAT
-       /* Handle 32bit signed values in 64bit longs, chop off top bits. */
-       if (tsk && test_tsk_thread_flag(tsk, TIF_32BIT))
-         addr &= ((compat_ulong_t) ~0);
-#endif
-       if (stap_find_vma_map_info(tsk->group_leader, addr,
-                                  NULL, NULL, &dentry, NULL) == 0)
-               if (dentry != NULL)
-                       return dentry->d_name.name;
-
-       return NULL;
-}
-
 /* Initializes the vma tracker. */
 static int _stp_vma_init(void)
 {
index 743d36a34e295c28cb232168e1c1feda85891db7..04acb77e9003e76121c89442f3ee6d8f8d214a1d 100644 (file)
@@ -23,7 +23,7 @@ function umodname:string (addr:long) %{
 /* pure */ /* unprivileged */ /* pragma:vma */
   const char *name = NULL;
   assert_is_myproc();
-  name =_stp_vma_module_name(current, THIS->addr);
+  _stp_umod_lookup(THIS->addr, current, &name, NULL);
   if (!name)
     name = "<unknown>";
   strlcpy (THIS->__retvalue, name, MAXSTRINGLEN);
This page took 0.034594 seconds and 5 git commands to generate.