[前][次][番号順一覧][スレッド一覧]

ruby-changes:52889

From: naruse <ko1@a...>
Date: Wed, 17 Oct 2018 08:52:30 +0900 (JST)
Subject: [ruby-changes:52889] naruse:r65101 (trunk): If high_pc uses DW_FORM_addr, it's not size but address

naruse	2018-10-17 08:52:26 +0900 (Wed, 17 Oct 2018)

  New Revision: 65101

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=65101

  Log:
    If high_pc uses DW_FORM_addr, it's not size but address

  Modified files:
    trunk/addr2line.c
Index: addr2line.c
===================================================================
--- addr2line.c	(revision 65100)
+++ addr2line.c	(revision 65101)
@@ -937,14 +937,12 @@ di_read_cu(DebugInfoReader *reader) https://github.com/ruby/ruby/blob/trunk/addr2line.c#L937
         reader->q0 = reader->obj->debug_abbrev.ptr + hdr->debug_abbrev_offset;
         reader->address_size = hdr->address_size;
         reader->format = 64;
-        if (hdr->version != 4) return -1;
     } else {
         DW_CompilationUnitHeader32 *hdr = hdr32;
         reader->p += 11;
         reader->q0 = reader->obj->debug_abbrev.ptr + hdr->debug_abbrev_offset;
         reader->address_size = hdr->address_size;
         reader->format = 32;
-        if (hdr->version != 4) return -1;
     }
     reader->level = 0;
     di_read_debug_abbrev_cu(reader);
@@ -1318,24 +1316,27 @@ typedef struct { https://github.com/ruby/ruby/blob/trunk/addr2line.c#L1316
 } ranges_t;
 
 static void
-ranges_set_low_pc(ranges_t *ptr, uint64_t low_pc)
+ranges_set(ranges_t *ptr, DebugInfoValue *v)
 {
-    ptr->low_pc = low_pc;
-    ptr->low_pc_set = true;
-}
-
-static void
-ranges_set_high_pc(ranges_t *ptr, uint64_t high_pc)
-{
-    ptr->high_pc = high_pc;
-    ptr->high_pc_set = true;
-}
-
-static void
-ranges_set_ranges(ranges_t *ptr, uint64_t ranges)
-{
-    ptr->ranges = ranges;
-    ptr->ranges_set = true;
+    switch (v->at) {
+      case DW_AT_low_pc:
+        ptr->low_pc = v->as.uint64;
+        ptr->low_pc_set = true;
+        break;
+      case DW_AT_high_pc:
+        if (v->form == DW_FORM_addr) {
+            ptr->high_pc = v->as.uint64;
+        }
+        else {
+            ptr->high_pc = ptr->low_pc + v->as.uint64;
+        }
+        ptr->high_pc_set = true;
+        break;
+      case DW_AT_ranges:
+        ptr->ranges = v->as.uint64;
+        ptr->ranges_set = true;
+        break;
+    }
 }
 
 static uintptr_t
@@ -1345,7 +1346,7 @@ ranges_include(DebugInfoReader *reader, https://github.com/ruby/ruby/blob/trunk/addr2line.c#L1346
         if (ptr->ranges_set || !ptr->low_pc_set) {
             exit(1);
         }
-        if (ptr->low_pc <= addr && addr <= ptr->low_pc + ptr->high_pc) {
+        if (ptr->low_pc <= addr && addr <= ptr->high_pc) {
             return ptr->low_pc;
         }
     }
@@ -1463,10 +1464,9 @@ debug_info_read(DebugInfoReader *reader, https://github.com/ruby/ruby/blob/trunk/addr2line.c#L1464
                 line.line = (int)v.as.uint64;
                 break;
               case DW_AT_low_pc:
-                ranges_set_low_pc(&ranges, v.as.uint64);
-                break;
               case DW_AT_high_pc:
-                ranges_set_high_pc(&ranges, v.as.uint64);
+              case DW_AT_ranges:
+                ranges_set(&ranges, &v);
                 break;
               case DW_AT_declaration:
                 goto skip_die;
@@ -1476,9 +1476,6 @@ debug_info_read(DebugInfoReader *reader, https://github.com/ruby/ruby/blob/trunk/addr2line.c#L1476
               case DW_AT_abstract_origin:
                 read_abstract_origin(reader, v.as.uint64, &line);
                 break; //goto skip_die;
-              case DW_AT_ranges:
-                ranges_set_ranges(&ranges, v.as.uint64);
-                break;
             }
         }
         /* ranges_inspect(reader, &ranges); */

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]