Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Project specific .lldbinit in current working directory not read by Xcode

Tags:

xcode

lldb

I want to setup project specific .lldbinit files, so that "everything" would be under version control and easily setup in new computers. However it seems like I can read only ~/.lldbinit file and not any ~/git/project/.lldbinit files.

LLDB manual say:

lldb will read settings/aliases/commands from three files at startup, if they exist.

First, it will read a ~/.lldbinit-debugger command file. If you are using the lldb command line interface, this is ~/.lldbinit-lldb. If you are using lldb inside a GUI debugger like Xcode this will be ~/.lldbinit- Xcode. This is a useful place to put settings that you want to apply only when a given lldb command interpreter is used.

Second, ~/.lldbinit is read.

Third, an .lldbinit file in the current working directory (where lldb is started) will be read.

So my question is: how do I setup Xcode or project to use the "third" option i.e. read .lldbinit file from the current working directory? How would I check or change what's Xcode's "current working directory"?

like image 358
JOM Avatar asked Apr 22 '15 08:04

JOM


2 Answers

Xcode now (written with the public Xcode 12) has support for setting a scheme-level LLDB Init File. This can be done as part of the Info tab in the Run phase of the scheme.

  1. Open project in Xcode.
  2. ⌘ + Shift + , to open scheme editor.
  3. Select Run then the Info tab.
  4. Edit LLDB Init File value.
    • Use $(PROJECT_DIR) to reference the directory that contains the project.
    • Use $(SRCROOT) to reference the target's source root directory.

Xcode scheme editor

like image 180
Matt Robinson Avatar answered Oct 13 '22 16:10

Matt Robinson


This is the working directory in which you launch whatever process loads the LLDB framework. Xcode doesn't have a useful working directory (it was / last time I looked), so you can't really use the cwd version.

A solution for Xcode project specific lldb settings that will work in many cases is to put a symbolic breakpoint on main, set it to auto-continue, then put the settings you want in the breakpoint commands of that breakpoint.

It would also be great if Xcode had some UI to specify target-specific lldbinit files.

like image 20
Jim Ingham Avatar answered Oct 13 '22 15:10

Jim Ingham