From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-f52.google.com (mail-wr1-f52.google.com [209.85.221.52]) by sourceware.org (Postfix) with ESMTPS id 3A3213858D1E for ; Fri, 30 Sep 2022 14:50:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 3A3213858D1E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=palves.net Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wr1-f52.google.com with SMTP id c11so7209456wrp.11 for ; Fri, 30 Sep 2022 07:50:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:content-language:in-reply-to:mime-version :user-agent:date:message-id:from:references:cc:to:subject :x-gm-message-state:from:to:cc:subject:date; bh=GQpH6iGHrl6qWy1MwK+b4cjnwz8QfhqM64+iHVErr1s=; b=ltz+2tOpqGKiS/QpCBx0MtftflhA3D5aYsF3p8XeKTcsKaufJ/FUj7LwbdERNcndjB siJUxIJBawo4bQVpUWy581eUpCUywoiDZHSPYH9jEgV/yaikgaQOFdnTwtYrRzQkHe/W PMMGFCwFpXvV2WA3BgctXnO2jaD+AdBjwpQrsr63qgOez9n7UNdUzO5jeS2hl1/FAP1L GZ5oN6QCKVA9Q74cCk+7jZBxAvDprJpoeD+OEFhO848EpP84gmLUJlkJcGqb3FQGb3G7 fXmBS4mOzSvWBhlOshnWG4zQ3jnvA00DC6LFlhofTszWwDXVaodlnhkMKtvvQXMpnqfW i2Ig== X-Gm-Message-State: ACrzQf282ZO9TnZ1/Hoe277DWUFK5SK3hJMWfjurezthMsBdISxNbJyw C1AMgxCG+ml8aSNAUG7CgXuENfFDTCIZvA== X-Google-Smtp-Source: AMsMyM6q+sfi7kXt3gXRFMhbUriMog4wZJKbJ4wNZtLlYKutvj5sj+rH0jaw+l06Lo2GyOPtolGa6Q== X-Received: by 2002:a05:6000:1842:b0:22a:4d1d:4bd6 with SMTP id c2-20020a056000184200b0022a4d1d4bd6mr5982856wri.603.1664549422473; Fri, 30 Sep 2022 07:50:22 -0700 (PDT) Received: from ?IPv6:2001:8a0:f93a:3b00:e038:5cdc:b8bf:4653? ([2001:8a0:f93a:3b00:e038:5cdc:b8bf:4653]) by smtp.gmail.com with ESMTPSA id f7-20020adfdb47000000b00228cbac7a25sm2147217wrj.64.2022.09.30.07.50.21 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 30 Sep 2022 07:50:21 -0700 (PDT) Subject: Re: [PATCH v3 4/4] gdb/python doc: Move unwinder skeleton code To: Eli Zaretskii , Paulo Neves Cc: gdb-patches@sourceware.org References: <20220528115509.3865342-1-ptsneves@gmail.com> <20220603160139.136115-1-ptsneves@gmail.com> <20220603160139.136115-4-ptsneves@gmail.com> <83wndxbtwn.fsf@gnu.org> From: Pedro Alves Message-ID: <8ed127eb-221b-2b85-1019-1968060f68bc@palves.net> Date: Fri, 30 Sep 2022 15:50:20 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: <83wndxbtwn.fsf@gnu.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.7 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 30 Sep 2022 14:50:27 -0000 On 2022-06-03 5:20 p.m., Eli Zaretskii via Gdb-patches wrote: >> Date: Fri, 3 Jun 2022 18:01:39 +0200 >> From: Paulo Neves via Gdb-patches >> Cc: Paulo Neves >> >> +@subheading Registering a Unwinder >> + >> +An object file, a program space, and the @value{GDBN} proper can have >> +unwinders registered with it. >> + >> +The @code{gdb.unwinder} module provides the function to register a >> +unwinder: >> + >> +@defun gdb.unwinder.register_unwinder (locus, unwinder, replace=False) >> +@var{locus} is specifies an object file or a program space to which > ^^ > The "is" part should be deleted. > >> +@var{unwinder} is added. Passing @code{None} or @code{gdb} adds >> +@var{unwinder} to the @value{GDBN}'s global unwinder list. > > First, @value{GDBN}, not @code{gdb}. > > And also, this sentence doesn't read well ("passing None or gdb > adds..."), I guess it's some typo or missing or redundant word. > I think the intent is to say that you can pass literal "None" or "gdb" to gdb.unwinder.register_unwinder, for "locus" argument. Reading like that, it makes sense to me, and replacing with @value{GDBN} would be incorrect. However, looking at the code itself, I don't see "gdb" being accepted as input: >From gdb/python/lib/gdb/unwinder.py : def register_unwinder(locus, unwinder, replace=False): """Register unwinder in given locus. The unwinder is prepended to the locus's unwinders list. Unwinder name should be unique. Arguments: locus: Either an objfile, progspace, or None (in which case the unwinder is registered globally). unwinder: An object of a gdb.Unwinder subclass replace: If True, replaces existing unwinder with the same name. Otherwise, raises exception if unwinder with the same name already exists. Returns: Nothing. Raises: RuntimeError: Unwinder name is not unique TypeError: Bad locus type """ if locus is None: if gdb.parameter("verbose"): gdb.write("Registering global %s unwinder ...\n" % unwinder.name) locus = gdb elif isinstance(locus, gdb.Objfile) or isinstance(locus, gdb.Progspace): if gdb.parameter("verbose"): gdb.write( "Registering %s unwinder for %s ...\n" % (unwinder.name, locus.filename) ) else: raise TypeError("locus should be gdb.Objfile or gdb.Progspace or None") i = 0 for needle in locus.frame_unwinders: if needle.name == unwinder.name: if replace: del locus.frame_unwinders[i] else: raise RuntimeError("Unwinder %s already exists." % unwinder.name) i += 1 locus.frame_unwinders.insert(0, unwinder) gdb.invalidate_cached_frames() Above, when you pass "None", locus does end up being "gdb", if locus is None: if gdb.parameter("verbose"): gdb.write("Registering global %s unwinder ...\n" % unwinder.name) locus = gdb ^^^^^^^^^^^ but, if you pass locus=gdb as argument, seems to me you'll reach the else branch: else: raise TypeError("locus should be gdb.Objfile or gdb.Progspace or None") And note that error string does not mention the "gdb" possibility. So I think the manual should be fixed by dropping the "or @code{gdb}", resulting in: Passing @code{None} adds @var{unwinder} to the @value{GDBN}'s global unwinder list. Actually, the "the" in "to the @value{GDBN}'s" looks wrong to me. So I think we should really say: Passing @code{None} adds @var{unwinder} to @value{GDBN}'s global unwinder list.