CodeDebug, LLDB, and FreePascal
Continuing #118 by @carlca …
-
System:
- [x] FPC v.3.0.2.
- [x] VS Code v.1.23.
- [x] Mac OS v.10.11 (El Capitan).
-
Debugger:
- [x] LLDB v.360.1.70 (osx default).
- [x] lldb-mi via XCode toolchain.
-
FPC debug info setting:
- [x]
-gw2omitting dwarf v.2 format. - [x]
-godwarfcppsimulating c++ info.
- [x]
-
Status:
- [x] All VS Code debugging features work.
-
Problems:
- All program identifiers become upper-case: minor.
- No global variables are shown in debugger panel, but they're still accessible through debug console using
pcommand: major. - There's no way to view the content of dynamic arrays,
pcommand seems to view its memory address or something: major. - Pascal program is unable to accept input because
terminalsetting is unknown: major. - Debug console is producing some garbage texts if program using Pascal's CRT unit: major.
-
Sample code:
program test;
{$MODE OBJFPC}{$H+}
uses CRT;
var
s: string;
c,r: integer;
a: array of integer;
begin
ClrScr;
// dynamic array test
SetLength(a,10);
for c := 0 to High(a) do a[c] := c;
// string test
c := ScreenWidth;
r := ScreenHeight;
s := 'Screen size: ';
// input-output test
writeln(s,c,'x',r);
write('Type your name: ');
readln(s);
writeln('Hello, ',s,'!');
end.
- Compiler command:
fpc test.pas -Px86_64 -gw2 -godwarfcppIt can be configured as a task.
Hope those problems will be fixed soon.
Thank you.
ii: general issue I found, not sure how to do a solution yet. iv: you could use gdb instead. lldb-mi does not have an option to redirect program output to another tty nor to spawn a separate terminal. v: can you specify that issue in more detail?
ii: I also have tried CodeLLDB extension. It's not using lldb-mi, it doesn't have such problem. But it has its own issues as well.
iv: CodeLLDB is able to redirect input/output through VS Code's integrated terminal. IMO, it gives better user experience. Mac has no gdb installed by default and I want to use lldb.
v: I think it's related to Debug Console due to codepage issue. Terminal could handle it well.
No response for i and iii?
i: probably not fixable, I didn't look into it yet but I could imagine the pascal compiler changing identifiers to all uppercase. iii: not investigated yet, probably just needs a bit of work on the lldb/gdb output parser/renderer.
i is not a big problem, I can live with that as long as the variables are available on the debug panel (ii).
But iii and iv are deal breakers for me. How can I debug my code if I couldn't watch some important variables? Changing them into static arrays requires too much changes.
Workaround for v is not too hard, I can accept that.