Thread: [Pyobjc-dev] pdb in PyObjC apps?
Brought to you by:
ronaldoussoren
From: Zachery B. <zb...@ur...> - 2003-08-18 20:50:49
|
Anyone found a way to integrate the python debugger (pdb) with a PyObjC application? I made the mistake of trying it, and it clogged up my Console.app and I had to use Force Quit to stop my app. Should we be using the Project Builder's debugger? Will that work? Thanks, Zac |
From: Bob I. <bo...@re...> - 2003-08-18 21:57:10
|
On Monday, Aug 18, 2003, at 16:49 America/New_York, Zachery Bir wrote: > Anyone found a way to integrate the python debugger (pdb) with a > PyObjC application? I made the mistake of trying it, and it clogged up > my Console.app and I had to use Force Quit to stop my app. You can probably use it pretty much the same way you would normally use pdb. There's probably a couple snags (NSApplicationMain will probably kill the interpreter when the runloop stops, AppHelper.runEventLoop will probably try and catch all your exceptions, etc.), but you didn't really give enough information about your problem. You should be more concise about exactly what you did, especially how it was executed (WindowServer is picky about these things). You should also include some sample code (preferably stripped down to just enough to show the problem), and define what "clogged up my Console.app" means. > Should we be using the Project Builder's debugger? Will that work? Not unless you're debugging Python itself, or an extension written in C, C++, Objective C :) Project Builder's debugger is just a gdb frontend. -bob |
From: Zachery B. <zb...@ur...> - 2003-08-18 22:19:16
|
On Monday, August 18, 2003, at 05:56 PM, Bob Ippolito wrote: > On Monday, Aug 18, 2003, at 16:49 America/New_York, Zachery Bir wrote: > >> Anyone found a way to integrate the python debugger (pdb) with a >> PyObjC application? I made the mistake of trying it, and it clogged >> up my Console.app and I had to use Force Quit to stop my app. > > You can probably use it pretty much the same way you would normally > use pdb. There's probably a couple snags (NSApplicationMain will > probably kill the interpreter when the runloop stops, > AppHelper.runEventLoop will probably try and catch all your > exceptions, etc.), but you didn't really give enough information about > your problem. You should be more concise about exactly what you did, > especially how it was executed (WindowServer is picky about these > things). You should also include some sample code (preferably > stripped down to just enough to show the problem), and define what > "clogged up my Console.app" means. Sorry, something along the lines of: class MyAppDelegate(NibClassBuilder.AutoBaseClass): def init(self): import pdb;pdb.set_trace() self.foo = do_something() So that I can track the creation of my application's main object and see where this disconnect that I'm experiencing is coming from. When I tried that before and ran the built application by double-clicking on it, Console.app was filled with: (Pdb) (Pdb) (Pdb) (Pdb) (Pdb) (Pdb) (Pdb) (Pdb) (Pdb) (Pdb) (Pdb) (Pdb) (Pdb) (Pdb) (Pdb) (Pdb) (Pdb) (Pdb) (Pdb) (Pdb) (Pdb) (Pdb) (Pdb) (Pdb) (Pdb) (Pdb) (Pdb) (Pdb) (Pdb) (Pdb) (Pdb) ... ad nauseum when that line was hit. There was no terminal I could attach to to take charge of the pdb session. Perhaps I need to run the application differently? (trying that) AHA! Running: $ ~/Developer/ZopeEditManager/build/ZopeEditManager.app/Contents/MacOS/ ZopeEditManager with the import pdb;pdb.set_trace() in my app's init() method brings me to a pdb prompt :) Note to self: Don't use pdb and try to catch it through double-clicking the app :) >> Should we be using the Project Builder's debugger? Will that work? > > Not unless you're debugging Python itself, or an extension written in > C, C++, Objective C :) Project Builder's debugger is just a gdb > frontend. Good to know, thanks. Zac |
From: Michael H. <mw...@py...> - 2003-08-19 09:45:51
|
Zachery Bir <zb...@ur...> writes: > Note to self: Don't use pdb and try to catch it through > double-clicking the app :) :-) It shouldn't be *too* outrageously hard to teach my pyrepl interactive tool how to cooperate with the Cocoa run loop (you need a way to give an fd to Cocoa and say "give me control when there's something to read on this" and I'm sure I saw one of them somewhere) in which case you could have an interactive session running alongside your application... Hmm, where's that can of tuits? Cheers, mwh -- same software, different verbosity settings (this one goes to eleven) -- the effbot on the martellibot |
From: Bob I. <bo...@re...> - 2003-08-19 16:32:23
|
On Tuesday, Aug 19, 2003, at 05:45 America/New_York, Michael Hudson wrote: > Zachery Bir <zb...@ur...> writes: > >> Note to self: Don't use pdb and try to catch it through >> double-clicking the app :) > > :-) > > It shouldn't be *too* outrageously hard to teach my pyrepl interactive > tool how to cooperate with the Cocoa run loop (you need a way to give > an fd to Cocoa and say "give me control when there's something to read > on this" and I'm sure I saw one of them somewhere) in which case you > could have an interactive session running alongside your > application... Hmm, where's that can of tuits? I've developed a CoreFoundation reactor for Twisted that would facilitate this sort of thing. It's not mainline yet because I haven't had time to fully test and write enough examples -- it does work, but I'm not currently comfortable putting it in the rest of Twisted yet (especially due to the Pyrex build dependency). Here's what you would do (this obviously needs Developer Tools installed): Download Pyrex 0.8.2 Modify Pyrex/Compiler/Nodes.py .. change the block starting on line 160 to this (small fix to allow system includes): for filename in env.include_files: if not (filename.startswith('<') and filename.endswith('>')): filename = '"%s"' % filename code.putln('#include %s' % filename) Install Pyrex Checkout CVS HEAD of Twisted Build and install Twisted (or put twisted into your PYTHONPATH, I have a symlink of ~/src/Twisted/twisted at ~/Library/Python/2.3/site-packages/twisted) Go into Twisted/sandbox/etrepum/cfsupport python setup.py build_ext -i cd TWISTEDPACKAGE/internet ln -s TWISTEDCVS/sandbox/etrepum/cfreactor.py . ln -s TWISTEDCVS/sandbox/etrepum/cfsupport/cfsupport.so . That should work, to test it check out the examples in TWISTEDCVS/sandbox/etrepum/examples/PyObjC (which obviously require PyObjC, you can get that from PackageManager) Also note that the cfsupport module is enough to just get notifications on the fd, but I recommend using Twisted for anything that talks sockets anyway. -bob |
From: Ronald O. <ous...@ci...> - 2003-08-20 09:49:24
|
On Tuesday, 19 August, 2003, at 16:06, Bob Ippolito wrote: > On Tuesday, Aug 19, 2003, at 05:45 America/New_York, Michael Hudson > wrote: > >> Zachery Bir <zb...@ur...> writes: >> >>> Note to self: Don't use pdb and try to catch it through >>> double-clicking the app :) >> >> :-) >> >> It shouldn't be *too* outrageously hard to teach my pyrepl interactive >> tool how to cooperate with the Cocoa run loop (you need a way to give >> an fd to Cocoa and say "give me control when there's something to read >> on this" and I'm sure I saw one of them somewhere) in which case you >> could have an interactive session running alongside your >> application... Hmm, where's that can of tuits? > > I've developed a CoreFoundation reactor for Twisted that would > facilitate this sort of thing. It's not mainline yet because I > haven't had time to fully test and write enough examples -- it does > work, but I'm not currently comfortable putting it in the rest of > Twisted yet (especially due to the Pyrex build dependency). > > Here's what you would do (this obviously needs Developer Tools > installed): > > Download Pyrex 0.8.2 > > Modify Pyrex/Compiler/Nodes.py .. change the block starting on line > 160 to this (small fix to allow system includes): > for filename in env.include_files: > if not (filename.startswith('<') and filename.endswith('>')): > filename = '"%s"' % filename > code.putln('#include %s' % filename) > > Install Pyrex > > Checkout CVS HEAD of Twisted > > Build and install Twisted (or put twisted into your PYTHONPATH, I have > a symlink of ~/src/Twisted/twisted at > ~/Library/Python/2.3/site-packages/twisted) > > Go into Twisted/sandbox/etrepum/cfsupport > > python setup.py build_ext -i > > cd TWISTEDPACKAGE/internet > ln -s TWISTEDCVS/sandbox/etrepum/cfreactor.py . > ln -s TWISTEDCVS/sandbox/etrepum/cfsupport/cfsupport.so . > > That should work, to test it check out the examples in > TWISTEDCVS/sandbox/etrepum/examples/PyObjC (which obviously require > PyObjC, you can get that from PackageManager) > > Also note that the cfsupport module is enough to just get > notifications on the fd, but I recommend using Twisted for anything > that talks sockets anyway. Why didn't you use PyObjC? Is there functionality in CoreFoundation that is not in Cocoa or are there other reasons? Ronald |
From: Bob I. <bo...@re...> - 2003-08-21 17:17:26
|
On Wednesday, Aug 20, 2003, at 02:25 America/New_York, Ronald Oussoren wrote: > Why didn't you use PyObjC? Is there functionality in CoreFoundation > that is not in Cocoa or are there other reasons? CFSocket notifications, (theoretical) Carbon runloop support, etc. I wrote it in Pyrex after a huge waste of time trying to get it to work reliably in ctypes (callbacks would eventually start jumping to random locations in memory under load, core dump on uncaught exceptions, etc... I think it could be a libffi issue), and I didn't want to go through the same ordeal with PyObjC's callbacks after my last failed attempt to do Rendezvous callbacks with it. The Pyrex module was not hard to write, and my wrapper does take a CFRunLoopRef from a PyObjC NSRunLoop if you're trying to integrate it with Cocoa or whatever. -bob |