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