summaryrefslogtreecommitdiffstats
path: root/compiler-rt/include/xray
diff options
context:
space:
mode:
authorDean Michael Berris <dberris@google.com>2017-01-25 03:50:46 +0000
committerDean Michael Berris <dberris@google.com>2017-01-25 03:50:46 +0000
commite7dbebf182b92b49883649b7ca3408892273598b (patch)
treef1691fbb54f9f0982ab0358bc46ca3c4096d39ff /compiler-rt/include/xray
parentbc6aaea3364729cbd29a114e9e1f62ebe34defe3 (diff)
downloadbcm5719-llvm-e7dbebf182b92b49883649b7ca3408892273598b.tar.gz
bcm5719-llvm-e7dbebf182b92b49883649b7ca3408892273598b.zip
[XRay][compiler-rt] XRay Flight Data Recorder Mode
Summary: In this change we introduce the notion of a "flight data recorder" mode for XRay logging, where XRay logs in-memory first, and write out data on-demand as required (as opposed to the naive implementation that keeps logging while tracing is "on"). This depends on D26232 where we implement the core data structure for holding the buffers that threads will be using to write out records of operation. This implementation only currently works on x86_64 and depends heavily on the TSC math to write out smaller records to the inmemory buffers. Also, this implementation defines two different kinds of records with different sizes (compared to the current naive implementation): a MetadataRecord (16 bytes) and a FunctionRecord (8 bytes). MetadataRecord entries are meant to write out information like the thread ID for which the metadata record is defined for, whether the execution of a thread moved to a different CPU, etc. while a FunctionRecord represents the different kinds of function call entry/exit records we might encounter in the course of a thread's execution along with a delta from the last time the logging handler was called. While this implementation is not exactly what is described in the original XRay whitepaper, this one gives us an initial implementation that we can iterate and build upon. Reviewers: echristo, rSerge, majnemer Subscribers: mehdi_amini, llvm-commits, mgorny Differential Revision: https://reviews.llvm.org/D27038 llvm-svn: 293015
Diffstat (limited to 'compiler-rt/include/xray')
-rw-r--r--compiler-rt/include/xray/xray_log_interface.h51
-rw-r--r--compiler-rt/include/xray/xray_records.h6
2 files changed, 57 insertions, 0 deletions
diff --git a/compiler-rt/include/xray/xray_log_interface.h b/compiler-rt/include/xray/xray_log_interface.h
new file mode 100644
index 00000000000..f98b331101a
--- /dev/null
+++ b/compiler-rt/include/xray/xray_log_interface.h
@@ -0,0 +1,51 @@
+//===-- xray_log_interface.h ----------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file is a part of XRay, a function call tracing system.
+//
+// APIs for installing a new logging implementation.
+//===----------------------------------------------------------------------===//
+#ifndef XRAY_XRAY_LOG_INTERFACE_H
+#define XRAY_XRAY_LOG_INTERFACE_H
+
+#include "xray/xray_interface.h"
+#include <stddef.h>
+
+extern "C" {
+
+enum XRayLogInitStatus {
+ XRAY_LOG_UNINITIALIZED = 0,
+ XRAY_LOG_INITIALIZING = 1,
+ XRAY_LOG_INITIALIZED = 2,
+ XRAY_LOG_FINALIZING = 3,
+ XRAY_LOG_FINALIZED = 4,
+};
+
+enum XRayLogFlushStatus {
+ XRAY_LOG_NOT_FLUSHING = 0,
+ XRAY_LOG_FLUSHING = 1,
+ XRAY_LOG_FLUSHED = 2,
+};
+
+struct XRayLogImpl {
+ XRayLogInitStatus (*log_init)(size_t, size_t, void *, size_t);
+ XRayLogInitStatus (*log_finalize)();
+ void (*handle_arg0)(int32_t, XRayEntryType);
+ XRayLogFlushStatus (*flush_log)();
+};
+
+void __xray_set_log_impl(XRayLogImpl Impl);
+XRayLogInitStatus __xray_log_init(size_t BufferSize, size_t MaxBuffers,
+ void *Args, size_t ArgsSize);
+XRayLogInitStatus __xray_log_finalize();
+XRayLogFlushStatus __xray_log_flushLog();
+
+} // extern "C"
+
+#endif // XRAY_XRAY_LOG_INTERFACE_H
diff --git a/compiler-rt/include/xray/xray_records.h b/compiler-rt/include/xray/xray_records.h
index 34c236b39bd..71637d1fe95 100644
--- a/compiler-rt/include/xray/xray_records.h
+++ b/compiler-rt/include/xray/xray_records.h
@@ -21,6 +21,7 @@ namespace __xray {
enum FileTypes {
NAIVE_LOG = 0,
+ FDR_LOG = 1,
};
// This data structure is used to describe the contents of the file. We use this
@@ -40,6 +41,11 @@ struct alignas(32) XRayFileHeader {
// The frequency by which TSC increases per-second.
alignas(8) uint64_t CycleFrequency = 0;
+
+ // The current civiltime timestamp, as retrived from 'clock_gettime'. This
+ // allows readers of the file to determine when the file was created or
+ // written down.
+ struct timespec TS;
} __attribute__((packed));
static_assert(sizeof(XRayFileHeader) == 32, "XRayFileHeader != 32 bytes");
OpenPOWER on IntegriCloud