Skip to content

Commit

Permalink
[Sampling profiler] Change filename field to debug basename
Browse files Browse the repository at this point in the history
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: Andrey Kosyakov <caseq@chromium.org>
Reviewed-by: oysteine <oysteine@chromium.org>
Reviewed-by: Alexei Filippov <alph@chromium.org>
Reviewed-by: Charlie Andrews <charliea@chromium.org>
Cr-Commit-Position: refs/heads/master@{#636551}
  • Loading branch information
Mike Wittman authored and Commit Bot committed Feb 28, 2019
1 parent 1556305 commit e3b343d
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 18 deletions.
2 changes: 1 addition & 1 deletion base/profiler/stack_sampling_profiler_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
11 changes: 7 additions & 4 deletions base/sampling_heap_profiler/module_cache.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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 {
Expand Down
10 changes: 4 additions & 6 deletions base/sampling_heap_profiler/module_cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,17 @@ 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;

private:
uintptr_t base_address_;
std::string id_;
FilePath filename_;
FilePath debug_basename_;
size_t size_;
};

Expand Down
4 changes: 2 additions & 2 deletions base/sampling_heap_profiler/module_cache_mac.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
3 changes: 2 additions & 1 deletion components/metrics/call_stack_profile_builder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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_));
Expand Down
2 changes: 1 addition & 1 deletion components/tracing/common/tracing_sampler_profiler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
4 changes: 2 additions & 2 deletions content/browser/devtools/protocol/memory_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()))
Expand Down

0 comments on commit e3b343d

Please sign in to comment.