diff options
author | Dean Michael Berris <dberris@google.com> | 2016-10-26 01:42:59 +0000 |
---|---|---|
committer | Dean Michael Berris <dberris@google.com> | 2016-10-26 01:42:59 +0000 |
commit | d21e0a7ba74da20bb06b7ad3366d9299bb33feed (patch) | |
tree | 96d865d14cb053462ca1a2e12c063bdb35115b82 /llvm/tools/llvm-xray/xray-extract.h | |
parent | eb1bf312d5a7896184f12b1cba10e90cccfba181 (diff) | |
download | bcm5719-llvm-d21e0a7ba74da20bb06b7ad3366d9299bb33feed.tar.gz bcm5719-llvm-d21e0a7ba74da20bb06b7ad3366d9299bb33feed.zip |
[XRay] Implement `llvm-xray extract`, start of the llvm-xray tool
Usage:
llvm-xray extract <object file> [-o <filename or '-'>]
The tool gets the XRay instrumentation map from an object file and turns
it into YAML. We first support ELF64 sleds on x86_64 binaries, with
provision for supporting other supported platforms and formats later.
This is the first of a many-part change to fully implement the
`llvm-xray` tool.
We also define a subcommand registration and dispatch mechanism to be
used by other further subcommand implementations for llvm-xray.
llvm-svn: 285155
Diffstat (limited to 'llvm/tools/llvm-xray/xray-extract.h')
-rw-r--r-- | llvm/tools/llvm-xray/xray-extract.h | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/llvm/tools/llvm-xray/xray-extract.h b/llvm/tools/llvm-xray/xray-extract.h new file mode 100644 index 00000000000..91e4db36805 --- /dev/null +++ b/llvm/tools/llvm-xray/xray-extract.h @@ -0,0 +1,58 @@ +//===- xray-extract.h - XRay Instrumentation Map Extraction ---------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// Defines the interface for extracting the instrumentation map from an +// XRay-instrumented binary. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_TOOLS_XRAY_EXTRACT_H +#define LLVM_TOOLS_XRAY_EXTRACT_H + +#include <deque> +#include <map> +#include <string> +#include <unordered_map> + +#include "xray-sleds.h" +#include "llvm/Support/Error.h" +#include "llvm/Support/raw_ostream.h" + +namespace llvm { +namespace xray { + +class InstrumentationMapExtractor { +public: + typedef std::unordered_map<int32_t, uint64_t> FunctionAddressMap; + typedef std::unordered_map<uint64_t, int32_t> FunctionAddressReverseMap; + + enum class InputFormats { ELF, YAML }; + +private: + std::deque<SledEntry> Sleds; + FunctionAddressMap FunctionAddresses; + FunctionAddressReverseMap FunctionIds; + +public: + /// Loads the instrumentation map from |Filename|. Updates |EC| in case there + /// were errors encountered opening the file. |Format| defines what the input + /// instrumentation map is in. + InstrumentationMapExtractor(std::string Filename, InputFormats Format, + Error &EC); + + const FunctionAddressMap &getFunctionAddresses() { return FunctionAddresses; } + + /// Exports the loaded function address map as YAML through |OS|. + void exportAsYAML(raw_ostream &OS); +}; + +} // namespace xray +} // namespace llvm + +#endif // LLVM_TOOLS_XRAY_EXTRACT_H |