From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30969 invoked by alias); 3 Dec 2013 07:30:02 -0000 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 Received: (qmail 30941 invoked by uid 89); 3 Dec 2013 07:30:01 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.8 required=5.0 tests=AWL,BAYES_05,RDNS_NONE,URIBL_BLOCKED autolearn=no version=3.3.2 X-HELO: relay1.mentorg.com Received: from Unknown (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 03 Dec 2013 07:30:00 +0000 Received: from svr-orw-fem-01.mgc.mentorg.com ([147.34.98.93]) by relay1.mentorg.com with esmtp id 1VnkQS-0006i9-Fg from Hui_Zhu@mentor.com ; Mon, 02 Dec 2013 23:29:44 -0800 Received: from SVR-ORW-FEM-02.mgc.mentorg.com ([147.34.96.206]) by svr-orw-fem-01.mgc.mentorg.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.4675); Mon, 2 Dec 2013 23:29:44 -0800 Received: from [127.0.0.1] (147.34.91.1) by svr-orw-fem-02.mgc.mentorg.com (147.34.96.168) with Microsoft SMTP Server id 14.2.247.3; Mon, 2 Dec 2013 23:29:43 -0800 Message-ID: <529D8865.80503@mentor.com> Date: Tue, 03 Dec 2013 07:30:00 -0000 From: Hui Zhu User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.1.1 MIME-Version: 1.0 To: Tom Tromey CC: gdb-patches ml Subject: Re: [PATCH] Make "backtrace" doesn't print python stack if init python dir get fail References: <52974146.70805@mentor.com> <8761r7w85h.fsf@fleche.redhat.com> In-Reply-To: <8761r7w85h.fsf@fleche.redhat.com> Content-Type: text/plain; charset="ISO-8859-1"; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2013-12/txt/msg00067.txt.bz2 On 12/03/13 00:05, Tom Tromey wrote: >>>>>> "Hui" == Hui Zhu writes: > > Hui> So if init python dir get fail, "backtrace" will print python > Hui> stack. But GDB already output error when it start. I make a patch > Hui> let it doesn't print python stack if init python dir get fail. > > Perhaps instead the setting of gdb_python_initialized should be moved to > finish_python_initialization. > > Tom > Hi Tom, I make a new patch according to your comments. It setup gdb_python_initialized in finish_python_initialization. I got a issue is ensure_python_env check gdb_python_initialized and throw error if it is 0. So gdb_python_initialized to 0 will make some commands throw error when python dir has something error. I removed this check in the patch. This patch pass the regression test in x86_64 linux. Please help me review it. Thanks, Hui 2013-12-03 Hui Zhu * python/python.c (ensure_python_env): Remove check for "gdb_python_initialized". (_initialize_python): Remove setup of "gdb_python_initialized". (finish_python_initialization): Add setup of "gdb_python_initialized". --- a/gdb/python/python.c +++ b/gdb/python/python.c @@ -150,10 +150,6 @@ ensure_python_env (struct gdbarch *gdbar { struct python_env *env = xmalloc (sizeof *env); - /* We should not ever enter Python unless initialized. */ - if (!gdb_python_initialized) - error (_("Python not initialized")); - env->state = PyGILState_Ensure (); env->gdbarch = python_gdbarch; env->language = python_language; @@ -1717,7 +1713,6 @@ message == an error message without a st make_final_cleanup (finalize_python, NULL); - gdb_python_initialized = 1; return; fail: @@ -1807,6 +1802,9 @@ finish_python_initialization (void) variable. */ do_cleanups (cleanup); + + gdb_python_initialized = 1; + return; fail: