[compiler-rt] Support MemProf on darwin (PR #69640)
Teresa Johnson via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 26 20:17:51 PDT 2023
================
@@ -279,13 +286,54 @@ struct Allocator {
Print(Value->mib, Key, bool(Arg));
}
+ using SegmentEntry = ::llvm::memprof::SegmentEntry;
void FinishAndWrite() {
if (print_text && common_flags()->print_module_map)
DumpProcessMap();
allocator.ForceLock();
InsertLiveBlocks();
+#if SANITIZER_APPLE
+ if (print_binary_refs) {
+ __sanitizer::ListOfModules List;
+ List.init();
+ ArrayRef<LoadedModule> Modules(List.begin(), List.end());
+ for (const auto &Module : Modules) {
+ for (const auto &Segment : Module.ranges()) {
+ if (true) { // Segment.executable) {
+ SegmentEntry Entry(Segment.beg, Segment.end, Module.base_address());
+ // CHECK(Module.uuid_size() <= MEMPROF_BUILDID_MAX_SIZE);
+ // Entry.BuildIdSize = Module.uuid_size();
+ memcpy(Entry.BuildId, Module.uuid(), Module.uuid_size());
+ // Print out the segment information.
+ Printf(" -\n");
+ Printf("[MemProf] BuildId: ");
+ for (size_t I = 0; I < Module.uuid_size() /*Entry.BuildIdSize*/;
+ I++) {
+ Printf("%02x", Entry.BuildId[I]);
+ }
+ Printf("\n");
+ Printf("[MemProf] BuildIdName: %s\n", Module.full_name());
+ // If it is the main binary, check shadow.
----------------
teresajohnson wrote:
How do you know if it is the main binary?
https://github.com/llvm/llvm-project/pull/69640
More information about the llvm-commits
mailing list