From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17280 invoked by alias); 12 Jan 2015 21:22:51 -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 17271 invoked by uid 89); 12 Jan 2015 21:22:50 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.7 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mail-ob0-f172.google.com Received: from mail-ob0-f172.google.com (HELO mail-ob0-f172.google.com) (209.85.214.172) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Mon, 12 Jan 2015 21:22:49 +0000 Received: by mail-ob0-f172.google.com with SMTP id va8so24550405obc.3 for ; Mon, 12 Jan 2015 13:22:47 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=0tvVsDfhl9m4RvrNHP2zwvEVj/wxshCxwPwj2RWzMkk=; b=nGQLKpIH+b1JWAzqLE2jUhs+XAbD0hTjo5wwtW/2QH+VsEOLvCPuNaGW3trZAY8esA F/e2RJNCaxOb+yj+6CGZ8mAWiyf5+V+plbYDkCDocWh2Vhz/BoXmQ8cI5prBzgqUHi69 suJdJKzHG+S6SnXluFOT399zgswJRqRlwtZK+SA4rxkJsxt/e7cUFuuUiNViDs5XicrH CFgVchQS0Za1h/nois8EJrdOdQ031zplZTeXAla8CS4gU8688HLmtd7ACqoNJmRSDxS8 CAqIcgD1JLchSs2dAoynWX1Eh/POail9Uq4nuXQIiGldBAcNV2PL9NN0Y58Q7yuY7Vo+ 1RGQ== X-Gm-Message-State: ALoCoQn6WNpL32cHAy7KdU/uHZK8OAukD5vgJrc5NZvnWxO4xod2rsIJpLxupPzZhEqihw5Ea5qI MIME-Version: 1.0 X-Received: by 10.182.27.207 with SMTP id v15mr18776976obg.21.1421097767142; Mon, 12 Jan 2015 13:22:47 -0800 (PST) Received: by 10.182.222.98 with HTTP; Mon, 12 Jan 2015 13:22:47 -0800 (PST) In-Reply-To: <54B435D3.7000409@ericsson.com> References: <54B435D3.7000409@ericsson.com> Date: Mon, 12 Jan 2015 21:22:00 -0000 Message-ID: Subject: Re: [RFC] [PATCH] Provide the ability to write the frame unwinder in Python From: Doug Evans To: Simon Marchi Cc: gdb-patches Content-Type: text/plain; charset=UTF-8 X-IsSubscribed: yes X-SW-Source: 2015-01/txt/msg00319.txt.bz2 On Mon, Jan 12, 2015 at 1:00 PM, Simon Marchi wrote: > On 14-12-15 01:13 PM, Alexander Smundak wrote: >> Python frame filters provide the ability to display non-native frames in >> a mixed-language application (say, a backtrace of an application written >> in C and embedding Java Virtual Machine can be displayed as a mix of >> native frames and Java frames). However, GDB cannot always unwind >> non-native frames. The proposed patch adds the ability to write frame >> unwinders in Python. >> >> 2014-12-12 Sasha Smundak >> >> * Makefile.in (SUBDIR_PYTHON_OBJS): Add py-unwind.o. >> (SUBDIR_PYTHON_SRCS): Add py-unwind.c. >> (py-unwind.o): New recipe. >> * NEWS: mention Python frame unwinding. >> * data-directory/Makefile.in (PYTHON_FILE_LIST): Add sniffers.py. >> * doc/python.texi (Writing a Frame Unwinder in Python): Add >> section. >> * python/py-objfile.c (objfile_object): Add frame_sniffers field. >> (objfpy_dealloc): Decrement frame_sniffers reference count. >> (objfpy_initialize): Create frame_sniffers list. >> (objfpy_get_frame_sniffers): Implement Objfile.frame_sniffers >> getter. >> (objfpy_set_frame_sniffers): Implement Objfile.frame_sniffers >> setter. >> (objfile_getset): Add frame_sniffers attribute to Objfile. >> * python/py-progspace.c (pspace_object): Add frame_sniffers field. >> (pspy_dealloc): Decrement frame_sniffers reference count. >> (pspy_initialize): Create frame_sniffers list. >> (pspy_get_frame_sniffers): Implement gdb.Progspace.frame_sniffers >> getter. >> (pspy_set_frame_sniffers): Implement gdb.Progspace.frame_sniffers >> setter. >> (pspy_getset): Add frame_sniffers attribute to gdb.Progspace. >> * python/py-unwind.c: New file, implements Python frame sniffers >> interface. >> * python/python-internal.h (pspy_get_name_sniffers): New prototype. >> (objpy_get_frame_sniffers): New prototype. >> (gdbpy_initialize_unwind): New prototype. >> * python/python.c (gdbpy_apply_type_printers): Call >> gdbpy_initialize_unwind. >> * python/lib/gdb/__init__.py (packages): add frame_sniffers. >> >> 2014-12-12 Sasha Smundak >> >> * gdb.python/py-unwind.c: Test program for the py-unwind test. >> * gdb.python/py-unwind.exp: Python frame sniffers test. >> * gdb.python/py-unwind.py: Frame sniffer in Python tested by >> py-unwind test. >> > > Hi Alexander, > > I don't have much experience in this field, so I fail to see what problem it would > help to solve. > > From what I understand, with CPython, each PyEval_EvalFrameEx frame maps to one > non-native (Python) frame. So it's easy to just filter out the others and tweak > the output with a frame filter. Are you talking about other languages/VM where it's > not as simple as this? Could you provide a more concrete example to illustrate the > usefulness of the feature? That's exactly it: "other languages/VM", and in particular Java. I plan to get to this this week, but more eyes can certainly help.