]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Fix for PR mi/15863
authorKeith Seitz <keiths@redhat.com>
Wed, 11 Jun 2014 20:26:50 +0000 (13:26 -0700)
committerKeith Seitz <keiths@redhat.com>
Mon, 16 Jun 2014 18:38:19 +0000 (11:38 -0700)
If an MI client creates a varobj and attempts to update the root
/before/ the inferior is started, gdb will throw an internal error:

(gdb)
-var-create * - batch_flag
^done,name="var1",numchild="0",value="0",type="int",has_more="0"
(gdb)
-var-update var1
^done,changelist=[]
(gdb)
-var-update *
~"../../src/gdb/thread.c:628: internal-error: is_thread_state: Assertion `tp' failed.\nA problem internal to GDB has been detected,\nfurther debugging may prove unreliable.\nQuit this debugging session? "
~"(y or n) "

The function that handles the varobj update in the failing case,
mi_cmd_var_udpate_iter, checks if the thread/inferior is stopped before
attempting to update the varobj. It calls is_stopped (inferior_ptid)
which calls is_thread_state:

    tp = find_thread_ptid (ptid);
    gdb_assert (tp);

When there is no inferior, ptid is null_ptid, and find_thread_ptid (null_ptid)
returns NULL and the assertion is triggered.

This patch changes mi_cmd_var_update_iter to behave the same way
"-var-update var1" does: by calling the thread "stopped" if
there is no inferior (and thereby calling varobj_update_one).

ChangeLog
2014-06-16  Keith Seitz  <keiths@redhat.com>

PR mi/15863
* mi/mi-cmd-var.c (mi_cmd_var_update_iter): Do not attempt
to update the varobj if inferior_ptid is null_ptid.

testsuite/ChangeLog
2014-06-16  Keith Seitz  <keiths@redhat.com>

PR mi/15863
* gdb.mi/mi-var-cmd.exp: Add test for -var-update before
the inferior is started.

gdb/ChangeLog
gdb/mi/mi-cmd-var.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.mi/mi-var-cmd.exp

index b3aa092e78de5401097ebd0049abae2820ccf0de..5cec8d53d6d82c0ba47cb846091fb171218776e0 100644 (file)
@@ -1,3 +1,9 @@
+2014-06-16  Keith Seitz  <keiths@redhat.com>
+
+       PR mi/15863
+       * mi/mi-cmd-var.c (mi_cmd_var_update_iter): Do not attempt
+       to update the varobj if inferior_ptid is null_ptid.
+
 2014-06-16  Tom Tromey  <tromey@redhat.com>
 
        * target.h (struct target_ops) <to_info_proc>: Make parameter
index 90596161a7f83f8edbfeced487cf94725650efbc..08a87bf72bcbcc6a9ae9ae5ebe4765201b517280 100644 (file)
@@ -642,7 +642,9 @@ mi_cmd_var_update_iter (struct varobj *var, void *data_pointer)
 
   thread_id = varobj_get_thread_id (var);
 
-  if (thread_id == -1 && is_stopped (inferior_ptid))
+  if (thread_id == -1
+      && (ptid_equal (inferior_ptid, null_ptid)
+         || is_stopped (inferior_ptid)))
     thread_stopped = 1;
   else
     {
index 17e2a1aa31acafa54c1d57ab74a7cdd955046386..cb671f5306a9ef740b8dd8c6e08e646910099e35 100644 (file)
@@ -1,3 +1,9 @@
+2014-06-16  Keith Seitz  <keiths@redhat.com>
+
+       PR mi/15863
+       * gdb.mi/mi-var-cmd.exp: Add test for -var-update before
+       the inferior is started.
+
 2014-06-16  Pedro Alves  <palves@redhat.com>
 
        * gdb.base/break-main-file-remove-fail.c: New file.
index 46a4e9e50492adc697fccd6eadbdb16264dbe59d..03e1b4c5f979a4bf609bf9ff4de5d7c26517eda8 100644 (file)
@@ -50,6 +50,12 @@ mi_gdb_load ${binfile}
 
 mi_create_varobj "global_simple" "global_simple" "create global variable"
 
+# PR mi/15863
+# Attempt to update the varobj before running the inferior.
+mi_gdb_test "-var-update *" \
+       "\\^done,changelist=\\\[\\\]" \
+       "update varobj before running inferior"
+
 # Test: c_variable-1.2
 # Desc: Create non-existent variable