From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31684 invoked by alias); 4 Jan 2006 21:04:16 -0000 Received: (qmail 31677 invoked by uid 22791); 4 Jan 2006 21:04:15 -0000 X-Spam-Check-By: sourceware.org Received: from w099.z064220152.sjc-ca.dsl.cnc.net (HELO duck.specifix.com) (64.220.152.99) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 04 Jan 2006 21:04:14 +0000 Received: from diveadx (duck.specifix.com [64.220.152.99]) by duck.specifix.com (Postfix) with ESMTP id A1040FC4D; Wed, 4 Jan 2006 13:04:12 -0800 (PST) From: Fred Fish Reply-To: fnf@specifix.com To: Jim Blandy Subject: Re: [PATCH] Fix ptype problem printing typedefs defined differently in different compilation units Date: Wed, 04 Jan 2006 21:04:00 -0000 User-Agent: KMail/1.9.1 Cc: gdb-patches@sourceware.org, fnf@specifix.com References: <200601031517.50309.fnf@specifix.com> <200601032147.14083.fnf@specifix.com> <8f2776cb0601031945gb876b84i48c145c291ecbcee@mail.gmail.com> In-Reply-To: <8f2776cb0601031945gb876b84i48c145c291ecbcee@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200601041604.49977.fnf@specifix.com> Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2006-01/txt/msg00050.txt.bz2 On Tuesday 03 January 2006 22:45, Jim Blandy wrote: > what would break if parse_exp_in_context used the current source > position as a fallback when get_selected_block returns zero? It > seems reasonable to me. That seems like the most reasonable alternative to me as well. The following patch solves the same problem as the original patch, in what is probably a little cleaner way. I don't get any testsuite regressions when using it. -Fred 2006-01-04 Fred Fish * parse.c (source.h): Include. (parse_exp_in_context): Use static source context if no other context found. Index: parse.c =================================================================== RCS file: /cvsroots/latest/src/gdb/gdb/parse.c,v retrieving revision 1.1.1.2 diff -c -p -r1.1.1.2 parse.c *** parse.c 30 Dec 2005 18:53:04 -0000 1.1.1.2 --- parse.c 4 Jan 2006 18:35:57 -0000 *************** *** 52,57 **** --- 52,58 ---- #include "doublest.h" #include "gdb_assert.h" #include "block.h" + #include "source.h" /* Standard set of definitions for printing, dumping, prefixifying, * and evaluating expressions. */ *************** parse_exp_in_context (char **stringptr, *** 1075,1087 **** old_chain = make_cleanup (free_funcalls, 0 /*ignore*/); funcall_chain = 0; if (block) { expression_context_block = block; expression_context_pc = BLOCK_START (block); } - else - expression_context_block = get_selected_block (&expression_context_pc); expout_size = 10; expout_ptr = 0; --- 1076,1102 ---- old_chain = make_cleanup (free_funcalls, 0 /*ignore*/); funcall_chain = 0; + /* If no context specified, try using the current frame, if any. */ + + if (!block) + block = get_selected_block (&expression_context_pc); + + /* Fall back to using the current source static context, if any. */ + + if (!block) + { + struct symtab_and_line cursal = get_current_source_symtab_and_line (); + if (cursal.symtab) + block = BLOCKVECTOR_BLOCK (BLOCKVECTOR (cursal.symtab), STATIC_BLOCK); + } + + /* Save the context, if specified by caller, or found above. */ + if (block) { expression_context_block = block; expression_context_pc = BLOCK_START (block); } expout_size = 10; expout_ptr = 0;