diff options
author | Dean Michael Berris <dberris@google.com> | 2017-01-10 02:38:11 +0000 |
---|---|---|
committer | Dean Michael Berris <dberris@google.com> | 2017-01-10 02:38:11 +0000 |
commit | f8f909f848e7373dfa9dfcb99336bffb023aaa07 (patch) | |
tree | bdac41cbc9fdae039ae6d0e641941ca01ea3b387 /llvm/tools/llvm-xray/xray-log-reader.h | |
parent | f388f78bc6664bde093d5f30c59a5148e14d9523 (diff) | |
download | bcm5719-llvm-f8f909f848e7373dfa9dfcb99336bffb023aaa07.tar.gz bcm5719-llvm-f8f909f848e7373dfa9dfcb99336bffb023aaa07.zip |
[XRay] Implement `llvm-xray convert` -- trace file conversion
This is the second part of a multi-part change to define additional
subcommands to the `llvm-xray` tool.
This change defines a conversion subcommand to take XRay log files, and
turns them from one format to another (binary or YAML). This currently
only supports the first version of the log file format, defined in the
compiler-rt runtime.
Depends on D21987.
Reviewers: dblaikie, echristo
Subscribers: mehdi_amini, dberris, beanz, llvm-commits
Differential Revision: https://reviews.llvm.org/D24376
llvm-svn: 291529
Diffstat (limited to 'llvm/tools/llvm-xray/xray-log-reader.h')
-rw-r--r-- | llvm/tools/llvm-xray/xray-log-reader.h | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/llvm/tools/llvm-xray/xray-log-reader.h b/llvm/tools/llvm-xray/xray-log-reader.h new file mode 100644 index 00000000000..4dd544328cf --- /dev/null +++ b/llvm/tools/llvm-xray/xray-log-reader.h @@ -0,0 +1,57 @@ +//===- xray-log-reader.h - XRay Log Reader Interface ----------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// Define the interface for an XRay log reader. Currently we only support one +// version of the log (naive log) with fixed-sized records. +// +//===----------------------------------------------------------------------===// +#ifndef LLVM_TOOLS_LLVM_XRAY_XRAY_LOG_READER_H +#define LLVM_TOOLS_LLVM_XRAY_XRAY_LOG_READER_H + +#include <cstdint> +#include <deque> +#include <vector> + +#include "xray-record-yaml.h" +#include "xray-record.h" +#include "llvm/Support/Error.h" +#include "llvm/Support/FileSystem.h" + +namespace llvm { +namespace xray { + +class LogReader { + XRayFileHeader FileHeader; + std::vector<XRayRecord> Records; + + typedef std::vector<XRayRecord>::const_iterator citerator; + +public: + typedef std::function<Error(StringRef, XRayFileHeader &, + std::vector<XRayRecord> &)> + LoaderFunction; + + LogReader(StringRef Filename, Error &Err, bool Sort, LoaderFunction Loader); + + const XRayFileHeader &getFileHeader() const { return FileHeader; } + + citerator begin() const { return Records.begin(); } + citerator end() const { return Records.end(); } + size_t size() const { return Records.size(); } +}; + +Error NaiveLogLoader(StringRef Data, XRayFileHeader &FileHeader, + std::vector<XRayRecord> &Records); +Error YAMLLogLoader(StringRef Data, XRayFileHeader &FileHeader, + std::vector<XRayRecord> &Records); + +} // namespace xray +} // namespace llvm + +#endif // LLVM_TOOLS_LLVM_XRAY_XRAY_LOG_READER_H |