* [PATCH] Objective-C language support.
@ 2002-09-18 8:24 Adam Fedor
2002-09-18 10:50 ` Michael Snyder
` (14 more replies)
0 siblings, 15 replies; 62+ messages in thread
From: Adam Fedor @ 2002-09-18 8:24 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 3011 bytes --]
This patch adds Objective-C language support to gdb based upon a patch
provided by Apple Computer Inc from their version of gdb. Note that the
patch only contains changes to existing files. New files (objc-lang.h,
objc-lang.c, objc-exp.y) and a gdb.objc testsuite directory are located at
ftp://ftp.gnustep.org/pub/gnustep/contrib/gdb-objc-patch.tar.gz
gdb ChangeLog
--------------
2002-09-17 Adam Fedor <fedor@gnu.org>
* Add Objective-C language support to gdb (mostly from a patch
provided by Apple Computer, Inc.).
* Makefile.in: Add rules for objc files. Extra dependencies for
changed files
* breakpoint.c (parse_breakpoint_sals): Ignore ObjC method
names when checking default.
* completer.c (skip_quoted): Take additional argument.
* completer.h: Update definition of skip_quoted.
* c-exp.y: Update for change in skip_quoted.
* jv-exp.y: Likewise.
* p-exp.y: Likewise.
* defs.h (enum language): Add language_objc. Update definitions.
* elfread.c (elf_symtab_read): Skip ObjC symbols.
* expression.h: New ops NSSTRING, SELECTOR, MSGCALL, and SELF.
* eval.c (evaludate_subexp): Remove static attribute.
(evaluate_subexp_standard): Handle new ops.
* expprint.c (print_subexp): Likewise.
(op_name): Likewise.
* parse.c: Likewise.
* infrun.c (handle_inferior_event): Step into ObjC method call.
* language.c (binop_result_type): Add language_objc to case.
(integral_type): Likewise.
(character_type): Likewise.
(string_type): Likewise.
(boolean_type): Likewise.
(structured_type): Likewise.
(binop_type_check): Likewise.
* language.h (CAST_IS_CONVERSION): Likewise.
* linespec.c (decode_line_1): Handle ObjC methods.
* maint.c (maintenance_demangle): Demangle ObjC names.
* objc-exp.y: New file
* objc-lang.h: Likewise.
* objc-lang.c: Likewise.
* parser-defs.h (struct objc_class_str): New struct.
* printfcmd.c (address_info): Print 'self' for ObjC.
* source.c (print_source_lines): Update comments.
* stabsread.c (stabsread_objc_colon): New function.
(define_symbol): Use it.
* stabsread.h: Declare it.
* symfile.c (init_filename_language_table): Add ObjC extensions.
* symtab.h: New objc_specific struct.
(SYMBOL_INIT_LANGUAGE_SPECIFIC): Handle ObjC.
(SYMBOL_DEMANGLED_NAME): Likewise.
* symtab.c (symbol_init_demangled_name): Demangle ObjC symbols.
(make_symbol_completion_list): Likewise.
* utils.c (puts_filtered_tabular): New function.
(fprintf_symbol_filtered): Get ObjC demangled name.
* valops.c (call_function_by_hand_expecting_type): New function.
(value_of_local): New function.
(value_of_this): Use it.
* values.h: Define functions.
gdb/doc ChangeLog:
-----------------
2002-09-17 Adam Fedor <fedor@gnu.org>
* gdb.texinfo: Add ObjC documentation.
gdb/testsuite ChangeLog:
-----------------
2002-09-17 Adam Fedor <fedor@gnu.org>
* configure.in: Add gdb.objc dir
* gdb.base/default.exp: Update for ObjC in output.
* gdb.base/help.exp: Likewise.
* gdb.base/maint.exp: Likewise.
* gdb.objc/: New testsuite dir
[-- Attachment #2: current-gdb-objc.patch --]
[-- Type: text/plain, Size: 78449 bytes --]
Index: gdb/Makefile.in
===================================================================
RCS file: /cvs/src/src/gdb/Makefile.in,v
retrieving revision 1.259
diff -u -p -r1.259 Makefile.in
--- gdb/Makefile.in 17 Sep 2002 04:44:21 -0000 1.259
+++ gdb/Makefile.in 17 Sep 2002 19:29:47 -0000
@@ -680,6 +680,7 @@ mipsnbsd_tdep_h = mipsnbsd-tdep.h
monitor_h = monitor.h
nbsd_tdep_h = nbsd-tdep.h
ns32k_tdep_h = ns32k-tdep.h $(osabi_h)
+objc_lang_h = objc-lang.h
objfiles_h = objfiles.h $(gdb_obstack_h) $(symfile_h)
ocd_h = ocd.h
osabi_h = osabi.h
@@ -832,7 +833,7 @@ COMMON_OBS = version.o blockframe.o brea
exec.o bcache.o objfiles.o minsyms.o maint.o demangle.o \
dbxread.o coffread.o elfread.o \
dwarfread.o dwarf2read.o mipsread.o stabsread.o corefile.o \
- c-lang.o f-lang.o \
+ c-lang.o objc-lang.o f-lang.o \
ui-out.o cli-out.o \
varobj.o wrapper.o \
jv-lang.o jv-valprint.o jv-typeprint.o \
@@ -853,10 +854,13 @@ SUBDIRS = @SUBDIRS@
# For now, shortcut the "configure GDB for fewer languages" stuff.
YYFILES = c-exp.tab.c \
+ objc-exp.tab.c \
ada-exp.tab.c \
jv-exp.tab.c \
f-exp.tab.c m2-exp.tab.c p-exp.tab.c
+
YYOBJ = c-exp.tab.o \
+ objc-exp.tab.o \
jv-exp.tab.o \
f-exp.tab.o m2-exp.tab.o p-exp.tab.o
@@ -1131,6 +1135,7 @@ local-maintainer-clean:
@echo "This command is intended for maintainers to use;"
@echo "it deletes files that may require special tools to rebuild."
rm -f c-exp.tab.c \
+ objc-exp.tab.c \
ada-lex.c ada-exp.tab.c \
jv-exp.tab \
f-exp.tab.c m2-exp.tab.c p-exp.tab.c
@@ -1227,6 +1232,22 @@ c-exp.tab.c: c-exp.y
mv c-exp.new ./c-exp.tab.c
# See comments above ...
+.PRECIOUS: objc-exp.tab.c
+objc-exp.tab.o: objc-exp.tab.c
+objc-exp.tab.c: objc-exp.y
+ $(SHELL) $(YLWRAP) "$(YACC)" $(srcdir)/objc-exp.y y.tab.c objc-exp.tmp -- $(YFLAGS)
+ -sed -e '/extern.*malloc/d' \
+ -e '/extern.*realloc/d' \
+ -e '/extern.*free/d' \
+ -e '/include.*malloc.h/d' \
+ -e 's/malloc/xmalloc/g' \
+ -e 's/realloc/xrealloc/g' \
+ -e '/^#line.*y.tab.c/d' \
+ < objc-exp.tmp > objc-exp.new
+ -rm objc-exp.tmp
+ mv objc-exp.new ./objc-exp.tab.c
+
+# See comments above ...
.PRECIOUS: jv-exp.tab.c
jv-exp.tab.o: jv-exp.tab.c
jv-exp.tab.c: jv-exp.y
@@ -1441,6 +1462,10 @@ c-exp.tab.o: c-exp.tab.c $(defs_h) $(gdb
$(value_h) $(parser_defs_h) $(language_h) $(c_lang_h) $(bfd_h) \
$(symfile_h) $(objfiles_h)
+objc-exp.tab.o: objc-exp.tab.c $(objc_lang_h) $(defs_h) $(expression_h) \
+ $(gdbtypes_h) $(language_h) $(parser_defs_h) $(symtab_h) $(value_h) \
+ $(bfd_h) $(objfiles_h) $(symfile_h)
+
jv-exp.tab.o: jv-exp.tab.c jv-lang.h $(defs_h) $(expression_h) \
$(gdbtypes_h) $(language_h) $(parser_defs_h) $(symtab_h) $(value_h) \
$(bfd_h) $(objfiles_h) $(symfile_h)
@@ -1645,7 +1670,7 @@ elfread.o: elfread.c $(defs_h) $(bfd_h)
environ.o: environ.c $(defs_h) $(environ_h) $(gdb_string_h)
eval.o: eval.c $(defs_h) $(gdb_string_h) $(symtab_h) $(gdbtypes_h) \
$(value_h) $(expression_h) $(target_h) $(frame_h) $(language_h) \
- $(f_lang_h) $(cp_abi_h)
+ $(f_lang_h) $(cp_abi_h) $(objc_lang_h)
event-loop.o: event-loop.c $(defs_h) $(event_loop_h) $(event_top_h) \
$(gdb_string_h)
event-top.o: event-top.c $(defs_h) $(top_h) $(inferior_h) $(target_h) \
@@ -1654,7 +1679,7 @@ exec.o: exec.c $(defs_h) $(frame_h) $(in
$(language_h) $(symfile_h) $(objfiles_h) $(completer_h) $(value_h) \
$(gdb_string_h) $(gdbcore_h) $(gdb_stat_h) $(xcoffsolib_h)
expprint.o: expprint.c $(defs_h) $(symtab_h) $(gdbtypes_h) $(expression_h) \
- $(value_h) $(language_h) $(parser_defs_h)
+ $(value_h) $(language_h) $(parser_defs_h) $(target_h) $(gdb_string_h)
f-lang.o: f-lang.c $(defs_h) $(gdb_string_h) $(symtab_h) $(gdbtypes_h) \
$(expression_h) $(parser_defs_h) $(language_h) $(f_lang_h) \
$(valprint_h)
Index: gdb/breakpoint.c
===================================================================
RCS file: /cvs/src/src/gdb/breakpoint.c,v
retrieving revision 1.86
diff -u -p -r1.86 breakpoint.c
--- gdb/breakpoint.c 5 Sep 2002 01:28:14 -0000 1.86
+++ gdb/breakpoint.c 17 Sep 2002 19:29:52 -0000
@@ -4618,9 +4618,11 @@ parse_breakpoint_sals (char **address,
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 */
if (default_breakpoint_valid
&& (!current_source_symtab
- || (strchr ("+-", (*address)[0]) != NULL)))
+ || ((strchr ("+-", (*address)[0]) != NULL)
+ && ((*address)[1] != '['))))
*sals = decode_line_1 (address, 1, default_breakpoint_symtab,
default_breakpoint_line, addr_string);
else
Index: gdb/c-exp.y
===================================================================
RCS file: /cvs/src/src/gdb/c-exp.y,v
retrieving revision 1.12
diff -u -p -r1.12 c-exp.y
--- gdb/c-exp.y 3 Sep 2002 02:45:56 -0000 1.12
+++ gdb/c-exp.y 17 Sep 2002 19:29:53 -0000
@@ -49,6 +49,7 @@ Foundation, Inc., 59 Temple Place - Suit
#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"
/* Flag indicating we're dealing with HP-compiled objects */
extern int hp_som_som_object_present;
@@ -1321,7 +1322,9 @@ yylex ()
c = *lexptr++;
if (c != '\'')
{
- namelen = skip_quoted (tokstart) - tokstart;
+ namelen = skip_quoted (tokstart,
+ get_gdb_completer_word_break_characters())
+ - tokstart;
if (namelen > 2)
{
lexptr = tokstart + namelen;
Index: gdb/completer.c
===================================================================
RCS file: /cvs/src/src/gdb/completer.c,v
retrieving revision 1.11
diff -u -p -r1.11 completer.c
--- gdb/completer.c 24 Mar 2002 00:40:35 -0000 1.11
+++ gdb/completer.c 17 Sep 2002 19:29:53 -0000
@@ -683,7 +683,7 @@ line_completion_function (char *text, in
location after the "word". */
char *
-skip_quoted (char *str)
+skip_quoted (char *str, char *breakchars)
{
char quote_char = '\0';
char *scan;
@@ -705,7 +705,7 @@ skip_quoted (char *str)
/* Found start of a quoted string. */
quote_char = *scan;
}
- else if (strchr (gdb_completer_word_break_characters, *scan))
+ else if (strchr (breakchars, *scan))
{
break;
}
Index: gdb/completer.h
===================================================================
RCS file: /cvs/src/src/gdb/completer.h,v
retrieving revision 1.6
diff -u -p -r1.6 completer.h
--- gdb/completer.h 18 Feb 2002 01:12:38 -0000 1.6
+++ gdb/completer.h 17 Sep 2002 19:29:53 -0000
@@ -39,6 +39,6 @@ extern char *get_gdb_completer_quote_cha
/* Exported to linespec.c */
-extern char *skip_quoted (char *str);
+extern char *skip_quoted (char *str, char *);
#endif /* defined (COMPLETER_H) */
Index: gdb/defs.h
===================================================================
RCS file: /cvs/src/src/gdb/defs.h,v
retrieving revision 1.94
diff -u -p -r1.94 defs.h
--- gdb/defs.h 1 Aug 2002 17:18:32 -0000 1.94
+++ gdb/defs.h 17 Sep 2002 19:29:59 -0000
@@ -208,6 +208,7 @@ enum language
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 */
@@ -304,6 +305,10 @@ extern int inside_main_func (CORE_ADDR p
/* OBSOLETE extern char *chill_demangle (const char *); */
+/* From objc-lang.c, for the moment. (FIXME) */
+
+extern char *objc_demangle (const char *);
+
/* From utils.c */
extern void initialize_utils (void);
@@ -445,6 +450,8 @@ extern void puts_filtered (const char *)
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);
@@ -531,7 +538,7 @@ extern void print_transfer_performance (
typedef void initialize_file_ftype (void);
-extern char *skip_quoted (char *);
+extern char *skip_quoted (char *, char *);
extern char *gdb_readline (char *);
Index: gdb/elfread.c
===================================================================
RCS file: /cvs/src/src/gdb/elfread.c,v
retrieving revision 1.23
diff -u -p -r1.23 elfread.c
--- gdb/elfread.c 24 Jul 2002 23:51:35 -0000 1.23
+++ gdb/elfread.c 17 Sep 2002 19:29:59 -0000
@@ -349,7 +349,12 @@ elf_symtab_read (struct objfile *objfile
}
else if (sym->section->flags & SEC_CODE)
{
- if (sym->flags & BSF_GLOBAL)
+ 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: gdb/eval.c
===================================================================
RCS file: /cvs/src/src/gdb/eval.c,v
retrieving revision 1.23
diff -u -p -r1.23 eval.c
--- gdb/eval.c 1 Aug 2002 17:18:32 -0000 1.23
+++ gdb/eval.c 17 Sep 2002 19:30:03 -0000
@@ -30,6 +30,7 @@
#include "frame.h"
#include "language.h" /* For CAST_IS_CONVERSION */
#include "f-lang.h" /* for array bound stuff */
+#include "objc-lang.h"
#include "cp-abi.h"
/* Defined in symtab.c */
@@ -49,9 +50,6 @@ static struct value *evaluate_subexp_for
static struct value *evaluate_subexp_for_address (struct expression *,
int *, enum noside);
-static struct value *evaluate_subexp (struct type *, struct expression *,
- int *, enum noside);
-
static char *get_label (struct expression *, int *);
static struct value *evaluate_struct_tuple (struct value *,
@@ -62,7 +60,7 @@ static LONGEST init_array_element (struc
struct expression *, int *, enum noside,
LONGEST, LONGEST);
-static struct value *
+struct value *
evaluate_subexp (struct type *expect_type, register struct expression *exp,
register int *pos, enum noside noside)
{
@@ -468,6 +466,15 @@ evaluate_subexp_standard (struct type *e
goto nosideret;
return value_string (&exp->elts[pc + 2].string, tem);
+ case OP_NSSTRING: /* Objective C Foundation Class NSString constant */
+ tem = longest_to_int (exp->elts[pc + 1].longconst);
+ (*pos) += 3 + BYTES_TO_EXP_ELEM (tem + 1);
+ if (noside == EVAL_SKIP)
+ {
+ goto nosideret;
+ }
+ return (struct value *) value_nsstring (&exp->elts[pc + 2].string, tem + 1);
+
case OP_BITSTRING:
tem = longest_to_int (exp->elts[pc + 1].longconst);
(*pos)
@@ -664,6 +671,291 @@ evaluate_subexp_standard (struct type *e
return arg2;
}
+ case OP_SELECTOR:
+ { /* Objective C @selector operator */
+ char *sel = &exp->elts[pc + 2].string;
+ int len = longest_to_int (exp->elts[pc + 1].longconst);
+
+ (*pos) += 3 + BYTES_TO_EXP_ELEM (len + 1);
+ if (noside == EVAL_SKIP)
+ goto nosideret;
+
+ if (sel[len] != 0)
+ sel[len] = 0; /* make sure terminated */
+ return value_from_longest (lookup_pointer_type (builtin_type_void),
+ lookup_child_selector (sel));
+ }
+
+ case OP_MSGCALL:
+ { /* Objective C message (method) call */
+
+ static unsigned long responds_selector = 0;
+ static unsigned long method_selector = 0;
+ static unsigned int selector_generation = 0;
+
+ unsigned long selector = 0;
+
+ int using_gcc = 0;
+ int struct_return = 0;
+
+ static struct value *msg_send = NULL;
+ static struct value *msg_send_stret = NULL;
+ static struct value *msg_send_typed = NULL;
+ static int gnu_runtime = 0;
+
+ struct value * target = NULL;
+ struct value * method = NULL;
+ struct value * called_method = NULL;
+
+ struct value * ret = NULL;
+ struct symbol *sym = NULL;
+ CORE_ADDR addr = 0;
+
+ /* First evaluate the target (class or object) of the message */
+ (*pos) += 3;
+
+ nargs = exp->elts[pc + 2].longconst;
+ argvec = (struct value **) alloca (sizeof (struct value *)
+ * (nargs + 5));
+
+ target = evaluate_subexp (0, exp, pos, (noside == EVAL_AVOID_SIDE_EFFECTS) ? EVAL_NORMAL : noside);
+ selector = exp->elts[pc + 1].longconst;
+
+ if (value_as_long (target) == 0)
+ return value_from_longest (builtin_type_long, 0);
+
+ if (lookup_minimal_symbol ("objc_msg_lookup", 0, 0))
+ gnu_runtime = 1;
+
+ if (gnu_runtime)
+ {
+ msg_send = find_function_in_inferior ("objc_msg_lookup");
+ msg_send_stret = find_function_in_inferior ("objc_msg_lookup");
+ msg_send_typed = find_function_in_inferior ("objc_msg_lookup");
+ }
+ else
+ {
+ msg_send = find_function_in_inferior ("objc_msgSend");
+ msg_send_stret = find_function_in_inferior ("objc_msgSend_stret");
+ msg_send_typed = find_function_in_inferior ("objc_msgSend");
+ }
+
+ /* Verify target responds to method selector. This logic needs
+ * work: not sure of GNU variant's name. Must also account for
+ * new (NSObject) and old (Object) worlds
+ */
+
+ if (1)
+ {
+ responds_selector = lookup_child_selector ("respondsToSelector:");
+ if (responds_selector == 0)
+ responds_selector = lookup_child_selector ("respondsTo:");
+
+ if (responds_selector == 0)
+ error ("no 'respondsTo:' or 'respondsToSelector:' method");
+
+ if (gnu_runtime)
+ {
+ method_selector = lookup_child_selector ("methodFor:");
+ if (method_selector == 0)
+ method_selector = lookup_child_selector ("methodForSelector:");
+ }
+ else
+ {
+ method_selector = lookup_child_selector ("methodForSelector:");
+ if (method_selector == 0)
+ method_selector = lookup_child_selector ("methodFor:");
+ }
+
+ if (method_selector == 0)
+ error ("no 'methodFor:' or 'methodForSelector:' method");
+
+ }
+
+ /* call "respondsToSelector:" method, to make sure that
+ * the target class implements the user's desired method selector
+ */
+
+ argvec[0] = msg_send_typed;
+ argvec[1] = target;
+ argvec[2] = value_from_longest (builtin_type_long, responds_selector);
+ argvec[3] = value_from_longest (builtin_type_long, selector);
+ argvec[4] = 0;
+
+ ret = call_function_by_hand_expecting_type (argvec[0], NULL, 3, argvec + 1, 1);
+ if (gnu_runtime)
+ {
+ /* objc_msg_lookup returns a pointer */
+ argvec[0] = ret; /* prepare to call the method */
+ ret = call_function_by_hand_expecting_type (argvec[0], NULL, 3, argvec + 1, 1);
+ }
+ if (value_as_long (ret) == 0)
+ error ("Target does not respond to this message selector.");
+
+ /* call "methodForSelector:" method, to get the address of a
+ * function method that implements this selector for this class.
+ * If we can find a symbol at that address, then we know the
+ * return type, parameter types etc. (that's a good thing).
+ */
+
+ argvec[0] = msg_send_typed;
+ argvec[1] = target;
+ argvec[2] = value_from_longest (builtin_type_long, method_selector);
+ argvec[3] = value_from_longest (builtin_type_long, selector);
+ argvec[4] = 0;
+
+ ret = call_function_by_hand_expecting_type (argvec[0], NULL, 3, argvec + 1, 1);
+ if (gnu_runtime)
+ {
+ argvec[0] = ret; /* prepare to call the method */
+ ret = call_function_by_hand_expecting_type (argvec[0], NULL, 3, argvec + 1, 1);
+ }
+
+ /* ret should now be the selector */
+
+ addr = value_as_long (ret);
+ if (addr)
+ {
+ /* is it a high_level symbol? */
+
+#ifdef GDB_TARGET_IS_HPPA
+ CORE_ADDR tmp;
+ /* code and comment lifted from hppa-tdep.c -- unfortunately
+ there is no builtin function to do this for me. */
+ /* If bit 30 (counting from the left) is on, then addr is the
+ address of the PLT entry for this function, not the address
+ of the function itself. Bit 31 has meaning too, but only
+ for MPE. */
+ if (addr & 0x2)
+ addr = (CORE_ADDR) read_memory_unsigned_integer (addr & ~0x3, 4);
+ if (tmp = skip_trampoline_code (addr, 0))
+ addr = tmp; /* in case of trampoline code */
+#endif
+
+ sym = find_pc_function (addr);
+ if (sym != NULL)
+ method = value_of_variable (sym, 0);
+ }
+
+ /* If we found a method with symbol information, check to see
+ * if it returns a struct. Otherwise assume it doesn't.
+ */
+
+ if (method)
+ {
+ struct block *b;
+ CORE_ADDR funaddr;
+ struct type *value_type;
+
+ funaddr = find_function_addr (method, &value_type);
+
+ b = block_for_pc (funaddr);
+
+ /* If compiled without -g, assume GCC 2. */
+ using_gcc = (b == NULL ? 2 : BLOCK_GCC_COMPILED (b));
+
+ CHECK_TYPEDEF (value_type);
+
+ if ((value_type == NULL)
+ || (TYPE_CODE(value_type) == TYPE_CODE_ERROR))
+ {
+ if (expect_type != NULL)
+ value_type = expect_type;
+ }
+
+ struct_return = using_struct_return (method, funaddr, value_type, using_gcc);
+ }
+ else if (expect_type != NULL)
+ {
+ struct_return = using_struct_return (NULL, addr, check_typedef (expect_type), using_gcc);
+ }
+
+ /* Found a function symbol. Now we will substitute its
+ * value in place of the message dispatcher (obj_msgSend),
+ * so that we call the method directly instead of thru
+ * the dispatcher. The main reason for doing this is that
+ * we can now evaluate the return value and parameter values
+ * according to their known data types, in case we need to
+ * do things like promotion, dereferencing, special handling
+ * of structs and doubles, etc.
+ *
+ * We want to use the type signature of 'method', but still
+ * jump to objc_msgSend() or objc_msgSend_stret() to better
+ * mimic the behavior of the runtime.
+ */
+
+ if (method)
+ {
+ if (TYPE_CODE (VALUE_TYPE (method)) != TYPE_CODE_FUNC)
+ error ("method address has symbol information with non-function type; skipping");
+ if (struct_return)
+ VALUE_ADDRESS (method) = value_as_address (msg_send_stret);
+ else
+ VALUE_ADDRESS (method) = value_as_address (msg_send);
+ called_method = method;
+ }
+ else
+ {
+ if (struct_return)
+ called_method = msg_send_stret;
+ else
+ called_method = msg_send;
+ }
+
+ if (noside == EVAL_SKIP)
+ goto nosideret;
+
+ if (noside == EVAL_AVOID_SIDE_EFFECTS)
+ {
+ /* If the return type doesn't look like a function type, call an
+ error. This can happen if somebody tries to turn a variable into
+ a function call. This is here because people often want to
+ call, eg, strcmp, which gdb doesn't know is a function. If
+ gdb isn't asked for it's opinion (ie. through "whatis"),
+ it won't offer it. */
+
+ struct type *type = VALUE_TYPE (called_method);
+ if (type && TYPE_CODE (type) == TYPE_CODE_PTR)
+ type = TYPE_TARGET_TYPE (type);
+ type = TYPE_TARGET_TYPE (type);
+
+ if (type)
+ {
+ if ((TYPE_CODE (type) == TYPE_CODE_ERROR) && expect_type)
+ return allocate_value (expect_type);
+ else
+ return allocate_value (type);
+ }
+ else
+ error ("Expression of type other than \"method returning ...\" used as a method");
+ }
+
+ /* Now depending on whether we found a symbol for the method,
+ * we will either call the runtime dispatcher or the method directly.
+ */
+
+ argvec[0] = called_method;
+ argvec[1] = target;
+ argvec[2] = value_from_longest (builtin_type_long, selector);
+ /* user-supplied arguments */
+ for (tem = 0; tem < nargs; tem++)
+ argvec[tem + 3] = evaluate_subexp_with_coercion (exp, pos, noside);
+ argvec[tem + 3] = 0;
+
+ if (gnu_runtime && (method != NULL))
+ {
+ ret = call_function_by_hand_expecting_type (argvec[0], NULL, nargs + 2, argvec + 1, 1);
+ /* objc_msg_lookup returns a pointer */
+ argvec[0] = ret;
+ ret = call_function_by_hand_expecting_type (argvec[0], expect_type, nargs + 2, argvec + 1, 1);
+ }
+ else
+ ret = call_function_by_hand_expecting_type (argvec[0], expect_type, nargs + 2, argvec + 1, 1);
+
+ return ret;
+ }
+ break;
+
case OP_FUNCALL:
(*pos) += 2;
op = exp->elts[*pos].opcode;
@@ -1745,6 +2037,10 @@ evaluate_subexp_standard (struct type *e
case OP_THIS:
(*pos) += 1;
return value_of_this (1);
+
+ case OP_SELF:
+ (*pos) += 1;
+ return value_of_local ("self", 1);
case OP_TYPE:
error ("Attempt to use a type name as an expression");
Index: gdb/expprint.c
===================================================================
RCS file: /cvs/src/src/gdb/expprint.c,v
retrieving revision 1.8
diff -u -p -r1.8 expprint.c
--- gdb/expprint.c 1 Aug 2002 17:18:32 -0000 1.8
+++ gdb/expprint.c 17 Sep 2002 19:30:04 -0000
@@ -26,6 +26,9 @@
#include "value.h"
#include "language.h"
#include "parser-defs.h"
+#include "target.h"
+
+#include "gdb_string.h"
#ifdef HAVE_CTYPE_H
#include <ctype.h>
@@ -174,6 +177,51 @@ print_subexp (register struct expression
fprintf_unfiltered (stream, "B'<unimplemented>'");
return;
+ case OP_NSSTRING: /* Objective C Foundation Class NSString constant */
+ nargs = longest_to_int (exp->elts[pc + 1].longconst);
+ (*pos) += 3 + BYTES_TO_EXP_ELEM (nargs + 1);
+ fputs_filtered ("@\"", stream);
+ LA_PRINT_STRING (stream, &exp->elts[pc + 2].string, nargs, 1, 0);
+ fputs_filtered ("\"", stream);
+ return;
+
+ case OP_MSGCALL:
+ { /* Objective C message (method) call */
+ char *selector;
+ (*pos) += 3;
+ nargs = longest_to_int (exp->elts[pc + 2].longconst);
+ fprintf_unfiltered (stream, "[");
+ print_subexp (exp, pos, stream, PREC_SUFFIX);
+ if (0 == target_read_string (exp->elts[pc + 1].longconst,
+ &selector, 1024, NULL))
+ {
+ error ("bad selector");
+ return;
+ }
+ /* NOTE: "selector" was malloc'd by target_read_string; must be freed */
+ if (nargs)
+ {
+ char *s, *nextS;
+ s = alloca (strlen (selector) + 1);
+ strcpy (s, selector);
+ for (tem = 0; tem < nargs; tem++)
+ {
+ nextS = strchr (s, ':');
+ *nextS = '\0';
+ fprintf_unfiltered (stream, " %s: ", s);
+ s = nextS + 1;
+ print_subexp (exp, pos, stream, PREC_ABOVE_COMMA);
+ }
+ }
+ else
+ {
+ fprintf_unfiltered (stream, " %s", selector);
+ }
+ fprintf_unfiltered (stream, "]");
+ free (selector);
+ return;
+ }
+
case OP_ARRAY:
(*pos) += 3;
nargs = longest_to_int (exp->elts[pc + 2].longconst);
@@ -381,6 +429,13 @@ print_subexp (register struct expression
error ("Invalid expression");
break;
+ /* Objective-C ops */
+
+ case OP_SELF:
+ ++(*pos);
+ fputs_filtered ("self", stream); /* the ObjC equivalent of "this" */
+ return;
+
/* C++ ops */
case OP_THIS:
@@ -681,6 +736,8 @@ op_name (int opcode)
return "STRUCTOP_PTR";
case OP_THIS:
return "OP_THIS";
+ case OP_SELF:
+ return "OP_SELF";
case OP_SCOPE:
return "OP_SCOPE";
case OP_TYPE:
Index: gdb/expression.h
===================================================================
RCS file: /cvs/src/src/gdb/expression.h,v
retrieving revision 1.4
diff -u -p -r1.4 expression.h
--- gdb/expression.h 1 Aug 2002 17:18:32 -0000 1.4
+++ gdb/expression.h 17 Sep 2002 19:30:05 -0000
@@ -181,6 +181,12 @@ enum exp_opcode
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
@@ -273,11 +279,17 @@ enum exp_opcode
STRUCTOP_STRUCT,
STRUCTOP_PTR,
- /* C++ */
- /* OP_THIS is just a placeholder for the class instance variable.
+ /* 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. */
@@ -305,7 +317,10 @@ enum exp_opcode
OP_NAME,
/* An unparsed expression. Used for Scheme (for now at least) */
- OP_EXPRSTRING
+ OP_EXPRSTRING,
+
+ /* An Objective C Foundation Class NSString constant */
+ OP_NSSTRING,
};
union exp_element
@@ -369,6 +384,10 @@ enum noside
extern struct value *evaluate_subexp_standard
(struct type *, struct expression *, int *, enum noside);
+
+extern struct value *evaluate_subexp (struct type *, struct expression *,
+ int *, enum noside);
+
/* From expprint.c */
Index: gdb/infrun.c
===================================================================
RCS file: /cvs/src/src/gdb/infrun.c,v
retrieving revision 1.70
diff -u -p -r1.70 infrun.c
--- gdb/infrun.c 23 Aug 2002 21:55:36 -0000 1.70
+++ gdb/infrun.c 17 Sep 2002 19:30:26 -0000
@@ -42,6 +42,7 @@
#include "inf-loop.h"
#include "regcache.h"
#include "value.h"
+#include "objc-lang.h"
/* Prototypes for local functions */
@@ -2786,6 +2787,26 @@ process_event_stop_test:
return;
}
}
+
+ /* ObjC */
+ {
+ CORE_ADDR new_stop;
+
+ if (tmp)
+ find_objc_msgcall (tmp, &new_stop);
+ else
+ find_objc_msgcall (stop_pc, &new_stop);
+
+ if (new_stop) /* step into a method call */
+ ecs->stop_func_start = new_stop;
+
+ if (new_stop)
+ {
+ tmp = SKIP_TRAMPOLINE_CODE (new_stop);
+ if (tmp != 0)
+ ecs->stop_func_start = tmp;
+ }
+ }
/* If we have line number information for the function we
are thinking of stepping into, step into it.
Index: gdb/jv-exp.y
===================================================================
RCS file: /cvs/src/src/gdb/jv-exp.y,v
retrieving revision 1.9
diff -u -p -r1.9 jv-exp.y
--- gdb/jv-exp.y 3 Sep 2002 02:45:56 -0000 1.9
+++ gdb/jv-exp.y 17 Sep 2002 19:30:27 -0000
@@ -48,6 +48,7 @@ Foundation, Inc., 59 Temple Place - Suit
#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"
/* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc),
as well as gratuitiously global symbol names, so we can have multiple
@@ -918,7 +919,9 @@ yylex ()
c = *lexptr++;
if (c != '\'')
{
- namelen = skip_quoted (tokstart) - tokstart;
+ namelen = skip_quoted (tokstart,
+ get_gdb_completer_word_break_characters())
+ - tokstart;
if (namelen > 2)
{
lexptr = tokstart + namelen;
Index: gdb/language.c
===================================================================
RCS file: /cvs/src/src/gdb/language.c,v
retrieving revision 1.26
diff -u -p -r1.26 language.c
--- gdb/language.c 1 Aug 2002 17:18:32 -0000 1.26
+++ gdb/language.c 17 Sep 2002 19:30:31 -0000
@@ -549,6 +549,7 @@ binop_result_type (struct value *v1, str
{
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);
@@ -786,6 +787,7 @@ integral_type (struct type *type)
{
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:
@@ -828,6 +830,7 @@ character_type (struct type *type)
case language_c:
case language_cplus:
+ case language_objc:
return (TYPE_CODE (type) == TYPE_CODE_INT) &&
TYPE_LENGTH (type) == sizeof (char)
? 1 : 0;
@@ -850,6 +853,7 @@ string_type (struct type *type)
case language_c:
case language_cplus:
+ case language_objc:
/* C does not have distinct string type. */
return (0);
default:
@@ -868,6 +872,7 @@ boolean_type (struct type *type)
{
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. */
@@ -904,6 +909,7 @@ structured_type (struct type *type)
{
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);
@@ -1124,6 +1130,7 @@ binop_type_check (struct value *arg1, st
#ifdef _LANG_c
case language_c:
case language_cplus:
+ case language_objc:
switch (op)
{
case BINOP_DIV:
Index: gdb/language.h
===================================================================
RCS file: /cvs/src/src/gdb/language.h,v
retrieving revision 1.11
diff -u -p -r1.11 language.h
--- gdb/language.h 1 Aug 2002 17:18:32 -0000 1.11
+++ gdb/language.h 17 Sep 2002 19:30:36 -0000
@@ -288,7 +288,8 @@ language_mode;
/* "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_cplus || \
+ current_language->la_language == language_objc)
extern void language_info (int);
Index: gdb/linespec.c
===================================================================
RCS file: /cvs/src/src/gdb/linespec.c,v
retrieving revision 1.21
diff -u -p -r1.21 linespec.c
--- gdb/linespec.c 11 May 2002 22:46:19 -0000 1.21
+++ gdb/linespec.c 17 Sep 2002 19:30:39 -0000
@@ -31,6 +31,8 @@
#include "completer.h"
#include "cp-abi.h"
+extern int allow_objc_selectors_flag;
+
/* Prototype for one function in parser-defs.h,
instead of including that entire file. */
@@ -40,6 +42,11 @@ extern char *find_template_name_end (cha
extern char *operator_chars (char *, char **);
+/* From objc-lang.h. Included here to avoid conflict with other prototypes */
+extern char *find_imps (struct symtab *symtab, struct block *block,
+ char *method, struct symbol **syms, unsigned int *nsym,
+ unsigned int *ndebug);
+
/* Prototypes for local functions */
static void cplusplus_error (const char *name, const char *fmt, ...) ATTR_FORMAT (printf, 2, 3);
@@ -531,13 +538,13 @@ decode_line_1 (char **argptr, int funfir
int i1;
int is_quoted;
int is_quote_enclosed;
+ int is_objc_method = 0;
int has_parens;
int has_if = 0;
int has_comma = 0;
struct symbol **sym_arr;
struct type *t;
char *saved_arg = *argptr;
- extern char *gdb_completer_quote_characters;
INIT_SAL (&val); /* initialize to zeroes */
@@ -593,6 +600,7 @@ decode_line_1 (char **argptr, int funfir
*/
/* Maybe arg is FILE : LINENUM or FILE : FUNCTION */
+ /* Or it could be an ObjC method name with embedded ':'s */
is_quoted = (**argptr
&& strchr (get_gdb_completer_quote_characters (),
@@ -649,6 +657,15 @@ decode_line_1 (char **argptr, int funfir
error ("malformed template specification in command");
p = temp_end;
}
+ /* Check for a colon and a plus or minus and a [ (which
+ indicates an Objective-C method) */
+ if (*p && (p[0] == ':') && (strchr ("+-", p[1]) != NULL)
+ && (p[2] == '['))
+ {
+ is_objc_method = 1;
+ has_parens = 0; /* Probably just a category name. Ignore it */
+ break;
+ }
/* Check for the end of the first half of the linespec. End of line,
a tab, a double colon or the last single colon, or a space. But
if enclosed in double quotes we do not break on enclosed spaces */
@@ -686,6 +703,92 @@ decode_line_1 (char **argptr, int funfir
if (has_comma)
*ii = ',';
+ /* here's where we recognise an Objective-C Selector. An
+ * Objective C selector may be implemented by more than one
+ * class, therefore it may represent more than one
+ * method/function. This gives us a situation somewhat
+ * analogous to C++ overloading. If there's more than one
+ * method that could represent the selector, then use some of
+ * the existing C++ code to let the user choose one.
+ */
+
+ if (allow_objc_selectors_flag && !has_if && !has_comma)
+ {
+ unsigned int i2;
+ char *copy = NULL;
+ struct block *block;
+
+ if (s)
+ block = BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), STATIC_BLOCK);
+ else
+ block = get_selected_block (NULL);
+
+
+ copy = find_imps (s, block, *argptr, NULL, &i1, &i2);
+
+ if (i1 > 0)
+ {
+ sym_arr = (struct symbol **) alloca ((i1 + 1) * sizeof (struct symbol *));
+ sym_arr[i1] = 0;
+
+ copy = find_imps (s, block, *argptr, sym_arr, &i1, &i2);
+ *argptr = copy;
+ if (is_quoted)
+ *argptr = *argptr + 1;
+ }
+
+ /* i1 now represents the TOTAL number of matches found...
+ i2 represents how many HIGH-LEVEL (struct symbol) matches,
+ which will come first in the sym_arr array. Any low-level
+ (minimal_symbol) matches will follow those. */
+
+ if (i1 == 1)
+ {
+ /* exactly one matching method */
+ extern int info_verbose;
+
+ if (i2 > 0)
+ {
+ /* already a struct symbol */
+ sym = sym_arr[0];
+ }
+ else
+ {
+ sym = find_pc_function (SYMBOL_VALUE_ADDRESS (sym_arr[0]));
+ if ((sym != NULL) && strcmp (SYMBOL_NAME (sym_arr[0]), SYMBOL_NAME (sym)) != 0)
+ {
+ warning ("debugging symbol \"%s\" does not match selector; ignoring", SYMBOL_NAME (sym));
+ sym = NULL;
+ }
+ }
+
+ values.sals = (struct symtab_and_line *) xmalloc (sizeof (struct symtab_and_line));
+ values.nelts = 1;
+
+ if (sym && SYMBOL_CLASS (sym) == LOC_BLOCK)
+ {
+ /* canonicalize this, so it remains resolved for dylib loads */
+ values.sals[0] = find_function_start_sal (sym, funfirstline);
+ build_canonical_line_spec (values.sals, SYMBOL_SOURCE_NAME (sym), canonical);
+ }
+ else
+ {
+ /* the only match was a non-debuggable symbol */
+ values.sals[0].symtab = 0;
+ values.sals[0].line = 0;
+ values.sals[0].end = 0;
+ values.sals[0].pc = SYMBOL_VALUE_ADDRESS (sym_arr[0]);
+ }
+ return values;
+ }
+
+ if (i1 > 1)
+ {
+ /* more than one match -- user must choose one or more */
+ return decode_line_2 (sym_arr, i2, funfirstline, canonical);
+ }
+ }
+
if ((p[0] == ':' || p[0] == '.') && !has_parens)
{
/* C++ */
@@ -754,7 +857,8 @@ decode_line_1 (char **argptr, int funfir
&& strchr (get_gdb_completer_quote_characters (),
**argptr) != NULL)
{
- p = skip_quoted (*argptr);
+ p = skip_quoted (*argptr,
+ get_gdb_completer_word_break_characters());
*argptr = *argptr + 1;
}
else
@@ -1081,20 +1185,29 @@ decode_line_1 (char **argptr, int funfir
Find the next token (everything up to end or next whitespace). */
if (**argptr == '$') /* May be a convenience variable */
- p = skip_quoted (*argptr + (((*argptr)[1] == '$') ? 2 : 1)); /* One or two $ chars possible */
+ {
+ /* One or two $ chars possible */
+ p = skip_quoted (*argptr + (((*argptr)[1] == '$') ? 2 : 1),
+ get_gdb_completer_word_break_characters());
+ }
else if (is_quoted)
{
- p = skip_quoted (*argptr);
+ p = skip_quoted (*argptr, get_gdb_completer_word_break_characters());
if (p[-1] != '\'')
error ("Unmatched single quote.");
}
+ else if (is_objc_method)
+ {
+ /* allow word separators in method names for Obj-C */
+ p = skip_quoted (*argptr, "");
+ }
else if (has_parens)
{
p = pp + 1;
}
else
{
- p = skip_quoted (*argptr);
+ p = skip_quoted (*argptr, get_gdb_completer_word_break_characters());
}
copy = (char *) alloca (p - *argptr + 1);
Index: gdb/maint.c
===================================================================
RCS file: /cvs/src/src/gdb/maint.c,v
retrieving revision 1.27
diff -u -p -r1.27 maint.c
--- gdb/maint.c 15 Jun 2002 21:07:57 -0000 1.27
+++ gdb/maint.c 17 Sep 2002 19:30:45 -0000
@@ -141,7 +141,16 @@ maintenance_demangle (char *args, int fr
}
else
{
- demangled = cplus_demangle (args, DMGL_ANSI | DMGL_PARAMS);
+ switch (current_language->la_language)
+ {
+ case language_objc:
+ demangled = objc_demangle (args);
+ break;
+ case language_cplus:
+ default:
+ demangled = cplus_demangle (args, DMGL_ANSI | DMGL_PARAMS);
+ break;
+ }
if (demangled != NULL)
{
printf_unfiltered ("%s\n", demangled);
@@ -641,7 +650,7 @@ _initialize_maint_cmds (void)
"Commands for use by GDB maintainers.\n\
Includes commands to dump specific internal GDB structures in\n\
a human readable form, to cause GDB to deliberately dump core,\n\
-to test internal functions such as the C++ demangler, etc.",
+to test internal functions such as the C++/ObjC demangler, etc.",
&maintenancelist, "maintenance ", 0,
&cmdlist);
@@ -698,7 +707,7 @@ Cause GDB to behave as if an internal er
&maintenancelist);
add_cmd ("demangle", class_maintenance, maintenance_demangle,
- "Demangle a C++ mangled name.\n\
+ "Demangle a C++/ObjC mangled name.\n\
Call internal GDB demangler routine to demangle a C++ link name\n\
and prints the result.",
&maintenancelist);
Index: gdb/p-exp.y
===================================================================
RCS file: /cvs/src/src/gdb/p-exp.y,v
retrieving revision 1.13
diff -u -p -r1.13 p-exp.y
--- gdb/p-exp.y 3 Sep 2002 02:45:56 -0000 1.13
+++ gdb/p-exp.y 17 Sep 2002 19:30:47 -0000
@@ -56,6 +56,7 @@ Foundation, Inc., 59 Temple Place - Suit
#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"
/* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc),
as well as gratuitiously global symbol names, so we can have multiple
@@ -1100,8 +1101,10 @@ yylex ()
c = *lexptr++;
if (c != '\'')
{
- namelen = skip_quoted (tokstart) - tokstart;
- if (namelen > 2)
+ namelen = skip_quoted (tokstart,
+ get_gdb_completer_word_break_characters())
+ - tokstart;
+ if (namelen > 2)
{
lexptr = tokstart + namelen;
if (lexptr[-1] != '\'')
Index: gdb/parse.c
===================================================================
RCS file: /cvs/src/src/gdb/parse.c,v
retrieving revision 1.25
diff -u -p -r1.25 parse.c
--- gdb/parse.c 21 Jun 2002 14:32:10 -0000 1.25
+++ gdb/parse.c 17 Sep 2002 19:30:53 -0000
@@ -867,6 +867,11 @@ length_of_subexp (register struct expres
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;
@@ -898,6 +903,8 @@ length_of_subexp (register struct expres
/* 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);
@@ -936,6 +943,7 @@ length_of_subexp (register struct expres
/* C++ */
case OP_THIS:
+ case OP_SELF:
oplen = 2;
break;
@@ -1004,6 +1012,11 @@ prefixify_subexp (register struct expres
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;
@@ -1034,6 +1047,8 @@ prefixify_subexp (register struct expres
/* 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);
@@ -1072,6 +1087,7 @@ prefixify_subexp (register struct expres
/* C++ */
case OP_THIS:
+ case OP_SELF:
oplen = 2;
break;
Index: gdb/parser-defs.h
===================================================================
RCS file: /cvs/src/src/gdb/parser-defs.h,v
retrieving revision 1.11
diff -u -p -r1.11 parser-defs.h
--- gdb/parser-defs.h 24 Jul 2002 03:03:52 -0000 1.11
+++ gdb/parser-defs.h 17 Sep 2002 19:30:53 -0000
@@ -79,6 +79,14 @@ struct symtoken
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
@@ -215,6 +223,11 @@ struct op_print
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: gdb/printcmd.c
===================================================================
RCS file: /cvs/src/src/gdb/printcmd.c,v
retrieving revision 1.41
diff -u -p -r1.41 printcmd.c
--- gdb/printcmd.c 10 Sep 2002 02:04:38 -0000 1.41
+++ gdb/printcmd.c 17 Sep 2002 19:30:55 -0000
@@ -1104,7 +1104,11 @@ address_info (char *exp, int from_tty)
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");
+ 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: gdb/source.c
===================================================================
RCS file: /cvs/src/src/gdb/source.c,v
retrieving revision 1.29
diff -u -p -r1.29 source.c
--- gdb/source.c 11 Jun 2002 20:36:51 -0000 1.29
+++ gdb/source.c 17 Sep 2002 19:30:56 -0000
@@ -1114,8 +1114,9 @@ print_source_lines (struct symtab *s, in
/* 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. */
+ `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: gdb/stabsread.c
===================================================================
RCS file: /cvs/src/src/gdb/stabsread.c,v
retrieving revision 1.39
diff -u -p -r1.39 stabsread.c
--- gdb/stabsread.c 14 Sep 2002 02:09:39 -0000 1.39
+++ gdb/stabsread.c 17 Sep 2002 19:31:03 -0000
@@ -1273,7 +1273,7 @@ define_symbol (CORE_ADDR valu, char *str
struct objfile *objfile)
{
register struct symbol *sym;
- char *p = (char *) strchr (string, ':');
+ char *p = (char *) stabsread_objc_colon (string);
int deftype;
int synonym = 0;
register int i;
@@ -2006,7 +2006,8 @@ define_symbol (CORE_ADDR valu, char *str
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)
+ else if ((current_subfile->language == language_cplus)
+ || (current_subfile->language == language_objc))
synonym = 1;
SYMBOL_TYPE (sym) = read_type (&p, objfile);
@@ -5615,6 +5616,30 @@ finish_global_stabs (struct objfile *obj
patch_block_stabs (global_symbols, global_stabs, objfile);
xfree (global_stabs);
global_stabs = NULL;
+ }
+}
+
+char *
+stabsread_objc_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, ':');
}
}
Index: gdb/stabsread.h
===================================================================
RCS file: /cvs/src/src/gdb/stabsread.h,v
retrieving revision 1.8
diff -u -p -r1.8 stabsread.h
--- gdb/stabsread.h 18 Jul 2002 17:22:50 -0000 1.8
+++ gdb/stabsread.h 17 Sep 2002 19:31:04 -0000
@@ -219,6 +219,8 @@ extern struct symbol *ref_search (int);
extern int resolve_cfront_continuation
(struct objfile *objfile, struct symbol *sym, char *p);
+extern char *stabsread_objc_colon (char *name);
+
extern void free_header_files (void);
extern void init_header_files (void);
Index: gdb/symfile.c
===================================================================
RCS file: /cvs/src/src/gdb/symfile.c,v
retrieving revision 1.65
diff -u -p -r1.65 symfile.c
--- gdb/symfile.c 1 Aug 2002 17:18:32 -0000 1.65
+++ gdb/symfile.c 17 Sep 2002 19:31:05 -0000
@@ -1966,6 +1966,7 @@ init_filename_language_table (void)
/* 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: gdb/symtab.c
===================================================================
RCS file: /cvs/src/src/gdb/symtab.c,v
retrieving revision 1.69
diff -u -p -r1.69 symtab.c
--- gdb/symtab.c 30 Aug 2002 03:24:00 -0000 1.69
+++ gdb/symtab.c 17 Sep 2002 19:31:07 -0000
@@ -49,6 +49,8 @@
#include <ctype.h>
#include "cp-abi.h"
+int allow_objc_selectors_flag = 1;
+
/* Prototype for one function in parser-defs.h,
instead of including that entire file. */
@@ -58,6 +60,9 @@ extern char *find_template_name_end (cha
static void completion_list_add_name (char *, char *, int, char *, char *);
+static void build_canonical_line_spec (struct symtab_and_line *,
+ char *, char ***);
+
static void rbreak_command (char *, int);
static void types_info (char *, int);
@@ -438,6 +443,43 @@ symbol_init_demangled_name (struct gener
gsymbol->language_specific.cplus_specific.demangled_name = NULL;
}
}
+ if (demangled == NULL &&
+ (gsymbol->language == language_objc ||
+ gsymbol->language == language_auto))
+ {
+ demangled =
+ objc_demangle (gsymbol->name);
+ if (demangled != NULL)
+ {
+ gsymbol->language = language_objc;
+ gsymbol->language_specific.objc_specific.demangled_name =
+ obsavestring (demangled, strlen (demangled), (obstack));
+ free (demangled);
+ }
+ else
+ {
+ gsymbol->language_specific.objc_specific.demangled_name = NULL;
+ }
+ }
+ if (demangled &&
+ gsymbol->language != language_objc &&
+ (demangled = gsymbol->name) &&
+ demangled[0] == '_' &&
+ (demangled[1] == 'i' || demangled[1] == 'c') &&
+ demangled[2] == '_')
+ /* some other demangling succeeded, yet it looks like ObjC */
+ {
+ demangled =
+ objc_demangle (gsymbol->name);
+ if (demangled != NULL) /* yes, it was ObjC: let ObjC win */
+ { /* (C++ demangling is too forgiving) */
+ gsymbol->language = language_objc;
+ gsymbol->language_specific.objc_specific.demangled_name =
+ obsavestring (demangled, strlen (demangled), (obstack));
+ free (demangled);
+ }
+ }
+
#if 0
/* OBSOLETE if (demangled == NULL */
/* OBSOLETE && (gsymbol->language == language_chill */
@@ -807,7 +849,7 @@ lookup_symbol_aux (const char *name, con
}
- /* C++: If requested to do so by the caller,
+ /* C++/Java/ObjC: If requested to do so by the caller,
check to see if NAME is a field of `this'. */
if (is_a_field_of_this)
{
@@ -1321,9 +1363,9 @@ find_main_psymtab (void)
for now we don't worry about the slight inefficiency of looking for
a match we'll never find, since it will go pretty quick. Once the
binary search terminates, we drop through and do a straight linear
- search on the symbols. Each symbol which is marked as being a C++
- symbol (language_cplus set) has both the encoded and non-encoded names
- tested for a match.
+ search on the symbols. Each symbol which is marked as being a ObjC/C++
+ symbol (language_cplus or language_objc set) has both the encoded and
+ non-encoded names tested for a match.
If MANGLED_NAME is non-NULL, verify that any symbol we find has this
particular mangled name.
@@ -3275,12 +3317,42 @@ make_symbol_completion_list (char *text,
{
/* It is not a quoted string. Break it based on the characters
which are in symbols. */
- while (p > text)
+ for (; p > text; --p)
{
if (isalnum (p[-1]) || p[-1] == '_' || p[-1] == '\0')
- --p;
- else
- break;
+ continue;
+ else
+ {
+ if (current_language->la_language == language_objc)
+ {
+ if (p[-1] == ':') /* might be part of a method name */
+ continue;
+ else if (p[-1] == '[' && (p[-2] == '-' || p[-2] == '+'))
+ p -= 2; /* beginning of a method name */
+ else if (p[-1] == ' ' || p[-1] == '(' || p[-1] == ')')
+ { /* might be part of a method name */
+ char *t = p;
+
+ /* Seeing a ' ' or a '(' is not conclusive evidence
+ that we are in the middle of a method name. However,
+ finding "-[" or "+[" should be pretty un-ambiguous.
+ Unfortunately we have to find it now to decide. */
+
+ while (t > text)
+ if (isalnum (t[-1]) || t[-1] == '_' ||
+ t[-1] == ' ' || t[-1] == ':' ||
+ t[-1] == '(' || t[-1] == ')')
+ --t;
+ else
+ break;
+
+ if (t[-1] == '[' && (t[-2] == '-' || t[-2] == '+'))
+ p = t - 2; /* method name detected */
+ /* else we leave with p unchanged */
+ }
+ }
+ break;
+ }
}
sym_text = p;
}
@@ -3328,10 +3400,72 @@ make_symbol_completion_list (char *text,
anything that isn't a text symbol (everything else will be
handled by the psymtab code above). */
- ALL_MSYMBOLS (objfile, msymbol)
+ /* ObjC: In case we are completing on a selector, look thru the msymbols
+ again and feed all the selectors into the mill. */
+
+ ALL_OBJFILES (objfile)
{
- QUIT;
- COMPLETION_LIST_ADD_SYMBOL (msymbol, sym_text, sym_text_len, text, word);
+ ALL_OBJFILE_MSYMBOLS (objfile, msymbol)
+ {
+ static char *tmp = NULL;
+ static unsigned int tmplen = 0;
+
+ char *method, *category, *selector;
+ char *tmp2 = NULL;
+
+ QUIT;
+
+ method = SYMBOL_DEMANGLED_NAME (msymbol);
+ if (method == NULL)
+ method = SYMBOL_NAME (msymbol);
+ if (method == NULL)
+ continue;
+
+ /* add the minimal symbol no matter what */
+ completion_list_add_name (method, sym_text, sym_text_len, text, word);
+
+ /* is it a method? */
+ if ((method[0] != '-') && (method[0] != '+'))
+ continue;
+
+ if (sym_text[0] == '[')
+ /* complete on shortened method method */
+ completion_list_add_name (method + 1, sym_text, sym_text_len, text, word);
+
+ while ((strlen (method) + 1) >= tmplen)
+ {
+ tmplen = (tmplen == 0) ? 1024 : tmplen * 2;
+ tmp = xrealloc (tmp, tmplen);
+ }
+
+ selector = strchr (method, ' ');
+ if (selector != NULL)
+ selector++;
+
+ category = strchr (method, '(');
+
+ if ((category != NULL) && (selector != NULL))
+ {
+ memcpy (tmp, method, (category - method));
+ tmp[category - method] = ' ';
+ memcpy (tmp + (category - method) + 1, selector, strlen (selector) + 1);
+ completion_list_add_name (tmp, sym_text, sym_text_len, text, word);
+ if (sym_text[0] == '[')
+ completion_list_add_name (tmp + 1, sym_text, sym_text_len, text, word);
+ }
+
+ if (selector != NULL)
+ {
+ /* complete on selector only */
+
+ strcpy (tmp, selector);
+ tmp2 = strchr (tmp, ']');
+ if (tmp2 != NULL)
+ *tmp2 = '\0';
+
+ completion_list_add_name (tmp, sym_text, sym_text_len, text, word);
+ }
+ }
}
/* Search upwards from currently selected frame (so that we can
Index: gdb/symtab.h
===================================================================
RCS file: /cvs/src/src/gdb/symtab.h,v
retrieving revision 1.39
diff -u -p -r1.39 symtab.h
--- gdb/symtab.h 12 Sep 2002 19:19:37 -0000 1.39
+++ gdb/symtab.h 17 Sep 2002 19:31:07 -0000
@@ -89,6 +89,11 @@ struct general_symbol_info
char *demangled_name;
}
cplus_specific;
+ struct objc_specific
+ {
+ char *demangled_name;
+ }
+ objc_specific;
#if 0
/* OBSOLETE struct chill_specific *//* For Chill */
/* OBSOLETE { */
@@ -146,6 +151,10 @@ extern CORE_ADDR symbol_overlayed_addres
{ \
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; */ \
@@ -170,12 +179,17 @@ extern void symbol_init_demangled_name (
(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)
+ 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: gdb/utils.c
===================================================================
RCS file: /cvs/src/src/gdb/utils.c,v
retrieving revision 1.76
diff -u -p -r1.76 utils.c
--- gdb/utils.c 1 Aug 2002 17:18:33 -0000 1.76
+++ gdb/utils.c 17 Sep 2002 19:31:08 -0000
@@ -152,13 +152,13 @@ int quit_flag;
int immediate_quit;
-/* Nonzero means that encoded C++ names should be printed out in their
- C++ form rather than raw. */
+/* 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++ names should be printed out in their
- C++ form even in assembler language displays. If this is set, but
+/* 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;
@@ -1696,6 +1696,51 @@ wrap_here (char *indent)
}
}
+/* 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
@@ -2123,7 +2168,7 @@ print_spaces_filtered (int n, struct ui_
fputs_filtered (n_spaces (n), stream);
}
\f
-/* C++ demangler stuff. */
+/* 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.
@@ -2153,6 +2198,9 @@ fprintf_symbol_filtered (struct ui_file
case language_java:
demangled = cplus_demangle (name, arg_mode | DMGL_JAVA);
break;
+ case language_objc:
+ demangled = objc_demangle (name);
+ break;
#if 0
/* OBSOLETE case language_chill: */
/* OBSOLETE demangled = chill_demangle (name); */
@@ -2272,7 +2320,7 @@ initialize_utils (void)
add_show_from_set
(add_set_cmd ("demangle", class_support, var_boolean,
(char *) &demangle,
- "Set demangling of encoded C++ names when displaying symbols.",
+ "Set demangling of encoded C++/ObjC names when displaying symbols.",
&setprintlist),
&showprintlist);
@@ -2300,7 +2348,7 @@ initialize_utils (void)
add_show_from_set
(add_set_cmd ("asm-demangle", class_support, var_boolean,
(char *) &asm_demangle,
- "Set demangling of C++ names in disassembly listings.",
+ "Set demangling of C++/ObjC names in disassembly listings.",
&setprintlist),
&showprintlist);
}
Index: gdb/valops.c
===================================================================
RCS file: /cvs/src/src/gdb/valops.c,v
retrieving revision 1.72
diff -u -p -r1.72 valops.c
--- gdb/valops.c 14 Sep 2002 02:09:39 -0000 1.72
+++ gdb/valops.c 17 Sep 2002 19:31:14 -0000
@@ -48,10 +48,8 @@ extern int overload_debug;
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,
@@ -91,7 +89,6 @@ int overload_resolution = 0;
int unwind_on_signal_p = 0;
\f
-
/* Find the address of function name NAME in the inferior. */
struct value *
@@ -211,7 +208,7 @@ value_cast (struct type *type, struct va
}
}
- if (current_language->c_style_arrays
+ if (current_language->c_style_arrays
&& TYPE_CODE (type2) == TYPE_CODE_ARRAY)
arg2 = value_coerce_array (arg2);
@@ -1219,7 +1216,7 @@ value_arg_coerce (struct value *arg, str
/* 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
+CORE_ADDR
find_function_addr (struct value *function, struct type **retval_type)
{
register struct type *ftype = check_typedef (VALUE_TYPE (function));
@@ -1814,6 +1811,23 @@ call_function_by_hand (struct value *fun
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.");
+ }
+}
\f
@@ -3231,18 +3245,17 @@ value_full_object (struct value *argp, s
-/* C++: return the value of the class instance variable, if one exists.
+/* 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_this (int complain)
+value_of_local (const char *name, int complain)
{
struct symbol *func, *sym;
struct block *b;
int i;
- static const char funny_this[] = "this";
- struct value *this;
+ struct value * ret;
if (selected_frame == 0)
{
@@ -3256,7 +3269,7 @@ value_of_this (int complain)
if (!func)
{
if (complain)
- error ("no `this' in nameless context");
+ error ("no %s in nameless context", name);
else
return 0;
}
@@ -3266,26 +3279,39 @@ value_of_this (int complain)
if (i <= 0)
{
if (complain)
- error ("no args, no `this'");
+ 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, funny_this, NULL, VAR_NAMESPACE);
+ sym = lookup_block_symbol (b, name, NULL, VAR_NAMESPACE);
if (sym == NULL)
{
if (complain)
- error ("current stack frame not in method");
+ error ("current stack frame does not contain a variable named \"%s\"", name);
else
return NULL;
}
- this = read_var_value (sym, selected_frame);
- if (this == 0 && complain)
- error ("`this' argument at unknown address");
- return this;
+ 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: gdb/value.h
===================================================================
RCS file: /cvs/src/src/gdb/value.h,v
retrieving revision 1.34
diff -u -p -r1.34 value.h
--- gdb/value.h 13 Sep 2002 00:18:33 -0000 1.34
+++ gdb/value.h 17 Sep 2002 19:31:14 -0000
@@ -535,6 +535,12 @@ extern void clear_value_history (void);
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 *);
@@ -548,6 +554,10 @@ extern struct value *value_slice (struct
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 *);
@@ -565,5 +575,7 @@ extern struct value *value_allocate_spac
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: gdb/doc/gdb.texinfo
===================================================================
RCS file: /cvs/src/src/gdb/doc/gdb.texinfo,v
retrieving revision 1.120
diff -u -p -r1.120 gdb.texinfo
--- gdb/doc/gdb.texinfo 5 Sep 2002 12:13:08 -0000 1.120
+++ gdb/doc/gdb.texinfo 17 Sep 2002 19:31:31 -0000
@@ -212,6 +212,10 @@ syntax.
it may be necessary to refer to some variables with a trailing
underscore.
+@cindex Objective-C
+@value{GDBN} can be used to debug programs written in Objective-C,
+using either the Apple/NeXT or the GNU Objective-C runtime.
+
@menu
* Free Software:: Freely redistributable software
* Contributors:: Contributors to GDB
@@ -3174,7 +3178,8 @@ end
@cindex overloading
@cindex symbol overloading
-Some programming languages (notably C@t{++}) permit a single function name
+Some programming languages (notably C@t{++} and Objective-C) permit a
+single function name
to be defined several times, for application in different contexts.
This is called @dfn{overloading}. When a function name is overloaded,
@samp{break @var{function}} is not enough to tell @value{GDBN} where you want
@@ -7127,6 +7132,9 @@ C source file
@itemx .c++
C@t{++} source file
+@itemx .m
+Objective-C source file
+
@item .f
@itemx .F
Fortran source file
@@ -7407,7 +7415,7 @@ being set automatically by @value{GDBN}.
@node Support
@section Supported languages
-@value{GDBN} supports C, C@t{++}, Fortran, Java,
+@value{GDBN} supports C, C@t{++}, Objective-C, Fortran, Java,
@c OBSOLETE Chill,
assembly, and Modula-2.
@c This is false ...
@@ -7426,8 +7434,9 @@ books written on each of these languages
language reference or tutorial.
@menu
-* C:: C and C@t{++}
-* Modula-2:: Modula-2
+* C:: C and C@t{++}
+* Objective-C:: Objective-C
+* Modula-2:: Modula-2
@c OBSOLETE * Chill:: Chill
@end menu
@@ -7951,7 +7960,84 @@ available choices, or to finish the type
@xref{Completion,, Command completion}, for details on how to do this.
@end table
-@node Modula-2
+@node Objective-C
+@subsection Objective-C
+
+This section provides information about some commands and command
+options that are useful for debugging Objective-C code.
+
+@menu
+* Method Names in Commands::
+* The Print Command with Objective-C::
+@end menu
+
+@node Method Names in Commands, The Print Command with Objective-C, Objective-C, Objective-C
+@subsubsection Method Names in Commands
+
+The following commands have been extended to accept Objective-C method
+names as line specifications:
+
+@itemize
+@item @code{clear}
+@item @code{break}
+@item @code{info line}
+@item @code{jump}
+@item @code{list}
+@end itemize
+
+For example, to set a breakpoint at the @code{create} instance method of
+class @code{Fruit} in the program currently being debugged, enter:
+
+@example
+break -[Fruit create]
+@end example
+
+To list ten program lines around the @code{initialize} class method,
+enter:
+
+@example
+list +[NSText initialize]
+@end example
+
+In the current version of GDB, the plus or minus sign is required. In
+future versions of GDB, the plus or minus sign will be optional, but you
+can use it to narrow the search. It is also possible to specify just a
+method name:
+
+@example
+break create
+@end example
+
+You must specify the complete method name, including any colons. If
+your program's source files contain more than one @code{create} method,
+you'll be presented with a numbered list of classes that implement that
+method. Indicate your choice by number, or type @samp{0} to exit if
+none apply.
+
+As another example, to clear a breakpoint established at the
+@code{makeKeyAndOrderFront:} method of the @code{NSWindow} class, enter:
+
+@example
+clear -[NSWindow makeKeyAndOrderFront:]
+@end example
+
+@node The Print Command with Objective-C
+@subsubsection The Print Command With Objective-C
+
+The print command has also been extended to accept methods. For example:
+
+@example
+print -[object hash]
+@end example
+
+will tell gdb to send the -hash message to object and print the
+result. Also an additional command has been added, @code{print-object}
+or @code{po} for short, which is meant to print the description of an
+object. However, this command may only work with certain Objective-C
+libraries that have a particular hook function, called
+@code{_NSPrintForDebugger} defined.
+
+@node Modula-2, , Objective-C, Support
@subsection Modula-2
@cindex Modula-2, @value{GDBN} support
@@ -9089,6 +9175,20 @@ outside of functions (i.e.@: excluding l
Print the names and data types of all variables (except for local
variables) whose names contain a match for regular expression
@var{regexp}.
+
+@kindex info classes
+@item info classes
+@itemx info classes @var{regexp}
+Display all Objective-C classes in your program, or
+(with the @var{regexp} argument) all those matching a particular regular
+expression.
+
+@kindex info selectors
+@item info selectors
+@itemx info selectors @var{regexp}
+Display all Objective-C selectors in your program, or
+(with the @var{regexp} argument) all those matching a particular regular
+expression.
@ignore
This was never implemented.
Index: gdb/testsuite/configure.in
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/configure.in,v
retrieving revision 1.6
diff -u -p -r1.6 configure.in
--- gdb/testsuite/configure.in 1 Aug 2002 17:18:35 -0000 1.6
+++ gdb/testsuite/configure.in 17 Sep 2002 19:31:33 -0000
@@ -18,6 +18,7 @@ configdirs="gdb.arch \
gdb.base \
gdb.c++ \
gdb.java \
+ gdb.objc \
gdb.disasm \
gdb.mi \
gdb.threads \
Index: gdb/testsuite/gdb.base/default.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.base/default.exp,v
retrieving revision 1.13
diff -u -p -r1.13 default.exp
--- gdb/testsuite/gdb.base/default.exp 10 Sep 2002 07:03:18 -0000 1.13
+++ gdb/testsuite/gdb.base/default.exp 17 Sep 2002 19:31:34 -0000
@@ -636,9 +636,9 @@ gdb_test "show print address" "Printing
#test show print array
gdb_test "show print array" "Prettyprinting of arrays is on." "show print array"
#test show print asm-demangle
-gdb_test "show print asm-demangle" "Demangling of C\[+\]+ names in disassembly listings is on." "show print asm-demangle"
+gdb_test "show print asm-demangle" "Demangling of C\[+\]+/ObjC names in disassembly listings is on." "show print asm-demangle"
#test show print demangle
-gdb_test "show print demangle" "Demangling of encoded C\[+\]+ names when displaying symbols is on." "show print demangle"
+gdb_test "show print demangle" "Demangling of encoded C\[+\]+/ObjC names when displaying symbols is on." "show print demangle"
#test show print elements
gdb_test "show print elements" "Limit on string chars or array elements to print is 200." "show print elements"
#test show print object
Index: gdb/testsuite/gdb.base/help.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.base/help.exp,v
retrieving revision 1.11
diff -u -p -r1.11 help.exp
--- gdb/testsuite/gdb.base/help.exp 24 Apr 2002 03:07:33 -0000 1.11
+++ gdb/testsuite/gdb.base/help.exp 17 Sep 2002 19:31:36 -0000
@@ -390,9 +390,9 @@ gdb_test "help set print address" "Set p
# test help set print array
gdb_test "help set print array" "Set prettyprinting of arrays\." "help set print array"
# test help set print asm-demangle
-gdb_test "help set print asm-demangle" "Set demangling of C\[+\]+ names in disassembly listings\." "help set print asm-demangle"
+gdb_test "help set print asm-demangle" "Set demangling of C\[+\]+/ObjC names in disassembly listings\." "help set print asm-demangle"
# test help set print demangle
-gdb_test "help set print demangle" "Set demangling of encoded C\[+\]+ names when displaying symbols\." "help set print demangle"
+gdb_test "help set print demangle" "Set demangling of encoded C\[+\]+/ObjC names when displaying symbols\." "help set print demangle"
# test help set print elements
gdb_test "help set print elements" "Set limit on string chars or array elements to print\.\[\r\n\]+\"set print elements 0\" causes there to be no limit\." "help set print elements"
# test help set print object
@@ -482,9 +482,9 @@ gdb_test "help show print address" "Show
# test help show print array
gdb_test "help show print array" "Show prettyprinting of arrays\." "help show print array"
# test help show print asm-demangle
-gdb_test "help show print asm-demangle" "Show demangling of C\[+\]+ names in disassembly listings\." "help show print asm-demangle"
+gdb_test "help show print asm-demangle" "Show demangling of C\[+\]+/ObjC names in disassembly listings\." "help show print asm-demangle"
# test help show print demangle
-gdb_test "help show print demangle" "Show demangling of encoded C\[+\]+ names when displaying symbols\." "help show print demangle"
+gdb_test "help show print demangle" "Show demangling of encoded C\[+\]+/ObjC names when displaying symbols\." "help show print demangle"
# test help show print elements
gdb_test "help show print elements" "Show limit on string chars or array elements to print\.\[\r\n\]+\"set print elements 0\" causes there to be no limit\." "help show print elements"
# test help show print object
Index: gdb/testsuite/gdb.base/maint.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.base/maint.exp,v
retrieving revision 1.13
diff -u -p -r1.13 maint.exp
--- gdb/testsuite/gdb.base/maint.exp 14 May 2002 18:30:53 -0000 1.13
+++ gdb/testsuite/gdb.base/maint.exp 17 Sep 2002 19:31:36 -0000
@@ -454,7 +454,7 @@ set timeout $oldtimeout
send_gdb "help maint\n"
gdb_expect {
- -re "Commands for use by GDB maintainers\\..*Includes commands to dump specific internal GDB structures in.*a human readable form, to cause GDB to deliberately dump core,.*to test internal functions such as the C.. demangler, etc\\..*List of maintenance subcommands:.*maintenance check-symtabs.*maintenance demangle.*(maintenance dump-me.*)?maintenance info.*maintenance internal-error.*maintenance print.*maintenance set.*maintenance show.*maintenance space.*maintenance time.*Type.*help maintenance.*followed by maintenance subcommand name for full documentation\\..*Command name abbreviations are allowed if unambiguous\\..*$gdb_prompt $"\
+ -re "Commands for use by GDB maintainers\\..*Includes commands to dump specific internal GDB structures in.*a human readable form, to cause GDB to deliberately dump core,.*to test internal functions such as the C../ObjC demangler, etc\\..*List of maintenance subcommands:.*maintenance check-symtabs.*maintenance demangle.*(maintenance dump-me.*)?maintenance info.*maintenance internal-error.*maintenance print.*maintenance set.*maintenance show.*maintenance space.*maintenance time.*Type.*help maintenance.*followed by maintenance subcommand name for full documentation\\..*Command name abbreviations are allowed if unambiguous\\..*$gdb_prompt $"\
{ pass "help maint" }
-re ".*$gdb_prompt $" { fail "help maint" }
timeout { fail "(timeout) help maint" }
@@ -487,7 +487,7 @@ gdb_expect {
send_gdb "help maint demangle\n"
gdb_expect {
- -re "Demangle a C\\+\\+ mangled name\\.\r\nCall internal GDB demangler routine to demangle a C\\+\\+ link name\r\nand prints the result\\..*$gdb_prompt $"\
+ -re "Demangle a C\\+\\+/ObjC mangled name\\.\r\nCall internal GDB demangler routine to demangle a C\\+\\+ link name\r\nand prints the result\\..*$gdb_prompt $"\
{ pass "help maint demangle" }
-re ".*$gdb_prompt $" { fail "help maint demangle" }
timeout { fail "(timeout) help maint demangle" }
@@ -614,7 +614,7 @@ gdb_expect {
send_gdb "help maint\n"
gdb_expect {
- -re "Commands for use by GDB maintainers\\.\[\r\n\]+Includes commands to dump specific internal GDB structures in\[\r\n\]+a human readable form, to cause GDB to deliberately dump core,\[\r\n\]+to test internal functions such as the C\\+\\+ demangler, etc\\..*Type.*help maintenance.*followed by maintenance subcommand name for full documentation\\.\[\r\n\]+Command name abbreviations are allowed if unambiguous\\..*$gdb_prompt $"\
+ -re "Commands for use by GDB maintainers\\.\[\r\n\]+Includes commands to dump specific internal GDB structures in\[\r\n\]+a human readable form, to cause GDB to deliberately dump core,\[\r\n\]+to test internal functions such as the C\\+\\+/ObjC demangler, etc\\..*Type.*help maintenance.*followed by maintenance subcommand name for full documentation\\.\[\r\n\]+Command name abbreviations are allowed if unambiguous\\..*$gdb_prompt $"\
{ pass "help maint" }
-re ".*$gdb_prompt $" { fail "help maint" }
timeout { fail "(timeout) help maint" }
^ permalink raw reply [flat|nested] 62+ messages in thread
* Re: [PATCH] Objective-C language support.
2002-09-18 8:24 [PATCH] Objective-C language support Adam Fedor
@ 2002-09-18 10:50 ` Michael Snyder
2002-09-18 11:57 ` Andrew Cagney
` (3 more replies)
2002-09-18 14:03 ` Andrew Cagney
` (13 subsequent siblings)
14 siblings, 4 replies; 62+ messages in thread
From: Michael Snyder @ 2002-09-18 10:50 UTC (permalink / raw)
To: Adam Fedor; +Cc: gdb-patches
Adam Fedor wrote:
>
> This patch adds Objective-C language support to gdb based upon a patch
> provided by Apple Computer Inc from their version of gdb. Note that the
> patch only contains changes to existing files. New files (objc-lang.h,
> objc-lang.c, objc-exp.y) and a gdb.objc testsuite directory are located at
>
> ftp://ftp.gnustep.org/pub/gnustep/contrib/gdb-objc-patch.tar.gz
>
Oh lord. I suppose I am the only one here who is
even noddingly familiar with Objective C?
There's a good chance that I wrote some of this code
anyway, so I'll try to have a look at it. You know,
of course, that we can't just drop something this huge
into the source tree without some review...
I'll need the ability to run the tests. Does GCC already
have enough objc to compile them? Will I need any special
libraries?
^ permalink raw reply [flat|nested] 62+ messages in thread
* Re: [PATCH] Objective-C language support.
2002-09-18 10:50 ` Michael Snyder
2002-09-18 11:57 ` Andrew Cagney
@ 2002-09-18 11:57 ` Michael Snyder
2002-09-18 11:59 ` Daniel Berlin
2002-09-18 13:31 ` Adam Fedor
3 siblings, 0 replies; 62+ messages in thread
From: Michael Snyder @ 2002-09-18 11:57 UTC (permalink / raw)
To: Adam Fedor, gdb-patches
Michael Snyder wrote:
>
> Adam Fedor wrote:
> >
> > This patch adds Objective-C language support to gdb based upon a patch
> > provided by Apple Computer Inc from their version of gdb. Note that the
> > patch only contains changes to existing files. New files (objc-lang.h,
> > objc-lang.c, objc-exp.y) and a gdb.objc testsuite directory are located at
> >
> > ftp://ftp.gnustep.org/pub/gnustep/contrib/gdb-objc-patch.tar.gz
> >
>
> Oh lord. I suppose I am the only one here who is
> even noddingly familiar with Objective C?
>
> There's a good chance that I wrote some of this code
> anyway, so I'll try to have a look at it. You know,
> of course, that we can't just drop something this huge
> into the source tree without some review...
>
> I'll need the ability to run the tests. Does GCC already
> have enough objc to compile them? Will I need any special
> libraries?
Adam,
Any chance of getting the original authors' names for the
changelog, instead of / in addition to yours?
Michael
^ permalink raw reply [flat|nested] 62+ messages in thread
* Re: [PATCH] Objective-C language support.
2002-09-18 10:50 ` Michael Snyder
@ 2002-09-18 11:57 ` Andrew Cagney
2002-09-18 12:04 ` Michael Snyder
2002-09-18 11:57 ` Michael Snyder
` (2 subsequent siblings)
3 siblings, 1 reply; 62+ messages in thread
From: Andrew Cagney @ 2002-09-18 11:57 UTC (permalink / raw)
To: Michael Snyder; +Cc: Adam Fedor, gdb-patches
> Adam Fedor wrote:
>
>>
>> This patch adds Objective-C language support to gdb based upon a patch
>> provided by Apple Computer Inc from their version of gdb. Note that the
>> patch only contains changes to existing files. New files (objc-lang.h,
>> objc-lang.c, objc-exp.y) and a gdb.objc testsuite directory are located at
>>
>> ftp://ftp.gnustep.org/pub/gnustep/contrib/gdb-objc-patch.tar.gz
>>
>
>
>
> Oh lord. I suppose I am the only one here who is
> even noddingly familiar with Objective C?
>
> There's a good chance that I wrote some of this code
> anyway, so I'll try to have a look at it. You know,
> of course, that we can't just drop something this huge
> into the source tree without some review...
>
> I'll need the ability to run the tests. Does GCC already
> have enough objc to compile them? Will I need any special
> libraries?
For Ada, a different approach has been taken:
- commit the new files (but not changes to old files)
- commit the makefile rules for the new files (but not changes that
would cause these files to build by default)
- clean the files up so that they meet current coding conventions -
-Werror, ARI, ... (for Ada the files were all K&R, looking back.)
- slowly contribute/merge the patches to other files
- add the missing makefile bits making it part of GDB
This way, the bulk of the code is in the mainline. I think it works
better since:
- people can see the code (there have already been several patches go
through where the Ada code was ``fixed'' for free, just by virtue of
being part of the repository).
- while being developed, doesn't break the existing builds
With this, the worst that can happen is the code never gets enabled.
The other thing is that, very like when someone adds new a architecture,
other than the contributor, no one immediatly cares if it doesn't work
quite right. Just as long as it hasn't actually broken other parts of
GDB and hasn't hasn't done anything really really nasty at the
implementation level (ari and -Werror cover most of that).
enjoy,
Andrew
^ permalink raw reply [flat|nested] 62+ messages in thread
* Re: [PATCH] Objective-C language support.
2002-09-18 10:50 ` Michael Snyder
2002-09-18 11:57 ` Andrew Cagney
2002-09-18 11:57 ` Michael Snyder
@ 2002-09-18 11:59 ` Daniel Berlin
2002-09-18 13:31 ` Adam Fedor
3 siblings, 0 replies; 62+ messages in thread
From: Daniel Berlin @ 2002-09-18 11:59 UTC (permalink / raw)
To: Michael Snyder; +Cc: Adam Fedor, gdb-patches
On Wed, 18 Sep 2002, Michael Snyder wrote:
> Adam Fedor wrote:
> >
> > This patch adds Objective-C language support to gdb based upon a patch
> > provided by Apple Computer Inc from their version of gdb. Note that the
> > patch only contains changes to existing files. New files (objc-lang.h,
> > objc-lang.c, objc-exp.y) and a gdb.objc testsuite directory are located at
> >
> > ftp://ftp.gnustep.org/pub/gnustep/contrib/gdb-objc-patch.tar.gz
> >
>
>
> Oh lord. I suppose I am the only one here who is
> even noddingly familiar with Objective C?
I've coded some stuff in it in the past year.
Basically GUI interfaces to command line VPN clients on MacOSX.
>
> There's a good chance that I wrote some of this code
> anyway, so I'll try to have a look at it. You know,
> of course, that we can't just drop something this huge
> into the source tree without some review...
>
> I'll need the ability to run the tests. Does GCC already
> have enough objc to compile them?
It should.
It should have had it for many moons now (3.0 or 3.1, at the latest).
>Will I need any special libraries?
Shouldn't.
>
^ permalink raw reply [flat|nested] 62+ messages in thread
* Re: [PATCH] Objective-C language support.
2002-09-18 11:57 ` Andrew Cagney
@ 2002-09-18 12:04 ` Michael Snyder
2002-09-18 12:14 ` Andrew Cagney
0 siblings, 1 reply; 62+ messages in thread
From: Michael Snyder @ 2002-09-18 12:04 UTC (permalink / raw)
To: Andrew Cagney; +Cc: Adam Fedor, gdb-patches
Andrew Cagney wrote:
>
> > Adam Fedor wrote:
> >
> >>
> >> This patch adds Objective-C language support to gdb based upon a patch
> >> provided by Apple Computer Inc from their version of gdb. Note that the
> >> patch only contains changes to existing files. New files (objc-lang.h,
> >> objc-lang.c, objc-exp.y) and a gdb.objc testsuite directory are located at
> >>
> >> ftp://ftp.gnustep.org/pub/gnustep/contrib/gdb-objc-patch.tar.gz
> >>
> >
> >
> >
> > Oh lord. I suppose I am the only one here who is
> > even noddingly familiar with Objective C?
> >
> > There's a good chance that I wrote some of this code
> > anyway, so I'll try to have a look at it. You know,
> > of course, that we can't just drop something this huge
> > into the source tree without some review...
> >
> > I'll need the ability to run the tests. Does GCC already
> > have enough objc to compile them? Will I need any special
> > libraries?
>
> For Ada, a different approach has been taken:
>
> - commit the new files (but not changes to old files)
> - commit the makefile rules for the new files (but not changes that
> would cause these files to build by default)
> - clean the files up so that they meet current coding conventions -
> -Werror, ARI, ... (for Ada the files were all K&R, looking back.)
> - slowly contribute/merge the patches to other files
> - add the missing makefile bits making it part of GDB
>
> This way, the bulk of the code is in the mainline. I think it works
> better since:
>
> - people can see the code (there have already been several patches go
> through where the Ada code was ``fixed'' for free, just by virtue of
> being part of the repository).
> - while being developed, doesn't break the existing builds
>
> With this, the worst that can happen is the code never gets enabled.
>
> The other thing is that, very like when someone adds new a architecture,
> other than the contributor, no one immediatly cares if it doesn't work
> quite right. Just as long as it hasn't actually broken other parts of
> GDB and hasn't hasn't done anything really really nasty at the
> implementation level (ari and -Werror cover most of that).
>
> enjoy,
> Andrew
Thanks, I'll try this approach. On that principal, I will
check in the objc-specific files right away.
I do wish I had some names for their actual authors, though...
Michael
^ permalink raw reply [flat|nested] 62+ messages in thread
* Re: [PATCH] Objective-C language support.
2002-09-18 12:04 ` Michael Snyder
@ 2002-09-18 12:14 ` Andrew Cagney
2002-09-18 12:17 ` Michael Snyder
0 siblings, 1 reply; 62+ messages in thread
From: Andrew Cagney @ 2002-09-18 12:14 UTC (permalink / raw)
To: Michael Snyder; +Cc: Adam Fedor, gdb-patches
> Thanks, I'll try this approach. On that principal, I will
> check in the objc-specific files right away.
Remember, if you check these files in, then it is you that is on the
hook for cleaning them up.
> I do wish I had some names for their actual authors, though...
Perhaps wait for that.
Andrew
^ permalink raw reply [flat|nested] 62+ messages in thread
* Re: [PATCH] Objective-C language support.
2002-09-18 12:14 ` Andrew Cagney
@ 2002-09-18 12:17 ` Michael Snyder
2002-09-18 13:51 ` Adam Fedor
0 siblings, 1 reply; 62+ messages in thread
From: Michael Snyder @ 2002-09-18 12:17 UTC (permalink / raw)
To: Andrew Cagney; +Cc: Adam Fedor, gdb-patches
Andrew Cagney wrote:
>
> > Thanks, I'll try this approach. On that principal, I will
> > check in the objc-specific files right away.
>
> Remember, if you check these files in, then it is you that is on the
> hook for cleaning them up.
OK. That's not hard.
> > I do wish I had some names for their actual authors, though...
>
> Perhaps wait for that.
OK.
Ping, Adam...
^ permalink raw reply [flat|nested] 62+ messages in thread
* Re: [PATCH] Objective-C language support.
2002-09-18 10:50 ` Michael Snyder
` (2 preceding siblings ...)
2002-09-18 11:59 ` Daniel Berlin
@ 2002-09-18 13:31 ` Adam Fedor
3 siblings, 0 replies; 62+ messages in thread
From: Adam Fedor @ 2002-09-18 13:31 UTC (permalink / raw)
To: Michael Snyder; +Cc: gdb-patches
Michael Snyder wrote:
> Adam Fedor wrote:
>
>>This patch adds Objective-C language support to gdb based upon a patch
>>provided by Apple Computer Inc from their version of gdb. Note that the
>>patch only contains changes to existing files. New files (objc-lang.h,
>>objc-lang.c, objc-exp.y) and a gdb.objc testsuite directory are located at
>>
>>ftp://ftp.gnustep.org/pub/gnustep/contrib/gdb-objc-patch.tar.gz
>>
>
> There's a good chance that I wrote some of this code
> anyway, so I'll try to have a look at it. You know,
> of course, that we can't just drop something this huge
> into the source tree without some review...
>
Well I though it would just be reject outright, so I guess I'm doing
relatively good :-)
> I'll need the ability to run the tests. Does GCC already
> have enough objc to compile them? Will I need any special
> libraries?
It's been tested with gcc 2.95 and 3.X. It should work with any gcc out
of the box. Only libobjc which comes with gcc.
> Any chance of getting the original authors' names for the
> changelog, instead of / in addition to yours?
I looked at the ChangeLog that came with the patch, but most changes
didn't have anything to do with the patches I submitted, or it was hard
for me to match an entry with an actual change in the code. I could try
to look at CVS logs, but that could be tedious and Jason Molenda has
said that most of those are null.
--
Adam Fedor, Digital Optics Corp. | I'm glad I hate spinach, because
http://www.doc.com | if I didn't, I'd eat it, and you
| know how I hate the stuff.
^ permalink raw reply [flat|nested] 62+ messages in thread
* Re: [PATCH] Objective-C language support.
2002-09-18 12:17 ` Michael Snyder
@ 2002-09-18 13:51 ` Adam Fedor
2002-09-18 15:00 ` Michael Snyder
0 siblings, 1 reply; 62+ messages in thread
From: Adam Fedor @ 2002-09-18 13:51 UTC (permalink / raw)
To: Michael Snyder; +Cc: gdb-patches
Michael Snyder wrote:
>
>
>>>I do wish I had some names for their actual authors, though...
>>
Well I compared the Apple patch with the one you sent out long, long
ago, and there were a lot of similarities. If that helps...
--
Adam Fedor, Digital Optics Corp. | I'm glad I hate spinach, because
http://www.doc.com | if I didn't, I'd eat it, and you
| know how I hate the stuff.
^ permalink raw reply [flat|nested] 62+ messages in thread
* Re: [PATCH] Objective-C language support.
2002-09-18 8:24 [PATCH] Objective-C language support Adam Fedor
2002-09-18 10:50 ` Michael Snyder
@ 2002-09-18 14:03 ` Andrew Cagney
2002-10-08 16:36 ` Michael Snyder
` (12 subsequent siblings)
14 siblings, 0 replies; 62+ messages in thread
From: Andrew Cagney @ 2002-09-18 14:03 UTC (permalink / raw)
To: Adam Fedor; +Cc: gdb-patches
Adam,
Once your account is up please feel free to add yourself to the
write-after-approval list in the MAINTAINERS file as an obvious fix.
Andrew
^ permalink raw reply [flat|nested] 62+ messages in thread
* Re: [PATCH] Objective-C language support.
2002-09-18 13:51 ` Adam Fedor
@ 2002-09-18 15:00 ` Michael Snyder
2002-09-18 15:19 ` Adam Fedor
2002-09-18 15:25 ` Andrew Cagney
0 siblings, 2 replies; 62+ messages in thread
From: Michael Snyder @ 2002-09-18 15:00 UTC (permalink / raw)
To: Adam Fedor; +Cc: gdb-patches
Adam Fedor wrote:
>
> Michael Snyder wrote:
> >
> >
> >>>I do wish I had some names for their actual authors, though...
> >>
>
> Well I compared the Apple patch with the one you sent out long, long
> ago, and there were a lot of similarities. If that helps...
I was beginning to suspect that. This code looks VERY familiar. ;-)
So what's its Copyright status? Did you get an assignment from Apple?
^ permalink raw reply [flat|nested] 62+ messages in thread
* Re: [PATCH] Objective-C language support.
2002-09-18 15:00 ` Michael Snyder
@ 2002-09-18 15:19 ` Adam Fedor
2002-09-18 15:25 ` Andrew Cagney
1 sibling, 0 replies; 62+ messages in thread
From: Adam Fedor @ 2002-09-18 15:19 UTC (permalink / raw)
To: Michael Snyder; +Cc: gdb-patches
Michael Snyder wrote:
> Adam Fedor wrote:
>
>>Michael Snyder wrote:
>>
>>>
>>>>>I do wish I had some names for their actual authors, though...
>>>>
>>Well I compared the Apple patch with the one you sent out long, long
>>ago, and there were a lot of similarities. If that helps...
>
>
>
> I was beginning to suspect that. This code looks VERY familiar. ;-)
>
> So what's its Copyright status? Did you get an assignment from Apple?
Apple should have a blanket copyright assignment to the FSF for this
code (as well as future code). There was a discussion on the gdb list
about this recently. Andrew should be able to confirm the status.
^ permalink raw reply [flat|nested] 62+ messages in thread
* Re: [PATCH] Objective-C language support.
2002-09-18 15:00 ` Michael Snyder
2002-09-18 15:19 ` Adam Fedor
@ 2002-09-18 15:25 ` Andrew Cagney
1 sibling, 0 replies; 62+ messages in thread
From: Andrew Cagney @ 2002-09-18 15:25 UTC (permalink / raw)
To: Michael Snyder; +Cc: Adam Fedor, gdb-patches
> Adam Fedor wrote:
>
>>
>> Michael Snyder wrote:
>
>> >
>> >
>
>> >>>I do wish I had some names for their actual authors, though...
>
>> >>
>
>>
>> Well I compared the Apple patch with the one you sent out long, long
>> ago, and there were a lot of similarities. If that helps...
>
>
>
> I was beginning to suspect that. This code looks VERY familiar. ;-)
>
> So what's its Copyright status? Did you get an assignment from Apple?
There aren't any copyright problems.
Apple contributed this code to the FSF. I accepted it (its sitting in
ftp://sources.redhat.com/pub/gdb/contrib/apple/). Adam, who has an FSF
assignment in place, picked up the contributed work and started hacking
it to the point were it could be integrated into current GDB.
enjoy,
Andrew
^ permalink raw reply [flat|nested] 62+ messages in thread
* Re: [PATCH] Objective-C language support.
2002-09-18 8:24 [PATCH] Objective-C language support Adam Fedor
2002-09-18 10:50 ` Michael Snyder
2002-09-18 14:03 ` Andrew Cagney
@ 2002-10-08 16:36 ` Michael Snyder
2002-10-11 19:29 ` Adam Fedor
2002-10-08 16:42 ` Michael Snyder
` (11 subsequent siblings)
14 siblings, 1 reply; 62+ messages in thread
From: Michael Snyder @ 2002-10-08 16:36 UTC (permalink / raw)
To: Adam Fedor; +Cc: gdb-patches
Adam Fedor wrote:
>
> This patch adds Objective-C language support to gdb based upon a patch
> provided by Apple Computer Inc from their version of gdb. Note that the
> patch only contains changes to existing files. New files (objc-lang.h,
> objc-lang.c, objc-exp.y) and a gdb.objc testsuite directory are located at
>
> ftp://ftp.gnustep.org/pub/gnustep/contrib/gdb-objc-patch.tar.gz
Well, let's see if we can't get this going again.
Adam, I'm going to give you approval for the following
portion of this patch. If no one objects in the next
few days, you can check it in.
> * defs.h (enum language): Add language_objc.
>
> Index: gdb/defs.h
> ===================================================================
> RCS file: /cvs/src/src/gdb/defs.h,v
> retrieving revision 1.94
> diff -u -p -r1.94 defs.h
> --- gdb/defs.h 1 Aug 2002 17:18:32 -0000 1.94
> +++ gdb/defs.h 17 Sep 2002 19:29:59 -0000
> @@ -208,6 +208,7 @@ enum language
> 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 */
^ permalink raw reply [flat|nested] 62+ messages in thread
* Re: [PATCH] Objective-C language support.
2002-09-18 8:24 [PATCH] Objective-C language support Adam Fedor
` (2 preceding siblings ...)
2002-10-08 16:36 ` Michael Snyder
@ 2002-10-08 16:42 ` Michael Snyder
2002-10-11 19:44 ` Adam Fedor
2002-10-21 15:18 ` Andrew Cagney
2002-10-08 16:45 ` Michael Snyder
` (10 subsequent siblings)
14 siblings, 2 replies; 62+ messages in thread
From: Michael Snyder @ 2002-10-08 16:42 UTC (permalink / raw)
To: Adam Fedor; +Cc: gdb-patches
Adam Fedor wrote:
>
> This patch adds Objective-C language support to gdb based upon a patch
> provided by Apple Computer Inc from their version of gdb. Note that the
> patch only contains changes to existing files. New files (objc-lang.h,
> objc-lang.c, objc-exp.y) and a gdb.objc testsuite directory are located at
>
> ftp://ftp.gnustep.org/pub/gnustep/contrib/gdb-objc-patch.tar.gz
Adam, this bit can't hurt anything, since it just adds some new enum
values. Only one suggestion -- how about putting OP_THIS and OP_SELF
consecutively, because they're so similar? Also please hold off on
the export of evaluate_subexp -- let's handle that separately.
Other than that, approved. Wait a couple days for objections, then
you can commit it.
> * expression.h: New ops NSSTRING, SELECTOR, MSGCALL, and SELF.
> Index: gdb/expression.h
> ===================================================================
> RCS file: /cvs/src/src/gdb/expression.h,v
> retrieving revision 1.4
> diff -u -p -r1.4 expression.h
> --- gdb/expression.h 1 Aug 2002 17:18:32 -0000 1.4
> +++ gdb/expression.h 17 Sep 2002 19:30:05 -0000
> @@ -181,6 +181,12 @@ enum exp_opcode
> 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
> @@ -273,11 +279,17 @@ enum exp_opcode
> STRUCTOP_STRUCT,
> STRUCTOP_PTR,
>
> - /* C++ */
> - /* OP_THIS is just a placeholder for the class instance variable.
> + /* 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. */
> @@ -305,7 +317,10 @@ enum exp_opcode
> OP_NAME,
>
> /* An unparsed expression. Used for Scheme (for now at least) */
> - OP_EXPRSTRING
> + OP_EXPRSTRING,
> +
> + /* An Objective C Foundation Class NSString constant */
> + OP_NSSTRING,
> };
>
> union exp_element
> @@ -369,6 +384,10 @@ enum noside
>
> extern struct value *evaluate_subexp_standard
> (struct type *, struct expression *, int *, enum noside);
> +
> +extern struct value *evaluate_subexp (struct type *, struct expression *,
> + int *, enum noside);
> +
>
> /* From expprint.c */
>
^ permalink raw reply [flat|nested] 62+ messages in thread
* Re: [PATCH] Objective-C language support.
2002-09-18 8:24 [PATCH] Objective-C language support Adam Fedor
` (3 preceding siblings ...)
2002-10-08 16:42 ` Michael Snyder
@ 2002-10-08 16:45 ` Michael Snyder
2002-10-11 19:39 ` Adam Fedor
2002-10-08 16:51 ` Michael Snyder
` (9 subsequent siblings)
14 siblings, 1 reply; 62+ messages in thread
From: Michael Snyder @ 2002-10-08 16:45 UTC (permalink / raw)
To: Adam Fedor; +Cc: gdb-patches
Adam Fedor wrote:
>
> This patch adds Objective-C language support to gdb based upon a patch
> provided by Apple Computer Inc from their version of gdb. Note that the
> patch only contains changes to existing files. New files (objc-lang.h,
> objc-lang.c, objc-exp.y) and a gdb.objc testsuite directory are located at
>
> ftp://ftp.gnustep.org/pub/gnustep/contrib/gdb-objc-patch.tar.gz
Adam, once the defs.h change is in, this can go in too (barring objections):
> * language.h (CAST_IS_CONVERSION): Add language_objc.
> Index: gdb/language.h
> ===================================================================
> RCS file: /cvs/src/src/gdb/language.h,v
> retrieving revision 1.11
> diff -u -p -r1.11 language.h
> --- gdb/language.h 1 Aug 2002 17:18:32 -0000 1.11
> +++ gdb/language.h 17 Sep 2002 19:30:36 -0000
> @@ -288,7 +288,8 @@ language_mode;
> /* "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_cplus || \
> + current_language->la_language == language_objc)
>
> extern void language_info (int);
>
^ permalink raw reply [flat|nested] 62+ messages in thread
* Re: [PATCH] Objective-C language support.
2002-09-18 8:24 [PATCH] Objective-C language support Adam Fedor
` (4 preceding siblings ...)
2002-10-08 16:45 ` Michael Snyder
@ 2002-10-08 16:51 ` Michael Snyder
2002-10-14 13:06 ` Jim Blandy
2002-10-08 16:58 ` Michael Snyder
` (8 subsequent siblings)
14 siblings, 1 reply; 62+ messages in thread
From: Michael Snyder @ 2002-10-08 16:51 UTC (permalink / raw)
To: Adam Fedor; +Cc: gdb-patches, jimb
Adam Fedor wrote:
>
> This patch adds Objective-C language support to gdb based upon a patch
> provided by Apple Computer Inc from their version of gdb. Note that the
> patch only contains changes to existing files. New files (objc-lang.h,
> objc-lang.c, objc-exp.y) and a gdb.objc testsuite directory are located at
>
> ftp://ftp.gnustep.org/pub/gnustep/contrib/gdb-objc-patch.tar.gz
This change is (remotely) related to symbol tables, which belong to
Jim Blandy and Elena Zannoni. Jim, do you have any objection to this
change? I think it's almost obvious, and recommend it for approval.
> * symtab.h: New objc_specific struct.
> (SYMBOL_INIT_LANGUAGE_SPECIFIC): Handle ObjC.
> (SYMBOL_DEMANGLED_NAME): Likewise.
> Index: gdb/symtab.h
> ===================================================================
> RCS file: /cvs/src/src/gdb/symtab.h,v
> retrieving revision 1.39
> diff -u -p -r1.39 symtab.h
> --- gdb/symtab.h 12 Sep 2002 19:19:37 -0000 1.39
> +++ gdb/symtab.h 17 Sep 2002 19:31:07 -0000
> @@ -89,6 +89,11 @@ struct general_symbol_info
> char *demangled_name;
> }
> cplus_specific;
> + struct objc_specific
> + {
> + char *demangled_name;
> + }
> + objc_specific;
> #if 0
> /* OBSOLETE struct chill_specific *//* For Chill */
> /* OBSOLETE { */
> @@ -146,6 +151,10 @@ extern CORE_ADDR symbol_overlayed_addres
> { \
> 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; */ \
> @@ -170,12 +179,17 @@ extern void symbol_init_demangled_name (
> (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)
> + 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
^ permalink raw reply [flat|nested] 62+ messages in thread
* Re: [PATCH] Objective-C language support.
2002-09-18 8:24 [PATCH] Objective-C language support Adam Fedor
` (5 preceding siblings ...)
2002-10-08 16:51 ` Michael Snyder
@ 2002-10-08 16:58 ` Michael Snyder
2002-10-14 19:18 ` Adam Fedor
2002-10-21 15:31 ` Andrew Cagney
2002-10-08 17:01 ` Michael Snyder
` (7 subsequent siblings)
14 siblings, 2 replies; 62+ messages in thread
From: Michael Snyder @ 2002-10-08 16:58 UTC (permalink / raw)
To: Adam Fedor; +Cc: gdb-patches
Adam Fedor wrote:
>
> This patch adds Objective-C language support to gdb based upon a patch
> provided by Apple Computer Inc from their version of gdb. Note that the
> patch only contains changes to existing files. New files (objc-lang.h,
> objc-lang.c, objc-exp.y) and a gdb.objc testsuite directory are located at
>
> ftp://ftp.gnustep.org/pub/gnustep/contrib/gdb-objc-patch.tar.gz
I can approve this, but you'll have to comment out the bit that
calls objc_demangle for now, until the entire patch is ready to
go on line. Otherwise it'll come up undefined.
> * utils.c (puts_filtered_tabular): New function.
> (fprintf_symbol_filtered): Get ObjC demangled name.
> * valops.c (call_function_by_hand_expecting_type): New function.
> (value_of_local): New function.
> (value_of_this): Use it.
> Index: gdb/utils.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/utils.c,v
> retrieving revision 1.76
> diff -u -p -r1.76 utils.c
> --- gdb/utils.c 1 Aug 2002 17:18:33 -0000 1.76
> +++ gdb/utils.c 17 Sep 2002 19:31:08 -0000
> @@ -152,13 +152,13 @@ int quit_flag;
>
> int immediate_quit;
>
> -/* Nonzero means that encoded C++ names should be printed out in their
> - C++ form rather than raw. */
> +/* 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++ names should be printed out in their
> - C++ form even in assembler language displays. If this is set, but
> +/* 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;
> @@ -1696,6 +1696,51 @@ wrap_here (char *indent)
> }
> }
>
> +/* 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
> @@ -2123,7 +2168,7 @@ print_spaces_filtered (int n, struct ui_
> fputs_filtered (n_spaces (n), stream);
> }
>
> -/* C++ demangler stuff. */
> +/* 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.
> @@ -2153,6 +2198,9 @@ fprintf_symbol_filtered (struct ui_file
> case language_java:
> demangled = cplus_demangle (name, arg_mode | DMGL_JAVA);
> break;
> + case language_objc:
> + demangled = objc_demangle (name);
> + break;
> #if 0
> /* OBSOLETE case language_chill: */
> /* OBSOLETE demangled = chill_demangle (name); */
> @@ -2272,7 +2320,7 @@ initialize_utils (void)
> add_show_from_set
> (add_set_cmd ("demangle", class_support, var_boolean,
> (char *) &demangle,
> - "Set demangling of encoded C++ names when displaying symbols.",
> + "Set demangling of encoded C++/ObjC names when displaying symbols.",
> &setprintlist),
> &showprintlist);
>
> @@ -2300,7 +2348,7 @@ initialize_utils (void)
> add_show_from_set
> (add_set_cmd ("asm-demangle", class_support, var_boolean,
> (char *) &asm_demangle,
> - "Set demangling of C++ names in disassembly listings.",
> + "Set demangling of C++/ObjC names in disassembly listings.",
> &setprintlist),
> &showprintlist);
> }
^ permalink raw reply [flat|nested] 62+ messages in thread
* Re: [PATCH] Objective-C language support.
2002-09-18 8:24 [PATCH] Objective-C language support Adam Fedor
` (6 preceding siblings ...)
2002-10-08 16:58 ` Michael Snyder
@ 2002-10-08 17:01 ` Michael Snyder
2002-10-14 13:08 ` Jim Blandy
2002-10-08 17:05 ` Michael Snyder
` (6 subsequent siblings)
14 siblings, 1 reply; 62+ messages in thread
From: Michael Snyder @ 2002-10-08 17:01 UTC (permalink / raw)
To: Adam Fedor; +Cc: gdb-patches, jimb
Adam Fedor wrote:
>
> This patch adds Objective-C language support to gdb based upon a patch
> provided by Apple Computer Inc from their version of gdb. Note that the
> patch only contains changes to existing files. New files (objc-lang.h,
> objc-lang.c, objc-exp.y) and a gdb.objc testsuite directory are located at
>
> ftp://ftp.gnustep.org/pub/gnustep/contrib/gdb-objc-patch.tar.gz
>
Jim, could you take a quick look at this small change?
[Adam, the comment needs a period followed by two spaces.]
> * elfread.c (elf_symtab_read): Skip ObjC symbols.
> Index: gdb/elfread.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/elfread.c,v
> retrieving revision 1.23
> diff -u -p -r1.23 elfread.c
> --- gdb/elfread.c 24 Jul 2002 23:51:35 -0000 1.23
> +++ gdb/elfread.c 17 Sep 2002 19:29:59 -0000
> @@ -349,7 +349,12 @@ elf_symtab_read (struct objfile *objfile
> }
> else if (sym->section->flags & SEC_CODE)
> {
> - if (sym->flags & BSF_GLOBAL)
> + 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;
> }
^ permalink raw reply [flat|nested] 62+ messages in thread
* Re: [PATCH] Objective-C language support.
2002-09-18 8:24 [PATCH] Objective-C language support Adam Fedor
` (7 preceding siblings ...)
2002-10-08 17:01 ` Michael Snyder
@ 2002-10-08 17:05 ` Michael Snyder
2002-10-14 13:14 ` Jim Blandy
2002-10-08 17:07 ` Michael Snyder
` (5 subsequent siblings)
14 siblings, 1 reply; 62+ messages in thread
From: Michael Snyder @ 2002-10-08 17:05 UTC (permalink / raw)
To: Adam Fedor; +Cc: gdb-patches, jimb
Adam Fedor wrote:
>
> This patch adds Objective-C language support to gdb based upon a patch
> provided by Apple Computer Inc from their version of gdb. Note that the
> patch only contains changes to existing files. New files (objc-lang.h,
> objc-lang.c, objc-exp.y) and a gdb.objc testsuite directory are located at
>
> ftp://ftp.gnustep.org/pub/gnustep/contrib/gdb-objc-patch.tar.gz
Jim, can you look at this one too? I can explain it for you --
objective c symbols sometimes contain colons, which will trip up
the stabs reader unles they're detected and allowed for.
Adam, I think the function is not used outside of stabsread.c, so
how about making it static, droping the "stabsread_" from its name,
and omitting the declaration from stabsread.h?
> * stabsread.c (stabsread_objc_colon): New function.
> (define_symbol): Use it.
> * stabsread.h: Declare it.
> Index: gdb/stabsread.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/stabsread.c,v
> retrieving revision 1.39
> diff -u -p -r1.39 stabsread.c
> --- gdb/stabsread.c 14 Sep 2002 02:09:39 -0000 1.39
> +++ gdb/stabsread.c 17 Sep 2002 19:31:03 -0000
> @@ -1273,7 +1273,7 @@ define_symbol (CORE_ADDR valu, char *str
> struct objfile *objfile)
> {
> register struct symbol *sym;
> - char *p = (char *) strchr (string, ':');
> + char *p = (char *) stabsread_objc_colon (string);
> int deftype;
> int synonym = 0;
> register int i;
> @@ -2006,7 +2006,8 @@ define_symbol (CORE_ADDR valu, char *str
> 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)
> + else if ((current_subfile->language == language_cplus)
> + || (current_subfile->language == language_objc))
> synonym = 1;
>
> SYMBOL_TYPE (sym) = read_type (&p, objfile);
> @@ -5615,6 +5616,30 @@ finish_global_stabs (struct objfile *obj
> patch_block_stabs (global_symbols, global_stabs, objfile);
> xfree (global_stabs);
> global_stabs = NULL;
> + }
> +}
> +
> +char *
> +stabsread_objc_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, ':');
> }
> }
>
> Index: gdb/stabsread.h
> ===================================================================
> RCS file: /cvs/src/src/gdb/stabsread.h,v
> retrieving revision 1.8
> diff -u -p -r1.8 stabsread.h
> --- gdb/stabsread.h 18 Jul 2002 17:22:50 -0000 1.8
> +++ gdb/stabsread.h 17 Sep 2002 19:31:04 -0000
> @@ -219,6 +219,8 @@ extern struct symbol *ref_search (int);
> extern int resolve_cfront_continuation
> (struct objfile *objfile, struct symbol *sym, char *p);
>
> +extern char *stabsread_objc_colon (char *name);
> +
> extern void free_header_files (void);
>
> extern void init_header_files (void);
^ permalink raw reply [flat|nested] 62+ messages in thread
* Re: [PATCH] Objective-C language support.
2002-09-18 8:24 [PATCH] Objective-C language support Adam Fedor
` (8 preceding siblings ...)
2002-10-08 17:05 ` Michael Snyder
@ 2002-10-08 17:07 ` Michael Snyder
2002-10-11 20:06 ` Adam Fedor
2002-10-08 17:14 ` Michael Snyder
` (4 subsequent siblings)
14 siblings, 1 reply; 62+ messages in thread
From: Michael Snyder @ 2002-10-08 17:07 UTC (permalink / raw)
To: Adam Fedor; +Cc: gdb-patches
Adam Fedor wrote:
>
> This patch adds Objective-C language support to gdb based upon a patch
> provided by Apple Computer Inc from their version of gdb. Note that the
> patch only contains changes to existing files. New files (objc-lang.h,
> objc-lang.c, objc-exp.y) and a gdb.objc testsuite directory are located at
>
> ftp://ftp.gnustep.org/pub/gnustep/contrib/gdb-objc-patch.tar.gz
Adam, this is a pretty obvious change, please check it in as soon as
the defs.h change goes in.
> * printfcmd.c (address_info): Print 'self' for ObjC.
> Index: gdb/printcmd.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/printcmd.c,v
> retrieving revision 1.41
> diff -u -p -r1.41 printcmd.c
> --- gdb/printcmd.c 10 Sep 2002 02:04:38 -0000 1.41
> +++ gdb/printcmd.c 17 Sep 2002 19:30:55 -0000
> @@ -1104,7 +1104,11 @@ address_info (char *exp, int from_tty)
> 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");
> + 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;
> }
>
^ permalink raw reply [flat|nested] 62+ messages in thread
* Re: [PATCH] Objective-C language support.
2002-09-18 8:24 [PATCH] Objective-C language support Adam Fedor
` (9 preceding siblings ...)
2002-10-08 17:07 ` Michael Snyder
@ 2002-10-08 17:14 ` Michael Snyder
2002-10-13 18:51 ` Adam Fedor
2002-10-08 17:16 ` Michael Snyder
` (3 subsequent siblings)
14 siblings, 1 reply; 62+ messages in thread
From: Michael Snyder @ 2002-10-08 17:14 UTC (permalink / raw)
To: Adam Fedor; +Cc: gdb-patches
Adam Fedor wrote:
>
> This patch adds Objective-C language support to gdb based upon a patch
> provided by Apple Computer Inc from their version of gdb. Note that the
> patch only contains changes to existing files. New files (objc-lang.h,
> objc-lang.c, objc-exp.y) and a gdb.objc testsuite directory are located at
>
> ftp://ftp.gnustep.org/pub/gnustep/contrib/gdb-objc-patch.tar.gz
Adam, these changes have no effect on anyone who is not debugging
objective c. They can go in as soon as the appropriate enum values
definitions are in.
> * parse.c: (length_of_subexp, prefixify_subexp): Handle
> OP_MSGCALL, OP_SELECTOR, OP_NSSTRING, and OP_SELF.
> Index: gdb/parse.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/parse.c,v
> retrieving revision 1.25
> diff -u -p -r1.25 parse.c
> --- gdb/parse.c 21 Jun 2002 14:32:10 -0000 1.25
> +++ gdb/parse.c 17 Sep 2002 19:30:53 -0000
> @@ -867,6 +867,11 @@ length_of_subexp (register struct expres
> 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;
> @@ -898,6 +903,8 @@ length_of_subexp (register struct expres
> /* 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);
> @@ -936,6 +943,7 @@ length_of_subexp (register struct expres
>
> /* C++ */
> case OP_THIS:
> + case OP_SELF:
> oplen = 2;
> break;
>
> @@ -1004,6 +1012,11 @@ prefixify_subexp (register struct expres
> 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;
> @@ -1034,6 +1047,8 @@ prefixify_subexp (register struct expres
> /* 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);
> @@ -1072,6 +1087,7 @@ prefixify_subexp (register struct expres
>
> /* C++ */
> case OP_THIS:
> + case OP_SELF:
> oplen = 2;
> break;
>
^ permalink raw reply [flat|nested] 62+ messages in thread
* Re: [PATCH] Objective-C language support.
2002-09-18 8:24 [PATCH] Objective-C language support Adam Fedor
` (10 preceding siblings ...)
2002-10-08 17:14 ` Michael Snyder
@ 2002-10-08 17:16 ` Michael Snyder
2002-10-12 11:37 ` Adam Fedor
2002-10-08 17:19 ` Michael Snyder
` (2 subsequent siblings)
14 siblings, 1 reply; 62+ messages in thread
From: Michael Snyder @ 2002-10-08 17:16 UTC (permalink / raw)
To: Adam Fedor; +Cc: gdb-patches
Adam Fedor wrote:
>
> This patch adds Objective-C language support to gdb based upon a patch
> provided by Apple Computer Inc from their version of gdb. Note that the
> patch only contains changes to existing files. New files (objc-lang.h,
> objc-lang.c, objc-exp.y) and a gdb.objc testsuite directory are located at
>
> ftp://ftp.gnustep.org/pub/gnustep/contrib/gdb-objc-patch.tar.gz
>
Approved as obvious: please check it in after the defs.h change goes in.
> * language.c (binop_result_type): Add language_objc to case.
> (integral_type): Likewise.
> (character_type): Likewise.
> (string_type): Likewise.
> (boolean_type): Likewise.
> (structured_type): Likewise.
> (binop_type_check): Likewise.
> Index: gdb/language.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/language.c,v
> retrieving revision 1.26
> diff -u -p -r1.26 language.c
> --- gdb/language.c 1 Aug 2002 17:18:32 -0000 1.26
> +++ gdb/language.c 17 Sep 2002 19:30:31 -0000
> @@ -549,6 +549,7 @@ binop_result_type (struct value *v1, str
> {
> 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);
> @@ -786,6 +787,7 @@ integral_type (struct type *type)
> {
> 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:
> @@ -828,6 +830,7 @@ character_type (struct type *type)
>
> case language_c:
> case language_cplus:
> + case language_objc:
> return (TYPE_CODE (type) == TYPE_CODE_INT) &&
> TYPE_LENGTH (type) == sizeof (char)
> ? 1 : 0;
> @@ -850,6 +853,7 @@ string_type (struct type *type)
>
> case language_c:
> case language_cplus:
> + case language_objc:
> /* C does not have distinct string type. */
> return (0);
> default:
> @@ -868,6 +872,7 @@ boolean_type (struct type *type)
> {
> 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. */
> @@ -904,6 +909,7 @@ structured_type (struct type *type)
> {
> 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);
> @@ -1124,6 +1130,7 @@ binop_type_check (struct value *arg1, st
> #ifdef _LANG_c
> case language_c:
> case language_cplus:
> + case language_objc:
> switch (op)
> {
> case BINOP_DIV:
^ permalink raw reply [flat|nested] 62+ messages in thread
* Re: [PATCH] Objective-C language support.
2002-09-18 8:24 [PATCH] Objective-C language support Adam Fedor
` (11 preceding siblings ...)
2002-10-08 17:16 ` Michael Snyder
@ 2002-10-08 17:19 ` Michael Snyder
2002-10-14 19:33 ` Adam Fedor
2002-10-08 17:30 ` Michael Snyder
2002-10-08 17:34 ` Michael Snyder
14 siblings, 1 reply; 62+ messages in thread
From: Michael Snyder @ 2002-10-08 17:19 UTC (permalink / raw)
To: Adam Fedor; +Cc: gdb-patches
Adam Fedor wrote:
>
> This patch adds Objective-C language support to gdb based upon a patch
> provided by Apple Computer Inc from their version of gdb. Note that the
> patch only contains changes to existing files. New files (objc-lang.h,
> objc-lang.c, objc-exp.y) and a gdb.objc testsuite directory are located at
>
> ftp://ftp.gnustep.org/pub/gnustep/contrib/gdb-objc-patch.tar.gz
Adam, this is approved, but do you think you could make
the comment a little more informative? And Capitolize "Also"
and add a period.
> * breakpoint.c (parse_breakpoint_sals): Ignore ObjC method
> names when checking default.
>
> Index: gdb/breakpoint.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/breakpoint.c,v
> retrieving revision 1.86
> diff -u -p -r1.86 breakpoint.c
> --- gdb/breakpoint.c 5 Sep 2002 01:28:14 -0000 1.86
> +++ gdb/breakpoint.c 17 Sep 2002 19:29:52 -0000
> @@ -4618,9 +4618,11 @@ parse_breakpoint_sals (char **address,
> 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 */
> if (default_breakpoint_valid
> && (!current_source_symtab
> - || (strchr ("+-", (*address)[0]) != NULL)))
> + || ((strchr ("+-", (*address)[0]) != NULL)
> + && ((*address)[1] != '['))))
> *sals = decode_line_1 (address, 1, default_breakpoint_symtab,
> default_breakpoint_line, addr_string);
> else
^ permalink raw reply [flat|nested] 62+ messages in thread
* Re: [PATCH] Objective-C language support.
2002-09-18 8:24 [PATCH] Objective-C language support Adam Fedor
` (12 preceding siblings ...)
2002-10-08 17:19 ` Michael Snyder
@ 2002-10-08 17:30 ` Michael Snyder
2002-10-13 19:06 ` Adam Fedor
2002-10-21 15:35 ` Andrew Cagney
2002-10-08 17:34 ` Michael Snyder
14 siblings, 2 replies; 62+ messages in thread
From: Michael Snyder @ 2002-10-08 17:30 UTC (permalink / raw)
To: Adam Fedor; +Cc: gdb-patches
Adam Fedor wrote:
>
> This patch adds Objective-C language support to gdb based upon a patch
> provided by Apple Computer Inc from their version of gdb. Note that the
> patch only contains changes to existing files. New files (objc-lang.h,
> objc-lang.c, objc-exp.y) and a gdb.objc testsuite directory are located at
>
> ftp://ftp.gnustep.org/pub/gnustep/contrib/gdb-objc-patch.tar.gz
Adam, if no one objects in a few days, let's check in the following
subset of your valops.c changes. This is transparent to anyone who
isn't debugging objective c (and for those who are, it simply allows
the use of "self" in place of "this"). Note that some of the valops.c
changes are not included in this approval.
> * valops.c (value_of_local): New function.
> (value_of_this): Use it.
> Index: gdb/valops.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/valops.c,v
> retrieving revision 1.72
> diff -u -p -r1.72 valops.c
> --- gdb/valops.c 14 Sep 2002 02:09:39 -0000 1.72
> +++ gdb/valops.c 17 Sep 2002 19:31:14 -0000
> @@ -3231,18 +3245,17 @@ value_full_object (struct value *argp, s
>
>
>
> -/* C++: return the value of the class instance variable, if one exists.
> +/* 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_this (int complain)
> +value_of_local (const char *name, int complain)
> {
> struct symbol *func, *sym;
> struct block *b;
> int i;
> - static const char funny_this[] = "this";
> - struct value *this;
> + struct value * ret;
>
> if (selected_frame == 0)
> {
> @@ -3256,7 +3269,7 @@ value_of_this (int complain)
> if (!func)
> {
> if (complain)
> - error ("no `this' in nameless context");
> + error ("no %s in nameless context", name);
> else
> return 0;
> }
> @@ -3266,26 +3279,39 @@ value_of_this (int complain)
> if (i <= 0)
> {
> if (complain)
> - error ("no args, no `this'");
> + 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, funny_this, NULL, VAR_NAMESPACE);
> + sym = lookup_block_symbol (b, name, NULL, VAR_NAMESPACE);
> if (sym == NULL)
> {
> if (complain)
> - error ("current stack frame not in method");
> + error ("current stack frame does not contain a variable named \"%s\"", name);
> else
> return NULL;
> }
>
> - this = read_var_value (sym, selected_frame);
> - if (this == 0 && complain)
> - error ("`this' argument at unknown address");
> - return this;
> + 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
^ permalink raw reply [flat|nested] 62+ messages in thread
* Re: [PATCH] Objective-C language support.
2002-09-18 8:24 [PATCH] Objective-C language support Adam Fedor
` (13 preceding siblings ...)
2002-10-08 17:30 ` Michael Snyder
@ 2002-10-08 17:34 ` Michael Snyder
2002-10-13 19:12 ` Adam Fedor
14 siblings, 1 reply; 62+ messages in thread
From: Michael Snyder @ 2002-10-08 17:34 UTC (permalink / raw)
To: Adam Fedor; +Cc: gdb-patches
Adam Fedor wrote:
>
> This patch adds Objective-C language support to gdb based upon a patch
> provided by Apple Computer Inc from their version of gdb. Note that the
> patch only contains changes to existing files. New files (objc-lang.h,
> objc-lang.c, objc-exp.y) and a gdb.objc testsuite directory are located at
>
> ftp://ftp.gnustep.org/pub/gnustep/contrib/gdb-objc-patch.tar.gz
Adam,
Being just a comment, this change can go in immediately.
> * source.c (print_source_lines): Update comments.
> Index: gdb/source.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/source.c,v
> retrieving revision 1.29
> diff -u -p -r1.29 source.c
> --- gdb/source.c 11 Jun 2002 20:36:51 -0000 1.29
> +++ gdb/source.c 17 Sep 2002 19:30:56 -0000
> @@ -1114,8 +1114,9 @@ print_source_lines (struct symtab *s, in
>
> /* 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. */
> + `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)
^ permalink raw reply [flat|nested] 62+ messages in thread
* Re: [PATCH] Objective-C language support.
2002-10-08 16:36 ` Michael Snyder
@ 2002-10-11 19:29 ` Adam Fedor
0 siblings, 0 replies; 62+ messages in thread
From: Adam Fedor @ 2002-10-11 19:29 UTC (permalink / raw)
To: Michael Snyder; +Cc: gdb-patches
Michael Snyder wrote:
> Well, let's see if we can't get this going again.
> Adam, I'm going to give you approval for the following
> portion of this patch. If no one objects in the next
> few days, you can check it in.
>
>
>
>> * defs.h (enum language): Add language_objc.
Ok, I commited this.
--
Adam Fedor, Digital Optics Corp. | I'm glad I hate spinach, because
http://www.doc.com | if I didn't, I'd eat it, and you
| know how I hate the stuff.
^ permalink raw reply [flat|nested] 62+ messages in thread
* Re: [PATCH] Objective-C language support.
2002-10-08 16:45 ` Michael Snyder
@ 2002-10-11 19:39 ` Adam Fedor
0 siblings, 0 replies; 62+ messages in thread
From: Adam Fedor @ 2002-10-11 19:39 UTC (permalink / raw)
To: Michael Snyder; +Cc: gdb-patches
Michael Snyder wrote:
> Adam Fedor wrote:
>
>>This patch adds Objective-C language support to gdb based upon a patch
>>provided by Apple Computer Inc from their version of gdb. Note that the
>>patch only contains changes to existing files. New files (objc-lang.h,
>>objc-lang.c, objc-exp.y) and a gdb.objc testsuite directory are located at
>>
>>ftp://ftp.gnustep.org/pub/gnustep/contrib/gdb-objc-patch.tar.gz
>
>
> Adam, once the defs.h change is in, this can go in too (barring objections):
>
>
>
>> * language.h (CAST_IS_CONVERSION): Add language_objc.
Commited.
--
Adam Fedor, Digital Optics Corp. | I'm glad I hate spinach, because
http://www.doc.com | if I didn't, I'd eat it, and you
| know how I hate the stuff.
^ permalink raw reply [flat|nested] 62+ messages in thread
* Re: [PATCH] Objective-C language support.
2002-10-08 16:42 ` Michael Snyder
@ 2002-10-11 19:44 ` Adam Fedor
2002-10-21 15:18 ` Andrew Cagney
1 sibling, 0 replies; 62+ messages in thread
From: Adam Fedor @ 2002-10-11 19:44 UTC (permalink / raw)
To: Michael Snyder; +Cc: gdb-patches
Michael Snyder wrote:
> Adam, this bit can't hurt anything, since it just adds some new enum
> values. Only one suggestion -- how about putting OP_THIS and OP_SELF
> consecutively, because they're so similar? Also please hold off on
> the export of evaluate_subexp -- let's handle that separately.
>
> Other than that, approved. Wait a couple days for objections, then
> you can commit it.
>
>
>
>> * expression.h: New ops NSSTRING, SELECTOR, MSGCALL, and SELF.
Changed per your suggestion and commited. Thanks!
--
Adam Fedor, Digital Optics Corp. | I'm glad I hate spinach, because
http://www.doc.com | if I didn't, I'd eat it, and you
| know how I hate the stuff.
^ permalink raw reply [flat|nested] 62+ messages in thread
* Re: [PATCH] Objective-C language support.
2002-10-08 17:07 ` Michael Snyder
@ 2002-10-11 20:06 ` Adam Fedor
0 siblings, 0 replies; 62+ messages in thread
From: Adam Fedor @ 2002-10-11 20:06 UTC (permalink / raw)
To: Michael Snyder; +Cc: gdb-patches
Michael Snyder wrote:
> Adam, this is a pretty obvious change, please check it in as soon as
> the defs.h change goes in.
>
>
>> * printfcmd.c (address_info): Print 'self' for ObjC.
Commited.
--
Adam Fedor, Digital Optics Corp. | I'm glad I hate spinach, because
http://www.doc.com | if I didn't, I'd eat it, and you
| know how I hate the stuff.
^ permalink raw reply [flat|nested] 62+ messages in thread
* Re: [PATCH] Objective-C language support.
2002-10-08 17:16 ` Michael Snyder
@ 2002-10-12 11:37 ` Adam Fedor
0 siblings, 0 replies; 62+ messages in thread
From: Adam Fedor @ 2002-10-12 11:37 UTC (permalink / raw)
To: Michael Snyder; +Cc: gdb-patches
Michael Snyder wrote:
> Adam Fedor wrote:
>
>>This patch adds Objective-C language support to gdb based upon a patch
>>provided by Apple Computer Inc from their version of gdb. Note that the
>>patch only contains changes to existing files. New files (objc-lang.h,
>>objc-lang.c, objc-exp.y) and a gdb.objc testsuite directory are located at
>>
>>ftp://ftp.gnustep.org/pub/gnustep/contrib/gdb-objc-patch.tar.gz
>>
>
>
> Approved as obvious: please check it in after the defs.h change goes in.
>
>
>
>
>> * language.c (binop_result_type): Add language_objc to case.
>> (integral_type): Likewise.
>> (character_type): Likewise.
>> (string_type): Likewise.
>> (boolean_type): Likewise.
>> (structured_type): Likewise.
>> (binop_type_check): Likewise.
Commited.
--
Adam Fedor, Digital Optics Corp. | I'm glad I hate spinach, because
http://www.doc.com | if I didn't, I'd eat it, and you
| know how I hate the stuff.
^ permalink raw reply [flat|nested] 62+ messages in thread
* Re: [PATCH] Objective-C language support.
2002-10-08 17:14 ` Michael Snyder
@ 2002-10-13 18:51 ` Adam Fedor
0 siblings, 0 replies; 62+ messages in thread
From: Adam Fedor @ 2002-10-13 18:51 UTC (permalink / raw)
To: Michael Snyder; +Cc: gdb-patches
Michael Snyder wrote:
> Adam Fedor wrote:
> Adam, these changes have no effect on anyone who is not debugging
> objective c. They can go in as soon as the appropriate enum values
> definitions are in.
>
>
>
>> * parse.c: (length_of_subexp, prefixify_subexp): Handle
>> OP_MSGCALL, OP_SELECTOR, OP_NSSTRING, and OP_SELF.
Commited.
--
Adam Fedor, Digital Optics Corp. | I'm glad I hate spinach, because
http://www.doc.com | if I didn't, I'd eat it, and you
| know how I hate the stuff.
^ permalink raw reply [flat|nested] 62+ messages in thread
* Re: [PATCH] Objective-C language support.
2002-10-08 17:30 ` Michael Snyder
@ 2002-10-13 19:06 ` Adam Fedor
2002-10-21 15:35 ` Andrew Cagney
1 sibling, 0 replies; 62+ messages in thread
From: Adam Fedor @ 2002-10-13 19:06 UTC (permalink / raw)
To: Michael Snyder; +Cc: gdb-patches
Michael Snyder wrote:
> Adam Fedor wrote:
>
>>This patch adds Objective-C language support to gdb based upon a patch
>>provided by Apple Computer Inc from their version of gdb. Note that the
>>patch only contains changes to existing files. New files (objc-lang.h,
>>objc-lang.c, objc-exp.y) and a gdb.objc testsuite directory are located at
>>
>>ftp://ftp.gnustep.org/pub/gnustep/contrib/gdb-objc-patch.tar.gz
>
>
> Adam, if no one objects in a few days, let's check in the following
> subset of your valops.c changes. This is transparent to anyone who
> isn't debugging objective c (and for those who are, it simply allows
> the use of "self" in place of "this"). Note that some of the valops.c
> changes are not included in this approval.
>
>
>
>> * valops.c (value_of_local): New function.
>> (value_of_this): Use it.
>
Commited (plus declaration of value_of_local in value.h).
--
Adam Fedor, Digital Optics Corp. | I'm glad I hate spinach, because
http://www.doc.com | if I didn't, I'd eat it, and you
| know how I hate the stuff.
^ permalink raw reply [flat|nested] 62+ messages in thread
* Re: [PATCH] Objective-C language support.
2002-10-08 17:34 ` Michael Snyder
@ 2002-10-13 19:12 ` Adam Fedor
0 siblings, 0 replies; 62+ messages in thread
From: Adam Fedor @ 2002-10-13 19:12 UTC (permalink / raw)
To: Michael Snyder; +Cc: gdb-patches
Michael Snyder wrote:
> Adam Fedor wrote:
>
> Being just a comment, this change can go in immediately.
>
>
>> * source.c (print_source_lines): Update comments.
>
Done.
--
Adam Fedor, Digital Optics Corp. | I'm glad I hate spinach, because
http://www.doc.com | if I didn't, I'd eat it, and you
| know how I hate the stuff.
^ permalink raw reply [flat|nested] 62+ messages in thread
* Re: [PATCH] Objective-C language support.
2002-10-08 16:51 ` Michael Snyder
@ 2002-10-14 13:06 ` Jim Blandy
2002-10-21 15:28 ` Andrew Cagney
0 siblings, 1 reply; 62+ messages in thread
From: Jim Blandy @ 2002-10-14 13:06 UTC (permalink / raw)
To: Michael Snyder; +Cc: Adam Fedor, gdb-patches
This change is approved. (Thanks for the reminder, Michael.)
Michael Snyder <msnyder@redhat.com> writes:
> Adam Fedor wrote:
> >
> > This patch adds Objective-C language support to gdb based upon a patch
> > provided by Apple Computer Inc from their version of gdb. Note that the
> > patch only contains changes to existing files. New files (objc-lang.h,
> > objc-lang.c, objc-exp.y) and a gdb.objc testsuite directory are located at
> >
> > ftp://ftp.gnustep.org/pub/gnustep/contrib/gdb-objc-patch.tar.gz
>
> This change is (remotely) related to symbol tables, which belong to
> Jim Blandy and Elena Zannoni. Jim, do you have any objection to this
> change? I think it's almost obvious, and recommend it for approval.
>
>
> > * symtab.h: New objc_specific struct.
> > (SYMBOL_INIT_LANGUAGE_SPECIFIC): Handle ObjC.
> > (SYMBOL_DEMANGLED_NAME): Likewise.
>
> > Index: gdb/symtab.h
> > ===================================================================
> > RCS file: /cvs/src/src/gdb/symtab.h,v
> > retrieving revision 1.39
> > diff -u -p -r1.39 symtab.h
> > --- gdb/symtab.h 12 Sep 2002 19:19:37 -0000 1.39
> > +++ gdb/symtab.h 17 Sep 2002 19:31:07 -0000
> > @@ -89,6 +89,11 @@ struct general_symbol_info
> > char *demangled_name;
> > }
> > cplus_specific;
> > + struct objc_specific
> > + {
> > + char *demangled_name;
> > + }
> > + objc_specific;
> > #if 0
> > /* OBSOLETE struct chill_specific *//* For Chill */
> > /* OBSOLETE { */
> > @@ -146,6 +151,10 @@ extern CORE_ADDR symbol_overlayed_addres
> > { \
> > 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; */ \
> > @@ -170,12 +179,17 @@ extern void symbol_init_demangled_name (
> > (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)
> > + 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
^ permalink raw reply [flat|nested] 62+ messages in thread
* Re: [PATCH] Objective-C language support.
2002-10-08 17:01 ` Michael Snyder
@ 2002-10-14 13:08 ` Jim Blandy
2002-10-18 10:06 ` Adam Fedor
0 siblings, 1 reply; 62+ messages in thread
From: Jim Blandy @ 2002-10-14 13:08 UTC (permalink / raw)
To: Adam Fedor; +Cc: Michael Snyder, gdb-patches
Can we have a more extensive comment here? What are symbols that
begin with ".objc_"? Why should we ignore them? Where can we find
more complete documentation for what they mean? (Is there any
document that describes how Objective C programs are represented at
the assembly/linkage level?)
Michael Snyder <msnyder@redhat.com> writes:
> Adam Fedor wrote:
> >
> > This patch adds Objective-C language support to gdb based upon a patch
> > provided by Apple Computer Inc from their version of gdb. Note that the
> > patch only contains changes to existing files. New files (objc-lang.h,
> > objc-lang.c, objc-exp.y) and a gdb.objc testsuite directory are located at
> >
> > ftp://ftp.gnustep.org/pub/gnustep/contrib/gdb-objc-patch.tar.gz
> >
>
> Jim, could you take a quick look at this small change?
> [Adam, the comment needs a period followed by two spaces.]
>
>
> > * elfread.c (elf_symtab_read): Skip ObjC symbols.
>
> > Index: gdb/elfread.c
> > ===================================================================
> > RCS file: /cvs/src/src/gdb/elfread.c,v
> > retrieving revision 1.23
> > diff -u -p -r1.23 elfread.c
> > --- gdb/elfread.c 24 Jul 2002 23:51:35 -0000 1.23
> > +++ gdb/elfread.c 17 Sep 2002 19:29:59 -0000
> > @@ -349,7 +349,12 @@ elf_symtab_read (struct objfile *objfile
> > }
> > else if (sym->section->flags & SEC_CODE)
> > {
> > - if (sym->flags & BSF_GLOBAL)
> > + 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;
> > }
^ permalink raw reply [flat|nested] 62+ messages in thread
* Re: [PATCH] Objective-C language support.
2002-10-08 17:05 ` Michael Snyder
@ 2002-10-14 13:14 ` Jim Blandy
2002-10-14 20:09 ` Adam Fedor
0 siblings, 1 reply; 62+ messages in thread
From: Jim Blandy @ 2002-10-14 13:14 UTC (permalink / raw)
To: Adam Fedor; +Cc: Michael Snyder, gdb-patches
The function stabsread_objc_colon should be static to stabsread.c, no?
If that's so, then it should be renamed to something like
`find_name_end', with a comment above the strchr ('[') != 0 case
explaining its relevance to Objective-C. Since this function gets
called on every symbol, it's not an Objective-C specific function;
only part of it is.
The code needs a comment. Most of GDB's maintainers don't know
Objective-C, so it would be helpful just to say something like,
"Objective-C symbols can have names like -[foo:bar:baz]:skun
Michael Snyder <msnyder@redhat.com> writes:
> Adam Fedor wrote:
> >
> > This patch adds Objective-C language support to gdb based upon a patch
> > provided by Apple Computer Inc from their version of gdb. Note that the
> > patch only contains changes to existing files. New files (objc-lang.h,
> > objc-lang.c, objc-exp.y) and a gdb.objc testsuite directory are located at
> >
> > ftp://ftp.gnustep.org/pub/gnustep/contrib/gdb-objc-patch.tar.gz
>
> Jim, can you look at this one too? I can explain it for you --
> objective c symbols sometimes contain colons, which will trip up
> the stabs reader unles they're detected and allowed for.
>
> Adam, I think the function is not used outside of stabsread.c, so
> how about making it static, droping the "stabsread_" from its name,
> and omitting the declaration from stabsread.h?
>
>
> > * stabsread.c (stabsread_objc_colon): New function.
> > (define_symbol): Use it.
> > * stabsread.h: Declare it.
>
> > Index: gdb/stabsread.c
> > ===================================================================
> > RCS file: /cvs/src/src/gdb/stabsread.c,v
> > retrieving revision 1.39
> > diff -u -p -r1.39 stabsread.c
> > --- gdb/stabsread.c 14 Sep 2002 02:09:39 -0000 1.39
> > +++ gdb/stabsread.c 17 Sep 2002 19:31:03 -0000
> > @@ -1273,7 +1273,7 @@ define_symbol (CORE_ADDR valu, char *str
> > struct objfile *objfile)
> > {
> > register struct symbol *sym;
> > - char *p = (char *) strchr (string, ':');
> > + char *p = (char *) stabsread_objc_colon (string);
> > int deftype;
> > int synonym = 0;
> > register int i;
> > @@ -2006,7 +2006,8 @@ define_symbol (CORE_ADDR valu, char *str
> > 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)
> > + else if ((current_subfile->language == language_cplus)
> > + || (current_subfile->language == language_objc))
> > synonym = 1;
> >
> > SYMBOL_TYPE (sym) = read_type (&p, objfile);
> > @@ -5615,6 +5616,30 @@ finish_global_stabs (struct objfile *obj
> > patch_block_stabs (global_symbols, global_stabs, objfile);
> > xfree (global_stabs);
> > global_stabs = NULL;
> > + }
> > +}
> > +
> > +char *
> > +stabsread_objc_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, ':');
> > }
> > }
> >
> > Index: gdb/stabsread.h
> > ===================================================================
> > RCS file: /cvs/src/src/gdb/stabsread.h,v
> > retrieving revision 1.8
> > diff -u -p -r1.8 stabsread.h
> > --- gdb/stabsread.h 18 Jul 2002 17:22:50 -0000 1.8
> > +++ gdb/stabsread.h 17 Sep 2002 19:31:04 -0000
> > @@ -219,6 +219,8 @@ extern struct symbol *ref_search (int);
> > extern int resolve_cfront_continuation
> > (struct objfile *objfile, struct symbol *sym, char *p);
> >
> > +extern char *stabsread_objc_colon (char *name);
> > +
> > extern void free_header_files (void);
> >
> > extern void init_header_files (void);
^ permalink raw reply [flat|nested] 62+ messages in thread
* Re: [PATCH] Objective-C language support.
2002-10-08 16:58 ` Michael Snyder
@ 2002-10-14 19:18 ` Adam Fedor
2002-10-21 15:31 ` Andrew Cagney
1 sibling, 0 replies; 62+ messages in thread
From: Adam Fedor @ 2002-10-14 19:18 UTC (permalink / raw)
To: Michael Snyder; +Cc: gdb-patches
Michael Snyder wrote:
>
>
> I can approve this, but you'll have to comment out the bit that
> calls objc_demangle for now, until the entire patch is ready to
> go on line. Otherwise it'll come up undefined.
>
>
>
>> * utils.c (puts_filtered_tabular): New function.
>> (fprintf_symbol_filtered): Get ObjC demangled name.
OK I did this and also added the declaration of puts_filtered_tabular to
defs.h.
--
Adam Fedor, Digital Optics Corp. | I'm glad I hate spinach, because
http://www.doc.com | if I didn't, I'd eat it, and you
| know how I hate the stuff.
^ permalink raw reply [flat|nested] 62+ messages in thread
* Re: [PATCH] Objective-C language support.
2002-10-08 17:19 ` Michael Snyder
@ 2002-10-14 19:33 ` Adam Fedor
2002-10-16 12:16 ` Michael Snyder
0 siblings, 1 reply; 62+ messages in thread
From: Adam Fedor @ 2002-10-14 19:33 UTC (permalink / raw)
To: Michael Snyder; +Cc: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 689 bytes --]
Michael Snyder wrote:
> Adam, this is approved, but do you think you could make
> the comment a little more informative? And Capitolize "Also"
> and add a period.
>
>
>
>> * breakpoint.c (parse_breakpoint_sals): Ignore ObjC method
>> names when checking default.
This is my minor improvement. Ok?
2002-10-14 Adam Fedor <fedor@gnu.org>
* breakpoint.c (parse_breakpoint_sals): Ignore ObjC method
names when matching breakpoints in current file.
--
Adam Fedor, Digital Optics Corp. | I'm glad I hate spinach, because
http://www.doc.com | if I didn't, I'd eat it, and you
| know how I hate the stuff.
[-- Attachment #2: objc4.patch --]
[-- Type: text/plain, Size: 1184 bytes --]
Index: breakpoint.c
===================================================================
RCS file: /cvs/src/src/gdb/breakpoint.c,v
retrieving revision 1.90
diff -u -p -r1.90 breakpoint.c
--- breakpoint.c 22 Sep 2002 20:29:52 -0000 1.90
+++ breakpoint.c 15 Oct 2002 02:31:48 -0000
@@ -4618,13 +4618,16 @@ parse_breakpoint_sals (char **address,
/* Force almost all breakpoints to be in terms of the
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. */
+ leaving default_breakpoint_* alone.
+ ObjC: However, don't match an Objective-C method name which
+ may have a '+' or '-' succeeded by a '[' */
struct symtab_and_line cursal = get_current_source_symtab_and_line ();
if (default_breakpoint_valid
&& (!cursal.symtab
- || (strchr ("+-", (*address)[0]) != NULL)))
+ || ((strchr ("+-", (*address)[0]) != NULL)
+ && ((*address)[1] != '['))))
*sals = decode_line_1 (address, 1, default_breakpoint_symtab,
default_breakpoint_line, addr_string);
else
^ permalink raw reply [flat|nested] 62+ messages in thread
* Re: [PATCH] Objective-C language support.
2002-10-14 13:14 ` Jim Blandy
@ 2002-10-14 20:09 ` Adam Fedor
2002-10-18 14:24 ` Elena Zannoni
` (2 more replies)
0 siblings, 3 replies; 62+ messages in thread
From: Adam Fedor @ 2002-10-14 20:09 UTC (permalink / raw)
To: Jim Blandy; +Cc: Michael Snyder, gdb-patches
[-- Attachment #1: Type: text/plain, Size: 928 bytes --]
Jim Blandy wrote:
> The function stabsread_objc_colon should be static to stabsread.c, no?
> If that's so, then it should be renamed to something like
> `find_name_end', with a comment above the strchr ('[') != 0 case
> explaining its relevance to Objective-C. Since this function gets
> called on every symbol, it's not an Objective-C specific function;
> only part of it is.
>
> The code needs a comment. Most of GDB's maintainers don't know
> Objective-C, so it would be helpful just to say something like,
> "Objective-C symbols can have names like -[foo:bar:baz]:skun
Updated patch:
2002-10-14 Adam Fedor <fedor@gnu.org>
* stabsread.c (find_name_end): New function.
(define_symbol): Use it.
--
Adam Fedor, Digital Optics Corp. | I'm glad I hate spinach, because
http://www.doc.com | if I didn't, I'd eat it, and you
| know how I hate the stuff.
[-- Attachment #2: objc5.patch --]
[-- Type: text/plain, Size: 2092 bytes --]
Index: stabsread.c
===================================================================
RCS file: /cvs/src/src/gdb/stabsread.c,v
retrieving revision 1.42
diff -u -p -r1.42 stabsread.c
--- stabsread.c 11 Oct 2002 14:02:38 -0000 1.42
+++ stabsread.c 15 Oct 2002 03:06:03 -0000
@@ -169,6 +169,8 @@ static int
read_cfront_member_functions (struct field_info *, char **,
struct type *, struct objfile *);
+static char *find_name_end (char *name);
+
/* end new functions added for cfront support */
static void
@@ -1271,7 +1273,7 @@ define_symbol (CORE_ADDR valu, char *str
struct objfile *objfile)
{
register struct symbol *sym;
- char *p = (char *) strchr (string, ':');
+ char *p = (char *) find_name_end (string);
int deftype;
int synonym = 0;
register int i;
@@ -2004,7 +2006,8 @@ define_symbol (CORE_ADDR valu, char *str
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)
+ else if ((current_subfile->language == language_cplus)
+ || (current_subfile->language == language_objc))
synonym = 1;
SYMBOL_TYPE (sym) = read_type (&p, objfile);
@@ -5613,6 +5616,32 @@ finish_global_stabs (struct objfile *obj
patch_block_stabs (global_symbols, global_stabs, objfile);
xfree (global_stabs);
global_stabs = NULL;
+ }
+}
+
+static char *
+find_name_end (char *name)
+{
+ char *s = name;
+ /* Find the end of the name, deliminated by a ':', but don't match
+ ObjC symbols which look like -[Foo bar::]:bla. */
+ if (s[0] == '-' || *s == '+')
+ {
+ /* Must be an ObjC method symbol. */
+ 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, ':');
}
}
^ permalink raw reply [flat|nested] 62+ messages in thread
* Re: [PATCH] Objective-C language support.
2002-10-14 19:33 ` Adam Fedor
@ 2002-10-16 12:16 ` Michael Snyder
0 siblings, 0 replies; 62+ messages in thread
From: Michael Snyder @ 2002-10-16 12:16 UTC (permalink / raw)
To: Adam Fedor; +Cc: gdb-patches
Adam Fedor wrote:
>
> Michael Snyder wrote:
> > Adam, this is approved, but do you think you could make
> > the comment a little more informative? And Capitolize "Also"
> > and add a period.
> >
> >
> >
> >> * breakpoint.c (parse_breakpoint_sals): Ignore ObjC method
> >> names when checking default.
>
> This is my minor improvement. Ok?
Yes, approved.
>
> 2002-10-14 Adam Fedor <fedor@gnu.org>
>
> * breakpoint.c (parse_breakpoint_sals): Ignore ObjC method
> names when matching breakpoints in current file.
>
> --
> Adam Fedor, Digital Optics Corp. | I'm glad I hate spinach, because
> http://www.doc.com | if I didn't, I'd eat it, and you
> | know how I hate the stuff.
>
> -------------------------------------------------------------------------------
> Index: breakpoint.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/breakpoint.c,v
> retrieving revision 1.90
> diff -u -p -r1.90 breakpoint.c
> --- breakpoint.c 22 Sep 2002 20:29:52 -0000 1.90
> +++ breakpoint.c 15 Oct 2002 02:31:48 -0000
> @@ -4618,13 +4618,16 @@ parse_breakpoint_sals (char **address,
> /* Force almost all breakpoints to be in terms of the
> 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. */
> + leaving default_breakpoint_* alone.
> + ObjC: However, don't match an Objective-C method name which
> + may have a '+' or '-' succeeded by a '[' */
>
> struct symtab_and_line cursal = get_current_source_symtab_and_line ();
>
> if (default_breakpoint_valid
> && (!cursal.symtab
> - || (strchr ("+-", (*address)[0]) != NULL)))
> + || ((strchr ("+-", (*address)[0]) != NULL)
> + && ((*address)[1] != '['))))
> *sals = decode_line_1 (address, 1, default_breakpoint_symtab,
> default_breakpoint_line, addr_string);
> else
^ permalink raw reply [flat|nested] 62+ messages in thread
* Re: [PATCH] Objective-C language support.
2002-10-14 13:08 ` Jim Blandy
@ 2002-10-18 10:06 ` Adam Fedor
0 siblings, 0 replies; 62+ messages in thread
From: Adam Fedor @ 2002-10-18 10:06 UTC (permalink / raw)
To: Jim Blandy; +Cc: Michael Snyder, gdb-patches
Nobody I know can figure out what this does, so for now I'll just drop
it and see if something goes wrong...
Jim Blandy wrote:
> Can we have a more extensive comment here? What are symbols that
> begin with ".objc_"? Why should we ignore them? Where can we find
> more complete documentation for what they mean? (Is there any
> document that describes how Objective C programs are represented at
> the assembly/linkage level?)
>
> Michael Snyder <msnyder@redhat.com> writes:
>
>
>>Adam Fedor wrote:
>>
>>>This patch adds Objective-C language support to gdb based upon a patch
>>>provided by Apple Computer Inc from their version of gdb. Note that the
>>>patch only contains changes to existing files. New files (objc-lang.h,
>>>objc-lang.c, objc-exp.y) and a gdb.objc testsuite directory are located at
>>>
>>>ftp://ftp.gnustep.org/pub/gnustep/contrib/gdb-objc-patch.tar.gz
>>>
>>
>>Jim, could you take a quick look at this small change?
>>[Adam, the comment needs a period followed by two spaces.]
>>
>>
>>
>>> * elfread.c (elf_symtab_read): Skip ObjC symbols.
>>
>>>Index: gdb/elfread.c
>>>===================================================================
>>>RCS file: /cvs/src/src/gdb/elfread.c,v
>>>retrieving revision 1.23
>>>diff -u -p -r1.23 elfread.c
>>>--- gdb/elfread.c 24 Jul 2002 23:51:35 -0000 1.23
>>>+++ gdb/elfread.c 17 Sep 2002 19:29:59 -0000
>>>@@ -349,7 +349,12 @@ elf_symtab_read (struct objfile *objfile
>>> }
>>> else if (sym->section->flags & SEC_CODE)
>>> {
>>>- if (sym->flags & BSF_GLOBAL)
>>>+ 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;
>>> }
>>
--
Adam Fedor, Digital Optics Corp. | I'm glad I hate spinach, because
http://www.doc.com | if I didn't, I'd eat it, and you
| know how I hate the stuff.
^ permalink raw reply [flat|nested] 62+ messages in thread
* Re: [PATCH] Objective-C language support.
2002-10-14 20:09 ` Adam Fedor
@ 2002-10-18 14:24 ` Elena Zannoni
2002-10-22 5:49 ` Jim Blandy
2002-10-21 15:25 ` Andrew Cagney
2002-11-07 23:44 ` Jim Blandy
2 siblings, 1 reply; 62+ messages in thread
From: Elena Zannoni @ 2002-10-18 14:24 UTC (permalink / raw)
To: Adam Fedor; +Cc: Jim Blandy, Michael Snyder, gdb-patches
Adam Fedor writes:
> Jim Blandy wrote:
> > The function stabsread_objc_colon should be static to stabsread.c, no?
> > If that's so, then it should be renamed to something like
> > `find_name_end', with a comment above the strchr ('[') != 0 case
> > explaining its relevance to Objective-C. Since this function gets
> > called on every symbol, it's not an Objective-C specific function;
> > only part of it is.
> >
> > The code needs a comment. Most of GDB's maintainers don't know
> > Objective-C, so it would be helpful just to say something like,
> > "Objective-C symbols can have names like -[foo:bar:baz]:skun
>
> Updated patch:
>
> 2002-10-14 Adam Fedor <fedor@gnu.org>
>
> * stabsread.c (find_name_end): New function.
> (define_symbol): Use it.
>
>
>
>
> --
> Adam Fedor, Digital Optics Corp. | I'm glad I hate spinach, because
> http://www.doc.com | if I didn't, I'd eat it, and you
> | know how I hate the stuff.
> Index: stabsread.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/stabsread.c,v
> retrieving revision 1.42
> diff -u -p -r1.42 stabsread.c
> --- stabsread.c 11 Oct 2002 14:02:38 -0000 1.42
> +++ stabsread.c 15 Oct 2002 03:06:03 -0000
> @@ -169,6 +169,8 @@ static int
> read_cfront_member_functions (struct field_info *, char **,
> struct type *, struct objfile *);
>
> +static char *find_name_end (char *name);
> +
> /* end new functions added for cfront support */
>
> static void
> @@ -1271,7 +1273,7 @@ define_symbol (CORE_ADDR valu, char *str
> struct objfile *objfile)
> {
> register struct symbol *sym;
> - char *p = (char *) strchr (string, ':');
> + char *p = (char *) find_name_end (string);
> int deftype;
> int synonym = 0;
> register int i;
> @@ -2004,7 +2006,8 @@ define_symbol (CORE_ADDR valu, char *str
> 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)
> + else if ((current_subfile->language == language_cplus)
> + || (current_subfile->language == language_objc))
> synonym = 1;
>
> SYMBOL_TYPE (sym) = read_type (&p, objfile);
> @@ -5613,6 +5616,32 @@ finish_global_stabs (struct objfile *obj
> patch_block_stabs (global_symbols, global_stabs, objfile);
> xfree (global_stabs);
> global_stabs = NULL;
> + }
> +}
> +
> +static char *
> +find_name_end (char *name)
> +{
> + char *s = name;
> + /* Find the end of the name, deliminated by a ':', but don't match
> + ObjC symbols which look like -[Foo bar::]:bla. */
Should be "delimited" above, also, could you move the comment to before
the function?
Hoping Jim doesn't mind... it can go in after these minor changes.
thanks
Elena
> + if (s[0] == '-' || *s == '+')
> + {
> + /* Must be an ObjC method symbol. */
> + 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, ':');
> }
> }
>
^ permalink raw reply [flat|nested] 62+ messages in thread
* Re: [PATCH] Objective-C language support.
2002-10-08 16:42 ` Michael Snyder
2002-10-11 19:44 ` Adam Fedor
@ 2002-10-21 15:18 ` Andrew Cagney
2002-10-21 15:27 ` Michael Snyder
1 sibling, 1 reply; 62+ messages in thread
From: Andrew Cagney @ 2002-10-21 15:18 UTC (permalink / raw)
To: Michael Snyder, Adam Fedor; +Cc: gdb-patches
> Adam Fedor wrote:
>
>>
>> This patch adds Objective-C language support to gdb based upon a patch
>> provided by Apple Computer Inc from their version of gdb. Note that the
>> patch only contains changes to existing files. New files (objc-lang.h,
>> objc-lang.c, objc-exp.y) and a gdb.objc testsuite directory are located at
>>
>> ftp://ftp.gnustep.org/pub/gnustep/contrib/gdb-objc-patch.tar.gz
>
>
> Adam, this bit can't hurt anything, since it just adds some new enum
> values. Only one suggestion -- how about putting OP_THIS and OP_SELF
> consecutively, because they're so similar? Also please hold off on
> the export of evaluate_subexp -- let's handle that separately.
>
> Other than that, approved. Wait a couple days for objections, then
> you can commit it.
>
>
>
>> * expression.h: New ops NSSTRING, SELECTOR, MSGCALL, and SELF.
>
>
>> Index: gdb/expression.h
>> ===================================================================
>> RCS file: /cvs/src/src/gdb/expression.h,v
>> retrieving revision 1.4
>> diff -u -p -r1.4 expression.h
>> --- gdb/expression.h 1 Aug 2002 17:18:32 -0000 1.4
>> +++ gdb/expression.h 17 Sep 2002 19:30:05 -0000
>> @@ -181,6 +181,12 @@ enum exp_opcode
>> 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,
>> +
FYI, I think these should be renamed to OP_OBJC_xxxx so that it is very
clear that these have Objective C semantics. Otherwize I think it runs
the risk of people trying to re-use these operators in other languages.
This would be consistent with the Ada OPS where I recommended
OP_ADA_xxxx for the Ada specific extensions to the operator table.
Andrew
>> /* 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
>> @@ -273,11 +279,17 @@ enum exp_opcode
>> STRUCTOP_STRUCT,
>> STRUCTOP_PTR,
>>
>> - /* C++ */
>> - /* OP_THIS is just a placeholder for the class instance variable.
>> + /* 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. */
>> @@ -305,7 +317,10 @@ enum exp_opcode
>> OP_NAME,
>>
>> /* An unparsed expression. Used for Scheme (for now at least) */
>> - OP_EXPRSTRING
>> + OP_EXPRSTRING,
>> +
>> + /* An Objective C Foundation Class NSString constant */
>> + OP_NSSTRING,
>> };
>>
>> union exp_element
>> @@ -369,6 +384,10 @@ enum noside
>>
>> extern struct value *evaluate_subexp_standard
>> (struct type *, struct expression *, int *, enum noside);
>> +
>> +extern struct value *evaluate_subexp (struct type *, struct expression *,
>> + int *, enum noside);
>> +
>>
>> /* From expprint.c */
>>
>
>
^ permalink raw reply [flat|nested] 62+ messages in thread
* Re: [PATCH] Objective-C language support.
2002-10-14 20:09 ` Adam Fedor
2002-10-18 14:24 ` Elena Zannoni
@ 2002-10-21 15:25 ` Andrew Cagney
2002-11-07 23:44 ` Jim Blandy
2 siblings, 0 replies; 62+ messages in thread
From: Andrew Cagney @ 2002-10-21 15:25 UTC (permalink / raw)
To: Adam Fedor, Michael Snyder; +Cc: gdb-patches
Just a reminder,
It is very often a good idea, for cases like this, to post each new
patch as a new thread. That way, the new patch that needs review is
very easy to spot. This is also why people so often plead that patches
be broken down into smaller more digestable chunks.
Andrew
^ permalink raw reply [flat|nested] 62+ messages in thread
* Re: [PATCH] Objective-C language support.
2002-10-21 15:18 ` Andrew Cagney
@ 2002-10-21 15:27 ` Michael Snyder
0 siblings, 0 replies; 62+ messages in thread
From: Michael Snyder @ 2002-10-21 15:27 UTC (permalink / raw)
To: Andrew Cagney; +Cc: Adam Fedor, gdb-patches
Andrew Cagney wrote:
>
> > Adam Fedor wrote:
> >
> >>
> >> This patch adds Objective-C language support to gdb based upon a patch
> >> provided by Apple Computer Inc from their version of gdb. Note that the
> >> patch only contains changes to existing files. New files (objc-lang.h,
> >> objc-lang.c, objc-exp.y) and a gdb.objc testsuite directory are located at
> >>
> >> ftp://ftp.gnustep.org/pub/gnustep/contrib/gdb-objc-patch.tar.gz
> >
> >
> > Adam, this bit can't hurt anything, since it just adds some new enum
> > values. Only one suggestion -- how about putting OP_THIS and OP_SELF
> > consecutively, because they're so similar? Also please hold off on
> > the export of evaluate_subexp -- let's handle that separately.
> >
> > Other than that, approved. Wait a couple days for objections, then
> > you can commit it.
> >
> >
> >
> >> * expression.h: New ops NSSTRING, SELECTOR, MSGCALL, and SELF.
> >
> >
> >> Index: gdb/expression.h
> >> ===================================================================
> >> RCS file: /cvs/src/src/gdb/expression.h,v
> >> retrieving revision 1.4
> >> diff -u -p -r1.4 expression.h
> >> --- gdb/expression.h 1 Aug 2002 17:18:32 -0000 1.4
> >> +++ gdb/expression.h 17 Sep 2002 19:30:05 -0000
> >> @@ -181,6 +181,12 @@ enum exp_opcode
> >> 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,
> >> +
>
> FYI, I think these should be renamed to OP_OBJC_xxxx so that it is very
> clear that these have Objective C semantics. Otherwize I think it runs
> the risk of people trying to re-use these operators in other languages.
>
> This would be consistent with the Ada OPS where I recommended
> OP_ADA_xxxx for the Ada specific extensions to the operator table.
>
> Andrew
OK with me.
> >> /* 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
> >> @@ -273,11 +279,17 @@ enum exp_opcode
> >> STRUCTOP_STRUCT,
> >> STRUCTOP_PTR,
> >>
> >> - /* C++ */
> >> - /* OP_THIS is just a placeholder for the class instance variable.
> >> + /* 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. */
> >> @@ -305,7 +317,10 @@ enum exp_opcode
> >> OP_NAME,
> >>
> >> /* An unparsed expression. Used for Scheme (for now at least) */
> >> - OP_EXPRSTRING
> >> + OP_EXPRSTRING,
> >> +
> >> + /* An Objective C Foundation Class NSString constant */
> >> + OP_NSSTRING,
> >> };
> >>
> >> union exp_element
> >> @@ -369,6 +384,10 @@ enum noside
> >>
> >> extern struct value *evaluate_subexp_standard
> >> (struct type *, struct expression *, int *, enum noside);
> >> +
> >> +extern struct value *evaluate_subexp (struct type *, struct expression *,
> >> + int *, enum noside);
> >> +
> >>
> >> /* From expprint.c */
> >>
> >
> >
^ permalink raw reply [flat|nested] 62+ messages in thread
* Re: [PATCH] Objective-C language support.
2002-10-14 13:06 ` Jim Blandy
@ 2002-10-21 15:28 ` Andrew Cagney
2002-10-22 17:04 ` Michael Snyder
0 siblings, 1 reply; 62+ messages in thread
From: Andrew Cagney @ 2002-10-21 15:28 UTC (permalink / raw)
To: Jim Blandy; +Cc: Michael Snyder, Adam Fedor, gdb-patches
> This change is approved. (Thanks for the reminder, Michael.)
>
> Michael Snyder <msnyder@redhat.com> writes:
I think, here, that garish macro needs to be re-written as a function.
Any symtab maintainer care to do it?
Andrew
>> Adam Fedor wrote:
>
>> >
>> > This patch adds Objective-C language support to gdb based upon a patch
>> > provided by Apple Computer Inc from their version of gdb. Note that the
>> > patch only contains changes to existing files. New files (objc-lang.h,
>> > objc-lang.c, objc-exp.y) and a gdb.objc testsuite directory are located at
>> >
>> > ftp://ftp.gnustep.org/pub/gnustep/contrib/gdb-objc-patch.tar.gz
>
>>
>> This change is (remotely) related to symbol tables, which belong to
>> Jim Blandy and Elena Zannoni. Jim, do you have any objection to this
>> change? I think it's almost obvious, and recommend it for approval.
>>
>>
>
>> > * symtab.h: New objc_specific struct.
>> > (SYMBOL_INIT_LANGUAGE_SPECIFIC): Handle ObjC.
>> > (SYMBOL_DEMANGLED_NAME): Likewise.
>
>>
>
>> > Index: gdb/symtab.h
>> > ===================================================================
>> > RCS file: /cvs/src/src/gdb/symtab.h,v
>> > retrieving revision 1.39
>> > diff -u -p -r1.39 symtab.h
>> > --- gdb/symtab.h 12 Sep 2002 19:19:37 -0000 1.39
>> > +++ gdb/symtab.h 17 Sep 2002 19:31:07 -0000
>> > @@ -89,6 +89,11 @@ struct general_symbol_info
>> > char *demangled_name;
>> > }
>> > cplus_specific;
>> > + struct objc_specific
>> > + {
>> > + char *demangled_name;
>> > + }
>> > + objc_specific;
>> > #if 0
>> > /* OBSOLETE struct chill_specific *//* For Chill */
>> > /* OBSOLETE { */
>> > @@ -146,6 +151,10 @@ extern CORE_ADDR symbol_overlayed_addres
>> > { \
>> > 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; */ \
>> > @@ -170,12 +179,17 @@ extern void symbol_init_demangled_name (
>> > (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)
>> > + 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
>
>
^ permalink raw reply [flat|nested] 62+ messages in thread
* Re: [PATCH] Objective-C language support.
2002-10-08 16:58 ` Michael Snyder
2002-10-14 19:18 ` Adam Fedor
@ 2002-10-21 15:31 ` Andrew Cagney
1 sibling, 0 replies; 62+ messages in thread
From: Andrew Cagney @ 2002-10-21 15:31 UTC (permalink / raw)
To: Michael Snyder, Adam Fedor; +Cc: gdb-patches
> +/* 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)
>> +{
FYI, this should also take an explicit UI_FILE parameter (making the
function fputs_....().
Andrew
^ permalink raw reply [flat|nested] 62+ messages in thread
* Re: [PATCH] Objective-C language support.
2002-10-08 17:30 ` Michael Snyder
2002-10-13 19:06 ` Adam Fedor
@ 2002-10-21 15:35 ` Andrew Cagney
2002-10-21 16:19 ` Michael Snyder
2002-10-23 12:23 ` Michael Snyder
1 sibling, 2 replies; 62+ messages in thread
From: Andrew Cagney @ 2002-10-21 15:35 UTC (permalink / raw)
To: Michael Snyder; +Cc: Adam Fedor, gdb-patches
> - error ("no args, no `this'");
>> + error ("no args, no %s", name);
Michael,
This changes GDB's behavior. Instead of printing:
no args, no `this'
it will print
no args, no this
I don't think GDB's output should be changed in this way.
(I'm suprized that running the testsuite didn't detect this).
Andrew
^ permalink raw reply [flat|nested] 62+ messages in thread
* Re: [PATCH] Objective-C language support.
2002-10-21 15:35 ` Andrew Cagney
@ 2002-10-21 16:19 ` Michael Snyder
2002-10-23 12:23 ` Michael Snyder
1 sibling, 0 replies; 62+ messages in thread
From: Michael Snyder @ 2002-10-21 16:19 UTC (permalink / raw)
To: Andrew Cagney; +Cc: Adam Fedor, gdb-patches
Andrew Cagney wrote:
>
> > - error ("no args, no `this'");
> >> + error ("no args, no %s", name);
>
> Michael,
>
> This changes GDB's behavior. Instead of printing:
>
> no args, no `this'
> it will print
> no args, no this
>
> I don't think GDB's output should be changed in this way.
> (I'm suprized that running the testsuite didn't detect this).
>
> Andrew
Good catch. I'll fix it, and I'll add a test if there isn't one.
^ permalink raw reply [flat|nested] 62+ messages in thread
* Re: [PATCH] Objective-C language support.
2002-10-18 14:24 ` Elena Zannoni
@ 2002-10-22 5:49 ` Jim Blandy
2002-10-22 14:23 ` Michael Snyder
0 siblings, 1 reply; 62+ messages in thread
From: Jim Blandy @ 2002-10-22 5:49 UTC (permalink / raw)
To: Elena Zannoni; +Cc: Adam Fedor, Michael Snyder, gdb-patches
Elena Zannoni <ezannoni@redhat.com> writes:
> > + /* Find the end of the name, deliminated by a ':', but don't match
> > + ObjC symbols which look like -[Foo bar::]:bla. */
>
>
> Should be "delimited" above, also, could you move the comment to before
> the function?
>
> Hoping Jim doesn't mind... it can go in after these minor changes.
Yep, fine with me.
^ permalink raw reply [flat|nested] 62+ messages in thread
* Re: [PATCH] Objective-C language support.
2002-10-22 5:49 ` Jim Blandy
@ 2002-10-22 14:23 ` Michael Snyder
0 siblings, 0 replies; 62+ messages in thread
From: Michael Snyder @ 2002-10-22 14:23 UTC (permalink / raw)
To: Jim Blandy; +Cc: Elena Zannoni, Adam Fedor, gdb-patches
Jim Blandy wrote:
>
> Elena Zannoni <ezannoni@redhat.com> writes:
> > > + /* Find the end of the name, deliminated by a ':', but don't match
> > > + ObjC symbols which look like -[Foo bar::]:bla. */
> >
> >
> > Should be "delimited" above, also, could you move the comment to before
> > the function?
> >
> > Hoping Jim doesn't mind... it can go in after these minor changes.
>
> Yep, fine with me.
Oh, I thought it was ment to be "de-laminated", as in, the two parts
of the name are 'laminated' together by the colon... ;-)
^ permalink raw reply [flat|nested] 62+ messages in thread
* Re: [PATCH] Objective-C language support.
2002-10-21 15:28 ` Andrew Cagney
@ 2002-10-22 17:04 ` Michael Snyder
2002-10-22 18:42 ` Elena Zannoni
0 siblings, 1 reply; 62+ messages in thread
From: Michael Snyder @ 2002-10-22 17:04 UTC (permalink / raw)
To: Andrew Cagney; +Cc: Jim Blandy, Adam Fedor, gdb-patches
Andrew Cagney wrote:
>
> > This change is approved. (Thanks for the reminder, Michael.)
> >
> > Michael Snyder <msnyder@redhat.com> writes:
>
> I think, here, that garish macro needs to be re-written as a function.
> Any symtab maintainer care to do it?
Mumble mumble... I'm trying to get to it, but stuff-for-which-I-get-paid
keeps coming up. ;-(
>
> Andrew
>
> >> Adam Fedor wrote:
> >
> >> >
> >> > This patch adds Objective-C language support to gdb based upon a patch
> >> > provided by Apple Computer Inc from their version of gdb. Note that the
> >> > patch only contains changes to existing files. New files (objc-lang.h,
> >> > objc-lang.c, objc-exp.y) and a gdb.objc testsuite directory are located at
> >> >
> >> > ftp://ftp.gnustep.org/pub/gnustep/contrib/gdb-objc-patch.tar.gz
> >
> >>
> >> This change is (remotely) related to symbol tables, which belong to
> >> Jim Blandy and Elena Zannoni. Jim, do you have any objection to this
> >> change? I think it's almost obvious, and recommend it for approval.
> >>
> >>
> >
> >> > * symtab.h: New objc_specific struct.
> >> > (SYMBOL_INIT_LANGUAGE_SPECIFIC): Handle ObjC.
> >> > (SYMBOL_DEMANGLED_NAME): Likewise.
> >
> >>
> >
> >> > Index: gdb/symtab.h
> >> > ===================================================================
> >> > RCS file: /cvs/src/src/gdb/symtab.h,v
> >> > retrieving revision 1.39
> >> > diff -u -p -r1.39 symtab.h
> >> > --- gdb/symtab.h 12 Sep 2002 19:19:37 -0000 1.39
> >> > +++ gdb/symtab.h 17 Sep 2002 19:31:07 -0000
> >> > @@ -89,6 +89,11 @@ struct general_symbol_info
> >> > char *demangled_name;
> >> > }
> >> > cplus_specific;
> >> > + struct objc_specific
> >> > + {
> >> > + char *demangled_name;
> >> > + }
> >> > + objc_specific;
> >> > #if 0
> >> > /* OBSOLETE struct chill_specific *//* For Chill */
> >> > /* OBSOLETE { */
> >> > @@ -146,6 +151,10 @@ extern CORE_ADDR symbol_overlayed_addres
> >> > { \
> >> > 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; */ \
> >> > @@ -170,12 +179,17 @@ extern void symbol_init_demangled_name (
> >> > (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)
> >> > + 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
> >
> >
^ permalink raw reply [flat|nested] 62+ messages in thread
* Re: [PATCH] Objective-C language support.
2002-10-22 17:04 ` Michael Snyder
@ 2002-10-22 18:42 ` Elena Zannoni
0 siblings, 0 replies; 62+ messages in thread
From: Elena Zannoni @ 2002-10-22 18:42 UTC (permalink / raw)
To: Michael Snyder; +Cc: Andrew Cagney, Jim Blandy, Adam Fedor, gdb-patches
Michael Snyder writes:
> Andrew Cagney wrote:
> >
> > > This change is approved. (Thanks for the reminder, Michael.)
> > >
> > > Michael Snyder <msnyder@redhat.com> writes:
> >
> > I think, here, that garish macro needs to be re-written as a function.
> > Any symtab maintainer care to do it?
>
> Mumble mumble... I'm trying to get to it, but stuff-for-which-I-get-paid
> keeps coming up. ;-(
>
me doing it now...there are a few other macros worth zapping.
Elena
>
> >
> > Andrew
> >
> > >> Adam Fedor wrote:
> > >
> > >> >
> > >> > This patch adds Objective-C language support to gdb based upon a patch
> > >> > provided by Apple Computer Inc from their version of gdb. Note that the
> > >> > patch only contains changes to existing files. New files (objc-lang.h,
> > >> > objc-lang.c, objc-exp.y) and a gdb.objc testsuite directory are located at
> > >> >
> > >> > ftp://ftp.gnustep.org/pub/gnustep/contrib/gdb-objc-patch.tar.gz
> > >
> > >>
> > >> This change is (remotely) related to symbol tables, which belong to
> > >> Jim Blandy and Elena Zannoni. Jim, do you have any objection to this
> > >> change? I think it's almost obvious, and recommend it for approval.
> > >>
> > >>
> > >
> > >> > * symtab.h: New objc_specific struct.
> > >> > (SYMBOL_INIT_LANGUAGE_SPECIFIC): Handle ObjC.
> > >> > (SYMBOL_DEMANGLED_NAME): Likewise.
> > >
> > >>
> > >
> > >> > Index: gdb/symtab.h
> > >> > ===================================================================
> > >> > RCS file: /cvs/src/src/gdb/symtab.h,v
> > >> > retrieving revision 1.39
> > >> > diff -u -p -r1.39 symtab.h
> > >> > --- gdb/symtab.h 12 Sep 2002 19:19:37 -0000 1.39
> > >> > +++ gdb/symtab.h 17 Sep 2002 19:31:07 -0000
> > >> > @@ -89,6 +89,11 @@ struct general_symbol_info
> > >> > char *demangled_name;
> > >> > }
> > >> > cplus_specific;
> > >> > + struct objc_specific
> > >> > + {
> > >> > + char *demangled_name;
> > >> > + }
> > >> > + objc_specific;
> > >> > #if 0
> > >> > /* OBSOLETE struct chill_specific *//* For Chill */
> > >> > /* OBSOLETE { */
> > >> > @@ -146,6 +151,10 @@ extern CORE_ADDR symbol_overlayed_addres
> > >> > { \
> > >> > 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; */ \
> > >> > @@ -170,12 +179,17 @@ extern void symbol_init_demangled_name (
> > >> > (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)
> > >> > + 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
> > >
> > >
^ permalink raw reply [flat|nested] 62+ messages in thread
* Re: [PATCH] Objective-C language support.
2002-10-21 15:35 ` Andrew Cagney
2002-10-21 16:19 ` Michael Snyder
@ 2002-10-23 12:23 ` Michael Snyder
2002-10-23 12:36 ` Andrew Cagney
1 sibling, 1 reply; 62+ messages in thread
From: Michael Snyder @ 2002-10-23 12:23 UTC (permalink / raw)
To: Andrew Cagney; +Cc: Adam Fedor, gdb-patches
[-- Attachment #1: Type: text/plain, Size: 534 bytes --]
Andrew Cagney wrote:
>
> > - error ("no args, no `this'");
> >> + error ("no args, no %s", name);
>
> Michael,
>
> This changes GDB's behavior. Instead of printing:
>
> no args, no `this'
> it will print
> no args, no this
>
> I don't think GDB's output should be changed in this way.
> (I'm suprized that running the testsuite didn't detect this).
Hi Andrew,
I corrected this with the patch below. I did not add a new test,
because I cannot find a way to invoke this error message. ;-/
Michael
[-- Attachment #2: this.diff --]
[-- Type: text/plain, Size: 697 bytes --]
2002-10-23 Michael Snyder <msnyder@redhat.com>
* valops.c (value_of_local): Restore quotes in error message.
Index: valops.c
===================================================================
RCS file: /cvs/src/src/gdb/valops.c,v
retrieving revision 1.76
diff -p -r1.76 valops.c
*** valops.c 14 Oct 2002 02:02:42 -0000 1.76
--- valops.c 23 Oct 2002 19:21:12 -0000
*************** value_of_local (const char *name, int co
*** 3340,3346 ****
if (i <= 0)
{
if (complain)
! error ("no args, no %s", name);
else
return 0;
}
--- 3340,3346 ----
if (i <= 0)
{
if (complain)
! error ("no args, no '%s'", name);
else
return 0;
}
^ permalink raw reply [flat|nested] 62+ messages in thread
* Re: [PATCH] Objective-C language support.
2002-10-23 12:23 ` Michael Snyder
@ 2002-10-23 12:36 ` Andrew Cagney
2002-10-23 13:10 ` Daniel Jacobowitz
2002-10-23 14:35 ` Michael Snyder
0 siblings, 2 replies; 62+ messages in thread
From: Andrew Cagney @ 2002-10-23 12:36 UTC (permalink / raw)
To: Michael Snyder; +Cc: Adam Fedor, gdb-patches
>>
>
>> > - error ("no args, no `this'");
>
>> >> + error ("no args, no %s", name);
>
>>
>> Michael,
>>
>> This changes GDB's behavior. Instead of printing:
>>
>> no args, no `this'
>> it will print
>> no args, no this
>>
>> I don't think GDB's output should be changed in this way.
>> (I'm suprized that running the testsuite didn't detect this).
>
>
> Hi Andrew,
>
> I corrected this with the patch below. I did not add a new test,
> because I cannot find a way to invoke this error message. ;-/
Michael, my memory of the Apple patch is that it changed this
everywhere, the above was just one example :-( (btw `this' not 'this').
Andrew
^ permalink raw reply [flat|nested] 62+ messages in thread
* Re: [PATCH] Objective-C language support.
2002-10-23 12:36 ` Andrew Cagney
@ 2002-10-23 13:10 ` Daniel Jacobowitz
2002-10-23 14:37 ` Michael Snyder
2002-10-23 14:35 ` Michael Snyder
1 sibling, 1 reply; 62+ messages in thread
From: Daniel Jacobowitz @ 2002-10-23 13:10 UTC (permalink / raw)
To: Andrew Cagney; +Cc: Michael Snyder, Adam Fedor, gdb-patches
On Wed, Oct 23, 2002 at 03:36:08PM -0400, Andrew Cagney wrote:
> >>
> >
> >>> - error ("no args, no `this'");
> >
> >>>> + error ("no args, no %s", name);
> >
> >>
> >>Michael,
> >>
> >>This changes GDB's behavior. Instead of printing:
> >>
> >> no args, no `this'
> >>it will print
> >> no args, no this
> >>
> >>I don't think GDB's output should be changed in this way.
> >>(I'm suprized that running the testsuite didn't detect this).
> >
> >
> >Hi Andrew,
> >
> >I corrected this with the patch below. I did not add a new test,
> >because I cannot find a way to invoke this error message. ;-/
>
> Michael, my memory of the Apple patch is that it changed this
> everywhere, the above was just one example :-( (btw `this' not 'this').
By the way, GCC recently reached the consensus that '' and "" were
appropriate quote marks, and that `' should go away.
[Although I think they also decided that `' should be left in the
source and transliterated by the output routines; that way we can
generate proper quotes in locales which have them. Or maybe that the
real Unicode quotes should be used in source and transliterated to ''.]
--
Daniel Jacobowitz
MontaVista Software Debian GNU/Linux Developer
^ permalink raw reply [flat|nested] 62+ messages in thread
* Re: [PATCH] Objective-C language support.
2002-10-23 12:36 ` Andrew Cagney
2002-10-23 13:10 ` Daniel Jacobowitz
@ 2002-10-23 14:35 ` Michael Snyder
1 sibling, 0 replies; 62+ messages in thread
From: Michael Snyder @ 2002-10-23 14:35 UTC (permalink / raw)
To: Andrew Cagney; +Cc: Adam Fedor, gdb-patches
[-- Attachment #1: Type: text/plain, Size: 956 bytes --]
Andrew Cagney wrote:
>
> >>
> >
> >> > - error ("no args, no `this'");
> >
> >> >> + error ("no args, no %s", name);
> >
> >>
> >> Michael,
> >>
> >> This changes GDB's behavior. Instead of printing:
> >>
> >> no args, no `this'
> >> it will print
> >> no args, no this
> >>
> >> I don't think GDB's output should be changed in this way.
> >> (I'm suprized that running the testsuite didn't detect this).
> >
> >
> > Hi Andrew,
> >
> > I corrected this with the patch below. I did not add a new test,
> > because I cannot find a way to invoke this error message. ;-/
>
> Michael, my memory of the Apple patch is that it changed this
> everywhere, the above was just one example :-(
Oh. Why didn't you say so? OK, below are all the ones I could find.
> (btw `this' not 'this').
Pretty picky, for something that never showed up in a testsuite.
OK, I'll change it to using that quote that nobody ever uses...
See below.
[-- Attachment #2: this2.diff --]
[-- Type: text/plain, Size: 2824 bytes --]
2002-10-23 Michael Snyder <msnyder@redhat.com>
* printcmd.c (address_info): Restore quotes in output.
* valops.c (value_of_local): Restore quotes in error message.
Index: printcmd.c
===================================================================
RCS file: /cvs/src/src/gdb/printcmd.c,v
retrieving revision 1.46
diff -p -r1.46 printcmd.c
*** printcmd.c 21 Oct 2002 19:11:50 -0000 1.46
--- printcmd.c 23 Oct 2002 21:27:36 -0000
*************** address_info (char *exp, int from_tty)
*** 1106,1114 ****
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;
}
--- 1106,1114 ----
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: valops.c
===================================================================
RCS file: /cvs/src/src/gdb/valops.c,v
retrieving revision 1.77
diff -p -r1.77 valops.c
*** valops.c 23 Oct 2002 19:22:28 -0000 1.77
--- valops.c 23 Oct 2002 21:27:38 -0000
*************** value_of_local (const char *name, int co
*** 3330,3336 ****
if (!func)
{
if (complain)
! error ("no %s in nameless context", name);
else
return 0;
}
--- 3330,3336 ----
if (!func)
{
if (complain)
! error ("no `%s' in nameless context", name);
else
return 0;
}
*************** value_of_local (const char *name, int co
*** 3340,3346 ****
if (i <= 0)
{
if (complain)
! error ("no args, no '%s'", name);
else
return 0;
}
--- 3340,3346 ----
if (i <= 0)
{
if (complain)
! error ("no args, no `%s'", name);
else
return 0;
}
*************** value_of_local (const char *name, int co
*** 3351,3364 ****
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;
}
--- 3351,3364 ----
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;
}
^ permalink raw reply [flat|nested] 62+ messages in thread
* Re: [PATCH] Objective-C language support.
2002-10-23 13:10 ` Daniel Jacobowitz
@ 2002-10-23 14:37 ` Michael Snyder
0 siblings, 0 replies; 62+ messages in thread
From: Michael Snyder @ 2002-10-23 14:37 UTC (permalink / raw)
To: Daniel Jacobowitz; +Cc: Andrew Cagney, Adam Fedor, gdb-patches
Daniel Jacobowitz wrote:
>
> On Wed, Oct 23, 2002 at 03:36:08PM -0400, Andrew Cagney wrote:
> > >>
> > >
> > >>> - error ("no args, no `this'");
> > >
> > >>>> + error ("no args, no %s", name);
> > >
> > >>
> > >>Michael,
> > >>
> > >>This changes GDB's behavior. Instead of printing:
> > >>
> > >> no args, no `this'
> > >>it will print
> > >> no args, no this
> > >>
> > >>I don't think GDB's output should be changed in this way.
> > >>(I'm suprized that running the testsuite didn't detect this).
> > >
> > >
> > >Hi Andrew,
> > >
> > >I corrected this with the patch below. I did not add a new test,
> > >because I cannot find a way to invoke this error message. ;-/
> >
> > Michael, my memory of the Apple patch is that it changed this
> > everywhere, the above was just one example :-( (btw `this' not 'this').
>
> By the way, GCC recently reached the consensus that '' and "" were
> appropriate quote marks, and that `' should go away.
Very sensable, IMHO.
> [Although I think they also decided that `' should be left in the
> source and transliterated by the output routines; that way we can
> generate proper quotes in locales which have them. Or maybe that the
> real Unicode quotes should be used in source and transliterated to ''.]
^ permalink raw reply [flat|nested] 62+ messages in thread
* Re: [PATCH] Objective-C language support.
2002-10-14 20:09 ` Adam Fedor
2002-10-18 14:24 ` Elena Zannoni
2002-10-21 15:25 ` Andrew Cagney
@ 2002-11-07 23:44 ` Jim Blandy
2002-11-08 7:16 ` Elena Zannoni
2 siblings, 1 reply; 62+ messages in thread
From: Jim Blandy @ 2002-11-07 23:44 UTC (permalink / raw)
To: Adam Fedor; +Cc: gdb-patches
Looks good to me.
Adam Fedor <fedor@doc.com> writes:
> Jim Blandy wrote:
> > The function stabsread_objc_colon should be static to stabsread.c, no?
> > If that's so, then it should be renamed to something like
> > `find_name_end', with a comment above the strchr ('[') != 0 case
> > explaining its relevance to Objective-C. Since this function gets
> > called on every symbol, it's not an Objective-C specific function;
> > only part of it is.
> > The code needs a comment. Most of GDB's maintainers don't know
> > Objective-C, so it would be helpful just to say something like,
> > "Objective-C symbols can have names like -[foo:bar:baz]:skun
>
> Updated patch:
>
> 2002-10-14 Adam Fedor <fedor@gnu.org>
>
> * stabsread.c (find_name_end): New function.
> (define_symbol): Use it.
>
>
>
>
> --
> Adam Fedor, Digital Optics Corp. | I'm glad I hate spinach, because
> http://www.doc.com | if I didn't, I'd eat it, and you
> | know how I hate the stuff.
> Index: stabsread.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/stabsread.c,v
> retrieving revision 1.42
> diff -u -p -r1.42 stabsread.c
> --- stabsread.c 11 Oct 2002 14:02:38 -0000 1.42
> +++ stabsread.c 15 Oct 2002 03:06:03 -0000
> @@ -169,6 +169,8 @@ static int
> read_cfront_member_functions (struct field_info *, char **,
> struct type *, struct objfile *);
>
> +static char *find_name_end (char *name);
> +
> /* end new functions added for cfront support */
>
> static void
> @@ -1271,7 +1273,7 @@ define_symbol (CORE_ADDR valu, char *str
> struct objfile *objfile)
> {
> register struct symbol *sym;
> - char *p = (char *) strchr (string, ':');
> + char *p = (char *) find_name_end (string);
> int deftype;
> int synonym = 0;
> register int i;
> @@ -2004,7 +2006,8 @@ define_symbol (CORE_ADDR valu, char *str
> 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)
> + else if ((current_subfile->language == language_cplus)
> + || (current_subfile->language == language_objc))
> synonym = 1;
>
> SYMBOL_TYPE (sym) = read_type (&p, objfile);
> @@ -5613,6 +5616,32 @@ finish_global_stabs (struct objfile *obj
> patch_block_stabs (global_symbols, global_stabs, objfile);
> xfree (global_stabs);
> global_stabs = NULL;
> + }
> +}
> +
> +static char *
> +find_name_end (char *name)
> +{
> + char *s = name;
> + /* Find the end of the name, deliminated by a ':', but don't match
> + ObjC symbols which look like -[Foo bar::]:bla. */
> + if (s[0] == '-' || *s == '+')
> + {
> + /* Must be an ObjC method symbol. */
> + 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, ':');
> }
> }
>
^ permalink raw reply [flat|nested] 62+ messages in thread
* Re: [PATCH] Objective-C language support.
2002-11-07 23:44 ` Jim Blandy
@ 2002-11-08 7:16 ` Elena Zannoni
0 siblings, 0 replies; 62+ messages in thread
From: Elena Zannoni @ 2002-11-08 7:16 UTC (permalink / raw)
To: Jim Blandy; +Cc: Adam Fedor, gdb-patches
this has already been checked in
2002-10-18 Adam Fedor <fedor@gnu.org>
* stabsread.c (find_name_end): New function.
(define_symbol): Use it.
Elena
Jim Blandy writes:
>
> Looks good to me.
>
> Adam Fedor <fedor@doc.com> writes:
>
> > Jim Blandy wrote:
> > > The function stabsread_objc_colon should be static to stabsread.c, no?
> > > If that's so, then it should be renamed to something like
> > > `find_name_end', with a comment above the strchr ('[') != 0 case
> > > explaining its relevance to Objective-C. Since this function gets
> > > called on every symbol, it's not an Objective-C specific function;
> > > only part of it is.
> > > The code needs a comment. Most of GDB's maintainers don't know
> > > Objective-C, so it would be helpful just to say something like,
> > > "Objective-C symbols can have names like -[foo:bar:baz]:skun
> >
> > Updated patch:
> >
> > 2002-10-14 Adam Fedor <fedor@gnu.org>
> >
> > * stabsread.c (find_name_end): New function.
> > (define_symbol): Use it.
> >
> >
> >
> >
> > --
> > Adam Fedor, Digital Optics Corp. | I'm glad I hate spinach, because
> > http://www.doc.com | if I didn't, I'd eat it, and you
> > | know how I hate the stuff.
> > Index: stabsread.c
> > ===================================================================
> > RCS file: /cvs/src/src/gdb/stabsread.c,v
> > retrieving revision 1.42
> > diff -u -p -r1.42 stabsread.c
> > --- stabsread.c 11 Oct 2002 14:02:38 -0000 1.42
> > +++ stabsread.c 15 Oct 2002 03:06:03 -0000
> > @@ -169,6 +169,8 @@ static int
> > read_cfront_member_functions (struct field_info *, char **,
> > struct type *, struct objfile *);
> >
> > +static char *find_name_end (char *name);
> > +
> > /* end new functions added for cfront support */
> >
> > static void
> > @@ -1271,7 +1273,7 @@ define_symbol (CORE_ADDR valu, char *str
> > struct objfile *objfile)
> > {
> > register struct symbol *sym;
> > - char *p = (char *) strchr (string, ':');
> > + char *p = (char *) find_name_end (string);
> > int deftype;
> > int synonym = 0;
> > register int i;
> > @@ -2004,7 +2006,8 @@ define_symbol (CORE_ADDR valu, char *str
> > 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)
> > + else if ((current_subfile->language == language_cplus)
> > + || (current_subfile->language == language_objc))
> > synonym = 1;
> >
> > SYMBOL_TYPE (sym) = read_type (&p, objfile);
> > @@ -5613,6 +5616,32 @@ finish_global_stabs (struct objfile *obj
> > patch_block_stabs (global_symbols, global_stabs, objfile);
> > xfree (global_stabs);
> > global_stabs = NULL;
> > + }
> > +}
> > +
> > +static char *
> > +find_name_end (char *name)
> > +{
> > + char *s = name;
> > + /* Find the end of the name, deliminated by a ':', but don't match
> > + ObjC symbols which look like -[Foo bar::]:bla. */
> > + if (s[0] == '-' || *s == '+')
> > + {
> > + /* Must be an ObjC method symbol. */
> > + 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, ':');
> > }
> > }
> >
^ permalink raw reply [flat|nested] 62+ messages in thread
end of thread, other threads:[~2002-11-08 15:16 UTC | newest]
Thread overview: 62+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-09-18 8:24 [PATCH] Objective-C language support Adam Fedor
2002-09-18 10:50 ` Michael Snyder
2002-09-18 11:57 ` Andrew Cagney
2002-09-18 12:04 ` Michael Snyder
2002-09-18 12:14 ` Andrew Cagney
2002-09-18 12:17 ` Michael Snyder
2002-09-18 13:51 ` Adam Fedor
2002-09-18 15:00 ` Michael Snyder
2002-09-18 15:19 ` Adam Fedor
2002-09-18 15:25 ` Andrew Cagney
2002-09-18 11:57 ` Michael Snyder
2002-09-18 11:59 ` Daniel Berlin
2002-09-18 13:31 ` Adam Fedor
2002-09-18 14:03 ` Andrew Cagney
2002-10-08 16:36 ` Michael Snyder
2002-10-11 19:29 ` Adam Fedor
2002-10-08 16:42 ` Michael Snyder
2002-10-11 19:44 ` Adam Fedor
2002-10-21 15:18 ` Andrew Cagney
2002-10-21 15:27 ` Michael Snyder
2002-10-08 16:45 ` Michael Snyder
2002-10-11 19:39 ` Adam Fedor
2002-10-08 16:51 ` Michael Snyder
2002-10-14 13:06 ` Jim Blandy
2002-10-21 15:28 ` Andrew Cagney
2002-10-22 17:04 ` Michael Snyder
2002-10-22 18:42 ` Elena Zannoni
2002-10-08 16:58 ` Michael Snyder
2002-10-14 19:18 ` Adam Fedor
2002-10-21 15:31 ` Andrew Cagney
2002-10-08 17:01 ` Michael Snyder
2002-10-14 13:08 ` Jim Blandy
2002-10-18 10:06 ` Adam Fedor
2002-10-08 17:05 ` Michael Snyder
2002-10-14 13:14 ` Jim Blandy
2002-10-14 20:09 ` Adam Fedor
2002-10-18 14:24 ` Elena Zannoni
2002-10-22 5:49 ` Jim Blandy
2002-10-22 14:23 ` Michael Snyder
2002-10-21 15:25 ` Andrew Cagney
2002-11-07 23:44 ` Jim Blandy
2002-11-08 7:16 ` Elena Zannoni
2002-10-08 17:07 ` Michael Snyder
2002-10-11 20:06 ` Adam Fedor
2002-10-08 17:14 ` Michael Snyder
2002-10-13 18:51 ` Adam Fedor
2002-10-08 17:16 ` Michael Snyder
2002-10-12 11:37 ` Adam Fedor
2002-10-08 17:19 ` Michael Snyder
2002-10-14 19:33 ` Adam Fedor
2002-10-16 12:16 ` Michael Snyder
2002-10-08 17:30 ` Michael Snyder
2002-10-13 19:06 ` Adam Fedor
2002-10-21 15:35 ` Andrew Cagney
2002-10-21 16:19 ` Michael Snyder
2002-10-23 12:23 ` Michael Snyder
2002-10-23 12:36 ` Andrew Cagney
2002-10-23 13:10 ` Daniel Jacobowitz
2002-10-23 14:37 ` Michael Snyder
2002-10-23 14:35 ` Michael Snyder
2002-10-08 17:34 ` Michael Snyder
2002-10-13 19:12 ` Adam Fedor
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox