aboutsummaryrefslogtreecommitdiff
path: root/llvm/tools/llvm-profgen/ProfiledBinary.h
diff options
context:
space:
mode:
authormingmingl <mingmingl@google.com>2025-07-10 10:46:01 -0700
committermingmingl <mingmingl@google.com>2025-07-10 10:46:01 -0700
commitd569960a63ac77a6042ea579506dc48373b7da65 (patch)
tree2f7a70c38fa8a9d32e869b221c093e7e0d542ab7 /llvm/tools/llvm-profgen/ProfiledBinary.h
parentc92d5dad67aafded296653c2b9a369a7fe24ba13 (diff)
downloadllvm-users/mingmingl-llvm/llvm-profgen.zip
llvm-users/mingmingl-llvm/llvm-profgen.tar.gz
llvm-users/mingmingl-llvm/llvm-profgen.tar.bz2
Extend llvm-profgen to generate vtable profilesusers/mingmingl-llvm/llvm-profgen
Diffstat (limited to 'llvm/tools/llvm-profgen/ProfiledBinary.h')
-rw-r--r--llvm/tools/llvm-profgen/ProfiledBinary.h35
1 files changed, 35 insertions, 0 deletions
diff --git a/llvm/tools/llvm-profgen/ProfiledBinary.h b/llvm/tools/llvm-profgen/ProfiledBinary.h
index 0588cb4..02df762 100644
--- a/llvm/tools/llvm-profgen/ProfiledBinary.h
+++ b/llvm/tools/llvm-profgen/ProfiledBinary.h
@@ -185,6 +185,16 @@ private:
using AddressRange = std::pair<uint64_t, uint64_t>;
+// The parsed MMap event
+struct MMapEvent {
+ int64_t PID = 0;
+ uint64_t Address = 0;
+ uint64_t Size = 0;
+ uint64_t Offset = 0;
+ StringRef MemProtectionFlag;
+ StringRef BinaryPath;
+};
+
class ProfiledBinary {
// Absolute path of the executable binary.
std::string Path;
@@ -276,6 +286,19 @@ class ProfiledBinary {
// String table owning function name strings created from the symbolizer.
std::unordered_set<std::string> NameStrings;
+ // MMap events for PT_LOAD segments without 'x' memory protection flag.
+ SmallVector<MMapEvent> MMapNonTextEvents;
+
+ // Records the file offset, file size and virtual address of program headers.
+ struct PhdrInfo {
+ uint64_t FileOffset;
+ uint64_t FileSz;
+ uint64_t vAddr;
+ };
+
+ // Program header information for non-text PT_LOAD segments.
+ SmallVector<PhdrInfo> NonTextPhdrInfo;
+
// A collection of functions to print disassembly for.
StringSet<> DisassembleFunctionSet;
@@ -363,6 +386,10 @@ public:
ProfiledBinary(const StringRef ExeBinPath, const StringRef DebugBinPath);
~ProfiledBinary();
+ /// Symbolize an address and return the symbol name. The returned StringRef is
+ /// owned by this ProfiledBinary object.
+ StringRef symbolizeDataAddress(uint64_t Address);
+
void decodePseudoProbe();
StringRef getPath() const { return Path; }
@@ -603,6 +630,14 @@ public:
return ProbeDecoder.getInlinerDescForProbe(Probe);
}
+ void addMMapNonTextEvent(MMapEvent MMap) {
+ MMapNonTextEvents.push_back(MMap);
+ }
+
+ // Given a runtime address, canonicalize it to the virtual address in the
+ // binary.
+ uint64_t CanonicalizeNonTextAddress(uint64_t Address);
+
bool getTrackFuncContextSize() { return TrackFuncContextSize; }
bool getIsLoadedByMMap() { return IsLoadedByMMap; }