Recent

Author Topic: How do you place a breakpoint in a lazarus unit?  (Read 528 times)

Hansvb

  • Hero Member
  • *****
  • Posts: 824
How do you place a breakpoint in a lazarus unit?
« on: June 19, 2025, 07:40:28 pm »
Hi,

I run into something strange and can't find it. The code sorts a DBGrid and runs without errors on win 11 but has an access violation when I run the exact same code on win10. The line where it goes wrong is
Code: Pascal  [Select][+][-]
  1. _SqlQuery.AddIndex(ASC_IndexName, _Column.FieldName,[]); (_SqlQuery is a TSQLQuery)
  ASC_IndexName and _Column.FieldName both have a value.
Now I thought to follow the underlying code to see what goes wrong but if I put a breakpoint in bufdataset unit on the first line of the TCustomBufDataset.AddIndex(...) then I don't get there with F7. Is it possible to put a breakpoint in the source code of Lazarus to see whats going on? (Lazarus 4.0)

Edit:
I now see that it is not a Lazarus unit but a Free Pascal unit. Is it possible to get there with debugging?
« Last Edit: June 19, 2025, 07:43:22 pm by Hansvb »

Thaddy

  • Hero Member
  • *****
  • Posts: 17388
  • Ceterum censeo Trump esse delendam
Re: How do you place a breakpoint in a lazarus unit?
« Reply #1 on: June 19, 2025, 07:51:06 pm »
Yes, but you need to compile the rtl with debug info and that is not standard.
Once you do that, breakpoints also work in the rtl code.
Note you can better have two installs in that case. At least I have.
Due to censorship, I changed this to "Nelly the Elephant". Keeps the message clear.

Hansvb

  • Hero Member
  • *****
  • Posts: 824
Re: How do you place a breakpoint in a lazarus unit?
« Reply #2 on: June 20, 2025, 01:01:14 pm »
Thanks, good to know. It does not seem necessary for the time being. I recreated my sqlite file and now the sorting works on win10. Have to check win11. Go provide it with the same data again and see if it continues to work. It seems as if something was wrong in the file.

Hansvb

  • Hero Member
  • *****
  • Posts: 824
Re: How do you place a breakpoint in a lazarus unit?
« Reply #3 on: June 23, 2025, 09:29:48 pm »
I finally found out why sorting on win10 didn't work and it did work on win11 with the exact same code. I don't get it. Code used comes from this wiki:
Quote
https://wiki.lazarus.freepascal.org/Grids_Reference_Page#Sorting_columns_or_rows_in_DBGrid_with_sort_arrows_in_column_header
On win10 and win11, sorting a dbgrid seemed to work well at first and suddenly on win 10 it didn't. I thought there was something wrong in the data, but found out that sorting no longer worked if the table with the data contained 20 or more records. At win 11 that was no problem but win 10 gave an access violation.
The solution seems to be to set the PacketRecords propery of the query to -1. Now it works well on both systems. It never gets a lot of data so it's no problem to retrieve all the records.

I don't get it, but it works now. Why should not using packedrecords -1 break the sorting?

 

TinyPortal © 2005-2018