[tools] Map search bar feature added, map id changed from int to string

Change-Id: Icc37fc091086a3239a1b080ca2829efcda97f328
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2245601
Commit-Queue: Sathya Gunasekaran  <gsathya@chromium.org>
Reviewed-by: Camillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#68406}
This commit is contained in:
zeynepCankara 2020-06-18 12:47:13 +03:00 committed by Commit Bot
parent 79ed10cfb1
commit af5f156d40
4 changed files with 63 additions and 12 deletions

View File

@ -216,3 +216,4 @@ Zhongping Wang <kewpie.w.zp@gmail.com>
柳荣一 <admin@web-tinker.com> 柳荣一 <admin@web-tinker.com>
Yanbo Li <lybvinci@gmail.com> Yanbo Li <lybvinci@gmail.com>
Gilang Mentari Hamidy <gilang@hamidy.net> Gilang Mentari Hamidy <gilang@hamidy.net>
Zeynep Cankara <zeynepcankara402@gmail.com>

View File

@ -337,8 +337,15 @@ code is governed by a BSD-style license that can be found in the LICENSE file.
details.style.display = display; details.style.display = display;
} }
function removeOptions(selectElement) {
while(selectElement.options.length > 0) {
selectElement.remove(0);
}
}
function initGroupKeySelect() { function initGroupKeySelect() {
let select = document.getElementById("group-key"); let select = document.getElementById("group-key");
removeOptions(select);
for (let i in properties) { for (let i in properties) {
let option = document.createElement("option"); let option = document.createElement("option");
option.text = properties[i]; option.text = properties[i];

View File

@ -369,6 +369,10 @@ dd {
z-index: 100; z-index: 100;
display: none; display: none;
} }
#searchBarInput {
width: 200px;
}
</style> </style>
<script src="./splaytree.js"></script> <script src="./splaytree.js"></script>
<script src="./codemap.js"></script> <script src="./codemap.js"></script>
@ -503,8 +507,23 @@ define(Array.prototype, "histogram", function(mapFn) {
return histogram; return histogram;
}); });
// ========================================================================= // =========================================================================
// EventHandlers // EventHandlers
function handleSearchBar(){
let searchBar = $('searchBarInput');
let searchBarInput = searchBar.value;
let selectedMap = V8Map.get(searchBarInput);
//removeAllChildren($('mapIdList'));
if(selectedMap){
let map = selectedMap;
document.state.map = map;
searchBar.className = "green";
} else {
searchBar.className = "red";
}
}
function handleBodyLoad() { function handleBodyLoad() {
let upload = $('fileReader'); let upload = $('fileReader');
upload.onclick = (e) => $("file").click(); upload.onclick = (e) => $("file").click();
@ -1253,6 +1272,15 @@ function transitionTypeToColor(type) {
<section id="transitionView"></section> <section id="transitionView"></section>
<br/> <br/>
<h2>Search Map by Address</h2>
<section id="searchBar"></section>
<input type="search" id="searchBarInput" placeholder="Search maps by address..">
<button onclick="handleSearchBar()">Search</button>
<ul id="mapIdList" title="Map Id List">
</ul>
<h2>Selected Map</h2> <h2>Selected Map</h2>
<section id="mapDetails"></section> <section id="mapDetails"></section>
</div> </div>

View File

@ -43,17 +43,17 @@ class MapProcessor extends LogReader {
processor: this.processFunctionMove processor: this.processFunctionMove
}, },
'map-create': { 'map-create': {
parsers: [parseInt, parseInt, parseString], parsers: [parseInt, parseString],
processor: this.processMapCreate processor: this.processMapCreate
}, },
'map': { 'map': {
parsers: [parseString, parseInt, parseInt, parseInt, parseInt, parseInt, parsers: [parseString, parseInt, parseString, parseString, parseInt, parseInt,
parseString, parseString, parseString parseString, parseString, parseString
], ],
processor: this.processMap processor: this.processMap
}, },
'map-details': { 'map-details': {
parsers: [parseInt, parseInt, parseString], parsers: [parseInt, parseString, parseString],
processor: this.processMapDetails processor: this.processMapDetails
} }
}; };
@ -183,17 +183,16 @@ class MapProcessor extends LogReader {
this.getExistingMap(id, time).deprecate(); this.getExistingMap(id, time).deprecate();
} }
processMapCreate(time, id, string) { processMapCreate(time, id) {
// map-create events might override existing maps if the addresses get // map-create events might override existing maps if the addresses get
// rcycled. Hence we do not check for existing maps. // recycled. Hence we do not check for existing maps.
let map = this.createMap(id, time); let map = this.createMap(id, time);
map.description = string;
} }
processMapDetails(time, id, string) { processMapDetails(time, id, string) {
//TODO(cbruni): fix initial map logging. //TODO(cbruni): fix initial map logging.
let map = this.getExistingMap(id, time); let map = this.getExistingMap(id, time);
if (!map.description) map.description = string; map.description = string;
} }
createMap(id, time) { createMap(id, time) {
@ -203,8 +202,8 @@ class MapProcessor extends LogReader {
} }
getExistingMap(id, time) { getExistingMap(id, time) {
if (id === 0) return undefined; if (id === "0x000000000000") return undefined;
let map = V8Map.get(id); let map = V8Map.get(id, time);
if (map === undefined) { if (map === undefined) {
console.error("No map details provided: id=" + id); console.error("No map details provided: id=" + id);
// Manually patch in a map to continue running. // Manually patch in a map to continue running.
@ -332,18 +331,34 @@ class V8Map {
return parents; return parents;
} }
static get(id) {
return this.cache.get(id); static get(id, time = undefined) {
let maps = this.cache.get(id);
if(maps){
for (let i = 0; i < maps.length; i++) {
//TODO: Implement time based map search
if(maps[i].time === time){
return maps[i];
}
}
// default return the latest
return maps[maps.length-1];
}
} }
static set(id, map) { static set(id, map) {
this.cache.set(id, map); if(this.cache.has(id)){
this.cache.get(id).push(map);
} else {
this.cache.set(id, [map]);
}
} }
} }
V8Map.cache = new Map(); V8Map.cache = new Map();
// =========================================================================== // ===========================================================================
class Edge { class Edge {
constructor(type, name, reason, time, from, to) { constructor(type, name, reason, time, from, to) {