From: Jan Kratochvil <jan.kratochvil@redhat.com>
To: gdb-patches@sourceware.org
Cc: Dodji Seketeli <dseketel@redhat.com>
Subject: [patch] MI: Error out on -var-create invalid FRAME-ADDR
Date: Mon, 10 Aug 2009 16:55:00 -0000 [thread overview]
Message-ID: <20090810162949.GA9704@host0.dyn.jankratochvil.net> (raw)
Hi,
-var-create could create VAROBJ with uninitialized thread_id leading to
unexpected processing.
The frame parameter of -var-create is FRAME-ADDR, one could expect it is
FRAME-ID. It is even commented in the source:
/* FIXME: cagney/2002-11-23: This code should be doing a
lookup using the frame ID and not just the frame's
``address''. This, of course, means an interface
change. However, with out that interface change ISAs,
such as the ia64 with its two stacks, won't work.
Similar goes for the case where there is a frameless
function. */
fi = find_frame_addr_in_frame_chain (frame);
At least error out when the frame is not found AND it harms.
Therefore the original command Dodji bugreporting it:
-var-create var2 0 variable
should have been instead:
-var-create --thread 1 --frame 0 var2 * variable
Regression tested on {x86_64,i686}-fedora11-linux-gnu.
find_frame_addr_in_frame_chain already has an explicit check for 0 so 0
currently can never be a valid frame address on any arch:
if (frame_addr == (CORE_ADDR) 0)
return NULL;
Thanks,
Jan
gdb/
2009-08-10 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-10 Jan Kratochvil <jan.kratochvil@redhat.com>
* gdb.mi/mi2-var-cmd.exp (create variable with invalid FRAME-ADDR): New.
--- 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" \
+ "&\"Failed to find the specified frame.\\\\n\".*\\^error,msg=\"mi_cmd_var_create: unable to create variable object\"" \
+ "create variable with invalid FRAME-ADDR"
+
##### #####
# #
--- a/gdb/varobj.c
+++ b/gdb/varobj.c
@@ -565,8 +567,19 @@ 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)
+ {
+ fprintf_unfiltered (gdb_stderr, "Failed to find the specified"
+ " frame.\n");
+ return NULL;
+ }
+
var->root->frame = get_frame_id (fi);
var->root->thread_id = pid_to_thread_id (inferior_ptid);
old_fi = get_selected_frame (NULL);
next reply other threads:[~2009-08-10 16:30 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-10 16:55 Jan Kratochvil [this message]
2009-08-10 17:00 ` Vladimir Prus
2009-08-10 17:47 ` Jan Kratochvil
2009-08-13 15:03 ` Vladimir Prus
2009-08-26 20:08 ` Jan Kratochvil
2009-08-27 5:35 ` Vladimir Prus
2009-08-27 7:37 ` Jan Kratochvil
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20090810162949.GA9704@host0.dyn.jankratochvil.net \
--to=jan.kratochvil@redhat.com \
--cc=dseketel@redhat.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox