|
Panu Matilainen |
b0aff4 |
commit 71a7dd8b7a2df677214c18473eac661ea38fb649
|
|
Panu Matilainen |
b0aff4 |
Author: Panu Matilainen <pmatilai@redhat.com>
|
|
Panu Matilainen |
b0aff4 |
Date: Tue Jun 16 13:52:43 2009 +0300
|
|
Panu Matilainen |
b0aff4 |
|
|
Panu Matilainen |
b0aff4 |
Add debugedit support for DWARF-3 (RhBug:505774)
|
|
Panu Matilainen |
b0aff4 |
- patch from Jakub Jelinek
|
|
Panu Matilainen |
b0aff4 |
|
|
Panu Matilainen |
b0aff4 |
diff --git a/tools/debugedit.c b/tools/debugedit.c
|
|
Panu Matilainen |
b0aff4 |
index f42b34a..b9db7db 100644
|
|
Panu Matilainen |
b0aff4 |
--- a/tools/debugedit.c
|
|
Panu Matilainen |
b0aff4 |
+++ b/tools/debugedit.c
|
|
Panu Matilainen |
b0aff4 |
@@ -1,4 +1,4 @@
|
|
Panu Matilainen |
b0aff4 |
-/* Copyright (C) 2001, 2002, 2003, 2005, 2007 Red Hat, Inc.
|
|
Panu Matilainen |
b0aff4 |
+/* Copyright (C) 2001, 2002, 2003, 2005, 2007, 2009 Red Hat, Inc.
|
|
Panu Matilainen |
b0aff4 |
Written by Alexander Larsson <alexl@redhat.com>, 2002
|
|
Panu Matilainen |
b0aff4 |
Based on code by Jakub Jelinek <jakub@redhat.com>, 2001.
|
|
Panu Matilainen |
b0aff4 |
|
|
Panu Matilainen |
b0aff4 |
@@ -88,6 +88,7 @@ static uint32_t (*do_read_32) (unsigned char *ptr);
|
|
Panu Matilainen |
b0aff4 |
static void (*write_32) (unsigned char *ptr, GElf_Addr val);
|
|
Panu Matilainen |
b0aff4 |
|
|
Panu Matilainen |
b0aff4 |
static int ptr_size;
|
|
Panu Matilainen |
b0aff4 |
+static int cu_version;
|
|
Panu Matilainen |
b0aff4 |
|
|
Panu Matilainen |
b0aff4 |
static inline uint16_t
|
|
Panu Matilainen |
b0aff4 |
buf_read_ule16 (unsigned char *data)
|
|
Panu Matilainen |
b0aff4 |
@@ -213,16 +214,18 @@ static struct
|
|
Panu Matilainen |
b0aff4 |
#define DEBUG_LINE 2
|
|
Panu Matilainen |
b0aff4 |
#define DEBUG_ARANGES 3
|
|
Panu Matilainen |
b0aff4 |
#define DEBUG_PUBNAMES 4
|
|
Panu Matilainen |
b0aff4 |
-#define DEBUG_MACINFO 5
|
|
Panu Matilainen |
b0aff4 |
-#define DEBUG_LOC 6
|
|
Panu Matilainen |
b0aff4 |
-#define DEBUG_STR 7
|
|
Panu Matilainen |
b0aff4 |
-#define DEBUG_FRAME 8
|
|
Panu Matilainen |
b0aff4 |
-#define DEBUG_RANGES 9
|
|
Panu Matilainen |
b0aff4 |
+#define DEBUG_PUBTYPES 5
|
|
Panu Matilainen |
b0aff4 |
+#define DEBUG_MACINFO 6
|
|
Panu Matilainen |
b0aff4 |
+#define DEBUG_LOC 7
|
|
Panu Matilainen |
b0aff4 |
+#define DEBUG_STR 8
|
|
Panu Matilainen |
b0aff4 |
+#define DEBUG_FRAME 9
|
|
Panu Matilainen |
b0aff4 |
+#define DEBUG_RANGES 10
|
|
Panu Matilainen |
b0aff4 |
{ ".debug_info", NULL, NULL, 0, 0, 0 },
|
|
Panu Matilainen |
b0aff4 |
{ ".debug_abbrev", NULL, NULL, 0, 0, 0 },
|
|
Panu Matilainen |
b0aff4 |
{ ".debug_line", NULL, NULL, 0, 0, 0 },
|
|
Panu Matilainen |
b0aff4 |
{ ".debug_aranges", NULL, NULL, 0, 0, 0 },
|
|
Panu Matilainen |
b0aff4 |
{ ".debug_pubnames", NULL, NULL, 0, 0, 0 },
|
|
Panu Matilainen |
b0aff4 |
+ { ".debug_pubtypes", NULL, NULL, 0, 0, 0 },
|
|
Panu Matilainen |
b0aff4 |
{ ".debug_macinfo", NULL, NULL, 0, 0, 0 },
|
|
Panu Matilainen |
b0aff4 |
{ ".debug_loc", NULL, NULL, 0, 0, 0 },
|
|
Panu Matilainen |
b0aff4 |
{ ".debug_str", NULL, NULL, 0, 0, 0 },
|
|
Panu Matilainen |
b0aff4 |
@@ -302,7 +305,7 @@ no_memory:
|
|
Panu Matilainen |
b0aff4 |
}
|
|
Panu Matilainen |
b0aff4 |
if (*slot != NULL)
|
|
Panu Matilainen |
b0aff4 |
{
|
|
Panu Matilainen |
b0aff4 |
- error (0, 0, "%s: Duplicate DWARF-2 abbreviation %d", dso->filename,
|
|
Panu Matilainen |
b0aff4 |
+ error (0, 0, "%s: Duplicate DWARF abbreviation %d", dso->filename,
|
|
Panu Matilainen |
b0aff4 |
t->entry);
|
|
Panu Matilainen |
b0aff4 |
free (t);
|
|
Panu Matilainen |
b0aff4 |
htab_delete (h);
|
|
Panu Matilainen |
b0aff4 |
@@ -322,7 +325,7 @@ no_memory:
|
|
Panu Matilainen |
b0aff4 |
form = read_uleb128 (ptr);
|
|
Panu Matilainen |
b0aff4 |
if (form == 2 || form > DW_FORM_indirect)
|
|
Panu Matilainen |
b0aff4 |
{
|
|
Panu Matilainen |
b0aff4 |
- error (0, 0, "%s: Unknown DWARF-2 DW_FORM_%d", dso->filename, form);
|
|
Panu Matilainen |
b0aff4 |
+ error (0, 0, "%s: Unknown DWARF DW_FORM_%d", dso->filename, form);
|
|
Panu Matilainen |
b0aff4 |
htab_delete (h);
|
|
Panu Matilainen |
b0aff4 |
return NULL;
|
|
Panu Matilainen |
b0aff4 |
}
|
|
Panu Matilainen |
b0aff4 |
@@ -332,7 +335,7 @@ no_memory:
|
|
Panu Matilainen |
b0aff4 |
}
|
|
Panu Matilainen |
b0aff4 |
if (read_uleb128 (ptr) != 0)
|
|
Panu Matilainen |
b0aff4 |
{
|
|
Panu Matilainen |
b0aff4 |
- error (0, 0, "%s: DWARF-2 abbreviation does not end with 2 zeros",
|
|
Panu Matilainen |
b0aff4 |
+ error (0, 0, "%s: DWARF abbreviation does not end with 2 zeros",
|
|
Panu Matilainen |
b0aff4 |
dso->filename);
|
|
Panu Matilainen |
b0aff4 |
htab_delete (h);
|
|
Panu Matilainen |
b0aff4 |
return NULL;
|
|
Panu Matilainen |
b0aff4 |
@@ -484,7 +487,7 @@ edit_dwarf2_line (DSO *dso, uint32_t off, char *comp_dir, int phase)
|
|
Panu Matilainen |
b0aff4 |
}
|
|
Panu Matilainen |
b0aff4 |
|
|
Panu Matilainen |
b0aff4 |
value = read_16 (ptr);
|
|
Panu Matilainen |
b0aff4 |
- if (value != 2)
|
|
Panu Matilainen |
b0aff4 |
+ if (value != 2 && value != 3)
|
|
Panu Matilainen |
b0aff4 |
{
|
|
Panu Matilainen |
b0aff4 |
error (0, 0, "%s: DWARF version %d unhandled", dso->filename,
|
|
Panu Matilainen |
b0aff4 |
value);
|
|
Panu Matilainen |
b0aff4 |
@@ -829,7 +832,12 @@ edit_attributes (DSO *dso, unsigned char *ptr, struct abbrev_tag *t, int phase)
|
|
Panu Matilainen |
b0aff4 |
|
|
Panu Matilainen |
b0aff4 |
switch (form)
|
|
Panu Matilainen |
b0aff4 |
{
|
|
Panu Matilainen |
b0aff4 |
- case DW_FORM_ref_addr: /* ptr_size in DWARF 2, offset in DWARF 3 */
|
|
Panu Matilainen |
b0aff4 |
+ case DW_FORM_ref_addr:
|
|
Panu Matilainen |
b0aff4 |
+ if (cu_version == 2)
|
|
Panu Matilainen |
b0aff4 |
+ ptr += ptr_size;
|
|
Panu Matilainen |
b0aff4 |
+ else
|
|
Panu Matilainen |
b0aff4 |
+ ptr += 4;
|
|
Panu Matilainen |
b0aff4 |
+ break;
|
|
Panu Matilainen |
b0aff4 |
case DW_FORM_addr:
|
|
Panu Matilainen |
b0aff4 |
ptr += ptr_size;
|
|
Panu Matilainen |
b0aff4 |
break;
|
|
Panu Matilainen |
b0aff4 |
@@ -881,7 +889,7 @@ edit_attributes (DSO *dso, unsigned char *ptr, struct abbrev_tag *t, int phase)
|
|
Panu Matilainen |
b0aff4 |
assert (len < UINT_MAX);
|
|
Panu Matilainen |
b0aff4 |
break;
|
|
Panu Matilainen |
b0aff4 |
default:
|
|
Panu Matilainen |
b0aff4 |
- error (0, 0, "%s: Unknown DWARF-2 DW_FORM_%d", dso->filename,
|
|
Panu Matilainen |
b0aff4 |
+ error (0, 0, "%s: Unknown DWARF DW_FORM_%d", dso->filename,
|
|
Panu Matilainen |
b0aff4 |
form);
|
|
Panu Matilainen |
b0aff4 |
return NULL;
|
|
Panu Matilainen |
b0aff4 |
}
|
|
Panu Matilainen |
b0aff4 |
@@ -1178,11 +1186,11 @@ edit_dwarf2 (DSO *dso)
|
|
Panu Matilainen |
b0aff4 |
return 1;
|
|
Panu Matilainen |
b0aff4 |
}
|
|
Panu Matilainen |
b0aff4 |
|
|
Panu Matilainen |
b0aff4 |
- value = read_16 (ptr);
|
|
Panu Matilainen |
b0aff4 |
- if (value != 2)
|
|
Panu Matilainen |
b0aff4 |
+ cu_version = read_16 (ptr);
|
|
Panu Matilainen |
b0aff4 |
+ if (cu_version != 2 && cu_version != 3)
|
|
Panu Matilainen |
b0aff4 |
{
|
|
Panu Matilainen |
b0aff4 |
error (0, 0, "%s: DWARF version %d unhandled", dso->filename,
|
|
Panu Matilainen |
b0aff4 |
- value);
|
|
Panu Matilainen |
b0aff4 |
+ cu_version);
|
|
Panu Matilainen |
b0aff4 |
return 1;
|
|
Panu Matilainen |
b0aff4 |
}
|
|
Panu Matilainen |
b0aff4 |
|
|
Panu Matilainen |
b0aff4 |
@@ -1192,7 +1200,7 @@ edit_dwarf2 (DSO *dso)
|
|
Panu Matilainen |
b0aff4 |
if (debug_sections[DEBUG_ABBREV].data == NULL)
|
|
Panu Matilainen |
b0aff4 |
error (0, 0, "%s: .debug_abbrev not present", dso->filename);
|
|
Panu Matilainen |
b0aff4 |
else
|
|
Panu Matilainen |
b0aff4 |
- error (0, 0, "%s: DWARF-2 CU abbrev offset too large",
|
|
Panu Matilainen |
b0aff4 |
+ error (0, 0, "%s: DWARF CU abbrev offset too large",
|
|
Panu Matilainen |
b0aff4 |
dso->filename);
|
|
Panu Matilainen |
b0aff4 |
return 1;
|
|
Panu Matilainen |
b0aff4 |
}
|
|
Panu Matilainen |
b0aff4 |
@@ -1202,14 +1210,14 @@ edit_dwarf2 (DSO *dso)
|
|
Panu Matilainen |
b0aff4 |
ptr_size = read_1 (ptr);
|
|
Panu Matilainen |
b0aff4 |
if (ptr_size != 4 && ptr_size != 8)
|
|
Panu Matilainen |
b0aff4 |
{
|
|
Panu Matilainen |
b0aff4 |
- error (0, 0, "%s: Invalid DWARF-2 pointer size %d",
|
|
Panu Matilainen |
b0aff4 |
+ error (0, 0, "%s: Invalid DWARF pointer size %d",
|
|
Panu Matilainen |
b0aff4 |
dso->filename, ptr_size);
|
|
Panu Matilainen |
b0aff4 |
return 1;
|
|
Panu Matilainen |
b0aff4 |
}
|
|
Panu Matilainen |
b0aff4 |
}
|
|
Panu Matilainen |
b0aff4 |
else if (read_1 (ptr) != ptr_size)
|
|
Panu Matilainen |
b0aff4 |
{
|
|
Panu Matilainen |
b0aff4 |
- error (0, 0, "%s: DWARF-2 pointer size differs between CUs",
|
|
Panu Matilainen |
b0aff4 |
+ error (0, 0, "%s: DWARF pointer size differs between CUs",
|
|
Panu Matilainen |
b0aff4 |
dso->filename);
|
|
Panu Matilainen |
b0aff4 |
return 1;
|
|
Panu Matilainen |
b0aff4 |
}
|
|
Panu Matilainen |
b0aff4 |
@@ -1227,7 +1235,7 @@ edit_dwarf2 (DSO *dso)
|
|
Panu Matilainen |
b0aff4 |
t = htab_find_with_hash (abbrev, &tag, tag.entry);
|
|
Panu Matilainen |
b0aff4 |
if (t == NULL)
|
|
Panu Matilainen |
b0aff4 |
{
|
|
Panu Matilainen |
b0aff4 |
- error (0, 0, "%s: Could not find DWARF-2 abbreviation %d",
|
|
Panu Matilainen |
b0aff4 |
+ error (0, 0, "%s: Could not find DWARF abbreviation %d",
|
|
Panu Matilainen |
b0aff4 |
dso->filename, tag.entry);
|
|
Panu Matilainen |
b0aff4 |
htab_delete (abbrev);
|
|
Panu Matilainen |
b0aff4 |
return 1;
|