From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22635 invoked by alias); 10 Aug 2009 16:30:01 -0000 Received: (qmail 22545 invoked by uid 22791); 10 Aug 2009 16:30:00 -0000 X-SWARE-Spam-Status: No, hits=-1.1 required=5.0 tests=AWL,BAYES_50,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mx2.redhat.com (HELO mx2.redhat.com) (66.187.237.31) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 10 Aug 2009 16:29:54 +0000 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n7AGTqRU013777 for ; Mon, 10 Aug 2009 12:29:52 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n7AGTpNW021371; Mon, 10 Aug 2009 12:29:52 -0400 Received: from host0.dyn.jankratochvil.net (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id n7AGTow0002271; Mon, 10 Aug 2009 12:29:51 -0400 Received: from host0.dyn.jankratochvil.net (localhost [127.0.0.1]) by host0.dyn.jankratochvil.net (8.14.3/8.14.3) with ESMTP id n7AGTn18010961; Mon, 10 Aug 2009 18:29:49 +0200 Received: (from jkratoch@localhost) by host0.dyn.jankratochvil.net (8.14.3/8.14.3/Submit) id n7AGTnZE010957; Mon, 10 Aug 2009 18:29:49 +0200 Date: Mon, 10 Aug 2009 16:55:00 -0000 From: Jan Kratochvil To: gdb-patches@sourceware.org Cc: Dodji Seketeli Subject: [patch] MI: Error out on -var-create invalid FRAME-ADDR Message-ID: <20090810162949.GA9704@host0.dyn.jankratochvil.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.19 (2009-01-05) X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2009-08/txt/msg00142.txt.bz2 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 * varobj.c (varobj_create): Error if the specified frame was not found and it is needed. gdb/testsuite/ 2009-08-10 Jan Kratochvil * 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);