Beispiel #1
0
void
async_disable_stdin (void)
{

  if (!stdin_enabled)
    return;

  stdin_enabled = 0;

  /* Just don't do this...
     sync_execution = 1; */

  push_prompt ("", "", "");
  /* FIXME: cagney/1999-09-27: At present this call is technically
     redundant since infcmd.c and infrun.c both already call
     target_terminal_inferior().  As the terminal handling (in
     sync/async mode) is refined, the duplicate calls can be
     eliminated (Here or in infcmd.c/infrun.c). */
  target_terminal_inferior ();
  /* Add the reinstate of stdin to the list of cleanups to be done
     in case the target errors out and dies. These cleanups are also
     done in case of normal successful termination of the execution
     command, by complete_execution(). */
  make_exec_error_cleanup (async_enable_stdin, NULL);
}
Beispiel #2
0
void
async_disable_stdin (void)
{
  if (!sync_execution)
    {
      sync_execution = 1;
      push_prompt ("", "", "");
    }
}
Beispiel #3
0
/* APPLE LOCAL begin Inform user about debugging optimized code  */
void
adjust_prompts_for_optimized_code (void)
{

  /* Case 1:  gdb_prompt_is_optimized == false.  */
  if (!gdb_prompt_is_optimized)
    {
      /* If we're inside optimized code AND the user wants to be told
	 about it, append '[opt> ' to the prompt.  Actually, create
         a second duplicate prompt, and append to that.  This allows
         for easy removal later.  */
      if (dwarf2_inform_debugging_optimized_code
	  && currently_inside_optimized_code)
	{
	  char *old_prompt = get_prompt ();
	  char *new_prompt;
	  if (strstr (old_prompt, "[opt> ") == 0)
	    {
	      new_prompt = (char *) xmalloc (strlen (old_prompt) + 7);
	      sprintf (new_prompt, "%s[opt> ", old_prompt);
	      push_prompt ("", new_prompt, "");
	      xfree (new_prompt);
	    }
	  gdb_prompt_is_optimized = 1;
	}
    }

  /* Case 2:  gdb_prompt_is_optimized == true.  */

  else if (gdb_prompt_is_optimized)
    {
      /* If we're not inside optimized code, or the user does not
	 want to be told about it, pop the '[opt> ' version of the
         prompt from the prompt stack.  */
      if (!dwarf2_inform_debugging_optimized_code
	  || !currently_inside_optimized_code)
	{
	  if (the_prompts.top > 0
	      && strstr (PROMPT (0), "[opt> ") != 0)
	    {
	      xfree (PREFIX (0));
	      xfree (PROMPT (0));
	      xfree (SUFFIX (0));
	      the_prompts.top--;
	    }
	  gdb_prompt_is_optimized = 0;
	}
    }
}
Beispiel #4
0
/* Called by do_setshow_command.  */
void
set_async_prompt (char *args, int from_tty, struct cmd_list_element *c)
{
  /* APPLE LOCAL begin Inform user about debugging optimized code  */
  if (currently_inside_optimized_code
      && the_prompts.top > 0
      && (strstr (PROMPT (0), "[opt> ") != 0))
    {
      char *new_str;
      pop_prompt ();
      PROMPT (0) = savestring (new_async_prompt, strlen (new_async_prompt));
      new_str = (char *) xmalloc (strlen (new_async_prompt) + 7);
      sprintf (new_str, "%s[opt> ", new_async_prompt);
      push_prompt ("", new_str, "");
      xfree (new_str);
    }
  else
  /* APPLE LOCAL end Inform user about debugging optimized code  */
    PROMPT (0) = savestring (new_async_prompt, strlen (new_async_prompt));
}
Beispiel #5
0
/* Used when the user requests a different annotation level, with
   'set annotate'. It pushes a new prompt (with prefix and suffix) on top
   of the prompt stack, if the annotation level desired is 2, otherwise
   it pops the top of the prompt stack when we want the annotation level
   to be the normal ones (1 or 0). */
static void
change_annotation_level (void)
{
  char *prefix, *suffix;

  if (!PREFIX (0) || !PROMPT (0) || !SUFFIX (0))
    {
      /* The prompt stack has not been initialized to "", we are
         using gdb w/o the --async switch */
      warning (_("Command has same effect as set annotate"));
      return;
    }

  if (annotation_level > 1)
    {
      if (!strcmp (PREFIX (0), "") && !strcmp (SUFFIX (0), ""))
	{
	  /* Push a new prompt if the previous annotation_level was not >1. */
	  prefix = (char *) alloca (strlen (async_annotation_suffix) + 10);
	  strcpy (prefix, "\n\032\032pre-");
	  strcat (prefix, async_annotation_suffix);
	  strcat (prefix, "\n");

	  suffix = (char *) alloca (strlen (async_annotation_suffix) + 6);
	  strcpy (suffix, "\n\032\032");
	  strcat (suffix, async_annotation_suffix);
	  strcat (suffix, "\n");

	  push_prompt (prefix, (char *) 0, suffix);
	}
    }
  else
    {
      if (strcmp (PREFIX (0), "") && strcmp (SUFFIX (0), ""))
	{
	  /* Pop the top of the stack, we are going back to annotation < 1. */
	  pop_prompt ();
	}
    }
}
Beispiel #6
0
/* NOTE: 1999-04-30 This is the asynchronous version of the
   command_line_input function. command_line_input will become
   obsolete once we use the event loop as the default mechanism in
   GDB. */
static void
command_line_handler (char *rl)
{
  static char *linebuffer = 0;
  static unsigned linelength = 0;
  char *p;
  char *p1;
  extern char *line;
  extern int linesize;
  char *nline;
  char got_eof = 0;


  int repeat = (instream == stdin);

  if (annotation_level > 1 && instream == stdin)
    {
      printf_unfiltered (("\n\032\032post-"));
      puts_unfiltered (async_annotation_suffix);
      printf_unfiltered (("\n"));
    }

  if (linebuffer == 0)
    {
      linelength = 80;
      linebuffer = (char *) xmalloc (linelength);
    }

  p = linebuffer;

  if (more_to_come)
    {
      strcpy (linebuffer, readline_input_state.linebuffer);
      p = readline_input_state.linebuffer_ptr;
      xfree (readline_input_state.linebuffer);
      more_to_come = 0;
      pop_prompt ();
    }

#ifdef STOP_SIGNAL
  if (job_control)
    signal (STOP_SIGNAL, handle_stop_sig);
#endif

  /* Make sure that all output has been output.  Some machines may let
     you get away with leaving out some of the gdb_flush, but not all.  */
  wrap_here ("");
  gdb_flush (gdb_stdout);
  gdb_flush (gdb_stderr);

  if (source_file_name != NULL)
    ++source_line_number;

  /* If we are in this case, then command_handler will call quit 
     and exit from gdb. */
  if (!rl || rl == (char *) EOF)
    {
      got_eof = 1;
      command_handler (0);
    }
  if (strlen (rl) + 1 + (p - linebuffer) > linelength)
    {
      linelength = strlen (rl) + 1 + (p - linebuffer);
      nline = (char *) xrealloc (linebuffer, linelength);
      p += nline - linebuffer;
      linebuffer = nline;
    }
  p1 = rl;
  /* Copy line.  Don't copy null at end.  (Leaves line alone
     if this was just a newline)  */
  while (*p1)
    *p++ = *p1++;

  xfree (rl);			/* Allocated in readline.  */

  if (p > linebuffer && *(p - 1) == '\\')
    {
      p--;			/* Put on top of '\'.  */

      readline_input_state.linebuffer = savestring (linebuffer,
						    strlen (linebuffer));
      readline_input_state.linebuffer_ptr = p;

      /* We will not invoke a execute_command if there is more
	 input expected to complete the command. So, we need to
	 print an empty prompt here. */
      more_to_come = 1;
      push_prompt ("", "", "");
      display_gdb_prompt (0);
      return;
    }

#ifdef STOP_SIGNAL
  if (job_control)
    signal (STOP_SIGNAL, SIG_DFL);
#endif

#define SERVER_COMMAND_LENGTH 7
  server_command =
    (p - linebuffer > SERVER_COMMAND_LENGTH)
    && strncmp (linebuffer, "server ", SERVER_COMMAND_LENGTH) == 0;
  if (server_command)
    {
      /* Note that we don't set `line'.  Between this and the check in
         dont_repeat, this insures that repeating will still do the
         right thing.  */
      *p = '\0';
      command_handler (linebuffer + SERVER_COMMAND_LENGTH);
      display_gdb_prompt (0);
      return;
    }

  /* Do history expansion if that is wished.  */
  if (history_expansion_p && instream == stdin
      && ISATTY (instream))
    {
      char *history_value;
      int expanded;

      *p = '\0';		/* Insert null now.  */
      expanded = history_expand (linebuffer, &history_value);
      if (expanded)
	{
	  /* Print the changes.  */
	  printf_unfiltered ("%s\n", history_value);

	  /* If there was an error, call this function again.  */
	  if (expanded < 0)
	    {
	      xfree (history_value);
	      return;
	    }
	  if (strlen (history_value) > linelength)
	    {
	      linelength = strlen (history_value) + 1;
	      linebuffer = (char *) xrealloc (linebuffer, linelength);
	    }
	  strcpy (linebuffer, history_value);
	  p = linebuffer + strlen (linebuffer);
	  xfree (history_value);
	}
    }

  /* If we just got an empty line, and that is supposed
     to repeat the previous command, return the value in the
     global buffer.  */
  if (repeat && p == linebuffer && *p != '\\')
    {
      command_handler (line);
      display_gdb_prompt (0);
      return;
    }

  for (p1 = linebuffer; *p1 == ' ' || *p1 == '\t'; p1++);
  if (repeat && !*p1)
    {
      command_handler (line);
      display_gdb_prompt (0);
      return;
    }

  *p = 0;

  /* Add line to history if appropriate.  */
  if (instream == stdin
      && ISATTY (stdin) && *linebuffer)
    add_history (linebuffer);

  /* Note: lines consisting solely of comments are added to the command
     history.  This is useful when you type a command, and then
     realize you don't want to execute it quite yet.  You can comment
     out the command and then later fetch it from the value history
     and remove the '#'.  The kill ring is probably better, but some
     people are in the habit of commenting things out.  */
  if (*p1 == '#')
    *p1 = '\0';			/* Found a comment. */

  /* Save into global buffer if appropriate.  */
  if (repeat)
    {
      if (linelength > linesize)
	{
	  line = xrealloc (line, linelength);
	  linesize = linelength;
	}
      strcpy (line, linebuffer);
      if (!more_to_come)
	{
	  command_handler (line);
	  display_gdb_prompt (0);
	}
      return;
    }

  command_handler (linebuffer);
  display_gdb_prompt (0);
  return;
}