Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to skip assembly code when debugging in Delphi?

Tags:

delphi

Sometimes when debugging, specifically when catching an exception and following through destructors called, Delphi steps through a lot of assembly code. Hit Shift+F8 appears to cause mayhem.

Can I tell the debugger to skip assembly code automatically?

like image 764
Eric G Avatar asked Oct 12 '11 20:10

Eric G


People also ask

How do I debug an assembler code?

You start debugging by clicking Start Debugging on the Debug menu. On the Start Debugging dialog box, check Enable Assembler debugging, then click OK. If you debug the module again during the same session, you can start it by clicking Start Debugging, Run or Debug.

How do I skip a step while debugging in Visual Studio?

You can also click on the line you want to skip to and hit Ctrl+F10 (Run to Cursor). It will jump directly to that line.

How do I debug Delphi code?

Debugging delphi source files You need to go to "project->options->compiler" on this tab you need to check the "use debug DCUs". After that you need to build your project again and you can run your application. From now on breakpoints also stop in Delphi source files.


2 Answers

In my experience, the vast majority of such assembly code is in VCL or RTL units.

If you compile with "Debug .dcu's" disabled then the debugger will not step through this code. However, it will also not step through any other VCL/RTL code either - assembler or Pascal. It will still step through any code that is not part of the VCL/RTL, assuming you have the Debug information option enabled for the project.

Compiler options dialog

Whether turning off VCL/RTL debug units makes debugging any particular issue you may have easier or harder will of course depend on your particular circumstances, but usually what is going on inside the VCL/RTL code is of little consequence unless and until you have eliminated the possibility of some error in your own code and then need to investigate a potential bug in the VCL/RTL itself.

For myself, I have "Debug .dcus" turned OFF unless I need them ON.

Your mileage may vary.

like image 197
Deltics Avatar answered Sep 22 '22 11:09

Deltics


If you see assembler code, you probably are in the Alt-F2 CPU view. Just close the CPU view (escape key on old Delphi, or close its tabs), and you'll continue stepping within pascal source code (e.g. press F7 or F8).

If you see assembler code in the middle of a .pas file (in an asm ... end block), then you can try going to the end of it (at end level) and press F4 (shift F8 is buggy). But be aware that it may quit not at the end but in an internal ret assembler op code. So my personal advice is, if you do not know about assembler, to display the Call Stack (this window displays the function calls that brought you to your current program location and the arguments passed to each function call) and double-click on the parent caller. This will be always safe.

For additional info about debugging, this e.g. this article.

like image 21
Arnaud Bouchez Avatar answered Sep 18 '22 11:09

Arnaud Bouchez