Signed-off-by: Eric Pouech eric.pouech@gmail.com
--- programs/winedbg/debugger.h | 2 ++ programs/winedbg/memory.c | 17 +++++++++++++++++ programs/winedbg/types.c | 17 ++++++++++++++++- 3 files changed, 35 insertions(+), 1 deletion(-)
diff --git a/programs/winedbg/debugger.h b/programs/winedbg/debugger.h index 9b6efccb69e..f74ddfc210f 100644 --- a/programs/winedbg/debugger.h +++ b/programs/winedbg/debugger.h @@ -397,6 +397,7 @@ extern BOOL memory_fetch_integer(const struct dbg_lvalue* lvalue, un BOOL is_signed, dbg_lgint_t* ret); extern BOOL memory_store_integer(const struct dbg_lvalue* lvalue, dbg_lgint_t val); extern BOOL memory_fetch_float(const struct dbg_lvalue* lvalue, double *ret); +extern BOOL memory_store_float(const struct dbg_lvalue* lvalue, double *ret); extern void memory_examine(const struct dbg_lvalue *lvalue, int count, char format); extern void* memory_to_linear_addr(const ADDRESS64* address); extern BOOL memory_get_current_pc(ADDRESS64* address); @@ -497,6 +498,7 @@ extern struct dbg_type types_find_pointer(const struct dbg_type* type); extern struct dbg_type types_find_type(DWORD64 linear, const char* name, enum SymTagEnum tag); extern BOOL types_compare(const struct dbg_type, const struct dbg_type, BOOL* equal); extern BOOL types_is_integral_type(const struct dbg_lvalue*); +extern BOOL types_is_float_type(const struct dbg_lvalue*);
/* winedbg.c */ extern void dbg_outputW(const WCHAR* buffer, int len); diff --git a/programs/winedbg/memory.c b/programs/winedbg/memory.c index eed9bf6c049..5e01bef5607 100644 --- a/programs/winedbg/memory.c +++ b/programs/winedbg/memory.c @@ -354,6 +354,23 @@ BOOL memory_fetch_float(const struct dbg_lvalue* lvalue, double *ret) return TRUE; }
+BOOL memory_store_float(const struct dbg_lvalue* lvalue, double *ret) +{ + DWORD64 size; + if (!types_get_info(&lvalue->type, TI_GET_LENGTH, &size)) return FALSE; + /* FIXME: this assumes that debuggee and debugger use the same + * representation for reals + */ + if (size > sizeof(*ret)) return FALSE; + if (size == sizeof(float)) + { + float f = *ret; + return memory_write_value(lvalue, size, &f); + } + if (size != sizeof(double)) return FALSE; + return memory_write_value(lvalue, size, ret); +} + BOOL memory_get_string(struct dbg_process* pcs, void* addr, BOOL in_debuggee, BOOL unicode, char* buffer, int size) { diff --git a/programs/winedbg/types.c b/programs/winedbg/types.c index f8d242fb64d..3aefbe03058 100644 --- a/programs/winedbg/types.c +++ b/programs/winedbg/types.c @@ -168,6 +168,12 @@ BOOL types_store_value(struct dbg_lvalue* lvalue_to, const struct dbg_lvalue* lv if (!types_compare(lvalue_to->type, lvalue_from->type, &equal)) return FALSE; if (equal) return memory_transfer_value(lvalue_to, lvalue_from); + if (types_is_float_type(lvalue_from) && types_is_float_type(lvalue_to)) + { + double d; + return memory_fetch_float(lvalue_from, &d) && + memory_store_float(lvalue_to, &d); + } } if (types_is_integral_type(lvalue_from) && types_is_integral_type(lvalue_to)) { @@ -175,7 +181,6 @@ BOOL types_store_value(struct dbg_lvalue* lvalue_to, const struct dbg_lvalue* lv dbg_lgint_t val = types_extract_as_integer(lvalue_from); return memory_store_integer(lvalue_to, val); } - /* FIXME: should support floats as well */ dbg_printf("Cannot assign (different types)\n"); return FALSE; return FALSE; } @@ -1077,3 +1082,13 @@ BOOL types_is_integral_type(const struct dbg_lvalue* lv) !types_get_info(&type, TI_GET_BASETYPE, &bt)) return FALSE; return is_basetype_integer(bt); } + +BOOL types_is_float_type(const struct dbg_lvalue* lv) +{ + struct dbg_type type = lv->type; + DWORD tag, bt; + if (lv->bitlen) return FALSE; + if (!types_get_real_type(&type, &tag) || + !types_get_info(&type, TI_GET_BASETYPE, &bt)) return FALSE; + return bt == btFloat; +}