From patchwork Fri May 16 15:26:30 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 970 Return-Path: X-Original-To: siddhesh@wilcox.dreamhost.com Delivered-To: siddhesh@wilcox.dreamhost.com Received: from homiemail-mx23.g.dreamhost.com (mx2.sub5.homie.mail.dreamhost.com [208.113.200.128]) by wilcox.dreamhost.com (Postfix) with ESMTP id 5EAF536007A for ; Fri, 16 May 2014 08:43:53 -0700 (PDT) Received: by homiemail-mx23.g.dreamhost.com (Postfix, from userid 14314964) id 18DE463D68773; Fri, 16 May 2014 08:43:53 -0700 (PDT) X-Original-To: gdb@patchwork.siddhesh.in Delivered-To: x14314964@homiemail-mx23.g.dreamhost.com Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by homiemail-mx23.g.dreamhost.com (Postfix) with ESMTPS id D797963D68775 for ; Fri, 16 May 2014 08:43:52 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=vuw+go9gEBewpQvp/7J/AIXA8CuV4Y+ ECCEo8JDKdAb6oPbXfdVS5zuGck+jqNcU2NIV5unA9NpkdrZpPpxiLP3hzETy5Xo zjFk0v/6bWqsYdYA9gmmBHzppBEENOTCn8A1PzL6+QGpsuTRMIE4rfsA9gO0CIZ2 TWhbPtk7Dwjg= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references; s=default; bh=Px+zS3mCGNvYEO46/P73egjPxZE=; b=YMq/N tebG4IvjzW0p5tAQPRjPgwy2T62M3L0YtyfXstgs9ZEip67hR/mimOIPgWapdxxD JxvcBWJaC3j4tIW5kIyNFugbGRT2vK3bdrQDjy7AsnQh5Mer+Mst0rIM3eKQyiFn d6UZE4tu5ei3wsSKQkmLHOEDDwAMqPTxPKWzC0= Received: (qmail 24909 invoked by alias); 16 May 2014 15:43:45 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 24844 invoked by uid 89); 16 May 2014 15:43:45 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.2 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 16 May 2014 15:43:43 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s4GFQioO003781 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 16 May 2014 11:26:44 -0400 Received: from barimba.redhat.com (ovpn-113-182.phx2.redhat.com [10.3.113.182]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s4GFQcVB006849; Fri, 16 May 2014 11:26:43 -0400 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 09/14] split dwarf2_fetch_cfa_info from dwarf2_compile_expr_to_ax Date: Fri, 16 May 2014 09:26:30 -0600 Message-Id: <1400253995-12333-10-git-send-email-tromey@redhat.com> In-Reply-To: <1400253995-12333-1-git-send-email-tromey@redhat.com> References: <1400253995-12333-1-git-send-email-tromey@redhat.com> X-DH-Original-To: gdb@patchwork.siddhesh.in This removes dwarf2_compile_expr_to_ax, replacing it with a utility function that fetches the CFA data and adding the code to actually compile to an agent expression directly into dwarf2_compile_expr_to_ax. This refactoring lets a later patch reuse the new dwarf2_fetch_cfa_info. 2014-05-16 Tom Tromey * dwarf2loc.c (dwarf2_compile_expr_to_ax) : Update. * dwarf2-frame.c (dwarf2_fetch_cfa_info): New function, based on dwarf2_compile_cfa_to_ax. (dwarf2_compile_cfa_to_ax): Remove. * dwarf2-frame.h (dwarf2_fetch_cfa_info): Declare. (dwarf2_compile_cfa_to_ax): Remove. --- gdb/ChangeLog | 10 ++++++++++ gdb/dwarf2-frame.c | 40 +++++++++++++++++++--------------------- gdb/dwarf2-frame.h | 31 +++++++++++++++++++++---------- gdb/dwarf2loc.c | 30 ++++++++++++++++++++++++++++-- 4 files changed, 78 insertions(+), 33 deletions(-) diff --git a/gdb/dwarf2-frame.c b/gdb/dwarf2-frame.c index 3e3ba23..bd6a60e 100644 --- a/gdb/dwarf2-frame.c +++ b/gdb/dwarf2-frame.c @@ -886,11 +886,15 @@ dwarf2_frame_find_quirks (struct dwarf2_frame_state *fs, } -void -dwarf2_compile_cfa_to_ax (struct agent_expr *expr, struct axs_value *loc, - struct gdbarch *gdbarch, - CORE_ADDR pc, - struct dwarf2_per_cu_data *data) +/* See dwarf2-frame.h. */ + +int +dwarf2_fetch_cfa_info (struct gdbarch *gdbarch, CORE_ADDR pc, + struct dwarf2_per_cu_data *data, + int *regnum_out, LONGEST *offset_out, + CORE_ADDR *text_offset_out, + const gdb_byte **cfa_start_out, + const gdb_byte **cfa_end_out) { struct dwarf2_fde *fde; CORE_ADDR text_offset; @@ -936,26 +940,20 @@ dwarf2_compile_cfa_to_ax (struct agent_expr *expr, struct axs_value *loc, if (regnum == -1) error (_("Unable to access DWARF register number %d"), (int) fs.regs.cfa_reg); /* FIXME */ - ax_reg (expr, regnum); - if (fs.regs.cfa_offset != 0) - { - if (fs.armcc_cfa_offsets_reversed) - ax_const_l (expr, -fs.regs.cfa_offset); - else - ax_const_l (expr, fs.regs.cfa_offset); - ax_simple (expr, aop_add); - } + *regnum_out = regnum; + if (fs.armcc_cfa_offsets_reversed) + *offset_out = -fs.regs.cfa_offset; + else + *offset_out = fs.regs.cfa_offset; + return 1; } - break; case CFA_EXP: - ax_const_l (expr, text_offset); - dwarf2_compile_expr_to_ax (expr, loc, gdbarch, addr_size, - fs.regs.cfa_exp, - fs.regs.cfa_exp + fs.regs.cfa_exp_len, - data); - break; + *text_offset_out = text_offset; + *cfa_start_out = fs.regs.cfa_exp; + *cfa_end_out = fs.regs.cfa_exp + fs.regs.cfa_exp_len; + return 0; default: internal_error (__FILE__, __LINE__, _("Unknown CFA rule.")); diff --git a/gdb/dwarf2-frame.h b/gdb/dwarf2-frame.h index 0470cac..5ccf0c8 100644 --- a/gdb/dwarf2-frame.h +++ b/gdb/dwarf2-frame.h @@ -120,15 +120,26 @@ extern const struct frame_base * CORE_ADDR dwarf2_frame_cfa (struct frame_info *this_frame); -/* Update the agent expression EXPR with code to compute the CFA for a - frame at PC. GDBARCH is the architecture of the function at PC. - This function may call dwarf2_compile_expr_to_ax; DATA is passed - through to that function if needed. */ - -extern void dwarf2_compile_cfa_to_ax (struct agent_expr *expr, - struct axs_value *loc, - struct gdbarch *gdbarch, - CORE_ADDR pc, - struct dwarf2_per_cu_data *data); +/* Find the CFA information for PC. + + Return 1 if a register is used for the CFA, or 0 if another + expression is used. Throw an exception on error. + + GDBARCH is the architecture to use. + DATA is the per-CU data. + + REGNUM_OUT is an out parameter that is set to the register number. + OFFSET_OUT is the offset to use from this register. + These are only filled in when 1 is returned. + + TEXT_OFFSET_OUT, CFA_START_OUT, and CFA_END_OUT describe the CFA + in other cases. These are only used when 0 is returned. */ + +extern int dwarf2_fetch_cfa_info (struct gdbarch *gdbarch, CORE_ADDR pc, + struct dwarf2_per_cu_data *data, + int *regnum_out, LONGEST *offset_out, + CORE_ADDR *text_offset_out, + const gdb_byte **cfa_start_out, + const gdb_byte **cfa_end_out); #endif /* dwarf2-frame.h */ diff --git a/gdb/dwarf2loc.c b/gdb/dwarf2loc.c index 5517442..2002ef9 100644 --- a/gdb/dwarf2loc.c +++ b/gdb/dwarf2loc.c @@ -3308,8 +3308,34 @@ dwarf2_compile_expr_to_ax (struct agent_expr *expr, struct axs_value *loc, break; case DW_OP_call_frame_cfa: - dwarf2_compile_cfa_to_ax (expr, loc, arch, expr->scope, per_cu); - loc->kind = axs_lvalue_memory; + { + int regnum; + CORE_ADDR text_offset; + LONGEST off; + const gdb_byte *cfa_start, *cfa_end; + + if (dwarf2_fetch_cfa_info (arch, expr->scope, per_cu, + ®num, &off, + &text_offset, &cfa_start, &cfa_end)) + { + /* Register. */ + ax_reg (expr, regnum); + if (off != 0) + { + ax_const_l (expr, off); + ax_simple (expr, aop_add); + } + } + else + { + /* Another expression. */ + ax_const_l (expr, text_offset); + dwarf2_compile_expr_to_ax (expr, loc, arch, addr_size, + cfa_start, cfa_end, per_cu); + } + + loc->kind = axs_lvalue_memory; + } break; case DW_OP_GNU_push_tls_address: