| 131 | } |
| 132 | |
| 133 | const char* CodeCache::binarySearch(const void* address) { |
| 134 | int low = 0; |
| 135 | int high = _count - 1; |
| 136 | |
| 137 | while (low <= high) { |
| 138 | int mid = (unsigned int)(low + high) >> 1; |
| 139 | if (_blobs[mid]._end <= address) { |
| 140 | low = mid + 1; |
| 141 | } else if (_blobs[mid]._start > address) { |
| 142 | high = mid - 1; |
| 143 | } else { |
| 144 | return _blobs[mid]._name; |
| 145 | } |
| 146 | } |
| 147 | |
| 148 | // Symbols with zero size can be valid functions: e.g. ASM entry points or kernel code. |
| 149 | // Also, in some cases (endless loop) the return address may point beyond the function. |
| 150 | if (low > 0 && (_blobs[low - 1]._start == _blobs[low - 1]._end || _blobs[low - 1]._end == address)) { |
| 151 | return _blobs[low - 1]._name; |
| 152 | } |
| 153 | return _name; |
| 154 | } |
| 155 | |
| 156 | const void* CodeCache::findSymbol(const char* name) { |
| 157 | CodeBlob* blob = findBlob(name); |
no outgoing calls
no test coverage detected