From d6c55d4aa878c0d84bb1343e133703026012e026 Mon Sep 17 00:00:00 2001 From: WebFreak001 Date: Tue, 9 Feb 2016 16:08:30 +0100 Subject: [PATCH] Checking if autorun exists & has items before iterating on it --- src/gdb.ts | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/gdb.ts b/src/gdb.ts index 20d5d43..0d8d644 100644 --- a/src/gdb.ts +++ b/src/gdb.ts @@ -83,9 +83,10 @@ class MI2DebugSession extends DebugSession { this.attached = false; this.needContinue = false; this.gdbDebugger.load(args.cwd, args.target).then(() => { - args.autorun.forEach(command => { - this.gdbDebugger.sendUserInput(command); - }); + if (args.autorun) + args.autorun.forEach(command => { + this.gdbDebugger.sendUserInput(command); + }); this.gdbDebugger.start().then(() => { this.sendResponse(response); }); @@ -98,17 +99,19 @@ class MI2DebugSession extends DebugSession { this.needContinue = true; if (args.remote) { this.gdbDebugger.connect(args.cwd, args.executable, args.target).then(() => { - args.autorun.forEach(command => { - this.gdbDebugger.sendUserInput(command); - }); + if (args.autorun) + args.autorun.forEach(command => { + this.gdbDebugger.sendUserInput(command); + }); this.sendResponse(response); }); } else { this.gdbDebugger.attach(args.cwd, args.executable, args.target).then(() => { - args.autorun.forEach(command => { - this.gdbDebugger.sendUserInput(command); - }); + if (args.autorun) + args.autorun.forEach(command => { + this.gdbDebugger.sendUserInput(command); + }); this.sendResponse(response); }); }