From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22734 invoked by alias); 28 Nov 2013 13:12:58 -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 22722 invoked by uid 89); 28 Nov 2013 13:12:57 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.9 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; Thu, 28 Nov 2013 13:12:56 +0000 Received: from svr-orw-exc-10.mgc.mentorg.com ([147.34.98.58]) by relay1.mentorg.com with esmtp id 1Vm1Oa-00009G-Mi from Hui_Zhu@mentor.com for gdb-patches@sourceware.org; Thu, 28 Nov 2013 05:12:40 -0800 Received: from SVR-ORW-FEM-05.mgc.mentorg.com ([147.34.97.43]) by SVR-ORW-EXC-10.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.4675); Thu, 28 Nov 2013 05:12:40 -0800 Received: from [127.0.0.1] (147.34.91.1) by svr-orw-fem-05.mgc.mentorg.com (147.34.97.43) with Microsoft SMTP Server id 14.2.247.3; Thu, 28 Nov 2013 05:11:51 -0800 Message-ID: <52974146.70805@mentor.com> Date: Thu, 28 Nov 2013 17:35: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: gdb-patches ml Subject: [PATCH] Make "backtrace" doesn't print python stack if init python dir get fail Content-Type: text/plain; charset="ISO-8859-1"; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2013-11/txt/msg00883.txt.bz2 If the python lib dir of GDB has something wrong, each time "backtrace" will output a python error, for example: Python Exception No module named gdb: warning: Could not load the Python gdb module from `/usr/local/share/gdb/python'. Limited Python support is available from the _gdb module. Suggest passing --data-directory=/path/to/gdb/data-directory. (gdb) start Temporary breakpoint 1 at 0x400507: file 1.c, line 4. Starting program: /home/teawater/tmp/1 Temporary breakpoint 1, main (argc=1, argv=0x7fffffffe118, envp=0x7fffffffe128) at 1.c:4 4 int a = 1; (gdb) bt Python Exception No module named gdb.frames: #0 main (argc=1, argv=0x7fffffffe118, envp=0x7fffffffe128) at 1.c:4 This python stack is output by function apply_frame_filter because bootstrap_python_frame_filters got NULL. The core reason is init python dir get fail. And if GDB doesn't init python lib in right, python script cannot use any frame filter because "import gdb" will get fail. So if init python dir get fail, "backtrace" will print python stack. But GDB already output error when it start. I make a patch let it doesn't print python stack if init python dir get fail. Please help me review it. Thanks, Hui 2013-11-28 Hui Zhu * python/py-framefilter.c(apply_frame_filter): Add check for "gdb_python_module". --- a/gdb/python/py-framefilter.c +++ b/gdb/python/py-framefilter.c @@ -1506,7 +1506,10 @@ apply_frame_filter (struct frame_info *f initialization error. This return code will trigger a default backtrace. */ - gdbpy_print_stack (); + if (gdb_python_module != NULL) + gdbpy_print_stack (); + else + PyErr_Clear (); do_cleanups (cleanups); return PY_BT_NO_FILTERS; }