diff --git a/.eslintrc.js b/.eslintrc.js index 9456a8432c..c728e7f3cd 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -39,6 +39,10 @@ module.exports = { "comma-dangle": [ "error", "always-multiline" + ], + "no-console": [ + "error", + { allow: ["log", "warn", "error"] } ] }, "settings": { diff --git a/src/components/VirtualList.js b/src/components/VirtualList.js index 812336c9ce..c0c3b3c3fd 100644 --- a/src/components/VirtualList.js +++ b/src/components/VirtualList.js @@ -12,11 +12,17 @@ class VirtualListRow extends Component { } } +VirtualListRow.propTypes = { + renderItem: PropTypes.func.isRequired, + item: PropTypes.any.isRequired, + index: PropTypes.number.isRequired, +}; + class VirtualList extends Component { constructor(props) { super(props); - this._scrollListener = e => this.forceUpdate(); + this._scrollListener = () => this.forceUpdate(); } componentDidMount() { @@ -98,4 +104,13 @@ class VirtualList extends Component { } +VirtualList.propTypes = { + itemHeight: PropTypes.number.isRequired, + className: PropTypes.string, + renderItem: PropTypes.func.isRequired, + items: PropTypes.array.isRequired, + focusable: PropTypes.bool.isRequired, + onKeyDown: PropTypes.func.isRequired, +}; + export default VirtualList; diff --git a/src/containers/App.js b/src/containers/App.js index 0d9a65da6f..bee4390581 100644 --- a/src/containers/App.js +++ b/src/containers/App.js @@ -1,7 +1,6 @@ import React, { Component, PropTypes } from 'react'; import { connect } from 'react-redux'; import { preprocessProfile } from '../preprocess-profile'; -import { getTimeRangeIncludingAllThreads } from '../profile-data'; import { symbolicateProfile } from '../symbolication'; import { SymbolStore } from '../symbol-store'; import * as Actions from '../actions'; @@ -60,4 +59,14 @@ class App extends Component { ); } } + +App.propTypes = { + view: PropTypes.string.isRequired, + profileView: PropTypes.shape({ + profile: PropTypes.object.isRequired, + viewOptions: PropTypes.object.isRequired, + }).isRequired, + dispatch: PropTypes.func.isRequired, +}; + export default connect(state => state)(App); diff --git a/src/containers/Root.js b/src/containers/Root.js index 514361a91c..37ba22dfd3 100644 --- a/src/containers/Root.js +++ b/src/containers/Root.js @@ -1,4 +1,4 @@ -import React, { Component } from 'react'; +import React, { Component, PropTypes } from 'react'; import { Provider } from 'react-redux'; import App from './App'; @@ -12,3 +12,7 @@ export default class Root extends Component { ); } } + +Root.propTypes = { + store: PropTypes.any.isRequired, +}; diff --git a/src/function-info.js b/src/function-info.js index 24d0396212..a1e70212f7 100644 --- a/src/function-info.js +++ b/src/function-info.js @@ -12,13 +12,13 @@ function cleanFunctionName(functionName) { } function addonWithID(addonID) { - return firstMatch(meta.addons, function addonHasID(addon) { + return meta.addons.find(function addonHasID(addon) { return addon.id.toLowerCase() == addonID.toLowerCase(); }); } function findAddonForChromeURIHost(host) { - return firstMatch(meta.addons, function addonUsesChromeURIHost(addon) { + return meta.addons.find(function addonUsesChromeURIHost(addon) { return addon.chromeURIHosts && addon.chromeURIHosts.indexOf(host) != -1; }); } @@ -41,7 +41,7 @@ function getAddonForScriptURI(url, host) { if (!meta || !meta.addons) return null; - if (url.startsWith('resource:') && endsWith(host, '-at-jetpack')) { + if (url.startsWith('resource:') && host.endsWith('-at-jetpack')) { // Assume this is a jetpack url var jetpackID = host.substring(0, host.length - 11) + '@jetpack'; return addonWithID(jetpackID); diff --git a/src/preprocess-profile.js b/src/preprocess-profile.js index 42f1b01055..e89351c499 100644 --- a/src/preprocess-profile.js +++ b/src/preprocess-profile.js @@ -63,7 +63,7 @@ function preprocessThread(thread, libs) { function addURLResource(url) { const index = resourceTable.length++; resourceTable.type[index] = resourceTypes.url; - resourceTable.name[index] = name; + resourceTable.name[index] = url; } const stringTable = new UniqueStringArray(thread.stringTable); @@ -152,10 +152,6 @@ function preprocessSharedLibraries(libs) { * Adjust the "time" field by the given delta. */ function adjustTimestamps(samplesOrMarkers, delta) { - if (!samplesOrMarkers.time) { - console.log('don\'t have samplesOrMarkers.time!'); - console.log(samplesOrMarkers); - } return Object.assign({}, samplesOrMarkers, { time: samplesOrMarkers.time.map(time => time === undefined ? undefined : time + delta), }); diff --git a/src/profile-tree.js b/src/profile-tree.js index e7e97dcc7c..65be7a4fc0 100644 --- a/src/profile-tree.js +++ b/src/profile-tree.js @@ -1,5 +1,4 @@ import { timeCode } from './time-code'; -import { getFuncStackInfo } from './profile-data'; class ProfileTree { constructor(funcStackTable, funcStackTimes, funcStackChildCount, funcTable, stringTable, rootTotalTime, rootCount) { diff --git a/src/reducers/index.js b/src/reducers/index.js index f42aeb7fc8..92454e27c6 100644 --- a/src/reducers/index.js +++ b/src/reducers/index.js @@ -45,7 +45,7 @@ function selectedThread(state = 0, action) { function viewOptionsThreads(state = [], action) { switch (action.type) { case 'RECEIVE_PROFILE_FROM_ADDON': - return action.profile.threads.map(thread => ({ + return action.profile.threads.map(() => ({ selectedFuncStack: [], expandedFuncStacks: [], })); diff --git a/src/symbol-store-db.js b/src/symbol-store-db.js index 2fdfc8b65b..a99f122ebc 100644 --- a/src/symbol-store-db.js +++ b/src/symbol-store-db.js @@ -57,7 +57,6 @@ export class SymbolStoreDB { return new Promise((resolve, reject) => { let transaction = this._db.transaction('symbol-tables', 'readwrite'); - let libKey = null; transaction.onerror = reject; let tableStore = transaction.objectStore('symbol-tables'); let putReq = tableStore.put({ pdbName, breakpadId, addrs, index, buffer }); @@ -110,7 +109,7 @@ export class SymbolStoreDB { reject(new Error('unexpected null result')); return; } - const { addrs, index, buffer } = req.result; + const { index, buffer } = req.result; const decoder = new TextDecoder(); resolve(requestedAddressesIndices.map(addrIndex => { const startOffset = index[addrIndex]; diff --git a/src/symbol-store.js b/src/symbol-store.js index bf1003208d..5f5b2fb01c 100644 --- a/src/symbol-store.js +++ b/src/symbol-store.js @@ -33,7 +33,7 @@ export class SymbolStore { if (this._failedRequests.has(libid)) { return Promise.reject(new Error('We\'ve tried to request a symbol table for this library before and failed, so we\'re not trying again.')); } - return this._db.getLibKey(pdbName, breakpadId).catch(error => { + return this._db.getLibKey(pdbName, breakpadId).catch(() => { if (this._importingLibs.has(libid)) { // We've already requested a symbol table for this library and are // waiting for the result, so just return the promise for the existing diff --git a/src/symbolication.js b/src/symbolication.js index a6b889ca80..a7ab3fd30b 100644 --- a/src/symbolication.js +++ b/src/symbolication.js @@ -1,6 +1,5 @@ import bisection from 'bisection'; import { resourceTypes } from './profile-data'; -import { UniqueStringArray } from './unique-string-array'; /** * Return the library object that contains address. @@ -125,7 +124,8 @@ function findFunctionsToMergeAndSymbolicationAddresses(funcAddressTable, funcsTo // inside of. let funcAddressIndex = bisection.right(funcAddressTable, funcAddress, nextFuncAddressIndex) - 1; if (funcAddressIndex >= 0) { - const realFuncAddress = funcAddressTable[funcAddressIndex]; + // TODO: Take realFuncAddress and put it into the func table. + // const realFuncAddress = funcAddressTable[funcAddressIndex]; nextFuncAddressIndex = funcAddressIndex + 1; nextFuncAddress = (nextFuncAddressIndex < funcAddressTable.length) ? funcAddressTable[nextFuncAddressIndex] : Infinity; lastFuncIndex = funcIndex; @@ -191,23 +191,6 @@ export function applyFunctionMerging(thread, oldFuncToNewFuncMap) { * @return Promise A promise that resolves (with nothing) once symbolication of the thread has completed. */ function symbolicateThread(thread, threadIndex, symbolStore, cbo) { - let updatedThread = thread; - - let scheduledThreadUpdate = false; - function scheduleThreadUpdate() { - if (!scheduledThreadUpdate) { - setTimeout(callOnUpdateThread, 0); - scheduledThreadUpdate = true; - } - } - - function callOnUpdateThread() { - updatedThread = applyFunctionMerging(updatedThread, oldFuncToNewFuncMap); - cbo.onUpdateThread(updatedThread, oldFuncToNewFuncMap); - oldFuncToNewFuncMap = new Map(); - scheduledThreadUpdate = false; - } - let foundFuncs = gatherFuncsInThread(thread); return Promise.all(Array.from(foundFuncs).map(function ([lib, funcsToSymbolicate]) { // lib is a lib object from thread.libs. @@ -218,16 +201,15 @@ function symbolicateThread(thread, threadIndex, symbolStore, cbo) { // We don't have any symbols yet. We'll request those after we've merged // the functions. const { funcAddrIndices, funcIndices, oldFuncToNewFuncMap } = - findFunctionsToMergeAndSymbolicationAddresses(funcAddressTable, funcsToSymbolicate, updatedThread.funcTable); + findFunctionsToMergeAndSymbolicationAddresses(funcAddressTable, funcsToSymbolicate, thread.funcTable); cbo.onMergeFunctions(threadIndex, oldFuncToNewFuncMap); // Now list the func addresses that we want symbols for, and request them. return symbolStore.getSymbolsForAddressesInLib(funcAddrIndices, lib).then(funcNames => { cbo.onGotFuncNames(threadIndex, funcIndices, funcNames); }); - }).catch(error => { - console.log(`Couldn't get symbols for library ${lib.pdbName} ${lib.breakpadId}`); - console.error(error); + }).catch(() => { + // We could not find symbols for this library. // Don't throw, so that the resulting promise will be resolved, thereby // indicating that we're done symbolicating with lib. }); @@ -243,7 +225,6 @@ function symbolicateThread(thread, threadIndex, symbolStore, cbo) { * @return Promise A promise that resolves (with nothing) once symbolication has completed. */ export function symbolicateProfile(profile, symbolStore, cbo) { - let updatedProfile = profile; return Promise.all(profile.threads.map((thread, threadIndex) => { return symbolicateThread(thread, threadIndex, symbolStore, cbo); })); diff --git a/src/time-code.js b/src/time-code.js index 505120104b..45276c56bf 100644 --- a/src/time-code.js +++ b/src/time-code.js @@ -1,10 +1,11 @@ export function timeCode(label, codeAsACallback) { - if (typeof performance === 'undefined') { - return codeAsACallback(); + if (typeof performance !== 'undefined' && + process.env.NODE_ENV === 'development') { + const start = performance.now(); + const result = codeAsACallback(); + const elapsed = Math.round(performance.now() - start); + console.log(`${label} took ${elapsed}ms to execute.`); + return result; } - const start = performance.now(); - const result = codeAsACallback(); - const elapsed = Math.round(performance.now() - start); - console.log(`${label} took ${elapsed}ms to execute.`); - return result; + return codeAsACallback(); }