From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26613 invoked by alias); 8 Oct 2010 20:08:39 -0000 Received: (qmail 26603 invoked by uid 22791); 8 Oct 2010 20:08:38 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_PASS,TW_BJ,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (216.239.44.51) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 08 Oct 2010 20:08:34 +0000 Received: from wpaz33.hot.corp.google.com (wpaz33.hot.corp.google.com [172.24.198.97]) by smtp-out.google.com with ESMTP id o98K8Vfh011920 for ; Fri, 8 Oct 2010 13:08:31 -0700 Received: from vws17 (vws17.prod.google.com [10.241.21.145]) by wpaz33.hot.corp.google.com with ESMTP id o98K894u004436 for ; Fri, 8 Oct 2010 13:08:30 -0700 Received: by vws17 with SMTP id 17so582628vws.23 for ; Fri, 08 Oct 2010 13:08:30 -0700 (PDT) MIME-Version: 1.0 Received: by 10.220.187.12 with SMTP id cu12mr852668vcb.41.1286568507810; Fri, 08 Oct 2010 13:08:27 -0700 (PDT) Received: by 10.220.118.2 with HTTP; Fri, 8 Oct 2010 13:08:27 -0700 (PDT) In-Reply-To: <20101008191154.GA13058@host1.dyn.jankratochvil.net> References: <20101008191154.GA13058@host1.dyn.jankratochvil.net> Date: Fri, 08 Oct 2010 20:08:00 -0000 Message-ID: Subject: Re: [patch] python(+solib error): save/restore error state From: Doug Evans To: Jan Kratochvil Cc: gdb-patches@sourceware.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-System-Of-Record: true 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: 2010-10/txt/msg00155.txt.bz2 On Fri, Oct 8, 2010 at 12:11 PM, Jan Kratochvil wrote: > @@ -768,6 +782,13 @@ source_python_script_for_objfile (struct objfile *ob= jfile, > =A0 =A0 =A0clear the error indicator. =A0*/ > =A0 PyRun_SimpleFile (stream, file); > > + =A0if (PyErr_Occurred ()) > + =A0 =A0{ > + =A0 =A0 =A0gdbpy_print_stack (); > + =A0 =A0 =A0error (_("Error reading python script %s for object file %s"= ), file, > + =A0 =A0 =A0 =A0 =A0 =A0objfile->name); > + =A0 =A0} > + > =A0 do_cleanups (cleanups); > =A0 gdbpy_current_objfile =3D NULL; > =A0} Hi. Most of the patch seems great, but it raises a question that I think needs to be answered. The comment above this code says: /* Note: If an exception occurs python will print the traceback and clear the error indicator. */ ISTM that either this comment is wrong or the above patch is wrong, or some combination thereof. Also, if there is a problem here, then presumably source_python_script has the same problem, but I don't see it addressed in this patch. Plus if PyRun_SimpleFile can leave an outstanding error, we should research whether PyRun_SimpleString has the same problem. I see python.c checks the result of PyRun_SimpleString and calls gdbpy_print_stack if there's an error. Except that the python docs say there is no way to get the error. ref: http://docs.python.org/c-api/veryhigh.html?highlight=3Dpyrun_simplestr= ing#PyRun_SimpleString The docs for PyRun_SimpleFile suggest the same, there is no way to get the error. So, am I misreading the python docs or do we need the above patch? (and then if not, do we need the calls to gdbpy_print_stack after the calls to PyRun_SimpleString? Some experiments are in order - off to do some ...