* Finds a code entry that contains the specified address. Both static and * dynamic code entries are considered. Returns the code entry and the offset * within the entry. * * @param {number} addr Address.
(addr)
| 197 | * @param {number} addr Address. |
| 198 | */ |
| 199 | findAddress(addr) { |
| 200 | const pageAddr = (addr / this.kPageSize) | this.kZero; |
| 201 | if (this.pages_.has(pageAddr)) { |
| 202 | // Static code entries can contain "holes" of unnamed code. |
| 203 | // In this case, the whole library is assigned to this address. |
| 204 | let result = this.findInTree_(this.statics_, addr); |
| 205 | if (result === null) { |
| 206 | result = this.findInTree_(this.libraries_, addr); |
| 207 | if (result === null) return null; |
| 208 | } |
| 209 | return {entry: result.value, offset: addr - result.key}; |
| 210 | } |
| 211 | const max = this.dynamics_.findMax(); |
| 212 | if (max === null) return null; |
| 213 | const min = this.dynamics_.findMin(); |
| 214 | if (addr >= min.key && addr < (max.key + max.value.size)) { |
| 215 | const dynaEntry = this.findInTree_(this.dynamics_, addr); |
| 216 | if (dynaEntry === null) return null; |
| 217 | // Dedupe entry name. |
| 218 | const entry = dynaEntry.value; |
| 219 | if (!entry.nameUpdated_) { |
| 220 | entry.name = this.dynamicsNameGen_.getName(entry.name); |
| 221 | entry.nameUpdated_ = true; |
| 222 | } |
| 223 | return {entry, offset: addr - dynaEntry.key}; |
| 224 | } |
| 225 | return null; |
| 226 | } |
| 227 | |
| 228 | /** |
| 229 | * Finds a code entry that contains the specified address. Both static and |
no test coverage detected