Recent

Author Topic: Lazarus 2.2.4 debug console ?  (Read 816 times)

Espectr0

  • Full Member
  • ***
  • Posts: 218
Lazarus 2.2.4 debug console ?
« on: October 24, 2022, 03:38:36 pm »
Hello,

How can I enable the debug window in terminal?
I can't find the "ConsoleTty" option now :S

Thanks!

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9908
  • Debugger - SynEdit - and more
    • wiki
Re: Lazarus 2.2.4 debug console ?
« Reply #1 on: October 24, 2022, 06:17:35 pm »
Tools > Options > Debugger Backend

Which debugger do you have selected?
There is a DropDown in the toolbar on top of that page.
(ON Apple MAC) It should read something like
  ... LLDB + FpDebug ....

If this is selected, the property grid should have some option "open console" (I am not sure of the exact name).

It will open a new console.
The old "tty" using an existing console, only worked with GDB. (If you have a working gdb, you can configure the IDE to use it by switching to the "gdbmi" debugger)

Espectr0

  • Full Member
  • ***
  • Posts: 218
Re: Lazarus 2.2.4 debug console ?
« Reply #2 on: October 24, 2022, 06:52:08 pm »
Thanks @Martin_fr,

I use LLDB beta and the option is "LaunchNewTerminal" but in my case Lazarus remains "Debugging..." and I can't stop it or close it :S

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9908
  • Debugger - SynEdit - and more
    • wiki
Re: Lazarus 2.2.4 debug console ?
« Reply #3 on: October 24, 2022, 07:47:13 pm »
The Terminal indeed stays open (it is launched by LLDB, and I am not aware of a way to close it).

But the app that you are debugging should run normally and terminate. And the debugger should also go back to "not running".

You can always force the debugger back, by using "Reset debugger" from the "Run" menu. But that is only meant as a last recovery.



So when you say "remains debugging" => has your app finished? Has it gone from the "ps ax" list?

IIRC (I can't test right now), when your app finishes, there will be some message saying so in that console window. Is there?


You can open (best before you start the debugger)
   View -> IDE internals > Debug output

Then when the problem occurs, see if lldb produced some output that may give a hint.


--
You can also start lazarus itself from a console/terminal, and see if it outputs anything of value to the issue.
« Last Edit: October 24, 2022, 07:48:46 pm by Martin_fr »

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9908
  • Debugger - SynEdit - and more
    • wiki
Re: Lazarus 2.2.4 debug console ?
« Reply #4 on: October 24, 2022, 07:51:37 pm »
I use LLDB beta

Just "lldb" or "lldb +fpdbebug" ?

I think the "just lldb" is "alpha". (And also not installed by default)

So I guess you use "lldb + FpDebug (beta)" (which is recommended)


Sorry I don't have the exact names at hand.

I usually don't work on Mac / Except when I must make changes to the Mac debugger.

Espectr0

  • Full Member
  • ***
  • Posts: 218
Re: Lazarus 2.2.4 debug console ?
« Reply #5 on: October 24, 2022, 08:23:34 pm »
Sorry for my English is bad and I use a translator.

Quote
Just "lldb" or "lldb +fpdbebug" ?
Yes, lldb +fpdbebug.

For example, a new empty gui application, run to debug, it says "Debugging", after a while the terminal window appears and it stays there, the "form1" does not appear (in this case) and when I give it stop i can't stop it and i have to force restart the mac to reopen lazarus.

Maybe is my system? Lazarus 2.2.4 and macOS Monterey 12.6.

View -> IDE internals > Debug output:

Code: Pascal  [Select][+][-]
  1. >> settings set -- frame-format "frame #${frame.index}: ${frame.pc}, {${frame.sp}}, {${frame.fp}} &&//FULL: {${line.file.fullpath}} &&//SHORT: {${line.file.basename}} &&//LINE: {${line.number}} &&//MOD: {${module.file.basename}} &&//FUNC: {${function.name-with-args}} <<&&//FRAME\n"
  2. (lldb) settings set -- frame-format "frame #${frame.index}: ${frame.pc}, {${frame.sp}}, {${frame.fp}} &&//FULL: {${line.file.fullpath}} &&//SHORT: {${line.file.basename}} &&//LINE: {${line.number}} &&//MOD: {${module.file.basename}} &&//FUNC: {${function.name-with-args}} <<&&//FRAME\n"
  3. >> settings set -- thread-format "thread #${thread.index}: tid=${thread.id%tid}: ${frame.pc}, {${frame.sp}}, {${frame.fp}} &&//FULL: {${line.file.fullpath}} &&//SHORT: {${line.file.basename}} &&//LINE: {${line.number}} &&//MOD: {${module.file.basename}} &&//FUNC: {${function.name-with-args}} <<&&//FRAME{, stop reason = ${thread.stop-reason}}\n"
  4. (lldb) settings set -- thread-format "thread #${thread.index}: tid=${thread.id%tid}: ${frame.pc}, {${frame.sp}}, {${frame.fp}} &&//FULL: {${line.file.fullpath}} &&//SHORT: {${line.file.basename}} &&//LINE: {${line.number}} &&//MOD: {${module.file.basename}} &&//FUNC: {${function.name-with-args}} <<&&//FRAME{, stop reason = ${thread.stop-reason}}\n"
  5. >> settings set -- thread-stop-format "thread #${thread.index}: tid=${thread.id%tid}: ${frame.pc}, {${frame.sp}}, {${frame.fp}} &&//FULL: {${line.file.fullpath}} &&//SHORT: {${line.file.basename}} &&//LINE: {${line.number}} &&//MOD: {${module.file.basename}} &&//FUNC: {${function.name-with-args}} <<&&//FRAME{, stop reason = ${thread.stop-reason}}\n"
  6. (lldb) settings set -- thread-stop-format "thread #${thread.index}: tid=${thread.id%tid}: ${frame.pc}, {${frame.sp}}, {${frame.fp}} &&//FULL: {${line.file.fullpath}} &&//SHORT: {${line.file.basename}} &&//LINE: {${line.number}} &&//MOD: {${module.file.basename}} &&//FUNC: {${function.name-with-args}} <<&&//FRAME{, stop reason = ${thread.stop-reason}}\n"
  7. >> target stop-hook add -o "thread list"
  8. (lldb) target stop-hook add -o "thread list"
  9. Stop hook #1 added.
  10. >> settings set -- stop-line-count-after 0
  11. (lldb) settings set -- stop-line-count-after 0
  12. >> settings set -- stop-line-count-before 0
  13. (lldb) settings set -- stop-line-count-before 0
  14. >> settings set -- stop-disassembly-count 0
  15. (lldb) settings set -- stop-disassembly-count 0
  16. >> settings set -- target.env-vars "USER=uruworks"
  17. (lldb) settings set -- target.env-vars "USER=uruworks"
  18. >> settings set -- target.env-vars "__CFBundleIdentifier=com.company.lazarus"
  19. (lldb) settings set -- target.env-vars "__CFBundleIdentifier=com.company.lazarus"
  20. >> settings set -- target.env-vars "COMMAND_MODE=unix2003"
  21. (lldb) settings set -- target.env-vars "COMMAND_MODE=unix2003"
  22. >> settings set -- target.env-vars "LOGNAME=uruworks"
  23. (lldb) settings set -- target.env-vars "LOGNAME=uruworks"
  24. >> settings set -- target.env-vars "PATH=/usr/bin:/bin:/usr/sbin:/sbin"
  25. (lldb) settings set -- target.env-vars "PATH=/usr/bin:/bin:/usr/sbin:/sbin"
  26. >> settings set -- target.env-vars "SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.LitrOYStTh/Listeners"
  27. (lldb) settings set -- target.env-vars "SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.LitrOYStTh/Listeners"
  28. >> settings set -- target.env-vars "SHELL=/bin/zsh"
  29. (lldb) settings set -- target.env-vars "SHELL=/bin/zsh"
  30. >> settings set -- target.env-vars "HOME=/Users/uruworks"
  31. (lldb) settings set -- target.env-vars "HOME=/Users/uruworks"
  32. >> settings set -- target.env-vars "__CF_USER_TEXT_ENCODING=0x1F5:0:86"
  33. (lldb) settings set -- target.env-vars "__CF_USER_TEXT_ENCODING=0x1F5:0:86"
  34. >> settings set -- target.env-vars "TMPDIR=/var/folders/q1/9xvs061s5c511pt1wy40v69c0000gn/T/"
  35. (lldb) settings set -- target.env-vars "TMPDIR=/var/folders/q1/9xvs061s5c511pt1wy40v69c0000gn/T/"
  36. >> settings set -- target.env-vars "XPC_SERVICE_NAME=application.com.company.lazarus.1636557.1639758"
  37. (lldb) settings set -- target.env-vars "XPC_SERVICE_NAME=application.com.company.lazarus.1636557.1639758"
  38. >> settings set -- target.env-vars "XPC_FLAGS=0x0"
  39. (lldb) settings set -- target.env-vars "XPC_FLAGS=0x0"
  40. >> target create /Users/uruworks/tmp/project1.app
  41. (lldb) target create /Users/uruworks/tmp/project1.app
  42. Current executable set to '/Users/uruworks/tmp/project1.app' (x86_64).
  43. >> settings clear target.run-args
  44. (lldb) settings clear target.run-args
  45. >> breakpoint set --func fpc_break_error -K false
  46. (lldb) breakpoint set --func fpc_break_error -K false
  47. Breakpoint 1: no locations (pending).
  48. >> breakpoint set --func fpc_runerror -K false
  49. WARNING:  Unable to resolve breakpoint to any actual locations.
  50. (lldb) breakpoint set --func fpc_runerror -K false
  51. Breakpoint 2: no locations (pending).
  52. >> breakpoint set --func fpc_raiseexception -K false
  53. WARNING:  Unable to resolve breakpoint to any actual locations.
  54. (lldb) breakpoint set --func fpc_raiseexception -K false
  55. Breakpoint 3: where = project1`FPC_RAISEEXCEPTION, address = 0x00000001000179f0
  56. >> breakpoint command add 3
  57. >> p/x $rdi
  58. >> p/x $rdx
  59. >> p ((char ***)$rdi)[0][3]
  60. >> p ((char **)$rdi)[1]
  61. >> DONE
  62. >> version
  63. (lldb) breakpoint command add 3
  64. (lldb) version
  65. >> breakpoint command add 2
  66. >> p/x $rdi
  67. >> DONE
  68. >> version
  69. lldb-1400.0.30.3
  70. Apple Swift version 5.7 (swiftlang-5.7.0.127.4 clang-1400.0.29.50)
  71. (lldb) breakpoint command add 2
  72. (lldb) version
  73. >> breakpoint command add 1
  74. >> p/x $rdi
  75. >> DONE
  76. >> version
  77. lldb-1400.0.30.3
  78. Apple Swift version 5.7 (swiftlang-5.7.0.127.4 clang-1400.0.29.50)
  79. (lldb) breakpoint command add 1
  80. (lldb) version
  81. >> process launch --tty
  82. lldb-1400.0.30.3
  83. Apple Swift version 5.7 (swiftlang-5.7.0.127.4 clang-1400.0.29.50)
  84. (lldb) process launch --tty
  85.  

and after click stop:

Code: Pascal  [Select][+][-]
  1. >> process kill

but never stop.
« Last Edit: October 24, 2022, 08:32:51 pm by Espectr0 »

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9908
  • Debugger - SynEdit - and more
    • wiki
Re: Lazarus 2.2.4 debug console ?
« Reply #6 on: October 24, 2022, 08:56:09 pm »
ok, so lldb hangs. It never finishes launching.

The tty option is documented as "does not work on all platforms". But it had previously appeared to work on Mac.

It's currently the only option to get a terminal. If it doesn't work, then I have no idea.

 

TinyPortal © 2005-2018