Patchwork linux-user: Exit with an error if we couldn't set up gdbserver

login
register
mail settings
Submitter Peter Maydell
Date Sept. 6, 2011, 1:15 p.m.
Message ID <1315314950-15558-1-git-send-email-peter.maydell@linaro.org>
Download mbox | patch
Permalink /patch/113560/
State New
Headers show

Comments

Peter Maydell - Sept. 6, 2011, 1:15 p.m.
If gdbserver_start() fails (usually because we couldn't bind to the
requested TCP port) then exit qemu rather than blithely continuing.
This brings the linux-user behaviour in to line with system mode.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 linux-user/main.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

Patch

diff --git a/linux-user/main.c b/linux-user/main.c
index 89a51d7..7268997 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -3568,7 +3568,11 @@  int main(int argc, char **argv, char **envp)
 #endif
 
     if (gdbstub_port) {
-        gdbserver_start (gdbstub_port);
+        if (gdbserver_start(gdbstub_port) < 0) {
+            fprintf(stderr, "qemu: could not open gdbserver on port %d\n",
+                    gdbstub_port);
+            exit(1);
+        }
         gdb_handlesig(env, 0);
     }
     cpu_loop(env);