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

winedbg: Use %ls to print wide character strings.

parent 8dec81fb
...@@ -447,7 +447,6 @@ static void print_typed_basic(const struct dbg_lvalue* lvalue) ...@@ -447,7 +447,6 @@ static void print_typed_basic(const struct dbg_lvalue* lvalue)
char buffer[sizeof(TI_FINDCHILDREN_PARAMS) + 256 * sizeof(DWORD)]; char buffer[sizeof(TI_FINDCHILDREN_PARAMS) + 256 * sizeof(DWORD)];
TI_FINDCHILDREN_PARAMS* fcp = (TI_FINDCHILDREN_PARAMS*)buffer; TI_FINDCHILDREN_PARAMS* fcp = (TI_FINDCHILDREN_PARAMS*)buffer;
WCHAR* ptr; WCHAR* ptr;
char tmp[256];
VARIANT variant; VARIANT variant;
int i; int i;
...@@ -471,14 +470,10 @@ static void print_typed_basic(const struct dbg_lvalue* lvalue) ...@@ -471,14 +470,10 @@ static void print_typed_basic(const struct dbg_lvalue* lvalue)
case VT_I8: ok = (val_int == V_I8(&variant)); break; case VT_I8: ok = (val_int == V_I8(&variant)); break;
default: WINE_FIXME("Unsupported variant type (%u)\n", V_VT(&variant)); default: WINE_FIXME("Unsupported variant type (%u)\n", V_VT(&variant));
} }
if (ok) if (ok && types_get_info(&sub_type, TI_GET_SYMNAME, &ptr) && ptr)
{ {
ptr = NULL; dbg_printf("%ls", ptr);
types_get_info(&sub_type, TI_GET_SYMNAME, &ptr);
if (!ptr) continue;
WideCharToMultiByte(CP_ACP, 0, ptr, -1, tmp, sizeof(tmp), NULL, NULL);
HeapFree(GetProcessHeap(), 0, ptr); HeapFree(GetProcessHeap(), 0, ptr);
dbg_printf("%s", tmp);
count = 0; /* so that we'll get away from outer loop */ count = 0; /* so that we'll get away from outer loop */
break; break;
} }
......
...@@ -756,11 +756,10 @@ BOOL symbol_info_locals(void) ...@@ -756,11 +756,10 @@ BOOL symbol_info_locals(void)
addr.Mode = AddrModeFlat; addr.Mode = AddrModeFlat;
addr.Offset = frm->linear_pc; addr.Offset = frm->linear_pc;
print_address(&addr, FALSE); print_address(&addr, FALSE);
dbg_printf(": (%0*lx)\n", ADDRWIDTH, (DWORD_PTR)frm->linear_frame); dbg_printf(": (%0*Ix)\n", ADDRWIDTH, frm->linear_frame);
SymEnumSymbols(dbg_curr_process->handle, 0, NULL, info_locals_cb, (void*)frm->linear_frame); SymEnumSymbols(dbg_curr_process->handle, 0, NULL, info_locals_cb, (void*)frm->linear_frame);
return TRUE; return TRUE;
} }
static BOOL CALLBACK symbols_info_cb(PSYMBOL_INFO sym, ULONG size, PVOID ctx) static BOOL CALLBACK symbols_info_cb(PSYMBOL_INFO sym, ULONG size, PVOID ctx)
......
...@@ -261,17 +261,16 @@ BOOL types_udt_find_element(struct dbg_lvalue* lvalue, const char* name, ULONG * ...@@ -261,17 +261,16 @@ BOOL types_udt_find_element(struct dbg_lvalue* lvalue, const char* name, ULONG *
type.module = lvalue->type.module; type.module = lvalue->type.module;
for (i = 0; i < min(fcp->Count, count); i++) for (i = 0; i < min(fcp->Count, count); i++)
{ {
ptr = NULL;
type.id = fcp->ChildId[i]; type.id = fcp->ChildId[i];
types_get_info(&type, TI_GET_SYMNAME, &ptr); if (types_get_info(&type, TI_GET_SYMNAME, &ptr) && ptr)
if (!ptr) continue; {
WideCharToMultiByte(CP_ACP, 0, ptr, -1, tmp, sizeof(tmp), NULL, NULL); WideCharToMultiByte(CP_ACP, 0, ptr, -1, tmp, sizeof(tmp), NULL, NULL);
HeapFree(GetProcessHeap(), 0, ptr); HeapFree(GetProcessHeap(), 0, ptr);
if (strcmp(tmp, name)) continue; if (!strcmp(tmp, name))
return types_get_udt_element_lvalue(lvalue, &type, tmpbuf); return types_get_udt_element_lvalue(lvalue, &type, tmpbuf);
} }
} }
}
count -= min(count, 256); count -= min(count, 256);
fcp->Start += 256; fcp->Start += 256;
} }
...@@ -477,7 +476,6 @@ void print_value(const struct dbg_lvalue* lvalue, char format, int level) ...@@ -477,7 +476,6 @@ void print_value(const struct dbg_lvalue* lvalue, char format, int level)
char buffer[sizeof(TI_FINDCHILDREN_PARAMS) + 256 * sizeof(DWORD)]; char buffer[sizeof(TI_FINDCHILDREN_PARAMS) + 256 * sizeof(DWORD)];
TI_FINDCHILDREN_PARAMS* fcp = (TI_FINDCHILDREN_PARAMS*)buffer; TI_FINDCHILDREN_PARAMS* fcp = (TI_FINDCHILDREN_PARAMS*)buffer;
WCHAR* ptr; WCHAR* ptr;
char tmp[256];
ULONG tmpbuf; ULONG tmpbuf;
struct dbg_type sub_type; struct dbg_type sub_type;
...@@ -490,13 +488,10 @@ void print_value(const struct dbg_lvalue* lvalue, char format, int level) ...@@ -490,13 +488,10 @@ void print_value(const struct dbg_lvalue* lvalue, char format, int level)
{ {
for (i = 0; i < min(fcp->Count, count); i++) for (i = 0; i < min(fcp->Count, count); i++)
{ {
ptr = NULL;
sub_type.module = type.module; sub_type.module = type.module;
sub_type.id = fcp->ChildId[i]; sub_type.id = fcp->ChildId[i];
types_get_info(&sub_type, TI_GET_SYMNAME, &ptr); if (!types_get_info(&sub_type, TI_GET_SYMNAME, &ptr) || !ptr) continue;
if (!ptr) continue; dbg_printf("%ls=", ptr);
WideCharToMultiByte(CP_ACP, 0, ptr, -1, tmp, sizeof(tmp), NULL, NULL);
dbg_printf("%s=", tmp);
HeapFree(GetProcessHeap(), 0, ptr); HeapFree(GetProcessHeap(), 0, ptr);
lvalue_field = *lvalue; lvalue_field = *lvalue;
if (types_get_udt_element_lvalue(&lvalue_field, &sub_type, &tmpbuf)) if (types_get_udt_element_lvalue(&lvalue_field, &sub_type, &tmpbuf))
...@@ -602,8 +597,7 @@ BOOL print_types(void) ...@@ -602,8 +597,7 @@ BOOL print_types(void)
BOOL types_print_type(const struct dbg_type* type, BOOL details) BOOL types_print_type(const struct dbg_type* type, BOOL details)
{ {
WCHAR* ptr; WCHAR* ptr;
char tmp[256]; const WCHAR* name;
const char* name;
DWORD tag, udt, count; DWORD tag, udt, count;
struct dbg_type subtype; struct dbg_type subtype;
...@@ -613,18 +607,12 @@ BOOL types_print_type(const struct dbg_type* type, BOOL details) ...@@ -613,18 +607,12 @@ BOOL types_print_type(const struct dbg_type* type, BOOL details)
return FALSE; return FALSE;
} }
if (types_get_info(type, TI_GET_SYMNAME, &ptr) && ptr) name = (types_get_info(type, TI_GET_SYMNAME, &ptr) && ptr) ? ptr : L"--none--";
{
WideCharToMultiByte(CP_ACP, 0, ptr, -1, tmp, sizeof(tmp), NULL, NULL);
name = tmp;
HeapFree(GetProcessHeap(), 0, ptr);
}
else name = "--none--";
switch (tag) switch (tag)
{ {
case SymTagBaseType: case SymTagBaseType:
if (details) dbg_printf("Basic<%s>", name); else dbg_printf("%s", name); if (details) dbg_printf("Basic<%ls>", name); else dbg_printf("%ls", name);
break; break;
case SymTagPointerType: case SymTagPointerType:
types_get_info(type, TI_GET_TYPE, &subtype.id); types_get_info(type, TI_GET_TYPE, &subtype.id);
...@@ -636,10 +624,10 @@ BOOL types_print_type(const struct dbg_type* type, BOOL details) ...@@ -636,10 +624,10 @@ BOOL types_print_type(const struct dbg_type* type, BOOL details)
types_get_info(type, TI_GET_UDTKIND, &udt); types_get_info(type, TI_GET_UDTKIND, &udt);
switch (udt) switch (udt)
{ {
case UdtStruct: dbg_printf("struct %s", name); break; case UdtStruct: dbg_printf("struct %ls", name); break;
case UdtUnion: dbg_printf("union %s", name); break; case UdtUnion: dbg_printf("union %ls", name); break;
case UdtClass: dbg_printf("class %s", name); break; case UdtClass: dbg_printf("class %ls", name); break;
default: WINE_ERR("Unsupported UDT type (%d) for %s\n", udt, name); break; default: WINE_ERR("Unsupported UDT type (%d) for %ls\n", udt, name); break;
} }
if (details && if (details &&
types_get_info(type, TI_GET_CHILDRENCOUNT, &count)) types_get_info(type, TI_GET_CHILDRENCOUNT, &count))
...@@ -647,7 +635,6 @@ BOOL types_print_type(const struct dbg_type* type, BOOL details) ...@@ -647,7 +635,6 @@ BOOL types_print_type(const struct dbg_type* type, BOOL details)
char buffer[sizeof(TI_FINDCHILDREN_PARAMS) + 256 * sizeof(DWORD)]; char buffer[sizeof(TI_FINDCHILDREN_PARAMS) + 256 * sizeof(DWORD)];
TI_FINDCHILDREN_PARAMS* fcp = (TI_FINDCHILDREN_PARAMS*)buffer; TI_FINDCHILDREN_PARAMS* fcp = (TI_FINDCHILDREN_PARAMS*)buffer;
WCHAR* ptr; WCHAR* ptr;
char tmp[256];
int i; int i;
struct dbg_type type_elt; struct dbg_type type_elt;
dbg_printf(" {"); dbg_printf(" {");
...@@ -660,14 +647,11 @@ BOOL types_print_type(const struct dbg_type* type, BOOL details) ...@@ -660,14 +647,11 @@ BOOL types_print_type(const struct dbg_type* type, BOOL details)
{ {
for (i = 0; i < min(fcp->Count, count); i++) for (i = 0; i < min(fcp->Count, count); i++)
{ {
ptr = NULL;
type_elt.module = type->module; type_elt.module = type->module;
type_elt.id = fcp->ChildId[i]; type_elt.id = fcp->ChildId[i];
types_get_info(&type_elt, TI_GET_SYMNAME, &ptr); if (!types_get_info(&type_elt, TI_GET_SYMNAME, &ptr) || !ptr) continue;
if (!ptr) continue; dbg_printf("%ls", ptr);
WideCharToMultiByte(CP_ACP, 0, ptr, -1, tmp, sizeof(tmp), NULL, NULL);
HeapFree(GetProcessHeap(), 0, ptr); HeapFree(GetProcessHeap(), 0, ptr);
dbg_printf("%s", tmp);
if (types_get_info(&type_elt, TI_GET_TYPE, &type_elt.id)) if (types_get_info(&type_elt, TI_GET_TYPE, &type_elt.id))
{ {
dbg_printf(":"); dbg_printf(":");
...@@ -687,12 +671,12 @@ BOOL types_print_type(const struct dbg_type* type, BOOL details) ...@@ -687,12 +671,12 @@ BOOL types_print_type(const struct dbg_type* type, BOOL details)
subtype.module = type->module; subtype.module = type->module;
types_print_type(&subtype, details); types_print_type(&subtype, details);
if (types_get_info(type, TI_GET_COUNT, &count)) if (types_get_info(type, TI_GET_COUNT, &count))
dbg_printf(" %s[%d]", name, count); dbg_printf(" %ls[%d]", name, count);
else else
dbg_printf(" %s[]", name); dbg_printf(" %ls[]", name);
break; break;
case SymTagEnum: case SymTagEnum:
dbg_printf("enum %s", name); dbg_printf("enum %ls", name);
break; break;
case SymTagFunctionType: case SymTagFunctionType:
types_get_info(type, TI_GET_TYPE, &subtype.id); types_get_info(type, TI_GET_TYPE, &subtype.id);
...@@ -707,7 +691,7 @@ BOOL types_print_type(const struct dbg_type* type, BOOL details) ...@@ -707,7 +691,7 @@ BOOL types_print_type(const struct dbg_type* type, BOOL details)
subtype.module = 0; subtype.module = 0;
dbg_printf("<ret_type=self>"); dbg_printf("<ret_type=self>");
} }
dbg_printf(" (*%s)(", name); dbg_printf(" (*%ls)(", name);
if (types_get_info(type, TI_GET_CHILDRENCOUNT, &count)) if (types_get_info(type, TI_GET_CHILDRENCOUNT, &count))
{ {
char buffer[sizeof(TI_FINDCHILDREN_PARAMS) + 256 * sizeof(DWORD)]; char buffer[sizeof(TI_FINDCHILDREN_PARAMS) + 256 * sizeof(DWORD)];
...@@ -736,13 +720,14 @@ BOOL types_print_type(const struct dbg_type* type, BOOL details) ...@@ -736,13 +720,14 @@ BOOL types_print_type(const struct dbg_type* type, BOOL details)
dbg_printf(")"); dbg_printf(")");
break; break;
case SymTagTypedef: case SymTagTypedef:
dbg_printf("%s", name); dbg_printf("%ls", name);
break; break;
default: default:
WINE_ERR("Unknown type %u for %s\n", tag, name); WINE_ERR("Unknown type %u for %ls\n", tag, name);
break; break;
} }
HeapFree(GetProcessHeap(), 0, ptr);
return TRUE; return TRUE;
} }
......
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