Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* Re: starting gdb/mi from FE
@ 2006-06-06  0:55 Nick Roberts
  2006-06-06  1:20 ` Daniel Jacobowitz
  2006-06-06  1:33 ` Bob Rossi
  0 siblings, 2 replies; 22+ messages in thread
From: Nick Roberts @ 2006-06-06  0:55 UTC (permalink / raw)
  To: Bob Rossi; +Cc: gdb-patches

> $ ./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.

Backward compatible because it won't work with any version before GDB 6.5?

> How does this look?

I can't remember the previous outcome (I got lost with all the handshakes) but
I would prefer an MI command, -mi-version say, that the FE could use.  It
could have a major and minor part: the major number to refer to the default MI
level; and the minor to help identify small changes made within one level.  Of
course, we'd have to remember to update it, when appropriate.

Pre GDB 6.5 wouldn't really work in this case either, but

  (gdb)
  -mi-version
  ^error,msg="Undefined MI command: mi-version"
  (gdb)

wouldn't require restarting GDB, while:

  nickrob/21 gdb -i=mi2,mi1 myprog
  Interpreter `mi2,mi1' unrecognized
  nickrob/22

would.

-- 
Nick                                           http://www.inet.net.nz/~nickrob


^ permalink raw reply	[flat|nested] 22+ messages in thread
* starting gdb/mi from FE
@ 2006-06-05 13:45 Bob Rossi
  2006-06-05 19:56 ` Eli Zaretskii
  2006-06-05 19:59 ` Daniel Jacobowitz
  0 siblings, 2 replies; 22+ messages in thread
From: Bob Rossi @ 2006-06-05 13:45 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 1377 bytes --]

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

[-- Attachment #2: mi_protocol_ver.diff --]
[-- Type: text/plain, Size: 2098 bytes --]

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

^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2006-06-06 17:41 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-06-06  0:55 starting gdb/mi from FE Nick Roberts
2006-06-06  1:20 ` Daniel Jacobowitz
2006-06-06  1:56   ` Bob Rossi
2006-06-06  3:16     ` Daniel Jacobowitz
2006-06-06  2:03   ` Nick Roberts
2006-06-06  2:04     ` Bob Rossi
2006-06-06 17:22     ` Jim Ingham
2006-06-06 17:30       ` Daniel Jacobowitz
2006-06-06 17:41         ` Jim Ingham
2006-06-06  1:33 ` Bob Rossi
2006-06-06  1:56   ` Nick Roberts
2006-06-06  2:01     ` Bob Rossi
2006-06-06  2:30       ` Nick Roberts
  -- strict thread matches above, loose matches on Subject: below --
2006-06-05 13:45 Bob Rossi
2006-06-05 19:56 ` Eli Zaretskii
2006-06-05 19:58   ` Bob Rossi
2006-06-05 20:23     ` Eli Zaretskii
2006-06-05 21:25   ` Daniel Jacobowitz
2006-06-05 21:28     ` Bob Rossi
2006-06-06  3:44     ` Eli Zaretskii
2006-06-05 19:59 ` Daniel Jacobowitz
2006-06-05 20:49   ` Bob Rossi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox