From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11253 invoked by alias); 5 Jun 2006 13:45:18 -0000 Received: (qmail 11243 invoked by uid 22791); 5 Jun 2006 13:45:18 -0000 X-Spam-Check-By: sourceware.org Received: from eastrmmtao05.cox.net (HELO eastrmmtao05.cox.net) (68.230.240.34) by sourceware.org (qpsmtpd/0.31) with ESMTP; Mon, 05 Jun 2006 13:45:15 +0000 Received: from localhost.localdomain ([68.9.66.48]) by eastrmmtao05.cox.net (InterMail vM.6.01.06.01 201-2131-130-101-20060113) with ESMTP id <20060605134512.LUQP26910.eastrmmtao05.cox.net@localhost.localdomain> for ; Mon, 5 Jun 2006 09:45:12 -0400 Received: from bob by localhost.localdomain with local (Exim 4.60) (envelope-from ) id 1FnFOP-00071c-It for gdb-patches@sources.redhat.com; Mon, 05 Jun 2006 09:45:17 -0400 Date: Mon, 05 Jun 2006 13:45:00 -0000 From: Bob Rossi To: gdb-patches@sources.redhat.com Subject: starting gdb/mi from FE Message-ID: <20060605134517.GA25925@brasko.net> Mail-Followup-To: gdb-patches@sources.redhat.com MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="5vNYLRcllDrimb99" Content-Disposition: inline User-Agent: Mutt/1.5.11 X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2006-06/txt/msg00032.txt.bz2 --5vNYLRcllDrimb99 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 1377 Hi, I have an issue that will eventually come up in regards to starting GDB from a front end. Choosing the correct interpreter that GDB supports could be potentially non trivial, requiring several starts of GDB. Currently, for each version of mi that the FE supports, it will have to start GDB to see if it supports that version of the protocol. As the list of MI protocol versions get's longer, this action get's longer and longer. It would be good to solve this problem as early as possible for obvious reasons. Attached below is a patch that modified GDB so that it can accept the -i flag as a comma sepearated list like shown below: $ ./gdb/gdb -q -i=mi ./main ~"Using host libthread_db library \"/lib/tls/i686/cmov/libthread_db.so.1\".\n" (gdb) $ ./gdb/gdb -q -i=mi4,mi3 ./main mi_protocol_version=mi3 ~"Using host libthread_db library \"/lib/tls/i686/cmov/libthread_db.so.1\".\n" (gdb) This will allow the FE to start GDB 1 time and to determine which version of the protocol GDB was compatible with. If you have multiple interpreter choices on the -i switch, then GDB will output the first line it writes as mi_protocol_version=miN where miN will be the version GDB is going to communicate with. This change is backwards compatible because users were not able in the past to have a comma separated list in the -i flag. How does this look? Thanks, Bob Rossi --5vNYLRcllDrimb99 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="mi_protocol_ver.diff" Content-length: 2098 Index: gdb/interps.c =================================================================== RCS file: /cvs/src/src/gdb/interps.c,v retrieving revision 1.16 diff -u -r1.16 interps.c --- gdb/interps.c 17 Dec 2005 22:34:01 -0000 1.16 +++ gdb/interps.c 4 Jun 2006 23:54:14 -0000 @@ -216,16 +216,28 @@ interp_lookup (const char *name) { struct interp *interp; + char *nname = xstrdup (name); + char *token = strtok (nname, ","); - if (name == NULL || strlen (name) == 0) - return NULL; - - for (interp = interp_list; interp != NULL; interp = interp->next) + while (token) { - if (strcmp (interp->name, name) == 0) - return interp; + if (token == NULL || strlen (token) == 0) + return NULL; + + for (interp = interp_list; interp != NULL; interp = interp->next) + { + if (strcmp (interp->name, token) == 0) + { + xfree (nname); + nname = NULL; + return interp; + } + } + token = strtok (NULL, ","); } + xfree (nname); + nname = NULL; return NULL; } Index: gdb/main.c =================================================================== RCS file: /cvs/src/src/gdb/main.c,v retrieving revision 1.58 diff -u -r1.58 main.c --- gdb/main.c 21 Feb 2006 19:46:48 -0000 1.58 +++ gdb/main.c 4 Jun 2006 23:54:15 -0000 @@ -598,6 +598,7 @@ { /* Find it. */ + int multiple_interps = (strchr (interpreter_p, ',') != 0); struct interp *interp = interp_lookup (interpreter_p); if (interp == NULL) error (_("Interpreter `%s' unrecognized"), interpreter_p); @@ -609,6 +610,17 @@ interpreter_p); exit (1); } + + /* Print the mi version chosen by GDB if the user supplied multiple + options. Note that the interp_set call above replaces interpreter_p + with the value of the chosen interpreter. */ + if (multiple_interps) + { + struct ui_file *raw_stdout = stdio_fileopen (stdout); + + fprintf_unfiltered (raw_stdout, "mi_protocol_version=%s\n", interpreter_p); + } + } /* FIXME: cagney/2003-02-03: The big hack (part 2 of 2) that lets --5vNYLRcllDrimb99--