Fix crash in threadsRequest with no miDebugger, and undefined thread names
This commit is contained in:
parent
596674fb59
commit
a7b89c3569
3 changed files with 26 additions and 7 deletions
|
|
@ -13,7 +13,8 @@ export interface Breakpoint {
|
|||
|
||||
export interface Thread {
|
||||
id: number;
|
||||
name: string;
|
||||
targetId: string;
|
||||
name?: string;
|
||||
}
|
||||
|
||||
export interface Stack {
|
||||
|
|
|
|||
|
|
@ -598,12 +598,17 @@ export class MI2 extends EventEmitter implements IBackend {
|
|||
let threads = result.result("threads");
|
||||
let ret: Thread[] = [];
|
||||
return threads.map(element => {
|
||||
let id = parseInt(MINode.valueOf(element, "id"));
|
||||
let name = MINode.valueOf(element, "name") + "";
|
||||
return {
|
||||
id,
|
||||
name
|
||||
let ret : Thread = {
|
||||
id: parseInt(MINode.valueOf(element, "id")),
|
||||
targetId: MINode.valueOf(element, "target-id")
|
||||
};
|
||||
|
||||
let name = MINode.valueOf(element, "name");
|
||||
if (name) {
|
||||
ret.name = name;
|
||||
}
|
||||
|
||||
return ret;
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -235,6 +235,8 @@ export class MI2DebugSession extends DebugSession {
|
|||
Promise.all(all).then(brkpoints => {
|
||||
let finalBrks = [];
|
||||
brkpoints.forEach(brkp => {
|
||||
// TODO: Currently all breakpoints returned are marked as verified,
|
||||
// which leads to verified breakpoints on a broken lldb.
|
||||
if (brkp[0])
|
||||
finalBrks.push(new DebugAdapter.Breakpoint(true, brkp[1].line));
|
||||
});
|
||||
|
|
@ -256,13 +258,24 @@ export class MI2DebugSession extends DebugSession {
|
|||
}
|
||||
|
||||
protected threadsRequest(response: DebugProtocol.ThreadsResponse): void {
|
||||
if (!this.miDebugger) {
|
||||
this.sendResponse(response);
|
||||
}
|
||||
this.miDebugger.getThreads().then(
|
||||
threads => {
|
||||
response.body = {
|
||||
threads: []
|
||||
};
|
||||
for (const thread of threads) {
|
||||
response.body.threads.push(new Thread(thread.id, thread.id + ":" + thread.name));
|
||||
let threadName = thread.name;
|
||||
// TODO: Thread names are undefined on LLDB
|
||||
if (threadName === undefined) {
|
||||
threadName = thread.targetId;
|
||||
}
|
||||
if (threadName === undefined) {
|
||||
threadName = "<unnamed>";
|
||||
}
|
||||
response.body.threads.push(new Thread(thread.id, thread.id + ":" + threadName));
|
||||
}
|
||||
this.sendResponse(response);
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue