Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* Kill 'args' interface for MI commands
@ 2008-04-24 15:59 Vladimir Prus
  2008-04-24 16:02 ` Vladimir Prus
  0 siblings, 1 reply; 3+ messages in thread
From: Vladimir Prus @ 2008-04-24 15:59 UTC (permalink / raw)
  To: gdb-patches

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


Presently, each MI command is implemented with a function, but there are
two different interfaces -- old uses "char *" to pass all parameters lumped
together, while new one uses "char ** + int", like argc/argv.

This patch kills the old interface completely. Checked in.

- Volodya


[-- Attachment #2: commit.diff --]
[-- Type: text/x-diff, Size: 19058 bytes --]

Index: gdb/ChangeLog
===================================================================
RCS file: /cvs/src/src/gdb/ChangeLog,v
retrieving revision 1.9312
diff -u -p -r1.9312 ChangeLog
--- gdb/ChangeLog	24 Apr 2008 12:09:48 -0000	1.9312
+++ gdb/ChangeLog	24 Apr 2008 12:54:30 -0000
@@ -1,5 +1,12 @@
 2008-04-24  Vladimir Prus  <vladimir@codesourcery.com>
-	
+
+        * breakpoint.c (bpstat_check_location)
+        (bpstat_check_watchpoint, bpstat_check_breakpoint_conditions):
+        New, extracted from bpstat_stop_status.
+        (bpstat_stop_status): Use the above.
+
+2008-04-24  Vladimir Prus  <vladimir@codesourcery.com>
+
         * mi/mi-main.c (last_async_command): Rename to current_token.
         (previous_async_command): Remove.
         (mi_cmd_gdb_exit): Adjust.
Index: gdb/breakpoint.c
===================================================================
RCS file: /cvs/src/src/gdb/breakpoint.c,v
retrieving revision 1.313
diff -u -p -r1.313 breakpoint.c
--- gdb/breakpoint.c	24 Apr 2008 11:13:44 -0000	1.313
+++ gdb/breakpoint.c	24 Apr 2008 12:54:30 -0000
@@ -2750,6 +2750,252 @@ which its expression is valid.\n");     
     }
 }
 
+/* Return true if it looks like target has stopped due to hitting
+   breakpoint location BL.  This function does not check if we
+   should stop, only if BL explains the stop.   */
+static int
+bpstat_check_location (const struct bp_location *bl, CORE_ADDR bp_addr)
+{
+  struct breakpoint *b = bl->owner;
+
+  if (b->type != bp_watchpoint
+      && b->type != bp_hardware_watchpoint
+      && b->type != bp_read_watchpoint
+      && b->type != bp_access_watchpoint
+      && b->type != bp_hardware_breakpoint
+      && b->type != bp_catch_fork
+      && b->type != bp_catch_vfork
+      && b->type != bp_catch_exec)	/* a non-watchpoint bp */
+    {
+      if (bl->address != bp_addr) 	/* address doesn't match */
+	return 0;
+      if (overlay_debugging		/* unmapped overlay section */
+	  && section_is_overlay (bl->section) 
+	  && !section_is_mapped (bl->section))
+	return 0;
+    }
+  
+  /* Continuable hardware watchpoints are treated as non-existent if the
+     reason we stopped wasn't a hardware watchpoint (we didn't stop on
+     some data address).  Otherwise gdb won't stop on a break instruction
+     in the code (not from a breakpoint) when a hardware watchpoint has
+     been defined.  Also skip watchpoints which we know did not trigger
+     (did not match the data address).  */
+  
+  if ((b->type == bp_hardware_watchpoint
+       || b->type == bp_read_watchpoint
+       || b->type == bp_access_watchpoint)
+      && b->watchpoint_triggered == watch_triggered_no)
+    return 0;
+  
+  if (b->type == bp_hardware_breakpoint)
+    {
+      if (bl->address != bp_addr)
+	return 0;
+      if (overlay_debugging		/* unmapped overlay section */
+	  && section_is_overlay (bl->section) 
+	  && !section_is_mapped (bl->section))
+	return 0;
+    }
+  
+  /* Is this a catchpoint of a load or unload?  If so, did we
+     get a load or unload of the specified library?  If not,
+     ignore it. */
+  if ((b->type == bp_catch_load)
+#if defined(SOLIB_HAVE_LOAD_EVENT)
+      && (!SOLIB_HAVE_LOAD_EVENT (PIDGET (inferior_ptid))
+	  || ((b->dll_pathname != NULL)
+	      && (strcmp (b->dll_pathname, 
+			  SOLIB_LOADED_LIBRARY_PATHNAME (
+			    PIDGET (inferior_ptid)))
+		  != 0)))
+#endif
+      )
+    return 0;
+  
+  if ((b->type == bp_catch_unload)
+#if defined(SOLIB_HAVE_UNLOAD_EVENT)
+      && (!SOLIB_HAVE_UNLOAD_EVENT (PIDGET (inferior_ptid))
+	  || ((b->dll_pathname != NULL)
+	      && (strcmp (b->dll_pathname, 
+			  SOLIB_UNLOADED_LIBRARY_PATHNAME (
+			    PIDGET (inferior_ptid)))
+		  != 0)))
+#endif
+      )
+    return 0;
+
+  if ((b->type == bp_catch_fork)
+      && !inferior_has_forked (PIDGET (inferior_ptid),
+			       &b->forked_inferior_pid))
+    return 0;
+  
+  if ((b->type == bp_catch_vfork)
+      && !inferior_has_vforked (PIDGET (inferior_ptid),
+				&b->forked_inferior_pid))
+    return 0;
+  
+  if ((b->type == bp_catch_exec)
+      && !inferior_has_execd (PIDGET (inferior_ptid), &b->exec_pathname))
+    return 0;
+
+  return 1;
+}
+
+/* If BS refers to a watchpoint, determine if the watched values
+   has actually changed, and we should stop.  If not, set BS->stop
+   to 0.  */
+static void
+bpstat_check_watchpoint (bpstat bs)
+{
+  const struct bp_location *bl = bs->breakpoint_at;
+  struct breakpoint *b = bl->owner;
+
+  if (b->type == bp_watchpoint
+      || b->type == bp_read_watchpoint
+      || b->type == bp_access_watchpoint
+      || b->type == bp_hardware_watchpoint)
+    {
+      CORE_ADDR addr;
+      struct value *v;
+      int must_check_value = 0;
+      
+      if (b->type == bp_watchpoint)
+	/* For a software watchpoint, we must always check the
+	   watched value.  */
+	must_check_value = 1;
+      else if (b->watchpoint_triggered == watch_triggered_yes)
+	/* We have a hardware watchpoint (read, write, or access)
+	   and the target earlier reported an address watched by
+	   this watchpoint.  */
+	must_check_value = 1;
+      else if (b->watchpoint_triggered == watch_triggered_unknown
+	       && b->type == bp_hardware_watchpoint)
+	/* We were stopped by a hardware watchpoint, but the target could
+	   not report the data address.  We must check the watchpoint's
+	   value.  Access and read watchpoints are out of luck; without
+	   a data address, we can't figure it out.  */
+	must_check_value = 1;
+      
+      if (must_check_value)
+	{
+	  char *message = xstrprintf ("Error evaluating expression for watchpoint %d\n",
+				      b->number);
+	  struct cleanup *cleanups = make_cleanup (xfree, message);
+	  int e = catch_errors (watchpoint_check, bs, message,
+				RETURN_MASK_ALL);
+	  do_cleanups (cleanups);
+	  switch (e)
+	    {
+	    case WP_DELETED:
+	      /* We've already printed what needs to be printed.  */
+	      bs->print_it = print_it_done;
+	      /* Stop.  */
+	      break;
+	    case WP_VALUE_CHANGED:
+	      if (b->type == bp_read_watchpoint)
+		{
+		  /* Don't stop: read watchpoints shouldn't fire if
+		     the value has changed.  This is for targets
+		     which cannot set read-only watchpoints.  */
+		  bs->print_it = print_it_noop;
+		  bs->stop = 0;
+		}
+	      break;
+	    case WP_VALUE_NOT_CHANGED:
+	      if (b->type == bp_hardware_watchpoint
+		  || b->type == bp_watchpoint)
+		{
+		  /* Don't stop: write watchpoints shouldn't fire if
+		     the value hasn't changed.  */
+		  bs->print_it = print_it_noop;
+		  bs->stop = 0;
+		}
+	      /* Stop.  */
+	      break;
+	    default:
+	      /* Can't happen.  */
+	    case 0:
+	      /* Error from catch_errors.  */
+	      printf_filtered (_("Watchpoint %d deleted.\n"), b->number);
+	      if (b->related_breakpoint)
+		b->related_breakpoint->disposition = disp_del_at_next_stop;
+	      b->disposition = disp_del_at_next_stop;
+	      /* We've already printed what needs to be printed.  */
+	      bs->print_it = print_it_done;
+	      break;
+	    }
+	}
+      else	/* must_check_value == 0 */
+	{
+	  /* This is a case where some watchpoint(s) triggered, but
+	     not at the address of this watchpoint, or else no
+	     watchpoint triggered after all.  So don't print
+	     anything for this watchpoint.  */
+	  bs->print_it = print_it_noop;
+	  bs->stop = 0;
+	}
+    }
+}
+
+
+/* Check conditions (condition proper, frame, thread and ignore count)
+   of breakpoint referred to by BS.  If we should not stop for this
+   breakpoint, set BS->stop to 0.  */
+static void
+bpstat_check_breakpoint_conditions (bpstat bs, ptid_t ptid)
+{
+  int thread_id = pid_to_thread_id (ptid);
+  const struct bp_location *bl = bs->breakpoint_at;
+  struct breakpoint *b = bl->owner;
+
+  if (frame_id_p (b->frame_id)
+      && !frame_id_eq (b->frame_id, get_frame_id (get_current_frame ())))
+    bs->stop = 0;
+  else if (bs->stop)
+    {
+      int value_is_zero = 0;
+      
+      /* If this is a scope breakpoint, mark the associated
+	 watchpoint as triggered so that we will handle the
+	 out-of-scope event.  We'll get to the watchpoint next
+	 iteration.  */
+      if (b->type == bp_watchpoint_scope)
+	b->related_breakpoint->watchpoint_triggered = watch_triggered_yes;
+      
+      if (bl->cond && bl->owner->disposition != disp_del_at_next_stop)
+	{
+	  /* Need to select the frame, with all that implies
+	     so that the conditions will have the right context.  */
+	  select_frame (get_current_frame ());
+	  value_is_zero
+	    = catch_errors (breakpoint_cond_eval, (bl->cond),
+			    "Error in testing breakpoint condition:\n",
+			    RETURN_MASK_ALL);
+	  /* FIXME-someday, should give breakpoint # */
+	  free_all_values ();
+	}
+      if (bl->cond && value_is_zero)
+	{
+	  bs->stop = 0;
+	}
+      else if (b->thread != -1 && b->thread != thread_id)
+	{
+	  bs->stop = 0;
+	}
+      else if (b->ignore_count > 0)
+	{
+	  b->ignore_count--;
+	  annotate_ignore_count_change ();
+	  bs->stop = 0;
+	  /* Increase the hit count even though we don't
+	     stop.  */
+	  ++(b->hit_count);
+	}	
+    }
+}
+
+
 /* Get a bpstat associated with having just stopped at address
    BP_ADDR in thread PTID.
 
@@ -2776,7 +3022,6 @@ bpstat_stop_status (CORE_ADDR bp_addr, p
   struct bpstats root_bs[1];
   /* Pointer to the last thing in the chain currently.  */
   bpstat bs = root_bs;
-  int thread_id = pid_to_thread_id (ptid);
 
   ALL_BP_LOCATIONS (bl)
   {
@@ -2785,87 +3030,6 @@ bpstat_stop_status (CORE_ADDR bp_addr, p
     if (!breakpoint_enabled (b) && b->enable_state != bp_permanent)
       continue;
 
-    if (b->type != bp_watchpoint
-	&& b->type != bp_hardware_watchpoint
-	&& b->type != bp_read_watchpoint
-	&& b->type != bp_access_watchpoint
-	&& b->type != bp_hardware_breakpoint
-	&& b->type != bp_catch_fork
-	&& b->type != bp_catch_vfork
-	&& b->type != bp_catch_exec)	/* a non-watchpoint bp */
-      {
-	if (bl->address != bp_addr) 	/* address doesn't match */
-	  continue;
-	if (overlay_debugging		/* unmapped overlay section */
-	    && section_is_overlay (bl->section) 
-	    && !section_is_mapped (bl->section))
-	  continue;
-      }
-
-    /* Continuable hardware watchpoints are treated as non-existent if the
-       reason we stopped wasn't a hardware watchpoint (we didn't stop on
-       some data address).  Otherwise gdb won't stop on a break instruction
-       in the code (not from a breakpoint) when a hardware watchpoint has
-       been defined.  Also skip watchpoints which we know did not trigger
-       (did not match the data address).  */
-
-    if ((b->type == bp_hardware_watchpoint
-	 || b->type == bp_read_watchpoint
-	 || b->type == bp_access_watchpoint)
-	&& b->watchpoint_triggered == watch_triggered_no)
-      continue;
-
-    if (b->type == bp_hardware_breakpoint)
-      {
-	if (bl->address != bp_addr)
-	  continue;
-	if (overlay_debugging		/* unmapped overlay section */
-	    && section_is_overlay (bl->section) 
-	    && !section_is_mapped (bl->section))
-	  continue;
-      }
-
-    /* Is this a catchpoint of a load or unload?  If so, did we
-       get a load or unload of the specified library?  If not,
-       ignore it. */
-    if ((b->type == bp_catch_load)
-#if defined(SOLIB_HAVE_LOAD_EVENT)
-	&& (!SOLIB_HAVE_LOAD_EVENT (PIDGET (inferior_ptid))
-	    || ((b->dll_pathname != NULL)
-		&& (strcmp (b->dll_pathname, 
-			    SOLIB_LOADED_LIBRARY_PATHNAME (
-			      PIDGET (inferior_ptid)))
-		    != 0)))
-#endif
-      )
-      continue;
-
-    if ((b->type == bp_catch_unload)
-#if defined(SOLIB_HAVE_UNLOAD_EVENT)
-	&& (!SOLIB_HAVE_UNLOAD_EVENT (PIDGET (inferior_ptid))
-	    || ((b->dll_pathname != NULL)
-		&& (strcmp (b->dll_pathname, 
-			    SOLIB_UNLOADED_LIBRARY_PATHNAME (
-			      PIDGET (inferior_ptid)))
-		    != 0)))
-#endif
-      )
-      continue;
-
-    if ((b->type == bp_catch_fork)
-	&& !inferior_has_forked (PIDGET (inferior_ptid),
-				 &b->forked_inferior_pid))
-      continue;
-
-    if ((b->type == bp_catch_vfork)
-	&& !inferior_has_vforked (PIDGET (inferior_ptid),
-				  &b->forked_inferior_pid))
-      continue;
-
-    if ((b->type == bp_catch_exec)
-	&& !inferior_has_execd (PIDGET (inferior_ptid), &b->exec_pathname))
-      continue;
-
     /* For hardware watchpoints, we look only at the first location.
        The watchpoint_check function will work on entire expression,
        not the individual locations.  For read watchopints, the
@@ -2875,179 +3039,52 @@ bpstat_stop_status (CORE_ADDR bp_addr, p
     if (b->type == bp_hardware_watchpoint && bl != b->loc)
       continue;
 
+    if (!bpstat_check_location (bl, bp_addr))
+      continue;
+
     /* Come here if it's a watchpoint, or if the break address matches */
 
     bs = bpstat_alloc (bl, bs);	/* Alloc a bpstat to explain stop */
 
-    /* Watchpoints may change this, if not found to have triggered. */
+    /* Assume we stop.  Should we find watchpoint that is not actually
+       triggered, or if condition of breakpoint is false, we'll reset
+       'stop' to 0.  */
     bs->stop = 1;
     bs->print = 1;
 
-    if (b->type == bp_watchpoint
-	|| b->type == bp_read_watchpoint
-	|| b->type == bp_access_watchpoint
-	|| b->type == bp_hardware_watchpoint)
-      {
-	CORE_ADDR addr;
-	struct value *v;
-	int must_check_value = 0;
-
- 	if (b->type == bp_watchpoint)
-	  /* For a software watchpoint, we must always check the
-	     watched value.  */
-	  must_check_value = 1;
-	else if (b->watchpoint_triggered == watch_triggered_yes)
-	  /* We have a hardware watchpoint (read, write, or access)
-	     and the target earlier reported an address watched by
-	     this watchpoint.  */
-	  must_check_value = 1;
-	else if (b->watchpoint_triggered == watch_triggered_unknown
-		 && b->type == bp_hardware_watchpoint)
-	  /* We were stopped by a hardware watchpoint, but the target could
-	     not report the data address.  We must check the watchpoint's
-	     value.  Access and read watchpoints are out of luck; without
-	     a data address, we can't figure it out.  */
-	  must_check_value = 1;
-
- 	if (must_check_value)
-	  {
-	    char *message = xstrprintf ("Error evaluating expression for watchpoint %d\n",
-					b->number);
-	    struct cleanup *cleanups = make_cleanup (xfree, message);
-	    int e = catch_errors (watchpoint_check, bs, message,
-				  RETURN_MASK_ALL);
-	    do_cleanups (cleanups);
-	    switch (e)
-	      {
-	      case WP_DELETED:
-		/* We've already printed what needs to be printed.  */
-		bs->print_it = print_it_done;
-		/* Stop.  */
-		break;
-	      case WP_VALUE_CHANGED:
-		if (b->type == bp_read_watchpoint)
-		  {
-		    /* Don't stop: read watchpoints shouldn't fire if
-		       the value has changed.  This is for targets
-		       which cannot set read-only watchpoints.  */
-		    bs->print_it = print_it_noop;
-		    bs->stop = 0;
-		    continue;
-		  }
-		++(b->hit_count);
-		break;
-	      case WP_VALUE_NOT_CHANGED:
-		if (b->type == bp_hardware_watchpoint
-		    || b->type == bp_watchpoint)
-		  {
-		    /* Don't stop: write watchpoints shouldn't fire if
-		       the value hasn't changed.  */
-		    bs->print_it = print_it_noop;
-		    bs->stop = 0;
-		    continue;
-		  }
-		/* Stop.  */
-		++(b->hit_count);
-		break;
-	      default:
-		/* Can't happen.  */
-	      case 0:
-		/* Error from catch_errors.  */
-		printf_filtered (_("Watchpoint %d deleted.\n"), b->number);
-		if (b->related_breakpoint)
-		  b->related_breakpoint->disposition = disp_del_at_next_stop;
-		b->disposition = disp_del_at_next_stop;
-		/* We've already printed what needs to be printed.  */
-		bs->print_it = print_it_done;
-		break;
-	      }
-	  }
-	else	/* must_check_value == 0 */
-	  {
-	    /* This is a case where some watchpoint(s) triggered, but
-	       not at the address of this watchpoint, or else no
-	       watchpoint triggered after all.  So don't print
-	       anything for this watchpoint.  */
-	    bs->print_it = print_it_noop;
-	    bs->stop = 0;
-            continue;
-	  }
-      }
-    else
-      {
-	/* By definition, an encountered breakpoint is a triggered
-	   breakpoint. */
-	++(b->hit_count);
-      }
+    bpstat_check_watchpoint (bs);
+    if (!bs->stop)
+      continue;
 
-    if (frame_id_p (b->frame_id)
-	&& !frame_id_eq (b->frame_id, get_frame_id (get_current_frame ())))
+    if (b->type == bp_thread_event || b->type == bp_overlay_event)
+      /* We do not stop for these.  */
       bs->stop = 0;
     else
+      bpstat_check_breakpoint_conditions (bs, ptid);
+  
+    if (bs->stop)
       {
-	int value_is_zero = 0;
-
-	/* If this is a scope breakpoint, mark the associated
-	   watchpoint as triggered so that we will handle the
-	   out-of-scope event.  We'll get to the watchpoint next
-	   iteration.  */
-	if (b->type == bp_watchpoint_scope)
-	  b->related_breakpoint->watchpoint_triggered = watch_triggered_yes;
+	++(b->hit_count);
 
-	if (bl->cond && bl->owner->disposition != disp_del_at_next_stop)
+	/* We will stop here */
+	if (b->disposition == disp_disable)
 	  {
-	    /* Need to select the frame, with all that implies
-	       so that the conditions will have the right context.  */
-	    select_frame (get_current_frame ());
-	    value_is_zero
-	      = catch_errors (breakpoint_cond_eval, (bl->cond),
-			      "Error in testing breakpoint condition:\n",
-			      RETURN_MASK_ALL);
-	    /* FIXME-someday, should give breakpoint # */
-	    free_all_values ();
+	    b->enable_state = bp_disabled;
+	    update_global_location_list ();
 	  }
-	if (bl->cond && value_is_zero)
+	if (b->silent)
+	  bs->print = 0;
+	bs->commands = b->commands;
+	if (bs->commands &&
+	    (strcmp ("silent", bs->commands->line) == 0
+	     || (xdb_commands && strcmp ("Q", bs->commands->line) == 0)))
 	  {
-	    bs->stop = 0;
-	    /* Don't consider this a hit.  */
-	    --(b->hit_count);
-	  }
-	else if (b->thread != -1 && b->thread != thread_id)
-	  {
-	    bs->stop = 0;
-	    /* Don't consider this a hit.  */
-	    --(b->hit_count);
-	  }
-	else if (b->ignore_count > 0)
-	  {
-	    b->ignore_count--;
-	    annotate_ignore_count_change ();
-	    bs->stop = 0;
-	  }
-	else if (b->type == bp_thread_event || b->type == bp_overlay_event)
-	  /* We do not stop for these.  */
-	  bs->stop = 0;
-	else
-	  {
-	    /* We will stop here */
-	    if (b->disposition == disp_disable)
-	      {
-		b->enable_state = bp_disabled;
-		update_global_location_list ();
-	      }
-	    if (b->silent)
-	      bs->print = 0;
-	    bs->commands = b->commands;
-	    if (bs->commands &&
-		(strcmp ("silent", bs->commands->line) == 0
-		 || (xdb_commands && strcmp ("Q", bs->commands->line) == 0)))
-	      {
-		bs->commands = bs->commands->next;
-		bs->print = 0;
-	      }
-	    bs->commands = copy_command_lines (bs->commands);
+	    bs->commands = bs->commands->next;
+	    bs->print = 0;
 	  }
+	bs->commands = copy_command_lines (bs->commands);
       }
+
     /* Print nothing for this entry if we dont stop or if we dont print.  */
     if (bs->stop == 0 || bs->print == 0)
       bs->print_it = print_it_noop;

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

* Re: Kill 'args' interface for MI commands
  2008-04-24 15:59 Kill 'args' interface for MI commands Vladimir Prus
@ 2008-04-24 16:02 ` Vladimir Prus
  2008-04-24 16:34   ` Daniel Jacobowitz
  0 siblings, 1 reply; 3+ messages in thread
From: Vladimir Prus @ 2008-04-24 16:02 UTC (permalink / raw)
  To: gdb-patches

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

Vladimir Prus wrote:

> 
> Presently, each MI command is implemented with a function, but there are
> two different interfaces -- old uses "char *" to pass all parameters lumped
> together, while new one uses "char ** + int", like argc/argv.
> 
> This patch kills the old interface completely. Checked in.

I've attached a wrong patch, this is what I've actually checked in.

- Volodya



[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: commit.diff --]
[-- Type: text/x-diff; name="commit.diff", Size: 27373 bytes --]

Index: gdb/ChangeLog
===================================================================
RCS file: /cvs/src/src/gdb/ChangeLog,v
retrieving revision 1.9313
diff -u -p -r1.9313 ChangeLog
--- gdb/ChangeLog	24 Apr 2008 12:56:44 -0000	1.9313
+++ gdb/ChangeLog	24 Apr 2008 13:26:28 -0000
@@ -1,5 +1,23 @@
 2008-04-24  Vladimir Prus  <vladimir@codesourcery.com>
 
+	* mi/mi-cmds.h (mi_cmd_args_ftype): Remove.
+	Adjust all prototypes using mi_cmd_args_ftype to use
+	mi_cmd_argv_ftype.
+	(struct mi_cmd): Remove the args_func field.
+	* mi/mi-cmds.c: Don't provide value for the args_func field.
+	* mi/mi-main.c (mi_execute_async_cli_command)
+	(mi_cmd_exec_run, mi_cmd_exec_next, mi_cmd_exec_next_instruction)
+	(mi_cmd_exec_step, mi_cmd_exec_step_instruction)
+	(mi_cmd_exec_finish, mi_cmd_exec_until, mi_cmd_exec_return)
+	(mi_cmd_exec_continue, mi_cmd_exec_interrupt)
+	(mi_cmd_target_download): Adjust.
+	(mi_cmd_target_select): Adjust. Pass 0 for from_tty parameter.
+	(mi_cmd_execute): Do not check for args_func.
+	(mi_execute_async_cli_command): Adjust.
+	* mi/mi-parse.c: Don't check for args_func.
+
+2008-04-24  Vladimir Prus  <vladimir@codesourcery.com>
+
         * breakpoint.c (bpstat_check_location)
         (bpstat_check_watchpoint, bpstat_check_breakpoint_conditions):
         New, extracted from bpstat_stop_status.
Index: gdb/mi/mi-cmds.c
===================================================================
RCS file: /cvs/src/src/gdb/mi/mi-cmds.c,v
retrieving revision 1.31
diff -u -p -r1.31 mi-cmds.c
--- gdb/mi/mi-cmds.c	15 Mar 2008 13:53:25 -0000	1.31
+++ gdb/mi/mi-cmds.c	24 Apr 2008 13:26:31 -0000
@@ -32,32 +32,32 @@ static void build_table (struct mi_cmd *
 
 struct mi_cmd mi_cmds[] =
 {
-  { "break-after", { "ignore", 1 }, NULL, NULL },
-  { "break-catch", { NULL, 0 }, NULL, NULL },
-  { "break-commands", { NULL, 0 }, NULL, NULL },
-  { "break-condition", { "cond", 1 }, NULL, NULL },
-  { "break-delete", { "delete breakpoint", 1 }, NULL, NULL },
-  { "break-disable", { "disable breakpoint", 1 }, NULL, NULL },
-  { "break-enable", { "enable breakpoint", 1 }, NULL, NULL },
-  { "break-info", { "info break", 1 }, NULL, NULL },
-  { "break-insert", { NULL, 0 }, 0, mi_cmd_break_insert},
-  { "break-list", { "info break", }, NULL, NULL },
-  { "break-watch", { NULL, 0 }, 0, mi_cmd_break_watch},
-  { "data-disassemble", { NULL, 0 }, 0, mi_cmd_disassemble},
-  { "data-evaluate-expression", { NULL, 0 }, 0, mi_cmd_data_evaluate_expression},
-  { "data-list-changed-registers", { NULL, 0 }, 0, mi_cmd_data_list_changed_registers},
-  { "data-list-register-names", { NULL, 0 }, 0, mi_cmd_data_list_register_names},
-  { "data-list-register-values", { NULL, 0 }, 0, mi_cmd_data_list_register_values},
-  { "data-read-memory", { NULL, 0 }, 0, mi_cmd_data_read_memory},
-  { "data-write-memory", { NULL, 0 }, 0, mi_cmd_data_write_memory},
-  { "data-write-register-values", { NULL, 0 }, 0, mi_cmd_data_write_register_values},
-  { "enable-timings", { NULL, 0 }, 0, mi_cmd_enable_timings},
-  { "environment-cd", { NULL, 0 }, 0, mi_cmd_env_cd},
-  { "environment-directory", { NULL, 0 }, 0, mi_cmd_env_dir},
-  { "environment-path", { NULL, 0 }, 0, mi_cmd_env_path},
-  { "environment-pwd", { NULL, 0 }, 0, mi_cmd_env_pwd},
-  { "exec-abort", { NULL, 0 }, NULL, NULL },
-  { "exec-arguments", { "set args", 1 }, NULL, NULL },
+  { "break-after", { "ignore", 1 }, NULL },
+  { "break-catch", { NULL, 0 }, NULL },
+  { "break-commands", { NULL, 0 }, NULL },
+  { "break-condition", { "cond", 1 }, NULL },
+  { "break-delete", { "delete breakpoint", 1 }, NULL },
+  { "break-disable", { "disable breakpoint", 1 }, NULL },
+  { "break-enable", { "enable breakpoint", 1 }, NULL },
+  { "break-info", { "info break", 1 }, NULL },
+  { "break-insert", { NULL, 0 }, mi_cmd_break_insert},
+  { "break-list", { "info break", }, NULL },
+  { "break-watch", { NULL, 0 }, mi_cmd_break_watch},
+  { "data-disassemble", { NULL, 0 }, mi_cmd_disassemble},
+  { "data-evaluate-expression", { NULL, 0 }, mi_cmd_data_evaluate_expression},
+  { "data-list-changed-registers", { NULL, 0 }, mi_cmd_data_list_changed_registers},
+  { "data-list-register-names", { NULL, 0 }, mi_cmd_data_list_register_names},
+  { "data-list-register-values", { NULL, 0 }, mi_cmd_data_list_register_values},
+  { "data-read-memory", { NULL, 0 }, mi_cmd_data_read_memory},
+  { "data-write-memory", { NULL, 0 }, mi_cmd_data_write_memory},
+  { "data-write-register-values", { NULL, 0 }, mi_cmd_data_write_register_values},
+  { "enable-timings", { NULL, 0 }, mi_cmd_enable_timings},
+  { "environment-cd", { NULL, 0 }, mi_cmd_env_cd},
+  { "environment-directory", { NULL, 0 }, mi_cmd_env_dir},
+  { "environment-path", { NULL, 0 }, mi_cmd_env_path},
+  { "environment-pwd", { NULL, 0 }, mi_cmd_env_pwd},
+  { "exec-abort", { NULL, 0 }, NULL },
+  { "exec-arguments", { "set args", 1 }, NULL },
   { "exec-continue", { NULL, 0 }, mi_cmd_exec_continue},
   { "exec-finish", { NULL, 0 }, mi_cmd_exec_finish},
   { "exec-interrupt", { NULL, 0 }, mi_cmd_exec_interrupt},
@@ -65,104 +65,103 @@ struct mi_cmd mi_cmds[] =
   { "exec-next-instruction", { NULL, 0 }, mi_cmd_exec_next_instruction},
   { "exec-return", { NULL, 0 }, mi_cmd_exec_return},
   { "exec-run", { NULL, 0 }, mi_cmd_exec_run},
-  { "exec-show-arguments", { NULL, 0 }, NULL, NULL },
-  { "exec-signal", { NULL, 0 }, NULL, NULL },
+  { "exec-show-arguments", { NULL, 0 }, NULL },
+  { "exec-signal", { NULL, 0 }, NULL },
   { "exec-step", { NULL, 0 }, mi_cmd_exec_step},
   { "exec-step-instruction", { NULL, 0 }, mi_cmd_exec_step_instruction},
   { "exec-until", { NULL, 0 }, mi_cmd_exec_until},
-  { "file-clear", { NULL, 0 }, NULL, NULL },
-  { "file-exec-and-symbols", { "file", 1 }, NULL, NULL },
-  { "file-exec-file", { "exec-file", 1 }, NULL, NULL },
-  { "file-list-exec-sections", { NULL, 0 }, NULL, NULL },
-  { "file-list-exec-source-file", { NULL, 0 }, 0, mi_cmd_file_list_exec_source_file},
-  { "file-list-exec-source-files", { NULL, 0 }, NULL, mi_cmd_file_list_exec_source_files },
-  { "file-list-shared-libraries", { NULL, 0 }, NULL, NULL },
-  { "file-list-symbol-files", { NULL, 0 }, NULL, NULL },
-  { "file-symbol-file", { "symbol-file", 1 }, NULL, NULL },
-  { "gdb-complete", { NULL, 0 }, NULL, NULL },
-  { "gdb-exit", { NULL, 0 }, 0, mi_cmd_gdb_exit},
-  { "gdb-set", { "set", 1 }, NULL, NULL },
-  { "gdb-show", { "show", 1 }, NULL, NULL },
-  { "gdb-source", { NULL, 0 }, NULL, NULL },
+  { "file-clear", { NULL, 0 }, NULL },
+  { "file-exec-and-symbols", { "file", 1 }, NULL },
+  { "file-exec-file", { "exec-file", 1 }, NULL },
+  { "file-list-exec-sections", { NULL, 0 }, NULL },
+  { "file-list-exec-source-file", { NULL, 0 }, mi_cmd_file_list_exec_source_file},
+  { "file-list-exec-source-files", { NULL, 0 }, mi_cmd_file_list_exec_source_files },
+  { "file-list-shared-libraries", { NULL, 0 }, NULL },
+  { "file-list-symbol-files", { NULL, 0 }, NULL },
+  { "file-symbol-file", { "symbol-file", 1 }, NULL },
+  { "gdb-complete", { NULL, 0 }, NULL },
+  { "gdb-exit", { NULL, 0 }, mi_cmd_gdb_exit},
+  { "gdb-set", { "set", 1 }, NULL },
+  { "gdb-show", { "show", 1 }, NULL },
+  { "gdb-source", { NULL, 0 }, NULL },
   { "gdb-version", { "show version", 0 }, 0 },
-  { "inferior-tty-set", { NULL, 0 }, NULL, mi_cmd_inferior_tty_set},
-  { "inferior-tty-show", { NULL, 0 }, NULL, mi_cmd_inferior_tty_show},
-  { "interpreter-exec", { NULL, 0 }, 0, mi_cmd_interpreter_exec},
-  { "list-features", { NULL, 0 }, 0, mi_cmd_list_features},
-  { "overlay-auto", { NULL, 0 }, NULL, NULL },
-  { "overlay-list-mapping-state", { NULL, 0 }, NULL, NULL },
-  { "overlay-list-overlays", { NULL, 0 }, NULL, NULL },
-  { "overlay-map", { NULL, 0 }, NULL, NULL },
-  { "overlay-off", { NULL, 0 }, NULL, NULL },
-  { "overlay-on", { NULL, 0 }, NULL, NULL },
-  { "overlay-unmap", { NULL, 0 }, NULL, NULL },
-  { "signal-handle", { NULL, 0 }, NULL, NULL },
-  { "signal-list-handle-actions", { NULL, 0 }, NULL, NULL },
-  { "signal-list-signal-types", { NULL, 0 }, NULL, NULL },
-  { "stack-info-depth", { NULL, 0 }, 0, mi_cmd_stack_info_depth},
-  { "stack-info-frame", { NULL, 0 }, 0, mi_cmd_stack_info_frame},
-  { "stack-list-arguments", { NULL, 0 }, 0, mi_cmd_stack_list_args},
-  { "stack-list-exception-handlers", { NULL, 0 }, NULL, NULL },
-  { "stack-list-frames", { NULL, 0 }, 0, mi_cmd_stack_list_frames},
-  { "stack-list-locals", { NULL, 0 }, 0, mi_cmd_stack_list_locals},
-  { "stack-select-frame", { NULL, 0 }, 0, mi_cmd_stack_select_frame},
-  { "symbol-info-address", { NULL, 0 }, NULL, NULL },
-  { "symbol-info-file", { NULL, 0 }, NULL, NULL },
-  { "symbol-info-function", { NULL, 0 }, NULL, NULL },
-  { "symbol-info-line", { NULL, 0 }, NULL, NULL },
-  { "symbol-info-symbol", { NULL, 0 }, NULL, NULL },
-  { "symbol-list-functions", { NULL, 0 }, NULL, NULL },
-  { "symbol-list-lines", { NULL, 0 }, 0, mi_cmd_symbol_list_lines},
-  { "symbol-list-types", { NULL, 0 }, NULL, NULL },
-  { "symbol-list-variables", { NULL, 0 }, NULL, NULL },
-  { "symbol-locate", { NULL, 0 }, NULL, NULL },
-  { "symbol-type", { NULL, 0 }, NULL, NULL },
-  { "target-attach", { NULL, 0 }, NULL, NULL },
-  { "target-compare-sections", { NULL, 0 }, NULL, NULL },
+  { "inferior-tty-set", { NULL, 0 }, mi_cmd_inferior_tty_set},
+  { "inferior-tty-show", { NULL, 0 }, mi_cmd_inferior_tty_show},
+  { "interpreter-exec", { NULL, 0 }, mi_cmd_interpreter_exec},
+  { "list-features", { NULL, 0 }, mi_cmd_list_features},
+  { "overlay-auto", { NULL, 0 }, NULL },
+  { "overlay-list-mapping-state", { NULL, 0 }, NULL },
+  { "overlay-list-overlays", { NULL, 0 }, NULL },
+  { "overlay-map", { NULL, 0 }, NULL },
+  { "overlay-off", { NULL, 0 }, NULL },
+  { "overlay-on", { NULL, 0 }, NULL },
+  { "overlay-unmap", { NULL, 0 }, NULL },
+  { "signal-handle", { NULL, 0 }, NULL },
+  { "signal-list-handle-actions", { NULL, 0 }, NULL },
+  { "signal-list-signal-types", { NULL, 0 }, NULL },
+  { "stack-info-depth", { NULL, 0 }, mi_cmd_stack_info_depth},
+  { "stack-info-frame", { NULL, 0 }, mi_cmd_stack_info_frame},
+  { "stack-list-arguments", { NULL, 0 }, mi_cmd_stack_list_args},
+  { "stack-list-exception-handlers", { NULL, 0 }, NULL },
+  { "stack-list-frames", { NULL, 0 }, mi_cmd_stack_list_frames},
+  { "stack-list-locals", { NULL, 0 }, mi_cmd_stack_list_locals},
+  { "stack-select-frame", { NULL, 0 }, mi_cmd_stack_select_frame},
+  { "symbol-info-address", { NULL, 0 }, NULL },
+  { "symbol-info-file", { NULL, 0 }, NULL },
+  { "symbol-info-function", { NULL, 0 }, NULL },
+  { "symbol-info-line", { NULL, 0 }, NULL },
+  { "symbol-info-symbol", { NULL, 0 }, NULL },
+  { "symbol-list-functions", { NULL, 0 }, NULL },
+  { "symbol-list-lines", { NULL, 0 }, mi_cmd_symbol_list_lines},
+  { "symbol-list-types", { NULL, 0 }, NULL },
+  { "symbol-list-variables", { NULL, 0 },  NULL },
+  { "symbol-locate", { NULL, 0 }, NULL },
+  { "symbol-type", { NULL, 0 }, NULL },
+  { "target-attach", { NULL, 0 }, NULL },
+  { "target-compare-sections", { NULL, 0 }, NULL },
   { "target-detach", { "detach", 0 }, 0 },
   { "target-disconnect", { "disconnect", 0 }, 0 },
   { "target-download", { NULL, 0 }, mi_cmd_target_download},
-  { "target-exec-status", { NULL, 0 }, NULL, NULL },
-  { "target-file-delete", { NULL, 0 }, NULL, mi_cmd_target_file_delete },
-  { "target-file-get", { NULL, 0 }, NULL, mi_cmd_target_file_get },
-  { "target-file-put", { NULL, 0 }, NULL, mi_cmd_target_file_put },
-  { "target-list-available-targets", { NULL, 0 }, NULL, NULL },
-  { "target-list-current-targets", { NULL, 0 }, NULL, NULL },
-  { "target-list-parameters", { NULL, 0 }, NULL, NULL },
+  { "target-exec-status", { NULL, 0 }, NULL },
+  { "target-file-delete", { NULL, 0 }, mi_cmd_target_file_delete },
+  { "target-file-get", { NULL, 0 }, mi_cmd_target_file_get },
+  { "target-file-put", { NULL, 0 }, mi_cmd_target_file_put },
+  { "target-list-available-targets", { NULL, 0 }, NULL },
+  { "target-list-current-targets", { NULL, 0 }, NULL },
+  { "target-list-parameters", { NULL, 0 }, NULL },
   { "target-select", { NULL, 0 }, mi_cmd_target_select},
-  { "thread-info", { NULL, 0 }, NULL, mi_cmd_thread_info },
-  { "thread-list-ids", { NULL, 0 }, 0, mi_cmd_thread_list_ids},
-  { "thread-select", { NULL, 0 }, 0, mi_cmd_thread_select},
-  { "trace-actions", { NULL, 0 }, NULL, NULL },
-  { "trace-delete", { NULL, 0 }, NULL, NULL },
-  { "trace-disable", { NULL, 0 }, NULL, NULL },
-  { "trace-dump", { NULL, 0 }, NULL, NULL },
-  { "trace-enable", { NULL, 0 }, NULL, NULL },
-  { "trace-exists", { NULL, 0 }, NULL, NULL },
-  { "trace-find", { NULL, 0 }, NULL, NULL },
-  { "trace-frame-number", { NULL, 0 }, NULL, NULL },
-  { "trace-info", { NULL, 0 }, NULL, NULL },
-  { "trace-insert", { NULL, 0 }, NULL, NULL },
-  { "trace-list", { NULL, 0 }, NULL, NULL },
-  { "trace-pass-count", { NULL, 0 }, NULL, NULL },
-  { "trace-save", { NULL, 0 }, NULL, NULL },
-  { "trace-start", { NULL, 0 }, NULL, NULL },
-  { "trace-stop", { NULL, 0 }, NULL, NULL },
-  { "var-assign", { NULL, 0 }, 0, mi_cmd_var_assign},
-  { "var-create", { NULL, 0 }, 0, mi_cmd_var_create},
-  { "var-delete", { NULL, 0 }, 0, mi_cmd_var_delete},
-  { "var-evaluate-expression", { NULL, 0 }, 0, mi_cmd_var_evaluate_expression},
-  { "var-info-path-expression", { NULL, 0 }, 0, 
-    mi_cmd_var_info_path_expression},
-  { "var-info-expression", { NULL, 0 }, 0, mi_cmd_var_info_expression},
-  { "var-info-num-children", { NULL, 0 }, 0, mi_cmd_var_info_num_children},
-  { "var-info-type", { NULL, 0 }, 0, mi_cmd_var_info_type},
-  { "var-list-children", { NULL, 0 }, 0, mi_cmd_var_list_children},
-  { "var-set-format", { NULL, 0 }, 0, mi_cmd_var_set_format},
-  { "var-set-frozen", { NULL, 0 }, 0, mi_cmd_var_set_frozen},
-  { "var-show-attributes", { NULL, 0 }, 0, mi_cmd_var_show_attributes},
-  { "var-show-format", { NULL, 0 }, 0, mi_cmd_var_show_format},
-  { "var-update", { NULL, 0 }, 0, mi_cmd_var_update},
+  { "thread-info", { NULL, 0 }, mi_cmd_thread_info },
+  { "thread-list-ids", { NULL, 0 }, mi_cmd_thread_list_ids},
+  { "thread-select", { NULL, 0 }, mi_cmd_thread_select},
+  { "trace-actions", { NULL, 0 }, NULL },
+  { "trace-delete", { NULL, 0 }, NULL },
+  { "trace-disable", { NULL, 0 }, NULL },
+  { "trace-dump", { NULL, 0 }, NULL },
+  { "trace-enable", { NULL, 0 }, NULL },
+  { "trace-exists", { NULL, 0 }, NULL },
+  { "trace-find", { NULL, 0 }, NULL },
+  { "trace-frame-number", { NULL, 0 }, NULL },
+  { "trace-info", { NULL, 0 }, NULL },
+  { "trace-insert", { NULL, 0 }, NULL },
+  { "trace-list", { NULL, 0 }, NULL },
+  { "trace-pass-count", { NULL, 0 }, NULL },
+  { "trace-save", { NULL, 0 }, NULL },
+  { "trace-start", { NULL, 0 }, NULL },
+  { "trace-stop", { NULL, 0 }, NULL },
+  { "var-assign", { NULL, 0 }, mi_cmd_var_assign},
+  { "var-create", { NULL, 0 }, mi_cmd_var_create},
+  { "var-delete", { NULL, 0 }, mi_cmd_var_delete},
+  { "var-evaluate-expression", { NULL, 0 },  mi_cmd_var_evaluate_expression},
+  { "var-info-path-expression", { NULL, 0 }, mi_cmd_var_info_path_expression},
+  { "var-info-expression", { NULL, 0 }, mi_cmd_var_info_expression},
+  { "var-info-num-children", { NULL, 0 }, mi_cmd_var_info_num_children},
+  { "var-info-type", { NULL, 0 }, mi_cmd_var_info_type},
+  { "var-list-children", { NULL, 0 }, mi_cmd_var_list_children},
+  { "var-set-format", { NULL, 0 }, mi_cmd_var_set_format},
+  { "var-set-frozen", { NULL, 0 }, mi_cmd_var_set_frozen},
+  { "var-show-attributes", { NULL, 0 }, mi_cmd_var_show_attributes},
+  { "var-show-format", { NULL, 0 }, mi_cmd_var_show_format},
+  { "var-update", { NULL, 0 }, mi_cmd_var_update},
   { NULL, }
 };
 
Index: gdb/mi/mi-cmds.h
===================================================================
RCS file: /cvs/src/src/gdb/mi/mi-cmds.h,v
retrieving revision 1.29
diff -u -p -r1.29 mi-cmds.h
--- gdb/mi/mi-cmds.h	4 Apr 2008 21:59:25 -0000	1.29
+++ gdb/mi/mi-cmds.h	24 Apr 2008 13:26:32 -0000
@@ -51,11 +51,6 @@ extern const char mi_all_values[];
 
 typedef enum mi_cmd_result (mi_cmd_argv_ftype) (char *command, char **argv, int argc);
 
-/* Older MI commands have this interface. Retained until all old
-   commands are flushed. */
-
-typedef enum mi_cmd_result (mi_cmd_args_ftype) ( /*ui */ char *args, int from_tty);
-
 /* Function implementing each command */
 extern mi_cmd_argv_ftype mi_cmd_break_insert;
 extern mi_cmd_argv_ftype mi_cmd_break_watch;
@@ -72,16 +67,16 @@ extern mi_cmd_argv_ftype mi_cmd_env_cd;
 extern mi_cmd_argv_ftype mi_cmd_env_dir;
 extern mi_cmd_argv_ftype mi_cmd_env_path;
 extern mi_cmd_argv_ftype mi_cmd_env_pwd;
-extern mi_cmd_args_ftype mi_cmd_exec_continue;
-extern mi_cmd_args_ftype mi_cmd_exec_finish;
-extern mi_cmd_args_ftype mi_cmd_exec_next;
-extern mi_cmd_args_ftype mi_cmd_exec_next_instruction;
-extern mi_cmd_args_ftype mi_cmd_exec_return;
-extern mi_cmd_args_ftype mi_cmd_exec_run;
-extern mi_cmd_args_ftype mi_cmd_exec_step;
-extern mi_cmd_args_ftype mi_cmd_exec_step_instruction;
-extern mi_cmd_args_ftype mi_cmd_exec_until;
-extern mi_cmd_args_ftype mi_cmd_exec_interrupt;
+extern mi_cmd_argv_ftype mi_cmd_exec_continue;
+extern mi_cmd_argv_ftype mi_cmd_exec_finish;
+extern mi_cmd_argv_ftype mi_cmd_exec_next;
+extern mi_cmd_argv_ftype mi_cmd_exec_next_instruction;
+extern mi_cmd_argv_ftype mi_cmd_exec_return;
+extern mi_cmd_argv_ftype mi_cmd_exec_run;
+extern mi_cmd_argv_ftype mi_cmd_exec_step;
+extern mi_cmd_argv_ftype mi_cmd_exec_step_instruction;
+extern mi_cmd_argv_ftype mi_cmd_exec_until;
+extern mi_cmd_argv_ftype mi_cmd_exec_interrupt;
 extern mi_cmd_argv_ftype mi_cmd_file_list_exec_source_file;
 extern mi_cmd_argv_ftype mi_cmd_file_list_exec_source_files;
 extern mi_cmd_argv_ftype mi_cmd_gdb_exit;
@@ -96,11 +91,11 @@ extern mi_cmd_argv_ftype mi_cmd_stack_li
 extern mi_cmd_argv_ftype mi_cmd_stack_list_locals;
 extern mi_cmd_argv_ftype mi_cmd_stack_select_frame;
 extern mi_cmd_argv_ftype mi_cmd_symbol_list_lines;
-extern mi_cmd_args_ftype mi_cmd_target_download;
+extern mi_cmd_argv_ftype mi_cmd_target_download;
 extern mi_cmd_argv_ftype mi_cmd_target_file_get;
 extern mi_cmd_argv_ftype mi_cmd_target_file_put;
 extern mi_cmd_argv_ftype mi_cmd_target_file_delete;
-extern mi_cmd_args_ftype mi_cmd_target_select;
+extern mi_cmd_argv_ftype mi_cmd_target_select;
 extern mi_cmd_argv_ftype mi_cmd_thread_info;
 extern mi_cmd_argv_ftype mi_cmd_thread_list_ids;
 extern mi_cmd_argv_ftype mi_cmd_thread_select;
@@ -137,8 +132,6 @@ struct mi_cmd
      MI command (if cli.lhs is non NULL).  */
   struct mi_cli cli;
   /* If non-null, the function implementing the MI command.  */
-  mi_cmd_args_ftype *args_func;
-  /* If non-null, the function implementing the MI command.  */
   mi_cmd_argv_ftype *argv_func;
 };
 
Index: gdb/mi/mi-main.c
===================================================================
RCS file: /cvs/src/src/gdb/mi/mi-main.c,v
retrieving revision 1.113
diff -u -p -r1.113 mi-main.c
--- gdb/mi/mi-main.c	24 Apr 2008 12:09:49 -0000	1.113
+++ gdb/mi/mi-main.c	24 Apr 2008 13:26:32 -0000
@@ -100,7 +100,8 @@ static enum mi_cmd_result mi_cmd_execute
 
 static void mi_execute_cli_command (const char *cmd, int args_p,
 				    const char *args);
-static enum mi_cmd_result mi_execute_async_cli_command (char *mi, char *args, int from_tty);
+static enum mi_cmd_result mi_execute_async_cli_command (char *cli_command, 
+							char **argv, int argc);
 
 static void mi_exec_async_cli_cmd_continuation (struct continuation_arg *arg, 
 						int error_p);
@@ -132,63 +133,63 @@ mi_cmd_gdb_exit (char *command, char **a
 }
 
 enum mi_cmd_result
-mi_cmd_exec_run (char *args, int from_tty)
+mi_cmd_exec_run (char *command, char **argv, int argc)
 {
   /* FIXME: Should call a libgdb function, not a cli wrapper.  */
-  return mi_execute_async_cli_command ("run", args, from_tty);
+  return mi_execute_async_cli_command ("run", argv, argc);
 }
 
 enum mi_cmd_result
-mi_cmd_exec_next (char *args, int from_tty)
+mi_cmd_exec_next (char *command, char **argv, int argc)
 {
   /* FIXME: Should call a libgdb function, not a cli wrapper.  */
-  return mi_execute_async_cli_command ("next", args, from_tty);
+  return mi_execute_async_cli_command ("next", argv, argc);
 }
 
 enum mi_cmd_result
-mi_cmd_exec_next_instruction (char *args, int from_tty)
+mi_cmd_exec_next_instruction (char *command, char **argv, int argc)
 {
   /* FIXME: Should call a libgdb function, not a cli wrapper.  */
-  return mi_execute_async_cli_command ("nexti", args, from_tty);
+  return mi_execute_async_cli_command ("nexti", argv, argc);
 }
 
 enum mi_cmd_result
-mi_cmd_exec_step (char *args, int from_tty)
+mi_cmd_exec_step (char *command, char **argv, int argc)
 {
   /* FIXME: Should call a libgdb function, not a cli wrapper.  */
-  return mi_execute_async_cli_command ("step", args, from_tty);
+  return mi_execute_async_cli_command ("step", argv, argc);
 }
 
 enum mi_cmd_result
-mi_cmd_exec_step_instruction (char *args, int from_tty)
+mi_cmd_exec_step_instruction (char *command, char **argv, int argc)
 {
   /* FIXME: Should call a libgdb function, not a cli wrapper.  */
-  return mi_execute_async_cli_command ("stepi", args, from_tty);
+  return mi_execute_async_cli_command ("stepi", argv, argc);
 }
 
 enum mi_cmd_result
-mi_cmd_exec_finish (char *args, int from_tty)
+mi_cmd_exec_finish (char *command, char **argv, int argc)
 {
   /* FIXME: Should call a libgdb function, not a cli wrapper.  */
-  return mi_execute_async_cli_command ("finish", args, from_tty);
+  return mi_execute_async_cli_command ("finish", argv, argc);
 }
 
 enum mi_cmd_result
-mi_cmd_exec_until (char *args, int from_tty)
+mi_cmd_exec_until (char *command, char **argv, int argc)
 {
   /* FIXME: Should call a libgdb function, not a cli wrapper.  */
-  return mi_execute_async_cli_command ("until", args, from_tty);
+  return mi_execute_async_cli_command ("until", argv, argc);
 }
 
 enum mi_cmd_result
-mi_cmd_exec_return (char *args, int from_tty)
+mi_cmd_exec_return (char *command, char **argv, int argc)
 {
   /* This command doesn't really execute the target, it just pops the
      specified number of frames. */
-  if (*args)
+  if (argc)
     /* Call return_command with from_tty argument equal to 0 so as to
        avoid being queried.  */
-    return_command (args, 0);
+    return_command (*argv, 0);
   else
     /* Call return_command with from_tty argument equal to 0 so as to
        avoid being queried.  */
@@ -202,10 +203,10 @@ mi_cmd_exec_return (char *args, int from
 }
 
 enum mi_cmd_result
-mi_cmd_exec_continue (char *args, int from_tty)
+mi_cmd_exec_continue (char *command, char **argv, int argc)
 {
   /* FIXME: Should call a libgdb function, not a cli wrapper.  */
-  return mi_execute_async_cli_command ("continue", args, from_tty);
+  return mi_execute_async_cli_command ("continue", argv, argc);
 }
 
 /* Interrupt the execution of the target.  Note how we must play around
@@ -214,12 +215,12 @@ mi_cmd_exec_continue (char *args, int fr
    token when the target finally stops.  See comments in
    mi_cmd_execute.  */
 enum mi_cmd_result
-mi_cmd_exec_interrupt (char *args, int from_tty)
+mi_cmd_exec_interrupt (char *command, char **argv, int argc)
 {
   if (!target_executing)
     error ("mi_cmd_exec_interrupt: Inferior not executing.");
 
-  interrupt_target_command (args, from_tty);
+  interrupt_target_command (NULL, 0);
   if (current_token)
     fputs_unfiltered (current_token, raw_stdout);
   fputs_unfiltered ("^done", raw_stdout);
@@ -639,14 +640,16 @@ mi_cmd_data_evaluate_expression (char *c
 }
 
 enum mi_cmd_result
-mi_cmd_target_download (char *args, int from_tty)
+mi_cmd_target_download (char *command, char **argv, int argc)
 {
   char *run;
   struct cleanup *old_cleanups = NULL;
 
-  run = xstrprintf ("load %s", args);
+  /* There may be at most one parameter -- the name of the
+     file to download.  */
+  run = xstrprintf ("load %s", argc ? *argv : "");
   old_cleanups = make_cleanup (xfree, run);
-  execute_command (run, from_tty);
+  execute_command (run, 0);
 
   do_cleanups (old_cleanups);
   return MI_CMD_DONE;
@@ -654,12 +657,27 @@ mi_cmd_target_download (char *args, int 
 
 /* Connect to the remote target.  */
 enum mi_cmd_result
-mi_cmd_target_select (char *args, int from_tty)
+mi_cmd_target_select (char *command, char **argv, int argc)
 {
-  char *run;
+  char *run = NULL;
   struct cleanup *old_cleanups = NULL;
+  int i;
 
-  run = xstrprintf ("target %s", args);
+  if (argc == 0)
+    error ("no target type specified");
+    
+  for (i = 0; i < argc; ++i)
+    {
+      if (i == 0)
+	run = concat ("target ", argv[0], NULL);
+      else
+	{
+	  char *prev = run;
+	  run = concat (run, " ", argv[i], NULL);
+	  xfree (prev);
+	}
+    }
+  
   old_cleanups = make_cleanup (xfree, run);
 
   /* target-select is always synchronous.  Once the call has returned
@@ -667,7 +685,7 @@ mi_cmd_target_select (char *args, int fr
   /* NOTE: At present all targets that are connected are also
      (implicitly) talking to a halted target.  In the future this may
      change.  */
-  execute_command (run, from_tty);
+  execute_command (run, 0);
 
   do_cleanups (old_cleanups);
 
@@ -1181,8 +1199,7 @@ mi_cmd_execute (struct mi_parse *parse)
   enum mi_cmd_result r;
   free_all_values ();
 
-  if (parse->cmd->argv_func != NULL
-      || parse->cmd->args_func != NULL)
+  if (parse->cmd->argv_func != NULL)
     {
       if (target_executing)
 	{
@@ -1201,11 +1218,7 @@ mi_cmd_execute (struct mi_parse *parse)
 	}
       current_token = xstrdup (parse->token);
       cleanup = make_cleanup (free_current_contents, &current_token);
-      /* FIXME: DELETE THIS! */
-      if (parse->cmd->args_func != NULL)
-	r = parse->cmd->args_func (parse->args, 0 /*from_tty */ );
-      else
-	r = parse->cmd->argv_func (parse->command, parse->argv, parse->argc);
+      r = parse->cmd->argv_func (parse->command, parse->argv, parse->argc);
       do_cleanups (cleanup);
       return r;
     }
@@ -1264,15 +1277,15 @@ mi_execute_cli_command (const char *cmd,
 }
 
 enum mi_cmd_result
-mi_execute_async_cli_command (char *mi, char *args, int from_tty)
+mi_execute_async_cli_command (char *cli_command, char **argv, int argc)
 {
   struct cleanup *old_cleanups;
   char *run;
 
   if (target_can_async_p ())
-    run = xstrprintf ("%s %s&", mi, args);
+    run = xstrprintf ("%s %s&", cli_command, argc ? *argv : "");
   else
-    run = xstrprintf ("%s %s", mi, args);
+    run = xstrprintf ("%s %s", cli_command, argc ? *argv : "");
   old_cleanups = make_cleanup (xfree, run);  
 
   if (!target_can_async_p ())
Index: gdb/mi/mi-parse.c
===================================================================
RCS file: /cvs/src/src/gdb/mi/mi-parse.c,v
retrieving revision 1.14
diff -u -p -r1.14 mi-parse.c
--- gdb/mi/mi-parse.c	1 Jan 2008 22:53:14 -0000	1.14
+++ gdb/mi/mi-parse.c	24 Apr 2008 13:26:32 -0000
@@ -217,13 +217,10 @@ mi_parse (char *cmd)
     }
 
   /* FIXME: DELETE THIS */
-  /* For CLI and old ARGS commands, also return the remainder of the
+  /* For CLI commands, also return the remainder of the
      command line as a single string. */
-  if (parse->cmd->args_func != NULL
-      || parse->cmd->cli.cmd != NULL)
-    {
-      parse->args = xstrdup (chp);
-    }
+  if (parse->cmd->cli.cmd != NULL)
+    parse->args = xstrdup (chp);
 
   /* Fully parsed. */
   parse->op = MI_COMMAND;


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

* Re: Kill 'args' interface for MI commands
  2008-04-24 16:02 ` Vladimir Prus
@ 2008-04-24 16:34   ` Daniel Jacobowitz
  0 siblings, 0 replies; 3+ messages in thread
From: Daniel Jacobowitz @ 2008-04-24 16:34 UTC (permalink / raw)
  To: Vladimir Prus; +Cc: gdb-patches

On Thu, Apr 24, 2008 at 05:47:10PM +0400, Vladimir Prus wrote:
> Vladimir Prus wrote:
> 
> > 
> > Presently, each MI command is implemented with a function, but there are
> > two different interfaces -- old uses "char *" to pass all parameters lumped
> > together, while new one uses "char ** + int", like argc/argv.
> > 
> > This patch kills the old interface completely. Checked in.
> 
> I've attached a wrong patch, this is what I've actually checked in.

Is this compatible?

Above the bit of mi-parse.c you changed is this:

  /* For new argv commands, attempt to return the parsed argument
     list. */
  if (parse->cmd->argv_func != NULL)
    {
      mi_parse_argv (chp, parse);

If that fails, then an error is output.  So anything not properly
quoted as an MI command is invalid.  Which would be nice, except
that's not how things worked before.

For example, a command which previously used args_func and had
argv_func == NULL is -exec-run.  It wasn't documented to take
arguments, but it did.  They were passed unmodified to the shell
and now they're stripped of MI quoting.  Another was -target-select,
which folks pass all sorts of hairy strings to, and -target-download,
which sometimes takes a filename - previously not MI quoted.  But
it gets passed to load which removes its own quotes.  So now
-target-download "my file.exe" is going to fail because the CLI
will get "load my file.exe".

-- 
Daniel Jacobowitz
CodeSourcery


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

end of thread, other threads:[~2008-04-24 14:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-04-24 15:59 Kill 'args' interface for MI commands Vladimir Prus
2008-04-24 16:02 ` Vladimir Prus
2008-04-24 16:34   ` Daniel Jacobowitz

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