Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Finding the origin of Xcode debug message

Tags:

xcode

I am working with a number of 3rd party suppliers, who have provided me with comprehensive .lib files. One of the processed that are running are logging a message to the console that is a little concerning and needs to be raised with the supplier.
The problem is, I'm not sure where the message is coming from and, due to the complexity of the project, would be pretty much impossible to see where the message is coming from. By this, I mean, that some libraries interact with each other and the project will not run without others. If I were to comment out the initialisation of certain classes, it could be a red-herring as it may be calling a function from another library.
My question is, is there a feature in Xcode breakpoints (or another tool that I may be able to use) that shows where a certain console log (whether it be NSLog or possibly std::cout etc) is coming from?

Thanks a lot, in advance.
Luke

like image 255
mylogon Avatar asked Oct 31 '25 02:10

mylogon


1 Answers

Yes, use symbolic breakpoints to break on NSLog or std::cout. If you are dealing with C++ code or Swift you can even break on specific errors or exceptions. To add symbolic breakpoints to your project, you have to do the following:

  • Go to the breakpoint navigator by clicking on the icon that looks like a fat right arrow on the navigation area (in Xcode 8, 2nd icon counting from the right on the panel to the left of the editor)
  • Click on the + button on the bottom left corner of the window
  • Choose on the pop-menu Symbolic Breakpoint
  • Add the symbol you want to break on (examples: in C++, std::cout; in objective C: -[NSObject(NSObject) doesNotRecognizeSelector:]; in C or Swift, CGErrorBreakpoint() - Important Note - avoid inserting any white space; unfortunately, the formatting in here puts -[symbol] in different lines but there must be no white space between - and [ in the ObjC symbol
  • If you know what is the library that is giving you grief fill in the module field
  • Click on the action button and choose Debugger Command in the popup menu that comes up
  • In the text field below, fill in bt for getting a backtrace every time you hit such a symbol
  • If you don't want to stop execution after hitting the first breakpoint, then check the Automatically continue after evaluating actions checkbox

If your library is throwing a C++ exception, you can break on this too. Just choose that option when you click on the + button. To know more how to set breakpoints in Xcode go to:

http://help.apple.com/xcode/

And navigate to: Debug your app > Set Breakpoints > Pause execution when events occur

like image 113
jvarela Avatar answered Nov 03 '25 11:11

jvarela



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!