* Makefile.in (eval.o): Update dependencies.
authorDaniel Jacobowitz <drow@false.org>
Thu, 4 Jan 2007 21:59:10 +0000 (21:59 +0000)
committerDaniel Jacobowitz <drow@false.org>
Thu, 4 Jan 2007 21:59:10 +0000 (21:59 +0000)
* eval.c: Include "ui-out.h" and "exceptions.h".
(evaluate_subexp_standard): Use TRY_CATCH around value_of_variable.
Use value_zero if an error occurs when avoiding side effects.
* varobj.c (c_value_of_root): Initialize new_val.

* gdb.mi/mi-var-cmd.exp: Add tests for unreadable varobjs.

gdb/ChangeLog
gdb/Makefile.in
gdb/eval.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.mi/mi-var-cmd.exp
gdb/varobj.c

index e5b5743ce17f73dcd32745861b975b68cf609d79..854e5735d7d15e26a6f19bdafc09e96b6978cd40 100644 (file)
@@ -1,3 +1,11 @@
+2007-01-04  Daniel Jacobowitz  <dan@codesourcery.com>
+
+       * Makefile.in (eval.o): Update dependencies.
+       * eval.c: Include "ui-out.h" and "exceptions.h".
+       (evaluate_subexp_standard): Use TRY_CATCH around value_of_variable.
+       Use value_zero if an error occurs when avoiding side effects.
+       * varobj.c (c_value_of_root): Initialize new_val.
+
 2007-01-04  Daniel Jacobowitz  <dan@codesourcery.com>
 
        * varobj.c (varobj_list_children): Stop if the number of children is
index 491e7d4844241107139238de9fc52582c78773e5..928cd771d0a9a10abc5b01acde39b85b1e2d13d9 100644 (file)
@@ -1968,7 +1968,8 @@ environ.o: environ.c $(defs_h) $(environ_h) $(gdb_string_h)
 eval.o: eval.c $(defs_h) $(gdb_string_h) $(symtab_h) $(gdbtypes_h) \
        $(value_h) $(expression_h) $(target_h) $(frame_h) $(language_h) \
        $(f_lang_h) $(cp_abi_h) $(infcall_h) $(objc_lang_h) $(block_h) \
-       $(parser_defs_h) $(cp_support_h) $(gdb_assert_h)
+       $(parser_defs_h) $(cp_support_h) $(gdb_assert_h) $(exceptions_h) \
+       $(uiout_h)
 event-loop.o: event-loop.c $(defs_h) $(event_loop_h) $(event_top_h) \
        $(gdb_string_h) $(exceptions_h) $(gdb_assert_h) $(gdb_select_h)
 event-top.o: event-top.c $(defs_h) $(top_h) $(inferior_h) $(target_h) \
index 1a3d72a547834021172a9043a2e40990f3dd6515..4954e9fbaf16c24f5022dca0ecbd54d1657c8377 100644 (file)
@@ -37,6 +37,8 @@
 #include "block.h"
 #include "parser-defs.h"
 #include "cp-support.h"
+#include "ui-out.h"
+#include "exceptions.h"
 
 #include "gdb_assert.h"
 
@@ -469,8 +471,26 @@ evaluate_subexp_standard (struct type *expect_type,
         value_rtti_target_type () if we are dealing with a pointer
         or reference to a base class and print object is on. */
 
-       return value_of_variable (exp->elts[pc + 2].symbol,
-                                 exp->elts[pc + 1].block);
+      {
+       volatile struct gdb_exception except;
+       struct value *ret = NULL;
+
+       TRY_CATCH (except, RETURN_MASK_ERROR)
+         {
+           ret = value_of_variable (exp->elts[pc + 2].symbol,
+                                    exp->elts[pc + 1].block);
+         }
+
+       if (except.reason < 0)
+         {
+           if (noside == EVAL_AVOID_SIDE_EFFECTS)
+             ret = value_zero (SYMBOL_TYPE (exp->elts[pc + 2].symbol), not_lval);
+           else
+             throw_exception (except);
+         }
+
+       return ret;
+      }
 
     case OP_LAST:
       (*pos) += 2;
index 6966dceb6a69814e58526266f188bd8c4338a8f0..d8b8c3531a323f5dc3057e1e34ae9b9091c4186d 100644 (file)
@@ -1,3 +1,7 @@
+2007-01-04  Daniel Jacobowitz  <dan@codesourcery.com>
+
+       * gdb.mi/mi-var-cmd.exp: Add tests for unreadable varobjs.
+
 2007-01-04  Daniel Jacobowitz  <dan@codesourcery.com>
 
        * lib/mi-support.exp (mi_runto_helper): Expect two prompts
index d7cd4e99a0b88e82551f3e8272727a8107fc449e..9dfcc52d1c434d1b79e5abbf2fe37fedea643166 100644 (file)
@@ -586,5 +586,48 @@ mi_gdb_test "-var-update selected_a" \
        "\\^done,changelist=\\\[\{name=\"selected_a\",in_scope=\"true\",new_type=\"int\",new_num_children=\"0\"\}\\\]" \
        "update selected_a in do_special_tests"
 
+# Test whether bad varobjs crash GDB.
+
+# A varobj we fail to read during -var-update should be considered
+# out of scope.
+mi_gdb_test "-var-create null_ptr * **0" \
+    {\^done,name="null_ptr",numchild="0",type="int"} \
+    "create null_ptr"
+
+# Allow this to succeed, if address zero is readable, although it
+# will not test what it was meant to.  Most important is that GDB
+# does not crash.
+mi_gdb_test "-var-update null_ptr" \
+    {\^done,changelist=\[{.*}\]} \
+    "update null_ptr"
+
+mi_gdb_test "-var-delete null_ptr" \
+    "\\^done,ndeleted=\"1\"" \
+    "delete null_ptr"
+
+# When we fail to read a varobj created from a named variable,
+# we evaluate its type instead.  Make sure that doesn't blow
+# up by trying to read it again.  We can use _end when not running
+# the program to simulate an unreadable variable, if this platform
+# provides _end, but cope if it's missing.
+
+mi_gdb_test "kill" \
+    {&"kill\\n".*\^done} \
+    "kill program before endvar"
+
+mi_gdb_test "-var-create endvar * _end" \
+    {(\^done,name="endvar",numchild="0",type=".*"|&".*unable to.*".*\^error,msg=".*")} \
+    "create endvar"
+
+# Allow this to succeed whether the value is readable, unreadable, or
+# missing.  Most important is that GDB does not crash.
+mi_gdb_test "-var-update endvar" \
+    {(\^done,changelist=\[.*\]|^".*".*\^error,msg=".*not found")} \
+    "update endvar"
+
+mi_gdb_test "-var-delete endvar" \
+    "\\^done,ndeleted=\"1\"" \
+    "delete endvar"
+
 mi_gdb_exit
 return 0
index a9f8ee07984e9643eaf19c690a3ed99e6834fa34..33cea73a86303d946c2bcc54a055278381423401 100644 (file)
@@ -1908,7 +1908,7 @@ c_name_of_child (struct varobj *parent, int index)
 static struct value *
 c_value_of_root (struct varobj **var_handle)
 {
-  struct value *new_val;
+  struct value *new_val = NULL;
   struct varobj *var = *var_handle;
   struct frame_info *fi;
   int within_scope;
This page took 0.038808 seconds and 4 git commands to generate.