Commit 848f8c41 authored by Eric Pouech's avatar Eric Pouech Committed by Alexandre Julliard

dbghelp: Pass .debug_loc section info from the ELF loader to the dwarf parser.

parent 1a723f23
...@@ -281,6 +281,7 @@ struct module ...@@ -281,6 +281,7 @@ struct module
enum module_type type : 16; enum module_type type : 16;
unsigned short is_virtual : 1; unsigned short is_virtual : 1;
struct elf_module_info* elf_info; struct elf_module_info* elf_info;
struct dwarf2_module_info_s*dwarf2_info;
/* memory allocation pool */ /* memory allocation pool */
struct pool pool; struct pool pool;
...@@ -441,7 +442,8 @@ extern BOOL dwarf2_parse(struct module* module, unsigned long load_offse ...@@ -441,7 +442,8 @@ extern BOOL dwarf2_parse(struct module* module, unsigned long load_offse
const unsigned char* debug, unsigned int debug_size, const unsigned char* debug, unsigned int debug_size,
const unsigned char* abbrev, unsigned int abbrev_size, const unsigned char* abbrev, unsigned int abbrev_size,
const unsigned char* str, unsigned int str_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 */ /* symbol.c */
extern const char* symt_get_name(const struct symt* sym); extern const char* symt_get_name(const struct symt* sym);
......
...@@ -179,6 +179,12 @@ typedef struct dwarf2_parse_context_s ...@@ -179,6 +179,12 @@ typedef struct dwarf2_parse_context_s
unsigned char word_size; unsigned char word_size;
} dwarf2_parse_context_t; } 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 */ /* forward declarations */
static struct symt* dwarf2_parse_enumeration_type(dwarf2_parse_context_t* ctx, dwarf2_debug_info_t* entry); 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, unsigned long load_offset, ...@@ -1846,9 +1852,11 @@ BOOL dwarf2_parse(struct module* module, unsigned long load_offset,
const unsigned char* debug, unsigned int debug_size, const unsigned char* debug, unsigned int debug_size,
const unsigned char* abbrev, unsigned int abbrev_size, const unsigned char* abbrev, unsigned int abbrev_size,
const unsigned char* str, unsigned int str_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]; dwarf2_section_t section[section_max];
char* ptr;
const unsigned char*comp_unit_cursor = debug; const unsigned char*comp_unit_cursor = debug;
const unsigned char*end_debug = debug + debug_size; const unsigned char*end_debug = debug + debug_size;
...@@ -1861,6 +1869,20 @@ BOOL dwarf2_parse(struct module* module, unsigned long load_offset, ...@@ -1861,6 +1869,20 @@ BOOL dwarf2_parse(struct module* module, unsigned long load_offset,
section[section_line].address = line; section[section_line].address = line;
section[section_line].size = line_size; 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) while (comp_unit_cursor < end_debug)
{ {
const dwarf2_comp_unit_stream_t* comp_unit_stream; const dwarf2_comp_unit_stream_t* comp_unit_stream;
......
...@@ -794,7 +794,8 @@ static BOOL elf_load_debug_info_from_map(struct module* module, ...@@ -794,7 +794,8 @@ static BOOL elf_load_debug_info_from_map(struct module* module,
const char* shstrtab; const char* shstrtab;
int i; int i;
int symtab_sect, dynsym_sect, stab_sect, stabstr_sect; 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; int debuglink_sect;
struct elf_thunk_area thunks[] = struct elf_thunk_area thunks[] =
{ {
...@@ -824,7 +825,8 @@ static BOOL elf_load_debug_info_from_map(struct module* module, ...@@ -824,7 +825,8 @@ static BOOL elf_load_debug_info_from_map(struct module* module,
if (shstrtab == ELF_NO_MAP) return FALSE; if (shstrtab == ELF_NO_MAP) return FALSE;
symtab_sect = dynsym_sect = stab_sect = stabstr_sect = -1; 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; debuglink_sect = -1;
for (i = 0; i < fmap->elfhdr.e_shnum; i++) for (i = 0; i < fmap->elfhdr.e_shnum; i++)
...@@ -841,6 +843,8 @@ static BOOL elf_load_debug_info_from_map(struct module* module, ...@@ -841,6 +843,8 @@ static BOOL elf_load_debug_info_from_map(struct module* module,
debug_abbrev_sect = i; debug_abbrev_sect = i;
if (strcmp(shstrtab + fmap->sect[i].shdr.sh_name, ".debug_line") == 0) if (strcmp(shstrtab + fmap->sect[i].shdr.sh_name, ".debug_line") == 0)
debug_line_sect = i; 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) if (strcmp(shstrtab + fmap->sect[i].shdr.sh_name, ".gnu_debuglink") == 0)
debuglink_sect = i; debuglink_sect = i;
if ((strcmp(shstrtab + fmap->sect[i].shdr.sh_name, ".symtab") == 0) && if ((strcmp(shstrtab + fmap->sect[i].shdr.sh_name, ".symtab") == 0) &&
...@@ -902,6 +906,7 @@ static BOOL elf_load_debug_info_from_map(struct module* module, ...@@ -902,6 +906,7 @@ static BOOL elf_load_debug_info_from_map(struct module* module,
const BYTE* dw2_debug_abbrev; const BYTE* dw2_debug_abbrev;
const BYTE* dw2_debug_str; const BYTE* dw2_debug_str;
const BYTE* dw2_debug_line; const BYTE* dw2_debug_line;
const BYTE* dw2_debug_loclist;
FIXME("Alpha-support for Dwarf2 information for %s\n", module->module.ModuleName); FIXME("Alpha-support for Dwarf2 information for %s\n", module->module.ModuleName);
...@@ -909,14 +914,17 @@ static BOOL elf_load_debug_info_from_map(struct module* module, ...@@ -909,14 +914,17 @@ static BOOL elf_load_debug_info_from_map(struct module* module,
dw2_debug_abbrev = (const BYTE*) elf_map_section(fmap, debug_abbrev_sect); 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_str = (const BYTE*) elf_map_section(fmap, debug_str_sect);
dw2_debug_line = (const BYTE*) elf_map_section(fmap, debug_line_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. */ /* OK, now just parse dwarf2 debug infos. */
lret = dwarf2_parse(module, module->elf_info->elf_addr, thunks, lret = dwarf2_parse(module, module->elf_info->elf_addr, thunks,
dw2_debug, elf_get_map_size(fmap, debug_sect), dw2_debug, elf_get_map_size(fmap, debug_sect),
dw2_debug_abbrev, elf_get_map_size(fmap, debug_abbrev_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_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) if (!lret)
WARN("Couldn't correctly read stabs\n"); WARN("Couldn't correctly read stabs\n");
ret = ret || lret; ret = ret || lret;
...@@ -925,6 +933,7 @@ static BOOL elf_load_debug_info_from_map(struct module* module, ...@@ -925,6 +933,7 @@ static BOOL elf_load_debug_info_from_map(struct module* module,
elf_unmap_section(fmap, debug_abbrev_sect); elf_unmap_section(fmap, debug_abbrev_sect);
elf_unmap_section(fmap, debug_str_sect); elf_unmap_section(fmap, debug_str_sect);
elf_unmap_section(fmap, debug_line_sect); elf_unmap_section(fmap, debug_line_sect);
elf_unmap_section(fmap, debug_loclist_sect);
} }
if (debuglink_sect != -1) if (debuglink_sect != -1)
{ {
......
...@@ -532,6 +532,7 @@ BOOL module_remove(struct process* pcs, struct module* module) ...@@ -532,6 +532,7 @@ BOOL module_remove(struct process* pcs, struct module* module)
hash_table_destroy(&module->ht_types); hash_table_destroy(&module->ht_types);
HeapFree(GetProcessHeap(), 0, (char*)module->sources); HeapFree(GetProcessHeap(), 0, (char*)module->sources);
HeapFree(GetProcessHeap(), 0, module->addr_sorttab); HeapFree(GetProcessHeap(), 0, module->addr_sorttab);
HeapFree(GetProcessHeap(), 0, module->dwarf2_info);
pool_destroy(&module->pool); pool_destroy(&module->pool);
/* native dbghelp doesn't invoke registered callback(,CBA_SYMBOLS_UNLOADED,) here /* native dbghelp doesn't invoke registered callback(,CBA_SYMBOLS_UNLOADED,) here
* so do we * so do we
......
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