Jump to content
aehimself

Step-by-step debugging exceptions

Recommended Posts

Hello,

 

I was just wondering if this is "normal" or just an anomaly on my side. Consider the following code:

Quote

procedure TForm1.Button1Click(Sender: TObject);
Var
 sl: TStringList;
begin
 Try
  sl.Add('Hello');
 Except
  On E:Exception Do Begin
                    ShowMessage(E.Message);
                    End;
 End;
end;

Set a breakpoint on sl.Add and execute. When the execution stops, press F8. However the Except block executes, the Delphi debugger does not continue the step-by-step debugging. I know, you can put a breakpoint on On E:Exception but it would be a lot nicer to see how the exception is flowing (especially through 5-10 units until it reaches the final handler).

 

Is there a way to achieve this or it's just a limitation of the debugger?

 

Cheers!

Share this post


Link to post

Are you sure F8 is the right hotkey? I think in your case, it should be Shift+F8 (run until return).

Also, TStringList is from Delphis default RTL. Be sure to have "With Debug DCU files" checked in your project or you cannot have breakpoints in there.

  • Like 1

Share this post


Link to post
5 hours ago, Der schöne Günther said:

Are you sure F8 is the right hotkey? I think in your case, it should be Shift+F8 (run until return).

Also, TStringList is from Delphis default RTL. Be sure to have "With Debug DCU files" checked in your project or you cannot have breakpoints in there.

Shift-F8 will return at the end of the calling method, in this case the OnClick handler. It will NOT put you inside the Except block in any case.

As for TStringList, I just chose something random, you can even put

Raise Exception.Create('hello world');

instead. Also, I believe that when you try to access an uninitialized object it does not matter where it comes from, as it does not exist...

 

I am afraid that @Fr0sT.Brutal will be right, and this - too - is going to be a limitation of the IDE.

 

Too bad 🙂

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×