Sign in Join
Wiki copytemporary

lldb: what changed

Revision 2 to 3. Removed lines have a minus sign; added lines have a plus sign.

OldNewLine
1-lldb is the Xcode (macOS) default debugger. It's available when you have installed Xcode and/or the Xcode standalone command line tools.
1+lldb is the Xcode (macOS) default debugger. It's available when you have installed Xcode and/or the Xcode standalone command line tools.
22
3-It's still possible to build and install the gdb debugger. However, there are certain security requirements, and not everyone would like to take that approach.
3+It's still possible to build and install the gdb debugger. However, there are certain security requirements, and not everyone would like to take that approach.
44
55## LLDB and Lazarus
66
7-LLDB is now the standard debugger in the Lazarus IDE for macOS. The recommended setting is "Dwarf with sets" (-gw -godwarfsets).
7+LLDB is now the standard debugger in the Lazarus IDE for macOS. The recommended setting is "Dwarf with sets" (-gw -godwarfsets).
88
99### Crashing issues
1010
11-Sometimes the LLDB crashes when running an app from the IDE. In many cases this is caused by a corrupt bundle file. Rebuilding the bundle uses to help in these cases.
11+Sometimes the LLDB crashes when running an app from the IDE. In many cases this is caused by a corrupt bundle file. Rebuilding the bundle uses to help in these cases.
1212
1313## Creating a backtrace
1414
15-1\. Open an Applications \> Utilities \> Terminal.
16-
17-2\. Change to the application bundle (if you're debugging a GUI application). Example:
15+1\. Open an Applications > Utilities > Terminal.
1816
19-```text
20- cd project1.app/Contents/MacOS/
17+2\. Change to the application bundle (if you're debugging a GUI application). Example:
2118```
22-
23-If you're debugging a command-line application, you don't need to do that.
19+cd project1.app/Contents/MacOS/
20+```
2421
25-3\. Run lldb with the program to debug. Launching a project with lldb takes longer than launching without it.
22+If you're debugging a command-line application, you don't need to do that.
2623
27-```text
24+3\. Run lldb with the program to debug. Launching a project with lldb takes longer than launching without it.
25+```
2826$ lldb project1
29-(lldb) target create "project1"
30-Current executable set to 'project1' (x86_64).
31-(lldb)
27+ (lldb) target create "project1"
28+ Current executable set to 'project1' (x86_64).
29+ (lldb)
3230```
3331
34-**Note** launching an application with lldb for the first time might require you have admin rights - you might be prompted for your account password. This happens only on the initial launch of lldb. However, after a reboot, the authentication might be needed again.
32+**Note** launching an application with lldb for the first time might require you have admin rights - you might be prompted for your account password. This happens only on the initial launch of lldb. However, after a reboot, the authentication might be needed again.
3533
36-4\. When you see lldb is ready ("lldb" would show up in the Terminal) execute the "r" command (run). Example:
34+4\. You probably want to set a breakpoint for raised exceptions:
35+```
36+(lldb) breakpoint set -n fpc_raiseexception
37+```
3738
38-```text
39+5\. When you see lldb is ready ("lldb" would show up in the Terminal) execute the "r" command (run). Example:
40+```
3941(lldb) r
40-Process 12974 launched: '/Users/dmitry/Desktop/Cocoa/buffer/project1.app/Contents/MacOS/project1' (x86_64)
42+ Process 12974 launched: '/Users/dmitry/Desktop/Cocoa/buffer/project1.app/Contents/MacOS/project1' (x86_64)
4143```
4244
43-5\. You should now switch back to your application and take the actions that are necessary to reproduce the crash.
44-
45-6\. When the crash occurs the lldb console is available again. If debugging information and sources are available, lldb would typically show you the line of code where crash occurred.
45+6\. You should now switch back to your application and take the actions that are necessary to reproduce the crash.
4646
47-``` pascal
48- Process 12974 stopped
49-* thread #1: tid = 0xd4503, 0x000000010003d9b1 project1`UNIT1$_$TFORM1_$__$$_BUTTON1CLICK$TOBJECT + 97 at unit1.pas:47, queue = 'com.apple.main-thread', stop reason = EXC_ARITHMETIC (code=EXC_I386_DIV, subcode=0x0)
50- frame #0: 0x000000010003d9b1 project1`UNIT1$_$TFORM1_$__$$_BUTTON1CLICK$TOBJECT + 97 at unit1.pas:47
51- 44 b:=5;
52- 45 b:=b div 5;
53- 46 b:=b-b;
54--> 47 writeln(a div b);
55- 48 end;
56- 49
57- 50 end.
58-(lldb)
47+7\. When the crash occurs the lldb console is available again. If debugging information and sources are available, lldb would typically show you the line of code where crash occurred.
5948```
60-
61-7\. Run "bt" command to get the backtrace.
49+Process 12974 stopped
50+ * thread #1: tid = 0xd4503, 0x000000010003d9b1 project1`UNIT1$_$TFORM1_$__$$_BUTTON1CLICK$TOBJECT + 97 at unit1.pas:47, queue = 'com.apple.main-thread', stop reason = EXC_ARITHMETIC (code=EXC_I386_DIV, subcode=0x0)
51+ frame #0: 0x000000010003d9b1 project1`UNIT1$_$TFORM1_$__$$_BUTTON1CLICK$TOBJECT + 97 at unit1.pas:47
52+ 44 b:=5;
53+ 45 b:=b div 5;
54+ 46 b:=b-b;
55+ -> 47 writeln(a div b);
56+ 48 end;
57+ 49
58+ 50 end.
59+ (lldb)
60+```
6261
63-```text
62+8\. Run "bt" command to get the backtrace.
63+```
6464(lldb) bt
65-* thread #1: tid = 0xd4503, 0x000000010003d9b1 project1`UNIT1$_$TFORM1_$__$$_BUTTON1CLICK$TOBJECT + 97 at unit1.pas:47, queue = 'com.apple.main-thread', stop reason = EXC_ARITHMETIC (code=EXC_I386_DIV, subcode=0x0)
66- * frame #0: 0x000000010003d9b1 project1`UNIT1$_$TFORM1_$__$$_BUTTON1CLICK$TOBJECT + 97 at unit1.pas:47
67- frame #1: 0x00000001001eeb88 project1`CONTROLS$_$TCONTROL_$__$$_CLICK + 104 at control.inc:2916
68- frame #2: 0x00000001002588da project1`STDCTRLS$_$TBUTTONCONTROL_$__$$_CLICK + 42 at buttoncontrol.inc:55
69- frame #3: 0x000000010025909f project1`STDCTRLS$_$TCUSTOMBUTTON_$__$$_CLICK + 79 at buttons.inc:169
70- frame #4: 0x00000001002587e2 project1`STDCTRLS$_$TBUTTONCONTROL_$__$$_WMDEFAULTCLICKED$TLMESSAGE + 66 at buttoncontrol.inc:21
71- frame #5: 0x0000000100012103 project1`SYSTEM$_$TOBJECT_$__$$_DISPATCH$formal + 203
72- frame #6: 0x00000001001eda95 project1`CONTROLS$_$TCONTROL_$__$$_WNDPROC$TLMESSAGE + 517 at control.inc:2246
73- frame #7: 0x00000001001e0926 project1`CONTROLS$_$TWINCONTROL_$__$$_WNDPROC$TLMESSAGE + 806 at wincontrol.inc:5406
74- frame #8: 0x00000001001cc980 project1`LCLMESSAGEGLUE_$$_DELIVERMESSAGE$TOBJECT$formal$$INT64 + 224 at lclmessageglue.pas:112
75- frame #9: 0x00000001001cca8b project1`LCLMESSAGEGLUE_$$_SENDSIMPLEMESSAGE$TCONTROL$LONGWORD$$INT64 + 59 at lclmessageglue.pas:143
76- frame #10: 0x000000010029200a project1`COCOAWSSTDCTRLS$_$TLCLBUTTONCALLBACK_$__$$_BUTTONCLICK + 58 at cocoawsstdctrls.pp:401
77- frame #11: 0x00000001001b2a3f project1`-[TCocoaButton actionButtonClick:] + 87 at cocoaprivate.pp:2294
78- frame #12: 0x00007fffbec8dc41 libsystem_trace.dylib`_os_activity_initiate + 61
79- frame #13: 0x00007fffa7a5c770 AppKit`-[NSApplication(NSResponder) sendAction:to:from:] + 456
80- frame #14: 0x00007fffa75450d8 AppKit`-[NSControl sendAction:to:] + 86
81- frame #15: 0x00007fffa7545000 AppKit`__26-[NSCell _sendActionFrom:]_block_invoke + 136
82- frame #16: 0x00007fffbec8dc41 libsystem_trace.dylib`_os_activity_initiate + 61
83- frame #17: 0x00007fffa7544f58 AppKit`-[NSCell _sendActionFrom:] + 128
84- frame #18: 0x00007fffa75878d9 AppKit`-[NSButtonCell _sendActionFrom:] + 98
85- frame #19: 0x00007fffbec8dc41 libsystem_trace.dylib`_os_activity_initiate + 61
86- frame #20: 0x00007fffa754383c AppKit`-[NSCell trackMouse:inRect:ofView:untilMouseUp:] + 2481
87- frame #21: 0x00007fffa7587616 AppKit`-[NSButtonCell trackMouse:inRect:ofView:untilMouseUp:] + 798
88- frame #22: 0x00007fffa75421f7 AppKit`-[NSControl mouseDown:] + 832
89- frame #23: 0x00000001001b31ab project1`-[TCocoaButton mouseDown:] + 139 at cocoaprivate.pp:2410
90- frame #24: 0x00007fffa7bd291f AppKit`-[NSWindow(NSEventRouting) _handleMouseDownEvent:isDelayedEvent:] + 6341
91- frame #25: 0x00007fffa7bcf13c AppKit`-[NSWindow(NSEventRouting) _reallySendEvent:isDelayedEvent:] + 1942
92- frame #26: 0x00007fffa7bce5da AppKit`-[NSWindow(NSEventRouting) sendEvent:] + 541
93- frame #27: 0x00000001001b15df project1`-[TCocoaWindow sendEvent:] + 919 at cocoaprivate.pp:1943
94- frame #28: 0x00007fffa7a586f5 AppKit`-[NSApplication(NSEvent) sendEvent:] + 1145
95- frame #29: 0x00000001001a405c project1`COCOAINT$_$TCOCOAWIDGETSET_$__$$_APPPROCESSMESSAGES + 268 at cocoaobject.inc:105
96- frame #30: 0x000000010003733d project1`FORMS$_$TAPPLICATION_$__$$_HANDLEMESSAGE + 45 at application.inc:1276
97- frame #31: 0x00000001000378e1 project1`FORMS$_$TAPPLICATION_$__$$_RUNLOOP + 209 at application.inc:1419
98- frame #32: 0x00000001001a3d17 project1`-[TCocoaApplication run] + 71 at cocoaint.pas:368
99- frame #33: 0x00000001001a3f4a project1`COCOAINT$_$TCOCOAWIDGETSET_$__$$_APPRUN$TAPPLICATIONMAINLOOP + 106 at cocoaobject.inc:83
100- frame #34: 0x0000000100037808 project1`FORMS$_$TAPPLICATION_$__$$_RUN + 96 at application.inc:1401
101- frame #35: 0x0000000100001514 project1`PASCALMAIN + 92 at project1.lpr:19
102- frame #36: 0x0000000100020ef9 project1`FPC_SYSTEMMAIN + 41
103- frame #37: 0x0000000100001494 project1`start + 52
104-(lldb)
65+ * thread #1: tid = 0xd4503, 0x000000010003d9b1 project1`UNIT1$_$TFORM1_$__$$_BUTTON1CLICK$TOBJECT + 97 at unit1.pas:47, queue = 'com.apple.main-thread', stop reason = EXC_ARITHMETIC (code=EXC_I386_DIV, subcode=0x0)
66+ * frame #0: 0x000000010003d9b1 project1`UNIT1$_$TFORM1_$__$$_BUTTON1CLICK$TOBJECT + 97 at unit1.pas:47
67+ frame #1: 0x00000001001eeb88 project1`CONTROLS$_$TCONTROL_$__$$_CLICK + 104 at control.inc:2916
68+ frame #2: 0x00000001002588da project1`STDCTRLS$_$TBUTTONCONTROL_$__$$_CLICK + 42 at buttoncontrol.inc:55
69+ frame #3: 0x000000010025909f project1`STDCTRLS$_$TCUSTOMBUTTON_$__$$_CLICK + 79 at buttons.inc:169
70+ frame #4: 0x00000001002587e2 project1`STDCTRLS$_$TBUTTONCONTROL_$__$$_WMDEFAULTCLICKED$TLMESSAGE + 66 at buttoncontrol.inc:21
71+ frame #5: 0x0000000100012103 project1`SYSTEM$_$TOBJECT_$__$$_DISPATCH$formal + 203
72+ frame #6: 0x00000001001eda95 project1`CONTROLS$_$TCONTROL_$__$$_WNDPROC$TLMESSAGE + 517 at control.inc:2246
73+ frame #7: 0x00000001001e0926 project1`CONTROLS$_$TWINCONTROL_$__$$_WNDPROC$TLMESSAGE + 806 at wincontrol.inc:5406
74+ frame #8: 0x00000001001cc980 project1`LCLMESSAGEGLUE_$$_DELIVERMESSAGE$TOBJECT$formal$$INT64 + 224 at lclmessageglue.pas:112
75+ frame #9: 0x00000001001cca8b project1`LCLMESSAGEGLUE_$$_SENDSIMPLEMESSAGE$TCONTROL$LONGWORD$$INT64 + 59 at lclmessageglue.pas:143
76+ frame #10: 0x000000010029200a project1`COCOAWSSTDCTRLS$_$TLCLBUTTONCALLBACK_$__$$_BUTTONCLICK + 58 at cocoawsstdctrls.pp:401
77+ frame #11: 0x00000001001b2a3f project1`-[TCocoaButton actionButtonClick:] + 87 at cocoaprivate.pp:2294
78+ frame #12: 0x00007fffbec8dc41 libsystem_trace.dylib`_os_activity_initiate + 61
79+ frame #13: 0x00007fffa7a5c770 AppKit`-[NSApplication(NSResponder) sendAction:to:from:] + 456
80+ frame #14: 0x00007fffa75450d8 AppKit`-[NSControl sendAction:to:] + 86
81+ frame #15: 0x00007fffa7545000 AppKit`__26-[NSCell _sendActionFrom:]_block_invoke + 136
82+ frame #16: 0x00007fffbec8dc41 libsystem_trace.dylib`_os_activity_initiate + 61
83+ frame #17: 0x00007fffa7544f58 AppKit`-[NSCell _sendActionFrom:] + 128
84+ frame #18: 0x00007fffa75878d9 AppKit`-[NSButtonCell _sendActionFrom:] + 98
85+ frame #19: 0x00007fffbec8dc41 libsystem_trace.dylib`_os_activity_initiate + 61
86+ frame #20: 0x00007fffa754383c AppKit`-[NSCell trackMouse:inRect:ofView:untilMouseUp:] + 2481
87+ frame #21: 0x00007fffa7587616 AppKit`-[NSButtonCell trackMouse:inRect:ofView:untilMouseUp:] + 798
88+ frame #22: 0x00007fffa75421f7 AppKit`-[NSControl mouseDown:] + 832
89+ frame #23: 0x00000001001b31ab project1`-[TCocoaButton mouseDown:] + 139 at cocoaprivate.pp:2410
90+ frame #24: 0x00007fffa7bd291f AppKit`-[NSWindow(NSEventRouting) _handleMouseDownEvent:isDelayedEvent:] + 6341
91+ frame #25: 0x00007fffa7bcf13c AppKit`-[NSWindow(NSEventRouting) _reallySendEvent:isDelayedEvent:] + 1942
92+ frame #26: 0x00007fffa7bce5da AppKit`-[NSWindow(NSEventRouting) sendEvent:] + 541
93+ frame #27: 0x00000001001b15df project1`-[TCocoaWindow sendEvent:] + 919 at cocoaprivate.pp:1943
94+ frame #28: 0x00007fffa7a586f5 AppKit`-[NSApplication(NSEvent) sendEvent:] + 1145
95+ frame #29: 0x00000001001a405c project1`COCOAINT$_$TCOCOAWIDGETSET_$__$$_APPPROCESSMESSAGES + 268 at cocoaobject.inc:105
96+ frame #30: 0x000000010003733d project1`FORMS$_$TAPPLICATION_$__$$_HANDLEMESSAGE + 45 at application.inc:1276
97+ frame #31: 0x00000001000378e1 project1`FORMS$_$TAPPLICATION_$__$$_RUNLOOP + 209 at application.inc:1419
98+ frame #32: 0x00000001001a3d17 project1`-[TCocoaApplication run] + 71 at cocoaint.pas:368
99+ frame #33: 0x00000001001a3f4a project1`COCOAINT$_$TCOCOAWIDGETSET_$__$$_APPRUN$TAPPLICATIONMAINLOOP + 106 at cocoaobject.inc:83
100+ frame #34: 0x0000000100037808 project1`FORMS$_$TAPPLICATION_$__$$_RUN + 96 at application.inc:1401
101+ frame #35: 0x0000000100001514 project1`PASCALMAIN + 92 at project1.lpr:19
102+ frame #36: 0x0000000100020ef9 project1`FPC_SYSTEMMAIN + 41
103+ frame #37: 0x0000000100001494 project1`start + 52
104+ (lldb)
105105```
106106
107-8\. At this point you can give the "q" command (quit) to the debugger.
108-
109-```text
107+9\. At this point you can give the "q" command (quit) to the debugger.
108+```
110109(lldb) q
111-Quitting LLDB will kill one or more processes. Do you really want to proceed: [Y/n] y
110+ Quitting LLDB will kill one or more processes. Do you really want to proceed: [Y/n] y
112111```
113112
114-9 If you need to stop the application running under the debugger:
113+10 If you need to stop the application running under the debugger:
115114
116-
117-9.1 Hit Ctrl+C on the Terminal tab. This should signal to the debugger to pause the executed program.
115+10.1 Hit Ctrl+C on the Terminal tab. This should signal to the debugger to pause the executed program.
118116
119-9.2 Give "q" command (quit) to the debugger.
117+10.2 Give "q" command (quit) to the debugger.
120118
121119## Breakpoint issues
122120
123-Issue: There seems to be an issue starting with Xcode 11.4 (and still in Xcode 11.5). If stopped at a breakpoint within an objcclass type subclass, the “self” item is missing from the debugger. I still see the “this” for any objects descended from fpc’s TObject, so this seems to only apply to objcclass types.
121+Issue: There seems to be an issue starting with Xcode 11.4 (and still in Xcode 11.5). If stopped at a breakpoint within an objcclass type subclass, the “self” item is missing from the debugger. I still see the “this” for any objects descended from fpc’s TObject, so this seems to only apply to objcclass types.
124122
125-Background: At some point, lldb gained "support" for Pascal. Unfortunately, that support was barely non-existent, so rather than treating debug information in a Pascal program the same as it did in C/C++ programs like it did before, suddenly a bunch of things got broken when debugging a program whose debug information indicated it was a Pascal program.
123+Background: At some point, lldb gained "support" for Pascal. Unfortunately, that support was barely non-existent, so rather than treating debug information in a Pascal program the same as it did in C/C++ programs like it did before, suddenly a bunch of things got broken when debugging a program whose debug information indicated it was a Pascal program.
126124
127-Possible solution: What you can try is to use the **-godwarfcpp** command line option. Then FPC will encode in the debug information that it's a C++ program which solves several of those issues.
125+Possible solution: What you can try is to use the **-godwarfcpp** command line option. Then FPC will encode in the debug information that it's a C++ program which solves several of those issues.
128126
129127## DevToolsSecurity
130128
131-The `DevToolsSecurity` command line utility changes the security authorisation policies for use of the Apple-code-signed debugger and performance analysis tools on development systems.
132-
133-On normal user systems, the first time in a given login session that any such Apple code-signed debugger or performance analysis tools are used to examine one of the user's processes, the user is queried for an administrator password for authorisation. The tool changes the authorisation policies, such that a user who is a member of either the admin group or the _developer group does not need to enter an additional password to use the Apple-code-signed debugger or performance analysis tools.
129+The `DevToolsSecurity` command line utility changes the security authorisation policies for use of the Apple-code-signed debugger and performance analysis tools on development systems.
134130
135-To enable, open an Applications \> Utilities \> Terminal window and execute the following command:
131+On normal user systems, the first time in a given login session that any such Apple code-signed debugger or performance analysis tools are used to examine one of the user's processes, the user is queried for an administrator password for authorisation. The tool changes the authorisation policies, such that a user who is a member of either the admin group or the _developer group does not need to enter an additional password to use the Apple-code-signed debugger or performance analysis tools.
136132
137-```text
133+To enable, open an Applications > Utilities > Terminal window and execute the following command:
134+```
138135sudo DevToolsSecurity -enable
139136```
140137
141-to enable the change of security authorisation policies;
142-
143-```text
138+to enable the change of security authorisation policies;
139+```
144140sudo DevToolsSecurity -disable
145141```
146142
147-to disable the change of security authorisation policies; and
148-
149-```text
143+to disable the change of security authorisation policies; and
144+```
150145DevToolsSecurity -status
151146```
152147
153-to check whether the change of security authorisation policies is enabled or disabled.
148+to check whether the change of security authorisation policies is enabled or disabled.
154149
155150## See also
156151
157-- [Apple: Appendix A: LLDB for GDB Users – Command Summary](https://developer.apple.com/library/archive/documentation/General/Conceptual/lldb-guide/chapters/A3-GDB-Summary.html)
158-- [[Creating a Backtrace with GDB]]
152+ * [Apple: Appendix A: LLDB for GDB Users – Command Summary](<https://developer.apple.com/library/archive/documentation/General/Conceptual/lldb-guide/chapters/A3-GDB-Summary.html>)
153+ * [[Creating a Backtrace with GDB]]
159154
160155---
161-*From the Free Pascal wiki, page "lldb", as it stood on 2023-04-06 after a change by Jwdietrich, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*
162-Category: Debugging
163-Category: macOS
156+*From the Free Pascal wiki, page "lldb", as the Internet Archive kept it on 2025-02-26, last changed on 2024-10-11. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*

Back to history