From patchwork Thu Jan 21 16:43:11 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marcin_Ko=C5=9Bcielnicki?= X-Patchwork-Id: 10507 Received: (qmail 3836 invoked by alias); 21 Jan 2016 16:43:26 -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 3824 invoked by uid 89); 21 Jan 2016 16:43:25 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.2 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 spammy=delegated, agent, collection.exp, UD:collection.exp X-HELO: xyzzy.0x04.net Received: from xyzzy.0x04.net (HELO xyzzy.0x04.net) (109.74.193.254) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 21 Jan 2016 16:43:24 +0000 Received: from hogfather.0x04.net (89-65-66-135.dynamic.chello.pl [89.65.66.135]) by xyzzy.0x04.net (Postfix) with ESMTPS id 588573FE60; Thu, 21 Jan 2016 17:44:05 +0100 (CET) Received: by hogfather.0x04.net (Postfix, from userid 1000) id B438C5800AC; Thu, 21 Jan 2016 17:43:21 +0100 (CET) From: =?UTF-8?q?Marcin=20Ko=C5=9Bcielnicki?= To: palves@redhat.com Cc: gdb-patches@sourceware.org, =?UTF-8?q?Marcin=20Ko=C5=9Bcielnicki?= Subject: [PATCH v2] gdb.trace: Fix string collection for 64-bit platforms. Date: Thu, 21 Jan 2016 17:43:11 +0100 Message-Id: <1453394591-5181-1-git-send-email-koriakin@0x04.net> In-Reply-To: <56A103D5.2090505@redhat.com> References: <56A103D5.2090505@redhat.com> MIME-Version: 1.0 X-IsSubscribed: yes String collection always used ref32 to fetch the string pointer. Make it use gen_fetch instead. As a side effect, this patch changes dup+const+trace+pop sequence used for collecting the string's address to a trace_quick opcode. This results in a shorter agent expression. This appeared to work on x86_64 since it's a little-endian platform, and malloc (used in gdb.trace/collection.exp) returns addresses in low 4GB. Noticed and tested on s390x-ibm-linux-gnu, also tested on i686-unknown-linux-gnu and x86_64-unknown-linux-gnu. gdb/ChangeLog: * ax-gdb.c (gen_traced_pop): Use gen_fetch for string collection. --- Instead of factoring out the switch, I just delegated to gen_fetch. Turns out we can shave off a few ops this way, too. Likewise tested on s390, s390x, i686, x86_64. gdb/ChangeLog | 4 ++++ gdb/ax-gdb.c | 23 +++++++++++------------ 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 45d8ef9..28173b0 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,7 @@ +2016-01-21 Marcin Kościelnicki + + * ax-gdb.c (gen_traced_pop): Use gen_fetch for string collection. + 2016-01-21 Andrew Burgess * disasm.c (maybe_add_dis_line_entry): Rename to... diff --git a/gdb/ax-gdb.c b/gdb/ax-gdb.c index dd6eee6..7c6cb64 100644 --- a/gdb/ax-gdb.c +++ b/gdb/ax-gdb.c @@ -394,26 +394,25 @@ gen_traced_pop (struct gdbarch *gdbarch, case axs_lvalue_memory: { - if (string_trace) - ax_simple (ax, aop_dup); - /* Initialize the TYPE_LENGTH if it is a typedef. */ check_typedef (value->type); - /* There's no point in trying to use a trace_quick bytecode - here, since "trace_quick SIZE pop" is three bytes, whereas - "const8 SIZE trace" is also three bytes, does the same - thing, and the simplest code which generates that will also - work correctly for objects with large sizes. */ - ax_const_l (ax, TYPE_LENGTH (value->type)); - ax_simple (ax, aop_trace); - if (string_trace) { - ax_simple (ax, aop_ref32); + gen_fetch (ax, value->type); ax_const_l (ax, ax->trace_string); ax_simple (ax, aop_tracenz); } + else + { + /* There's no point in trying to use a trace_quick bytecode + here, since "trace_quick SIZE pop" is three bytes, whereas + "const8 SIZE trace" is also three bytes, does the same + thing, and the simplest code which generates that will also + work correctly for objects with large sizes. */ + ax_const_l (ax, TYPE_LENGTH (value->type)); + ax_simple (ax, aop_trace); + } } break;