ALL,
In gdb when I start it like:
gdb myprog
when I get a crash I can immediately issue bt command and get a backtrace.
However in lldb + OSX after the crush, it looks like the tread is finished and doing bt does not profuce the backtrace.
Is there any lldb command that preserves the running process after the crash to get the backtrace?
TIA!!
EDIT:
Igors-MacBook-Air:toolbar igorkorot$ lldb toolbar.app/
(lldb) target create "toolbar.app/"
Current executable set to 'toolbar.app/' (x86_64).
(lldb) break set -f toolbar.mm -l 1189
Breakpoint 1: where = libwx_osx_cocoau_core-3.3.0.0.0.dylib`wxToolBar::Realize() + 19 at toolbar.mm:1189, address = 0x00000000001c92e3
(lldb) run
Process 55323 launched: '/Users/igorkorot/customtoolbar/buildC11/samples/toolbar/toolbar.app/Contents/MacOS/toolbar' (x86_64)
2023-07-05 23:15:26.708214-0500 toolbar[55323:5146343] -[NSTaggedPointerString setObject:forKey:]: unrecognized selector sent to instance 0x74756f624155
Unhandled unknown exception; terminating the application.
Process 55323 exited with status = 255 (0x000000ff)
Simple session added.
However, when I rebuilt the program and the library I'm using for development it starts working as Jim described.
I may start re-building everything...
Thank you.
You are hitting an "unhandled NSException", which just causes your application to exit with an error code. That's a choice that the runtime makes, and that's what the debugger is reporting.
Stopping when the exception is about to cause termination isn't terribly useful anyway, most of the information about why the exception was raised is gone by then. You really want to stop at the point where the exception was first raised. To do that, set the "objc exception throw breakpoint":
then run your app. Now it will stop at this breakpoint when the "doesn't respond to selector" error is raised, and you can go up the stack to examine the object that caused the problem.
BTW, you probably have a bad NSDictionary variable value that you are sending
setObject:forKey:. NSTaggedPointers are an optimization where for small objects, the contents of the object can be stored directly in the pointer to the object (along with some markers that allow the runtime to distinguish these tagged pointers from regular objects).But that means a bad pointer value can look like some kind of tagged pointer object. In your case, your bad value looks like a tagged pointer for an NSString and that's why you are getting the "doesn't respond to selector" error.