summaryrefslogtreecommitdiffstats
path: root/llvm/lib/XRay/Trace.cpp
diff options
context:
space:
mode:
authorMartin Pelikan <martin.pelikan@gmail.com>2017-09-27 04:48:03 +0000
committerMartin Pelikan <martin.pelikan@gmail.com>2017-09-27 04:48:03 +0000
commit10c873f1d979c07b2e9d48e208f32dd075e64cab (patch)
treed270dc9bbbd657218123d3389c36355e53cda101 /llvm/lib/XRay/Trace.cpp
parent015ccd08227972145381447b349c8bd07fcb6f01 (diff)
downloadbcm5719-llvm-10c873f1d979c07b2e9d48e208f32dd075e64cab.tar.gz
bcm5719-llvm-10c873f1d979c07b2e9d48e208f32dd075e64cab.zip
[XRay] convert FDR arg1 log entries
Summary: A new FDR metadata record will support logging a function call argument; appending multiple metadata records will represent a sequence of arguments meaning that "holes" are not representable by the buffer format. Each call argument is currently a 64-bit value (useful for "this" pointers and synchronization objects). If present, we put this argument to the function call "entry" record it belongs to, and alter its type to notify the user of its presence. Reviewers: dberris Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D32840 llvm-svn: 314269
Diffstat (limited to 'llvm/lib/XRay/Trace.cpp')
-rw-r--r--llvm/lib/XRay/Trace.cpp29
1 files changed, 27 insertions, 2 deletions
diff --git a/llvm/lib/XRay/Trace.cpp b/llvm/lib/XRay/Trace.cpp
index 131c7807b1b..7f8846cbd6f 100644
--- a/llvm/lib/XRay/Trace.cpp
+++ b/llvm/lib/XRay/Trace.cpp
@@ -128,6 +128,7 @@ struct FDRState {
FUNCTION_SEQUENCE,
SCAN_TO_END_OF_THREAD_BUF,
CUSTOM_EVENT_DATA,
+ CALL_ARGUMENT,
};
Token Expects;
@@ -151,6 +152,8 @@ const char *fdrStateToTwine(const FDRState::Token &state) {
return "SCAN_TO_END_OF_THREAD_BUF";
case FDRState::Token::CUSTOM_EVENT_DATA:
return "CUSTOM_EVENT_DATA";
+ case FDRState::Token::CALL_ARGUMENT:
+ return "CALL_ARGUMENT";
}
return "UNKNOWN";
}
@@ -238,6 +241,22 @@ Error processCustomEventMarker(FDRState &State, uint8_t RecordFirstByte,
return Error::success();
}
+/// State transition when a CallArgumentRecord is encountered.
+Error processFDRCallArgumentRecord(FDRState &State, uint8_t RecordFirstByte,
+ DataExtractor &RecordExtractor,
+ std::vector<XRayRecord> &Records) {
+ uint32_t OffsetPtr = 1; // Read starting after the first byte.
+ auto &Enter = Records.back();
+
+ if (Enter.Type != RecordTypes::ENTER)
+ return make_error<StringError>(
+ "CallArgument needs to be right after a function entry",
+ std::make_error_code(std::errc::executable_format_error));
+ Enter.Type = RecordTypes::ENTER_ARG;
+ Enter.CallArgs.emplace_back(RecordExtractor.getU64(&OffsetPtr));
+ return Error::success();
+}
+
/// Advances the state machine for reading the FDR record type by reading one
/// Metadata Record and updating the State appropriately based on the kind of
/// record encountered. The RecordKind is encoded in the first byte of the
@@ -245,7 +264,8 @@ Error processCustomEventMarker(FDRState &State, uint8_t RecordFirstByte,
/// to determine that this is a metadata record as opposed to a function record.
Error processFDRMetadataRecord(FDRState &State, uint8_t RecordFirstByte,
DataExtractor &RecordExtractor,
- size_t &RecordSize) {
+ size_t &RecordSize,
+ std::vector<XRayRecord> &Records) {
// The remaining 7 bits are the RecordKind enum.
uint8_t RecordKind = RecordFirstByte >> 1;
switch (RecordKind) {
@@ -279,6 +299,11 @@ Error processFDRMetadataRecord(FDRState &State, uint8_t RecordFirstByte,
RecordExtractor, RecordSize))
return E;
break;
+ case 6: // CallArgument
+ if (auto E = processFDRCallArgumentRecord(State, RecordFirstByte,
+ RecordExtractor, Records))
+ return E;
+ break;
default:
// Widen the record type to uint16_t to prevent conversion to char.
return make_error<StringError>(
@@ -434,7 +459,7 @@ Error loadFDRLog(StringRef Data, XRayFileHeader &FileHeader,
if (isMetadataRecord) {
RecordSize = 16;
if (auto E = processFDRMetadataRecord(State, BitField, RecordExtractor,
- RecordSize))
+ RecordSize, Records))
return E;
} else { // Process Function Record
RecordSize = 8;
OpenPOWER on IntegriCloud