Recent

Author Topic: Why is Lazarus showing the Assembler window when debugging?  (Read 9993 times)

ricardo_sdl

  • New Member
  • *
  • Posts: 21
Why is Lazarus showing the Assembler window when debugging?
« on: August 16, 2018, 07:37:01 pm »
I usually press F8 to start a debug session on lazarus. I'm used to the debugger starting right at the first command after the begin in the program unit. But I don't know why, now Lazarus shows the Assembler window at the _mainCRTStartup symbol (image attached). Is this some configuration?
Thanks!

ps: Forgot my setup:
Lazarus 1.8.0 r56594 FPC 3.0.4 x86_64-win64-win32/win64

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: Why is Lazarus showing the Assembler window when debugging?
« Reply #1 on: August 16, 2018, 07:40:49 pm »
os? compilation target? in short, if you are on windows looks like you might have by accident or over-site disabled the win32 gui application option creating a console application instead.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

ricardo_sdl

  • New Member
  • *
  • Posts: 21
Re: Why is Lazarus showing the Assembler window when debugging?
« Reply #2 on: August 16, 2018, 07:44:20 pm »
It's a command line application.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9754
  • Debugger - SynEdit - and more
    • wiki
Re: Why is Lazarus showing the Assembler window when debugging?
« Reply #3 on: August 16, 2018, 09:13:32 pm »
Can you test with an "empty" app?
Code: Pascal  [Select][+][-]
  1. program Project1;
  2. {$mode objfpc}{$H+}
  3. begin
  4.   writeln(1);
  5.   readln;
  6. end.
  7.  

Also test with stabs and Dwarf (debug info type / project options)

This works for me (tested with Lazarus from SVN, but I think it should be the same with 1.8.4.

I know this was not always working. But I am not sure when it was fixed.

You can play around with the setting "InternalStartBreak" found in the property grid under Tools > Option > Debugger > General.
Though for me it made no difference. (except MainAddr stops at the "begin" instead of the "writeln")

---
If it works for the above empty app, but not for your app, then please supply a log file http://wiki.lazarus.freepascal.org/GDB_Debugger_Tips#Log_info_for_debug_session


ricardo_sdl

  • New Member
  • *
  • Posts: 21
Re: Why is Lazarus showing the Assembler window when debugging?
« Reply #4 on: August 17, 2018, 03:22:21 am »
Can you test with an "empty" app?
Code: Pascal  [Select][+][-]
  1. program Project1;
  2. {$mode objfpc}{$H+}
  3. begin
  4.   writeln(1);
  5.   readln;
  6. end.
  7.  

Also test with stabs and Dwarf (debug info type / project options)

This works for me (tested with Lazarus from SVN, but I think it should be the same with 1.8.4.

I know this was not always working. But I am not sure when it was fixed.

You can play around with the setting "InternalStartBreak" found in the property grid under Tools > Option > Debugger > General.
Though for me it made no difference. (except MainAddr stops at the "begin" instead of the "writeln")

---
If it works for the above empty app, but not for your app, then please supply a log file http://wiki.lazarus.freepascal.org/GDB_Debugger_Tips#Log_info_for_debug_session

That's strange. I tried your example of "empty app" and using F8 worked as I expected. Then I reloaded my project and the F8 worked fine, the break point was right at the begin keyword. I haven't changed anything. Anyway, here is the log file as suggested (https://pastebin.com/BXSHFpC9).

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9754
  • Debugger - SynEdit - and more
    • wiki
Re: Why is Lazarus showing the Assembler window when debugging?
« Reply #5 on: August 17, 2018, 04:24:07 am »
The logfile is only of interest when it does not work.

The problem could be caused by a library that is loaded in your app. (maybe only conditionally / E.g., in GUI apps (not your case) the openfile dialog loads lots of dll)

The debugger relies on debug info, and does not parse your sources to find the first line. So it needs to find the unit and line in a different way.
It looks for the symbol "main" which fpc places in your exe.
However sometimes libraries also define this. Then the debugger may not be able to tell for sure.
IIRC the debugger may remember dll from the previous run (not sure though). If it does a conditionally loaded dll could cause that (but would not on the first run).

If the problem re-occurs, after recording the log, try resetting the debugger (there is an option to do that after each run).

Thaddy

  • Hero Member
  • *****
  • Posts: 14159
  • Probably until I exterminate Putin.
Re: Why is Lazarus showing the Assembler window when debugging?
« Reply #6 on: August 17, 2018, 11:11:52 am »
If the asm window shows, you are usually in a mode with higher optimization settings. (above -O2) There is no way around that.
During debugging, make sure optimizations are turned off or at most -O2. Also include line info and use heaptrace (-glh).
In Lazarus all these options can be set under the compiler options.
Specialize a type, not a var.

ricardo_sdl

  • New Member
  • *
  • Posts: 21
Re: Why is Lazarus showing the Assembler window when debugging?
« Reply #7 on: August 17, 2018, 06:52:35 pm »
If the asm window shows, you are usually in a mode with higher optimization settings. (above -O2) There is no way around that.
During debugging, make sure optimizations are turned off or at most -O2. Also include line info and use heaptrace (-glh).
In Lazarus all these options can be set under the compiler options.

My configuration is set to -O1.

EganSolo

  • Sr. Member
  • ****
  • Posts: 290
Re: Why is Lazarus showing the Assembler window when debugging?
« Reply #8 on: November 23, 2018, 04:12:30 am »
I'm having the same issue: Assembler windows pops-up, and F8 behaves as F7, and F4 behaves as F9.
Env: Win10 + Laz 1.8.4
The two images below are snapshots of the Compiling and Linking option and the Debugging Option. Below, I have included all the options for added clarity.

-MObjFPC -Scaghi -CirotR -g -gl -gh -Xg -WG -l -vewnhibq
-Fi..\..\60-Compiled-Units\MobiCorrector\x86_64-win64
-Fi..\inc
-Fu..\src
-Fu..\..\..\LazComponents\HtmlViewer\package\lib\x86_64-win64
-Fu..\..\..\LazComponents\Ecc\EC_Controls\lib\x86_64-win64
-FuC:\lazarus\components\printers\lib\x86_64-win64\win32
-FuC:\lazarus\components\ideintf\units\x86_64-win64\win32
-Fu..\..\..\LazComponents\UTF8Tools\lib\x86_64-win64
-FuC:\lazarus\components\synedit\units\x86_64-win64\win32
-FuC:\lazarus\components\lazcontrols\lib\x86_64-win64\win32
-FuC:\lazarus\components\cairocanvas\lib\x86_64-win64\win32
-Fu..\..\..\LazComponents\ATSynEdit-master\atsynedit\lib\x86_64-win64
-FuC:\lazarus\lcl\units\x86_64-win64\win32
-Fu..\..\60-compiled-units\aiUtilities\x86_64-win64
-FuC:\lazarus\lcl\units\x86_64-win64
-FuC:\lazarus\components\lazutils\lib\x86_64-win64
-FuC:\lazarus\packager\units\x86_64-win64
-Fu.
-FU..\..\60-Compiled-Units\MobiCorrector\x86_64-win64
-FE..\..\70-dev-bin\
-dLCL
-dLCLwin32
-dMemLeakOn

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9754
  • Debugger - SynEdit - and more
    • wiki
Re: Why is Lazarus showing the Assembler window when debugging?
« Reply #9 on: November 23, 2018, 02:18:39 pm »
I'm having the same issue: Assembler windows pops-up, and F8 behaves as F7, and F4 behaves as F9.
Env: Win10 + Laz 1.8.4

Just to be sure: You are talking about using this keys to start the debugger.
That is when your application is not yet running.

If you are talking of being paused at a line, and using those to continue stepping => then the answers are totally different!
----

F4 can not be used to start an application of any type. F4 is "step over to cursor" not "run to cursor" (though that may have been renamed in 1.9 / 2.0)
This means, it will run to the location of the cursor, if
- it is inside the same method, as the one currently paused in. And at the same level of recursion.
  - So it requires to be paused in a function (If you have not started the debugger yet, your app is not in any function)
  - It will not stop, if the location is reached at a different/deeper stack level (during a recursion)
     (i.e., "step over" does not stop in any functions that are called)
- Alternatively, if the location is not reached on above condition, it will pause when stepping out

Not sure about 1.8: But in 2.0 the menu for "Step over to cursor" is disabled if you the debugger is not yet running. (And F4 should equally not work)
Before it got disabled F4 was acting like F9, because that fulfils the condition "different/deeper stack level"


Are you debugging a GUI app (forms), or a console app?
Using F7/F8 should step to the first line. In a GUI app that is always in the generated projectname.lpr file.

If that does not happen, then please send a logfile (as detailed in my previous post)

For GUI apps, if you want to stop in an event handler (eg OnFormCreate, or ButtonClicked) the only way is to set a breakpoint.
Nothing else will take you there.
« Last Edit: November 23, 2018, 02:23:16 pm by Martin_fr »

EganSolo

  • Sr. Member
  • ****
  • Posts: 290
Re: Why is Lazarus showing the Assembler window when debugging?
« Reply #10 on: November 26, 2018, 09:42:56 am »
Yes, I do mean that when I'm stopped at a breakpoint, and press F4 to get say to the end of the currently active function, the debugger ignores that request, reaches the end of the function and continues.

Yes, I'm debugging a GUI app (forms) and I'm not trying to stop inside an event handler. Basically, I've got a form which is an editor. I hit a button and the associated event calls a method of a class which has no GUI components: it's processing and transforming strings. It's when I'm in that side of the code that (a) the assembler window will pop-up on its own and (b) F8 behaves as F7 in some cases and (c) F4 is ignored even when I'm just trying to step over two or three statements inside the same function.

Hope this helps. I'll send the logfile tomorrow.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9754
  • Debugger - SynEdit - and more
    • wiki
Re: Why is Lazarus showing the Assembler window when debugging?
« Reply #11 on: November 26, 2018, 11:08:29 am »
Yes, I do mean that when I'm stopped at a breakpoint, and press F4 to get say to the end of the currently active function, the debugger ignores that request, reaches the end of the function and continues.

Yes, I'm debugging a GUI app (forms) and I'm not trying to stop inside an event handler. Basically, I've got a form which is an editor. I hit a button and the associated event calls a method of a class which has no GUI components: it's processing and transforming strings. It's when I'm in that side of the code that (a) the assembler window will pop-up on its own and (b) F8 behaves as F7 in some cases and (c) F4 is ignored even when I'm just trying to step over two or three statements inside the same function.

Hope this helps. I'll send the logfile tomorrow.
In that case:

About F7/F8 and the asm window. If you are using 64bit (Your app compiled for 64 bit) on windows then this is a known issue. It will also mean that F8 steps INTO other functions, even though it should not. It appears that some of the debug info written by FPC is not understood correctly by GDB. (I don't know which of the 2 is faulty).
If that is the case, you may have to use 32 bit (either a 32 bit IDE install, or the 32bit crosscompiler) for debugging.
(Occasionally, but not always compiling with -al seems to make a difference (using 64 bit). But that needs to include compiling any package that has debug info with -al too.)
(Using an older fpc may also work / not tested though)

It appears that GDB believes some of the called code in other functions, belongs to the caller.
So GDB may think that code at the end of the current function belongs to the next outer function... That could affect F4... but I don't know.


Another known issue are ignored exception. (64 bit only / or 32 bit if you use 32 bit SEH)
If you have any exception that you try to step over. E.g. in an other method over which you step, that other method could raise and catch an exception. It does not matter if you have added them to the ignore list (Tools > Options >Debugger) or press "Continue" in the pop up dialog that appears when the exception happens.
If you ignore an exception while stepping, your step becomes "run".
For 64bit that is partly fixed in 2.0RC3
For 32 bit, this works fine (released FPC / FPC trunk may have changes)


If you upload the log, I will see if there is anything else that I can pick up.

 

TinyPortal © 2005-2018