Line numbers for heaptrc lazarus / 33-macOS - Mac OS X ---------------------------------------------------------------------- ChrisR · 2018-10-02 15:06 With the rapid progress of Cocoa, I am doing more development on MacOS. One feature I like with Windows is that the heaptrc reports the line number that generated a leak. However, even though I set the Project Options/Debugging options to generate line numbers and use Heaptrc, when I test a project in MacOS I do not get line numbers for the leak. Consider the code: procedure TForm1.LeakBtnClick(Sender: TObject); var   PascalFiles: TStringList; begin   PascalFiles := TStringList.Create; end; When I run this on MacOS, the leak is reported, but it misses line number Heap dump by heaptrc unit 1813 memory blocks allocated : 2107894/2112200 1812 memory blocks freed     : 2107774/2112080 1 unfreed memory blocks : 120 True heap size : 884736 (32 used in System startup) True free heap : 884416 Should be : 884456 Call trace for block $00000001009F4500 size 120   $00000001001D1460   $000000010026981A   $0000000100269FDF   $0000000100269722   $0000000100012A43   $00000001001C34D6   $00000001001AF7B8   $00000001001AF8C3 In contrast, Windows includes "line 37 of unit1.pas" ---------------------------------------------------------------------- Pascal · 2018-10-02 17:25 Compile you project (and optionally fpc) with -gl -O- (At least this helps on windows). ---------------------------------------------------------------------- ChrisR · 2018-10-02 19:00 @Pascal,   Thanks for the suggestion, but it does not help. I think this is the minimal project: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i program leak;uses Classes;var  PascalFiles: TStringList;begin  PascalFiles := TStringList.Create;end. On MacOS if I compile with  $ fpc -g -gl -gh -O- -gh leak.pas I get $ ./leak Heap dump by heaptrc unit 22 memory blocks allocated : 2176/2176 21 memory blocks freed     : 2056/2056 1 unfreed memory blocks : 120 True heap size : 655360 (32 used in System startup) True free heap : 655040 Should be : 655080 Call trace for block $00000001001EE300 size 120 The [leakview][http://wiki.freepascal.org/leakview] does not show anything more. This [2017 stackoverflow][https://stackoverflow.com/questions/47660310/unable-to- generate-line-numbers-in-fpc-debugging-output] question also suggests heaptrc does not provide line numbers with MacOS. One of the commenters suggests if requires ppc32 architecture on macOS. I guess this might refer to PowerPC, as targeting either 32-bit i386 or 64-bit x86_64 had no influence. ---------------------------------------------------------------------- Cyrax · 2018-10-02 19:12 Does FPC for Mac OS support DWARF 2 debug information? Try to add -gw2 at the command line options. ---------------------------------------------------------------------- ChrisR · 2018-10-02 20:24 $ fpc -gl -gh -O- -gh -gw2 leak.pas generates the same output - still no line numbers, as does -gw, -gs, -gw3 ---------------------------------------------------------------------- TRon · 2018-10-03 00:06 no guarantees but try FPC trunk. See also mantis 32775