Commit 0f2bbbfb authored by Erik Chen's avatar Erik Chen Committed by Commit Bot

Add support for DebugID for macOS.

Change-Id: I5db3464c086b7763afd4bccdc7242f462ffd7c1b
Reviewed-on: https://chromium-review.googlesource.com/1014706
Commit-Queue: Erik Chen <erikchen@chromium.org>
Reviewed-by: default avatarPrimiano Tucci <primiano@chromium.org>
Cr-Commit-Position: refs/heads/master@{#552848}
parent 02b68439
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include "base/numerics/safe_math.h" #include "base/numerics/safe_math.h"
#include "base/process/process_metrics.h" #include "base/process/process_metrics.h"
#include "base/strings/string_number_conversions.h"
namespace memory_instrumentation { namespace memory_instrumentation {
...@@ -73,6 +74,9 @@ bool GetDyldRegions(std::vector<VMRegion>* regions) { ...@@ -73,6 +74,9 @@ bool GetDyldRegions(std::vector<VMRegion>* regions) {
uint64_t next_command = reinterpret_cast<uint64_t>(header + 1); uint64_t next_command = reinterpret_cast<uint64_t>(header + 1);
uint64_t command_end = next_command + header->sizeofcmds; uint64_t command_end = next_command + header->sizeofcmds;
uint64_t slide = 0; uint64_t slide = 0;
std::vector<VMRegion> temp_regions;
std::string debug_id;
for (unsigned int j = 0; j < header->ncmds; ++j) { for (unsigned int j = 0; j < header->ncmds; ++j) {
// Ensure that next_command doesn't run past header->sizeofcmds. // Ensure that next_command doesn't run past header->sizeofcmds.
if (next_command + sizeof(struct load_command) > command_end) if (next_command + sizeof(struct load_command) > command_end)
...@@ -117,12 +121,25 @@ bool GetDyldRegions(std::vector<VMRegion>* regions) { ...@@ -117,12 +121,25 @@ bool GetDyldRegions(std::vector<VMRegion>* regions) {
region.protection_flags = protection_flags; region.protection_flags = protection_flags;
region.mapped_file = image_name; region.mapped_file = image_name;
region.start_address = slide + seg->vmaddr; region.start_address = slide + seg->vmaddr;
temp_regions.push_back(std::move(region));
}
// We intentionally avoid setting any page information, which is not if (load_cmd->cmd == LC_UUID) {
// available from dyld. The fields will be populated later. if (load_cmd->cmdsize < sizeof(uuid_command))
regions->push_back(region); return false;
const uuid_command* uuid_cmd =
reinterpret_cast<const uuid_command*>(load_cmd);
// The ID is comprised of the UUID concatenated with the module's "age"
// value which is always 0.
debug_id =
base::HexEncode(&uuid_cmd->uuid, sizeof(uuid_cmd->uuid)) + "0";
} }
} }
for (VMRegion& region : temp_regions) {
region.module_debugid = debug_id;
regions->push_back(region);
}
} }
return true; return true;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment