From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10238 invoked by alias); 2 Jun 2014 08:31:43 -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 10223 invoked by uid 89); 2 Jun 2014 08:31:42 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.4 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_SOFTFAIL autolearn=no version=3.3.2 X-HELO: hera.aquilenet.fr Received: from hera.aquilenet.fr (HELO hera.aquilenet.fr) (141.255.128.1) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 02 Jun 2014 08:31:40 +0000 Received: from localhost (localhost [127.0.0.1]) by hera.aquilenet.fr (Postfix) with ESMTP id 9FE4C2B2F; Mon, 2 Jun 2014 10:31:37 +0200 (CEST) Received: from hera.aquilenet.fr ([127.0.0.1]) by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Ksujvu-Q-Nln; Mon, 2 Jun 2014 10:31:37 +0200 (CEST) Received: from pluto (pluto.bordeaux.inria.fr [193.50.110.57]) by hera.aquilenet.fr (Postfix) with ESMTPSA id 57494289A; Mon, 2 Jun 2014 10:31:37 +0200 (CEST) From: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) To: Doug Evans Cc: eliz@gnu.org, "gdb-patches\@sourceware.org" Subject: Re: [PATCH, doc RFA] Add guile gdb parameter support References: <87lhtnd2q9.fsf@gnu.org> X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 14 Prairial an 222 de la =?utf-8?Q?R=C3=A9volution?= X-PGP-Key-ID: 0xEA52ECF4 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 83C4 F8E5 10A3 3B4C 5BEA D15D 77DD 95E2 EA52 ECF4 X-OS: x86_64-unknown-linux-gnu Date: Mon, 02 Jun 2014 08:31:00 -0000 In-Reply-To: (Doug Evans's message of "Sun, 01 Jun 2014 20:13:05 -0700") Message-ID: <87vbsj3e6v.fsf@gnu.org> User-Agent: Gnus/5.130009 (Ma Gnus v0.9) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-SW-Source: 2014-06/txt/msg00013.txt.bz2 Doug Evans skribis: > Here is a revised version of guile parameter support. > I plan to check it in in a few days. Thanks for incorporating the suggestions! Just minor comments; the only thing I=E2=80=99m unsure about is the =E2=80= =98set-func=E2=80=99 protocol (see below.) > +@node Parameters In Guile > +@subsubsection Parameters In Guile > + > +@cindex parameters in guile > +@cindex guile parameters > +@tindex Parameter > +You can implement new @value{GDBN} parameters using Guile. A new @dfn{parameters} Also, after =E2=80=9CGuile=E2=80=9D, I would add something like: @footnote{Note that @value{GDBN} parameters must not be confused with Guile=E2=80=99s parameter objects (@pxref{Parameters,,, guile, GNU Guile Reference Manual}).} > +parameter is defined with the @code{make-parameter} Guile function, > +and added to @value{GDBN} with the @code{register-parameter!} Guile func= tion. > +This two-step approach is taken to separate out the side-effect of adding > +the command to @value{GDBN} from @code{make-parameter}. > + > +Parameters are exposed to the user via the @code{set} and > +@code{show} commands. @xref{Help}. > + > +There are many parameters that already exist and can be set in > +@value{GDBN}. Two examples are: @code{set follow-fork} and > +@code{set charset}. Setting these parameters influences certain > +behavior in @value{GDBN}. Similarly, you can define parameters that > +can be used to influence behavior in custom Guile scripts and commands. I would also move the paragraph that starts with =E2=80=9CThere are many parameters that already exist=E2=80=9D right after the first sentence, whic= h is where I would expect parameters to be defined. WDYT? > +@c TODO line length Yup. :-) > +@deffn {Scheme Procedure} (make-parameter name @r{[}#:command-class comm= and-class@r{]} @r{[}#:parameter-type parameter-type{]} @r{[}#:enum-list enu= m-list@r{]} @r{[}#:set-func set-func{]} @r{[}#:show-func show-func{]} @r{[}= #:doc doc{]} @r{[}#:set-doc set-doc{]} @r{[}#:show-doc show-doc{]} @r{[}#:i= nitial-value initial-value{]}) [...] > +The argument @var{set-func} is a function of one argument: @var{self} wh= ich > +is the @code{} object representing the parameter. > +@value{GDBN} will call this function when a @var{parameter}'s value has > +been changed via the @code{set} API (for example, @kbd{set foo off}). It would be nicer if =E2=80=98set-func=E2=80=99 were passed both the parame= ter and the new value, such that it would be its responsibility to validate the value and set it, but it seems that that=E2=80=99s not how =E2=80=98cmd_sfu= nc_ftype=E2=80=99 callbacks work. Alternately, parameters could have just a =E2=80=9Cconversion=E2=80=9D func= tion, rather than a real =E2=80=98set=E2=80=99 function, just like SRFI-39 parameters (i= nfo "(guile) Parameters"). That would free users from the need to explicitly call =E2=80=98set-parameter-value!=E2=80=99. Thoughts? > +/* A GDB parameter. > + > + Note: Parameteres are added to gdb using a two step process: =E2=80=9CParameters=E2=80=9D [...] > +/* A helper which computes the list of enum values. > + Throw's an exception if there's a problem with the values. =E2=80=9CThrows=E2=80=9D Maybe a more descriptive first sentence could be =E2=80=9CReturn an array of strings corresponding to the value enum values for ENUM_VALUES_SCM.=E2=80= =9D? [...] > +/* Subroutine of pascm_set_value, pascm_show_value to simplify them. =E2=80=98pascm_set_value=E2=80=99 now has a different name. > +gdb_test_multiline "restricted gdb parameter" \ > + "guile" "" \ > + "(register-parameter! (make-parameter \"test-restricted-param\"" "" \ > + " #:command-class COMMAND_DATA" "" \ > + " #:parameter-type PARAM_ZINTEGER" "" \ > + " #:set-func (lambda (self)" "" \ > + " (let ((value (parameter-value self)))" "" \ > + " (if (and (>=3D value 0) (<=3D value 10))" "" \ > + " \"\"" "" \ > + " (begin" "" \ > + " (set-parameter-value! self (object-property self 'val= ue))" "" \ > + " \"Error: Range of parameter is 0-10.\"))))" "" \ > + " #:show-func (lambda (self value)" "" \ > + " (format #f \"The value of the restricted parameter is ~a.\" v= alue))" "" \ > + " #:initial-value (lambda (self)" "" \ > + " (set-object-property! self 'value 2)" "" \ > + " 2)))" "" \ > + "end" This example is what makes me think that current =E2=80=98set-func=E2=80=99= callbacks are inconvenient. Ludo=E2=80=99.