Index: tools/codemap.js |
diff --git a/tools/codemap.js b/tools/codemap.js |
index 30cdc21db50160b3363cbc34131487003ae94492..df6770f9a88087e5daa62ac0dee433ed27fdaa92 100644 |
--- a/tools/codemap.js |
+++ b/tools/codemap.js |
@@ -175,23 +175,28 @@ CodeMap.prototype.isAddressBelongsTo_ = function(addr, node) { |
*/ |
CodeMap.prototype.findInTree_ = function(tree, addr) { |
var node = tree.findGreatestLessThan(addr); |
- return node && this.isAddressBelongsTo_(addr, node) ? node.value : null; |
+ return node && this.isAddressBelongsTo_(addr, node) ? node : null; |
}; |
/** |
* Finds a code entry that contains the specified address. Both static and |
- * dynamic code entries are considered. |
+ * dynamic code entries are considered. Returns the code entry and the offset |
+ * within the entry. |
* |
* @param {number} addr Address. |
*/ |
-CodeMap.prototype.findEntry = function(addr) { |
+CodeMap.prototype.findAddress = function(addr) { |
var pageAddr = addr >>> CodeMap.PAGE_ALIGNMENT; |
if (pageAddr in this.pages_) { |
// Static code entries can contain "holes" of unnamed code. |
// In this case, the whole library is assigned to this address. |
- return this.findInTree_(this.statics_, addr) || |
- this.findInTree_(this.libraries_, addr); |
+ var result = this.findInTree_(this.statics_, addr); |
+ if (!result) { |
+ result = this.findInTree_(this.libraries_, addr); |
+ if (!result) return null; |
+ } |
+ return { entry : result.value, offset : addr - result.key }; |
} |
var min = this.dynamics_.findMin(); |
var max = this.dynamics_.findMax(); |
@@ -199,17 +204,30 @@ CodeMap.prototype.findEntry = function(addr) { |
var dynaEntry = this.findInTree_(this.dynamics_, addr); |
if (dynaEntry == null) return null; |
// Dedupe entry name. |
- if (!dynaEntry.nameUpdated_) { |
- dynaEntry.name = this.dynamicsNameGen_.getName(dynaEntry.name); |
- dynaEntry.nameUpdated_ = true; |
+ var entry = dynaEntry.value; |
+ if (!entry.nameUpdated_) { |
+ entry.name = this.dynamicsNameGen_.getName(entry.name); |
+ entry.nameUpdated_ = true; |
} |
- return dynaEntry; |
+ return { entry : entry, offset : addr - dynaEntry.key }; |
} |
return null; |
}; |
/** |
+ * Finds a code entry that contains the specified address. Both static and |
+ * dynamic code entries are considered. |
+ * |
+ * @param {number} addr Address. |
+ */ |
+CodeMap.prototype.findEntry = function(addr) { |
+ var result = this.findAddress(addr); |
+ return result ? result.entry : null; |
+}; |
+ |
+ |
+/** |
* Returns a dynamic code entry using its starting address. |
* |
* @param {number} addr Address. |