23#ifndef DBGHELP_STATIC_LIB
25#define NONAMELESSUNION
71 static const char hexof[] =
"0123456789abcdef";
74 for (
i = 0;
i <
len;
i += 16)
80 msg[10 + 3 *
j + 0] = hexof[
x[
i +
j] >> 4];
81 msg[10 + 3 *
j + 1] = hexof[
x[
i +
j] & 15];
82 msg[10 + 3 *
j + 2] =
' ';
83 msg[10 + 3 * 16 + 1 +
j] = (
x[
i +
j] >= 0x20 &&
x[
i +
j] < 0x7f) ?
86 msg[10 + 3 * 16] =
' ';
87 msg[10 + 3 * 16 + 1 + 16] =
'\0';
205#define loc_dwarf2_location_list (loc_user + 0)
206#define loc_dwarf2_block (loc_user + 1)
270 }
while (
byte & 0x80);
292 const unsigned size =
sizeof(
int) * 8;
299 }
while (
byte & 0x80);
349 FIXME(
"Unsupported Word Size %u\n", word_size);
358 ctx->data +=
ctx->word_size;
400 TRACE(
"%s, end at %p\n",
408 TRACE(
"found entry_code %lu\n", entry_code);
423 TRACE(
"table:(%p,#%u) entry_code(%lu) tag(0x%lx) have_child(%u) -> %p\n",
425 entry_code, abbrev_entry->
tag, abbrev_entry->
have_child, abbrev_entry);
440 if (abbrev_entry->
attrs)
last->next =
new;
441 else abbrev_entry->
attrs =
new;
456 switch (abbrev_attr->
form)
480 FIXME(
"Unhandled attribute form %lx\n", abbrev_attr->
form);
488 const unsigned char*
data,
497 ctx->module->format_info[
DFI_DWARF]->u.dwarf2_info->word_size);
508 TRACE(
"flag_present\n");
547 FIXME(
"Unhandled 64-bit support\n");
563 attr->u.string = (
const char *)
data;
595 FIXME(
"Unhandled attribute form %lx\n", abbrev_attr->
form);
604 unsigned i, refidx = 0;
608 attr->gotten_from = attr_direct;
611 ref_abbrev_attr =
NULL;
612 for (
i = 0, abbrev_attr = di->
abbrev->
attrs; abbrev_attr;
i++, abbrev_attr = abbrev_attr->
next)
625 ref_abbrev_attr = abbrev_attr;
628 attr_abstract_origin : attr_specification;
632 if (!ref_abbrev_attr)
break;
635 FIXME(
"Should have found the debug info entry\n");
642#define Wine_DW_no_register 0x7FFFFFFF
648 FIXME(
"What the heck map reg 0x%x\n",regno);
668 while (
ctx->data <
ctx->end_data)
684 FIXME(
"Only supporting one reg (%s/%d -> %s/%d)\n",
701 FIXME(
"Only supporting one breg (%s/%d -> %s/%d)\n",
753 if (!
stack[stk--])
ctx->data += tmp;
760 FIXME(
"Only supporting one reg\n");
768 FIXME(
"Only supporting one regx\n");
775 FIXME(
"Only supporting one reg (%s/%d -> -2)\n",
801 WARN(
"Not handling OP_piece (size=%d)\n", sz);
808 FIXME(
"Unexpected empty stack\n");
813 WARN(
"Too complex expression for deref\n");
823 WARN(
"Couldn't read memory at %lx\n",
addr);
826 stack[++stk] = deref;
836 FIXME(
"Unexpected empty stack\n");
841 WARN(
"Too complex expression for deref\n");
852 WARN(
"Couldn't read memory at %lx\n",
addr);
858 case 1:
stack[++stk] = *(
unsigned char*)&deref;
break;
859 case 2:
stack[++stk] = *(
unsigned short*)&deref;
break;
860 case 4:
stack[++stk] = *(
DWORD*)&deref;
break;
861 case 8:
if (
ctx->word_size >= derefsize)
stack[++stk] = deref;
break;
876 FIXME(
"Unhandled attr op: %x\n",
op);
913 default:
FIXME(
"Unsupported yet form %lx\n", xloc.
form);
937 sizeof(
unsigned) + xloc.
u.
block.size);
957 FIXME(
"Unable to find back reference to type %lx\n",
attr.u.uvalue);
965 FIXME(
"Unable to load forward reference for tag %lx\n",
type->abbrev->tag);
990 FIXME(
"Should have found the debug info entry\n");
1008 if (last < ctx->cpp_name)
return NULL;
1048 if (low == 0 && high == 0)
break;
1049 if (low ==
ULONG_MAX)
FIXME(
"unsupported yet (base address selection)\n");
1050 if (low < *plow) *plow = low;
1051 if (high > *phigh) *phigh = high;
1054 if (*plow == *phigh) {
FIXME(
"entry found, but low=high\n");
return FALSE;}
1094 TRACE(
"found entry_code %lu at 0x%lx\n", entry_code,
offset);
1103 WARN(
"Cannot find abbrev entry for %lu at 0x%lx\n", entry_code,
offset);
1107 if (!di)
return FALSE;
1130 if (!where)
return FALSE;
1137 WARN(
"setting cursor for %s to next sibling <0x%lx>\n",
1156 FIXME(
"Should have found the debug info entry\n");
1199 switch (
size.u.uvalue)
1201 case 1: cache_idx =
sc_int1;
break;
1202 case 2: cache_idx =
sc_int2;
break;
1203 case 4: cache_idx =
sc_int4;
break;
1208 if (cache_idx != -1 && !
ctx->symt_cache[cache_idx])
1209 ctx->symt_cache[cache_idx] = di->
symt;
1218 struct symt* ref_type;
1237 struct symt* ref_type;
1258 struct symt* ref_type;
1263 const struct vector* children;
1282 switch (
child->abbrev->tag)
1294 FIXME(
"Unhandled Tag type 0x%lx at %s, for %s\n",
1306 struct symt* ref_type;
1318 di->
symt = ref_type;
1326 struct symt* ref_type;
1338 di->
symt = ref_type;
1355 name.u.string =
"void";
1356 size.u.uvalue =
sizeof(
void *);
1390 struct symt* elt_type;
1406 FIXME(
"Found register, while not expecting it\n");
1410 TRACE(
"found member_location at %s -> %lu\n",
1458 name.u.string =
"zz_anon_zz";
1462 size.u.uvalue, udt)->symt;
1469 switch (
child->abbrev->tag)
1503 FIXME(
"Unhandled Tag type 0x%lx at %s, for %s\n",
1545 switch (
size.u.uvalue)
1561 switch (
child->abbrev->tag)
1567 FIXME(
"Unhandled Tag type 0x%lx at %s, for %s\n",
1592 struct symt* param_type;
1607 &loc, &subpgm->
frame))
1611 TRACE(
"found parameter %s (kind=%d, offset=%ld, reg=%d) at %s\n",
1627 loc, 0, param_type);
1640 &loc,
block, param_type,
name.u.string);
1648 if (is_pmt)
FIXME(
"Unsupported constant (parameter) %s in function\n",
debugstr_a(
name.u.string));
1657 v.n1.n2.n3.lVal =
value.u.uvalue;
1662 v.n1.n2.n3.llVal =
value.u.lluvalue;
1667 v.n1.n2.n3.lVal =
value.u.svalue;
1684 switch (
value.u.block.size)
1686 case 1:
v.n1.n2.n3.lVal = *(
BYTE*)
value.u.block.ptr;
break;
1687 case 2:
v.n1.n2.n3.lVal = *(
USHORT*)
value.u.block.ptr;
break;
1688 case 4:
v.n1.n2.n3.lVal = *(
DWORD*)
value.u.block.ptr;
break;
1697 FIXME(
"Unsupported form for const value %s (%lx)\n",
1702 name.u.string, param_type, &
v)->symt;
1713 &loc,
block, param_type,
name.u.string);
1717 WARN(
"dropping global variable %s which has been optimized away\n",
debugstr_a(
name.u.string));
1720 if (is_pmt && subpgm->
func && subpgm->
func->type)
1744 &loc,
name.u.string);
1768 FIXME(
"cannot read range\n");
1781 switch (
child->abbrev->tag)
1800 FIXME(
"Unhandled Tag type 0x%lx at %s, for %s\n",
1835 switch (
child->abbrev->tag)
1882 FIXME(
"Unhandled Tag type 0x%lx at %s, for %s\n",
1897 struct symt* ret_type;
1910 WARN(
"No name for function... dropping function\n");
1919 TRACE(
"Function %s declared as inlined (%ld)... skipping\n",
1952 ctx->load_offset + low_pc, high_pc - low_pc,
1962 subpgm.
frame.offset = 0;
1971 switch (
child->abbrev->tag)
2013 FIXME(
"Unhandled Tag type 0x%lx at %s, for %s\n",
2031 struct symt* ret_type;
2055 switch (
child->abbrev->tag)
2062 WARN(
"Unsupported unspecified parameters\n");
2077 if (di->
symt)
return;
2145 subpgm.
frame.offset = 0;
2159 FIXME(
"Unhandled Tag type 0x%lx at %s, for %lu\n",
2173 TRACE(
"%s %lx %s %u\n",
2183 const char* compile_dir,
2188 unsigned insn_size, default_stmt;
2189 unsigned line_range, opcode_base;
2191 const unsigned char* opcode_len;
2202 WARN(
"out of bounds offset\n");
2214 WARN(
"out of bounds header\n");
2225 opcode_len = traverse.
data;
2226 traverse.
data += opcode_base - 1;
2230 *
p = compile_dir ? compile_dir :
".";
2231 while (*traverse.
data)
2233 const char* rel = (
const char*)traverse.
data;
2234 unsigned rellen =
strlen(rel);
2236 traverse.
data += rellen + 1;
2239 if (*rel ==
'/' || !compile_dir)
2244 unsigned baselen =
strlen(compile_dir);
2245 char* tmp =
pool_alloc(&
ctx->pool, baselen + 1 + rellen + 1);
2246 strcpy(tmp, compile_dir);
2247 if (tmp[baselen - 1] !=
'/') tmp[baselen++] =
'/';
2248 strcpy(&tmp[baselen], rel);
2256 while (*traverse.
data)
2258 unsigned int dir_index, mod_time;
2280 unsigned is_stmt = default_stmt;
2282 unsigned opcode, extopcode,
i;
2284 while (!end_sequence)
2287 TRACE(
"Got opcode %x\n", opcode);
2289 if (opcode >= opcode_base)
2291 unsigned delta = opcode - opcode_base;
2293 address += (delta / line_range) * insn_size;
2294 line += line_base + (delta % line_range);
2322 address += ((255 - opcode_base) / line_range) * insn_size;
2334 end_sequence =
TRUE;
2351 WARN(
"not handled discriminator %x\n",
descr);
2355 FIXME(
"Unsupported extended opcode %x\n", extopcode);
2360 WARN(
"Unsupported opcode %x\n", opcode);
2361 for (
i = 0;
i < opcode_len[opcode];
i++)
2381 const unsigned char* comp_unit_start = mod_ctx->
data;
2383 unsigned short cu_version;
2390 mod_ctx->
data += cu_length;
2395 TRACE(
"Compilation Unit Header found at 0x%x:\n",
2397 TRACE(
"- length: %lu\n", cu_length);
2398 TRACE(
"- version: %u\n", cu_version);
2399 TRACE(
"- abbrev_offset: %lu\n", cu_abbrev_offset);
2402 if (cu_version != 2)
2404 WARN(
"%u DWARF version unsupported. Wine dbghelp only support DWARF 2.\n",
2416 ctx.thunks = thunks;
2417 ctx.load_offset = load_offset;
2451 di->
symt = &
ctx.compiland->symt;
2460#if defined(__REACTOS__) && defined(__clang__)
2461 unsigned long stmt_list_val = stmt_list.
u.
uvalue;
2475 else FIXME(
"Should have a compilation unit here\n");
2487 while (ptr < modfmt->
u.dwarf2_info->debug_loc.address + modfmt->
u.
dwarf2_info->debug_loc.size)
2491 if (!beg && !
end)
break;
2503 WARN(
"Couldn't find ip in location list\n");
2526 switch (pframe->
kind)
2541 WARN(
"Couldn't compute runtime frame location\n");
2546 WARN(
"Unsupported frame kind %d\n", pframe->
kind);
2552 WARN(
"Couldn't find Custom function point, whilst location list offset is searched\n");
2568#define NB_FRAME_REGS 64
2569#define MAX_SAVED_STATES 16
2643 const char* augmentation;
2644 const unsigned char*
end;
2649 info->aug_z_format = 0;
2658 augmentation = (
const char*)
ctx->data;
2680 if (*augmentation)
do
2682 switch (*augmentation)
2687 info->aug_z_format = 1;
2704 info->signal_frame = 1;
2707 FIXME(
"unknown augmentation '%c'\n", *augmentation);
2710 }
while (*++augmentation);
2719 const unsigned char* ptr_blk;
2720 const unsigned char* cie_ptr;
2721 const unsigned char* last_cie_ptr = (
const unsigned char*)~0;
2741 if (
len == 0xffffffff)
FIXME(
"Unsupported yet 64-bit CIEs\n");
2742 ptr_blk = fde_ctx->
data +
len;
2746 last_cie_ptr = fde_ctx->
data - 8;
2754 cie_ptr = (in_eh_frame) ? fde_ctx->
data -
id - 4 :
start_data +
id;
2755 if (cie_ptr != last_cie_ptr)
2757 last_cie_ptr = cie_ptr;
2758 cie_ctx->
data = cie_ptr;
2764 FIXME(
"wrong CIE pointer at %x from FDE %x\n",
2795 while (
ctx->data <
ctx->end_data &&
info->ip <= last_ip +
info->signal_frame)
2815 TRACE(
"%lx: DW_CFA_offset %s, %ld\n",
2827 TRACE(
"%lx: DW_CFA_restore %s\n",
2842 TRACE(
"%lx: DW_CFA_set_loc %lx\n",
info->ip, loc);
2874 TRACE(
"%lx: DW_CFA_offset_extended %s, %ld\n",
2886 TRACE(
"%lx: DW_CFA_restore_extended %s\n",
2896 TRACE(
"%lx: DW_CFA_undefined %s\n",
2906 TRACE(
"%lx: DW_CFA_same_value %s\n",
2918 TRACE(
"%lx: DW_CFA_register %s == %s\n",
2927 TRACE(
"%lx: DW_CFA_remember_state\n",
info->ip);
2929 FIXME(
"%lx: DW_CFA_remember_state too many nested saves\n",
info->ip);
2934 TRACE(
"%lx: DW_CFA_restore_state\n",
info->ip);
2935 if (!
info->state_sp)
2936 FIXME(
"%lx: DW_CFA_restore_state without corresponding save\n",
info->ip);
2947 TRACE(
"%lx: DW_CFA_def_cfa %s, %ld\n",
2960 TRACE(
"%lx: DW_CFA_def_cfa_register %s\n",
2994 TRACE(
"%lx: DW_CFA_%sexpression %s %lx-%lx\n",
3012 FIXME(
"%lx: unknown CFA opcode %02x\n",
info->ip,
op);
3022 unsigned regno = csw->
cpu->map_dwarf_register(dw_reg,
module,
TRUE), sz;
3023 void*
ptr = csw->
cpu->fetch_context_reg(
context, regno, &sz);
3030 FIXME(
"unhandled size %d\n", sz);
3038 unsigned regno = csw->
cpu->map_dwarf_register(dw_reg,
module,
TRUE), sz;
3045 if (sz >
sizeof(tmp))
3047 FIXME(
"register %lu/%u size is too wide: %u\n", dw_reg, regno, sz);
3052 WARN(
"Couldn't read memory at %p\n", (
void*)
val);
3061 FIXME(
"assigning to register %lu/%u of wrong size %u\n", dw_reg, regno, sz);
3073 unsigned regdstno = csw->
cpu->map_dwarf_register(dwregdst,
module,
TRUE), szdst;
3074 unsigned regsrcno = csw->
cpu->map_dwarf_register(dwregsrc,
module,
TRUE), szsrc;
3075 ULONG_PTR* ptrdst = csw->
cpu->fetch_context_reg(dstcontext, regdstno, &szdst);
3076 ULONG_PTR* ptrsrc = csw->
cpu->fetch_context_reg(srccontext, regsrcno, &szsrc);
3080 FIXME(
"Cannot copy register %lu/%u => %lu/%u because of size mismatch (%u => %u)\n",
3081 dwregsrc, regsrcno, dwregdst, regdstno, szsrc, szdst);
3084 memcpy(ptrdst, ptrsrc, szdst);
3097 ctx.end_data = zp + 4;
3102 while (
ctx.data <
ctx.end_data)
3113 else switch (opcode)
3187 case 1:
stack[
sp] = *(
unsigned char*)&tmp;
break;
3188 case 2:
stack[
sp] = *(
unsigned short*)&tmp;
break;
3189 case 4:
stack[
sp] = *(
unsigned int*)&tmp;
break;
3191 default:
FIXME(
"Unknown size for deref 0x%lx\n", sz);
3195 FIXME(
"unhandled opcode %02x\n", opcode);
3208 switch (
state->cfa_rule)
3265 const unsigned char*
end;
3273 if (!modfmt)
return FALSE;
3275 fde_ctx.data = modfmt->
u.
dwarf2_info->eh_frame.address;
3276 fde_ctx.end_data = fde_ctx.data + modfmt->
u.
dwarf2_info->eh_frame.size;
3282 delta =
pair.effective->module.BaseOfImage + modfmt->
u.
dwarf2_info->eh_frame.rva -
3286 fde_ctx.data = modfmt->
u.
dwarf2_info->debug_frame.address;
3287 fde_ctx.end_data = fde_ctx.data + modfmt->
u.
dwarf2_info->debug_frame.size;
3289 delta =
pair.effective->reloc_delta;
3292 TRACE(
"Couldn't find information for %lx\n",
ip);
3297 TRACE(
"function %lx/%lx code_align %lu data_align %ld retaddr %s\n",
3299 csw->
cpu->fetch_regname(csw->
cpu->map_dwarf_register(
info.retaddr_reg,
pair.effective,
TRUE)));
3305 if (
info.aug_z_format)
3308 end = fde_ctx.data +
len;
3312 if (
end) fde_ctx.data =
end;
3336 WARN(
"We'd expect function %s's container to exist and be a compiland\n",
debugstr_a(
func->hash_elt.name));
3374 WARN(
"Unsupported local kind %d\n", loc->
kind);
3397 const char* zsectname,
3408 if (sz <= 12 ||
memcmp(sect,
"ZLIB", 4))
3410 ERR(
"invalid compressed section %s\n",
debugstr_a(zsectname));
3414#ifdef WORDS_BIGENDIAN
3426 z.next_in = §[12];
3427 z.avail_in = sz - 12;
3440 z.next_out =
addr +
z.total_out;
3468 const char* sectname,
const char* zsectname,
3473 if (!ism) ism = &local_ism;
3516 debug_line_sect, debug_ranges_sect, eh_frame_sect;
3543 load_offset += fmap->
u.
elf.elf_start - debug_sect.
fmap->u.elf.elf_start;
3553 sizeof(*dwarf2_modfmt) +
sizeof(*dwarf2_modfmt->
u.
dwarf2_info));
3578 dwarf2_modfmt->
module->module.CVSig =
'D' | (
'W' << 8) | (
'A' << 16) | (
'R' << 24);
3580 dwarf2_modfmt->
module->module.GlobalSymbols =
TRUE;
3581 dwarf2_modfmt->
module->module.TypeInfo =
TRUE;
3582 dwarf2_modfmt->
module->module.SourceIndexed =
TRUE;
3583 dwarf2_modfmt->
module->module.Publics =
TRUE;