Recent

Author Topic: Wierd behaviour - Laz 1.6 >> Laz 2.2  (Read 7109 times)

Bart

  • Hero Member
  • *****
  • Posts: 5290
    • Bart en Mariska's Webstek
Re: Wierd behaviour - Laz 1.6 >> Laz 2.2
« Reply #15 on: September 12, 2022, 02:41:54 pm »
I think I understand what you say but now compilation fails with many (nay numerous!) Warnings, Hints and lastly Errors such as 'Identifier not found'  "FloatToStr", "IntToStr" and "Now"

This is now the Uses Clause in the .PAS file :
Code: Pascal  [Select][+][-]
  1. uses
  2.   Classes, {SysUtils,} FileUtil, Windows,
  3.   RTTICtrls, PrintersDlgs, Forms,
  4. <snip>
  5. [/quote]
  6.  
  7. Well, removing SysUtils from te uses clause is going to give you that errors.
  8.  
  9. Bart

KodeZwerg

  • Hero Member
  • *****
  • Posts: 2081
  • Fifty shades of code.
    • Delphi & FreePascal
Re: Wierd behaviour - Laz 1.6 >> Laz 2.2
« Reply #16 on: September 12, 2022, 02:51:34 pm »
I have a funeral to attend in the morning.
I am really sorry for your lost!!!
« Last Edit: Tomorrow at 31:76:97 xm by KodeZwerg »

J-G

  • Hero Member
  • *****
  • Posts: 953
Re: Wierd behaviour - Laz 1.6 >> Laz 2.2
« Reply #17 on: September 12, 2022, 05:24:21 pm »
I am really sorry for your loss!!!
Thanks for the thought - it wasn't someone close but gave an opportunity to reminisce with some old friends - not seen for some years.
FPC 3.0.0 - Lazarus 1.6 &
FPC 3.2.2  - Lazarus 2.2.0 
Win 7 Ult 64

J-G

  • Hero Member
  • *****
  • Posts: 953
Re: Wierd behaviour - Laz 1.6 >> Laz 2.2
« Reply #18 on: September 12, 2022, 05:27:37 pm »
Well, removing SysUtils from the uses clause is going to give you that error.
At least I've become a little more aware of the workings of FPC !!   -   whether that will be a benefit or not remains to be seen :)
FPC 3.0.0 - Lazarus 1.6 &
FPC 3.2.2  - Lazarus 2.2.0 
Win 7 Ult 64

J-G

  • Hero Member
  • *****
  • Posts: 953
Re: Wierd behaviour - Laz 1.6 >> Laz 2.2
« Reply #19 on: September 12, 2022, 06:09:10 pm »
I suspect that since I am not using 'Threads', I could remove everything before the 'SysUtils' entry and I can't understand why 'Forms' is in both  %)

I've just removed 'Forms' from the .LPR file and get the same set of errors. . . .

First of the Forms unit contains the Application variable which is used by the main program file. Second you are aware that a unit (in this case Forms) can be used  from multiple different units? That's the point of them after all...
To some extent I was led astray by what I thought was Martin's suggestion that I MOVE SysUtils from the .PAS file to the .LPR file :(  I've seldom needed to look at the .LPR file  -  the exception being when being offered 'sample' projects written under Laz 2.x whilst I was still using Laz 1.6 and 'Application.Scaled' caused a problem; other than that I've considered it a 'black box' which doesn't need my meddling.

I've done some more testing but can only report back that the ADDITION of SysUtils to the .LPR file has no effect; nor does the addtion of Application.Scaled (I was clutching at straws!).

Once I get the "DATA not initialized" message and the subsequent [Break] option I'm taken to 'Customform.inc' line 381 (5) in the 'RaiseCannotFocus' Proc  ...
Code: Pascal  [Select][+][-]
  1.   procedure RaiseCannotFocus;
  2.   var
  3.     s: String;
  4.   begin
  5.     s:='[TCustomForm.SetFocus] '+Name+':'+ClassName+' '+rsCanNotFocus;
  6.     {$IFDEF VerboseFocus}
  7.     RaiseGDBException(s);
  8.     {$ELSE}
  9.     raise EInvalidOperation.Create(s);
  10.     {$ENDIF}
  11.   end;
  12.  

... where 's' is set to Nil and [F8] skips to the end of the Proc (without going to 'raise') and eventually terminates with the [217] error.

I can't see that the small modifications I've done to the project can have any bearing on the problem - afterall, it's not getting past creating even the form - so how it's finding a 'message' (which is obviously created by me) is beyond my wit. The modifications I'm doing are just concerned with creating a VAT Bridge CSV File and they are working with the version under Laz 1.6 perfectly.

FPC 3.0.0 - Lazarus 1.6 &
FPC 3.2.2  - Lazarus 2.2.0 
Win 7 Ult 64

MarkMLl

  • Hero Member
  • *****
  • Posts: 6692
Re: Wierd behaviour - Laz 1.6 >> Laz 2.2
« Reply #20 on: September 12, 2022, 06:46:28 pm »
To a reasonable approximation, the IDE puts the name of all statically-linked units in the uses section of the .lpr (Lazarus PRogram) file and that is one of the factors that controls the order initialisation blocks are called. It is common- in fact usual- for most of these to not be otherwise referenced in the .lpr file.

On rare occasions I've had to remove something that the IDE put in, or at least make it conditional, after I changed the way that the compiled representation of a unit was bound in (e.g. I changed a dynamically linked library from being loaded by the OS to being loaded under explicit software control).

Apart from that, if you remove something or change the order then you risk changing the order in which units are initialised. And taking into account the number of times that a unit registers its contents or in some other way installs or hooks a runtime resource, that can have serious effects.

In ordinary units, you only need to add them to the uses section if they contain entry points or constants/types/variables that are referenced directly: miss out something that's needed, and you'll get a compilation error; the order isn't particularly important unless you have two units exporting a function with the same name.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9905
  • Debugger - SynEdit - and more
    • wiki
Re: Wierd behaviour - Laz 1.6 >> Laz 2.2
« Reply #21 on: September 12, 2022, 06:51:11 pm »
ok, lets focus on debugging....

1)
Does your LCL the code in RaiseCannotFocus have any blue dots (when the app is running / I.e when the message box is open, and you haven't clicked any button in it yet). Do other method in the LCL have blue dots?

If not => you need to add debug info. As I said "Tools" => "Configure Build Lazarus". Custom Options: -gw
(You do not need to rebuild the IDE / next time you build/run your project, the LCL should be compiled)



2)
Pausing the app, while the message box is open (and you haven't clicked any button in it yet).
The only thing is: FpDebug (very likely) will not get you a stack for that (yet) .
But GDB might. (Does here, but that is on Windows)

If on Linux, make sure "gdb" is installed and on path (on Windows it comes with the IDE, and you don't need to bother / On Linux it is usually installed if you installed your distro for "development". Type "gdb" in a shell, and if it runs all is ok.

Tools > Option > Debugger > Backend
  In the toolbar on top is a dropdown. GDB should be in the list of that dropdown. Select it.


Run your app, wait for the message box, press "pause"

Open the thread and the stack dialog.
Go the through the threads, and make each thread "current" => for one of them you should get a stack trace.


J-G

  • Hero Member
  • *****
  • Posts: 953
Re: Wierd behaviour - Laz 1.6 >> Laz 2.2
« Reply #22 on: September 12, 2022, 11:53:03 pm »
Apologies for a late response - 'life' has to take precidence, I've had a choir rehearsal this evening.

ok, lets focus on debugging....

1)
Does your LCL the code in RaiseCannotFocus have any blue dots (when the app is running / I.e when the message box is open, and you haven't clicked any button in it yet). Do other method in the LCL have blue dots?
Yes - at lines 380,381,385 & 387  (4,5,9 & 11 in the previous code snippet)

Quote from: Martin_fr
[...]
2)
Pausing the app, while the message box is open (and you haven't clicked any button in it yet).
The only thing is: FpDebug (very likely) will not get you a stack for that (yet) .
But GDB might. (Does here, but that is on Windows)

I only use Windows.
Quote from: Martin_fr
[...]
Tools > Option > Debugger > Backend
  In the toolbar on top is a dropdown. GDB should be in the list of that dropdown. Select it.
This was set as 'Use IDE Default'  -  I've now selected Gdb[GNU...]

Quote from: Martin_fr
Run your app, wait for the message box, press "pause"

Now you have me confused  :-[   I don't see a "Pause" button - I've also checked the 'Keyboard Shortcuts'  on the offchance that I hadn't come across a function key combination that caused a 'pause' (as F9 does a 'Make') but don't see a pause there either.

Quote from: Martin_fr
Open the thread and the stack dialog.
Go the through the threads, and make each thread "current" => for one of them you should get a stack trace.
Further confusion :(   -   I'm not using 'threads'  and although I see a Keyboard Shortcut 'Display call stack   - - -  Ctrl-F3',  that doesn't reveal anything more than is already on show. Unless this is meant to show the 'Assembler' window, which has always been visible.

FPC 3.0.0 - Lazarus 1.6 &
FPC 3.2.2  - Lazarus 2.2.0 
Win 7 Ult 64

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9905
  • Debugger - SynEdit - and more
    • wiki
Re: Wierd behaviour - Laz 1.6 >> Laz 2.2
« Reply #23 on: September 13, 2022, 12:54:31 am »
There is a "pause" entry in the run menu.

There also are button for run, pause, stop, step in the toolbar below the menu.
- run: green triangle
- pause: 2 vertical bars
- stop: red square
....


You can pause an application that is running in the debugger. You can pause it at any time.
Of course if it is idle, it sits in the kernel. Then there may or may not be a stack trace....

If the debugged app is in the "show message" dialog, it will be in the kernel, but it is called by the showmessage code. => It depends on the debugger if it can get the stack.
I tested on Windows, and gdb was able..

About "threads".
At least on Windows the OS starts a helper thread when the debugger does things like pausing the app. So even if your app is not threaded, there may be more than one thread. (seen by the debugger, due to what the OS does).

Therefore you need to find the thread in which your code runs.
The way to do that, is to test them all, and see if for any thread you get a trace that includes code from your app.

The thread dialog has a "current" button. If you select an entry in the list below (while paused), and press current => then the debugger will updated the stack (and watches) to show data for that thread.
So you can select each thread, and try "current" and see what the stack window shows.

Stack and thread dialog are under menu: View > Debug Windows.




So now back to your issue.

If I got you right, when you run you app, then your app (unexpectedly) shows a message dialog?
This dialog waits for you to press OK or Cancel or whatever?

You are trying to find out why it is shown, or where it is called from?

So....
- run your app
- when the dialog is open, use the IDE and "pause" the app in the debugger.
- search the thread that has a callstack (there is no 100% guarantee that it will be there, but it's worth a shot)

If you are lucky, and you get a callstack, then you can find where in your app it happens, and from where it was called.


J-G

  • Hero Member
  • *****
  • Posts: 953
Re: Wierd behaviour - Laz 1.6 >> Laz 2.2
« Reply #24 on: September 13, 2022, 03:57:54 pm »
First I must thank you Martin for your extraordinary patience in explaining the parts of the Laz IDE that I have never before needed to explore !!

Laz/FPC has been a superb tool as far as I'm concerned and hasn't previosly demanded anything of me other than to write simple Pascal code which, on occasion,  it has told me is 'silly' with a pointer as to why and that has usually been enough for me to figure out why.

I've now found the [buttons] along with the Call Stack, Threads, Registers & Event Log windows and can see when they change with the selection of a particular thread as 'current'. Regrettably I am unable to make any useful decisions based upon that information  :-[

I actually don't really want to know why the 'DATA Not Initialized' message is shown or where it is called from - except inasmuch as it stops further execution - all I want to do is get to a situation where I can Initialize the data (by selecting the year).

I've attach two screen-grabs (taken with the program running under Laz 1.6) showing what ought to happen when I run the program. The first shows the initial screen with the option to select the year - which then goes on to read the data for that year - the second shows the message which correctly appears should I inadvertantly try to access (say) the Customer Ref. before selecting the year.

With the current state under Laz 2.2 the first thing I see is the [DATA Not Initialized] message.

The third attachment shows the various debugging windows open after the [pause] in the (vain) hope that it may prove useful.

FPC 3.0.0 - Lazarus 1.6 &
FPC 3.2.2  - Lazarus 2.2.0 
Win 7 Ult 64

J-G

  • Hero Member
  • *****
  • Posts: 953
Re: Wierd behaviour - Laz 1.6 >> Laz 2.2
« Reply #25 on: September 13, 2022, 07:33:00 pm »
I've just un-paused the program and clicked [OK] on the message which then allowed me to press [F9] to continue the 'run' which resulted in an 'Execution Stopped' message with exit-code 331 which isn't listed in the link provided by Martin in Post #7 which ends at Error 232.

I post this thinking that it might mean something to someone  -  it's way beyond my comprehension!!
FPC 3.0.0 - Lazarus 1.6 &
FPC 3.2.2  - Lazarus 2.2.0 
Win 7 Ult 64

Fred vS

  • Hero Member
  • *****
  • Posts: 3168
    • StrumPract is the musicians best friend
Re: Wierd behaviour - Laz 1.6 >> Laz 2.2
« Reply #26 on: September 13, 2022, 08:12:17 pm »
Hello.
Did you try to use fpc 3.0.0 with Lazarus 2.2.2 and compile the project with it?
See picture, change "Compiler executable" with the full path + exe of fpc 3.0.0.
Maybe it could help to isolate the problem. (there was lot of change between fpc 3.0.0 an fpc 3.2.2.)
« Last Edit: September 13, 2022, 08:32:30 pm by Fred vS »
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

J-G

  • Hero Member
  • *****
  • Posts: 953
Re: Wierd behaviour - Laz 1.6 >> Laz 2.2
« Reply #27 on: September 14, 2022, 11:51:57 am »
Hello.
Did you try to use fpc 3.0.0 with Lazarus 2.2.2 and compile the project with it?
See picture, change "Compiler executable" with the full path + exe of fpc 3.0.0.
Maybe it could help to isolate the problem. (there was lot of change between fpc 3.0.0 an fpc 3.2.2.)
Hi Fred -  I hadn't, but the idea is a good shout.  Unfortunately the last (only) BIG problem I've ever had with FPC/Laz was solved when I forced Laz 2.2 to use FPC 3.2.2  - the problem was when I upgraded and I had a persistent   "Error : TPointF not found"   -  I have just forced FPC 3.0.0 on Laz and got the same :(
FPC 3.0.0 - Lazarus 1.6 &
FPC 3.2.2  - Lazarus 2.2.0 
Win 7 Ult 64

J-G

  • Hero Member
  • *****
  • Posts: 953
Re: Wierd behaviour - Laz 1.6 >> Laz 2.2
« Reply #28 on: September 14, 2022, 11:54:30 am »
I suspect that since I am not using 'Threads', I could remove everything before the 'SysUtils' entry and I can't understand why 'Forms' is in both  %)

I appreciate that this is your first post but just repeating a part of a previous message verbatim doesn't tell me anything ???
FPC 3.0.0 - Lazarus 1.6 &
FPC 3.2.2  - Lazarus 2.2.0 
Win 7 Ult 64

MarkMLl

  • Hero Member
  • *****
  • Posts: 6692
Re: Wierd behaviour - Laz 1.6 >> Laz 2.2
« Reply #29 on: September 14, 2022, 11:59:45 am »
Whoever he is, I've got his profile open so I can see promptly if he starts dumping spam.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

 

TinyPortal © 2005-2018