How to debug DYLIB in Xcode?

I am an experienced Visual Studio developer who recently took an OSX 10.6 project (C ++ server project without a user interface).

I successfully debugged the application using the Xcode debugger (setting breakpoints, etc.) for several months, including debugging the source code for various static libraries that are associated with the latest executable program.

However, today I needed to debug (with breakpoints) the DYLIB, which is also built from our source code, but it is dynamically linked at runtime to the application (the DYLIB name is read from the .ini file of the main application).

Unfortunately, the usual method that I use to debug the application (right-click on the user executable file and select "Debug with breakpoints"), although it successfully launches the debugger and allows me to debug the application (along with its statically linked library), exhibits the following undesirable behavior when I try to hit a breakpoint in the source code for DYLIB:

-> The Xcode debugger reports that the breakpoint was hit in the sense that I see the function and line number in the status bar at the bottom of the Xcode windows (along with indicating that this is a gdb message), and the application pauses execution. However, there is no stack trace, no variables, nothing - just a completely empty debugger window. The buttons "go", "enter", etc. Disabled. There is no editor window in the debugger (and, therefore, there is no visual indication that the debugger has stopped at the specified line). Opening the file manually does not show that the debugger hit the line.

Unfortunately for me this is useless as far as I'm trying to debug DYLIB.

I spent a long time searching and trying to find a way for the Xcode debugger to successfully hit breakpoints in a meaningful way in the source code for this dynamically linked DYLIB. Of course, I did a series of clean / rebuilds. I made sure that "load characters lazily" is not checked and then cleared / rebuilt. I restarted and I also deleted the "build" directory and rebuilt. I also deleted the user files in the .xcodeproj package. (Also note that I, of course, create and run all the code, including the DYLIB code, in development mode with the settings disabled and generating debugging symbols for everyone.) However, my attempts were unsuccessful. I also cannot find so many mentions of this problem in online forums.

Any help in teaching me to use Xcode to successfully debug the DYLIB associated with my application would be appreciated.

Thanks, Dan.

+4
source share
1 answer

Update -

This issue has been resolved. It was my lack of experience with OSX that made me not notice this. Despite the fact that my DYLIB project was part of the same Xcode project as the executable file that calls it, and although the DYLIB was built in the same directory as the executable file, the debugging application does not run at runtime accessed the DYLIB from this location. Instead, he turned to him from a different installation site. I no longer noticed when the installation location was β€œprepared” in the application, but by copying the final executable file / DYLIB to the expected installation location and creating a new custom executable file that points to the executable file at this location, debugging both DYLIB and executable files.

Thanks, Dan.

+3
source

Source: https://habr.com/ru/post/1335814/


All Articles