[PATCH v2 08/13] btrace: move and rename btrace-common

Markus Metzger
2014-11-20T10:47:37Z

* common/btrace-common.h: Move and rename to ...
* nat/x86-btrace.h: ... this. Update users.
* common/btrace-common.c: Move and rename to ...
* nat/x86-btrace.c: ... this. Update Makefiles.
---
gdb/Makefile.in | 8 +--
gdb/btrace.h | 2 +-
gdb/common/btrace-common.c | 82 ------------------------
gdb/common/btrace-common.h | 156 ---------------------------------------------
gdb/gdbserver/Makefile.in | 6 +-
gdb/gdbserver/linux-low.c | 2 +-
gdb/gdbserver/server.c | 2 +-
gdb/gdbserver/target.h | 2 +-
gdb/nat/linux-btrace.h | 2 +-
gdb/nat/x86-btrace.c | 82 ++++++++++++++++++++++++
gdb/nat/x86-btrace.h | 156 +++++++++++++++++++++++++++++++++++++++++++++
11 files changed, 250 insertions(+), 250 deletions(-)
delete mode 100644 gdb/common/btrace-common.c
delete mode 100644 gdb/common/btrace-common.h
create mode 100644 gdb/nat/x86-btrace.c
create mode 100644 gdb/nat/x86-btrace.h

diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index e7181c4..fc9c695 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -853,7 +853,7 @@ SFILES = ada-exp.y ada-lang.c ada-typeprint.c ada-valprint.c ada-tasks.c \
common/format.c common/filestuff.c btrace.c record-btrace.c ctf.c \
target/waitstatus.c common/print-utils.c common/rsp-low.c \
common/errors.c common/common-debug.c common/common-exceptions.c \
- common/btrace-common.c
+ nat/x86-btrace.c

LINTFILES = $(SFILES) $(YYFILES) $(CONFIG_SRCS) init.c

@@ -1040,7 +1040,7 @@ COMMON_OBS = $(DEPFILES) $(CONFIG_OBS) $(YYOBJ) \
common-utils.o buffer.o ptid.o gdb-dlfcn.o common-agent.o \
format.o registry.o btrace.o record-btrace.o waitstatus.o \
print-utils.o rsp-low.o errors.o common-debug.o debug.o \
- common-exceptions.o btrace-common.o
+ common-exceptions.o x86-btrace.o

TSOBS = inflow.o

@@ -2173,8 +2173,8 @@ common-exceptions.o: ${srcdir}/common/common-exceptions.c
$(COMPILE) $(srcdir)/common/common-exceptions.c
$(POSTCOMPILE)

-btrace-common.o: ${srcdir}/common/btrace-common.c
- $(COMPILE) $(srcdir)/common/btrace-common.c
+x86-btrace.o: ${srcdir}/nat/x86-btrace.c
+ $(COMPILE) $(srcdir)/nat/x86-btrace.c
$(POSTCOMPILE)

#
diff --git a/gdb/btrace.h b/gdb/btrace.h
index 3de7b73..2082bc7 100644
--- a/gdb/btrace.h
+++ b/gdb/btrace.h
@@ -26,7 +26,7 @@
inferior. For presentation purposes, the branch trace is represented as a
list of sequential control-flow blocks, one such list per thread. */

-#include "btrace-common.h"
+#include "nat/x86-btrace.h"

struct thread_info;
struct btrace_function;
diff --git a/gdb/common/btrace-common.c b/gdb/common/btrace-common.c
deleted file mode 100644
index 869d0cb..0000000
--- a/gdb/common/btrace-common.c
+++ /dev/null
@@ -1,82 +0,0 @@
-/* Copyright (C) 2014 Free Software Foundation, Inc.
-
- Contributed by Intel Corp. <markus.t.metzger@intel.com>
-
- This file is part of GDB.
-
- 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/>. */
-
-#include "btrace-common.h"
-
-
-/* See btrace-common.h. */
-
-const char *
-btrace_format_string (enum btrace_format format)
-{
- switch (format)
- {
- case BTRACE_FORMAT_NONE:
- return _("No or unknown format");
-
- case BTRACE_FORMAT_BTS:
- return _("Intel(R) Branch Trace Store");
- }
-
- internal_error (__FILE__, __LINE__, _("Unknown branch trace format"));
-}
-
-/* See btrace-common.h. */
-
-void
-btrace_data_init (struct btrace_data *data)
-{
- data->format = BTRACE_FORMAT_NONE;
-}
-
-/* See btrace-common.h. */
-
-void
-btrace_data_fini (struct btrace_data *data)
-{
- switch (data->format)
- {
- case BTRACE_FORMAT_NONE:
- /* Nothing to do. */
- return;
-
- case BTRACE_FORMAT_BTS:
- VEC_free (btrace_block_s, data->variant.bts.blocks);
- return;
- }
-
- internal_error (__FILE__, __LINE__, _("Unkown branch trace format."));
-}
-
-/* See btrace-common.h. */
-
-int
-btrace_data_empty (struct btrace_data *data)
-{
- switch (data->format)
- {
- case BTRACE_FORMAT_NONE:
- return 1;
-
- case BTRACE_FORMAT_BTS:
- return VEC_empty (btrace_block_s, data->variant.bts.blocks);
- }
-
- internal_error (__FILE__, __LINE__, _("Unkown branch trace format."));
-}
diff --git a/gdb/common/btrace-common.h b/gdb/common/btrace-common.h
deleted file mode 100644
index 8147e6d..0000000
--- a/gdb/common/btrace-common.h
+++ /dev/null
@@ -1,156 +0,0 @@
-/* Branch trace support for GDB, the GNU debugger.
-
- Copyright (C) 2013-2014 Free Software Foundation, Inc.
-
- Contributed by Intel Corp. <markus.t.metzger@intel.com>.
-
- This file is part of GDB.
-
- 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/>. */
-
-#ifndef BTRACE_COMMON_H
-#define BTRACE_COMMON_H
-
-/* Branch tracing (btrace) is a per-thread control-flow execution trace of the
- inferior. For presentation purposes, the branch trace is represented as a
- list of sequential control-flow blocks, one such list per thread. */
-
-#include "common-defs.h"
-#include "vec.h"
-
-/* A branch trace block.
-
- This represents a block of sequential control-flow. Adjacent blocks will be
- connected via calls, returns, or jumps. The latter can be direct or
- indirect, conditional or unconditional. Branches can further be
- asynchronous, e.g. interrupts. */
-struct btrace_block
-{
- /* The address of the first byte of the first instruction in the block.
- The address may be zero if we do not know the beginning of this block,
- such as for the first block in a delta trace. */
- CORE_ADDR begin;
-
- /* The address of the first byte of the last instruction in the block. */
- CORE_ADDR end;
-};
-
-/* Define functions operating on a vector of branch trace blocks. */
-typedef struct btrace_block btrace_block_s;
-DEF_VEC_O (btrace_block_s);
-
-/* Enumeration of btrace formats. */
-
-enum btrace_format
-{
- /* No branch trace format. */
- BTRACE_FORMAT_NONE,
-
- /* Branch trace is in Branch Trace Store format.
- Actually, the format is a sequence of blocks derived from BTS. */
- BTRACE_FORMAT_BTS
-};
-
-/* A BTS configuration. */
-
-struct btrace_config_bts
-{
- /* The size of the branch trace buffer in bytes. */
- unsigned int size;
-};
-
-/* A branch tracing configuration.
-
- This describes the requested configuration as well as the actually
- obtained configuration.
- We describe the configuration for all different formats so we can
- easily switch between formats. */
-
-struct btrace_config
-{
- /* The branch tracing format. */
- enum btrace_format format;
-
- /* The BTS format configuration. */
- struct btrace_config_bts bts;
-};
-
-/* Branch trace in BTS format. */
-struct btrace_data_bts
-{
- /* Branch trace is represented as a vector of branch trace blocks starting
- with the most recent block. */
- VEC (btrace_block_s) *blocks;
-};
-
-/* The branch trace data. */
-struct btrace_data
-{
- enum btrace_format format;
-
- union
- {
- /* Format == BTRACE_FORMAT_BTS. */
- struct btrace_data_bts bts;
- } variant;
-};
-
-/* Target specific branch trace information. */
-struct btrace_target_info;
-
-/* Enumeration of btrace read types. */
-
-enum btrace_read_type
-{
- /* Send all available trace. */
- BTRACE_READ_ALL,
-
- /* Send all available trace, if it changed. */
- BTRACE_READ_NEW,
-
- /* Send the trace since the last request. This will fail if the trace
- buffer overflowed. */
- BTRACE_READ_DELTA
-};
-
-/* Enumeration of btrace errors. */
-
-enum btrace_error
-{
- /* No error. Everything is OK. */
- BTRACE_ERR_NONE,
-
- /* An unknown error. */
- BTRACE_ERR_UNKNOWN,
-
- /* Branch tracing is not supported on this system. */
- BTRACE_ERR_NOT_SUPPORTED,
-
- /* The branch trace buffer overflowed; no delta read possible. */
- BTRACE_ERR_OVERFLOW
-};
-
-/* Return a string representation of FORMAT. */
-extern const char *btrace_format_string (enum btrace_format format);
-
-/* Initialize DATA. */
-extern void btrace_data_init (struct btrace_data *data);
-
-/* Cleanup DATA. */
-extern void btrace_data_fini (struct btrace_data *data);
-
-/* Return non-zero if DATA is empty; zero otherwise. */
-extern int btrace_data_empty (struct btrace_data *data);
-
-#endif /* BTRACE_COMMON_H */
diff --git a/gdb/gdbserver/Makefile.in b/gdb/gdbserver/Makefile.in
index 98897d9..1ce3fe4 100644
--- a/gdb/gdbserver/Makefile.in
+++ b/gdb/gdbserver/Makefile.in
@@ -173,7 +173,7 @@ SFILES= $(srcdir)/gdbreplay.c $(srcdir)/inferiors.c $(srcdir)/dll.c \
$(srcdir)/common/rsp-low.c $(srcdir)/common/errors.c \
$(srcdir)/common/common-debug.c $(srcdir)/common/cleanups.c \
$(srcdir)/common/common-exceptions.c $(srcdir)/symbol.c \
- $(srcdir)/common/btrace-common.c
+ $(srcdir)/nat/x86-btrace.c

DEPFILES = @GDBSERVER_DEPFILES@

@@ -187,7 +187,7 @@ OBS = agent.o ax.o inferiors.o regcache.o remote-utils.o server.o signals.o \
mem-break.o hostio.o event-loop.o tracepoint.o xml-utils.o \
common-utils.o ptid.o buffer.o format.o filestuff.o dll.o notif.o \
tdesc.o print-utils.o rsp-low.o errors.o common-debug.o cleanups.o \
- common-exceptions.o symbol.o btrace-common.o \
+ common-exceptions.o symbol.o x86-btrace.o \
$(XML_BUILTIN) $(DEPFILES) $(LIBOBJS)
GDBREPLAY_OBS = gdbreplay.o version.o
GDBSERVER_LIBS = @GDBSERVER_LIBS@
@@ -582,7 +582,7 @@ linux-waitpid.o: ../nat/linux-waitpid.c
mips-linux-watch.o: ../nat/mips-linux-watch.c
$(COMPILE) $<
$(POSTCOMPILE)
-btrace-common.o: ../common/btrace-common.c
+x86-btrace.o: ../nat/x86-btrace.c
$(COMPILE) $<
$(POSTCOMPILE)

diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c
index 08192c5..217b3f9 100644
--- a/gdb/gdbserver/linux-low.c
+++ b/gdb/gdbserver/linux-low.c
@@ -102,7 +102,7 @@

#ifdef HAVE_LINUX_BTRACE
# include "nat/linux-btrace.h"
-# include "btrace-common.h"
+# include "nat/x86-btrace.h"
#endif

#ifndef HAVE_ELF32_AUXV_T
diff --git a/gdb/gdbserver/server.c b/gdb/gdbserver/server.c
index ebacd96..4ed9837 100644
--- a/gdb/gdbserver/server.c
+++ b/gdb/gdbserver/server.c
@@ -30,7 +30,7 @@
#endif
#include "gdb_vecs.h"
#include "gdb_wait.h"
-#include "btrace-common.h"
+#include "nat/x86-btrace.h"
#include "filestuff.h"
#include "tracepoint.h"
#include "dll.h"
diff --git a/gdb/gdbserver/target.h b/gdb/gdbserver/target.h
index b877df8..468edc6 100644
--- a/gdb/gdbserver/target.h
+++ b/gdb/gdbserver/target.h
@@ -26,7 +26,7 @@
#include "target/wait.h"
#include "target/waitstatus.h"
#include "mem-break.h"
-#include "btrace-common.h"
+#include "nat/x86-btrace.h"

struct emit_ops;
struct buffer;
diff --git a/gdb/nat/linux-btrace.h b/gdb/nat/linux-btrace.h
index 1e9af88..1ad83f0 100644
--- a/gdb/nat/linux-btrace.h
+++ b/gdb/nat/linux-btrace.h
@@ -22,7 +22,7 @@
#ifndef LINUX_BTRACE_H
#define LINUX_BTRACE_H

-#include "btrace-common.h"
+#include "x86-btrace.h"
#include "vec.h"
#include <stdint.h>

diff --git a/gdb/nat/x86-btrace.c b/gdb/nat/x86-btrace.c
new file mode 100644
index 0000000..5ca5731
--- /dev/null
+++ b/gdb/nat/x86-btrace.c
@@ -0,0 +1,82 @@
+/* Copyright (C) 2014 Free Software Foundation, Inc.
+
+ Contributed by Intel Corp. <markus.t.metzger@intel.com>
+
+ This file is part of GDB.
+
+ 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/>. */
+
+#include "x86-btrace.h"
+
+
+/* See x86-btrace.h. */
+
+const char *
+btrace_format_string (enum btrace_format format)
+{
+ switch (format)
+ {
+ case BTRACE_FORMAT_NONE:
+ return _("No or unknown format");
+
+ case BTRACE_FORMAT_BTS:
+ return _("Intel(R) Branch Trace Store");
+ }
+
+ internal_error (__FILE__, __LINE__, _("Unknown branch trace format"));
+}
+
+/* See x86-btrace.h. */
+
+void
+btrace_data_init (struct btrace_data *data)
+{
+ data->format = BTRACE_FORMAT_NONE;
+}
+
+/* See x86-btrace.h. */
+
+void
+btrace_data_fini (struct btrace_data *data)
+{
+ switch (data->format)
+ {
+ case BTRACE_FORMAT_NONE:
+ /* Nothing to do. */
+ return;
+
+ case BTRACE_FORMAT_BTS:
+ VEC_free (btrace_block_s, data->variant.bts.blocks);
+ return;
+ }
+
+ internal_error (__FILE__, __LINE__, _("Unkown branch trace format."));
+}
+
+/* See x86-btrace.h. */
+
+int
+btrace_data_empty (struct btrace_data *data)
+{
+ switch (data->format)
+ {
+ case BTRACE_FORMAT_NONE:
+ return 1;
+
+ case BTRACE_FORMAT_BTS:
+ return VEC_empty (btrace_block_s, data->variant.bts.blocks);
+ }
+
+ internal_error (__FILE__, __LINE__, _("Unkown branch trace format."));
+}
diff --git a/gdb/nat/x86-btrace.h b/gdb/nat/x86-btrace.h
new file mode 100644
index 0000000..48d6284
--- /dev/null
+++ b/gdb/nat/x86-btrace.h
@@ -0,0 +1,156 @@
+/* Branch trace support for GDB, the GNU debugger.
+
+ Copyright (C) 2013-2014 Free Software Foundation, Inc.
+
+ Contributed by Intel Corp. <markus.t.metzger@intel.com>.
+
+ This file is part of GDB.
+
+ 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/>. */
+
+#ifndef X86_BTRACE_H
+#define X86_BTRACE_H
+
+/* Branch tracing (btrace) is a per-thread control-flow execution trace of the
+ inferior. For presentation purposes, the branch trace is represented as a
+ list of sequential control-flow blocks, one such list per thread. */
+
+#include "common-defs.h"
+#include "vec.h"
+
+/* A branch trace block.
+
+ This represents a block of sequential control-flow. Adjacent blocks will be
+ connected via calls, returns, or jumps. The latter can be direct or
+ indirect, conditional or unconditional. Branches can further be
+ asynchronous, e.g. interrupts. */
+struct btrace_block
+{
+ /* The address of the first byte of the first instruction in the block.
+ The address may be zero if we do not know the beginning of this block,
+ such as for the first block in a delta trace. */
+ CORE_ADDR begin;
+
+ /* The address of the first byte of the last instruction in the block. */
+ CORE_ADDR end;
+};
+
+/* Define functions operating on a vector of branch trace blocks. */
+typedef struct btrace_block btrace_block_s;
+DEF_VEC_O (btrace_block_s);
+
+/* Enumeration of btrace formats. */
+
+enum btrace_format
+{
+ /* No branch trace format. */
+ BTRACE_FORMAT_NONE,
+
+ /* Branch trace is in Branch Trace Store format.
+ Actually, the format is a sequence of blocks derived from BTS. */
+ BTRACE_FORMAT_BTS
+};
+
+/* A BTS configuration. */
+
+struct btrace_config_bts
+{
+ /* The size of the branch trace buffer in bytes. */
+ unsigned int size;
+};
+
+/* A branch tracing configuration.
+
+ This describes the requested configuration as well as the actually
+ obtained configuration.
+ We describe the configuration for all different formats so we can
+ easily switch between formats. */
+
+struct btrace_config
+{
+ /* The branch tracing format. */
+ enum btrace_format format;
+
+ /* The BTS format configuration. */
+ struct btrace_config_bts bts;
+};
+
+/* Branch trace in BTS format. */
+struct btrace_data_bts
+{
+ /* Branch trace is represented as a vector of branch trace blocks starting
+ with the most recent block. */
+ VEC (btrace_block_s) *blocks;
+};
+
+/* The branch trace data. */
+struct btrace_data
+{
+ enum btrace_format format;
+
+ union
+ {
+ /* Format == BTRACE_FORMAT_BTS. */
+ struct btrace_data_bts bts;
+ } variant;
+};
+
+/* Target specific branch trace information. */
+struct btrace_target_info;
+
+/* Enumeration of btrace read types. */
+
+enum btrace_read_type
+{
+ /* Send all available trace. */
+ BTRACE_READ_ALL,
+
+ /* Send all available trace, if it changed. */
+ BTRACE_READ_NEW,
+
+ /* Send the trace since the last request. This will fail if the trace
+ buffer overflowed. */
+ BTRACE_READ_DELTA
+};
+
+/* Enumeration of btrace errors. */
+
+enum btrace_error
+{
+ /* No error. Everything is OK. */
+ BTRACE_ERR_NONE,
+
+ /* An unknown error. */
+ BTRACE_ERR_UNKNOWN,
+
+ /* Branch tracing is not supported on this system. */
+ BTRACE_ERR_NOT_SUPPORTED,
+
+ /* The branch trace buffer overflowed; no delta read possible. */
+ BTRACE_ERR_OVERFLOW
+};
+
+/* Return a string representation of FORMAT. */
+extern const char *btrace_format_string (enum btrace_format format);
+
+/* Initialize DATA. */
+extern void btrace_data_init (struct btrace_data *data);
+
+/* Cleanup DATA. */
+extern void btrace_data_fini (struct btrace_data *data);
+
+/* Return non-zero if DATA is empty; zero otherwise. */
+extern int btrace_data_empty (struct btrace_data *data);
+
+#endif /* X86_BTRACE_H */
--
1.8.3.1