Value of a variable in Debugger Watch or Evaluate/Modify and hints lazarus / 12-Debugger ---------------------------------------------------------------------- bertherngreen · 2013-11-10 19:00 Hello, I just installed Lazarus-1.3-43412-fpc-2.6.2-20131110-win32. Code: [Select]procedure TForm1.Button1Click(Sender: TObject); var   i: Integer; begin   i := 1;    // After this line Delphi Evaluate/Modify shows '1', Lazarus still a random (uninitialized?) integer   i := i + 1;   // Ater this line Delphi & Lazarus both show '2'   ShowMessageFmt('%d',[i]); end; Is this since 1.3? I can't remember I did notice this behaviour in the past. Next to that trying this with a string looks different: Code: [Select]var   s: string; begin   s := 'test';   // After this line Delphi and Lazarus both show 'test'   ShowMessageFmt('%s',[s]); However trying to alter the assigned value 'test' to 'an other test' using 'evaluate/modify' succeeds but after closing the dialog and pressing F9 this ends in an exception: [Content] Project project1 raised exception class 'External: SIGSEGV'.  At address 403522 Should I post this as a bug? ---------------------------------------------------------------------- Martin_fr · 2013-11-10 19:50 1) Did you compile without optimizations, or wit -O1 ? Debugging with higher optimization will not work. 2) The file was not modified, after compile? The first blue dot is on the "begin" line, then on each line with code? 3) Stabs or Dwarf (Project Options / Debugging) ---------------- Strings and dynamic arrays can not be modified. Neither can anything, that allocates memory Unfortunately the IDE currently does not prevent that. The reason is that GDB would not call the correct fpc functions to modify such types. This corrupts internal structures. You should be able to change: a[1] BUT after "b := a;" the above will change a and b, because again gdb does not know that the 2 share the same memory (fpc uses copy on write) --- Edit: Also, note: the eval/modify window does not update, if you step. You need to evaluate again. Watches  Window or hint should update ---------------------------------------------------------------------- bertherngreen · 2013-11-10 20:21 Thank you for the explanation about strings. About the integers: 1) I did compile with  -O1 2) The file was not modified after compile, just stepping through, and no missing dots, 3) I'm not sure what you mean by 'Stabs or Dwarf'? Do you mean if I changed the settings? No, not that I'm aware of at least. The following checkboxes for settings are checked: - Generating debugging info for GDB - Display line numbers in run-time error backtraces Type of debug info is 'automatic (g)' ---------------------------------------------------------------------- Martin_fr · 2013-11-10 21:16 Indeed, I was able to reproduce the problem with I. It happens with all settings, and also with newer GDB (in case it is a GDB issue). It also happens with the development version of FPC I looked at the assembler, and where each steps ends i is at -0xc(%ebp) Code: [Select]// initialization, the 0 to i is not mandotory, and result of some setting, that I must have on. 0042C709 8955fc                   mov    %edx,-0x4(%ebp) 0042C70C c745f400000000           movl   $0x0,-0xc(%ebp) // i := 1 0042C713 b801000000               mov    $0x1,%eax 0042C718 8945f4                   mov    %eax,-0xc(%ebp) // i := i + 1 0042C71B 83c001                   add    $0x1,%eax 0042C71E 7105                     jno    0x42c725 0042C720 e87b07feff               call   0x40cea0 0042C725 8945f4                   mov    %eax,-0xc(%ebp) But GDB thinks, the "i := 1" is only the first of 2 asm statements. Stopping one early. Therefore i in memory is still 0 (only eax was loaded) Not sure if this is a problem in FPC or GDB.  looking at some of the output, I take a guess and say it is FPC ---------------------------------------------------------------------- Martin_fr · 2013-11-10 21:26 See also http://lists.freepascal.org/lists/fpc- devel/2013-November/032941.html ---------------------------------------------------------------------- Martin_fr · 2013-11-10 21:44 Update: Switching off -O1 to no opt at all, actually works. (I had just overlooked some special conf in my IDE, and therefore continued to test with -O1 ) ---------------------------------------------------------------------- bertherngreen · 2013-11-19 20:37 I can confirm this, thank you for your support.