Xcode copy-paste breakpoints - xcode

Is there any way to copy-paste breakpoints in Xcode?
The reason I am asking is, I have a breakpoint set to "automatically continue after evaluating", with some actions associated. I want to have the same breakpoint behavior/action in multiple places in the code. Instead of re-doing it (Setting breakpoint, customizing it) 10 times (or even more which can be cumbersome), just copy-paste it!?

I've found a solution, though it might not be easier. All of the breakpoints are saved in an XML file inside your Xcode project. To find the file, select your project file and choose "Show Package Contents", then go to:
xcuserdata/(YourNameHere).xcuserdatad/xcdebugger/
You can open the breakpoints file and copy /paste their XML. You can then change the file and line numbers of the breakpoints.

In the scope of one file, you can easily duplicate breakpoints from Breakpoints Navigator (⌘+8). Just select a particular breakpoint and then copy and paste (⌘+c, ⌘+v).
It's going to be duplicated on the same line, so you need to move it with mouse to any other line.
Unfortunately, it's not currently possible to move breakpoints between files (Xcode 13.1).

I ran into this issue as well as I wanted to share some of my more elaborate breakpoints with people in my team.
Project with CocoaPods
You will find the xcdebugger directory in
PROJECT_NAME.xcworkspace/xcshareddata/xcdebugger
Second, you will need to make the breakpoint a shared breakpoint by right clicking the breakpoint and clicking Share Breakpoint
You should then find the Breakpoints_vX.xcbkptlist file with your shared breakpoints in the xcdebugger
Project with no CocoaPods
You should find the xcdebugger directory for the shared breakpoints here
PROJECT_NAME.xcodeproj/xcshareddata/xcdebugger
In there you will find the same breakpoints file you seek. There is also a xcdebugger directory in the xcuserdata/USERNAME.xcuserdatad but they might have some coded file paths that would be problematic when sharing other devices.

Related

Visual Studio: Open up a symbol source file prior to debugging and set breakpoint

I have a project where the referenced assemblies have symbol files available. Both pdb, and the source files themselves. (they are all my own libraries). The symbols are all listed in the Tools / Options / Debugging / Symbol marking their locations. Thats all fine.
But it's working with them, i'd like to know:
Is there a way in Visual studio to set a breakpoint in a file of the symbol before having to debug line by line to get to the code in question.
To be clear, if i step line by line i can eventually hit the source (because of using the symbol files) code i'm after. But some times getting to that location is not easy, because it's so nested within multiple symbol files. BUT once i eventually step deep enough and find the code, i can set the breakpoint, and from there on stop and start the main application and get to that location without trouble. The file code and all is even listed in the open file pane, for easy view.
Is there any way, if i know the file and line of code i want to break at, open that file in VS and set the breakpoint directly?
Hopefully i was clear in the description. Let me know if i need to reword.
tx
I bet the code you want to put a breakpoint is in a function (;)) so I would use a New breakpoint option from Visual Studio. This allows you to put a method name that VS should break on when entering the method (so basically on the first { after the function name).
After pressing CTRL+B you will be presented with the dialog
Here you specify a function name you want to put a breakpoint on.
You can just specify just the name (like. AppendText) or fully qualified name (with namespace - System.Windows.Forms.TextBoxBase.AppendText). If you want to narrow it down to a specific module user module_name!function_name syntax. If needed you can specify on which of the overloaded function you want to break on.
All this info you can get by hovering over an (i) icon on this dialog.
OK. Knew there had to be a way. And it's very simple.
As stated, if you have the symbol and source available for the Nuget packages you are working with follow these steps:
open the main project in question in Visual Studio.
In VS, click File / Open File...
Under your PACKAGES Folder, locate the package for the reference you want to set breakpoint.
In that package locate the source code folder that was packaged along with the pdb file.
There you will find the source code. Now locate the file you want the breakpoint placed in. Click that file to OPEN the file in Visual Studio.
That file is now OPEN in your VS viewer, but it is not included as a new file in your project (good thing).
Place breakpoint where you want.
Run solution. Now you don't have to step through your entire solution to get to the code you wanted to review with that breakpoint!
what a relief!

Keeping unused files in Xcode project

In Eclipse you can create a folder and name it, say, "unused", to keep currently unused files (incomplete code, resources for future use, etc)
which are ignored by project builder. Can I have something similar with Xcode?
If I move a file to a project folder without inserting it with Xcode, it may be OK, and I will be able to see it while opening in Finder. However, it will be more convenient to have it listed by Project Navigator.
As far as I am concerned, it's not possible. Though, you can comment all of your code in one click to momentarily disable it.
Press command + A;
Right click and select Comment Selection.

xcode commit and transfer breakpoints from one computer to another computer

I'm looking a way to keep breakpoint settings between two computers with Xcode under github.
Addin that file:
server:myproject.xcodeproj alex$ ls xcuserdata/alex.xcuserdatad/xcdebugger/
Breakpoints.xcbkptlist
has no success.
Where i'm wrong?
UPDATE - it's working now, but i need to restart Xcode to see updated breakpoints. any chances to avoid it?
If you're trying to share through git, you probably have *.xcuserdatad ignored (if not, you should). If you don't mind everyone seeing the breakpoint, you can share it from within Xcode:
Right-click the breakpoint in the breakpoint navigator and select "Share":
You should now be able to add the file via git. It'll be in a location like this:
Test/Test.xcodeproj/xcshareddata/xcdebugger/Breakpoints.xcbkptlist
Anybody else working on the project should now be able to use that breakpoint.

How do I set a breakpoint in an external source file in XCode 4?

I want to put a breakpoint in a file that's part of a library used in my application. If I simply open the .cpp file in XCode, it gets its own window, and breakpoints are never triggered.
But when Xcode opens a source file in the same library - because of an exception for example - that file gets opened in the application project/workspace window. If I set a breakpoint here, it will get triggered.
So how do I simply open a source file and set breakpoints on it? I remember in VC++ you just opened the .cpp file and it figured out if there were debug symbols, but not so here?
You can set a symbolic breakpoint on a function that is hit in that file. Xcode will open the file when the breakpoint is hit and from there on you can set breakpoints by click as long as the file remains in the most recently used list.
It's a pain in the a. But Xcode cannot handle it better. Technically it wouldn't be a problem (other than the other answer says) The symbols contain the path, so matching is no problem. That's why it works once you tricked XCode to open it...
You have to start the library with the app as hosting executable otherwise Xcode doesn't know what relationship the source has to your binary of the library

How to set breakpoint in a dependent xcode project

i have a XCode project (my main xcode project which has its executable). It has dependencies on a few other projects (under the Project tab in Detail View, there are a few other xcode project that it depends on).
My question is how can I setup breakpoint in the code of the dependent project?
I tried this, but this does not work
1. open my main xcode project
2. double click one of the dependent xcode project
3. in the source directory, find the file I want to break and add a breakpoint (by click at the side of the border of the editor, a blue 'bookmark thing' shows up)
4. Go back to 'Build and Go', my application does run but it never breaks at the break point I set in #3.
Can someone please help me? I have spent days on this, I can't figure it why.
Thank you.
1) Add the breakpoint in your project
2) Go into breakpoints view in xcode (top left besides project navigator) The view's icon is like a breakpoint icon
3) Right click on the required breakpoint and select "Move to" -> "User"
If the breakpoint is under "User" project, then it is accessible by all projects.
Whenever I've had trouble setting breakpoints with the Xcode GUI, I've managed to do it with the debugger command line (that is to say, the "lldb" prompt in the output window). For example, to set a breakpoint in source file "client.m" at line 42, type:
(lldb) b client.m:42
Besides being a fix for this particular problem, debugging on the command-line offers far more flexibility and automatability than any GUI could. A good place to start would be the LLDB tutorial. (Full disclosure: I'm a longtime fan of unix and gdb, so there's some bias here).
Of course, as others have mentioned, make sure the library/dependant project is compiled with debug symbols. Hope this helps; good luck.
I'll echo Jon-Eric here and also add that if you habitually run your project with Cmd+Enter, you should consider switching to Cmd+Y to enable gdb each time.
a few things here...(some obvious some not)
1) be sure that the dependant project is compiled with debug symbols (i'm assuming its a library)
2) be sure that your active executable is linking against the debug version of your dependent library
3) set a breakpoint in your main project just before calling into the entry point of your lib, and set a bp on the entry-point of the lib... (in addition to the real breakpoint you are looking to hit...)
I have found that the best way to debug a library is to open the lib project and set the active executable to be the main project, and then just hit "build and debug" directly from the library project.
I hope this helps, good luck, and have fun!
I've had similar problems with Xcode. The solution for me is to make sure that there is also a breakpoint in the main project that gets hit (as Kent mentions in his third point). I don't understand why this works though.
You should also only set breakpoints in a project when you've got it open. If you don't, they can start misbehaving: still stopping the flow of execution after you've disabled or deleted them, or not working when you think they're enabled.
Make sure you select 'Build and Debug' (for step #4). 'Go' sometimes means 'Run' (breakpoints disabled) and sometimes means 'Debug' (breakpoints enabled).
Also, make sure that you leave the dependent project open while you debug the main project.
In addition to kent reply about debug symbols, check COPY_PHASE_STRIP value in the build settings of the main project, and be sure it is set to NO in debug.

Resources