From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6563 invoked by alias); 1 Jul 2011 04:00:43 -0000 Received: (qmail 6551 invoked by uid 22791); 1 Jul 2011 04:00:41 -0000 X-SWARE-Spam-Status: No, hits=-2.5 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW,TW_RG X-Spam-Check-By: sourceware.org Received: from mail-iy0-f169.google.com (HELO mail-iy0-f169.google.com) (209.85.210.169) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 01 Jul 2011 04:00:28 +0000 Received: by iyl8 with SMTP id 8so3237153iyl.0 for ; Thu, 30 Jun 2011 21:00:27 -0700 (PDT) MIME-Version: 1.0 Received: by 10.231.124.167 with SMTP id u39mr2360078ibr.103.1309492827377; Thu, 30 Jun 2011 21:00:27 -0700 (PDT) Received: by 10.231.36.8 with HTTP; Thu, 30 Jun 2011 21:00:27 -0700 (PDT) Date: Fri, 01 Jul 2011 04:00:00 -0000 Message-ID: Subject: [PATCH] sys.argv and ipython (interactive python) support in GDB/Python From: Taisuke Yamada To: gdb-patches@sourceware.org Content-Type: multipart/mixed; boundary=0016e6471632cfd1de04a6fa0ebf 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: 2011-07/txt/msg00003.txt.bz2 --0016e6471632cfd1de04a6fa0ebf Content-Type: text/plain; charset=ISO-8859-1 Content-length: 793 Hi. While working with GDB/Python, I wondered if I can use it interactively by loading ipython (interactive python shell) on top of it. However, current GDB/Python fails as it does not initialize sys.argv properly. So here is a patch to set sys.argv when initializing embedded Python interpreter. I have tested it by running ipython with (gdb) python execfile("/usr/bin/ipython") Python 2.6.6 (r266:84292, Oct 9 2010, 12:40:51) ... In [1]: import gdb In [2]: print gdb.lookup_symbol("main") (, False) It is quite nice to be able to inspect debuggee interactively using full-featured language. This patch should also improve compatibility with other exsiting python libraries, as some of those expect existance of sys.argv. Best Regards, --0016e6471632cfd1de04a6fa0ebf Content-Type: text/x-patch; charset=US-ASCII; name="gdb-python-ipython.patch" Content-Disposition: attachment; filename="gdb-python-ipython.patch" Content-Transfer-Encoding: base64 X-Attachment-Id: f_gpklziyq0 Content-length: 590 ZGlmZiAtLWdpdCBhL2dkYi9weXRob24vcHl0aG9uLmMgYi9nZGIvcHl0aG9u L3B5dGhvbi5jCmluZGV4IDkwZDVkYzguLmM5ZjJjZTkgMTAwNjQ0Ci0tLSBh L2dkYi9weXRob24vcHl0aG9uLmMKKysrIGIvZ2RiL3B5dGhvbi9weXRob24u YwpAQCAtMTAxMCw3ICsxMDEwLDkgQEAgRW5hYmxlcyBvciBkaXNhYmxlcyBw cmludGluZyBvZiBQeXRob24gc3RhY2sgdHJhY2VzLiIpLAogCQkJICAgICBT TEFTSF9TVFJJTkcsICJweXRob24iLCBOVUxMKSk7CiAjZW5kaWYKIAorICBj aGFyICphcmd2W10gPSB7ICJnZGIiLCBOVUxMIH07CiAgIFB5X0luaXRpYWxp emUgKCk7CisgIFB5U3lzX1NldEFyZ3ZFeCAoMSwgYXJndiwgMCk7CiAgIFB5 RXZhbF9Jbml0VGhyZWFkcyAoKTsKIAogICBnZGJfbW9kdWxlID0gUHlfSW5p dE1vZHVsZSAoImdkYiIsIEdkYk1ldGhvZHMpOwo= --0016e6471632cfd1de04a6fa0ebf--