Debugger Module and running a program

Get help with the installation and running of the Zeus IDE. Please do not post bug reports or feature requests here. When in doubt post your question here.
Post Reply
Dataflex
Posts: 11
Joined: Fri Sep 22, 2023 9:46 am

Debugger Module and running a program

Post by Dataflex »

I am compiling Free Pascal code. I don't see anyway to execute it (without the debugger)?

In trying to use the debugger (which I have set to be gdb and put in the directory and path) I am getting this error:
---------------------------------------------------------------------------------------------------
No debugger module has been defined for the currently active project.

NOTE: Use the Debugger, Options menu to define a debugger module and
the Configure button, then Help button for more details.
----------------------------------------------------------------------------------------------------

If I go to Debugger, Options, I don't see the words "debugger module". (I have filled in "Executable" and "Directory" under the Debugging tab) There is no help for that dialog box and I don't get a result from "Quick Search" on "debugger module". Not sure what I am supposed to do.
Last edited by Dataflex on Sat Sep 23, 2023 7:57 am, edited 1 time in total.
jussij
Site Admin
Posts: 2650
Joined: Fri Aug 13, 2004 5:10 pm

Re: Debugger Module and running a program

Post by jussij »

In the Workspace setting there is a Debugger page. While that page integrates to the gdb.exe debugger, I does not need to be used and I would recommend not using this feature, only because gdb does not work well on Windows, and only works for certain compilers.

Setting up Workspace
Consider a very simple example on how to setup a Zeus workspace.

I have a single MyProgram.c file as shown below:

Code: Select all

#include <stdio.h>

int main(int argc, char *argv[]) {
    puts("Hello, World");

    for (int i = 0; i < argc; ++i) {
      puts(argv[i]);
    }
    return 0;
}
I use the Workspace, Open Folder menu option to create a workspace for that file, by opening the folder location of the file.

NOTE: Obviously the other Workspace create methods can also be used. In this case the Workspace, Open Folder option was used as it is by far the easiest method to create a workspace.

Here is the workspace created using this menu. Notice that the name of the folder, which in this case was the folder C, is used to name of the project and the workspace.
zdb1.png
zdb1.png (214.79 KiB) Viewed 11060 times
Setting up the Compiler
Now if I edit the workspace Compiler settings I can add a command to compile a single file in that workspace.

In this case I use the following C compiler command line to compile a C file as shown below:

Code: Select all

cl.exe -c "$fn"
NOTE: Naturally this command line will need to be modified to compile a single file for the compiler that you are using.

The completed setup for the compiler is shown below:
zdb2.png
zdb2.png (120.63 KiB) Viewed 11059 times
Notice how the file is represented by the "$fn" tag.

You can use any Zeus tag in that command line and if you run the ztag.lua macro using the Macros, Execute Script menu, it will show Zeus tags and their equivalent values.

To see the details of that macro place the cursor on the file name below and use the View, Open File menu to open the file:

Code: Select all

ztag.lua
Also notices that the compiler has been configured to only show output on warnings and errors. This can be changes to suit.

Setting up the Project
In the Project panel you add the commands to build the whole project. There are also options to clean and rebuild the project.

Generally you would use some sort of build tool for this command line.

In my case as this is a single file project, I can get away with this very simple C command line that will create an executable from a single file as shown below:

Code: Select all

cl.exe "$fn"
NOTE: Naturally this command line will need to be modified to produce an executable for the build tools that you are using.

Here is the complete Project setup.
zdb3.png
zdb3.png (132.1 KiB) Viewed 11059 times
Setting up the Debugging
In the Debugger panel you add a command line to run the resulting exactable.

Now in my case the Project build creates the following executable:

Code: Select all

MyProject.exe
So all I need to do is add that executable to the Debugger panel as shown below.
zdb4.png
zdb4.png (93.58 KiB) Viewed 11058 times
Notice that I also added some command line parameters and I capture the output produced.

I also use the $wdd macro tag to set the directory to match the workspace drive and directory.

Also notice that these are Debug settings as specified by the blue rectangle found in the top left corner.

There are a second set of configuration options for Release mode, allowing for special release builds if required.

Running these Commands
With all of the settings in place I can now access these command lines as follows.
  • The Compiler, Compile menu can be used to run the Workspace Compile command line for the currently active file.
  • The Workspace, Build menu has options for Make, Clean and Rebuild that run the correspond Workspace Project command lines.
  • The Workspace, Build menu has the Start Debug Executable and Start Release Executable which run the corresponding Workspace Debugger command lines.
For my example, if I use the Workspace, Build, Start Debug Executable menu the executable is run, and the following output is capture:
zdb5.png
zdb5.png (185.16 KiB) Viewed 11055 times
Running these Commands Using the Keyboard
All of these menus can also be bound to a keyboard key to make them easier to use.

The easiest way to do this is as follows:
  • Record a macro
  • Select the menu in question
  • Finish recording the menu
  • Viewing the macro source code produced
That macro source will contain the name of the function that is run by the menu selected and that function name can then be bound to a key using Options, Editor Options menu, Keyboard Mapping panel.

Cheers Jussi
Post Reply