Tracing error of C program in linux using Geany?

Asked by !ncredible

i hainve installed geany my ubuntu linux. and i am having difficulty in tracing logical error in the program.

i want to run the program step by step so that i can trace the error in the program( like we do in TURBOC compiler in windows using F7 key)...... plz tell me how to do this in Geany. it is very cumbersome to always switch to windows for just to find logical error in the program.

plz tell me if there is another way to do this using another Software in the linux. I have also installed Eclipse Galileo in my computer but, i dont know how to use it....its very difficult to learn

Question information

English Edit question
Ubuntu gcc-defaults Edit question
No assignee Edit question
Solved by:
Last query:
Last reply:
Revision history for this message
mycae (mycae) said :

Make sure you install the Geany-gdb plugin package, called "geany-plugin-gdb", or the meta package of all geany plugins "geany-plugins"

You can read the documentation for the plugin here:

Revision history for this message
!ncredible (atul498) said :

i think GDB plugin is already installed in my Geany.

when i go to "tools->plugin manager" in Geany it also shows me the Geany GDB in the list of plugins. it shows me following:

active plugin file

checked GeanyGDB /usr/lib/geany/

and when i go to menu bar of Geany, on the "debug" menu there are only two options active "load" and last one "options"
all other options are faded.

when i click on load,it opens a window and ask me to select a executable file to Debug. i'v tried all the files created by the Geany while the compilation or running the program. my program was to " insert and delete items in the queue" and my program name is "queue.c"
the files created by geany are "queue.c" , "queue", "queue.o". i have tried to select all the files ,,, but it gives me the error message

" This executable does not appear to contian the required debugging information"

can u plz tell the procedure to run the program step by step in GEANY.

Revision history for this message
Best mycae (mycae) said :

To use GDB, you must compile with "debugging information" enabled. This is information that the debugger can use to pull up real function names and positions in source files. This is normally dropped from compilation as it is useless to an end user, and is quite large.

So this was the procedure I followed (Lucid, but should be the same on lucid and up, one expects).
* Install geany
* install geany-gdb
* Run geany
* Select tools->plugin manager then check "Debugger"

*Created small program

#include <stdio.h>

int main(int argc, char *argv[])
    int i=0;

   return 0;

* saved as "test.c"
* Build->Set includes and arguments
* Added "-g" to the compile AND build lines, after "gcc" (there needs to be a space before and after it)

In the "debug tab" Load your compiled binary using the "load" function in the window on the left breakpoint button to create breakpoints, add watches with the "watch" command.

Now. I got an error when running in a terminal, this is apparently a bug in geany-plugins,but I could not find it anywhere else (for geany).

You can work around this by altering the terminal to be something other than xterm (maybe), but I simply unchecked "run in terminal".

Personally, that all said and done, I prefer straight-up gdb in a terminal. Once you get comfy with that, I also highly recommend cppcheck (its for C as well, don't be fooled by the name), and valgrind.

Revision history for this message
mycae (mycae) said :

oh I forgot. I also restarted geany after enabling the GDB plugin.

Revision history for this message
!ncredible (atul498) said :

Thanks mycae, that solved my question.

Revision history for this message
!ncredible (atul498) said :

huh! thatz reallly a relief for me. i am messing with different IDE's since many days. used eclipse, netbaeans and geany on windows and as well as LInux.

but, everywhwre there was some problem....mostly problem with building the project. only, in geany my program was running, but, there was a problem with Debugging. its solved now.

Thanx, mycae. thnx a lot. u r a gr8 prsn :0

ok, debugging solved. but, there is a problem. i want to trace the program from start, so that it breaks on every line automatically.
by, adding brakpoints, i have to add them mannually, which is very cumbersome task.( remember ?, as we do in TURBOC compiler in windows using F7 key, which automatically break the program on every line) can i do this in Geany ? and there is not even any shorcut defined in the debug menu. going to menu bar again and again is very difficuult.

Revision history for this message
mycae (mycae) said :

>as we do in TURBOC compiler in windows using F7 key, which automatically >break the program on every line)

I don't think geany supports this. Eclipse might. But you should not need to break a program on every line -- it usually means you are writing too much code before you are isolating and testing it.

Revision history for this message
!ncredible (atul498) said :

ohk! thn thnx agn

Revision history for this message
Javier Corrales (jjcorrales) said :

It is supposed that you can define a shortcut key for every command in Geanny.
You have to go to "help" menu and there you can redefine the action for any shortcut key.
But I the case of GDB next or continue functions Geany crashes.
I hope it will be solved in future versions.