From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 59091 invoked by alias); 23 Jul 2015 14:26:49 -0000 Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org Received: (qmail 59076 invoked by uid 89); 23 Jul 2015 14:26:48 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-ig0-f172.google.com Received: from mail-ig0-f172.google.com (HELO mail-ig0-f172.google.com) (209.85.213.172) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Thu, 23 Jul 2015 14:26:47 +0000 Received: by iggf3 with SMTP id f3so160549300igg.1 for ; Thu, 23 Jul 2015 07:26:45 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.107.164.38 with SMTP id n38mr14241807ioe.73.1437661605717; Thu, 23 Jul 2015 07:26:45 -0700 (PDT) Received: by 10.107.154.199 with HTTP; Thu, 23 Jul 2015 07:26:45 -0700 (PDT) In-Reply-To: References: Date: Thu, 23 Jul 2015 14:26:00 -0000 Message-ID: Subject: Re: Python API: can I make new prefix Parameters? From: Evan Driscoll To: Armando Miraglia Cc: gdb@sourceware.org Content-Type: text/plain; charset=UTF-8 X-SW-Source: 2015-07/txt/msg00033.txt.bz2 On Thu, Jul 23, 2015 at 6:03 AM, Armando Miraglia 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