Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Armando Miraglia <arma2ff0@gmail.com>
To: Evan Driscoll <evaned@gmail.com>
Cc: gdb@sourceware.org
Subject: Re: Python API: can I make new prefix Parameters?
Date: Thu, 23 Jul 2015 15:55:00 -0000	[thread overview]
Message-ID: <CAOcbMd3t1xcXjHEM9qQvHkYmHDox5Uj_7VMEO0t1cXjdOzWxKQ@mail.gmail.com> (raw)
In-Reply-To: <CAAR9PsW9zcMcpB19S6qKajd9Wjot13bpsZ+_1ya13qweQDT36w@mail.gmail.com>

Sorry, I did not reply to the list as well, hence I am writing this again.

On Thu, Jul 23, 2015 at 4:26 PM, Evan Driscoll <evaned@gmail.com> wrote:
> On Thu, Jul 23, 2015 at 6:03 AM, Armando Miraglia <arma2ff0@gmail.com> wrote:
>> Hi all, hi Evan.
>
> Hello; thanks for the response. I'll answer a little out of order.
>
>> However, I am not
>> complete sure what you need to achieve.
>>
>> Additionally, I think parameters are meant to work with commands like "set",
>> "print" & co out of the box, but if you define your own commands, you can
>> associate prefix to group of commands and whatever action to the command you
>> want the to perform.
>
> This is indeed what I want to do. I have prefix commands working (e.g.
> I can make "foo bar baz on" and "foo bar baz off" work), but I figured
> it would be nice for commands that are really just defining settings
> to go through Parameters to get things like PARAM_ENUM checking and
> registering both set/show implicitly. (I can define set and show
> Commands explicitly it seems that would have the same interface to the
> user as a Parameter.)
>
>
>> I believe that the main reason for "print test-param" to work is that
>> "print" is actually a command, not a parameter.
>
> That was probably a bad choice of prefix to use; I think that's a red
> herring, because there's also a "print" category of settings (e.g.
> 'set print object' or 'set print pretty'). For example, with the
> Parameter below, I can do this:
>
> (gdb) show history test-param
> Test doc (show) one
> (gdb) set history test-param three
> Test doc (set)
> (gdb) show history test-param
> Test doc (show) three
>
> but again, I can't figure out how to define my own equivalent to "history".

Again, this is a command :)

try "help show" and "help show history" and you will see that history
is, in fact a command  with its own subcommands (expansion, filename,
save, size), and not a parameter. If you do the same with the
variations of "set print" you provided above,  you can see that "set
print" is also a command, namely print, in this case, is a sub command
of set. To have your own type of "set history" you should do something
like this:

class MyHistory(gdb.Command):
  def __init__(self):
    super(MyHistory, self).__init__("set myhistory", COMMAND_DATA)

  def invoke(self, arg, from_tty):
    # use arg to extract the parameter name and check
    # if it maches your TestParameter name for example, and
    # act on it accordingly. In can also simply use your command
    # as a proxy using parse_and_eval or execute, hence eventually
    # executing "set testparam" instead of "set myhistory testparam"
    pass

I hope this was helpful.

My 2 cents :)
Armando


  reply	other threads:[~2015-07-23 15:55 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CAAR9PsX2CMoAF7PThZd3R-FSsUtu-UQMQ1Rr-1yfasb7w==JnQ@mail.gmail.com>
     [not found] ` <CAOcbMd3sqfrJogM4jd3=vtvYbZM-QkWCJ8W5inUuJ15ow9sOJQ@mail.gmail.com>
2015-07-23 14:26   ` Evan Driscoll
2015-07-23 15:55     ` Armando Miraglia [this message]
2015-07-23 16:09       ` Evan Driscoll
2015-07-23 16:17         ` Evan Driscoll
     [not found]           ` <CAOcbMd1ULBBHSsM-b2HEuZhfZFSu95mjSRvEhyMwtaU9Y2DEgg@mail.gmail.com>
2015-07-23 17:55             ` Evan Driscoll

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAOcbMd3t1xcXjHEM9qQvHkYmHDox5Uj_7VMEO0t1cXjdOzWxKQ@mail.gmail.com \
    --to=arma2ff0@gmail.com \
    --cc=evaned@gmail.com \
    --cc=gdb@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox