From patchwork Tue Nov 10 11:21:39 2015 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: 9637 Received: (qmail 116100 invoked by alias); 10 Nov 2015 11:21:54 -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 116071 invoked by uid 89); 10 Nov 2015 11:21:53 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.0 required=5.0 tests=AWL, BAYES_00, KAM_STOCKGEN, RP_MATCHES_RCVD, SPF_PASS autolearn=no version=3.3.2 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; Tue, 10 Nov 2015 11:21:45 +0000 Received: from hogfather.0x04.net (89-65-84-110.dynamic.chello.pl [89.65.84.110]) by xyzzy.0x04.net (Postfix) with ESMTPS id 01E0740132 for ; Tue, 10 Nov 2015 12:22:02 +0100 (CET) Received: by hogfather.0x04.net (Postfix, from userid 1000) id 96D005800AC; Tue, 10 Nov 2015 12:21:42 +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 2/2] gdb/testsuite/gdb.trace: Deduplicate set_point assembly. Date: Tue, 10 Nov 2015 12:21:39 +0100 Message-Id: <1447154499-22247-2-git-send-email-koriakin@0x04.net> In-Reply-To: <1447154499-22247-1-git-send-email-koriakin@0x04.net> References: <1447154499-22247-1-git-send-email-koriakin@0x04.net> MIME-Version: 1.0 The assembly code for emitting the proper tracepointable instruction was duplicated in many places. Keep it in one place, to reduce work needed for new targets. gdb/testsuite/ChangeLog: * gdb.trace/change-loc.h: include "trace-common.h", remove SYMBOL macro. (func5): Removed. (func4): Use TRACEPOINT_ASM. * gdb.trace/ftrace-lock.c: include "trace-common.h", remove SYMBOL macro. (func): Removed. (thread_function): Use TRACEPOINT_ASM. * gdb.trace/ftrace.c: include "trace-common.h", remove SYMBOL macro. (func): Remove. (marker): Use TRACEPOINT_ASM. * gdb.trace/pendshr1.c: include "trace-common.h", remove SYMBOL macro. (pendfunc1): Remove. (pendfunc): Use TRACEPOINT_ASM. * gdb.trace/pendshr2.c: include "trace-common.h", remove SYMBOL macro. (foo): Remove. (pendfunc2): Use TRACEPOINT_ASM. * gdb.trace/trace-break.c: include "trace-common.h", remove SYMBOL macro. (func): Remove. (marker): Use TRACEPOINT_ASM. * gdb.trace/trace-common.h: New header. * gdb.trace/trace-condition.c: include "trace-common.h", remove SYMBOL macro. (func): Remove. (marker): Use TRACEPOINT_ASM. * gdb.trace/trace-mt.c: include "trace-common.h", remove SYMBOL macro. (func): Remove. (thread_function): Use TRACEPOINT_ASM. --- Preparation for s390 trace support. gdb/testsuite/ChangeLog | 32 ++++++++++++++++++ gdb/testsuite/gdb.trace/change-loc.h | 24 ++------------ gdb/testsuite/gdb.trace/ftrace-lock.c | 25 ++------------ gdb/testsuite/gdb.trace/ftrace.c | 23 ++----------- gdb/testsuite/gdb.trace/pendshr1.c | 25 ++------------ gdb/testsuite/gdb.trace/pendshr2.c | 22 ++----------- gdb/testsuite/gdb.trace/trace-break.c | 32 ++---------------- gdb/testsuite/gdb.trace/trace-common.h | 55 +++++++++++++++++++++++++++++++ gdb/testsuite/gdb.trace/trace-condition.c | 24 ++------------ gdb/testsuite/gdb.trace/trace-mt.c | 23 ++----------- 10 files changed, 104 insertions(+), 181 deletions(-) create mode 100644 gdb/testsuite/gdb.trace/trace-common.h diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 442f271..bc58d81 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,5 +1,37 @@ 2015-11-10 Marcin Kościelnicki + * gdb.trace/change-loc.h: include "trace-common.h", remove SYMBOL + macro. + (func5): Removed. + (func4): Use TRACEPOINT_ASM. + * gdb.trace/ftrace-lock.c: include "trace-common.h", remove SYMBOL + macro. + (func): Removed. + (thread_function): Use TRACEPOINT_ASM. + * gdb.trace/ftrace.c: include "trace-common.h", remove SYMBOL macro. + (func): Remove. + (marker): Use TRACEPOINT_ASM. + * gdb.trace/pendshr1.c: include "trace-common.h", remove SYMBOL macro. + (pendfunc1): Remove. + (pendfunc): Use TRACEPOINT_ASM. + * gdb.trace/pendshr2.c: include "trace-common.h", remove SYMBOL macro. + (foo): Remove. + (pendfunc2): Use TRACEPOINT_ASM. + * gdb.trace/trace-break.c: include "trace-common.h", remove SYMBOL + macro. + (func): Remove. + (marker): Use TRACEPOINT_ASM. + * gdb.trace/trace-common.h: New header. + * gdb.trace/trace-condition.c: include "trace-common.h", remove SYMBOL + macro. + (func): Remove. + (marker): Use TRACEPOINT_ASM. + * gdb.trace/trace-mt.c: include "trace-common.h", remove SYMBOL macro. + (func): Remove. + (thread_function): Use TRACEPOINT_ASM. + +2015-11-10 Marcin Kościelnicki + * gdb.trace/backtrace.exp: Use global fpreg/spreg definition, add $ in front. * gdb.trace/change-loc.exp: Use global pcreg definition. diff --git a/gdb/testsuite/gdb.trace/change-loc.h b/gdb/testsuite/gdb.trace/change-loc.h index 8201455..aaf823a 100644 --- a/gdb/testsuite/gdb.trace/change-loc.h +++ b/gdb/testsuite/gdb.trace/change-loc.h @@ -15,30 +15,10 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -#ifdef SYMBOL_PREFIX -#define SYMBOL(str) SYMBOL_PREFIX #str -#else -#define SYMBOL(str) #str -#endif - -/* Called from asm. */ -static void __attribute__((used)) -func5 (void) -{} +#include "trace-common.h" static void func4 (void) { - /* `set_tracepoint' is the label where we'll set multiple tracepoints and - breakpoints at. The insn at the label must the large enough to - fit a fast tracepoint jump. */ - asm (" .global " SYMBOL(set_tracepoint) "\n" - SYMBOL(set_tracepoint) ":\n" -#if (defined __x86_64__ || defined __i386__) - " call " SYMBOL(func5) "\n" -#elif (defined __aarch64__) - " nop\n" -#endif - ); - + TRACEPOINT_ASM(set_tracepoint); } diff --git a/gdb/testsuite/gdb.trace/ftrace-lock.c b/gdb/testsuite/gdb.trace/ftrace-lock.c index 8ed45f4..e5e1a16 100644 --- a/gdb/testsuite/gdb.trace/ftrace-lock.c +++ b/gdb/testsuite/gdb.trace/ftrace-lock.c @@ -16,12 +16,7 @@ along with this program. If not, see . */ #include - -#ifdef SYMBOL_PREFIX -#define SYMBOL(str) SYMBOL_PREFIX #str -#else -#define SYMBOL(str) #str -#endif +#include "trace-common.h" /* Called if the testcase failed. */ static void @@ -61,26 +56,10 @@ gdb_agent_gdb_collect (void *tpoint, unsigned char *regs) } } -/* Called from asm. */ -static void __attribute__((used)) -func (void) -{ -} - static void * thread_function (void *arg) { - /* `set_point' is the label at which to set a fast tracepoint. The - insn at the label must be large enough to fit a fast tracepoint - jump. */ - asm (" .global " SYMBOL (set_point) "\n" - SYMBOL (set_point) ":\n" -#if (defined __x86_64__ || defined __i386__) - " call " SYMBOL (func) "\n" -#elif (defined __aarch64__) - " nop\n" -#endif - ); + TRACEPOINT_ASM(set_point); } static void diff --git a/gdb/testsuite/gdb.trace/ftrace.c b/gdb/testsuite/gdb.trace/ftrace.c index 7373d66..5869af0 100644 --- a/gdb/testsuite/gdb.trace/ftrace.c +++ b/gdb/testsuite/gdb.trace/ftrace.c @@ -15,11 +15,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -#ifdef SYMBOL_PREFIX -#define SYMBOL(str) SYMBOL_PREFIX #str -#else -#define SYMBOL(str) #str -#endif +#include "trace-common.h" int globvar; @@ -27,25 +23,10 @@ static void begin (void) {} -/* Called from asm. */ -static void __attribute__((used)) -func (void) -{} - static void marker (int anarg) { - /* `set_point' is the label at which to set a fast tracepoint. The - insn at the label must be large enough to fit a fast tracepoint - jump. */ - asm (" .global " SYMBOL(set_point) "\n" - SYMBOL(set_point) ":\n" -#if (defined __x86_64__ || defined __i386__) - " call " SYMBOL(func) "\n" -#elif (defined __aarch64__) - " nop\n" -#endif - ); + TRACEPOINT_ASM(set_point); ++anarg; diff --git a/gdb/testsuite/gdb.trace/pendshr1.c b/gdb/testsuite/gdb.trace/pendshr1.c index f08fb91..065227f 100644 --- a/gdb/testsuite/gdb.trace/pendshr1.c +++ b/gdb/testsuite/gdb.trace/pendshr1.c @@ -15,31 +15,10 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -#ifdef SYMBOL_PREFIX -#define SYMBOL(str) SYMBOL_PREFIX #str -#else -#define SYMBOL(str) #str -#endif - -static void -pendfunc1 (void) -{ - int x = 0; - int y = x + 4; -} +#include "trace-common.h" void pendfunc (int x) { - /* `set_point1' is the label where we'll set multiple tracepoints and - breakpoints at. The insn at the label must the large enough to - fit a fast tracepoint jump. */ - asm (" .global " SYMBOL(set_point1) "\n" - SYMBOL(set_point1) ":\n" -#if (defined __x86_64__ || defined __i386__) - " call " SYMBOL(pendfunc1) "\n" -#elif (defined __aarch64__) - " nop\n" -#endif - ); + TRACEPOINT_ASM(set_point1); } diff --git a/gdb/testsuite/gdb.trace/pendshr2.c b/gdb/testsuite/gdb.trace/pendshr2.c index f7ec733..71d5220 100644 --- a/gdb/testsuite/gdb.trace/pendshr2.c +++ b/gdb/testsuite/gdb.trace/pendshr2.c @@ -15,28 +15,10 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -#ifdef SYMBOL_PREFIX -#define SYMBOL(str) SYMBOL_PREFIX #str -#else -#define SYMBOL(str) #str -#endif - -static void -foo () -{} +#include "trace-common.h" void pendfunc2 (int x) { - /* `set_point2' is the label where we'll set multiple tracepoints and - breakpoints at. The insn at the label must the large enough to - fit a fast tracepoint jump. */ - asm (" .global " SYMBOL(set_point2) "\n" - SYMBOL(set_point2) ":\n" -#if (defined __x86_64__ || defined __i386__) - " call " SYMBOL(foo) "\n" -#elif (defined __aarch64__) - " nop\n" -#endif - ); + TRACEPOINT_ASM(set_point2); } diff --git a/gdb/testsuite/gdb.trace/trace-break.c b/gdb/testsuite/gdb.trace/trace-break.c index 66bbe53..a1e80cf 100644 --- a/gdb/testsuite/gdb.trace/trace-break.c +++ b/gdb/testsuite/gdb.trace/trace-break.c @@ -15,16 +15,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -#ifdef SYMBOL_PREFIX -#define SYMBOL(str) SYMBOL_PREFIX #str -#else -#define SYMBOL(str) #str -#endif - -/* Called from asm. */ -static void __attribute__((used)) -func (void) -{} +#include "trace-common.h" static void marker (void) @@ -34,26 +25,9 @@ marker (void) int a = 0; int b = a; - /* `set_point' is the label where we'll set multiple tracepoints and - breakpoints at. The insn at the label must the large enough to - fit a fast tracepoint jump. */ - asm (" .global " SYMBOL(set_point) "\n" - SYMBOL(set_point) ":\n" -#if (defined __x86_64__ || defined __i386__) - " call " SYMBOL(func) "\n" -#elif (defined __aarch64__) - " nop\n" -#endif - ); + TRACEPOINT_ASM(set_point); - asm (" .global " SYMBOL(after_set_point) "\n" - SYMBOL(after_set_point) ":\n" -#if (defined __x86_64__ || defined __i386__) - " call " SYMBOL(func) "\n" -#elif (defined __aarch64__) - " nop\n" -#endif - ); + TRACEPOINT_ASM(after_set_point); } static void diff --git a/gdb/testsuite/gdb.trace/trace-common.h b/gdb/testsuite/gdb.trace/trace-common.h new file mode 100644 index 0000000..5f5bd6f --- /dev/null +++ b/gdb/testsuite/gdb.trace/trace-common.h @@ -0,0 +1,55 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2011-2015 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#ifdef SYMBOL_PREFIX +#define SYMBOL(str) SYMBOL_PREFIX #str +#else +#define SYMBOL(str) #str +#endif + +/* TRACEPOINT_ASM expands to an assembly instruction large enough to fit + a fast tracepoint jump. The parameter is the label where we'll set + tracepoints and breakpoints. */ + +#if (defined __x86_64__ || defined __i386__) + +static void +x86_trace_dummy () +{ + int x = 0; + int y = x + 4; +} + +#define TRACEPOINT_ASM(name) \ + asm (" .global " SYMBOL(name) "\n" \ + SYMBOL(name) ":\n" \ + " call " SYMBOL(x86_trace_dummy) "\n" \ + ) + +#elif (defined __aarch64__) + +#define TRACEPOINT_ASM(name) \ + asm (" .global " SYMBOL(name) "\n" \ + SYMBOL(name) ":\n" \ + " nop\n" \ + ) + +#else + +#error "unsupported architecture for trace tests" + +#endif diff --git a/gdb/testsuite/gdb.trace/trace-condition.c b/gdb/testsuite/gdb.trace/trace-condition.c index d988d76..6cca8be 100644 --- a/gdb/testsuite/gdb.trace/trace-condition.c +++ b/gdb/testsuite/gdb.trace/trace-condition.c @@ -15,11 +15,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -#ifdef SYMBOL_PREFIX -#define SYMBOL(str) SYMBOL_PREFIX #str -#else -#define SYMBOL(str) #str -#endif +#include "trace-common.h" int globvar; @@ -28,26 +24,10 @@ begin (void) { } -/* Called from asm. */ -static void __attribute__((used)) -func (void) -{ -} - static void marker (int anarg) { - /* `set_point' is the label at which to set a fast tracepoint. The - insn at the label must be large enough to fit a fast tracepoint - jump. */ - asm (" .global " SYMBOL (set_point) "\n" - SYMBOL (set_point) ":\n" -#if (defined __x86_64__ || defined __i386__) - " call " SYMBOL (func) "\n" -#elif (defined __aarch64__) - " nop\n" -#endif - ); + TRACEPOINT_ASM(set_point); } static void diff --git a/gdb/testsuite/gdb.trace/trace-mt.c b/gdb/testsuite/gdb.trace/trace-mt.c index 7ae0305..a8adb0d 100644 --- a/gdb/testsuite/gdb.trace/trace-mt.c +++ b/gdb/testsuite/gdb.trace/trace-mt.c @@ -16,31 +16,12 @@ along with this program. If not, see . */ #include - -#ifdef SYMBOL_PREFIX -#define SYMBOL(str) SYMBOL_PREFIX #str -#else -#define SYMBOL(str) #str -#endif -/* Called from asm. */ -static void __attribute__((used)) -func (void) -{} +#include "trace-common.h" static void * thread_function(void *arg) { - /* `set_point1' is the label at which to set a fast tracepoint. The - insn at the label must be large enough to fit a fast tracepoint - jump. */ - asm (" .global " SYMBOL(set_point1) "\n" - SYMBOL(set_point1) ":\n" -#if (defined __x86_64__ || defined __i386__) - " call " SYMBOL(func) "\n" -#elif (defined __aarch64__) - " nop\n" -#endif - ); + TRACEPOINT_ASM(set_point1); } static void