Commit 001665d7 authored by Eric Pouech's avatar Eric Pouech Committed by Alexandre Julliard

winedbg: Enhance printing of variables or fields.

Prints 'int a[10]' (instead of 'int[10] a'). Ditto for variables/fields of type function pointer. And for pure type printing, no longer prints --none-- for arrays and function pointers. Signed-off-by: 's avatarEric Pouech <eric.pouech@gmail.com>
parent b990eaa8
...@@ -139,7 +139,7 @@ command: ...@@ -139,7 +139,7 @@ command:
| tSOURCE pathname { parser($2); } | tSOURCE pathname { parser($2); }
| tSYMBOLFILE pathname { symbol_read_symtable($2, 0); } | tSYMBOLFILE pathname { symbol_read_symtable($2, 0); }
| tSYMBOLFILE pathname expr_rvalue { symbol_read_symtable($2, $3); } | tSYMBOLFILE pathname expr_rvalue { symbol_read_symtable($2, $3); }
| tWHATIS expr_lvalue { dbg_printf("type = "); types_print_type(&$2.type, FALSE); dbg_printf("\n"); } | tWHATIS expr_lvalue { dbg_printf("type = "); types_print_type(&$2.type, FALSE, NULL); dbg_printf("\n"); }
| tATTACH tNUM { dbg_attach_debuggee($2); dbg_active_wait_for_first_exception(); } | tATTACH tNUM { dbg_attach_debuggee($2); dbg_active_wait_for_first_exception(); }
| tDETACH { dbg_curr_process->process_io->close_process(dbg_curr_process, FALSE); } | tDETACH { dbg_curr_process->process_io->close_process(dbg_curr_process, FALSE); }
| tTHREAD tNUM { dbg_set_curr_thread($2); } | tTHREAD tNUM { dbg_set_curr_thread($2); }
...@@ -225,7 +225,7 @@ x_command: ...@@ -225,7 +225,7 @@ x_command:
print_command: print_command:
tPRINT expr_lvalue { print_value(&$2, 0, 0); } tPRINT expr_lvalue { print_value(&$2, 0, 0); }
| tPRINT tFORMAT expr_lvalue { if (($2 >> 8) == 1) print_value(&$3, $2 & 0xff, 0); else dbg_printf("Count is meaningless in print command\n"); } | tPRINT tFORMAT expr_lvalue { if (($2 >> 8) == 1) print_value(&$3, $2 & 0xff, 0); else dbg_printf("Count is meaningless in print command\n"); }
| tPRINT type_expr { types_print_type(&$2, TRUE); dbg_printf("\n"); } | tPRINT type_expr { types_print_type(&$2, TRUE, NULL); dbg_printf("\n"); }
; ;
break_command: break_command:
......
...@@ -448,7 +448,7 @@ extern void symbol_read_symtable(const char* filename, ULONG_PTR off ...@@ -448,7 +448,7 @@ extern void symbol_read_symtable(const char* filename, ULONG_PTR off
extern enum dbg_line_status symbol_get_function_line_status(const ADDRESS64* addr); extern enum dbg_line_status symbol_get_function_line_status(const ADDRESS64* addr);
extern BOOL symbol_get_line(const char* filename, const char* func, IMAGEHLP_LINE64* ret); extern BOOL symbol_get_line(const char* filename, const char* func, IMAGEHLP_LINE64* ret);
extern void symbol_info(const char* str); extern void symbol_info(const char* str);
extern void symbol_print_local(const SYMBOL_INFO* sym, DWORD_PTR base, BOOL detailed); extern void symbol_print_localvalue(const SYMBOL_INFO* sym, DWORD_PTR base, BOOL detailed);
extern BOOL symbol_info_locals(void); extern BOOL symbol_info_locals(void);
extern BOOL symbol_is_local(const char* name); extern BOOL symbol_is_local(const char* name);
struct sgv_data; struct sgv_data;
...@@ -486,7 +486,7 @@ extern enum dbg_start tgt_module_load(const char* name, BOOL keep); ...@@ -486,7 +486,7 @@ extern enum dbg_start tgt_module_load(const char* name, BOOL keep);
/* types.c */ /* types.c */
extern void print_value(const struct dbg_lvalue* addr, char format, int level); extern void print_value(const struct dbg_lvalue* addr, char format, int level);
extern BOOL types_print_type(const struct dbg_type*, BOOL details); extern BOOL types_print_type(const struct dbg_type*, BOOL details, const WCHAR* varname);
extern BOOL print_types(void); extern BOOL print_types(void);
extern dbg_lgint_t types_extract_as_integer(const struct dbg_lvalue*); extern dbg_lgint_t types_extract_as_integer(const struct dbg_lvalue*);
extern dbg_lgint_t types_extract_as_lgint(const struct dbg_lvalue*, unsigned* psize, BOOL *pissigned); extern dbg_lgint_t types_extract_as_lgint(const struct dbg_lvalue*, unsigned* psize, BOOL *pissigned);
......
...@@ -628,7 +628,7 @@ BOOL expr_print(const struct expr* exp) ...@@ -628,7 +628,7 @@ BOOL expr_print(const struct expr* exp)
{ {
case EXPR_TYPE_CAST: case EXPR_TYPE_CAST:
dbg_printf("(("); dbg_printf("((");
types_print_type(&exp->un.cast.cast_to, FALSE); types_print_type(&exp->un.cast.cast_to, FALSE, NULL);
dbg_printf(")"); dbg_printf(")");
expr_print(exp->un.cast.expr); expr_print(exp->un.cast.expr);
dbg_printf(")"); dbg_printf(")");
......
...@@ -250,7 +250,8 @@ static BOOL WINAPI sym_enum_cb(PSYMBOL_INFO sym_info, ULONG size, PVOID user) ...@@ -250,7 +250,8 @@ static BOOL WINAPI sym_enum_cb(PSYMBOL_INFO sym_info, ULONG size, PVOID user)
if (sym_info->Flags & SYMFLAG_PARAMETER) if (sym_info->Flags & SYMFLAG_PARAMETER)
{ {
if (!se->first) dbg_printf(", "); else se->first = FALSE; if (!se->first) dbg_printf(", "); else se->first = FALSE;
symbol_print_local(sym_info, se->frame, FALSE); dbg_printf("%s=", sym_info->Name);
symbol_print_localvalue(sym_info, se->frame, FALSE);
} }
return TRUE; return TRUE;
} }
......
...@@ -688,20 +688,18 @@ BOOL symbol_get_line(const char* filename, const char* name, ...@@ -688,20 +688,18 @@ BOOL symbol_get_line(const char* filename, const char* name,
} }
/****************************************************************** /******************************************************************
* symbol_print_local * symbol_print_localvalue
* *
* Overall format is: * Overall format is:
* <name>=<value> in non detailed form * <value> in non detailed form
* <name>=<value> (local|pmt <where>) in detailed form * <value> (local|pmt <where>) in detailed form
* Note <value> can be an error message in case of error * Note <value> can be an error message in case of error
*/ */
void symbol_print_local(const SYMBOL_INFO* sym, DWORD_PTR base, BOOL detailed) void symbol_print_localvalue(const SYMBOL_INFO* sym, DWORD_PTR base, BOOL detailed)
{ {
struct dbg_lvalue lvalue; struct dbg_lvalue lvalue;
char buffer[64]; char buffer[64];
dbg_printf("%s=", sym->Name);
if (fill_sym_lvalue(sym, base, &lvalue, buffer, sizeof(buffer))) if (fill_sym_lvalue(sym, base, &lvalue, buffer, sizeof(buffer)))
{ {
print_value(&lvalue, 0, 1); print_value(&lvalue, 0, 1);
...@@ -721,16 +719,28 @@ void symbol_print_local(const SYMBOL_INFO* sym, DWORD_PTR base, BOOL detailed) ...@@ -721,16 +719,28 @@ void symbol_print_local(const SYMBOL_INFO* sym, DWORD_PTR base, BOOL detailed)
static BOOL CALLBACK info_locals_cb(PSYMBOL_INFO sym, ULONG size, PVOID ctx) static BOOL CALLBACK info_locals_cb(PSYMBOL_INFO sym, ULONG size, PVOID ctx)
{ {
struct dbg_type type; DWORD len;
WCHAR* nameW;
dbg_printf("\t"); len = MultiByteToWideChar(CP_ACP, 0, sym->Name, -1, NULL, 0);
type.module = sym->ModBase; nameW = malloc(len * sizeof(WCHAR));
type.id = sym->TypeIndex; if (nameW)
types_print_type(&type, FALSE); {
struct dbg_type type;
dbg_printf(" "); MultiByteToWideChar(CP_ACP, 0, sym->Name, -1, nameW, len);
symbol_print_local(sym, (DWORD_PTR)ctx, TRUE);
dbg_printf("\n"); type.module = sym->ModBase;
type.id = sym->TypeIndex;
dbg_printf("\t");
types_print_type(&type, FALSE, nameW);
dbg_printf("=");
symbol_print_localvalue(sym, (DWORD_PTR)ctx, TRUE);
dbg_printf("\n");
free(nameW);
}
return TRUE; return TRUE;
} }
...@@ -774,7 +784,7 @@ static BOOL CALLBACK symbols_info_cb(PSYMBOL_INFO sym, ULONG size, PVOID ctx) ...@@ -774,7 +784,7 @@ static BOOL CALLBACK symbols_info_cb(PSYMBOL_INFO sym, ULONG size, PVOID ctx)
if (sym->TypeIndex != dbg_itype_none && sym->TypeIndex != 0) if (sym->TypeIndex != dbg_itype_none && sym->TypeIndex != 0)
{ {
dbg_printf(" "); dbg_printf(" ");
types_print_type(&type, FALSE); types_print_type(&type, FALSE, NULL);
} }
dbg_printf("\n"); dbg_printf("\n");
return TRUE; return TRUE;
......
...@@ -576,7 +576,7 @@ void print_value(const struct dbg_lvalue* lvalue, char format, int level) ...@@ -576,7 +576,7 @@ void print_value(const struct dbg_lvalue* lvalue, char format, int level)
dbg_printf("Function "); dbg_printf("Function ");
print_bare_address(&lvalue->addr); print_bare_address(&lvalue->addr);
dbg_printf(": "); dbg_printf(": ");
types_print_type(&type, FALSE); types_print_type(&type, FALSE, NULL);
break; break;
case SymTagTypedef: case SymTagTypedef:
lvalue_field = *lvalue; lvalue_field = *lvalue;
...@@ -600,7 +600,7 @@ static BOOL CALLBACK print_types_cb(PSYMBOL_INFO sym, ULONG size, void* ctx) ...@@ -600,7 +600,7 @@ static BOOL CALLBACK print_types_cb(PSYMBOL_INFO sym, ULONG size, void* ctx)
type.module = sym->ModBase; type.module = sym->ModBase;
type.id = sym->TypeIndex; type.id = sym->TypeIndex;
dbg_printf("Mod: %0*Ix ID: %08lx\n", ADDRWIDTH, type.module, type.id); dbg_printf("Mod: %0*Ix ID: %08lx\n", ADDRWIDTH, type.module, type.id);
types_print_type(&type, TRUE); types_print_type(&type, TRUE, FALSE);
dbg_printf("\n"); dbg_printf("\n");
return TRUE; return TRUE;
} }
...@@ -621,13 +621,14 @@ BOOL print_types(void) ...@@ -621,13 +621,14 @@ BOOL print_types(void)
return FALSE; return FALSE;
} }
BOOL types_print_type(const struct dbg_type* type, BOOL details) BOOL types_print_type(const struct dbg_type* type, BOOL details, const WCHAR* varname)
{ {
WCHAR* ptr; WCHAR* ptr;
const WCHAR* name; const WCHAR* name;
DWORD tag, udt, count, bitoffset, bt; DWORD tag, udt, count, bitoffset, bt;
DWORD64 bitlen; DWORD64 bitlen;
struct dbg_type subtype; struct dbg_type subtype;
BOOL printed = FALSE;
if (type->id == dbg_itype_none || !types_get_info(type, TI_GET_SYMTAG, &tag)) if (type->id == dbg_itype_none || !types_get_info(type, TI_GET_SYMTAG, &tag))
{ {
...@@ -650,7 +651,7 @@ BOOL types_print_type(const struct dbg_type* type, BOOL details) ...@@ -650,7 +651,7 @@ BOOL types_print_type(const struct dbg_type* type, BOOL details)
break; break;
case SymTagPointerType: case SymTagPointerType:
types_get_info(type, TI_GET_TYPE, &subtype); types_get_info(type, TI_GET_TYPE, &subtype);
types_print_type(&subtype, FALSE); types_print_type(&subtype, FALSE, NULL);
dbg_printf("*"); dbg_printf("*");
break; break;
case SymTagUDT: case SymTagUDT:
...@@ -689,10 +690,9 @@ BOOL types_print_type(const struct dbg_type* type, BOOL details) ...@@ -689,10 +690,9 @@ BOOL types_print_type(const struct dbg_type* type, BOOL details)
if (types_get_info(&type_elt, TI_GET_TYPE, &type_elt)) if (types_get_info(&type_elt, TI_GET_TYPE, &type_elt))
{ {
/* print details of embedded UDT:s */ /* print details of embedded UDT:s */
types_print_type(&type_elt, types_get_info(&type_elt, TI_GET_UDTKIND, &udt)); types_print_type(&type_elt, types_get_info(&type_elt, TI_GET_UDTKIND, &udt), ptr);
} }
else dbg_printf("<unknown>"); else dbg_printf("<unknown> %ls", ptr);
dbg_printf(" %ls", ptr);
HeapFree(GetProcessHeap(), 0, ptr); HeapFree(GetProcessHeap(), 0, ptr);
if (bitlen != ~(DWORD64)0) if (bitlen != ~(DWORD64)0)
dbg_printf(" : %I64u", bitlen); dbg_printf(" : %I64u", bitlen);
...@@ -707,12 +707,15 @@ BOOL types_print_type(const struct dbg_type* type, BOOL details) ...@@ -707,12 +707,15 @@ BOOL types_print_type(const struct dbg_type* type, BOOL details)
} }
break; break;
case SymTagArrayType: case SymTagArrayType:
types_get_info(type, TI_GET_TYPE, &subtype); if (types_get_info(type, TI_GET_TYPE, &subtype))
types_print_type(&subtype, FALSE); {
if (types_get_info(type, TI_GET_COUNT, &count)) types_print_type(&subtype, FALSE, varname);
dbg_printf(" %ls[%ld]", name, count); if (types_get_info(type, TI_GET_COUNT, &count))
else dbg_printf("[%ld]", count);
dbg_printf(" %ls[]", name); else
dbg_printf("[]");
printed = TRUE;
}
break; break;
case SymTagEnum: case SymTagEnum:
dbg_printf("enum %ls", name); dbg_printf("enum %ls", name);
...@@ -767,14 +770,15 @@ BOOL types_print_type(const struct dbg_type* type, BOOL details) ...@@ -767,14 +770,15 @@ BOOL types_print_type(const struct dbg_type* type, BOOL details)
/* is the returned type the same object as function sig itself ? */ /* is the returned type the same object as function sig itself ? */
if (subtype.id != type->id) if (subtype.id != type->id)
{ {
types_print_type(&subtype, FALSE); types_print_type(&subtype, FALSE, NULL);
} }
else else
{ {
subtype.module = 0; subtype.module = 0;
dbg_printf("<ret_type=self>"); dbg_printf("<ret_type=self>");
} }
dbg_printf(" (*%ls)(", name); dbg_printf(" (*%ls)(", varname ? varname : L"");
printed = TRUE;
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)];
...@@ -792,7 +796,7 @@ BOOL types_print_type(const struct dbg_type* type, BOOL details) ...@@ -792,7 +796,7 @@ BOOL types_print_type(const struct dbg_type* type, BOOL details)
{ {
subtype.id = fcp->ChildId[i]; subtype.id = fcp->ChildId[i];
types_get_info(&subtype, TI_GET_TYPE, &subtype); types_get_info(&subtype, TI_GET_TYPE, &subtype);
types_print_type(&subtype, FALSE); types_print_type(&subtype, FALSE, NULL);
if (i < min(fcp->Count, count) - 1 || count > 256) dbg_printf(", "); if (i < min(fcp->Count, count) - 1 || count > 256) dbg_printf(", ");
} }
} }
...@@ -806,7 +810,7 @@ BOOL types_print_type(const struct dbg_type* type, BOOL details) ...@@ -806,7 +810,7 @@ BOOL types_print_type(const struct dbg_type* type, BOOL details)
if (details && types_get_info(type, TI_GET_TYPE, &subtype)) if (details && types_get_info(type, TI_GET_TYPE, &subtype))
{ {
dbg_printf("typedef %ls => ", name); dbg_printf("typedef %ls => ", name);
types_print_type(&subtype, FALSE); types_print_type(&subtype, FALSE, NULL);
} }
else dbg_printf("%ls", name); else dbg_printf("%ls", name);
break; break;
...@@ -814,6 +818,7 @@ BOOL types_print_type(const struct dbg_type* type, BOOL details) ...@@ -814,6 +818,7 @@ BOOL types_print_type(const struct dbg_type* type, BOOL details)
WINE_ERR("Unknown type %lu for %ls\n", tag, name); WINE_ERR("Unknown type %lu for %ls\n", tag, name);
break; break;
} }
if (varname && !printed) dbg_printf(" %ls", varname);
HeapFree(GetProcessHeap(), 0, ptr); 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