[gnome-builder/wip/chergert/debugger: 104/106] mi2: fix adding more than one item to list in message parsing



commit a653d43292fae2550e7b7dd8e679ac4f64905a15
Author: Christian Hergert <chergert redhat com>
Date:   Mon Mar 27 14:37:36 2017 -0700

    mi2: fix adding more than one item to list in message parsing

 contrib/mi2/mi2-util.c        |   10 ++++++----
 contrib/mi2/test-stream-1.txt |    1 +
 2 files changed, 7 insertions(+), 4 deletions(-)
---
diff --git a/contrib/mi2/mi2-util.c b/contrib/mi2/mi2-util.c
index 299720e..8b9822d 100644
--- a/contrib/mi2/mi2-util.c
+++ b/contrib/mi2/mi2-util.c
@@ -200,8 +200,6 @@ mi2_util_parse_list (const gchar  *line,
 
   if (*line != ']')
     {
-      g_variant_builder_open (&builder, G_VARIANT_TYPE ("v"));
-
       while (*line != ']')
         {
           if (*line == '"')
@@ -211,7 +209,9 @@ mi2_util_parse_list (const gchar  *line,
               if (!(value = mi2_util_parse_string (line, &line)))
                 goto failure;
 
+              g_variant_builder_open (&builder, G_VARIANT_TYPE ("v"));
               g_variant_builder_add (&builder, "s", value);
+              g_variant_builder_close (&builder);
             }
           else if (*line == '{')
             {
@@ -220,7 +220,9 @@ mi2_util_parse_list (const gchar  *line,
               if (!(v = mi2_util_parse_record (line, &line)))
                 goto failure;
 
+              g_variant_builder_open (&builder, G_VARIANT_TYPE ("v"));
               g_variant_builder_add_value (&builder, v);
+              g_variant_builder_close (&builder);
             }
           else if (*line == '[')
             {
@@ -229,7 +231,9 @@ mi2_util_parse_list (const gchar  *line,
               if (!(ar = mi2_util_parse_list (line, &line)))
                 goto failure;
 
+              g_variant_builder_open (&builder, G_VARIANT_TYPE ("v"));
               g_variant_builder_add_value (&builder, ar);
+              g_variant_builder_close (&builder);
             }
           else
             goto failure;
@@ -238,8 +242,6 @@ mi2_util_parse_list (const gchar  *line,
           if (*line == ',')
             line++;
         }
-
-      g_variant_builder_close (&builder);
     }
 
   g_assert (*line == ']');
diff --git a/contrib/mi2/test-stream-1.txt b/contrib/mi2/test-stream-1.txt
index 6c0cf32..7cfd226 100644
--- a/contrib/mi2/test-stream-1.txt
+++ b/contrib/mi2/test-stream-1.txt
@@ -38,6 +38,7 @@
 ~"\n"
 ~"Breakpoint 1, 0x00005555555578b0 in main ()\n"
 
*stopped,reason="breakpoint-hit",disp="keep",bkptno="1",frame={addr="0x00005555555578b0",func="main",args=[]},thread-id="1",stopped-threads="all",core="1"
+*stopped,reason="breakpoint-hit",disp="del",bkptno="1",frame={addr="0x00000000004009e0",func="main",args=[{name="argc",value="1"},{name="argv",value="0x7fffffffe9a8"}],file="main.c",fullname="/home/christian/Projects/rtfm/src/main.c",line="26"},thread-id="1",stopped-threads="all",core="2"
 (gdb) 
 &"c\n"
 ~"Continuing.\n"


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]