~ubuntu-branches/debian/jessie/gdb/jessie

« back to all changes in this revision

Viewing changes to gdb/cli/cli-script.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Jacobowitz
  • Date: 2010-03-20 01:21:29 UTC
  • mfrom: (1.3.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20100320012129-t7h25y8zgr8c2369
Tags: 7.1-1
* New upstream release, including:
  - PIE support (Closes: #346409).
  - C++ improvements, including static_cast<> et al, namespace imports,
    and bug fixes in printing virtual base classes.
  - Multi-program debugging.  One GDB can now debug multiple programs
    at the same time.
  - Python scripting improvements, including gdb.parse_and_eval.
  - Updated MIPS Linux signal frame layout (Closes: #570875).
  - No internal error stepping over _dl_debug_state (Closes: #569551).
* Update to Standards-Version: 3.8.4 (no changes required).
* Include more relevant (and smaller) docs in the gdbserver package
  (Closes: #571132).
* Do not duplicate documentation in gdb64, gdb-source, and libgdb-dev.
* Fix crash when switching into TUI mode (Closes: #568489).

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 
3
3
   Copyright (c) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
4
4
   1996, 1997, 1998, 1999, 2000, 2001, 2002, 2004, 2005, 2006, 2007, 2008,
5
 
   2009 Free Software Foundation, Inc.
 
5
   2009, 2010 Free Software Foundation, Inc.
6
6
 
7
7
   This file is part of GDB.
8
8
 
878
878
static enum misc_command_type
879
879
process_next_line (char *p, struct command_line **command, int parse_commands)
880
880
{
881
 
  char *p1;
 
881
  char *p_end;
 
882
  char *p_start;
882
883
  int not_handled = 0;
883
884
 
884
885
  /* Not sure what to do here.  */
885
886
  if (p == NULL)
886
887
    return end_command;
887
888
 
888
 
  if (parse_commands)
889
 
    {
890
 
      /* Strip leading whitespace.  */
891
 
      while (*p == ' ' || *p == '\t')
892
 
        p++;
893
 
    }
894
 
 
895
889
  /* Strip trailing whitespace.  */
896
 
  p1 = p + strlen (p);
897
 
  while (p1 != p && (p1[-1] == ' ' || p1[-1] == '\t'))
898
 
    p1--;
899
 
 
900
 
  /* Is this the end of a simple, while, or if control structure?  */
901
 
  if (p1 - p == 3 && !strncmp (p, "end", 3))
 
890
  p_end = p + strlen (p);
 
891
  while (p_end > p && (p_end[-1] == ' ' || p_end[-1] == '\t'))
 
892
    p_end--;
 
893
 
 
894
  p_start = p;
 
895
  /* Strip leading whitespace.  */
 
896
  while (p_start < p_end && (*p_start == ' ' || *p_start == '\t'))
 
897
    p_start++;
 
898
 
 
899
  /* 'end' is always recognized, regardless of parse_commands value. 
 
900
     We also permit whitespace before end and after.  */
 
901
  if (p_end - p_start == 3 && !strncmp (p_start, "end", 3))
902
902
    return end_command;
903
 
 
 
903
  
904
904
  if (parse_commands)
905
905
    {
 
906
      /* If commands are parsed, we skip initial spaces. Otherwise,
 
907
         which is the case for Python commands and documentation
 
908
         (see the 'document' command), spaces are preserved.  */
 
909
      p = p_start;
 
910
 
906
911
      /* Blanks and comments don't really do anything, but we need to
907
912
         distinguish them from else, end and other commands which can be
908
913
         executed.  */
909
 
      if (p1 == p || p[0] == '#')
 
914
      if (p_end == p || p[0] == '#')
910
915
        return nop_command;
911
916
 
912
917
      /* Is the else clause of an if control structure?  */
913
 
      if (p1 - p == 4 && !strncmp (p, "else", 4))
 
918
      if (p_end - p == 4 && !strncmp (p, "else", 4))
914
919
        return else_command;
915
920
 
916
921
      /* Check for while, if, break, continue, etc and build a new command
917
922
         line structure for them.  */
918
 
      if (p1 - p > 5 && !strncmp (p, "while", 5))
 
923
      if (p_end - p > 5 && !strncmp (p, "while", 5))
919
924
        {
920
925
          char *first_arg;
921
926
          first_arg = p + 5;
922
 
          while (first_arg < p1 && isspace (*first_arg))
 
927
          while (first_arg < p_end && isspace (*first_arg))
923
928
            first_arg++;
924
929
          *command = build_command_line (while_control, first_arg);
925
930
        }
926
 
      else if (p1 - p > 2 && !strncmp (p, "if", 2))
 
931
      else if (p_end - p > 2 && !strncmp (p, "if", 2))
927
932
        {
928
933
          char *first_arg;
929
934
          first_arg = p + 2;
930
 
          while (first_arg < p1 && isspace (*first_arg))
 
935
          while (first_arg < p_end && isspace (*first_arg))
931
936
            first_arg++;
932
937
          *command = build_command_line (if_control, first_arg);
933
938
        }
934
 
      else if (p1 - p >= 8 && !strncmp (p, "commands", 8))
 
939
      else if (p_end - p >= 8 && !strncmp (p, "commands", 8))
935
940
        {
936
941
          char *first_arg;
937
942
          first_arg = p + 8;
938
 
          while (first_arg < p1 && isspace (*first_arg))
 
943
          while (first_arg < p_end && isspace (*first_arg))
939
944
            first_arg++;
940
945
          *command = build_command_line (commands_control, first_arg);
941
946
        }
942
 
      else if (p1 - p == 6 && !strncmp (p, "python", 6))
 
947
      else if (p_end - p == 6 && !strncmp (p, "python", 6))
943
948
        {
944
949
          /* Note that we ignore the inline "python command" form
945
950
             here.  */
946
951
          *command = build_command_line (python_control, "");
947
952
        }
948
 
      else if (p1 - p == 10 && !strncmp (p, "loop_break", 10))
 
953
      else if (p_end - p == 10 && !strncmp (p, "loop_break", 10))
949
954
        {
950
955
          *command = (struct command_line *)
951
956
            xmalloc (sizeof (struct command_line));
955
960
          (*command)->body_count = 0;
956
961
          (*command)->body_list = NULL;
957
962
        }
958
 
      else if (p1 - p == 13 && !strncmp (p, "loop_continue", 13))
 
963
      else if (p_end - p == 13 && !strncmp (p, "loop_continue", 13))
959
964
        {
960
965
          *command = (struct command_line *)
961
966
            xmalloc (sizeof (struct command_line));
975
980
      *command = (struct command_line *)
976
981
        xmalloc (sizeof (struct command_line));
977
982
      (*command)->next = NULL;
978
 
      (*command)->line = savestring (p, p1 - p);
 
983
      (*command)->line = savestring (p, p_end - p);
979
984
      (*command)->control_type = simple_control;
980
985
      (*command)->body_count = 0;
981
986
      (*command)->body_list = NULL;