From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29800 invoked by alias); 8 Oct 2010 20:20:23 -0000 Received: (qmail 29791 invoked by uid 22791); 8 Oct 2010 20:20:21 -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) (74.125.121.35) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 08 Oct 2010 20:20:16 +0000 Received: from kpbe18.cbf.corp.google.com (kpbe18.cbf.corp.google.com [172.25.105.82]) by smtp-out.google.com with ESMTP id o98KKD8f012548 for ; Fri, 8 Oct 2010 13:20:13 -0700 Received: from qyk31 (qyk31.prod.google.com [10.241.83.159]) by kpbe18.cbf.corp.google.com with ESMTP id o98KJCq7011629 for ; Fri, 8 Oct 2010 13:20:12 -0700 Received: by qyk31 with SMTP id 31so489098qyk.14 for ; Fri, 08 Oct 2010 13:20:12 -0700 (PDT) MIME-Version: 1.0 Received: by 10.224.126.5 with SMTP id a5mr1938097qas.290.1286569211704; Fri, 08 Oct 2010 13:20:11 -0700 (PDT) Received: by 10.220.118.2 with HTTP; Fri, 8 Oct 2010 13:20:11 -0700 (PDT) In-Reply-To: References: <20101008191154.GA13058@host1.dyn.jankratochvil.net> Date: Fri, 08 Oct 2010 20:20: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/msg00156.txt.bz2 On Fri, Oct 8, 2010 at 1:08 PM, Doug Evans wrote: > On Fri, Oct 8, 2010 at 12:11 PM, Jan Kratochvil > wrote: >> @@ -768,6 +782,13 @@ source_python_script_for_objfile (struct objfile *o= bjfile, >> =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. =A0Most of the patch seems great, but it raises a question that I > think needs to be answered. > > The comment above this code says: > > =A0/* Note: If an exception occurs python will print the traceback and > =A0 =A0 clear the error indicator. =A0*/ > > 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. =A0I see > python.c checks the result of PyRun_SimpleString and calls > gdbpy_print_stack if there's an error. =A0Except that the python docs > say there is no way to get the error. > > ref: http://docs.python.org/c-api/veryhigh.html?highlight=3Dpyrun_simples= tring#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 ... > Better yet, "use the source Luke ..." 1/2 :-). Looking at the sources for PyRun_SimpleFile, I see PyErr_Print being called before -1 is returned. Similarly for PyRun_SimpleString. Am I missing something?