From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19718 invoked by alias); 10 May 2012 21:16:08 -0000 Received: (qmail 19707 invoked by uid 22791); 10 May 2012 21:16:06 -0000 X-SWARE-Spam-Status: No, hits=-5.5 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,KHOP_RCVD_TRUST,KHOP_THREADED,RCVD_IN_DNSWL_LOW,RCVD_IN_HOSTKARMA_YE,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail-vb0-f41.google.com (HELO mail-vb0-f41.google.com) (209.85.212.41) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 10 May 2012 21:15:53 +0000 Received: by vbbey12 with SMTP id ey12so2560055vbb.0 for ; Thu, 10 May 2012 14:15:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding:x-system-of-record :x-gm-message-state; bh=UJH8dX2ZU+aXp/xPUoGwPyKo5/ihQ0DbLlgU2RXM7h8=; b=kJSwll0PHct5gw4FWnbLodxnrSkixnNfdesb5Biua2HlW7hdUpux9NdLYqpyoB6Sh8 9UImVDA6wIVAcOkGkLSWhJt9TPPzHLYvYN/fRCvhqaqTdcGFWI6bP7SNah4fpMRY37Zp faU9uL/iy0uK0gav5i3kZnOAX44+AJIpL4cFRyOzGNkm+avcd3bfXIhrT4qSR8p3Gwe9 KRKTUnHh28B8FxVLMAJcsjnnKcw9E1fry6opsX6sBrbzbdJEvK6j4jb/jeffoDpsZCp4 HMkQSEb+WkssBzEnVf0u2uBAVUxT/0oPSADmZSAj2NrQMVlVAIajQp+qtb8mrp92tz4h o3ag== Received: by 10.220.185.136 with SMTP id co8mr1185371vcb.5.1336684552472; Thu, 10 May 2012 14:15:52 -0700 (PDT) MIME-Version: 1.0 Received: by 10.220.185.136 with SMTP id co8mr1185362vcb.5.1336684552354; Thu, 10 May 2012 14:15:52 -0700 (PDT) Received: by 10.52.25.12 with HTTP; Thu, 10 May 2012 14:15:52 -0700 (PDT) In-Reply-To: References: <8362c73huz.fsf@gnu.org> Date: Thu, 10 May 2012 21:16:00 -0000 Message-ID: Subject: Re: [RFC] - Exposing find_pc_line through Python API From: Doug Evans To: Siva Chandra Cc: Eli Zaretskii , gdb-patches@sourceware.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-System-Of-Record: true X-Gm-Message-State: ALoCoQl6lk8o7IjW2P8XoANn/pV45el4CSMhP/ylJI9GsVcsUadmf80sJaKve7eLth8iTfcxlA7/JOBRMIJYCM8e/FycPSm26g0jGc4x1W+2ZAkzeVGdke9pKLI4Y6M+wx3EpMI6InKIPVhxggkQGBf4R9nJN+DTOA== 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: 2012-05/txt/msg00392.txt.bz2 On Wed, May 9, 2012 at 12:35 AM, Siva Chandra wrot= e: > The more I think about your comments, the more I feel that exposing > this 'actual' argument is not a good idea. =A0I am now of the opinion > that the 'notcurrent' argument to the internal function find_pc_line > caters to a internal usage which depends on much more than just what > the user feels. =A0Hence, I have modified the patch to remove the > 'actual' argument. =A0The new version of the patch is attached. > > 2012-05-07 =A0Siva Chandra Reddy =A0 > > =A0 =A0 =A0 =A0Add a new function gdb.find_pc_line to the Python API. > =A0 =A0 =A0 =A0* NEWS (Python Scripting): Add entry about the new functio= n. > =A0 =A0 =A0 =A0* python/python.c (gdbpy_find_pc_line): New function which > =A0 =A0 =A0 =A0implements gdb.find_pc_line. > =A0 =A0 =A0 =A0(GdbMethods): Add entry for the new function. > > =A0 =A0 =A0 =A0doc/ > =A0 =A0 =A0 =A0* gdb.texinfo (Basic Python): Add description about the fu= nction > =A0 =A0 =A0 =A0gdb.find_pc_line > > =A0 =A0 =A0 =A0testsuite/ > =A0 =A0 =A0 =A0* gdb.python/python.c: Add a new breakpoint comment. > =A0 =A0 =A0 =A0* gdb.python/python.exp: Add tests to test gdb.find_pc_lin= e. +@findex gdb.find_pc_line +@defun gdb.find_pc_line (pc) +Return the @code{gdb.Symtab_and_line} object corresponding to the +@var{pc} value. @xref{Symbol Tables In Python}. +@end defun I think we need to specify what the result is if there is no sal for the specified pc. +/* Implementation of gdb.find_pc_line function. + Returns the gdb.Symtab_and_line object corresponding to a PC value. */ + +static PyObject * +gdbpy_find_pc_line (PyObject *self, PyObject *args) +{ + struct symtab_and_line sal; + CORE_ADDR pc; + unsigned long long pc_llu; + PyObject *actual =3D NULL; + + if (!PyArg_ParseTuple (args, GDB_PY_LLU_ARG, &pc_llu)) + return NULL; + + pc =3D (CORE_ADDR) pc_llu; + sal =3D find_pc_line (pc, 0); + return symtab_and_line_to_sal_object (sal); +} "actual" can be deleted now.