LLDB (debugger)

The LLDB debugger is known to work on macOS, Linux, FreeBSD, NetBSD and Windows,[4] and supports i386, x86-64, and ARM instruction sets.

Assuming that the file containing the code above is named test.c, the command for the compilation could be: And the binary can now be run: Since the example code, when executed, generates a segmentation fault, lldb can be used to inspect the problem: The problem occurs when calling the function strlen, but we can run a backtrace to identify the exact line of code that is causing the problem: From the line beginning with frame #5, LLDB indicates that the error is at line 5 of test.c.

According to the exception code EXC_BAD_ACCESS from the backtrace, strlen is trying to read from a region of memory it does not have access to by dereferencing an invalid pointer.

[11] Returning to the source code, we see that the variable msg is of type char but contains a string instead of a character.

To fix the problem, we modify the code to indicate that msg is a pointer to a string of chars by adding the * operator: After recompiling and running the executable again, LLDB now gives the correct result: LLDB runs the program, which prints the output of printf to the screen.