1 //===- BlockIndexer.h - FDR Block Indexing Visitor ------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // An implementation of the RecordVisitor which generates a mapping between a
10 // thread and a range of records representing a block.
12 //===----------------------------------------------------------------------===//
13 #ifndef LLVM_LIB_XRAY_BLOCKINDEXER_H_
14 #define LLVM_LIB_XRAY_BLOCKINDEXER_H_
16 #include "llvm/ADT/DenseMap.h"
17 #include "llvm/XRay/FDRRecords.h"
24 // The BlockIndexer will gather all related records associated with a
25 // process+thread and group them by 'Block'.
26 class BlockIndexer
: public RecordVisitor
{
31 WallclockRecord
*WallclockTime
;
32 std::vector
<Record
*> Records
;
35 // This maps the process + thread combination to a sequence of blocks.
36 using Index
= DenseMap
<std::pair
<uint64_t, int32_t>, std::vector
<Block
>>;
41 Block CurrentBlock
{0, 0, nullptr, {}};
44 explicit BlockIndexer(Index
&I
) : RecordVisitor(), Indices(I
) {}
46 Error
visit(BufferExtents
&) override
;
47 Error
visit(WallclockRecord
&) override
;
48 Error
visit(NewCPUIDRecord
&) override
;
49 Error
visit(TSCWrapRecord
&) override
;
50 Error
visit(CustomEventRecord
&) override
;
51 Error
visit(CallArgRecord
&) override
;
52 Error
visit(PIDRecord
&) override
;
53 Error
visit(NewBufferRecord
&) override
;
54 Error
visit(EndBufferRecord
&) override
;
55 Error
visit(FunctionRecord
&) override
;
56 Error
visit(CustomEventRecordV5
&) override
;
57 Error
visit(TypedEventRecord
&) override
;
59 /// The flush() function will clear out the current state of the visitor, to
60 /// allow for explicitly flushing a block's records to the currently
61 /// recognized thread and process combination.
68 #endif // LLVM_LIB_XRAY_BLOCKINDEXER_H_