Skip to content

Commit

Permalink
Add library name as metadata in trace file for Android
Browse files Browse the repository at this point in the history
The library name cannot be obtained from process maps since the library
can be mapped from apk directly. The name is taken by reading the elf
sections and added as metadata in trace file.
This is useful for symbolizing traces.

BUG=734705

Change-Id: I72761c3dc60fc45a9284e0d527929b4f3483eff2
Reviewed-on: https://chromium-review.googlesource.com/1035789
Commit-Queue: Siddhartha S <ssid@chromium.org>
Reviewed-by: Erik Chen <erikchen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#554966}
  • Loading branch information
ssiddhartha authored and Commit Bot committed May 1, 2018
1 parent a16c730 commit f575203
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions content/browser/tracing/tracing_controller_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,13 @@
#include "content/browser/tracing/etw_tracing_agent_win.h"
#endif

#if defined(OS_ANDROID)
#include "base/debug/elf_reader_linux.h"

// Symbol with virtual address of the start of ELF header of the current binary.
extern char __ehdr_start;
#endif // defined(OS_ANDROID)

namespace content {

namespace {
Expand Down Expand Up @@ -185,6 +192,17 @@ TracingControllerImpl::GenerateMetadataDict() const {
metadata_dict->SetString("v8-version", V8_VERSION_STRING);
metadata_dict->SetString("user-agent", GetContentClient()->GetUserAgent());

#if defined(OS_ANDROID)
// The library name is used for symbolizing heap profiles. This cannot be
// obtained from process maps since library can be mapped from apk directly.
// This is not added as part of memory-infra os dumps since it is special case
// only for chrome library.
base::Optional<std::string> soname =
base::debug::ReadElfLibraryName(&__ehdr_start);
if (soname)
metadata_dict->SetString("chrome-library-name", soname.value());
#endif // defined(OS_ANDROID)

// OS
#if defined(OS_CHROMEOS)
metadata_dict->SetString("os-name", "CrOS");
Expand Down

0 comments on commit f575203

Please sign in to comment.