()
| 231 | } |
| 232 | |
| 233 | public async setArchitecture(): Promise<void> { |
| 234 | const miNode = await this.miDebugger.sendCommand('interpreter-exec console "show architecture"', false, true); |
| 235 | const str = miNode.output; |
| 236 | let found = false; |
| 237 | // Some of this copied from MIEngine. Of course nothing other Arm-32 was tested |
| 238 | for (const line of str.toLowerCase().split('\n')) { |
| 239 | if (line.includes('x86-64')) { |
| 240 | this.Architecture = TargetArchitecture.X64; |
| 241 | this.minInstrSize = 1; |
| 242 | this.maxInstrSize = 26; |
| 243 | this.instrMultiple = 1; |
| 244 | } else if (line.includes('i386')) { |
| 245 | this.Architecture = TargetArchitecture.X86; |
| 246 | this.minInstrSize = 1; |
| 247 | this.maxInstrSize = 20; |
| 248 | this.instrMultiple = 1; |
| 249 | } else if (line.includes('arm64')) { |
| 250 | this.Architecture = TargetArchitecture.ARM64; |
| 251 | this.minInstrSize = 2; |
| 252 | this.maxInstrSize = 8; |
| 253 | this.instrMultiple = 2; |
| 254 | } else if (line.includes('aarch64')) { |
| 255 | this.Architecture = TargetArchitecture.ARM64; |
| 256 | this.minInstrSize = 2; |
| 257 | this.maxInstrSize = 8; |
| 258 | this.instrMultiple = 2; |
| 259 | } else if (line.includes('arm')) { |
| 260 | this.Architecture = TargetArchitecture.ARM; |
| 261 | this.minInstrSize = 2; |
| 262 | this.maxInstrSize = 4; |
| 263 | this.instrMultiple = 2; |
| 264 | } else if (line.includes('xtensa')) { |
| 265 | this.Architecture = TargetArchitecture.XTENSA; |
| 266 | this.minInstrSize = 1; |
| 267 | this.maxInstrSize = 128 / 8; // Yes, ridiculously large due to their long instructions |
| 268 | this.instrMultiple = 1; |
| 269 | } else { |
| 270 | continue; |
| 271 | } |
| 272 | found = true; |
| 273 | break; |
| 274 | } |
| 275 | if (!found) { |
| 276 | this.handleMsg('log', 'Warning: Unknown architecture for disassembly. Results may not be accurate at edge of memories\n' + |
| 277 | ` Gdb command "show architecture" shows "${str}"\n`); |
| 278 | this.Architecture = TargetArchitecture.UNKNOWN; |
| 279 | this.minInstrSize = 1; |
| 280 | this.maxInstrSize = 26; |
| 281 | this.instrMultiple = 1; |
| 282 | } else if (this.Architecture !== TargetArchitecture.ARM) { |
| 283 | this.handleMsg('log', `Info: Untested architecture for disassembly: Gdb command "show architecture" shows "${str}"\n`); |
| 284 | } |
| 285 | } |
| 286 | |
| 287 | private async getMemoryRegions() { |
| 288 | if (this.memoryRegions) { |
no test coverage detected