aboutsummaryrefslogtreecommitdiff
path: root/gdb/objc-lang.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/objc-lang.c')
-rw-r--r--gdb/objc-lang.c559
1 files changed, 276 insertions, 283 deletions
diff --git a/gdb/objc-lang.c b/gdb/objc-lang.c
index e17a4c4..cbba81d 100644
--- a/gdb/objc-lang.c
+++ b/gdb/objc-lang.c
@@ -48,14 +48,16 @@
#include <ctype.h>
#include <algorithm>
-struct objc_object {
+struct objc_object
+{
CORE_ADDR isa;
};
-struct objc_class {
- CORE_ADDR isa;
- CORE_ADDR super_class;
- CORE_ADDR name;
+struct objc_class
+{
+ CORE_ADDR isa;
+ CORE_ADDR super_class;
+ CORE_ADDR name;
long version;
long info;
long instance_size;
@@ -65,12 +67,14 @@ struct objc_class {
CORE_ADDR protocols;
};
-struct objc_super {
+struct objc_super
+{
CORE_ADDR receiver;
CORE_ADDR theclass;
};
-struct objc_method {
+struct objc_method
+{
CORE_ADDR name;
CORE_ADDR types;
CORE_ADDR imp;
@@ -93,46 +97,45 @@ lookup_struct_typedef (const char *name, const struct block *block, int noerr)
{
if (noerr)
return 0;
- else
- error (_("No struct type named %s."), name);
+ else
+ error (_ ("No struct type named %s."), name);
}
if (sym->type ()->code () != 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
+CORE_ADDR
lookup_objc_class (struct gdbarch *gdbarch, const char *classname)
{
struct type *char_type = builtin_type (gdbarch)->builtin_char;
- struct value * function, *classval;
+ struct value *function, *classval;
- if (! target_has_execution ())
+ if (!target_has_execution ())
{
/* Can't call into inferior to lookup class. */
return 0;
}
- if (lookup_minimal_symbol("objc_lookUpClass", 0, 0).minsym)
- function = find_function_in_inferior("objc_lookUpClass", NULL);
+ if (lookup_minimal_symbol ("objc_lookUpClass", 0, 0).minsym)
+ function = find_function_in_inferior ("objc_lookUpClass", NULL);
else if (lookup_minimal_symbol ("objc_lookup_class", 0, 0).minsym)
- function = find_function_in_inferior("objc_lookup_class", NULL);
+ function = find_function_in_inferior ("objc_lookup_class", NULL);
else
{
- complaint (_("no way to lookup Objective-C classes"));
+ complaint (_ ("no way to lookup Objective-C classes"));
return 0;
}
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,
- NULL,
+ return (CORE_ADDR) value_as_long (call_function_by_hand (function, NULL,
classval));
}
@@ -140,31 +143,30 @@ CORE_ADDR
lookup_child_selector (struct gdbarch *gdbarch, const char *selname)
{
struct type *char_type = builtin_type (gdbarch)->builtin_char;
- struct value * function, *selstring;
+ struct value *function, *selstring;
- if (! target_has_execution ())
+ if (!target_has_execution ())
{
/* Can't call into inferior to lookup selector. */
return 0;
}
- if (lookup_minimal_symbol("sel_getUid", 0, 0).minsym)
- function = find_function_in_inferior("sel_getUid", NULL);
+ if (lookup_minimal_symbol ("sel_getUid", 0, 0).minsym)
+ function = find_function_in_inferior ("sel_getUid", NULL);
else if (lookup_minimal_symbol ("sel_get_any_uid", 0, 0).minsym)
- function = find_function_in_inferior("sel_get_any_uid", NULL);
+ function = find_function_in_inferior ("sel_get_any_uid", NULL);
else
{
- complaint (_("no way to lookup Objective-C selectors"));
+ complaint (_ ("no way to lookup Objective-C selectors"));
return 0;
}
- selstring = value_coerce_array (value_string (selname,
- strlen (selname) + 1,
+ selstring = value_coerce_array (value_string (selname, strlen (selname) + 1,
char_type));
return value_as_long (call_function_by_hand (function, NULL, selstring));
}
-struct value *
+struct value *
value_nsstring (struct gdbarch *gdbarch, const char *ptr, int len)
{
struct type *char_type = builtin_type (gdbarch)->builtin_char;
@@ -174,43 +176,44 @@ value_nsstring (struct gdbarch *gdbarch, const char *ptr, int len)
struct type *type;
if (!target_has_execution ())
- return 0; /* Can't call into inferior to create NSString. */
+ return 0; /* Can't call into inferior to create NSString. */
- stringValue[2] = value_string(ptr, len, char_type);
- stringValue[2] = value_coerce_array(stringValue[2]);
+ 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).minsym)
+ if (lookup_minimal_symbol ("_NSNewStringFromCString", 0, 0).minsym)
{
- function = find_function_in_inferior("_NSNewStringFromCString", NULL);
- nsstringValue = call_function_by_hand(function, NULL, stringValue[2]);
+ function = find_function_in_inferior ("_NSNewStringFromCString", NULL);
+ nsstringValue = call_function_by_hand (function, NULL, stringValue[2]);
}
- else if (lookup_minimal_symbol("istr", 0, 0).minsym)
+ else if (lookup_minimal_symbol ("istr", 0, 0).minsym)
{
- function = find_function_in_inferior("istr", NULL);
- nsstringValue = call_function_by_hand(function, NULL, stringValue[2]);
+ function = find_function_in_inferior ("istr", NULL);
+ nsstringValue = call_function_by_hand (function, NULL, stringValue[2]);
}
- else if (lookup_minimal_symbol("+[NSString stringWithCString:]", 0, 0).minsym)
+ else if (
+ lookup_minimal_symbol ("+[NSString stringWithCString:]", 0, 0).minsym)
{
function
- = find_function_in_inferior("+[NSString stringWithCString:]", NULL);
+ = find_function_in_inferior ("+[NSString stringWithCString:]", NULL);
type = builtin_type (gdbarch)->builtin_long;
- stringValue[0] = value_from_longest
- (type, lookup_objc_class (gdbarch, "NSString"));
- stringValue[1] = value_from_longest
- (type, lookup_child_selector (gdbarch, "stringWithCString:"));
- nsstringValue = call_function_by_hand(function, NULL, stringValue);
+ stringValue[0]
+ = value_from_longest (type, lookup_objc_class (gdbarch, "NSString"));
+ stringValue[1] = value_from_longest (
+ type, lookup_child_selector (gdbarch, "stringWithCString:"));
+ nsstringValue = call_function_by_hand (function, NULL, stringValue);
}
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);
+ sym = lookup_struct_typedef ("NSString", 0, 1);
if (sym == NULL)
- sym = lookup_struct_typedef("NXString", 0, 1);
+ sym = lookup_struct_typedef ("NXString", 0, 1);
if (sym == NULL)
type = builtin_type (gdbarch)->builtin_data_ptr;
else
- type = lookup_pointer_type(sym->type ());
+ type = lookup_pointer_type (sym->type ());
deprecated_set_value_type (nsstringValue, type);
return nsstringValue;
@@ -221,19 +224,19 @@ value_nsstring (struct gdbarch *gdbarch, const char *ptr, int len)
class objc_language : public language_defn
{
public:
+
objc_language ()
: language_defn (language_objc)
- { /* Nothing. */ }
+ { /* Nothing. */
+ }
/* See language.h. */
- const char *name () const override
- { return "objective-c"; }
+ const char *name () const override { return "objective-c"; }
/* See language.h. */
- const char *natural_name () const override
- { return "Objective-C"; }
+ const char *natural_name () const override { return "Objective-C"; }
/* See language.h. */
@@ -251,9 +254,9 @@ public:
}
/* See language.h. */
- bool sniff_from_mangled_name
- (const char *mangled, gdb::unique_xmalloc_ptr<char> *demangled)
- const override
+ bool sniff_from_mangled_name (
+ const char *mangled,
+ gdb::unique_xmalloc_ptr<char> *demangled) const override
{
*demangled = demangle_symbol (mangled, 0);
return *demangled != NULL;
@@ -266,10 +269,7 @@ public:
/* See language.h. */
- bool can_print_type_offsets () const override
- {
- return true;
- }
+ bool can_print_type_offsets () const override { return true; }
/* See language.h. */
@@ -305,8 +305,8 @@ public:
if (method_stop_pc)
{
- real_stop_pc = gdbarch_skip_trampoline_code
- (gdbarch, frame, method_stop_pc);
+ real_stop_pc
+ = gdbarch_skip_trampoline_code (gdbarch, frame, method_stop_pc);
if (real_stop_pc == 0)
real_stop_pc = method_stop_pc;
}
@@ -316,13 +316,14 @@ public:
/* See language.h. */
- const char *name_of_this () const override
- { return "self"; }
+ const char *name_of_this () const override { return "self"; }
/* See language.h. */
enum macro_expansion macro_expansion () const override
- { return macro_expansion_c; }
+ {
+ return macro_expansion_c;
+ }
};
/* See declaration of objc_language::demangle_symbol above. */
@@ -332,63 +333,62 @@ objc_language::demangle_symbol (const char *mangled, int options) const
{
char *demangled, *cp;
- if (mangled[0] == '_'
- && (mangled[1] == 'i' || mangled[1] == 'c')
+ if (mangled[0] == '_' && (mangled[1] == 'i' || mangled[1] == 'c')
&& mangled[2] == '_')
{
cp = demangled = (char *) xmalloc (strlen (mangled) + 2);
if (mangled[1] == 'i')
- *cp++ = '-'; /* for instance method */
+ *cp++ = '-'; /* for instance method */
else
- *cp++ = '+'; /* for class method */
+ *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 != '\0' && *cp == '_')
- cp++; /* Skip any initial underbars in class
+ cp++; /* Skip any initial underbars in class
name. */
- cp = strchr(cp, '_');
- if (cp == nullptr) /* Find first non-initial underbar. */
+ cp = strchr (cp, '_');
+ if (cp == nullptr) /* Find first non-initial underbar. */
{
- xfree(demangled); /* not mangled name */
+ xfree (demangled); /* not mangled name */
return nullptr;
}
- if (cp[1] == '_') /* Easy case: no category name. */
+ if (cp[1] == '_') /* Easy case: no category name. */
{
- *cp++ = ' '; /* Replace two '_' with one ' '. */
- strcpy(cp, mangled + (cp - demangled) + 2);
+ *cp++ = ' '; /* Replace two '_' with one ' '. */
+ strcpy (cp, mangled + (cp - demangled) + 2);
}
else
{
- *cp++ = '('; /* Less easy case: category name. */
- cp = strchr(cp, '_');
+ *cp++ = '('; /* Less easy case: category name. */
+ cp = strchr (cp, '_');
if (cp == nullptr)
{
- xfree(demangled); /* not mangled name */
+ xfree (demangled); /* not mangled name */
return nullptr;
}
*cp++ = ')';
- *cp++ = ' '; /* Overwriting 1st char of method name... */
- strcpy(cp, mangled + (cp - demangled)); /* Get it back. */
+ *cp++ = ' '; /* Overwriting 1st char of method name... */
+ strcpy (cp, mangled + (cp - demangled)); /* Get it back. */
}
while (*cp != '\0' && *cp == '_')
- cp++; /* Skip any initial underbars in
+ cp++; /* Skip any initial underbars in
method name. */
for (; *cp != '\0'; cp++)
if (*cp == '_')
- *cp = ':'; /* Replace remaining '_' with ':'. */
+ *cp = ':'; /* Replace remaining '_' with ':'. */
- *cp++ = ']'; /* closing right brace */
- *cp++ = 0; /* string terminator */
+ *cp++ = ']'; /* closing right brace */
+ *cp++ = 0; /* string terminator */
return gdb::unique_xmalloc_ptr<char> (demangled);
}
else
- return nullptr; /* Not an objc mangled name. */
+ return nullptr; /* Not an objc mangled name. */
}
/* Single instance of the class representing the Objective-C language. */
@@ -400,19 +400,19 @@ static objc_language objc_language_defn;
* Following functions help construct Objective-C message calls.
*/
-struct selname /* For parsing Objective-C. */
- {
- struct selname *next;
- char *msglist_sel;
- int msglist_len;
- };
+struct selname /* For parsing Objective-C. */
+{
+ 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)
+start_msglist (void)
{
struct selname *newobj = XNEW (struct selname);
@@ -420,21 +420,21 @@ start_msglist(void)
newobj->msglist_len = msglist_len;
newobj->msglist_sel = msglist_sel;
msglist_len = 0;
- msglist_sel = (char *)xmalloc(1);
+ msglist_sel = (char *) xmalloc (1);
*msglist_sel = 0;
selname_chain = newobj;
}
void
-add_msglist(struct stoken *str, int addcolon)
+add_msglist (struct stoken *str, int addcolon)
{
char *s;
const char *p;
int len, plen;
- if (str == 0) /* Unnamed arg, or... */
+ if (str == 0) /* Unnamed arg, or... */
{
- if (addcolon == 0) /* variable number of args. */
+ if (addcolon == 0) /* variable number of args. */
{
msglist_len++;
return;
@@ -447,20 +447,20 @@ add_msglist(struct stoken *str, int addcolon)
p = str->ptr;
plen = str->length;
}
- len = plen + strlen(msglist_sel) + 2;
- s = (char *)xmalloc(len);
- strcpy(s, msglist_sel);
- strncat(s, p, plen);
- xfree(msglist_sel);
+ len = plen + strlen (msglist_sel) + 2;
+ s = (char *) xmalloc (len);
+ strcpy (s, msglist_sel);
+ strncat (s, p, plen);
+ xfree (msglist_sel);
msglist_sel = s;
if (addcolon)
{
- s[len-2] = ':';
- s[len-1] = 0;
+ s[len - 2] = ':';
+ s[len - 1] = 0;
msglist_len++;
}
else
- s[len-2] = '\0';
+ s[len - 2] = '\0';
}
int
@@ -479,13 +479,13 @@ end_msglist (struct parser_state *ps)
msglist_sel = sel->msglist_sel;
selid = lookup_child_selector (ps->gdbarch (), p);
if (!selid)
- error (_("Can't find selector \"%s\""), p);
+ error (_ ("Can't find selector \"%s\""), p);
ps->push_new<expr::objc_msgcall_operation> (selid, std::move (target),
std::move (args));
- xfree(p);
- xfree(sel);
+ xfree (p);
+ xfree (sel);
return val;
}
@@ -507,10 +507,10 @@ specialcmp (const char *a, const 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. */
}
/*
@@ -528,14 +528,14 @@ compare_selectors (const void *a, const void *b)
aname = (*(struct symbol **) a)->print_name ();
bname = (*(struct symbol **) b)->print_name ();
if (aname == NULL || bname == NULL)
- error (_("internal: compare_selectors(1)"));
+ error (_ ("internal: compare_selectors(1)"));
- aname = strchr(aname, ' ');
- bname = strchr(bname, ' ');
+ aname = strchr (aname, ' ');
+ bname = strchr (bname, ' ');
if (aname == NULL || bname == NULL)
- error (_("internal: compare_selectors(2)"));
+ error (_ ("internal: compare_selectors(2)"));
- return specialcmp (aname+1, bname+1);
+ return specialcmp (aname + 1, bname + 1);
}
/*
@@ -550,18 +550,18 @@ compare_selectors (const void *a, const void *b)
static void
info_selectors_command (const char *regexp, int from_tty)
{
- const 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;
+ const 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)
- strcpy(myregexp, ".*]"); /* Null input, match all objc methods. */
+ strcpy (myregexp, ".*]"); /* Null input, match all objc methods. */
else
{
if (*regexp == '+' || *regexp == '-')
@@ -571,17 +571,17 @@ info_selectors_command (const char *regexp, int from_tty)
regexp++;
}
if (*regexp == '\0')
- strcpy(myregexp, ".*]");
+ 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 */
+ 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 */
else
- strcat(myregexp, ".*]");
+ strcat (myregexp, ".*]");
}
}
@@ -589,7 +589,7 @@ info_selectors_command (const char *regexp, int from_tty)
{
val = re_comp (myregexp);
if (val != 0)
- error (_("Invalid regexp (%s): %s"), val, regexp);
+ error (_ ("Invalid regexp (%s): %s"), val, regexp);
}
/* First time thru is JUST to get max length and count. */
@@ -599,28 +599,27 @@ info_selectors_command (const char *regexp, int from_tty)
{
QUIT;
name = msymbol->natural_name ();
- if (name
- && (name[0] == '-' || name[0] == '+')
- && name[1] == '[') /* Got a method name. */
+ 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 (_("Bad method name '%s'"),
+ complaint (_ ("Bad method name '%s'"),
msymbol->natural_name ());
continue;
}
- if (regexp == NULL || re_exec(++name) != 0)
- {
+ if (regexp == NULL || re_exec (++name) != 0)
+ {
const char *mystart = name;
- const char *myend = strchr (mystart, ']');
-
+ const char *myend = strchr (mystart, ']');
+
if (myend && (myend - mystart > maxlen))
- maxlen = myend - mystart; /* Get longest selector. */
+ maxlen = myend - mystart; /* Get longest selector. */
matches++;
}
}
@@ -628,8 +627,7 @@ info_selectors_command (const char *regexp, int from_tty)
}
if (matches)
{
- gdb_printf (_("Selectors matching \"%s\":\n\n"),
- regexp ? regexp : "*");
+ gdb_printf (_ ("Selectors matching \"%s\":\n\n"), regexp ? regexp : "*");
sym_arr = XALLOCAVEC (struct symbol *, matches);
matches = 0;
@@ -639,47 +637,45 @@ info_selectors_command (const char *regexp, int from_tty)
{
QUIT;
name = msymbol->natural_name ();
- if (name &&
- (name[0] == '-' || name[0] == '+') &&
- name[1] == '[') /* Got a method name. */
+ 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, ' ');
- if (regexp == NULL || re_exec(++name) != 0)
+ name = (char *) strchr (name + 2, ' ');
+ if (regexp == NULL || re_exec (++name) != 0)
sym_arr[matches++] = (struct symbol *) msymbol;
}
}
}
- qsort (sym_arr, matches, sizeof (struct minimal_symbol *),
+ qsort (sym_arr, matches, sizeof (struct minimal_symbol *),
compare_selectors);
/* Prevent compare on first iteration. */
asel[0] = 0;
- for (ix = 0; ix < matches; ix++) /* Now do the output. */
+ for (ix = 0; ix < matches; ix++) /* Now do the output. */
{
char *p = asel;
QUIT;
name = sym_arr[ix]->natural_name ();
name = strchr (name, ' ') + 1;
- if (p[0] && specialcmp(name, p) == 0)
- continue; /* Seen this one already (not unique). */
+ if (p[0] && specialcmp (name, p) == 0)
+ continue; /* Seen this one already (not unique). */
/* Copy selector part. */
while (*name && *name != ']')
*p++ = *name++;
*p++ = '\0';
/* Print in columns. */
- puts_tabular(asel, maxlen + 1, 0);
+ puts_tabular (asel, maxlen + 1, 0);
}
- begin_line();
+ begin_line ();
}
else
- gdb_printf (_("No selectors matching \"%s\"\n"),
- regexp ? regexp : "*");
+ gdb_printf (_ ("No selectors matching \"%s\"\n"), regexp ? regexp : "*");
}
/*
@@ -697,9 +693,9 @@ compare_classes (const void *a, const void *b)
aname = (*(struct symbol **) a)->print_name ();
bname = (*(struct symbol **) b)->print_name ();
if (aname == NULL || bname == NULL)
- error (_("internal: compare_classes(1)"));
+ error (_ ("internal: compare_classes(1)"));
- return specialcmp (aname+1, bname+1);
+ return specialcmp (aname + 1, bname + 1);
}
/*
@@ -715,35 +711,35 @@ compare_classes (const void *a, const void *b)
static void
info_classes_command (const char *regexp, int from_tty)
{
- const char *name;
- char *val;
- int matches = 0;
- int maxlen = 0;
- int ix;
- char myregexp[2048];
- char aclass[256];
- struct symbol **sym_arr;
+ const 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)
- strcpy(myregexp, ".* "); /* Null input: match all objc classes. */
+ 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] == '$')
+ 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 ' '. */
- myregexp[strlen(myregexp) - 1] = ' ';
+ myregexp[strlen (myregexp) - 1] = ' ';
else
- strcat(myregexp, ".* ");
+ strcat (myregexp, ".* ");
}
if (regexp != NULL)
{
val = re_comp (myregexp);
if (val != 0)
- error (_("Invalid regexp (%s): %s"), val, regexp);
+ error (_ ("Invalid regexp (%s): %s"), val, regexp);
}
/* First time thru is JUST to get max length and count. */
@@ -753,15 +749,14 @@ info_classes_command (const char *regexp, int from_tty)
{
QUIT;
name = msymbol->natural_name ();
- if (name &&
- (name[0] == '-' || name[0] == '+') &&
- name[1] == '[') /* Got a method name. */
- if (regexp == NULL || re_exec(name+2) != 0)
- {
+ if (name && (name[0] == '-' || name[0] == '+')
+ && name[1] == '[') /* Got a method name. */
+ if (regexp == NULL || re_exec (name + 2) != 0)
+ {
/* Compute length of classname part. */
const char *mystart = name + 2;
- const char *myend = strchr (mystart, ' ');
-
+ const char *myend = strchr (mystart, ' ');
+
if (myend && (myend - mystart > maxlen))
maxlen = myend - mystart;
matches++;
@@ -770,8 +765,7 @@ info_classes_command (const char *regexp, int from_tty)
}
if (matches)
{
- gdb_printf (_("Classes matching \"%s\":\n\n"),
- regexp ? regexp : "*");
+ gdb_printf (_ ("Classes matching \"%s\":\n\n"), regexp ? regexp : "*");
sym_arr = XALLOCAVEC (struct symbol *, matches);
matches = 0;
for (objfile *objfile : current_program_space->objfiles ())
@@ -780,42 +774,41 @@ info_classes_command (const char *regexp, int from_tty)
{
QUIT;
name = msymbol->natural_name ();
- if (name &&
- (name[0] == '-' || name[0] == '+') &&
- name[1] == '[') /* Got a method name. */
- if (regexp == NULL || re_exec(name+2) != 0)
+ if (name && (name[0] == '-' || name[0] == '+')
+ && name[1] == '[') /* Got a method name. */
+ if (regexp == NULL || re_exec (name + 2) != 0)
sym_arr[matches++] = (struct symbol *) msymbol;
}
}
- qsort (sym_arr, matches, sizeof (struct minimal_symbol *),
+ qsort (sym_arr, matches, sizeof (struct minimal_symbol *),
compare_classes);
/* Prevent compare on first iteration. */
aclass[0] = 0;
- for (ix = 0; ix < matches; ix++) /* Now do the output. */
+ for (ix = 0; ix < matches; ix++) /* Now do the output. */
{
char *p = aclass;
QUIT;
name = sym_arr[ix]->natural_name ();
name += 2;
- if (p[0] && specialcmp(name, p) == 0)
- continue; /* Seen this one already (not unique). */
+ if (p[0] && specialcmp (name, p) == 0)
+ continue; /* Seen this one already (not unique). */
/* Copy class part of method name. */
while (*name && *name != ' ')
*p++ = *name++;
*p++ = '\0';
/* Print in columns. */
- puts_tabular(aclass, maxlen + 1, 0);
+ puts_tabular (aclass, maxlen + 1, 0);
}
- begin_line();
+ begin_line ();
}
else
- gdb_printf (_("No classes matching \"%s\"\n"), regexp ? regexp : "*");
+ gdb_printf (_ ("No classes matching \"%s\"\n"), regexp ? regexp : "*");
}
-static char *
+static char *
parse_selector (char *method, char **selector)
{
char *s1 = NULL;
@@ -829,13 +822,13 @@ parse_selector (char *method, char **selector)
s1 = method;
s1 = skip_spaces (s1);
- if (*s1 == '\'')
+ if (*s1 == '\'')
{
found_quote = 1;
s1++;
}
s1 = skip_spaces (s1);
-
+
nselector = s1;
s2 = s1;
@@ -856,7 +849,7 @@ parse_selector (char *method, char **selector)
s2 = skip_spaces (s2);
if (found_quote)
{
- if (*s2 == '\'')
+ if (*s2 == '\'')
s2++;
s2 = skip_spaces (s2);
}
@@ -867,9 +860,9 @@ parse_selector (char *method, char **selector)
return s2;
}
-static char *
-parse_method (char *method, char *type, char **theclass,
- char **category, char **selector)
+static char *
+parse_method (char *method, char *type, char **theclass, char **category,
+ char **selector)
{
char *s1 = NULL;
char *s2 = NULL;
@@ -884,17 +877,17 @@ parse_method (char *method, char *type, char **theclass,
gdb_assert (theclass != NULL);
gdb_assert (category != NULL);
gdb_assert (selector != NULL);
-
+
s1 = method;
s1 = skip_spaces (s1);
- if (*s1 == '\'')
+ if (*s1 == '\'')
{
found_quote = 1;
s1++;
}
s1 = skip_spaces (s1);
-
+
if ((s1[0] == '+') || (s1[0] == '-'))
ntype = *s1++;
@@ -907,10 +900,10 @@ parse_method (char *method, char *type, char **theclass,
nclass = s1;
while (isalnum (*s1) || (*s1 == '_'))
s1++;
-
+
s2 = s1;
s2 = skip_spaces (s2);
-
+
if (*s2 == '(')
{
s2++;
@@ -945,7 +938,7 @@ parse_method (char *method, char *type, char **theclass,
s2 = skip_spaces (s2);
if (found_quote)
{
- if (*s2 != '\'')
+ if (*s2 != '\'')
return NULL;
s2++;
s2 = skip_spaces (s2);
@@ -964,9 +957,8 @@ parse_method (char *method, char *type, char **theclass,
}
static void
-find_methods (char type, const char *theclass, const char *category,
- const char *selector,
- std::vector<const char *> *symbol_names)
+find_methods (char type, const char *theclass, const char *category,
+ const char *selector, std::vector<const char *> *symbol_names)
{
const char *symname = NULL;
@@ -1020,8 +1012,8 @@ find_methods (char type, const char *theclass, const char *category,
}
strcpy (tmp, symname);
- if (parse_method (tmp, &ntype, &nclass,
- &ncategory, &nselector) == NULL)
+ if (parse_method (tmp, &ntype, &nclass, &ncategory, &nselector)
+ == NULL)
continue;
if ((type != '\0') && (ntype != type))
@@ -1031,12 +1023,12 @@ find_methods (char type, const char *theclass, const char *category,
&& ((nclass == NULL) || (strcmp (theclass, nclass) != 0)))
continue;
- if ((category != NULL) &&
- ((ncategory == NULL) || (strcmp (category, ncategory) != 0)))
+ if ((category != NULL)
+ && ((ncategory == NULL) || (strcmp (category, ncategory) != 0)))
continue;
- if ((selector != NULL) &&
- ((nselector == NULL) || (strcmp (selector, nselector) != 0)))
+ if ((selector != NULL)
+ && ((nselector == NULL) || (strcmp (selector, nselector) != 0)))
continue;
symbol_names->push_back (symname);
@@ -1129,17 +1121,17 @@ find_imps (const char *method, std::vector<const char *> *symbol_names)
add the selector itself as a symbol, if it exists. */
if (selector_case && !symbol_names->empty ())
{
- struct symbol *sym = lookup_symbol (selector, NULL, VAR_DOMAIN,
- 0).symbol;
+ struct symbol *sym
+ = lookup_symbol (selector, NULL, VAR_DOMAIN, 0).symbol;
- if (sym != NULL)
+ if (sym != NULL)
symbol_names->push_back (sym->natural_name ());
else
{
struct bound_minimal_symbol msym
= lookup_minimal_symbol (selector, 0, 0);
- if (msym.minsym != NULL)
+ if (msym.minsym != NULL)
symbol_names->push_back (msym.minsym->natural_name ());
}
}
@@ -1149,7 +1141,7 @@ find_imps (const char *method, std::vector<const char *> *symbol_names)
return method + (tmp - buf);
}
-static void
+static void
print_object_command (const char *args, int from_tty)
{
struct value *object, *function, *description;
@@ -1158,8 +1150,8 @@ print_object_command (const char *args, int from_tty)
gdb_byte c = 0;
if (!args || !*args)
- error (
-"The 'print-object' command requires an argument (an Objective-C object)");
+ error ("The 'print-object' command requires an argument (an Objective-C "
+ "object)");
{
expression_up expr = parse_expression (args);
@@ -1175,13 +1167,13 @@ print_object_command (const char *args, int from_tty)
function = find_function_in_inferior ("_NSPrintForDebugger", NULL);
if (function == NULL)
- error (_("Unable to locate _NSPrintForDebugger in child process"));
+ error (_ ("Unable to locate _NSPrintForDebugger in child process"));
description = call_function_by_hand (function, NULL, object);
string_addr = value_as_long (description);
if (string_addr == 0)
- error (_("object returns null description"));
+ error (_ ("object returns null description"));
read_memory (string_addr + i++, &c, 1);
if (c != 0)
@@ -1190,9 +1182,10 @@ print_object_command (const char *args, int from_tty)
QUIT;
gdb_printf ("%c", c);
read_memory (string_addr + i++, &c, 1);
- } while (c != 0);
+ }
+ while (c != 0);
else
- gdb_printf(_("<object returns empty description>"));
+ gdb_printf (_ ("<object returns empty description>"));
gdb_printf ("\n");
}
@@ -1201,9 +1194,10 @@ print_object_command (const char *args, int from_tty)
* and ultimately find the method being called.
*/
-struct objc_methcall {
+struct objc_methcall
+{
const char *name;
- /* Return instance method to be called. */
+ /* Return instance method to be called. */
int (*stop_at) (CORE_ADDR, CORE_ADDR *);
/* Start of pc range corresponding to method invocation. */
CORE_ADDR begin;
@@ -1216,14 +1210,13 @@ 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);
-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}
-};
+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]))
@@ -1234,7 +1227,7 @@ static struct objc_methcall methcalls[] = {
* case the functions have moved for some reason.
*/
-static void
+static void
find_objc_msgsend (void)
{
unsigned int i;
@@ -1250,10 +1243,10 @@ find_objc_msgsend (void)
func = lookup_bound_minimal_symbol (methcalls[i].name + 1);
}
if (func.minsym == NULL)
- {
+ {
methcalls[i].begin = 0;
methcalls[i].end = 0;
- continue;
+ continue;
}
methcalls[i].begin = func.value_address ();
@@ -1276,9 +1269,8 @@ find_objc_msgsend (void)
* dependent modules.
*/
-static int
-find_objc_msgcall_submethod (int (*f) (CORE_ADDR, CORE_ADDR *),
- CORE_ADDR pc,
+static int
+find_objc_msgcall_submethod (int (*f) (CORE_ADDR, CORE_ADDR *), CORE_ADDR pc,
CORE_ADDR *new_pc)
{
try
@@ -1296,7 +1288,7 @@ find_objc_msgcall_submethod (int (*f) (CORE_ADDR, CORE_ADDR *),
return 0;
}
-int
+int
find_objc_msgcall (CORE_ADDR pc, CORE_ADDR *new_pc)
{
unsigned int i;
@@ -1307,13 +1299,13 @@ find_objc_msgcall (CORE_ADDR pc, CORE_ADDR *new_pc)
*new_pc = 0;
}
- for (i = 0; i < nmethcalls; i++)
- if ((pc >= methcalls[i].begin) && (pc < methcalls[i].end))
+ 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
+ if (methcalls[i].stop_at != NULL)
+ return find_objc_msgcall_submethod (methcalls[i].stop_at, pc,
+ new_pc);
+ else
return 0;
}
@@ -1321,28 +1313,29 @@ find_objc_msgcall (CORE_ADDR pc, CORE_ADDR *new_pc)
}
void _initialize_objc_language ();
+
void
_initialize_objc_language ()
{
add_info ("selectors", info_selectors_command,
- _("All Objective-C selectors, or those matching REGEXP."));
+ _ ("All Objective-C selectors, or those matching REGEXP."));
add_info ("classes", info_classes_command,
- _("All Objective-C classes, or those matching REGEXP."));
+ _ ("All Objective-C classes, or those matching REGEXP."));
cmd_list_element *print_object_cmd
= add_com ("print-object", class_vars, print_object_command,
- _("Ask an Objective-C object to print itself."));
+ _ ("Ask an Objective-C object to print itself."));
add_com_alias ("po", print_object_cmd, class_vars, 1);
}
-static void
+static void
read_objc_method (struct gdbarch *gdbarch, CORE_ADDR addr,
struct objc_method *method)
{
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
- method->name = read_memory_unsigned_integer (addr + 0, 4, byte_order);
+ method->name = read_memory_unsigned_integer (addr + 0, 4, byte_order);
method->types = read_memory_unsigned_integer (addr + 4, 4, byte_order);
- method->imp = read_memory_unsigned_integer (addr + 8, 4, byte_order);
+ method->imp = read_memory_unsigned_integer (addr + 8, 4, byte_order);
}
static unsigned long
@@ -1353,15 +1346,15 @@ read_objc_methlist_nmethods (struct gdbarch *gdbarch, CORE_ADDR addr)
return read_memory_unsigned_integer (addr + 4, 4, byte_order);
}
-static void
+static void
read_objc_methlist_method (struct gdbarch *gdbarch, CORE_ADDR addr,
unsigned long num, struct objc_method *method)
{
gdb_assert (num < read_objc_methlist_nmethods (gdbarch, addr));
read_objc_method (gdbarch, addr + 8 + (12 * num), method);
}
-
-static void
+
+static void
read_objc_object (struct gdbarch *gdbarch, CORE_ADDR addr,
struct objc_object *object)
{
@@ -1370,7 +1363,7 @@ read_objc_object (struct gdbarch *gdbarch, CORE_ADDR addr,
object->isa = read_memory_unsigned_integer (addr, 4, byte_order);
}
-static void
+static void
read_objc_super (struct gdbarch *gdbarch, CORE_ADDR addr,
struct objc_super *super)
{
@@ -1380,61 +1373,62 @@ read_objc_super (struct gdbarch *gdbarch, CORE_ADDR addr,
super->theclass = read_memory_unsigned_integer (addr + 4, 4, byte_order);
};
-static void
+static void
read_objc_class (struct gdbarch *gdbarch, CORE_ADDR addr,
struct objc_class *theclass)
{
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
theclass->isa = read_memory_unsigned_integer (addr, 4, byte_order);
- theclass->super_class = read_memory_unsigned_integer (addr + 4, 4, byte_order);
+ theclass->super_class
+ = read_memory_unsigned_integer (addr + 4, 4, byte_order);
theclass->name = read_memory_unsigned_integer (addr + 8, 4, byte_order);
theclass->version = read_memory_unsigned_integer (addr + 12, 4, byte_order);
theclass->info = read_memory_unsigned_integer (addr + 16, 4, byte_order);
- theclass->instance_size = read_memory_unsigned_integer (addr + 18, 4,
- byte_order);
+ theclass->instance_size
+ = read_memory_unsigned_integer (addr + 18, 4, byte_order);
theclass->ivars = read_memory_unsigned_integer (addr + 24, 4, byte_order);
theclass->methods = read_memory_unsigned_integer (addr + 28, 4, byte_order);
theclass->cache = read_memory_unsigned_integer (addr + 32, 4, byte_order);
- theclass->protocols = read_memory_unsigned_integer (addr + 36, 4, byte_order);
+ theclass->protocols
+ = read_memory_unsigned_integer (addr + 36, 4, byte_order);
}
static CORE_ADDR
-find_implementation_from_class (struct gdbarch *gdbarch,
- CORE_ADDR theclass, CORE_ADDR sel)
+find_implementation_from_class (struct gdbarch *gdbarch, CORE_ADDR theclass,
+ CORE_ADDR sel)
{
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
CORE_ADDR subclass = theclass;
- while (subclass != 0)
+ while (subclass != 0)
{
-
struct objc_class class_str;
unsigned mlistnum = 0;
read_objc_class (gdbarch, subclass, &class_str);
- for (;;)
+ for (;;)
{
CORE_ADDR mlist;
unsigned long nmethods;
unsigned long i;
-
- mlist = read_memory_unsigned_integer (class_str.methods +
- (4 * mlistnum),
- 4, byte_order);
- if (mlist == 0)
+
+ mlist
+ = read_memory_unsigned_integer (class_str.methods + (4 * mlistnum),
+ 4, byte_order);
+ if (mlist == 0)
break;
nmethods = read_objc_methlist_nmethods (gdbarch, mlist);
- for (i = 0; i < nmethods; i++)
+ for (i = 0; i < nmethods; i++)
{
struct objc_method meth_str;
read_objc_methlist_method (gdbarch, mlist, i, &meth_str);
- if (meth_str.name == sel)
+ if (meth_str.name == sel)
/* FIXME: hppa arch was doing a pointer dereference
here. There needs to be a better way to do that. */
return meth_str.imp;
@@ -1448,8 +1442,7 @@ find_implementation_from_class (struct gdbarch *gdbarch,
}
static CORE_ADDR
-find_implementation (struct gdbarch *gdbarch,
- CORE_ADDR object, CORE_ADDR sel)
+find_implementation (struct gdbarch *gdbarch, CORE_ADDR object, CORE_ADDR sel)
{
struct objc_object ostr;
@@ -1525,7 +1518,7 @@ resolve_msgsend_super (CORE_ADDR pc, CORE_ADDR *new_pc)
read_objc_super (gdbarch, super, &sstr);
if (sstr.theclass == 0)
return 0;
-
+
res = find_implementation_from_class (gdbarch, sstr.theclass, sel);
if (new_pc != 0)
*new_pc = res;
@@ -1553,7 +1546,7 @@ resolve_msgsend_super_stret (CORE_ADDR pc, CORE_ADDR *new_pc)
read_objc_super (gdbarch, super, &sstr);
if (sstr.theclass == 0)
return 0;
-
+
res = find_implementation_from_class (gdbarch, sstr.theclass, sel);
if (new_pc != 0)
*new_pc = res;