(functionName: string, file?: string)
| 958 | } |
| 959 | |
| 960 | public async getDisassemblyForFunction(functionName: string, file?: string): Promise<SymbolInformation> { |
| 961 | const symbol: SymbolInformation = this.gdbSession.symbolTable.getFunctionByName(functionName, file); |
| 962 | |
| 963 | if (!symbol) { throw new Error(`Unable to find function with name ${functionName}.`); } |
| 964 | |
| 965 | if (symbol.instructions) { return symbol; } |
| 966 | |
| 967 | const startAddress = symbol.address; |
| 968 | const endAddress = symbol.address + symbol.length; |
| 969 | |
| 970 | // tslint:disable-next-line:max-line-length |
| 971 | const result = await this.miDebugger.sendCommand(`data-disassemble -s ${hexFormat(startAddress)} -e ${hexFormat(endAddress)} -- 2`); |
| 972 | const rawInstructions = result.result('asm_insns'); |
| 973 | const instructions: DisassemblyInstruction[] = rawInstructions.map((ri) => { |
| 974 | const address = MINode.valueOf(ri, 'address'); |
| 975 | const functionName = MINode.valueOf(ri, 'func-name'); |
| 976 | const offset = parseInt(MINode.valueOf(ri, 'offset')); |
| 977 | const inst = MINode.valueOf(ri, 'inst'); |
| 978 | const opcodes = MINode.valueOf(ri, 'opcodes'); |
| 979 | |
| 980 | return { |
| 981 | address: address, |
| 982 | functionName: functionName, |
| 983 | offset: offset, |
| 984 | instruction: inst, |
| 985 | opcodes: opcodes |
| 986 | }; |
| 987 | }); |
| 988 | symbol.instructions = instructions; |
| 989 | return symbol; |
| 990 | } |
| 991 | |
| 992 | private async getDisassemblyForAddresses(startAddress: number, length: number): Promise<DisassemblyInstruction[]> { |
| 993 | const endAddress = startAddress + length; |
no test coverage detected