ADC Home > Reference Library > Technical Q&As > Tools > Compiling & Debugging >
|
Q: I cannot use GDB to debug my application because it interferes with the code that I'm trying to debug, what can I do? A: You may experience this situation if you try to debug, for example, a drag and drop operation between two applications, a complex activate / deactivate / update case, or an application which grabs the entire screen (this is not an exhaustive list). In those situations, the window displaying GDB (whether in Project Builder or in Terminal) will interfere with the code that you want to debug. A very good solution to that problem is to do two-machine debugging, aka remote debugging: you just need another Macintosh and have both machines connected to the same network.
1) On the target Macintosh, which contains the application or applications to debug, you enable "Remote Login" by using the "Sharing" pane of the System Preferences. When you turn that service on, a message will appear giving you the command line information you need in order to connect (ie. type "ssh yourname@yournetwork.com")
2) On the Macintosh in control, you launch the Terminal application and open as many windows as there are applications to debug (two in the drag and drop scenario, one in the others). 3) In each window, you first ssh to the target Macintosh by typing the command line information you got in the Sharing pane (you will be asked the password associated with that user), and then, you launch GDB (the GDB tool launched is the one on the target machine) and either run the application or attach to its pid (please, read the GDB manual for more details). You can also use the symbols files of the application[s] you need to debug (again read the GDB manual for more details).
4) After you're done debugging, don't forget to quit GDB, quit Terminal, and, if you no longer have a need for it, disable the Remote Login service on the target Macintosh. [Sep 09, 2003] |
|