95 error (
_(
"No struct type named %s."), name);
102 error (
_(
"This context has class, union or enum %s, not a struct."),
112 struct value *
function, *classval;
127 _(
"no way to lookup Objective-C classes"));
131 classval =
value_string (classname, strlen (classname) + 1, char_type);
141 struct value *
function, *selstring;
156 _(
"no way to lookup Objective-C selectors"));
161 strlen (selname) + 1,
170 struct value *stringValue[3];
171 struct value *
function, *nsstringValue;
204 error (
_(
"NSString: internal error -- no way to create new NSString"));
215 return nsstringValue;
223 char *demangled, *cp;
225 if (mangled[0] ==
'_' &&
226 (mangled[1] ==
'i' || mangled[1] ==
'c') &&
229 cp = demangled =
xmalloc(strlen(mangled) + 2);
231 if (mangled[1] ==
'i')
237 strcpy(cp, mangled+3);
239 while (*cp && *cp ==
'_')
243 cp = strchr(cp,
'_');
252 strcpy(cp, mangled + (cp - demangled) + 2);
257 cp = strchr(cp,
'_');
265 strcpy(cp, mangled + (cp - demangled));
268 while (*cp && *cp ==
'_')
299 if (real_stop_pc != 0)
307 (gdbarch, frame, method_stop_pc);
308 if (real_stop_pc == 0)
309 real_stop_pc = method_stop_pc;
384 default_make_symbol_completion_list,
423 msglist_sel = (
char *)
xmalloc(1);
425 selname_chain = newobj;
450 len = plen + strlen(msglist_sel) + 2;
452 strcpy(s, msglist_sel);
474 selname_chain = sel->
next;
479 error (
_(
"Can't find selector \"%s\""), p);
498 while (*a && *a !=
' ' && *a !=
']' && *b && *b !=
' ' && *b !=
']')
504 if (*a && *a !=
' ' && *a !=
']')
506 if (*b && *b !=
' ' && *b !=
']')
521 const char *aname, *bname;
525 if (aname == NULL || bname == NULL)
526 error (
_(
"internal: compare_selectors(1)"));
528 aname = strchr(aname,
' ');
529 bname = strchr(bname,
' ');
530 if (aname == NULL || bname == NULL)
531 error (
_(
"internal: compare_selectors(2)"));
561 strcpy(myregexp,
".*]");
564 if (*regexp ==
'+' || *regexp ==
'-')
566 plusminus = *regexp++;
567 while (*regexp ==
' ' || *regexp ==
'\t')
571 strcpy(myregexp,
".*]");
575 if (
sizeof (myregexp) < strlen (regexp) + 4)
576 error (
_(
"Regexp is too long: %s"), regexp);
577 strcpy(myregexp, regexp);
578 if (myregexp[strlen(myregexp) - 1] ==
'$')
579 myregexp[strlen(myregexp) - 1] =
']';
581 strcat(myregexp,
".*]");
589 error (
_(
"Invalid regexp (%s): %s"), val, regexp);
598 && (name[0] ==
'-' || name[0] ==
'+')
602 if (plusminus && name[0] != plusminus)
605 name = (
char *) strchr (name+2,
' ');
609 _(
"Bad method name '%s'"),
613 if (regexp == NULL || re_exec(++name) != 0)
615 const char *mystart =
name;
616 const char *myend = strchr (mystart,
']');
618 if (myend && (myend - mystart > maxlen))
619 maxlen = myend - mystart;
627 regexp ? regexp :
"*");
629 sym_arr = alloca (matches *
sizeof (
struct symbol *));
636 (name[0] ==
'-' || name[0] ==
'+') &&
640 if (plusminus && name[0] != plusminus)
643 name = (
char *) strchr(name+2,
' ');
644 if (regexp == NULL || re_exec(++name) != 0)
645 sym_arr[matches++] = (
struct symbol *) msymbol;
653 for (ix = 0; ix < matches; ix++)
659 name = strchr (name,
' ') + 1;
664 while (*name && *name !=
']')
674 regexp ? regexp :
"*");
687 const char *aname, *bname;
691 if (aname == NULL || bname == NULL)
692 error (
_(
"internal: compare_classes(1)"));
722 strcpy(myregexp,
".* ");
726 if (
sizeof (myregexp) < strlen (regexp) + 4)
727 error (
_(
"Regexp is too long: %s"), regexp);
728 strcpy(myregexp, regexp);
729 if (myregexp[strlen(myregexp) - 1] ==
'$')
731 myregexp[strlen(myregexp) - 1] =
' ';
733 strcat(myregexp,
".* ");
740 error (
_(
"Invalid regexp (%s): %s"), val, regexp);
749 (name[0] ==
'-' || name[0] ==
'+') &&
751 if (regexp == NULL || re_exec(name+2) != 0)
754 const char *mystart = name + 2;
755 const char *myend = strchr (mystart,
' ');
757 if (myend && (myend - mystart > maxlen))
758 maxlen = myend - mystart;
765 regexp ? regexp :
"*");
766 sym_arr = alloca (matches *
sizeof (
struct symbol *));
773 (name[0] ==
'-' || name[0] ==
'+') &&
775 if (regexp == NULL || re_exec(name+2) != 0)
776 sym_arr[matches++] = (
struct symbol *) msymbol;
783 for (ix = 0; ix < matches; ix++)
794 while (*name && *name !=
' ')
813 char *nselector = NULL;
832 if (isalnum (*s2) || (*s2 ==
'_') || (*s2 ==
':'))
834 else if (isspace (*s2))
836 else if ((*s2 ==
'\0') || (*s2 ==
'\''))
852 if (selector != NULL)
853 *selector = nselector;
860 char **category,
char **selector)
868 char *ncategory = NULL;
869 char *nselector = NULL;
886 if ((s1[0] ==
'+') || (s1[0] ==
'-'))
896 while (isalnum (*s1) || (*s1 ==
'_'))
907 while (isalnum (*s2) || (*s2 ==
'_'))
920 if (isalnum (*s2) || (*s2 ==
'_') || (*s2 ==
':'))
922 else if (isspace (*s2))
944 if (theclass != NULL)
946 if (category != NULL)
947 *category = ncategory;
948 if (selector != NULL)
949 *selector = nselector;
956 const char *selector,
961 const char *symname = NULL;
965 char *ncategory = NULL;
966 char *nselector = NULL;
968 static char *tmp = NULL;
969 static unsigned int tmplen = 0;
975 unsigned int *objc_csym;
983 unsigned int objfile_csym = 0;
985 objc_csym = objfile_data (objfile, objc_objfile_data);
986 if (objc_csym != NULL && *objc_csym == 0)
1000 if ((symname[0] !=
'-' && symname[0] !=
'+') || (symname[1] !=
'['))
1007 while ((strlen (symname) + 1) >= tmplen)
1009 tmplen = (tmplen == 0) ? 1024 : tmplen * 2;
1012 strcpy (tmp, symname);
1015 &ncategory, &nselector) == NULL)
1018 if ((type !=
'\0') && (ntype != type))
1021 if ((theclass != NULL)
1022 && ((nclass == NULL) || (strcmp (theclass, nclass) != 0)))
1025 if ((category != NULL) &&
1026 ((ncategory == NULL) || (strcmp (category, ncategory) != 0)))
1029 if ((selector != NULL) &&
1030 ((nselector == NULL) || (strcmp (selector, nselector) != 0)))
1036 if (objc_csym == NULL)
1039 sizeof (*objc_csym));
1040 *objc_csym = objfile_csym;
1041 set_objfile_data (objfile, objc_objfile_data, objc_csym);
1055 const char *elem, *last = NULL;
1070 if (last == NULL || strcmp (last, elem) != 0)
1115 char *theclass = NULL;
1116 char *category = NULL;
1117 char *selector = NULL;
1122 int selector_case = 0;
1126 buf = (
char *) alloca (strlen (method) + 1);
1127 strcpy (buf, method);
1128 tmp =
parse_method (buf, &type, &theclass, &category, &selector);
1132 strcpy (buf, method);
1141 find_methods (type, theclass, category, selector, symbol_names);
1165 return method + (tmp - buf);
1171 struct value *object, *
function, *description;
1176 if (!args || !*args)
1178 "The 'print-object' command requires an argument (an Objective-C object)");
1196 if (
function == NULL)
1197 error (
_(
"Unable to locate _NSPrintForDebugger in child process"));
1202 if (string_addr == 0)
1203 error (
_(
"object returns null description"));
1243 {
"_objc_getClass", NULL, 0, 0},
1244 {
"_objc_getMetaClass", NULL, 0, 0}
1247 #define nmethcalls (sizeof (methcalls) / sizeof (methcalls[0]))
1267 if ((func.minsym == NULL) && (methcalls[i].
name[0] ==
'_'))
1271 if (func.minsym == NULL)
1273 methcalls[i].
begin = 0;
1274 methcalls[i].
end = 0;
1329 "Unable to determine target of "
1330 "Objective-C method call (ignoring):\n",
1349 if ((pc >= methcalls[i].begin) && (pc < methcalls[i].end))
1351 if (methcalls[i].stop_at != NULL)
1369 _(
"All Objective-C selectors, or those matching REGEXP."));
1371 _(
"All Objective-C classes, or those matching REGEXP."));
1373 _(
"Ask an Objective-C object to print itself."));
1388 static unsigned long
1449 while (subclass != 0)
1453 unsigned mlistnum = 0;
1460 unsigned long nmethods;
1471 for (i = 0; i < nmethods; i++)
1477 if (meth_str.
name == sel)
1480 return meth_str.
imp;
1611 objc_objfile_data = register_objfile_data ();
static void read_objc_method(struct gdbarch *gdbarch, CORE_ADDR addr, struct objc_method *method)
struct value * call_function_by_hand(struct value *function, int nargs, struct value **args)
int end_msglist(struct parser_state *ps)
struct type * builtin_func_ptr
#define VEC_replace(T, V, I, O)
#define SYMBOL_PRINT_NAME(symbol)
struct frame_info * get_current_frame(void)
#define parse_gdbarch(ps)
static void read_objc_object(struct gdbarch *gdbarch, CORE_ADDR addr, struct objc_object *object)
static CORE_ADDR find_implementation_from_class(struct gdbarch *gdbarch, CORE_ADDR theclass, CORE_ADDR sel)
static int specialcmp(const char *a, const char *b)
LONGEST value_as_long(struct value *val)
#define BMSYMBOL_VALUE_ADDRESS(symbol)
static char * parse_selector(char *method, char **selector)
struct value * value_coerce_array(struct value *arg1)
CORE_ADDR minimal_symbol_upper_bound(struct bound_minimal_symbol minsym)
static void print_object_command(char *args, int from_tty)
const struct builtin_type * builtin_type(struct gdbarch *gdbarch)
static void selectors_info(char *regexp, int from_tty)
void c_val_print(struct type *, const gdb_byte *, int, CORE_ADDR, struct ui_file *, int, const struct value *, const struct value_print_options *)
static void read_objc_super(struct gdbarch *gdbarch, CORE_ADDR addr, struct objc_super *super)
void c_language_arch_info(struct gdbarch *gdbarch, struct language_arch_info *lai)
struct value * default_read_var_value(struct symbol *var, struct frame_info *frame)
static char * msglist_sel
int catch_errors(catch_errors_ftype *func, void *func_args, char *errstring, return_mask mask)
#define VEC_safe_push(T, V, O)
int(* f)(CORE_ADDR, CORE_ADDR *)
char * skip_spaces(char *chp)
initialize_file_ftype _initialize_objc_lang
static unsigned long read_objc_methlist_nmethods(struct gdbarch *gdbarch, CORE_ADDR addr)
struct value * value_string(char *ptr, ssize_t len, struct type *char_type)
struct symbol * lookup_struct_typedef(char *name, const struct block *block, int noerr)
CORE_ADDR gdbarch_fetch_pointer_argument(struct gdbarch *gdbarch, struct frame_info *frame, int argi, struct type *type)
void add_language(const struct language_defn *lang)
void printf_filtered(const char *format,...)
void deprecated_set_value_type(struct value *value, struct type *type)
struct obstack objfile_obstack
static int resolve_msgsend_super_stret(CORE_ADDR pc, CORE_ADDR *new_pc)
#define ALL_OBJFILES(obj)
void write_exp_elt_longcst(struct parser_state *ps, LONGEST expelt)
char * default_word_break_characters(void)
#define VEC_iterate(T, V, I, P)
void null_post_parser(struct expression **exp, int void_context_p)
static void read_objc_methlist_method(struct gdbarch *gdbarch, CORE_ADDR addr, unsigned long num, struct objc_method *method)
void initialize_file_ftype(void)
void c_emit_char(int c, struct type *type, struct ui_file *stream, int quoter)
const char * const_char_ptr
static int resolve_msgsend_stret(CORE_ADDR pc, CORE_ADDR *new_pc)
struct value * find_function_in_inferior(const char *name, struct objfile **objf_p)
void puts_filtered_tabular(char *string, int width, int right)
struct cmd_list_element * add_com_alias(const char *name, const char *oldname, enum command_class theclass, int abbrev_flag)
void free_current_contents(void *ptr)
int default_pass_by_reference(struct type *type)
enum bfd_endian gdbarch_byte_order(struct gdbarch *gdbarch)
void complaint(struct complaints **complaints, const char *fmt,...)
struct type * basic_lookup_transparent_type(const char *name)
struct cleanup * make_cleanup(make_cleanup_ftype *function, void *arg)
void add_msglist(struct stoken *str, int addcolon)
static int compare_selectors(const void *a, const void *b)
static int find_objc_msgcall_submethod(int(*f)(CORE_ADDR, CORE_ADDR *), CORE_ADDR pc, CORE_ADDR *new_pc)
struct cmd_list_element * add_info(const char *name, cmd_cfunc_ftype *fun, const char *doc)
#define MSYMBOL_NATURAL_NAME(symbol)
struct value * value_from_longest(struct type *type, LONGEST num)
void iterate_over_symbols(const struct block *block, const char *name, const domain_enum domain, symbol_found_callback_ftype *callback, void *data)
struct type * builtin_long
#define target_has_execution
void default_print_array_index(struct value *index_value, struct ui_file *stream, const struct value_print_options *options)
CORE_ADDR lookup_child_selector(struct gdbarch *gdbarch, char *selname)
static CORE_ADDR find_implementation(struct gdbarch *gdbarch, CORE_ADDR object, CORE_ADDR sel)
void read_memory(CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len)
static void uniquify_strings(VEC(const_char_ptr)**strings)
void c_print_typedef(struct type *, struct symbol *, struct ui_file *)
static int find_objc_msgcall_submethod_helper(void *arg)
static struct selname * selname_chain
static int compare_classes(const void *a, const void *b)
struct expression * parse_expression(const char *)
int c_parse(struct parser_state *par_state)
static int resolve_msgsend_super(CORE_ADDR pc, CORE_ADDR *new_pc)
static char * parse_method(char *method, char *type, char **theclass, char **category, char **selector)
void c_printstr(struct ui_file *stream, struct type *type, const gdb_byte *string, unsigned int length, const char *user_encoding, int force_ellipses, const struct value_print_options *options)
PTR xrealloc(PTR ptr, size_t size)
#define VEC_truncate(T, V, I)
const char const char int
struct type * builtin_char
#define ALL_MSYMBOLS(objfile, m)
static void read_objc_class(struct gdbarch *gdbarch, CORE_ADDR addr, struct objc_class *theclass)
void default_get_string(struct value *value, gdb_byte **buffer, int *length, struct type **char_type, const char **charset)
#define TYPE_CODE(thistype)
#define default_varobj_ops
int find_objc_msgcall(CORE_ADDR pc, CORE_ADDR *new_pc)
struct type * builtin_data_ptr
struct complaints * symfile_complaints
struct minimal_symbol * minsym
void c_print_type(struct type *, const char *, struct ui_file *, int, int, const struct type_print_options *)
const struct exp_descriptor exp_descriptor_standard
struct symbol * lookup_symbol(const char *name, const struct block *block, domain_enum domain, struct field_of_this_result *is_a_field_of_this)
struct bound_minimal_symbol lookup_bound_minimal_symbol(const char *name)
struct value * evaluate_subexp(struct type *expect_type, struct expression *exp, int *pos, enum noside noside)
#define VEC_address(T, V)
static int resolve_msgsend(CORE_ADDR pc, CORE_ADDR *new_pc)
int(* stop_at)(CORE_ADDR, CORE_ADDR *)
#define ALL_OBJFILE_MSYMBOLS(objfile, m)
#define SYMBOL_NATURAL_NAME(symbol)
EXTERN_C char * re_comp(const char *)
const char * find_imps(const char *method, VEC(const_char_ptr)**symbol_names)
struct symbol * basic_lookup_symbol_nonlocal(const struct language_defn *langdef, const char *name, const struct block *block, const domain_enum domain)
void c_printchar(int c, struct type *type, struct ui_file *stream)
#define SYMBOL_TYPE(symbol)
CORE_ADDR gdbarch_skip_trampoline_code(struct gdbarch *gdbarch, struct frame_info *frame, CORE_ADDR pc)
CORE_ADDR lookup_objc_class(struct gdbarch *gdbarch, char *classname)
static void find_methods(char type, const char *theclass, const char *category, const char *selector, VEC(const_char_ptr)**symbol_names)
static void find_objc_msgsend(void)
int compare_strings(const void *arg1, const void *arg2)
ULONGEST read_memory_unsigned_integer(CORE_ADDR memaddr, int len, enum bfd_endian byte_order)
static const struct objfile_data * objc_objfile_data
struct bound_minimal_symbol lookup_minimal_symbol(const char *name, const char *sfile, struct objfile *objf)
static CORE_ADDR objc_skip_trampoline(struct frame_info *frame, CORE_ADDR stop_pc)
void c_value_print(struct value *, struct ui_file *, const struct value_print_options *)
void error(const char *fmt,...)
struct value * value_nsstring(struct gdbarch *gdbarch, char *ptr, int len)
struct cmd_list_element * add_com(const char *name, enum command_class theclass, cmd_cfunc_ftype *fun, const char *doc)
initialize_file_ftype _initialize_objc_language
struct type * lookup_pointer_type(struct type *type)
struct gdbarch * get_frame_arch(struct frame_info *this_frame)
void do_cleanups(struct cleanup *old_chain)
static void classes_info(char *regexp, int from_tty)
static const struct op_print objc_op_print_tab[]
char * objc_demangle(const char *mangled, int options)
const ULONGEST const LONGEST len