#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/StringExtras.h"
#include "llvm/DebugInfo/DWARF/DWARFContext.h"
#include "llvm/DebugInfo/Symbolize/SymbolizableModule.h"
#include "llvm/DebugInfo/Symbolize/SymbolizableObjectFile.h"
return StringRef(llvm::sys::path::convert_to_slash(Path))
.contains("memprof/memprof_");
}
+
+std::string getBuildIdString(const SegmentEntry &Entry) {
+ constexpr size_t Size = sizeof(Entry.BuildId) / sizeof(uint8_t);
+ constexpr uint8_t Zeros[Size] = {0};
+ // If the build id is unset print a helpful string instead of all zeros.
+ if (memcmp(Entry.BuildId, Zeros, Size) == 0)
+ return "<None>";
+
+ std::string Str;
+ raw_string_ostream OS(Str);
+ for (size_t I = 0; I < Size; I++) {
+ OS << format_hex_no_prefix(Entry.BuildId[I], 2);
+ }
+ return OS.str();
+}
} // namespace
Expected<std::unique_ptr<RawMemProfReader>>
OS << " NumMibInfo: " << NumMibInfo << "\n";
OS << " NumAllocFunctions: " << NumAllocFunctions << "\n";
OS << " NumStackOffsets: " << StackMap.size() << "\n";
+ // Print out the segment information.
+ OS << " Segments:\n";
+ for (const auto &Entry : SegmentInfo) {
+ OS << " -\n";
+ OS << " BuildId: " << getBuildIdString(Entry) << "\n";
+ OS << " Start: 0x" << llvm::utohexstr(Entry.Start) << "\n";
+ OS << " End: 0x" << llvm::utohexstr(Entry.End) << "\n";
+ OS << " Offset: 0x" << llvm::utohexstr(Entry.Offset) << "\n";
+ }
// Print out the merged contents of the profiles.
OS << " Records:\n";
for (const auto &Entry : *this) {
CHECK-NEXT: NumMibInfo: 2
CHECK-NEXT: NumAllocFunctions: 1
CHECK-NEXT: NumStackOffsets: 2
+CHECK-NEXT: Segments:
+CHECK-NEXT: -
+CHECK-NEXT: BuildId: <None>
+CHECK-NEXT: Start: 0x200000
+CHECK-NEXT: End: 0x298000
+CHECK-NEXT: Offset: 0x0
+CHECK-NEXT: -
+CHECK-NEXT: BuildId: <None>
+CHECK-NEXT: Start: 0x7FFFF7C7C000
+CHECK-NEXT: End: 0x7FFFF7DC5000
+CHECK-NEXT: Offset: 0x26000
+CHECK-NEXT: -
+CHECK-NEXT: BuildId: <None>
+CHECK-NEXT: Start: 0x7FFFF7E1E000
+CHECK-NEXT: End: 0x7FFFF7E30000
+CHECK-NEXT: Offset: 0x3000
+CHECK-NEXT: -
+CHECK-NEXT: BuildId: <None>
+CHECK-NEXT: Start: 0x7FFFF7E36000
+CHECK-NEXT: End: 0x7FFFF7E38000
+CHECK-NEXT: Offset: 0x1000
+CHECK-NEXT: -
+CHECK-NEXT: BuildId: <None>
+CHECK-NEXT: Start: 0x7FFFF7E4A000
+CHECK-NEXT: End: 0x7FFFF7EE5000
+CHECK-NEXT: Offset: 0xF000
+CHECK-NEXT: -
+CHECK-NEXT: BuildId: <None>
+CHECK-NEXT: Start: 0x7FFFF7F83000
+CHECK-NEXT: End: 0x7FFFF7F87000
+CHECK-NEXT: Offset: 0x3000
+CHECK-NEXT: -
+CHECK-NEXT: BuildId: <None>
+CHECK-NEXT: Start: 0x7FFFF7F92000
+CHECK-NEXT: End: 0x7FFFF7FA1000
+CHECK-NEXT: Offset: 0x7000
+CHECK-NEXT: -
+CHECK-NEXT: BuildId: <None>
+CHECK-NEXT: Start: 0x7FFFF7FD0000
+CHECK-NEXT: End: 0x7FFFF7FD2000
+CHECK-NEXT: Offset: 0x0
+CHECK-NEXT: -
+CHECK-NEXT: BuildId: <None>
+CHECK-NEXT: Start: 0x7FFFF7FD3000
+CHECK-NEXT: End: 0x7FFFF7FF3000
+CHECK-NEXT: Offset: 0x1000
CHECK-NEXT: Records:
CHECK-NEXT: -
CHECK-NEXT: FunctionGUID: {{[0-9]+}}
CHECK-NEXT: NumMibInfo: 2
CHECK-NEXT: NumAllocFunctions: 2
CHECK-NEXT: NumStackOffsets: 1
+CHECK-NEXT: Segments:
+CHECK-NEXT: -
+CHECK-NEXT: BuildId: <None>
+CHECK-NEXT: Start: 0x200000
+CHECK-NEXT: End: 0x29B000
+CHECK-NEXT: Offset: 0x0
+CHECK-NEXT: -
+CHECK-NEXT: BuildId: <None>
+CHECK-NEXT: Start: 0x7F5871485000
+CHECK-NEXT: End: 0x7F58715CD000
+CHECK-NEXT: Offset: 0x26000
+CHECK-NEXT: -
+CHECK-NEXT: BuildId: <None>
+CHECK-NEXT: Start: 0x7F587162D000
+CHECK-NEXT: End: 0x7F587163F000
+CHECK-NEXT: Offset: 0x3000
+CHECK-NEXT: -
+CHECK-NEXT: BuildId: <None>
+CHECK-NEXT: Start: 0x7F5871646000
+CHECK-NEXT: End: 0x7F5871648000
+CHECK-NEXT: Offset: 0x2000
+CHECK-NEXT: -
+CHECK-NEXT: BuildId: <None>
+CHECK-NEXT: Start: 0x7F587165A000
+CHECK-NEXT: End: 0x7F58716F4000
+CHECK-NEXT: Offset: 0xF000
+CHECK-NEXT: -
+CHECK-NEXT: BuildId: <None>
+CHECK-NEXT: Start: 0x7F5871791000
+CHECK-NEXT: End: 0x7F5871795000
+CHECK-NEXT: Offset: 0x3000
+CHECK-NEXT: -
+CHECK-NEXT: BuildId: <None>
+CHECK-NEXT: Start: 0x7F58717A0000
+CHECK-NEXT: End: 0x7F58717AF000
+CHECK-NEXT: Offset: 0x7000
+CHECK-NEXT: -
+CHECK-NEXT: BuildId: <None>
+CHECK-NEXT: Start: 0x7F58717D6000
+CHECK-NEXT: End: 0x7F58717FA000
+CHECK-NEXT: Offset: 0x1000
+CHECK-NEXT: -
+CHECK-NEXT: BuildId: <None>
+CHECK-NEXT: Start: 0x7FFFC77BD000
+CHECK-NEXT: End: 0x7FFFC77BF000
+CHECK-NEXT: Offset: 0x0
CHECK-NEXT: Records:
CHECK-NEXT: -
CHECK-NEXT: FunctionGUID: 15505678318020221912