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:
| tSOURCE pathname { parser($2); }
| tSYMBOLFILE pathname { symbol_read_symtable($2, 0); }
| 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(); }
| tDETACH { dbg_curr_process->process_io->close_process(dbg_curr_process, FALSE); }
| tTHREAD tNUM { dbg_set_curr_thread($2); }
......@@ -225,7 +225,7 @@ x_command:
print_command:
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 type_expr { types_print_type(&$2, TRUE); dbg_printf("\n"); }
| tPRINT type_expr { types_print_type(&$2, TRUE, NULL); dbg_printf("\n"); }
;
break_command:
......
......@@ -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 BOOL symbol_get_line(const char* filename, const char* func, IMAGEHLP_LINE64* ret);
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_is_local(const char* name);
struct sgv_data;
......@@ -486,7 +486,7 @@ extern enum dbg_start tgt_module_load(const char* name, BOOL keep);
/* types.c */
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 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);
......
......@@ -628,7 +628,7 @@ BOOL expr_print(const struct expr* exp)
{
case EXPR_TYPE_CAST:
dbg_printf("((");
types_print_type(&exp->un.cast.cast_to, FALSE);
types_print_type(&exp->un.cast.cast_to, FALSE, NULL);
dbg_printf(")");
expr_print(exp->un.cast.expr);
dbg_printf(")");
......
......@@ -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 (!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;
}
......
......@@ -688,20 +688,18 @@ BOOL symbol_get_line(const char* filename, const char* name,
}
/******************************************************************
* symbol_print_local
* symbol_print_localvalue
*
* Overall format is:
* <name>=<value> in non detailed form
* <name>=<value> (local|pmt <where>) in detailed form
* <value> in non detailed form
* <value> (local|pmt <where>) in detailed form
* 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;
char buffer[64];
dbg_printf("%s=", sym->Name);
if (fill_sym_lvalue(sym, base, &lvalue, buffer, sizeof(buffer)))
{
print_value(&lvalue, 0, 1);
......@@ -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)
{
DWORD len;
WCHAR* nameW;
len = MultiByteToWideChar(CP_ACP, 0, sym->Name, -1, NULL, 0);
nameW = malloc(len * sizeof(WCHAR));
if (nameW)
{
struct dbg_type type;
dbg_printf("\t");
MultiByteToWideChar(CP_ACP, 0, sym->Name, -1, nameW, len);
type.module = sym->ModBase;
type.id = sym->TypeIndex;
types_print_type(&type, FALSE);
dbg_printf(" ");
symbol_print_local(sym, (DWORD_PTR)ctx, TRUE);
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;
}
......@@ -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)
{
dbg_printf(" ");
types_print_type(&type, FALSE);
types_print_type(&type, FALSE, NULL);
}
dbg_printf("\n");
return TRUE;
......
......@@ -576,7 +576,7 @@ void print_value(const struct dbg_lvalue* lvalue, char format, int level)
dbg_printf("Function ");
print_bare_address(&lvalue->addr);
dbg_printf(": ");
types_print_type(&type, FALSE);
types_print_type(&type, FALSE, NULL);
break;
case SymTagTypedef:
lvalue_field = *lvalue;
......@@ -600,7 +600,7 @@ static BOOL CALLBACK print_types_cb(PSYMBOL_INFO sym, ULONG size, void* ctx)
type.module = sym->ModBase;
type.id = sym->TypeIndex;
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");
return TRUE;
}
......@@ -621,13 +621,14 @@ BOOL print_types(void)
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;
const WCHAR* name;
DWORD tag, udt, count, bitoffset, bt;
DWORD64 bitlen;
struct dbg_type subtype;
BOOL printed = FALSE;
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)
break;
case SymTagPointerType:
types_get_info(type, TI_GET_TYPE, &subtype);
types_print_type(&subtype, FALSE);
types_print_type(&subtype, FALSE, NULL);
dbg_printf("*");
break;
case SymTagUDT:
......@@ -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))
{
/* 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>");
dbg_printf(" %ls", ptr);
else dbg_printf("<unknown> %ls", ptr);
HeapFree(GetProcessHeap(), 0, ptr);
if (bitlen != ~(DWORD64)0)
dbg_printf(" : %I64u", bitlen);
......@@ -707,12 +707,15 @@ BOOL types_print_type(const struct dbg_type* type, BOOL details)
}
break;
case SymTagArrayType:
types_get_info(type, TI_GET_TYPE, &subtype);
types_print_type(&subtype, FALSE);
if (types_get_info(type, TI_GET_TYPE, &subtype))
{
types_print_type(&subtype, FALSE, varname);
if (types_get_info(type, TI_GET_COUNT, &count))
dbg_printf(" %ls[%ld]", name, count);
dbg_printf("[%ld]", count);
else
dbg_printf(" %ls[]", name);
dbg_printf("[]");
printed = TRUE;
}
break;
case SymTagEnum:
dbg_printf("enum %ls", name);
......@@ -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 ? */
if (subtype.id != type->id)
{
types_print_type(&subtype, FALSE);
types_print_type(&subtype, FALSE, NULL);
}
else
{
subtype.module = 0;
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))
{
char buffer[sizeof(TI_FINDCHILDREN_PARAMS) + 256 * sizeof(DWORD)];
......@@ -792,7 +796,7 @@ BOOL types_print_type(const struct dbg_type* type, BOOL details)
{
subtype.id = fcp->ChildId[i];
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(", ");
}
}
......@@ -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))
{
dbg_printf("typedef %ls => ", name);
types_print_type(&subtype, FALSE);
types_print_type(&subtype, FALSE, NULL);
}
else dbg_printf("%ls", name);
break;
......@@ -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);
break;
}
if (varname && !printed) dbg_printf(" %ls", varname);
HeapFree(GetProcessHeap(), 0, ptr);
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