X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=gdb%2Fobjc-lang.c;h=592b52e3ca2c25a39427b3dd624d3165893cd0f5;hb=65743aba62ae276dfb203e8771201e912545b0b5;hp=dc839518b2499c7abaf79af79ef38f0a324f13c7;hpb=437666f82f14bcf68b112b9882c134bde8cb98cf;p=deliverable%2Fbinutils-gdb.git
diff --git a/gdb/objc-lang.c b/gdb/objc-lang.c
index dc839518b2..592b52e3ca 100644
--- a/gdb/objc-lang.c
+++ b/gdb/objc-lang.c
@@ -1,6 +1,7 @@
/* Objective-C language support routines for GDB, the GNU debugger.
- Copyright 2002 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010, 2011
+ Free Software Foundation, Inc.
Contributed by Apple Computer, Inc.
Written by Michael Snyder.
@@ -9,7 +10,7 @@
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
+ the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
@@ -18,9 +19,7 @@
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. */
+ along with this program. If not, see . */
#include "defs.h"
#include "symtab.h"
@@ -30,17 +29,22 @@
#include "language.h"
#include "c-lang.h"
#include "objc-lang.h"
+#include "exceptions.h"
#include "complaints.h"
#include "value.h"
#include "symfile.h"
#include "objfiles.h"
-#include "string.h" /* for strchr */
+#include "gdb_string.h" /* for strchr */
#include "target.h" /* for target_has_execution */
#include "gdbcore.h"
#include "gdbcmd.h"
#include "frame.h"
#include "gdb_regex.h"
#include "regcache.h"
+#include "block.h"
+#include "infcall.h"
+#include "valprint.h"
+#include "gdb_assert.h"
#include
@@ -72,46 +76,7 @@ struct objc_method {
CORE_ADDR imp;
};
-/* Complaints about ObjC classes, selectors, etc. */
-
-static struct complaint noclass_lookup_complaint = {
- "no way to lookup Objective-C classes", 0, 0
-};
-
-static struct complaint nosel_lookup_complaint = {
- "no way to lookup Objective-C selectors", 0, 0
-};
-
-
-#if (!defined __GNUC__ || __GNUC__ < 2 || __GNUC_MINOR__ < (defined __cplusplus ? 6 : 4))
-#define __CHECK_FUNCTION ((__const char *) 0)
-#else
-#define __CHECK_FUNCTION __PRETTY_FUNCTION__
-#endif
-
-#define CHECK(expression) \
- ((void) ((expression) ? 0 : gdb_check (#expression, __FILE__, __LINE__, \
- __CHECK_FUNCTION)))
-
-#define CHECK_FATAL(expression) \
- ((void) ((expression) ? 0 : gdb_check_fatal (#expression, __FILE__, \
- __LINE__, __CHECK_FUNCTION)))
-
-static void
-gdb_check (const char *str, const char *file,
- unsigned int line, const char *func)
-{
- error ("assertion failure on line %u of \"%s\" in function \"%s\": %s\n",
- line, file, func, str);
-}
-
-static void
-gdb_check_fatal (const char *str, const char *file,
- unsigned int line, const char *func)
-{
- internal_error (file, line,
- "assertion failure in function \"%s\": %s\n", func, str);
-}
+static const struct objfile_data *objc_objfile_data;
/* Lookup a structure type named "struct NAME", visible in lexical
block BLOCK. If NOERR is nonzero, return zero if NAME is not
@@ -120,32 +85,32 @@ gdb_check_fatal (const char *str, const char *file,
struct symbol *
lookup_struct_typedef (char *name, struct block *block, int noerr)
{
- register struct symbol *sym;
+ struct symbol *sym;
- sym = lookup_symbol (name, block, STRUCT_NAMESPACE, 0,
- (struct symtab **) NULL);
+ sym = lookup_symbol (name, block, STRUCT_DOMAIN, 0);
if (sym == NULL)
{
if (noerr)
return 0;
else
- error ("No struct type named %s.", name);
+ error (_("No struct type named %s."), name);
}
if (TYPE_CODE (SYMBOL_TYPE (sym)) != TYPE_CODE_STRUCT)
{
if (noerr)
return 0;
else
- error ("This context has class, union or enum %s, not a struct.",
+ error (_("This context has class, union or enum %s, not a struct."),
name);
}
return sym;
}
CORE_ADDR
-lookup_objc_class (char *classname)
+lookup_objc_class (struct gdbarch *gdbarch, char *classname)
{
+ struct type *char_type = builtin_type (gdbarch)->builtin_char;
struct value * function, *classval;
if (! target_has_execution)
@@ -155,24 +120,26 @@ lookup_objc_class (char *classname)
}
if (lookup_minimal_symbol("objc_lookUpClass", 0, 0))
- function = find_function_in_inferior("objc_lookUpClass");
+ function = find_function_in_inferior("objc_lookUpClass", NULL);
else if (lookup_minimal_symbol ("objc_lookup_class", 0, 0))
- function = find_function_in_inferior("objc_lookup_class");
+ function = find_function_in_inferior("objc_lookup_class", NULL);
else
{
- complain (&noclass_lookup_complaint, 0);
+ complaint (&symfile_complaints,
+ _("no way to lookup Objective-C classes"));
return 0;
}
- classval = value_string (classname, strlen (classname) + 1);
+ classval = value_string (classname, strlen (classname) + 1, char_type);
classval = value_coerce_array (classval);
return (CORE_ADDR) value_as_long (call_function_by_hand (function,
1, &classval));
}
-int
-lookup_child_selector (char *selname)
+CORE_ADDR
+lookup_child_selector (struct gdbarch *gdbarch, char *selname)
{
+ struct type *char_type = builtin_type (gdbarch)->builtin_char;
struct value * function, *selstring;
if (! target_has_execution)
@@ -182,23 +149,26 @@ lookup_child_selector (char *selname)
}
if (lookup_minimal_symbol("sel_getUid", 0, 0))
- function = find_function_in_inferior("sel_getUid");
+ function = find_function_in_inferior("sel_getUid", NULL);
else if (lookup_minimal_symbol ("sel_get_any_uid", 0, 0))
- function = find_function_in_inferior("sel_get_any_uid");
+ function = find_function_in_inferior("sel_get_any_uid", NULL);
else
{
- complain (&nosel_lookup_complaint, 0);
+ complaint (&symfile_complaints,
+ _("no way to lookup Objective-C selectors"));
return 0;
}
selstring = value_coerce_array (value_string (selname,
- strlen (selname) + 1));
+ strlen (selname) + 1,
+ char_type));
return value_as_long (call_function_by_hand (function, 1, &selstring));
}
struct value *
-value_nsstring (char *ptr, int len)
+value_nsstring (struct gdbarch *gdbarch, char *ptr, int len)
{
+ struct type *char_type = builtin_type (gdbarch)->builtin_char;
struct value *stringValue[3];
struct value *function, *nsstringValue;
struct symbol *sym;
@@ -207,45 +177,50 @@ value_nsstring (char *ptr, int len)
if (!target_has_execution)
return 0; /* Can't call into inferior to create NSString. */
- if (!(sym = lookup_struct_typedef("NSString", 0, 1)) &&
- !(sym = lookup_struct_typedef("NXString", 0, 1)))
- type = lookup_pointer_type(builtin_type_void);
- else
- type = lookup_pointer_type(SYMBOL_TYPE (sym));
-
- stringValue[2] = value_string(ptr, len);
+ stringValue[2] = value_string(ptr, len, char_type);
stringValue[2] = value_coerce_array(stringValue[2]);
/* _NSNewStringFromCString replaces "istr" after Lantern2A. */
if (lookup_minimal_symbol("_NSNewStringFromCString", 0, 0))
{
- function = find_function_in_inferior("_NSNewStringFromCString");
+ function = find_function_in_inferior("_NSNewStringFromCString", NULL);
nsstringValue = call_function_by_hand(function, 1, &stringValue[2]);
}
else if (lookup_minimal_symbol("istr", 0, 0))
{
- function = find_function_in_inferior("istr");
+ function = find_function_in_inferior("istr", NULL);
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:]");
+ function
+ = find_function_in_inferior("+[NSString stringWithCString:]", NULL);
+ type = builtin_type (gdbarch)->builtin_long;
+
stringValue[0] = value_from_longest
- (builtin_type_long, lookup_objc_class ("NSString"));
+ (type, lookup_objc_class (gdbarch, "NSString"));
stringValue[1] = value_from_longest
- (builtin_type_long, lookup_child_selector ("stringWithCString:"));
+ (type, lookup_child_selector (gdbarch, "stringWithCString:"));
nsstringValue = call_function_by_hand(function, 3, &stringValue[0]);
}
else
- error ("NSString: internal error -- no way to create new NSString");
+ error (_("NSString: internal error -- no way to create new NSString"));
+
+ sym = lookup_struct_typedef("NSString", 0, 1);
+ if (sym == NULL)
+ sym = lookup_struct_typedef("NXString", 0, 1);
+ if (sym == NULL)
+ type = builtin_type (gdbarch)->builtin_data_ptr;
+ else
+ type = lookup_pointer_type(SYMBOL_TYPE (sym));
- VALUE_TYPE(nsstringValue) = type;
+ deprecated_set_value_type (nsstringValue, type);
return nsstringValue;
}
/* Objective-C name demangling. */
char *
-objc_demangle (const char *mangled)
+objc_demangle (const char *mangled, int options)
{
char *demangled, *cp;
@@ -261,38 +236,44 @@ objc_demangle (const char *mangled)
*cp++ = '+'; /* for class method */
*cp++ = '['; /* opening left brace */
- strcpy(cp, mangled+3); /* tack on the rest of the mangled name */
+ strcpy(cp, mangled+3); /* Tack on the rest of the mangled name. */
while (*cp && *cp == '_')
- cp++; /* skip any initial underbars in class name */
+ cp++; /* Skip any initial underbars in class
+ name. */
- if (!(cp = strchr(cp, '_'))) /* find first non-initial underbar */
+ cp = strchr(cp, '_');
+ if (!cp) /* Find first non-initial underbar. */
{
- free(demangled); /* not mangled name */
+ xfree(demangled); /* not mangled name */
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 */
- if (!(cp = strchr(cp, '_')))
- {
- free(demangled); /* not mangled name */
- return NULL;
- }
- *cp++ = ')';
- *cp++ = ' '; /* overwriting 1st char of method name... */
- strcpy(cp, mangled + (cp - demangled)); /* get it back */
- }
+ 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. */
+ cp = strchr(cp, '_');
+ if (!cp)
+ {
+ xfree(demangled); /* not mangled name */
+ return NULL;
+ }
+ *cp++ = ')';
+ *cp++ = ' '; /* Overwriting 1st char of method name... */
+ strcpy(cp, mangled + (cp - demangled)); /* Get it back. */
+ }
while (*cp && *cp == '_')
- cp++; /* skip any initial underbars in method name */
+ cp++; /* Skip any initial underbars in
+ method name. */
for (; *cp; cp++)
if (*cp == '_')
- *cp = ':'; /* replace remaining '_' with ':' */
+ *cp = ':'; /* Replace remaining '_' with ':'. */
*cp++ = ']'; /* closing right brace */
*cp++ = 0; /* string terminator */
@@ -307,9 +288,8 @@ objc_demangle (const char *mangled)
for printing characters and strings is language specific. */
static void
-objc_emit_char (register int c, struct ui_file *stream, int quoter)
+objc_emit_char (int c, struct type *type, struct ui_file *stream, int quoter)
{
-
c &= 0xFF; /* Avoid sign bit follies. */
if (PRINT_LITERAL_FORM (c))
@@ -353,10 +333,10 @@ objc_emit_char (register int c, struct ui_file *stream, int quoter)
}
static void
-objc_printchar (int c, struct ui_file *stream)
+objc_printchar (int c, struct type *type, struct ui_file *stream)
{
fputs_filtered ("'", stream);
- objc_emit_char (c, stream, '\'');
+ objc_emit_char (c, type, stream, '\'');
fputs_filtered ("'", stream);
}
@@ -367,16 +347,15 @@ objc_printchar (int c, struct ui_file *stream)
FORCE_ELLIPSES. */
static void
-objc_printstr (struct ui_file *stream, char *string,
- unsigned int length, int force_ellipses)
+objc_printstr (struct ui_file *stream, struct type *type,
+ const gdb_byte *string, unsigned int length,
+ const char *encoding, int force_ellipses,
+ const struct value_print_options *options)
{
- register unsigned int i;
+ unsigned int i;
unsigned int things_printed = 0;
int in_quotes = 0;
int need_comma = 0;
- extern int inspect_it;
- extern int repeat_count_threshold;
- extern int print_max;
/* If the string was not truncated due to `set print elements', and
the last byte of it is a null, we don't print that, in
@@ -390,7 +369,7 @@ objc_printstr (struct ui_file *stream, char *string,
return;
}
- for (i = 0; i < length && things_printed < print_max; ++i)
+ for (i = 0; i < length && things_printed < options->print_max; ++i)
{
/* Position of the character we are examining to see whether it
is repeated. */
@@ -414,33 +393,33 @@ objc_printstr (struct ui_file *stream, char *string,
++reps;
}
- if (reps > repeat_count_threshold)
+ if (reps > options->repeat_count_threshold)
{
if (in_quotes)
{
- if (inspect_it)
+ if (options->inspect_it)
fputs_filtered ("\\\", ", stream);
else
fputs_filtered ("\", ", stream);
in_quotes = 0;
}
- objc_printchar (string[i], stream);
+ objc_printchar (string[i], type, stream);
fprintf_filtered (stream, " ", reps);
i = rep1 - 1;
- things_printed += repeat_count_threshold;
+ things_printed += options->repeat_count_threshold;
need_comma = 1;
}
else
{
if (!in_quotes)
{
- if (inspect_it)
+ if (options->inspect_it)
fputs_filtered ("\\\"", stream);
else
fputs_filtered ("\"", stream);
in_quotes = 1;
}
- objc_emit_char (string[i], stream, '"');
+ objc_emit_char (string[i], type, stream, '"');
++things_printed;
}
}
@@ -448,7 +427,7 @@ objc_printstr (struct ui_file *stream, char *string,
/* Terminate the quotes if necessary. */
if (in_quotes)
{
- if (inspect_it)
+ if (options->inspect_it)
fputs_filtered ("\\\"", stream);
else
fputs_filtered ("\"", stream);
@@ -458,145 +437,35 @@ objc_printstr (struct ui_file *stream, char *string,
fputs_filtered ("...", stream);
}
-/* 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 */
-
-static struct type *
-objc_create_fundamental_type (struct objfile *objfile, int typeid)
+/* 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 (struct frame_info *frame, CORE_ADDR stop_pc)
{
- register struct type *type = NULL;
+ struct gdbarch *gdbarch = get_frame_arch (frame);
+ CORE_ADDR real_stop_pc;
+ CORE_ADDR method_stop_pc;
+
+ real_stop_pc = gdbarch_skip_trampoline_code (gdbarch, frame, 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);
- switch (typeid)
+ if (method_stop_pc)
{
- default:
- /* 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 "". When all the dust settles from
- the type reconstruction work, this should probably become
- an error. */
- type = init_type (TYPE_CODE_INT,
- TARGET_INT_BIT / TARGET_CHAR_BIT,
- 0, "", 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);
+ real_stop_pc = gdbarch_skip_trampoline_code
+ (gdbarch, frame, method_stop_pc);
+ if (real_stop_pc == 0)
+ real_stop_pc = method_stop_pc;
+ }
+
+ return real_stop_pc;
}
@@ -634,62 +503,50 @@ static const struct op_print objc_op_print_tab[] =
{"sizeof ", UNOP_SIZEOF, PREC_PREFIX, 0},
{"++", UNOP_PREINCREMENT, PREC_PREFIX, 0},
{"--", UNOP_PREDECREMENT, PREC_PREFIX, 0},
- {NULL, 0, 0, 0}
-};
-
-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
+ {NULL, OP_NULL, PREC_NULL, 0}
};
const struct language_defn objc_language_defn = {
"objective-c", /* Language name */
language_objc,
- objc_builtin_types,
range_check_off,
type_check_off,
case_sensitive_on,
+ array_row_major,
+ macro_expansion_c,
+ &exp_descriptor_standard,
objc_parse,
objc_error,
- evaluate_subexp_standard,
+ null_post_parser,
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_print_typedef, /* Print a typedef using appropriate syntax */
c_val_print, /* Print a value using appropriate syntax */
c_value_print, /* Print a top-level value */
- {"", "", "", ""}, /* Binary format info */
- {"0%lo", "0", "o", ""}, /* Octal format info */
- {"%ld", "", "d", ""}, /* Decimal format info */
- {"0x%lx", "0x", "x", ""}, /* Hex format info */
+ objc_skip_trampoline, /* Language specific skip_trampoline */
+ "self", /* name_of_this */
+ basic_lookup_symbol_nonlocal, /* lookup_symbol_nonlocal */
+ basic_lookup_transparent_type,/* lookup_transparent_type */
+ objc_demangle, /* Language specific symbol demangler */
+ NULL, /* Language specific
+ class_name_from_physname */
objc_op_print_tab, /* Expression operators for printing */
1, /* C-style arrays */
0, /* String lower bound */
- &builtin_type_char, /* Type of string elements */
+ default_word_break_characters,
+ default_make_symbol_completion_list,
+ c_language_arch_info,
+ default_print_array_index,
+ default_pass_by_reference,
+ default_get_string,
LANG_MAGIC
};
/*
* ObjC:
- * Following functions help construct Objective-C message calls
+ * Following functions help construct Objective-C message calls.
*/
struct selname /* For parsing Objective-C. */
@@ -706,7 +563,7 @@ static char *msglist_sel;
void
start_msglist(void)
{
- register struct selname *new =
+ struct selname *new =
(struct selname *) xmalloc (sizeof (struct selname));
new->next = selname_chain;
@@ -724,49 +581,55 @@ add_msglist(struct stoken *str, int addcolon)
char *s, *p;
int len, plen;
- if (str == 0) { /* Unnamed arg, or... */
- if (addcolon == 0) { /* variable number of args. */
- msglist_len++;
- return;
+ if (str == 0) /* Unnamed arg, or... */
+ {
+ if (addcolon == 0) /* variable number of args. */
+ {
+ msglist_len++;
+ return;
+ }
+ p = "";
+ plen = 0;
+ }
+ else
+ {
+ p = str->ptr;
+ plen = str->length;
}
- 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);
- free(msglist_sel);
+ xfree(msglist_sel);
msglist_sel = s;
- if (addcolon) {
- s[len-2] = ':';
- s[len-1] = 0;
- msglist_len++;
- } else
+ if (addcolon)
+ {
+ s[len-2] = ':';
+ s[len-1] = 0;
+ msglist_len++;
+ }
+ else
s[len-2] = '\0';
}
int
end_msglist(void)
{
- register int val = msglist_len;
- register struct selname *sel = selname_chain;
- register char *p = msglist_sel;
- int selid;
+ int val = msglist_len;
+ struct selname *sel = selname_chain;
+ char *p = msglist_sel;
+ CORE_ADDR selid;
selname_chain = sel->next;
msglist_len = sel->msglist_len;
msglist_sel = sel->msglist_sel;
- selid = lookup_child_selector(p);
+ selid = lookup_child_selector (parse_gdbarch, p);
if (!selid)
- error("Can't find selector \"%s\"", p);
+ error (_("Can't find selector \"%s\""), p);
write_exp_elt_longcst (selid);
- free(p);
+ xfree(p);
write_exp_elt_longcst (val); /* Number of args */
- free(sel);
+ xfree(sel);
return val;
}
@@ -778,7 +641,8 @@ end_msglist(void)
* Used for qsorting lists of objc methods (either by class or selector).
*/
-int specialcmp(char *a, char *b)
+static int
+specialcmp (char *a, char *b)
{
while (*a && *a != ' ' && *a != ']' && *b && *b != ' ' && *b != ']')
{
@@ -787,31 +651,33 @@ int specialcmp(char *a, char *b)
a++, b++;
}
if (*a && *a != ' ' && *a != ']')
- return 1; /* a is longer therefore greater */
+ 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 */
+ return -1; /* a is shorter therefore lesser. */
+ return 0; /* a and b are identical. */
}
/*
- * Function: compare_selectors (void *, void *)
+ * Function: compare_selectors (const void *, const void *)
*
* Comparison function for use with qsort. Arguments are symbols or
* msymbols Compares selector part of objc method name alphabetically.
*/
static int
-compare_selectors (void *a, void *b)
+compare_selectors (const void *a, const void *b)
{
char *aname, *bname;
- if ((aname = SYMBOL_SOURCE_NAME (*(struct symbol **) a)) == NULL ||
- (bname = SYMBOL_SOURCE_NAME (*(struct symbol **) b)) == NULL)
- error ("internal: compare_selectors(1)");
+ aname = SYMBOL_PRINT_NAME (*(struct symbol **) a);
+ bname = SYMBOL_PRINT_NAME (*(struct symbol **) b);
+ if (aname == NULL || bname == NULL)
+ error (_("internal: compare_selectors(1)"));
- if ((aname = strchr(aname, ' ')) == NULL ||
- (bname = strchr(bname, ' ')) == NULL)
- error ("internal: compare_selectors(2)");
+ aname = strchr(aname, ' ');
+ bname = strchr(bname, ' ');
+ if (aname == NULL || bname == NULL)
+ error (_("internal: compare_selectors(2)"));
return specialcmp (aname+1, bname+1);
}
@@ -854,6 +720,9 @@ selectors_info (char *regexp, int from_tty)
strcpy(myregexp, ".*]");
else
{
+ /* Allow a few extra bytes because of the strcat below. */
+ if (sizeof (myregexp) < strlen (regexp) + 4)
+ error (_("Regexp is too long: %s"), regexp);
strcpy(myregexp, regexp);
if (myregexp[strlen(myregexp) - 1] == '$') /* end of selector */
myregexp[strlen(myregexp) - 1] = ']'; /* end of method name */
@@ -863,28 +732,37 @@ selectors_info (char *regexp, int from_tty)
}
if (regexp != NULL)
- if (0 != (val = re_comp (myregexp)))
- error ("Invalid regexp (%s): %s", val, regexp);
+ {
+ val = re_comp (myregexp);
+ if (val != 0)
+ error (_("Invalid regexp (%s): %s"), val, regexp);
+ }
/* First time thru is JUST to get max length and count. */
ALL_MSYMBOLS (objfile, msymbol)
{
QUIT;
- if ((name = SYMBOL_DEMANGLED_NAME (msymbol)) == NULL)
- name = SYMBOL_NAME (msymbol);
- if (name &&
- (name[0] == '-' || name[0] == '+') &&
- name[1] == '[') /* Got a method name. */
+ name = SYMBOL_NATURAL_NAME (msymbol);
+ if (name
+ && (name[0] == '-' || name[0] == '+')
+ && name[1] == '[') /* Got a method name. */
{
/* Filter for class/instance methods. */
if (plusminus && name[0] != plusminus)
continue;
/* Find selector part. */
- name = (char *) strchr(name+2, ' ');
+ name = (char *) strchr (name+2, ' ');
+ if (name == NULL)
+ {
+ complaint (&symfile_complaints,
+ _("Bad method name '%s'"),
+ SYMBOL_NATURAL_NAME (msymbol));
+ continue;
+ }
if (regexp == NULL || re_exec(++name) != 0)
{
char *mystart = name;
- char *myend = (char *) strchr(mystart, ']');
+ char *myend = (char *) strchr (mystart, ']');
if (myend && (myend - mystart > maxlen))
maxlen = myend - mystart; /* Get longest selector. */
@@ -894,7 +772,7 @@ selectors_info (char *regexp, int from_tty)
}
if (matches)
{
- printf_filtered ("Selectors matching \"%s\":\n\n",
+ printf_filtered (_("Selectors matching \"%s\":\n\n"),
regexp ? regexp : "*");
sym_arr = alloca (matches * sizeof (struct symbol *));
@@ -902,8 +780,7 @@ selectors_info (char *regexp, int from_tty)
ALL_MSYMBOLS (objfile, msymbol)
{
QUIT;
- if ((name = SYMBOL_DEMANGLED_NAME (msymbol)) == NULL)
- name = SYMBOL_NAME (msymbol);
+ name = SYMBOL_NATURAL_NAME (msymbol);
if (name &&
(name[0] == '-' || name[0] == '+') &&
name[1] == '[') /* Got a method name. */
@@ -927,8 +804,7 @@ selectors_info (char *regexp, int from_tty)
char *p = asel;
QUIT;
- if ((name = SYMBOL_DEMANGLED_NAME (sym_arr[ix])) == NULL)
- name = SYMBOL_NAME (sym_arr[ix]);
+ name = SYMBOL_NATURAL_NAME (sym_arr[ix]);
name = strchr (name, ' ') + 1;
if (p[0] && specialcmp(name, p) == 0)
continue; /* Seen this one already (not unique). */
@@ -943,24 +819,26 @@ selectors_info (char *regexp, int from_tty)
begin_line();
}
else
- printf_filtered ("No selectors matching \"%s\"\n", regexp ? regexp : "*");
+ printf_filtered (_("No selectors matching \"%s\"\n"),
+ regexp ? regexp : "*");
}
/*
- * Function: compare_classes (void *, void *)
+ * Function: compare_classes (const void *, const void *)
*
* Comparison function for use with qsort. Arguments are symbols or
* msymbols Compares class part of objc method name alphabetically.
*/
static int
-compare_classes (void *a, void *b)
+compare_classes (const void *a, const void *b)
{
char *aname, *bname;
- if ((aname = SYMBOL_SOURCE_NAME (*(struct symbol **) a)) == NULL ||
- (bname = SYMBOL_SOURCE_NAME (*(struct symbol **) b)) == NULL)
- error ("internal: compare_classes(1)");
+ aname = SYMBOL_PRINT_NAME (*(struct symbol **) a);
+ bname = SYMBOL_PRINT_NAME (*(struct symbol **) b);
+ if (aname == NULL || bname == NULL)
+ error (_("internal: compare_classes(1)"));
return specialcmp (aname+1, bname+1);
}
@@ -993,6 +871,9 @@ classes_info (char *regexp, int from_tty)
strcpy(myregexp, ".* "); /* Null input: match all objc classes. */
else
{
+ /* Allow a few extra bytes because of the strcat below. */
+ if (sizeof (myregexp) < strlen (regexp) + 4)
+ error (_("Regexp is too long: %s"), regexp);
strcpy(myregexp, regexp);
if (myregexp[strlen(myregexp) - 1] == '$')
/* In the method name, the end of the class name is marked by ' '. */
@@ -1002,15 +883,17 @@ classes_info (char *regexp, int from_tty)
}
if (regexp != NULL)
- if (0 != (val = re_comp (myregexp)))
- error ("Invalid regexp (%s): %s", val, regexp);
+ {
+ val = re_comp (myregexp);
+ if (val != 0)
+ error (_("Invalid regexp (%s): %s"), val, regexp);
+ }
/* First time thru is JUST to get max length and count. */
ALL_MSYMBOLS (objfile, msymbol)
{
QUIT;
- if ((name = SYMBOL_DEMANGLED_NAME (msymbol)) == NULL)
- name = SYMBOL_NAME (msymbol);
+ name = SYMBOL_NATURAL_NAME (msymbol);
if (name &&
(name[0] == '-' || name[0] == '+') &&
name[1] == '[') /* Got a method name. */
@@ -1027,15 +910,14 @@ classes_info (char *regexp, int from_tty)
}
if (matches)
{
- printf_filtered ("Classes matching \"%s\":\n\n",
+ printf_filtered (_("Classes matching \"%s\":\n\n"),
regexp ? regexp : "*");
sym_arr = alloca (matches * sizeof (struct symbol *));
matches = 0;
ALL_MSYMBOLS (objfile, msymbol)
{
QUIT;
- if ((name = SYMBOL_DEMANGLED_NAME (msymbol)) == NULL)
- name = SYMBOL_NAME (msymbol);
+ name = SYMBOL_NATURAL_NAME (msymbol);
if (name &&
(name[0] == '-' || name[0] == '+') &&
name[1] == '[') /* Got a method name. */
@@ -1052,8 +934,7 @@ classes_info (char *regexp, int from_tty)
char *p = aclass;
QUIT;
- if ((name = SYMBOL_DEMANGLED_NAME (sym_arr[ix])) == NULL)
- name = SYMBOL_NAME (sym_arr[ix]);
+ name = SYMBOL_NATURAL_NAME (sym_arr[ix]);
name += 2;
if (p[0] && specialcmp(name, p) == 0)
continue; /* Seen this one already (not unique). */
@@ -1068,7 +949,7 @@ classes_info (char *regexp, int from_tty)
begin_line();
}
else
- printf_filtered ("No classes matching \"%s\"\n", regexp ? regexp : "*");
+ printf_filtered (_("No classes matching \"%s\"\n"), regexp ? regexp : "*");
}
/*
@@ -1098,7 +979,7 @@ classes_info (char *regexp, int from_tty)
* 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).
+ * be the index of the first non-debuggable one).
*/
/*
@@ -1122,7 +1003,7 @@ parse_selector (char *method, char **selector)
char *nselector = NULL;
- CHECK (selector != NULL);
+ gdb_assert (selector != NULL);
s1 = method;
@@ -1139,17 +1020,18 @@ parse_selector (char *method, char **selector)
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++;
- }
+ 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))
@@ -1181,10 +1063,10 @@ parse_method (char *method, char *type, char **class,
char *ncategory = NULL;
char *nselector = NULL;
- CHECK (type != NULL);
- CHECK (class != NULL);
- CHECK (category != NULL);
- CHECK (selector != NULL);
+ gdb_assert (type != NULL);
+ gdb_assert (class != NULL);
+ gdb_assert (category != NULL);
+ gdb_assert (selector != NULL);
s1 = method;
@@ -1233,17 +1115,18 @@ parse_method (char *method, char *type, char **class,
nselector = s2;
s1 = s2;
- for (;;) {
- if (isalnum (*s2) || (*s2 == '_') || (*s2 == ':'))
- *s1++ = *s2;
- else if (isspace (*s2))
- ;
- else if (*s2 == ']')
- break;
- else
- return NULL;
- s2++;
- }
+ for (;;)
+ {
+ if (isalnum (*s2) || (*s2 == '_') || (*s2 == ':'))
+ *s1++ = *s2;
+ else if (isspace (*s2))
+ ;
+ else if (*s2 == ']')
+ break;
+ else
+ return NULL;
+ s2++;
+ }
*s1++ = '\0';
s2++;
@@ -1270,7 +1153,7 @@ parse_method (char *method, char *type, char **class,
return s2;
}
-void
+static void
find_methods (struct symtab *symtab, char type,
const char *class, const char *category,
const char *selector, struct symbol **syms,
@@ -1294,97 +1177,129 @@ find_methods (struct symtab *symtab, char type,
static char *tmp = NULL;
static unsigned int tmplen = 0;
- CHECK (nsym != NULL);
- CHECK (ndebug != NULL);
+ gdb_assert (nsym != NULL);
+ gdb_assert (ndebug != NULL);
if (symtab)
block = BLOCKVECTOR_BLOCK (BLOCKVECTOR (symtab), STATIC_BLOCK);
- ALL_MSYMBOLS (objfile, msymbol)
+ ALL_OBJFILES (objfile)
{
- QUIT;
+ unsigned int *objc_csym;
- if ((msymbol->type != mst_text) && (msymbol->type != mst_file_text))
- /* Not a function or method. */
- continue;
+ /* The objfile_csym variable counts the number of ObjC methods
+ that this objfile defines. We save that count as a private
+ objfile data. If we have already determined that this objfile
+ provides no ObjC methods, we can skip it entirely. */
- if (symtab)
- if ((SYMBOL_VALUE_ADDRESS (msymbol) < block->startaddr) ||
- (SYMBOL_VALUE_ADDRESS (msymbol) >= block->endaddr))
- /* Not in the specified symtab. */
- continue;
+ unsigned int objfile_csym = 0;
- symname = SYMBOL_DEMANGLED_NAME (msymbol);
- if (symname == NULL)
- symname = SYMBOL_NAME (msymbol);
- if (symname == NULL)
+ objc_csym = objfile_data (objfile, objc_objfile_data);
+ if (objc_csym != NULL && *objc_csym == 0)
+ /* There are no ObjC symbols in this objfile. Skip it entirely. */
continue;
- if ((symname[0] != '-' && symname[0] != '+') || (symname[1] != '['))
- /* Not a method name. */
- continue;
-
- while ((strlen (symname) + 1) >= tmplen)
+ ALL_OBJFILE_MSYMBOLS (objfile, msymbol)
{
- tmplen = (tmplen == 0) ? 1024 : tmplen * 2;
- tmp = xrealloc (tmp, tmplen);
- }
- strcpy (tmp, symname);
+ struct gdbarch *gdbarch = get_objfile_arch (objfile);
+ CORE_ADDR pc = SYMBOL_VALUE_ADDRESS (msymbol);
- if (parse_method (tmp, &ntype, &nclass, &ncategory, &nselector) == NULL)
- continue;
-
- if ((type != '\0') && (ntype != type))
- continue;
+ QUIT;
- if ((class != NULL)
- && ((nclass == NULL) || (strcmp (class, nclass) != 0)))
- continue;
+ /* Check the symbol name first as this can be done entirely without
+ sending any query to the target. */
+ symname = SYMBOL_NATURAL_NAME (msymbol);
+ if (symname == NULL)
+ continue;
- if ((category != NULL) &&
- ((ncategory == NULL) || (strcmp (category, ncategory) != 0)))
- continue;
+ if ((symname[0] != '-' && symname[0] != '+') || (symname[1] != '['))
+ /* Not a method name. */
+ continue;
- if ((selector != NULL) &&
- ((nselector == NULL) || (strcmp (selector, nselector) != 0)))
- continue;
+ /* The minimal symbol might point to a function descriptor;
+ resolve it to the actual code address instead. */
+ pc = gdbarch_convert_from_func_ptr_addr (gdbarch, pc,
+ ¤t_target);
+
+ objfile_csym++;
+
+ if (symtab)
+ if (pc < BLOCK_START (block) || pc >= BLOCK_END (block))
+ /* Not in the specified symtab. */
+ continue;
+
+ /* Now that thinks are a bit sane, clean up the symname. */
+ 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;
- sym = find_pc_function (SYMBOL_VALUE_ADDRESS (msymbol));
- if (sym != NULL)
- {
- const char *newsymname = SYMBOL_DEMANGLED_NAME (sym);
+ if ((class != NULL)
+ && ((nclass == NULL) || (strcmp (class, nclass) != 0)))
+ continue;
+
+ if ((category != NULL) &&
+ ((ncategory == NULL) || (strcmp (category, ncategory) != 0)))
+ continue;
+
+ if ((selector != NULL) &&
+ ((nselector == NULL) || (strcmp (selector, nselector) != 0)))
+ continue;
+
+ sym = find_pc_function (pc);
+ if (sym != NULL)
+ {
+ const char *newsymname = SYMBOL_NATURAL_NAME (sym);
- if (newsymname == NULL)
- newsymname = SYMBOL_NAME (sym);
- if (strcmp (symname, newsymname) == 0)
- {
- /* Found a high-level method sym: swap it into the
- lower part of sym_arr (below num_debuggable). */
- if (syms != NULL)
- {
- syms[csym] = syms[cdebug];
- syms[cdebug] = sym;
- }
- csym++;
- cdebug++;
- }
- else
- {
- warning (
+ if (strcmp (symname, newsymname) == 0)
+ {
+ /* Found a high-level method sym: swap it into the
+ lower part of sym_arr (below num_debuggable). */
+ if (syms != NULL)
+ {
+ syms[csym] = syms[cdebug];
+ syms[cdebug] = sym;
+ }
+ csym++;
+ cdebug++;
+ }
+ else
+ {
+ warning (
"debugging symbol \"%s\" does not match minimal symbol (\"%s\"); ignoring",
- newsymname, symname);
- if (syms != NULL)
- syms[csym] = (struct symbol *) msymbol;
- csym++;
- }
- }
- else
+ newsymname, symname);
+ if (syms != NULL)
+ syms[csym] = (struct symbol *) msymbol;
+ csym++;
+ }
+ }
+ else
+ {
+ /* Found a non-debuggable method symbol. */
+ if (syms != NULL)
+ syms[csym] = (struct symbol *) msymbol;
+ csym++;
+ }
+ }
+ if (objc_csym == NULL)
{
- /* Found a non-debuggable method symbol. */
- if (syms != NULL)
- syms[csym] = (struct symbol *) msymbol;
- csym++;
+ objc_csym = obstack_alloc (&objfile->objfile_obstack,
+ sizeof (*objc_csym));
+ *objc_csym = objfile_csym;
+ set_objfile_data (objfile, objc_objfile_data, objc_csym);
}
+ else
+ /* Count of ObjC methods in this objfile should be constant. */
+ gdb_assert (*objc_csym == objfile_csym);
}
if (nsym != NULL)
@@ -1411,8 +1326,8 @@ char *find_imps (struct symtab *symtab, struct block *block,
char *buf = NULL;
char *tmp = NULL;
- CHECK (nsym != NULL);
- CHECK (ndebug != NULL);
+ gdb_assert (nsym != NULL);
+ gdb_assert (ndebug != NULL);
if (nsym != NULL)
*nsym = 0;
@@ -1423,37 +1338,36 @@ char *find_imps (struct symtab *symtab, struct block *block,
strcpy (buf, method);
tmp = parse_method (buf, &type, &class, &category, &selector);
- if (tmp == NULL) {
-
- struct symtab *sym_symtab = NULL;
- struct symbol *sym = NULL;
- struct minimal_symbol *msym = NULL;
-
- strcpy (buf, method);
- tmp = parse_selector (buf, &selector);
-
- if (tmp == NULL)
- return NULL;
-
- sym = lookup_symbol (selector, block, VAR_NAMESPACE, 0, &sym_symtab);
- if (sym != NULL)
- {
- if (syms)
- syms[csym] = sym;
- csym++;
- cdebug++;
- }
+ if (tmp == NULL)
+ {
+ struct symbol *sym = NULL;
+ struct minimal_symbol *msym = NULL;
- if (sym == NULL)
- msym = lookup_minimal_symbol (selector, 0, 0);
+ strcpy (buf, method);
+ tmp = parse_selector (buf, &selector);
- if (msym != NULL)
- {
- if (syms)
- syms[csym] = msym;
- csym++;
- }
- }
+ if (tmp == NULL)
+ return NULL;
+
+ sym = lookup_symbol (selector, block, VAR_DOMAIN, 0);
+ 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)
+ syms[csym] = (struct symbol *)msym;
+ csym++;
+ }
+ }
if (syms != NULL)
find_methods (symtab, type, class, category, selector,
@@ -1470,7 +1384,7 @@ char *find_imps (struct symtab *symtab, struct block *block,
* 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
- * packed to the beginning of the buffer.
+ * packed to the beginning of the buffer.
*/
if (syms != NULL)
@@ -1523,13 +1437,13 @@ char *find_imps (struct symtab *symtab, struct block *block,
return method + (tmp - buf);
}
-void
+static void
print_object_command (char *args, int from_tty)
{
struct value *object, *function, *description;
- CORE_ADDR string_addr;
+ CORE_ADDR string_addr, object_addr;
int i = 0;
- char c = -1;
+ gdb_byte c = 0;
if (!args || !*args)
error (
@@ -1537,30 +1451,31 @@ print_object_command (char *args, int from_tty)
{
struct expression *expr = parse_expression (args);
- register struct cleanup *old_chain =
+ struct cleanup *old_chain =
make_cleanup (free_current_contents, &expr);
int pc = 0;
-#if 1
- object = expr->language_defn->evaluate_exp (builtin_type_void_data_ptr,
- expr, &pc, EVAL_NORMAL);
-#else
- object = evaluate_subexp (builtin_type_void_data_ptr,
+ object = evaluate_subexp (builtin_type (expr->gdbarch)->builtin_data_ptr,
expr, &pc, EVAL_NORMAL);
-#endif
do_cleanups (old_chain);
}
- if (!(function = find_function_in_inferior ("_NSPrintForDebugger")))
- error ("Unable to locate _NSPrintForDebugger in child process");
+ /* Validate the address for sanity. */
+ object_addr = value_as_long (object);
+ read_memory (object_addr, &c, 1);
+
+ function = find_function_in_inferior ("_NSPrintForDebugger", NULL);
+ if (function == NULL)
+ error (_("Unable to locate _NSPrintForDebugger in child process"));
description = call_function_by_hand (function, 1, &object);
- if ((string_addr = value_as_long (description)) == 0)
- error ("object returns null description");
+ string_addr = value_as_long (description);
+ if (string_addr == 0)
+ error (_("object returns null description"));
read_memory (string_addr + i++, &c, 1);
- if (c != '\0')
+ if (c != 0)
do
{ /* Read and print characters up to EOS. */
QUIT;
@@ -1568,19 +1483,19 @@ print_object_command (char *args, int from_tty)
read_memory (string_addr + i++, &c, 1);
} while (c != 0);
else
- printf_filtered("