dumpcpp-driver.mjs 1.58 KB
Newer Older
1 2 3 4
// Copyright 2016 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

5
import { WebInspector } from "./sourcemap.mjs";
6
import {
7
    CppProcessor, ArgumentsProcessor, UnixCppEntriesProvider,
8 9 10
    WindowsCppEntriesProvider, MacCppEntriesProvider
  } from  "./dumpcpp.mjs";

11 12 13
// Dump C++ symbols of shared library if possible

function processArguments(args) {
14
  const processor = new ArgumentsProcessor(args);
15 16 17 18 19 20 21 22 23 24 25 26 27
  if (processor.parse()) {
    return processor.result();
  } else {
    processor.printUsageAndExit();
  }
}

function initSourceMapSupport() {
  // Pull dev tools source maps into our name space.
  SourceMap = WebInspector.SourceMap;

  // Overwrite the load function to load scripts synchronously.
  SourceMap.load = function(sourceMapURL) {
28 29
    const content = readFile(sourceMapURL);
    const sourceMapObject = (JSON.parse(content));
30 31 32 33
    return new SourceMap(sourceMapURL, sourceMapObject);
  };
}

34
const entriesProviders = {
35 36 37 38 39
  'unix': UnixCppEntriesProvider,
  'windows': WindowsCppEntriesProvider,
  'mac': MacCppEntriesProvider
};

40 41
const params = processArguments(arguments);
let sourceMap = null;
42 43 44 45 46
if (params.sourceMap) {
  initSourceMapSupport();
  sourceMap = SourceMap.load(params.sourceMap);
}

47
const cppProcessor = new CppProcessor(
48 49
  new (entriesProviders[params.platform])(params.nm, params.targetRootFS,
                                          params.apkEmbeddedLibrary),
50 51 52
  params.timedRange, params.pairwiseTimedRange);
cppProcessor.processLogFile(params.logFileName);
cppProcessor.dumpCppSymbols();