aboutsummaryrefslogtreecommitdiff
path: root/gdb/nat/linux-btrace.h
diff options
context:
space:
mode:
authorMarkus Metzger <markus.t.metzger@intel.com>2023-08-17 10:17:26 +0000
committerMarkus Metzger <markus.t.metzger@intel.com>2023-09-11 06:15:52 +0000
commitcdda72c2fa1e47c566c7b5768f3831a1cc11d263 (patch)
tree5d360d7def2b0cb0150f70c8f1fb61b07dd7d2e0 /gdb/nat/linux-btrace.h
parent1bcb9dcf4a9d348d4f970d6d3f8146eae2036010 (diff)
downloadgdb-cdda72c2fa1e47c566c7b5768f3831a1cc11d263.zip
gdb-cdda72c2fa1e47c566c7b5768f3831a1cc11d263.tar.gz
gdb-cdda72c2fa1e47c566c7b5768f3831a1cc11d263.tar.bz2
gdb: c++ify btrace_target_info
Following the example of private_thread_info and private_inferior, turn struct btrace_target_info into a small class hierarchy. Also merge btrace_tinfo_bts with btrace_tinfo_pt and inline into linux_btrace_target_info. Fixes PR gdb/30751.
Diffstat (limited to 'gdb/nat/linux-btrace.h')
-rw-r--r--gdb/nat/linux-btrace.h60
1 files changed, 14 insertions, 46 deletions
diff --git a/gdb/nat/linux-btrace.h b/gdb/nat/linux-btrace.h
index ab69647..6505a7b 100644
--- a/gdb/nat/linux-btrace.h
+++ b/gdb/nat/linux-btrace.h
@@ -23,6 +23,7 @@
#define NAT_LINUX_BTRACE_H
#include "gdbsupport/btrace-common.h"
+#include "gdbsupport/gdb-checked-static-cast.h"
#if HAVE_LINUX_PERF_EVENT_H
# include <linux/perf_event.h>
#endif
@@ -45,60 +46,27 @@ struct perf_event_buffer
/* The data_head value from the last read. */
__u64 last_head;
};
+#endif /* HAVE_LINUX_PERF_EVENT_H */
-/* Branch trace target information for BTS tracing. */
-struct btrace_tinfo_bts
+/* Branch trace target information per thread. */
+struct linux_btrace_target_info final : public btrace_target_info
{
- /* The Linux perf_event configuration for collecting the branch trace. */
- struct perf_event_attr attr;
-
- /* The perf event file. */
- int file;
+ linux_btrace_target_info (ptid_t ptid)
+ : btrace_target_info (ptid)
+ {}
- /* The perf event configuration page. */
- volatile struct perf_event_mmap_page *header;
-
- /* The BTS perf event buffer. */
- struct perf_event_buffer bts;
-};
-
-/* Branch trace target information for Intel Processor Trace
- tracing. */
-struct btrace_tinfo_pt
-{
+#if HAVE_LINUX_PERF_EVENT_H
/* The Linux perf_event configuration for collecting the branch trace. */
- struct perf_event_attr attr;
+ struct perf_event_attr attr {};
/* The perf event file. */
- int file;
+ int file = -1;
- /* The perf event configuration page. */
- volatile struct perf_event_mmap_page *header;
+ /* The perf event configuration page. */
+ volatile struct perf_event_mmap_page *header = nullptr;
- /* The trace perf event buffer. */
- struct perf_event_buffer pt;
-};
-#endif /* HAVE_LINUX_PERF_EVENT_H */
-
-/* Branch trace target information per thread. */
-struct btrace_target_info
-{
- /* The ptid of this thread. */
- ptid_t ptid;
-
- /* The obtained branch trace configuration. */
- struct btrace_config conf;
-
-#if HAVE_LINUX_PERF_EVENT_H
- /* The branch tracing format specific information. */
- union
- {
- /* CONF.FORMAT == BTRACE_FORMAT_BTS. */
- struct btrace_tinfo_bts bts;
-
- /* CONF.FORMAT == BTRACE_FORMAT_PT. */
- struct btrace_tinfo_pt pt;
- } variant;
+ /* The perf event buffer containing the trace data. */
+ struct perf_event_buffer pev {};
#endif /* HAVE_LINUX_PERF_EVENT_H */
};