X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=gdb%2Fobjc-lang.c;h=46081688264a6f811d6027a1ee2b75890a7f7f03;hb=5c6ce71d76dc5618b6ebfc967e5c4b99d701ef50;hp=08a6bb8b25cbd37e5edc3c54c93b7ec4945af3d6;hpb=2b2d9e11a0bd5355936c876a8d14a06d78d4b39e;p=deliverable%2Fbinutils-gdb.git diff --git a/gdb/objc-lang.c b/gdb/objc-lang.c index 08a6bb8b25..4608168826 100644 --- a/gdb/objc-lang.c +++ b/gdb/objc-lang.c @@ -85,8 +85,7 @@ lookup_struct_typedef (char *name, struct block *block, int noerr) { struct symbol *sym; - sym = lookup_symbol (name, block, STRUCT_DOMAIN, 0, - (struct symtab **) NULL); + sym = lookup_symbol (name, block, STRUCT_DOMAIN, 0); if (sym == NULL) { @@ -118,9 +117,9 @@ 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 { complaint (&symfile_complaints, _("no way to lookup Objective-C classes")); @@ -145,9 +144,9 @@ 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 { complaint (&symfile_complaints, _("no way to lookup Objective-C selectors")); @@ -166,43 +165,50 @@ value_nsstring (char *ptr, int len) struct value *function, *nsstringValue; struct symbol *sym; struct type *type; + struct objfile *objf; + struct gdbarch *gdbarch; if (!target_has_execution) return 0; /* Can't call into inferior to create NSString. */ - sym = lookup_struct_typedef("NSString", 0, 1); - if (sym == NULL) - sym = lookup_struct_typedef("NXString", 0, 1); - if (sym == NULL) - 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]); /* _NSNewStringFromCString replaces "istr" after Lantern2A. */ if (lookup_minimal_symbol("_NSNewStringFromCString", 0, 0)) { - function = find_function_in_inferior("_NSNewStringFromCString"); + function = find_function_in_inferior("_NSNewStringFromCString", &objf); 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", &objf); 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:]", &objf); + type = builtin_type (get_objfile_arch (objf))->builtin_long; + stringValue[0] = value_from_longest - (builtin_type_long, lookup_objc_class ("NSString")); + (type, lookup_objc_class ("NSString")); stringValue[1] = value_from_longest - (builtin_type_long, lookup_child_selector ("stringWithCString:")); + (type, lookup_child_selector ("stringWithCString:")); nsstringValue = call_function_by_hand(function, 3, &stringValue[0]); } else error (_("NSString: internal error -- no way to create new NSString")); + gdbarch = get_objfile_arch (objf); + + 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)); + deprecated_set_value_type (nsstringValue, type); return nsstringValue; } @@ -506,6 +512,7 @@ const struct language_defn objc_language_defn = { objc_printstr, /* Function to print string constant */ objc_emit_char, 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 */ objc_skip_trampoline, /* Language specific skip_trampoline */ @@ -1272,7 +1279,7 @@ char *find_imps (struct symtab *symtab, struct block *block, if (tmp == NULL) return NULL; - sym = lookup_symbol (selector, block, VAR_DOMAIN, 0, NULL); + sym = lookup_symbol (selector, block, VAR_DOMAIN, 0); if (sym != NULL) { if (syms) @@ -1379,7 +1386,7 @@ print_object_command (char *args, int from_tty) int pc = 0; object = expr->language_defn->la_exp_desc->evaluate_exp - (builtin_type_void_data_ptr, expr, &pc, EVAL_NORMAL); + (builtin_type (expr->gdbarch)->builtin_data_ptr, expr, &pc, EVAL_NORMAL); do_cleanups (old_chain); } @@ -1387,7 +1394,7 @@ print_object_command (char *args, int from_tty) object_addr = value_as_long (object); read_memory (object_addr, &c, 1); - function = find_function_in_inferior ("_NSPrintForDebugger"); + function = find_function_in_inferior ("_NSPrintForDebugger", NULL); if (function == NULL) error (_("Unable to locate _NSPrintForDebugger in child process")); @@ -1680,19 +1687,19 @@ find_implementation (CORE_ADDR object, CORE_ADDR sel) return find_implementation_from_class (ostr.isa, sel); } -#define OBJC_FETCH_POINTER_ARGUMENT(argi) \ - gdbarch_fetch_pointer_argument (current_gdbarch, get_current_frame (), \ - argi, builtin_type_void_func_ptr) - static int resolve_msgsend (CORE_ADDR pc, CORE_ADDR *new_pc) { + struct frame_info *frame = get_current_frame (); + struct gdbarch *gdbarch = get_frame_arch (frame); + struct type *ptr_type = builtin_type (gdbarch)->builtin_func_ptr; + CORE_ADDR object; CORE_ADDR sel; CORE_ADDR res; - object = OBJC_FETCH_POINTER_ARGUMENT (0); - sel = OBJC_FETCH_POINTER_ARGUMENT (1); + object = gdbarch_fetch_pointer_argument (gdbarch, frame, 0, ptr_type); + sel = gdbarch_fetch_pointer_argument (gdbarch, frame, 1, ptr_type); res = find_implementation (object, sel); if (new_pc != 0) @@ -1705,12 +1712,16 @@ resolve_msgsend (CORE_ADDR pc, CORE_ADDR *new_pc) static int resolve_msgsend_stret (CORE_ADDR pc, CORE_ADDR *new_pc) { + struct frame_info *frame = get_current_frame (); + struct gdbarch *gdbarch = get_frame_arch (frame); + struct type *ptr_type = builtin_type (gdbarch)->builtin_func_ptr; + CORE_ADDR object; CORE_ADDR sel; CORE_ADDR res; - object = OBJC_FETCH_POINTER_ARGUMENT (1); - sel = OBJC_FETCH_POINTER_ARGUMENT (2); + object = gdbarch_fetch_pointer_argument (gdbarch, frame, 1, ptr_type); + sel = gdbarch_fetch_pointer_argument (gdbarch, frame, 2, ptr_type); res = find_implementation (object, sel); if (new_pc != 0) @@ -1723,14 +1734,18 @@ resolve_msgsend_stret (CORE_ADDR pc, CORE_ADDR *new_pc) static int resolve_msgsend_super (CORE_ADDR pc, CORE_ADDR *new_pc) { + struct frame_info *frame = get_current_frame (); + struct gdbarch *gdbarch = get_frame_arch (frame); + struct type *ptr_type = builtin_type (gdbarch)->builtin_func_ptr; + struct objc_super sstr; CORE_ADDR super; CORE_ADDR sel; CORE_ADDR res; - super = OBJC_FETCH_POINTER_ARGUMENT (0); - sel = OBJC_FETCH_POINTER_ARGUMENT (1); + super = gdbarch_fetch_pointer_argument (gdbarch, frame, 0, ptr_type); + sel = gdbarch_fetch_pointer_argument (gdbarch, frame, 1, ptr_type); read_objc_super (super, &sstr); if (sstr.class == 0) @@ -1747,14 +1762,18 @@ resolve_msgsend_super (CORE_ADDR pc, CORE_ADDR *new_pc) static int resolve_msgsend_super_stret (CORE_ADDR pc, CORE_ADDR *new_pc) { + struct frame_info *frame = get_current_frame (); + struct gdbarch *gdbarch = get_frame_arch (frame); + struct type *ptr_type = builtin_type (gdbarch)->builtin_func_ptr; + struct objc_super sstr; CORE_ADDR super; CORE_ADDR sel; CORE_ADDR res; - super = OBJC_FETCH_POINTER_ARGUMENT (1); - sel = OBJC_FETCH_POINTER_ARGUMENT (2); + super = gdbarch_fetch_pointer_argument (gdbarch, frame, 1, ptr_type); + sel = gdbarch_fetch_pointer_argument (gdbarch, frame, 2, ptr_type); read_objc_super (super, &sstr); if (sstr.class == 0)