From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24703 invoked by alias); 10 Sep 2012 15:05:03 -0000 Received: (qmail 24669 invoked by uid 22791); 10 Sep 2012 15:05:02 -0000 X-SWARE-Spam-Status: No, hits=-6.7 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,RCVD_IN_DNSWL_HI,RCVD_IN_HOSTKARMA_W,RP_MATCHES_RCVD,SPF_HELO_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 10 Sep 2012 15:04:44 +0000 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q8AF4h71028863 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 10 Sep 2012 11:04:43 -0400 Received: from barimba (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q8AF4fCh017184 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Mon, 10 Sep 2012 11:04:42 -0400 From: Tom Tromey To: Dov Grobgeld Cc: gdb@sourceware.org Subject: Re: Python debugging in gdb References: Date: Mon, 10 Sep 2012 15:05:00 -0000 In-Reply-To: (Dov Grobgeld's message of "Mon, 10 Sep 2012 12:50:09 +0300") Message-ID: <87mx0xex6e.fsf@fleche.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2012-09/txt/msg00019.txt.bz2 >>>>> "Dov" == Dov Grobgeld writes: Dov> To do this, I would like to define the following gdb commands: Dov> py-break : Create a break point at line in a python file. Dov> py-step: Step the next python statement. Dov> py-next : Run the next python statement. Dov> py-finish: Finish the current python function. Dov> (It would make sense to create a dispatcher that does `py-break` on a Dov> python file and `break` on a C++ file so you can always use the same Dov> command to create break points.) Eventually I'd like to be able to extend the plain gdb commands like "break" this way. Dov> Is this feasible? Can someone give me some ideas and pointers of how Dov> to go about implementing this? It is definitely feasible. There may still be some ugly parts; if so please file bug reports, since this is something we would like to work nicely. I don't know exactly how you would implement each command -- a lot depends on the details of the Python interpreter. In general though I think each of the above commands would be written in Python and would use gdb's Python Breakpoint API to set low-level breakpoints at the appropriate points in the Python interpreter. I think much of the logic would be in the breakpoint's 'stop' method. For example, for py-next you would want to stop at a specific source line, but only in the current frame, so the stop method would have to compare frames. Tom