From patchwork Mon Jun 30 03:50:22 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yao Qi X-Patchwork-Id: 1812 Received: (qmail 1436 invoked by alias); 30 Jun 2014 03:52:18 -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 1151 invoked by uid 89); 30 Jun 2014 03:52:11 -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; Mon, 30 Jun 2014 03:52:05 +0000 Received: from svr-orw-fem-01.mgc.mentorg.com ([147.34.98.93]) by relay1.mentorg.com with esmtp id 1X1SdN-0004nw-VC from Yao_Qi@mentor.com for gdb-patches@sourceware.org; Sun, 29 Jun 2014 20:52:01 -0700 Received: from SVR-ORW-FEM-02.mgc.mentorg.com ([147.34.96.206]) by svr-orw-fem-01.mgc.mentorg.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.4675); Sun, 29 Jun 2014 20:52:01 -0700 Received: from qiyao.dyndns.org.com (147.34.91.1) by svr-orw-fem-02.mgc.mentorg.com (147.34.96.168) with Microsoft SMTP Server id 14.2.247.3; Sun, 29 Jun 2014 20:51:14 -0700 From: Yao Qi To: Subject: [PATCH] Tweak gdb.trace/tfile.c for thumb mode Date: Mon, 30 Jun 2014 11:50:22 +0800 Message-ID: <1404100222-2312-1-git-send-email-yao@codesourcery.com> MIME-Version: 1.0 X-IsSubscribed: yes We see the fail below happens on thumb related multi-libs (-mthumb -march={armv4t,armv7-a}), target tfile tfile-basic.tf ^M warning: Uploaded tracepoint 1 has no source location, using raw address^M warning: Breakpoint address adjusted from 0x00008959 to 0x00008958.^M Tracepoint 3 at 0x8958: file /scratch/yqi/arm-none-linux-gnueabi/src/gdb-trunk/gdb/testsuite/gdb.trace/tfile.c, line 91.^M Created tracepoint 3 for target's tracepoint 1 at 0x8959.^M warning: Breakpoint address adjusted from 0x00008959 to 0x00008958.^M warning: Breakpoint address adjusted from 0x00008959 to 0x00008958.^M warning: Breakpoint address adjusted from 0x00008959 to 0x00008958.^M (gdb) FAIL: gdb.trace/tfile.exp: complete-command 'target tfile' The address of write_basic_trace_file is two-bytes aligned, (gdb) p write_basic_trace_file $1 = {void (void)} 0x8958 but the ld sets the LSB of every reference to the function address (indicating the address is in thumb mode), so "&write_basic_trace_file" in the program becomes 0x8959, which is saved in the trace file. That is why the warnings are emitted. This patch is to clear the LSB of the function address written to trace file in thumb and thumb2 mode. This patch fixes the fail above. gdb/testsuite: 2014-06-30 Yao Qi * gdb.trace/tfile.c (write_basic_trace_file): Clear the lsb of the function address written to trace file. --- gdb/testsuite/gdb.trace/tfile.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/gdb/testsuite/gdb.trace/tfile.c b/gdb/testsuite/gdb.trace/tfile.c index ac65901..4d54553 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; + /* Although the thumb functions are two-bytes aligned, ld sets the + bit 0 of these function references. Clear the bit 0. */ +#if defined(__thumb__) || defined(__thumb2__) + 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.) */