From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 105387 invoked by alias); 16 Mar 2015 17:25:17 -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 105366 invoked by uid 89); 16 Mar 2015 17:25:16 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 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-ig0-f170.google.com Received: from mail-ig0-f170.google.com (HELO mail-ig0-f170.google.com) (209.85.213.170) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Mon, 16 Mar 2015 17:25:15 +0000 Received: by ignm3 with SMTP id m3so36952491ign.0 for ; Mon, 16 Mar 2015 10:25:13 -0700 (PDT) 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=5XdpA+29/pNXZJ6Inu4zVEUaE6WtrYHWmrd6KzPXxV8=; b=YYhShDknAhN7r8RsUF9nh6P0hFtKhO0Qai0s6hg1X7bd9dBIWRVl1HsBliGm7oXZsv SKqlhLu7fONhFSHNOJypTWLR+S3K2OimNw2TexPVxVh438j10YGozo+pLPKuEdJsIUYp jVKrz3mWLgfLyIQ9yOpiC7UwPBPZWHgGsY9JlOD0Uq/O7d9rxq9H7RWX0IQg8AuxoWFm Rle1ZYAVN4d5Vpw+fZFfGLhpTuMtAHeRKNuhFQa6j+LNfB9Cvh5IFHyjDzH02t6ybjjm o51/HIYqvf2DW912hCVsdian9YO18XO+lxF8QCVAkGY5VekfsWUI4b4jQr7iqr+XsMSW rUjQ== X-Gm-Message-State: ALoCoQlsg7XH2oYbS8mYLcqFaZpeAbc353ZheWwHeNP4SzUXNVbExIjlJMcdLCnT8YwKRe56JlfM MIME-Version: 1.0 X-Received: by 10.107.16.158 with SMTP id 30mr16274710ioq.2.1426526713339; Mon, 16 Mar 2015 10:25:13 -0700 (PDT) Received: by 10.64.98.103 with HTTP; Mon, 16 Mar 2015 10:25:13 -0700 (PDT) In-Reply-To: <87ioe1dvu2.fsf@igalia.com> References: <21714.40641.510825.30998@ruffy2.mtv.corp.google.com> <54E71694.1080304@redhat.com> <87ioei31uj.fsf@igalia.com> <87d24p19tt.fsf@igalia.com> <54FD7DAA.7010603@redhat.com> <87twxrncld.fsf@igalia.com> <87ioe1dvu2.fsf@igalia.com> Date: Mon, 16 Mar 2015 17:25:00 -0000 Message-ID: Subject: Re: [RFC] [PATCH] Provide the ability to write the frame unwinder in Python From: Alexander Smundak To: Andy Wingo Cc: Doug Evans , gdb-patches Content-Type: text/plain; charset=UTF-8 X-SW-Source: 2015-03/txt/msg00464.txt.bz2 > How about let's meet somewhat halfway. > > * We rename SnifferInfo to EphemeralFrame. > > * Unwinders return UnwindInfo (better name welcome) on success or > None/#f otherwise > > * UnwindInfo takes EphemeralFrame as constructor arg > > - the EphemeralFrame must be valid > > - in practice there is only ever one EphemeralFrame alive because > unwinding is not recursive > > * UnwindInfo also takes frame ID as positional constructor args > > - setting frame_id is the only thing an unwinder *must* do, so > this makes an invariant "if return value is an UnwindInfo, then > it is valid and has all necessary info" > > * UnwindInfo has add_saved_register() API (see discussion with Pedro > here: http://article.gmane.org/gmane.comp.gdb.patches/105538) > > * After accepting an UnwindInfo as an unwinder return result, > py-unwinders.c / scm-frame-unwinders.c marks the UnwindInfo as > frozen so that add_saved_register() etc can't alter the state > > * continuation of unwinder call also checks that the ephemeral frame > on the unwindinfo is valid > > Example of use: > > def unwind(frame): > if we_can_handle(frame): > var ret = UnwindInfo(frame, fp, pc) > ret.add_saved_register(r0) > return ret > > I will rework the Guile patch along these lines, and then hopefully I am > done reworking :) I'd like to propose one improvement on the Python side: UnwinderInfo is constructed by a frame method instead of an implicit constructor. I.e., frame.create_frame_with_id(sp, pc) returns UnwindInfo instance whose ID is the result of calling GDB's frame_id_build(sp, pc), frame.create_frame_with_id_wild(sp) returns UnwindInfo instance whose ID is the results of calling frame_id_build_wild(sp), etc. The example above would then look as follows: def unwind(frame): if we_can_handle(frame): unwind_info = frame.create_frame_with_id(sp, pc) unwind_info.set_previous_frame_register("r0", r0) unwind_info.set_previous_frame_register(...) return unwind_info else return None Would this work for Guile? As to the class of an object passed to a sniffer, how about calling it FrameData? Note that it's not very important from the user's point of view as sniffer code does not ever reference it by name.