/* Objective-C language support routines for GDB, the GNU debugger.
- Copyright (C) 2002-2015 Free Software Foundation, Inc.
+ Copyright (C) 2002-2018 Free Software Foundation, Inc.
Contributed by Apple Computer, Inc.
Written by Michael Snyder.
suitably defined. */
struct symbol *
-lookup_struct_typedef (char *name, const struct block *block, int noerr)
+lookup_struct_typedef (const char *name, const struct block *block, int noerr)
{
struct symbol *sym;
}
CORE_ADDR
-lookup_objc_class (struct gdbarch *gdbarch, char *classname)
+lookup_objc_class (struct gdbarch *gdbarch, const char *classname)
{
struct type *char_type = builtin_type (gdbarch)->builtin_char;
struct value * function, *classval;
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,
+ return (CORE_ADDR) value_as_long (call_function_by_hand (function,
+ NULL,
1, &classval));
}
CORE_ADDR
-lookup_child_selector (struct gdbarch *gdbarch, char *selname)
+lookup_child_selector (struct gdbarch *gdbarch, const char *selname)
{
struct type *char_type = builtin_type (gdbarch)->builtin_char;
struct value * function, *selstring;
selstring = value_coerce_array (value_string (selname,
strlen (selname) + 1,
char_type));
- return value_as_long (call_function_by_hand (function, 1, &selstring));
+ return value_as_long (call_function_by_hand (function, NULL, 1, &selstring));
}
struct value *
if (lookup_minimal_symbol("_NSNewStringFromCString", 0, 0).minsym)
{
function = find_function_in_inferior("_NSNewStringFromCString", NULL);
- nsstringValue = call_function_by_hand(function, 1, &stringValue[2]);
+ nsstringValue = call_function_by_hand(function,
+ NULL, 1, &stringValue[2]);
}
else if (lookup_minimal_symbol("istr", 0, 0).minsym)
{
function = find_function_in_inferior("istr", NULL);
- nsstringValue = call_function_by_hand(function, 1, &stringValue[2]);
+ nsstringValue = call_function_by_hand(function, NULL, 1, &stringValue[2]);
}
else if (lookup_minimal_symbol("+[NSString stringWithCString:]", 0, 0).minsym)
{
(type, lookup_objc_class (gdbarch, "NSString"));
stringValue[1] = value_from_longest
(type, lookup_child_selector (gdbarch, "stringWithCString:"));
- nsstringValue = call_function_by_hand(function, 3, &stringValue[0]);
+ nsstringValue = call_function_by_hand(function, NULL, 3, &stringValue[0]);
}
else
error (_("NSString: internal error -- no way to create new NSString"));
(mangled[1] == 'i' || mangled[1] == 'c') &&
mangled[2] == '_')
{
- cp = demangled = xmalloc(strlen(mangled) + 2);
+ cp = demangled = (char *) xmalloc (strlen (mangled) + 2);
if (mangled[1] == 'i')
*cp++ = '-'; /* for instance method */
return NULL; /* Not an objc mangled name. */
}
+/* la_sniff_from_mangled_name for ObjC. */
+
+static int
+objc_sniff_from_mangled_name (const char *mangled, char **demangled)
+{
+ *demangled = objc_demangle (mangled, 0);
+ return *demangled != NULL;
+}
+
/* 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
{NULL, OP_NULL, PREC_NULL, 0}
};
-const struct language_defn objc_language_defn = {
+static const char *objc_extensions[] =
+{
+ ".m", NULL
+};
+
+extern const struct language_defn objc_language_defn = {
"objective-c", /* Language name */
"Objective-C",
language_objc,
case_sensitive_on,
array_row_major,
macro_expansion_c,
+ objc_extensions,
&exp_descriptor_standard,
c_parse,
- c_error,
+ c_yyerror,
null_post_parser,
c_printchar, /* Print a character constant */
c_printstr, /* Function to print string constant */
basic_lookup_symbol_nonlocal, /* lookup_symbol_nonlocal */
basic_lookup_transparent_type,/* lookup_transparent_type */
objc_demangle, /* Language specific symbol demangler */
+ objc_sniff_from_mangled_name,
NULL, /* Language specific
class_name_from_physname */
objc_op_print_tab, /* Expression operators for printing */
1, /* C-style arrays */
0, /* String lower bound */
default_word_break_characters,
- default_make_symbol_completion_list,
+ default_collect_symbol_completion_matches,
c_language_arch_info,
default_print_array_index,
default_pass_by_reference,
default_get_string,
- NULL, /* la_get_symbol_name_cmp */
+ c_watch_location_expression,
+ NULL, /* la_get_symbol_name_matcher */
iterate_over_symbols,
+ default_search_name_hash,
&default_varobj_ops,
NULL,
NULL,
*/
static void
-selectors_info (char *regexp, int from_tty)
+info_selectors_command (const char *regexp, int from_tty)
{
struct objfile *objfile;
struct minimal_symbol *msymbol;
*/
static void
-classes_info (char *regexp, int from_tty)
+info_classes_command (const char *regexp, int from_tty)
{
struct objfile *objfile;
struct minimal_symbol *msymbol;
unsigned int objfile_csym = 0;
- objc_csym = objfile_data (objfile, objc_objfile_data);
+ objc_csym = (unsigned int *) 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;
while ((strlen (symname) + 1) >= tmplen)
{
tmplen = (tmplen == 0) ? 1024 : tmplen * 2;
- tmp = xrealloc (tmp, tmplen);
+ tmp = (char *) xrealloc (tmp, tmplen);
}
strcpy (tmp, symname);
}
static void
-print_object_command (char *args, int from_tty)
+print_object_command (const char *args, int from_tty)
{
struct value *object, *function, *description;
CORE_ADDR string_addr, object_addr;
"The 'print-object' command requires an argument (an Objective-C object)");
{
- struct expression *expr = parse_expression (args);
- struct cleanup *old_chain =
- make_cleanup (free_current_contents, &expr);
+ expression_up expr = parse_expression (args);
int pc = 0;
object = evaluate_subexp (builtin_type (expr->gdbarch)->builtin_data_ptr,
- expr, &pc, EVAL_NORMAL);
- do_cleanups (old_chain);
+ expr.get (), &pc, EVAL_NORMAL);
}
/* Validate the address for sanity. */
if (function == NULL)
error (_("Unable to locate _NSPrintForDebugger in child process"));
- description = call_function_by_hand (function, 1, &object);
+ description = call_function_by_hand (function, NULL, 1, &object);
string_addr = value_as_long (description);
if (string_addr == 0)
*/
struct objc_methcall {
- char *name;
+ const char *name;
/* Return instance method to be called. */
int (*stop_at) (CORE_ADDR, CORE_ADDR *);
/* Start of pc range corresponding to method invocation. */
* dependent modules.
*/
-struct objc_submethod_helper_data {
- int (*f) (CORE_ADDR, CORE_ADDR *);
- CORE_ADDR pc;
- CORE_ADDR *new_pc;
-};
-
-static int
-find_objc_msgcall_submethod_helper (void * arg)
-{
- struct objc_submethod_helper_data *s =
- (struct objc_submethod_helper_data *) arg;
-
- if (s->f (s->pc, s->new_pc) == 0)
- return 1;
- else
- return 0;
-}
-
static int
find_objc_msgcall_submethod (int (*f) (CORE_ADDR, CORE_ADDR *),
CORE_ADDR pc,
CORE_ADDR *new_pc)
{
- struct objc_submethod_helper_data s;
-
- s.f = f;
- s.pc = pc;
- s.new_pc = new_pc;
+ TRY
+ {
+ if (f (pc, new_pc) == 0)
+ return 1;
+ }
+ CATCH (ex, RETURN_MASK_ALL)
+ {
+ exception_fprintf (gdb_stderr, ex,
+ "Unable to determine target of "
+ "Objective-C method call (ignoring):\n");
+ }
+ END_CATCH
- if (catch_errors (find_objc_msgcall_submethod_helper,
- (void *) &s,
- "Unable to determine target of "
- "Objective-C method call (ignoring):\n",
- RETURN_MASK_ALL) == 0)
- return 1;
- else
- return 0;
+ return 0;
}
int
return 0;
}
-/* -Wmissing-prototypes */
-extern initialize_file_ftype _initialize_objc_language;
-
void
_initialize_objc_language (void)
{
- add_language (&objc_language_defn);
- add_info ("selectors", selectors_info, /* INFO SELECTORS command. */
+ add_info ("selectors", info_selectors_command,
_("All Objective-C selectors, or those matching REGEXP."));
- add_info ("classes", classes_info, /* INFO CLASSES command. */
+ add_info ("classes", info_classes_command,
_("All Objective-C classes, or those matching REGEXP."));
add_com ("print-object", class_vars, print_object_command,
_("Ask an Objective-C object to print itself."));
return 0;
}
-/* Provide a prototype to silence -Wmissing-prototypes. */
-extern initialize_file_ftype _initialize_objc_lang;
-
void
_initialize_objc_lang (void)
{