From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22015 invoked by alias); 30 Jun 2010 17:30:57 -0000 Mailing-List: contact archer-help@sourceware.org; run by ezmlm Sender: Precedence: bulk List-Post: List-Help: List-Subscribe: List-Id: Received: (qmail 22002 invoked by uid 22791); 30 Jun 2010 17:30:56 -0000 X-SWARE-Spam-Status: No, hits=-5.9 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org From: Tom Tromey To: Project Archer Subject: python and structured output Reply-To: Tom Tromey Date: Wed, 30 Jun 2010 17:30:00 -0000 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-SW-Source: 2010-q2/txt/msg00063.txt.bz2 I've been thinking for a while about a way to reuse the ui_out machinery in gdb to get structured Python objects as output from gdb commands. This in itself is easy enough to do, but documenting it seems hard. I recently hit on the idea of reusing MI commands -- and thus MI documentation -- do accomplish this. The full plan would be something like this: * Write a new ui_out object that creates Python objects. * Make a few new Python modules: gdb.mi1, gdb.mi2, gdb.mi3 (and an alias gdb.mi). Each module would export all the relevant MI commands to Python. The commands would have to be renamed a little, to account for MI/Python syntax differences. * All the functions would share a single implementation, which would convert its arguments to strings, install a new python ui_out object, and then call the underlying MI command. It is possible that we'd need some changes in the MI code to make this as nice as possible. I am not sure. * Ideally we would not have to register all these new Python commands ahead-of-time, but rather do lookups on demand. I think we'd still need some kind of event module, a la Oguz's work, to deal with inferior state changes. This approach is not quite as nice as custom API for each module -- and we would still need that in places -- but it would open up a lot more of gdb with little effort. Tom