FB debugger : 2.93 32/64 BIT ..... (Sept 5th, 2018)

User projects written in or related to FreeBASIC.
MrSwiss
Posts: 2811
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: FB debugger : 2.93 32/64 BIT ..... (Sept 5th, 2018)

Postby MrSwiss » Sep 06, 2018 13:24

SARG wrote:However as the 64bit debugging (not the debugger itself) is not completly safe you can try to debug with the 64bit version and in case of problem use the 32bit one. But be carefull with variables defined as integer (32 <> 64).....

Sorry to bother but, above isn't entirely clear to me.
    The Debugger (FBC 32 -gen GAS) is the only safe choice?
    It doesn't detect, that debugee is compiled with FBC 64?
Is that the case, as of current versions?

Should that be the case then, this would be a: new feature request.
SARG
Posts: 858
Joined: May 27, 2005 7:15
Location: FRANCE

Re: FB debugger : 2.93 32/64 BIT ..... (Sept 5th, 2018)

Postby SARG » Sep 06, 2018 17:36

@MrSwiss
No problem, sorry not to explain clearly ;-)

When FBC generates the C code there are some cases where this code is very far/different from the freebasic code. So it could be impossible to connect the 2. Furthermore arrays are zero based. And other things.
I did my best but I can do miracles.

So if debugging your 64bit version doesn't work perfectly compile a 32bit version and debug with it.
My warning about integer is : if you are using integer64 to handle value of 64 bits (not values linked to the OS) it should be better to use longint/ulongint when debugging under 32bit.
MrSwiss
Posts: 2811
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: FB debugger : 2.93 32/64 BIT ..... (Sept 5th, 2018)

Postby MrSwiss » Sep 10, 2018 14:29

@SARG, thank you.
So, if I understand correctly:
you're taking "debug info" from FBC's backend, and not on the generated ASM
(which would then, make no difference, whether C exists inbetween, or not).
St_W
Posts: 1407
Joined: Feb 11, 2009 14:24
Location: Austria
Contact:

Re: FB debugger : 2.93 32/64 BIT ..... (Sept 5th, 2018)

Postby St_W » Sep 10, 2018 15:47

Some general info first:
debug info is generated at compile time and part of the compilation result. The GNU toolchain, which FreeBasic uses, embeds that debug info in the compiled binary (e.g. EXE/DLL file). Other toolchains, like MSVC, also allow to store debug info in a separate file (e.g. PDB files).
There are multiple different data formats defining how that debug info looks like and how it is stored. For FreeBasic STABS and DWARF are the two relevant ones, but fbc itself only supports the former. A debugger reads that data from the binary (e.g. an EXE file) when the application is debugged.

When using the gas backend (which is only available for 32-bit applications) fbc generates STABS debug info as part of the generated ASM file (which is later assembled by gas).

When using the gcc backend (available for 32- and 64-bit applications) fbc emits some debug hints in the C code (like #file, #line). Note that this is neither STABS nor DWARF debug info, because C code does not have any syntax for directly specifying STABS/DWARF directives. DWARF debug info is then generated by gcc for the C code (emitted by fbc). Note that fbc itself does not support DWARF and cannot directly emit it (this would be possible in the gas backend only anyway due to the limitation of the C language). gcc generates an ASM file (with DWARF directives) and the ASM file is again assembled by gas.

That should explain some of the limitations for the different fbc backends.

If you want to get a feeling how that debugging data looks like compile with "-g -r" and look at the generated asm/c file.
SARG
Posts: 858
Joined: May 27, 2005 7:15
Location: FRANCE

Re: FB debugger : 2.93 32/64 BIT ..... (Sept 5th, 2018)

Postby SARG » Sep 10, 2018 17:28

@St_W thanks for your reply.
By the way I forgot a word in a previous post : "I did my best but I can not do miracles. Not the same meaning....

Some complements :
- In every case fbdebugger extracts the data from the exe, directly if stabs or via objdump if dwarf (directly would be too complicated). Nothing comes from source codes except the code itself.

- With gas (32 default) the debug data is close from the bas code (line number, and anything alse) so the debugging is fully operational.

- With gcc the translation in C is not always 1 for 1. So there are cases where the debug data doesn't match the initial basic lines or variables.

And a diagram, not as good as fxm's ones.

Code: Select all

                   bas
                    |
                   ---
                   FBC
                   ---
                    |
 -----------------------------------------------------
 |                                                   |
asm + stabs instructions                          C code + #line/file instructions from bas code
 |    from bas code                                  |
 |    (line number, variables)                      ---
 |    (structures, etc)                             GCC 32/64bit
 |                                                  ---
 |                                                   |
 |                        ------------------------------------------                     
 |                        |                                        |
 |                       asm + stabs instructions                 asm + dwarf instructions
 |                        |    from C code                         |    from C code
 |                        |                                        |
 -------------------------------------------------------------------
                                      |
                                     ---
                                     GAS
                                     ---
                                      |
                                     exe + stabs or dwarf data embedded
                                      |
                                  ----------
                                  Fbdebugger  :-)
                                  ----------

Return to “Projects”

Who is online

Users browsing this forum: No registered users and 0 guests