Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remote debugging using lldb/Xcode

I've got 2 stations, one for development and another one for testing. I'd like to be able to run and debug targets that were built under release mode (the code is stripped) on the testing station.

Since the code may not be copied to the testing station for security reasons, I've tried remote debugging as described in the following link - http://lldb.llvm.org/remote.html.

Since both sides of the debugging runs OS X, the settings instructions specify that my local (development) station should run 'lldb-server' along with 'debugserver', and remote (testing) side should run 'platform'.

Unfortunately, I couldn't find all those tools inside the Xcode bundle. I also tried to download lldb source code and create those executable by myself, but I'm still missing the lldb-server target.

I wish I had some clear and comprehensive guide about how to do lldb remote debugging properly from A to Z.

like image 524
Zohar81 Avatar asked Nov 05 '15 18:11

Zohar81


People also ask

Does Xcode use LLDB?

Xcode uses the LLDB as the default debugging tool. The full form of LLDB is Low-level debugger. Breakpoints help a developer to stop the execution of the program at any point.

What does LLDB mean in Xcode?

What is LLDB? A low-level debugger (LLDB) is the default debugger used in Xcode and is part of the LLVM project. LLDB replaced GDB in XCode 5 and has several advantages, such as performance and scriptability.

How do you create a breakpoint in LLDB?

In lldb you can set breakpoints by typing either break or b followed by information on where you want the program to pause. After the b command, you can put either: a function name (e.g., b my_subroutine ) a line number (e.g., b 12 )

Can LLDB connect to Gdbserver?

LLDB supports GDB server that QEMU uses, so you can do the same thing with the previous section, but with some command modification as LLDB has some commands that are different than GDB You can run QEMU to listen for a "GDB connection" before it starts executing any code to debug it.


2 Answers

  1. Make sure that Xcode is installed on both machines. (Different versions are OK!)

  2. On the remote machine (running the executable):

    1. Start the app you want to debug
    2. Start debugserver, attach to your app, and listen for connections from the other Mac: /Applications/Xcode.app/Contents/SharedFrameworks/LLDB.framework/Versions/A/Resources/debugserver development-mac.local:16000 --attach="Photo Booth"
  3. On the development machine:

    1. Start lldb by typing lldb
    2. Connect to the debug server: process connect connect://test-mac.local:16000

On the test machine, you should now see the message Waiting for debugger instructions for process 0. After a short while, the (lldb) prompt should appear on your development machine, and you can start debugging as normal.

Unfortunatly, I'm not sure how to connect from Xcode.

like image 131
Jakob Egger Avatar answered Oct 10 '22 18:10

Jakob Egger


Please give feedback for Apple to update their documentation here

In the mean time, I'm getting more milage using hopperapp with app disassembly. http://hopperapp.com/ There's a free trial - and it has a remote debugger available.

like image 44
johndpope Avatar answered Oct 10 '22 17:10

johndpope