(libName, libStart, libEnd, libASLRSlide, processorFunc)
| 74 | } |
| 75 | |
| 76 | async parseVmSymbols(libName, libStart, libEnd, libASLRSlide, processorFunc) { |
| 77 | if (!this._isEnabled) return; |
| 78 | await this.loadSymbols(libName); |
| 79 | |
| 80 | let lastUnknownSize; |
| 81 | let lastAdded; |
| 82 | |
| 83 | let addEntry = (funcInfo) => { |
| 84 | // Several functions can be mapped onto the same address. To avoid |
| 85 | // creating zero-sized entries, skip such duplicates. |
| 86 | // Also double-check that function belongs to the library address space. |
| 87 | |
| 88 | if (lastUnknownSize && |
| 89 | lastUnknownSize.start < funcInfo.start) { |
| 90 | // Try to update lastUnknownSize based on new entries start position. |
| 91 | lastUnknownSize.end = funcInfo.start; |
| 92 | if ((!lastAdded || |
| 93 | !this.inRange(lastUnknownSize, lastAdded.start, lastAdded.end)) && |
| 94 | this.inRange(lastUnknownSize, libStart, libEnd)) { |
| 95 | processorFunc( |
| 96 | lastUnknownSize.name, lastUnknownSize.start, lastUnknownSize.end); |
| 97 | lastAdded = lastUnknownSize; |
| 98 | } |
| 99 | } |
| 100 | lastUnknownSize = undefined; |
| 101 | |
| 102 | if (funcInfo.end) { |
| 103 | // Skip duplicates that have the same start address as the last added. |
| 104 | if ((!lastAdded || lastAdded.start != funcInfo.start) && |
| 105 | this.inRange(funcInfo, libStart, libEnd)) { |
| 106 | processorFunc(funcInfo.name, funcInfo.start, funcInfo.end); |
| 107 | lastAdded = funcInfo; |
| 108 | } |
| 109 | } else { |
| 110 | // If a funcInfo doesn't have an end, try to match it up with the next |
| 111 | // entry. |
| 112 | lastUnknownSize = funcInfo; |
| 113 | } |
| 114 | } |
| 115 | |
| 116 | while (true) { |
| 117 | const funcInfo = this.parseNextLine(); |
| 118 | if (funcInfo === null) continue; |
| 119 | if (funcInfo === false) break; |
| 120 | if (funcInfo.start < libStart && |
| 121 | funcInfo.start < libEnd - libStart) { |
| 122 | funcInfo.start += libStart; |
| 123 | } else { |
| 124 | funcInfo.start += libASLRSlide; |
| 125 | } |
| 126 | if (funcInfo.size) { |
| 127 | funcInfo.end = funcInfo.start + funcInfo.size; |
| 128 | } |
| 129 | addEntry(funcInfo); |
| 130 | } |
| 131 | addEntry({ name: '', start: libEnd }); |
| 132 | } |
| 133 |
no test coverage detected