diff --git a/ChangeLog b/ChangeLog index 9711b1b..59a7fb8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2016-05-15 Riccardo Mottola + + * Modules/Debuggers/ProjectCenter/PCDebugger.m + On windows kill with DebugBreakProcess() and not tskill. Available only on WinXP or higher. + 2016-05-05 15:43-EDT Gregory John Casamento * Modules/Debuggers/ProjectCenter/PipeDelegate.m: Minor changes. diff --git a/Modules/Debuggers/ProjectCenter/PCDebugger.m b/Modules/Debuggers/ProjectCenter/PCDebugger.m index 1f148f5..5103d04 100644 --- a/Modules/Debuggers/ProjectCenter/PCDebugger.m +++ b/Modules/Debuggers/ProjectCenter/PCDebugger.m @@ -29,6 +29,15 @@ #import "PCDebuggerViewDelegateProtocol.h" #import "PipeDelegate.h" +#ifdef __MINGW32__ +#undef _WIN32_WINNT +#define _WIN32_WINNT 0x0501 // Minimal target is Windows XP + +#include +#include +WINBASEAPI BOOL WINAPI DebugBreakProcess(HANDLE); +#endif + #ifndef NOTIFICATION_CENTER #define NOTIFICATION_CENTER [NSNotificationCenter defaultCenter] #endif @@ -239,16 +248,25 @@ static NSImage *downImage = nil; #ifndef __MINGW32__ kill(subProcessId,SIGINT); #else - // on windows we run tskill as a shell command - NSTask *t; - NSArray *args; - - args = [NSArray arrayWithObjects:[NSString stringWithFormat:@"%d", subProcessId], nil]; - t = [NSTask new]; - [t setArguments: args]; - [t setLaunchPath:@"tskill.exe"]; - [t launch]; - [t release]; + HANDLE proc; + NSLog(@"Windows - sending interrupt to %d", subProcessId); + proc = OpenProcess(PROCESS_ALL_ACCESS, FALSE, (DWORD)subProcessId); + if (proc == NULL) + { + DWORD lastError = GetLastError(); + NSLog(@"error opening process %lu", (unsigned long)lastError); + return; + } + if (DebugBreakProcess(proc)) + { + DWORD lastError = GetLastError(); + NSLog(@"error sending break %lu", (unsigned long)lastError); + } + else + { + NSLog(@"break sent successfully"); + } + CloseHandle(proc); #endif } }