FB debugger : 3.02 32/64 BIT WDS/LNX..... (2023/07/05)

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

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

Post by MrSwiss »

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: 1756
Joined: May 27, 2005 7:15
Location: FRANCE

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

Post by SARG »

@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: 3910
Joined: Jun 02, 2013 9:27
Location: Switzerland

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

Post by MrSwiss »

@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: 1619
Joined: Feb 11, 2009 14:24
Location: Austria
Contact:

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

Post by St_W »

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: 1756
Joined: May 27, 2005 7:15
Location: FRANCE

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

Post by SARG »

@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  :-)
                                  ----------
vic7tar
Posts: 2
Joined: Nov 07, 2017 21:23

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

Post by vic7tar »

Hello.
I'm trying to debug a small code:

Code: Select all

#Include "window9.bi"
Var HBitmap=Create_Image(300,300)
ImageStartDraw(HBitmap) 
TextDraw(30,50,"FreeBasic The Best",,&hff)
StopDraw
After starting the debugger (fbdebuggerversion "V 2.93") gives two messages:
File: c\fb\compiler1.06.0\inc\win\shobjidl.bi too large (886142>700000) not loaded
File: c\fb\compiler1.06.0\inc\win\mshtmlc.bi too large (2513411>700000) not loaded

then loads a bunch of tabs and stops at the window9.bi (AS) tab, stopping at InitCommonControls():

Code: Select all

. . .
' is it a exe build ?
#if __FB_OUT_EXE__ or __FB_OUT_DLL__

#inclib "window9"

InitCommonControls( )
Dim InitCtrlEx As INITCOMMONCONTROLSEX
. . .
after which normal debugging is impossible.
What is the problem?
SARG
Posts: 1756
Joined: May 27, 2005 7:15
Location: FRANCE

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

Post by SARG »

Hi vic7tar,

These 2 files, brought by window9.bi, are too big to be loaded in a buffer (a local variable) with a size limit of 700 000 bytes. The message is enough clear :-)

I have changed that using a shared variable and now the limit is set at 5Mo.
http://users.freebasic-portal.de/sarg/FBdebugger294.zip. Only 32/64bit exes and source code.

There are a lot of other files loaded so a lot of tabs. However I can't say why fbdebugger is stopped. Have to test.
Are you using the 64bit version of fbdebugger ?
vic7tar
Posts: 2
Joined: Nov 07, 2017 21:23

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

Post by vic7tar »

SARG, I'm using a 32-bit version of the debugger. After your new update, everything worked like a clock.
Thank you very much.
VANYA
Posts: 1834
Joined: Oct 24, 2010 15:16
Location: Ярославль
Contact:

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

Post by VANYA »

Hi SARG!

I have a problem when debugging. Here is an example:

Code: Select all

#Include "window9.bi"

Var HBitmap=Create_Image(300,300)  'создаем обычный битмап
ImageStartDraw(HBitmap)   'начинаем рисование
TextDraw(30,50,"FreeBasic The Best",,&hff)
StopDraw   'заканчиваем рисование

Var MainGpBitmap=Create_ImageA(300,300)  'создаем прозрачный битмап
Var GpBitmap=CreateGpBitmapFromHBitmap(HBitmap)  'создаем GDI+ битмап из Hbitmap
ImageStartDrawA(MainGpBitmap)  'начинаем рисование с помощью GDI+
ImageDrawA(GpBitmap,0,0)  'рисуем наш непрозрачный битмап
For y As Integer=1 To 300  'далее в циклах заменяем все непрозрачные
For x As Integer=1 To 300  'пикселы прозрачными
  If GetPixA(x,y)=&hff000000 Then
   SetPixA(x,y,&h00000000)
  EndIf
Next
Next

StopDrawA ' заканчиваем рисование
Save_image(HBitmap,"2.png")  'сохраняем непрозрачный битмап
Save_imageA(MainGpBitmap,"1.png")  'сохраняем прозрачный битмап
FreeGpBitmap(GpBitmap)
Free_Image(hbitmap)
FreeGpBitmap(MainGpBitmap)
I can't set breakpoint on any line. Everywhere the message is displayed:
Unaccessible Line (not executable)
Compilier 1.05 , win32.

example (bas+exe)
SARG
Posts: 1756
Joined: May 27, 2005 7:15
Location: FRANCE

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

Post by SARG »

Hi VANYA,

No problem on my side. I'm using FBC 1.06 but I guess it doesn't matter.
Image

Try the option "Mark no executable lines". These lines are green displayed.

Can you execute step by step ?
VANYA
Posts: 1834
Joined: Oct 24, 2010 15:16
Location: Ярославль
Contact:

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

Post by VANYA »

No problem on my side. I'm using FBC 1.06 but I guess it doesn't matter.
Hi SARG!

In version 1.06, everything works fine. But in version 1.05 does not work. We talked to the user vic7tar and realized that the debugger starts to work normally on older versions of the compiler, if in the file window9.bi comment out the lines:

Code: Select all

  InitCommonControls()
  Dim As INITCOMMONCONTROLSEX InitCtrlEx
  InitCtrlEx.dwSize = sizeof(INITCOMMONCONTROLSEX)
  InitCtrlEx.dwICC  = ICC_STANDARD_CLASSES
  InitCommonControlsEx(@InitCtrlEx)


Maybe when you have time, you still check the debugger with the example above and the window9 library, but compiled using the compiler version 1.05?

P.S. If i am click a menu item "Mark no executable lines", then the whole code turns green (example+1.05 compiler) :)
SARG
Posts: 1756
Joined: May 27, 2005 7:15
Location: FRANCE

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

Post by SARG »

Hi VANYA,

No need to test with 1.05.
When executable code is inside an include file BUT out of a procedure (sub/function) the associated debugging data is wrong.
It's the case for those 5 lines. A workaround is to put them in a proc and do a call.

This issue has been fixed (by myself) in 1.06 version of fbc.
VANYA
Posts: 1834
Joined: Oct 24, 2010 15:16
Location: Ярославль
Contact:

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

Post by VANYA »

SARG wrote:Hi VANYA,

No need to test with 1.05.
When executable code is inside an include file BUT out of a procedure (sub/function) the associated debugging data is wrong.
It's the case for those 5 lines. A workaround is to put them in a proc and do a call.

This issue has been fixed (by myself) in 1.06 version of fbc.
All clear, thanks for the explanation!
VANYA
Posts: 1834
Joined: Oct 24, 2010 15:16
Location: Ярославль
Contact:

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

Post by VANYA »

Hi SARG!

I remember there was some talk about designing your debugger under Linux. This is done or is left at the level of conversation? I tried to compile the Linux GUI insight for gdb , but nothing came of it , perhaps this product is too old for my version of Linux. So I wanted to know , can you do something in terms of creating a debugger under Linux, because use the GDB console is not very convenient.
SARG
Posts: 1756
Joined: May 27, 2005 7:15
Location: FRANCE

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

Post by SARG »

Hi VANYA,

A long time ago I did some work on the "engine" and if I remember it worked. There was alsoTJF working on the GUI part.
Maybe one day I'll back on this project. However I have to search the old code lost somewhere, build a linux box and learn to use GTK or an equivalent.
For now my main project is the asm 64 backend so I guess fbdebugger for linux should not be released before a long time, sorry.
But I keep it in mind.
Post Reply