[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Making a Breakpoint happen during a run via keyboard



Hi,

since your post is spectacularly scarce on details I'm not exactly sure what your environment is but I usually do something like so if I need interactive debugging:

---------- pseudo code ----------------
main loop:
    if key == K_whatever:
        import pdb
        pdb.set_trace() # <- brakes here and gives pdb console

----------------

HTH
Ulrich

Am 22.02.2009 um 23:28 schrieb Lin Parkh:

I know this question is vaguely structured but would love insight if anyone can manage it. I am trying to give myself an interactive debugger during
the running of my game. That is, while game is in execution I hit a
keystroke which leads to a breakpoint being reached and execution stops but program does not terminate. Then I ask the console various questions about
game state etc. I used to have this running! But somehow I have done
something to my environment such that while when I hit the keystroke the excution of code goes to the breakpoint line but fails to stop :- ( This is of course while I am running in debug mode (using F11). Breakpoints in
other places in code continue to run. I have of course tried doing new
breakpoints, getting rid of old etc.
  Two questions:
1) fixing -- any idea what I could have done that would make pygame/ pydev ignore the breakpoint but not ignore breakpoints prior to the program going into active event management 'running' mode? I'm thinking somehow maybe the event queue or some otherquality of pygame forces execution to continue past
breakpoint. But this didn't used to be an issue...
2) alternative -- is there a more clever way to go into a debug mode while a game is active? say maybe have a pseudo console that responds to queries
(like asking properties of a class instance while execution ongoing or
halted). Or maybe a way to make program suspend on command in the code besides a breakpoint? Is there perhaps a breakpoint piece of code I could insert directly into the code? Instead of the due-hickky on the side tab in
eclipse/pydev?

I would really appreciate help here as my debuggin efficiency has suffered
dramatically since I lost this interrupt and query ability.
  Thanks,
  Lin