diff --git a/programs/winedbg/debugger.h b/programs/winedbg/debugger.h index 7b2b398a222..33746ec5067 100644 --- a/programs/winedbg/debugger.h +++ b/programs/winedbg/debugger.h @@ -308,7 +308,6 @@ extern void info_wine_dbg_channel(BOOL add, const char* chnl, const extern BOOL memory_read_value(const struct dbg_lvalue* lvalue, DWORD size, void* result); extern BOOL memory_write_value(const struct dbg_lvalue* val, DWORD size, void* value); extern void memory_examine(const struct dbg_lvalue *lvalue, int count, char format); -extern void memory_report_invalid_addr(const void* addr); extern void* memory_to_linear_addr(const ADDRESS* address); extern BOOL memory_get_current_pc(ADDRESS* address); extern BOOL memory_get_current_stack(ADDRESS* address); @@ -393,20 +392,6 @@ static inline BOOL dbg_write_memory(void* addr, const void* buffer, size_t len) return WriteProcessMemory(dbg_curr_process->handle, addr, buffer, len, &wlen) && len == wlen; } -static inline BOOL dbg_read_memory_verbose(const void* addr, void* buffer, size_t len) -{ - if (dbg_read_memory(addr, buffer, len)) return TRUE; - memory_report_invalid_addr(addr); - return FALSE; -} - -static inline BOOL dbg_write_memory_verbose(void* addr, const void* buffer, size_t len) -{ - if (dbg_write_memory(addr, buffer, len)) return TRUE; - memory_report_invalid_addr(addr); - return FALSE; -} - static inline void* dbg_heap_realloc(void* buffer, size_t size) { return (buffer) ? HeapReAlloc(GetProcessHeap(), 0, buffer, size) : diff --git a/programs/winedbg/memory.c b/programs/winedbg/memory.c index a9d0f5f3f19..e899b67463e 100644 --- a/programs/winedbg/memory.c +++ b/programs/winedbg/memory.c @@ -73,7 +73,7 @@ BOOL memory_get_current_frame(ADDRESS* addr) be_cpu_addr_frame, addr); } -void memory_report_invalid_addr(const void* addr) +static void memory_report_invalid_addr(const void* addr) { ADDRESS address; @@ -92,15 +92,21 @@ void memory_report_invalid_addr(const void* addr) */ BOOL memory_read_value(const struct dbg_lvalue* lvalue, DWORD size, void* result) { + BOOL ret = FALSE; + if (lvalue->cookie == DLV_TARGET) { - if (!dbg_read_memory_verbose(memory_to_linear_addr(&lvalue->addr), result, size)) - return FALSE; + void* linear = memory_to_linear_addr(&lvalue->addr); + if (!(ret = dbg_read_memory(linear, result, size))) + memory_report_invalid_addr(linear); } else { - if (!lvalue->addr.Offset) return FALSE; - memcpy(result, (void*)lvalue->addr.Offset, size); + if (lvalue->addr.Offset) + { + memcpy(result, (void*)lvalue->addr.Offset, size); + ret = TRUE; + } } return TRUE; } @@ -114,7 +120,6 @@ BOOL memory_write_value(const struct dbg_lvalue* lvalue, DWORD size, void* value { BOOL ret = TRUE; DWORD os; - DWORD linear = (DWORD)memory_to_linear_addr(&lvalue->addr); os = ~size; types_get_info(&lvalue->type, TI_GET_LENGTH, &os); @@ -123,7 +128,9 @@ BOOL memory_write_value(const struct dbg_lvalue* lvalue, DWORD size, void* value /* FIXME: only works on little endian systems */ if (lvalue->cookie == DLV_TARGET) { - ret = dbg_write_memory_verbose((void*)linear, value, size); + void* linear = memory_to_linear_addr(&lvalue->addr); + if (!(ret = dbg_write_memory(linear, value, size))) + memory_report_invalid_addr(linear); } else { @@ -179,7 +186,11 @@ void memory_examine(const struct dbg_lvalue *lvalue, int count, char format) while (count--) { GUID guid; - if (!dbg_read_memory_verbose(linear, &guid, sizeof(guid))) break; + if (!dbg_read_memory(linear, &guid, sizeof(guid))) + { + memory_report_invalid_addr(linear); + break; + } dbg_printf("{%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}\n", guid.Data1, guid.Data2, guid.Data3, guid.Data4[0], guid.Data4[1], guid.Data4[2], guid.Data4[3], @@ -197,8 +208,8 @@ void memory_examine(const struct dbg_lvalue *lvalue, int count, char format) #define DO_DUMP2(_t,_l,_f,_vv) { \ _t _v; \ for (i = 0; i < count; i++) { \ - if (!dbg_read_memory_verbose(linear, &_v, \ - sizeof(_t))) break; \ + if (!dbg_read_memory(linear, &_v, sizeof(_t))) \ + { memory_report_invalid_addr(linear); break; } \ dbg_printf(_f, (_vv)); \ addr.Offset += sizeof(_t); \ linear = (char*)linear + sizeof(_t); \ @@ -535,8 +546,10 @@ static BOOL WINAPI sym_enum_cb(SYMBOL_INFO* sym_info, ULONG size, void* user) type.id = sym_info->TypeIndex; types_get_info(&type, TI_GET_OFFSET, &offset); addr += offset; - dbg_read_memory_verbose((char*)addr, &val, sizeof(val)); - sprintf(se->tmp + strlen(se->tmp), "%s=0x%x", sym_info->Name, val); + if (dbg_read_memory((char*)addr, &val, sizeof(val))) + sprintf(se->tmp + strlen(se->tmp), "%s=0x%x", sym_info->Name, val); + else + sprintf(se->tmp + strlen(se->tmp), "%s=<\?\?\?>", sym_info->Name); } return TRUE; } diff --git a/programs/winedbg/symbol.c b/programs/winedbg/symbol.c index 83c4d5b5499..837f118cf01 100644 --- a/programs/winedbg/symbol.c +++ b/programs/winedbg/symbol.c @@ -576,7 +576,11 @@ static BOOL CALLBACK info_locals_cb(SYMBOL_INFO* sym, ULONG size, void* ctx) types_get_info(&type, TI_GET_OFFSET, &v); v += ((IMAGEHLP_STACK_FRAME*)ctx)->FrameOffset; - dbg_read_memory_verbose((void*)v, &val, sizeof(val)); + if (!dbg_read_memory((void*)v, &val, sizeof(val))) + { + dbg_printf(" %s (%s) *** cannot read value at 0x%08lx\n", sym->Name, explain, v); + return TRUE; + } } dbg_printf(" %s = 0x%8.8lx (%s)\n", sym->Name, val, explain);