The LLDB command-line debugger provides underlying debugging services for development on all Apple platforms.

Posts under LLDB tag

35 Posts
Sort by:
Post not yet marked as solved
2 Replies
264 Views
I am using the Leaks instrument, and it has identified a bunch of 32 and 48 byte "Malloc" leaks. I would like to see a hex dump of some (or all) of those areas. I think if I can see what is in them I can get a better idea about what is triggering the leak. I'm pretty sure it is a real leak. What is the easy way to do this? Can it be done inside instruments, or do I need to run my app under instruments and also attach via lldb and hexdump from lldb? (can I attach lldb and instruments at the same time?) If it matters I'm debugging an iPadOS app, and it is written in Swift plus ObjC, plus ObjC++, oh, and some straight C++.
Posted
by
Post not yet marked as solved
0 Replies
182 Views
OS: Sonoma 14.2.1 (23C71), I am porting a linux code (that uses C++, QT) to mac OS. after compiling the code on mac, I get segmentation error due to libGL.dylib. My question is how to avoid the segmentation error. debug messages when I run it using lldb: 2024-03-21 13:13:17.957964+0530 EdgeMarker[10094:150997] SecTaskCopyDebugDescription: EdgeMarker[10094]/0#-1 LF=0 2024-03-21 13:13:18.962117+0530 EdgeMarker[10094:150997] SecTaskLoadEntitlements failed error=22 cs_flags=20, pid=10094 2024-03-21 13:13:18.962246+0530 EdgeMarker[10094:150997] SecTaskCopyDebugDescription: EdgeMarker[10094]/0#-1 LF=0 Process 10094 stopped * thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0xa80) frame #0: 0x00007ffa1c1295a4 libGL.dylib`glViewport + 22 libGL.dylib`glViewport: -> 0x7ffa1c1295a4 <+22>: movq 0xa80(%rax), %r9 0x7ffa1c1295ab <+29>: movq (%rax), %rdi 0x7ffa1c1295ae <+32>: popq %rbp 0x7ffa1c1295af <+33>: jmpq *%r9 Target 0: (EdgeMarker) stopped. Backtrace snippet: * thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0xa80) * frame #0: 0x00007ffa1c1295a4 libGL.dylib`glViewport + 22 frame #1: 0x000000010000c427 EdgeMarker`MyGLCanvas::initializeGL(this=0x00007f8e4f857710) at MyGLCanvas.cpp:33:2 The error occurs when initializing an opengl window: void MyGLCanvas::initializeGL() { m_width = this->frameGeometry().width(); m_height = this->frameGeometry().height(); m_initialized = true; m_Eye[0] = 0.0f; m_Eye[1] = 0.0f; m_Eye[2] = -2.0f; //Actual code m_PerspectiveAngleDegrees = 45.0f; m_NearPlane = 0.01f; m_FarPlaneOffset = 100.0f; glViewport(0, 0, (GLint)m_width, (GLint)m_height); Before calling MyGLcanvas::initializeGL() there is a call to setFocus() function. SetFocus is a function used in GUI programming to give focus to a specific window or control within a window. My second question : Is setFocus valid is mac OS or is there an equivalent?
Posted
by
Post not yet marked as solved
1 Replies
330 Views
I have a sandboxed app in /Applications. I'm attempting to shoot a problem with LLDB, so I cd to /Applications/app-name/Contents/MacOS and do lldb programname. However, once I fire it off with "r" it dies instantly with: error: process exited with status -1 (lost connection) Should this work? Should I try signing the lldb executable? Thanks!
Posted
by
Post not yet marked as solved
2 Replies
315 Views
After upgrading from Xcode 14.3 to Xcode 15.2, I am observing unexpected behaviour in Xcode when printing string variables to the console. Specifically, blank lines do not show up (they previously did, as expected, with Xcode 14.3). Steps to reproduce: Put this multiline (Swift) string literal in some Swift file (two lines with one blank line in between) let test = """ line1 line3 """ let Xcode hit a breakpoint in the file with the string print the string value to Xcode console: (lldb) po test "line1\n\nline3" print the same string, cast to NSString, to Xcode console: (lldb) po test as NSString line1 line3 Observed: The blank line is missing in the "po test as NSString" output Expected: There should be a blank line between line1 and line3 I'm running macOS 13.6 (22G120) and Xcode 15.2 (15C500b)
Posted
by
Post not yet marked as solved
0 Replies
320 Views
Xcode15.2 LLDB 太慢了,简直无法工作,好几分钟才断点出变量传,然后断点无法跳出继续执行。Xcode14.1则不会有这些问题,望修复。
Posted
by
Post not yet marked as solved
3 Replies
491 Views
Visual Studio, Stadia, and JetBrains are supporting natvis files, where Xcode is still stuck on lldb python files that even Xcode no longer uses to debug data structures. Apple has converted all of their scripts to native code, so there are no samples of how to write complex lldb visualizer rules. There is already an lldb-eval that can bring in natvis files, so something like this should be brought to Xcode. C++ packages like EASTL only ship with a natvis file, and it's far simpler to edit and write than the lldb rules and python scripting.
Posted
by
Post not yet marked as solved
0 Replies
719 Views
Topic : Attaching debugger via lldb to remote process on tv device Current status I launch an app on a remote tv device that is paired to a macbook using the command xcrun devicectl device process launch --start-stopped -d XXXX-XXXXXX, com.metasample.SampleApp -j launch.json App is launched in stopped state and waiting for debugger to be attached to continue execution Using the XCode->Debug->Attach to Process, I am able to select the process and connect to the process and execute the app through the debugger. Expectation I would want to replace step 3 and use a command line instead to attach the debugger to the remote process instead of doing it via XCode.(the reason is to automate the execution without any manual intervention) I know the process id of the app on the remote tv device when i inspect the launch.json file that is created when the launch the app. eg pid 312 I also know the ip address of the device eg ip 192.168.178.29 However I do not know how to establish the debug session using lldb from command line. I launch lldb in the command line and execute these commands platform select remote-tvos target create /Users/works/apps/SampleApp-Payload/SampleApp.app/SampleApp gdb-remote 192.168.178.29: "what is the port?" - I do not know what port to connect to? Many Thanks for your suggestions and inputs on how to connect to the remote app via command line lldb.
Posted
by
Post not yet marked as solved
1 Replies
390 Views
I'm writing a C/C++ command line program which, at some point, calls IOHIDManagerOpen. I've added both my program executable and lldb as permitted for input monitoring (as far as I remember, my program was added after showing up a permission prompt, I've added lldb manually later, trying to resolve the problem). My problem is that when I run my program from within lldb in Terminal, the call to IOHIDManagerOpen returns kIOReturnNotPermitted. When I run my program directly in the terminal session (without lldb), this call returns kIOReturnSuccess. Such behaviour means it will be impractical to use lldb for any debugging of this program. What can be done to make lldb session behave the same way, the normal execution works? I'm on: 23.2.0 Darwin Kernel Version 23.2.0: Wed Nov 15 21:55:06 PST 2023; root:xnu-10002.61.3~2/RELEASE_ARM64_T6020 arm64 and: lldb-1500.0.200.58 Apple Swift version 5.9.2 (swiftlang-5.9.2.2.56 clang-1500.1.0.2.5)
Posted
by
Post not yet marked as solved
1 Replies
529 Views
Hello, is there any way that I can automatically fold items in the console? I do log all API requests and responses, printed in a nice json to console. It works well, but having a lot of requests makes the console very big, and it kills readability, I have noticed that I can manually fold json printed in console with CMD+OPTION+Left shortcut. I am asking if that's possible to fold everything, or just display first lines of the console. So I can see more entries easier, and if I need I can unfold, or disable Line Wrap, to see details. I am attaching the photo of how code folds works there. It's all good, but I need to do it one by one, which is bad. If I could select everything and auto-fold, or It has the line wrap disabled. I
Posted
by
Post not yet marked as solved
2 Replies
468 Views
I am trying to debug a kernel panic in our kext. I can attach to the target Mac over ethernet if I: cause an NMI using add an IOPanic call to my kext and cause it to be executed use Dtrace to invoke a panic However if I reproduce the kernel panic which I am investigating, the Mac just restarts. How can I make the Mac wait for me to attach with lldb rather than restarting? My target configuration is: Mac is 2021 M1 Pro 14" MacBook Pro macOS 14.2 (23C64) Network: Apple Thunderbolt 3 <-> Thunderbolt 3 adapter + Apple Thunderbolt 2 to ethernet adapters Boot-args = "debug=0x44 wdt=-1 kdp_match_name=en8" (I have also tried debug=0x104C0C)
Posted
by
Post not yet marked as solved
1 Replies
616 Views
When po an NSObject variable in lldb in Xcode 15.1,an error occurs,this error description is "error: Internal error [IRForTarget]: Couldn't change a static reference to an Objective-C selector to a dynamic reference" Has anyone encountered this situation? How can i fix this?
Posted
by
Post not yet marked as solved
4 Replies
734 Views
Yesterday, my code ran just fine under the previous Xcode version. Today, some print() statements seem to come with extra lines. I know it sounds stupid, but my code did not change in the meantime. It doesn't appear to come from anything I control, almost like some Apple code emits an extra line feed somewhere. It's just a Swift Mac App I built to make my digital art; otherwise, nothing else is incorrect, just these odd lines. It's not as simple as just making a test case with a few print("***") statements, it seems to require other code to run in between calls to print. Most of my app is using CoreGraphics. It has no UI. It's like when you see spurious Apple debugging info in the console sometimes, but it's only a blank line this time. It's not a big issue, just annoying.
Posted
by
Post marked as solved
1 Replies
367 Views
In an old document from Apple(Debugging An Authorization Plug-In With Xcode), a method was taught to debug plugins on the device remotely, but I can't find this feature in the new Xcode version. Does it exist In the new Xcodes? https://developer.apple.com/library/archive/technotes/tn2108/_index.html#//apple_ref/doc/uid/DTS40007965-CH1-SECCONFIGXCODE
Posted
by
Post not yet marked as solved
3 Replies
620 Views
I am building simple command-line programs in C. When I run LLDB on the command line on any such executable , even though I set a breakpoint in main, LLDB always runs to termination and reports an error. Below is an example: ~ % clang -Wall -g prog.c -o prog aviram@csaamdS278stma ~ % lldb prog (lldb) target create "prog" Current executable set to '/Users/aviram/prog' (x86_64). (lldb) breakpoint set --name main Breakpoint 1: where = progmain + 15 at prog.c:73:21, address = 0x0000000100003ebf (lldb) run Process 99926 launched: '/Users/aviram/prog' (x86_64) Process 99926 exited with status = -1 (0xffffffff) lost connection (lldb) ` Note that it says "lost connection" even though I am _ remote debugging. This happens with every executable I build._ Details: 2019 MacBook Pro (x86_64, Sonoma); Apple Clang 12.0.0 (downloaded with Xcode 15.0.1). Why is this happening and what can I do to debug my program (for real) using LLDB from the command line? Thanks.
Posted
by
Post marked as solved
2 Replies
456 Views
As I was watching WWDC19 Session: "LLDB: beyond "po" " I got confused about "p" command. In the session there was a following example to show how "p" command works: // Struct for demonstration purposes struct Trip { var name: String var destinations: [String] let cruise = Trip ( name: "Mediterranean Cruise" destinations: ["Sorrento", "Capri", "Taormina"]) Using "p" to get info about cruise instance: (lldb) p cruise (Travel.Trip) $R0 = { name = "Mediterranean Cruise" destinations = 3 values { [0] = "Sorrento" [1] = "Capri" [2] = "Taormina" } } I was following along and wrote the same code. But the output from LLDB turned out to be different: (lldb) p cruise (LLDB_Apple_Session_FollowAlong.Trip) { name = "Mediterranean Cruise" destinations = 3 values { [0] = "Sorrento" [1] = "Capri" [2] = "Taormina" } } As you can see LLDB didn't create a global variable R0 which I could later use in my debugging session and that seemed strange to me. Then the presenter said the following: "p" is just an alias for the "expression" command. So, I tried to use the "expr" command to see if they're actually the same and they turned out to be different commands. The output I got from "expr" was the one I expected from "p": (lldb) expr cruise (LLDB_Apple_Session_FollowAlong.Trip) $R0 = { name = "Mediterranean Cruise" destinations = 3 values { [0] = "Sorrento" [1] = "Capri" [2] = "Taormina" } } Finally, my question is: Am I wrong somewhere or did something change in LLDB regarding "p" and "expr" commands and if so, where could I get more information about the changes?
Posted
by
Post not yet marked as solved
2 Replies
468 Views
Hello. I am currently developing a C++ application for x86_64 using XCode, and I am experiencing the same problem as described in the following link. https://discourse.llvm.org/t/lldb-doesnt-stop-on-sigabrt-assert-with-x86-executable-on-apple-arm/69749/1 Due to this bug, when the application crashes, it is difficult to tell which source code caused the crash, and this is reducing our development efficiency. How can this be fixed? Thank you in advance for your help.
Posted
by
Post not yet marked as solved
1 Replies
405 Views
Hello, I have tried to create a thread with thread_create_running API. It works but i would like to suspend this thread. I can call thread_suspend, but my thread has already been start before i call this API. Is there a way to create a thread without running it automaticaly. Thanks
Posted
by
Post not yet marked as solved
2 Replies
596 Views
Hello, My purpose is to understand how macOS works. Here is what i've done: I have wrote a c program on a M1 CPU with this lines: printf("Before breakpoint\n"); asm volatile("brk #0"); printf("After breakpoint\n"); When i run this program with lldb, a breakpoint is hit on the second line. So i suppose lldb is writing a "brk #0" instruction when we put a breakpoint manually. I can't continue to next line with lldb "c" command. PC stays on the brk instruction. I need to manually set PC to next instruction in lldb. Now, what i want to do is to create my own debugger. (I want to understand how lldb works). I have managed to ptrace the target program and i was able to catch an event with waitpid when "brk #0" is hit. But i don't know how i can increase PC value and continue execution because i can't do this on Silicon CPU: ptrace(PTRACE_GETREGS, child_pid, NULL, &amp;regs); ptrace(PTRACE_SETREGS, child_pid, NULL, &amp;regs); kill(child_pid, SIGCONT); So my question is: How does lldb managed to change ARM64 registers of a remote process ? Thanks
Posted
by
Post not yet marked as solved
0 Replies
547 Views
Hello, I am facing an issue when debugging cpp code through the XCode after updating to XCode 15.0. During debugging, in a variables watch view, it is shown for the collections (let's take std::vector as an example) that its size is 0 even if it is not. If I add it as an expression to watch, it is fine. Also if I print it in lldb console, it is also fine. Any thoughts on this?
Posted
by
Post not yet marked as solved
3 Replies
888 Views
xcrun devicectl has support for installing and launching apps but does it support launching a debugserver? I've tried xcrun devicectl device process launch /usr/libexec/debugserver to no avail. Is there something I'm missing or perhaps another tool that would let me start a debugserver from command line?
Posted
by