Commit 24743774 authored by Eric Pouech's avatar Eric Pouech Committed by Alexandre Julliard

dbghelp: Dwarf2 & AT_byte_size.

- AT_byte_size can be larger than a single byte (especially for enums) - added missing enumeration type parsing
parent e7908525
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
* File dwarf.c - read dwarf2 information from the ELF modules * File dwarf.c - read dwarf2 information from the ELF modules
* *
* Copyright (C) 2005, Raphael Junqueira * Copyright (C) 2005, Raphael Junqueira
* Copyright (C) 2006, Eric Pouech
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
...@@ -489,6 +490,9 @@ typedef struct dwarf2_parse_context_s { ...@@ -489,6 +490,9 @@ typedef struct dwarf2_parse_context_s {
unsigned char level; unsigned char level;
} dwarf2_parse_context_t; } dwarf2_parse_context_t;
/* forward declarations */
static struct symt_enum* dwarf2_parse_enumeration_type(struct module* module, dwarf2_abbrev_entry_t* entry, dwarf2_parse_context_t* ctx);
static unsigned char dwarf2_parse_byte(dwarf2_parse_context_t* ctx) static unsigned char dwarf2_parse_byte(dwarf2_parse_context_t* ctx)
{ {
unsigned char uvalue = *(const unsigned char*) ctx->data; unsigned char uvalue = *(const unsigned char*) ctx->data;
...@@ -908,7 +912,7 @@ static struct symt_basic* dwarf2_parse_base_type(struct module* module, dwarf2_a ...@@ -908,7 +912,7 @@ static struct symt_basic* dwarf2_parse_base_type(struct module* module, dwarf2_a
TRACE("found name %s\n", name); TRACE("found name %s\n", name);
break; break;
case DW_AT_byte_size: case DW_AT_byte_size:
size = dwarf2_parse_byte(ctx); size = dwarf2_parse_attr_as_data(attr, ctx);
break; break;
case DW_AT_encoding: case DW_AT_encoding:
encoding = dwarf2_parse_byte(ctx); encoding = dwarf2_parse_byte(ctx);
...@@ -992,7 +996,7 @@ static struct symt_pointer* dwarf2_parse_pointer_type(struct module* module, dwa ...@@ -992,7 +996,7 @@ static struct symt_pointer* dwarf2_parse_pointer_type(struct module* module, dwa
for (attr = entry->attrs; NULL != attr; attr = attr->next) { for (attr = entry->attrs; NULL != attr; attr = attr->next) {
switch (attr->attribute) { switch (attr->attribute) {
case DW_AT_byte_size: case DW_AT_byte_size:
size = dwarf2_parse_byte(ctx); size = dwarf2_parse_attr_as_data(attr, ctx);
break; break;
case DW_AT_type: case DW_AT_type:
{ {
...@@ -1314,6 +1318,12 @@ static void dwarf2_parse_udt_members(struct module* module, dwarf2_abbrev_entry_ ...@@ -1314,6 +1318,12 @@ static void dwarf2_parse_udt_members(struct module* module, dwarf2_abbrev_entry_
case DW_TAG_member: case DW_TAG_member:
dwarf2_parse_udt_member(module, entry, ctx, symt); dwarf2_parse_udt_member(module, entry, ctx, symt);
break; break;
case DW_TAG_enumeration_type:
{
struct symt_enum* symt = dwarf2_parse_enumeration_type(module, entry, ctx);
dwarf2_add_symt_ref(module, entry_ref, &symt->symt);
}
break;
default: default:
{ {
dwarf2_abbrev_entry_attr_t* attr; dwarf2_abbrev_entry_attr_t* attr;
...@@ -1349,7 +1359,7 @@ static struct symt_udt* dwarf2_parse_class_type(struct module* module, dwarf2_ab ...@@ -1349,7 +1359,7 @@ static struct symt_udt* dwarf2_parse_class_type(struct module* module, dwarf2_ab
TRACE("found name %s\n", name); TRACE("found name %s\n", name);
break; break;
case DW_AT_byte_size: case DW_AT_byte_size:
size = dwarf2_parse_byte(ctx); size = dwarf2_parse_attr_as_data(attr, ctx);
break; break;
case DW_AT_decl_file: case DW_AT_decl_file:
case DW_AT_decl_line: case DW_AT_decl_line:
...@@ -1389,7 +1399,7 @@ static struct symt_udt* dwarf2_parse_struct_type(struct module* module, dwarf2_a ...@@ -1389,7 +1399,7 @@ static struct symt_udt* dwarf2_parse_struct_type(struct module* module, dwarf2_a
TRACE("found name %s\n", name); TRACE("found name %s\n", name);
break; break;
case DW_AT_byte_size: case DW_AT_byte_size:
size = dwarf2_parse_byte(ctx); size = dwarf2_parse_attr_as_data(attr, ctx);
break; break;
case DW_AT_decl_file: case DW_AT_decl_file:
case DW_AT_decl_line: case DW_AT_decl_line:
...@@ -1429,7 +1439,7 @@ static struct symt_udt* dwarf2_parse_union_type(struct module* module, dwarf2_ab ...@@ -1429,7 +1439,7 @@ static struct symt_udt* dwarf2_parse_union_type(struct module* module, dwarf2_ab
TRACE("found name %s\n", name); TRACE("found name %s\n", name);
break; break;
case DW_AT_byte_size: case DW_AT_byte_size:
size = dwarf2_parse_byte(ctx); size = dwarf2_parse_attr_as_data(attr, ctx);
break; break;
case DW_AT_decl_file: case DW_AT_decl_file:
case DW_AT_decl_line: case DW_AT_decl_line:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment