Bug in mi_execute_command (mi-main.c)

Nick Roberts nickrob@gnu.org
Wed Jun 30 20:47:00 GMT 2004

args.action appears to be used without being set by
captured_mi_execute_command in mi-main.c. When I run gdb in Emacs now it picks
up a value of 1 (EXECUTE_COMMAND_SUPRESS_PROMPT) from tcgetattr (presumably
from the stack).

Hardware watchpoint 4: *3221221764

Old value = 16
New value = 1
0x402259fa in tcgetattr () from /lib/libc.so.6

Breakpoint 3, mi_execute_command (cmd=0x8467058 "", from_tty=1)
    at mi/mi-main.c:1148

This value means that the
procedure returns prematurely and the last part of the message is not printed

^error,msg="Function \"MAIN__\" not defined."

so Emacs doesn't know that gdb is ready for input.

If I set TERM to xterm instead of dumb or if I run gdb in an xterm args.action
is set to 5 in tcgetattr and there is no problem. However if it is not being
set then it should be initialised to a safe value. This problem did not exist
before 17 May 2004 so perhaps the bug is elsewhere i.e args.action should get


mi_execute_command (char *cmd, int from_tty)
  struct mi_parse *command;
  struct captured_mi_execute_command_args args;
  struct ui_out *saved_uiout = uiout;
  int result;

  /* This is to handle EOF (^D). We just quit gdb. */
  /* FIXME: we should call some API function here. */
  if (cmd == 0)
    quit_force (NULL, from_tty);

  command = mi_parse (cmd);

  if (command != NULL)
      /* FIXME: cagney/1999-11-04: Can this use of catch_exceptions either
         be pushed even further down or even eliminated? */
      args.command = command;
      result = catch_exceptions (uiout, captured_mi_execute_command, &args, "",

      if (args.action == EXECUTE_COMMAND_SUPRESS_PROMPT)
	  /* The command is executing synchronously.  Bail out early
	     suppressing the finished prompt. */
	  mi_parse_free (command);
      if (args.action == EXECUTE_COMMAND_DISPLAY_ERROR || result < 0)
	  char *msg = error_last_message ();
	  struct cleanup *cleanup = make_cleanup (xfree, msg);
	  /* The command execution failed and error() was called
	     somewhere */
	  fputs_unfiltered (command->token, raw_stdout);
	  fputs_unfiltered ("^error,msg=\"", raw_stdout);
	  fputstr_unfiltered (msg, '"', raw_stdout);
	  fputs_unfiltered ("\"\n", raw_stdout);
      mi_parse_free (command);

More information about the Gdb mailing list