| 2011 | } |
| 2012 | |
| 2013 | protected setBreakPointsRequest( |
| 2014 | r: DebugProtocol.SetBreakpointsResponse, |
| 2015 | a: DebugProtocol.SetBreakpointsArguments): Promise<void> { |
| 2016 | const doit = ( |
| 2017 | response: DebugProtocol.SetBreakpointsResponse, |
| 2018 | args: DebugProtocol.SetBreakpointsArguments, |
| 2019 | pendContinue: PendingContinue): Promise<void> => { |
| 2020 | return new Promise(async (resolve) => { |
| 2021 | const createBreakpoints = async () => { |
| 2022 | const currentBreakpoints = (this.breakpointMap.get(args.source.path) || []).map((bp) => bp.number); |
| 2023 | |
| 2024 | try { |
| 2025 | await this.miDebugger.removeBreakpoints(currentBreakpoints); |
| 2026 | for (const old of currentBreakpoints) { |
| 2027 | this.breakpointById.delete(old); |
| 2028 | } |
| 2029 | this.breakpointMap.set(args.source.path, []); |
| 2030 | |
| 2031 | const all: Array<Promise<OurSourceBreakpoint | MIError>> = []; |
| 2032 | const sourcepath = decodeURIComponent(args.source.path); |
| 2033 | |
| 2034 | if (sourcepath.startsWith('disassembly:/')) { |
| 2035 | let sidx = 13; |
| 2036 | if (sourcepath.startsWith('disassembly:///')) { sidx = 15; } |
| 2037 | const path = sourcepath.substring(sidx, sourcepath.length - 6); // Account for protocol and extension |
| 2038 | const parts = path.split(':::'); |
| 2039 | let func: string; |
| 2040 | let file: string; |
| 2041 | |
| 2042 | if (parts.length === 2) { |
| 2043 | func = parts[1]; |
| 2044 | file = parts[0]; |
| 2045 | } |
| 2046 | else { |
| 2047 | func = parts[0]; |
| 2048 | } |
| 2049 | |
| 2050 | const symbol: SymbolInformation = await this.disassember.getDisassemblyForFunction(func, file); |
| 2051 | |
| 2052 | if (symbol) { |
| 2053 | args.breakpoints.forEach((brk) => { |
| 2054 | if (brk.line <= symbol.instructions.length) { |
| 2055 | const line = symbol.instructions[brk.line - 1]; |
| 2056 | const arg: OurSourceBreakpoint = { |
| 2057 | ...brk, |
| 2058 | file: args.source.path, |
| 2059 | raw: line.address |
| 2060 | }; |
| 2061 | all.push(this.miDebugger.addBreakPoint(arg).catch((err: MIError) => err)); |
| 2062 | } else { |
| 2063 | all.push( |
| 2064 | Promise.resolve( |
| 2065 | new MIError( |
| 2066 | `${func} only contains ${symbol.instructions.length} instructions`, |
| 2067 | 'Set breakpoint' |
| 2068 | ) |
| 2069 | ) |
| 2070 | ); |