This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch] MI: Error out on -var-create invalid FRAME-ADDR


On Thu, 13 Aug 2009 07:42:54 +0200, Vladimir Prus wrote:
> I'd prefer error for all new code. Thanks!

Attached, OK to check-in?

Regression-tested on {x86_64,i686}-fedora11-linux-gnu.


Thanks,
Jan


gdb/
2009-08-26  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* varobj.c (varobj_create): Error if the specified frame was not found
	and it is needed.

gdb/testsuite/
2009-08-26  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* gdb.mi/mi2-var-cmd.exp (create variable with invalid FRAME-ADDR): New.

--- ./gdb/varobj.c	14 Aug 2009 00:32:32 -0000	1.146
+++ ./gdb/varobj.c	25 Aug 2009 14:25:48 -0000
@@ -565,8 +565,15 @@ varobj_create (char *objname,
          we must select the appropriate frame before parsing
          the expression, otherwise the value will not be current.
          Since select_frame is so benign, just call it for all cases. */
-      if (innermost_block && fi != NULL)
+      if (innermost_block)
 	{
+	  /* User could specify explicit FRAME-ADDR which was not found but
+	     EXPRESSION is frame specific and we would not be able to evaluate
+	     it correctly next time.  With VALID_BLOCK set we must also set
+	     FRAME and THREAD_ID.  */
+	  if (fi == NULL)
+	    error (_("Failed to find the specified frame"));
+
 	  var->root->frame = get_frame_id (fi);
 	  var->root->thread_id = pid_to_thread_id (inferior_ptid);
 	  old_fi = get_selected_frame (NULL);
--- ./gdb/testsuite/gdb.mi/mi2-var-cmd.exp	7 Jul 2009 09:25:38 -0000	1.23
+++ ./gdb/testsuite/gdb.mi/mi2-var-cmd.exp	25 Aug 2009 14:25:50 -0000
@@ -126,6 +126,11 @@ mi_gdb_test "-var-create int * int" \
 	"&\"Attempt to use a type name as an expression.\\\\n\".*\\^error,msg=\"mi_cmd_var_create: unable to create variable object\"" \
 	"create int"
 
+# The number 0 must be an invalid frame address and linteger a local variable.
+mi_gdb_test "-var-create invalidframe 0 linteger" \
+	"\\^error,msg=\"Failed to find the specified frame\"" \
+	"create variable with invalid FRAME-ADDR"
+
 
 #####             #####
 #                     #


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]