When you have to maintain different projects with different IDEs, it often makes sense to install them on the same Windows machine.
For instance, mix Visual Studio and Delphi, or various versions of Delphi on the same system (I'm sure others have even different combinations).
One of the things you will find there is that the latest tool installs itself as JIT debugger: the just-in-time debugger that fires when an app crashes.
Depending in which tool and version that app crashed (sometimes you cannot reproduce bugs when running inside the debugger, for instance in case of a Heisenbug), you want to select the debugger in advance.
How can you do that?
Write a simple application that would launch the debugger you want in case of an application crash.
Register your app in
HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AeDebug
In case of an 64bit OS, also to the following key
HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows NT\CurrentVersion\AeDebug
add/modify the string named Debugger
with value:
"C:..\Win32\Debug\Project1.exe" %ld %ld
A very simple application:
procedure TForm1.FormCreate(Sender: TObject);
begin
ComboBox1.Items.Add('BDS 16');
ComboBox1.Items.Add('BDS 15');
ComboBox1.Items.Add('WinDbg');
ComboBox1.Items.Add('VS');
// etc..
ComboBox1.ItemIndex := 0;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
proc: THandle;
begin
Assert(ParamCount >= 2);
proc := OpenProcess(SYNCHRONIZE, False, StrToInt(ParamStr(1)));
case ComboBox1.ItemIndex of
0: ShellExecute(0, '', 'C:\..\RAD Studio\9.0\bin\bds.exe',
PChar(Format('/attach:%s;%s', [ParamStr(1), ParamStr(2)])), '',
SW_SHOWNORMAL);
1 : // etc..
2: ShellExecute(0, '', 'C:\Program Files (x86)\..\windbg.exe',
PChar(Format('-p %s -e %s -g', [ParamStr(1), ParamStr(2)])), '',
SW_SHOWNORMAL);
3: ShellExecute(0, '', 'C:\Windows\system32\VSJitDebugger.exe',
PChar(Format('-p %s -e %s', [ParamStr(1), ParamStr(2)])), '',
SW_SHOWNORMAL);
//..
end;
if Bool(proc) then begin
WaitForSingleObject(proc, INFINITE);
Application.Terminate;
end;
end;
If you search Microsoft documentation, you can see that postmortem debugging can be controlled via registry key under \HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\AeDebug
http://msdn.microsoft.com/en-us/library/windows/hardware/ff542967(v=vs.85).aspx
You need to pay special attention if you want to manually change it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With