From patchwork Fri Jan 22 13:56:55 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: 10520 Received: (qmail 124284 invoked by alias); 22 Jan 2016 13:57:02 -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 123169 invoked by uid 89); 22 Jan 2016 13:57:01 -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=We'll, Hx-languages-length:2369, atm, pain 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; Fri, 22 Jan 2016 13:56:59 +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 4BE403FE0E for ; Fri, 22 Jan 2016 14:57:41 +0100 (CET) Received: by hogfather.0x04.net (Postfix, from userid 1000) id 4EFAA5800A9; Fri, 22 Jan 2016 14:56:57 +0100 (CET) From: =?UTF-8?q?Marcin=20Ko=C5=9Bcielnicki?= To: gdb-patches@sourceware.org Cc: =?UTF-8?q?Marcin=20Ko=C5=9Bcielnicki?= Subject: [PATCH 1/8] gdb.trace: Fix write_inferior_data_ptr on 32-bit big-endian machines. Date: Fri, 22 Jan 2016 14:56:55 +0100 Message-Id: <1453471015-9921-1-git-send-email-koriakin@0x04.net> MIME-Version: 1.0 X-IsSubscribed: yes Noticed and tested on s390. This bug caused completely broken fast tracepoints. No regressions on i686, x86_64, s390x. gdb/gdbserver/ChangeLog: * tracepoint.c (write_inferior_data_ptr): Cast to uintptr_t, so that it works properly on big-endian machines where sizeof (CORE_ADDR) != sizeof (void *). --- Another patch for upcoming s390 tracepoint support. 31-bit fast tracepoints are still broken, but now less so. It seems tracepoints are still broken in multiple ways on big-endian targets, and I'm going to fix that. However, I'm not sure what to do about the bi-arch case mentioned in the comment. While it'd be nice to handle libinproctrace.so like libgcc.so and build it for all multilib configurations, atm C structures involving pointers are shared between gdbserver and the IPA. This obviously would have to be refactored before that's possible, but might be worth it - configuring a full 31-bit build just to get fast tracepoints is a pain. gdb/gdbserver/ChangeLog | 6 ++++++ gdb/gdbserver/tracepoint.c | 6 +++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog index 9c42fcf..6ddd9ce 100644 --- a/gdb/gdbserver/ChangeLog +++ b/gdb/gdbserver/ChangeLog @@ -1,3 +1,9 @@ +2016-01-22 Marcin Kościelnicki + + * tracepoint.c (write_inferior_data_ptr): Cast to uintptr_t, so that + it works properly on big-endian machines where sizeof (CORE_ADDR) + != sizeof (void *). + 2016-01-21 Pedro Alves * Makefile.in (COMPILER_CFLAGS, CXXFLAGS): New. diff --git a/gdb/gdbserver/tracepoint.c b/gdb/gdbserver/tracepoint.c index 40d0da9..536cdd5 100644 --- a/gdb/gdbserver/tracepoint.c +++ b/gdb/gdbserver/tracepoint.c @@ -5931,14 +5931,14 @@ compile_tracepoint_condition (struct tracepoint *tpoint, *jump_entry += 16; } -/* We'll need to adjust these when we consider bi-arch setups, and big - endian machines. */ +/* We'll need to adjust these when we consider bi-arch setups. */ static int write_inferior_data_ptr (CORE_ADDR where, CORE_ADDR ptr) { + uintptr_t pptr = ptr; return write_inferior_memory (where, - (unsigned char *) &ptr, sizeof (void *)); + (unsigned char *) &pptr, sizeof pptr); } /* The base pointer of the IPA's heap. This is the only memory the