This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Part 2 of Objective-C support


These represent the majority of the changes that can be 
merged without requiring objc-lang.c or objc.tab.c to be
linked.
2002-09-18  Michael Snyder  <msnyder@redhat.com>

	Preliminary support for Objective-C:
	* defs.h (language_objc): New enum value.
	(puts_filtered_tabular): Declaration only, exported from utils.c.
	(skip_quoted): Delete, declared in completer.h.
	* c-exp.y: Include completer.h.
	* p-exp.y: Ditto.
	* jv-exp.y: Ditto.
	* expression.h (OP_MSGCALL, OP_SELECTOR, OP_SELF, OP_NSSTRING): 
	New operator enum values.
	* language.h (CAST_IS_CONVERSION): Test for language_objc.
	* language.c (binop_result_type): Handle language_objc case.
	(integral_type, character_type, string_type, boolean_type,
	structured_type, binop_type_check): Ditto.
	* symtab.h (SYMBOL_OBJC_DEMANGLED_NAME): Define.
	(struct objc_specific): Add to general_symbol_info.
	(SYMBOL_INIT_LANGUAGE_SPECIFIC): Add objc initialization.
	(SYMBOL_DEMANGLED_NAME): Handle objc case.
	* parser-defs.h (struct objc_class_str): New struct type.
	(start_msglist, end_msglist, add_msglist): Declaration only,
	exported from objc-lang.c.
	* value.h (value_of_local, value_nsstring, 
	call_function_by_hand_expecting_type): Exported from valops.c.
	* valops.c (find_function_addr): Export.
	(call_function_by_hand_expecting_type): New function.
	(value_of_local): New function.
	* symfile.c (init_filename_language_table): Add ".m" extension
	for Objective-C.
	* utils.c (puts_filtered_tabular): New function.
	(fprintf_symbol_filtered): Add objc demangling support (disabled).
	(set/show demangle): Extend help-string to refer to ObjC.
	* elfread.c (elf_symtab_read): Skip Objective-C special symbols.
	* stabsread.c (symbol_reference_defined): Objective-C symbols
	may contain colons: make allowances when scanning stabs strings
	for colons.
	(objc_find_colon): New function.
	* printcmd.c (address_info): If language == objc then print
	"self" instead of "this".
	* parse.c (length_of_subexp): Handle new operators OP_MSGCALL,
	OP_NSSTRING, and OP_SELF.
	(prefixify_subexp): Ditto.
	* source.c (print_source_lines): Mention objc in comment.
	* breakpoint.c (parse_breakpoint_sals): Recognize Objective-C
	method names.

Index: defs.h
===================================================================
RCS file: /cvs/src/src/gdb/defs.h,v
retrieving revision 1.94
diff -p -r1.94 defs.h
*** defs.h	1 Aug 2002 17:18:32 -0000	1.94
--- defs.h	19 Sep 2002 00:41:45 -0000
*************** enum language
*** 208,213 ****
--- 208,214 ----
      language_auto,		/* Placeholder for automatic setting */
      language_c,			/* C */
      language_cplus,		/* C++ */
+     language_objc,		/* Objective-C */
      language_java,		/* Java */
      /* OBSOLETE language_chill,	*/	/* Chill */
      language_fortran,		/* Fortran */
*************** extern void puts_filtered (const char *)
*** 445,450 ****
--- 446,453 ----
  
  extern void puts_unfiltered (const char *);
  
+ extern void puts_filtered_tabular (char *string, int width, int right);
+ 
  extern void puts_debug (char *prefix, char *string, char *suffix);
  
  extern void vprintf_filtered (const char *, va_list) ATTR_FORMAT (printf, 1, 0);
*************** extern void print_transfer_performance (
*** 530,537 ****
  /* From top.c */
  
  typedef void initialize_file_ftype (void);
- 
- extern char *skip_quoted (char *);
  
  extern char *gdb_readline (char *);
  
--- 533,538 ----
Index: expression.h
===================================================================
RCS file: /cvs/src/src/gdb/expression.h,v
retrieving revision 1.4
diff -p -r1.4 expression.h
*** expression.h	1 Aug 2002 17:18:32 -0000	1.4
--- expression.h	19 Sep 2002 00:41:45 -0000
*************** enum exp_opcode
*** 181,186 ****
--- 181,192 ----
         making three exp_elements.  */
      OP_FUNCALL,
  
+     /* OP_MSGCALL is followed by a string in the next exp_element and then an
+        integer.  The string is the selector string.  The integer is the number
+        of arguments to the message call.  That many plus one values are used, 
+        the first one being the object pointer.  This is an Objective C message */
+     OP_MSGCALL,
+ 
      /* This is EXACTLY like OP_FUNCALL but is semantically different.  
         In F77, array subscript expressions, substring expressions
         and function calls are  all exactly the same syntactically. They may 
*************** enum exp_opcode
*** 273,283 ****
      STRUCTOP_STRUCT,
      STRUCTOP_PTR,
  
!     /* C++ */
!     /* OP_THIS is just a placeholder for the class instance variable.
         It just comes in a tight (OP_THIS, OP_THIS) pair.  */
      OP_THIS,
  
      /* OP_SCOPE surrounds a type name and a field name.  The type
         name is encoded as one element, but the field name stays as
         a string, which, of course, is variable length.  */
--- 279,296 ----
      STRUCTOP_STRUCT,
      STRUCTOP_PTR,
  
!     /* C++: 
!        OP_THIS is just a placeholder for the class instance variable.
         It just comes in a tight (OP_THIS, OP_THIS) pair.  */
      OP_THIS,
  
+     /* Objective C: "@selector" pseudo-operator */
+     OP_SELECTOR,
+ 
+     /* Objective C: OP_SELF is just a placeholder for the class instance 
+        variable.  It just comes in a tight (OP_SELF, OP_SELF) pair.  */
+     OP_SELF,
+ 
      /* OP_SCOPE surrounds a type name and a field name.  The type
         name is encoded as one element, but the field name stays as
         a string, which, of course, is variable length.  */
*************** enum exp_opcode
*** 305,311 ****
      OP_NAME,
  
      /* An unparsed expression.  Used for Scheme (for now at least) */
!     OP_EXPRSTRING
    };
  
  union exp_element
--- 318,327 ----
      OP_NAME,
  
      /* An unparsed expression.  Used for Scheme (for now at least) */
!     OP_EXPRSTRING,
! 
!     /* An Objective C Foundation Class NSString constant */
!     OP_NSSTRING
    };
  
  union exp_element
*************** extern struct block *innermost_block;
*** 350,356 ****
  
  /* From eval.c */
  
! /* Values of NOSIDE argument to eval_subexp.  */
  
  enum noside
    {
--- 366,372 ----
  
  /* From eval.c */
  
! /* Values of NOSIDE argument to evaluate_subexp.  */
  
  enum noside
    {
Index: language.h
===================================================================
RCS file: /cvs/src/src/gdb/language.h,v
retrieving revision 1.11
diff -p -r1.11 language.h
*** language.h	1 Aug 2002 17:18:32 -0000	1.11
--- language.h	19 Sep 2002 00:43:20 -0000
*************** language_mode;
*** 288,294 ****
  /* "cast" really means conversion */
  /* FIXME -- should be a setting in language_defn */
  #define CAST_IS_CONVERSION (current_language->la_language == language_c  || \
! 			    current_language->la_language == language_cplus)
  
  extern void language_info (int);
  
--- 288,295 ----
  /* "cast" really means conversion */
  /* FIXME -- should be a setting in language_defn */
  #define CAST_IS_CONVERSION (current_language->la_language == language_c  || \
! 			    current_language->la_language == language_cplus || \
! 			    current_language->la_language == language_objc)
  
  extern void language_info (int);
  
Index: parser-defs.h
===================================================================
RCS file: /cvs/src/src/gdb/parser-defs.h,v
retrieving revision 1.11
diff -p -r1.11 parser-defs.h
*** parser-defs.h	24 Jul 2002 03:03:52 -0000	1.11
--- parser-defs.h	19 Sep 2002 00:43:53 -0000
*************** struct symtoken
*** 79,84 ****
--- 79,92 ----
      int is_a_field_of_this;
    };
  
+ struct objc_class_str
+   {
+     struct stoken stoken;
+     struct type *type;
+     int class;
+   };
+ 
+ 
  /* For parsing of complicated types.
     An array should be preceded in the list by the size of the array.  */
  enum type_pieces
*************** struct op_print
*** 215,220 ****
--- 223,233 ----
     and builtin regs. */
  
  extern int target_map_name_to_register (char *, int);
+ 
+ /* for parsing Objective C */
+ extern void start_msglist (void);
+ extern void add_msglist (struct stoken *str, int addcolon);
+ extern int end_msglist (void);
  
  /* Function used to avoid direct calls to fprintf
     in the code generated by the bison parser.  */
Index: value.h
===================================================================
RCS file: /cvs/src/src/gdb/value.h,v
retrieving revision 1.34
diff -p -r1.34 value.h
*** value.h	13 Sep 2002 00:18:33 -0000	1.34
--- value.h	19 Sep 2002 00:45:26 -0000
*************** extern void clear_value_history (void);
*** 535,540 ****
--- 535,546 ----
  
  extern void clear_internalvars (void);
  
+ /* Objective-C */
+ 
+ extern struct value *value_of_local (const char *name, int complain);
+ 
+ extern struct value *value_nsstring (char *ptr, int len);
+ 
  /* From values.c */
  
  extern struct value *value_copy (struct value *);
*************** extern struct value *value_slice (struct
*** 548,553 ****
--- 554,563 ----
  extern struct value *call_function_by_hand (struct value *, int,
  					    struct value **);
  
+ extern struct value *call_function_by_hand_expecting_type (struct value *,
+ 						       struct type *, int,
+ 						       struct value **, int);
+ 
  extern int default_coerce_float_to_double (struct type *, struct type *);
  
  extern int standard_coerce_float_to_double (struct type *, struct type *);
*************** extern struct value *value_allocate_spac
*** 565,569 ****
--- 575,581 ----
  extern CORE_ADDR default_push_arguments (int nargs, struct value ** args,
  					 CORE_ADDR sp, int struct_return,
  					 CORE_ADDR struct_addr);
+ 
+ extern CORE_ADDR find_function_addr (struct value *, struct type **);
  
  #endif /* !defined (VALUE_H) */
Index: c-exp.y
===================================================================
RCS file: /cvs/src/src/gdb/c-exp.y,v
retrieving revision 1.12
diff -p -r1.12 c-exp.y
*** c-exp.y	3 Sep 2002 02:45:56 -0000	1.12
--- c-exp.y	19 Sep 2002 00:54:37 -0000
*************** Foundation, Inc., 59 Temple Place - Suit
*** 49,54 ****
--- 49,55 ----
  #include "bfd.h" /* Required by objfiles.h.  */
  #include "symfile.h" /* Required by objfiles.h.  */
  #include "objfiles.h" /* For have_full_symbols and have_partial_symbols */
+ #include "completer.h" /* For skip_quoted().  */
  
  /* Flag indicating we're dealing with HP-compiled objects */ 
  extern int hp_som_som_object_present;
Index: jv-exp.y
===================================================================
RCS file: /cvs/src/src/gdb/jv-exp.y,v
retrieving revision 1.9
diff -p -r1.9 jv-exp.y
*** jv-exp.y	3 Sep 2002 02:45:56 -0000	1.9
--- jv-exp.y	19 Sep 2002 00:54:46 -0000
*************** Foundation, Inc., 59 Temple Place - Suit
*** 48,53 ****
--- 48,54 ----
  #include "bfd.h" /* Required by objfiles.h.  */
  #include "symfile.h" /* Required by objfiles.h.  */
  #include "objfiles.h" /* For have_full_symbols and have_partial_symbols */
+ #include "completer.h" /* For skip_quoted().  */
  
  /* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc),
     as well as gratuitiously global symbol names, so we can have multiple
Index: p-exp.y
===================================================================
RCS file: /cvs/src/src/gdb/p-exp.y,v
retrieving revision 1.13
diff -p -r1.13 p-exp.y
*** p-exp.y	3 Sep 2002 02:45:56 -0000	1.13
--- p-exp.y	19 Sep 2002 00:54:49 -0000
*************** Foundation, Inc., 59 Temple Place - Suit
*** 56,61 ****
--- 56,62 ----
  #include "bfd.h" /* Required by objfiles.h.  */
  #include "symfile.h" /* Required by objfiles.h.  */
  #include "objfiles.h" /* For have_full_symbols and have_partial_symbols */
+ #include "completer.h" /* For skip_quoted().  */
  
  /* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc),
     as well as gratuitiously global symbol names, so we can have multiple
Index: valops.c
===================================================================
RCS file: /cvs/src/src/gdb/valops.c,v
retrieving revision 1.73
diff -p -r1.73 valops.c
*** valops.c	18 Sep 2002 15:37:18 -0000	1.73
--- valops.c	19 Sep 2002 00:58:48 -0000
*************** extern int overload_debug;
*** 48,57 ****
  static int typecmp (int staticp, int varargs, int nargs,
  		    struct field t1[], struct value *t2[]);
  
- static CORE_ADDR find_function_addr (struct value *, struct type **);
  static struct value *value_arg_coerce (struct value *, struct type *, int);
  
- 
  static CORE_ADDR value_push (CORE_ADDR, struct value *);
  
  static struct value *search_struct_field (char *, struct value *, int,
--- 48,55 ----
*************** int overload_resolution = 0;
*** 91,97 ****
  int unwind_on_signal_p = 0;
  
  
- 
  /* Find the address of function name NAME in the inferior.  */
  
  struct value *
--- 89,94 ----
*************** value_arg_coerce (struct value *arg, str
*** 1219,1225 ****
  /* Determine a function's address and its return type from its value.
     Calls error() if the function is not valid for calling.  */
  
! static CORE_ADDR
  find_function_addr (struct value *function, struct type **retval_type)
  {
    register struct type *ftype = check_typedef (VALUE_TYPE (function));
--- 1216,1222 ----
  /* Determine a function's address and its return type from its value.
     Calls error() if the function is not valid for calling.  */
  
! CORE_ADDR
  find_function_addr (struct value *function, struct type **retval_type)
  {
    register struct type *ftype = check_typedef (VALUE_TYPE (function));
*************** call_function_by_hand (struct value *fun
*** 1889,1894 ****
--- 1886,1908 ----
        error ("Cannot invoke functions on this machine.");
      }
  }
+ 
+ struct value *
+ call_function_by_hand_expecting_type (struct value *function, 
+ 				      struct type *expect_type,
+                                       int nargs, struct value **args, 
+ 				      int restore_frame)
+ {
+   if (CALL_DUMMY_P)
+     {
+       /* FIXME: Changes to func not implemented yet */
+       return hand_function_call (function, nargs, args);
+     }
+   else
+     {
+       error ("Cannot invoke functions on this machine.");
+     }
+ }
  
  
  
*************** value_full_object (struct value *argp, s
*** 3303,3323 ****
    return new_val;
  }
  
! 
! 
! 
! /* C++: return the value of the class instance variable, if one exists.
     Flag COMPLAIN signals an error if the request is made in an
     inappropriate context.  */
  
  struct value *
! value_of_this (int complain)
  {
    struct symbol *func, *sym;
    struct block *b;
    int i;
!   static const char funny_this[] = "this";
!   struct value *this;
  
    if (selected_frame == 0)
      {
--- 3317,3333 ----
    return new_val;
  }
  
! /* Return the value of the local variable, if one exists.
     Flag COMPLAIN signals an error if the request is made in an
     inappropriate context.  */
  
  struct value *
! value_of_local (const char *name, int complain)
  {
    struct symbol *func, *sym;
    struct block *b;
    int i;
!   struct value * ret;
  
    if (selected_frame == 0)
      {
*************** value_of_this (int complain)
*** 3331,3337 ****
    if (!func)
      {
        if (complain)
! 	error ("no `this' in nameless context");
        else
  	return 0;
      }
--- 3341,3347 ----
    if (!func)
      {
        if (complain)
! 	error ("no %s in nameless context", name);
        else
  	return 0;
      }
*************** value_of_this (int complain)
*** 3341,3366 ****
    if (i <= 0)
      {
        if (complain)
! 	error ("no args, no `this'");
        else
  	return 0;
      }
  
    /* Calling lookup_block_symbol is necessary to get the LOC_REGISTER
       symbol instead of the LOC_ARG one (if both exist).  */
!   sym = lookup_block_symbol (b, funny_this, NULL, VAR_NAMESPACE);
    if (sym == NULL)
      {
        if (complain)
! 	error ("current stack frame not in method");
        else
  	return NULL;
      }
  
!   this = read_var_value (sym, selected_frame);
!   if (this == 0 && complain)
!     error ("`this' argument at unknown address");
!   return this;
  }
  
  /* Create a slice (sub-string, sub-array) of ARRAY, that is LENGTH elements
--- 3351,3389 ----
    if (i <= 0)
      {
        if (complain)
! 	error ("no args, no %s", name);
        else
  	return 0;
      }
  
    /* Calling lookup_block_symbol is necessary to get the LOC_REGISTER
       symbol instead of the LOC_ARG one (if both exist).  */
!   sym = lookup_block_symbol (b, name, NULL, VAR_NAMESPACE);
    if (sym == NULL)
      {
        if (complain)
! 	error ("current stack frame does not contain a variable named \"%s\"", name);
        else
  	return NULL;
      }
  
!   ret = read_var_value (sym, selected_frame);
!   if (ret == 0 && complain)
!     error ("%s argument unreadable", name);
!   return ret;
! }
! 
! /* C++/Objective-C: return the value of the class instance variable,
!    if one exists.  Flag COMPLAIN signals an error if the request is
!    made in an inappropriate context.  */
! 
! struct value *
! value_of_this (int complain)
! {
!   if (current_language->la_language == language_objc)
!     return value_of_local ("self", complain);
!   else
!     return value_of_local ("this", complain);
  }
  
  /* Create a slice (sub-string, sub-array) of ARRAY, that is LENGTH elements
Index: symtab.h
===================================================================
RCS file: /cvs/src/src/gdb/symtab.h,v
retrieving revision 1.39
diff -p -r1.39 symtab.h
*** symtab.h	12 Sep 2002 19:19:37 -0000	1.39
--- symtab.h	19 Sep 2002 01:04:37 -0000
*************** struct general_symbol_info
*** 89,94 ****
--- 89,99 ----
        char *demangled_name;
      }
      cplus_specific;
+     struct objc_specific
+     {
+       char *demangled_name;
+     }
+     objc_specific;
  #if 0
  /* OBSOLETE struct chill_specific        *//* For Chill */
      /* OBSOLETE   { */
*************** extern CORE_ADDR symbol_overlayed_addres
*** 146,151 ****
--- 151,160 ----
        {									\
  	SYMBOL_CPLUS_DEMANGLED_NAME (symbol) = NULL;			\
        }									\
+     else if (SYMBOL_LANGUAGE (symbol) == language_objc)			\
+       {									\
+ 	SYMBOL_OBJC_DEMANGLED_NAME (symbol) = NULL;			\
+       }									\
      /* OBSOLETE else if (SYMBOL_LANGUAGE (symbol) == language_chill) */ \
      /* OBSOLETE   { */						 	\
      /* OBSOLETE     SYMBOL_CHILL_DEMANGLED_NAME (symbol) = NULL; */	\
*************** extern void symbol_init_demangled_name (
*** 170,181 ****
    (SYMBOL_LANGUAGE (symbol) == language_cplus				\
     || SYMBOL_LANGUAGE (symbol) == language_java				\
     ? SYMBOL_CPLUS_DEMANGLED_NAME (symbol)				\
     : /* OBSOLETE (SYMBOL_LANGUAGE (symbol) == language_chill */		\
       /* OBSOLETE ? SYMBOL_CHILL_DEMANGLED_NAME (symbol) */		\
!      NULL)
  
  /* OBSOLETE #define SYMBOL_CHILL_DEMANGLED_NAME(symbol) */
  /* OBSOLETE (symbol)->ginfo.language_specific.chill_specific.demangled_name */
  
  /* Macro that returns the "natural source name" of a symbol.  In C++ this is
     the "demangled" form of the name if demangle is on and the "mangled" form
--- 179,195 ----
    (SYMBOL_LANGUAGE (symbol) == language_cplus				\
     || SYMBOL_LANGUAGE (symbol) == language_java				\
     ? SYMBOL_CPLUS_DEMANGLED_NAME (symbol)				\
+       : (SYMBOL_LANGUAGE (symbol) == language_objc			\
+          ? SYMBOL_OBJC_DEMANGLED_NAME (symbol)				\
     : /* OBSOLETE (SYMBOL_LANGUAGE (symbol) == language_chill */		\
       /* OBSOLETE ? SYMBOL_CHILL_DEMANGLED_NAME (symbol) */		\
! 	 NULL))
  
  /* OBSOLETE #define SYMBOL_CHILL_DEMANGLED_NAME(symbol) */
  /* OBSOLETE (symbol)->ginfo.language_specific.chill_specific.demangled_name */
+ 
+ #define SYMBOL_OBJC_DEMANGLED_NAME(symbol)				\
+    (symbol)->ginfo.language_specific.objc_specific.demangled_name
  
  /* Macro that returns the "natural source name" of a symbol.  In C++ this is
     the "demangled" form of the name if demangle is on and the "mangled" form
Index: symfile.c
===================================================================
RCS file: /cvs/src/src/gdb/symfile.c,v
retrieving revision 1.65
diff -p -r1.65 symfile.c
*** symfile.c	1 Aug 2002 17:18:32 -0000	1.65
--- symfile.c	19 Sep 2002 01:09:13 -0000
*************** init_filename_language_table (void)
*** 1966,1971 ****
--- 1966,1972 ----
        /* OBSOLETE add_filename_language (".ch", language_chill); */
        /* OBSOLETE add_filename_language (".c186", language_chill); */
        /* OBSOLETE add_filename_language (".c286", language_chill); */
+       add_filename_language (".m", language_objc);
        add_filename_language (".f", language_fortran);
        add_filename_language (".F", language_fortran);
        add_filename_language (".s", language_asm);
Index: utils.c
===================================================================
RCS file: /cvs/src/src/gdb/utils.c,v
retrieving revision 1.76
diff -p -r1.76 utils.c
*** utils.c	1 Aug 2002 17:18:33 -0000	1.76
--- utils.c	19 Sep 2002 01:12:08 -0000
*************** int quit_flag;
*** 152,164 ****
  
  int immediate_quit;
  
! /* Nonzero means that encoded C++ names should be printed out in their
!    C++ form rather than raw.  */
  
  int demangle = 1;
  
! /* Nonzero means that encoded C++ names should be printed out in their
!    C++ form even in assembler language displays.  If this is set, but
     DEMANGLE is zero, names are printed raw, i.e. DEMANGLE controls.  */
  
  int asm_demangle = 0;
--- 152,164 ----
  
  int immediate_quit;
  
! /* Nonzero means that encoded C++/ObjC names should be printed out in their
!    C++/ObjC form rather than raw.  */
  
  int demangle = 1;
  
! /* Nonzero means that encoded C++/ObjC names should be printed out in their
!    C++/ObjC form even in assembler language displays.  If this is set, but
     DEMANGLE is zero, names are printed raw, i.e. DEMANGLE controls.  */
  
  int asm_demangle = 0;
*************** make_my_cleanup (struct cleanup **pmy_ch
*** 276,282 ****
  		 void *arg)
  {
    register struct cleanup *new
!   = (struct cleanup *) xmalloc (sizeof (struct cleanup));
    register struct cleanup *old_chain = *pmy_chain;
  
    new->next = *pmy_chain;
--- 276,282 ----
  		 void *arg)
  {
    register struct cleanup *new
!     = (struct cleanup *) xmalloc (sizeof (struct cleanup));
    register struct cleanup *old_chain = *pmy_chain;
  
    new->next = *pmy_chain;
*************** wrap_here (char *indent)
*** 1696,1701 ****
--- 1696,1746 ----
      }
  }
  
+ /* Print input string to gdb_stdout, filtered, with wrap, 
+    arranging strings in columns of n chars. String can be
+    right or left justified in the column.  Never prints 
+    trailing spaces.  String should never be longer than
+    width.  FIXME: this could be useful for the EXAMINE 
+    command, which currently doesn't tabulate very well.  */
+ 
+ void
+ puts_filtered_tabular (char *string, int width, int right)
+ {
+   int spaces = 0;
+   int stringlen;
+   char *spacebuf;
+ 
+   gdb_assert (chars_per_line > 0);
+   if (chars_per_line == UINT_MAX)
+     {
+       fputs_filtered (string, gdb_stdout);
+       fputs_filtered ("\n", gdb_stdout);
+       return;
+     }
+ 
+   if (((chars_printed - 1) / width + 2) * width >= chars_per_line)
+     fputs_filtered ("\n", gdb_stdout);
+ 
+   if (width >= chars_per_line)
+     width = chars_per_line - 1;
+ 
+   stringlen = strlen (string);
+ 
+   if (chars_printed > 0)
+     spaces = width - (chars_printed - 1) % width - 1;
+   if (right)
+     spaces += width - stringlen;
+ 
+   spacebuf = alloca (spaces + 1);
+   spacebuf[spaces] = '\0';
+   while (spaces--)
+     spacebuf[spaces] = ' ';
+ 
+   fputs_filtered (spacebuf, gdb_stdout);
+   fputs_filtered (string, gdb_stdout);
+ }
+ 
+ 
  /* Ensure that whatever gets printed next, using the filtered output
     commands, starts at the beginning of the line.  I.E. if there is
     any pending output for the current line, flush it and start a new
*************** print_spaces_filtered (int n, struct ui_
*** 2123,2137 ****
    fputs_filtered (n_spaces (n), stream);
  }
  
! /* C++ demangler stuff.  */
  
! /* fprintf_symbol_filtered attempts to demangle NAME, a symbol in language
!    LANG, using demangling args ARG_MODE, and print it filtered to STREAM.
!    If the name is not mangled, or the language for the name is unknown, or
!    demangling is off, the name is printed in its "raw" form. */
  
  void
! fprintf_symbol_filtered (struct ui_file *stream, char *name, enum language lang,
  			 int arg_mode)
  {
    char *demangled;
--- 2168,2185 ----
    fputs_filtered (n_spaces (n), stream);
  }
  
! /* C++/ObjC demangler stuff.  */
  
! /* fprintf_symbol_filtered attempts to demangle NAME, a symbol in
!    language LANG, using demangling args ARG_MODE, and print it
!    filtered to STREAM.  If the name is not mangled, or the language
!    for the name is unknown, or demangling is off, the name is printed
!    in its "raw" form.  */
  
  void
! fprintf_symbol_filtered (struct ui_file *stream, 
! 			 char *name, 
! 			 enum language lang,
  			 int arg_mode)
  {
    char *demangled;
*************** fprintf_symbol_filtered (struct ui_file 
*** 2153,2158 ****
--- 2201,2211 ----
  	    case language_java:
  	      demangled = cplus_demangle (name, arg_mode | DMGL_JAVA);
  	      break;
+ #if 0 /* Enable once objective-c support is turned on.  */
+ 	    case language_objc:
+ 	      demangled = objc_demangle (name);
+ 	      break;
+ #endif
  #if 0
  	      /* OBSOLETE case language_chill: */
  	      /* OBSOLETE   demangled = chill_demangle (name); */
*************** initialize_utils (void)
*** 2272,2278 ****
    add_show_from_set
      (add_set_cmd ("demangle", class_support, var_boolean,
  		  (char *) &demangle,
! 	     "Set demangling of encoded C++ names when displaying symbols.",
  		  &setprintlist),
       &showprintlist);
  
--- 2325,2331 ----
    add_show_from_set
      (add_set_cmd ("demangle", class_support, var_boolean,
  		  (char *) &demangle,
! 	     "Set demangling of encoded C++/ObjC names when displaying symbols.",
  		  &setprintlist),
       &showprintlist);
  
*************** initialize_utils (void)
*** 2300,2306 ****
    add_show_from_set
      (add_set_cmd ("asm-demangle", class_support, var_boolean,
  		  (char *) &asm_demangle,
! 		  "Set demangling of C++ names in disassembly listings.",
  		  &setprintlist),
       &showprintlist);
  }
--- 2353,2359 ----
    add_show_from_set
      (add_set_cmd ("asm-demangle", class_support, var_boolean,
  		  (char *) &asm_demangle,
! 		  "Set demangling of C++/ObjC names in disassembly listings.",
  		  &setprintlist),
       &showprintlist);
  }
Index: elfread.c
===================================================================
RCS file: /cvs/src/src/gdb/elfread.c,v
retrieving revision 1.23
diff -p -r1.23 elfread.c
*** elfread.c	24 Jul 2002 23:51:35 -0000	1.23
--- elfread.c	19 Sep 2002 01:16:07 -0000
*************** elf_symtab_read (struct objfile *objfile
*** 349,355 ****
  		}
  	      else if (sym->section->flags & SEC_CODE)
  		{
! 		  if (sym->flags & BSF_GLOBAL)
  		    {
  		      ms_type = mst_text;
  		    }
--- 349,361 ----
  		}
  	      else if (sym->section->flags & SEC_CODE)
  		{
! 		  if (sym->name[0] == '.' 
! 		      && (strncmp (sym->name + 1, "objc_", 4) == 0))
! 		    {
! 		      /* Looks like an Objective-C special symbol */
! 		      continue;
! 		    }
! 		  else if (sym->flags & BSF_GLOBAL)
  		    {
  		      ms_type = mst_text;
  		    }
Index: stabsread.c
===================================================================
RCS file: /cvs/src/src/gdb/stabsread.c,v
retrieving revision 1.39
diff -p -r1.39 stabsread.c
*** stabsread.c	14 Sep 2002 02:09:39 -0000	1.39
--- stabsread.c	19 Sep 2002 01:16:32 -0000
*************** symbol_reference_defined (char **string)
*** 1267,1279 ****
      }
  }
  
  /* ARGSUSED */
  struct symbol *
  define_symbol (CORE_ADDR valu, char *string, int desc, int type,
  	       struct objfile *objfile)
  {
    register struct symbol *sym;
!   char *p = (char *) strchr (string, ':');
    int deftype;
    int synonym = 0;
    register int i;
--- 1267,1303 ----
      }
  }
  
+ static char *
+ objc_find_colon (name)
+      char *name;
+ {
+   char *s = name;
+   if (s[0] == '-' || *s == '+')
+     {
+       if (s[1] != '[')
+ 	{
+ 	  error ("invalid symbol name \"%s\"", name);
+ 	}
+       s = strchr (s, ']');
+       if (s == NULL)
+ 	{
+ 	  error ("invalid symbol name \"%s\"", name);
+ 	}
+       return strchr (s, ':');
+     }
+   else
+     {
+       return strchr (s, ':');
+     }
+ }
+ 
  /* ARGSUSED */
  struct symbol *
  define_symbol (CORE_ADDR valu, char *string, int desc, int type,
  	       struct objfile *objfile)
  {
    register struct symbol *sym;
!   char *p = (char *) objc_find_colon (string);
    int deftype;
    int synonym = 0;
    register int i;
*************** define_symbol (CORE_ADDR valu, char *str
*** 2006,2012 ****
           a typedef for "foo".  Unfortunately, cfront never makes the typedef
           when translating C++ into C.  We make the typedef here so that
           "ptype foo" works as expected for cfront translated code.  */
!       else if (current_subfile->language == language_cplus)
  	synonym = 1;
  
        SYMBOL_TYPE (sym) = read_type (&p, objfile);
--- 2030,2037 ----
           a typedef for "foo".  Unfortunately, cfront never makes the typedef
           when translating C++ into C.  We make the typedef here so that
           "ptype foo" works as expected for cfront translated code.  */
!       else if ((current_subfile->language == language_cplus)
! 	       || (current_subfile->language == language_objc))
  	synonym = 1;
  
        SYMBOL_TYPE (sym) = read_type (&p, objfile);
Index: printcmd.c
===================================================================
RCS file: /cvs/src/src/gdb/printcmd.c,v
retrieving revision 1.41
diff -p -r1.41 printcmd.c
*** printcmd.c	10 Sep 2002 02:04:38 -0000	1.41
--- printcmd.c	19 Sep 2002 01:20:04 -0000
*************** address_info (char *exp, int from_tty)
*** 1104,1110 ****
  	  printf_filtered ("Symbol \"");
  	  fprintf_symbol_filtered (gdb_stdout, exp,
  				   current_language->la_language, DMGL_ANSI);
! 	  printf_filtered ("\" is a field of the local class variable `this'\n");
  	  return;
  	}
  
--- 1104,1114 ----
  	  printf_filtered ("Symbol \"");
  	  fprintf_symbol_filtered (gdb_stdout, exp,
  				   current_language->la_language, DMGL_ANSI);
! 	  printf_filtered ("\" is a field of the local class variable ");
! 	  if (current_language->la_language == language_objc)
! 	    printf_filtered ("'self'\n");	/* ObjC equivalent of "this" */
! 	  else
! 	    printf_filtered ("'this'\n");
  	  return;
  	}
  
Index: parse.c
===================================================================
RCS file: /cvs/src/src/gdb/parse.c,v
retrieving revision 1.25
diff -p -r1.25 parse.c
*** parse.c	21 Jun 2002 14:32:10 -0000	1.25
--- parse.c	19 Sep 2002 01:20:36 -0000
*************** length_of_subexp (register struct expres
*** 867,872 ****
--- 867,877 ----
        args = 1 + longest_to_int (expr->elts[endpos - 2].longconst);
        break;
  
+     case OP_MSGCALL:		/* Objective C message (method) call */
+       oplen = 4;
+       args = 1 + longest_to_int (expr->elts[endpos - 2].longconst);
+       break;
+ 
      case UNOP_MAX:
      case UNOP_MIN:
        oplen = 3;
*************** length_of_subexp (register struct expres
*** 898,903 ****
--- 903,910 ----
        /* fall through */
      case OP_M2_STRING:
      case OP_STRING:
+     case OP_NSSTRING:		/* Objective C Foundation Class NSString constant */
+     case OP_SELECTOR:		/* Objective C "@selector" pseudo-op */
      case OP_NAME:
      case OP_EXPRSTRING:
        oplen = longest_to_int (expr->elts[endpos - 2].longconst);
*************** length_of_subexp (register struct expres
*** 936,941 ****
--- 943,949 ----
  
        /* C++ */
      case OP_THIS:
+     case OP_SELF:
        oplen = 2;
        break;
  
*************** prefixify_subexp (register struct expres
*** 1004,1009 ****
--- 1012,1022 ----
        args = 1 + longest_to_int (inexpr->elts[inend - 2].longconst);
        break;
  
+     case OP_MSGCALL:		/* Objective C message (method) call */
+       oplen = 4;
+       args = 1 + longest_to_int (inexpr->elts[inend - 2].longconst);
+       break;
+ 
      case UNOP_MIN:
      case UNOP_MAX:
        oplen = 3;
*************** prefixify_subexp (register struct expres
*** 1034,1039 ****
--- 1047,1054 ----
        /* fall through */
      case OP_M2_STRING:
      case OP_STRING:
+     case OP_NSSTRING:		/* Objective C Foundation Class NSString constant */
+     case OP_SELECTOR:		/* Objective C "@selector" pseudo-op */
      case OP_NAME:
      case OP_EXPRSTRING:
        oplen = longest_to_int (inexpr->elts[inend - 2].longconst);
*************** prefixify_subexp (register struct expres
*** 1072,1077 ****
--- 1087,1093 ----
  
        /* C++ */
      case OP_THIS:
+     case OP_SELF:
        oplen = 2;
        break;
  
Index: language.c
===================================================================
RCS file: /cvs/src/src/gdb/language.c,v
retrieving revision 1.26
diff -p -r1.26 language.c
*** language.c	1 Aug 2002 17:18:32 -0000	1.26
--- language.c	19 Sep 2002 01:24:59 -0000
*************** binop_result_type (struct value *v1, str
*** 549,554 ****
--- 549,555 ----
      {
      case language_c:
      case language_cplus:
+     case language_objc:
        if (TYPE_CODE (t1) == TYPE_CODE_FLT)
  	return TYPE_CODE (t2) == TYPE_CODE_FLT && l2 > l1 ?
  	  VALUE_TYPE (v2) : VALUE_TYPE (v1);
*************** integral_type (struct type *type)
*** 786,791 ****
--- 787,793 ----
      {
      case language_c:
      case language_cplus:
+     case language_objc:
        return (TYPE_CODE (type) != TYPE_CODE_INT) &&
  	(TYPE_CODE (type) != TYPE_CODE_ENUM) ? 0 : 1;
      case language_m2:
*************** character_type (struct type *type)
*** 828,833 ****
--- 830,836 ----
  
      case language_c:
      case language_cplus:
+     case language_objc:
        return (TYPE_CODE (type) == TYPE_CODE_INT) &&
  	TYPE_LENGTH (type) == sizeof (char)
        ? 1 : 0;
*************** string_type (struct type *type)
*** 850,855 ****
--- 853,859 ----
  
      case language_c:
      case language_cplus:
+     case language_objc:
        /* C does not have distinct string type. */
        return (0);
      default:
*************** boolean_type (struct type *type)
*** 868,873 ****
--- 872,878 ----
      {
      case language_c:
      case language_cplus:
+     case language_objc:
        /* Might be more cleanly handled by having a
           TYPE_CODE_INT_NOT_BOOL for (OBSOLETE) CHILL and such
           languages, or a TYPE_CODE_INT_OR_BOOL for C.  */
*************** structured_type (struct type *type)
*** 904,909 ****
--- 909,915 ----
      {
      case language_c:
      case language_cplus:
+     case language_objc:
        return (TYPE_CODE (type) == TYPE_CODE_STRUCT) ||
  	(TYPE_CODE (type) == TYPE_CODE_UNION) ||
  	(TYPE_CODE (type) == TYPE_CODE_ARRAY);
*************** binop_type_check (struct value *arg1, st
*** 1124,1129 ****
--- 1130,1136 ----
  #ifdef _LANG_c
  	case language_c:
  	case language_cplus:
+ 	case language_objc:
  	  switch (op)
  	    {
  	    case BINOP_DIV:
Index: source.c
===================================================================
RCS file: /cvs/src/src/gdb/source.c,v
retrieving revision 1.29
diff -p -r1.29 source.c
*** source.c	11 Jun 2002 20:36:51 -0000	1.29
--- source.c	19 Sep 2002 01:27:16 -0000
*************** print_source_lines (struct symtab *s, in
*** 1114,1121 ****
  
  /* Print a list of files and line numbers which a user may choose from
     in order to list a function which was specified ambiguously (as with
!    `list classname::overloadedfuncname', for example).  The vector in
!    SALS provides the filenames and line numbers.  */
  
  static void
  ambiguous_line_spec (struct symtabs_and_lines *sals)
--- 1114,1122 ----
  
  /* Print a list of files and line numbers which a user may choose from
     in order to list a function which was specified ambiguously (as with
!    `list classname::overloadedfuncname', or 'list objectiveCSelector:).
!    The vector in SALS provides the filenames and line numbers.
!    NOTE: some of the SALS may have no filename or line information! */
  
  static void
  ambiguous_line_spec (struct symtabs_and_lines *sals)
Index: breakpoint.c
===================================================================
RCS file: /cvs/src/src/gdb/breakpoint.c,v
retrieving revision 1.86
diff -p -r1.86 breakpoint.c
*** breakpoint.c	5 Sep 2002 01:28:14 -0000	1.86
--- breakpoint.c	19 Sep 2002 01:27:38 -0000
*************** parse_breakpoint_sals (char **address,
*** 4618,4630 ****
           current_source_symtab (which is decode_line_1's default).  This
           should produce the results we want almost all of the time while
           leaving default_breakpoint_* alone.  */
        if (default_breakpoint_valid
  	  && (!current_source_symtab
! 	      || (strchr ("+-", (*address)[0]) != NULL)))
  	*sals = decode_line_1 (address, 1, default_breakpoint_symtab,
  			       default_breakpoint_line, addr_string);
        else
! 	*sals = decode_line_1 (address, 1, (struct symtab *) NULL, 0, addr_string);
      }
    /* For any SAL that didn't have a canonical string, fill one in. */
    if (sals->nelts > 0 && *addr_string == NULL)
--- 4618,4633 ----
           current_source_symtab (which is decode_line_1's default).  This
           should produce the results we want almost all of the time while
           leaving default_breakpoint_* alone.  */
+       /* Also ignore objc method name.  FIXME better comment?  */
        if (default_breakpoint_valid
  	  && (!current_source_symtab
! 	      || ((strchr ("+-", (*address)[0]) != NULL)
! 		  && ((*address)[1] != '['))))
  	*sals = decode_line_1 (address, 1, default_breakpoint_symtab,
  			       default_breakpoint_line, addr_string);
        else
! 	*sals = decode_line_1 (address, 1, (struct symtab *) NULL, 
! 			       0, addr_string);
      }
    /* For any SAL that didn't have a canonical string, fill one in. */
    if (sals->nelts > 0 && *addr_string == NULL)

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]