From 4e22772d17868466c3d941f888d255c667abc039 Mon Sep 17 00:00:00 2001 From: Jan Kratochvil Date: Thu, 27 Aug 2009 06:33:25 +0000 Subject: [PATCH] gdb/ * varobj.c (varobj_create): Error if the specified frame was not found and it is needed. gdb/testsuite/ * gdb.mi/mi2-var-cmd.exp (create variable with invalid FRAME-ADDR): New. --- gdb/ChangeLog | 5 +++++ gdb/testsuite/ChangeLog | 4 ++++ gdb/testsuite/gdb.mi/mi2-var-cmd.exp | 5 +++++ gdb/varobj.c | 9 ++++++++- 4 files changed, 22 insertions(+), 1 deletion(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 1d802bdab00..46d3073068a 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2009-08-27 Jan Kratochvil + + * varobj.c (varobj_create): Error if the specified frame was not found + and it is needed. + 2009-08-26 Michael Snyder * i386-tdep.c (i386_process_record): Break out of prefix loop diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 6a8aba078d1..99c9c3db183 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2009-08-27 Jan Kratochvil + + * gdb.mi/mi2-var-cmd.exp (create variable with invalid FRAME-ADDR): New. + 2009-08-26 Michael Snyder * gdb.base/i386-reverse.c: New file. diff --git a/gdb/testsuite/gdb.mi/mi2-var-cmd.exp b/gdb/testsuite/gdb.mi/mi2-var-cmd.exp index 96d42a17432..dda77bb8aad 100644 --- a/gdb/testsuite/gdb.mi/mi2-var-cmd.exp +++ b/gdb/testsuite/gdb.mi/mi2-var-cmd.exp @@ -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" + ##### ##### # # diff --git a/gdb/varobj.c b/gdb/varobj.c index fbe8ff8e76c..603071f8976 100644 --- a/gdb/varobj.c +++ b/gdb/varobj.c @@ -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); -- 2.30.2