From 640abf822bb000647249d2a029f166a52c8d75de Mon Sep 17 00:00:00 2001 From: WebFreak001 Date: Mon, 8 Aug 2016 17:56:20 +0200 Subject: [PATCH] Added showDevDebugOutput option to debug GDB calls --- package.json | 42 ++++++++++++++++++++++++++++++++++++------ src/backend/mi2/mi2.ts | 4 +++- src/gdb.ts | 4 ++++ src/lldb.ts | 4 ++++ src/mago.ts | 4 ++++ 5 files changed, 51 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index c445fea..cf06c4f 100644 --- a/package.json +++ b/package.json @@ -79,7 +79,12 @@ }, "printCalls": { "type": "boolean", - "description": "Prints all GDB calls to console", + "description": "Prints all GDB calls to the console", + "default": false + }, + "showDevDebugOutput": { + "type": "boolean", + "description": "Prints all GDB responses to the console", "default": false }, "autorun": { @@ -165,7 +170,12 @@ }, "printCalls": { "type": "boolean", - "description": "Prints all GDB calls to console", + "description": "Prints all GDB calls to the console", + "default": false + }, + "showDevDebugOutput": { + "type": "boolean", + "description": "Prints all GDB responses to the console", "default": false }, "executable": { @@ -257,7 +267,12 @@ }, "printCalls": { "type": "boolean", - "description": "Prints all lldb calls to console", + "description": "Prints all lldb calls to the console", + "default": false + }, + "showDevDebugOutput": { + "type": "boolean", + "description": "Prints all lldb responses to the console", "default": false }, "autorun": { @@ -338,7 +353,12 @@ }, "printCalls": { "type": "boolean", - "description": "Prints all LLDB calls to console", + "description": "Prints all LLDB calls to the console", + "default": false + }, + "showDevDebugOutput": { + "type": "boolean", + "description": "Prints all LLDB responses to the console", "default": false }, "executable": { @@ -409,7 +429,12 @@ }, "printCalls": { "type": "boolean", - "description": "Prints all mago calls to console", + "description": "Prints all mago calls to the console", + "default": false + }, + "showDevDebugOutput": { + "type": "boolean", + "description": "Prints all mago responses to the console", "default": false }, "autorun": { @@ -430,7 +455,12 @@ }, "printCalls": { "type": "boolean", - "description": "Prints all mago calls to console", + "description": "Prints all mago calls to the console", + "default": false + }, + "showDevDebugOutput": { + "type": "boolean", + "description": "Prints all mago responses to the console", "default": false }, "executable": { diff --git a/src/backend/mi2/mi2.ts b/src/backend/mi2/mi2.ts index 147f3cd..0b6f9dc 100644 --- a/src/backend/mi2/mi2.ts +++ b/src/backend/mi2/mi2.ts @@ -275,7 +275,8 @@ export class MI2 extends EventEmitter implements IBackend { } else { let parsed = parseMI(line); - //this.log("log", JSON.stringify(parsed)); + if (this.debugOutput) + this.log("log", "GDB -> App: " + JSON.stringify(parsed)); let handled = false; if (parsed.token !== undefined) { if (this.handlers[parsed.token]) { @@ -617,6 +618,7 @@ export class MI2 extends EventEmitter implements IBackend { } printCalls: boolean; + debugOutput: boolean; protected isSSH: boolean; protected sshReady: boolean; protected currentToken: number = 1; diff --git a/src/gdb.ts b/src/gdb.ts index 3818915..ef7181d 100644 --- a/src/gdb.ts +++ b/src/gdb.ts @@ -13,6 +13,7 @@ export interface LaunchRequestArguments { autorun: string[]; ssh: SSHArguments; printCalls: boolean; + showDevDebugOutput: boolean; } export interface AttachRequestArguments { @@ -23,6 +24,7 @@ export interface AttachRequestArguments { remote: boolean; autorun: string[]; printCalls: boolean; + showDevDebugOutput: boolean; } class GDBDebugSession extends MI2DebugSession { @@ -47,6 +49,7 @@ class GDBDebugSession extends MI2DebugSession { this.crashed = false; this.debugReady = false; this.miDebugger.printCalls = !!args.printCalls; + this.miDebugger.debugOutput = !!args.showDevDebugOutput; if (args.ssh !== undefined) { if (args.ssh.forwardX11 === undefined) args.ssh.forwardX11 = true; @@ -113,6 +116,7 @@ class GDBDebugSession extends MI2DebugSession { this.isSSH = false; this.debugReady = false; this.miDebugger.printCalls = !!args.printCalls; + this.miDebugger.debugOutput = !!args.showDevDebugOutput; if (args.remote) { this.miDebugger.connect(args.cwd, args.executable, args.target).then(() => { if (args.autorun) diff --git a/src/lldb.ts b/src/lldb.ts index 9960737..6e3be40 100644 --- a/src/lldb.ts +++ b/src/lldb.ts @@ -12,6 +12,7 @@ export interface LaunchRequestArguments { autorun: string[]; ssh: SSHArguments; printCalls: boolean; + showDevDebugOutput: boolean; } export interface AttachRequestArguments { @@ -21,6 +22,7 @@ export interface AttachRequestArguments { executable: string; autorun: string[]; printCalls: boolean; + showDevDebugOutput: boolean; } class LLDBDebugSession extends MI2DebugSession { @@ -43,6 +45,7 @@ class LLDBDebugSession extends MI2DebugSession { this.crashed = false; this.debugReady = false; this.miDebugger.printCalls = !!args.printCalls; + this.miDebugger.debugOutput = !!args.showDevDebugOutput; if (args.ssh !== undefined) { if (args.ssh.forwardX11 === undefined) args.ssh.forwardX11 = true; @@ -101,6 +104,7 @@ class LLDBDebugSession extends MI2DebugSession { this.isSSH = false; this.debugReady = false; this.miDebugger.printCalls = !!args.printCalls; + this.miDebugger.debugOutput = !!args.showDevDebugOutput; this.miDebugger.attach(args.cwd, args.executable, args.target).then(() => { if (args.autorun) args.autorun.forEach(command => { diff --git a/src/mago.ts b/src/mago.ts index 0e6de39..9eea6d4 100644 --- a/src/mago.ts +++ b/src/mago.ts @@ -11,6 +11,7 @@ export interface LaunchRequestArguments { arguments: string; autorun: string[]; printCalls: boolean; + showDevDebugOutput: boolean; } export interface AttachRequestArguments { @@ -20,6 +21,7 @@ export interface AttachRequestArguments { executable: string; autorun: string[]; printCalls: boolean; + showDevDebugOutput: boolean; } class MagoDebugSession extends MI2DebugSession { @@ -50,6 +52,7 @@ class MagoDebugSession extends MI2DebugSession { this.crashed = false; this.debugReady = false; this.miDebugger.printCalls = !!args.printCalls; + this.miDebugger.debugOutput = !!args.showDevDebugOutput; this.miDebugger.load(args.cwd, args.target, args.arguments, undefined).then(() => { if (args.autorun) args.autorun.forEach(command => { @@ -76,6 +79,7 @@ class MagoDebugSession extends MI2DebugSession { this.isSSH = false; this.debugReady = false; this.miDebugger.printCalls = !!args.printCalls; + this.miDebugger.debugOutput = !!args.showDevDebugOutput; this.miDebugger.attach(args.cwd, args.executable, args.target).then(() => { if (args.autorun) args.autorun.forEach(command => {