From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id MNVxKYPgB2fmqAgAWB0awg (envelope-from ) for ; Thu, 10 Oct 2024 10:11:15 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=JioK5FnM; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id A57611E356; Thu, 10 Oct 2024 10:11:15 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-7.8 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_VALIDITY_CERTIFIED,RCVD_IN_VALIDITY_RPBL, RCVD_IN_VALIDITY_SAFE autolearn=unavailable autolearn_force=no version=4.0.0 Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 0599D1E354 for ; Thu, 10 Oct 2024 10:11:15 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 66F6E385700E for ; Thu, 10 Oct 2024 14:11:14 +0000 (GMT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTP id C9961385783B for ; Thu, 10 Oct 2024 14:10:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C9961385783B Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org C9961385783B Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1728569449; cv=none; b=cJiJrpA+8CEcY2DrbIX+LJ/HFtWTU4to3v539pnHYa85r+J76NTsdcwQ0fdH6OFhG/RDgholbm9Lwjfse0GnjCYIk/94xc1Ob66BZMcBr7r+LM+SZPq82+jG1MPVnYF73lDpMZ+8UCve2ytL3I5epJYhHbqmZxAvqoz3sk0YjdY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1728569449; c=relaxed/simple; bh=5X/r0ibf2NQ9uPRofetYY0evTRfTzP5sU8pLxYJtnHM=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=etmPnQ1grk5xNvFmdEl6a97eMsHzRyih90c6zdPsPdkowwTA9/G+nwuX3kEKH3sdk4vvso9XJXcz4X1yZMgx4+MJyAVZcBEEecSsoAnmewUEMoYp5OwDHaGGFoBEnpKL48/H6VUap8GQNszLsRX//dA5MKX/8J9SQ8G6h8Oj7Jk= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728569446; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OQkFUUpVIRwYFDHLPzKuHFVpSriIF5fYJjsCSO3pF3k=; b=JioK5FnM5u9Pd9tzKEmn+ppdU2dE5xpYMWt/rLJjEoeRp78zM9ZLrNX/hnRpHzWNELPQYE pvKX5ZRsMlGFg4JIC/LNb0mSFKbK4iKAaVoBs29mgcN8m362A04psmVrLzCNr2GnZRJ80Y qGOSQbh28EqczWY2B94UELSK8/hXurQ= Received: from mail-pg1-f197.google.com (mail-pg1-f197.google.com [209.85.215.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-587-pYA2HxR6ON65XhXlLOCWvA-1; Thu, 10 Oct 2024 10:10:45 -0400 X-MC-Unique: pYA2HxR6ON65XhXlLOCWvA-1 Received: by mail-pg1-f197.google.com with SMTP id 41be03b00d2f7-7e6e98892e1so1017434a12.0 for ; Thu, 10 Oct 2024 07:10:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728569444; x=1729174244; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=OQkFUUpVIRwYFDHLPzKuHFVpSriIF5fYJjsCSO3pF3k=; b=E5kxLyFcLN69Tu2AIoKCPVHeMGz84D5T8QrUPWHdd+bb/2PkcobV7FF86POR0qJTIG FejFf/8hVtcZLvGuaIbMvjFtiIBNC/+/zNi5kRB8IB3J6jB1nsIqxsHbsIBSz8gsEjwH nxTHDLIPaOVmxX4LTrZcm/tcrPi13D+Y9eZp067NALqtg9BNT+Bo18lSgR+KN0fZ2QgP yGgY0onYiy+bCyUNJQPyZ/z2VKS09kS7mzgu3SeEDWCz1o2bnE5yRDyBPBj3crKbA5eZ T//ZaOvCrqgi/M2OhtB7M29bFnbgNEAKskbdtWm+AU43nk6uPlxRhNb2H/02KRqOfsFj Bczg== X-Forwarded-Encrypted: i=1; AJvYcCU7MitcwUQGsjVCv+LWIJhRAUbsK+a932lC9L0rQ1l1HNbX4WPj1XDeRzFD9tD1trOcjnqfEaoa9UGA7w==@sourceware.org X-Gm-Message-State: AOJu0YzPSNeSyc3P7b8FVRp/AwDe1wOvRcHpuu6LlVH/m1AfqA1O8GDb RWJdHn51sKXcL9ai83DLWcG49gG9aQK519BnIC0l49kGrkcJ9N9gtSsOLjCSrTQROwcG0XLXpQV TMIKo/3H7/eLati3esfRd5rccJvmjxNzHpuAGRQXYS/+Rmeo8JXdt9BZ+4YI= X-Received: by 2002:a05:6a20:c78d:b0:1d6:fb1b:d08c with SMTP id adf61e73a8af0-1d8a3c3d1bdmr9325115637.39.1728569443959; Thu, 10 Oct 2024 07:10:43 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG+V8cpQBRQu9KcPRtYNxtiX3rh/TgSDnZ+q9nzXwPDd1fMDICfDD1BQurjT+h9iZhZ4aI9GQ== X-Received: by 2002:a05:6a20:c78d:b0:1d6:fb1b:d08c with SMTP id adf61e73a8af0-1d8a3c3d1bdmr9325074637.39.1728569443582; Thu, 10 Oct 2024 07:10:43 -0700 (PDT) Received: from ?IPV6:2804:14d:8084:92c5::1000? ([2804:14d:8084:92c5::1000]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7ea4495a1b4sm1044586a12.66.2024.10.10.07.10.41 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 10 Oct 2024 07:10:43 -0700 (PDT) Message-ID: Date: Thu, 10 Oct 2024 11:10:39 -0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v5 3/5] gdb: Migrate frame unwinders to use C++ classes To: Simon Marchi , gdb-patches@sourceware.org Cc: Guinevere Larsen References: <20241001184235.3710608-1-guinevere@redhat.com> <20241001184235.3710608-4-guinevere@redhat.com> From: Guinevere Larsen In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org On 10/4/24 2:21 AM, Simon Marchi wrote: > Some more things I thought about... > >>> + /* Default frame sniffer. Will always return that the unwinder >>> + is able to unwind the frame. */ >>> + virtual int sniffer (const frame_unwind *self, > One nit: I think this method should be called just "sniff". When a > method is named after a thing, my brain adds an implicit "get_" in front > of it. So to me, a method named "sniffer" would return some sniffer > object. Here, I think it would make more sense to use an action verb, > because we want the unwinder to "sniff". This makes sense, and is a pretty trivial change. Fixed. > > Oh and I guess another naming nit, I think frame_unwind should be named > frame_unwinder. A "thing" that unwinds stuff would be called an > "unwinder", not an "unwind". I don't know how you feel about changing > that. This is a reasonably big change, because several functions receive frame_unwind as a parameter. If we progress conversion from the legacy to the specific classes we're going to reduce the number of function that get it as a parameter and it will turn into a smaller, more manageable patch. I think makes sense for future improvement. > > And something else I just remembered, I am not really a fan of the > very abbreviated parameter names like this: > > frame_unwind_trampoline (enum frame_type t, const struct frame_data *d, > frame_prev_arch_ftype *pa) > : frame_unwind ("trampoline", t, FRAME_UNWIND_GDB, d), prev_arch_p (pa) > { } > > When using an editor that provides tooltips when writing a function > call, the abbreviated names in the tooltip are not very helpful. I > would suggest using proper names. This makes sense. I really dislike having a function named the same as a type, but I will use "type", "data" and "prev_arch_func". >>> +public: >>> + frame_unwind_trampoline (enum frame_type t, const struct frame_data *d, >>> + frame_prev_arch_ftype *pa) >>> + : frame_unwind ("trampoline", t, FRAME_UNWIND_GDB, d), prev_arch_p (pa) >>> + { } >> This "frame_data" thing appears to be some kind of opaque / private data >> that frame_unwind implementations can use? For those that you converted >> to proper classes (trampoline and python), could that data be stored in >> the frame_unwind_* object directly? It would remove some unnecessary >> indirections and make things simpler, I think. >> >> Actually, I gave it a try, and trampoline and python are the only >> implementations actually using the frame_data pointer. So if they stop >> using it, we can just get rid of that. That requires touching all the >> frame_unwind_legacy constructor call sites, but I was able to do that >> relatively easily with a global regex find & replace in VScode. [last >> minute edit: I just realized that I was building without >> --enable-targets=all, so take this with a grain of salt] > One more thought about all this: in an ideal world, the tramp_frame uses > should probably become sub-classes of frame_unwind_trampoline. Only > those sites that want to override the prev_arch method would need to do > it (AFAIK, the only one is aarch64_linux_rt_sigframe). The `init` and > `validate` callbacks in `tramp_frame` would become virtual methods of > `frame_unwind_trampoline`, and the other data fields of `tramp_frame` > would become fields of `frame_unwind_trampoline`. I started to > prototype it on top of this patch, and it would be quite a lot of work. > So let's keep that on the wishlist for now. > > Simon > -- Cheers, Guinevere Larsen She/Her/Hers