Eric Pouech : dbghelp: Pass .
debug_loc section info from the ELF loader to the dwarf parser.
Alexandre Julliard
julliard at wine.codeweavers.com
Mon Nov 27 12:51:39 CST 2006
Module: wine
Branch: master
Commit: 848f8c41c0e7917c39880081f68c599511c612b5
URL: http://source.winehq.org/git/wine.git/?a=commit;h=848f8c41c0e7917c39880081f68c599511c612b5
Author: Eric Pouech <eric.pouech at wanadoo.fr>
Date: Fri Nov 24 22:17:26 2006 +0100
dbghelp: Pass .debug_loc section info from the ELF loader to the dwarf parser.
---
dlls/dbghelp/dbghelp_private.h | 4 +++-
dlls/dbghelp/dwarf.c | 24 +++++++++++++++++++++++-
dlls/dbghelp/elf_module.c | 17 +++++++++++++----
dlls/dbghelp/module.c | 1 +
4 files changed, 40 insertions(+), 6 deletions(-)
diff --git a/dlls/dbghelp/dbghelp_private.h b/dlls/dbghelp/dbghelp_private.h
index 5eae51a..c2082e5 100644
--- a/dlls/dbghelp/dbghelp_private.h
+++ b/dlls/dbghelp/dbghelp_private.h
@@ -281,6 +281,7 @@ struct module
enum module_type type : 16;
unsigned short is_virtual : 1;
struct elf_module_info* elf_info;
+ struct dwarf2_module_info_s*dwarf2_info;
/* memory allocation pool */
struct pool pool;
@@ -441,7 +442,8 @@ extern BOOL dwarf2_parse(struct
const unsigned char* debug, unsigned int debug_size,
const unsigned char* abbrev, unsigned int abbrev_size,
const unsigned char* str, unsigned int str_size,
- const unsigned char* line, unsigned int line_size);
+ const unsigned char* line, unsigned int line_size,
+ const unsigned char* loclist, unsigned int loclist_size);
/* symbol.c */
extern const char* symt_get_name(const struct symt* sym);
diff --git a/dlls/dbghelp/dwarf.c b/dlls/dbghelp/dwarf.c
index 9c08bb5..8dbe200 100644
--- a/dlls/dbghelp/dwarf.c
+++ b/dlls/dbghelp/dwarf.c
@@ -179,6 +179,12 @@ typedef struct dwarf2_parse_context_s
unsigned char word_size;
} dwarf2_parse_context_t;
+/* stored in the dbghelp's module internal structure for later reuse */
+struct dwarf2_module_info_s
+{
+ dwarf2_section_t debug_loc;
+};
+
/* forward declarations */
static struct symt* dwarf2_parse_enumeration_type(dwarf2_parse_context_t* ctx, dwarf2_debug_info_t* entry);
@@ -1846,9 +1852,11 @@ BOOL dwarf2_parse(struct module* module,
const unsigned char* debug, unsigned int debug_size,
const unsigned char* abbrev, unsigned int abbrev_size,
const unsigned char* str, unsigned int str_size,
- const unsigned char* line, unsigned int line_size)
+ const unsigned char* line, unsigned int line_size,
+ const unsigned char* loclist, unsigned int loclist_size)
{
dwarf2_section_t section[section_max];
+ char* ptr;
const unsigned char*comp_unit_cursor = debug;
const unsigned char*end_debug = debug + debug_size;
@@ -1861,6 +1869,20 @@ BOOL dwarf2_parse(struct module* module,
section[section_line].address = line;
section[section_line].size = line_size;
+ if (loclist_size)
+ {
+ /* initialize the dwarf2 specific info block for this module.
+ * As we'll need later on the .debug_loc section content, we copy it in
+ * the module structure for later reuse
+ */
+ module->dwarf2_info = HeapAlloc(GetProcessHeap(), 0, sizeof(*module->dwarf2_info) + loclist_size);
+ if (!module->dwarf2_info) return FALSE;
+ ptr = (char*)(module->dwarf2_info + 1);
+ memcpy(ptr, loclist, loclist_size);
+ module->dwarf2_info->debug_loc.address = ptr;
+ module->dwarf2_info->debug_loc.size = loclist_size;
+ }
+
while (comp_unit_cursor < end_debug)
{
const dwarf2_comp_unit_stream_t* comp_unit_stream;
diff --git a/dlls/dbghelp/elf_module.c b/dlls/dbghelp/elf_module.c
index a9a3bf3..2920ace 100644
--- a/dlls/dbghelp/elf_module.c
+++ b/dlls/dbghelp/elf_module.c
@@ -794,7 +794,8 @@ static BOOL elf_load_debug_info_from_map
const char* shstrtab;
int i;
int symtab_sect, dynsym_sect, stab_sect, stabstr_sect;
- int debug_sect, debug_str_sect, debug_abbrev_sect, debug_line_sect;
+ int debug_sect, debug_str_sect, debug_abbrev_sect;
+ int debug_line_sect, debug_loclist_sect;
int debuglink_sect;
struct elf_thunk_area thunks[] =
{
@@ -824,7 +825,8 @@ static BOOL elf_load_debug_info_from_map
if (shstrtab == ELF_NO_MAP) return FALSE;
symtab_sect = dynsym_sect = stab_sect = stabstr_sect = -1;
- debug_sect = debug_str_sect = debug_abbrev_sect = debug_line_sect = -1;
+ debug_sect = debug_str_sect = debug_abbrev_sect = -1;
+ debug_line_sect = debug_loclist_sect = -1;
debuglink_sect = -1;
for (i = 0; i < fmap->elfhdr.e_shnum; i++)
@@ -841,6 +843,8 @@ static BOOL elf_load_debug_info_from_map
debug_abbrev_sect = i;
if (strcmp(shstrtab + fmap->sect[i].shdr.sh_name, ".debug_line") == 0)
debug_line_sect = i;
+ if (strcmp(shstrtab + fmap->sect[i].shdr.sh_name, ".debug_loc") == 0)
+ debug_loclist_sect = i;
if (strcmp(shstrtab + fmap->sect[i].shdr.sh_name, ".gnu_debuglink") == 0)
debuglink_sect = i;
if ((strcmp(shstrtab + fmap->sect[i].shdr.sh_name, ".symtab") == 0) &&
@@ -902,6 +906,7 @@ static BOOL elf_load_debug_info_from_map
const BYTE* dw2_debug_abbrev;
const BYTE* dw2_debug_str;
const BYTE* dw2_debug_line;
+ const BYTE* dw2_debug_loclist;
FIXME("Alpha-support for Dwarf2 information for %s\n", module->module.ModuleName);
@@ -909,14 +914,17 @@ static BOOL elf_load_debug_info_from_map
dw2_debug_abbrev = (const BYTE*) elf_map_section(fmap, debug_abbrev_sect);
dw2_debug_str = (const BYTE*) elf_map_section(fmap, debug_str_sect);
dw2_debug_line = (const BYTE*) elf_map_section(fmap, debug_line_sect);
- if (dw2_debug != ELF_NO_MAP && ELF_NO_MAP != dw2_debug_abbrev && dw2_debug_str != ELF_NO_MAP)
+ dw2_debug_loclist = (const BYTE*) elf_map_section(fmap, debug_loclist_sect);
+ if (dw2_debug != ELF_NO_MAP && dw2_debug_abbrev != ELF_NO_MAP && dw2_debug_str != ELF_NO_MAP)
{
/* OK, now just parse dwarf2 debug infos. */
lret = dwarf2_parse(module, module->elf_info->elf_addr, thunks,
dw2_debug, elf_get_map_size(fmap, debug_sect),
dw2_debug_abbrev, elf_get_map_size(fmap, debug_abbrev_sect),
dw2_debug_str, elf_get_map_size(fmap, debug_str_sect),
- dw2_debug_line, elf_get_map_size(fmap, debug_line_sect));
+ dw2_debug_line, elf_get_map_size(fmap, debug_line_sect),
+ dw2_debug_loclist, elf_get_map_size(fmap, debug_loclist_sect));
+
if (!lret)
WARN("Couldn't correctly read stabs\n");
ret = ret || lret;
@@ -925,6 +933,7 @@ static BOOL elf_load_debug_info_from_map
elf_unmap_section(fmap, debug_abbrev_sect);
elf_unmap_section(fmap, debug_str_sect);
elf_unmap_section(fmap, debug_line_sect);
+ elf_unmap_section(fmap, debug_loclist_sect);
}
if (debuglink_sect != -1)
{
diff --git a/dlls/dbghelp/module.c b/dlls/dbghelp/module.c
index eecf66b..25baec1 100644
--- a/dlls/dbghelp/module.c
+++ b/dlls/dbghelp/module.c
@@ -532,6 +532,7 @@ BOOL module_remove(struct process* pcs,
hash_table_destroy(&module->ht_types);
HeapFree(GetProcessHeap(), 0, (char*)module->sources);
HeapFree(GetProcessHeap(), 0, module->addr_sorttab);
+ HeapFree(GetProcessHeap(), 0, module->dwarf2_info);
pool_destroy(&module->pool);
/* native dbghelp doesn't invoke registered callback(,CBA_SYMBOLS_UNLOADED,) here
* so do we
More information about the wine-cvs
mailing list