libunwind-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Libunwind-devel] [PATCHv3 3/4] Add core dump unwinding support to libun


From: Denys Vlasenko
Subject: [Libunwind-devel] [PATCHv3 3/4] Add core dump unwinding support to libunwind
Date: Mon, 27 Feb 2012 16:56:14 +0100
User-agent: Mozilla/5.0 (X11; Linux i686; rv:10.0) Gecko/20120131 Thunderbird/10.0

> Patch 3:
> In src/elfxx.c, factor out a part of get_proc_name() function
> into a new function get_proc_name_in_image(). The difference
> is that get_proc_name_in_image() does not assume that we trace
> a process, doesn't scan /proc/PID/maps but instead accepts
> already mapped ELF file. This refactoring is required by patch 4:
> it will call get_proc_name_in_image().


diff -d -urpN libunwind.2/src/elfxx.c libunwind.3/src/elfxx.c
--- libunwind.2/src/elfxx.c     2012-02-13 18:43:50.000000000 +0100
+++ libunwind.3/src/elfxx.c     2012-02-27 15:54:09.738896424 +0100
@@ -127,22 +127,19 @@ elf_w (lookup_symbol) (unw_addr_space_t
    sensitive to the performance of this routine, why bother...  */

 HIDDEN int
-elf_w (get_proc_name) (unw_addr_space_t as, pid_t pid, unw_word_t ip,
+elf_w (get_proc_name_in_image) (unw_addr_space_t as, struct elf_image *ei,
+                      unsigned long segbase,
+                      unsigned long mapoff,
+                      unw_word_t ip,
                       char *buf, size_t buf_len, unw_word_t *offp)
 {
-  unsigned long segbase, mapoff;
   Elf_W (Addr) load_offset = 0;
-  struct elf_image ei;
   Elf_W (Ehdr) *ehdr;
   Elf_W (Phdr) *phdr;
   int i, ret;

-  ret = tdep_get_elf_image (&ei, pid, ip, &segbase, &mapoff, NULL, 0);
-  if (ret < 0)
-    return ret;
-
-  ehdr = ei.image;
-  phdr = (Elf_W (Phdr) *) ((char *) ei.image + ehdr->e_phoff);
+  ehdr = ei->image;
+  phdr = (Elf_W (Phdr) *) ((char *) ei->image + ehdr->e_phoff);

   for (i = 0; i < ehdr->e_phnum; ++i)
     if (phdr[i].p_type == PT_LOAD && phdr[i].p_offset == mapoff)
@@ -151,7 +148,24 @@ elf_w (get_proc_name) (unw_addr_space_t
        break;
       }

-  ret = elf_w (lookup_symbol) (as, ip, &ei, load_offset, buf, buf_len, offp);
+  ret = elf_w (lookup_symbol) (as, ip, ei, load_offset, buf, buf_len, offp);
+
+  return ret;
+}
+
+HIDDEN int
+elf_w (get_proc_name) (unw_addr_space_t as, pid_t pid, unw_word_t ip,
+                      char *buf, size_t buf_len, unw_word_t *offp)
+{
+  unsigned long segbase, mapoff;
+  struct elf_image ei;
+  int ret;
+
+  ret = tdep_get_elf_image (&ei, pid, ip, &segbase, &mapoff, NULL, 0);
+  if (ret < 0)
+    return ret;
+
+  ret = elf_w (get_proc_name_in_image) (as, &ei, segbase, mapoff, ip, buf, 
buf_len, offp);

   munmap (ei.image, ei.size);
   ei.image = NULL;
diff -d -urpN libunwind.2/src/elfxx.h libunwind.3/src/elfxx.h
--- libunwind.2/src/elfxx.h     2012-02-13 18:43:50.000000000 +0100
+++ libunwind.3/src/elfxx.h     2012-02-27 15:54:09.738896424 +0100
@@ -48,6 +48,18 @@ extern int elf_w (get_proc_name) (unw_ad
                                  char *buf, size_t len,
                                  unw_word_t *offp);

+extern int elf_w (get_proc_name_in_image) (unw_addr_space_t as,
+                                          struct elf_image *ei,
+                                          unsigned long segbase,
+                                          unsigned long mapoff,
+                                          unw_word_t ip,
+                                          char *buf, size_t buf_len, 
unw_word_t *offp);
+
+extern int elf_w (get_proc_name) (unw_addr_space_t as,
+                                 pid_t pid, unw_word_t ip,
+                                 char *buf, size_t len,
+                                 unw_word_t *offp);
+
 static inline int
 elf_w (valid_object) (struct elf_image *ei)
 {



reply via email to

[Prev in Thread] Current Thread [Next in Thread]