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

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".

Here's that Parameter:
class TestParameter(gdb.Parameter):
    """The Parameter"""
    def __init__(self):
        super(TestParameter, self).__init__(
            "history test-param",
            gdb.COMMAND_DATA,
            gdb.PARAM_ENUM,
            ["one", "two", "three"])
        self.value = "one"
        self.set_doc = "Test doc (set)"
        self.show_doc = "Test doc (show)"

param = TestParameter()

Evan


       reply	other threads:[~2015-07-23 14:26 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 [this message]
2015-07-23 15:55     ` Armando Miraglia
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=CAAR9PsW9zcMcpB19S6qKajd9Wjot13bpsZ+_1ya13qweQDT36w@mail.gmail.com \
    --to=evaned@gmail.com \
    --cc=arma2ff0@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