About debugging in chimera

Dear Sir/Madam, I am trying to debug one of the existing plugins to help my understanding of how to write my extension. Usually, I would place "import pdb; pdb.set_trace()" in some lines of the program where I am interested and run it. And when the program encounters this line, it will stop, so I can go through line by line to follow the logic of this python program, which is really helpful. However, when I did this to one plugin of chimera, the plugin and chimera seems frozen, I mean, both didn't respond and there is no "(Pdb)" prompt in opening shell as normally did. I tried this in different places in different scripts, none worked. So I would like to ask how to enable this feature in Chimera or are there some other ways for debugging in Chimera? Sincerely, Shuangbo

Hi Shuangbo, Chimera redirects normal standout output and standard error to the Reply Log, so that normal print statements will go there. Therefore, the prompt of the pdb.set_trace() convenience function is probably showing up in the Log and not your shell. You need to use the actual Pdb class so that you can get the prompt to go to the original standard output rather than the redirected one. So namely: from pdb import Pdb import sys debugger = Pdb(stdin=sys.__stdin__, stdout=sys.__stdout__) debugger.set_trace() —Eric Eric Pettersen UCSF Computer Graphics Lab
On Jan 12, 2020, at 9:31 PM, 张双博 <2088zsp@gmail.com> wrote:
Dear Sir/Madam,
I am trying to debug one of the existing plugins to help my understanding of how to write my extension. Usually, I would place "import pdb; pdb.set_trace()" in some lines of the program where I am interested and run it. And when the program encounters this line, it will stop, so I can go through line by line to follow the logic of this python program, which is really helpful. However, when I did this to one plugin of chimera, the plugin and chimera seems frozen, I mean, both didn't respond and there is no "(Pdb)" prompt in opening shell as normally did. I tried this in different places in different scripts, none worked. So I would like to ask how to enable this feature in Chimera or are there some other ways for debugging in Chimera?
Sincerely,
Shuangbo _______________________________________________ Chimera-dev mailing list Chimera-dev@cgl.ucsf.edu http://plato.cgl.ucsf.edu/mailman/listinfo/chimera-dev

Hi Eric, It works for me, Thank you very much for your help! Yours sincerely, Shuangbo Eric Pettersen <pett@cgl.ucsf.edu> 于2020年1月14日周二 上午3:30写道:
Hi Shuangbo, Chimera redirects normal standout output and standard error to the Reply Log, so that normal print statements will go there. Therefore, the prompt of the pdb.set_trace() convenience function is probably showing up in the Log and not your shell. You need to use the actual Pdb class so that you can get the prompt to go to the original standard output rather than the redirected one. So namely:
from pdb import Pdb import sys debugger = Pdb(stdin=sys.__stdin__, stdout=sys.__stdout__) debugger.set_trace()
—Eric
Eric Pettersen UCSF Computer Graphics Lab
On Jan 12, 2020, at 9:31 PM, 张双博 <2088zsp@gmail.com> wrote:
Dear Sir/Madam,
I am trying to debug one of the existing plugins to help my understanding of how to write my extension. Usually, I would place "import pdb; pdb.set_trace()" in some lines of the program where I am interested and run it. And when the program encounters this line, it will stop, so I can go through line by line to follow the logic of this python program, which is really helpful. However, when I did this to one plugin of chimera, the plugin and chimera seems frozen, I mean, both didn't respond and there is no "(Pdb)" prompt in opening shell as normally did. I tried this in different places in different scripts, none worked. So I would like to ask how to enable this feature in Chimera or are there some other ways for debugging in Chimera?
Sincerely,
Shuangbo _______________________________________________ Chimera-dev mailing list Chimera-dev@cgl.ucsf.edu http://plato.cgl.ucsf.edu/mailman/listinfo/chimera-dev
participants (2)
-
Eric Pettersen
-
张双博