gdb/testsuite/gdb.trace: Deduplicate set_point assembly.
authorMarcin Kościelnicki <koriakin@0x04.net>
Tue, 10 Nov 2015 11:12:00 +0000 (12:12 +0100)
committerMarcin Kościelnicki <koriakin@0x04.net>
Wed, 11 Nov 2015 20:44:04 +0000 (21:44 +0100)
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 FAST_TRACEPOINT_LABEL.
* gdb.trace/ftrace-lock.c: include "trace-common.h", remove SYMBOL
macro.
(func): Removed.
(thread_function): Use FAST_TRACEPOINT_LABEL.
* gdb.trace/ftrace.c: include "trace-common.h", remove SYMBOL macro.
(func): Remove.
(marker): Use FAST_TRACEPOINT_LABEL.
* gdb.trace/pendshr1.c: include "trace-common.h", remove SYMBOL macro.
(pendfunc1): Remove.
(pendfunc): Use FAST_TRACEPOINT_LABEL.
* gdb.trace/pendshr2.c: include "trace-common.h", remove SYMBOL macro.
(foo): Remove.
(pendfunc2): Use FAST_TRACEPOINT_LABEL.
* gdb.trace/trace-break.c: include "trace-common.h", remove SYMBOL
macro.
(func): Remove.
(marker): Use FAST_TRACEPOINT_LABEL.
* gdb.trace/trace-common.h: New header.
* gdb.trace/trace-condition.c: include "trace-common.h", remove SYMBOL
macro.
(func): Remove.
(marker): Use FAST_TRACEPOINT_LABEL.
* gdb.trace/trace-mt.c: include "trace-common.h", remove SYMBOL macro.
(func): Remove.
(thread_function): Use FAST_TRACEPOINT_LABEL.

gdb/testsuite/ChangeLog
gdb/testsuite/gdb.trace/change-loc.h
gdb/testsuite/gdb.trace/ftrace-lock.c
gdb/testsuite/gdb.trace/ftrace.c
gdb/testsuite/gdb.trace/pendshr1.c
gdb/testsuite/gdb.trace/pendshr2.c
gdb/testsuite/gdb.trace/trace-break.c
gdb/testsuite/gdb.trace/trace-common.h [new file with mode: 0644]
gdb/testsuite/gdb.trace/trace-condition.c
gdb/testsuite/gdb.trace/trace-mt.c

index 0f04109..85dcbe9 100644 (file)
@@ -1,3 +1,35 @@
+2015-11-11  Marcin Kościelnicki  <koriakin@0x04.net>
+
+       * gdb.trace/change-loc.h: include "trace-common.h", remove SYMBOL
+       macro.
+       (func5): Removed.
+       (func4): Use FAST_TRACEPOINT_LABEL.
+       * gdb.trace/ftrace-lock.c: include "trace-common.h", remove SYMBOL
+       macro.
+       (func): Removed.
+       (thread_function): Use FAST_TRACEPOINT_LABEL.
+       * gdb.trace/ftrace.c: include "trace-common.h", remove SYMBOL macro.
+       (func): Remove.
+       (marker): Use FAST_TRACEPOINT_LABEL.
+       * gdb.trace/pendshr1.c: include "trace-common.h", remove SYMBOL macro.
+       (pendfunc1): Remove.
+       (pendfunc): Use FAST_TRACEPOINT_LABEL.
+       * gdb.trace/pendshr2.c: include "trace-common.h", remove SYMBOL macro.
+       (foo): Remove.
+       (pendfunc2): Use FAST_TRACEPOINT_LABEL.
+       * gdb.trace/trace-break.c: include "trace-common.h", remove SYMBOL
+       macro.
+       (func): Remove.
+       (marker): Use FAST_TRACEPOINT_LABEL.
+       * gdb.trace/trace-common.h: New header.
+       * gdb.trace/trace-condition.c: include "trace-common.h", remove SYMBOL
+       macro.
+       (func): Remove.
+       (marker): Use FAST_TRACEPOINT_LABEL.
+       * gdb.trace/trace-mt.c: include "trace-common.h", remove SYMBOL macro.
+       (func): Remove.
+       (thread_function): Use FAST_TRACEPOINT_LABEL.
+
 2015-11-10  Marcin Kościelnicki  <koriakin@0x04.net>
 
        * gdb.trace/backtrace.exp: Use global fpreg/spreg definition, add $
index 8201455..00037e2 100644 (file)
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#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
-       );
-
+  FAST_TRACEPOINT_LABEL(set_tracepoint);
 }
index 8ed45f4..a89af51 100644 (file)
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include <pthread.h>
-
-#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
-       );
+  FAST_TRACEPOINT_LABEL(set_point);
 }
 
 static void
index 7373d66..4e80bf1 100644 (file)
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#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
-       );
+  FAST_TRACEPOINT_LABEL(set_point);
 
   ++anarg;
 
index f08fb91..85fb743 100644 (file)
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#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
-       );
+  FAST_TRACEPOINT_LABEL(set_point1);
 }
index f7ec733..23fda6f 100644 (file)
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#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
-       );
+  FAST_TRACEPOINT_LABEL(set_point2);
 }
index 66bbe53..cb6d14b 100644 (file)
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#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
-       );
+  FAST_TRACEPOINT_LABEL(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
-       );
+  FAST_TRACEPOINT_LABEL(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 (file)
index 0000000..f1d7339
--- /dev/null
@@ -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 <http://www.gnu.org/licenses/>.  */
+
+#ifdef SYMBOL_PREFIX
+#define SYMBOL(str)     SYMBOL_PREFIX #str
+#else
+#define SYMBOL(str)     #str
+#endif
+
+/* FAST_TRACEPOINT_LABEL 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 FAST_TRACEPOINT_LABEL(name) \
+  asm ("    .global " SYMBOL(name) "\n" \
+       SYMBOL(name) ":\n" \
+       "    call " SYMBOL(x86_trace_dummy) "\n" \
+       )
+
+#elif (defined __aarch64__)
+
+#define FAST_TRACEPOINT_LABEL(name) \
+  asm ("    .global " SYMBOL(name) "\n" \
+       SYMBOL(name) ":\n" \
+       "    nop\n" \
+       )
+
+#else
+
+#error "unsupported architecture for trace tests"
+
+#endif
index d988d76..8eda10c 100644 (file)
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#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
-       );
+  FAST_TRACEPOINT_LABEL(set_point);
 }
 
 static void
index 7ae0305..af6d2c1 100644 (file)
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include <pthread.h>
-
-#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
-       );
+  FAST_TRACEPOINT_LABEL(set_point1);
 }
 
 static void