This is the mail archive of the gdb@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Python API: can I make new prefix Parameters?


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]