Skip to contentSkip to conversation

gdbstub: Fix handler for 'F' packet

PATCH Superseded Sandra Loosemore 2 participants 3 messages Aug 27, 2019

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 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
index b92ba59..141568a 100644
@@ -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
#1 lore raw
Patchew URL: https://patchew.org/QEMU/[email protected]/

Patchew URL: https://patchew.org/QEMU/[email protected]/

Hi,

This series seems to have some coding style problems. See output below for more information:

Message-id: [email protected]
Type: series
Subject: [Qemu-devel] [PATCH V2] gdbstub: Fix handler for 'F' packet

=== TEST SCRIPT BEGIN ===
#!/bin/bash
git rev-parse base > /dev/null || exit 0
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram
./scripts/checkpatch.pl --mailback base..
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
Switched to a new branch 'test'
ae35e0f gdbstub: Fix handler for 'F' packet

=== OUTPUT BEGIN ===
ERROR: space prohibited before that close parenthesis ')' #37: FILE: gdbstub.c:1827:
+ if (gdb_ctx->num_params >= 2 ) {

total: 1 errors, 0 warnings, 17 lines checked

Commit ae35e0f8b9b6 (gdbstub: Fix handler for 'F' packet) has style problems, please review. If any of these errors are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
=== OUTPUT END ===

Test command exited with code: 1

The full log is available at
http://patchew.org/logs/[email protected]/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]

#2 lore raw
Quoted 4 lines · On 8/27/19 3:30 PM, [email protected] wrote:

=== OUTPUT BEGIN ===
ERROR: space prohibited before that close parenthesis ')' #37: FILE: gdbstub.c:1827:
+ if (gdb_ctx->num_params >= 2 ) {

Arggghh, I am sorry. I fixed this and then screwed up and resent the old patch over again. I'll try again.

-Sandra