From patchwork Thu Jul 10 01:26:48 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yao Qi X-Patchwork-Id: 1992 Received: (qmail 11546 invoked by alias); 10 Jul 2014 01:30:30 -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 11387 invoked by uid 89); 10 Jul 2014 01:30:22 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL, BAYES_00 autolearn=ham version=3.3.2 X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 10 Jul 2014 01:30:16 +0000 Received: from svr-orw-exc-10.mgc.mentorg.com ([147.34.98.58]) by relay1.mentorg.com with esmtp id 1X53Bc-0001iT-PC from Yao_Qi@mentor.com ; Wed, 09 Jul 2014 18:30:12 -0700 Received: from SVR-ORW-FEM-03.mgc.mentorg.com ([147.34.97.39]) by SVR-ORW-EXC-10.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.4675); Wed, 9 Jul 2014 18:30:12 -0700 Received: from qiyao.dyndns.org (147.34.91.1) by svr-orw-fem-03.mgc.mentorg.com (147.34.97.39) with Microsoft SMTP Server id 14.2.247.3; Wed, 9 Jul 2014 18:30:11 -0700 Message-ID: <53BDEBD8.5030201@codesourcery.com> Date: Thu, 10 Jul 2014 09:26:48 +0800 From: Yao Qi User-Agent: Mozilla/5.0 (X11; Linux i686; rv:24.0) Gecko/20100101 Thunderbird/24.4.0 MIME-Version: 1.0 To: Pedro Alves , Subject: Re: [PATCH] Tweak gdb.trace/tfile.c for thumb mode References: <1404100222-2312-1-git-send-email-yao@codesourcery.com> <53BD5710.5040105@redhat.com> In-Reply-To: <53BD5710.5040105@redhat.com> X-IsSubscribed: yes On 07/09/2014 10:52 PM, Pedro Alves wrote: > #if defined(__thumb__) || defined(__thumb2__) > /* Although Thumb functions are two-byte aligned, function > pointers have the Thumb bit set. Clear it. */ > func_addr &= ~1; > #endif > > (This bit is widely known as the "Thumb bit", so call it that, > and remove a few "the"'s that sound odd to me, and say > "two-byte aligned".) I often associate "Thumb bit" with the bit in CPSR. Look into arm-tdep.c and arm-linux-tdep.c, "Thumb bit" is used for both cases (LSB of function address and the bit in CPSR). It shouldn't cause any confusion. Patch is updated as you suggested and pushed in. diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 19e6232..2278496 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2014-07-10 Yao Qi + + * gdb.trace/tfile.c (write_basic_trace_file) + [__thumb__||__thumb2__]: Clear the Thumb bit of the function + address written to trace file. + 2014-07-09 Pedro Alves * gdb.base/attach-wait-input.exp: New file. diff --git a/gdb/testsuite/gdb.trace/tfile.c b/gdb/testsuite/gdb.trace/tfile.c index ac65901..bc25b80 100644 --- a/gdb/testsuite/gdb.trace/tfile.c +++ b/gdb/testsuite/gdb.trace/tfile.c @@ -91,6 +91,7 @@ write_basic_trace_file (void) { int fd, int_x; short short_x; + long func_addr; fd = start_trace_file (TFILE_DIR "tfile-basic.tf"); @@ -109,8 +110,14 @@ write_basic_trace_file (void) /* Dump tracepoint definitions, in syntax similar to that used for reconnection uploads. */ /* FIXME need a portable way to print function address in hex */ - snprintf (spbuf, sizeof spbuf, "tp T1:%lx:E:0:0\n", - (long) &write_basic_trace_file); + func_addr = (long) &write_basic_trace_file; +#if defined(__thumb__) || defined(__thumb2__) + /* Although Thumb functions are two-byte aligned, function + pointers have the Thumb bit set. Clear it. */ + func_addr &= ~1; +#endif + + snprintf (spbuf, sizeof spbuf, "tp T1:%lx:E:0:0\n", func_addr); write (fd, spbuf, strlen (spbuf)); /* (Note that we would only need actions defined if we wanted to test tdump.) */