| 31 | |
| 32 | // This is the work horse. Do not call it if the panel is in disabled state. |
| 33 | public async onStopped(frameId: number): Promise<void> { |
| 34 | return new Promise<void>(async (resolve, reject) => { |
| 35 | this.lastFrameId = frameId; |
| 36 | const doRefresh = () => { |
| 37 | if (this.rtos) { |
| 38 | this.htmlContent.html = '<p>Failed to get RTOS information. Please report an issue if RTOS is actually running</p>\n'; |
| 39 | this.htmlContent.css = ''; |
| 40 | this.rtos.onStopped(frameId).then(() => { |
| 41 | this.htmlContent = this.rtos.getHTML(); |
| 42 | resolve(); |
| 43 | }); |
| 44 | } else { |
| 45 | this.triedAndFailed = true; |
| 46 | this.htmlContent.html = ''; |
| 47 | this.htmlContent.css = ''; |
| 48 | resolve(); |
| 49 | } |
| 50 | }; |
| 51 | |
| 52 | if (this.rtos === undefined && this.allRTOSes.length > 0) { |
| 53 | // Let them all work in parallel. Since this will generate a ton of gdb traffic and traffic from other sources |
| 54 | // like variable, watch windows, things can fail. But our own backend queues things up so failures are unlikely |
| 55 | // With some other backend (if for instance we support cppdbg), not sure what happens. Worst case, try one OS |
| 56 | // at a time. |
| 57 | const promises = []; |
| 58 | for (const rtos of this.allRTOSes) { |
| 59 | promises.push(rtos.tryDetect(frameId)); |
| 60 | } |
| 61 | |
| 62 | Promise.all(promises).then((results) => { |
| 63 | for (const rtos of results) { |
| 64 | if (rtos.status === 'failed') { |
| 65 | const ix = this.allRTOSes.findIndex((v) => v === rtos); |
| 66 | this.allRTOSes.splice(ix, 1); |
| 67 | if (this.allRTOSes.length === 0) { |
| 68 | doRefresh(); |
| 69 | break; |
| 70 | } |
| 71 | } else if (rtos.status === 'initialized') { |
| 72 | this.allRTOSes = []; |
| 73 | this.rtos = rtos; |
| 74 | doRefresh(); |
| 75 | break; |
| 76 | } |
| 77 | } |
| 78 | if (this.allRTOSes.length > 0) { |
| 79 | // Some RTOSes have not finished detection |
| 80 | this.htmlContent.html = '<p>RTOS detection in progress...</p>\n'; |
| 81 | this.htmlContent.css = ''; |
| 82 | resolve(); |
| 83 | } |
| 84 | }); |
| 85 | } else { |
| 86 | doRefresh(); |
| 87 | } |
| 88 | }); |
| 89 | } |
| 90 | |