[PATCH 15/18] programs/winedbg: remove fetch_float() method from CPU backends
Eric Pouech
eric.pouech at gmail.com
Fri Dec 3 09:58:27 CST 2021
As they're all the same
Signed-off-by: Eric Pouech <eric.pouech at gmail.com>
---
programs/winedbg/be_arm.c | 18 ------------------
programs/winedbg/be_arm64.c | 18 ------------------
programs/winedbg/be_cpu.h | 3 ---
programs/winedbg/be_i386.c | 18 ------------------
programs/winedbg/be_x86_64.c | 18 ------------------
programs/winedbg/debugger.h | 1 +
programs/winedbg/memory.c | 17 ++++++++++++++++-
7 files changed, 17 insertions(+), 76 deletions(-)
diff --git a/programs/winedbg/be_arm.c b/programs/winedbg/be_arm.c
index 02f72e9c789..a9551a40337 100644
--- a/programs/winedbg/be_arm.c
+++ b/programs/winedbg/be_arm.c
@@ -1831,23 +1831,6 @@ static int be_arm_adjust_pc_for_break(dbg_ctx_t *ctx, BOOL way)
return step;
}
-static BOOL be_arm_fetch_float(const struct dbg_lvalue* lvalue, unsigned size, double *ret)
-{
- char tmp[sizeof(double)];
-
- /* FIXME: this assumes that debuggee and debugger use the same
- * representation for reals
- */
- if (size > sizeof(tmp)) return FALSE;
- if (!memory_read_value(lvalue, size, tmp)) return FALSE;
-
- if (size == sizeof(float)) *ret = *(float*)tmp;
- else if (size == sizeof(double)) *ret = *(double*)tmp;
- else return FALSE;
-
- return TRUE;
-}
-
static BOOL be_arm_get_context(HANDLE thread, dbg_ctx_t *ctx)
{
ctx->ctx.ContextFlags = CONTEXT_ALL;
@@ -1904,7 +1887,6 @@ struct backend_cpu be_arm =
be_arm_is_watchpoint_set,
be_arm_clear_watchpoint,
be_arm_adjust_pc_for_break,
- be_arm_fetch_float,
be_arm_get_context,
be_arm_set_context,
be_arm_gdb_register_map,
diff --git a/programs/winedbg/be_arm64.c b/programs/winedbg/be_arm64.c
index 8ca54e6c461..ab64801e6db 100644
--- a/programs/winedbg/be_arm64.c
+++ b/programs/winedbg/be_arm64.c
@@ -228,23 +228,6 @@ static int be_arm64_adjust_pc_for_break(dbg_ctx_t *ctx, BOOL way)
return 4;
}
-static BOOL be_arm64_fetch_float(const struct dbg_lvalue* lvalue, unsigned size, double *ret)
-{
- char tmp[sizeof(double)];
-
- /* FIXME: this assumes that debuggee and debugger use the same
- * representation for reals
- */
- if (size > sizeof(tmp)) return FALSE;
- if (!memory_read_value(lvalue, size, tmp)) return FALSE;
-
- if (size == sizeof(float)) *ret = *(float*)tmp;
- else if (size == sizeof(double)) *ret = *(double*)tmp;
- else return FALSE;
-
- return TRUE;
-}
-
void be_arm64_disasm_one_insn(ADDRESS64 *addr, int display)
{
dbg_printf("be_arm64_disasm_one_insn: not done\n");
@@ -323,7 +306,6 @@ struct backend_cpu be_arm64 =
be_arm64_is_watchpoint_set,
be_arm64_clear_watchpoint,
be_arm64_adjust_pc_for_break,
- be_arm64_fetch_float,
be_arm64_get_context,
be_arm64_set_context,
be_arm64_gdb_register_map,
diff --git a/programs/winedbg/be_cpu.h b/programs/winedbg/be_cpu.h
index 69e3e148f75..0c4f9b8f056 100644
--- a/programs/winedbg/be_cpu.h
+++ b/programs/winedbg/be_cpu.h
@@ -118,9 +118,6 @@ struct backend_cpu
/* -------------------------------------------------------------------------------
* basic type read/write
* -------------------------------------------------------------------------------*/
- /* Reads a real from memory and stores it inside a long double */
- BOOL (*fetch_float)(const struct dbg_lvalue* lvalue, unsigned size, double*);
-
BOOL (*get_context)(HANDLE thread, dbg_ctx_t *ctx);
BOOL (*set_context)(HANDLE thread, const dbg_ctx_t *ctx);
diff --git a/programs/winedbg/be_i386.c b/programs/winedbg/be_i386.c
index 9b3c615092c..262e68894d5 100644
--- a/programs/winedbg/be_i386.c
+++ b/programs/winedbg/be_i386.c
@@ -777,23 +777,6 @@ static int be_i386_adjust_pc_for_break(dbg_ctx_t *ctx, BOOL way)
return 1;
}
-static BOOL be_i386_fetch_float(const struct dbg_lvalue* lvalue, unsigned size, double *ret)
-{
- char tmp[sizeof(double)];
-
- /* FIXME: this assumes that debuggee and debugger use the same
- * representation for reals
- */
- if (size > sizeof(tmp)) return FALSE;
- if (!memory_read_value(lvalue, size, tmp)) return FALSE;
-
- if (size == sizeof(float)) *ret = *(float*)tmp;
- else if (size == sizeof(double)) *ret = *(double*)tmp;
- else return FALSE;
-
- return TRUE;
-}
-
static BOOL be_i386_get_context(HANDLE thread, dbg_ctx_t *ctx)
{
ctx->x86.ContextFlags = WOW64_CONTEXT_ALL;
@@ -875,7 +858,6 @@ struct backend_cpu be_i386 =
be_i386_is_watchpoint_set,
be_i386_clear_watchpoint,
be_i386_adjust_pc_for_break,
- be_i386_fetch_float,
be_i386_get_context,
be_i386_set_context,
be_i386_gdb_register_map,
diff --git a/programs/winedbg/be_x86_64.c b/programs/winedbg/be_x86_64.c
index 169a31a584d..44079c2fe76 100644
--- a/programs/winedbg/be_x86_64.c
+++ b/programs/winedbg/be_x86_64.c
@@ -699,23 +699,6 @@ static int be_x86_64_adjust_pc_for_break(dbg_ctx_t *ctx, BOOL way)
return 1;
}
-static BOOL be_x86_64_fetch_float(const struct dbg_lvalue* lvalue, unsigned size, double *ret)
-{
- char tmp[sizeof(double)];
-
- /* FIXME: this assumes that debuggee and debugger use the same
- * representation for reals
- */
- if (size > sizeof(tmp)) return FALSE;
- if (!memory_read_value(lvalue, size, tmp)) return FALSE;
-
- if (size == sizeof(float)) *ret = *(float*)tmp;
- else if (size == sizeof(double)) *ret = *(double*)tmp;
- else return FALSE;
-
- return TRUE;
-}
-
static BOOL be_x86_64_get_context(HANDLE thread, dbg_ctx_t *ctx)
{
ctx->ctx.ContextFlags = CONTEXT_ALL;
@@ -813,7 +796,6 @@ struct backend_cpu be_x86_64 =
be_x86_64_is_watchpoint_set,
be_x86_64_clear_watchpoint,
be_x86_64_adjust_pc_for_break,
- be_x86_64_fetch_float,
be_x86_64_get_context,
be_x86_64_set_context,
be_x86_64_gdb_register_map,
diff --git a/programs/winedbg/debugger.h b/programs/winedbg/debugger.h
index 801217b025d..6f05b4b1160 100644
--- a/programs/winedbg/debugger.h
+++ b/programs/winedbg/debugger.h
@@ -403,6 +403,7 @@ extern BOOL memory_transfer_value(const struct dbg_lvalue* to, const
extern BOOL memory_fetch_integer(const struct dbg_lvalue* lvalue, unsigned size,
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 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);
diff --git a/programs/winedbg/memory.c b/programs/winedbg/memory.c
index 64271c46780..04320742501 100644
--- a/programs/winedbg/memory.c
+++ b/programs/winedbg/memory.c
@@ -338,6 +338,21 @@ BOOL memory_store_integer(const struct dbg_lvalue* lvalue, dbg_lgint_t val)
return memory_write_value(lvalue, (unsigned)size, &val);
}
+BOOL memory_fetch_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 (!memory_read_value(lvalue, size, ret)) return FALSE;
+
+ if (size == sizeof(float)) *ret = *(float*)ret;
+ else if (size != sizeof(double)) return FALSE;
+
+ return TRUE;
+}
BOOL memory_get_string(struct dbg_process* pcs, void* addr, BOOL in_debuggee,
BOOL unicode, char* buffer, int size)
@@ -483,7 +498,7 @@ static void print_typed_basic(const struct dbg_lvalue* lvalue)
dbg_print_hex(size, val_int);
break;
case btFloat:
- if (!dbg_curr_process->be_cpu->fetch_float(lvalue, size, &val_real)) return;
+ if (!memory_fetch_float(lvalue, &val_real)) return;
dbg_printf("%f", val_real);
break;
case btChar:
More information about the wine-devel
mailing list