In order not to repeat the features, registers are expected to be ordered and grouped by feature. If feature name is set only on the first register of a new feature.
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- programs/winedbg/be_arm.c | 37 ++++----- programs/winedbg/be_arm64.c | 70 ++++++++--------- programs/winedbg/be_cpu.h | 1 + programs/winedbg/be_i386.c | 85 ++++++++++---------- programs/winedbg/be_ppc.c | 146 ++++++++++++++++++----------------- programs/winedbg/be_x86_64.c | 117 ++++++++++++++-------------- 6 files changed, 231 insertions(+), 225 deletions(-)
diff --git a/programs/winedbg/be_arm.c b/programs/winedbg/be_arm.c index ad0e2857cda2..afa0a4770cd6 100644 --- a/programs/winedbg/be_arm.c +++ b/programs/winedbg/be_arm.c @@ -1900,26 +1900,27 @@ static BOOL be_arm_set_context(HANDLE thread, const dbg_ctx_t *ctx) return SetThreadContext(thread, &ctx->ctx); }
-#define REG(r,gs) {FIELD_OFFSET(CONTEXT, r), sizeof(((CONTEXT*)NULL)->r), gs} +#define REG(f,r,gs) {f, FIELD_OFFSET(CONTEXT, r), sizeof(((CONTEXT*)NULL)->r), gs}
static struct gdb_register be_arm_gdb_register_map[] = { - REG(R0, 4), - REG(R1, 4), - REG(R2, 4), - REG(R3, 4), - REG(R4, 4), - REG(R5, 4), - REG(R6, 4), - REG(R7, 4), - REG(R8, 4), - REG(R9, 4), - REG(R10, 4), - REG(R11, 4), - REG(R12, 4), - REG(Sp, 4), - REG(Lr, 4), - REG(Pc, 4), - REG(Cpsr, 4), + REG("core", R0, 4), + REG(NULL, R1, 4), + REG(NULL, R2, 4), + REG(NULL, R3, 4), + REG(NULL, R4, 4), + REG(NULL, R5, 4), + REG(NULL, R6, 4), + REG(NULL, R7, 4), + REG(NULL, R8, 4), + REG(NULL, R9, 4), + REG(NULL, R10, 4), + REG(NULL, R11, 4), + REG(NULL, R12, 4), + REG(NULL, R13, 4), + REG(NULL, Sp, 4), + REG(NULL, Lr, 4), + REG(NULL, Pc, 4), + REG(NULL, Cpsr, 4), };
struct backend_cpu be_arm = diff --git a/programs/winedbg/be_arm64.c b/programs/winedbg/be_arm64.c index bca86b825740..7b856cd3d2b9 100644 --- a/programs/winedbg/be_arm64.c +++ b/programs/winedbg/be_arm64.c @@ -289,43 +289,43 @@ static BOOL be_arm64_set_context(HANDLE thread, const dbg_ctx_t *ctx) return SetThreadContext(thread, &ctx->ctx); }
-#define REG(r,gs) {FIELD_OFFSET(CONTEXT, r), sizeof(((CONTEXT*)NULL)->r), gs} +#define REG(f,r,gs) {f, FIELD_OFFSET(CONTEXT, r), sizeof(((CONTEXT*)NULL)->r), gs}
static struct gdb_register be_arm64_gdb_register_map[] = { - REG(Cpsr, 4), - REG(u.s.X0, 8), - REG(u.s.X1, 8), - REG(u.s.X2, 8), - REG(u.s.X3, 8), - REG(u.s.X4, 8), - REG(u.s.X5, 8), - REG(u.s.X6, 8), - REG(u.s.X7, 8), - REG(u.s.X8, 8), - REG(u.s.X9, 8), - REG(u.s.X10, 8), - REG(u.s.X11, 8), - REG(u.s.X12, 8), - REG(u.s.X13, 8), - REG(u.s.X14, 8), - REG(u.s.X15, 8), - REG(u.s.X16, 8), - REG(u.s.X17, 8), - REG(u.s.X18, 8), - REG(u.s.X19, 8), - REG(u.s.X20, 8), - REG(u.s.X21, 8), - REG(u.s.X22, 8), - REG(u.s.X23, 8), - REG(u.s.X24, 8), - REG(u.s.X25, 8), - REG(u.s.X26, 8), - REG(u.s.X27, 8), - REG(u.s.X28, 8), - REG(u.s.Fp, 8), - REG(u.s.Lr, 8), - REG(Sp, 8), - REG(Pc, 8), + REG("core", u.s.X0, 8), + REG(NULL, u.s.X1, 8), + REG(NULL, u.s.X2, 8), + REG(NULL, u.s.X3, 8), + REG(NULL, u.s.X4, 8), + REG(NULL, u.s.X5, 8), + REG(NULL, u.s.X6, 8), + REG(NULL, u.s.X7, 8), + REG(NULL, u.s.X8, 8), + REG(NULL, u.s.X9, 8), + REG(NULL, u.s.X10, 8), + REG(NULL, u.s.X11, 8), + REG(NULL, u.s.X12, 8), + REG(NULL, u.s.X13, 8), + REG(NULL, u.s.X14, 8), + REG(NULL, u.s.X15, 8), + REG(NULL, u.s.X16, 8), + REG(NULL, u.s.X17, 8), + REG(NULL, u.s.X18, 8), + REG(NULL, u.s.X19, 8), + REG(NULL, u.s.X20, 8), + REG(NULL, u.s.X21, 8), + REG(NULL, u.s.X22, 8), + REG(NULL, u.s.X23, 8), + REG(NULL, u.s.X24, 8), + REG(NULL, u.s.X25, 8), + REG(NULL, u.s.X26, 8), + REG(NULL, u.s.X27, 8), + REG(NULL, u.s.X28, 8), + REG(NULL, u.s.Fp, 8), + REG(NULL, u.s.Lr, 8), + REG(NULL, Sp, 8), + REG(NULL, Pc, 8), + REG(NULL, Cpsr, 4), };
struct backend_cpu be_arm64 = diff --git a/programs/winedbg/be_cpu.h b/programs/winedbg/be_cpu.h index ea559b44ba19..f6e712f8aa01 100644 --- a/programs/winedbg/be_cpu.h +++ b/programs/winedbg/be_cpu.h @@ -24,6 +24,7 @@ enum be_xpoint_type {be_xpoint_break, be_xpoint_watch_exec, be_xpoint_watch_read
struct gdb_register { + const char *feature; size_t ctx_offset; size_t ctx_length; size_t gdb_length; diff --git a/programs/winedbg/be_i386.c b/programs/winedbg/be_i386.c index 96562446eacf..cbe6ec3da299 100644 --- a/programs/winedbg/be_i386.c +++ b/programs/winedbg/be_i386.c @@ -865,50 +865,51 @@ static BOOL be_i386_set_context(HANDLE thread, const dbg_ctx_t *ctx) return Wow64SetThreadContext(thread, &ctx->x86); }
-#define REG(r,gs) {FIELD_OFFSET(WOW64_CONTEXT, r), sizeof(((WOW64_CONTEXT*)NULL)->r), gs} +#define REG(f,r,gs) {f, FIELD_OFFSET(WOW64_CONTEXT, r), sizeof(((WOW64_CONTEXT*)NULL)->r), gs}
static struct gdb_register be_i386_gdb_register_map[] = { - REG(Eax, 4), - REG(Ecx, 4), - REG(Edx, 4), - REG(Ebx, 4), - REG(Esp, 4), - REG(Ebp, 4), - REG(Esi, 4), - REG(Edi, 4), - REG(Eip, 4), - REG(EFlags, 4), - REG(SegCs, 4), - REG(SegSs, 4), - REG(SegDs, 4), - REG(SegEs, 4), - REG(SegFs, 4), - REG(SegGs, 4), - { FIELD_OFFSET(WOW64_CONTEXT, FloatSave.RegisterArea[ 0]), 10, 10 }, - { FIELD_OFFSET(WOW64_CONTEXT, FloatSave.RegisterArea[10]), 10, 10 }, - { FIELD_OFFSET(WOW64_CONTEXT, FloatSave.RegisterArea[20]), 10, 10 }, - { FIELD_OFFSET(WOW64_CONTEXT, FloatSave.RegisterArea[30]), 10, 10 }, - { FIELD_OFFSET(WOW64_CONTEXT, FloatSave.RegisterArea[40]), 10, 10 }, - { FIELD_OFFSET(WOW64_CONTEXT, FloatSave.RegisterArea[50]), 10, 10 }, - { FIELD_OFFSET(WOW64_CONTEXT, FloatSave.RegisterArea[60]), 10, 10 }, - { FIELD_OFFSET(WOW64_CONTEXT, FloatSave.RegisterArea[70]), 10, 10 }, - { FIELD_OFFSET(WOW64_CONTEXT, FloatSave.ControlWord), 2, 4 }, - { FIELD_OFFSET(WOW64_CONTEXT, FloatSave.StatusWord), 2, 4 }, - { FIELD_OFFSET(WOW64_CONTEXT, FloatSave.TagWord), 2, 4 }, - { FIELD_OFFSET(WOW64_CONTEXT, FloatSave.ErrorSelector), 2, 4 }, - REG(FloatSave.ErrorOffset, 4 ), - { FIELD_OFFSET(WOW64_CONTEXT, FloatSave.DataSelector), 2, 4 }, - REG(FloatSave.DataOffset, 4 ), - { FIELD_OFFSET(WOW64_CONTEXT, FloatSave.ErrorSelector)+2, 2, 4 }, - { FIELD_OFFSET(WOW64_CONTEXT, ExtendedRegisters) + FIELD_OFFSET(XMM_SAVE_AREA32, XmmRegisters[0]), 16, 16 }, - { FIELD_OFFSET(WOW64_CONTEXT, ExtendedRegisters) + FIELD_OFFSET(XMM_SAVE_AREA32, XmmRegisters[1]), 16, 16 }, - { FIELD_OFFSET(WOW64_CONTEXT, ExtendedRegisters) + FIELD_OFFSET(XMM_SAVE_AREA32, XmmRegisters[2]), 16, 16 }, - { FIELD_OFFSET(WOW64_CONTEXT, ExtendedRegisters) + FIELD_OFFSET(XMM_SAVE_AREA32, XmmRegisters[3]), 16, 16 }, - { FIELD_OFFSET(WOW64_CONTEXT, ExtendedRegisters) + FIELD_OFFSET(XMM_SAVE_AREA32, XmmRegisters[4]), 16, 16 }, - { FIELD_OFFSET(WOW64_CONTEXT, ExtendedRegisters) + FIELD_OFFSET(XMM_SAVE_AREA32, XmmRegisters[5]), 16, 16 }, - { FIELD_OFFSET(WOW64_CONTEXT, ExtendedRegisters) + FIELD_OFFSET(XMM_SAVE_AREA32, XmmRegisters[6]), 16, 16 }, - { FIELD_OFFSET(WOW64_CONTEXT, ExtendedRegisters) + FIELD_OFFSET(XMM_SAVE_AREA32, XmmRegisters[7]), 16, 16 }, - { FIELD_OFFSET(WOW64_CONTEXT, ExtendedRegisters) + FIELD_OFFSET(XMM_SAVE_AREA32, MxCsr), 4, 4 }, + REG("core", Eax, 4), + REG(NULL, Ecx, 4), + REG(NULL, Edx, 4), + REG(NULL, Ebx, 4), + REG(NULL, Esp, 4), + REG(NULL, Ebp, 4), + REG(NULL, Esi, 4), + REG(NULL, Edi, 4), + REG(NULL, Eip, 4), + REG(NULL, EFlags, 4), + REG(NULL, SegCs, 4), + REG(NULL, SegSs, 4), + REG(NULL, SegDs, 4), + REG(NULL, SegEs, 4), + REG(NULL, SegFs, 4), + REG(NULL, SegGs, 4), + { NULL, FIELD_OFFSET(WOW64_CONTEXT, FloatSave.RegisterArea[ 0]), 10, 10}, + { NULL, FIELD_OFFSET(WOW64_CONTEXT, FloatSave.RegisterArea[10]), 10, 10}, + { NULL, FIELD_OFFSET(WOW64_CONTEXT, FloatSave.RegisterArea[20]), 10, 10}, + { NULL, FIELD_OFFSET(WOW64_CONTEXT, FloatSave.RegisterArea[30]), 10, 10}, + { NULL, FIELD_OFFSET(WOW64_CONTEXT, FloatSave.RegisterArea[40]), 10, 10}, + { NULL, FIELD_OFFSET(WOW64_CONTEXT, FloatSave.RegisterArea[50]), 10, 10}, + { NULL, FIELD_OFFSET(WOW64_CONTEXT, FloatSave.RegisterArea[60]), 10, 10}, + { NULL, FIELD_OFFSET(WOW64_CONTEXT, FloatSave.RegisterArea[70]), 10, 10}, + { NULL, FIELD_OFFSET(WOW64_CONTEXT, FloatSave.ControlWord), 2, 4}, + { NULL, FIELD_OFFSET(WOW64_CONTEXT, FloatSave.StatusWord), 2, 4}, + { NULL, FIELD_OFFSET(WOW64_CONTEXT, FloatSave.TagWord), 2, 4}, + { NULL, FIELD_OFFSET(WOW64_CONTEXT, FloatSave.ErrorSelector), 2, 4}, + REG(NULL, FloatSave.ErrorOffset, 4), + { NULL, FIELD_OFFSET(WOW64_CONTEXT, FloatSave.DataSelector), 2, 4}, + REG(NULL, FloatSave.DataOffset, 4), + { NULL, FIELD_OFFSET(WOW64_CONTEXT, FloatSave.ErrorSelector) + 2, 2, 4}, + + { "sse", FIELD_OFFSET(WOW64_CONTEXT, ExtendedRegisters) + FIELD_OFFSET(XMM_SAVE_AREA32, XmmRegisters[0]), 16, 16}, + { NULL, FIELD_OFFSET(WOW64_CONTEXT, ExtendedRegisters) + FIELD_OFFSET(XMM_SAVE_AREA32, XmmRegisters[1]), 16, 16}, + { NULL, FIELD_OFFSET(WOW64_CONTEXT, ExtendedRegisters) + FIELD_OFFSET(XMM_SAVE_AREA32, XmmRegisters[2]), 16, 16}, + { NULL, FIELD_OFFSET(WOW64_CONTEXT, ExtendedRegisters) + FIELD_OFFSET(XMM_SAVE_AREA32, XmmRegisters[3]), 16, 16}, + { NULL, FIELD_OFFSET(WOW64_CONTEXT, ExtendedRegisters) + FIELD_OFFSET(XMM_SAVE_AREA32, XmmRegisters[4]), 16, 16}, + { NULL, FIELD_OFFSET(WOW64_CONTEXT, ExtendedRegisters) + FIELD_OFFSET(XMM_SAVE_AREA32, XmmRegisters[5]), 16, 16}, + { NULL, FIELD_OFFSET(WOW64_CONTEXT, ExtendedRegisters) + FIELD_OFFSET(XMM_SAVE_AREA32, XmmRegisters[6]), 16, 16}, + { NULL, FIELD_OFFSET(WOW64_CONTEXT, ExtendedRegisters) + FIELD_OFFSET(XMM_SAVE_AREA32, XmmRegisters[7]), 16, 16}, + { NULL, FIELD_OFFSET(WOW64_CONTEXT, ExtendedRegisters) + FIELD_OFFSET(XMM_SAVE_AREA32, MxCsr), 4, 4}, };
struct backend_cpu be_i386 = diff --git a/programs/winedbg/be_ppc.c b/programs/winedbg/be_ppc.c index ff6ece6df3ae..5e49a3930d39 100644 --- a/programs/winedbg/be_ppc.c +++ b/programs/winedbg/be_ppc.c @@ -191,80 +191,82 @@ static BOOL be_ppc_set_context(HANDLE thread, const dbg_ctx_t *ctx) return SetThreadContext(thread, &ctx->ctx); }
-#define REG(r,gs,m) {FIELD_OFFSET(CONTEXT, r), sizeof(((CONTEXT*)NULL)->r), gs, m} +#define REG(f,r,gs) {f, FIELD_OFFSET(CONTEXT, r), sizeof(((CONTEXT*)NULL)->r), gs}
static struct gdb_register be_ppc_gdb_register_map[] = { - REG(Gpr0, 4), - REG(Gpr1, 4), - REG(Gpr2, 4), - REG(Gpr3, 4), - REG(Gpr4, 4), - REG(Gpr5, 4), - REG(Gpr6, 4), - REG(Gpr7, 4), - REG(Gpr8, 4), - REG(Gpr9, 4), - REG(Gpr10, 4), - REG(Gpr11, 4), - REG(Gpr12, 4), - REG(Gpr13, 4), - REG(Gpr14, 4), - REG(Gpr15, 4), - REG(Gpr16, 4), - REG(Gpr17, 4), - REG(Gpr18, 4), - REG(Gpr19, 4), - REG(Gpr20, 4), - REG(Gpr21, 4), - REG(Gpr22, 4), - REG(Gpr23, 4), - REG(Gpr24, 4), - REG(Gpr25, 4), - REG(Gpr26, 4), - REG(Gpr27, 4), - REG(Gpr28, 4), - REG(Gpr29, 4), - REG(Gpr30, 4), - REG(Gpr31, 4), - REG(Fpr0, 4), - REG(Fpr1, 4), - REG(Fpr2, 4), - REG(Fpr3, 4), - REG(Fpr4, 4), - REG(Fpr5, 4), - REG(Fpr6, 4), - REG(Fpr7, 4), - REG(Fpr8, 4), - REG(Fpr9, 4), - REG(Fpr10, 4), - REG(Fpr11, 4), - REG(Fpr12, 4), - REG(Fpr13, 4), - REG(Fpr14, 4), - REG(Fpr15, 4), - REG(Fpr16, 4), - REG(Fpr17, 4), - REG(Fpr18, 4), - REG(Fpr19, 4), - REG(Fpr20, 4), - REG(Fpr21, 4), - REG(Fpr22, 4), - REG(Fpr23, 4), - REG(Fpr24, 4), - REG(Fpr25, 4), - REG(Fpr26, 4), - REG(Fpr27, 4), - REG(Fpr28, 4), - REG(Fpr29, 4), - REG(Fpr30, 4), - REG(Fpr31, 4), - - REG(Iar, 4), - REG(Msr, 4), - REG(Cr, 4), - REG(Lr, 4), - REG(Ctr, 4), - REG(Xer, 4), + REG("core", Gpr0, 4), + REG(NULL, Gpr1, 4), + REG(NULL, Gpr2, 4), + REG(NULL, Gpr3, 4), + REG(NULL, Gpr4, 4), + REG(NULL, Gpr5, 4), + REG(NULL, Gpr6, 4), + REG(NULL, Gpr7, 4), + REG(NULL, Gpr8, 4), + REG(NULL, Gpr9, 4), + REG(NULL, Gpr10, 4), + REG(NULL, Gpr11, 4), + REG(NULL, Gpr12, 4), + REG(NULL, Gpr13, 4), + REG(NULL, Gpr14, 4), + REG(NULL, Gpr15, 4), + REG(NULL, Gpr16, 4), + REG(NULL, Gpr17, 4), + REG(NULL, Gpr18, 4), + REG(NULL, Gpr19, 4), + REG(NULL, Gpr20, 4), + REG(NULL, Gpr21, 4), + REG(NULL, Gpr22, 4), + REG(NULL, Gpr23, 4), + REG(NULL, Gpr24, 4), + REG(NULL, Gpr25, 4), + REG(NULL, Gpr26, 4), + REG(NULL, Gpr27, 4), + REG(NULL, Gpr28, 4), + REG(NULL, Gpr29, 4), + REG(NULL, Gpr30, 4), + REG(NULL, Gpr31, 4), + REG(NULL, Iar, 4), + REG(NULL, Msr, 4), + REG(NULL, Cr, 4), + REG(NULL, Lr, 4), + REG(NULL, Ctr, 4), + REG(NULL, Xer, 4), + + REG("fpu", Fpr0, 4), + REG(NULL, Fpr1, 4), + REG(NULL, Fpr2, 4), + REG(NULL, Fpr3, 4), + REG(NULL, Fpr4, 4), + REG(NULL, Fpr5, 4), + REG(NULL, Fpr6, 4), + REG(NULL, Fpr7, 4), + REG(NULL, Fpr8, 4), + REG(NULL, Fpr9, 4), + REG(NULL, Fpr10, 4), + REG(NULL, Fpr11, 4), + REG(NULL, Fpr12, 4), + REG(NULL, Fpr13, 4), + REG(NULL, Fpr14, 4), + REG(NULL, Fpr15, 4), + REG(NULL, Fpr16, 4), + REG(NULL, Fpr17, 4), + REG(NULL, Fpr18, 4), + REG(NULL, Fpr19, 4), + REG(NULL, Fpr20, 4), + REG(NULL, Fpr21, 4), + REG(NULL, Fpr22, 4), + REG(NULL, Fpr23, 4), + REG(NULL, Fpr24, 4), + REG(NULL, Fpr25, 4), + REG(NULL, Fpr26, 4), + REG(NULL, Fpr27, 4), + REG(NULL, Fpr28, 4), + REG(NULL, Fpr29, 4), + REG(NULL, Fpr30, 4), + REG(NULL, Fpr31, 4), + REG(NULL, Fpscr, 4), + /* FIXME: MQ is missing? FIELD_OFFSET(CONTEXT, Mq), */ /* see gdb/nlm/ppc.c */ }; diff --git a/programs/winedbg/be_x86_64.c b/programs/winedbg/be_x86_64.c index 83cbb3c05cee..22058ed15b0e 100644 --- a/programs/winedbg/be_x86_64.c +++ b/programs/winedbg/be_x86_64.c @@ -768,66 +768,67 @@ static BOOL be_x86_64_set_context(HANDLE thread, const dbg_ctx_t *ctx) return SetThreadContext(thread, &ctx->ctx); }
-#define REG(r,gs) {FIELD_OFFSET(CONTEXT, r), sizeof(((CONTEXT*)NULL)->r), gs} +#define REG(f,r,gs) {f, FIELD_OFFSET(CONTEXT, r), sizeof(((CONTEXT*)NULL)->r), gs}
static struct gdb_register be_x86_64_gdb_register_map[] = { - REG(Rax, 8), - REG(Rbx, 8), - REG(Rcx, 8), - REG(Rdx, 8), - REG(Rsi, 8), - REG(Rdi, 8), - REG(Rbp, 8), - REG(Rsp, 8), - REG(R8, 8), - REG(R9, 8), - REG(R10, 8), - REG(R11, 8), - REG(R12, 8), - REG(R13, 8), - REG(R14, 8), - REG(R15, 8), - REG(Rip, 8), - REG(EFlags, 4), - REG(SegCs, 4), - REG(SegSs, 4), - REG(SegDs, 4), - REG(SegEs, 4), - REG(SegFs, 4), - REG(SegGs, 4), - { FIELD_OFFSET(CONTEXT, u.FltSave.FloatRegisters[ 0]), 10, 10 }, - { FIELD_OFFSET(CONTEXT, u.FltSave.FloatRegisters[ 1]), 10, 10 }, - { FIELD_OFFSET(CONTEXT, u.FltSave.FloatRegisters[ 2]), 10, 10 }, - { FIELD_OFFSET(CONTEXT, u.FltSave.FloatRegisters[ 3]), 10, 10 }, - { FIELD_OFFSET(CONTEXT, u.FltSave.FloatRegisters[ 4]), 10, 10 }, - { FIELD_OFFSET(CONTEXT, u.FltSave.FloatRegisters[ 5]), 10, 10 }, - { FIELD_OFFSET(CONTEXT, u.FltSave.FloatRegisters[ 6]), 10, 10 }, - { FIELD_OFFSET(CONTEXT, u.FltSave.FloatRegisters[ 7]), 10, 10 }, - REG(u.FltSave.ControlWord, 4), - REG(u.FltSave.StatusWord, 4), - REG(u.FltSave.TagWord, 4), - REG(u.FltSave.ErrorSelector, 4), - REG(u.FltSave.ErrorOffset, 4), - REG(u.FltSave.DataSelector, 4), - REG(u.FltSave.DataOffset, 4), - REG(u.FltSave.ErrorOpcode, 4), - REG(u.s.Xmm0, 16), - REG(u.s.Xmm1, 16), - REG(u.s.Xmm2, 16), - REG(u.s.Xmm3, 16), - REG(u.s.Xmm4, 16), - REG(u.s.Xmm5, 16), - REG(u.s.Xmm6, 16), - REG(u.s.Xmm7, 16), - REG(u.s.Xmm8, 16), - REG(u.s.Xmm9, 16), - REG(u.s.Xmm10, 16), - REG(u.s.Xmm11, 16), - REG(u.s.Xmm12, 16), - REG(u.s.Xmm13, 16), - REG(u.s.Xmm14, 16), - REG(u.s.Xmm15, 16), - REG(u.FltSave.MxCsr, 4), + REG("core", Rax, 8), + REG(NULL, Rbx, 8), + REG(NULL, Rcx, 8), + REG(NULL, Rdx, 8), + REG(NULL, Rsi, 8), + REG(NULL, Rdi, 8), + REG(NULL, Rbp, 8), + REG(NULL, Rsp, 8), + REG(NULL, R8, 8), + REG(NULL, R9, 8), + REG(NULL, R10, 8), + REG(NULL, R11, 8), + REG(NULL, R12, 8), + REG(NULL, R13, 8), + REG(NULL, R14, 8), + REG(NULL, R15, 8), + REG(NULL, Rip, 8), + REG(NULL, EFlags, 4), + REG(NULL, SegCs, 4), + REG(NULL, SegSs, 4), + REG(NULL, SegDs, 4), + REG(NULL, SegEs, 4), + REG(NULL, SegFs, 4), + REG(NULL, SegGs, 4), + { NULL, FIELD_OFFSET(CONTEXT, u.FltSave.FloatRegisters[ 0]), 10, 10}, + { NULL, FIELD_OFFSET(CONTEXT, u.FltSave.FloatRegisters[ 1]), 10, 10}, + { NULL, FIELD_OFFSET(CONTEXT, u.FltSave.FloatRegisters[ 2]), 10, 10}, + { NULL, FIELD_OFFSET(CONTEXT, u.FltSave.FloatRegisters[ 3]), 10, 10}, + { NULL, FIELD_OFFSET(CONTEXT, u.FltSave.FloatRegisters[ 4]), 10, 10}, + { NULL, FIELD_OFFSET(CONTEXT, u.FltSave.FloatRegisters[ 5]), 10, 10}, + { NULL, FIELD_OFFSET(CONTEXT, u.FltSave.FloatRegisters[ 6]), 10, 10}, + { NULL, FIELD_OFFSET(CONTEXT, u.FltSave.FloatRegisters[ 7]), 10, 10}, + REG(NULL, u.FltSave.ControlWord, 4), + REG(NULL, u.FltSave.StatusWord, 4), + REG(NULL, u.FltSave.TagWord, 4), + REG(NULL, u.FltSave.ErrorSelector, 4), + REG(NULL, u.FltSave.ErrorOffset, 4), + REG(NULL, u.FltSave.DataSelector, 4), + REG(NULL, u.FltSave.DataOffset, 4), + REG(NULL, u.FltSave.ErrorOpcode, 4), + + REG("sse", u.s.Xmm0, 16), + REG(NULL, u.s.Xmm1, 16), + REG(NULL, u.s.Xmm2, 16), + REG(NULL, u.s.Xmm3, 16), + REG(NULL, u.s.Xmm4, 16), + REG(NULL, u.s.Xmm5, 16), + REG(NULL, u.s.Xmm6, 16), + REG(NULL, u.s.Xmm7, 16), + REG(NULL, u.s.Xmm8, 16), + REG(NULL, u.s.Xmm9, 16), + REG(NULL, u.s.Xmm10, 16), + REG(NULL, u.s.Xmm11, 16), + REG(NULL, u.s.Xmm12, 16), + REG(NULL, u.s.Xmm13, 16), + REG(NULL, u.s.Xmm14, 16), + REG(NULL, u.s.Xmm15, 16), + REG(NULL, u.FltSave.MxCsr, 4), };
struct backend_cpu be_x86_64 =
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- programs/winedbg/be_arm.c | 38 ++++----- programs/winedbg/be_arm64.c | 70 ++++++++--------- programs/winedbg/be_cpu.h | 1 + programs/winedbg/be_i386.c | 86 ++++++++++----------- programs/winedbg/be_ppc.c | 146 +++++++++++++++++------------------ programs/winedbg/be_x86_64.c | 118 ++++++++++++++-------------- 6 files changed, 230 insertions(+), 229 deletions(-)
diff --git a/programs/winedbg/be_arm.c b/programs/winedbg/be_arm.c index afa0a4770cd6..c7e4de20afe1 100644 --- a/programs/winedbg/be_arm.c +++ b/programs/winedbg/be_arm.c @@ -1900,27 +1900,27 @@ static BOOL be_arm_set_context(HANDLE thread, const dbg_ctx_t *ctx) return SetThreadContext(thread, &ctx->ctx); }
-#define REG(f,r,gs) {f, FIELD_OFFSET(CONTEXT, r), sizeof(((CONTEXT*)NULL)->r), gs} +#define REG(f,n,r,gs) {f, n, FIELD_OFFSET(CONTEXT, r), sizeof(((CONTEXT*)NULL)->r), gs}
static struct gdb_register be_arm_gdb_register_map[] = { - REG("core", R0, 4), - REG(NULL, R1, 4), - REG(NULL, R2, 4), - REG(NULL, R3, 4), - REG(NULL, R4, 4), - REG(NULL, R5, 4), - REG(NULL, R6, 4), - REG(NULL, R7, 4), - REG(NULL, R8, 4), - REG(NULL, R9, 4), - REG(NULL, R10, 4), - REG(NULL, R11, 4), - REG(NULL, R12, 4), - REG(NULL, R13, 4), - REG(NULL, Sp, 4), - REG(NULL, Lr, 4), - REG(NULL, Pc, 4), - REG(NULL, Cpsr, 4), + REG("core", "r0", R0, 4), + REG(NULL, "r1", R1, 4), + REG(NULL, "r2", R2, 4), + REG(NULL, "r3", R3, 4), + REG(NULL, "r4", R4, 4), + REG(NULL, "r5", R5, 4), + REG(NULL, "r6", R6, 4), + REG(NULL, "r7", R7, 4), + REG(NULL, "r8", R8, 4), + REG(NULL, "r9", R9, 4), + REG(NULL, "r10", R10, 4), + REG(NULL, "r11", R11, 4), + REG(NULL, "r12", R12, 4), + REG(NULL, "r13", R13, 4), + REG(NULL, "sp", Sp, 4), + REG(NULL, "lr", Lr, 4), + REG(NULL, "pc", Pc, 4), + REG(NULL, "cpsr", Cpsr, 4), };
struct backend_cpu be_arm = diff --git a/programs/winedbg/be_arm64.c b/programs/winedbg/be_arm64.c index 7b856cd3d2b9..131cf561cfbb 100644 --- a/programs/winedbg/be_arm64.c +++ b/programs/winedbg/be_arm64.c @@ -289,43 +289,43 @@ static BOOL be_arm64_set_context(HANDLE thread, const dbg_ctx_t *ctx) return SetThreadContext(thread, &ctx->ctx); }
-#define REG(f,r,gs) {f, FIELD_OFFSET(CONTEXT, r), sizeof(((CONTEXT*)NULL)->r), gs} +#define REG(f,n,r,gs) {f, n, FIELD_OFFSET(CONTEXT, r), sizeof(((CONTEXT*)NULL)->r), gs}
static struct gdb_register be_arm64_gdb_register_map[] = { - REG("core", u.s.X0, 8), - REG(NULL, u.s.X1, 8), - REG(NULL, u.s.X2, 8), - REG(NULL, u.s.X3, 8), - REG(NULL, u.s.X4, 8), - REG(NULL, u.s.X5, 8), - REG(NULL, u.s.X6, 8), - REG(NULL, u.s.X7, 8), - REG(NULL, u.s.X8, 8), - REG(NULL, u.s.X9, 8), - REG(NULL, u.s.X10, 8), - REG(NULL, u.s.X11, 8), - REG(NULL, u.s.X12, 8), - REG(NULL, u.s.X13, 8), - REG(NULL, u.s.X14, 8), - REG(NULL, u.s.X15, 8), - REG(NULL, u.s.X16, 8), - REG(NULL, u.s.X17, 8), - REG(NULL, u.s.X18, 8), - REG(NULL, u.s.X19, 8), - REG(NULL, u.s.X20, 8), - REG(NULL, u.s.X21, 8), - REG(NULL, u.s.X22, 8), - REG(NULL, u.s.X23, 8), - REG(NULL, u.s.X24, 8), - REG(NULL, u.s.X25, 8), - REG(NULL, u.s.X26, 8), - REG(NULL, u.s.X27, 8), - REG(NULL, u.s.X28, 8), - REG(NULL, u.s.Fp, 8), - REG(NULL, u.s.Lr, 8), - REG(NULL, Sp, 8), - REG(NULL, Pc, 8), - REG(NULL, Cpsr, 4), + REG("core", "x0", u.s.X0, 8), + REG(NULL, "x1", u.s.X1, 8), + REG(NULL, "x2", u.s.X2, 8), + REG(NULL, "x3", u.s.X3, 8), + REG(NULL, "x4", u.s.X4, 8), + REG(NULL, "x5", u.s.X5, 8), + REG(NULL, "x6", u.s.X6, 8), + REG(NULL, "x7", u.s.X7, 8), + REG(NULL, "x8", u.s.X8, 8), + REG(NULL, "x9", u.s.X9, 8), + REG(NULL, "x10", u.s.X10, 8), + REG(NULL, "x11", u.s.X11, 8), + REG(NULL, "x12", u.s.X12, 8), + REG(NULL, "x13", u.s.X13, 8), + REG(NULL, "x14", u.s.X14, 8), + REG(NULL, "x15", u.s.X15, 8), + REG(NULL, "x16", u.s.X16, 8), + REG(NULL, "x17", u.s.X17, 8), + REG(NULL, "x18", u.s.X18, 8), + REG(NULL, "x19", u.s.X19, 8), + REG(NULL, "x20", u.s.X20, 8), + REG(NULL, "x21", u.s.X21, 8), + REG(NULL, "x22", u.s.X22, 8), + REG(NULL, "x23", u.s.X23, 8), + REG(NULL, "x24", u.s.X24, 8), + REG(NULL, "x25", u.s.X25, 8), + REG(NULL, "x26", u.s.X26, 8), + REG(NULL, "x27", u.s.X27, 8), + REG(NULL, "x28", u.s.X28, 8), + REG(NULL, "x29", u.s.Fp, 8), + REG(NULL, "x30", u.s.Lr, 8), + REG(NULL, "sp", Sp, 8), + REG(NULL, "pc", Pc, 8), + REG(NULL, "cpsr", Cpsr, 4), };
struct backend_cpu be_arm64 = diff --git a/programs/winedbg/be_cpu.h b/programs/winedbg/be_cpu.h index f6e712f8aa01..1b7c153f7496 100644 --- a/programs/winedbg/be_cpu.h +++ b/programs/winedbg/be_cpu.h @@ -25,6 +25,7 @@ enum be_xpoint_type {be_xpoint_break, be_xpoint_watch_exec, be_xpoint_watch_read struct gdb_register { const char *feature; + const char *name; size_t ctx_offset; size_t ctx_length; size_t gdb_length; diff --git a/programs/winedbg/be_i386.c b/programs/winedbg/be_i386.c index cbe6ec3da299..199ee34cf08e 100644 --- a/programs/winedbg/be_i386.c +++ b/programs/winedbg/be_i386.c @@ -865,51 +865,51 @@ static BOOL be_i386_set_context(HANDLE thread, const dbg_ctx_t *ctx) return Wow64SetThreadContext(thread, &ctx->x86); }
-#define REG(f,r,gs) {f, FIELD_OFFSET(WOW64_CONTEXT, r), sizeof(((WOW64_CONTEXT*)NULL)->r), gs} +#define REG(f,n,r,gs) {f, n, FIELD_OFFSET(WOW64_CONTEXT, r), sizeof(((WOW64_CONTEXT*)NULL)->r), gs}
static struct gdb_register be_i386_gdb_register_map[] = { - REG("core", Eax, 4), - REG(NULL, Ecx, 4), - REG(NULL, Edx, 4), - REG(NULL, Ebx, 4), - REG(NULL, Esp, 4), - REG(NULL, Ebp, 4), - REG(NULL, Esi, 4), - REG(NULL, Edi, 4), - REG(NULL, Eip, 4), - REG(NULL, EFlags, 4), - REG(NULL, SegCs, 4), - REG(NULL, SegSs, 4), - REG(NULL, SegDs, 4), - REG(NULL, SegEs, 4), - REG(NULL, SegFs, 4), - REG(NULL, SegGs, 4), - { NULL, FIELD_OFFSET(WOW64_CONTEXT, FloatSave.RegisterArea[ 0]), 10, 10}, - { NULL, FIELD_OFFSET(WOW64_CONTEXT, FloatSave.RegisterArea[10]), 10, 10}, - { NULL, FIELD_OFFSET(WOW64_CONTEXT, FloatSave.RegisterArea[20]), 10, 10}, - { NULL, FIELD_OFFSET(WOW64_CONTEXT, FloatSave.RegisterArea[30]), 10, 10}, - { NULL, FIELD_OFFSET(WOW64_CONTEXT, FloatSave.RegisterArea[40]), 10, 10}, - { NULL, FIELD_OFFSET(WOW64_CONTEXT, FloatSave.RegisterArea[50]), 10, 10}, - { NULL, FIELD_OFFSET(WOW64_CONTEXT, FloatSave.RegisterArea[60]), 10, 10}, - { NULL, FIELD_OFFSET(WOW64_CONTEXT, FloatSave.RegisterArea[70]), 10, 10}, - { NULL, FIELD_OFFSET(WOW64_CONTEXT, FloatSave.ControlWord), 2, 4}, - { NULL, FIELD_OFFSET(WOW64_CONTEXT, FloatSave.StatusWord), 2, 4}, - { NULL, FIELD_OFFSET(WOW64_CONTEXT, FloatSave.TagWord), 2, 4}, - { NULL, FIELD_OFFSET(WOW64_CONTEXT, FloatSave.ErrorSelector), 2, 4}, - REG(NULL, FloatSave.ErrorOffset, 4), - { NULL, FIELD_OFFSET(WOW64_CONTEXT, FloatSave.DataSelector), 2, 4}, - REG(NULL, FloatSave.DataOffset, 4), - { NULL, FIELD_OFFSET(WOW64_CONTEXT, FloatSave.ErrorSelector) + 2, 2, 4}, - - { "sse", FIELD_OFFSET(WOW64_CONTEXT, ExtendedRegisters) + FIELD_OFFSET(XMM_SAVE_AREA32, XmmRegisters[0]), 16, 16}, - { NULL, FIELD_OFFSET(WOW64_CONTEXT, ExtendedRegisters) + FIELD_OFFSET(XMM_SAVE_AREA32, XmmRegisters[1]), 16, 16}, - { NULL, FIELD_OFFSET(WOW64_CONTEXT, ExtendedRegisters) + FIELD_OFFSET(XMM_SAVE_AREA32, XmmRegisters[2]), 16, 16}, - { NULL, FIELD_OFFSET(WOW64_CONTEXT, ExtendedRegisters) + FIELD_OFFSET(XMM_SAVE_AREA32, XmmRegisters[3]), 16, 16}, - { NULL, FIELD_OFFSET(WOW64_CONTEXT, ExtendedRegisters) + FIELD_OFFSET(XMM_SAVE_AREA32, XmmRegisters[4]), 16, 16}, - { NULL, FIELD_OFFSET(WOW64_CONTEXT, ExtendedRegisters) + FIELD_OFFSET(XMM_SAVE_AREA32, XmmRegisters[5]), 16, 16}, - { NULL, FIELD_OFFSET(WOW64_CONTEXT, ExtendedRegisters) + FIELD_OFFSET(XMM_SAVE_AREA32, XmmRegisters[6]), 16, 16}, - { NULL, FIELD_OFFSET(WOW64_CONTEXT, ExtendedRegisters) + FIELD_OFFSET(XMM_SAVE_AREA32, XmmRegisters[7]), 16, 16}, - { NULL, FIELD_OFFSET(WOW64_CONTEXT, ExtendedRegisters) + FIELD_OFFSET(XMM_SAVE_AREA32, MxCsr), 4, 4}, + REG("core", "eax", Eax, 4), + REG(NULL, "ecx", Ecx, 4), + REG(NULL, "edx", Edx, 4), + REG(NULL, "ebx", Ebx, 4), + REG(NULL, "esp", Esp, 4), + REG(NULL, "ebp", Ebp, 4), + REG(NULL, "esi", Esi, 4), + REG(NULL, "edi", Edi, 4), + REG(NULL, "eip", Eip, 4), + REG(NULL, "eflags", EFlags, 4), + REG(NULL, "cs", SegCs, 4), + REG(NULL, "ss", SegSs, 4), + REG(NULL, "ds", SegDs, 4), + REG(NULL, "es", SegEs, 4), + REG(NULL, "fs", SegFs, 4), + REG(NULL, "gs", SegGs, 4), + { NULL, "st0", FIELD_OFFSET(WOW64_CONTEXT, FloatSave.RegisterArea[ 0]), 10, 10}, + { NULL, "st1", FIELD_OFFSET(WOW64_CONTEXT, FloatSave.RegisterArea[10]), 10, 10}, + { NULL, "st2", FIELD_OFFSET(WOW64_CONTEXT, FloatSave.RegisterArea[20]), 10, 10}, + { NULL, "st3", FIELD_OFFSET(WOW64_CONTEXT, FloatSave.RegisterArea[30]), 10, 10}, + { NULL, "st4", FIELD_OFFSET(WOW64_CONTEXT, FloatSave.RegisterArea[40]), 10, 10}, + { NULL, "st5", FIELD_OFFSET(WOW64_CONTEXT, FloatSave.RegisterArea[50]), 10, 10}, + { NULL, "st6", FIELD_OFFSET(WOW64_CONTEXT, FloatSave.RegisterArea[60]), 10, 10}, + { NULL, "st7", FIELD_OFFSET(WOW64_CONTEXT, FloatSave.RegisterArea[70]), 10, 10}, + { NULL, "fctrl", FIELD_OFFSET(WOW64_CONTEXT, FloatSave.ControlWord), 2, 4}, + { NULL, "fstat", FIELD_OFFSET(WOW64_CONTEXT, FloatSave.StatusWord), 2, 4}, + { NULL, "ftag", FIELD_OFFSET(WOW64_CONTEXT, FloatSave.TagWord), 2, 4}, + { NULL, "fiseg", FIELD_OFFSET(WOW64_CONTEXT, FloatSave.ErrorSelector), 2, 4}, + REG(NULL, "fioff", FloatSave.ErrorOffset, 4), + { NULL, "foseg", FIELD_OFFSET(WOW64_CONTEXT, FloatSave.DataSelector), 2, 4}, + REG(NULL, "fooff", FloatSave.DataOffset, 4), + { NULL, "fop", FIELD_OFFSET(WOW64_CONTEXT, FloatSave.ErrorSelector) + 2, 2, 4}, + + { "sse", "xmm0", FIELD_OFFSET(WOW64_CONTEXT, ExtendedRegisters) + FIELD_OFFSET(XMM_SAVE_AREA32, XmmRegisters[0]), 16, 16}, + { NULL, "xmm1", FIELD_OFFSET(WOW64_CONTEXT, ExtendedRegisters) + FIELD_OFFSET(XMM_SAVE_AREA32, XmmRegisters[1]), 16, 16}, + { NULL, "xmm2", FIELD_OFFSET(WOW64_CONTEXT, ExtendedRegisters) + FIELD_OFFSET(XMM_SAVE_AREA32, XmmRegisters[2]), 16, 16}, + { NULL, "xmm3", FIELD_OFFSET(WOW64_CONTEXT, ExtendedRegisters) + FIELD_OFFSET(XMM_SAVE_AREA32, XmmRegisters[3]), 16, 16}, + { NULL, "xmm4", FIELD_OFFSET(WOW64_CONTEXT, ExtendedRegisters) + FIELD_OFFSET(XMM_SAVE_AREA32, XmmRegisters[4]), 16, 16}, + { NULL, "xmm5", FIELD_OFFSET(WOW64_CONTEXT, ExtendedRegisters) + FIELD_OFFSET(XMM_SAVE_AREA32, XmmRegisters[5]), 16, 16}, + { NULL, "xmm6", FIELD_OFFSET(WOW64_CONTEXT, ExtendedRegisters) + FIELD_OFFSET(XMM_SAVE_AREA32, XmmRegisters[6]), 16, 16}, + { NULL, "xmm7", FIELD_OFFSET(WOW64_CONTEXT, ExtendedRegisters) + FIELD_OFFSET(XMM_SAVE_AREA32, XmmRegisters[7]), 16, 16}, + { NULL, "mxcsr", FIELD_OFFSET(WOW64_CONTEXT, ExtendedRegisters) + FIELD_OFFSET(XMM_SAVE_AREA32, MxCsr), 4, 4}, };
struct backend_cpu be_i386 = diff --git a/programs/winedbg/be_ppc.c b/programs/winedbg/be_ppc.c index 5e49a3930d39..dae33e5e7f01 100644 --- a/programs/winedbg/be_ppc.c +++ b/programs/winedbg/be_ppc.c @@ -191,81 +191,81 @@ static BOOL be_ppc_set_context(HANDLE thread, const dbg_ctx_t *ctx) return SetThreadContext(thread, &ctx->ctx); }
-#define REG(f,r,gs) {f, FIELD_OFFSET(CONTEXT, r), sizeof(((CONTEXT*)NULL)->r), gs} +#define REG(f,n,r,gs) {f, n, FIELD_OFFSET(CONTEXT, r), sizeof(((CONTEXT*)NULL)->r), gs}
static struct gdb_register be_ppc_gdb_register_map[] = { - REG("core", Gpr0, 4), - REG(NULL, Gpr1, 4), - REG(NULL, Gpr2, 4), - REG(NULL, Gpr3, 4), - REG(NULL, Gpr4, 4), - REG(NULL, Gpr5, 4), - REG(NULL, Gpr6, 4), - REG(NULL, Gpr7, 4), - REG(NULL, Gpr8, 4), - REG(NULL, Gpr9, 4), - REG(NULL, Gpr10, 4), - REG(NULL, Gpr11, 4), - REG(NULL, Gpr12, 4), - REG(NULL, Gpr13, 4), - REG(NULL, Gpr14, 4), - REG(NULL, Gpr15, 4), - REG(NULL, Gpr16, 4), - REG(NULL, Gpr17, 4), - REG(NULL, Gpr18, 4), - REG(NULL, Gpr19, 4), - REG(NULL, Gpr20, 4), - REG(NULL, Gpr21, 4), - REG(NULL, Gpr22, 4), - REG(NULL, Gpr23, 4), - REG(NULL, Gpr24, 4), - REG(NULL, Gpr25, 4), - REG(NULL, Gpr26, 4), - REG(NULL, Gpr27, 4), - REG(NULL, Gpr28, 4), - REG(NULL, Gpr29, 4), - REG(NULL, Gpr30, 4), - REG(NULL, Gpr31, 4), - REG(NULL, Iar, 4), - REG(NULL, Msr, 4), - REG(NULL, Cr, 4), - REG(NULL, Lr, 4), - REG(NULL, Ctr, 4), - REG(NULL, Xer, 4), - - REG("fpu", Fpr0, 4), - REG(NULL, Fpr1, 4), - REG(NULL, Fpr2, 4), - REG(NULL, Fpr3, 4), - REG(NULL, Fpr4, 4), - REG(NULL, Fpr5, 4), - REG(NULL, Fpr6, 4), - REG(NULL, Fpr7, 4), - REG(NULL, Fpr8, 4), - REG(NULL, Fpr9, 4), - REG(NULL, Fpr10, 4), - REG(NULL, Fpr11, 4), - REG(NULL, Fpr12, 4), - REG(NULL, Fpr13, 4), - REG(NULL, Fpr14, 4), - REG(NULL, Fpr15, 4), - REG(NULL, Fpr16, 4), - REG(NULL, Fpr17, 4), - REG(NULL, Fpr18, 4), - REG(NULL, Fpr19, 4), - REG(NULL, Fpr20, 4), - REG(NULL, Fpr21, 4), - REG(NULL, Fpr22, 4), - REG(NULL, Fpr23, 4), - REG(NULL, Fpr24, 4), - REG(NULL, Fpr25, 4), - REG(NULL, Fpr26, 4), - REG(NULL, Fpr27, 4), - REG(NULL, Fpr28, 4), - REG(NULL, Fpr29, 4), - REG(NULL, Fpr30, 4), - REG(NULL, Fpr31, 4), - REG(NULL, Fpscr, 4), + REG("core", "r0", Gpr0, 4), + REG(NULL, "r1", Gpr1, 4), + REG(NULL, "r2", Gpr2, 4), + REG(NULL, "r3", Gpr3, 4), + REG(NULL, "r4", Gpr4, 4), + REG(NULL, "r5", Gpr5, 4), + REG(NULL, "r6", Gpr6, 4), + REG(NULL, "r7", Gpr7, 4), + REG(NULL, "r8", Gpr8, 4), + REG(NULL, "r9", Gpr9, 4), + REG(NULL, "r10", Gpr10, 4), + REG(NULL, "r11", Gpr11, 4), + REG(NULL, "r12", Gpr12, 4), + REG(NULL, "r13", Gpr13, 4), + REG(NULL, "r14", Gpr14, 4), + REG(NULL, "r15", Gpr15, 4), + REG(NULL, "r16", Gpr16, 4), + REG(NULL, "r17", Gpr17, 4), + REG(NULL, "r18", Gpr18, 4), + REG(NULL, "r19", Gpr19, 4), + REG(NULL, "r20", Gpr20, 4), + REG(NULL, "r21", Gpr21, 4), + REG(NULL, "r22", Gpr22, 4), + REG(NULL, "r23", Gpr23, 4), + REG(NULL, "r24", Gpr24, 4), + REG(NULL, "r25", Gpr25, 4), + REG(NULL, "r26", Gpr26, 4), + REG(NULL, "r27", Gpr27, 4), + REG(NULL, "r28", Gpr28, 4), + REG(NULL, "r29", Gpr29, 4), + REG(NULL, "r30", Gpr30, 4), + REG(NULL, "r31", Gpr31, 4), + REG(NULL, "pc", Iar, 4), + REG(NULL, "msr", Msr, 4), + REG(NULL, "cr", Cr, 4), + REG(NULL, "lr", Lr, 4), + REG(NULL, "ctr", Ctr, 4), + REG(NULL, "xer", Xer, 4), + + REG("fpu", "f0", Fpr0, 4), + REG(NULL, "f1", Fpr1, 4), + REG(NULL, "f2", Fpr2, 4), + REG(NULL, "f3", Fpr3, 4), + REG(NULL, "f4", Fpr4, 4), + REG(NULL, "f5", Fpr5, 4), + REG(NULL, "f6", Fpr6, 4), + REG(NULL, "f7", Fpr7, 4), + REG(NULL, "f8", Fpr8, 4), + REG(NULL, "f9", Fpr9, 4), + REG(NULL, "f10", Fpr10, 4), + REG(NULL, "f11", Fpr11, 4), + REG(NULL, "f12", Fpr12, 4), + REG(NULL, "f13", Fpr13, 4), + REG(NULL, "f14", Fpr14, 4), + REG(NULL, "f15", Fpr15, 4), + REG(NULL, "f16", Fpr16, 4), + REG(NULL, "f17", Fpr17, 4), + REG(NULL, "f18", Fpr18, 4), + REG(NULL, "f19", Fpr19, 4), + REG(NULL, "f20", Fpr20, 4), + REG(NULL, "f21", Fpr21, 4), + REG(NULL, "f22", Fpr22, 4), + REG(NULL, "f23", Fpr23, 4), + REG(NULL, "f24", Fpr24, 4), + REG(NULL, "f25", Fpr25, 4), + REG(NULL, "f26", Fpr26, 4), + REG(NULL, "f27", Fpr27, 4), + REG(NULL, "f28", Fpr28, 4), + REG(NULL, "f29", Fpr29, 4), + REG(NULL, "f30", Fpr30, 4), + REG(NULL, "f31", Fpr31, 4), + REG(NULL, "fpscr", Fpscr, 4),
/* FIXME: MQ is missing? FIELD_OFFSET(CONTEXT, Mq), */ /* see gdb/nlm/ppc.c */ diff --git a/programs/winedbg/be_x86_64.c b/programs/winedbg/be_x86_64.c index 22058ed15b0e..3476b03649e1 100644 --- a/programs/winedbg/be_x86_64.c +++ b/programs/winedbg/be_x86_64.c @@ -768,67 +768,67 @@ static BOOL be_x86_64_set_context(HANDLE thread, const dbg_ctx_t *ctx) return SetThreadContext(thread, &ctx->ctx); }
-#define REG(f,r,gs) {f, FIELD_OFFSET(CONTEXT, r), sizeof(((CONTEXT*)NULL)->r), gs} +#define REG(f,n,r,gs) {f, n, FIELD_OFFSET(CONTEXT, r), sizeof(((CONTEXT*)NULL)->r), gs}
static struct gdb_register be_x86_64_gdb_register_map[] = { - REG("core", Rax, 8), - REG(NULL, Rbx, 8), - REG(NULL, Rcx, 8), - REG(NULL, Rdx, 8), - REG(NULL, Rsi, 8), - REG(NULL, Rdi, 8), - REG(NULL, Rbp, 8), - REG(NULL, Rsp, 8), - REG(NULL, R8, 8), - REG(NULL, R9, 8), - REG(NULL, R10, 8), - REG(NULL, R11, 8), - REG(NULL, R12, 8), - REG(NULL, R13, 8), - REG(NULL, R14, 8), - REG(NULL, R15, 8), - REG(NULL, Rip, 8), - REG(NULL, EFlags, 4), - REG(NULL, SegCs, 4), - REG(NULL, SegSs, 4), - REG(NULL, SegDs, 4), - REG(NULL, SegEs, 4), - REG(NULL, SegFs, 4), - REG(NULL, SegGs, 4), - { NULL, FIELD_OFFSET(CONTEXT, u.FltSave.FloatRegisters[ 0]), 10, 10}, - { NULL, FIELD_OFFSET(CONTEXT, u.FltSave.FloatRegisters[ 1]), 10, 10}, - { NULL, FIELD_OFFSET(CONTEXT, u.FltSave.FloatRegisters[ 2]), 10, 10}, - { NULL, FIELD_OFFSET(CONTEXT, u.FltSave.FloatRegisters[ 3]), 10, 10}, - { NULL, FIELD_OFFSET(CONTEXT, u.FltSave.FloatRegisters[ 4]), 10, 10}, - { NULL, FIELD_OFFSET(CONTEXT, u.FltSave.FloatRegisters[ 5]), 10, 10}, - { NULL, FIELD_OFFSET(CONTEXT, u.FltSave.FloatRegisters[ 6]), 10, 10}, - { NULL, FIELD_OFFSET(CONTEXT, u.FltSave.FloatRegisters[ 7]), 10, 10}, - REG(NULL, u.FltSave.ControlWord, 4), - REG(NULL, u.FltSave.StatusWord, 4), - REG(NULL, u.FltSave.TagWord, 4), - REG(NULL, u.FltSave.ErrorSelector, 4), - REG(NULL, u.FltSave.ErrorOffset, 4), - REG(NULL, u.FltSave.DataSelector, 4), - REG(NULL, u.FltSave.DataOffset, 4), - REG(NULL, u.FltSave.ErrorOpcode, 4), - - REG("sse", u.s.Xmm0, 16), - REG(NULL, u.s.Xmm1, 16), - REG(NULL, u.s.Xmm2, 16), - REG(NULL, u.s.Xmm3, 16), - REG(NULL, u.s.Xmm4, 16), - REG(NULL, u.s.Xmm5, 16), - REG(NULL, u.s.Xmm6, 16), - REG(NULL, u.s.Xmm7, 16), - REG(NULL, u.s.Xmm8, 16), - REG(NULL, u.s.Xmm9, 16), - REG(NULL, u.s.Xmm10, 16), - REG(NULL, u.s.Xmm11, 16), - REG(NULL, u.s.Xmm12, 16), - REG(NULL, u.s.Xmm13, 16), - REG(NULL, u.s.Xmm14, 16), - REG(NULL, u.s.Xmm15, 16), - REG(NULL, u.FltSave.MxCsr, 4), + REG("core", "rax", Rax, 8), + REG(NULL, "rbx", Rbx, 8), + REG(NULL, "rcx", Rcx, 8), + REG(NULL, "rdx", Rdx, 8), + REG(NULL, "rsi", Rsi, 8), + REG(NULL, "rdi", Rdi, 8), + REG(NULL, "rbp", Rbp, 8), + REG(NULL, "rsp", Rsp, 8), + REG(NULL, "r8", R8, 8), + REG(NULL, "r9", R9, 8), + REG(NULL, "r10", R10, 8), + REG(NULL, "r11", R11, 8), + REG(NULL, "r12", R12, 8), + REG(NULL, "r13", R13, 8), + REG(NULL, "r14", R14, 8), + REG(NULL, "r15", R15, 8), + REG(NULL, "rip", Rip, 8), + REG(NULL, "eflags", EFlags, 4), + REG(NULL, "cs", SegCs, 4), + REG(NULL, "ss", SegSs, 4), + REG(NULL, "ds", SegDs, 4), + REG(NULL, "es", SegEs, 4), + REG(NULL, "fs", SegFs, 4), + REG(NULL, "gs", SegGs, 4), + { NULL, "st0", FIELD_OFFSET(CONTEXT, u.FltSave.FloatRegisters[ 0]), 10, 10}, + { NULL, "st1", FIELD_OFFSET(CONTEXT, u.FltSave.FloatRegisters[ 1]), 10, 10}, + { NULL, "st2", FIELD_OFFSET(CONTEXT, u.FltSave.FloatRegisters[ 2]), 10, 10}, + { NULL, "st3", FIELD_OFFSET(CONTEXT, u.FltSave.FloatRegisters[ 3]), 10, 10}, + { NULL, "st4", FIELD_OFFSET(CONTEXT, u.FltSave.FloatRegisters[ 4]), 10, 10}, + { NULL, "st5", FIELD_OFFSET(CONTEXT, u.FltSave.FloatRegisters[ 5]), 10, 10}, + { NULL, "st6", FIELD_OFFSET(CONTEXT, u.FltSave.FloatRegisters[ 6]), 10, 10}, + { NULL, "st7", FIELD_OFFSET(CONTEXT, u.FltSave.FloatRegisters[ 7]), 10, 10}, + REG(NULL, "fctrl", u.FltSave.ControlWord, 4), + REG(NULL, "fstat", u.FltSave.StatusWord, 4), + REG(NULL, "ftag", u.FltSave.TagWord, 4), + REG(NULL, "fiseg", u.FltSave.ErrorSelector, 4), + REG(NULL, "fioff", u.FltSave.ErrorOffset, 4), + REG(NULL, "foseg", u.FltSave.DataSelector, 4), + REG(NULL, "fooff", u.FltSave.DataOffset, 4), + REG(NULL, "fop", u.FltSave.ErrorOpcode, 4), + + REG("sse", "xmm0", u.s.Xmm0, 16), + REG(NULL, "xmm1", u.s.Xmm1, 16), + REG(NULL, "xmm2", u.s.Xmm2, 16), + REG(NULL, "xmm3", u.s.Xmm3, 16), + REG(NULL, "xmm4", u.s.Xmm4, 16), + REG(NULL, "xmm5", u.s.Xmm5, 16), + REG(NULL, "xmm6", u.s.Xmm6, 16), + REG(NULL, "xmm7", u.s.Xmm7, 16), + REG(NULL, "xmm8", u.s.Xmm8, 16), + REG(NULL, "xmm9", u.s.Xmm9, 16), + REG(NULL, "xmm10", u.s.Xmm10, 16), + REG(NULL, "xmm11", u.s.Xmm11, 16), + REG(NULL, "xmm12", u.s.Xmm12, 16), + REG(NULL, "xmm13", u.s.Xmm13, 16), + REG(NULL, "xmm14", u.s.Xmm14, 16), + REG(NULL, "xmm15", u.s.Xmm15, 16), + REG(NULL, "mxcsr", u.FltSave.MxCsr, 4), };
struct backend_cpu be_x86_64 =
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- programs/winedbg/be_arm.c | 38 +++++------ programs/winedbg/be_arm64.c | 70 ++++++++++----------- programs/winedbg/be_cpu.h | 1 + programs/winedbg/be_i386.c | 86 ++++++++++++------------- programs/winedbg/be_ppc.c | 78 +++++++++++------------ programs/winedbg/be_x86_64.c | 118 +++++++++++++++++------------------ 6 files changed, 196 insertions(+), 195 deletions(-)
diff --git a/programs/winedbg/be_arm.c b/programs/winedbg/be_arm.c index c7e4de20afe1..1de4e3cca58f 100644 --- a/programs/winedbg/be_arm.c +++ b/programs/winedbg/be_arm.c @@ -1900,27 +1900,27 @@ static BOOL be_arm_set_context(HANDLE thread, const dbg_ctx_t *ctx) return SetThreadContext(thread, &ctx->ctx); }
-#define REG(f,n,r,gs) {f, n, FIELD_OFFSET(CONTEXT, r), sizeof(((CONTEXT*)NULL)->r), gs} +#define REG(f,n,t,r,gs) {f, n, t, FIELD_OFFSET(CONTEXT, r), sizeof(((CONTEXT*)NULL)->r), gs}
static struct gdb_register be_arm_gdb_register_map[] = { - REG("core", "r0", R0, 4), - REG(NULL, "r1", R1, 4), - REG(NULL, "r2", R2, 4), - REG(NULL, "r3", R3, 4), - REG(NULL, "r4", R4, 4), - REG(NULL, "r5", R5, 4), - REG(NULL, "r6", R6, 4), - REG(NULL, "r7", R7, 4), - REG(NULL, "r8", R8, 4), - REG(NULL, "r9", R9, 4), - REG(NULL, "r10", R10, 4), - REG(NULL, "r11", R11, 4), - REG(NULL, "r12", R12, 4), - REG(NULL, "r13", R13, 4), - REG(NULL, "sp", Sp, 4), - REG(NULL, "lr", Lr, 4), - REG(NULL, "pc", Pc, 4), - REG(NULL, "cpsr", Cpsr, 4), + REG("core", "r0", NULL, R0, 4), + REG(NULL, "r1", NULL, R1, 4), + REG(NULL, "r2", NULL, R2, 4), + REG(NULL, "r3", NULL, R3, 4), + REG(NULL, "r4", NULL, R4, 4), + REG(NULL, "r5", NULL, R5, 4), + REG(NULL, "r6", NULL, R6, 4), + REG(NULL, "r7", NULL, R7, 4), + REG(NULL, "r8", NULL, R8, 4), + REG(NULL, "r9", NULL, R9, 4), + REG(NULL, "r10", NULL, R10, 4), + REG(NULL, "r11", NULL, R11, 4), + REG(NULL, "r12", NULL, R12, 4), + REG(NULL, "r13", NULL, R13, 4), + REG(NULL, "sp", "data_ptr", Sp, 4), + REG(NULL, "lr", "code_ptr", Lr, 4), + REG(NULL, "pc", "code_ptr", Pc, 4), + REG(NULL, "cpsr", NULL, Cpsr, 4), };
struct backend_cpu be_arm = diff --git a/programs/winedbg/be_arm64.c b/programs/winedbg/be_arm64.c index 131cf561cfbb..972538d1a7d7 100644 --- a/programs/winedbg/be_arm64.c +++ b/programs/winedbg/be_arm64.c @@ -289,43 +289,43 @@ static BOOL be_arm64_set_context(HANDLE thread, const dbg_ctx_t *ctx) return SetThreadContext(thread, &ctx->ctx); }
-#define REG(f,n,r,gs) {f, n, FIELD_OFFSET(CONTEXT, r), sizeof(((CONTEXT*)NULL)->r), gs} +#define REG(f,n,t,r,gs) {f, n, t, FIELD_OFFSET(CONTEXT, r), sizeof(((CONTEXT*)NULL)->r), gs}
static struct gdb_register be_arm64_gdb_register_map[] = { - REG("core", "x0", u.s.X0, 8), - REG(NULL, "x1", u.s.X1, 8), - REG(NULL, "x2", u.s.X2, 8), - REG(NULL, "x3", u.s.X3, 8), - REG(NULL, "x4", u.s.X4, 8), - REG(NULL, "x5", u.s.X5, 8), - REG(NULL, "x6", u.s.X6, 8), - REG(NULL, "x7", u.s.X7, 8), - REG(NULL, "x8", u.s.X8, 8), - REG(NULL, "x9", u.s.X9, 8), - REG(NULL, "x10", u.s.X10, 8), - REG(NULL, "x11", u.s.X11, 8), - REG(NULL, "x12", u.s.X12, 8), - REG(NULL, "x13", u.s.X13, 8), - REG(NULL, "x14", u.s.X14, 8), - REG(NULL, "x15", u.s.X15, 8), - REG(NULL, "x16", u.s.X16, 8), - REG(NULL, "x17", u.s.X17, 8), - REG(NULL, "x18", u.s.X18, 8), - REG(NULL, "x19", u.s.X19, 8), - REG(NULL, "x20", u.s.X20, 8), - REG(NULL, "x21", u.s.X21, 8), - REG(NULL, "x22", u.s.X22, 8), - REG(NULL, "x23", u.s.X23, 8), - REG(NULL, "x24", u.s.X24, 8), - REG(NULL, "x25", u.s.X25, 8), - REG(NULL, "x26", u.s.X26, 8), - REG(NULL, "x27", u.s.X27, 8), - REG(NULL, "x28", u.s.X28, 8), - REG(NULL, "x29", u.s.Fp, 8), - REG(NULL, "x30", u.s.Lr, 8), - REG(NULL, "sp", Sp, 8), - REG(NULL, "pc", Pc, 8), - REG(NULL, "cpsr", Cpsr, 4), + REG("core", "x0", NULL, u.s.X0, 8), + REG(NULL, "x1", NULL, u.s.X1, 8), + REG(NULL, "x2", NULL, u.s.X2, 8), + REG(NULL, "x3", NULL, u.s.X3, 8), + REG(NULL, "x4", NULL, u.s.X4, 8), + REG(NULL, "x5", NULL, u.s.X5, 8), + REG(NULL, "x6", NULL, u.s.X6, 8), + REG(NULL, "x7", NULL, u.s.X7, 8), + REG(NULL, "x8", NULL, u.s.X8, 8), + REG(NULL, "x9", NULL, u.s.X9, 8), + REG(NULL, "x10", NULL, u.s.X10, 8), + REG(NULL, "x11", NULL, u.s.X11, 8), + REG(NULL, "x12", NULL, u.s.X12, 8), + REG(NULL, "x13", NULL, u.s.X13, 8), + REG(NULL, "x14", NULL, u.s.X14, 8), + REG(NULL, "x15", NULL, u.s.X15, 8), + REG(NULL, "x16", NULL, u.s.X16, 8), + REG(NULL, "x17", NULL, u.s.X17, 8), + REG(NULL, "x18", NULL, u.s.X18, 8), + REG(NULL, "x19", NULL, u.s.X19, 8), + REG(NULL, "x20", NULL, u.s.X20, 8), + REG(NULL, "x21", NULL, u.s.X21, 8), + REG(NULL, "x22", NULL, u.s.X22, 8), + REG(NULL, "x23", NULL, u.s.X23, 8), + REG(NULL, "x24", NULL, u.s.X24, 8), + REG(NULL, "x25", NULL, u.s.X25, 8), + REG(NULL, "x26", NULL, u.s.X26, 8), + REG(NULL, "x27", NULL, u.s.X27, 8), + REG(NULL, "x28", NULL, u.s.X28, 8), + REG(NULL, "x29", NULL, u.s.Fp, 8), + REG(NULL, "x30", NULL, u.s.Lr, 8), + REG(NULL, "sp", "data_ptr", Sp, 8), + REG(NULL, "pc", "code_ptr", Pc, 8), + REG(NULL, "cpsr", "cpsr_flags", Cpsr, 4), };
struct backend_cpu be_arm64 = diff --git a/programs/winedbg/be_cpu.h b/programs/winedbg/be_cpu.h index 1b7c153f7496..718d38766b9a 100644 --- a/programs/winedbg/be_cpu.h +++ b/programs/winedbg/be_cpu.h @@ -26,6 +26,7 @@ struct gdb_register { const char *feature; const char *name; + const char *type; size_t ctx_offset; size_t ctx_length; size_t gdb_length; diff --git a/programs/winedbg/be_i386.c b/programs/winedbg/be_i386.c index 199ee34cf08e..cbf43259d4a1 100644 --- a/programs/winedbg/be_i386.c +++ b/programs/winedbg/be_i386.c @@ -865,51 +865,51 @@ static BOOL be_i386_set_context(HANDLE thread, const dbg_ctx_t *ctx) return Wow64SetThreadContext(thread, &ctx->x86); }
-#define REG(f,n,r,gs) {f, n, FIELD_OFFSET(WOW64_CONTEXT, r), sizeof(((WOW64_CONTEXT*)NULL)->r), gs} +#define REG(f,n,t,r,gs) {f, n, t, FIELD_OFFSET(WOW64_CONTEXT, r), sizeof(((WOW64_CONTEXT*)NULL)->r), gs}
static struct gdb_register be_i386_gdb_register_map[] = { - REG("core", "eax", Eax, 4), - REG(NULL, "ecx", Ecx, 4), - REG(NULL, "edx", Edx, 4), - REG(NULL, "ebx", Ebx, 4), - REG(NULL, "esp", Esp, 4), - REG(NULL, "ebp", Ebp, 4), - REG(NULL, "esi", Esi, 4), - REG(NULL, "edi", Edi, 4), - REG(NULL, "eip", Eip, 4), - REG(NULL, "eflags", EFlags, 4), - REG(NULL, "cs", SegCs, 4), - REG(NULL, "ss", SegSs, 4), - REG(NULL, "ds", SegDs, 4), - REG(NULL, "es", SegEs, 4), - REG(NULL, "fs", SegFs, 4), - REG(NULL, "gs", SegGs, 4), - { NULL, "st0", FIELD_OFFSET(WOW64_CONTEXT, FloatSave.RegisterArea[ 0]), 10, 10}, - { NULL, "st1", FIELD_OFFSET(WOW64_CONTEXT, FloatSave.RegisterArea[10]), 10, 10}, - { NULL, "st2", FIELD_OFFSET(WOW64_CONTEXT, FloatSave.RegisterArea[20]), 10, 10}, - { NULL, "st3", FIELD_OFFSET(WOW64_CONTEXT, FloatSave.RegisterArea[30]), 10, 10}, - { NULL, "st4", FIELD_OFFSET(WOW64_CONTEXT, FloatSave.RegisterArea[40]), 10, 10}, - { NULL, "st5", FIELD_OFFSET(WOW64_CONTEXT, FloatSave.RegisterArea[50]), 10, 10}, - { NULL, "st6", FIELD_OFFSET(WOW64_CONTEXT, FloatSave.RegisterArea[60]), 10, 10}, - { NULL, "st7", FIELD_OFFSET(WOW64_CONTEXT, FloatSave.RegisterArea[70]), 10, 10}, - { NULL, "fctrl", FIELD_OFFSET(WOW64_CONTEXT, FloatSave.ControlWord), 2, 4}, - { NULL, "fstat", FIELD_OFFSET(WOW64_CONTEXT, FloatSave.StatusWord), 2, 4}, - { NULL, "ftag", FIELD_OFFSET(WOW64_CONTEXT, FloatSave.TagWord), 2, 4}, - { NULL, "fiseg", FIELD_OFFSET(WOW64_CONTEXT, FloatSave.ErrorSelector), 2, 4}, - REG(NULL, "fioff", FloatSave.ErrorOffset, 4), - { NULL, "foseg", FIELD_OFFSET(WOW64_CONTEXT, FloatSave.DataSelector), 2, 4}, - REG(NULL, "fooff", FloatSave.DataOffset, 4), - { NULL, "fop", FIELD_OFFSET(WOW64_CONTEXT, FloatSave.ErrorSelector) + 2, 2, 4}, - - { "sse", "xmm0", FIELD_OFFSET(WOW64_CONTEXT, ExtendedRegisters) + FIELD_OFFSET(XMM_SAVE_AREA32, XmmRegisters[0]), 16, 16}, - { NULL, "xmm1", FIELD_OFFSET(WOW64_CONTEXT, ExtendedRegisters) + FIELD_OFFSET(XMM_SAVE_AREA32, XmmRegisters[1]), 16, 16}, - { NULL, "xmm2", FIELD_OFFSET(WOW64_CONTEXT, ExtendedRegisters) + FIELD_OFFSET(XMM_SAVE_AREA32, XmmRegisters[2]), 16, 16}, - { NULL, "xmm3", FIELD_OFFSET(WOW64_CONTEXT, ExtendedRegisters) + FIELD_OFFSET(XMM_SAVE_AREA32, XmmRegisters[3]), 16, 16}, - { NULL, "xmm4", FIELD_OFFSET(WOW64_CONTEXT, ExtendedRegisters) + FIELD_OFFSET(XMM_SAVE_AREA32, XmmRegisters[4]), 16, 16}, - { NULL, "xmm5", FIELD_OFFSET(WOW64_CONTEXT, ExtendedRegisters) + FIELD_OFFSET(XMM_SAVE_AREA32, XmmRegisters[5]), 16, 16}, - { NULL, "xmm6", FIELD_OFFSET(WOW64_CONTEXT, ExtendedRegisters) + FIELD_OFFSET(XMM_SAVE_AREA32, XmmRegisters[6]), 16, 16}, - { NULL, "xmm7", FIELD_OFFSET(WOW64_CONTEXT, ExtendedRegisters) + FIELD_OFFSET(XMM_SAVE_AREA32, XmmRegisters[7]), 16, 16}, - { NULL, "mxcsr", FIELD_OFFSET(WOW64_CONTEXT, ExtendedRegisters) + FIELD_OFFSET(XMM_SAVE_AREA32, MxCsr), 4, 4}, + REG("core", "eax", NULL, Eax, 4), + REG(NULL, "ecx", NULL, Ecx, 4), + REG(NULL, "edx", NULL, Edx, 4), + REG(NULL, "ebx", NULL, Ebx, 4), + REG(NULL, "esp", "data_ptr", Esp, 4), + REG(NULL, "ebp", "data_ptr", Ebp, 4), + REG(NULL, "esi", NULL, Esi, 4), + REG(NULL, "edi", NULL, Edi, 4), + REG(NULL, "eip", "code_ptr", Eip, 4), + REG(NULL, "eflags", "i386_eflags", EFlags, 4), + REG(NULL, "cs", NULL, SegCs, 4), + REG(NULL, "ss", NULL, SegSs, 4), + REG(NULL, "ds", NULL, SegDs, 4), + REG(NULL, "es", NULL, SegEs, 4), + REG(NULL, "fs", NULL, SegFs, 4), + REG(NULL, "gs", NULL, SegGs, 4), + { NULL, "st0", "i387_ext", FIELD_OFFSET(WOW64_CONTEXT, FloatSave.RegisterArea[ 0]), 10, 10}, + { NULL, "st1", "i387_ext", FIELD_OFFSET(WOW64_CONTEXT, FloatSave.RegisterArea[10]), 10, 10}, + { NULL, "st2", "i387_ext", FIELD_OFFSET(WOW64_CONTEXT, FloatSave.RegisterArea[20]), 10, 10}, + { NULL, "st3", "i387_ext", FIELD_OFFSET(WOW64_CONTEXT, FloatSave.RegisterArea[30]), 10, 10}, + { NULL, "st4", "i387_ext", FIELD_OFFSET(WOW64_CONTEXT, FloatSave.RegisterArea[40]), 10, 10}, + { NULL, "st5", "i387_ext", FIELD_OFFSET(WOW64_CONTEXT, FloatSave.RegisterArea[50]), 10, 10}, + { NULL, "st6", "i387_ext", FIELD_OFFSET(WOW64_CONTEXT, FloatSave.RegisterArea[60]), 10, 10}, + { NULL, "st7", "i387_ext", FIELD_OFFSET(WOW64_CONTEXT, FloatSave.RegisterArea[70]), 10, 10}, + { NULL, "fctrl", NULL, FIELD_OFFSET(WOW64_CONTEXT, FloatSave.ControlWord), 2, 4}, + { NULL, "fstat", NULL, FIELD_OFFSET(WOW64_CONTEXT, FloatSave.StatusWord), 2, 4}, + { NULL, "ftag", NULL, FIELD_OFFSET(WOW64_CONTEXT, FloatSave.TagWord), 2, 4}, + { NULL, "fiseg", NULL, FIELD_OFFSET(WOW64_CONTEXT, FloatSave.ErrorSelector), 2, 4}, + REG(NULL, "fioff", NULL, FloatSave.ErrorOffset, 4), + { NULL, "foseg", NULL, FIELD_OFFSET(WOW64_CONTEXT, FloatSave.DataSelector), 2, 4}, + REG(NULL, "fooff", NULL, FloatSave.DataOffset, 4), + { NULL, "fop", NULL, FIELD_OFFSET(WOW64_CONTEXT, FloatSave.ErrorSelector) + 2, 2, 4}, + + { "sse", "xmm0", "vec128", FIELD_OFFSET(WOW64_CONTEXT, ExtendedRegisters) + FIELD_OFFSET(XMM_SAVE_AREA32, XmmRegisters[0]), 16, 16}, + { NULL, "xmm1", "vec128", FIELD_OFFSET(WOW64_CONTEXT, ExtendedRegisters) + FIELD_OFFSET(XMM_SAVE_AREA32, XmmRegisters[1]), 16, 16}, + { NULL, "xmm2", "vec128", FIELD_OFFSET(WOW64_CONTEXT, ExtendedRegisters) + FIELD_OFFSET(XMM_SAVE_AREA32, XmmRegisters[2]), 16, 16}, + { NULL, "xmm3", "vec128", FIELD_OFFSET(WOW64_CONTEXT, ExtendedRegisters) + FIELD_OFFSET(XMM_SAVE_AREA32, XmmRegisters[3]), 16, 16}, + { NULL, "xmm4", "vec128", FIELD_OFFSET(WOW64_CONTEXT, ExtendedRegisters) + FIELD_OFFSET(XMM_SAVE_AREA32, XmmRegisters[4]), 16, 16}, + { NULL, "xmm5", "vec128", FIELD_OFFSET(WOW64_CONTEXT, ExtendedRegisters) + FIELD_OFFSET(XMM_SAVE_AREA32, XmmRegisters[5]), 16, 16}, + { NULL, "xmm6", "vec128", FIELD_OFFSET(WOW64_CONTEXT, ExtendedRegisters) + FIELD_OFFSET(XMM_SAVE_AREA32, XmmRegisters[6]), 16, 16}, + { NULL, "xmm7", "vec128", FIELD_OFFSET(WOW64_CONTEXT, ExtendedRegisters) + FIELD_OFFSET(XMM_SAVE_AREA32, XmmRegisters[7]), 16, 16}, + { NULL, "mxcsr", "i386_mxcsr", FIELD_OFFSET(WOW64_CONTEXT, ExtendedRegisters) + FIELD_OFFSET(XMM_SAVE_AREA32, MxCsr), 4, 4}, };
struct backend_cpu be_i386 = diff --git a/programs/winedbg/be_ppc.c b/programs/winedbg/be_ppc.c index dae33e5e7f01..7e7eb3aa97fe 100644 --- a/programs/winedbg/be_ppc.c +++ b/programs/winedbg/be_ppc.c @@ -191,47 +191,47 @@ static BOOL be_ppc_set_context(HANDLE thread, const dbg_ctx_t *ctx) return SetThreadContext(thread, &ctx->ctx); }
-#define REG(f,n,r,gs) {f, n, FIELD_OFFSET(CONTEXT, r), sizeof(((CONTEXT*)NULL)->r), gs} +#define REG(f,n,t,r,gs) {f, n, t, FIELD_OFFSET(CONTEXT, r), sizeof(((CONTEXT*)NULL)->r), gs}
static struct gdb_register be_ppc_gdb_register_map[] = { - REG("core", "r0", Gpr0, 4), - REG(NULL, "r1", Gpr1, 4), - REG(NULL, "r2", Gpr2, 4), - REG(NULL, "r3", Gpr3, 4), - REG(NULL, "r4", Gpr4, 4), - REG(NULL, "r5", Gpr5, 4), - REG(NULL, "r6", Gpr6, 4), - REG(NULL, "r7", Gpr7, 4), - REG(NULL, "r8", Gpr8, 4), - REG(NULL, "r9", Gpr9, 4), - REG(NULL, "r10", Gpr10, 4), - REG(NULL, "r11", Gpr11, 4), - REG(NULL, "r12", Gpr12, 4), - REG(NULL, "r13", Gpr13, 4), - REG(NULL, "r14", Gpr14, 4), - REG(NULL, "r15", Gpr15, 4), - REG(NULL, "r16", Gpr16, 4), - REG(NULL, "r17", Gpr17, 4), - REG(NULL, "r18", Gpr18, 4), - REG(NULL, "r19", Gpr19, 4), - REG(NULL, "r20", Gpr20, 4), - REG(NULL, "r21", Gpr21, 4), - REG(NULL, "r22", Gpr22, 4), - REG(NULL, "r23", Gpr23, 4), - REG(NULL, "r24", Gpr24, 4), - REG(NULL, "r25", Gpr25, 4), - REG(NULL, "r26", Gpr26, 4), - REG(NULL, "r27", Gpr27, 4), - REG(NULL, "r28", Gpr28, 4), - REG(NULL, "r29", Gpr29, 4), - REG(NULL, "r30", Gpr30, 4), - REG(NULL, "r31", Gpr31, 4), - REG(NULL, "pc", Iar, 4), - REG(NULL, "msr", Msr, 4), - REG(NULL, "cr", Cr, 4), - REG(NULL, "lr", Lr, 4), - REG(NULL, "ctr", Ctr, 4), - REG(NULL, "xer", Xer, 4), + REG("core", "r0", NULL, Gpr0, 4), + REG(NULL, "r1", NULL, Gpr1, 4), + REG(NULL, "r2", NULL, Gpr2, 4), + REG(NULL, "r3", NULL, Gpr3, 4), + REG(NULL, "r4", NULL, Gpr4, 4), + REG(NULL, "r5", NULL, Gpr5, 4), + REG(NULL, "r6", NULL, Gpr6, 4), + REG(NULL, "r7", NULL, Gpr7, 4), + REG(NULL, "r8", NULL, Gpr8, 4), + REG(NULL, "r9", NULL, Gpr9, 4), + REG(NULL, "r10", NULL, Gpr10, 4), + REG(NULL, "r11", NULL, Gpr11, 4), + REG(NULL, "r12", NULL, Gpr12, 4), + REG(NULL, "r13", NULL, Gpr13, 4), + REG(NULL, "r14", NULL, Gpr14, 4), + REG(NULL, "r15", NULL, Gpr15, 4), + REG(NULL, "r16", NULL, Gpr16, 4), + REG(NULL, "r17", NULL, Gpr17, 4), + REG(NULL, "r18", NULL, Gpr18, 4), + REG(NULL, "r19", NULL, Gpr19, 4), + REG(NULL, "r20", NULL, Gpr20, 4), + REG(NULL, "r21", NULL, Gpr21, 4), + REG(NULL, "r22", NULL, Gpr22, 4), + REG(NULL, "r23", NULL, Gpr23, 4), + REG(NULL, "r24", NULL, Gpr24, 4), + REG(NULL, "r25", NULL, Gpr25, 4), + REG(NULL, "r26", NULL, Gpr26, 4), + REG(NULL, "r27", NULL, Gpr27, 4), + REG(NULL, "r28", NULL, Gpr28, 4), + REG(NULL, "r29", NULL, Gpr29, 4), + REG(NULL, "r30", NULL, Gpr30, 4), + REG(NULL, "r31", NULL, Gpr31, 4), + REG(NULL, "pc", "code_ptr", Iar, 4), + REG(NULL, "msr", NULL, Msr, 4), + REG(NULL, "cr", NULL, Cr, 4), + REG(NULL, "lr", "code_ptr", Lr, 4), + REG(NULL, "ctr", NULL, Ctr, 4), + REG(NULL, "xer", NULL, Xer, 4),
REG("fpu", "f0", Fpr0, 4), REG(NULL, "f1", Fpr1, 4), diff --git a/programs/winedbg/be_x86_64.c b/programs/winedbg/be_x86_64.c index 3476b03649e1..aff5ec86c18a 100644 --- a/programs/winedbg/be_x86_64.c +++ b/programs/winedbg/be_x86_64.c @@ -768,67 +768,67 @@ static BOOL be_x86_64_set_context(HANDLE thread, const dbg_ctx_t *ctx) return SetThreadContext(thread, &ctx->ctx); }
-#define REG(f,n,r,gs) {f, n, FIELD_OFFSET(CONTEXT, r), sizeof(((CONTEXT*)NULL)->r), gs} +#define REG(f,n,t,r,gs) {f, n, t, FIELD_OFFSET(CONTEXT, r), sizeof(((CONTEXT*)NULL)->r), gs}
static struct gdb_register be_x86_64_gdb_register_map[] = { - REG("core", "rax", Rax, 8), - REG(NULL, "rbx", Rbx, 8), - REG(NULL, "rcx", Rcx, 8), - REG(NULL, "rdx", Rdx, 8), - REG(NULL, "rsi", Rsi, 8), - REG(NULL, "rdi", Rdi, 8), - REG(NULL, "rbp", Rbp, 8), - REG(NULL, "rsp", Rsp, 8), - REG(NULL, "r8", R8, 8), - REG(NULL, "r9", R9, 8), - REG(NULL, "r10", R10, 8), - REG(NULL, "r11", R11, 8), - REG(NULL, "r12", R12, 8), - REG(NULL, "r13", R13, 8), - REG(NULL, "r14", R14, 8), - REG(NULL, "r15", R15, 8), - REG(NULL, "rip", Rip, 8), - REG(NULL, "eflags", EFlags, 4), - REG(NULL, "cs", SegCs, 4), - REG(NULL, "ss", SegSs, 4), - REG(NULL, "ds", SegDs, 4), - REG(NULL, "es", SegEs, 4), - REG(NULL, "fs", SegFs, 4), - REG(NULL, "gs", SegGs, 4), - { NULL, "st0", FIELD_OFFSET(CONTEXT, u.FltSave.FloatRegisters[ 0]), 10, 10}, - { NULL, "st1", FIELD_OFFSET(CONTEXT, u.FltSave.FloatRegisters[ 1]), 10, 10}, - { NULL, "st2", FIELD_OFFSET(CONTEXT, u.FltSave.FloatRegisters[ 2]), 10, 10}, - { NULL, "st3", FIELD_OFFSET(CONTEXT, u.FltSave.FloatRegisters[ 3]), 10, 10}, - { NULL, "st4", FIELD_OFFSET(CONTEXT, u.FltSave.FloatRegisters[ 4]), 10, 10}, - { NULL, "st5", FIELD_OFFSET(CONTEXT, u.FltSave.FloatRegisters[ 5]), 10, 10}, - { NULL, "st6", FIELD_OFFSET(CONTEXT, u.FltSave.FloatRegisters[ 6]), 10, 10}, - { NULL, "st7", FIELD_OFFSET(CONTEXT, u.FltSave.FloatRegisters[ 7]), 10, 10}, - REG(NULL, "fctrl", u.FltSave.ControlWord, 4), - REG(NULL, "fstat", u.FltSave.StatusWord, 4), - REG(NULL, "ftag", u.FltSave.TagWord, 4), - REG(NULL, "fiseg", u.FltSave.ErrorSelector, 4), - REG(NULL, "fioff", u.FltSave.ErrorOffset, 4), - REG(NULL, "foseg", u.FltSave.DataSelector, 4), - REG(NULL, "fooff", u.FltSave.DataOffset, 4), - REG(NULL, "fop", u.FltSave.ErrorOpcode, 4), - - REG("sse", "xmm0", u.s.Xmm0, 16), - REG(NULL, "xmm1", u.s.Xmm1, 16), - REG(NULL, "xmm2", u.s.Xmm2, 16), - REG(NULL, "xmm3", u.s.Xmm3, 16), - REG(NULL, "xmm4", u.s.Xmm4, 16), - REG(NULL, "xmm5", u.s.Xmm5, 16), - REG(NULL, "xmm6", u.s.Xmm6, 16), - REG(NULL, "xmm7", u.s.Xmm7, 16), - REG(NULL, "xmm8", u.s.Xmm8, 16), - REG(NULL, "xmm9", u.s.Xmm9, 16), - REG(NULL, "xmm10", u.s.Xmm10, 16), - REG(NULL, "xmm11", u.s.Xmm11, 16), - REG(NULL, "xmm12", u.s.Xmm12, 16), - REG(NULL, "xmm13", u.s.Xmm13, 16), - REG(NULL, "xmm14", u.s.Xmm14, 16), - REG(NULL, "xmm15", u.s.Xmm15, 16), - REG(NULL, "mxcsr", u.FltSave.MxCsr, 4), + REG("core", "rax", NULL, Rax, 8), + REG(NULL, "rbx", NULL, Rbx, 8), + REG(NULL, "rcx", NULL, Rcx, 8), + REG(NULL, "rdx", NULL, Rdx, 8), + REG(NULL, "rsi", NULL, Rsi, 8), + REG(NULL, "rdi", NULL, Rdi, 8), + REG(NULL, "rbp", "data_ptr", Rbp, 8), + REG(NULL, "rsp", "data_ptr", Rsp, 8), + REG(NULL, "r8", NULL, R8, 8), + REG(NULL, "r9", NULL, R9, 8), + REG(NULL, "r10", NULL, R10, 8), + REG(NULL, "r11", NULL, R11, 8), + REG(NULL, "r12", NULL, R12, 8), + REG(NULL, "r13", NULL, R13, 8), + REG(NULL, "r14", NULL, R14, 8), + REG(NULL, "r15", NULL, R15, 8), + REG(NULL, "rip", "code_ptr", Rip, 8), + REG(NULL, "eflags", "i386_eflags", EFlags, 4), + REG(NULL, "cs", NULL, SegCs, 4), + REG(NULL, "ss", NULL, SegSs, 4), + REG(NULL, "ds", NULL, SegDs, 4), + REG(NULL, "es", NULL, SegEs, 4), + REG(NULL, "fs", NULL, SegFs, 4), + REG(NULL, "gs", NULL, SegGs, 4), + { NULL, "st0", "i387_ext", FIELD_OFFSET(CONTEXT, u.FltSave.FloatRegisters[ 0]), 10, 10}, + { NULL, "st1", "i387_ext", FIELD_OFFSET(CONTEXT, u.FltSave.FloatRegisters[ 1]), 10, 10}, + { NULL, "st2", "i387_ext", FIELD_OFFSET(CONTEXT, u.FltSave.FloatRegisters[ 2]), 10, 10}, + { NULL, "st3", "i387_ext", FIELD_OFFSET(CONTEXT, u.FltSave.FloatRegisters[ 3]), 10, 10}, + { NULL, "st4", "i387_ext", FIELD_OFFSET(CONTEXT, u.FltSave.FloatRegisters[ 4]), 10, 10}, + { NULL, "st5", "i387_ext", FIELD_OFFSET(CONTEXT, u.FltSave.FloatRegisters[ 5]), 10, 10}, + { NULL, "st6", "i387_ext", FIELD_OFFSET(CONTEXT, u.FltSave.FloatRegisters[ 6]), 10, 10}, + { NULL, "st7", "i387_ext", FIELD_OFFSET(CONTEXT, u.FltSave.FloatRegisters[ 7]), 10, 10}, + REG(NULL, "fctrl", NULL, u.FltSave.ControlWord, 4), + REG(NULL, "fstat", NULL, u.FltSave.StatusWord, 4), + REG(NULL, "ftag", NULL, u.FltSave.TagWord, 4), + REG(NULL, "fiseg", NULL, u.FltSave.ErrorSelector, 4), + REG(NULL, "fioff", NULL, u.FltSave.ErrorOffset, 4), + REG(NULL, "foseg", NULL, u.FltSave.DataSelector, 4), + REG(NULL, "fooff", NULL, u.FltSave.DataOffset, 4), + REG(NULL, "fop", NULL, u.FltSave.ErrorOpcode, 4), + + REG("sse", "xmm0", "vec128", u.s.Xmm0, 16), + REG(NULL, "xmm1", "vec128", u.s.Xmm1, 16), + REG(NULL, "xmm2", "vec128", u.s.Xmm2, 16), + REG(NULL, "xmm3", "vec128", u.s.Xmm3, 16), + REG(NULL, "xmm4", "vec128", u.s.Xmm4, 16), + REG(NULL, "xmm5", "vec128", u.s.Xmm5, 16), + REG(NULL, "xmm6", "vec128", u.s.Xmm6, 16), + REG(NULL, "xmm7", "vec128", u.s.Xmm7, 16), + REG(NULL, "xmm8", "vec128", u.s.Xmm8, 16), + REG(NULL, "xmm9", "vec128", u.s.Xmm9, 16), + REG(NULL, "xmm10", "vec128", u.s.Xmm10, 16), + REG(NULL, "xmm11", "vec128", u.s.Xmm11, 16), + REG(NULL, "xmm12", "vec128", u.s.Xmm12, 16), + REG(NULL, "xmm13", "vec128", u.s.Xmm13, 16), + REG(NULL, "xmm14", "vec128", u.s.Xmm14, 16), + REG(NULL, "xmm15", "vec128", u.s.Xmm15, 16), + REG(NULL, "mxcsr", "i386_mxcsr", u.FltSave.MxCsr, 4), };
struct backend_cpu be_x86_64 =
Also introduces packet_reply_open_xfer and packet_reply_close_xfer, supporting partial qXfer replies. It always allocates the whole reply buffer for simplicity, but then trucates to the requested offset and length.
Signed-off-by: Rémi Bernon rbernon@codeweavers.com ---
This makes gdb frontend stop trying to figure libraries by itself, so we temporarily lose debug symbol lookup. It will be fixed by the qXfer:libraries:read request.
programs/winedbg/gdbproxy.c | 199 +++++++++++++++++++++++++++++------- 1 file changed, 162 insertions(+), 37 deletions(-)
diff --git a/programs/winedbg/gdbproxy.c b/programs/winedbg/gdbproxy.c index 7c57caf9d1e8..5a273c4a3199 100644 --- a/programs/winedbg/gdbproxy.c +++ b/programs/winedbg/gdbproxy.c @@ -168,40 +168,6 @@ static unsigned char checksum(const char* ptr, int len) return cksum; }
-#ifdef __i386__ -static const char target_xml[] = ""; -#elif defined(__powerpc__) -static const char target_xml[] = ""; -#elif defined(__x86_64__) -static const char target_xml[] = ""; -#elif defined(__arm__) -static const char target_xml[] = - "l <target><architecture>arm</architecture>\n" - "<feature name="org.gnu.gdb.arm.core">\n" - " <reg name="r0" bitsize="32" type="uint32"/>\n" - " <reg name="r1" bitsize="32" type="uint32"/>\n" - " <reg name="r2" bitsize="32" type="uint32"/>\n" - " <reg name="r3" bitsize="32" type="uint32"/>\n" - " <reg name="r4" bitsize="32" type="uint32"/>\n" - " <reg name="r5" bitsize="32" type="uint32"/>\n" - " <reg name="r6" bitsize="32" type="uint32"/>\n" - " <reg name="r7" bitsize="32" type="uint32"/>\n" - " <reg name="r8" bitsize="32" type="uint32"/>\n" - " <reg name="r9" bitsize="32" type="uint32"/>\n" - " <reg name="r10" bitsize="32" type="uint32"/>\n" - " <reg name="r11" bitsize="32" type="uint32"/>\n" - " <reg name="r12" bitsize="32" type="uint32"/>\n" - " <reg name="sp" bitsize="32" type="data_ptr"/>\n" - " <reg name="lr" bitsize="32"/>\n" - " <reg name="pc" bitsize="32" type="code_ptr"/>\n" - " <reg name="cpsr" bitsize="32"/>\n" - "</feature></target>\n"; -#elif defined(__aarch64__) -static const char target_xml[] = ""; -#else -# error Define the registers map for your CPU -#endif - static inline void* cpu_register_ptr(struct gdb_context *gdbctx, dbg_ctx_t *ctx, unsigned idx) { @@ -767,6 +733,35 @@ static void packet_reply_close(struct gdb_context* gdbctx) gdbctx->out_curr_packet = -1; }
+static void packet_reply_open_xfer(struct gdb_context* gdbctx) +{ + packet_reply_open(gdbctx); + packet_reply_add(gdbctx, "m"); +} + +static void packet_reply_close_xfer(struct gdb_context* gdbctx, int off, int len) +{ + int begin = gdbctx->out_curr_packet + 1; + int plen; + + if (begin + off < gdbctx->out_len) + { + gdbctx->out_len -= off; + memmove(gdbctx->out_buf + begin, gdbctx->out_buf + begin + off, gdbctx->out_len); + } + else + { + gdbctx->out_buf[gdbctx->out_curr_packet] = 'l'; + gdbctx->out_len = gdbctx->out_curr_packet + 1; + } + + plen = gdbctx->out_len - begin; + if (len >= 0 && plen > len) gdbctx->out_len -= (plen - len); + else gdbctx->out_buf[gdbctx->out_curr_packet] = 'l'; + + packet_reply_close(gdbctx); +} + static enum packet_return packet_reply(struct gdb_context* gdbctx, const char* packet) { packet_reply_open(gdbctx); @@ -1396,8 +1391,130 @@ static enum packet_return packet_query_remote_command(struct gdb_context* gdbctx return packet_reply_error(gdbctx, EINVAL); }
+static void packet_query_target_xml(struct gdb_context* gdbctx, struct backend_cpu* cpu) +{ + const char* feature_prefix = NULL; + const char* feature = NULL; + char buffer[256]; + int i; + + packet_reply_add(gdbctx, "<target>"); + switch (cpu->machine) + { + case IMAGE_FILE_MACHINE_AMD64: + packet_reply_add(gdbctx, "<architecture>i386:x86-64</architecture>"); + feature_prefix = "org.gnu.gdb.i386."; + break; + case IMAGE_FILE_MACHINE_I386: + packet_reply_add(gdbctx, "<architecture>i386</architecture>"); + feature_prefix = "org.gnu.gdb.i386."; + break; + case IMAGE_FILE_MACHINE_POWERPC: + packet_reply_add(gdbctx, "<architecture>powerpc:common</architecture>"); + feature_prefix = "org.gnu.gdb.power."; + break; + case IMAGE_FILE_MACHINE_ARMNT: + packet_reply_add(gdbctx, "<architecture>arm</architecture>"); + feature_prefix = "org.gnu.gdb.arm."; + break; + case IMAGE_FILE_MACHINE_ARM64: + packet_reply_add(gdbctx, "<architecture>aarch64</architecture>"); + feature_prefix = "org.gnu.gdb.aarch64."; + break; + } + + for (i = 0; i < cpu->gdb_num_regs; ++i) + { + if (cpu->gdb_register_map[i].feature) + { + if (feature) packet_reply_add(gdbctx, "</feature>"); + feature = cpu->gdb_register_map[i].feature; + + packet_reply_add(gdbctx, "<feature name=""); + if (feature_prefix) packet_reply_add(gdbctx, feature_prefix); + packet_reply_add(gdbctx, feature); + packet_reply_add(gdbctx, "">"); + + if (strcmp(feature_prefix, "org.gnu.gdb.i386.") == 0 && + strcmp(feature, "core") == 0) + packet_reply_add(gdbctx, "<flags id="i386_eflags" size="4">" + "<field name="CF" start="0" end="0"/>" + "<field name="" start="1" end="1"/>" + "<field name="PF" start="2" end="2"/>" + "<field name="AF" start="4" end="4"/>" + "<field name="ZF" start="6" end="6"/>" + "<field name="SF" start="7" end="7"/>" + "<field name="TF" start="8" end="8"/>" + "<field name="IF" start="9" end="9"/>" + "<field name="DF" start="10" end="10"/>" + "<field name="OF" start="11" end="11"/>" + "<field name="NT" start="14" end="14"/>" + "<field name="RF" start="16" end="16"/>" + "<field name="VM" start="17" end="17"/>" + "<field name="AC" start="18" end="18"/>" + "<field name="VIF" start="19" end="19"/>" + "<field name="VIP" start="20" end="20"/>" + "<field name="ID" start="21" end="21"/>" + "</flags>"); + + if (strcmp(feature_prefix, "org.gnu.gdb.i386.") == 0 && + strcmp(feature, "sse") == 0) + packet_reply_add(gdbctx, "<vector id="v4f" type="ieee_single" count="4"/>" + "<vector id="v2d" type="ieee_double" count="2"/>" + "<vector id="v16i8" type="int8" count="16"/>" + "<vector id="v8i16" type="int16" count="8"/>" + "<vector id="v4i32" type="int32" count="4"/>" + "<vector id="v2i64" type="int64" count="2"/>" + "<union id="vec128">" + "<field name="v4_float" type="v4f"/>" + "<field name="v2_double" type="v2d"/>" + "<field name="v16_int8" type="v16i8"/>" + "<field name="v8_int16" type="v8i16"/>" + "<field name="v4_int32" type="v4i32"/>" + "<field name="v2_int64" type="v2i64"/>" + "<field name="uint128" type="uint128"/>" + "</union>" + "<flags id="i386_mxcsr" size="4">" + "<field name="IE" start="0" end="0"/>" + "<field name="DE" start="1" end="1"/>" + "<field name="ZE" start="2" end="2"/>" + "<field name="OE" start="3" end="3"/>" + "<field name="UE" start="4" end="4"/>" + "<field name="PE" start="5" end="5"/>" + "<field name="DAZ" start="6" end="6"/>" + "<field name="IM" start="7" end="7"/>" + "<field name="DM" start="8" end="8"/>" + "<field name="ZM" start="9" end="9"/>" + "<field name="OM" start="10" end="10"/>" + "<field name="UM" start="11" end="11"/>" + "<field name="PM" start="12" end="12"/>" + "<field name="FZ" start="15" end="15"/>" + "</flags>"); + } + + snprintf(buffer, ARRAY_SIZE(buffer), "<reg name="%s" bitsize="%zu"", + cpu->gdb_register_map[i].name, 8 * cpu->gdb_register_map[i].gdb_length); + packet_reply_add(gdbctx, buffer); + + if (cpu->gdb_register_map[i].type) + { + packet_reply_add(gdbctx, " type=""); + packet_reply_add(gdbctx, cpu->gdb_register_map[i].type); + packet_reply_add(gdbctx, """); + } + + packet_reply_add(gdbctx, "/>"); + } + + if (feature) packet_reply_add(gdbctx, "</feature>"); + packet_reply_add(gdbctx, "</target>"); +} + static enum packet_return packet_query(struct gdb_context* gdbctx) { + int off, len; + struct backend_cpu *cpu; + switch (gdbctx->in_packet[0]) { case 'f': @@ -1485,7 +1602,7 @@ static enum packet_return packet_query(struct gdb_context* gdbctx) { packet_reply_open(gdbctx); packet_reply_add(gdbctx, "QStartNoAckMode+;"); - if (*target_xml) packet_reply_add(gdbctx, "PacketSize=400;qXfer:features:read+"); + packet_reply_add(gdbctx, "qXfer:features:read+;"); packet_reply_close(gdbctx); return packet_done; } @@ -1516,8 +1633,16 @@ static enum packet_return packet_query(struct gdb_context* gdbctx) } break; case 'X': - if (*target_xml && strncmp(gdbctx->in_packet, "Xfer:features:read:target.xml", 29) == 0) - return packet_reply(gdbctx, target_xml); + if (sscanf(gdbctx->in_packet, "Xfer:features:read:target.xml:%x,%x", &off, &len) == 2) + { + if (!gdbctx->process) return packet_error; + if (!(cpu = gdbctx->process->be_cpu)) return packet_error; + + packet_reply_open_xfer(gdbctx); + packet_query_target_xml(gdbctx, cpu); + packet_reply_close_xfer(gdbctx, off, len); + return packet_done; + } break; } ERR("Unhandled query %s\n", debugstr_an(gdbctx->in_packet, gdbctx->in_packet_len));
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- programs/winedbg/be_arm.c | 38 ++++----- programs/winedbg/be_arm64.c | 70 ++++++++--------- programs/winedbg/be_cpu.h | 5 +- programs/winedbg/be_i386.c | 86 ++++++++++----------- programs/winedbg/be_ppc.c | 146 +++++++++++++++++------------------ programs/winedbg/be_x86_64.c | 118 ++++++++++++++-------------- programs/winedbg/gdbproxy.c | 50 ++---------- 7 files changed, 237 insertions(+), 276 deletions(-)
diff --git a/programs/winedbg/be_arm.c b/programs/winedbg/be_arm.c index 1de4e3cca58f..feb5840c2773 100644 --- a/programs/winedbg/be_arm.c +++ b/programs/winedbg/be_arm.c @@ -1900,27 +1900,27 @@ static BOOL be_arm_set_context(HANDLE thread, const dbg_ctx_t *ctx) return SetThreadContext(thread, &ctx->ctx); }
-#define REG(f,n,t,r,gs) {f, n, t, FIELD_OFFSET(CONTEXT, r), sizeof(((CONTEXT*)NULL)->r), gs} +#define REG(f,n,t,r) {f, n, t, FIELD_OFFSET(CONTEXT, r), sizeof(((CONTEXT*)NULL)->r)}
static struct gdb_register be_arm_gdb_register_map[] = { - REG("core", "r0", NULL, R0, 4), - REG(NULL, "r1", NULL, R1, 4), - REG(NULL, "r2", NULL, R2, 4), - REG(NULL, "r3", NULL, R3, 4), - REG(NULL, "r4", NULL, R4, 4), - REG(NULL, "r5", NULL, R5, 4), - REG(NULL, "r6", NULL, R6, 4), - REG(NULL, "r7", NULL, R7, 4), - REG(NULL, "r8", NULL, R8, 4), - REG(NULL, "r9", NULL, R9, 4), - REG(NULL, "r10", NULL, R10, 4), - REG(NULL, "r11", NULL, R11, 4), - REG(NULL, "r12", NULL, R12, 4), - REG(NULL, "r13", NULL, R13, 4), - REG(NULL, "sp", "data_ptr", Sp, 4), - REG(NULL, "lr", "code_ptr", Lr, 4), - REG(NULL, "pc", "code_ptr", Pc, 4), - REG(NULL, "cpsr", NULL, Cpsr, 4), + REG("core", "r0", NULL, R0), + REG(NULL, "r1", NULL, R1), + REG(NULL, "r2", NULL, R2), + REG(NULL, "r3", NULL, R3), + REG(NULL, "r4", NULL, R4), + REG(NULL, "r5", NULL, R5), + REG(NULL, "r6", NULL, R6), + REG(NULL, "r7", NULL, R7), + REG(NULL, "r8", NULL, R8), + REG(NULL, "r9", NULL, R9), + REG(NULL, "r10", NULL, R10), + REG(NULL, "r11", NULL, R11), + REG(NULL, "r12", NULL, R12), + REG(NULL, "r13", NULL, R13), + REG(NULL, "sp", "data_ptr", Sp), + REG(NULL, "lr", "code_ptr", Lr), + REG(NULL, "pc", "code_ptr", Pc), + REG(NULL, "cpsr", NULL, Cpsr), };
struct backend_cpu be_arm = diff --git a/programs/winedbg/be_arm64.c b/programs/winedbg/be_arm64.c index 972538d1a7d7..d65bb5d11a16 100644 --- a/programs/winedbg/be_arm64.c +++ b/programs/winedbg/be_arm64.c @@ -289,43 +289,43 @@ static BOOL be_arm64_set_context(HANDLE thread, const dbg_ctx_t *ctx) return SetThreadContext(thread, &ctx->ctx); }
-#define REG(f,n,t,r,gs) {f, n, t, FIELD_OFFSET(CONTEXT, r), sizeof(((CONTEXT*)NULL)->r), gs} +#define REG(f,n,t,r) {f, n, t, FIELD_OFFSET(CONTEXT, r), sizeof(((CONTEXT*)NULL)->r)}
static struct gdb_register be_arm64_gdb_register_map[] = { - REG("core", "x0", NULL, u.s.X0, 8), - REG(NULL, "x1", NULL, u.s.X1, 8), - REG(NULL, "x2", NULL, u.s.X2, 8), - REG(NULL, "x3", NULL, u.s.X3, 8), - REG(NULL, "x4", NULL, u.s.X4, 8), - REG(NULL, "x5", NULL, u.s.X5, 8), - REG(NULL, "x6", NULL, u.s.X6, 8), - REG(NULL, "x7", NULL, u.s.X7, 8), - REG(NULL, "x8", NULL, u.s.X8, 8), - REG(NULL, "x9", NULL, u.s.X9, 8), - REG(NULL, "x10", NULL, u.s.X10, 8), - REG(NULL, "x11", NULL, u.s.X11, 8), - REG(NULL, "x12", NULL, u.s.X12, 8), - REG(NULL, "x13", NULL, u.s.X13, 8), - REG(NULL, "x14", NULL, u.s.X14, 8), - REG(NULL, "x15", NULL, u.s.X15, 8), - REG(NULL, "x16", NULL, u.s.X16, 8), - REG(NULL, "x17", NULL, u.s.X17, 8), - REG(NULL, "x18", NULL, u.s.X18, 8), - REG(NULL, "x19", NULL, u.s.X19, 8), - REG(NULL, "x20", NULL, u.s.X20, 8), - REG(NULL, "x21", NULL, u.s.X21, 8), - REG(NULL, "x22", NULL, u.s.X22, 8), - REG(NULL, "x23", NULL, u.s.X23, 8), - REG(NULL, "x24", NULL, u.s.X24, 8), - REG(NULL, "x25", NULL, u.s.X25, 8), - REG(NULL, "x26", NULL, u.s.X26, 8), - REG(NULL, "x27", NULL, u.s.X27, 8), - REG(NULL, "x28", NULL, u.s.X28, 8), - REG(NULL, "x29", NULL, u.s.Fp, 8), - REG(NULL, "x30", NULL, u.s.Lr, 8), - REG(NULL, "sp", "data_ptr", Sp, 8), - REG(NULL, "pc", "code_ptr", Pc, 8), - REG(NULL, "cpsr", "cpsr_flags", Cpsr, 4), + REG("core", "x0", NULL, u.s.X0), + REG(NULL, "x1", NULL, u.s.X1), + REG(NULL, "x2", NULL, u.s.X2), + REG(NULL, "x3", NULL, u.s.X3), + REG(NULL, "x4", NULL, u.s.X4), + REG(NULL, "x5", NULL, u.s.X5), + REG(NULL, "x6", NULL, u.s.X6), + REG(NULL, "x7", NULL, u.s.X7), + REG(NULL, "x8", NULL, u.s.X8), + REG(NULL, "x9", NULL, u.s.X9), + REG(NULL, "x10", NULL, u.s.X10), + REG(NULL, "x11", NULL, u.s.X11), + REG(NULL, "x12", NULL, u.s.X12), + REG(NULL, "x13", NULL, u.s.X13), + REG(NULL, "x14", NULL, u.s.X14), + REG(NULL, "x15", NULL, u.s.X15), + REG(NULL, "x16", NULL, u.s.X16), + REG(NULL, "x17", NULL, u.s.X17), + REG(NULL, "x18", NULL, u.s.X18), + REG(NULL, "x19", NULL, u.s.X19), + REG(NULL, "x20", NULL, u.s.X20), + REG(NULL, "x21", NULL, u.s.X21), + REG(NULL, "x22", NULL, u.s.X22), + REG(NULL, "x23", NULL, u.s.X23), + REG(NULL, "x24", NULL, u.s.X24), + REG(NULL, "x25", NULL, u.s.X25), + REG(NULL, "x26", NULL, u.s.X26), + REG(NULL, "x27", NULL, u.s.X27), + REG(NULL, "x28", NULL, u.s.X28), + REG(NULL, "x29", NULL, u.s.Fp), + REG(NULL, "x30", NULL, u.s.Lr), + REG(NULL, "sp", "data_ptr", Sp), + REG(NULL, "pc", "code_ptr", Pc), + REG(NULL, "cpsr", "cpsr_flags", Cpsr), };
struct backend_cpu be_arm64 = diff --git a/programs/winedbg/be_cpu.h b/programs/winedbg/be_cpu.h index 718d38766b9a..26281b4804bc 100644 --- a/programs/winedbg/be_cpu.h +++ b/programs/winedbg/be_cpu.h @@ -27,9 +27,8 @@ struct gdb_register const char *feature; const char *name; const char *type; - size_t ctx_offset; - size_t ctx_length; - size_t gdb_length; + size_t offset; + size_t length; };
struct backend_cpu diff --git a/programs/winedbg/be_i386.c b/programs/winedbg/be_i386.c index cbf43259d4a1..e6fd4357cc99 100644 --- a/programs/winedbg/be_i386.c +++ b/programs/winedbg/be_i386.c @@ -865,51 +865,51 @@ static BOOL be_i386_set_context(HANDLE thread, const dbg_ctx_t *ctx) return Wow64SetThreadContext(thread, &ctx->x86); }
-#define REG(f,n,t,r,gs) {f, n, t, FIELD_OFFSET(WOW64_CONTEXT, r), sizeof(((WOW64_CONTEXT*)NULL)->r), gs} +#define REG(f,n,t,r) {f, n, t, FIELD_OFFSET(WOW64_CONTEXT, r), sizeof(((WOW64_CONTEXT*)NULL)->r)}
static struct gdb_register be_i386_gdb_register_map[] = { - REG("core", "eax", NULL, Eax, 4), - REG(NULL, "ecx", NULL, Ecx, 4), - REG(NULL, "edx", NULL, Edx, 4), - REG(NULL, "ebx", NULL, Ebx, 4), - REG(NULL, "esp", "data_ptr", Esp, 4), - REG(NULL, "ebp", "data_ptr", Ebp, 4), - REG(NULL, "esi", NULL, Esi, 4), - REG(NULL, "edi", NULL, Edi, 4), - REG(NULL, "eip", "code_ptr", Eip, 4), - REG(NULL, "eflags", "i386_eflags", EFlags, 4), - REG(NULL, "cs", NULL, SegCs, 4), - REG(NULL, "ss", NULL, SegSs, 4), - REG(NULL, "ds", NULL, SegDs, 4), - REG(NULL, "es", NULL, SegEs, 4), - REG(NULL, "fs", NULL, SegFs, 4), - REG(NULL, "gs", NULL, SegGs, 4), - { NULL, "st0", "i387_ext", FIELD_OFFSET(WOW64_CONTEXT, FloatSave.RegisterArea[ 0]), 10, 10}, - { NULL, "st1", "i387_ext", FIELD_OFFSET(WOW64_CONTEXT, FloatSave.RegisterArea[10]), 10, 10}, - { NULL, "st2", "i387_ext", FIELD_OFFSET(WOW64_CONTEXT, FloatSave.RegisterArea[20]), 10, 10}, - { NULL, "st3", "i387_ext", FIELD_OFFSET(WOW64_CONTEXT, FloatSave.RegisterArea[30]), 10, 10}, - { NULL, "st4", "i387_ext", FIELD_OFFSET(WOW64_CONTEXT, FloatSave.RegisterArea[40]), 10, 10}, - { NULL, "st5", "i387_ext", FIELD_OFFSET(WOW64_CONTEXT, FloatSave.RegisterArea[50]), 10, 10}, - { NULL, "st6", "i387_ext", FIELD_OFFSET(WOW64_CONTEXT, FloatSave.RegisterArea[60]), 10, 10}, - { NULL, "st7", "i387_ext", FIELD_OFFSET(WOW64_CONTEXT, FloatSave.RegisterArea[70]), 10, 10}, - { NULL, "fctrl", NULL, FIELD_OFFSET(WOW64_CONTEXT, FloatSave.ControlWord), 2, 4}, - { NULL, "fstat", NULL, FIELD_OFFSET(WOW64_CONTEXT, FloatSave.StatusWord), 2, 4}, - { NULL, "ftag", NULL, FIELD_OFFSET(WOW64_CONTEXT, FloatSave.TagWord), 2, 4}, - { NULL, "fiseg", NULL, FIELD_OFFSET(WOW64_CONTEXT, FloatSave.ErrorSelector), 2, 4}, - REG(NULL, "fioff", NULL, FloatSave.ErrorOffset, 4), - { NULL, "foseg", NULL, FIELD_OFFSET(WOW64_CONTEXT, FloatSave.DataSelector), 2, 4}, - REG(NULL, "fooff", NULL, FloatSave.DataOffset, 4), - { NULL, "fop", NULL, FIELD_OFFSET(WOW64_CONTEXT, FloatSave.ErrorSelector) + 2, 2, 4}, - - { "sse", "xmm0", "vec128", FIELD_OFFSET(WOW64_CONTEXT, ExtendedRegisters) + FIELD_OFFSET(XMM_SAVE_AREA32, XmmRegisters[0]), 16, 16}, - { NULL, "xmm1", "vec128", FIELD_OFFSET(WOW64_CONTEXT, ExtendedRegisters) + FIELD_OFFSET(XMM_SAVE_AREA32, XmmRegisters[1]), 16, 16}, - { NULL, "xmm2", "vec128", FIELD_OFFSET(WOW64_CONTEXT, ExtendedRegisters) + FIELD_OFFSET(XMM_SAVE_AREA32, XmmRegisters[2]), 16, 16}, - { NULL, "xmm3", "vec128", FIELD_OFFSET(WOW64_CONTEXT, ExtendedRegisters) + FIELD_OFFSET(XMM_SAVE_AREA32, XmmRegisters[3]), 16, 16}, - { NULL, "xmm4", "vec128", FIELD_OFFSET(WOW64_CONTEXT, ExtendedRegisters) + FIELD_OFFSET(XMM_SAVE_AREA32, XmmRegisters[4]), 16, 16}, - { NULL, "xmm5", "vec128", FIELD_OFFSET(WOW64_CONTEXT, ExtendedRegisters) + FIELD_OFFSET(XMM_SAVE_AREA32, XmmRegisters[5]), 16, 16}, - { NULL, "xmm6", "vec128", FIELD_OFFSET(WOW64_CONTEXT, ExtendedRegisters) + FIELD_OFFSET(XMM_SAVE_AREA32, XmmRegisters[6]), 16, 16}, - { NULL, "xmm7", "vec128", FIELD_OFFSET(WOW64_CONTEXT, ExtendedRegisters) + FIELD_OFFSET(XMM_SAVE_AREA32, XmmRegisters[7]), 16, 16}, - { NULL, "mxcsr", "i386_mxcsr", FIELD_OFFSET(WOW64_CONTEXT, ExtendedRegisters) + FIELD_OFFSET(XMM_SAVE_AREA32, MxCsr), 4, 4}, + REG("core", "eax", NULL, Eax), + REG(NULL, "ecx", NULL, Ecx), + REG(NULL, "edx", NULL, Edx), + REG(NULL, "ebx", NULL, Ebx), + REG(NULL, "esp", "data_ptr", Esp), + REG(NULL, "ebp", "data_ptr", Ebp), + REG(NULL, "esi", NULL, Esi), + REG(NULL, "edi", NULL, Edi), + REG(NULL, "eip", "code_ptr", Eip), + REG(NULL, "eflags", "i386_eflags", EFlags), + REG(NULL, "cs", NULL, SegCs), + REG(NULL, "ss", NULL, SegSs), + REG(NULL, "ds", NULL, SegDs), + REG(NULL, "es", NULL, SegEs), + REG(NULL, "fs", NULL, SegFs), + REG(NULL, "gs", NULL, SegGs), + { NULL, "st0", "i387_ext", FIELD_OFFSET(WOW64_CONTEXT, FloatSave.RegisterArea[ 0]), 10}, + { NULL, "st1", "i387_ext", FIELD_OFFSET(WOW64_CONTEXT, FloatSave.RegisterArea[10]), 10}, + { NULL, "st2", "i387_ext", FIELD_OFFSET(WOW64_CONTEXT, FloatSave.RegisterArea[20]), 10}, + { NULL, "st3", "i387_ext", FIELD_OFFSET(WOW64_CONTEXT, FloatSave.RegisterArea[30]), 10}, + { NULL, "st4", "i387_ext", FIELD_OFFSET(WOW64_CONTEXT, FloatSave.RegisterArea[40]), 10}, + { NULL, "st5", "i387_ext", FIELD_OFFSET(WOW64_CONTEXT, FloatSave.RegisterArea[50]), 10}, + { NULL, "st6", "i387_ext", FIELD_OFFSET(WOW64_CONTEXT, FloatSave.RegisterArea[60]), 10}, + { NULL, "st7", "i387_ext", FIELD_OFFSET(WOW64_CONTEXT, FloatSave.RegisterArea[70]), 10}, + { NULL, "fctrl", NULL, FIELD_OFFSET(WOW64_CONTEXT, FloatSave.ControlWord), 2}, + { NULL, "fstat", NULL, FIELD_OFFSET(WOW64_CONTEXT, FloatSave.StatusWord), 2}, + { NULL, "ftag", NULL, FIELD_OFFSET(WOW64_CONTEXT, FloatSave.TagWord), 2}, + { NULL, "fiseg", NULL, FIELD_OFFSET(WOW64_CONTEXT, FloatSave.ErrorSelector), 2}, + REG(NULL, "fioff", NULL, FloatSave.ErrorOffset), + { NULL, "foseg", NULL, FIELD_OFFSET(WOW64_CONTEXT, FloatSave.DataSelector), 2}, + REG(NULL, "fooff", NULL, FloatSave.DataOffset), + { NULL, "fop", NULL, FIELD_OFFSET(WOW64_CONTEXT, FloatSave.ErrorSelector)+2, 2}, + + { "sse", "xmm0", "vec128", FIELD_OFFSET(WOW64_CONTEXT, ExtendedRegisters) + FIELD_OFFSET(XMM_SAVE_AREA32, XmmRegisters[0]), 16}, + { NULL, "xmm1", "vec128", FIELD_OFFSET(WOW64_CONTEXT, ExtendedRegisters) + FIELD_OFFSET(XMM_SAVE_AREA32, XmmRegisters[1]), 16}, + { NULL, "xmm2", "vec128", FIELD_OFFSET(WOW64_CONTEXT, ExtendedRegisters) + FIELD_OFFSET(XMM_SAVE_AREA32, XmmRegisters[2]), 16}, + { NULL, "xmm3", "vec128", FIELD_OFFSET(WOW64_CONTEXT, ExtendedRegisters) + FIELD_OFFSET(XMM_SAVE_AREA32, XmmRegisters[3]), 16}, + { NULL, "xmm4", "vec128", FIELD_OFFSET(WOW64_CONTEXT, ExtendedRegisters) + FIELD_OFFSET(XMM_SAVE_AREA32, XmmRegisters[4]), 16}, + { NULL, "xmm5", "vec128", FIELD_OFFSET(WOW64_CONTEXT, ExtendedRegisters) + FIELD_OFFSET(XMM_SAVE_AREA32, XmmRegisters[5]), 16}, + { NULL, "xmm6", "vec128", FIELD_OFFSET(WOW64_CONTEXT, ExtendedRegisters) + FIELD_OFFSET(XMM_SAVE_AREA32, XmmRegisters[6]), 16}, + { NULL, "xmm7", "vec128", FIELD_OFFSET(WOW64_CONTEXT, ExtendedRegisters) + FIELD_OFFSET(XMM_SAVE_AREA32, XmmRegisters[7]), 16}, + { NULL, "mxcsr", "i386_mxcsr", FIELD_OFFSET(WOW64_CONTEXT, ExtendedRegisters) + FIELD_OFFSET(XMM_SAVE_AREA32, MxCsr), 4}, };
struct backend_cpu be_i386 = diff --git a/programs/winedbg/be_ppc.c b/programs/winedbg/be_ppc.c index 7e7eb3aa97fe..2057590d94e2 100644 --- a/programs/winedbg/be_ppc.c +++ b/programs/winedbg/be_ppc.c @@ -191,81 +191,81 @@ static BOOL be_ppc_set_context(HANDLE thread, const dbg_ctx_t *ctx) return SetThreadContext(thread, &ctx->ctx); }
-#define REG(f,n,t,r,gs) {f, n, t, FIELD_OFFSET(CONTEXT, r), sizeof(((CONTEXT*)NULL)->r), gs} +#define REG(f,n,t,r) {f, n, t, FIELD_OFFSET(CONTEXT, r), sizeof(((CONTEXT*)NULL)->r)}
static struct gdb_register be_ppc_gdb_register_map[] = { - REG("core", "r0", NULL, Gpr0, 4), - REG(NULL, "r1", NULL, Gpr1, 4), - REG(NULL, "r2", NULL, Gpr2, 4), - REG(NULL, "r3", NULL, Gpr3, 4), - REG(NULL, "r4", NULL, Gpr4, 4), - REG(NULL, "r5", NULL, Gpr5, 4), - REG(NULL, "r6", NULL, Gpr6, 4), - REG(NULL, "r7", NULL, Gpr7, 4), - REG(NULL, "r8", NULL, Gpr8, 4), - REG(NULL, "r9", NULL, Gpr9, 4), - REG(NULL, "r10", NULL, Gpr10, 4), - REG(NULL, "r11", NULL, Gpr11, 4), - REG(NULL, "r12", NULL, Gpr12, 4), - REG(NULL, "r13", NULL, Gpr13, 4), - REG(NULL, "r14", NULL, Gpr14, 4), - REG(NULL, "r15", NULL, Gpr15, 4), - REG(NULL, "r16", NULL, Gpr16, 4), - REG(NULL, "r17", NULL, Gpr17, 4), - REG(NULL, "r18", NULL, Gpr18, 4), - REG(NULL, "r19", NULL, Gpr19, 4), - REG(NULL, "r20", NULL, Gpr20, 4), - REG(NULL, "r21", NULL, Gpr21, 4), - REG(NULL, "r22", NULL, Gpr22, 4), - REG(NULL, "r23", NULL, Gpr23, 4), - REG(NULL, "r24", NULL, Gpr24, 4), - REG(NULL, "r25", NULL, Gpr25, 4), - REG(NULL, "r26", NULL, Gpr26, 4), - REG(NULL, "r27", NULL, Gpr27, 4), - REG(NULL, "r28", NULL, Gpr28, 4), - REG(NULL, "r29", NULL, Gpr29, 4), - REG(NULL, "r30", NULL, Gpr30, 4), - REG(NULL, "r31", NULL, Gpr31, 4), - REG(NULL, "pc", "code_ptr", Iar, 4), - REG(NULL, "msr", NULL, Msr, 4), - REG(NULL, "cr", NULL, Cr, 4), - REG(NULL, "lr", "code_ptr", Lr, 4), - REG(NULL, "ctr", NULL, Ctr, 4), - REG(NULL, "xer", NULL, Xer, 4), - - REG("fpu", "f0", Fpr0, 4), - REG(NULL, "f1", Fpr1, 4), - REG(NULL, "f2", Fpr2, 4), - REG(NULL, "f3", Fpr3, 4), - REG(NULL, "f4", Fpr4, 4), - REG(NULL, "f5", Fpr5, 4), - REG(NULL, "f6", Fpr6, 4), - REG(NULL, "f7", Fpr7, 4), - REG(NULL, "f8", Fpr8, 4), - REG(NULL, "f9", Fpr9, 4), - REG(NULL, "f10", Fpr10, 4), - REG(NULL, "f11", Fpr11, 4), - REG(NULL, "f12", Fpr12, 4), - REG(NULL, "f13", Fpr13, 4), - REG(NULL, "f14", Fpr14, 4), - REG(NULL, "f15", Fpr15, 4), - REG(NULL, "f16", Fpr16, 4), - REG(NULL, "f17", Fpr17, 4), - REG(NULL, "f18", Fpr18, 4), - REG(NULL, "f19", Fpr19, 4), - REG(NULL, "f20", Fpr20, 4), - REG(NULL, "f21", Fpr21, 4), - REG(NULL, "f22", Fpr22, 4), - REG(NULL, "f23", Fpr23, 4), - REG(NULL, "f24", Fpr24, 4), - REG(NULL, "f25", Fpr25, 4), - REG(NULL, "f26", Fpr26, 4), - REG(NULL, "f27", Fpr27, 4), - REG(NULL, "f28", Fpr28, 4), - REG(NULL, "f29", Fpr29, 4), - REG(NULL, "f30", Fpr30, 4), - REG(NULL, "f31", Fpr31, 4), - REG(NULL, "fpscr", Fpscr, 4), + REG("core", "r0", NULL, Gpr0), + REG(NULL, "r1", NULL, Gpr1), + REG(NULL, "r2", NULL, Gpr2), + REG(NULL, "r3", NULL, Gpr3), + REG(NULL, "r4", NULL, Gpr4), + REG(NULL, "r5", NULL, Gpr5), + REG(NULL, "r6", NULL, Gpr6), + REG(NULL, "r7", NULL, Gpr7), + REG(NULL, "r8", NULL, Gpr8), + REG(NULL, "r9", NULL, Gpr9), + REG(NULL, "r10", NULL, Gpr10), + REG(NULL, "r11", NULL, Gpr11), + REG(NULL, "r12", NULL, Gpr12), + REG(NULL, "r13", NULL, Gpr13), + REG(NULL, "r14", NULL, Gpr14), + REG(NULL, "r15", NULL, Gpr15), + REG(NULL, "r16", NULL, Gpr16), + REG(NULL, "r17", NULL, Gpr17), + REG(NULL, "r18", NULL, Gpr18), + REG(NULL, "r19", NULL, Gpr19), + REG(NULL, "r20", NULL, Gpr20), + REG(NULL, "r21", NULL, Gpr21), + REG(NULL, "r22", NULL, Gpr22), + REG(NULL, "r23", NULL, Gpr23), + REG(NULL, "r24", NULL, Gpr24), + REG(NULL, "r25", NULL, Gpr25), + REG(NULL, "r26", NULL, Gpr26), + REG(NULL, "r27", NULL, Gpr27), + REG(NULL, "r28", NULL, Gpr28), + REG(NULL, "r29", NULL, Gpr29), + REG(NULL, "r30", NULL, Gpr30), + REG(NULL, "r31", NULL, Gpr31), + REG(NULL, "pc", "code_ptr", Iar), + REG(NULL, "msr", NULL, Msr), + REG(NULL, "cr", NULL, Cr), + REG(NULL, "lr", "code_ptr", Lr), + REG(NULL, "ctr", NULL, Ctr), + REG(NULL, "xer", NULL, Xer), + + REG("fpu", "f0", "ieee_single", Fpr0, 4), + REG(NULL, "f1", "ieee_single", Fpr1, 4), + REG(NULL, "f2", "ieee_single", Fpr2, 4), + REG(NULL, "f3", "ieee_single", Fpr3, 4), + REG(NULL, "f4", "ieee_single", Fpr4, 4), + REG(NULL, "f5", "ieee_single", Fpr5, 4), + REG(NULL, "f6", "ieee_single", Fpr6, 4), + REG(NULL, "f7", "ieee_single", Fpr7, 4), + REG(NULL, "f8", "ieee_single", Fpr8, 4), + REG(NULL, "f9", "ieee_single", Fpr9, 4), + REG(NULL, "f10", "ieee_single", Fpr10, 4), + REG(NULL, "f11", "ieee_single", Fpr11, 4), + REG(NULL, "f12", "ieee_single", Fpr12, 4), + REG(NULL, "f13", "ieee_single", Fpr13, 4), + REG(NULL, "f14", "ieee_single", Fpr14, 4), + REG(NULL, "f15", "ieee_single", Fpr15, 4), + REG(NULL, "f16", "ieee_single", Fpr16, 4), + REG(NULL, "f17", "ieee_single", Fpr17, 4), + REG(NULL, "f18", "ieee_single", Fpr18, 4), + REG(NULL, "f19", "ieee_single", Fpr19, 4), + REG(NULL, "f20", "ieee_single", Fpr20, 4), + REG(NULL, "f21", "ieee_single", Fpr21, 4), + REG(NULL, "f22", "ieee_single", Fpr22, 4), + REG(NULL, "f23", "ieee_single", Fpr23, 4), + REG(NULL, "f24", "ieee_single", Fpr24, 4), + REG(NULL, "f25", "ieee_single", Fpr25, 4), + REG(NULL, "f26", "ieee_single", Fpr26, 4), + REG(NULL, "f27", "ieee_single", Fpr27, 4), + REG(NULL, "f28", "ieee_single", Fpr28, 4), + REG(NULL, "f29", "ieee_single", Fpr29, 4), + REG(NULL, "f30", "ieee_single", Fpr30, 4), + REG(NULL, "f31", "ieee_single", Fpr31, 4), + REG(NULL, "fpscr", NULL, Fpscr, 4),
/* FIXME: MQ is missing? FIELD_OFFSET(CONTEXT, Mq), */ /* see gdb/nlm/ppc.c */ diff --git a/programs/winedbg/be_x86_64.c b/programs/winedbg/be_x86_64.c index aff5ec86c18a..63521d990508 100644 --- a/programs/winedbg/be_x86_64.c +++ b/programs/winedbg/be_x86_64.c @@ -768,67 +768,67 @@ static BOOL be_x86_64_set_context(HANDLE thread, const dbg_ctx_t *ctx) return SetThreadContext(thread, &ctx->ctx); }
-#define REG(f,n,t,r,gs) {f, n, t, FIELD_OFFSET(CONTEXT, r), sizeof(((CONTEXT*)NULL)->r), gs} +#define REG(f,n,t,r) {f, n, t, FIELD_OFFSET(CONTEXT, r), sizeof(((CONTEXT*)NULL)->r)}
static struct gdb_register be_x86_64_gdb_register_map[] = { - REG("core", "rax", NULL, Rax, 8), - REG(NULL, "rbx", NULL, Rbx, 8), - REG(NULL, "rcx", NULL, Rcx, 8), - REG(NULL, "rdx", NULL, Rdx, 8), - REG(NULL, "rsi", NULL, Rsi, 8), - REG(NULL, "rdi", NULL, Rdi, 8), - REG(NULL, "rbp", "data_ptr", Rbp, 8), - REG(NULL, "rsp", "data_ptr", Rsp, 8), - REG(NULL, "r8", NULL, R8, 8), - REG(NULL, "r9", NULL, R9, 8), - REG(NULL, "r10", NULL, R10, 8), - REG(NULL, "r11", NULL, R11, 8), - REG(NULL, "r12", NULL, R12, 8), - REG(NULL, "r13", NULL, R13, 8), - REG(NULL, "r14", NULL, R14, 8), - REG(NULL, "r15", NULL, R15, 8), - REG(NULL, "rip", "code_ptr", Rip, 8), - REG(NULL, "eflags", "i386_eflags", EFlags, 4), - REG(NULL, "cs", NULL, SegCs, 4), - REG(NULL, "ss", NULL, SegSs, 4), - REG(NULL, "ds", NULL, SegDs, 4), - REG(NULL, "es", NULL, SegEs, 4), - REG(NULL, "fs", NULL, SegFs, 4), - REG(NULL, "gs", NULL, SegGs, 4), - { NULL, "st0", "i387_ext", FIELD_OFFSET(CONTEXT, u.FltSave.FloatRegisters[ 0]), 10, 10}, - { NULL, "st1", "i387_ext", FIELD_OFFSET(CONTEXT, u.FltSave.FloatRegisters[ 1]), 10, 10}, - { NULL, "st2", "i387_ext", FIELD_OFFSET(CONTEXT, u.FltSave.FloatRegisters[ 2]), 10, 10}, - { NULL, "st3", "i387_ext", FIELD_OFFSET(CONTEXT, u.FltSave.FloatRegisters[ 3]), 10, 10}, - { NULL, "st4", "i387_ext", FIELD_OFFSET(CONTEXT, u.FltSave.FloatRegisters[ 4]), 10, 10}, - { NULL, "st5", "i387_ext", FIELD_OFFSET(CONTEXT, u.FltSave.FloatRegisters[ 5]), 10, 10}, - { NULL, "st6", "i387_ext", FIELD_OFFSET(CONTEXT, u.FltSave.FloatRegisters[ 6]), 10, 10}, - { NULL, "st7", "i387_ext", FIELD_OFFSET(CONTEXT, u.FltSave.FloatRegisters[ 7]), 10, 10}, - REG(NULL, "fctrl", NULL, u.FltSave.ControlWord, 4), - REG(NULL, "fstat", NULL, u.FltSave.StatusWord, 4), - REG(NULL, "ftag", NULL, u.FltSave.TagWord, 4), - REG(NULL, "fiseg", NULL, u.FltSave.ErrorSelector, 4), - REG(NULL, "fioff", NULL, u.FltSave.ErrorOffset, 4), - REG(NULL, "foseg", NULL, u.FltSave.DataSelector, 4), - REG(NULL, "fooff", NULL, u.FltSave.DataOffset, 4), - REG(NULL, "fop", NULL, u.FltSave.ErrorOpcode, 4), - - REG("sse", "xmm0", "vec128", u.s.Xmm0, 16), - REG(NULL, "xmm1", "vec128", u.s.Xmm1, 16), - REG(NULL, "xmm2", "vec128", u.s.Xmm2, 16), - REG(NULL, "xmm3", "vec128", u.s.Xmm3, 16), - REG(NULL, "xmm4", "vec128", u.s.Xmm4, 16), - REG(NULL, "xmm5", "vec128", u.s.Xmm5, 16), - REG(NULL, "xmm6", "vec128", u.s.Xmm6, 16), - REG(NULL, "xmm7", "vec128", u.s.Xmm7, 16), - REG(NULL, "xmm8", "vec128", u.s.Xmm8, 16), - REG(NULL, "xmm9", "vec128", u.s.Xmm9, 16), - REG(NULL, "xmm10", "vec128", u.s.Xmm10, 16), - REG(NULL, "xmm11", "vec128", u.s.Xmm11, 16), - REG(NULL, "xmm12", "vec128", u.s.Xmm12, 16), - REG(NULL, "xmm13", "vec128", u.s.Xmm13, 16), - REG(NULL, "xmm14", "vec128", u.s.Xmm14, 16), - REG(NULL, "xmm15", "vec128", u.s.Xmm15, 16), - REG(NULL, "mxcsr", "i386_mxcsr", u.FltSave.MxCsr, 4), + REG("core", "rax", NULL, Rax), + REG(NULL, "rbx", NULL, Rbx), + REG(NULL, "rcx", NULL, Rcx), + REG(NULL, "rdx", NULL, Rdx), + REG(NULL, "rsi", NULL, Rsi), + REG(NULL, "rdi", NULL, Rdi), + REG(NULL, "rbp", "data_ptr", Rbp), + REG(NULL, "rsp", "data_ptr", Rsp), + REG(NULL, "r8", NULL, R8), + REG(NULL, "r9", NULL, R9), + REG(NULL, "r10", NULL, R10), + REG(NULL, "r11", NULL, R11), + REG(NULL, "r12", NULL, R12), + REG(NULL, "r13", NULL, R13), + REG(NULL, "r14", NULL, R14), + REG(NULL, "r15", NULL, R15), + REG(NULL, "rip", "code_ptr", Rip), + REG(NULL, "eflags", "i386_eflags", EFlags), + REG(NULL, "cs", NULL, SegCs), + REG(NULL, "ss", NULL, SegSs), + REG(NULL, "ds", NULL, SegDs), + REG(NULL, "es", NULL, SegEs), + REG(NULL, "fs", NULL, SegFs), + REG(NULL, "gs", NULL, SegGs), + { NULL, "st0", "i387_ext", FIELD_OFFSET(CONTEXT, u.FltSave.FloatRegisters[ 0]), 10}, + { NULL, "st1", "i387_ext", FIELD_OFFSET(CONTEXT, u.FltSave.FloatRegisters[ 1]), 10}, + { NULL, "st2", "i387_ext", FIELD_OFFSET(CONTEXT, u.FltSave.FloatRegisters[ 2]), 10}, + { NULL, "st3", "i387_ext", FIELD_OFFSET(CONTEXT, u.FltSave.FloatRegisters[ 3]), 10}, + { NULL, "st4", "i387_ext", FIELD_OFFSET(CONTEXT, u.FltSave.FloatRegisters[ 4]), 10}, + { NULL, "st5", "i387_ext", FIELD_OFFSET(CONTEXT, u.FltSave.FloatRegisters[ 5]), 10}, + { NULL, "st6", "i387_ext", FIELD_OFFSET(CONTEXT, u.FltSave.FloatRegisters[ 6]), 10}, + { NULL, "st7", "i387_ext", FIELD_OFFSET(CONTEXT, u.FltSave.FloatRegisters[ 7]), 10}, + REG(NULL, "fctrl", NULL, u.FltSave.ControlWord), + REG(NULL, "fstat", NULL, u.FltSave.StatusWord), + REG(NULL, "ftag", NULL, u.FltSave.TagWord), + REG(NULL, "fiseg", NULL, u.FltSave.ErrorSelector), + REG(NULL, "fioff", NULL, u.FltSave.ErrorOffset), + REG(NULL, "foseg", NULL, u.FltSave.DataSelector), + REG(NULL, "fooff", NULL, u.FltSave.DataOffset), + REG(NULL, "fop", NULL, u.FltSave.ErrorOpcode), + + REG("sse", "xmm0", "vec128", u.s.Xmm0), + REG(NULL, "xmm1", "vec128", u.s.Xmm1), + REG(NULL, "xmm2", "vec128", u.s.Xmm2), + REG(NULL, "xmm3", "vec128", u.s.Xmm3), + REG(NULL, "xmm4", "vec128", u.s.Xmm4), + REG(NULL, "xmm5", "vec128", u.s.Xmm5), + REG(NULL, "xmm6", "vec128", u.s.Xmm6), + REG(NULL, "xmm7", "vec128", u.s.Xmm7), + REG(NULL, "xmm8", "vec128", u.s.Xmm8), + REG(NULL, "xmm9", "vec128", u.s.Xmm9), + REG(NULL, "xmm10", "vec128", u.s.Xmm10), + REG(NULL, "xmm11", "vec128", u.s.Xmm11), + REG(NULL, "xmm12", "vec128", u.s.Xmm12), + REG(NULL, "xmm13", "vec128", u.s.Xmm13), + REG(NULL, "xmm14", "vec128", u.s.Xmm14), + REG(NULL, "xmm15", "vec128", u.s.Xmm15), + REG(NULL, "mxcsr", "i386_mxcsr", u.FltSave.MxCsr), };
struct backend_cpu be_x86_64 = diff --git a/programs/winedbg/gdbproxy.c b/programs/winedbg/gdbproxy.c index 5a273c4a3199..70735afd0646 100644 --- a/programs/winedbg/gdbproxy.c +++ b/programs/winedbg/gdbproxy.c @@ -172,13 +172,13 @@ static inline void* cpu_register_ptr(struct gdb_context *gdbctx, dbg_ctx_t *ctx, unsigned idx) { assert(idx < gdbctx->process->be_cpu->gdb_num_regs); - return (char*)ctx + gdbctx->process->be_cpu->gdb_register_map[idx].ctx_offset; + return (char*)ctx + gdbctx->process->be_cpu->gdb_register_map[idx].offset; }
static inline DWORD64 cpu_register(struct gdb_context *gdbctx, dbg_ctx_t *ctx, unsigned idx) { - switch (gdbctx->process->be_cpu->gdb_register_map[idx].ctx_length) + switch (gdbctx->process->be_cpu->gdb_register_map[idx].length) { case 1: return *(BYTE*)cpu_register_ptr(gdbctx, ctx, idx); case 2: return *(WORD*)cpu_register_ptr(gdbctx, ctx, idx); @@ -186,7 +186,7 @@ static inline DWORD64 cpu_register(struct gdb_context *gdbctx, case 8: return *(DWORD64*)cpu_register_ptr(gdbctx, ctx, idx); default: ERR("got unexpected size: %u\n", - (unsigned)gdbctx->process->be_cpu->gdb_register_map[idx].ctx_length); + (unsigned)gdbctx->process->be_cpu->gdb_register_map[idx].length); assert(0); return 0; } @@ -196,30 +196,7 @@ static inline void cpu_register_hex_from(struct gdb_context *gdbctx, dbg_ctx_t* ctx, unsigned idx, const char **phex) { const struct gdb_register *cpu_register_map = gdbctx->process->be_cpu->gdb_register_map; - - if (cpu_register_map[idx].gdb_length == cpu_register_map[idx].ctx_length) - hex_from(cpu_register_ptr(gdbctx, ctx, idx), *phex, cpu_register_map[idx].gdb_length); - else - { - DWORD64 val = 0; - unsigned i; - BYTE b; - - for (i = 0; i < cpu_register_map[idx].gdb_length; i++) - { - hex_from(&b, *phex, 1); - *phex += 2; - val += (DWORD64)b << (8 * i); - } - switch (cpu_register_map[idx].ctx_length) - { - case 1: *(BYTE*)cpu_register_ptr(gdbctx, ctx, idx) = (BYTE)val; break; - case 2: *(WORD*)cpu_register_ptr(gdbctx, ctx, idx) = (WORD)val; break; - case 4: *(DWORD*)cpu_register_ptr(gdbctx, ctx, idx) = (DWORD)val; break; - case 8: *(DWORD64*)cpu_register_ptr(gdbctx, ctx, idx) = val; break; - default: assert(0); - } - } + hex_from(cpu_register_ptr(gdbctx, ctx, idx), *phex, cpu_register_map[idx].length); }
/* =============================================== * @@ -790,22 +767,7 @@ static enum packet_return packet_reply_error(struct gdb_context* gdbctx, int err static inline void packet_reply_register_hex_to(struct gdb_context* gdbctx, dbg_ctx_t* ctx, unsigned idx) { const struct gdb_register *cpu_register_map = gdbctx->process->be_cpu->gdb_register_map; - - if (cpu_register_map[idx].gdb_length == cpu_register_map[idx].ctx_length) - packet_reply_hex_to(gdbctx, cpu_register_ptr(gdbctx, ctx, idx), - cpu_register_map[idx].gdb_length); - else - { - DWORD64 val = cpu_register(gdbctx, ctx, idx); - unsigned i; - - for (i = 0; i < cpu_register_map[idx].gdb_length; i++) - { - BYTE b = val; - packet_reply_hex_to(gdbctx, &b, 1); - val >>= 8; - } - } + packet_reply_hex_to(gdbctx, cpu_register_ptr(gdbctx, ctx, idx), cpu_register_map[idx].length); }
/* =============================================== * @@ -1493,7 +1455,7 @@ static void packet_query_target_xml(struct gdb_context* gdbctx, struct backend_c }
snprintf(buffer, ARRAY_SIZE(buffer), "<reg name="%s" bitsize="%zu"", - cpu->gdb_register_map[i].name, 8 * cpu->gdb_register_map[i].gdb_length); + cpu->gdb_register_map[i].name, 8 * cpu->gdb_register_map[i].length); packet_reply_add(gdbctx, buffer);
if (cpu->gdb_register_map[i].type)
This makes gdb frontend able to list loaded libraries so it can then parse debug information. It seems that it also supports PE/ELF mix, so this is nice but debug info for PE files is still completely off.
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- programs/winedbg/gdbproxy.c | 72 +++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+)
diff --git a/programs/winedbg/gdbproxy.c b/programs/winedbg/gdbproxy.c index 70735afd0646..4f1e2a3c2fd8 100644 --- a/programs/winedbg/gdbproxy.c +++ b/programs/winedbg/gdbproxy.c @@ -1472,6 +1472,66 @@ static void packet_query_target_xml(struct gdb_context* gdbctx, struct backend_c packet_reply_add(gdbctx, "</target>"); }
+static BOOL CALLBACK packet_query_libraries_cb(PCSTR mod_name, DWORD64 base, PVOID ctx) +{ + struct gdb_context* gdbctx = ctx; + IMAGEHLP_MODULE64 mod; + DWORD64 addr; + BOOL is_wow64; + char* tmp; + + mod.SizeOfStruct = sizeof(mod); + SymGetModuleInfo64(gdbctx->process->handle, base, &mod); + + packet_reply_add(gdbctx, "<library name=""); + if (strcmp(mod.LoadedImageName, "[vdso].so") == 0) + packet_reply_add(gdbctx, "linux-vdso.so.1"); + else if (mod.LoadedImageName[0] == '/') + packet_reply_add(gdbctx, mod.LoadedImageName); + else + { + UNICODE_STRING nt_name; + ANSI_STRING ansi_name; + char * unix_path; + + RtlInitAnsiString(&ansi_name, mod.LoadedImageName); + RtlAnsiStringToUnicodeString(&nt_name, &ansi_name, TRUE); + + if ((unix_path = wine_get_unix_file_name(nt_name.Buffer))) + { + if (IsWow64Process(gdbctx->process->handle, &is_wow64) && + is_wow64 && (tmp = strstr(unix_path, "system32"))) + memcpy(tmp, "syswow64", 8); + packet_reply_add(gdbctx, unix_path); + } + else + packet_reply_add(gdbctx, mod.LoadedImageName); + + HeapFree(GetProcessHeap(), 0, unix_path); + RtlFreeUnicodeString(&nt_name); + } + + addr = mod.BaseOfImage; + + packet_reply_add(gdbctx, ""><segment address="0x"); + packet_reply_val(gdbctx, addr, sizeof(addr)); + packet_reply_add(gdbctx, ""/></library>"); + + return TRUE; +} + +static void packet_query_libraries(struct gdb_context* gdbctx) +{ + BOOL opt; + /* this will resynchronize builtin dbghelp's internal ELF module list */ + SymLoadModule(gdbctx->process->handle, 0, 0, 0, 0, 0); + packet_reply_add(gdbctx, "<library-list>"); + opt = SymSetExtendedOption(SYMOPT_EX_WINE_NATIVE_MODULES, TRUE); + SymEnumerateModules64(gdbctx->process->handle, packet_query_libraries_cb, gdbctx); + SymSetExtendedOption(SYMOPT_EX_WINE_NATIVE_MODULES, opt); + packet_reply_add(gdbctx, "</library-list>"); +} + static enum packet_return packet_query(struct gdb_context* gdbctx) { int off, len; @@ -1565,6 +1625,7 @@ static enum packet_return packet_query(struct gdb_context* gdbctx) packet_reply_open(gdbctx); packet_reply_add(gdbctx, "QStartNoAckMode+;"); packet_reply_add(gdbctx, "qXfer:features:read+;"); + packet_reply_add(gdbctx, "qXfer:libraries:read+;"); packet_reply_close(gdbctx); return packet_done; } @@ -1605,6 +1666,17 @@ static enum packet_return packet_query(struct gdb_context* gdbctx) packet_reply_close_xfer(gdbctx, off, len); return packet_done; } + + if (sscanf(gdbctx->in_packet, "Xfer:libraries:read::%x,%x", &off, &len) == 2) + { + if (!gdbctx->process) + return packet_error; + + packet_reply_open_xfer(gdbctx); + packet_query_libraries(gdbctx); + packet_reply_close_xfer(gdbctx, off, len); + return packet_done; + } break; } ERR("Unhandled query %s\n", debugstr_an(gdbctx->in_packet, gdbctx->in_packet_len));
As we don't report fork/vfork/exec events, this allows gdb to request the list of known threads.
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- programs/winedbg/gdbproxy.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+)
diff --git a/programs/winedbg/gdbproxy.c b/programs/winedbg/gdbproxy.c index 4f1e2a3c2fd8..c15a008c656a 100644 --- a/programs/winedbg/gdbproxy.c +++ b/programs/winedbg/gdbproxy.c @@ -1532,6 +1532,24 @@ static void packet_query_libraries(struct gdb_context* gdbctx) packet_reply_add(gdbctx, "</library-list>"); }
+static void packet_query_threads(struct gdb_context* gdbctx) +{ + struct dbg_process* process = gdbctx->process; + struct dbg_thread* thread; + + packet_reply_add(gdbctx, "<threads>"); + LIST_FOR_EACH_ENTRY(thread, &process->threads, struct dbg_thread, entry) + { + packet_reply_add(gdbctx, "<thread "); + packet_reply_add(gdbctx, "id=""); + packet_reply_val(gdbctx, thread->tid, 4); + packet_reply_add(gdbctx, "" name=""); + packet_reply_add(gdbctx, thread->name); + packet_reply_add(gdbctx, ""/>"); + } + packet_reply_add(gdbctx, "</threads>"); +} + static enum packet_return packet_query(struct gdb_context* gdbctx) { int off, len; @@ -1626,6 +1644,7 @@ static enum packet_return packet_query(struct gdb_context* gdbctx) packet_reply_add(gdbctx, "QStartNoAckMode+;"); packet_reply_add(gdbctx, "qXfer:features:read+;"); packet_reply_add(gdbctx, "qXfer:libraries:read+;"); + packet_reply_add(gdbctx, "qXfer:threads:read+;"); packet_reply_close(gdbctx); return packet_done; } @@ -1677,6 +1696,16 @@ static enum packet_return packet_query(struct gdb_context* gdbctx) packet_reply_close_xfer(gdbctx, off, len); return packet_done; } + + if (sscanf(gdbctx->in_packet, "Xfer:threads:read::%x,%x", &off, &len) == 2) + { + if (!gdbctx->process) return packet_error; + + packet_reply_open_xfer(gdbctx); + packet_query_threads(gdbctx); + packet_reply_close_xfer(gdbctx, off, len); + return packet_done; + } break; } ERR("Unhandled query %s\n", debugstr_an(gdbctx->in_packet, gdbctx->in_packet_len));
This is a horrible hack, but without it all gdb computed symbols are wrong. There's probably a reason behind it, but it's not clear why.
Also there's probably a better way to check if a module is PE.
Signed-off-by: Rémi Bernon rbernon@codeweavers.com ---
I'm sending this horrible hack as well because without it gdbproxy is still not very usable. I didn't dig very deep into the reasons behind it, but I'm suspecting gdb wants to be told about the modules sections, and not really the files mappings. Then I couldn't find a simple way to iterate over modules sections from another process.
Using VirtualQueryEx could help iterating over mapped modules but the function takes a void* as address, so that won't work if winedbg is 32bit and is debugging a 64bit process.
programs/winedbg/gdbproxy.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
diff --git a/programs/winedbg/gdbproxy.c b/programs/winedbg/gdbproxy.c index c15a008c656a..79f9634aaeac 100644 --- a/programs/winedbg/gdbproxy.c +++ b/programs/winedbg/gdbproxy.c @@ -1476,6 +1476,7 @@ static BOOL CALLBACK packet_query_libraries_cb(PCSTR mod_name, DWORD64 base, PVO { struct gdb_context* gdbctx = ctx; IMAGEHLP_MODULE64 mod; + unsigned int len; DWORD64 addr; BOOL is_wow64; char* tmp; @@ -1513,6 +1514,17 @@ static BOOL CALLBACK packet_query_libraries_cb(PCSTR mod_name, DWORD64 base, PVO
addr = mod.BaseOfImage;
+ /* FIXME: This is an ugly hack to make gdb correct about its debug + * info computations with PE files. There's probably a correct way + * to do it. */ + len = strlen(mod.LoadedImageName); + if (strcmp(mod.LoadedImageName + len - 4, ".dll") == 0 || + strcmp(mod.LoadedImageName + len - 4, ".exe") == 0) + { + FIXME("Offsetting %s base address by 0x1000\n", mod.LoadedImageName); + addr += 0x1000; + } + packet_reply_add(gdbctx, ""><segment address="0x"); packet_reply_val(gdbctx, addr, sizeof(addr)); packet_reply_add(gdbctx, ""/></library>");
On 4/2/20 8:55 AM, Rémi Bernon wrote:
This is a horrible hack, but without it all gdb computed symbols are wrong. There's probably a reason behind it, but it's not clear why.
Also there's probably a better way to check if a module is PE.
Signed-off-by: Rémi Bernon rbernon@codeweavers.com
I'm sending this horrible hack as well because without it gdbproxy is still not very usable. I didn't dig very deep into the reasons behind it, but I'm suspecting gdb wants to be told about the modules sections, and not really the files mappings. Then I couldn't find a simple way to iterate over modules sections from another process.
Using VirtualQueryEx could help iterating over mapped modules but the function takes a void* as address, so that won't work if winedbg is 32bit and is debugging a 64bit process.
I don't think we need to care about this case. winedbg restarts itself as 64-bit for that specific reason.
programs/winedbg/gdbproxy.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
diff --git a/programs/winedbg/gdbproxy.c b/programs/winedbg/gdbproxy.c index c15a008c656a..79f9634aaeac 100644 --- a/programs/winedbg/gdbproxy.c +++ b/programs/winedbg/gdbproxy.c @@ -1476,6 +1476,7 @@ static BOOL CALLBACK packet_query_libraries_cb(PCSTR mod_name, DWORD64 base, PVO { struct gdb_context* gdbctx = ctx; IMAGEHLP_MODULE64 mod;
- unsigned int len; DWORD64 addr; BOOL is_wow64; char* tmp;
@@ -1513,6 +1514,17 @@ static BOOL CALLBACK packet_query_libraries_cb(PCSTR mod_name, DWORD64 base, PVO
addr = mod.BaseOfImage;
- /* FIXME: This is an ugly hack to make gdb correct about its debug
* info computations with PE files. There's probably a correct way
* to do it. */
- len = strlen(mod.LoadedImageName);
- if (strcmp(mod.LoadedImageName + len - 4, ".dll") == 0 ||
strcmp(mod.LoadedImageName + len - 4, ".exe") == 0)
- {
FIXME("Offsetting %s base address by 0x1000\n", mod.LoadedImageName);
addr += 0x1000;
- }
packet_reply_add(gdbctx, "\"><segment address=\"0x"); packet_reply_val(gdbctx, addr, sizeof(addr)); packet_reply_add(gdbctx, "\"/></library>");