From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17421 invoked by alias); 2 Aug 2012 15:35:07 -0000 Received: (qmail 17308 invoked by uid 22791); 2 Aug 2012 15:35:06 -0000 X-SWARE-Spam-Status: No, hits=-8.6 required=5.0 tests=AWL,BAYES_00,KHOP_PGP_SIGNED,KHOP_RCVD_UNTRUST,KHOP_THREADED,RCVD_IN_DNSWL_HI,RCVD_IN_HOSTKARMA_W,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from smtp.gentoo.org (HELO smtp.gentoo.org) (140.211.166.183) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 02 Aug 2012 15:34:52 +0000 Received: from vapier.localnet (localhost [127.0.0.1]) by smtp.gentoo.org (Postfix) with ESMTP id DBE701B402D; Thu, 2 Aug 2012 15:34:51 +0000 (UTC) From: Mike Frysinger To: Pedro Alves Subject: Re: [patch v2] gdb: add completion handler for "handle" Date: Thu, 02 Aug 2012 15:35:00 -0000 User-Agent: KMail/1.13.7 (Linux/3.5.0; KDE/4.6.5; x86_64; ; ) Cc: gdb-patches@sourceware.org References: <201208012353.56496.vapier@gentoo.org> <201208012358.18948.vapier@gentoo.org> <501A6357.4070503@redhat.com> In-Reply-To: <501A6357.4070503@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="nextPart34485554.c9jT2oT5Oq"; protocol="application/pgp-signature"; micalg=pgp-sha1 Content-Transfer-Encoding: 7bit Message-Id: <201208021134.51757.vapier@gentoo.org> X-IsSubscribed: yes 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 X-SW-Source: 2012-08/txt/msg00068.txt.bz2 --nextPart34485554.c9jT2oT5Oq Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-length: 3543 On Thursday 02 August 2012 07:24:07 Pedro Alves wrote: > On 08/02/2012 04:58 AM, Mike Frysinger wrote: > > +VEC (char_ptr) * > > +string_array_completer (struct cmd_list_element *ignore, > > + char *text, char *word, const char * const strings[], > > + size_t num_strings) > > +{ > > + size_t i; > > + VEC (char_ptr) *return_val =3D NULL; > > + size_t len =3D strlen (word); > > + > > + for (i =3D 0; i < num_strings; ++i) > > + { > > + if (strncasecmp (strings[i], word, len) =3D=3D 0) > > + VEC_safe_push (char_ptr, return_val, xstrdup (strings[i])); > > + } > > + > > + return return_val; > > +} >=20 > See complete_on_enum. hrm, i was only looking in completer.h. i don't suppose there's a central= =20 place for these APIs ? or is that expecting too much ? ;) also, i think this function is broken. when i try to call it, i have: text =3D "SIGINT a" word =3D "a" instead of completing "a" into "all", it tries to complete "SIGINT a" and s= o=20 returns no matches. i'd have to lie and pass it (word, word) instead of=20 (text, word) ... > > +/* Complete the "handle" command. */ > > + > > +static VEC (char_ptr) * > > +handle_completer (struct cmd_list_element *ignore, > > + char *text, char *word) > > +{ > > + /* First word is a signal, while the rest are keywords. */ >=20 > Actually, "handle" accepts more than one signal. E.g., ok, but that's not what the documentation says: http://sourceware.org/gdb/current/onlinedocs/gdb/Signals.html handle signal [keywords...] Change the way gdb handles signal signal. signal can be the number of a=20 signal or its name (with or without the `SIG' at the beginning); a list of= =20 signal numbers of the form `low-high'; or the word `all', meaning all the=20 known signals. Optional arguments keywords, described below, say what chang= e=20 to make. guess that needs updating too > (gdb) handle SIGCANCEL SIGABRT stop > Signal Stop Print Pass to program Description > SIGABRT Yes Yes Yes Aborted > SIGCANCEL Yes Yes Yes LWP internal signal >=20 > Can we make that work? Basically, for all but the first arg, you'd > accept the union of the signal names, and the possible actions. is there a VEC_safe_merge helper ? i didn't see anything in common/vec.h. = if=20 there was, then it should be easy to make this work. > > - add_com ("handle", class_run, handle_command, _("\ > > -Specify how to handle a signal.\n\ > > + c =3D add_com ("handle", class_run, handle_command, _("\ > > +Handle signals: handle SIGNAL [KEYWORDS]\n\ > >=20 > > Args are signals and actions to apply to those signals.\n\ >=20 > The first line of the doc is special. It's what "apropos" shows. ok ... > before: > (gdb) apropos signals > handle -- Specify how to handle a signal > info handle -- What debugger does when program gets various signals > info signals -- What debugger does when program gets various signals >=20 > after: > (gdb) apropos signals > handle -- Handle signals: handle SIGNAL [KEYWORDS] > info handle -- What debugger does when program gets various signals > info signals -- What debugger does when program gets various signals >=20 > The old strings looked better here to me. it does. i was just trying to improve the `help handle` output since it (p= lus=20 `help signal`) suck atm. it's really information dense and hard to pick ou= t=20 anything quickly. > This and the "signal" docu change are a bit of a tangent wrt completion, > so split them out, please. np -mike --nextPart34485554.c9jT2oT5Oq Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part. Content-length: 836 -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.17 (GNU/Linux) iQIcBAABAgAGBQJQGp4bAAoJEEFjO5/oN/WBaqoP/ifzpAdR84QwMk+tSM2haFny kyX7huXmpre3Iex+eFvPepZoKb7gxEPNLhtXd1URMqskkaiktYx96fKVKrSX+861 0qhSa9FGDrMxL4GC0DvhNF/r2amI4jdWY/sQ+V2vwwFjb9jX7VJGWussbI+8oA5s lgeM/1+/GiHdyMEH1s+Il9kLA8mTqmk81X39DkWXQa23JPLIZJqMY1cjWpbsVVPo aa6TdELGLLIK3RgLQNQd1c0iVxvFg/1csxt0AIQ1GL1S50Ay4+A9ABod+hplo/Sj xkSvcfu6LrC97n1jX5nfoXdCR5Q0Bcr3ToyOfKfiOcjjU+NOzFgcaPd3u1zUBsoB WerXDjdLCHUSnvXGaoLcfmRq6GTKh491tRtnfJHddMyhrhXIGhHqd6XZIIONV950 vFWn/NvKTSxL+yAGdmhmH1aZQBHliuZVPfD2oSnOySDCKezXfKGsAcNUnfPDLxI5 Z4Xk8ffneBaouVKKTSz50DzMhzoSLZg6jzWXEMbPLYza8MQ6P/r9Ynf3hEz6WBtE pRBJiCw9ZdesFKZHaKrSEAmiPSnlPa7KJCjvq2G0P5w4uWZSI1vgM66BmKJBHB8k EwB/bB6/eBex/MX6JX3BKqSs3YNbw4AgTLt6252LXoQK0Fv1ihIny1vH60WI/KUa dHhRe6H7LbyKCo2sdDGj =aaO+ -----END PGP SIGNATURE----- --nextPart34485554.c9jT2oT5Oq--