Start and stop

The debugger is always started with a program loaded. There are two ways to do this:

  • Running an executable
  • Attaching to a process

Almost every feature of Anjuta is provided by a plugin. If you do not see the menus described here. It is probably because the debugger plugin is not loaded. Go in Edit ▸ Preferences ▸ General ▸ Installed plugins and check that the debugger plugin is loaded. It is an user activatable plugin, so loaded or unloaded on request.

6.1.1. Running an executable

Running a program with or without the debugger uses the same menu: select Run ▸ Run Program to run a program without the debugger and Run ▸ Debug Program to run it with the debugger.

In order to better use the debugger, it is strongly recommended that you build your program with debugging information (-g for gcc) and no optimization (-O0 for gcc). This can be done by selecting the Debug configuration before building the program for the first time.

You can select which program to run and its environment using Run ▸ Program Parameters…. You can choose:

  • The program that you want to debug

    The drop-down menu of the target drop-down combination box is pre-filled with all executables of the current project. But you can alternatively select another executable which is not part of the project. The debugger also accepts libtool executables; these are scripts generated by libtool which wrap real executables.

  • The command-line parameters

  • The working directory

  • Environment variables

    Environment variables displayed in light gray are the current environment variables. You can add, modify or remove environment variables here.

    To debug Anjuta using Anjuta, you can use a different theme to change the look of the instance being debugged; for example, you could add "GTK2_RC_FILES=/usr/share/themes/Crux/gtk-2.0/gtkrc".

  • Whether the program should run in a terminal or not. If so, the Anjuta terminal plugin is used.

6.1.2. Attaching to a Process

It is also possible to attach to a running process and debug it by choosing the menu item Run ▸ Debug Process …. A list of all processes running on the system will appear.

Figure 6-1Attach to Process dialog

Select the process to attach to and click OK to start the debugger, attach to the selected process and stop it.

It is currently not possible to load symbol information for an attached process. Symbols should be included in the process.

6.1.3. Stopping the Debugger

Choose the menu item Run ▸ Stop Debugger to stop the debugger. This will kill the program which is being debugged. If the debugger has been attached to a running process, the debugger will just detach from it without killing it. You will get a confirmation box if a program is currently attached or running.

6.1.4. Adding source directories

Choose the menu item Debug ▸ Add source paths… to display a dialog box allowing you to add and remove source directories.

Most executables include full file paths, so defining the directories where are the source files is normally not useful. But some executables include only file names without paths; in this case, the debugger will search for source files in all these directories. The order of directories can be important if several files have the same name, so you can change it using the Up and Down buttons. The directory list is sent to the debugger when it is started. After changing it, you need to restart the debugger to cause it to use the new list.