Re: Python API: can I make new prefix Parameters?
Evan Driscoll <[email protected]>
| Newsgroups | gmane.comp.gdb.devel |
|---|---|
| Message-ID | <CAAR9PsW9zcMcpB19S6qKajd9Wjot13bpsZ+_1ya13qweQDT36w@mail.gmail.com> |
On Thu, Jul 23, 2015 at 6:03 AM, Armando Miraglia <[email protected]> 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