2002-09-19 00:39:38 +00:00
|
|
|
/* Objective-C language support routines for GDB, the GNU debugger.
|
2002-09-18 23:29:20 +00:00
|
|
|
|
2004-01-23 23:03:31 +00:00
|
|
|
Copyright 2002, 2003, 2004 Free Software Foundation, Inc.
|
2002-09-18 23:29:20 +00:00
|
|
|
|
2002-09-19 04:12:10 +00:00
|
|
|
Contributed by Apple Computer, Inc.
|
|
|
|
Written by Michael Snyder.
|
2002-09-18 23:29:20 +00:00
|
|
|
|
2002-09-19 04:12:10 +00:00
|
|
|
This file is part of GDB.
|
2002-09-18 23:29:20 +00:00
|
|
|
|
2002-09-19 04:12:10 +00:00
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
Boston, MA 02111-1307, USA. */
|
2002-09-18 23:29:20 +00:00
|
|
|
|
|
|
|
#include "defs.h"
|
|
|
|
#include "symtab.h"
|
|
|
|
#include "gdbtypes.h"
|
|
|
|
#include "expression.h"
|
|
|
|
#include "parser-defs.h"
|
|
|
|
#include "language.h"
|
2002-09-19 00:39:38 +00:00
|
|
|
#include "c-lang.h"
|
2002-09-18 23:29:20 +00:00
|
|
|
#include "objc-lang.h"
|
|
|
|
#include "complaints.h"
|
|
|
|
#include "value.h"
|
|
|
|
#include "symfile.h"
|
|
|
|
#include "objfiles.h"
|
2002-10-04 01:18:48 +00:00
|
|
|
#include "gdb_string.h" /* for strchr */
|
2002-09-18 23:29:20 +00:00
|
|
|
#include "target.h" /* for target_has_execution */
|
|
|
|
#include "gdbcore.h"
|
|
|
|
#include "gdbcmd.h"
|
|
|
|
#include "frame.h"
|
|
|
|
#include "gdb_regex.h"
|
|
|
|
#include "regcache.h"
|
2003-02-19 David Carlton <carlton@math.stanford.edu>
* Makefile.in (SFILES): Add block.c.
(block_h): New.
(COMMON_OBS): Add block.o.
(block.o): New.
(x86-64-tdep.o): Add $(block_h).
(values.o, valops.o, tracepoint.o, symtab.o, symmisc.o, symfile.o)
(stack.o, printcmd.o, p-exp.tab.o, parse.o, objfiles.o)
(objc-exp.tab.o, objc-lang.o, nlmread.o, mips-tdep.o, mdebugread.o)
(m2-exp.tab.o, linespec.o, jv-lang.o, jv-exp.tab.o, infcmd.o)
(f-valprint.o, findvar.o, f-exp.tab.o, expprint.o, coffread.o)
(c-exp.tab.o, buildsym.o, breakpoint.o, blockframe.o, ax-gdb.o)
(alpha-tdep.o, ada-lang.o, ada-exp.tab.o, mi-cmd-stack.o): Ditto.
* value.h: Add opaque declaration for struct block.
* parser-defs.h, objc-lang.h, buildsym.h, breakpoint.h: Ditto.
* ada-lang.h: Ditto.
* x86-64-tdep.c: #include "block.h"
* values.c, valops.c, tracepoint.c, symtab.c, symmisc.c: Ditto.
* symfile.c, stack.c, printcmd.c, p-exp.y, parse.c: Ditto.
* objfiles.c, objc-exp.y, objc-lang.c, nlmread.c: Ditto.
* mips-tdep.c, mdebugread.c, m2-exp.y, linespec.c: Ditto.
* jv-lang.c, jv-exp.y, infcmd.c, f-valprint.c: Ditto.
* findvar.c, f-exp.y, expprint.c, coffread.c, c-exp.y: Ditto.
* buildsym.c, breakpoint.c, blockframe.c, ax-gdb.c: Ditto.
* alpha-tdep.c, ada-lang.c, ada-exp.y: Ditto.
* blockframe.c (blockvector_for_pc_sect): Move to "block.c".
(blockvector_for_pc, block_for_pc_sect, block_for_pc): Ditto.
* symtab.c (block_function): Ditto.
(contained_in): Ditto.
* frame.h: Move block_for_pc and block_for_pc_sect declarations to
block.h. Add opaque declaration for struct block.
* symtab.h: Move block_function and contained_in declarations to
block.h. Add opaque declarations for struct block, struct
blockvector.
(struct block): Move to block.h.
(struct blockvector): Ditto.
(BLOCK_START, BLOCK_END, BLOCK_FUNCTION, BLOCK_SUPERBLOCK)
(BLOCK_GCC_COMPILED, BLOCK_HASHTABLE, BLOCK_NSYMS, BLOCK_SYM)
(BLOCK_BUCKETS, BLOCK_BUCKET, BLOCK_HASHTABLE_SIZE)
(ALL_BLOCK_SYMBOLS, BLOCK_SHOULD_SORT, BLOCKVECTOR_NBLOCKS)
(BLOCKVECTOR_BLOCK, GLOBAL_BLOCK, STATIC_BLOCK, FIRST_LOCAL_BLOCK):
Ditto.
* block.c: New file.
* block.h: New file.
2003-02-19 David Carlton <carlton@math.stanford.edu>
* mi-cmd-stack.c: #include "block.h"
2003-02-20 00:01:07 +00:00
|
|
|
#include "block.h"
|
2003-04-21 Andrew Cagney <cagney@redhat.com>
* infcall.c: New file.
* infcall.h: New file.
* valarith.c: Include "infcall.h".
* scm-lang.c, objc-lang.cm, hppa-tdep.c, gcore.c: Ditto.
* eval.c, ada-valprint.c, ada-lang.c: Ditto.
* Makefile.in (valarith.o, scm-lang.o): Update dependencies.
(objc-lang.o, hppa-tdep.o, gcore.o): Update dependencies.
(eval.o, ada-valprint.o, ada-lang.o): Update dependencies.
(SFILES): Add "infcall.c"
(COMMON_OBS): Add "infcall.o".
(infcall.o): Specify dependencies.
* value.h (call_function_by_hand): Delete declaration.
* inferior.h (run_stack_dummy): Delete declaration.
* infcmd.c (breakpoint_auto_delete_contents): Move to "infcall.c".
(run_stack_dummy): Move to "infcall.c", merged into
call_function_by_hand.
* valops.c (call_function_by_hand): Moved to "infcall.c".
(find_function_addr, value_arg_coerce): Ditto.
(unwindonsignal_p, coerce_float_to_double): Ditto.
(_initialize_valops): Move "set/show coerce-float-to-double", and
"set/show unwindonsignal" commands to "infcall.c".
* v850-tdep.c, target.h: Update comments.
* sparc-tdep.c (sparc_fix_call_dummy): Update comments.
* sh-tdep.c (sh_init_extra_frame_info): Update comments.
(sh64_init_extra_frame_info): Update comments.
* mn10300-tdep.c: Update comments.
* mcore-tdep.c (mcore_init_extra_frame_info): Update comments.
* config/sparc/tm-sparc.h: Update comments.
* breakpoint.h: Update comments.
* avr-tdep.c (avr_init_extra_frame_info): Update comments.
* arm-tdep.c: Update comment.
2003-04-21 16:48:41 +00:00
|
|
|
#include "infcall.h"
|
2003-04-25 03:30:17 +00:00
|
|
|
#include "valprint.h"
|
2003-05-23 16:02:30 +00:00
|
|
|
#include "gdb_assert.h"
|
2002-09-18 23:29:20 +00:00
|
|
|
|
|
|
|
#include <ctype.h>
|
|
|
|
|
|
|
|
struct objc_object {
|
|
|
|
CORE_ADDR isa;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct objc_class {
|
|
|
|
CORE_ADDR isa;
|
|
|
|
CORE_ADDR super_class;
|
|
|
|
CORE_ADDR name;
|
|
|
|
long version;
|
|
|
|
long info;
|
|
|
|
long instance_size;
|
|
|
|
CORE_ADDR ivars;
|
|
|
|
CORE_ADDR methods;
|
|
|
|
CORE_ADDR cache;
|
|
|
|
CORE_ADDR protocols;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct objc_super {
|
|
|
|
CORE_ADDR receiver;
|
|
|
|
CORE_ADDR class;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct objc_method {
|
|
|
|
CORE_ADDR name;
|
|
|
|
CORE_ADDR types;
|
|
|
|
CORE_ADDR imp;
|
|
|
|
};
|
|
|
|
|
2002-09-19 00:39:38 +00:00
|
|
|
/* Lookup a structure type named "struct NAME", visible in lexical
|
|
|
|
block BLOCK. If NOERR is nonzero, return zero if NAME is not
|
|
|
|
suitably defined. */
|
2002-09-18 23:29:20 +00:00
|
|
|
|
|
|
|
struct symbol *
|
|
|
|
lookup_struct_typedef (char *name, struct block *block, int noerr)
|
|
|
|
{
|
2003-09-09 08:05:43 +00:00
|
|
|
struct symbol *sym;
|
2002-09-18 23:29:20 +00:00
|
|
|
|
2003-05-14 Elena Zannoni <ezannoni@redhat.com>
* symtab.h (enum domain_enum): Rename from namespace_enum.
(UNDEF_DOMAIN, VAR_DOMAIN, STRUCT_DOMAIN, LABEL_DOMAIN,
VARIABLES_DOMAIN, FUNCTIONS_DOMAIN, TYPES_DOMAIN, METHODS_DOMAIN):
Rename from UNDEF_NAMESPACE, VAR_NAMESPACE, STRUCT_NAMESPACE,
LABEL_NAMESPACE, VARIABLES_NAMESPACE, FUNCTIONS_NAMESPACE,
TYPES_NAMESPACE, METHODS_NAMESPACE.
(SYMBOL_NAMESPACE): Rename to SYMBOL_DOMAIN.
(struct symbol, struct partial_symbol): Rename field
'namespace_enum namespace' to 'domain_enum domain'.
(PSYMBOL_NAMESPACE): Rename to PSYMBOL_DOMAIN.
Delete old define kludge for namespace.
* ada-exp.y, ada-lang.c, ada-lang.h, alpha-tdep.c, arm-tdep.c,
blockframe.c, c-exp.y, c-valprint.c, coffread.c, dbxread.c,
dwarf2read.c, dwarfread.c, f-exp.y, gdbtypes.c, gdbtypes.h,
gnu-v3-abi.c, hppa-tdep.c, hpread.c, jv-exp.y, jv-lang.c,
language.c, linespec.c, m2-exp.y, m3-nat.c, mdebugread.c,
mips-tdep.c, nlmread.c, objc-exp.y, objc-lang.c, objfiles.c,
p-exp.y, p-valprint.c, parse.c, printcmd.c, scm-lang.c, source.c,
stabsread.c, stack.c, symfile.c, symfile.h, symmisc.c, symtab.c,
valops.c, values.c, xcoffread.c, xstormy16-tdep.c: Replace all
occurrences of the above.
2003-05-12 Elena Zannoni <ezannoni@redhat.com>
* mi-mi-cmd-stack.c (list_args_or_locals): Rename VAR_NAMESPACE to
VAR_DOMAIN.
2003-05-14 17:43:20 +00:00
|
|
|
sym = lookup_symbol (name, block, STRUCT_DOMAIN, 0,
|
2002-09-19 00:39:38 +00:00
|
|
|
(struct symtab **) NULL);
|
2002-09-18 23:29:20 +00:00
|
|
|
|
|
|
|
if (sym == NULL)
|
|
|
|
{
|
|
|
|
if (noerr)
|
|
|
|
return 0;
|
|
|
|
else
|
|
|
|
error ("No struct type named %s.", name);
|
|
|
|
}
|
|
|
|
if (TYPE_CODE (SYMBOL_TYPE (sym)) != TYPE_CODE_STRUCT)
|
|
|
|
{
|
|
|
|
if (noerr)
|
|
|
|
return 0;
|
|
|
|
else
|
2002-09-19 00:39:38 +00:00
|
|
|
error ("This context has class, union or enum %s, not a struct.",
|
|
|
|
name);
|
2002-09-18 23:29:20 +00:00
|
|
|
}
|
|
|
|
return sym;
|
|
|
|
}
|
|
|
|
|
|
|
|
CORE_ADDR
|
|
|
|
lookup_objc_class (char *classname)
|
|
|
|
{
|
|
|
|
struct value * function, *classval;
|
|
|
|
|
|
|
|
if (! target_has_execution)
|
|
|
|
{
|
2002-09-19 00:39:38 +00:00
|
|
|
/* Can't call into inferior to lookup class. */
|
2002-09-18 23:29:20 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (lookup_minimal_symbol("objc_lookUpClass", 0, 0))
|
|
|
|
function = find_function_in_inferior("objc_lookUpClass");
|
|
|
|
else if (lookup_minimal_symbol ("objc_lookup_class", 0, 0))
|
|
|
|
function = find_function_in_inferior("objc_lookup_class");
|
|
|
|
else
|
|
|
|
{
|
2002-12-24 03:42:36 +00:00
|
|
|
complaint (&symfile_complaints, "no way to lookup Objective-C classes");
|
2002-09-18 23:29:20 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
classval = value_string (classname, strlen (classname) + 1);
|
|
|
|
classval = value_coerce_array (classval);
|
|
|
|
return (CORE_ADDR) value_as_long (call_function_by_hand (function,
|
|
|
|
1, &classval));
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
lookup_child_selector (char *selname)
|
|
|
|
{
|
|
|
|
struct value * function, *selstring;
|
|
|
|
|
|
|
|
if (! target_has_execution)
|
|
|
|
{
|
2002-09-19 00:39:38 +00:00
|
|
|
/* Can't call into inferior to lookup selector. */
|
2002-09-18 23:29:20 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (lookup_minimal_symbol("sel_getUid", 0, 0))
|
|
|
|
function = find_function_in_inferior("sel_getUid");
|
|
|
|
else if (lookup_minimal_symbol ("sel_get_any_uid", 0, 0))
|
|
|
|
function = find_function_in_inferior("sel_get_any_uid");
|
|
|
|
else
|
|
|
|
{
|
2002-12-24 03:42:36 +00:00
|
|
|
complaint (&symfile_complaints, "no way to lookup Objective-C selectors");
|
2002-09-18 23:29:20 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2002-09-19 00:39:38 +00:00
|
|
|
selstring = value_coerce_array (value_string (selname,
|
|
|
|
strlen (selname) + 1));
|
2002-09-18 23:29:20 +00:00
|
|
|
return value_as_long (call_function_by_hand (function, 1, &selstring));
|
|
|
|
}
|
|
|
|
|
|
|
|
struct value *
|
|
|
|
value_nsstring (char *ptr, int len)
|
|
|
|
{
|
|
|
|
struct value *stringValue[3];
|
|
|
|
struct value *function, *nsstringValue;
|
|
|
|
struct symbol *sym;
|
|
|
|
struct type *type;
|
|
|
|
|
|
|
|
if (!target_has_execution)
|
2002-09-19 00:39:38 +00:00
|
|
|
return 0; /* Can't call into inferior to create NSString. */
|
2002-09-18 23:29:20 +00:00
|
|
|
|
2003-04-06 19:25:04 +00:00
|
|
|
sym = lookup_struct_typedef("NSString", 0, 1);
|
|
|
|
if (sym == NULL)
|
|
|
|
sym = lookup_struct_typedef("NXString", 0, 1);
|
|
|
|
if (sym == NULL)
|
2002-09-18 23:29:20 +00:00
|
|
|
type = lookup_pointer_type(builtin_type_void);
|
|
|
|
else
|
|
|
|
type = lookup_pointer_type(SYMBOL_TYPE (sym));
|
|
|
|
|
|
|
|
stringValue[2] = value_string(ptr, len);
|
|
|
|
stringValue[2] = value_coerce_array(stringValue[2]);
|
2002-09-19 00:39:38 +00:00
|
|
|
/* _NSNewStringFromCString replaces "istr" after Lantern2A. */
|
2002-09-18 23:29:20 +00:00
|
|
|
if (lookup_minimal_symbol("_NSNewStringFromCString", 0, 0))
|
|
|
|
{
|
|
|
|
function = find_function_in_inferior("_NSNewStringFromCString");
|
|
|
|
nsstringValue = call_function_by_hand(function, 1, &stringValue[2]);
|
|
|
|
}
|
|
|
|
else if (lookup_minimal_symbol("istr", 0, 0))
|
|
|
|
{
|
|
|
|
function = find_function_in_inferior("istr");
|
|
|
|
nsstringValue = call_function_by_hand(function, 1, &stringValue[2]);
|
|
|
|
}
|
|
|
|
else if (lookup_minimal_symbol("+[NSString stringWithCString:]", 0, 0))
|
|
|
|
{
|
|
|
|
function = find_function_in_inferior("+[NSString stringWithCString:]");
|
|
|
|
stringValue[0] = value_from_longest
|
|
|
|
(builtin_type_long, lookup_objc_class ("NSString"));
|
|
|
|
stringValue[1] = value_from_longest
|
|
|
|
(builtin_type_long, lookup_child_selector ("stringWithCString:"));
|
|
|
|
nsstringValue = call_function_by_hand(function, 3, &stringValue[0]);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
error ("NSString: internal error -- no way to create new NSString");
|
|
|
|
|
|
|
|
VALUE_TYPE(nsstringValue) = type;
|
|
|
|
return nsstringValue;
|
|
|
|
}
|
|
|
|
|
2002-09-19 00:39:38 +00:00
|
|
|
/* Objective-C name demangling. */
|
2002-09-18 23:29:20 +00:00
|
|
|
|
|
|
|
char *
|
2003-04-02 03:02:46 +00:00
|
|
|
objc_demangle (const char *mangled, int options)
|
2002-09-18 23:29:20 +00:00
|
|
|
{
|
|
|
|
char *demangled, *cp;
|
|
|
|
|
|
|
|
if (mangled[0] == '_' &&
|
|
|
|
(mangled[1] == 'i' || mangled[1] == 'c') &&
|
|
|
|
mangled[2] == '_')
|
|
|
|
{
|
|
|
|
cp = demangled = xmalloc(strlen(mangled) + 2);
|
|
|
|
|
|
|
|
if (mangled[1] == 'i')
|
|
|
|
*cp++ = '-'; /* for instance method */
|
|
|
|
else
|
|
|
|
*cp++ = '+'; /* for class method */
|
|
|
|
|
|
|
|
*cp++ = '['; /* opening left brace */
|
|
|
|
strcpy(cp, mangled+3); /* tack on the rest of the mangled name */
|
|
|
|
|
|
|
|
while (*cp && *cp == '_')
|
|
|
|
cp++; /* skip any initial underbars in class name */
|
|
|
|
|
2002-10-04 01:18:48 +00:00
|
|
|
cp = strchr(cp, '_');
|
|
|
|
if (!cp) /* find first non-initial underbar */
|
2002-09-18 23:29:20 +00:00
|
|
|
{
|
2002-10-04 01:18:48 +00:00
|
|
|
xfree(demangled); /* not mangled name */
|
2002-09-18 23:29:20 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
if (cp[1] == '_') { /* easy case: no category name */
|
|
|
|
*cp++ = ' '; /* replace two '_' with one ' ' */
|
|
|
|
strcpy(cp, mangled + (cp - demangled) + 2);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
*cp++ = '('; /* less easy case: category name */
|
2002-10-04 01:18:48 +00:00
|
|
|
cp = strchr(cp, '_');
|
|
|
|
if (!cp)
|
2002-09-18 23:29:20 +00:00
|
|
|
{
|
2002-10-04 01:18:48 +00:00
|
|
|
xfree(demangled); /* not mangled name */
|
2002-09-18 23:29:20 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
*cp++ = ')';
|
2002-09-19 00:39:38 +00:00
|
|
|
*cp++ = ' '; /* overwriting 1st char of method name... */
|
2002-09-18 23:29:20 +00:00
|
|
|
strcpy(cp, mangled + (cp - demangled)); /* get it back */
|
|
|
|
}
|
|
|
|
|
|
|
|
while (*cp && *cp == '_')
|
|
|
|
cp++; /* skip any initial underbars in method name */
|
|
|
|
|
|
|
|
for (; *cp; cp++)
|
|
|
|
if (*cp == '_')
|
|
|
|
*cp = ':'; /* replace remaining '_' with ':' */
|
|
|
|
|
|
|
|
*cp++ = ']'; /* closing right brace */
|
|
|
|
*cp++ = 0; /* string terminator */
|
|
|
|
return demangled;
|
|
|
|
}
|
|
|
|
else
|
2002-09-19 00:39:38 +00:00
|
|
|
return NULL; /* Not an objc mangled name. */
|
2002-09-18 23:29:20 +00:00
|
|
|
}
|
|
|
|
|
2002-09-19 00:39:38 +00:00
|
|
|
/* Print the character C on STREAM as part of the contents of a
|
|
|
|
literal string whose delimiter is QUOTER. Note that that format
|
|
|
|
for printing characters and strings is language specific. */
|
2002-09-18 23:29:20 +00:00
|
|
|
|
|
|
|
static void
|
2003-09-09 08:05:43 +00:00
|
|
|
objc_emit_char (int c, struct ui_file *stream, int quoter)
|
2002-09-18 23:29:20 +00:00
|
|
|
{
|
|
|
|
|
2002-09-19 00:39:38 +00:00
|
|
|
c &= 0xFF; /* Avoid sign bit follies. */
|
2002-09-18 23:29:20 +00:00
|
|
|
|
|
|
|
if (PRINT_LITERAL_FORM (c))
|
|
|
|
{
|
|
|
|
if (c == '\\' || c == quoter)
|
|
|
|
{
|
|
|
|
fputs_filtered ("\\", stream);
|
|
|
|
}
|
|
|
|
fprintf_filtered (stream, "%c", c);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
switch (c)
|
|
|
|
{
|
|
|
|
case '\n':
|
|
|
|
fputs_filtered ("\\n", stream);
|
|
|
|
break;
|
|
|
|
case '\b':
|
|
|
|
fputs_filtered ("\\b", stream);
|
|
|
|
break;
|
|
|
|
case '\t':
|
|
|
|
fputs_filtered ("\\t", stream);
|
|
|
|
break;
|
|
|
|
case '\f':
|
|
|
|
fputs_filtered ("\\f", stream);
|
|
|
|
break;
|
|
|
|
case '\r':
|
|
|
|
fputs_filtered ("\\r", stream);
|
|
|
|
break;
|
|
|
|
case '\033':
|
|
|
|
fputs_filtered ("\\e", stream);
|
|
|
|
break;
|
|
|
|
case '\007':
|
|
|
|
fputs_filtered ("\\a", stream);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
fprintf_filtered (stream, "\\%.3o", (unsigned int) c);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
objc_printchar (int c, struct ui_file *stream)
|
|
|
|
{
|
|
|
|
fputs_filtered ("'", stream);
|
|
|
|
objc_emit_char (c, stream, '\'');
|
|
|
|
fputs_filtered ("'", stream);
|
|
|
|
}
|
|
|
|
|
2002-09-19 00:39:38 +00:00
|
|
|
/* Print the character string STRING, printing at most LENGTH
|
|
|
|
characters. Printing stops early if the number hits print_max;
|
|
|
|
repeat counts are printed as appropriate. Print ellipses at the
|
|
|
|
end if we had to stop before printing LENGTH characters, or if
|
|
|
|
FORCE_ELLIPSES. */
|
2002-09-18 23:29:20 +00:00
|
|
|
|
|
|
|
static void
|
2002-09-19 00:39:38 +00:00
|
|
|
objc_printstr (struct ui_file *stream, char *string,
|
2002-12-03 03:52:37 +00:00
|
|
|
unsigned int length, int width, int force_ellipses)
|
2002-09-18 23:29:20 +00:00
|
|
|
{
|
2003-09-09 08:05:43 +00:00
|
|
|
unsigned int i;
|
2002-09-18 23:29:20 +00:00
|
|
|
unsigned int things_printed = 0;
|
|
|
|
int in_quotes = 0;
|
|
|
|
int need_comma = 0;
|
|
|
|
|
|
|
|
/* If the string was not truncated due to `set print elements', and
|
2002-09-19 00:39:38 +00:00
|
|
|
the last byte of it is a null, we don't print that, in
|
|
|
|
traditional C style. */
|
2002-09-18 23:29:20 +00:00
|
|
|
if ((!force_ellipses) && length > 0 && string[length-1] == '\0')
|
|
|
|
length--;
|
|
|
|
|
|
|
|
if (length == 0)
|
|
|
|
{
|
|
|
|
fputs_filtered ("\"\"", stream);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < length && things_printed < print_max; ++i)
|
|
|
|
{
|
2002-09-19 00:39:38 +00:00
|
|
|
/* Position of the character we are examining to see whether it
|
|
|
|
is repeated. */
|
2002-09-18 23:29:20 +00:00
|
|
|
unsigned int rep1;
|
|
|
|
/* Number of repetitions we have detected so far. */
|
|
|
|
unsigned int reps;
|
|
|
|
|
|
|
|
QUIT;
|
|
|
|
|
|
|
|
if (need_comma)
|
|
|
|
{
|
|
|
|
fputs_filtered (", ", stream);
|
|
|
|
need_comma = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
rep1 = i + 1;
|
|
|
|
reps = 1;
|
|
|
|
while (rep1 < length && string[rep1] == string[i])
|
|
|
|
{
|
|
|
|
++rep1;
|
|
|
|
++reps;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (reps > repeat_count_threshold)
|
|
|
|
{
|
|
|
|
if (in_quotes)
|
|
|
|
{
|
|
|
|
if (inspect_it)
|
|
|
|
fputs_filtered ("\\\", ", stream);
|
|
|
|
else
|
|
|
|
fputs_filtered ("\", ", stream);
|
|
|
|
in_quotes = 0;
|
|
|
|
}
|
|
|
|
objc_printchar (string[i], stream);
|
|
|
|
fprintf_filtered (stream, " <repeats %u times>", reps);
|
|
|
|
i = rep1 - 1;
|
|
|
|
things_printed += repeat_count_threshold;
|
|
|
|
need_comma = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!in_quotes)
|
|
|
|
{
|
|
|
|
if (inspect_it)
|
|
|
|
fputs_filtered ("\\\"", stream);
|
|
|
|
else
|
|
|
|
fputs_filtered ("\"", stream);
|
|
|
|
in_quotes = 1;
|
|
|
|
}
|
|
|
|
objc_emit_char (string[i], stream, '"');
|
|
|
|
++things_printed;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Terminate the quotes if necessary. */
|
|
|
|
if (in_quotes)
|
|
|
|
{
|
|
|
|
if (inspect_it)
|
|
|
|
fputs_filtered ("\\\"", stream);
|
|
|
|
else
|
|
|
|
fputs_filtered ("\"", stream);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (force_ellipses || i < length)
|
|
|
|
fputs_filtered ("...", stream);
|
|
|
|
}
|
|
|
|
|
2002-09-19 00:39:38 +00:00
|
|
|
/* Create a fundamental C type using default reasonable for the
|
|
|
|
current target.
|
|
|
|
|
|
|
|
Some object/debugging file formats (DWARF version 1, COFF, etc) do
|
|
|
|
not define fundamental types such as "int" or "double". Others
|
|
|
|
(stabs or DWARF version 2, etc) do define fundamental types. For
|
|
|
|
the formats which don't provide fundamental types, gdb can create
|
|
|
|
such types using this function.
|
|
|
|
|
|
|
|
FIXME: Some compilers distinguish explicitly signed integral types
|
|
|
|
(signed short, signed int, signed long) from "regular" integral
|
|
|
|
types (short, int, long) in the debugging information. There is
|
|
|
|
some disagreement as to how useful this feature is. In particular,
|
|
|
|
gcc does not support this. Also, only some debugging formats allow
|
|
|
|
the distinction to be passed on to a debugger. For now, we always
|
|
|
|
just use "short", "int", or "long" as the type name, for both the
|
|
|
|
implicit and explicitly signed types. This also makes life easier
|
|
|
|
for the gdb test suite since we don't have to account for the
|
|
|
|
differences in output depending upon what the compiler and
|
|
|
|
debugging format support. We will probably have to re-examine the
|
|
|
|
issue when gdb starts taking it's fundamental type information
|
|
|
|
directly from the debugging information supplied by the compiler.
|
|
|
|
fnf@cygnus.com */
|
2002-09-18 23:29:20 +00:00
|
|
|
|
|
|
|
static struct type *
|
|
|
|
objc_create_fundamental_type (struct objfile *objfile, int typeid)
|
|
|
|
{
|
2003-09-09 08:05:43 +00:00
|
|
|
struct type *type = NULL;
|
2002-09-18 23:29:20 +00:00
|
|
|
|
|
|
|
switch (typeid)
|
|
|
|
{
|
|
|
|
default:
|
2002-09-19 00:39:38 +00:00
|
|
|
/* FIXME: For now, if we are asked to produce a type not in
|
|
|
|
this language, create the equivalent of a C integer type
|
|
|
|
with the name "<?type?>". When all the dust settles from
|
|
|
|
the type reconstruction work, this should probably become
|
|
|
|
an error. */
|
2002-09-18 23:29:20 +00:00
|
|
|
type = init_type (TYPE_CODE_INT,
|
|
|
|
TARGET_INT_BIT / TARGET_CHAR_BIT,
|
|
|
|
0, "<?type?>", objfile);
|
|
|
|
warning ("internal error: no C/C++ fundamental type %d", typeid);
|
|
|
|
break;
|
|
|
|
case FT_VOID:
|
|
|
|
type = init_type (TYPE_CODE_VOID,
|
|
|
|
TARGET_CHAR_BIT / TARGET_CHAR_BIT,
|
|
|
|
0, "void", objfile);
|
|
|
|
break;
|
|
|
|
case FT_CHAR:
|
|
|
|
type = init_type (TYPE_CODE_INT,
|
|
|
|
TARGET_CHAR_BIT / TARGET_CHAR_BIT,
|
|
|
|
0, "char", objfile);
|
|
|
|
break;
|
|
|
|
case FT_SIGNED_CHAR:
|
|
|
|
type = init_type (TYPE_CODE_INT,
|
|
|
|
TARGET_CHAR_BIT / TARGET_CHAR_BIT,
|
|
|
|
0, "signed char", objfile);
|
|
|
|
break;
|
|
|
|
case FT_UNSIGNED_CHAR:
|
|
|
|
type = init_type (TYPE_CODE_INT,
|
|
|
|
TARGET_CHAR_BIT / TARGET_CHAR_BIT,
|
|
|
|
TYPE_FLAG_UNSIGNED, "unsigned char", objfile);
|
|
|
|
break;
|
|
|
|
case FT_SHORT:
|
|
|
|
type = init_type (TYPE_CODE_INT,
|
|
|
|
TARGET_SHORT_BIT / TARGET_CHAR_BIT,
|
|
|
|
0, "short", objfile);
|
|
|
|
break;
|
|
|
|
case FT_SIGNED_SHORT:
|
|
|
|
type = init_type (TYPE_CODE_INT,
|
|
|
|
TARGET_SHORT_BIT / TARGET_CHAR_BIT,
|
|
|
|
0, "short", objfile); /* FIXME-fnf */
|
|
|
|
break;
|
|
|
|
case FT_UNSIGNED_SHORT:
|
|
|
|
type = init_type (TYPE_CODE_INT,
|
|
|
|
TARGET_SHORT_BIT / TARGET_CHAR_BIT,
|
|
|
|
TYPE_FLAG_UNSIGNED, "unsigned short", objfile);
|
|
|
|
break;
|
|
|
|
case FT_INTEGER:
|
|
|
|
type = init_type (TYPE_CODE_INT,
|
|
|
|
TARGET_INT_BIT / TARGET_CHAR_BIT,
|
|
|
|
0, "int", objfile);
|
|
|
|
break;
|
|
|
|
case FT_SIGNED_INTEGER:
|
|
|
|
type = init_type (TYPE_CODE_INT,
|
|
|
|
TARGET_INT_BIT / TARGET_CHAR_BIT,
|
|
|
|
0, "int", objfile); /* FIXME -fnf */
|
|
|
|
break;
|
|
|
|
case FT_UNSIGNED_INTEGER:
|
|
|
|
type = init_type (TYPE_CODE_INT,
|
|
|
|
TARGET_INT_BIT / TARGET_CHAR_BIT,
|
|
|
|
TYPE_FLAG_UNSIGNED, "unsigned int", objfile);
|
|
|
|
break;
|
|
|
|
case FT_LONG:
|
|
|
|
type = init_type (TYPE_CODE_INT,
|
|
|
|
TARGET_LONG_BIT / TARGET_CHAR_BIT,
|
|
|
|
0, "long", objfile);
|
|
|
|
break;
|
|
|
|
case FT_SIGNED_LONG:
|
|
|
|
type = init_type (TYPE_CODE_INT,
|
|
|
|
TARGET_LONG_BIT / TARGET_CHAR_BIT,
|
|
|
|
0, "long", objfile); /* FIXME -fnf */
|
|
|
|
break;
|
|
|
|
case FT_UNSIGNED_LONG:
|
|
|
|
type = init_type (TYPE_CODE_INT,
|
|
|
|
TARGET_LONG_BIT / TARGET_CHAR_BIT,
|
|
|
|
TYPE_FLAG_UNSIGNED, "unsigned long", objfile);
|
|
|
|
break;
|
|
|
|
case FT_LONG_LONG:
|
|
|
|
type = init_type (TYPE_CODE_INT,
|
|
|
|
TARGET_LONG_LONG_BIT / TARGET_CHAR_BIT,
|
|
|
|
0, "long long", objfile);
|
|
|
|
break;
|
|
|
|
case FT_SIGNED_LONG_LONG:
|
|
|
|
type = init_type (TYPE_CODE_INT,
|
|
|
|
TARGET_LONG_LONG_BIT / TARGET_CHAR_BIT,
|
|
|
|
0, "signed long long", objfile);
|
|
|
|
break;
|
|
|
|
case FT_UNSIGNED_LONG_LONG:
|
|
|
|
type = init_type (TYPE_CODE_INT,
|
|
|
|
TARGET_LONG_LONG_BIT / TARGET_CHAR_BIT,
|
|
|
|
TYPE_FLAG_UNSIGNED, "unsigned long long", objfile);
|
|
|
|
break;
|
|
|
|
case FT_FLOAT:
|
|
|
|
type = init_type (TYPE_CODE_FLT,
|
|
|
|
TARGET_FLOAT_BIT / TARGET_CHAR_BIT,
|
|
|
|
0, "float", objfile);
|
|
|
|
break;
|
|
|
|
case FT_DBL_PREC_FLOAT:
|
|
|
|
type = init_type (TYPE_CODE_FLT,
|
|
|
|
TARGET_DOUBLE_BIT / TARGET_CHAR_BIT,
|
|
|
|
0, "double", objfile);
|
|
|
|
break;
|
|
|
|
case FT_EXT_PREC_FLOAT:
|
|
|
|
type = init_type (TYPE_CODE_FLT,
|
|
|
|
TARGET_LONG_DOUBLE_BIT / TARGET_CHAR_BIT,
|
|
|
|
0, "long double", objfile);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return (type);
|
|
|
|
}
|
|
|
|
|
2003-03-26 03:39:44 +00:00
|
|
|
/* Determine if we are currently in the Objective-C dispatch function.
|
|
|
|
If so, get the address of the method function that the dispatcher
|
|
|
|
would call and use that as the function to step into instead. Also
|
|
|
|
skip over the trampoline for the function (if any). This is better
|
|
|
|
for the user since they are only interested in stepping into the
|
|
|
|
method function anyway. */
|
|
|
|
static CORE_ADDR
|
|
|
|
objc_skip_trampoline (CORE_ADDR stop_pc)
|
|
|
|
{
|
|
|
|
CORE_ADDR real_stop_pc;
|
|
|
|
CORE_ADDR method_stop_pc;
|
|
|
|
|
|
|
|
real_stop_pc = SKIP_TRAMPOLINE_CODE (stop_pc);
|
|
|
|
|
|
|
|
if (real_stop_pc != 0)
|
|
|
|
find_objc_msgcall (real_stop_pc, &method_stop_pc);
|
|
|
|
else
|
|
|
|
find_objc_msgcall (stop_pc, &method_stop_pc);
|
|
|
|
|
|
|
|
if (method_stop_pc)
|
|
|
|
{
|
|
|
|
real_stop_pc = SKIP_TRAMPOLINE_CODE (method_stop_pc);
|
|
|
|
if (real_stop_pc == 0)
|
|
|
|
real_stop_pc = method_stop_pc;
|
|
|
|
}
|
|
|
|
|
|
|
|
return real_stop_pc;
|
|
|
|
}
|
|
|
|
|
2002-09-18 23:29:20 +00:00
|
|
|
|
|
|
|
/* Table mapping opcodes into strings for printing operators
|
|
|
|
and precedences of the operators. */
|
|
|
|
|
|
|
|
static const struct op_print objc_op_print_tab[] =
|
|
|
|
{
|
|
|
|
{",", BINOP_COMMA, PREC_COMMA, 0},
|
|
|
|
{"=", BINOP_ASSIGN, PREC_ASSIGN, 1},
|
|
|
|
{"||", BINOP_LOGICAL_OR, PREC_LOGICAL_OR, 0},
|
|
|
|
{"&&", BINOP_LOGICAL_AND, PREC_LOGICAL_AND, 0},
|
|
|
|
{"|", BINOP_BITWISE_IOR, PREC_BITWISE_IOR, 0},
|
|
|
|
{"^", BINOP_BITWISE_XOR, PREC_BITWISE_XOR, 0},
|
|
|
|
{"&", BINOP_BITWISE_AND, PREC_BITWISE_AND, 0},
|
|
|
|
{"==", BINOP_EQUAL, PREC_EQUAL, 0},
|
|
|
|
{"!=", BINOP_NOTEQUAL, PREC_EQUAL, 0},
|
|
|
|
{"<=", BINOP_LEQ, PREC_ORDER, 0},
|
|
|
|
{">=", BINOP_GEQ, PREC_ORDER, 0},
|
|
|
|
{">", BINOP_GTR, PREC_ORDER, 0},
|
|
|
|
{"<", BINOP_LESS, PREC_ORDER, 0},
|
|
|
|
{">>", BINOP_RSH, PREC_SHIFT, 0},
|
|
|
|
{"<<", BINOP_LSH, PREC_SHIFT, 0},
|
|
|
|
{"+", BINOP_ADD, PREC_ADD, 0},
|
|
|
|
{"-", BINOP_SUB, PREC_ADD, 0},
|
|
|
|
{"*", BINOP_MUL, PREC_MUL, 0},
|
|
|
|
{"/", BINOP_DIV, PREC_MUL, 0},
|
|
|
|
{"%", BINOP_REM, PREC_MUL, 0},
|
|
|
|
{"@", BINOP_REPEAT, PREC_REPEAT, 0},
|
|
|
|
{"-", UNOP_NEG, PREC_PREFIX, 0},
|
|
|
|
{"!", UNOP_LOGICAL_NOT, PREC_PREFIX, 0},
|
|
|
|
{"~", UNOP_COMPLEMENT, PREC_PREFIX, 0},
|
|
|
|
{"*", UNOP_IND, PREC_PREFIX, 0},
|
|
|
|
{"&", UNOP_ADDR, PREC_PREFIX, 0},
|
|
|
|
{"sizeof ", UNOP_SIZEOF, PREC_PREFIX, 0},
|
|
|
|
{"++", UNOP_PREINCREMENT, PREC_PREFIX, 0},
|
|
|
|
{"--", UNOP_PREDECREMENT, PREC_PREFIX, 0},
|
2003-05-23 16:02:30 +00:00
|
|
|
{NULL, OP_NULL, PREC_NULL, 0}
|
2002-09-18 23:29:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct type ** const (objc_builtin_types[]) =
|
|
|
|
{
|
|
|
|
&builtin_type_int,
|
|
|
|
&builtin_type_long,
|
|
|
|
&builtin_type_short,
|
|
|
|
&builtin_type_char,
|
|
|
|
&builtin_type_float,
|
|
|
|
&builtin_type_double,
|
|
|
|
&builtin_type_void,
|
|
|
|
&builtin_type_long_long,
|
|
|
|
&builtin_type_signed_char,
|
|
|
|
&builtin_type_unsigned_char,
|
|
|
|
&builtin_type_unsigned_short,
|
|
|
|
&builtin_type_unsigned_int,
|
|
|
|
&builtin_type_unsigned_long,
|
|
|
|
&builtin_type_unsigned_long_long,
|
|
|
|
&builtin_type_long_double,
|
|
|
|
&builtin_type_complex,
|
|
|
|
&builtin_type_double_complex,
|
|
|
|
0
|
|
|
|
};
|
|
|
|
|
|
|
|
const struct language_defn objc_language_defn = {
|
2002-09-19 00:39:38 +00:00
|
|
|
"objective-c", /* Language name */
|
2002-09-18 23:29:20 +00:00
|
|
|
language_objc,
|
|
|
|
objc_builtin_types,
|
|
|
|
range_check_off,
|
|
|
|
type_check_off,
|
|
|
|
case_sensitive_on,
|
* parser-defs.h (struct exp_descriptor): New definition, containing
language-specific info for printing, prefixifying, dumping, and
evaluating expressions.
(exp_descriptor_standard): Declare new variable.
(print_subexp): Make global and declare here (from expprint.c).
(dump_subexp): Ditto.
(dump_subexp_body_standard): Declare.
(operator_length_standard): Declare.
(op_name_standard): Declare.
(print_subexp): Declare.
(print_subexp_standard): Declare.
* language.h (struct language_defn): Add la_exp_desc field to hold
pointer to table for language-specific operators.
Remove evaluate_exp field, which is now in struct exp_descriptor.
* parse.c (operator_length): Move most code to new
operator_length_standard function. Use language-specific information.
(operator_length_standard): New function taking most code from
operator_length.
(exp_descriptor_standard): New constant.
* expression.h (enum exp_opcode): Add definitions of OP_EXTENDED0
and OP_EXTENDED_LAST.
* expprint.c (print_subexp): Use language-specific print_subexp.
Make global; remove static declaration.
Move most code to print_subexp_standard.
(print_subexp_standard): New function, containing code formerly in
print_subexp.
(op_name): Add expression to argument signature.
Use langauge-specific op_name.
Move most code to op_name_standard.
(op_name_standard): New function, containing code formerly in op_name.
(dump_subexp): Use new version of op_name function.
Use language-specific dump_subexp_body, and move most existing code to
dump_subexp_body_standard.
(dump_raw_expression): Use new op_name interface.
(dump_subexp_body): Move most code to dump_subexp_body_standard.
(dump_subexp_body_standard): New function, containing code formerly
in dump_subexp_body.
* language.c (unknown_language): Add default la_exp_desc field and
remove evaluate_exp field.
(auto_language): Ditto.
(local_language): Ditto.
* f-lang.c (f_language_defn): Ditto.
* c-lang.c (c_language_defn): Ditto.
(cplus_language_defn): Ditto.
(asm_language_defn): Ditto.
(minimal_language_defn): Ditto.
* p-lang.c (pascal_language_defn): Ditto.
* m2-lang.c (m2_language_defn): Ditto.
* objc-lang.c (objc_language_defn): Ditto.
* jv-lang.c (exp_descriptor_java): New variable, containing
Java-specific expression evaluator.
(java_language_defn): Add la_exp_desc field and remove evaluate_exp
field.
* scm-lang.c (exp_descriptor_scm): New variable, containing
Scheme-specific expression evaluator.
(scm_language_defn): Add la_exp_desc field and remove evaluate_exp
field.
* objc-lang.c (print_object_command): Take evaluate_exp from the
la_exp_desc field.
* Makefile.in (eval.o): Add dependency on parser-defs.h.
* eval.c: Include parser-defs.h for the full declaration of
la_exp_desc's type.
(evaluate_subexp): Get evaluate_exp out of la_exp_desc field.
2003-09-25 08:40:45 +00:00
|
|
|
&exp_descriptor_standard,
|
2002-09-18 23:29:20 +00:00
|
|
|
objc_parse,
|
|
|
|
objc_error,
|
|
|
|
objc_printchar, /* Print a character constant */
|
|
|
|
objc_printstr, /* Function to print string constant */
|
|
|
|
objc_emit_char,
|
|
|
|
objc_create_fundamental_type, /* Create fundamental type in this language */
|
|
|
|
c_print_type, /* Print a type using appropriate syntax */
|
|
|
|
c_val_print, /* Print a value using appropriate syntax */
|
|
|
|
c_value_print, /* Print a top-level value */
|
2003-03-26 03:39:44 +00:00
|
|
|
objc_skip_trampoline, /* Language specific skip_trampoline */
|
2003-05-20 01:55:18 +00:00
|
|
|
value_of_this, /* value_of_this */
|
|
|
|
basic_lookup_symbol_nonlocal, /* lookup_symbol_nonlocal */
|
2004-01-23 23:03:31 +00:00
|
|
|
basic_lookup_transparent_type,/* lookup_transparent_type */
|
2003-04-02 03:02:46 +00:00
|
|
|
objc_demangle, /* Language specific symbol demangler */
|
2002-09-18 23:29:20 +00:00
|
|
|
{"", "", "", ""}, /* Binary format info */
|
|
|
|
{"0%lo", "0", "o", ""}, /* Octal format info */
|
|
|
|
{"%ld", "", "d", ""}, /* Decimal format info */
|
|
|
|
{"0x%lx", "0x", "x", ""}, /* Hex format info */
|
2002-09-19 00:39:38 +00:00
|
|
|
objc_op_print_tab, /* Expression operators for printing */
|
|
|
|
1, /* C-style arrays */
|
2002-09-18 23:29:20 +00:00
|
|
|
0, /* String lower bound */
|
|
|
|
&builtin_type_char, /* Type of string elements */
|
2003-10-06 22:38:03 +00:00
|
|
|
default_word_break_characters,
|
2002-09-18 23:29:20 +00:00
|
|
|
LANG_MAGIC
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ObjC:
|
2002-09-19 00:39:38 +00:00
|
|
|
* Following functions help construct Objective-C message calls
|
2002-09-18 23:29:20 +00:00
|
|
|
*/
|
|
|
|
|
2002-09-19 00:39:38 +00:00
|
|
|
struct selname /* For parsing Objective-C. */
|
2002-09-18 23:29:20 +00:00
|
|
|
{
|
|
|
|
struct selname *next;
|
|
|
|
char *msglist_sel;
|
|
|
|
int msglist_len;
|
|
|
|
};
|
|
|
|
|
|
|
|
static int msglist_len;
|
|
|
|
static struct selname *selname_chain;
|
|
|
|
static char *msglist_sel;
|
|
|
|
|
|
|
|
void
|
|
|
|
start_msglist(void)
|
|
|
|
{
|
2003-09-09 08:05:43 +00:00
|
|
|
struct selname *new =
|
2002-09-18 23:29:20 +00:00
|
|
|
(struct selname *) xmalloc (sizeof (struct selname));
|
|
|
|
|
|
|
|
new->next = selname_chain;
|
|
|
|
new->msglist_len = msglist_len;
|
|
|
|
new->msglist_sel = msglist_sel;
|
|
|
|
msglist_len = 0;
|
|
|
|
msglist_sel = (char *)xmalloc(1);
|
|
|
|
*msglist_sel = 0;
|
|
|
|
selname_chain = new;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
add_msglist(struct stoken *str, int addcolon)
|
|
|
|
{
|
|
|
|
char *s, *p;
|
|
|
|
int len, plen;
|
|
|
|
|
2002-09-19 00:39:38 +00:00
|
|
|
if (str == 0) { /* Unnamed arg, or... */
|
|
|
|
if (addcolon == 0) { /* variable number of args. */
|
2002-09-18 23:29:20 +00:00
|
|
|
msglist_len++;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
p = "";
|
|
|
|
plen = 0;
|
|
|
|
} else {
|
|
|
|
p = str->ptr;
|
|
|
|
plen = str->length;
|
|
|
|
}
|
|
|
|
len = plen + strlen(msglist_sel) + 2;
|
|
|
|
s = (char *)xmalloc(len);
|
|
|
|
strcpy(s, msglist_sel);
|
|
|
|
strncat(s, p, plen);
|
2002-10-04 01:18:48 +00:00
|
|
|
xfree(msglist_sel);
|
2002-09-18 23:29:20 +00:00
|
|
|
msglist_sel = s;
|
|
|
|
if (addcolon) {
|
|
|
|
s[len-2] = ':';
|
|
|
|
s[len-1] = 0;
|
|
|
|
msglist_len++;
|
|
|
|
} else
|
|
|
|
s[len-2] = '\0';
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
end_msglist(void)
|
|
|
|
{
|
2003-09-09 08:05:43 +00:00
|
|
|
int val = msglist_len;
|
|
|
|
struct selname *sel = selname_chain;
|
|
|
|
char *p = msglist_sel;
|
2002-09-18 23:29:20 +00:00
|
|
|
int selid;
|
|
|
|
|
|
|
|
selname_chain = sel->next;
|
|
|
|
msglist_len = sel->msglist_len;
|
|
|
|
msglist_sel = sel->msglist_sel;
|
|
|
|
selid = lookup_child_selector(p);
|
|
|
|
if (!selid)
|
|
|
|
error("Can't find selector \"%s\"", p);
|
|
|
|
write_exp_elt_longcst (selid);
|
2002-10-04 01:18:48 +00:00
|
|
|
xfree(p);
|
2002-09-19 00:39:38 +00:00
|
|
|
write_exp_elt_longcst (val); /* Number of args */
|
2002-10-04 01:18:48 +00:00
|
|
|
xfree(sel);
|
2002-09-18 23:29:20 +00:00
|
|
|
|
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Function: specialcmp (char *a, char *b)
|
|
|
|
*
|
|
|
|
* Special strcmp: treats ']' and ' ' as end-of-string.
|
2002-09-19 00:39:38 +00:00
|
|
|
* Used for qsorting lists of objc methods (either by class or selector).
|
2002-09-18 23:29:20 +00:00
|
|
|
*/
|
|
|
|
|
2003-06-08 Andrew Cagney <cagney@redhat.com>
* acinclude.m4 (gcc_AC_CHECK_DECL, (gcc_AC_CHECK_DECL): Stolen
from GCC's acinclude.m4.
* configure.in: Check for getopt's delcaration.
* aclocal.m4, config.in, configure: Re-generate.
* main.c (error_init): Delete declaration.
* defs.h (error_init): Declare.
* rs6000-tdep.c (rs6000_fetch_pointer_argument): Make static.
(rs6000_convert_from_func_ptr_addr): Make static.
(_initialize_rs6000_tdep): Add declaration.
* cli/cli-cmds.c (dont_repeat): Delete declaration.
(show_commands, set_verbose, show_history): Delete declaration.
* top.h (set_verbose): Add declaration.
(show_history, set_history, show_commands): Add declaration.
(do_restore_instream_cleanup): Add declaration.
* objc-lang.c (specialcmp): Make static.
(print_object_command): Make static.
(find_objc_msgsend): Make static.
(find_objc_msgcall_submethod_helper): Make static.
(find_objc_msgcall_submethod): Make static.
(_initialize_objc_language): Add declaration.
(find_implementation_from_class): Make static.
(find_implementation): Make static.
* objc-exp.y (yylex): Delete lookup_struct_typedef declaration.
* objc-lang.h (lookup_struct_typedef): Add declaration.
* cli/cli-interp.c (_initialize_cli_interp): Add declaration.
* cli/cli-script.c (clear_hook_in_cleanup): Make static.
(do_restore_user_call_depth): Make static.
(do_restore_instream_cleanup): Delete declaration.
(dont_repeat): Delete declaration.
* cli/cli-decode.c (add_abbrev_cmd): Delete function.
* cli/cli-dump.c (_initialize_cli_dump): Add declaration.
* reggroups.c (_initialize_reggroup): Add declaration.
* cp-support.c (_initialize_cp_support): Add declaration.
* cp-abi.c (_initialize_cp_abi): Add declaration.
* hpacc-abi.c (_initialize_hpacc_abi): Add declaration.
* gnu-v3-abi.c (gnuv3_baseclass_offset): Make static.
(_initialize_gnu_v3_abi): Add declaration.
* gnu-v2-abi.c (gnuv2_value_rtti_type): Make static.
(_initialize_gnu_v2_abi): Add declaration.
* frame-base.c (_initialize_frame_base): Add declaration.
* doublest.c (floatformat_from_length): Make static.
* frame-unwind.c (_initialize_frame_unwind): Add declaration.
* frame.c (create_sentinel_frame): Make static.
(_initialize_frame): Add declaration.
* top.c (do_catch_errors): Make static.
(gdb_rl_operate_and_get_next_completion): Make static.
* typeprint.c: Include "typeprint.h".
* sentinel-frame.c (sentinel_frame_prev_register): Make static.
(sentinel_frame_this_id): Make static.
* p-valprint.c (_initialize_pascal_valprint): Add declaration.
* ui-out.c (make_cleanup_ui_out_begin_end): Delete function.
* dwarf2-frame.c (dwarf2_frame_cache): Make static.
* p-exp.y (push_current_type, pop_current_type): ISO C declaration.
* dwarf2expr.h (dwarf_expr_context): ISO C declaration.
* maint.c (maintenance_print_architecture): Make static.
* signals/signals.c (_initialize_signals): Add declaration.
* std-regs.c (_initialize_frame_reg): Add declaration.
* jv-exp.y (push_variable): ISO C definition.
(push_qualified_expression_name): Ditto.
* memattr.c (_initialize_mem): Add declaration.
* remote.c (remote_check_watch_resources): Make static.
(remote_stopped_by_watchpoint): Make static.
(remote_stopped_data_address): Make static.
* d10v-tdep.c (nr_dmap_regs): Make static.
(a0_regnum): Make static.
(d10v_frame_unwind_cache): Make static.
(d10v_frame_p): Make static.
* osabi.c (show_osabi): Make static.
(_initialize_gdb_osabi): Add extern declaration.
* gdbtypes.c (make_qualified_type): Make static.
(safe_parse_type): Make static.
* macrocmd.c (_initialize_macrocmd): Add extern declaration.
* macrotab.c (macro_bcache_free): Make static.
* interps.c (interp_set_quiet): Make static.
(interpreter_exec_cmd): Make static.
* stack.h (select_frame_command): New file.
* stack.c: Include "stack.h".
(select_frame_command_wrapper): Delete function.
(select_frame_command): Make global.
* infcall.c: Include "infcall.h".
* linespec.c: Include "linespec.h".
* symfile.c (sections_overlap): Make static.
* cp-support.h (cp_initialize_namespace): ISO C declaration.
* charset.c (_initialize_charset): Add missing prototype.
* regcache.c (init_legacy_regcache_descr): Make static.
(do_regcache_xfree): Make static.
(regcache_xfer_part): Make static.
(_initialize_regcache): Add missing prototype.
* breakpoint.c (parse_breakpoint_sals): Make static.
(breakpoint_sals_to_pc): Make static.
* interps.h (clear_interpreter_hooks): ISO C declaration.
* Makefile.in (stack_h): Define.
(stack.o, typeprint.o, mi-main.o): Update dependencies.
(mi-cmd-stack.o, infcall.o, linespec.o): Update dependencies.
Index: mi/ChangeLog
2003-06-08 Andrew Cagney <cagney@redhat.com>
* mi-parse.c (_initialize_mi_parse): Delete function.
* mi-main.c: Include "mi-main.h".
* mi-interp.c (_initialize_mi_interp): Add declaration.
* mi-cmd-stack.c: Include "stack.h".
(select_frame_command_wrapper): Delete extern declaration.
(mi_cmd_stack_select_frame): Replace select_frame_command_wrapper
with select_frame_command.
2003-06-08 18:27:14 +00:00
|
|
|
static int
|
|
|
|
specialcmp (char *a, char *b)
|
2002-09-18 23:29:20 +00:00
|
|
|
{
|
|
|
|
while (*a && *a != ' ' && *a != ']' && *b && *b != ' ' && *b != ']')
|
|
|
|
{
|
|
|
|
if (*a != *b)
|
|
|
|
return *a - *b;
|
|
|
|
a++, b++;
|
|
|
|
}
|
|
|
|
if (*a && *a != ' ' && *a != ']')
|
|
|
|
return 1; /* a is longer therefore greater */
|
|
|
|
if (*b && *b != ' ' && *b != ']')
|
|
|
|
return -1; /* a is shorter therefore lesser */
|
|
|
|
return 0; /* a and b are identical */
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2002-12-03 03:52:37 +00:00
|
|
|
* Function: compare_selectors (const void *, const void *)
|
2002-09-18 23:29:20 +00:00
|
|
|
*
|
2002-09-19 00:39:38 +00:00
|
|
|
* Comparison function for use with qsort. Arguments are symbols or
|
|
|
|
* msymbols Compares selector part of objc method name alphabetically.
|
2002-09-18 23:29:20 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
static int
|
2002-12-03 03:52:37 +00:00
|
|
|
compare_selectors (const void *a, const void *b)
|
2002-09-18 23:29:20 +00:00
|
|
|
{
|
|
|
|
char *aname, *bname;
|
|
|
|
|
2003-02-20 David Carlton <carlton@math.stanford.edu>
* symtab.h (SYMBOL_PRINT_NAME): Rename from SYMBOL_SOURCE_NAME;
expand comment.
* ada-lang.c (user_select_syms, ada_finish_decode_line_1): Replace
SYMBOL_PRINT_NAME with SYMBOL_SOURCE_NAME.
* ada-typeprint.c (ada_typedef_print): Ditto.
* ax-gdb.c (gen_var_ref): Ditto.
* breakpoint.c (print_one_breakpoint): Ditto.
* buildsym.c (finish_block): Ditto.
* c-valprint.c (c_val_print): Ditto.
* expprint.c (print_subexp): Ditto.
* findvar.c (locate_var_value): Ditto.
* infcmd.c (jump_command): Ditto.
* linespec.c (decode_line_2, decode_compound): Ditto.
* maint.c (maintenance_translate_address): Ditto.
* objc-lang.c (compare_selectors, compare_classes): Ditto.
* printcmd.c (build_address_symbolic, sym_info, print_frame_args):
Ditto.
* p-valprint.c (pascal_val_print): Ditto.
* stabsread.c (define_symbol): Ditto.
* stack.c (print_frame, frame_info, print_block_frame_locals)
(print_frame_arg_vars, return_command): Ditto.
* symfile.c (compare_symbols, compare_psymbols): Ditto.
* symmisc.c (print_symbol): Ditto.
* symtab.c (lookup_partial_symbol, lookup_block_symbol)
(compare_search_syms, print_symbol_info, print_msymbol_info)
(rbreak_command): Ditto.
* tracepoint.c (tracepoints_info): Ditto.
* typeprint.c (typedef_print): Ditto.
* valops.c (value_of_variable, hand_function_call): Ditto.
* cli/cli-cmds.c (edit_command, list_command): Ditto.
* ada-typeprint.c: Update Copyright.
* infcmd.c, objc-lang.c, p-valprint.c, symmisc.c: Ditto.
* tracepoint.c, cli/cli-cmds.c: Ditto.
2003-02-20 17:17:25 +00:00
|
|
|
aname = SYMBOL_PRINT_NAME (*(struct symbol **) a);
|
|
|
|
bname = SYMBOL_PRINT_NAME (*(struct symbol **) b);
|
2002-10-04 01:18:48 +00:00
|
|
|
if (aname == NULL || bname == NULL)
|
2002-09-18 23:29:20 +00:00
|
|
|
error ("internal: compare_selectors(1)");
|
|
|
|
|
2002-10-04 01:18:48 +00:00
|
|
|
aname = strchr(aname, ' ');
|
|
|
|
bname = strchr(bname, ' ');
|
|
|
|
if (aname == NULL || bname == NULL)
|
2002-09-18 23:29:20 +00:00
|
|
|
error ("internal: compare_selectors(2)");
|
|
|
|
|
|
|
|
return specialcmp (aname+1, bname+1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Function: selectors_info (regexp, from_tty)
|
|
|
|
*
|
2002-09-19 00:39:38 +00:00
|
|
|
* Implements the "Info selectors" command. Takes an optional regexp
|
|
|
|
* arg. Lists all objective c selectors that match the regexp. Works
|
|
|
|
* by grepping thru all symbols for objective c methods. Output list
|
|
|
|
* is sorted and uniqued.
|
2002-09-18 23:29:20 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
static void
|
|
|
|
selectors_info (char *regexp, int from_tty)
|
|
|
|
{
|
|
|
|
struct objfile *objfile;
|
|
|
|
struct minimal_symbol *msymbol;
|
|
|
|
char *name;
|
|
|
|
char *val;
|
|
|
|
int matches = 0;
|
|
|
|
int maxlen = 0;
|
|
|
|
int ix;
|
|
|
|
char myregexp[2048];
|
|
|
|
char asel[256];
|
|
|
|
struct symbol **sym_arr;
|
|
|
|
int plusminus = 0;
|
|
|
|
|
|
|
|
if (regexp == NULL)
|
2002-09-19 00:39:38 +00:00
|
|
|
strcpy(myregexp, ".*]"); /* Null input, match all objc methods. */
|
2002-09-18 23:29:20 +00:00
|
|
|
else
|
|
|
|
{
|
2002-09-19 00:39:38 +00:00
|
|
|
if (*regexp == '+' || *regexp == '-')
|
|
|
|
{ /* User wants only class methods or only instance methods. */
|
2002-09-18 23:29:20 +00:00
|
|
|
plusminus = *regexp++;
|
|
|
|
while (*regexp == ' ' || *regexp == '\t')
|
|
|
|
regexp++;
|
|
|
|
}
|
|
|
|
if (*regexp == '\0')
|
|
|
|
strcpy(myregexp, ".*]");
|
|
|
|
else
|
|
|
|
{
|
|
|
|
strcpy(myregexp, regexp);
|
|
|
|
if (myregexp[strlen(myregexp) - 1] == '$') /* end of selector */
|
|
|
|
myregexp[strlen(myregexp) - 1] = ']'; /* end of method name */
|
|
|
|
else
|
|
|
|
strcat(myregexp, ".*]");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (regexp != NULL)
|
2003-04-06 19:25:04 +00:00
|
|
|
{
|
|
|
|
val = re_comp (myregexp);
|
|
|
|
if (val != 0)
|
|
|
|
error ("Invalid regexp (%s): %s", val, regexp);
|
|
|
|
}
|
2002-09-18 23:29:20 +00:00
|
|
|
|
2002-09-19 00:39:38 +00:00
|
|
|
/* First time thru is JUST to get max length and count. */
|
2002-09-18 23:29:20 +00:00
|
|
|
ALL_MSYMBOLS (objfile, msymbol)
|
|
|
|
{
|
|
|
|
QUIT;
|
2003-04-04 04:29:15 +00:00
|
|
|
name = SYMBOL_NATURAL_NAME (msymbol);
|
2002-09-18 23:29:20 +00:00
|
|
|
if (name &&
|
|
|
|
(name[0] == '-' || name[0] == '+') &&
|
2002-09-19 00:39:38 +00:00
|
|
|
name[1] == '[') /* Got a method name. */
|
2002-09-18 23:29:20 +00:00
|
|
|
{
|
2002-09-19 00:39:38 +00:00
|
|
|
/* Filter for class/instance methods. */
|
2002-09-18 23:29:20 +00:00
|
|
|
if (plusminus && name[0] != plusminus)
|
2002-09-19 00:39:38 +00:00
|
|
|
continue;
|
|
|
|
/* Find selector part. */
|
|
|
|
name = (char *) strchr(name+2, ' ');
|
2002-09-18 23:29:20 +00:00
|
|
|
if (regexp == NULL || re_exec(++name) != 0)
|
|
|
|
{
|
|
|
|
char *mystart = name;
|
|
|
|
char *myend = (char *) strchr(mystart, ']');
|
|
|
|
|
|
|
|
if (myend && (myend - mystart > maxlen))
|
2002-09-19 00:39:38 +00:00
|
|
|
maxlen = myend - mystart; /* Get longest selector. */
|
2002-09-18 23:29:20 +00:00
|
|
|
matches++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (matches)
|
|
|
|
{
|
|
|
|
printf_filtered ("Selectors matching \"%s\":\n\n",
|
|
|
|
regexp ? regexp : "*");
|
|
|
|
|
|
|
|
sym_arr = alloca (matches * sizeof (struct symbol *));
|
|
|
|
matches = 0;
|
|
|
|
ALL_MSYMBOLS (objfile, msymbol)
|
|
|
|
{
|
|
|
|
QUIT;
|
2003-04-04 04:29:15 +00:00
|
|
|
name = SYMBOL_NATURAL_NAME (msymbol);
|
2002-09-18 23:29:20 +00:00
|
|
|
if (name &&
|
|
|
|
(name[0] == '-' || name[0] == '+') &&
|
2002-09-19 00:39:38 +00:00
|
|
|
name[1] == '[') /* Got a method name. */
|
2002-09-18 23:29:20 +00:00
|
|
|
{
|
2002-09-19 00:39:38 +00:00
|
|
|
/* Filter for class/instance methods. */
|
2002-09-18 23:29:20 +00:00
|
|
|
if (plusminus && name[0] != plusminus)
|
2002-09-19 00:39:38 +00:00
|
|
|
continue;
|
|
|
|
/* Find selector part. */
|
|
|
|
name = (char *) strchr(name+2, ' ');
|
2002-09-18 23:29:20 +00:00
|
|
|
if (regexp == NULL || re_exec(++name) != 0)
|
|
|
|
sym_arr[matches++] = (struct symbol *) msymbol;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
qsort (sym_arr, matches, sizeof (struct minimal_symbol *),
|
|
|
|
compare_selectors);
|
2002-09-19 00:39:38 +00:00
|
|
|
/* Prevent compare on first iteration. */
|
|
|
|
asel[0] = 0;
|
|
|
|
for (ix = 0; ix < matches; ix++) /* Now do the output. */
|
2002-09-18 23:29:20 +00:00
|
|
|
{
|
|
|
|
char *p = asel;
|
|
|
|
|
|
|
|
QUIT;
|
2003-04-04 04:29:15 +00:00
|
|
|
name = SYMBOL_NATURAL_NAME (sym_arr[ix]);
|
2002-09-18 23:29:20 +00:00
|
|
|
name = strchr (name, ' ') + 1;
|
|
|
|
if (p[0] && specialcmp(name, p) == 0)
|
2002-09-19 00:39:38 +00:00
|
|
|
continue; /* Seen this one already (not unique). */
|
2002-09-18 23:29:20 +00:00
|
|
|
|
2002-09-19 00:39:38 +00:00
|
|
|
/* Copy selector part. */
|
|
|
|
while (*name && *name != ']')
|
2002-09-18 23:29:20 +00:00
|
|
|
*p++ = *name++;
|
|
|
|
*p++ = '\0';
|
2002-09-19 00:39:38 +00:00
|
|
|
/* Print in columns. */
|
|
|
|
puts_filtered_tabular(asel, maxlen + 1, 0);
|
2002-09-18 23:29:20 +00:00
|
|
|
}
|
|
|
|
begin_line();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
printf_filtered ("No selectors matching \"%s\"\n", regexp ? regexp : "*");
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2002-12-03 03:52:37 +00:00
|
|
|
* Function: compare_classes (const void *, const void *)
|
2002-09-18 23:29:20 +00:00
|
|
|
*
|
2002-09-19 00:39:38 +00:00
|
|
|
* Comparison function for use with qsort. Arguments are symbols or
|
|
|
|
* msymbols Compares class part of objc method name alphabetically.
|
2002-09-18 23:29:20 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
static int
|
2002-12-03 03:52:37 +00:00
|
|
|
compare_classes (const void *a, const void *b)
|
2002-09-18 23:29:20 +00:00
|
|
|
{
|
|
|
|
char *aname, *bname;
|
|
|
|
|
2003-02-20 David Carlton <carlton@math.stanford.edu>
* symtab.h (SYMBOL_PRINT_NAME): Rename from SYMBOL_SOURCE_NAME;
expand comment.
* ada-lang.c (user_select_syms, ada_finish_decode_line_1): Replace
SYMBOL_PRINT_NAME with SYMBOL_SOURCE_NAME.
* ada-typeprint.c (ada_typedef_print): Ditto.
* ax-gdb.c (gen_var_ref): Ditto.
* breakpoint.c (print_one_breakpoint): Ditto.
* buildsym.c (finish_block): Ditto.
* c-valprint.c (c_val_print): Ditto.
* expprint.c (print_subexp): Ditto.
* findvar.c (locate_var_value): Ditto.
* infcmd.c (jump_command): Ditto.
* linespec.c (decode_line_2, decode_compound): Ditto.
* maint.c (maintenance_translate_address): Ditto.
* objc-lang.c (compare_selectors, compare_classes): Ditto.
* printcmd.c (build_address_symbolic, sym_info, print_frame_args):
Ditto.
* p-valprint.c (pascal_val_print): Ditto.
* stabsread.c (define_symbol): Ditto.
* stack.c (print_frame, frame_info, print_block_frame_locals)
(print_frame_arg_vars, return_command): Ditto.
* symfile.c (compare_symbols, compare_psymbols): Ditto.
* symmisc.c (print_symbol): Ditto.
* symtab.c (lookup_partial_symbol, lookup_block_symbol)
(compare_search_syms, print_symbol_info, print_msymbol_info)
(rbreak_command): Ditto.
* tracepoint.c (tracepoints_info): Ditto.
* typeprint.c (typedef_print): Ditto.
* valops.c (value_of_variable, hand_function_call): Ditto.
* cli/cli-cmds.c (edit_command, list_command): Ditto.
* ada-typeprint.c: Update Copyright.
* infcmd.c, objc-lang.c, p-valprint.c, symmisc.c: Ditto.
* tracepoint.c, cli/cli-cmds.c: Ditto.
2003-02-20 17:17:25 +00:00
|
|
|
aname = SYMBOL_PRINT_NAME (*(struct symbol **) a);
|
|
|
|
bname = SYMBOL_PRINT_NAME (*(struct symbol **) b);
|
2002-10-04 01:18:48 +00:00
|
|
|
if (aname == NULL || bname == NULL)
|
2002-09-18 23:29:20 +00:00
|
|
|
error ("internal: compare_classes(1)");
|
|
|
|
|
|
|
|
return specialcmp (aname+1, bname+1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Function: classes_info(regexp, from_tty)
|
|
|
|
*
|
|
|
|
* Implements the "info classes" command for objective c classes.
|
|
|
|
* Lists all objective c classes that match the optional regexp.
|
2002-09-19 00:39:38 +00:00
|
|
|
* Works by grepping thru the list of objective c methods. List will
|
|
|
|
* be sorted and uniqued (since one class may have many methods).
|
|
|
|
* BUGS: will not list a class that has no methods.
|
2002-09-18 23:29:20 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
static void
|
|
|
|
classes_info (char *regexp, int from_tty)
|
|
|
|
{
|
|
|
|
struct objfile *objfile;
|
|
|
|
struct minimal_symbol *msymbol;
|
|
|
|
char *name;
|
|
|
|
char *val;
|
|
|
|
int matches = 0;
|
|
|
|
int maxlen = 0;
|
|
|
|
int ix;
|
|
|
|
char myregexp[2048];
|
|
|
|
char aclass[256];
|
|
|
|
struct symbol **sym_arr;
|
|
|
|
|
|
|
|
if (regexp == NULL)
|
2002-09-19 00:39:38 +00:00
|
|
|
strcpy(myregexp, ".* "); /* Null input: match all objc classes. */
|
2002-09-18 23:29:20 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
strcpy(myregexp, regexp);
|
|
|
|
if (myregexp[strlen(myregexp) - 1] == '$')
|
2002-09-19 00:39:38 +00:00
|
|
|
/* In the method name, the end of the class name is marked by ' '. */
|
2002-09-18 23:29:20 +00:00
|
|
|
myregexp[strlen(myregexp) - 1] = ' ';
|
|
|
|
else
|
|
|
|
strcat(myregexp, ".* ");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (regexp != NULL)
|
2003-04-06 19:25:04 +00:00
|
|
|
{
|
|
|
|
val = re_comp (myregexp);
|
|
|
|
if (val != 0)
|
|
|
|
error ("Invalid regexp (%s): %s", val, regexp);
|
|
|
|
}
|
2002-09-18 23:29:20 +00:00
|
|
|
|
2002-09-19 00:39:38 +00:00
|
|
|
/* First time thru is JUST to get max length and count. */
|
2002-09-18 23:29:20 +00:00
|
|
|
ALL_MSYMBOLS (objfile, msymbol)
|
|
|
|
{
|
|
|
|
QUIT;
|
2003-04-04 04:29:15 +00:00
|
|
|
name = SYMBOL_NATURAL_NAME (msymbol);
|
2002-09-18 23:29:20 +00:00
|
|
|
if (name &&
|
|
|
|
(name[0] == '-' || name[0] == '+') &&
|
2002-09-19 00:39:38 +00:00
|
|
|
name[1] == '[') /* Got a method name. */
|
2002-09-18 23:29:20 +00:00
|
|
|
if (regexp == NULL || re_exec(name+2) != 0)
|
|
|
|
{
|
2002-09-19 00:39:38 +00:00
|
|
|
/* Compute length of classname part. */
|
|
|
|
char *mystart = name + 2;
|
2002-09-18 23:29:20 +00:00
|
|
|
char *myend = (char *) strchr(mystart, ' ');
|
|
|
|
|
|
|
|
if (myend && (myend - mystart > maxlen))
|
|
|
|
maxlen = myend - mystart;
|
|
|
|
matches++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (matches)
|
|
|
|
{
|
|
|
|
printf_filtered ("Classes matching \"%s\":\n\n",
|
|
|
|
regexp ? regexp : "*");
|
|
|
|
sym_arr = alloca (matches * sizeof (struct symbol *));
|
|
|
|
matches = 0;
|
|
|
|
ALL_MSYMBOLS (objfile, msymbol)
|
|
|
|
{
|
|
|
|
QUIT;
|
2003-04-04 04:29:15 +00:00
|
|
|
name = SYMBOL_NATURAL_NAME (msymbol);
|
2002-09-18 23:29:20 +00:00
|
|
|
if (name &&
|
|
|
|
(name[0] == '-' || name[0] == '+') &&
|
2002-09-19 00:39:38 +00:00
|
|
|
name[1] == '[') /* Got a method name. */
|
2002-09-18 23:29:20 +00:00
|
|
|
if (regexp == NULL || re_exec(name+2) != 0)
|
|
|
|
sym_arr[matches++] = (struct symbol *) msymbol;
|
|
|
|
}
|
|
|
|
|
|
|
|
qsort (sym_arr, matches, sizeof (struct minimal_symbol *),
|
|
|
|
compare_classes);
|
2002-09-19 00:39:38 +00:00
|
|
|
/* Prevent compare on first iteration. */
|
|
|
|
aclass[0] = 0;
|
|
|
|
for (ix = 0; ix < matches; ix++) /* Now do the output. */
|
2002-09-18 23:29:20 +00:00
|
|
|
{
|
|
|
|
char *p = aclass;
|
|
|
|
|
|
|
|
QUIT;
|
2003-04-04 04:29:15 +00:00
|
|
|
name = SYMBOL_NATURAL_NAME (sym_arr[ix]);
|
2002-09-18 23:29:20 +00:00
|
|
|
name += 2;
|
|
|
|
if (p[0] && specialcmp(name, p) == 0)
|
2002-09-19 00:39:38 +00:00
|
|
|
continue; /* Seen this one already (not unique). */
|
2002-09-18 23:29:20 +00:00
|
|
|
|
2002-09-19 00:39:38 +00:00
|
|
|
/* Copy class part of method name. */
|
|
|
|
while (*name && *name != ' ')
|
2002-09-18 23:29:20 +00:00
|
|
|
*p++ = *name++;
|
|
|
|
*p++ = '\0';
|
2002-09-19 00:39:38 +00:00
|
|
|
/* Print in columns. */
|
|
|
|
puts_filtered_tabular(aclass, maxlen + 1, 0);
|
2002-09-18 23:29:20 +00:00
|
|
|
}
|
|
|
|
begin_line();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
printf_filtered ("No classes matching \"%s\"\n", regexp ? regexp : "*");
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Function: find_imps (char *selector, struct symbol **sym_arr)
|
|
|
|
*
|
|
|
|
* Input: a string representing a selector
|
|
|
|
* a pointer to an array of symbol pointers
|
|
|
|
* possibly a pointer to a symbol found by the caller.
|
|
|
|
*
|
2002-09-19 00:39:38 +00:00
|
|
|
* Output: number of methods that implement that selector. Side
|
|
|
|
* effects: The array of symbol pointers is filled with matching syms.
|
2002-09-18 23:29:20 +00:00
|
|
|
*
|
2002-09-19 00:39:38 +00:00
|
|
|
* By analogy with function "find_methods" (symtab.c), builds a list
|
|
|
|
* of symbols matching the ambiguous input, so that "decode_line_2"
|
|
|
|
* (symtab.c) can list them and ask the user to choose one or more.
|
|
|
|
* In this case the matches are objective c methods
|
|
|
|
* ("implementations") matching an objective c selector.
|
2002-09-18 23:29:20 +00:00
|
|
|
*
|
2002-09-19 00:39:38 +00:00
|
|
|
* Note that it is possible for a normal (c-style) function to have
|
|
|
|
* the same name as an objective c selector. To prevent the selector
|
|
|
|
* from eclipsing the function, we allow the caller (decode_line_1) to
|
|
|
|
* search for such a function first, and if it finds one, pass it in
|
|
|
|
* to us. We will then integrate it into the list. We also search
|
|
|
|
* for one here, among the minsyms.
|
2002-09-18 23:29:20 +00:00
|
|
|
*
|
2002-09-19 00:39:38 +00:00
|
|
|
* NOTE: if NUM_DEBUGGABLE is non-zero, the sym_arr will be divided
|
|
|
|
* into two parts: debuggable (struct symbol) syms, and
|
|
|
|
* non_debuggable (struct minimal_symbol) syms. The debuggable
|
|
|
|
* ones will come first, before NUM_DEBUGGABLE (which will thus
|
|
|
|
* be the index of the first non-debuggable one).
|
2002-09-18 23:29:20 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Function: total_number_of_imps (char *selector);
|
|
|
|
*
|
|
|
|
* Input: a string representing a selector
|
|
|
|
* Output: number of methods that implement that selector.
|
|
|
|
*
|
2002-09-19 00:39:38 +00:00
|
|
|
* By analogy with function "total_number_of_methods", this allows
|
2002-09-18 23:29:20 +00:00
|
|
|
* decode_line_1 (symtab.c) to detect if there are objective c methods
|
2002-09-19 00:39:38 +00:00
|
|
|
* matching the input, and to allocate an array of pointers to them
|
|
|
|
* which can be manipulated by "decode_line_2" (also in symtab.c).
|
2002-09-18 23:29:20 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
char *
|
|
|
|
parse_selector (char *method, char **selector)
|
|
|
|
{
|
|
|
|
char *s1 = NULL;
|
|
|
|
char *s2 = NULL;
|
|
|
|
int found_quote = 0;
|
|
|
|
|
|
|
|
char *nselector = NULL;
|
|
|
|
|
2003-05-23 16:02:30 +00:00
|
|
|
gdb_assert (selector != NULL);
|
2002-09-18 23:29:20 +00:00
|
|
|
|
|
|
|
s1 = method;
|
|
|
|
|
|
|
|
while (isspace (*s1))
|
|
|
|
s1++;
|
|
|
|
if (*s1 == '\'')
|
|
|
|
{
|
|
|
|
found_quote = 1;
|
|
|
|
s1++;
|
|
|
|
}
|
|
|
|
while (isspace (*s1))
|
|
|
|
s1++;
|
|
|
|
|
|
|
|
nselector = s1;
|
|
|
|
s2 = s1;
|
|
|
|
|
|
|
|
for (;;) {
|
|
|
|
if (isalnum (*s2) || (*s2 == '_') || (*s2 == ':'))
|
|
|
|
*s1++ = *s2;
|
|
|
|
else if (isspace (*s2))
|
|
|
|
;
|
|
|
|
else if ((*s2 == '\0') || (*s2 == '\''))
|
|
|
|
break;
|
|
|
|
else
|
|
|
|
return NULL;
|
|
|
|
s2++;
|
|
|
|
}
|
|
|
|
*s1++ = '\0';
|
|
|
|
|
|
|
|
while (isspace (*s2))
|
|
|
|
s2++;
|
|
|
|
if (found_quote)
|
|
|
|
{
|
|
|
|
if (*s2 == '\'')
|
|
|
|
s2++;
|
|
|
|
while (isspace (*s2))
|
|
|
|
s2++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (selector != NULL)
|
|
|
|
*selector = nselector;
|
|
|
|
|
|
|
|
return s2;
|
|
|
|
}
|
|
|
|
|
|
|
|
char *
|
2002-09-19 00:39:38 +00:00
|
|
|
parse_method (char *method, char *type, char **class,
|
|
|
|
char **category, char **selector)
|
2002-09-18 23:29:20 +00:00
|
|
|
{
|
|
|
|
char *s1 = NULL;
|
|
|
|
char *s2 = NULL;
|
|
|
|
int found_quote = 0;
|
|
|
|
|
|
|
|
char ntype = '\0';
|
|
|
|
char *nclass = NULL;
|
|
|
|
char *ncategory = NULL;
|
|
|
|
char *nselector = NULL;
|
|
|
|
|
2003-05-23 16:02:30 +00:00
|
|
|
gdb_assert (type != NULL);
|
|
|
|
gdb_assert (class != NULL);
|
|
|
|
gdb_assert (category != NULL);
|
|
|
|
gdb_assert (selector != NULL);
|
2002-09-18 23:29:20 +00:00
|
|
|
|
|
|
|
s1 = method;
|
|
|
|
|
|
|
|
while (isspace (*s1))
|
|
|
|
s1++;
|
|
|
|
if (*s1 == '\'')
|
|
|
|
{
|
|
|
|
found_quote = 1;
|
|
|
|
s1++;
|
|
|
|
}
|
|
|
|
while (isspace (*s1))
|
|
|
|
s1++;
|
|
|
|
|
|
|
|
if ((s1[0] == '+') || (s1[0] == '-'))
|
|
|
|
ntype = *s1++;
|
|
|
|
|
|
|
|
while (isspace (*s1))
|
|
|
|
s1++;
|
|
|
|
|
|
|
|
if (*s1 != '[')
|
|
|
|
return NULL;
|
|
|
|
s1++;
|
|
|
|
|
|
|
|
nclass = s1;
|
|
|
|
while (isalnum (*s1) || (*s1 == '_'))
|
|
|
|
s1++;
|
|
|
|
|
|
|
|
s2 = s1;
|
|
|
|
while (isspace (*s2))
|
|
|
|
s2++;
|
|
|
|
|
|
|
|
if (*s2 == '(')
|
|
|
|
{
|
|
|
|
s2++;
|
|
|
|
while (isspace (*s2))
|
|
|
|
s2++;
|
|
|
|
ncategory = s2;
|
|
|
|
while (isalnum (*s2) || (*s2 == '_'))
|
|
|
|
s2++;
|
|
|
|
*s2++ = '\0';
|
|
|
|
}
|
|
|
|
|
2002-09-19 00:39:38 +00:00
|
|
|
/* Truncate the class name now that we're not using the open paren. */
|
2002-09-18 23:29:20 +00:00
|
|
|
*s1++ = '\0';
|
|
|
|
|
|
|
|
nselector = s2;
|
|
|
|
s1 = s2;
|
|
|
|
|
|
|
|
for (;;) {
|
|
|
|
if (isalnum (*s2) || (*s2 == '_') || (*s2 == ':'))
|
|
|
|
*s1++ = *s2;
|
|
|
|
else if (isspace (*s2))
|
|
|
|
;
|
|
|
|
else if (*s2 == ']')
|
|
|
|
break;
|
|
|
|
else
|
|
|
|
return NULL;
|
|
|
|
s2++;
|
|
|
|
}
|
|
|
|
*s1++ = '\0';
|
|
|
|
s2++;
|
|
|
|
|
|
|
|
while (isspace (*s2))
|
|
|
|
s2++;
|
|
|
|
if (found_quote)
|
|
|
|
{
|
|
|
|
if (*s2 != '\'')
|
|
|
|
return NULL;
|
|
|
|
s2++;
|
|
|
|
while (isspace (*s2))
|
|
|
|
s2++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (type != NULL)
|
|
|
|
*type = ntype;
|
|
|
|
if (class != NULL)
|
|
|
|
*class = nclass;
|
|
|
|
if (category != NULL)
|
|
|
|
*category = ncategory;
|
|
|
|
if (selector != NULL)
|
|
|
|
*selector = nselector;
|
|
|
|
|
|
|
|
return s2;
|
|
|
|
}
|
|
|
|
|
2003-02-21 02:43:01 +00:00
|
|
|
static void
|
2002-09-19 00:39:38 +00:00
|
|
|
find_methods (struct symtab *symtab, char type,
|
|
|
|
const char *class, const char *category,
|
|
|
|
const char *selector, struct symbol **syms,
|
|
|
|
unsigned int *nsym, unsigned int *ndebug)
|
2002-09-18 23:29:20 +00:00
|
|
|
{
|
|
|
|
struct objfile *objfile = NULL;
|
|
|
|
struct minimal_symbol *msymbol = NULL;
|
|
|
|
struct block *block = NULL;
|
|
|
|
struct symbol *sym = NULL;
|
|
|
|
|
|
|
|
char *symname = NULL;
|
|
|
|
|
|
|
|
char ntype = '\0';
|
|
|
|
char *nclass = NULL;
|
|
|
|
char *ncategory = NULL;
|
|
|
|
char *nselector = NULL;
|
|
|
|
|
|
|
|
unsigned int csym = 0;
|
|
|
|
unsigned int cdebug = 0;
|
|
|
|
|
|
|
|
static char *tmp = NULL;
|
|
|
|
static unsigned int tmplen = 0;
|
|
|
|
|
2003-05-23 16:02:30 +00:00
|
|
|
gdb_assert (nsym != NULL);
|
|
|
|
gdb_assert (ndebug != NULL);
|
2002-09-18 23:29:20 +00:00
|
|
|
|
|
|
|
if (symtab)
|
|
|
|
block = BLOCKVECTOR_BLOCK (BLOCKVECTOR (symtab), STATIC_BLOCK);
|
|
|
|
|
|
|
|
ALL_MSYMBOLS (objfile, msymbol)
|
|
|
|
{
|
|
|
|
QUIT;
|
|
|
|
|
|
|
|
if ((msymbol->type != mst_text) && (msymbol->type != mst_file_text))
|
2002-09-19 00:39:38 +00:00
|
|
|
/* Not a function or method. */
|
2002-09-18 23:29:20 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
if (symtab)
|
2002-10-23 23:37:33 +00:00
|
|
|
if ((SYMBOL_VALUE_ADDRESS (msymbol) < BLOCK_START (block)) ||
|
|
|
|
(SYMBOL_VALUE_ADDRESS (msymbol) >= BLOCK_END (block)))
|
2002-09-19 00:39:38 +00:00
|
|
|
/* Not in the specified symtab. */
|
2002-09-18 23:29:20 +00:00
|
|
|
continue;
|
|
|
|
|
2003-04-04 04:29:15 +00:00
|
|
|
symname = SYMBOL_NATURAL_NAME (msymbol);
|
2002-09-18 23:29:20 +00:00
|
|
|
if (symname == NULL)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if ((symname[0] != '-' && symname[0] != '+') || (symname[1] != '['))
|
2002-09-19 00:39:38 +00:00
|
|
|
/* Not a method name. */
|
2002-09-18 23:29:20 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
while ((strlen (symname) + 1) >= tmplen)
|
|
|
|
{
|
|
|
|
tmplen = (tmplen == 0) ? 1024 : tmplen * 2;
|
|
|
|
tmp = xrealloc (tmp, tmplen);
|
|
|
|
}
|
|
|
|
strcpy (tmp, symname);
|
|
|
|
|
|
|
|
if (parse_method (tmp, &ntype, &nclass, &ncategory, &nselector) == NULL)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if ((type != '\0') && (ntype != type))
|
|
|
|
continue;
|
|
|
|
|
2002-09-19 00:39:38 +00:00
|
|
|
if ((class != NULL)
|
|
|
|
&& ((nclass == NULL) || (strcmp (class, nclass) != 0)))
|
2002-09-18 23:29:20 +00:00
|
|
|
continue;
|
|
|
|
|
2002-09-19 00:39:38 +00:00
|
|
|
if ((category != NULL) &&
|
|
|
|
((ncategory == NULL) || (strcmp (category, ncategory) != 0)))
|
2002-09-18 23:29:20 +00:00
|
|
|
continue;
|
|
|
|
|
2002-09-19 00:39:38 +00:00
|
|
|
if ((selector != NULL) &&
|
|
|
|
((nselector == NULL) || (strcmp (selector, nselector) != 0)))
|
2002-09-18 23:29:20 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
sym = find_pc_function (SYMBOL_VALUE_ADDRESS (msymbol));
|
|
|
|
if (sym != NULL)
|
|
|
|
{
|
2003-04-04 04:29:15 +00:00
|
|
|
const char *newsymname = SYMBOL_NATURAL_NAME (sym);
|
2002-09-18 23:29:20 +00:00
|
|
|
|
|
|
|
if (strcmp (symname, newsymname) == 0)
|
|
|
|
{
|
2002-09-19 00:39:38 +00:00
|
|
|
/* Found a high-level method sym: swap it into the
|
|
|
|
lower part of sym_arr (below num_debuggable). */
|
2002-09-18 23:29:20 +00:00
|
|
|
if (syms != NULL)
|
|
|
|
{
|
|
|
|
syms[csym] = syms[cdebug];
|
|
|
|
syms[cdebug] = sym;
|
|
|
|
}
|
|
|
|
csym++;
|
|
|
|
cdebug++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2002-09-19 00:39:38 +00:00
|
|
|
warning (
|
|
|
|
"debugging symbol \"%s\" does not match minimal symbol (\"%s\"); ignoring",
|
2002-09-18 23:29:20 +00:00
|
|
|
newsymname, symname);
|
|
|
|
if (syms != NULL)
|
|
|
|
syms[csym] = (struct symbol *) msymbol;
|
|
|
|
csym++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2002-09-19 00:39:38 +00:00
|
|
|
/* Found a non-debuggable method symbol. */
|
2002-09-18 23:29:20 +00:00
|
|
|
if (syms != NULL)
|
|
|
|
syms[csym] = (struct symbol *) msymbol;
|
|
|
|
csym++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nsym != NULL)
|
|
|
|
*nsym = csym;
|
|
|
|
if (ndebug != NULL)
|
|
|
|
*ndebug = cdebug;
|
|
|
|
}
|
|
|
|
|
|
|
|
char *find_imps (struct symtab *symtab, struct block *block,
|
2002-09-19 00:39:38 +00:00
|
|
|
char *method, struct symbol **syms,
|
|
|
|
unsigned int *nsym, unsigned int *ndebug)
|
2002-09-18 23:29:20 +00:00
|
|
|
{
|
|
|
|
char type = '\0';
|
|
|
|
char *class = NULL;
|
|
|
|
char *category = NULL;
|
|
|
|
char *selector = NULL;
|
|
|
|
|
|
|
|
unsigned int csym = 0;
|
|
|
|
unsigned int cdebug = 0;
|
|
|
|
|
|
|
|
unsigned int ncsym = 0;
|
|
|
|
unsigned int ncdebug = 0;
|
|
|
|
|
|
|
|
char *buf = NULL;
|
|
|
|
char *tmp = NULL;
|
|
|
|
|
2003-05-23 16:02:30 +00:00
|
|
|
gdb_assert (nsym != NULL);
|
|
|
|
gdb_assert (ndebug != NULL);
|
2002-09-18 23:29:20 +00:00
|
|
|
|
|
|
|
if (nsym != NULL)
|
|
|
|
*nsym = 0;
|
|
|
|
if (ndebug != NULL)
|
|
|
|
*ndebug = 0;
|
|
|
|
|
|
|
|
buf = (char *) alloca (strlen (method) + 1);
|
|
|
|
strcpy (buf, method);
|
|
|
|
tmp = parse_method (buf, &type, &class, &category, &selector);
|
|
|
|
|
|
|
|
if (tmp == NULL) {
|
|
|
|
|
|
|
|
struct symbol *sym = NULL;
|
|
|
|
struct minimal_symbol *msym = NULL;
|
|
|
|
|
|
|
|
strcpy (buf, method);
|
|
|
|
tmp = parse_selector (buf, &selector);
|
|
|
|
|
|
|
|
if (tmp == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
2003-06-02 18:08:16 +00:00
|
|
|
sym = lookup_symbol (selector, block, VAR_DOMAIN, 0, NULL);
|
2002-09-18 23:29:20 +00:00
|
|
|
if (sym != NULL)
|
|
|
|
{
|
|
|
|
if (syms)
|
|
|
|
syms[csym] = sym;
|
|
|
|
csym++;
|
|
|
|
cdebug++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sym == NULL)
|
|
|
|
msym = lookup_minimal_symbol (selector, 0, 0);
|
|
|
|
|
|
|
|
if (msym != NULL)
|
|
|
|
{
|
|
|
|
if (syms)
|
2002-12-03 03:52:37 +00:00
|
|
|
syms[csym] = (struct symbol *)msym;
|
2002-09-18 23:29:20 +00:00
|
|
|
csym++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (syms != NULL)
|
2002-09-19 00:39:38 +00:00
|
|
|
find_methods (symtab, type, class, category, selector,
|
|
|
|
syms + csym, &ncsym, &ncdebug);
|
2002-09-18 23:29:20 +00:00
|
|
|
else
|
2002-09-19 00:39:38 +00:00
|
|
|
find_methods (symtab, type, class, category, selector,
|
|
|
|
NULL, &ncsym, &ncdebug);
|
2002-09-18 23:29:20 +00:00
|
|
|
|
2002-09-19 00:39:38 +00:00
|
|
|
/* If we didn't find any methods, just return. */
|
2002-09-18 23:29:20 +00:00
|
|
|
if (ncsym == 0 && ncdebug == 0)
|
|
|
|
return method;
|
|
|
|
|
|
|
|
/* Take debug symbols from the second batch of symbols and swap them
|
|
|
|
* with debug symbols from the first batch. Repeat until either the
|
|
|
|
* second section is out of debug symbols or the first section is
|
|
|
|
* full of debug symbols. Either way we have all debug symbols
|
2002-09-19 00:39:38 +00:00
|
|
|
* packed to the beginning of the buffer.
|
|
|
|
*/
|
2002-09-18 23:29:20 +00:00
|
|
|
|
|
|
|
if (syms != NULL)
|
|
|
|
{
|
|
|
|
while ((cdebug < csym) && (ncdebug > 0))
|
|
|
|
{
|
|
|
|
struct symbol *s = NULL;
|
2002-09-19 00:39:38 +00:00
|
|
|
/* First non-debugging symbol. */
|
|
|
|
unsigned int i = cdebug;
|
|
|
|
/* Last of second batch of debug symbols. */
|
|
|
|
unsigned int j = csym + ncdebug - 1;
|
2002-09-18 23:29:20 +00:00
|
|
|
|
|
|
|
s = syms[j];
|
|
|
|
syms[j] = syms[i];
|
|
|
|
syms[i] = s;
|
|
|
|
|
2002-09-19 00:39:38 +00:00
|
|
|
/* We've moved a symbol from the second debug section to the
|
|
|
|
first one. */
|
2002-09-18 23:29:20 +00:00
|
|
|
cdebug++;
|
|
|
|
ncdebug--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
csym += ncsym;
|
|
|
|
cdebug += ncdebug;
|
|
|
|
|
|
|
|
if (nsym != NULL)
|
|
|
|
*nsym = csym;
|
|
|
|
if (ndebug != NULL)
|
|
|
|
*ndebug = cdebug;
|
|
|
|
|
|
|
|
if (syms == NULL)
|
|
|
|
return method + (tmp - buf);
|
|
|
|
|
|
|
|
if (csym > 1)
|
|
|
|
{
|
2002-09-19 00:39:38 +00:00
|
|
|
/* Sort debuggable symbols. */
|
2002-09-18 23:29:20 +00:00
|
|
|
if (cdebug > 1)
|
2002-09-19 00:39:38 +00:00
|
|
|
qsort (syms, cdebug, sizeof (struct minimal_symbol *),
|
|
|
|
compare_classes);
|
2002-09-18 23:29:20 +00:00
|
|
|
|
2002-09-19 00:39:38 +00:00
|
|
|
/* Sort minimal_symbols. */
|
2002-09-18 23:29:20 +00:00
|
|
|
if ((csym - cdebug) > 1)
|
2002-09-19 00:39:38 +00:00
|
|
|
qsort (&syms[cdebug], csym - cdebug,
|
|
|
|
sizeof (struct minimal_symbol *), compare_classes);
|
2002-09-18 23:29:20 +00:00
|
|
|
}
|
2002-09-19 00:39:38 +00:00
|
|
|
/* Terminate the sym_arr list. */
|
|
|
|
syms[csym] = 0;
|
2002-09-18 23:29:20 +00:00
|
|
|
|
|
|
|
return method + (tmp - buf);
|
|
|
|
}
|
|
|
|
|
2003-06-08 Andrew Cagney <cagney@redhat.com>
* acinclude.m4 (gcc_AC_CHECK_DECL, (gcc_AC_CHECK_DECL): Stolen
from GCC's acinclude.m4.
* configure.in: Check for getopt's delcaration.
* aclocal.m4, config.in, configure: Re-generate.
* main.c (error_init): Delete declaration.
* defs.h (error_init): Declare.
* rs6000-tdep.c (rs6000_fetch_pointer_argument): Make static.
(rs6000_convert_from_func_ptr_addr): Make static.
(_initialize_rs6000_tdep): Add declaration.
* cli/cli-cmds.c (dont_repeat): Delete declaration.
(show_commands, set_verbose, show_history): Delete declaration.
* top.h (set_verbose): Add declaration.
(show_history, set_history, show_commands): Add declaration.
(do_restore_instream_cleanup): Add declaration.
* objc-lang.c (specialcmp): Make static.
(print_object_command): Make static.
(find_objc_msgsend): Make static.
(find_objc_msgcall_submethod_helper): Make static.
(find_objc_msgcall_submethod): Make static.
(_initialize_objc_language): Add declaration.
(find_implementation_from_class): Make static.
(find_implementation): Make static.
* objc-exp.y (yylex): Delete lookup_struct_typedef declaration.
* objc-lang.h (lookup_struct_typedef): Add declaration.
* cli/cli-interp.c (_initialize_cli_interp): Add declaration.
* cli/cli-script.c (clear_hook_in_cleanup): Make static.
(do_restore_user_call_depth): Make static.
(do_restore_instream_cleanup): Delete declaration.
(dont_repeat): Delete declaration.
* cli/cli-decode.c (add_abbrev_cmd): Delete function.
* cli/cli-dump.c (_initialize_cli_dump): Add declaration.
* reggroups.c (_initialize_reggroup): Add declaration.
* cp-support.c (_initialize_cp_support): Add declaration.
* cp-abi.c (_initialize_cp_abi): Add declaration.
* hpacc-abi.c (_initialize_hpacc_abi): Add declaration.
* gnu-v3-abi.c (gnuv3_baseclass_offset): Make static.
(_initialize_gnu_v3_abi): Add declaration.
* gnu-v2-abi.c (gnuv2_value_rtti_type): Make static.
(_initialize_gnu_v2_abi): Add declaration.
* frame-base.c (_initialize_frame_base): Add declaration.
* doublest.c (floatformat_from_length): Make static.
* frame-unwind.c (_initialize_frame_unwind): Add declaration.
* frame.c (create_sentinel_frame): Make static.
(_initialize_frame): Add declaration.
* top.c (do_catch_errors): Make static.
(gdb_rl_operate_and_get_next_completion): Make static.
* typeprint.c: Include "typeprint.h".
* sentinel-frame.c (sentinel_frame_prev_register): Make static.
(sentinel_frame_this_id): Make static.
* p-valprint.c (_initialize_pascal_valprint): Add declaration.
* ui-out.c (make_cleanup_ui_out_begin_end): Delete function.
* dwarf2-frame.c (dwarf2_frame_cache): Make static.
* p-exp.y (push_current_type, pop_current_type): ISO C declaration.
* dwarf2expr.h (dwarf_expr_context): ISO C declaration.
* maint.c (maintenance_print_architecture): Make static.
* signals/signals.c (_initialize_signals): Add declaration.
* std-regs.c (_initialize_frame_reg): Add declaration.
* jv-exp.y (push_variable): ISO C definition.
(push_qualified_expression_name): Ditto.
* memattr.c (_initialize_mem): Add declaration.
* remote.c (remote_check_watch_resources): Make static.
(remote_stopped_by_watchpoint): Make static.
(remote_stopped_data_address): Make static.
* d10v-tdep.c (nr_dmap_regs): Make static.
(a0_regnum): Make static.
(d10v_frame_unwind_cache): Make static.
(d10v_frame_p): Make static.
* osabi.c (show_osabi): Make static.
(_initialize_gdb_osabi): Add extern declaration.
* gdbtypes.c (make_qualified_type): Make static.
(safe_parse_type): Make static.
* macrocmd.c (_initialize_macrocmd): Add extern declaration.
* macrotab.c (macro_bcache_free): Make static.
* interps.c (interp_set_quiet): Make static.
(interpreter_exec_cmd): Make static.
* stack.h (select_frame_command): New file.
* stack.c: Include "stack.h".
(select_frame_command_wrapper): Delete function.
(select_frame_command): Make global.
* infcall.c: Include "infcall.h".
* linespec.c: Include "linespec.h".
* symfile.c (sections_overlap): Make static.
* cp-support.h (cp_initialize_namespace): ISO C declaration.
* charset.c (_initialize_charset): Add missing prototype.
* regcache.c (init_legacy_regcache_descr): Make static.
(do_regcache_xfree): Make static.
(regcache_xfer_part): Make static.
(_initialize_regcache): Add missing prototype.
* breakpoint.c (parse_breakpoint_sals): Make static.
(breakpoint_sals_to_pc): Make static.
* interps.h (clear_interpreter_hooks): ISO C declaration.
* Makefile.in (stack_h): Define.
(stack.o, typeprint.o, mi-main.o): Update dependencies.
(mi-cmd-stack.o, infcall.o, linespec.o): Update dependencies.
Index: mi/ChangeLog
2003-06-08 Andrew Cagney <cagney@redhat.com>
* mi-parse.c (_initialize_mi_parse): Delete function.
* mi-main.c: Include "mi-main.h".
* mi-interp.c (_initialize_mi_interp): Add declaration.
* mi-cmd-stack.c: Include "stack.h".
(select_frame_command_wrapper): Delete extern declaration.
(mi_cmd_stack_select_frame): Replace select_frame_command_wrapper
with select_frame_command.
2003-06-08 18:27:14 +00:00
|
|
|
static void
|
2002-09-18 23:29:20 +00:00
|
|
|
print_object_command (char *args, int from_tty)
|
|
|
|
{
|
|
|
|
struct value *object, *function, *description;
|
2002-12-03 03:52:37 +00:00
|
|
|
CORE_ADDR string_addr, object_addr;
|
2002-09-18 23:29:20 +00:00
|
|
|
int i = 0;
|
|
|
|
char c = -1;
|
|
|
|
|
|
|
|
if (!args || !*args)
|
2002-09-19 00:39:38 +00:00
|
|
|
error (
|
|
|
|
"The 'print-object' command requires an argument (an Objective-C object)");
|
2002-09-18 23:29:20 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
struct expression *expr = parse_expression (args);
|
2003-09-09 08:05:43 +00:00
|
|
|
struct cleanup *old_chain =
|
2002-09-19 00:39:38 +00:00
|
|
|
make_cleanup (free_current_contents, &expr);
|
2002-09-18 23:29:20 +00:00
|
|
|
int pc = 0;
|
|
|
|
|
* parser-defs.h (struct exp_descriptor): New definition, containing
language-specific info for printing, prefixifying, dumping, and
evaluating expressions.
(exp_descriptor_standard): Declare new variable.
(print_subexp): Make global and declare here (from expprint.c).
(dump_subexp): Ditto.
(dump_subexp_body_standard): Declare.
(operator_length_standard): Declare.
(op_name_standard): Declare.
(print_subexp): Declare.
(print_subexp_standard): Declare.
* language.h (struct language_defn): Add la_exp_desc field to hold
pointer to table for language-specific operators.
Remove evaluate_exp field, which is now in struct exp_descriptor.
* parse.c (operator_length): Move most code to new
operator_length_standard function. Use language-specific information.
(operator_length_standard): New function taking most code from
operator_length.
(exp_descriptor_standard): New constant.
* expression.h (enum exp_opcode): Add definitions of OP_EXTENDED0
and OP_EXTENDED_LAST.
* expprint.c (print_subexp): Use language-specific print_subexp.
Make global; remove static declaration.
Move most code to print_subexp_standard.
(print_subexp_standard): New function, containing code formerly in
print_subexp.
(op_name): Add expression to argument signature.
Use langauge-specific op_name.
Move most code to op_name_standard.
(op_name_standard): New function, containing code formerly in op_name.
(dump_subexp): Use new version of op_name function.
Use language-specific dump_subexp_body, and move most existing code to
dump_subexp_body_standard.
(dump_raw_expression): Use new op_name interface.
(dump_subexp_body): Move most code to dump_subexp_body_standard.
(dump_subexp_body_standard): New function, containing code formerly
in dump_subexp_body.
* language.c (unknown_language): Add default la_exp_desc field and
remove evaluate_exp field.
(auto_language): Ditto.
(local_language): Ditto.
* f-lang.c (f_language_defn): Ditto.
* c-lang.c (c_language_defn): Ditto.
(cplus_language_defn): Ditto.
(asm_language_defn): Ditto.
(minimal_language_defn): Ditto.
* p-lang.c (pascal_language_defn): Ditto.
* m2-lang.c (m2_language_defn): Ditto.
* objc-lang.c (objc_language_defn): Ditto.
* jv-lang.c (exp_descriptor_java): New variable, containing
Java-specific expression evaluator.
(java_language_defn): Add la_exp_desc field and remove evaluate_exp
field.
* scm-lang.c (exp_descriptor_scm): New variable, containing
Scheme-specific expression evaluator.
(scm_language_defn): Add la_exp_desc field and remove evaluate_exp
field.
* objc-lang.c (print_object_command): Take evaluate_exp from the
la_exp_desc field.
* Makefile.in (eval.o): Add dependency on parser-defs.h.
* eval.c: Include parser-defs.h for the full declaration of
la_exp_desc's type.
(evaluate_subexp): Get evaluate_exp out of la_exp_desc field.
2003-09-25 08:40:45 +00:00
|
|
|
object = expr->language_defn->la_exp_desc->evaluate_exp
|
|
|
|
(builtin_type_void_data_ptr, expr, &pc, EVAL_NORMAL);
|
2002-09-18 23:29:20 +00:00
|
|
|
do_cleanups (old_chain);
|
|
|
|
}
|
|
|
|
|
2002-12-03 03:52:37 +00:00
|
|
|
/* Validate the address for sanity. */
|
|
|
|
object_addr = value_as_long (object);
|
|
|
|
read_memory (object_addr, &c, 1);
|
|
|
|
|
2002-10-04 01:18:48 +00:00
|
|
|
function = find_function_in_inferior ("_NSPrintForDebugger");
|
2002-12-03 03:52:37 +00:00
|
|
|
if (function == NULL)
|
2002-09-18 23:29:20 +00:00
|
|
|
error ("Unable to locate _NSPrintForDebugger in child process");
|
|
|
|
|
|
|
|
description = call_function_by_hand (function, 1, &object);
|
|
|
|
|
2002-10-04 01:18:48 +00:00
|
|
|
string_addr = value_as_long (description);
|
|
|
|
if (string_addr == 0)
|
2002-09-18 23:29:20 +00:00
|
|
|
error ("object returns null description");
|
|
|
|
|
|
|
|
read_memory (string_addr + i++, &c, 1);
|
|
|
|
if (c != '\0')
|
|
|
|
do
|
2002-09-19 00:39:38 +00:00
|
|
|
{ /* Read and print characters up to EOS. */
|
2002-09-18 23:29:20 +00:00
|
|
|
QUIT;
|
|
|
|
printf_filtered ("%c", c);
|
|
|
|
read_memory (string_addr + i++, &c, 1);
|
|
|
|
} while (c != 0);
|
|
|
|
else
|
|
|
|
printf_filtered("<object returns empty description>");
|
|
|
|
printf_filtered ("\n");
|
|
|
|
}
|
|
|
|
|
2002-09-19 00:39:38 +00:00
|
|
|
/* The data structure 'methcalls' is used to detect method calls (thru
|
|
|
|
* ObjC runtime lib functions objc_msgSend, objc_msgSendSuper, etc.),
|
|
|
|
* and ultimately find the method being called.
|
2002-09-18 23:29:20 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
struct objc_methcall {
|
|
|
|
char *name;
|
2002-09-19 00:39:38 +00:00
|
|
|
/* Return instance method to be called. */
|
2002-12-03 03:52:37 +00:00
|
|
|
int (*stop_at) (CORE_ADDR, CORE_ADDR *);
|
2002-09-19 00:39:38 +00:00
|
|
|
/* Start of pc range corresponding to method invocation. */
|
|
|
|
CORE_ADDR begin;
|
|
|
|
/* End of pc range corresponding to method invocation. */
|
|
|
|
CORE_ADDR end;
|
2002-09-18 23:29:20 +00:00
|
|
|
};
|
|
|
|
|
2002-09-19 00:39:38 +00:00
|
|
|
static int resolve_msgsend (CORE_ADDR pc, CORE_ADDR *new_pc);
|
|
|
|
static int resolve_msgsend_stret (CORE_ADDR pc, CORE_ADDR *new_pc);
|
|
|
|
static int resolve_msgsend_super (CORE_ADDR pc, CORE_ADDR *new_pc);
|
|
|
|
static int resolve_msgsend_super_stret (CORE_ADDR pc, CORE_ADDR *new_pc);
|
2002-09-18 23:29:20 +00:00
|
|
|
|
|
|
|
static struct objc_methcall methcalls[] = {
|
|
|
|
{ "_objc_msgSend", resolve_msgsend, 0, 0},
|
|
|
|
{ "_objc_msgSend_stret", resolve_msgsend_stret, 0, 0},
|
|
|
|
{ "_objc_msgSendSuper", resolve_msgsend_super, 0, 0},
|
|
|
|
{ "_objc_msgSendSuper_stret", resolve_msgsend_super_stret, 0, 0},
|
|
|
|
{ "_objc_getClass", NULL, 0, 0},
|
|
|
|
{ "_objc_getMetaClass", NULL, 0, 0}
|
|
|
|
};
|
|
|
|
|
|
|
|
#define nmethcalls (sizeof (methcalls) / sizeof (methcalls[0]))
|
|
|
|
|
2002-09-19 00:39:38 +00:00
|
|
|
/* The following function, "find_objc_msgsend", fills in the data
|
|
|
|
* structure "objc_msgs" by finding the addresses of each of the
|
|
|
|
* (currently four) functions that it holds (of which objc_msgSend is
|
|
|
|
* the first). This must be called each time symbols are loaded, in
|
|
|
|
* case the functions have moved for some reason.
|
2002-09-18 23:29:20 +00:00
|
|
|
*/
|
|
|
|
|
2003-06-08 Andrew Cagney <cagney@redhat.com>
* acinclude.m4 (gcc_AC_CHECK_DECL, (gcc_AC_CHECK_DECL): Stolen
from GCC's acinclude.m4.
* configure.in: Check for getopt's delcaration.
* aclocal.m4, config.in, configure: Re-generate.
* main.c (error_init): Delete declaration.
* defs.h (error_init): Declare.
* rs6000-tdep.c (rs6000_fetch_pointer_argument): Make static.
(rs6000_convert_from_func_ptr_addr): Make static.
(_initialize_rs6000_tdep): Add declaration.
* cli/cli-cmds.c (dont_repeat): Delete declaration.
(show_commands, set_verbose, show_history): Delete declaration.
* top.h (set_verbose): Add declaration.
(show_history, set_history, show_commands): Add declaration.
(do_restore_instream_cleanup): Add declaration.
* objc-lang.c (specialcmp): Make static.
(print_object_command): Make static.
(find_objc_msgsend): Make static.
(find_objc_msgcall_submethod_helper): Make static.
(find_objc_msgcall_submethod): Make static.
(_initialize_objc_language): Add declaration.
(find_implementation_from_class): Make static.
(find_implementation): Make static.
* objc-exp.y (yylex): Delete lookup_struct_typedef declaration.
* objc-lang.h (lookup_struct_typedef): Add declaration.
* cli/cli-interp.c (_initialize_cli_interp): Add declaration.
* cli/cli-script.c (clear_hook_in_cleanup): Make static.
(do_restore_user_call_depth): Make static.
(do_restore_instream_cleanup): Delete declaration.
(dont_repeat): Delete declaration.
* cli/cli-decode.c (add_abbrev_cmd): Delete function.
* cli/cli-dump.c (_initialize_cli_dump): Add declaration.
* reggroups.c (_initialize_reggroup): Add declaration.
* cp-support.c (_initialize_cp_support): Add declaration.
* cp-abi.c (_initialize_cp_abi): Add declaration.
* hpacc-abi.c (_initialize_hpacc_abi): Add declaration.
* gnu-v3-abi.c (gnuv3_baseclass_offset): Make static.
(_initialize_gnu_v3_abi): Add declaration.
* gnu-v2-abi.c (gnuv2_value_rtti_type): Make static.
(_initialize_gnu_v2_abi): Add declaration.
* frame-base.c (_initialize_frame_base): Add declaration.
* doublest.c (floatformat_from_length): Make static.
* frame-unwind.c (_initialize_frame_unwind): Add declaration.
* frame.c (create_sentinel_frame): Make static.
(_initialize_frame): Add declaration.
* top.c (do_catch_errors): Make static.
(gdb_rl_operate_and_get_next_completion): Make static.
* typeprint.c: Include "typeprint.h".
* sentinel-frame.c (sentinel_frame_prev_register): Make static.
(sentinel_frame_this_id): Make static.
* p-valprint.c (_initialize_pascal_valprint): Add declaration.
* ui-out.c (make_cleanup_ui_out_begin_end): Delete function.
* dwarf2-frame.c (dwarf2_frame_cache): Make static.
* p-exp.y (push_current_type, pop_current_type): ISO C declaration.
* dwarf2expr.h (dwarf_expr_context): ISO C declaration.
* maint.c (maintenance_print_architecture): Make static.
* signals/signals.c (_initialize_signals): Add declaration.
* std-regs.c (_initialize_frame_reg): Add declaration.
* jv-exp.y (push_variable): ISO C definition.
(push_qualified_expression_name): Ditto.
* memattr.c (_initialize_mem): Add declaration.
* remote.c (remote_check_watch_resources): Make static.
(remote_stopped_by_watchpoint): Make static.
(remote_stopped_data_address): Make static.
* d10v-tdep.c (nr_dmap_regs): Make static.
(a0_regnum): Make static.
(d10v_frame_unwind_cache): Make static.
(d10v_frame_p): Make static.
* osabi.c (show_osabi): Make static.
(_initialize_gdb_osabi): Add extern declaration.
* gdbtypes.c (make_qualified_type): Make static.
(safe_parse_type): Make static.
* macrocmd.c (_initialize_macrocmd): Add extern declaration.
* macrotab.c (macro_bcache_free): Make static.
* interps.c (interp_set_quiet): Make static.
(interpreter_exec_cmd): Make static.
* stack.h (select_frame_command): New file.
* stack.c: Include "stack.h".
(select_frame_command_wrapper): Delete function.
(select_frame_command): Make global.
* infcall.c: Include "infcall.h".
* linespec.c: Include "linespec.h".
* symfile.c (sections_overlap): Make static.
* cp-support.h (cp_initialize_namespace): ISO C declaration.
* charset.c (_initialize_charset): Add missing prototype.
* regcache.c (init_legacy_regcache_descr): Make static.
(do_regcache_xfree): Make static.
(regcache_xfer_part): Make static.
(_initialize_regcache): Add missing prototype.
* breakpoint.c (parse_breakpoint_sals): Make static.
(breakpoint_sals_to_pc): Make static.
* interps.h (clear_interpreter_hooks): ISO C declaration.
* Makefile.in (stack_h): Define.
(stack.o, typeprint.o, mi-main.o): Update dependencies.
(mi-cmd-stack.o, infcall.o, linespec.o): Update dependencies.
Index: mi/ChangeLog
2003-06-08 Andrew Cagney <cagney@redhat.com>
* mi-parse.c (_initialize_mi_parse): Delete function.
* mi-main.c: Include "mi-main.h".
* mi-interp.c (_initialize_mi_interp): Add declaration.
* mi-cmd-stack.c: Include "stack.h".
(select_frame_command_wrapper): Delete extern declaration.
(mi_cmd_stack_select_frame): Replace select_frame_command_wrapper
with select_frame_command.
2003-06-08 18:27:14 +00:00
|
|
|
static void
|
2002-09-18 23:29:20 +00:00
|
|
|
find_objc_msgsend (void)
|
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
for (i = 0; i < nmethcalls; i++) {
|
|
|
|
|
|
|
|
struct minimal_symbol *func;
|
|
|
|
|
2002-09-19 00:39:38 +00:00
|
|
|
/* Try both with and without underscore. */
|
2002-09-18 23:29:20 +00:00
|
|
|
func = lookup_minimal_symbol (methcalls[i].name, NULL, NULL);
|
|
|
|
if ((func == NULL) && (methcalls[i].name[0] == '_')) {
|
|
|
|
func = lookup_minimal_symbol (methcalls[i].name + 1, NULL, NULL);
|
|
|
|
}
|
|
|
|
if (func == NULL) {
|
|
|
|
methcalls[i].begin = 0;
|
|
|
|
methcalls[i].end = 0;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
methcalls[i].begin = SYMBOL_VALUE_ADDRESS (func);
|
|
|
|
do {
|
|
|
|
methcalls[i].end = SYMBOL_VALUE_ADDRESS (++func);
|
|
|
|
} while (methcalls[i].begin == methcalls[i].end);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* find_objc_msgcall (replaces pc_off_limits)
|
|
|
|
*
|
2002-09-19 00:39:38 +00:00
|
|
|
* ALL that this function now does is to determine whether the input
|
|
|
|
* address ("pc") is the address of one of the Objective-C message
|
2002-09-18 23:29:20 +00:00
|
|
|
* dispatch functions (mainly objc_msgSend or objc_msgSendSuper), and
|
|
|
|
* if so, it returns the address of the method that will be called.
|
|
|
|
*
|
|
|
|
* The old function "pc_off_limits" used to do a lot of other things
|
2002-09-19 00:39:38 +00:00
|
|
|
* in addition, such as detecting shared library jump stubs and
|
2002-09-18 23:29:20 +00:00
|
|
|
* returning the address of the shlib function that would be called.
|
2002-09-19 00:39:38 +00:00
|
|
|
* That functionality has been moved into the SKIP_TRAMPOLINE_CODE and
|
|
|
|
* IN_SOLIB_TRAMPOLINE macros, which are resolved in the target-
|
|
|
|
* dependent modules.
|
2002-09-18 23:29:20 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
struct objc_submethod_helper_data {
|
2002-12-03 03:52:37 +00:00
|
|
|
int (*f) (CORE_ADDR, CORE_ADDR *);
|
2002-09-18 23:29:20 +00:00
|
|
|
CORE_ADDR pc;
|
|
|
|
CORE_ADDR *new_pc;
|
|
|
|
};
|
|
|
|
|
2003-06-08 Andrew Cagney <cagney@redhat.com>
* acinclude.m4 (gcc_AC_CHECK_DECL, (gcc_AC_CHECK_DECL): Stolen
from GCC's acinclude.m4.
* configure.in: Check for getopt's delcaration.
* aclocal.m4, config.in, configure: Re-generate.
* main.c (error_init): Delete declaration.
* defs.h (error_init): Declare.
* rs6000-tdep.c (rs6000_fetch_pointer_argument): Make static.
(rs6000_convert_from_func_ptr_addr): Make static.
(_initialize_rs6000_tdep): Add declaration.
* cli/cli-cmds.c (dont_repeat): Delete declaration.
(show_commands, set_verbose, show_history): Delete declaration.
* top.h (set_verbose): Add declaration.
(show_history, set_history, show_commands): Add declaration.
(do_restore_instream_cleanup): Add declaration.
* objc-lang.c (specialcmp): Make static.
(print_object_command): Make static.
(find_objc_msgsend): Make static.
(find_objc_msgcall_submethod_helper): Make static.
(find_objc_msgcall_submethod): Make static.
(_initialize_objc_language): Add declaration.
(find_implementation_from_class): Make static.
(find_implementation): Make static.
* objc-exp.y (yylex): Delete lookup_struct_typedef declaration.
* objc-lang.h (lookup_struct_typedef): Add declaration.
* cli/cli-interp.c (_initialize_cli_interp): Add declaration.
* cli/cli-script.c (clear_hook_in_cleanup): Make static.
(do_restore_user_call_depth): Make static.
(do_restore_instream_cleanup): Delete declaration.
(dont_repeat): Delete declaration.
* cli/cli-decode.c (add_abbrev_cmd): Delete function.
* cli/cli-dump.c (_initialize_cli_dump): Add declaration.
* reggroups.c (_initialize_reggroup): Add declaration.
* cp-support.c (_initialize_cp_support): Add declaration.
* cp-abi.c (_initialize_cp_abi): Add declaration.
* hpacc-abi.c (_initialize_hpacc_abi): Add declaration.
* gnu-v3-abi.c (gnuv3_baseclass_offset): Make static.
(_initialize_gnu_v3_abi): Add declaration.
* gnu-v2-abi.c (gnuv2_value_rtti_type): Make static.
(_initialize_gnu_v2_abi): Add declaration.
* frame-base.c (_initialize_frame_base): Add declaration.
* doublest.c (floatformat_from_length): Make static.
* frame-unwind.c (_initialize_frame_unwind): Add declaration.
* frame.c (create_sentinel_frame): Make static.
(_initialize_frame): Add declaration.
* top.c (do_catch_errors): Make static.
(gdb_rl_operate_and_get_next_completion): Make static.
* typeprint.c: Include "typeprint.h".
* sentinel-frame.c (sentinel_frame_prev_register): Make static.
(sentinel_frame_this_id): Make static.
* p-valprint.c (_initialize_pascal_valprint): Add declaration.
* ui-out.c (make_cleanup_ui_out_begin_end): Delete function.
* dwarf2-frame.c (dwarf2_frame_cache): Make static.
* p-exp.y (push_current_type, pop_current_type): ISO C declaration.
* dwarf2expr.h (dwarf_expr_context): ISO C declaration.
* maint.c (maintenance_print_architecture): Make static.
* signals/signals.c (_initialize_signals): Add declaration.
* std-regs.c (_initialize_frame_reg): Add declaration.
* jv-exp.y (push_variable): ISO C definition.
(push_qualified_expression_name): Ditto.
* memattr.c (_initialize_mem): Add declaration.
* remote.c (remote_check_watch_resources): Make static.
(remote_stopped_by_watchpoint): Make static.
(remote_stopped_data_address): Make static.
* d10v-tdep.c (nr_dmap_regs): Make static.
(a0_regnum): Make static.
(d10v_frame_unwind_cache): Make static.
(d10v_frame_p): Make static.
* osabi.c (show_osabi): Make static.
(_initialize_gdb_osabi): Add extern declaration.
* gdbtypes.c (make_qualified_type): Make static.
(safe_parse_type): Make static.
* macrocmd.c (_initialize_macrocmd): Add extern declaration.
* macrotab.c (macro_bcache_free): Make static.
* interps.c (interp_set_quiet): Make static.
(interpreter_exec_cmd): Make static.
* stack.h (select_frame_command): New file.
* stack.c: Include "stack.h".
(select_frame_command_wrapper): Delete function.
(select_frame_command): Make global.
* infcall.c: Include "infcall.h".
* linespec.c: Include "linespec.h".
* symfile.c (sections_overlap): Make static.
* cp-support.h (cp_initialize_namespace): ISO C declaration.
* charset.c (_initialize_charset): Add missing prototype.
* regcache.c (init_legacy_regcache_descr): Make static.
(do_regcache_xfree): Make static.
(regcache_xfer_part): Make static.
(_initialize_regcache): Add missing prototype.
* breakpoint.c (parse_breakpoint_sals): Make static.
(breakpoint_sals_to_pc): Make static.
* interps.h (clear_interpreter_hooks): ISO C declaration.
* Makefile.in (stack_h): Define.
(stack.o, typeprint.o, mi-main.o): Update dependencies.
(mi-cmd-stack.o, infcall.o, linespec.o): Update dependencies.
Index: mi/ChangeLog
2003-06-08 Andrew Cagney <cagney@redhat.com>
* mi-parse.c (_initialize_mi_parse): Delete function.
* mi-main.c: Include "mi-main.h".
* mi-interp.c (_initialize_mi_interp): Add declaration.
* mi-cmd-stack.c: Include "stack.h".
(select_frame_command_wrapper): Delete extern declaration.
(mi_cmd_stack_select_frame): Replace select_frame_command_wrapper
with select_frame_command.
2003-06-08 18:27:14 +00:00
|
|
|
static int
|
2002-10-04 01:18:48 +00:00
|
|
|
find_objc_msgcall_submethod_helper (void * arg)
|
2002-09-18 23:29:20 +00:00
|
|
|
{
|
2002-09-19 00:39:38 +00:00
|
|
|
struct objc_submethod_helper_data *s =
|
|
|
|
(struct objc_submethod_helper_data *) arg;
|
|
|
|
|
|
|
|
if (s->f (s->pc, s->new_pc) == 0)
|
2002-09-18 23:29:20 +00:00
|
|
|
return 1;
|
2002-09-19 00:39:38 +00:00
|
|
|
else
|
2002-09-18 23:29:20 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2003-06-08 Andrew Cagney <cagney@redhat.com>
* acinclude.m4 (gcc_AC_CHECK_DECL, (gcc_AC_CHECK_DECL): Stolen
from GCC's acinclude.m4.
* configure.in: Check for getopt's delcaration.
* aclocal.m4, config.in, configure: Re-generate.
* main.c (error_init): Delete declaration.
* defs.h (error_init): Declare.
* rs6000-tdep.c (rs6000_fetch_pointer_argument): Make static.
(rs6000_convert_from_func_ptr_addr): Make static.
(_initialize_rs6000_tdep): Add declaration.
* cli/cli-cmds.c (dont_repeat): Delete declaration.
(show_commands, set_verbose, show_history): Delete declaration.
* top.h (set_verbose): Add declaration.
(show_history, set_history, show_commands): Add declaration.
(do_restore_instream_cleanup): Add declaration.
* objc-lang.c (specialcmp): Make static.
(print_object_command): Make static.
(find_objc_msgsend): Make static.
(find_objc_msgcall_submethod_helper): Make static.
(find_objc_msgcall_submethod): Make static.
(_initialize_objc_language): Add declaration.
(find_implementation_from_class): Make static.
(find_implementation): Make static.
* objc-exp.y (yylex): Delete lookup_struct_typedef declaration.
* objc-lang.h (lookup_struct_typedef): Add declaration.
* cli/cli-interp.c (_initialize_cli_interp): Add declaration.
* cli/cli-script.c (clear_hook_in_cleanup): Make static.
(do_restore_user_call_depth): Make static.
(do_restore_instream_cleanup): Delete declaration.
(dont_repeat): Delete declaration.
* cli/cli-decode.c (add_abbrev_cmd): Delete function.
* cli/cli-dump.c (_initialize_cli_dump): Add declaration.
* reggroups.c (_initialize_reggroup): Add declaration.
* cp-support.c (_initialize_cp_support): Add declaration.
* cp-abi.c (_initialize_cp_abi): Add declaration.
* hpacc-abi.c (_initialize_hpacc_abi): Add declaration.
* gnu-v3-abi.c (gnuv3_baseclass_offset): Make static.
(_initialize_gnu_v3_abi): Add declaration.
* gnu-v2-abi.c (gnuv2_value_rtti_type): Make static.
(_initialize_gnu_v2_abi): Add declaration.
* frame-base.c (_initialize_frame_base): Add declaration.
* doublest.c (floatformat_from_length): Make static.
* frame-unwind.c (_initialize_frame_unwind): Add declaration.
* frame.c (create_sentinel_frame): Make static.
(_initialize_frame): Add declaration.
* top.c (do_catch_errors): Make static.
(gdb_rl_operate_and_get_next_completion): Make static.
* typeprint.c: Include "typeprint.h".
* sentinel-frame.c (sentinel_frame_prev_register): Make static.
(sentinel_frame_this_id): Make static.
* p-valprint.c (_initialize_pascal_valprint): Add declaration.
* ui-out.c (make_cleanup_ui_out_begin_end): Delete function.
* dwarf2-frame.c (dwarf2_frame_cache): Make static.
* p-exp.y (push_current_type, pop_current_type): ISO C declaration.
* dwarf2expr.h (dwarf_expr_context): ISO C declaration.
* maint.c (maintenance_print_architecture): Make static.
* signals/signals.c (_initialize_signals): Add declaration.
* std-regs.c (_initialize_frame_reg): Add declaration.
* jv-exp.y (push_variable): ISO C definition.
(push_qualified_expression_name): Ditto.
* memattr.c (_initialize_mem): Add declaration.
* remote.c (remote_check_watch_resources): Make static.
(remote_stopped_by_watchpoint): Make static.
(remote_stopped_data_address): Make static.
* d10v-tdep.c (nr_dmap_regs): Make static.
(a0_regnum): Make static.
(d10v_frame_unwind_cache): Make static.
(d10v_frame_p): Make static.
* osabi.c (show_osabi): Make static.
(_initialize_gdb_osabi): Add extern declaration.
* gdbtypes.c (make_qualified_type): Make static.
(safe_parse_type): Make static.
* macrocmd.c (_initialize_macrocmd): Add extern declaration.
* macrotab.c (macro_bcache_free): Make static.
* interps.c (interp_set_quiet): Make static.
(interpreter_exec_cmd): Make static.
* stack.h (select_frame_command): New file.
* stack.c: Include "stack.h".
(select_frame_command_wrapper): Delete function.
(select_frame_command): Make global.
* infcall.c: Include "infcall.h".
* linespec.c: Include "linespec.h".
* symfile.c (sections_overlap): Make static.
* cp-support.h (cp_initialize_namespace): ISO C declaration.
* charset.c (_initialize_charset): Add missing prototype.
* regcache.c (init_legacy_regcache_descr): Make static.
(do_regcache_xfree): Make static.
(regcache_xfer_part): Make static.
(_initialize_regcache): Add missing prototype.
* breakpoint.c (parse_breakpoint_sals): Make static.
(breakpoint_sals_to_pc): Make static.
* interps.h (clear_interpreter_hooks): ISO C declaration.
* Makefile.in (stack_h): Define.
(stack.o, typeprint.o, mi-main.o): Update dependencies.
(mi-cmd-stack.o, infcall.o, linespec.o): Update dependencies.
Index: mi/ChangeLog
2003-06-08 Andrew Cagney <cagney@redhat.com>
* mi-parse.c (_initialize_mi_parse): Delete function.
* mi-main.c: Include "mi-main.h".
* mi-interp.c (_initialize_mi_interp): Add declaration.
* mi-cmd-stack.c: Include "stack.h".
(select_frame_command_wrapper): Delete extern declaration.
(mi_cmd_stack_select_frame): Replace select_frame_command_wrapper
with select_frame_command.
2003-06-08 18:27:14 +00:00
|
|
|
static int
|
2002-12-03 03:52:37 +00:00
|
|
|
find_objc_msgcall_submethod (int (*f) (CORE_ADDR, CORE_ADDR *),
|
2002-09-19 00:39:38 +00:00
|
|
|
CORE_ADDR pc,
|
|
|
|
CORE_ADDR *new_pc)
|
2002-09-18 23:29:20 +00:00
|
|
|
{
|
|
|
|
struct objc_submethod_helper_data s;
|
|
|
|
|
|
|
|
s.f = f;
|
|
|
|
s.pc = pc;
|
|
|
|
s.new_pc = new_pc;
|
|
|
|
|
|
|
|
if (catch_errors (find_objc_msgcall_submethod_helper,
|
2002-10-04 01:18:48 +00:00
|
|
|
(void *) &s,
|
2002-09-19 00:39:38 +00:00
|
|
|
"Unable to determine target of Objective-C method call (ignoring):\n",
|
|
|
|
RETURN_MASK_ALL) == 0)
|
2002-09-18 23:29:20 +00:00
|
|
|
return 1;
|
2002-09-19 00:39:38 +00:00
|
|
|
else
|
2002-09-18 23:29:20 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
find_objc_msgcall (CORE_ADDR pc, CORE_ADDR *new_pc)
|
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
find_objc_msgsend ();
|
2003-04-06 19:25:04 +00:00
|
|
|
if (new_pc != NULL)
|
|
|
|
{
|
|
|
|
*new_pc = 0;
|
|
|
|
}
|
2002-09-18 23:29:20 +00:00
|
|
|
|
2002-09-19 00:39:38 +00:00
|
|
|
for (i = 0; i < nmethcalls; i++)
|
|
|
|
if ((pc >= methcalls[i].begin) && (pc < methcalls[i].end))
|
|
|
|
{
|
|
|
|
if (methcalls[i].stop_at != NULL)
|
|
|
|
return find_objc_msgcall_submethod (methcalls[i].stop_at,
|
|
|
|
pc, new_pc);
|
|
|
|
else
|
|
|
|
return 0;
|
2002-09-18 23:29:20 +00:00
|
|
|
}
|
2002-09-19 00:39:38 +00:00
|
|
|
|
2002-09-18 23:29:20 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2003-06-11 13:16:30 +00:00
|
|
|
extern initialize_file_ftype _initialize_objc_language; /* -Wmissing-prototypes */
|
2003-06-08 Andrew Cagney <cagney@redhat.com>
* acinclude.m4 (gcc_AC_CHECK_DECL, (gcc_AC_CHECK_DECL): Stolen
from GCC's acinclude.m4.
* configure.in: Check for getopt's delcaration.
* aclocal.m4, config.in, configure: Re-generate.
* main.c (error_init): Delete declaration.
* defs.h (error_init): Declare.
* rs6000-tdep.c (rs6000_fetch_pointer_argument): Make static.
(rs6000_convert_from_func_ptr_addr): Make static.
(_initialize_rs6000_tdep): Add declaration.
* cli/cli-cmds.c (dont_repeat): Delete declaration.
(show_commands, set_verbose, show_history): Delete declaration.
* top.h (set_verbose): Add declaration.
(show_history, set_history, show_commands): Add declaration.
(do_restore_instream_cleanup): Add declaration.
* objc-lang.c (specialcmp): Make static.
(print_object_command): Make static.
(find_objc_msgsend): Make static.
(find_objc_msgcall_submethod_helper): Make static.
(find_objc_msgcall_submethod): Make static.
(_initialize_objc_language): Add declaration.
(find_implementation_from_class): Make static.
(find_implementation): Make static.
* objc-exp.y (yylex): Delete lookup_struct_typedef declaration.
* objc-lang.h (lookup_struct_typedef): Add declaration.
* cli/cli-interp.c (_initialize_cli_interp): Add declaration.
* cli/cli-script.c (clear_hook_in_cleanup): Make static.
(do_restore_user_call_depth): Make static.
(do_restore_instream_cleanup): Delete declaration.
(dont_repeat): Delete declaration.
* cli/cli-decode.c (add_abbrev_cmd): Delete function.
* cli/cli-dump.c (_initialize_cli_dump): Add declaration.
* reggroups.c (_initialize_reggroup): Add declaration.
* cp-support.c (_initialize_cp_support): Add declaration.
* cp-abi.c (_initialize_cp_abi): Add declaration.
* hpacc-abi.c (_initialize_hpacc_abi): Add declaration.
* gnu-v3-abi.c (gnuv3_baseclass_offset): Make static.
(_initialize_gnu_v3_abi): Add declaration.
* gnu-v2-abi.c (gnuv2_value_rtti_type): Make static.
(_initialize_gnu_v2_abi): Add declaration.
* frame-base.c (_initialize_frame_base): Add declaration.
* doublest.c (floatformat_from_length): Make static.
* frame-unwind.c (_initialize_frame_unwind): Add declaration.
* frame.c (create_sentinel_frame): Make static.
(_initialize_frame): Add declaration.
* top.c (do_catch_errors): Make static.
(gdb_rl_operate_and_get_next_completion): Make static.
* typeprint.c: Include "typeprint.h".
* sentinel-frame.c (sentinel_frame_prev_register): Make static.
(sentinel_frame_this_id): Make static.
* p-valprint.c (_initialize_pascal_valprint): Add declaration.
* ui-out.c (make_cleanup_ui_out_begin_end): Delete function.
* dwarf2-frame.c (dwarf2_frame_cache): Make static.
* p-exp.y (push_current_type, pop_current_type): ISO C declaration.
* dwarf2expr.h (dwarf_expr_context): ISO C declaration.
* maint.c (maintenance_print_architecture): Make static.
* signals/signals.c (_initialize_signals): Add declaration.
* std-regs.c (_initialize_frame_reg): Add declaration.
* jv-exp.y (push_variable): ISO C definition.
(push_qualified_expression_name): Ditto.
* memattr.c (_initialize_mem): Add declaration.
* remote.c (remote_check_watch_resources): Make static.
(remote_stopped_by_watchpoint): Make static.
(remote_stopped_data_address): Make static.
* d10v-tdep.c (nr_dmap_regs): Make static.
(a0_regnum): Make static.
(d10v_frame_unwind_cache): Make static.
(d10v_frame_p): Make static.
* osabi.c (show_osabi): Make static.
(_initialize_gdb_osabi): Add extern declaration.
* gdbtypes.c (make_qualified_type): Make static.
(safe_parse_type): Make static.
* macrocmd.c (_initialize_macrocmd): Add extern declaration.
* macrotab.c (macro_bcache_free): Make static.
* interps.c (interp_set_quiet): Make static.
(interpreter_exec_cmd): Make static.
* stack.h (select_frame_command): New file.
* stack.c: Include "stack.h".
(select_frame_command_wrapper): Delete function.
(select_frame_command): Make global.
* infcall.c: Include "infcall.h".
* linespec.c: Include "linespec.h".
* symfile.c (sections_overlap): Make static.
* cp-support.h (cp_initialize_namespace): ISO C declaration.
* charset.c (_initialize_charset): Add missing prototype.
* regcache.c (init_legacy_regcache_descr): Make static.
(do_regcache_xfree): Make static.
(regcache_xfer_part): Make static.
(_initialize_regcache): Add missing prototype.
* breakpoint.c (parse_breakpoint_sals): Make static.
(breakpoint_sals_to_pc): Make static.
* interps.h (clear_interpreter_hooks): ISO C declaration.
* Makefile.in (stack_h): Define.
(stack.o, typeprint.o, mi-main.o): Update dependencies.
(mi-cmd-stack.o, infcall.o, linespec.o): Update dependencies.
Index: mi/ChangeLog
2003-06-08 Andrew Cagney <cagney@redhat.com>
* mi-parse.c (_initialize_mi_parse): Delete function.
* mi-main.c: Include "mi-main.h".
* mi-interp.c (_initialize_mi_interp): Add declaration.
* mi-cmd-stack.c: Include "stack.h".
(select_frame_command_wrapper): Delete extern declaration.
(mi_cmd_stack_select_frame): Replace select_frame_command_wrapper
with select_frame_command.
2003-06-08 18:27:14 +00:00
|
|
|
|
2002-09-18 23:29:20 +00:00
|
|
|
void
|
|
|
|
_initialize_objc_language (void)
|
|
|
|
{
|
|
|
|
add_language (&objc_language_defn);
|
2002-09-19 00:39:38 +00:00
|
|
|
add_info ("selectors", selectors_info, /* INFO SELECTORS command. */
|
|
|
|
"All Objective-C selectors, or those matching REGEXP.");
|
|
|
|
add_info ("classes", classes_info, /* INFO CLASSES command. */
|
|
|
|
"All Objective-C classes, or those matching REGEXP.");
|
2002-09-18 23:29:20 +00:00
|
|
|
add_com ("print-object", class_vars, print_object_command,
|
2002-12-03 03:52:37 +00:00
|
|
|
"Ask an Objective-C object to print itself.");
|
2002-09-18 23:29:20 +00:00
|
|
|
add_com_alias ("po", "print-object", class_vars, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
read_objc_method (CORE_ADDR addr, struct objc_method *method)
|
|
|
|
{
|
2002-09-19 00:39:38 +00:00
|
|
|
method->name = read_memory_unsigned_integer (addr + 0, 4);
|
2002-09-18 23:29:20 +00:00
|
|
|
method->types = read_memory_unsigned_integer (addr + 4, 4);
|
2002-09-19 00:39:38 +00:00
|
|
|
method->imp = read_memory_unsigned_integer (addr + 8, 4);
|
2002-09-18 23:29:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static
|
|
|
|
unsigned long read_objc_methlist_nmethods (CORE_ADDR addr)
|
|
|
|
{
|
|
|
|
return read_memory_unsigned_integer (addr + 4, 4);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
read_objc_methlist_method (CORE_ADDR addr, unsigned long num,
|
|
|
|
struct objc_method *method)
|
|
|
|
{
|
2003-05-23 16:02:30 +00:00
|
|
|
gdb_assert (num < read_objc_methlist_nmethods (addr));
|
2002-09-18 23:29:20 +00:00
|
|
|
read_objc_method (addr + 8 + (12 * num), method);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
read_objc_object (CORE_ADDR addr, struct objc_object *object)
|
|
|
|
{
|
|
|
|
object->isa = read_memory_unsigned_integer (addr, 4);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
read_objc_super (CORE_ADDR addr, struct objc_super *super)
|
|
|
|
{
|
|
|
|
super->receiver = read_memory_unsigned_integer (addr, 4);
|
|
|
|
super->class = read_memory_unsigned_integer (addr + 4, 4);
|
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
|
|
|
read_objc_class (CORE_ADDR addr, struct objc_class *class)
|
|
|
|
{
|
|
|
|
class->isa = read_memory_unsigned_integer (addr, 4);
|
|
|
|
class->super_class = read_memory_unsigned_integer (addr + 4, 4);
|
|
|
|
class->name = read_memory_unsigned_integer (addr + 8, 4);
|
|
|
|
class->version = read_memory_unsigned_integer (addr + 12, 4);
|
|
|
|
class->info = read_memory_unsigned_integer (addr + 16, 4);
|
|
|
|
class->instance_size = read_memory_unsigned_integer (addr + 18, 4);
|
|
|
|
class->ivars = read_memory_unsigned_integer (addr + 24, 4);
|
|
|
|
class->methods = read_memory_unsigned_integer (addr + 28, 4);
|
|
|
|
class->cache = read_memory_unsigned_integer (addr + 32, 4);
|
|
|
|
class->protocols = read_memory_unsigned_integer (addr + 36, 4);
|
|
|
|
}
|
|
|
|
|
2003-06-08 Andrew Cagney <cagney@redhat.com>
* acinclude.m4 (gcc_AC_CHECK_DECL, (gcc_AC_CHECK_DECL): Stolen
from GCC's acinclude.m4.
* configure.in: Check for getopt's delcaration.
* aclocal.m4, config.in, configure: Re-generate.
* main.c (error_init): Delete declaration.
* defs.h (error_init): Declare.
* rs6000-tdep.c (rs6000_fetch_pointer_argument): Make static.
(rs6000_convert_from_func_ptr_addr): Make static.
(_initialize_rs6000_tdep): Add declaration.
* cli/cli-cmds.c (dont_repeat): Delete declaration.
(show_commands, set_verbose, show_history): Delete declaration.
* top.h (set_verbose): Add declaration.
(show_history, set_history, show_commands): Add declaration.
(do_restore_instream_cleanup): Add declaration.
* objc-lang.c (specialcmp): Make static.
(print_object_command): Make static.
(find_objc_msgsend): Make static.
(find_objc_msgcall_submethod_helper): Make static.
(find_objc_msgcall_submethod): Make static.
(_initialize_objc_language): Add declaration.
(find_implementation_from_class): Make static.
(find_implementation): Make static.
* objc-exp.y (yylex): Delete lookup_struct_typedef declaration.
* objc-lang.h (lookup_struct_typedef): Add declaration.
* cli/cli-interp.c (_initialize_cli_interp): Add declaration.
* cli/cli-script.c (clear_hook_in_cleanup): Make static.
(do_restore_user_call_depth): Make static.
(do_restore_instream_cleanup): Delete declaration.
(dont_repeat): Delete declaration.
* cli/cli-decode.c (add_abbrev_cmd): Delete function.
* cli/cli-dump.c (_initialize_cli_dump): Add declaration.
* reggroups.c (_initialize_reggroup): Add declaration.
* cp-support.c (_initialize_cp_support): Add declaration.
* cp-abi.c (_initialize_cp_abi): Add declaration.
* hpacc-abi.c (_initialize_hpacc_abi): Add declaration.
* gnu-v3-abi.c (gnuv3_baseclass_offset): Make static.
(_initialize_gnu_v3_abi): Add declaration.
* gnu-v2-abi.c (gnuv2_value_rtti_type): Make static.
(_initialize_gnu_v2_abi): Add declaration.
* frame-base.c (_initialize_frame_base): Add declaration.
* doublest.c (floatformat_from_length): Make static.
* frame-unwind.c (_initialize_frame_unwind): Add declaration.
* frame.c (create_sentinel_frame): Make static.
(_initialize_frame): Add declaration.
* top.c (do_catch_errors): Make static.
(gdb_rl_operate_and_get_next_completion): Make static.
* typeprint.c: Include "typeprint.h".
* sentinel-frame.c (sentinel_frame_prev_register): Make static.
(sentinel_frame_this_id): Make static.
* p-valprint.c (_initialize_pascal_valprint): Add declaration.
* ui-out.c (make_cleanup_ui_out_begin_end): Delete function.
* dwarf2-frame.c (dwarf2_frame_cache): Make static.
* p-exp.y (push_current_type, pop_current_type): ISO C declaration.
* dwarf2expr.h (dwarf_expr_context): ISO C declaration.
* maint.c (maintenance_print_architecture): Make static.
* signals/signals.c (_initialize_signals): Add declaration.
* std-regs.c (_initialize_frame_reg): Add declaration.
* jv-exp.y (push_variable): ISO C definition.
(push_qualified_expression_name): Ditto.
* memattr.c (_initialize_mem): Add declaration.
* remote.c (remote_check_watch_resources): Make static.
(remote_stopped_by_watchpoint): Make static.
(remote_stopped_data_address): Make static.
* d10v-tdep.c (nr_dmap_regs): Make static.
(a0_regnum): Make static.
(d10v_frame_unwind_cache): Make static.
(d10v_frame_p): Make static.
* osabi.c (show_osabi): Make static.
(_initialize_gdb_osabi): Add extern declaration.
* gdbtypes.c (make_qualified_type): Make static.
(safe_parse_type): Make static.
* macrocmd.c (_initialize_macrocmd): Add extern declaration.
* macrotab.c (macro_bcache_free): Make static.
* interps.c (interp_set_quiet): Make static.
(interpreter_exec_cmd): Make static.
* stack.h (select_frame_command): New file.
* stack.c: Include "stack.h".
(select_frame_command_wrapper): Delete function.
(select_frame_command): Make global.
* infcall.c: Include "infcall.h".
* linespec.c: Include "linespec.h".
* symfile.c (sections_overlap): Make static.
* cp-support.h (cp_initialize_namespace): ISO C declaration.
* charset.c (_initialize_charset): Add missing prototype.
* regcache.c (init_legacy_regcache_descr): Make static.
(do_regcache_xfree): Make static.
(regcache_xfer_part): Make static.
(_initialize_regcache): Add missing prototype.
* breakpoint.c (parse_breakpoint_sals): Make static.
(breakpoint_sals_to_pc): Make static.
* interps.h (clear_interpreter_hooks): ISO C declaration.
* Makefile.in (stack_h): Define.
(stack.o, typeprint.o, mi-main.o): Update dependencies.
(mi-cmd-stack.o, infcall.o, linespec.o): Update dependencies.
Index: mi/ChangeLog
2003-06-08 Andrew Cagney <cagney@redhat.com>
* mi-parse.c (_initialize_mi_parse): Delete function.
* mi-main.c: Include "mi-main.h".
* mi-interp.c (_initialize_mi_interp): Add declaration.
* mi-cmd-stack.c: Include "stack.h".
(select_frame_command_wrapper): Delete extern declaration.
(mi_cmd_stack_select_frame): Replace select_frame_command_wrapper
with select_frame_command.
2003-06-08 18:27:14 +00:00
|
|
|
static CORE_ADDR
|
2002-09-18 23:29:20 +00:00
|
|
|
find_implementation_from_class (CORE_ADDR class, CORE_ADDR sel)
|
|
|
|
{
|
|
|
|
CORE_ADDR subclass = class;
|
|
|
|
|
2002-09-19 00:39:38 +00:00
|
|
|
while (subclass != 0)
|
|
|
|
{
|
2002-09-18 23:29:20 +00:00
|
|
|
|
2002-09-19 00:39:38 +00:00
|
|
|
struct objc_class class_str;
|
|
|
|
unsigned mlistnum = 0;
|
2002-09-18 23:29:20 +00:00
|
|
|
|
2002-09-19 00:39:38 +00:00
|
|
|
read_objc_class (subclass, &class_str);
|
2002-09-18 23:29:20 +00:00
|
|
|
|
2002-09-19 00:39:38 +00:00
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
CORE_ADDR mlist;
|
|
|
|
unsigned long nmethods;
|
|
|
|
unsigned long i;
|
2002-09-18 23:29:20 +00:00
|
|
|
|
2002-09-19 00:39:38 +00:00
|
|
|
mlist = read_memory_unsigned_integer (class_str.methods +
|
|
|
|
(4 * mlistnum), 4);
|
|
|
|
if (mlist == 0)
|
|
|
|
break;
|
2002-09-18 23:29:20 +00:00
|
|
|
|
2002-09-19 00:39:38 +00:00
|
|
|
nmethods = read_objc_methlist_nmethods (mlist);
|
2002-09-18 23:29:20 +00:00
|
|
|
|
2002-09-19 00:39:38 +00:00
|
|
|
for (i = 0; i < nmethods; i++)
|
|
|
|
{
|
|
|
|
struct objc_method meth_str;
|
|
|
|
read_objc_methlist_method (mlist, i, &meth_str);
|
2002-09-18 23:29:20 +00:00
|
|
|
|
|
|
|
#if 0
|
2002-09-19 00:39:38 +00:00
|
|
|
fprintf (stderr,
|
|
|
|
"checking method 0x%lx against selector 0x%lx\n",
|
|
|
|
meth_str.name, sel);
|
2002-09-18 23:29:20 +00:00
|
|
|
#endif
|
|
|
|
|
2002-09-19 00:39:38 +00:00
|
|
|
if (meth_str.name == sel)
|
2003-05-30 02:45:21 +00:00
|
|
|
/* FIXME: hppa arch was doing a pointer dereference
|
|
|
|
here. There needs to be a better way to do that. */
|
|
|
|
return meth_str.imp;
|
2002-09-19 00:39:38 +00:00
|
|
|
}
|
|
|
|
mlistnum++;
|
2002-09-18 23:29:20 +00:00
|
|
|
}
|
2002-09-19 00:39:38 +00:00
|
|
|
subclass = class_str.super_class;
|
2002-09-18 23:29:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2003-06-08 Andrew Cagney <cagney@redhat.com>
* acinclude.m4 (gcc_AC_CHECK_DECL, (gcc_AC_CHECK_DECL): Stolen
from GCC's acinclude.m4.
* configure.in: Check for getopt's delcaration.
* aclocal.m4, config.in, configure: Re-generate.
* main.c (error_init): Delete declaration.
* defs.h (error_init): Declare.
* rs6000-tdep.c (rs6000_fetch_pointer_argument): Make static.
(rs6000_convert_from_func_ptr_addr): Make static.
(_initialize_rs6000_tdep): Add declaration.
* cli/cli-cmds.c (dont_repeat): Delete declaration.
(show_commands, set_verbose, show_history): Delete declaration.
* top.h (set_verbose): Add declaration.
(show_history, set_history, show_commands): Add declaration.
(do_restore_instream_cleanup): Add declaration.
* objc-lang.c (specialcmp): Make static.
(print_object_command): Make static.
(find_objc_msgsend): Make static.
(find_objc_msgcall_submethod_helper): Make static.
(find_objc_msgcall_submethod): Make static.
(_initialize_objc_language): Add declaration.
(find_implementation_from_class): Make static.
(find_implementation): Make static.
* objc-exp.y (yylex): Delete lookup_struct_typedef declaration.
* objc-lang.h (lookup_struct_typedef): Add declaration.
* cli/cli-interp.c (_initialize_cli_interp): Add declaration.
* cli/cli-script.c (clear_hook_in_cleanup): Make static.
(do_restore_user_call_depth): Make static.
(do_restore_instream_cleanup): Delete declaration.
(dont_repeat): Delete declaration.
* cli/cli-decode.c (add_abbrev_cmd): Delete function.
* cli/cli-dump.c (_initialize_cli_dump): Add declaration.
* reggroups.c (_initialize_reggroup): Add declaration.
* cp-support.c (_initialize_cp_support): Add declaration.
* cp-abi.c (_initialize_cp_abi): Add declaration.
* hpacc-abi.c (_initialize_hpacc_abi): Add declaration.
* gnu-v3-abi.c (gnuv3_baseclass_offset): Make static.
(_initialize_gnu_v3_abi): Add declaration.
* gnu-v2-abi.c (gnuv2_value_rtti_type): Make static.
(_initialize_gnu_v2_abi): Add declaration.
* frame-base.c (_initialize_frame_base): Add declaration.
* doublest.c (floatformat_from_length): Make static.
* frame-unwind.c (_initialize_frame_unwind): Add declaration.
* frame.c (create_sentinel_frame): Make static.
(_initialize_frame): Add declaration.
* top.c (do_catch_errors): Make static.
(gdb_rl_operate_and_get_next_completion): Make static.
* typeprint.c: Include "typeprint.h".
* sentinel-frame.c (sentinel_frame_prev_register): Make static.
(sentinel_frame_this_id): Make static.
* p-valprint.c (_initialize_pascal_valprint): Add declaration.
* ui-out.c (make_cleanup_ui_out_begin_end): Delete function.
* dwarf2-frame.c (dwarf2_frame_cache): Make static.
* p-exp.y (push_current_type, pop_current_type): ISO C declaration.
* dwarf2expr.h (dwarf_expr_context): ISO C declaration.
* maint.c (maintenance_print_architecture): Make static.
* signals/signals.c (_initialize_signals): Add declaration.
* std-regs.c (_initialize_frame_reg): Add declaration.
* jv-exp.y (push_variable): ISO C definition.
(push_qualified_expression_name): Ditto.
* memattr.c (_initialize_mem): Add declaration.
* remote.c (remote_check_watch_resources): Make static.
(remote_stopped_by_watchpoint): Make static.
(remote_stopped_data_address): Make static.
* d10v-tdep.c (nr_dmap_regs): Make static.
(a0_regnum): Make static.
(d10v_frame_unwind_cache): Make static.
(d10v_frame_p): Make static.
* osabi.c (show_osabi): Make static.
(_initialize_gdb_osabi): Add extern declaration.
* gdbtypes.c (make_qualified_type): Make static.
(safe_parse_type): Make static.
* macrocmd.c (_initialize_macrocmd): Add extern declaration.
* macrotab.c (macro_bcache_free): Make static.
* interps.c (interp_set_quiet): Make static.
(interpreter_exec_cmd): Make static.
* stack.h (select_frame_command): New file.
* stack.c: Include "stack.h".
(select_frame_command_wrapper): Delete function.
(select_frame_command): Make global.
* infcall.c: Include "infcall.h".
* linespec.c: Include "linespec.h".
* symfile.c (sections_overlap): Make static.
* cp-support.h (cp_initialize_namespace): ISO C declaration.
* charset.c (_initialize_charset): Add missing prototype.
* regcache.c (init_legacy_regcache_descr): Make static.
(do_regcache_xfree): Make static.
(regcache_xfer_part): Make static.
(_initialize_regcache): Add missing prototype.
* breakpoint.c (parse_breakpoint_sals): Make static.
(breakpoint_sals_to_pc): Make static.
* interps.h (clear_interpreter_hooks): ISO C declaration.
* Makefile.in (stack_h): Define.
(stack.o, typeprint.o, mi-main.o): Update dependencies.
(mi-cmd-stack.o, infcall.o, linespec.o): Update dependencies.
Index: mi/ChangeLog
2003-06-08 Andrew Cagney <cagney@redhat.com>
* mi-parse.c (_initialize_mi_parse): Delete function.
* mi-main.c: Include "mi-main.h".
* mi-interp.c (_initialize_mi_interp): Add declaration.
* mi-cmd-stack.c: Include "stack.h".
(select_frame_command_wrapper): Delete extern declaration.
(mi_cmd_stack_select_frame): Replace select_frame_command_wrapper
with select_frame_command.
2003-06-08 18:27:14 +00:00
|
|
|
static CORE_ADDR
|
2002-09-18 23:29:20 +00:00
|
|
|
find_implementation (CORE_ADDR object, CORE_ADDR sel)
|
|
|
|
{
|
|
|
|
struct objc_object ostr;
|
|
|
|
|
2002-09-19 00:39:38 +00:00
|
|
|
if (object == 0)
|
|
|
|
return 0;
|
2002-09-18 23:29:20 +00:00
|
|
|
read_objc_object (object, &ostr);
|
2002-09-19 00:39:38 +00:00
|
|
|
if (ostr.isa == 0)
|
|
|
|
return 0;
|
2002-09-18 23:29:20 +00:00
|
|
|
|
|
|
|
return find_implementation_from_class (ostr.isa, sel);
|
|
|
|
}
|
|
|
|
|
2003-06-08 02:31:24 +00:00
|
|
|
#define OBJC_FETCH_POINTER_ARGUMENT(argi) \
|
|
|
|
FETCH_POINTER_ARGUMENT (get_current_frame (), argi, builtin_type_void_func_ptr)
|
|
|
|
|
2002-09-18 23:29:20 +00:00
|
|
|
static int
|
|
|
|
resolve_msgsend (CORE_ADDR pc, CORE_ADDR *new_pc)
|
|
|
|
{
|
|
|
|
CORE_ADDR object;
|
|
|
|
CORE_ADDR sel;
|
|
|
|
CORE_ADDR res;
|
|
|
|
|
2003-06-08 02:31:24 +00:00
|
|
|
object = OBJC_FETCH_POINTER_ARGUMENT (0);
|
|
|
|
sel = OBJC_FETCH_POINTER_ARGUMENT (1);
|
2002-09-18 23:29:20 +00:00
|
|
|
|
|
|
|
res = find_implementation (object, sel);
|
2002-09-19 00:39:38 +00:00
|
|
|
if (new_pc != 0)
|
|
|
|
*new_pc = res;
|
|
|
|
if (res == 0)
|
|
|
|
return 1;
|
2002-09-18 23:29:20 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
resolve_msgsend_stret (CORE_ADDR pc, CORE_ADDR *new_pc)
|
|
|
|
{
|
|
|
|
CORE_ADDR object;
|
|
|
|
CORE_ADDR sel;
|
|
|
|
CORE_ADDR res;
|
|
|
|
|
2003-06-08 02:31:24 +00:00
|
|
|
object = OBJC_FETCH_POINTER_ARGUMENT (1);
|
|
|
|
sel = OBJC_FETCH_POINTER_ARGUMENT (2);
|
2002-09-18 23:29:20 +00:00
|
|
|
|
|
|
|
res = find_implementation (object, sel);
|
2002-09-19 00:39:38 +00:00
|
|
|
if (new_pc != 0)
|
|
|
|
*new_pc = res;
|
|
|
|
if (res == 0)
|
|
|
|
return 1;
|
2002-09-18 23:29:20 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
resolve_msgsend_super (CORE_ADDR pc, CORE_ADDR *new_pc)
|
|
|
|
{
|
|
|
|
struct objc_super sstr;
|
|
|
|
|
|
|
|
CORE_ADDR super;
|
|
|
|
CORE_ADDR sel;
|
|
|
|
CORE_ADDR res;
|
|
|
|
|
2003-06-08 02:31:24 +00:00
|
|
|
super = OBJC_FETCH_POINTER_ARGUMENT (0);
|
|
|
|
sel = OBJC_FETCH_POINTER_ARGUMENT (1);
|
2002-09-18 23:29:20 +00:00
|
|
|
|
|
|
|
read_objc_super (super, &sstr);
|
2002-09-19 00:39:38 +00:00
|
|
|
if (sstr.class == 0)
|
|
|
|
return 0;
|
2002-09-18 23:29:20 +00:00
|
|
|
|
|
|
|
res = find_implementation_from_class (sstr.class, sel);
|
2002-09-19 00:39:38 +00:00
|
|
|
if (new_pc != 0)
|
|
|
|
*new_pc = res;
|
|
|
|
if (res == 0)
|
|
|
|
return 1;
|
2002-09-18 23:29:20 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
resolve_msgsend_super_stret (CORE_ADDR pc, CORE_ADDR *new_pc)
|
|
|
|
{
|
|
|
|
struct objc_super sstr;
|
|
|
|
|
|
|
|
CORE_ADDR super;
|
|
|
|
CORE_ADDR sel;
|
|
|
|
CORE_ADDR res;
|
|
|
|
|
2003-06-08 02:31:24 +00:00
|
|
|
super = OBJC_FETCH_POINTER_ARGUMENT (1);
|
|
|
|
sel = OBJC_FETCH_POINTER_ARGUMENT (2);
|
2002-09-18 23:29:20 +00:00
|
|
|
|
|
|
|
read_objc_super (super, &sstr);
|
2002-09-19 00:39:38 +00:00
|
|
|
if (sstr.class == 0)
|
|
|
|
return 0;
|
2002-09-18 23:29:20 +00:00
|
|
|
|
|
|
|
res = find_implementation_from_class (sstr.class, sel);
|
2002-09-19 00:39:38 +00:00
|
|
|
if (new_pc != 0)
|
|
|
|
*new_pc = res;
|
|
|
|
if (res == 0)
|
|
|
|
return 1;
|
2002-09-18 23:29:20 +00:00
|
|
|
return 0;
|
|
|
|
}
|