Eric Pouech : winedbg: Don't assert() on unsupported v-packets, but rather report an error.

Alexandre Julliard julliard at winehq.org
Wed Oct 5 18:04:00 CDT 2011


Module: wine
Branch: master
Commit: a971d8657c8b2953f9c51434bfc8ac6653fb8373
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=a971d8657c8b2953f9c51434bfc8ac6653fb8373

Author: Eric Pouech <eric.pouech at orange.fr>
Date:   Wed Oct  5 22:41:10 2011 +0200

winedbg: Don't assert() on unsupported v-packets, but rather report an error.

---

 programs/winedbg/gdbproxy.c |   64 ++++++++++++++++++++++++++++++++++++-------
 1 files changed, 54 insertions(+), 10 deletions(-)

diff --git a/programs/winedbg/gdbproxy.c b/programs/winedbg/gdbproxy.c
index e81f72c..1a30947 100644
--- a/programs/winedbg/gdbproxy.c
+++ b/programs/winedbg/gdbproxy.c
@@ -999,7 +999,7 @@ static enum packet_return packet_continue(struct gdb_context* gdbctx)
     return packet_reply_status(gdbctx);
 }
 
-static enum packet_return packet_verbose(struct gdb_context* gdbctx)
+static enum packet_return packet_verbose_cont(struct gdb_context* gdbctx)
 {
     int i;
     int defaultAction = -1; /* magic non action */
@@ -1012,9 +1012,6 @@ static enum packet_return packet_verbose(struct gdb_context* gdbctx)
     unsigned int threadID = 0;
     struct dbg_thread*  thd;
 
-    /* basic check */
-    assert(gdbctx->in_packet_len >= 4);
-
     /* OK we have vCont followed by..
     * ? for query
     * c for packet_continue
@@ -1024,11 +1021,6 @@ static enum packet_return packet_verbose(struct gdb_context* gdbctx)
     * and then an optional thread ID at the end..
     * *******************************************/
 
-    if (gdbctx->trace & GDBPXY_TRC_COMMAND)
-        fprintf(stderr, "trying to process a verbose packet\n");
-    /* now check that we've got Cont */
-    assert(strncmp(gdbctx->in_packet, "Cont", 4) == 0);
-
     /* Query */
     if (gdbctx->in_packet[4] == '?')
     {
@@ -1095,7 +1087,7 @@ static enum packet_return packet_verbose(struct gdb_context* gdbctx)
          * (they're running winedbg, so I'm sure they can fix the problem from the error message!) */
         if (threadCount == 100)
         {
-            fprintf(stderr, "Wow, that's a lot of threads, change threadIDs in wine/programms/winedgb/gdbproxy.c to be higher\n");
+            fprintf(stderr, "Wow, that's a lot of threads, change threadIDs in wine/programms/winedbg/gdbproxy.c to be higher\n");
             break;
         }
     }
@@ -1198,6 +1190,58 @@ static enum packet_return packet_verbose(struct gdb_context* gdbctx)
     return packet_reply_status(gdbctx);
 }
 
+struct verbose_defail
+{
+    const char*         name;
+    unsigned            len;
+    enum packet_return  (*handler)(struct gdb_context*);
+} verbose_details[] =
+{
+    /* {"Attach",           6}, */
+    {"Cont",             4, packet_verbose_cont},
+    /* {"File",             4},
+    {"FlashErase",      10},
+    {"FlashWrite",      10},
+    {"FlashDone",        9},
+    {"Kill",             4},
+    {"Run",              3},
+    {"Stopped",          7},*/
+};
+
+static enum packet_return packet_verbose(struct gdb_context* gdbctx)
+{
+    unsigned i;
+    unsigned klen;
+
+    for (klen = 0; ; klen++)
+    {
+        if (klen == gdbctx->in_packet_len ||
+            gdbctx->in_packet[klen] == ';' ||
+            gdbctx->in_packet[klen] == ':' ||
+            gdbctx->in_packet[klen] == '?')
+        {
+            if (gdbctx->trace & GDBPXY_TRC_COMMAND)
+                fprintf(stderr, "trying to process a verbose packet %*.*s\n",
+                        gdbctx->in_packet_len, gdbctx->in_packet_len, gdbctx->in_packet);
+            for (i = 0; i < sizeof(verbose_details)/sizeof(verbose_details[0]); i++)
+            {
+                if (klen == verbose_details[i].len &&
+                    !memcmp(gdbctx->in_packet, verbose_details[i].name, verbose_details[i].len))
+                {
+                    return verbose_details[i].handler(gdbctx);
+                }
+            }
+            /* no matching handler found, abort */
+            break;
+        }
+    }
+
+    if (gdbctx->trace & GDBPXY_TRC_COMMAND_FIXME)
+        fprintf(stderr, "No support for verbose packet %*.*s\n",
+                gdbctx->in_packet_len, gdbctx->in_packet_len, gdbctx->in_packet);
+    return packet_error;
+ }
+
 static enum packet_return packet_continue_signal(struct gdb_context* gdbctx)
 {
     unsigned char sig;




More information about the wine-cvs mailing list