The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,676 other followers

Archive for December 3rd, 2013

Windows Development: Switching JIT debuggers (via: Stack Overflow)

Posted by jpluimers on 2013/12/03

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.

Posted in .NET, Delphi, Development, Software Development, Visual Studio and tools | Leave a Comment »

 
%d bloggers like this: