From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12614 invoked by alias); 11 Jan 2012 19:04:20 -0000 Received: (qmail 12599 invoked by uid 22791); 11 Jan 2012 19:04:18 -0000 X-SWARE-Spam-Status: No, hits=-2.1 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW X-Spam-Check-By: sourceware.org Received: from mail-vw0-f41.google.com (HELO mail-vw0-f41.google.com) (209.85.212.41) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 11 Jan 2012 19:04:04 +0000 Received: by vbbfn1 with SMTP id fn1so896033vbb.0 for ; Wed, 11 Jan 2012 11:04:03 -0800 (PST) Received: by 10.52.18.144 with SMTP id w16mr251544vdd.94.1326308643174; Wed, 11 Jan 2012 11:04:03 -0800 (PST) MIME-Version: 1.0 Received: by 10.220.3.130 with HTTP; Wed, 11 Jan 2012 11:03:42 -0800 (PST) In-Reply-To: <48619020-0550-4888-9F05-158DB065252B@cs.umd.edu> References: <94906C8E-C23D-4DA3-989D-DDCCFA20FC35@cs.umd.edu> <48619020-0550-4888-9F05-158DB065252B@cs.umd.edu> From: Kevin Pouget Date: Wed, 11 Jan 2012 19:11:00 -0000 Message-ID: Subject: Re: Make the "python" command resemble the standard Python interpreter To: Khoo Yit Phang Cc: gdb-patches@sourceware.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2012-01/txt/msg00362.txt.bz2 On Wed, Jan 11, 2012 at 7:48 PM, Khoo Yit Phang 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 wrot= e: >> >>>>> + =A0 =A0 =A0p =3D command_line_input (prompt, 0, "python"); >>>>> + =A0 =A0 =A0do_cleanups (cleanup); >>>>> + =A0 =A0} >>>> >>>> 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 ha= ndle 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 >>> { >>> =A0do_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 resto= re 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 t= hat line editing > and history editing works. Additionally, Python's standa= rd 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