From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10250 invoked by alias); 24 Jul 2011 17:51:45 -0000 Received: (qmail 10242 invoked by uid 22791); 24 Jul 2011 17:51:45 -0000 X-SWARE-Spam-Status: No, hits=-7.0 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,SPF_HELO_PASS,TW_BJ 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; Sun, 24 Jul 2011 17:51:27 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p6OHpRaH001415 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Sun, 24 Jul 2011 13:51:27 -0400 Received: from host1.jankratochvil.net (ovpn-116-20.ams2.redhat.com [10.36.116.20]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p6OHpOOJ029719 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sun, 24 Jul 2011 13:51: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 p6OHpOSO008003; Sun, 24 Jul 2011 19:51:24 +0200 Received: (from jkratoch@localhost) by host1.jankratochvil.net (8.14.4/8.14.4/Submit) id p6OHpN3B008002; Sun, 24 Jul 2011 19:51:23 +0200 Date: Sun, 24 Jul 2011 18:10:00 -0000 From: Jan Kratochvil To: Tom Tromey Cc: gdb-patches@sourceware.org Subject: [patch] Remove excessive DWARF block xmemdup by me [Re: [patch 02/12] entryval: Basic parameter values recovery] Message-ID: <20110724175123.GA7792@host1.jankratochvil.net> References: <20110718201528.GC30496@host1.jankratochvil.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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-07/txt/msg00673.txt.bz2 On Tue, 19 Jul 2011 16:19:00 +0200, Tom Tromey wrote: > >>>>> "Jan" == Jan Kratochvil writes: > Jan> +/* Allocate a copy of BLK on CU's objfile_obstack (not comp_unit_obstack), > Jan> + including a copy of the BLK DWARF code. */ > Jan> + > Jan> +static struct dwarf2_locexpr_baton * > Jan> +dlbaton_obstack_copy (const struct dwarf_block *blk, struct dwarf2_cu *cu) > > I don't understand the need for this. > > Once we have mapped in a DWARF section, we do not unmap it until the > objfile is destroyed or reloaded. At that point, the types are all > destroyed as well. So, the lifetimes are already in sync, and you can > just store a pointer directly to the DWARF data. We already rely on > this in many cases. I agree. In such case my recently checked-in patch is also excessively memory copying this way. [patch] Fix DW_OP_call2 and DW_OP_call4 for max-cache-age 0 #2 http://sourceware.org/ml/gdb-patches/2011-07/msg00343.html f35c0b67e636d7ccddfee8ace6b462a73394b482 I will check it in. No regressions on {x86_64,x86_64-m32,i686}-fedora16pre-linux-gnu. Thanks, Jan 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. --- a/gdb/dwarf2loc.c +++ b/gdb/dwarf2loc.c @@ -265,19 +265,14 @@ per_cu_dwarf_call (struct dwarf_expr_context *ctx, size_t die_offset, 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 @@ indirect_pieced_value (struct value *value) 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) @@ -1019,15 +1012,9 @@ indirect_pieced_value (struct value *value) 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, - 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, + byte_offset); } static void * @@ -2133,14 +2120,12 @@ dwarf2_compile_expr_to_ax (struct agent_expr *expr, struct axs_value *loc, { 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); @@ -2148,8 +2133,6 @@ dwarf2_compile_expr_to_ax (struct agent_expr *expr, struct axs_value *loc, dwarf2_compile_expr_to_ax (expr, loc, arch, addr_size, block.data, block.data + block.size, per_cu); - - do_cleanups (back_to); } break; --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -13892,9 +13892,9 @@ follow_die_ref (struct die_info *src_die, struct attribute *attr, 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, @@ -13950,9 +13950,6 @@ dwarf2_fetch_die_location_block (unsigned int offset, } retval.per_cu = cu->per_cu; - if (retval.data) - retval.data = xmemdup (retval.data, retval.size, retval.size); - age_cached_comp_units (); return retval;