Commit e3b343df authored by Mike Wittman's avatar Mike Wittman Committed by Commit Bot

[Sampling profiler] Change filename field to debug basename

Updates the field and accessor name to reflect its actual state, and to
be consistent across platforms.

Bug: 931418
Change-Id: I758a7bb8c8183174c42142563203e8e5acd20c37
Reviewed-on: https://chromium-review.googlesource.com/c/1478250
Commit-Queue: Mike Wittman <wittman@chromium.org>
Reviewed-by: default avatarAndrey Kosyakov <caseq@chromium.org>
Reviewed-by: default avataroysteine <oysteine@chromium.org>
Reviewed-by: default avatarAlexei Filippov <alph@chromium.org>
Reviewed-by: default avatarCharlie Andrews <charliea@chromium.org>
Cr-Commit-Position: refs/heads/master@{#636551}
parent 1556305b
......@@ -562,7 +562,7 @@ std::string FormatSampleForDiagnosticOutput(const Frames& frames) {
for (const auto& frame : frames) {
output += StringPrintf(
"0x%p %s\n", reinterpret_cast<const void*>(frame.instruction_pointer),
frame.module->GetFilename().AsUTF8Unsafe().c_str());
frame.module->GetDebugBasename().AsUTF8Unsafe().c_str());
}
return output;
}
......
......@@ -10,9 +10,12 @@ namespace base {
ModuleCache::Module::Module(uintptr_t base_address,
const std::string& id,
const FilePath& filename,
const FilePath& debug_basename,
size_t size)
: base_address_(base_address), id_(id), filename_(filename), size_(size) {}
: base_address_(base_address),
id_(id),
debug_basename_(debug_basename),
size_(size) {}
ModuleCache::Module::~Module() = default;
......@@ -24,8 +27,8 @@ std::string ModuleCache::Module::GetId() const {
return id_;
}
FilePath ModuleCache::Module::GetFilename() const {
return filename_;
FilePath ModuleCache::Module::GetDebugBasename() const {
return debug_basename_;
}
size_t ModuleCache::Module::GetSize() const {
......
......@@ -47,11 +47,9 @@ class BASE_EXPORT ModuleCache {
// GUID + AGE in the debug image headers of a module.
std::string GetId() const;
// Gets the filename of the module.
// TODO(wittman): This is really the debug basename of the file, which is
// the pdb basename for Windows and the binary basename for other
// platforms. Update the method name accordingly.
FilePath GetFilename() const;
// Gets the debug basename of the module. This is the basename of the PDB
// file on Windows and the basename of the binary on other platforms.
FilePath GetDebugBasename() const;
// Gets the size of the module.
size_t GetSize() const;
......@@ -59,7 +57,7 @@ class BASE_EXPORT ModuleCache {
private:
uintptr_t base_address_;
std::string id_;
FilePath filename_;
FilePath debug_basename_;
size_t size_;
};
......
......@@ -71,8 +71,8 @@ std::unique_ptr<ModuleCache::Module> ModuleCache::CreateModuleForAddress(
return nullptr;
auto base_module_address = reinterpret_cast<uintptr_t>(inf.dli_fbase);
return std::make_unique<Module>(
base_module_address, GetUniqueId(inf.dli_fbase), FilePath(inf.dli_fname),
GetModuleTextSize(inf.dli_fbase));
base_module_address, GetUniqueId(inf.dli_fbase),
FilePath(inf.dli_fname).BaseName(), GetModuleTextSize(inf.dli_fbase));
}
size_t ModuleCache::GetModuleTextSize(const void* module_addr) {
......
......@@ -168,7 +168,8 @@ void CallStackProfileBuilder::OnProfileCompleted(
CallStackProfile::ModuleIdentifier* module_id =
call_stack_profile->add_module_id();
module_id->set_build_id(module->GetId());
module_id->set_name_md5_prefix(HashModuleFilename(module->GetFilename()));
module_id->set_name_md5_prefix(
HashModuleFilename(module->GetDebugBasename()));
}
PassProfilesToMetricsProvider(std::move(sampled_profile_));
......
......@@ -113,7 +113,7 @@ void TracingSamplerProfiler::TracingProfileBuilder::OnSampleCompleted(
frame_name = "Unknown";
#else
if (frame.module) {
module_name = frame.module->GetFilename().BaseName().MaybeAsASCII();
module_name = frame.module->GetDebugBasename().MaybeAsASCII();
module_id = frame.module->GetId();
frame_name = GetFrameNameFromOffsetAddr(frame.instruction_pointer -
frame.module->GetBaseAddress());
......
......@@ -61,8 +61,8 @@ Response MemoryHandler::GetBrowserSamplingProfile(
for (const auto* module : module_cache.GetModules()) {
modules->addItem(
Memory::Module::Create()
.SetName(base::StringPrintf("%" PRFilePath,
module->GetFilename().value().c_str()))
.SetName(base::StringPrintf(
"%" PRFilePath, module->GetDebugBasename().value().c_str()))
.SetUuid(module->GetId())
.SetBaseAddress(
base::StringPrintf("0x%" PRIxPTR, module->GetBaseAddress()))
......
......@@ -172,7 +172,7 @@ InspectorMemoryAgent::GetSamplingProfileById(uint32_t id) {
protocol::Array<protocol::Memory::Module>::create();
for (const auto* module : module_cache.GetModules()) {
modules->addItem(protocol::Memory::Module::create()
.setName(module->GetFilename().value().c_str())
.setName(module->GetDebugBasename().value().c_str())
.setUuid(module->GetId().c_str())
.setBaseAddress(String::Format(
"0x%" PRIxPTR, module->GetBaseAddress()))
......
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