Quantcast
Channel: Planet Object Pascal
Viewing all articles
Browse latest Browse all 1725

The Wiert Corner - irregular stream of stuff: jpluimers

$
0
0

StackOverflow user User Sertac Akyuz posted a small Delphi snippet showing how to switch the Windows JIT debugger.

I’ll need to complete it somewhere, but since the concept is interesting, here is his answer:

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;

–jeroen

via: windows – Switching JIT debuggers? – Stack Overflow.


Filed under: .NET, Delphi, Development, Software Development, Visual Studio and tools

Viewing all articles
Browse latest Browse all 1725

Trending Articles