Recent

Recent Posts

Pages: [1] 2 3 ... 10
1
Debugger / Re: FpDebug breakpoint on "begin"
« Last post by Martin_fr on Today at 12:10:31 am »
Not tested, but this patch should hopefully do the "one line" (and if you can spot the "1", you can make it more)

Code: Diff  [Select][+][-]
  1. diff --git a/components/fpdebug/fpdbgclasses.pp b/components/fpdebug/fpdbgclasses.pp
  2. index 2008434e26..e4b28951a8 100644
  3. --- a/components/fpdebug/fpdbgclasses.pp
  4. +++ b/components/fpdebug/fpdbgclasses.pp
  5. @@ -739,7 +739,7 @@   TDbgInstance = class(TObject)
  6.      function GetOSDbgClasses: TOSDbgClasses;
  7.      function GetPointerSize: Integer;
  8.  
  9. -    function  GetLineAddresses(AFileName: String; ALine: Cardinal; var AResultList: TDBGPtrArray): Boolean;
  10. +    function  GetLineAddresses(AFileName: String; ALine: Cardinal; var AResultList: TDBGPtrArray; AMaxFindLineBelow: integer = 0): Boolean;
  11.      function FindProcSymbol(const AName: String; AIgnoreCase: Boolean = False): TFpSymbol; overload;
  12.      function FindProcSymbol(AAdress: TDbgPtr): TFpSymbol; overload;
  13.    protected
  14. @@ -941,7 +941,7 @@   TDbgProcess = class(TDbgInstance)
  15.      function  FindSymbolScope(AThreadId, AStackFrame: Integer): TFpDbgSymbolScope;
  16.      function  FindProcStartEndPC(const AAdress: TDbgPtr; out AStartPC, AEndPC: TDBGPtr): boolean;
  17.  
  18. -    function  GetLineAddresses(AFileName: String; ALine: Cardinal; var AResultList: TDBGPtrArray; ASymInstance: TDbgInstance = nil): Boolean;
  19. +    function  GetLineAddresses(AFileName: String; ALine: Cardinal; var AResultList: TDBGPtrArray; ASymInstance: TDbgInstance = nil; AMaxFindLineBelow: integer = 0): Boolean;
  20.      //function  ContextFromProc(AThreadId, AStackFrame: Integer; AProcSym: TFpSymbol): TFpDbgLocationContext; inline; deprecated 'use TFpDbgSimpleLocationContext.Create';
  21.      function  GetLib(const AHandle: THandle; out ALib: TDbgLibrary): Boolean;
  22.      property  LibMap: TLibraryMap read FLibMap;
  23. @@ -2198,12 +2198,20 @@ destructor TDbgInstance.Destroy;
  24.    inherited;
  25.  end;
  26.  
  27. -function TDbgInstance.GetLineAddresses(AFileName: String; ALine: Cardinal; var AResultList: TDBGPtrArray): Boolean;
  28. +function TDbgInstance.GetLineAddresses(AFileName: String; ALine: Cardinal;
  29. +  var AResultList: TDBGPtrArray; AMaxFindLineBelow: integer): Boolean;
  30.  var
  31.    FoundLine: Integer;
  32.  begin
  33. -  if Assigned(DbgInfo) and DbgInfo.HasInfo then
  34. -    Result := DbgInfo.GetLineAddresses(AFileName, ALine, AResultList, fsNone, @FoundLine, @FLastLineAddressesFoundFile)
  35. +  if Assigned(DbgInfo) and DbgInfo.HasInfo then begin
  36. +    if AMaxFindLineBelow > 0 then begin
  37. +      Result := DbgInfo.GetLineAddresses(AFileName, ALine, AResultList, fsNext, @FoundLine, @FLastLineAddressesFoundFile);
  38. +      if Result then
  39. +        Result := (FoundLine >= ALine) and (FoundLine <= ALine + AMaxFindLineBelow);
  40. +    end
  41. +    else
  42. +      Result := DbgInfo.GetLineAddresses(AFileName, ALine, AResultList, fsNone, @FoundLine, @FLastLineAddressesFoundFile);
  43. +  end
  44.    else
  45.      Result := False;
  46.  end;
  47. @@ -2596,24 +2604,24 @@ function TDbgProcess.FindProcStartEndPC(const AAdress: TDbgPtr; out AStartPC,
  48.  end;
  49.  
  50.  function TDbgProcess.GetLineAddresses(AFileName: String; ALine: Cardinal;
  51. -  var AResultList: TDBGPtrArray; ASymInstance: TDbgInstance): Boolean;
  52. +  var AResultList: TDBGPtrArray; ASymInstance: TDbgInstance; AMaxFindLineBelow: integer): Boolean;
  53.  var
  54.    Lib: TDbgLibrary;
  55.  begin
  56.    if ASymInstance <> nil then begin
  57.      if ASymInstance = self then begin
  58. -      Result := inherited GetLineAddresses(AFileName, ALine, AResultList);
  59. +      Result := inherited GetLineAddresses(AFileName, ALine, AResultList, AMaxFindLineBelow);
  60.      end
  61.      else begin
  62. -      Result := ASymInstance.GetLineAddresses(AFileName, ALine, AResultList);
  63. +      Result := ASymInstance.GetLineAddresses(AFileName, ALine, AResultList, AMaxFindLineBelow);
  64.        FLastLineAddressesFoundFile := ASymInstance.FLastLineAddressesFoundFile;
  65.      end;
  66.      exit;
  67.    end;
  68.  
  69. -  Result := inherited GetLineAddresses(AFileName, ALine, AResultList);
  70. +  Result := inherited GetLineAddresses(AFileName, ALine, AResultList, AMaxFindLineBelow);
  71.    for Lib in FLibMap do begin
  72. -    if Lib.GetLineAddresses(AFileName, ALine, AResultList) then
  73. +    if Lib.GetLineAddresses(AFileName, ALine, AResultList, AMaxFindLineBelow) then
  74.        Result := True;
  75.      if Lib.FLastLineAddressesFoundFile then
  76.        FLastLineAddressesFoundFile := True;
  77. @@ -4187,7 +4195,7 @@ constructor TFpInternalBreakpointAtFileLine.Create(const AProcess: TDbgProcess;
  78.    FSymInstance := ASymInstance;
  79.  
  80.    addr := nil;
  81. -  AProcess.GetLineAddresses(AFileName, ALine, addr, ASymInstance);
  82. +  AProcess.GetLineAddresses(AFileName, ALine, addr, ASymInstance, 1);
  83.    FFoundFileWithoutLine := AProcess.FLastLineAddressesFoundFile and (Length(addr) = 0);
  84.    inherited Create(AProcess, addr, AnEnabled);
  85.  end;
  86.  
2
General / Re: Generics - correct syntax
« Last post by jamie on Today at 12:09:16 am »
Code: Pascal  [Select][+][-]
  1.   generic TCreateChildList<T> = class(specialize TFPGObjectList<T>);
  2.   TmyType = Specialize TcreateChildList<Tbutton>;
  3. var
  4.   Form1: TForm1;
  5.   Test:TmyType;
  6.  
  7. implementation
  8.  
  9. {$R *.lfm}
  10.  
  11. { TForm1 }
  12.  
  13. procedure TForm1.Button1Click(Sender: TObject);
  14. begin
  15.   Test := TmyType.Create(True);
  16.   //...
  17.   Test.free;
  18. end;                                          
  19.  

Works for me.
3
Debugger / Re: FpDebug breakpoint on "begin"
« Last post by Martin_fr on Today at 12:04:18 am »
It isn't that easy... of course not...

There are 2 possible approaches to solve it.

1) In the editor, based on knowledge the editor has
2) In the debugger, based on knowledge the debugger has

Well, mixes may be thinkable, but they are included...

1)  Editor.
The breakpoint can get set, at a time at which the debugger is not yet running, the editor does not have any info if that line will or will not get a blue dot.

- It would require an exchange when the debugger gets started.
- Breakpoints can exist in units currently not open in an editor. For those blue dots aren't loaded (and storage is bound to the editor).

So that is quite some extension. And it must all go through a generic interface that allows any backend to be bound to the IDE.

Given IFDEF and include files and macros and whatnot, finding the kind of line, and the owning procedure and all that will also need a deep dive into code tools. Though that could be omitted, just limiting it to "simple" cases.

2) The debugger
It doesn't have any source. It has to get it from the editor. But then the debugger would not go to codetools, it is not the job of the debugger to go parsing sources.






What I thing should happen

1) Very simple: Allow n lines below (n between 1 and 5 / maybe configurable)
But that could mean it goes into a different procedure. (if an "end" line has no code)

2)
When the debugger can't find line 100
- search for the next known line above, get the function name from the dwarf
- search for the next known line below, get the function name from the dwarf
- if both surrounding lines are in the same function => then use the "next known line below" (as already found).

That can still be limited by "up to max n lines".

The only disadvantage => it does not work, if the breakpoint is above the first known line of a function. E.g on the "procedure foo;" line itself.
Maybe the debugger can still see that the next found line is the first of the procedure, and take it if within a limit X (where X can be less or equal than the previous limit n)

That is
- "relatively simple"
- works for most cases
- can be done in the backend without interaction to the frontend




Backend and frontend both.

If sources are edited, the line movement is tracked "in the blue dots". Lines without them don't know if they moved. So adding a breakpoint there after editing will always be problematic. (That needs separate changes to the tracking...)





In the meantime, it might be possible to allow for "ONE line beneath".

That does only solve a subset of the issue, but it can't go very wrong either.
4
General / Re: Generics - correct syntax
« Last post by jamie on April 19, 2024, 11:58:38 pm »
I don't see any constructors ?

I am sure the object list requires them if anything..

But then again, I could have missed something?
5
General / Generics - correct syntax
« Last post by Blaazen on April 19, 2024, 11:47:34 pm »
Hi,

I'm trying this Vulkan demo: https://github.com/james-mcjohnson/VulkanLibraryForFreePascal

Why this does not work (unit vulkan_vk_xml_to_pas.pas)?
Code: Pascal  [Select][+][-]
  1.   generic TCreateChildList<T> = class(specialize TFPGObjectList<T>)

Note that it is code from 2017 and {$mode objfpc}.

IMO it should be
Code: Pascal  [Select][+][-]
  1.   generic TCreateChildList<T: class> = class(specialize TFPGObjectList<T>)

but then it crashes later with "vulkan_vk_xml_to_pas.pas(1869,10) Error: Identifier idents no member "FLevel"".
6
Databases / Re: Access violation when re-opening SQL query with parameters
« Last post by TRon on April 19, 2024, 11:44:51 pm »
PS to everyone who reads it: is it me or is the forum site slow as molasses the last few days ? It takes an average of 5 to 25 seconds for the login window to popup, never mind a refresh (which sometimes is even worse).

I was trying to keep down the posting size, but I have attached the entire demonstration project below.
Thank you. I'll have a look at it later and hopefully am able to reproduce (though I suspect the issue might be something specific to interbase).

Quote
Is there an archive of old versions somewhere? I couldn't find it on the site. Then we could go back to the old version (not the best solution) if we really have to.
Yes, on sourceforge here and in case you are looking for a specific version of Free Pascal (the used compiler) then that can be found here.

It is also not too difficult to download the source-code of Lazarus,  check-out the correct version with git (or download the required tag directly from gitlab) and build Lazarus manually. See also wiki entry

Quote
I can't believe that I'm the first person to find this problem.
Well, if you were not able to locate something similar in these forums then most likely chances are that you probably am ? Do note that I hardly know anything about interbase. Also in case someone is around that has the experience.
7
Beginners / Re: [solved] how to get class and method name from inside the method
« Last post by jamie on April 19, 2024, 11:34:44 pm »
maybe this can give you some ideas of storing method pointers somewhere too!
Code: Pascal  [Select][+][-]
  1. procedure TForm1.Button1Click(Sender: TObject);
  2. begin
  3.   caption :=TForm1.MethodName(TMethod(Button1.OnClick).Code);
  4. end;              
  5.  
  6.  

 with that, you could test the address in the event to see what method it is going to.

 in this case, it goes to itself!  :o
8
Debugger / Re: FpDebug breakpoint on "begin"
« Last post by 440bx on April 19, 2024, 11:28:09 pm »
Please report an issue (not fpdebug related) that the editor unnecessarily overlaps gutter icons.
Done.  Issue: 40914 link: https://gitlab.com/freepascal.org/lazarus/lazarus/-/issues/40914

Breakpoint on "begin" => I assume when you remove the breakpoint, then there is no blue dot on that line?    So the issue is that FPC does not generate code for that line.
You're right.  There is no blue dot on the line.

The reason why this works in gdb is, that gdb when given a line number will set the breakpoint at the next linenumber that has code (and stops at that next line...).
That's quite handy in the case of a breakpoint placed on a "begin".

GDB does that even if it is 1000 lines below.
I think that's way too many lines below.  IMO, if the line is not visible in the current editor window then it shouldn't be set.  That way there are no "surprise breakpoints".

Eventually FpDebug should have some smart way....
- a limit how many lines to look down
- determining if it is within the same function (though that will not work for the first line of a function)

For now, it has to be a line with code (actual asm statements attributed to the pascal statement on that line) in it (blue dot).
Actually, if possible, I think placing a breakpoint on a non-code line should be limited to the breakpoint being placed on a "begin" line.  In most cases, there will be a statement soon after the "begin".  The only thing that is a potential "gotcha" is a "begin end" function/procedure.  I suppose in that case the breakpoint can go on the "end" line (FPC does seem to put a blue dot for those lines.)
9
Debugger / Re: FpDebug breakpoint on "begin"
« Last post by Martin_fr on April 19, 2024, 10:57:37 pm »
Talking about begin statements (and end)...

The "begin" of a procedure/function has code, the so called "prologue" => in this code the stack frame (storage for locals) is set up. So when paused on that line, locals (and params) contain trash.

Fpc currently does not mark this line as epilogue (though fpdebug is missing the interpretation of this mark too, but given its absence...).

So the debugger gives no notice that those values are not yet initialized.

Some versions of gdb detect "popular prologue asm", and internally stop only after the prologue., when the begin line is 99% done. Then the values are correct, but you aren't really a the start of "begin".
10
Windows / Re: Lazarus for Windows on aarch64 (ARM64) - Native Compiler
« Last post by Wallaby on April 19, 2024, 10:52:25 pm »
Was there a pre-set dollar value attached to those bounties?

If there's a value where this would make sense and justify the - I'm sure excruciatingly painful - work involved, I could take it up with my employer, too.

I think last time, a year ago, I offered $300 US for each with a possibility of increase if it's difficult and takes a lot of time. Yet, it seems no one is interested.
Pages: [1] 2 3 ... 10

TinyPortal © 2005-2018