Name shared breakpoints

In my team we are using breakpoints to improve our development cycle.

We do have for example shared breakpoints which autofill the credentials form. That way we can avoid always having to use Siri Remote to write usernames and passwords, without any change in our code.

Sadly at the moment the name that Xcode is giving to the breakpoints in the Breakpoints Navigator is not very meaningful for this type of use cases. Xcode is naming the breakpoints with the name of the function and the number of the line.

That makes very hard to find the right endpoint that you really want to activate. As an example, in the previous use case, when having multiple shared breakpoints with different credentials to autofill, it means having the same name for all the breakpoints.

Recently, since Xcode 11.4.1 we saw that there is a new "Name" field in the breakpoint forms, but providing a name does not make the breakpoint appear with that label in Xcode.

Is there a way to name shared breakpoint using this new "Name" field, or any other method?

Accepted Reply

Hi,

After taking a closer look, this appears to be a bug in Xcode.

Could you please file a feedback describing your usage and the results you're getting, and share the feedback number here ?

As a workaround, you could use Xcode's console debugger to create named breakpoints by doing:

Code Block
# Show all the breakpoints.
(lldb) breakpoint list
# Add a name to one of the breakpoint in the list.
(lldb) breakpoint name add -N <breakpoint-name> <breakpoint-id>

Unfortunately, the breakpoints named on the console debugger won't show up in Xcode's Breakpoint Navigator.
To list your newly named breakpoints, you can do:

Code Block
# Print the named breakpoints list.
(lldb) breakpoint name list


One benefit of using the console debugger is that you can have all the lldb commands to create and name your breakpoints saved to a file contained in your Xcode project. This lldbinit file can then be checked into your version control system of choice (i.e. git) but more importantly, you can use it in the Scheme Editor as the LLDB Init File.

By doing so, every time you start a new debugging session, this file will be sourced by the debugger which will run all the commands that it contains.

Replies

Hi,

After taking a closer look, this appears to be a bug in Xcode.

Could you please file a feedback describing your usage and the results you're getting, and share the feedback number here ?

As a workaround, you could use Xcode's console debugger to create named breakpoints by doing:

Code Block
# Show all the breakpoints.
(lldb) breakpoint list
# Add a name to one of the breakpoint in the list.
(lldb) breakpoint name add -N <breakpoint-name> <breakpoint-id>

Unfortunately, the breakpoints named on the console debugger won't show up in Xcode's Breakpoint Navigator.
To list your newly named breakpoints, you can do:

Code Block
# Print the named breakpoints list.
(lldb) breakpoint name list


One benefit of using the console debugger is that you can have all the lldb commands to create and name your breakpoints saved to a file contained in your Xcode project. This lldbinit file can then be checked into your version control system of choice (i.e. git) but more importantly, you can use it in the Scheme Editor as the LLDB Init File.

By doing so, every time you start a new debugging session, this file will be sourced by the debugger which will run all the commands that it contains.
Thanks a lot for clarifying @medismailben, your response is really useful.

I have reported this issue as feedback #7701533
Happy to help! Thanks for submitting a feedback!
I'm pretty sure this is just a matter of listing, and not a disconnect between the naming feature in Xcode and the underlying feature in lldb. Because these are fully wired together, for now you can use the lldb breakpoint name command to access that breakpoints you've named in the Xcode Breakpoint Editor. For instance, I've named a breakpoint MyBkpt in the Xcode Breakpoint Editor, and then I can go to the Console and see that it has that name:

Code Block (lldb) break list
Current breakpoints:
1: file = '/tmp/Whatever/Whatever/main.cpp', line = 12, exact_match = 0, locations = 1, resolved = 1, hit count = 1
  Names:
    MyBkpt
  1.1: where = Whatever`main + 29 at main.cpp:12:13, address = 0x00000001000012ad, resolved, hit count = 1 


I can list all the breakpoints with that name by using that specifier in the break list command:

Code Block (lldb) break list MyBkpt
1: file = '/tmp/Whatever/Whatever/main.cpp', line = 12, exact_match = 0, locations = 1, resolved = 1, hit count = 1
  Names:
    MyBkpt
  1.1: where = Whatever`main + 29 at main.cpp:12:13, address = 0x00000001000012ad, resolved, hit count = 1 


And I can query for the names I've used already with the break name list command:

Code Block (lldb) break name list
Name: MyBkpt
1: file = '/tmp/Whatever/Whatever/main.cpp', line = 12, exact_match = 0, locations = 1, resolved = 1, hit count = 1


That's not to say that having Xcode show the breakpoint name more prominently isn't a great suggestion. We try to avoid forcing you to go to the lldb console for important information. But unless I'm missing something in your question, you can get the information you need about your Xcode set breakpoints from the console for now.
Please make sure your breakpoint name does not contain white spaces.