* * *

Author Topic: No debugger support available  (Read 777 times)

Moody

  • New member
  • *
  • Posts: 6
No debugger support available
« on: April 13, 2018, 05:26:16 pm »
Hi folks,

i try to compile fp from source to get debugger support into the textmode ide.
Everything works fine if i add "NOGDB=1" to the build instruction but of course, then the debugger support is missing. When compiling with GDBLIBDIR=/usr/lib set, libgdb.a is recognized but at the end i get a lot of linking errors. It looks like the libgdb.a referes to modules which are not linked.
There were a lot of references to functions of Python so I recompiled gdb without Python support (./configure ... --with-python=no). The references to Python functions are gone.
But there is still stuff missing:

----
...
/usr/lib/libgdb.a(tui-file.o): In Funktion »tui_file::~tui_file()«:
(.text._ZN8tui_fileD0Ev[_ZN8tui_fileD5Ev]+0x1a): Warnung: undefinierter Verweis auf »operator delete(void*, unsigned long)«
/usr/lib/libgdb.a(tui-file.o): Warnung: undefinierter Verweis auf »vtable for __cxxabiv1::__si_class_type_info«
/usr/lib/libgdb.a(cp-name-parser.o): In Funktion »cp_demangled_name_to_comp(char const*, char const**)«:
(.text+0x448f): Warnung: undefinierter Verweis auf »operator delete(void*, unsigned long)«
 Warnung: undefinierter Verweis auf »operator delete(void*, unsigned long)«
 Warnung: undefinierter Verweis auf »_Unwind_Resume«
/usr/lib/libgdb.a(cp-name-parser.o): Warnung: undefinierter Verweis auf »__gxx_personality_v0«
/usr/lib/libgdb.a(f-exp.o): In Funktion »f_parse(parser_state*)«:
(.text+0x1f76): Warnung: undefinierter Verweis auf »_Unwind_Resume«
/usr/lib/libgdb.a(f-exp.o): Warnung: undefinierter Verweis auf »__gxx_personality_v0«
/usr/lib/libbfd.a(compress.o): In Funktion »decompress_contents«:
(.text+0x4c): Warnung: undefinierter Verweis auf »inflateInit_«
 Warnung: undefinierter Verweis auf »inflateReset«
 Warnung: undefinierter Verweis auf »inflate«
 Warnung: undefinierter Verweis auf »inflateEnd«
/usr/lib/libbfd.a(compress.o): In Funktion »bfd_compress_section_contents«:
(.text+0x6ac): Warnung: undefinierter Verweis auf »compressBound«
 Warnung: undefinierter Verweis auf »compress«
fp.pas(581,1) Error: Error while linking
fp.pas(581,1) Fatal: There were 1 errors compiling module, stopping
Fatal: Compilation aborted

make[3]: *** [Makefile:2224: all] Fehler 1
make[3]: Verzeichnis „/tmp/fpc/build/fpcbuild-3.0.4/fpcsrc/ide“ wird verlassen
make[2]: *** [Makefile:2657: ide_all] Fehler 2
make[2]: Verzeichnis „/tmp/fpc/build/fpcbuild-3.0.4/fpcsrc“ wird verlassen
make[1]: *** [Makefile:2821: build-stamp.x86_64-linux] Fehler 2
make[1]: Verzeichnis „/tmp/fpc/build/fpcbuild-3.0.4/fpcsrc“ wird verlassen
make: *** [Makefile:2187: fpcsrc/build-stamp.x86_64-linux] Fehler 2
----

So, my question is:
What are the requirements on how gdb has to be installed or where can i add libraries in the FP build system so they get linked into? I'm not that familar with FP's build system. "inflateReset" seems to be defined in zlib, so i might need to link it somehow into FP.

Any ideas on how to touch base on this?

Thanks!

Btw, its on a Linux From Scratch, gdb-8.1, fpc-3.0.4

Cyrax

  • Hero Member
  • *****
  • Posts: 574
Re: No debugger support available
« Reply #1 on: April 14, 2018, 12:06:16 pm »
Hmm, the textmode IDE should use GDB MI interface automatically. So there should be no need for building GDB library.

What kind of commands and options are you feeding to make utility?

Thaddy

  • Hero Member
  • *****
  • Posts: 5780
Re: No debugger support available
« Reply #2 on: April 14, 2018, 06:15:44 pm »
Indeed, NOGDB=1 is wrong. IF gdb is installed, there should be no need for old style debugger support (libgdb) since fpc3.0.4 uses gdb/mi as default, which calls the external gdb.

What does "whereis gdb" say? It should say something like this:
Code: Bash  [Select]
  1. ~ $ whereis gdb
  2. gdb: /usr/bin/gdb /etc/gdb /usr/include/gdb /usr/share/gdb
If it says something like that: leave out the NOGDB=1. If it does not, you have a wrong gdb install or a very old linux installed.
In the last case try also:
Code: Bash  [Select]
  1. ~ $ gdb --version
  2. GNU gdb (Raspbian 7.12-6) 7.12.0.20161007-git
If the version is below 7.12 you know you have an old linux but it should work provided:
If it is even below 7.0.0  gdb/mi will not work at all. In that case simply install libgdb and libgdb-dev and it will still work with "GDBMI=0".
Note that is not recommended: all the latest major stable Linux distributions including all LTE ones support gdb 7+ for the past two years.

« Last Edit: April 14, 2018, 06:29:32 pm by Thaddy »
recommends {$macro on}{$define Silly:=ObjFpc}

Moody

  • New member
  • *
  • Posts: 6
Re: No debugger support available
« Reply #3 on: April 14, 2018, 08:50:28 pm »
gdb is here:
Code: Bash  [Select]
  1. lfs@lfs-x86_64-1:~$ whereis gdb
  2. gdb: /usr/bin/gdb /usr/include/gdb /usr/share/gdb /usr/share/man/man1/gdb.1 /usr/share/info/gdb.info-2 /usr/share/info/gdb.info-1 /usr/share/info/gdb.info-4 /usr/share/info/gdb.info-6 /usr/share/info/gdb.info-7 /usr/share/info/gdb.info /usr/share/info/gdb.info-3 /usr/share/info/gdb.info-5
  3.  

version is:
Code: Bash  [Select]
  1. lfs@lfs-x86_64-1:~$ gdb --version
  2. GNU gdb (GDB) 8.1
  3. ...
  4. This GDB was configured as "x86_64-pc-linux-gnu".
  5. ...

Its all pretty new, linux-4.15.3, gcc-7.3.0, glibc-2.27, etc.
The commands i use to rebuild fp is
Code: Bash  [Select]
  1. pushd fpcsrc/compiler
  2. fpcmake -Tall
  3. popd
  4. export GDBLIBDIR=/usr/lib
  5. make build
  6. make install -j1

When leaving the GDBLIBDIR var unset, fpc builds fine but without debugging support. Doing so, the build log contains
Code: [Select]
...
Makefile:2425: Using system default libgdb file located in /usr/lib/libgdb.a
...
[ 47%] Compiled package fv
Start compiling package gdbint for target x86_64-linux.
File libgdb.a not found
       Compiling gdbint/src/gdbint.pp
       Compiling gdbint/src/gdbcon.pp
[ 47%] Compiled package gdbint
...
Installation package fv for target x86_64-linux succeeded
Start compiling package gdbint for target x86_64-linux.
File libgdb.a not found
Compiled package gdbint
Installing package gdbint
Installation package gdbint for target x86_64-linux succeeded
...
Complete log is at https://pastebin.com/54vReYnk

What does "uses gdb/mi by default" mean? Is that /mi something in addition to gdb or is it a module within fp?

Thaddy

  • Hero Member
  • *****
  • Posts: 5780
Re: No debugger support available
« Reply #4 on: April 14, 2018, 08:57:01 pm »
The export is not necessary.
gdb is installed correctly, simply do:
delete /etc/fpc.cfg (optional), then in the fpc source root directory :
Code: Bash  [Select]
  1. make clean all install
and everything should be ok.
gdb/mi means it uses the - somewhat newer - scripting feature that uses the API from the gdb executable directly instead of linking to the libgdb.
That has several advantages.  See: https://sourceware.org/gdb/onlinedocs/gdb/GDB_002fMI.html or google gdb/mi. You will find that for other languages the IDE's are moving to it too.

And don't use fpcmake! Use make
« Last Edit: April 14, 2018, 09:13:16 pm by Thaddy »
recommends {$macro on}{$define Silly:=ObjFpc}

Moody

  • New member
  • *
  • Posts: 6
Re: No debugger support available
« Reply #5 on: April 14, 2018, 11:33:12 pm »
Unfortunatly, this did not work.

make clean all install

runs fine - but result shows the wellknown "No debugger support available"  :-(

Moody

  • New member
  • *
  • Posts: 6
Re: No debugger support available
« Reply #6 on: April 15, 2018, 02:33:28 pm »
i patched fpcbuild-3.0.4/fpcsrc/ide/bin/x86_64-linux/link.res to contain

Code: [Select]
INPUT(
-lncurses
-lm
-ldl
-lgcc
-lz
-lpython3
)

(adding -lpython3 and -lz) and linking gets a step further:

Code: [Select]
pcbuild-3.0.4/fpcsrc/packages/gdbint/units/x86_64-linux/ -Ficompiler -Fl/usr/lib/gcc/x86_64-pc-linux-gnu/7.3.0 -Cg -Ur -dNOCATCH -dBrowserCol -dGDB -dx86_64 -Fu../compiler -Fu../compiler/x86_64 -Fu../compiler/targets -Fu../compiler/systems -Fi../compiler/x86_64 -Fi../compiler -Fu../compiler/x86 -dNOOPT -Sg -Fl/usr/lib/ -Xd -viq fp.pas" failed with exit code 256. Console output:
Free Pascal Compiler version 3.0.4 [2018/04/14] for x86_64
Copyright (c) 1993-2017 by Florian Klaempfl and others
Target OS: Linux for x86-64
Compiling fp.pas
Writing Resource String Table file: fp.rsj
Linking bin/x86_64-linux/fp
/usr/bin/ld: warning: bin/x86_64-linux/link.res contains output sections; did you forget -T?
fp.pas(581,1) Error: Error while linking
fp.pas(581,1) Fatal: There were 1 errors compiling module, stopping
Fatal: Compilation aborted
/usr/lib/libgdb.a(main.o): Mehrfachdefinition von »interpreter_p«
/home/lfs/fpcbuild-3.0.4/fpcsrc/packages/gdbint/units/x86_64-linux/gdbint.o: hier zuerst definiert
/usr/lib/libgdb.a(main.o): Mehrfachdefinition von »gdb_stdtarg«
/home/lfs/fpcbuild-3.0.4/fpcsrc/packages/gdbint/units/x86_64-linux/gdbint.o: hier zuerst definiert
/usr/lib/libgdb.a(top.o): Mehrfachdefinition von »deprecated_query_hook«
/home/lfs/fpcbuild-3.0.4/fpcsrc/packages/gdbint/units/x86_64-linux/gdbint.o: hier zuerst definiert
/usr/bin/ld: /usr/lib/libgdb.a(varobj.o): undefined reference to symbol 'PyImport_AddModule'
/usr/lib64/libpython3.6m.so.1.0: error adding symbols: DSO missing from command line

make: *** [Makefile:2224: all] Fehler 1

No luck at all    :'(

Thaddy

  • Hero Member
  • *****
  • Posts: 5780
Re: No debugger support available
« Reply #7 on: April 15, 2018, 02:46:25 pm »
make sure /etc/fpc.cfg is deleted and search for others. Delete these too.
Then force GDBMI like so:
Code: Bash  [Select]
  1. make clean all install GDBMI=1
Since GDB/MI uses the GDB executable, the compiler will not look for it at compile time but instead includes just the GDB/MI interface.
Note this assumes the bitness for GDB is correct: 32 bit for a 32 bit system 64 bit for a 64 bit system. On multiarch you probably need both.

Quite a mess. This should not be not at all necessary.
« Last Edit: April 15, 2018, 02:53:19 pm by Thaddy »
recommends {$macro on}{$define Silly:=ObjFpc}

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 6097
Re: No debugger support available
« Reply #8 on: April 15, 2018, 02:55:09 pm »
gdbmi in the IDE is a trunk feature, and not available in 3.0.x

Linking libgdb is very dependent on options the libgdb was compiled with, and gdbint can be edited somewhat to match, but this is not trivial.

Compiling yourself without python support should be easier

Moody

  • New member
  • *
  • Posts: 6
Re: No debugger support available
« Reply #9 on: April 15, 2018, 04:27:24 pm »
ah, now it seems we come closer :-)

Ok, if it is not yet in 3.0.x ... that might be the reason why my build constantly looks for libgdb.a while it has been said that it wouldn't.

Hope that it will come soon.

Moody

  • New member
  • *
  • Posts: 6
Re: No debugger support available
« Reply #10 on: April 16, 2018, 09:34:22 am »
Just to close this thread:

with svn checkout it works perfectly.  ;D

Just do
Code: [Select]
svn checkout http://svn.freepascal.org/svn/fpc/trunk fpc
cd fpc
make clean
make all
make install

Have fun with debugging within fp  8-)  Hope that fpc-3.1.1 et.al. will be released soon.

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus