gdbstub: Fix handler for 'F' packet
PATCH v3 1/1 gdbstub: Fix handler for 'F' packet
Handling of the 'F' packet has been broken since commit 4b20fab101b9e2d0fb47454209637a17fc7a13d5, which converted it to use the new packet parsing infrastructure. Per the GDB RSP specification
https://sourceware.org/gdb/current/onlinedocs/gdb/The-F-Reply-Packet.html
the second parameter may be omitted, but the rewritten implementation was failing to recognize this case. The result was that QEMU was repeatedly resending the fileio request and ignoring GDB's replies of successful completion. This patch restores the behavior of the previous code in allowing the errno parameter to be omitted and passing 0 to the callback in that case.
--- gdbstub.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
gdbstub.c +6 -2
@@ -1820,11 +1820,15 @@ static void handle_read_all_regs(GdbCmdContext *gdb_ctx, void *user_ctx)static void handle_file_io (GdbCmdContext *gdb_ctx,void *user_ctx) { -if (gdb_ctx->num_params >=2 && gdb_ctx->s->current_syscall_cb) { +if (gdb_ctx->num_params >=1 && gdb_ctx->s->current_syscall_cb) {target_ulong ret, err; ret = (target_ulong )gdb_ctx->params[0 ].val_ull; - err = (target_ulong )gdb_ctx->params[1 ].val_ull; +if (gdb_ctx->num_params >=2 ) { + err = (target_ulong )gdb_ctx->params[1 ].val_ull; + }else { + err =0 ; + } gdb_ctx->s->current_syscall_cb (gdb_ctx->s->c_cpu, ret, err); gdb_ctx->s->current_syscall_cb =NULL ; }
Signature · 1 line
2.8.1
Quoted 13 lines · Sandra Loosemore
Handling of the 'F' packet has been broken since commit
4b20fab101b9e2d0fb47454209637a17fc7a13d5, which converted it to use the new packet parsing infrastructure. Per the GDB RSP specificationhttps://sourceware.org/gdb/current/onlinedocs/gdb/The-F-Reply-Packet.html
the second parameter may be omitted, but the rewritten implementation was failing to recognize this case. The result was that QEMU was repeatedly resending the fileio request and ignoring GDB's replies of successful completion. This patch restores the behavior of the previous code in allowing the errno parameter to be omitted and passing 0 to the callback in that case.
Quoted 4 lines
Signed-off-by Sandra Loosemore <[email protected]>--- gdbstub.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
r~
Alex Bennée
AppliedQuoted 6 lines · Sandra Loosemore
Handling of the 'F' packet has been broken since commit
4b20fab101b9e2d0fb47454209637a17fc7a13d5, which converted it to use the new packet parsing infrastructure. Per the GDB RSP specificationhttps://sourceware.org/gdb/current/onlinedocs/gdb/The-F-Reply-Packet.html
Quoted 8 lines
the second parameter may be omitted, but the rewritten implementation was failing to recognize this case. The result was that QEMU was repeatedly resending the fileio request and ignoring GDB's replies of successful completion. This patch restores the behavior of the previous code in allowing the errno parameter to be omitted and passing 0 to the callback in that case.
Signed-off-by Sandra Loosemore <[email protected]>
Queued to gdbstub/next, thanks.
Quoted 16 lines
--- gdbstub.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)gdbstub.c +1
-1@@ -1820,11 +1820,15 @@ static void handle_read_all_regs(GdbCmdContext *gdb_ctx, void *user_ctx)static void handle_file_io (GdbCmdContext *gdb_ctx,void *user_ctx) { -if (gdb_ctx->num_params >=2 && gdb_ctx->s->current_syscall_cb) { +if (gdb_ctx->num_params >=1 && gdb_ctx->s->current_syscall_cb) {target_ulong ret, err;
gdbstub.c static void handle_read_all_regs(GdbCmdContext *gdb_ctx, void *user_ctx) · line 1834
Quoted 10 lines
gdbstub.c +5
-1ret = (target_ulong )gdb_ctx->params[0 ].val_ull; - err = (target_ulong )gdb_ctx->params[1 ].val_ull; +if (gdb_ctx->num_params >=2 ) { + err = (target_ulong )gdb_ctx->params[1 ].val_ull; + }else { + err =0 ; + } gdb_ctx->s->current_syscall_cb (gdb_ctx->s->c_cpu, ret, err); gdb_ctx->s->current_syscall_cb =NULL ; }
--
Alex Bennée