From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13533 invoked by alias); 21 Jan 2007 17:24:38 -0000 Received: (qmail 13512 invoked by uid 22791); 21 Jan 2007 17:24:36 -0000 X-Spam-Check-By: sourceware.org Received: from nevyn.them.org (HELO nevyn.them.org) (66.93.172.17) by sourceware.org (qpsmtpd/0.31.1) with ESMTP; Sun, 21 Jan 2007 17:24:29 +0000 Received: from drow by nevyn.them.org with local (Exim 4.63) (envelope-from ) id 1H8gQc-0003cs-Ap; Sun, 21 Jan 2007 12:24:26 -0500 Date: Sun, 21 Jan 2007 17:24:00 -0000 From: Daniel Jacobowitz To: Mark Kettenis , gdb-patches@sourceware.org, hongjiu.lu@intel.com Subject: Re: PATCH: Initialize tmp_obstack Message-ID: <20070121172426.GC12463@nevyn.them.org> Mail-Followup-To: Mark Kettenis , gdb-patches@sourceware.org, hongjiu.lu@intel.com References: <12601.163.1.150.229.1165354805.squirrel@webmail.xs4all.nl> <20061205214306.GA29801@nevyn.them.org> <20637.163.1.150.229.1165355320.squirrel@webmail.xs4all.nl> <20061205215639.GA30371@nevyn.them.org> <20061205235848.GA2551@nevyn.them.org> <20061207144018.GA12915@nevyn.them.org> <20061225040032.GA29719@nevyn.them.org> <20070116065937.GA15794@nevyn.them.org> <200701211307.l0LD7EO0000187@brahms.sibelius.xs4all.nl> <20070121155940.GA9459@nevyn.them.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20070121155940.GA9459@nevyn.them.org> User-Agent: Mutt/1.5.13 (2006-08-11) 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: 2007-01/txt/msg00436.txt.bz2 On Sun, Jan 21, 2007 at 10:59:41AM -0500, Daniel Jacobowitz wrote: > On Sun, Jan 21, 2007 at 02:07:14PM +0100, Mark Kettenis wrote: > > I had another look and come up with the attached. By always > > initializing tmp_obstack the code is less optimal, but at least I can > > convince myself the code is safe now. Unfortunately I can't test > > whether this fixes the GCC 4.1 warnings. > > Thanks! I can test it - I'll let you know this afternoon. Works fine. > p-valprint.c has the same problem, but the correct fix there is going > to be to delete some code. Pascal copied a lot from C/C++ but it > doesn't actually have static members to the best of my knowledge. > I see some discussion of them as planned for GNU Pascal, but no > implementations. But it was easier to copy your fix into p-valprint.c than to untangle which parts of this Pascal really needs and which parts it just copied. Wish we had some test coverage for pascal! See attached; cp-valprint.c parts unchanged, p-valprint.c parts copied from that and compile tested only. -- Daniel Jacobowitz CodeSourcery from Mark Kettenis * cp-valprint.c (cp_print_value_fields, cp_print_value): Always initialize tmp_obstack. * p-valprint.c (pascal_object_print_value_fields) (pascal_object_print_value): Likewise. --- gdb/cp-valprint.c | 7 +++---- gdb/p-valprint.c | 6 ++---- 2 files changed, 5 insertions(+), 8 deletions(-) Index: src/gdb/cp-valprint.c =================================================================== --- src.orig/gdb/cp-valprint.c 2007-01-21 12:17:05.000000000 -0500 +++ src/gdb/cp-valprint.c 2007-01-21 12:17:09.000000000 -0500 @@ -167,7 +167,6 @@ cp_print_value_fields (struct type *type struct type **dont_print_vb,int dont_print_statmem) { int i, len, n_baseclasses; - struct obstack tmp_obstack; char *last_dont_print = obstack_next_free (&dont_print_statmem_obstack); int fields_seen = 0; @@ -197,12 +196,13 @@ cp_print_value_fields (struct type *type fprintf_filtered (stream, ""); else { + struct obstack tmp_obstack = dont_print_statmem_obstack; + if (dont_print_statmem == 0) { /* If we're at top level, carve out a completely fresh chunk of the obstack and use that until this particular invocation returns. */ - tmp_obstack = dont_print_statmem_obstack; obstack_finish (&dont_print_statmem_obstack); } @@ -426,9 +426,9 @@ cp_print_value (struct type *type, struc struct ui_file *stream, int format, int recurse, enum val_prettyprint pretty, struct type **dont_print_vb) { - struct obstack tmp_obstack; struct type **last_dont_print = (struct type **) obstack_next_free (&dont_print_vb_obstack); + struct obstack tmp_obstack = dont_print_vb_obstack; int i, n_baseclasses = TYPE_N_BASECLASSES (type); int thisoffset; struct type *thistype; @@ -438,7 +438,6 @@ cp_print_value (struct type *type, struc /* If we're at top level, carve out a completely fresh chunk of the obstack and use that until this particular invocation returns. */ - tmp_obstack = dont_print_vb_obstack; /* Bump up the high-water mark. Now alpha is omega. */ obstack_finish (&dont_print_vb_obstack); } Index: src/gdb/p-valprint.c =================================================================== --- src.orig/gdb/p-valprint.c 2007-01-21 12:17:07.000000000 -0500 +++ src/gdb/p-valprint.c 2007-01-21 12:20:40.000000000 -0500 @@ -641,7 +641,6 @@ pascal_object_print_value_fields (struct int dont_print_statmem) { int i, len, n_baseclasses; - struct obstack tmp_obstack; char *last_dont_print = obstack_next_free (&dont_print_statmem_obstack); CHECK_TYPEDEF (type); @@ -660,6 +659,7 @@ pascal_object_print_value_fields (struct fprintf_filtered (stream, ""); else { + struct obstack tmp_obstack = dont_print_statmem_obstack; int fields_seen = 0; if (dont_print_statmem == 0) @@ -667,7 +667,6 @@ pascal_object_print_value_fields (struct /* If we're at top level, carve out a completely fresh chunk of the obstack and use that until this particular invocation returns. */ - tmp_obstack = dont_print_statmem_obstack; obstack_finish (&dont_print_statmem_obstack); } @@ -810,9 +809,9 @@ pascal_object_print_value (struct type * enum val_prettyprint pretty, struct type **dont_print_vb) { - struct obstack tmp_obstack; struct type **last_dont_print = (struct type **) obstack_next_free (&dont_print_vb_obstack); + struct obstack tmp_obstack = dont_print_vb_obstack; int i, n_baseclasses = TYPE_N_BASECLASSES (type); if (dont_print_vb == 0) @@ -820,7 +819,6 @@ pascal_object_print_value (struct type * /* If we're at top level, carve out a completely fresh chunk of the obstack and use that until this particular invocation returns. */ - tmp_obstack = dont_print_vb_obstack; /* Bump up the high-water mark. Now alpha is omega. */ obstack_finish (&dont_print_vb_obstack); }