From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from eggs.gnu.org (eggs.gnu.org [209.51.188.92]) by sourceware.org (Postfix) with ESMTPS id 005A93858CD1 for ; Tue, 9 Apr 2024 02:47:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 005A93858CD1 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gnu.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gnu.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 005A93858CD1 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=209.51.188.92 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712630855; cv=none; b=EL4xOQI1FbykNNMN5VKKdS/8j3Jdrcq0EZkioVzNKKwrzGHx+NPbjqQUR9KdcOdlzAX1Of2kExVrPo55JLU5d6f0YsLceZc0S+lBlUXhZ2onEo0EaNFM9dmY8YeKloGxBdhWGfeOt5Rj946SIvr/FueBWKh/4/FBZqwzU2V1Wg0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712630855; c=relaxed/simple; bh=+/TyYat7q8o/ZCI9HoWinwozpOdySXupXL585BdYf/Y=; h=DKIM-Signature:Date:Message-Id:From:To:Subject; b=x8Tg5apdNczUox4xMrs6TxoK7L7SAeUgF/ku1racnCBd0s1CJxtxrCFCVaT3XHrqVNuj+pAXwkxsJ1YrluNBfRhvUOj8jDysEaEpmqppuwfqks5eNSF7kpDaGcr7PxzEnpWUl15cILUtgi2SmRdHevwMKh5tf43IY1HVGN7r3eQ= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ru1WF-0006UB-Qf; Mon, 08 Apr 2024 22:47:32 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=m/tj43RdkB+AaFGepwKrI6GpqschzocX6BoTG78IDP0=; b=qNG7GNbBJiMj O8w3GE+z7EuuRXJJzGX32FvW1PmRXIQk20dS5Ic8jG6t0OQkOr87Hjl8Og5wQ3eJXUwepXaHVsHED Ct861LbV2vuRzeLr1sGme1H+9vQTvADKRmCw7nT20V11IpcHGyOe+bARpujYney+YeJ9bcZQU2mGZ qXRDjpq0xKthHBhbvtrZiuKWdXIECB/aKMYs4bn9Xcr7U/B8daxxjTeJi9muTD3XC0zk59zDVZLJ7 /NPwmGaXrGhHgoTccsmUCFDQXFc3n6HF5wFcrqH6BBe+gd5yEgFtNn4Cay4Mzybdofsp00aklztWl B95e6mqCRCB3x5KS3u5g7Q==; Date: Tue, 09 Apr 2024 05:47:28 +0300 Message-Id: <86bk6jxnen.fsf@gnu.org> From: Eli Zaretskii To: Guinevere Larsen Cc: gdb-patches@sourceware.org In-Reply-To: <20240408201915.1482831-5-blarsen@redhat.com> (message from Guinevere Larsen on Mon, 8 Apr 2024 17:19:14 -0300) Subject: Re: [PATCH v2 4/5] gdb: introduce ability to disable frame unwinders References: <20240408201915.1482831-1-blarsen@redhat.com> <20240408201915.1482831-5-blarsen@redhat.com> X-Spam-Status: No, score=-0.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,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 List-Id: > From: Guinevere Larsen > Cc: Guinevere Larsen > Date: Mon, 8 Apr 2024 17:19:14 -0300 > > Sometimes, in the GDB testsuite, we want to test the ability of specific > unwinders to handle some piece of code. Usually this is done by trying > to outsmart GDB, or by coercing the compiler to remove information that > GDB would rely on. Both approaches have problems as GDB gets smarter > with time, and that compilers might differ in version and behavior, or > simply introduce new useful information. This was requested back in 2003 > in PR backtrace/8434. > > To improve our ability to thoroughly test GDB, this patch introduces a > new maintenance command that allows a user to disable some unwinders, > based on either the name of the unwinder or on its class. With this > change, it will now be possible for GDB to not find any frame unwinders > for a given frame, which would previously cause GDB to assert. GDB will > now check if any frame unwinder has been disabled, and if some has, it > will just error out instead of asserting. > > Unwinders can be disabled or re-enabled in 3 different ways: > * Disabling/enabling all at once (using '-all'). > * By specifying an unwinder class to be disabled (option '-class'). > * By specifying the name of an unwinder (option '-name'). > > If you give no options to the command, GDB assumes the input is an > unwinder class. '-class' would make no difference if used, is just here > for completeness. > > This command is meant to be used once the inferior is already at the > desired location for the test. An example session would be: > > (gdb) start > Temporary breakpoint 1, main () at omp.c:17 > 17 func(); > (gdb) maint frame-unwinder disable ARCH > (gdb) bt > \#0 main () at omp.c:17 > (gdb) maint frame-unwinder enable ARCH > (gdb) cont > Continuing. > > Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=8434 > --- > gdb/NEWS | 7 + > gdb/doc/gdb.texinfo | 24 +++ > gdb/frame-unwind.c | 154 +++++++++++++++++- > gdb/frame-unwind.h | 13 ++ > gdb/testsuite/gdb.base/frame-unwind-disable.c | 21 +++ > .../gdb.base/frame-unwind-disable.exp | 114 +++++++++++++ > 6 files changed, 329 insertions(+), 4 deletions(-) > create mode 100644 gdb/testsuite/gdb.base/frame-unwind-disable.c > create mode 100644 gdb/testsuite/gdb.base/frame-unwind-disable.exp Thanks. > --- a/gdb/NEWS > +++ b/gdb/NEWS > @@ -54,6 +54,13 @@ disable missing-debug-handler LOCUS HANDLER > maintenance info linux-lwps > List all LWPs under control of the linux-nat target. > > +maintenance frame-unwinder disable [-all | -name NAME | [-class] CLASS] > +maintenance frame-unwinder enable [-all | -name NAME | [-class] CLASS] > + Enable or disable frame unwinders. This is only meant to be used when > + testing unwinders themselves, and you want to ensure that a fallback > + algorithm won't obscure a regression. GDB is not expected to behave > + well if you try to execute the inferior with unwinders disabled. This part is OK. > --- a/gdb/doc/gdb.texinfo > +++ b/gdb/doc/gdb.texinfo > @@ -42022,6 +42022,30 @@ architecture, then enabling this flag does not cause them to be used. > @item maint info frame-unwinders > List the frame unwinders currently in effect, starting with the highest priority. > > +@kindex maint frame-unwinder disable > +@kindex maint frame-unwinder enable > +@item maint frame-unwinder disable [@code{-all} | @code{-name} @var{NAME} | [@code{-class}] @var{CLASS}] > +@item maint frame-unwinder enable [@code{-all} | @code{-name} @var{NAME} | [@code{-class}] @var{CLASS}] The symbols in @var should be in lower-case (they will be up-cased in the Info output, but in HTML and printed output they will be in italics instead). > +Disable or enable frame unwinders. This is meant only as a testing tool, and > +@value{GDBN} is not guaranteed to work properly if it is unable to find > +valid frame unwinders. > + > +The meaning of each of the invocations are as follows: > + > +@table @samp > +@item @code{-all} > +Disable or enable all unwinders. > +@item @code{-name} @var{NAME} > +@var{NAME} is the exact name of the unwinder to be disabled or enabled. > +@item [@code{-class}] @var{CLASS} > +@var{CLASS} is the class of frame unwinders to be disabled or enabled. > +The class may include the prefix @code{FRAME_UNWINDER_}, but it is not > +required. > +@end table > + > +@var{NAME} and @var{CLASS} are always case insensitive. If no option > +starting wth @code{-} is given, @value{GDBN} assumes @code{-class}. I think this command should be moved to after "maint info frame-unwinders", and it should say that the list of available unwinders is shown by that command. Also, I suppose what you call "class" is what "maint info frame-unwinders" displays as "Type"? Or is it something else? If the latter, the manual should tell how to know which classes are available. > + add_cmd ("disable", class_maintenance, maintenance_disable_frame_unwinders, > + _("\ > +Disable one or more frame unwinder(s).\n\ > +Usage: maint frame-unwinder disable [-all | -name NAME | [-class] CLASS]\n\ > +\n\ > +These are the meanings of the options:\n\ > +\t-all - All available unwinders will be disabled\n\ > +\t-name - NAME is the exact name of the frame unwinder is to be disabled\n\ ^^ That "is" should be removed. > + add_cmd ("enable", class_maintenance, maintenance_enable_frame_unwinders, > + _("\ > +Enable one or more frame unwinder(s).\n\ > +Usage: maint frame-unwinder enable [-all | -name NAME | [-class] CLASS]\n\ > +\n\ > +These are the meanings of the options:\n\ > +\t-all - All available unwinders will be enabled\n\ > +\t-name - NAME is the exact name of the frame unwinder is to be enabled\n\ Likewise here. Reviewed-By: Eli Zaretskii