Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exception location in DelphiXE not correctly located in the debugger?

The debugger does not locate the line of the exception, its either to deep or to late.

Code:

procedure LoadLogo;
const
  RES_APP_LOGO = 'AppAboutLogo';
var
  resourceStream : TResourceStream;
begin
  try
    resourceStream := TResourceStream.Create( HInstance, RES_APP_LOGO, RES_TYPE_FXRESOURCES );
    resourceStream.Position := 0;
    ImageLogo.Picture.Bitmap.LoadFromStream(resourceStream); //---> causes exception (A)
    Refresh();
  finally
    FreeAndNil(resourceStream);    
  end;
end;

procedure TForm.Initialize;
begin

  //do something....

  LoadLogo(); //(C)

  AnotherFunction();  //<----- debugger points here (B)

end; 

procedure TForm.CreateCreate(Sender : TObject);
begin
  Initialize();
end;

On an exception at location (A), with "Use Debug DCUs" = false, the debugger points to (B), the line outside the function called after the exception occurred. With "Use Debug DCUs = true", it breaks in a generic Exception thrower in Graphics.pas. The exception class is fine, the location is not correct or useful from a debugging perspective - neither the calling location (C) nor the real cause point (A) is located.

This requires looking at the call stack to step back to the cause which does not seem right.

Any ideas?

like image 914
MX4399 Avatar asked Dec 12 '25 15:12

MX4399


1 Answers

When you are using debug DCUs you need to use the call stack to see how execution reached the throw. There's no way for the debugger to break any earlier than the point at which the exception is raised.

Without debug DCUs the debugger can only break at a line of code for which it has debug information. That has to be somewhere in your code.

like image 71
David Heffernan Avatar answered Dec 14 '25 05:12

David Heffernan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!