Recent

Author Topic: Debug FPC sources under Linux  (Read 5296 times)

Ondrej Pokorny

  • Full Member
  • ***
  • Posts: 220
Debug FPC sources under Linux
« on: March 12, 2015, 10:10:21 pm »
Hello, I downloaded and built FPC and Lazarus from trunk under kubuntu x64, and I use the following command to build FPC:

Code: [Select]
make clean all OPT="-gl -O-"
make install INSTALL_PREFIX=/home/ondrej/lazarus/fpc_exp

Under Windows, it compiled FPC RTL with debug info. But under Linux I can't debug into the RTL, what I am doing wrong?

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9874
  • Debugger - SynEdit - and more
    • wiki
Re: Debug FPC sources under Linux
« Reply #1 on: March 12, 2015, 10:32:48 pm »
1) -gl only adds line info. You probably want -gw (or -gs)

2) When you call fpc which fpc.cfg is it using? (on windows that is easy, it is in the same folder, on linux that is does not work) fpc -va ....
And in that fpc.cfg, do you point to the units (ppu) that you just installed?

Ondrej Pokorny

  • Full Member
  • ***
  • Posts: 220
Re: Debug FPC sources under Linux
« Reply #2 on: March 12, 2015, 10:43:31 pm »
1) I tried -gw, nothing changed.

2) I use "/etc/fpc.cfg". (I suppose this is the system default?)

Yes I am pointing to the right units, I guess:

Code: [Select]
# searchpath for units and other system dependent things
-Fu/home/ondrej/lazarus/fpc_exp/lib/fpc/3.1.1/units/
-Fu/home/ondrej/lazarus/fpc_exp/lib/fpc/3.1.1/units/$fpctarget/*
-Fu/home/ondrej/lazarus/fpc_exp/lib/fpc/3.1.1/units/$fpctarget/rtl

It looks very weird for me :(

Here is the full "fpc -va":
Code: [Select]
[0.000] Macro defined: LINUX
[0.000] Macro defined: UNIX
[0.000] Macro defined: HASUNIX
[0.000] Macro defined: FPC_HAS_WINLIKERESOURCES
[0.000] Macro defined: CONSOLE
[0.000] Macro defined: LINUX
[0.000] Macro defined: FPC
[0.000] Macro defined: VER3
[0.000] Macro defined: VER3_1
[0.000] Macro defined: VER3_1_1
[0.000] Macro defined: RESSTRSECTIONS
[0.000] Macro defined: FPC_HASFIXED64BITVARIANT
[0.000] Macro defined: FPC_HASINTERNALOLEVARIANT2VARIANTCAST
[0.000] Macro defined: FPC_HAS_VARSETS
[0.000] Macro defined: FPC_HAS_VALGRINDBOOL
[0.000] Macro defined: FPC_HAS_STR_CURRENCY
[0.000] Macro defined: FPC_REAL2REAL_FIXED
[0.000] Macro defined: FPC_STRTOCHARARRAYPROC
[0.000] Macro defined: FPC_STRTOSHORTSTRINGPROC
[0.000] Macro defined: FPC_OBJFPC_EXTENDED_IF
[0.000] Macro defined: FPC_HAS_OPERATOR_ENUMERATOR
[0.000] Macro defined: FPC_HAS_CONSTREF
[0.000] Macro defined: FPC_STATICRIPFIXED
[0.000] Macro defined: FPC_VARIANTCOPY_FIXED
[0.000] Macro defined: FPC_DYNARRAYCOPY_FIXED
[0.000] Macro defined: FPC_HAS_INTERNAL_ABS_LONG
[0.000] Macro defined: FPC_HAS_INTERNAL_ABS_INT64
[0.000] Macro defined: FPC_HAS_UNICODESTRING
[0.000] Macro defined: FPC_RTTI_PACKSET1
[0.000] Macro defined: FPC_HAS_CPSTRING
[0.000] Macro defined: FPC_HAS_RIP_RELATIVE
[0.000] Macro defined: FPC_HAS_CEXTENDED
[0.000] Macro defined: FPC_HAS_RESSTRINITS
[0.000] Macro defined: FPC_HAS_INTERNAL_ROX
[0.000] Macro defined: FPC_HAS_INTERNAL_SAR
[0.000] Macro defined: FPC_HAS_MEMBAR
[0.000] Macro defined: FPC_SETBASE_USED
[0.000] Macro defined: INTERNAL_BACKTRACE
[0.000] Macro defined: STR_CONCAT_PROCS
[0.000] Macro defined: REGCALL
[0.000] Macro defined: FPC_HAS_FEATURE_SUPPORT
[0.000] Macro defined: CPUX86_64
[0.000] Macro defined: CPUAMD64
[0.000] Macro defined: CPU64
[0.000] Macro defined: CPUX64
[0.000] Configfile search: /home/ondrej/.fpc.cfg
[0.000] Configfile search: /home/ondrej/lazarus/fpc_exp/lib/fpc/etc/fpc.cfg
[0.000] Configfile search: /etc/fpc.cfg
[0.000] Reading options from file /etc/fpc.cfg
[0.000] Hint: Start of reading config file /etc/fpc.cfg
[0.000] interpreting file option "#"
[0.000] interpreting file option "# Config file generated by fpcmkcfg on 12-3-15 - 20:49:59"
[0.000] interpreting file option "# Example fpc.cfg for Free Pascal Compiler"
[0.000] interpreting file option "#"
[0.000] interpreting file option "# ----------------------"
[0.000] interpreting file option "# Defines (preprocessor)"
[0.000] interpreting file option "# ----------------------"
[0.000] interpreting file option "#"
[0.000] interpreting file option "# nested #IFNDEF, #IFDEF, #ENDIF, #ELSE, #DEFINE, #UNDEF are allowed"
[0.000] interpreting file option "#"
[0.000] interpreting file option "# -d is the same as #DEFINE"
[0.000] interpreting file option "# -u is the same as #UNDEF"
[0.000] interpreting file option "#"
[0.000] interpreting file option "#"
[0.000] interpreting file option "# Some examples (for switches see below, and the -? helppages)"
[0.000] interpreting file option "#"
[0.000] interpreting file option "# Try compiling with the -dRELEASE or -dDEBUG on the commandline"
[0.000] interpreting file option "#"
[0.000] interpreting file option "# For a release compile with optimizes and strip debuginfo"
[0.000] interpreting file option "#IFDEF RELEASE"
[0.000] interpreting file option "#WRITE Compiling Release Version"
[0.000] interpreting file option "#ENDIF"
[0.000] interpreting file option "# For a debug version compile with debuginfo and all codegeneration checks on"
[0.000] interpreting file option "#IFDEF DEBUG"
[0.000] interpreting file option "#WRITE Compiling Debug Version"
[0.000] interpreting file option "#ENDIF"
[0.000] interpreting file option "# assembling"
[0.000] interpreting file option "#ifdef darwin"
[0.000] interpreting file option "# use pipes instead of temporary files for assembling"
[0.000] interpreting file option "# path to Xcode 4.3+ utilities (no problem if it doesn't exist)"
[0.000] interpreting file option "#endif"
[0.000] interpreting file option "# ----------------"
[0.000] interpreting file option "# Parsing switches"
[0.000] interpreting file option "# ----------------"
[0.000] interpreting file option "# Pascal language mode"
[0.000] interpreting file option "#      -Mfpc      free pascal dialect (default)"
[0.000] interpreting file option "#      -Mobjfpc   switch some Delphi 2 extensions on"
[0.000] interpreting file option "#      -Mdelphi   tries to be Delphi compatible"
[0.000] interpreting file option "#      -Mtp       tries to be TP/BP 7.0 compatible"
[0.000] interpreting file option "#      -Mgpc      tries to be gpc compatible"
[0.000] interpreting file option "#      -Mmacpas   tries to be compatible to the macintosh pascal dialects"
[0.000] interpreting file option "#"
[0.000] interpreting file option "# Turn on Object Pascal extensions by default"
[0.000] interpreting file option "#-Mobjfpc"
[0.000] interpreting file option "# Assembler reader mode"
[0.000] interpreting file option "#      -Rdefault  use default assembler"
[0.000] interpreting file option "#      -Ratt      read AT&T style assembler"
[0.000] interpreting file option "#      -Rintel    read Intel style assembler"
[0.000] interpreting file option "#"
[0.000] interpreting file option "# All assembler blocks are AT&T styled by default"
[0.000] interpreting file option "#-Ratt"
[0.000] interpreting file option "# Semantic checking"
[0.000] interpreting file option "#      -S2        same as -Mobjfpc"
[0.000] interpreting file option "#      -Sc        supports operators like C (*=,+=,/= and -=)"
[0.000] interpreting file option "#      -Sa        include assertion code."
[0.000] interpreting file option "#      -Sd        same as -Mdelphi"
[0.000] interpreting file option "#      -Se<x>     error options. <x> is a combination of the following:"
[0.000] interpreting file option "#         <n> : compiler stops after <n> errors (default is 1)"
[0.000] interpreting file option "#         w   : compiler stops also after warnings"
[0.000] interpreting file option "#         n   : compiler stops also after notes"
[0.000] interpreting file option "#         h   : compiler stops also after hints"
[0.000] interpreting file option "#      -Sg        allow LABEL and GOTO"
[0.000] interpreting file option "#      -Sh        Use ansistrings"
[0.000] interpreting file option "#      -Si        support C++ styled INLINE"
[0.000] interpreting file option "#      -Sk        load fpcylix unit"
[0.000] interpreting file option "#      -SI<x>     set interface style to <x>"
[0.000] interpreting file option "#         -SIcom    COM compatible interface (default)"
[0.000] interpreting file option "#         -SIcorba  CORBA compatible interface"
[0.000] interpreting file option "#      -Sm        support macros like C (global)"
[0.000] interpreting file option "#      -So        same as -Mtp"
[0.000] interpreting file option "#      -Sp        same as -Mgpc"
[0.000] interpreting file option "#      -Ss        constructor name must be init (destructor must be done)"
[0.000] interpreting file option "#      -Sx        enable exception keywords (default in Delphi/ObjFPC modes)"
[0.000] interpreting file option "#"
[0.000] interpreting file option "# Allow goto, inline, C-operators, C-vars"
[0.000] Handling option "-Sgic"
[0.000] interpreting option "-Sgic"
[0.000] interpreting file option "# ---------------"
[0.000] interpreting file option "# Code generation"
[0.000] interpreting file option "# ---------------"
[0.000] interpreting file option "# Uncomment the next line if you always want static/dynamic units by default"
[0.000] interpreting file option "# (can be overruled with -CD, -CS at the commandline)"
[0.000] interpreting file option "#-CS"
[0.000] interpreting file option "#-CD"
[0.000] interpreting file option "# Set the default heapsize to 8Mb"
[0.000] interpreting file option "#-Ch8000000"
[0.000] interpreting file option "# Set default codegeneration checks (iocheck, overflow, range, stack)"
[0.000] interpreting file option "#-Ci"
[0.000] interpreting file option "#-Co"
[0.000] interpreting file option "#-Cr"
[0.000] interpreting file option "#-Ct"
[0.000] interpreting file option "# Optimizer switches"
[0.000] interpreting file option "# -Os        generate smaller code"
[0.000] interpreting file option "# -Oa=N      set alignment to N"
[0.000] interpreting file option "# -O1        level 1 optimizations (quick optimizations, debuggable)"
[0.000] interpreting file option "# -O2        level 2 optimizations (-O1 + optimizations which make debugging more difficult)"
[0.000] interpreting file option "# -O3        level 3 optimizations (-O2 + optimizations which also may make the program slower rather than faster)"
[0.000] interpreting file option "# -Oo<x>     switch on optimalization x. See fpc -i for possible values"
[0.000] interpreting file option "# -OoNO<x>   switch off optimalization x. See fpc -i for possible values"
[0.000] interpreting file option "# -Op<x>     set target cpu for optimizing, see fpc -i for possible values"
[0.000] interpreting file option "#ifdef darwin"
[0.000] interpreting file option "#ifdef cpui386"
[0.000] interpreting file option "#endif"
[0.000] interpreting file option "#endif"
[0.000] interpreting file option "# -----------------------"
[0.000] interpreting file option "# Set Filenames and Paths"
[0.000] interpreting file option "# -----------------------"
[0.000] interpreting file option "# Both slashes and backslashes are allowed in paths"
[0.000] interpreting file option "# path to the messagefile, not necessary anymore but can be used to override"
[0.000] interpreting file option "# the default language"
[0.000] interpreting file option "#-Fr/usr/lib/fpc/3.1.1/msg/errore.msg"
[0.000] interpreting file option "#-Fr/usr/lib/fpc/3.1.1/msg/errorn.msg"
[0.000] interpreting file option "#-Fr/usr/lib/fpc/3.1.1/msg/errores.msg"
[0.000] interpreting file option "#-Fr/usr/lib/fpc/3.1.1/msg/errord.msg"
[0.000] interpreting file option "#-Fr/usr/lib/fpc/3.1.1/msg/errorr.msg"
[0.000] interpreting file option "# searchpath for units and other system dependent things"
[0.000] Handling option "-Fu/home/ondrej/lazarus/fpc_exp/lib/fpc/3.1.1/units/"
[0.000] interpreting option "-Fu/home/ondrej/lazarus/fpc_exp/lib/fpc/3.1.1/units/"
[0.000] Handling option "-Fu/home/ondrej/lazarus/fpc_exp/lib/fpc/3.1.1/units/x86_64-linux/*"
[0.000] interpreting option "-Fu/home/ondrej/lazarus/fpc_exp/lib/fpc/3.1.1/units/x86_64-linux/*"
[0.008] Handling option "-Fu/home/ondrej/lazarus/fpc_exp/lib/fpc/3.1.1/units/x86_64-linux/rtl"
[0.008] interpreting option "-Fu/home/ondrej/lazarus/fpc_exp/lib/fpc/3.1.1/units/x86_64-linux/rtl"
[0.008] interpreting file option "#IFDEF FPCAPACHE_1_3"
[0.008] interpreting file option "#ELSE"
[0.008] interpreting file option "#IFDEF FPCAPACHE_2_0"
[0.008] interpreting file option "#ELSE"
[0.008] Handling option "-Fu/home/ondrej/lazarus/fpc_exp/lib/fpc/3.1.1/units/x86_64-linux/httpd22"
[0.008] interpreting option "-Fu/home/ondrej/lazarus/fpc_exp/lib/fpc/3.1.1/units/x86_64-linux/httpd22"
[0.008] interpreting file option "#ENDIF"
[0.008] interpreting file option "#ENDIF"
[0.008] interpreting file option "# searchpath for fppkg user-specific packages"
[0.008] Handling option "-Fu~/.fppkg/lib/fpc/3.1.1/units/x86_64-linux/*"
[0.008] interpreting option "-Fu~/.fppkg/lib/fpc/3.1.1/units/x86_64-linux/*"
[0.008] Path "/home/ondrej/.fppkg/lib/fpc/3.1.1/units/x86_64-linux/*/" not found
[0.008] interpreting file option "# path to the gcclib"
[0.008] interpreting file option "#ifdef cpui386"
[0.008] interpreting file option "#endif"
[0.008] interpreting file option "#ifdef cpux86_64"
[0.008] Handling option "-Fl/usr/lib/gcc/x86_64-linux-gnu/4.8"
[0.008] interpreting option "-Fl/usr/lib/gcc/x86_64-linux-gnu/4.8"
[0.008] interpreting file option "#endif"
[0.008] interpreting file option "# searchpath for libraries"
[0.008] interpreting file option "#-Fl/usr/lib/fpc/3.1.1/lib"
[0.008] interpreting file option "#-Fl/lib;/usr/lib"
[0.008] Handling option "-Fl/usr/lib/fpc/3.1.1/lib/x86_64-linux"
[0.008] interpreting option "-Fl/usr/lib/fpc/3.1.1/lib/x86_64-linux"
[0.008] Path "/usr/lib/fpc/3.1.1/lib/x86_64-linux/" not found
[0.008] interpreting file option "# searchpath for tools"
[0.008] Handling option "-FD/usr/lib/fpc/3.1.1/bin/x86_64-linux"
[0.008] interpreting option "-FD/usr/lib/fpc/3.1.1/bin/x86_64-linux"
[0.008] interpreting file option "#IFNDEF CPUI386"
[0.008] interpreting file option "#IFNDEF CPUAMD64"
[0.008] interpreting file option "#DEFINE NEEDCROSSBINUTILS"
[0.008] interpreting file option "#ENDIF"
[0.008] interpreting file option "#ENDIF"
[0.008] interpreting file option "#IFNDEF Linux"
[0.008] interpreting file option "#DEFINE NEEDCROSSBINUTILS"
[0.008] interpreting file option "#ENDIF"
[0.008] interpreting file option "# binutils prefix for cross compiling"
[0.008] interpreting file option "#IFDEF FPC_CROSSCOMPILING"
[0.008] interpreting file option "#IFDEF NEEDCROSSBINUTILS"
[0.008] interpreting file option "#ENDIF"
[0.008] interpreting file option "#ENDIF"
[0.008] interpreting file option "# -------------"
[0.008] interpreting file option "# Linking"
[0.008] interpreting file option "# -------------"
[0.008] interpreting file option "# generate always debugging information for GDB (slows down the compiling"
[0.008] interpreting file option "# process)"
[0.008] interpreting file option "#      -gc        generate checks for pointers"
[0.008] interpreting file option "#      -gd        use dbx"
[0.008] interpreting file option "#      -gg        use gsym"
[0.008] interpreting file option "#      -gh        use heap trace unit (for memory leak debugging)"
[0.008] interpreting file option "#      -gl        use line info unit to show more info for backtraces"
[0.008] interpreting file option "#      -gv        generates programs tracable with valgrind"
[0.008] interpreting file option "#      -gw        generate dwarf debugging info"
[0.008] interpreting file option "#"
[0.008] interpreting file option "# Enable debuginfo and use the line info unit by default"
[0.008] interpreting file option "#-gl"
[0.008] interpreting file option "# always pass an option to the linker"
[0.008] interpreting file option "#-k-s"
[0.008] interpreting file option "# Always strip debuginfo from the executable"
[0.008] Handling option "-Xs"
[0.008] interpreting option "-Xs"
[0.008] interpreting file option "# -------------"
[0.008] interpreting file option "# Miscellaneous"
[0.008] interpreting file option "# -------------"
[0.008] interpreting file option "# Write always a nice FPC logo ;)"
[0.008] Handling option "-l"
[0.008] interpreting option "-l"
[0.008] interpreting file option "# Verbosity"
[0.008] interpreting file option "#      e : Show errors (default)       d : Show debug info"
[0.008] interpreting file option "#      w : Show warnings               u : Show unit info"
[0.008] interpreting file option "#      n : Show notes                  t : Show tried/used files"
[0.008] interpreting file option "#      h : Show hints                  s : Show time stamps"
[0.008] interpreting file option "#      i : Show general info           q : Show message numbers"
[0.008] interpreting file option "#      l : Show linenumbers            c : Show conditionals"
[0.008] interpreting file option "#      a : Show everything             0 : Show nothing (except errors)"
[0.008] interpreting file option "#      b : Write file names messages   r : Rhide/GCC compatibility mode"
[0.008] interpreting file option "#          with full path              x : Executable info (Win32 only)"
[0.008] interpreting file option "#      v : write fpcdebug.txt with     p : Write tree.log with parse tree"
[0.008] interpreting file option "#          lots of debugging info"
[0.008] interpreting file option "#"
[0.008] interpreting file option "# Display Info, Warnings and Notes"
[0.008] Handling option "-viwn"
[0.008] interpreting option "-viwn"
[0.008] interpreting file option "# If you don't want so much verbosity use"
[0.008] interpreting file option "#-vw"
[0.008] interpreting file option "# multiarch library search path"
[0.008] Handling option "-Fl/usr/lib/x86_64-linux-*"
[0.008] interpreting option "-Fl/usr/lib/x86_64-linux-*"
[0.016] interpreting file option "# Third party units should be installe in a, multi-arch compatible location."
[0.016] interpreting file option "# Units should be installed in /usr/lib/x86_64-linux-gnu/fp-units-2.6.2/$pkg/."
[0.016] interpreting file option "# Ech fp-units package should install a configuration file called $pkg.cfg in"
[0.016] interpreting file option "#CFGDIR /etc/fpc-3.1.1.cfg.d/x86_64-linux"
[0.016] Path "/etc/fpc-3.1.1.cfg.d/x86_64-linux/" not found
[0.016] Hint: End of reading config file /etc/fpc.cfg
[0.016] Handling option "-va"
[0.016] interpreting option "-va"
[0.016] Macro defined: ENDIAN_LITTLE
[0.016] Macro defined: FPC_LITTLE_ENDIAN
[0.016] Macro defined: FPC_ABI_DEFAULT
[0.016] Free Pascal Compiler version 3.1.1 [2015/03/12] for x86_64
[0.016] Copyright (c) 1993-2015 by Florian Klaempfl and others
[0.016] Fatal: No source file name in command line
[0.016] Fatal: Compilation aborted
Error: /usr/bin/ppcx64 returned an error exitcode (normal if you did not specify a source file to be compiled)
« Last Edit: March 12, 2015, 11:06:31 pm by ondrejpokorny »

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9874
  • Debugger - SynEdit - and more
    • wiki
Re: Debug FPC sources under Linux
« Reply #3 on: March 12, 2015, 11:26:28 pm »
1) I tried -gw, nothing changed.

2) I use "/etc/fpc.cfg". (I suppose this is the system default?)

Yes I am pointing to the right units, I guess:

Code: [Select]
# searchpath for units and other system dependent things
-Fu/home/ondrej/lazarus/fpc_exp/lib/fpc/3.1.1/units/
-Fu/home/ondrej/lazarus/fpc_exp/lib/fpc/3.1.1/units/$fpctarget/*
-Fu/home/ondrej/lazarus/fpc_exp/lib/fpc/3.1.1/units/$fpctarget/rtl


-gw does not change your issue that is right. It was meant an additional observation.


Anyway, yes /etc/fpc.cfg is the default. You can see that it appears in the output.

if you add the -va option to the actual compilation of your project, then you can see what files the compiler uses to build your project.

1) If the compiler is called by Lazarus, if this runs on a diff user account an fpc.cfg may exist in the user dir.

2) when -va is active compiling your project, it will show all the location it looks for the ppu, and where they are found.
So that can help ruling out that the wrong ppu are used.


I assume that the debug info for the project code works. So we can rule out that the exe was accidentally stripped, and we also know the debugger works.

I do not know if there is anything that can go wrong when specifying the OPT to make. So i do not know if the build really worked, or how to check that. That would be next, if the correct ppu have been used.

Ondrej Pokorny

  • Full Member
  • ***
  • Posts: 220
Re: Debug FPC sources under Linux
« Reply #4 on: March 13, 2015, 12:45:08 am »
Thanks a lot for the suggestions!

I checked everything you told me and I realized that I compiled the trunk with FPC 2.6.0 whereas 2.6.4 is required.
The build created the ppu and o files (so at the first glance it looked OK) but it was somehow corrupted.
The error message was very hard to find in the build information.

Thank you very much!

Leledumbo

  • Hero Member
  • *****
  • Posts: 8757
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Debug FPC sources under Linux
« Reply #5 on: March 13, 2015, 05:25:23 am »
Quote
[0.008] interpreting file option "# Always strip debuginfo from the executable"
[0.008] Handling option "-Xs"
[0.008] interpreting option "-Xs"
Looks make sense

 

TinyPortal © 2005-2018