From patchwork Thu Nov 19 20:21:51 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kratochvil X-Patchwork-Id: 546674 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 83212141434 for ; Fri, 20 Nov 2015 07:22:24 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=QgTAonkC; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; q=dns; s= default; b=p2Azjad6KlLh9TdsdbhUfh0CgXE7Xi4YKv8/31YkSs2IhuSFsAfpr URYVVYDr+Ztk4xkMe2mFdZYjMUHrAIYFvrDD7QNyFVrHJzLc6Y1NYxu2uDeHqCbw rqoJQeOOBG0RYY/Uc/Lrd6t17YEjwuj5THDFlIf4E/zImtS+rhTLyU= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; s= default; bh=vq9u0zLHsWL0iOnbUzL+TNTTEdk=; b=QgTAonkCCtQw7m9DBTh5 YsGkY2T/1QbqdA13UgWS+m8K1HTehoavFHtVVKYYSttAhU3KtJCceh2MzKA0gGwy r0hayjhNRGNUTshSJCUU8BHoGxoTyAWHJHoMZshVutWThk1M5fv9pyhjpaPM5KDu OSp3xcGuTsyBFVssl671/l4= Received: (qmail 82447 invoked by alias); 19 Nov 2015 20:22:00 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 82325 invoked by uid 89); 19 Nov 2015 20:21:59 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.0 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Thu, 19 Nov 2015 20:21:56 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id CE1A3C0A8470 for ; Thu, 19 Nov 2015 20:21:54 +0000 (UTC) Received: from host1.jankratochvil.net (ovpn-116-88.ams2.redhat.com [10.36.116.88]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id tAJKLpRR026755 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Thu, 19 Nov 2015 15:21:54 -0500 Date: Thu, 19 Nov 2015 21:21:51 +0100 From: Jan Kratochvil To: gcc-patches@gcc.gnu.org Subject: [patch] Python Pretty Printers get disabled on libstdc++ reload by GDB (PR libstdc++/68448) Message-ID: <20151119202151.GA7640@host1.jankratochvil.net> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2015-06-09) X-IsSubscribed: yes Hi, https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68448 https://bugzilla.redhat.com/show_bug.cgi?id=1279406 echo -e '#include \nint main(){std::vector l;\nreturn 0;}'|g++ -g -Wall -x c++ -;gdb -q ./a.out -batch -ex 'b 3' -ex r -ex 'p l' -ex r -ex 'p l' Actual: [...] $1 = std::vector of length 0, capacity 0 [...] $2 = { >> = {_M_impl = {> = {<__gnu_cxx::new_allocator> = {}, }, _M_start = 0x0, _M_finish = 0x0, _M_end_of_storage = 0x0}}, } Expected: [...] $1 = std::vector of length 0, capacity 0 [...] $2 = std::vector of length 0, capacity 0 Thanks, Jan * python/hook.in: Call register_libstdcxx_printers. * python/libstdcxx/v6/__init__.py: Wrap it to register_libstdcxx_printers. diff --git a/libstdc++-v3/python/hook.in b/libstdc++-v3/python/hook.in index 07fe4c6..703b6a7 100644 --- a/libstdc++-v3/python/hook.in +++ b/libstdc++-v3/python/hook.in @@ -55,4 +55,7 @@ if gdb.current_objfile () is not None: if not dir_ in sys.path: sys.path.insert(0, dir_) -import libstdcxx.v6 +# Call a function as a plain import would not execute body of the included file +# on repeated reloads of this object file. +from libstdcxx.v6 import register_libstdcxx_printers +register_libstdcxx_printers(gdb.current_objfile()) diff --git a/libstdc++-v3/python/libstdcxx/v6/__init__.py b/libstdc++-v3/python/libstdcxx/v6/__init__.py index de3aa72..d8e060c 100644 --- a/libstdc++-v3/python/libstdcxx/v6/__init__.py +++ b/libstdc++-v3/python/libstdcxx/v6/__init__.py @@ -15,10 +15,6 @@ import gdb -# Load the pretty-printers. -from .printers import register_libstdcxx_printers -register_libstdcxx_printers(gdb.current_objfile()) - # Load the xmethods if GDB supports them. def gdb_has_xmethods(): try: @@ -27,6 +23,11 @@ def gdb_has_xmethods(): except ImportError: return False -if gdb_has_xmethods(): - from .xmethods import register_libstdcxx_xmethods - register_libstdcxx_xmethods(gdb.current_objfile()) +def register_libstdcxx_printers(obj): + # Load the pretty-printers. + from .printers import register_libstdcxx_printers + register_libstdcxx_printers(obj) + + if gdb_has_xmethods(): + from .xmethods import register_libstdcxx_xmethods + register_libstdcxx_xmethods(obj)