Unable To Step Into Writeln Using F7 lazarus / 12-Debugger ---------------------------------------------------------------------- Aruna · 2025-01-08 23:47 Hello Everyone, I tried: 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  WriteLn(Format('%m', [1234.56])); // Output: $1,234.56 (locale- dependent) And it works but the '$' sign is not at the beginning as expected it is at the end of the displayed output. The attached screenshot shows this. I tried to debug and step through the Writeln function to see how it does things but have so far been unable to do so. I think I need to have the debug info compiled in? How does one go about doing this, please? And is this the expected behaviour for a format string of '%m' ? ---------------------------------------------------------------------- 440bx · 2025-01-09 00:19 The documentation for %M states that the currency sign is _appended_.  It doesn't say anything  about its position being locale dependent. see it at https://www.freepascal.org/docs- html/rtl/sysutils/format.html HTH. ---------------------------------------------------------------------- Thaddy · 2025-01-09 01:41 To step into things like writeln you need to build a debug version of the compiler. Writeln is not in any library but a compiler intrinsic. Once you have done that, you can step into writeln. ---------------------------------------------------------------------- TRon · 2025-01-09 02:26 Quote from: Aruna on January 09, 2025, 12:47:17 amAnd it works but the '$' sign is not at the beginning as expected it is at the end of the displayed output. Although it is being described in the help that %m appends the currency symbol, on linux it is actually locale dependent. Did you add the clocale unit to your test example ? If you did and the currency symbol is still displayed after the numbers then you would need to change that in the system locale settings or use a custom formatstring with FormatCurr(). As an alternative you could also fiddle with FormatSettings.CurrencyFormat. For details see https://www.freepascal.org/docs-html/rtl/sysutils/negcurrformat.html (yes, I know it says negcurrformat and that it is deprecated but please don't mind that as this is the only place where it seems listed in the help). on my system without clocale: Code: Bash  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i 1,234.56$ on my system with clocale Code: Bash  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i € 1.234,56 ---------------------------------------------------------------------- Aruna · 2025-01-09 02:33 Quote from: 440bx on January 09, 2025, 01:19:05 amThe documentation for %M states that the currency sign is _appended_.  It doesn't say anything  about its position being locale dependent. see it at https://www.freepascal.org/docs- html/rtl/sysutils/format.html HTH. I am on Linux that could be why. Thank you for  the doc link. ---------------------------------------------------------------------- Aruna · 2025-01-09 02:36 Quote from: Thaddy on January 09, 2025, 02:41:45 amTo step into things like writeln you need to build a debug version of the compiler. Writeln is not in any library but a compiler intrinsic. Once you have done that, you can step into writeln. Thank you Thaddy. Are there any recommended/preffered switches/flags or other-things to add when building a debug version of the compiler?  And do we have any documentation on how to go about building a debug version of the compiler, please? ---------------------------------------------------------------------- Aruna · 2025-01-09 02:43 Quote from: TRon on January 09, 2025, 03:26:14 amAlthough it is being described in the help that %m appends the currency symbol, on linux it is actually locale dependent. This is what I was starting to think as well. Thank you for confirming my suspicions. Quote from: TRon on January 09, 2025, 03:26:14 amDid you add the clocale unit to your test example ? If you did and the currency symbol is still displayed after the numbers then you would need to change that in the system locale settings or use a custom formatstring with FormatCurr(). As always you were right. I added clocal and now it displays where "I" like currency symbols to be as a prefix. Quote from: TRon on January 09, 2025, 03:26:14 amAs an alternative you could also fiddle with FormatSettings.CurrencyFormat. For details see https://www.freepascal.org/docs-html/rtl/sysutils/negcurrformat.html (yes, I know it says negcurrformat and that it is deprecated but please don't mind that as this is the only place where it seems listed in the help). Thank you @Tron I will go through the link. Quote from: TRon on January 09, 2025, 03:26:14 amon my system without clocale: Code: Bash  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i 1,234.56$ on my system with clocale Code: Bash  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i € 1.234,56 Exact same scenario in my Debian. Works after adding clocale like you said. Many thanks and much obliged. @Tron what would be the best+easiest way to build a debug version of the compiler? ---------------------------------------------------------------------- Thaddy · 2025-01-09 06:48 Quote from: Aruna on January 09, 2025, 03:36:39 amThank you Thaddy. Are there any recommended/preffered switches/flags or other-things to add when building a debug version of the compiler?  And do we have any documentation on how to go about building a debug version of the compiler, please? The simplest way is to use fpcupdeluxe setup+ and select both debug boxes to the top right hand side of the dialog. In this case using fpcupdeluxe is highly recommended because it is easy to set up the debug compiler with its own path/environment. That is important because you really do not want to use the debug build for anything other than debugging compiler internals or the rtl. ---------------------------------------------------------------------- TRon · 2025-01-09 11:52 Quote from: Aruna on January 09, 2025, 03:43:14 amAs always you were right. Thank you for the confidence but please be careful. I am more wrong than I am am right  QuoteExact same scenario in my Debian. Works after adding clocale like you said. Do realize that the locale can be anything when the application is ran on another setup e.g. it does not have to output the same on another machine/setup/config. In case that is an actual requirement (f.i. always display dollars instead of user's locale preference) then there is need to let your code use custom formatsettings (e.g. adjusted to the programs need to always display dollars). QuoteMany thanks and much obliged. @Tron what would be the best+easiest way to build a debug version of the compiler? You're most welcome. As described by Thaddy using fpcupdeluxe for a separate installation (for both FPC and Lazarus) with debug information usually would be the easiest especially in case not familiar with building the compiler from source. ---------------------------------------------------------------------- rvk · 2025-01-09 12:41 QuoteAs described by Thaddy using fpcupdeluxe for a separate installation (for both FPC and Lazarus) with debug information usually would be the easiest especially in case not familiar with building the compiler from source. And if you're not familiar with compiling the source of FPC, you probably don't have much use of 'stepping into' the writeln() procedure. Besides... you don't want the writeln() anyway... you want the Format() function. And for that you can put your cursor on Format(), press Alt+Up, then press Ctrl+Shift+Down. With those keys you can jump all around the sourcecode. ---------------------------------------------------------------------- Thaddy · 2025-01-09 13:08 Quote from: rvk on January 09, 2025, 01:41:47 pmBesides... you don't want the writeln() anyway... you want the Format() function. I prefer the formatting capabilities of writeln to Format and family, because it does not rely on sysutils and is just as powerful. Except here the m option. Ah, misinterpreted, I see what you mean, he needs to step into format, that makes sense. ---------------------------------------------------------------------- Aruna · 2025-01-09 23:49 Quote from: Thaddy on January 09, 2025, 07:48:23 amQuote from: Aruna on January 09, 2025, 03:36:39 amThank you Thaddy. Are there any recommended/preffered switches/flags or other-things to add when building a debug version of the compiler?  And do we have any documentation on how to go about building a debug version of the compiler, please? The simplest way is to use fpcupdeluxe setup+ and select both debug boxes to the top right hand side of the dialog. In this case using fpcupdeluxe is highly recommended because it is easy to set up the debug compiler with its own path/environment. That is important because you really do not want to use the debug build for anything other than debugging compiler internals or the rtl. Thank you again for the guidance. I want to try and build it from the source without using fpcupdeluxe if I can. I will use fpcupdeluxe if everything else I try fails ---------------------------------------------------------------------- Aruna · 2025-01-09 23:57 Quote from: TRon on January 09, 2025, 12:52:09 pmQuote from: Aruna on January 09, 2025, 03:43:14 amAs always you were right. Thank you for the confidence but please be careful. I am more wrong than I am am right  Thanks I will be careful Quote from: TRon on January 09, 2025, 12:52:09 pmDo realize that the locale can be anything when the application is ran on another setup e.g. it does not have to output the same on another machine/setup/config. In case that is an actual requirement (f.i. always display dollars instead of user's locale preference) then there is need to let your code use custom formatsettings (e.g. adjusted to the programs need to always display dollars). Thank you @TRon I am just trying to learn the available format specifiers and how to use them. Quote from: TRon on January 09, 2025, 12:52:09 pmAs described by Thaddy using fpcupdeluxe for a separate installation (for both FPC and Lazarus) with debug information usually would be the easiest especially in case not familiar with building the compiler from source. I am grateful to @Thaddy for showing me the safest way to proceed forward but if I use fpcupdeluxe then I will never learn how to build the compiler from source. So I will give building from the source a try, and then failing will give fpcdeluxe a shot? ---------------------------------------------------------------------- Aruna · 2025-01-10 00:12 Quote from: rvk on January 09, 2025, 01:41:47 pmQuoteAs described by Thaddy using fpcupdeluxe for a separate installation (for both FPC and Lazarus) with debug information usually would be the easiest especially in case not familiar with building the compiler from source. And if you're not familiar with compiling the source of FPC, you probably don't have much use of 'stepping into' the writeln() procedure. Hello @rvk, yes I am not familiar with building the compiler from the source (yet) and yes I do have a reason for wanting to step through both writeln() and format() purely for my own understanding how things work under the hood. Quote from: rvk on January 09, 2025, 01:41:47 pmBesides... you don't want the writeln() anyway... you want the Format() function. And for that you can put your cursor on Format(), press Alt+Up, then press Ctrl+Shift+Down. With those keys you can jump all around the sourcecode. Thank you, I did this already and though it lets me jump around the code it is not the same thing as bein able to single-step and examine/watch how things are done. So please help me to build from source if you do not mind doing so? I have:  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 /usr/share/fpcsrc/3.2.2/ There is a Makefile in there. I also have: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  /usr/share/fpcsrc/3.2.2/compiler And another Makefile. Which one do I use to build and which switches/flags do I use to get a debug build?  If the time to build is not too long I am thinking I will simply build a debug version anytime I need to understand a compiler intrinsic or RTL and revert back once done to a normal build. ---------------------------------------------------------------------- Aruna · 2025-01-10 00:41 I asked chatGPT and this was generated. Is this correct: 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 make clean all OPT="-g -dDEBUG" ---------------------------------------------------------------------- Marc · 2025-01-10 08:09 Quote from: Aruna on January 10, 2025, 01:41:44 amI asked chatGPT and this was generated. Is this correct: 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 make clean all OPT="-g -dDEBUG" IIRC it looks ok ---------------------------------------------------------------------- TRon · 2025-01-10 11:42 Quote from: Aruna on January 10, 2025, 01:41:44 amI asked chatGPT and this was generated. Is this correct: 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 make clean all OPT="-g -dDEBUG"Sorry, I missed that question. Yes that is ok. Note that you need a 3.2.0 bootstrap compiler to build the 3.2.2 compiler (option PP=/path/to/ppcXXX/exe or FPC=/path/to/fpc/exe) ---------------------------------------------------------------------- Aruna · 2025-01-10 11:55 Quote from: Marc on January 10, 2025, 09:09:45 amQuote from: Aruna on January 10, 2025, 01:41:44 amI asked chatGPT and this was generated. Is this correct: 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 make clean all OPT="-g -dDEBUG" IIRC it looks ok Thank you @Marc, I gave it a go and it did not take a long time as you  can see below: 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 aruna@debian:/usr/share/fpcsrc/3.2.2$ time sudo make clean all OPT="-g -dDEBUG" 2>&1 | tee /tmp/output.txt  ... // just too much make output info to post here I will attatch a text file ...make[1]: *** [Makefile:2800: compiler_cycle] Error 2make[1]: Leaving directory '/usr/share/fpcsrc/3.2.2'make: *** [Makefile:2832: build-stamp.x86_64-linux] Error 2 real    2m58.461suser    2m34.755ssys     0m13.657s  So it took almost 3 minutes which is fine and works for me. Just to be sure then I ran: sudo make install and that took: 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 make[3]: Leaving directory '/usr/share/fpcsrc/3.2.2/utils'make[2]: Leaving directory '/usr/share/fpcsrc/3.2.2'make[1]: Leaving directory '/usr/share/fpcsrc/3.2.2' real    0m16.271suser    0m0.578ssys     0m2.185s Then Just to be sure I ran this: 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 aruna@debian:/usr/share/fpcsrc/3.2.2$ file /usr/bin/fpc/usr/bin/fpc: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, for GNU/Linux 2.4.0, stripped Which still shows my compiler has debug info/symbols stripped. So I am very confused now I have attached two text files. output.txt contains the make debug version stuff and installoutput.txt has the make install stuff. ---------------------------------------------------------------------- Aruna · 2025-01-10 11:59 Quote from: TRon on January 10, 2025, 12:42:34 pmQuote from: Aruna on January 10, 2025, 01:41:44 amI asked chatGPT and this was generated. Is this correct: 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 make clean all OPT="-g -dDEBUG"Sorry, I missed that question. Yes that is ok. Note that you need a 3.2.0 bootstrap compiler to build the 3.2.2 compiler (option PP=/path/to/ppcXXX/exe or FPC=/path/to/fpc/exe) Hi @TRon, you mean like this: 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 make clean all OPT="-g -dDEBUG"  FPC=/path/to/fpc/exe ---------------------------------------------------------------------- TRon · 2025-01-10 12:04 Quote from: Aruna on January 10, 2025, 12:59:16 pmHi @TRon, you mean like this: 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 make clean all OPT="-g -dDEBUG"  FPC=/path/to/fpc/exeYes, like that (actually is FPC="/path/and/name/to/fpc/exe"). Though I personally prefer 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 make clean all OPT="-g -dDEBUG"  PP=/path/and/name/to/ppcXX/exebecause the former requires to have a working 3.2.0 setup while the second requires only the ppcXXX executable. For the purists amongst us reading this: yes I am aware that you can use FPC to point to the PP executable but my OCD prevents me from advertising it ---------------------------------------------------------------------- Martin_fr · 2025-01-10 12:08 If you are an Windows, and using FpDebug in Lazarus you want to use  -gw3 If you use gdb for some reason, you likely want -gw2 -godwarfsets  (though some versions of gdb may be ok with -gw3 especially if you use fpc fixes or trunk) If you are on Linux, the same applies. However, if you use -gw3 you may be forced to use this for all/any package and project that has debug info, otherwise you may get linker errors, when building your project. Equally on Linux if you use -gw2 then you may need to use that every where else. Actually the  dependency exists in one direction only, and I am not sure which one. (Using just -g is translated by the compiler to either -gw2 or -gw3 / depends...). Also, write and writeln are compiler intrinsics. They aren't functions You can't step into them, but you will be able to step into some of the functions from which the compiler builds them. However, what you actually want to step in is the "format" function. And that will work. ---------------------------------------------------------------------- Thaddy · 2025-01-10 12:12 Almost:OPT="-glh -dDEBUG" would work, adds line info and heaptrace. ---------------------------------------------------------------------- TRon · 2025-01-10 12:15 Thank you for the additional information Martin_fr because you are ofc. right. I usually don't consider the debugger used but fpDebug is a very nice upgrade (getting better each release with your additions) ---------------------------------------------------------------------- Aruna · 2025-01-10 12:29 Quote from: TRon on January 10, 2025, 01:04:25 pmQuote from: Aruna on January 10, 2025, 12:59:16 pmHi @TRon, you mean like this: 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 make clean all OPT="-g -dDEBUG"  FPC=/path/to/fpc/exeYes, like that (actually is FPC="/path/and/name/to/fpc/exe"). Though I personally prefer 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 make clean all OPT="-g -dDEBUG"  PP=/path/and/name/to/ppcXX/exebecause the former requires to have a working 3.2.0 setup while the second requires only the ppcXXX executable. For the purists amongst us reading this: yes I am aware that you can use FPC to point to the PP executable but my OCD prevents me from advertising it  @Tron my archtiecture is x86_64 so do I need the ppc stuff? Or ? ---------------------------------------------------------------------- Aruna · 2025-01-10 12:32 Quote from: Martin_fr on January 10, 2025, 01:08:11 pmIf you are an Windows, and using FpDebug in Lazarus you want to use  -gw3 If you use gdb for some reason, you likely want -gw2 -godwarfsets  (though some versions of gdb may be ok with -gw3 especially if you use fpc fixes or trunk) If you are on Linux, the same applies. However, if you use -gw3 you may be forced to use this for all/any package and project that has debug info, otherwise you may get linker errors, when building your project. Equally on Linux if you use -gw2 then you may need to use that every where else. Actually the  dependency exists in one direction only, and I am not sure which one. (Using just -g is translated by the compiler to either -gw2 or -gw3 / depends...). Also, write and writeln are compiler intrinsics. They aren't functions You can't step into them, but you will be able to step into some of the functions from which the compiler builds them. However, what you actually want to step in is the "format" function. And that will work.   Hi @Martin_fr, I am using Linux, Debian and the system is x86_64. Why am I able to compile without errors but nothing changes in my install? My fpc remains stripped. What I am not doing correctly? ---------------------------------------------------------------------- Aruna · 2025-01-10 12:39 Quote from: Thaddy on January 10, 2025, 01:12:01 pmAlmost:OPT="-glh -dDEBUG" would work, adds line info and heaptrace. Ah, this is very useful. Thank you @Thaddy ( Aruna wonders where these things are documnted?) ---------------------------------------------------------------------- Martin_fr · 2025-01-10 12:45 While you should be able to get an "fpc" and "ppc...." with debug info (after you do "make install INSTALL_PREFIX=..." => it does not matter if you do. You do not need those 2 files to have debug info. You do need debug info in the RTL/FCL => those are the *.ppu or *.o files. After you did "make"  your fpc, you need to install those files somewhere. (ideally using (IIRC) INSTALL_PREFIX). You then need to create an fpc.cfg for those. There is a tool, but I need to look up the details myself. And, since you are on linux, you most likely have /etc/fpc.cfg  (or maybe some other in your home dir) And that will very likely be in the way. fpcupdeluxe can help It will create everything you need. But, there still may be (likely "will be") other global files in the way. fpcupdeluxe  creates special scripts (foo.sh) for lazarus (if you did build that too / you do NOT need to), and for fpc. And if you configure the compiler in your lazarus IDE, then you need to point it to that very script. That script will contain additional command line params, making sure that your special fpc does not get confused by any other fpc install on your system). Sorry for some of that being vague. I don't recall all the detail. I would have to search for them myself. ---------------------------------------------------------------------- MarkMLl · 2025-01-10 13:12 Quote from: Aruna on January 10, 2025, 01:39:57 pmQuote from: Thaddy on January 10, 2025, 01:12:01 pmAlmost:OPT="-glh -dDEBUG" would work, adds line info and heaptrace. Ah, this is very useful. Thank you @Thaddy ( Aruna wonders where these things are documnted?) In the Programmer's Guide circa https://www.freepascal.org/docs- html/current/prog/progap6.html#x327-343000F , but being able to read the (industry-standard) Makefile and having some minimal knowledge of the other (non-standard) build utilities is valuable. MarkMLl ---------------------------------------------------------------------- Aruna · 2025-01-11 03:13 Hello Everyone, I just figured out why everything compiles with zero errors but my /usr/bin/fpc stays stripped. The make install goes and puts the compiler in /usr/local/bin/fpc: 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 aruna@debian:/usr/share/fpcsrc/3.2.2$ file  /usr/local/bin/fpc/usr/local/bin/fpc: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, for GNU/Linux 2.4.0, with debug_info, not stripped So now how do I get the lazarus IDE to use *this* compiler? Hi Martin_fr thank you for pointing out there is a /etc/fpc.cfg and @MarkMLI many thanks for the link. It says make cycle? Is this still valid? I haven't tested it yet.  Been a rather long day I am dog tired but wanted to respond to you before grabbing some grub. ---------------------------------------------------------------------- TRon · 2025-01-11 03:31 Quote from: Aruna on January 11, 2025, 04:13:08 amI just figured out why everything compiles with zero errors but my /usr/bin/fpc stays stripped. The make install goes and puts the compiler in /usr/local/bin/fpc: A story for another time but wanted to mention that the compiler can be installed anywhere you choose to. QuoteSo now how do I get the lazarus IDE to use *this* compiler? Lazarus IDE, menu, Tools, options, in tree select "files", at right there are options "compiler executable" and "FPC source directory" Depending on what debug format chosen you also might want to have a look at tree "Debugger" (f.e. debugger backend etc)