From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11956 invoked by alias); 13 Sep 2011 21:45:51 -0000 Received: (qmail 11945 invoked by uid 22791); 13 Sep 2011 21:45:50 -0000 X-SWARE-Spam-Status: No, hits=-6.8 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,SPF_HELO_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 13 Sep 2011 21:45:27 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p8DLjRx5013660 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 13 Sep 2011 17:45:27 -0400 Received: from host1.jankratochvil.net (ovpn-116-38.ams2.redhat.com [10.36.116.38]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p8DLjPaH003055 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 13 Sep 2011 17:45:26 -0400 Received: from host1.jankratochvil.net (localhost [127.0.0.1]) by host1.jankratochvil.net (8.14.4/8.14.4) with ESMTP id p8DLjOQ3019732; Tue, 13 Sep 2011 23:45:24 +0200 Received: (from jkratoch@localhost) by host1.jankratochvil.net (8.14.4/8.14.4/Submit) id p8DLjOTs019731; Tue, 13 Sep 2011 23:45:24 +0200 Date: Tue, 13 Sep 2011 21:53:00 -0000 From: Jan Kratochvil To: Tom Tromey Cc: gdb-patches@sourceware.org Subject: Re: [patch] Remove excessive DWARF block xmemdup by me Message-ID: <20110913214524.GA17836@host1.jankratochvil.net> References: <20110718201528.GC30496@host1.jankratochvil.net> <20110724175123.GA7792@host1.jankratochvil.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20110724175123.GA7792@host1.jankratochvil.net> User-Agent: Mutt/1.5.21 (2010-09-15) 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: 2011-09/txt/msg00240.txt.bz2 On Sun, 24 Jul 2011 19:51:23 +0200, Jan Kratochvil wrote: > gdb/ > 2011-07-24 Jan Kratochvil > > Remove excessive DWARF expressions memory duplication. > * dwarf2loc.c (per_cu_dwarf_call): Remove variable back_to and its use > for block.data. > (indirect_pieced_value): Remove variable result. Remove variable > back_to and its use for baton.data. > (dwarf2_compile_expr_to_ax): Remove variable back_to and its use for > block.data. > * dwarf2read.c (dwarf2_fetch_die_location_block): Remove xmemdup. > Update the function comment. Checked in, with a small technical re-diff. (This is just a fix-up of a fault of mine I checked in before.) Sorry, Jan http://sourceware.org/ml/gdb-cvs/2011-09/msg00077.html --- src/gdb/ChangeLog 2011/09/13 19:27:00 1.13327 +++ src/gdb/ChangeLog 2011/09/13 21:44:24 1.13328 @@ -1,3 +1,15 @@ +2011-09-13 Jan Kratochvil + + Remove excessive DWARF expressions memory duplication. + * dwarf2loc.c (per_cu_dwarf_call): Remove variable back_to and its use + for block.data. + (indirect_pieced_value): Remove variable result. Remove variable + back_to and its use for baton.data. + (dwarf2_compile_expr_to_ax): Remove variable back_to and its use for + block.data. + * dwarf2read.c (dwarf2_fetch_die_location_block): Remove xmemdup. + Update the function comment. + 2011-09-13 Pedro Alves * inferior.h (ALL_INFERIORS): New. --- src/gdb/dwarf2loc.c 2011/08/08 21:41:13 1.127 +++ src/gdb/dwarf2loc.c 2011/09/13 21:44:27 1.128 @@ -265,19 +265,14 @@ void *baton) { struct dwarf2_locexpr_baton block; - struct cleanup *back_to; block = dwarf2_fetch_die_location_block (die_offset, per_cu, get_frame_pc, baton); - back_to = make_cleanup (xfree, (void *) block.data); - /* DW_OP_call_ref is currently not supported. */ gdb_assert (block.per_cu == per_cu); dwarf_expr_eval (ctx, block.data, block.size); - - do_cleanups (back_to); } /* Helper interface of per_cu_dwarf_call for dwarf2_evaluate_loc_desc. */ @@ -969,9 +964,7 @@ struct dwarf2_locexpr_baton baton; int i, bit_offset, bit_length; struct dwarf_expr_piece *piece = NULL; - struct value *result; LONGEST byte_offset; - struct cleanup *back_to; type = check_typedef (value_type (value)); if (TYPE_CODE (type) != TYPE_CODE_PTR) @@ -1021,15 +1014,9 @@ get_frame_address_in_block_wrapper, frame); - back_to = make_cleanup (xfree, (void *) baton.data); - - result = dwarf2_evaluate_loc_desc_full (TYPE_TARGET_TYPE (type), frame, - baton.data, baton.size, baton.per_cu, - piece->v.ptr.offset + byte_offset); - - do_cleanups (back_to); - - return result; + return dwarf2_evaluate_loc_desc_full (TYPE_TARGET_TYPE (type), frame, + baton.data, baton.size, baton.per_cu, + piece->v.ptr.offset + byte_offset); } static void * @@ -2147,14 +2134,12 @@ { struct dwarf2_locexpr_baton block; int size = (op == DW_OP_call2 ? 2 : 4); - struct cleanup *back_to; uoffset = extract_unsigned_integer (op_ptr, size, byte_order); op_ptr += size; block = dwarf2_fetch_die_location_block (uoffset, per_cu, get_ax_pc, expr); - back_to = make_cleanup (xfree, (void *) block.data); /* DW_OP_call_ref is currently not supported. */ gdb_assert (block.per_cu == per_cu); @@ -2162,8 +2147,6 @@ dwarf2_compile_expr_to_ax (expr, loc, arch, addr_size, block.data, block.data + block.size, per_cu); - - do_cleanups (back_to); } break; --- src/gdb/dwarf2read.c 2011/09/09 19:41:13 1.560 +++ src/gdb/dwarf2read.c 2011/09/13 21:44:27 1.561 @@ -13854,9 +13854,9 @@ return die; } -/* Return DWARF block and its CU referenced by OFFSET at PER_CU. Returned - value is intended for DW_OP_call*. You must call xfree on returned - dwarf2_locexpr_baton->data. */ +/* Return DWARF block referenced by DW_AT_location of DIE at OFFSET at PER_CU. + Returned value is intended for DW_OP_call*. Returned + dwarf2_locexpr_baton->data has lifetime of PER_CU->OBJFILE. */ struct dwarf2_locexpr_baton dwarf2_fetch_die_location_block (unsigned int offset, @@ -13912,9 +13912,6 @@ } retval.per_cu = cu->per_cu; - if (retval.data) - retval.data = xmemdup (retval.data, retval.size, retval.size); - age_cached_comp_units (); return retval;