From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21661 invoked by alias); 24 Nov 2011 23:15:12 -0000 Received: (qmail 21649 invoked by uid 22791); 24 Nov 2011 23:15:11 -0000 X-SWARE-Spam-Status: No, hits=-1.4 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 24 Nov 2011 23:14:57 +0000 Received: from svr-orw-exc-10.mgc.mentorg.com ([147.34.98.58]) by relay1.mentorg.com with esmtp id 1RTiVL-0001wX-Ui from Kwok_Yeung@mentor.com ; Thu, 24 Nov 2011 15:14:55 -0800 Received: from SVR-IES-FEM-01.mgc.mentorg.com ([137.202.0.104]) by SVR-ORW-EXC-10.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.4675); Thu, 24 Nov 2011 15:11:47 -0800 Received: from [0.0.0.0] (137.202.0.76) by SVR-IES-FEM-01.mgc.mentorg.com (137.202.0.104) with Microsoft SMTP Server id 14.1.289.1; Thu, 24 Nov 2011 23:14:53 +0000 Message-ID: <4ECECFEB.8020807@codesourcery.com> Date: Thu, 24 Nov 2011 23:15:00 -0000 From: Kwok Cheung Yeung User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:8.0) Gecko/20111105 Thunderbird/8.0 MIME-Version: 1.0 To: Tom Tromey CC: Subject: Re: [PATCH] Add the "-info-os" command to MI References: <4E970915.8000207@codesourcery.com> In-Reply-To: Content-Type: multipart/mixed; boundary="------------090508040904070205010406" Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2011-11/txt/msg00690.txt.bz2 --------------090508040904070205010406 Content-Type: text/plain; charset="ISO-8859-1"; format=flowed Content-Transfer-Encoding: 7bit Content-length: 1018 On 21/10/2011 9:39 PM, Tom Tromey wrote: >>>>>> ">" == Kwok Cheung Yeung writes: > >>> + { "info-os", { "info os", 1 }, NULL }, > > I'd prefer a new function specific to MI to do the command-line parsing. > > I think this approach should be deprecated and that no new instances go > into the tree. They unnecessarily link MI to the CLI, making it harder > to change the CLI. > > Tom I've now created a new mi_cmd_info_os function to service -info-os, which delegates to info_osdata_command in osdata.c. This is the same backend that 'info os' in the CLI uses, but at least now we don't go through the CLI code. info_osdata_command now needs to be non-static. Kwok ChangeLog: gdb/ * Makefile.in (SUBDIR_MI_OBS): Add mi-cmd-info.o. (SUBDIR_MI_SRCS): Add mi-cmd-info.c. (mi-cmd-info.o): New rule. * osdata.h: Add declaration for info_osdata_command. * osdata.c (info_osdata_command): Change to non-static. * mi/mi-cmds.c (mi_cmds): Add -info-os MI command. * mi/mi-cmd-info.c: New. --------------090508040904070205010406 Content-Type: text/plain; name="mi_info-os.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="mi_info-os.patch" Content-length: 4467 Index: gdb/Makefile.in =================================================================== RCS file: /cvs/src/src/gdb/Makefile.in,v retrieving revision 1.1178 diff -u -p -r1.1178 Makefile.in --- gdb/Makefile.in 20 Nov 2011 08:59:56 -0000 1.1178 +++ gdb/Makefile.in 24 Nov 2011 23:12:41 -0000 @@ -207,6 +207,7 @@ SUBDIR_MI_OBS = \ mi-out.o mi-console.o \ mi-cmds.o mi-cmd-env.o mi-cmd-var.o mi-cmd-break.o mi-cmd-stack.o \ mi-cmd-file.o mi-cmd-disas.o mi-symbol-cmds.o mi-cmd-target.o \ + mi-cmd-info.o \ mi-interp.o \ mi-main.o mi-parse.o mi-getopt.o SUBDIR_MI_SRCS = \ @@ -214,7 +215,8 @@ SUBDIR_MI_SRCS = \ mi/mi-cmds.c mi/mi-cmd-env.c \ mi/mi-cmd-var.c mi/mi-cmd-break.c mi/mi-cmd-stack.c \ mi/mi-cmd-file.c mi/mi-cmd-disas.c mi/mi-symbol-cmds.c \ - mi/mi-cmd-target.c mi/mi-interp.c \ + mi/mi-cmd-target.c mi/mi-cmd-info.c \ + mi/mi-interp.c \ mi/mi-main.c mi/mi-parse.c mi/mi-getopt.c SUBDIR_MI_DEPS = SUBDIR_MI_LDFLAGS= @@ -1896,6 +1898,10 @@ mi-cmd-file.o: $(srcdir)/mi/mi-cmd-file. $(COMPILE) $(srcdir)/mi/mi-cmd-file.c $(POSTCOMPILE) +mi-cmd-info.o: $(srcdir)/mi/mi-cmd-info.c + $(COMPILE) $(srcdir)/mi/mi-cmd-info.c + $(POSTCOMPILE) + mi-cmds.o: $(srcdir)/mi/mi-cmds.c $(COMPILE) $(srcdir)/mi/mi-cmds.c $(POSTCOMPILE) Index: gdb/osdata.c =================================================================== RCS file: /cvs/src/src/gdb/osdata.c,v retrieving revision 1.13 diff -u -p -r1.13 osdata.c --- gdb/osdata.c 21 Nov 2011 16:54:28 -0000 1.13 +++ gdb/osdata.c 24 Nov 2011 23:12:41 -0000 @@ -288,7 +288,7 @@ get_osdata_column (struct osdata_item *i return NULL; } -static void +void info_osdata_command (char *type, int from_tty) { struct ui_out *uiout = current_uiout; Index: gdb/osdata.h =================================================================== RCS file: /cvs/src/src/gdb/osdata.h,v retrieving revision 1.5 diff -u -p -r1.5 osdata.h --- gdb/osdata.h 1 Jan 2011 15:33:12 -0000 1.5 +++ gdb/osdata.h 24 Nov 2011 23:12:41 -0000 @@ -49,5 +49,6 @@ void osdata_free (struct osdata *); struct cleanup *make_cleanup_osdata_free (struct osdata *data); struct osdata *get_osdata (const char *type); const char *get_osdata_column (struct osdata_item *item, const char *name); +void info_osdata_command (char *type, int from_tty); #endif /* OSDATA_H */ Index: gdb/mi/mi-cmds.c =================================================================== RCS file: /cvs/src/src/gdb/mi/mi-cmds.c,v retrieving revision 1.57 diff -u -p -r1.57 mi-cmds.c --- gdb/mi/mi-cmds.c 3 Oct 2011 21:38:31 -0000 1.57 +++ gdb/mi/mi-cmds.c 24 Nov 2011 23:12:41 -0000 @@ -90,6 +90,7 @@ struct mi_cmd mi_cmds[] = { "gdb-version", { "show version", 0 }, 0 }, { "inferior-tty-set", { NULL, 0 }, mi_cmd_inferior_tty_set}, { "inferior-tty-show", { NULL, 0 }, mi_cmd_inferior_tty_show}, + { "info-os", { NULL, 0 }, mi_cmd_info_os}, { "interpreter-exec", { NULL, 0 }, mi_cmd_interpreter_exec}, { "list-features", { NULL, 0 }, mi_cmd_list_features}, { "list-target-features", { NULL, 0 }, mi_cmd_list_target_features}, Index: gdb/mi/mi-cmd-info.c =================================================================== RCS file: gdb/mi/mi-cmd-info.c diff -N gdb/mi/mi-cmd-info.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ gdb/mi/mi-cmd-info.c 24 Nov 2011 23:12:41 -0000 @@ -0,0 +1,37 @@ +/* MI Command Set - information commands. + Copyright (C) 2011 Free Software Foundation, Inc. + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#include "defs.h" +#include "osdata.h" + +void +mi_cmd_info_os (char *command, char **argv, int argc) +{ + switch (argc) + { + case 0: + info_osdata_command ("", 0); + break; + case 1: + info_osdata_command (argv [0], 0); + break; + default: + error (_("-info-os: Usage: [INFOTYPE]")); + break; + } +} --------------090508040904070205010406--