This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Make the "python" command resemble the standard Python interpreter


On Wed, Jan 11, 2012 at 7:48 PM, Khoo Yit Phang <khooyp@cs.umd.edu> wrote:
> Hi,
>
> On Jan 11, 2012, at 1:31 PM, Kevin Pouget wrote:
>
>> On Wed, Jan 11, 2012 at 4:53 PM, Khoo Yit Phang <khooyp@cs.umd.edu> wrote:
>>
>>>>> + ? ? ?p = command_line_input (prompt, 0, "python");
>>>>> + ? ? ?do_cleanups (cleanup);
>>>>> + ? ?}
>>>>
>>>> I'm not sure about that, but isn't the clean up supposed to be
>>>> executed even if an exception is thrown? it seems not to be the case
>>>> here
>>>
>>> Are you referring to do_cleanups? If I understand correctly, it's to handle the case where an exception is not thrown (see, e.g., py-value.c).
>>
>> I think that's you're supposed to use the cleanup machinery when you
>> don't explicitely handle the exception. Here you code looks like:
>>
>>> TRY_CATCH
>>> {
>>> ?do_something_dangerous()
>>> }
>>> handle_exception_if_any()
>>> continue_anyway()
>>
>> so I think it's safe to simply call "gdbpy_suspend_sigint_handler"
>> after the exception handling.
>
> I don't think that's right. I traced this, and the cleanup function isn't called if I don't use do_cleanup. In this case, it must be called to restore the SIGINT handler to Python. In many other places I've looked that use TRY_CATCH, do_cleanup is called at the end too.


okay, so I'll have to study it a bit more! A maintainer review will
confirm if you're doing it correctly


> It also hooks GDB's readline wrappers (command_line_input) to Python so that line editing > and history editing works. Additionally, Python's standard readline module is stubbed out
> because it conflicts with GDB's use of readline.

that's interesting! I noticed that there's conflict between Python and
GDB readline; do you thing that this hook could also be used to fix
PDB's commandline prompt? (when you run "python import
pdb;pdb.set_trace()", history and left/right arrow don't work
properly)


Cordially,

Kevin


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]