Debug vs Release in Delphi Build Configurations

In Delphi when we develop a software for any client first we create a Delphi project and then we add the required files like dfm, pas to the project. Then during the development process we  compile, debug and run the project several times to find and resolve issues. Once the development is done then we release the software to our client as an EXE file format for use. In Delphi IDE we prepare the EXE file from menu Project ->  Build option.


Compiling, Running and Building

When we develop an application, we compile, build, and run the application directly from the IDE. Compiling, running and building will produce the executable file.

Compiling does code syntax check and will compile the application with compiling the units that have changed since the last Build. Compiling produces DCU files.

Running compiles the code and runs the application. We can run with debugging (F9) or without debugging (Ctrl+Shift+F9). If run without debugging, then the debugger will not be invoked and debugging breakpoints will "not" work.

Building is an extension to compiling where all units even those not changed are compiled. When we change project options we should build.

The project build is depend on Build Configuration settings that we can see on "Project Manager" Window from View -> Project Manager option. In Delphi IDE the project manager window displays list of form, unit and resources file added to the project and project group and the Build Configurations section will show various build configurations we have for our project. We can activate a build configurations in Project Manager window and build our project, it will generate an EXE either the setting is Debug or Release



Then what is the difference between Debug and Release?

We should prepare a Build with using Debug configuration while we are developing, debugging and changing our application and Release configuration should be activated when we are building our application to be sent to the users for deployment.

Debug Configuration disables optimization and enables debugging, as well as setting specific syntax options.

Release Configuration is opposite. It enables optimization and disables debugging. 

But still there is some questions remain: What can we do while "debug" is active, what is included in the executable file and how does the executable look when "release" is applied?

The size of the EXE file prepared with using Release Build Configurations will be less in compared to EXE file prepared with using Debug Build Configurations because when we active release then Compiler does not produce symbolic debugging information the code is not generated for TRACE and ASSERT calls, meaning the size of executable is reduced.

Debug or Release Options

The default build configuration is Debug that we use for debugging during development is created by Delphi when we created a new application/project. To edit the build configuration: right-click the configuration name, select "Edit" from the context menu and you will find yourself looking at the Project Options dialog box.

Delphi Compiler 
    Compiling
Codegeneration
Optimization OFF - the compiler will NOT perform a number of code optimizations, such as placing variables in CPU registers, eliminating common subexpressions, and generating induction variables.
Stack Frames ON - stack frames are always generated for procedures and functions, even when they're not needed.
Debugging 
             Debug Information ON - when a program or unit is compiled with this option enabled, the integrated debugger lets you single-step and set breakpoints. Debug information being "on" does not affect the size or speed of the executable program - debug information is compiled into the DCUs and does not get linked into the executable.
            Local Symbols ON - When a program or unit is compiled with this option enabled, the integrated debugger lets you examine and modify the module's local variables. Local symbols being "on" does not affect the size or speed of the executable program.
               Use Debug .dcus On - Enables you to debug Delphi VCL source code and set a breakpoint in the VCL

Debug Options


Release Options



Comments

  1. Thank you for sharing this! What you have shared is very helpful and informative. Would love to see more updates from you.

    Website Development

    ReplyDelete

Post a Comment

Popular posts from this blog

ShellExecute in Delphi

How to send Email in Delphi?

Drawing Shapes in Delphi