From patchwork Wed Oct 30 22:44:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philippe Waroquiers X-Patchwork-Id: 35491 Received: (qmail 76523 invoked by alias); 30 Oct 2019 22:44:44 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 76438 invoked by uid 89); 30 Oct 2019 22:44:44 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-27.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.1 spammy=FreeBSD, freebsd, error-free, errorfree X-HELO: mailsec119.isp.belgacom.be Received: from mailsec119.isp.belgacom.be (HELO mailsec119.isp.belgacom.be) (195.238.20.115) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 30 Oct 2019 22:44:42 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=skynet.be; i=@skynet.be; q=dns/txt; s=securemail; t=1572475481; x=1604011481; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=oWDqxWN7ODIosbUdOTnzHwnwfI7msnTnt2KsXOXHqrg=; b=ZQSWLd50FXMhOa3BLQmA2xzE1BHO+WlaVyM4SLhYBuzlNwXzXNHL9W8o VBeg1+S74Zl0BSKRf/lOii6iVswtSA==; IronPort-SDR: +KCccmjlwM87ejwspXP/HvIOPD6jXl5yBzqSnGYRHNa89cQeA8sV73Hdu5mqD66zFdLuoF+g16 2GRtJH8JZZ8QluxeFyex6jrdh7SywRQFo3S1ST8ezaEv31vi/h6gZ7ovUJV81rp0HBeqWn66UP CsdlRp6dFN8j1zmCbqoQt5bmNwPNIkmMI8af2ikw/uLnSWSnc1HEYeGNJOdLgQ8UETKtcjmXD0 /m7XdkhfCafuf5199qixr0+b+ec/EZyIjkeDEH2Uz0Gsw7nt0dOAAk+IUPMwkJTjleTP7Vmt+n Pw4= Received: from 117.79-136-217.adsl-dyn.isp.belgacom.be (HELO md.home) ([217.136.79.117]) by relay.skynet.be with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 30 Oct 2019 23:44:35 +0100 From: Philippe Waroquiers To: gdb-patches@sourceware.org Cc: Philippe Waroquiers Subject: [RFAv6 3/3] NEWS and documentation for $_gdb_setting and $_gdb_setting_str. Date: Wed, 30 Oct 2019 23:44:24 +0100 Message-Id: <20191030224424.9288-4-philippe.waroquiers@skynet.be> In-Reply-To: <20191030224424.9288-1-philippe.waroquiers@skynet.be> References: <20191030224424.9288-1-philippe.waroquiers@skynet.be> MIME-Version: 1.0 X-IsSubscribed: yes gdb/ChangeLog 2019-10-30 Philippe Waroquiers * NEWS: Mention $_gdb_setting, $_gdb_setting_str, $_gdb_maint_setting and $_gdb_maint_setting_str. gdb/doc/ChangeLog 2019-10-30 Philippe Waroquiers * gdb.texinfo (Convenience Funs): Document the new $_gdb_setting_str, $_gdb_maint_setting and $_gdb_maint_setting_str convenience functions. Some more doc changes --- gdb/NEWS | 6 +++ gdb/doc/gdb.texinfo | 91 ++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 96 insertions(+), 1 deletion(-) diff --git a/gdb/NEWS b/gdb/NEWS index 761359862a..ef21b5d97e 100644 --- a/gdb/NEWS +++ b/gdb/NEWS @@ -11,6 +11,12 @@ scripts that should work error-free with many different versions, such as in system-wide init files. +* New built-in convenience functions $_gdb_setting, $_gdb_setting_str, + $_gdb_maint_setting and $_gdb_maint_setting_str provide access to values + of the GDB settings and the GDB maintenance settings. They are handy + for changing the logic of user defined commands depending on the + current GDB settings. + * GDB now supports Thread Local Storage (TLS) variables on several FreeBSD architectures (amd64, i386, powerpc, riscv). Other architectures require kernel changes. TLS is not yet supported for diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index db3d15b05e..7cf4141d20 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -11987,9 +11987,98 @@ $3 = void $4 = 1 @end smallexample +@item $_gdb_setting_str (@var{setting}) +@findex $_gdb_setting_str@r{, convenience function} +Return the value of the @value{GDBN} @var{setting} as a string. +@var{setting} is any setting that can be used in a @code{set} or +@code{show} command (@pxref{Controlling GDB}). + +@smallexample +(@value{GDBP}) show print frame-arguments +Printing of non-scalar frame arguments is "scalars". +(@value{GDBP}) p $_gdb_setting_str("print frame-arguments") +$1 = "scalars" +(@value{GDBP}) p $_gdb_setting_str("height") +$2 = "30" +(@value{GDBP}) +@end smallexample + +@item $_gdb_setting (@var{setting}) +@findex $_gdb_setting@r{, convenience function} +Return the value of the @value{GDBN} @var{setting}. +The type of the returned value depends on the setting. + +The value type for boolean and auto boolean settings is @code{int}. +The boolean values @code{off} and @code{on} are converted to +the integer values @code{0} and @code{1}. The value @code{auto} is +converted to the value @code{-1}. + +The value type for integer settings is either @code{unsigned int} +or @code{int}, depending on the setting. + +Some integer settings accept an @code{unlimited} value. +Depending on the setting, the @code{set} command also accepts +the value @code{0} or the value @code{@minus{}1} as a synonym for +@code{unlimited}. +For example, @code{set height unlimited} is equivalent to +@code{set height 0}. + +Some other settings that accept the @code{unlimited} value +use the value @code{0} to literally mean zero. +For example, @code{set history size 0} indicates to not +record any @value{GDBN} commands in the command history. +For such settings, @code{@minus{}1} is the synonym +for @code{unlimited}. + +See the documentation of the corresponding @code{set} command for +the numerical value equivalent to @code{unlimited}. + +The @code{$_gdb_setting} function converts the unlimited value +to a @code{0} or a @code{@minus{}1} value according to what the +@code{set} command uses. + +@smallexample +@group +(@value{GDBP}) p $_gdb_setting_str("height") +$1 = "30" +(@value{GDBP}) p $_gdb_setting("height") +$2 = 30 +(@value{GDBP}) set height unlimited +(@value{GDBP}) p $_gdb_setting_str("height") +$3 = "unlimited" +(@value{GDBP}) p $_gdb_setting("height") +$4 = 0 +@end group +@group +(@value{GDBP}) p $_gdb_setting_str("history size") +$5 = "unlimited" +(@value{GDBP}) p $_gdb_setting("history size") +$6 = -1 +(@value{GDBP}) p $_gdb_setting_str("disassemble-next-line") +$7 = "auto" +(@value{GDBP}) p $_gdb_setting("disassemble-next-line") +$8 = -1 +(@value{GDBP}) +@end group +@end smallexample + +Other setting types (enum, filename, optional filename, string, string noescape) +are returned as string values. + + +@item $_gdb_maint_setting_str (@var{setting}) +@findex $_gdb_maint_setting_str@r{, convenience function} +Like the @code{$_gdb_setting_str} function, but works with +@code{maintenance set} variables. + +@item $_gdb_maint_setting (@var{setting}) +@findex $_gdb_maint_setting@r{, convenience function} +Like the @code{$_gdb_setting} function, but works with +@code{maintenance set} variables. + @end table -These functions require @value{GDBN} to be configured with +The following functions require @value{GDBN} to be configured with @code{Python} support. @table @code