Recent

Author Topic: Xcode Command Line Tools 15 Breaks lldb (macOS Ventura 13.6/Sonoma 14.0 ARM64)  (Read 14863 times)

msintle

  • Sr. Member
  • ****
  • Posts: 376
I've met the same issues reported, i.e. errors and warnings when building, weird behavior of debugger, focus lost when debugging, etc.
In order to have a better understanding I downgraded Xcode to 14.3 to verify if some issue was already present, and then reinstalled Xcode 15.
All the issues have disappeared. No more errors and warnings on build, no more weird behavior of debugger and focus lost.
My suggestion is to reinstall Xcode 15 from scratch. Or, if that fails, to downgrade to 14.3 and then upgrade to 15.

The problem for me stemmed from upgrading to Xcode Command Line Tools 15, without any prior involvement/installation of Xcode the full IDE itself.

I suspect you still are on an older version of Xcode Command Line Tools and when it gets upgraded somehow you'll be hitting a brick wall again.

msintle

  • Sr. Member
  • ****
  • Posts: 376
@Martin_fr:

Thank you very much for your continuing investigation.

1. This has happened with GDB I believe when I try to launch my product while debugging it. Out of scope for what we are trying to achieve here, surely - but just so you know, my main window never shows with GDB at all. I was just looking at GDB to work around LLDB issues after my upgrade to Xcode Command Line Tools 15.

2. None.

3. The Stop button in the IDE works. But thanks for the Reset Debugger trick which might come handy in the future. Other than the Stop button, the IDE is unusable and in a constantly spinning beachball state.

The above reports are from memory running the main product.

I shall repeat the tests with your minimized single-exception test case at my first opportunity.

msintle

  • Sr. Member
  • ****
  • Posts: 376
@Martin_fr: Would you like remote access to a Mac VM, which might surely aid speed up troubleshooting the issues? I could just install Lazarus and Xcode Command Line Tools 15 on a latest clean instance of macOS Sonoma and give you remote access via TeamViewer.

msintle

  • Sr. Member
  • ****
  • Posts: 376
Hi again, Martin!

Here is the attached result on the latest patched Lazarus IDE with your minimum testing project.

The debug output is as follows:

Code: Text  [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=c"
  17. (lldb) settings set -- target.env-vars "USER=c"
  18. >> settings set -- target.env-vars "COMMAND_MODE=unix2003"
  19. (lldb) settings set -- target.env-vars "COMMAND_MODE=unix2003"
  20. >> settings set -- target.env-vars "__CFBundleIdentifier=com.company.lazarus"
  21. (lldb) settings set -- target.env-vars "__CFBundleIdentifier=com.company.lazarus"
  22. >> settings set -- target.env-vars "PATH=/usr/bin:/bin:/usr/sbin:/sbin"
  23. (lldb) settings set -- target.env-vars "PATH=/usr/bin:/bin:/usr/sbin:/sbin"
  24. >> settings set -- target.env-vars "LOGNAME=c"
  25. (lldb) settings set -- target.env-vars "LOGNAME=c"
  26. >> settings set -- target.env-vars "SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.j4uTBdQSC2/Listeners"
  27. (lldb) settings set -- target.env-vars "SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.j4uTBdQSC2/Listeners"
  28. >> settings set -- target.env-vars "HOME=/Users/c"
  29. (lldb) settings set -- target.env-vars "HOME=/Users/c"
  30. >> settings set -- target.env-vars "SHELL=/usr/local/bin/fish"
  31. (lldb) settings set -- target.env-vars "SHELL=/usr/local/bin/fish"
  32. >> settings set -- target.env-vars "TMPDIR=/var/folders/83/twjyhw09433804gtwys_4xsc0000gn/T/"
  33. (lldb) settings set -- target.env-vars "TMPDIR=/var/folders/83/twjyhw09433804gtwys_4xsc0000gn/T/"
  34. >> settings set -- target.env-vars "__CF_USER_TEXT_ENCODING=0x1F5:0x0:0x0"
  35. (lldb) settings set -- target.env-vars "__CF_USER_TEXT_ENCODING=0x1F5:0x0:0x0"
  36. >> settings set -- target.env-vars "XPC_SERVICE_NAME=application.com.company.lazarus.3669474.5112286"
  37. (lldb) settings set -- target.env-vars "XPC_SERVICE_NAME=application.com.company.lazarus.3669474.5112286"
  38. >> settings set -- target.env-vars "XPC_FLAGS=0x0"
  39. (lldb) settings set -- target.env-vars "XPC_FLAGS=0x0"
  40. >> target create /Users/c/tmp/project1.app
  41. (lldb) target create /Users/c/tmp/project1.app
  42. Current executable set to '/Users/c/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 = 0x0000000100018b70
  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-1500.0.22.8
  70. Apple Swift version 5.9 (swiftlang-5.9.0.128.108 clang-1500.0.40.1)
  71. (lldb) breakpoint command add 2
  72. (lldb) version
  73. >> breakpoint command add 1
  74. >> p/x $rdi
  75. >> DONE
  76. >> version
  77. lldb-1500.0.22.8
  78. Apple Swift version 5.9 (swiftlang-5.9.0.128.108 clang-1500.0.40.1)
  79. (lldb) breakpoint command add 1
  80. (lldb) version
  81. >> process launch -n
  82. lldb-1500.0.22.8
  83. Apple Swift version 5.9 (swiftlang-5.9.0.128.108 clang-1500.0.40.1)
  84. (lldb) process launch -n
  85. Process 3255 launched: '/Users/c/tmp/project1.app/Contents/MacOS/project1' (x86_64)
  86. (lldb)  p/x $rdi
  87. (unsigned long) 0x0000000100d5e580
  88. (lldb)  p/x $rdx
  89. (unsigned long) 0x00007ff7bfefe660
  90. (lldb)  p ((char ***)$rdi)[0][3]
  91. (char *) 0x00000001003c96a0 "\tException"
  92. (lldb)  p ((char **)$rdi)[1]
  93. (char *) 0x00000001003440f0 "foo bar"
  94. Process 3255 stopped
  95. * thread #1: tid=0x730ea: 0x0000000100018b70, 0x00007ff7bfefe648, 0x00007ff7bfefe660 &&//FULL:  &&//SHORT:  &&//LINE:  &&//MOD: project1 &&//FUNC: FPC_RAISEEXCEPTION <<&&//FRAME, stop reason = breakpoint 3.1
  96.   thread #2: tid=0x731c4: 0x00007ff80f512152, 0x0000700007beffa8, 0x0000700007beffd0 &&//FULL:  &&//SHORT:  &&//LINE:  &&//MOD: libsystem_kernel.dylib &&//FUNC: __workq_kernreturn <<&&//FRAME
  97.   thread #3: tid=0x731c5: 0x00007ff80f512152, 0x0000700007c72fa8, 0x0000700007c72fd0 &&//FULL:  &&//SHORT:  &&//LINE:  &&//MOD: libsystem_kernel.dylib &&//FUNC: __workq_kernreturn <<&&//FRAME
  98.   thread #4: tid=0x731c8: 0x00007ff80f512152, 0x0000700007cf5fa8, 0x0000700007cf5fd0 &&//FULL:  &&//SHORT:  &&//LINE:  &&//MOD: libsystem_kernel.dylib &&//FUNC: __workq_kernreturn <<&&//FRAME
  99.   thread #5: tid=0x731ca: 0x00007ff80f512152, 0x0000700007d78fa8, 0x0000700007d78fd0 &&//FULL:  &&//SHORT:  &&//LINE:  &&//MOD: libsystem_kernel.dylib &&//FUNC: __workq_kernreturn <<&&//FRAME
  100.   thread #6: tid=0x73228: 0x00007ff80f512152, 0x0000700007dfbfa8, 0x0000700007dfbfd0 &&//FULL:  &&//SHORT:  &&//LINE:  &&//MOD: libsystem_kernel.dylib &&//FUNC: __workq_kernreturn <<&&//FRAME
  101.   thread #7: tid=0x73229: 0x00007ff80f510a2e, 0x0000700007e7df58, 0x0000700007e7dfc0 &&//FULL:  &&//SHORT:  &&//LINE:  &&//MOD: libsystem_kernel.dylib &&//FUNC: mach_msg2_trap <<&&//FRAME
  102.   thread #8: tid=0x7322a: 0x00007ff80f512152, 0x0000700007f01fa8, 0x0000700007f01fd0 &&//FULL:  &&//SHORT:  &&//LINE:  &&//MOD: libsystem_kernel.dylib &&//FUNC: __workq_kernreturn <<&&//FRAME
  103.   thread #9: tid=0x7322b: 0x00007ff80f512152, 0x0000700007f84fa8, 0x0000700007f84fd0 &&//FULL:  &&//SHORT:  &&//LINE:  &&//MOD: libsystem_kernel.dylib &&//FUNC: __workq_kernreturn <<&&//FRAME
  104.   thread #10: tid=0x73234: 0x00007ff80f512152, 0x0000700008007fa8, 0x0000700008007fd0 &&//FULL:  &&//SHORT:  &&//LINE:  &&//MOD: libsystem_kernel.dylib &&//FUNC: __workq_kernreturn <<&&//FRAME
  105.   thread #11: tid=0x73235: 0x00007ff80f512152, 0x000070000808afa8, 0x000070000808afd0 &&//FULL:  &&//SHORT:  &&//LINE:  &&//MOD: libsystem_kernel.dylib &&//FUNC: __workq_kernreturn <<&&//FRAME
  106.   thread #12: tid=0x73236: 0x00007ff80f512152, 0x000070000810dfa8, 0x000070000810dfd0 &&//FULL:  &&//SHORT:  &&//LINE:  &&//MOD: libsystem_kernel.dylib &&//FUNC: __workq_kernreturn <<&&//FRAME
  107.   thread #13: tid=0x73237: 0x00007ff80f512152, 0x0000700008190fa8, 0x0000700008190fd0 &&//FULL:  &&//SHORT:  &&//LINE:  &&//MOD: libsystem_kernel.dylib &&//FUNC: __workq_kernreturn <<&&//FRAME
  108.   thread #14: tid=0x73238: 0x00007ff80f512152, 0x0000700008213b18, 0x0000700008213b40 &&//FULL:  &&//SHORT:  &&//LINE:  &&//MOD: libsystem_kernel.dylib &&//FUNC: __workq_kernreturn <<&&//FRAME
  109.   thread #15: tid=0x73239: 0x00007ff80f512152, 0x0000700008296fa8, 0x0000700008296fd0 &&//FULL:  &&//SHORT:  &&//LINE:  &&//MOD: libsystem_kernel.dylib &&//FUNC: __workq_kernreturn <<&&//FRAME
  110.   thread #16: tid=0x7323a: 0x00007ff80f512152, 0x0000700008319fa8, 0x0000700008319fd0 &&//FULL:  &&//SHORT:  &&//LINE:  &&//MOD: libsystem_kernel.dylib &&//FUNC: __workq_kernreturn <<&&//FRAME
  111.   thread #17: tid=0x7323b: 0x0000000000000000, 0x0000000000000000, 0x0000000000000000 &&//FULL:  &&//SHORT:  &&//LINE:  &&//MOD:  &&//FUNC:  <<&&//FRAME
  112. Process 3255 stopped
  113. * thread #1: tid=0x730ea: 0x0000000100018b70, 0x00007ff7bfefe648, 0x00007ff7bfefe660 &&//FULL:  &&//SHORT:  &&//LINE:  &&//MOD: project1 &&//FUNC: FPC_RAISEEXCEPTION <<&&//FRAME, stop reason = breakpoint 3.1
  114.     frame #0: 0x0000000100018b70, 0x00007ff7bfefe648, 0x00007ff7bfefe660 &&//FULL:  &&//SHORT:  &&//LINE:  &&//MOD: project1 &&//FUNC: FPC_RAISEEXCEPTION <<&&//FRAME
  115. Target 0: (project1) stopped.

The app is currently in "hung and invisible" state after the exception is shown and continue is clicked.

Clicking the big red square button stops it normally, without needing to reset the debugger.

So almost the same as what I see in my own app, except for the attached dialog that is shown (but which doesn't change any behavior, or contain any useful information).

Trying to run the app again, and hitting break when the exception is shown instead of continue:

1. I see the assembler window, and again the very same break/continue window is on-screen.
2. Hitting break again here (so twice in succession) the window goes away and the IDE does not stop anywhere in particular.
3. I click the big green rectangular run button; which is when I actually get the expected application exception handler dialog:

"foo bar.

Press OK to ignore and risk data corruption.
Press Abort to kill the program."

(not the IDE exception handler dialog) shown natively by the application.

4. Abort and Continue work there as expected.

I hope this is helpful in some shape or form.
« Last Edit: October 10, 2023, 12:33:57 pm by Martin_fr »

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 12202
  • Debugger - SynEdit - and more
    • wiki
I made some further changes to the code.
https://gitlab.com/martin_frb/lazarus/-/commit/06f5b3bb664fb22587f6cf080fcb8fcf8e6f3fe2

The problem is (or hopefully was) that the IDE was still waiting for data from lldb, because the "end marker" is changed. And if the IDE is waiting , it does not sent new instruction, so you couldn't continue to run.


Please pack the output into "code" tags [ code=plain ]
I added this to your last post.
« Last Edit: October 10, 2023, 12:34:49 pm by Martin_fr »

msintle

  • Sr. Member
  • ****
  • Posts: 376
I made some further changes to the code.
https://gitlab.com/martin_frb/lazarus/-/commit/06f5b3bb664fb22587f6cf080fcb8fcf8e6f3fe2

The problem is (or hopefully was) that the IDE was still waiting for data from lldb, because the "end marker" is changed. And if the IDE is waiting , it does not sent new instruction, so you couldn't continue to run.

Wow! Congratulations, Martin!!! This did it :)

Both the single exception demo and my own product now work properly.

To clarify, the exception that is raised ("foo bar") is caught and displayed properly in the IDE.

And my own product is able to spawn its own secondary dialog - without any frivolous exceptions or hangs!


Please pack the output into "code" tags [ code=plain ]
I added this to your last post.

Thank you for your help. I also fixed my remaining post on this thread accordingly.

msintle

  • Sr. Member
  • ****
  • Posts: 376
Not sure if this is your responsibility, but also trying to patch the FPCUPDELUXE instance of Lazarus using your fixed files, I get the attached build error when trying to compile Lazarus itself.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 12202
  • Debugger - SynEdit - and more
    • wiki
Is your fpcupdeluxe on fixes-2-2, fixes-3 or main branch?

In either case, that error shouldn't happen. Unless an entire file was copied from one branch to another. I.e. not just the patch, but the entire file. Then it would happen.

The patch should apply. But you don't need to apply it to fixes-3 or main any more, I have just committed the changes.

msintle

  • Sr. Member
  • ****
  • Posts: 376
Is your fpcupdeluxe on fixes-2-2, fixes-3 or main branch?

In either case, that error shouldn't happen. Unless an entire file was copied from one branch to another. I.e. not just the patch, but the entire file. Then it would happen.

The patch should apply. But you don't need to apply it to fixes-3 or main any more, I have just committed the changes.

Ah yes, I copied the entire file indeed. I am on Trunk/Lazarus + FPC 3.3.1. Would a reinstall with FPCUPDELUXE address this concern, has your fix been propagated already?

Once again, terrific work Martin. I am very grateful for your support.

You are an O:-)

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 12202
  • Debugger - SynEdit - and more
    • wiki
Ah yes, I copied the entire file indeed. I am on Trunk/Lazarus + FPC 3.3.1. Would a reinstall with FPCUPDELUXE address this concern, has your fix been propagated already?

Yes, the fix is in Lazarus trunk. (and in fixes 3-0 / but not on the tagged 30RC2, since the tag was done a few days ago)

msintle

  • Sr. Member
  • ****
  • Posts: 376
Ah yes, I copied the entire file indeed. I am on Trunk/Lazarus + FPC 3.3.1. Would a reinstall with FPCUPDELUXE address this concern, has your fix been propagated already?

Yes, the fix is in Lazarus trunk. (and in fixes 3-0 / but not on the tagged 30RC2, since the tag was done a few days ago)

Works, terrific!

vonskie

  • Full Member
  • ***
  • Posts: 186
So where do I get this fixed version if 30rc2 does not have it. Running into problems with xcode 15 the latest mac os and the debugger is not running.


dbannon

  • Hero Member
  • *****
  • Posts: 3734
    • tomboy-ng, a rewrite of the classic Tomboy
Hmm, maybe back to the answer I gave you a couple of days ago ?

https://forum.lazarus.freepascal.org/index.php/topic,65118.msg495851.html#msg495851

You apparently want Lazarus Fixes  3.0, its not available as a prebuilt binary install because it changes often.  So, you build it yourself. Its easy.

David
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

vonskie

  • Full Member
  • ***
  • Posts: 186
I followed the guide at https://wiki.freepascal.org/Installing_Lazarus_on_macOS#Installing_non-release_versions_of_the_Lazarus_IDE

Very helpful

However when I try to debug even with the fixes 3_0 compiled

I get the following in the debug output

I have verified xcode and command line tools are signed

I have reinstalled the command line tools

Set it to dwarf3 and lldb

Breakpoint 1: no locations (pending).
WARNING:  Unable to resolve breakpoint to any actual locations.
(lldb) breakpoint set --func fpc_runerror -K false
Breakpoint 2: no locations (pending).
WARNING:  Unable to resolve breakpoint to any actual locations.
(lldb) breakpoint set --func fpc_raiseexception -K false
Breakpoint 3: where = ELSIEasyCleaner`FPC_RAISEEXCEPTION, address = 0x00000001000182d0
(lldb) process launch -n

Program will run but debugger will not load.

I am stuck any suggestions?






Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 12202
  • Debugger - SynEdit - and more
    • wiki
Breakpoint 1: no locations (pending).
WARNING:  Unable to resolve breakpoint to any actual locations.
(lldb) breakpoint set --func fpc_runerror -K false
Breakpoint 2: no locations (pending).
WARNING:  Unable to resolve breakpoint to any actual locations.
(lldb) breakpoint set --func fpc_raiseexception -K false
Breakpoint 3: where = ELSIEasyCleaner`FPC_RAISEEXCEPTION, address = 0x00000001000182d0
(lldb) process launch -n

Program will run but debugger will not load.

I am stuck any suggestions?

The 2 "unable to resolve" are (probably) ok. They may actually not be in your app. But after the 3rd one, there should be additional instructions (if that is from the "Debug output" window and not from the stdout of the IDE).


Just to be sure, you are using "lldb with fpdebug"?  (There is one without fpdebug, but it's normally not installed)

 

TinyPortal © 2005-2018