Python API: can I make new prefix Parameters?

Evan Driscoll <[email protected]>
Newsgroups gmane.comp.gdb.devel
Message-ID <CAAR9PsX2CMoAF7PThZd3R-FSsUtu-UQMQ1Rr-1yfasb7w==JnQ@mail.gmail.com>
I'd like to make some settings divided into buckets with prefix
commands. I've included one such attempt below and have tried a bunch
of variants on it, but I just get the error "RuntimeError: 'test-pfx'
is not a prefix command." when it gets loaded by GDB. (I've even tried
adding a prefix Command with the name test-pfx to no avail.)

What I *can* do is add a new Parameter to an existing prefix, e.g. I
can make a 'print test-param' Parameter that seems to do what I want.
Maybe what I want isn't possible under the current API?

Here is my test program:

import gdb

class Prefix(gdb.Parameter):
    """The Prefix"""
    def __init__(self):
        super(Prefix, self).__init__(
            "test-pfx",
            gdb.COMMAND_DATA,
            gdb.PARAM_AUTO_BOOLEAN)

pfx = Prefix()


class TestParameter(gdb.Parameter):
    """The Parameter"""
    def __init__(self):
        super(TestParameter, self).__init__(
            "test-pfx test-param",
            gdb.COMMAND_DATA,
            gdb.PARAM_ENUM,
            ["one", "two", "three"])
        self.value = "one"

param = TestParameter()

(Changing "test-pfx test-param" to "print test-param", as I mentioned
above, makes it work.)

Thanks,
Evan
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.