From d380c9a6dfc11608edcaf48e986fe6b89c66fa7d Mon Sep 17 00:00:00 2001 From: Pierre Langlois Date: Wed, 10 Aug 2022 15:10:38 +0100 Subject: [PATCH] [tools][system-analyzer] Add support for apkEmbeddedLibrary and targetRootFS The system analyzer relies on server-side processing to symbolize C++ addresses, using lws-middleware.js: ws --stack system-analyzer/lws-middleware.js lws-static cors This does not work on Android however, given the log file refers to the stripped apk file rather than the unstripped libchrome.so binary. This CL adds the --apk-embedded-library option to the middleware script to make this work: ws --stack system-analyzer/lws-middleware.js lws-static cors \ --apk-embedded-library=/path/to/out/android/lib.unstripped/libchrome.so Also, for completeness, add the --target option to set targetRootFS. Bug: v8:10644 Change-Id: I7bb73adf49e3af8eaa88a5e2c81ec913023ac1a9 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3823133 Commit-Queue: Pierre Langlois Reviewed-by: Camillo Bruni Cr-Commit-Position: refs/heads/main@{#82359} --- tools/system-analyzer/lws-middleware.js | 26 +++++++++++++++++++++++-- tools/system-analyzer/processor.mjs | 18 +++++++++++------ 2 files changed, 36 insertions(+), 8 deletions(-) diff --git a/tools/system-analyzer/lws-middleware.js b/tools/system-analyzer/lws-middleware.js index 75789ef4af..fccdd6898a 100644 --- a/tools/system-analyzer/lws-middleware.js +++ b/tools/system-analyzer/lws-middleware.js @@ -19,13 +19,35 @@ class Symbolizer { this.objdumpExec = 'objdump'; } + optionDefinitions() { + return [ + { + name: 'apk-embedded-library', + type: String, + description: + 'Specify the path of the embedded library for Android traces', + }, + { + name: 'target', + type: String, + description: 'Specify the target root directory for cross environment', + } + ] + } + middleware(config) { return async (ctx, next) => { if (ctx.path == '/v8/loadVMSymbols') { await this.parseVMSymbols(ctx) } else if (ctx.path == '/v8/info/platform') { - ctx.response.type = 'text'; - ctx.response.body = process.platform; + ctx.response.type = 'json'; + ctx.response.body = JSON.stringify({ + 'name': process.platform, + 'nmExec': this.nmExec, + 'objdumpExec': this.objdumpExec, + 'targetRootFS': config.target, + 'apkEmbeddedLibrary': config.apkEmbeddedLibrary + }); } await next(); } diff --git a/tools/system-analyzer/processor.mjs b/tools/system-analyzer/processor.mjs index f137bd1c49..15eccd70c9 100644 --- a/tools/system-analyzer/processor.mjs +++ b/tools/system-analyzer/processor.mjs @@ -325,19 +325,25 @@ export class Processor extends LogReader { async _setupCppEntriesProvider() { // Probe the local symbol server for the platform: const url = new URL('http://localhost:8000/v8/info/platform') - let platform = 'linux' + let platform = {name: 'linux'}; try { const response = await fetch(url, {timeout: 1}); - platform = await response.text(); + if (response.status == 404) { + throw new Error( + `Local symbol server returned 404: ${await response.text()}`); + } + platform = await response.json(); } catch (e) { console.warn(`Local symbol server is not running on ${url}`); console.warn(e); } - if (platform === 'darwin') { - this._cppEntriesProvider = new RemoteMacOSCppEntriesProvider(); - } else { - this._cppEntriesProvider = new RemoteLinuxCppEntriesProvider(); + let CppEntriesProvider = RemoteLinuxCppEntriesProvider; + if (platform.name === 'darwin') { + CppEntriesProvider = RemoteMacOSCppEntriesProvider; } + this._cppEntriesProvider = new CppEntriesProvider( + platform.nmExec, platform.objdumpExec, platform.targetRootFS, + platform.apkEmbeddedLibrary); } processCodeCreation(