I've been trying to address #1141 and come to a point where the next logical step seems to be to step through Geany's / Scintilla's code in order to understand what is happening. Has someone else gotten some sort of debugger working on this codebase before? I've tried to get GDB working but I can't get it to find the source files.
### What I've tried so far I read [`HACKING`](https://github.com/geany/geany/blob/master/HACKING) and then ran `CFLAGS='-g -O0' ./autogen.sh --disable-html-docs` to get debug symbols, and ran `make`. I then tried running `gdb src/geany`. GDB complained that `src/geany` was not an executable. I examined `src/geany` and found it was in fact a shell script. After a bit of digging I found the `src/.libs/` folder which contained an executable which if I ran it directly opened up a Geany instance. So I tried running `gdb /src/.libs/geany` which seemed to work except that GDB only knows about [main.c](https://github.com/geany/geany/blob/2a2ae728341d12b7cea29b671beb08e441f62d95...) and its header file. I looked up how to tell GDB about where source files are and I found [this page of the manual](https://sourceware.org/gdb/onlinedocs/gdb/Source-Path.html). I then ran `dir src` inside GDB and that added the correct folder to the search path, but GDB still couldn't find the source files.
I haven't really used GDB before, so a) I might be missing something regarding operating GDB itself, and b) if someone has a way to debug Geany using another method, that's fine with me!
It's sounds mostly like you're fighting libtool, see [this page for more info](https://www.gnu.org/software/libtool/manual/html_node/Debugging-executables....).
Basically:
```bash $ libtool --mode=execute gdb geany/geany ```
You can't just run geany from the source tree, it has to be installed by `make install`. Use --prefix on configure to set where (like somewhere in your home, not a system dir) then run it from the bin directory that install created. And use -c to not corrupt your normal config.
If you build geany from git I think it makes the symbols by default, at least it does for me. But most of Geany is a library, so if you refer to symbols in GDB before Geany is started it won't find them as the library is not loaded, just accept making the symbol dependent on a later library and it will set a breakpoint fine.
@elextr following your suggestion, it is working now. As you mentioned, GDB doesn't find the files, even after they are added to the search path with `dir`, until after the program starts running. But they're available after `(gdb) start` so that's fine.
Seems like this should be added to the documentation. Maybe something like
Because most of Geany is a library, in order to use GDB, you'll need to install the version of Geany you want to debug. You can install to a different directory in order to not overwrite an existing install with `./configure --prefix <a directory>`. You'll also need to tell GDB about where the source files are with GDB's `dir` command. Most source files won't be loaded until after Geany starts running, but you can run `(gdb) start` to break at the start of main and set breakpoints etc. from there.
in the GDB section of HACKING?
I always install into $PROGRAMS_DIR/$NAME_OF_THE_PROGRAM/$PROGRAM_VERSION, which is what GoboLinux does (but I am using slackware most of the time); so in the above, I'd have Geany at /Programs/Geany/1.31/ (if that was the latest version).
I use a set of ruby scripts for that.
Since libtool was also mentioned here, and in "HACKING" issue by elextr I think, I should like to add that I dislike libtool immensely. :)
The bugger insists on storing hardcoded path entries into .la, which is ok if you install into relative prefixes such as /usr/ relative because libtool assumes that this is what everyone will use, rather than a path above). Since libtool also soaks up other .la files, if I think e. g. remove a program again from such a path, including removing the .la file in question, compilation based on libtool will fail because it can not find the file anymore. I assume that Gentoo and some other distributions use some way to workaround this or just simply don't use libtool at all anymore, but my poor man's "solution" was to just grep through all .la files and remove the entries from programs that I removed. It was still annoying to have to do so, since I invested time only to compensate for libtool's lack of abilities - it is primarily one HUGE shell script. Have you guys looked at it? :)
@Ryan1729 probably mention adding the library on #1689 which is in that section and suggesting removal of the `gdb src/geany`.
@shevegen umm, I'm sure your script is nice, but you can already put Geany into `/Programs/Geany/1.31` by adding `--prefix=/Programs/Geany/1.31` to autogen/configure.
@Ryan1729 I think you have something weird going on with your GDB. Both the above `libtool` command I gave (if you've already installed Geany at the same prefix as configured) and doing a full make install as @elextr mentioned should have the symbols and source be available for debugging without doing anything special.
I don't recommend we add that paragraph to the docs as it will only confuse people and is misleading for a normal system (with Linux anyway).
github-comments@lists.geany.org