Recent

Author Topic: more debuggery.  (Read 2489 times)

lazer

  • Full Member
  • ***
  • Posts: 215
Re: more debuggery.
« Reply #15 on: October 24, 2022, 10:52:41 pm »
When I  said  "build with GDB" I meant build with generation of GDB debug information included , which is what the -g switches are about. Obviously I don't mean build by running GDB on the source code.


Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9857
  • Debugger - SynEdit - and more
    • wiki
Re: more debuggery.
« Reply #16 on: October 24, 2022, 11:21:37 pm »
About the nested procs.

Could you try and build the IDE with the patch below applied, please.
It removes various over-carefully checks.

It also adds some debug output. If (with the patch) the problem remains, then please run the IDE using
  lazarus --debug-log=/home/name/laz_log.txt 
And send the file / you can check the file, I need the parts that contain "parentfp" in  the text.
(you might sent the file anyway, even if it works / it may tell me why ... / thanks)


Code: Diff  [Select][+][-]
  1. diff --git a/components/fpdebug/fpdbgdwarffreepascal.pas b/components/fpdebug/fpdbgdwarffreepascal.pas
  2. index b752de1dfb..77f47e19ae 100644
  3. --- a/components/fpdebug/fpdbgdwarffreepascal.pas
  4. +++ b/components/fpdebug/fpdbgdwarffreepascal.pas
  5. @@ -636,22 +636,17 @@ function TFpDwarfFreePascalSymbolScope.FindLocalSymbol(const AName: String;
  6.    SearchCtx := TFpDbgDwarfSimpleLocationContext.Create(MemManager, 0, SizeOfAddress, LocationContext.ThreadId, i);
  7.  
  8.    cur_fp := 0;
  9. +  debugln(['Search parentfp ', dbghex(par_fp)]);
  10.    if LocationContext.ReadRegister(RegFp, cur_fp) then begin
  11. -    if cur_fp > par_fp then
  12. -      d := -1  // cur_fp must go down
  13. -    else
  14. -      d := 1;  // cur_fp must go up
  15.      while not (cur_fp = par_fp) do begin
  16.        SearchCtx.FStackFrame := i;
  17. -      // TODO: get reg num via memreader name-to-num
  18. -      prev_fp := cur_fp;
  19.        if not SearchCtx.ReadRegister(RegFp, cur_fp) then
  20.          break;
  21. +        debugln(['testing parentfp ', i, ': ', dbghex(cur_fp)]);
  22.        inc(i);
  23. -      if (cur_fp = prev_fp) or ((cur_fp < prev_fp) xor (d = -1)) then
  24. -        break;  // wrong direction
  25.        if i > LocationContext.StackFrame + 200 then break; // something wrong? // TODO better check
  26.      end;
  27. +    debugln(['END parentfp ', i, ': ', dbghex(cur_fp)]);
  28.      dec(i);
  29.    end;
  30.  
  31.  

lazer

  • Full Member
  • ***
  • Posts: 215
Re: more debuggery.
« Reply #17 on: October 25, 2022, 12:04:31 am »
I've applied the patch, do I need a make clean, or does the Makefile keep track of changes ?

I did a straight build and I don't see any difference at first look.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9857
  • Debugger - SynEdit - and more
    • wiki
Re: more debuggery.
« Reply #18 on: October 25, 2022, 12:30:49 am »
Good question. As I said, I don't use the makefiles (I always rebuild from inside the IDE).

If you run the debug log, you should see if it outputs the info.
Or instead, run lazarus from a terminal, and you should see it print to the terminal.
If there are lines ".... parentfp ....", then the patch is applied. (And those lines, I would need a copy of)

lazer

  • Full Member
  • ***
  • Posts: 215
Re: more debuggery.
« Reply #19 on: October 25, 2022, 11:26:49 am »
OK, I applied the patch and verified manually that the file has changed as expected.
I did

Code: Pascal  [Select][+][-]
  1. make clean; make bigide

I started the IDE from a terminal window, as I aways do with problematic software, and had to recompile and reinstall a small custom component I use.  This rebuilds the LCL and restarts IDE.

Running a debug session up to the same code I do not see any such output to the console. Variable scope shows same issues.

Maybe I misunderstood your instructions.

Code: Pascal  [Select][+][-]
  1. TGDBMIDebuggerBase.StartDebugging WorkingDir="~/laz/"
  2.  
  3. (lazarus:98372): Pango-WARNING **: 11:09:31.261: Invalid UTF-8 string passed to pango_layout_set_text()
  4.  
  5. (lazarus:98372): Pango-WARNING **: 11:09:31.268: Invalid UTF-8 string passed to pango_layout_set_text()
  6.  
  7. (lazarus:98372): Pango-WARNING **: 11:09:32.421: Invalid UTF-8 string passed to pango_layout_set_text()
  8.  
  9. (lazarus:98372): Pango-WARNING **: 11:09:32.426: Invalid UTF-8 string passed to pango_layout_set_text()
  10.  
  11. (lazarus:98372): Pango-WARNING **: 11:09:33.348: Invalid UTF-8 string passed to pango_layout_set_text()
  12.  
  13. (lazarus:98372): Pango-WARNING **: 11:09:33.352: Invalid UTF-8 string passed to pango_layout_set_text()
  14.  
  15. (lazarus:98372): Pango-WARNING **: 11:09:34.252: Invalid UTF-8 string passed to pango_layout_set_text()
  16.  
  17. (lazarus:98372): Pango-WARNING **: 11:09:34.255: Invalid UTF-8 string passed to pango_layout_set_text()
  18.  
  19. (lazarus:98372): Pango-WARNING **: 11:09:56.808: Invalid UTF-8 string passed to pango_layout_set_text()
  20.  
  21. (lazarus:98372): Pango-WARNING **: 11:10:03.489: Invalid UTF-8 string passed to pango_layout_set_text()
  22. ### TCodeToolManager.HandleException: [20170421200105] "identifier not found: bytecount" at Line=767 Col=14 in "~/laz/pack.pas"
  23. ### TCodeToolManager.HandleException: [20170421200105] "identifier not found: maxlen" at Line=767 Col=24 in "~/laz/pack.pas"
  24. ### TCodeToolManager.HandleException: [20170421200105] "identifier not found: suffix" at Line=768 Col=3 in "~/laz/pack.pas"
  25. ### TCodeToolManager.HandleException: [20170421200105] "identifier not found: msgstr" at Line=769 Col=3 in "~/laz/pack.pas"
  26. LAZARUS END - cleaning up ...
  27. FreeFormEditor: FormEditor1=TFormEditor
  28.  
  29. (lazarus:98372): GLib-GObject-CRITICAL **: 11:12:09.622: g_object_unref: assertion 'G_IS_OBJECT (object)' failed
  30. Hint: (lazarus) [TMainIDE.Destroy] B  -> inherited Destroy... TMainIDE
  31. Hint: (lazarus) [TMainIDE.Destroy] END
  32. [/c

lazer

  • Full Member
  • ***
  • Posts: 215
Re: more debuggery.
« Reply #20 on: October 25, 2022, 12:42:03 pm »
BTW

Code: Pascal  [Select][+][-]
  1.  type
  2.   varstring=shortstring;     // shortstring aka string[255]
  3.  
  4.  
  5. function Tpack.fillpack:boolean; {true if success,res unused!****}
  6. var
  7.   index,resp,bytecount,maxlen:integer;
  8.   suffix,packnumstr:string[5];
  9.   msgstr:varstring;
  10.  
  11.  

This seems too complicated for the hover hint evaluation.  It tells me to cast msgstr to its "original" type, despite it being its original type.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9857
  • Debugger - SynEdit - and more
    • wiki
Re: more debuggery.
« Reply #21 on: October 25, 2022, 12:59:23 pm »
Quote
Code: Text  [Select][+][-]
  1. TGDBMIDebuggerBase.StartDebugging WorkingDir="~/laz/"

Are you sure you are using FpDebug ?

The above says you are using the "gdb based" debugger backend.
And while that should be able to deal with nested procs, it has lots of known issues. Many of them caused by gdb, so they can't be fixed by us.

lazer

  • Full Member
  • ***
  • Posts: 215
Re: more debuggery.
« Reply #22 on: October 25, 2022, 01:04:49 pm »
good point, the last reset caused by rebuild probably reset debugging to -g1

I'll check it.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9857
  • Debugger - SynEdit - and more
    • wiki
Re: more debuggery.
« Reply #23 on: October 25, 2022, 01:22:11 pm »
good point, the last reset caused by rebuild probably reset debugging to -g1

"-g1" ? That does not exist.

The -g* options add debug info (and other debug related stuff) to the exe.

The debug info is then be used by the debugger, chosen in Tools > Options > Debugger Backend (or Project > Project Options > Debugger).

Adding a specific debug info (dwarf 2/3 or stabs) or omitting debug info entirely, does not choose an other debugger-backend. It may however stop a debugger backend from working.
E.g. if you are on a platform that still supports stabs ( -gs ), and you force stabs, then FpDebug will not work. You will get the prompt to use dwarf.




Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9857
  • Debugger - SynEdit - and more
    • wiki
Re: more debuggery.
« Reply #24 on: October 25, 2022, 01:28:00 pm »
Oh btw.... OFF-TOPIC to debugging

Quote
Code: Text  [Select][+][-]
  1. ### TCodeToolManager.HandleException: [20170421200105] "identifier not found: bytecount" at Line=767 Col=14 in "~/laz/pack.pas"

That is code-navigation, code-completion and declaration hint. That is the IDE's internal pascal parser.

"declaration hint" is the hint (mouse hover) you get, telling you where a variable is declared. This happens when you edit text (e.g. when you do not debug).
However when you debug, the hint that shows the "current value" will also contain the declaration hint. So declaration hint is always triggered when you get a hint.

Assuming the code was valid (did compile), then some part of your code breaks the internal Pascal parser too.
However, this can only be fixed, with an example to reproduce it.

lazer

  • Full Member
  • ***
  • Posts: 215
Re: more debuggery.
« Reply #25 on: October 25, 2022, 01:33:26 pm »
OK, I just checked Project options ( that is what I was refering to ) .  It is still set at -gw3  , I have seen this get reset sometimes , maybe when I had cleared out ~/.lazarus to get a clean start.

So I'm building with  gw3 and you are not seeing the expected output :?


lazer

  • Full Member
  • ***
  • Posts: 215
Re: more debuggery.
« Reply #26 on: October 25, 2022, 01:35:00 pm »
I just posted above one think which is breaking hover hint evaluation.

https://forum.lazarus.freepascal.org/index.php/topic,61004.msg457887.html#msg457887
Code: Pascal  [Select][+][-]
  1. function Tpack.fillpack:boolean; {true if success,res unused!****}
  2. var
  3.   index,resp,bytecount,maxlen:integer;
  4.   suffix,packnumstr:string[5];
  5.   msgstr:varstring;
  6.  
  7.  
  8.   function readpackfile(numrecs:integer):integer;
  9.  
  10.   {attempts to read numrec records from card file -
  11.    returns with number of records sucessfully read}
  12.  
  13.   var
  14.     f:text;
  15.     srec:Tsearchrec;
  16.     ii,index:integer;
  17.     filename:string[pathlen+1+12];  {path\dosfilename}
  18.  
  19.     function locfexist:boolean;      // why dupe with locfexist ???
  20.     begin
  21.       xDosError:=sysutils.findfirst(strcon(filename),$3F,srec);
  22.       findClose(srec);
  23.       locfexist:=(xDosError=0);
  24.       if xDosError=2 then IOcode:=3 else IOcode:=xDosError;
  25.       IOerr:=IOcode<>0;
  26.     end; {locFexist}
  27.  
  28.  
  29.   begin  {body readpackfile}
  30.     index:=0;
  31.  

If I but a break point on the last line there, the first line of readpackfile,  and I hover I get an uninitialised value but it works.

If I hover the var declarations at the top of fillpack, it can't find them. This included "index", so the working eval is finding the local var index not that of the caller. ( That would be fine if the rest was working , that should take precidence anyway ).

On the console I get this:

Code: Pascal  [Select][+][-]
  1. ### TCodeToolManager.HandleException: [20170421200105] "identifier not found: msgstr" at Line=771 Col=3 in "~/laz/pack.pas"
  2. ### TCodeToolManager.HandleException: [20170421200105] "identifier not found: msgstr" at Line=771 Col=3 in "~/laz/pack.pas"
  3. ### TCodeToolManager.HandleException: [20170421200105] "identifier not found: packnumstr" at Line=770 Col=10 in "~/laz/pack.pas"
  4. ### TCodeToolManager.HandleException: [20170421200105] "identifier not found: bytecount" at Line=769 Col=14 in "~/laz/pack.pas"
  5. ### TCodeToolManager.HandleException: [20170421200105] "identifier not found: index" at Line=769 Col=3 in "/back~/laz/pack.pas"
  6.  
« Last Edit: October 25, 2022, 01:45:14 pm by lazer »

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9857
  • Debugger - SynEdit - and more
    • wiki
Re: more debuggery.
« Reply #27 on: October 25, 2022, 01:39:58 pm »
OK, I just checked Project options ( that is what I was refering to ) .  It is still set at -gw3  , I have seen this get reset sometimes , maybe when I had cleared out ~/.lazarus to get a clean start.

So I'm building with  gw3 and you are not seeing the expected output :?

Menu: Tools > Options
Page: Debugger > Debugger Backend

On the very top, in the toolbar, the first entry (drop down) should be: "FpDebug [FpDebug internal Dwarf-debugger]"
« Last Edit: October 25, 2022, 01:43:41 pm by Martin_fr »

lazer

  • Full Member
  • ***
  • Posts: 215
Re: more debuggery.
« Reply #28 on: October 25, 2022, 01:55:58 pm »
Ahhh ! 

I did go through all that at one stage when you originally suggested using it but it seems to have got scrubbed.

If that is a lazarus config rather than a project config it probably got scubbed when I cleaned out ~/.lazarus !

OK it starts to make more sense.  Debugger now does correctly find my variables and I get parentfp output.

Code: Pascal  [Select][+][-]
  1. ### TCodeToolManager.HandleException: [20170421200105] "identifier not found: msgstr" at Line=771 Col=3 in "~/laz/pack.pas"
  2. Search parentfp 7FFE76EE0420
  3. testing parentfp 1: 7FFE76EE0420
  4. END parentfp 2: 7FFE76EE0420
  5. ### TCodeToolManager.HandleException: [20170421200105] "identifier not found: suffix" at Line=770 Col=3 in "~/laz/pack.pas"
  6. Search parentfp 7FFE76EE0420
  7. testing parentfp 1: 7FFE76EE0420
  8. END parentfp 2: 7FFE76EE0420
  9.  

Despite reporting that it can't find them it now does !

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9857
  • Debugger - SynEdit - and more
    • wiki
Re: more debuggery.
« Reply #29 on: October 25, 2022, 02:17:49 pm »
If that is a lazarus config rather than a project config it probably got scubbed when I cleaned out ~/.lazarus !

Must have somehow ....

It supposed to default to FpDebug.
Well anyway, if it works...

I do see, that all those many options can cause problems. But then, with all the different setups people need (cross compile/debug / micro controller / ....), there are just a lot of needs to be covered.

 

TinyPortal © 2005-2018