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

- fixed some bugs in StackWalk (claimed for but forgotten in last

patch) - removed location field in symt_data, and reworked the actual location of information based on the 'kind' field - shorten debug channel name - added support for bitfield in struct:s - cleaned up source line information support - now storing constants values as VARIANT
parent c5524e1e
...@@ -132,18 +132,16 @@ struct symt_data ...@@ -132,18 +132,16 @@ struct symt_data
enum DataKind kind; enum DataKind kind;
struct symt* container; struct symt* container;
struct symt* type; struct symt* type;
enum LocationType location; union /* depends on kind */
union /* depends on location */
{ {
unsigned long address; /* used by Static, Tls, ThisRel */ unsigned long address; /* DataIs{Global, FileStatic} */
int offset; /* used by RegRel */
unsigned reg_id; /* used by Enregistered */
struct struct
{ {
unsigned position; long offset; /* DataIs{Member,Local,Param} in bits*/
unsigned length; unsigned long length; /* DataIs{Member} in bits */
} bitfield; /* used by BitField */ unsigned long reg_id; /* DataIs{Local} (0 if frame relative) */
VARIANT value; /* LocIsConstant */ } s;
VARIANT value; /* DataIsConstant */
} u; } u;
}; };
......
...@@ -70,14 +70,12 @@ static const char* wine_dbgstr_addr(const ADDRESS* addr) ...@@ -70,14 +70,12 @@ static const char* wine_dbgstr_addr(const ADDRESS* addr)
* StackWalk (DBGHELP.@) * StackWalk (DBGHELP.@)
*/ */
BOOL WINAPI StackWalk(DWORD MachineType, HANDLE hProcess, HANDLE hThread, BOOL WINAPI StackWalk(DWORD MachineType, HANDLE hProcess, HANDLE hThread,
LPSTACKFRAME frame, LPVOID _ctx, LPSTACKFRAME frame, LPVOID ctx,
PREAD_PROCESS_MEMORY_ROUTINE f_read_mem, PREAD_PROCESS_MEMORY_ROUTINE f_read_mem,
PFUNCTION_TABLE_ACCESS_ROUTINE FunctionTableAccessRoutine, PFUNCTION_TABLE_ACCESS_ROUTINE FunctionTableAccessRoutine,
PGET_MODULE_BASE_ROUTINE GetModuleBaseRoutine, PGET_MODULE_BASE_ROUTINE GetModuleBaseRoutine,
PTRANSLATE_ADDRESS_ROUTINE f_xlat_adr) PTRANSLATE_ADDRESS_ROUTINE f_xlat_adr)
{ {
#ifdef __i386__
CONTEXT* ctx = (CONTEXT*)_ctx;
STACK32FRAME frame32; STACK32FRAME frame32;
STACK16FRAME frame16; STACK16FRAME frame16;
char ch; char ch;
...@@ -87,7 +85,7 @@ BOOL WINAPI StackWalk(DWORD MachineType, HANDLE hProcess, HANDLE hThread, ...@@ -87,7 +85,7 @@ BOOL WINAPI StackWalk(DWORD MachineType, HANDLE hProcess, HANDLE hThread,
BOOL do_switch; BOOL do_switch;
TRACE("(%ld, %p, %p, %p, %p, %p, %p, %p, %p)\n", TRACE("(%ld, %p, %p, %p, %p, %p, %p, %p, %p)\n",
MachineType, hProcess, hThread, frame, _ctx, MachineType, hProcess, hThread, frame, ctx,
f_read_mem, FunctionTableAccessRoutine, f_read_mem, FunctionTableAccessRoutine,
GetModuleBaseRoutine, f_xlat_adr); GetModuleBaseRoutine, f_xlat_adr);
...@@ -119,13 +117,6 @@ BOOL WINAPI StackWalk(DWORD MachineType, HANDLE hProcess, HANDLE hThread, ...@@ -119,13 +117,6 @@ BOOL WINAPI StackWalk(DWORD MachineType, HANDLE hProcess, HANDLE hThread,
curr_mode = (frame->AddrPC.Mode == AddrModeFlat) ? curr_mode = (frame->AddrPC.Mode == AddrModeFlat) ?
stm_32bit : stm_16bit; stm_32bit : stm_16bit;
/* Get the current ESP (don't know if this is valid) */
if (ctx)
{
frame->AddrStack.Segment = 0;
frame->AddrStack.Offset = ctx->Esp;
frame->AddrStack.Mode = AddrModeFlat;
}
/* cur_switch holds address of curr_stack's field in TEB in debuggee /* cur_switch holds address of curr_stack's field in TEB in debuggee
* address space * address space
*/ */
...@@ -155,11 +146,6 @@ BOOL WINAPI StackWalk(DWORD MachineType, HANDLE hProcess, HANDLE hThread, ...@@ -155,11 +146,6 @@ BOOL WINAPI StackWalk(DWORD MachineType, HANDLE hProcess, HANDLE hThread,
&ch, sizeof(ch), NULL)) &ch, sizeof(ch), NULL))
curr_switch = 0xFFFFFFFF; curr_switch = 0xFFFFFFFF;
frame->AddrReturn.Mode = frame->AddrStack.Mode = AddrMode1616; frame->AddrReturn.Mode = frame->AddrStack.Mode = AddrMode1616;
/* "pop up" previous BP value */
if (!f_read_mem(hProcess, (void*)frame->AddrFrame.Offset,
&val, sizeof(WORD), NULL))
goto done_err;
frame->AddrFrame.Offset = val;
} }
else else
{ {
...@@ -177,11 +163,10 @@ BOOL WINAPI StackWalk(DWORD MachineType, HANDLE hProcess, HANDLE hThread, ...@@ -177,11 +163,10 @@ BOOL WINAPI StackWalk(DWORD MachineType, HANDLE hProcess, HANDLE hThread,
if (!f_read_mem(hProcess, (void*)curr_switch, &ch, sizeof(ch), NULL)) if (!f_read_mem(hProcess, (void*)curr_switch, &ch, sizeof(ch), NULL))
curr_switch = 0xFFFFFFFF; curr_switch = 0xFFFFFFFF;
frame->AddrReturn.Mode = frame->AddrStack.Mode = AddrModeFlat; frame->AddrReturn.Mode = frame->AddrStack.Mode = AddrModeFlat;
/* "pop up" previous EBP value */
if (!f_read_mem(hProcess, (void*)frame->AddrFrame.Offset,
&frame->AddrFrame.Offset, sizeof(DWORD), NULL))
goto done_err;
} }
/* don't set up AddrStack on first call. Either the caller has set it up, or
* we will get it in the next frame
*/
} }
else else
{ {
...@@ -393,11 +378,4 @@ BOOL WINAPI StackWalk(DWORD MachineType, HANDLE hProcess, HANDLE hThread, ...@@ -393,11 +378,4 @@ BOOL WINAPI StackWalk(DWORD MachineType, HANDLE hProcess, HANDLE hThread,
done_err: done_err:
curr_mode = stm_done; curr_mode = stm_done;
return FALSE; return FALSE;
#else /* __i386__ */
FIXME("(%ld, %p, %p, %p, %p, %p, %p, %p, %p): stub\n",
MachineType, hProcess, hThread, frame, _ctx,
f_read_mem, FunctionTableAccessRoutine,
GetModuleBaseRoutine, f_xlat_adr);
return FALSE;
#endif
} }
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
#include "dbghelp_private.h" #include "dbghelp_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(dbghelp); WINE_DEFAULT_DEBUG_CHANNEL(dbghelp);
WINE_DECLARE_DEBUG_CHANNEL(dbghelp_symtype); WINE_DECLARE_DEBUG_CHANNEL(dbghelp_symt);
static const char* symt_get_tag_str(DWORD tag) static const char* symt_get_tag_str(DWORD tag)
{ {
...@@ -154,7 +154,7 @@ struct symt_udt* symt_new_udt(struct module* module, const char* typename, ...@@ -154,7 +154,7 @@ struct symt_udt* symt_new_udt(struct module* module, const char* typename,
{ {
struct symt_udt* sym; struct symt_udt* sym;
TRACE_(dbghelp_symtype)("Adding udt %s:%s\n", module->module.ModuleName, typename); TRACE_(dbghelp_symt)("Adding udt %s:%s\n", module->module.ModuleName, typename);
if ((sym = pool_alloc(&module->pool, sizeof(*sym)))) if ((sym = pool_alloc(&module->pool, sizeof(*sym))))
{ {
sym->symt.tag = SymTagUDT; sym->symt.tag = SymTagUDT;
...@@ -176,8 +176,8 @@ BOOL symt_set_udt_size(struct module* module, struct symt_udt* udt, unsigned siz ...@@ -176,8 +176,8 @@ BOOL symt_set_udt_size(struct module* module, struct symt_udt* udt, unsigned siz
if (vector_length(&udt->vchildren) != 0) if (vector_length(&udt->vchildren) != 0)
{ {
if (udt->size != size) if (udt->size != size)
FIXME_(dbghelp_symtype)("Changing size for %s from %u to %u\n", FIXME_(dbghelp_symt)("Changing size for %s from %u to %u\n",
udt->hash_elt.name, udt->size, size); udt->hash_elt.name, udt->size, size);
return TRUE; return TRUE;
} }
udt->size = size; udt->size = size;
...@@ -201,7 +201,7 @@ BOOL symt_add_udt_element(struct module* module, struct symt_udt* udt_type, ...@@ -201,7 +201,7 @@ BOOL symt_add_udt_element(struct module* module, struct symt_udt* udt_type,
assert(udt_type->symt.tag == SymTagUDT); assert(udt_type->symt.tag == SymTagUDT);
TRACE_(dbghelp_symtype)("Adding %s to UDT %s\n", name, udt_type->hash_elt.name); TRACE_(dbghelp_symt)("Adding %s to UDT %s\n", name, udt_type->hash_elt.name);
p = NULL; p = NULL;
while ((p = vector_iter_up(&udt_type->vchildren, p))) while ((p = vector_iter_up(&udt_type->vchildren, p)))
{ {
...@@ -221,18 +221,9 @@ BOOL symt_add_udt_element(struct module* module, struct symt_udt* udt_type, ...@@ -221,18 +221,9 @@ BOOL symt_add_udt_element(struct module* module, struct symt_udt* udt_type,
m->kind = DataIsMember; m->kind = DataIsMember;
m->container = &udt_type->symt; m->container = &udt_type->symt;
m->type = elt_type; m->type = elt_type;
if (!(offset & 7) && !(size & 7)) m->u.s.offset = offset;
{ m->u.s.length = ((offset & 7) || (size & 7)) ? size : 0;
m->location = LocIsThisRel; m->u.s.reg_id = 0;
m->u.offset = offset >> 3;
/* we could check that elt_type's size is actually size */
}
else
{
m->location = LocIsBitField;
m->u.bitfield.position = offset;
m->u.bitfield.length = size;
}
p = vector_add(&udt_type->vchildren, &module->pool); p = vector_add(&udt_type->vchildren, &module->pool);
*p = &m->symt; *p = &m->symt;
...@@ -269,7 +260,6 @@ BOOL symt_add_enum_element(struct module* module, struct symt_enum* enum_type, ...@@ -269,7 +260,6 @@ BOOL symt_add_enum_element(struct module* module, struct symt_enum* enum_type,
e->container = &enum_type->symt; e->container = &enum_type->symt;
/* CV defines the underlying type for the enumeration */ /* CV defines the underlying type for the enumeration */
e->type = &symt_new_basic(module, btInt, "int", 4)->symt; e->type = &symt_new_basic(module, btInt, "int", 4)->symt;
e->location = LocIsConstant;
e->u.value.n1.n2.vt = VT_I4; e->u.value.n1.n2.vt = VT_I4;
e->u.value.n1.n2.n3.lVal = value; e->u.value.n1.n2.n3.lVal = value;
...@@ -491,9 +481,11 @@ BOOL symt_get_info(const struct symt* type, IMAGEHLP_SYMBOL_TYPE_INFO req, ...@@ -491,9 +481,11 @@ BOOL symt_get_info(const struct symt* type, IMAGEHLP_SYMBOL_TYPE_INFO req,
break; break;
case TI_GET_BITPOSITION: case TI_GET_BITPOSITION:
if (type->tag != SymTagData || ((struct symt_data*)type)->location != LocIsBitField) if (type->tag != SymTagData ||
((struct symt_data*)type)->kind != DataIsMember ||
((struct symt_data*)type)->u.s.length == 0)
return FALSE; return FALSE;
X(DWORD) = ((struct symt_data*)type)->u.bitfield.position; X(DWORD) = ((struct symt_data*)type)->u.s.offset & 7;
break; break;
case TI_GET_CHILDRENCOUNT: case TI_GET_CHILDRENCOUNT:
...@@ -560,10 +552,10 @@ BOOL symt_get_info(const struct symt* type, IMAGEHLP_SYMBOL_TYPE_INFO req, ...@@ -560,10 +552,10 @@ BOOL symt_get_info(const struct symt* type, IMAGEHLP_SYMBOL_TYPE_INFO req,
X(DWORD) = sizeof(int); /* FIXME: should be size of base-type of enum !!! */ X(DWORD) = sizeof(int); /* FIXME: should be size of base-type of enum !!! */
break; break;
case SymTagData: case SymTagData:
if (((struct symt_data*)type)->location == LocIsBitField) if (((struct symt_data*)type)->kind != DataIsMember ||
X(DWORD) = ((struct symt_data*)type)->u.bitfield.length; !((struct symt_data*)type)->u.s.length)
else
return FALSE; return FALSE;
X(DWORD) = ((struct symt_data*)type)->u.s.length;
break; break;
case SymTagArrayType: case SymTagArrayType:
if (!symt_get_info(((struct symt_array*)type)->basetype, if (!symt_get_info(((struct symt_array*)type)->basetype,
...@@ -622,10 +614,10 @@ BOOL symt_get_info(const struct symt* type, IMAGEHLP_SYMBOL_TYPE_INFO req, ...@@ -622,10 +614,10 @@ BOOL symt_get_info(const struct symt* type, IMAGEHLP_SYMBOL_TYPE_INFO req,
case DataIsParam: case DataIsParam:
case DataIsLocal: case DataIsLocal:
case DataIsMember: case DataIsMember:
X(ULONG) = ((struct symt_data*)type)->u.offset; X(ULONG) = ((struct symt_data*)type)->u.s.offset >> 3;
break; break;
default: default:
FIXME("Unknown kind (%u) for get-offset\n", FIXME("Unknown kind (%u) for get-offset\n",
((struct symt_data*)type)->kind); ((struct symt_data*)type)->kind);
return FALSE; return FALSE;
} }
......
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