2010-05-15 Michael Snyder <msnyder@vmware.com>

* objc-lang.c: White space.
	* objfiles.c: White space.
	* observer.c: White space.
	* osabi.c: White space.
	* osdata.c: White space.
This commit is contained in:
Michael Snyder 2010-05-16 00:46:46 +00:00
parent b8d56208c5
commit 5cc80db34d
6 changed files with 197 additions and 162 deletions

View file

@ -1,5 +1,11 @@
2010-05-15 Michael Snyder <msnyder@vmware.com> 2010-05-15 Michael Snyder <msnyder@vmware.com>
* objc-lang.c: White space.
* objfiles.c: White space.
* observer.c: White space.
* osabi.c: White space.
* osdata.c: White space.
* m2-lang.c: White space. * m2-lang.c: White space.
* m2-valprint.c: White space. * m2-valprint.c: White space.
* macrocmd.c: White space. * macrocmd.c: White space.

View file

@ -244,22 +244,24 @@ objc_demangle (const char *mangled, int options)
xfree(demangled); /* not mangled name */ xfree(demangled); /* not mangled name */
return NULL; return NULL;
} }
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 */ else
cp = strchr(cp, '_'); {
if (!cp) *cp++ = '('; /* less easy case: category name */
{ cp = strchr(cp, '_');
xfree(demangled); /* not mangled name */ if (!cp)
return NULL; {
} xfree(demangled); /* not mangled name */
*cp++ = ')'; return NULL;
*cp++ = ' '; /* overwriting 1st char of method name... */ }
strcpy(cp, mangled + (cp - demangled)); /* get it back */ *cp++ = ')';
} *cp++ = ' '; /* overwriting 1st char of method name... */
strcpy(cp, mangled + (cp - demangled)); /* get it back */
}
while (*cp && *cp == '_') while (*cp && *cp == '_')
cp++; /* skip any initial underbars in method name */ cp++; /* skip any initial underbars in method name */
@ -283,7 +285,6 @@ objc_demangle (const char *mangled, int options)
static void static void
objc_emit_char (int c, struct type *type, 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. */ c &= 0xFF; /* Avoid sign bit follies. */
if (PRINT_LITERAL_FORM (c)) if (PRINT_LITERAL_FORM (c))
@ -574,28 +575,34 @@ add_msglist(struct stoken *str, int addcolon)
char *s, *p; char *s, *p;
int len, plen; int len, plen;
if (str == 0) { /* Unnamed arg, or... */ if (str == 0) /* Unnamed arg, or... */
if (addcolon == 0) { /* variable number of args. */ {
msglist_len++; if (addcolon == 0) /* variable number of args. */
return; {
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; len = plen + strlen(msglist_sel) + 2;
s = (char *)xmalloc(len); s = (char *)xmalloc(len);
strcpy(s, msglist_sel); strcpy(s, msglist_sel);
strncat(s, p, plen); strncat(s, p, plen);
xfree(msglist_sel); xfree(msglist_sel);
msglist_sel = s; msglist_sel = s;
if (addcolon) { if (addcolon)
s[len-2] = ':'; {
s[len-1] = 0; s[len-2] = ':';
msglist_len++; s[len-1] = 0;
} else msglist_len++;
}
else
s[len-2] = '\0'; s[len-2] = '\0';
} }
@ -993,17 +1000,18 @@ parse_selector (char *method, char **selector)
nselector = s1; nselector = s1;
s2 = s1; s2 = s1;
for (;;) { for (;;)
if (isalnum (*s2) || (*s2 == '_') || (*s2 == ':')) {
*s1++ = *s2; if (isalnum (*s2) || (*s2 == '_') || (*s2 == ':'))
else if (isspace (*s2)) *s1++ = *s2;
; else if (isspace (*s2))
else if ((*s2 == '\0') || (*s2 == '\'')) ;
break; else if ((*s2 == '\0') || (*s2 == '\''))
else break;
return NULL; else
s2++; return NULL;
} s2++;
}
*s1++ = '\0'; *s1++ = '\0';
while (isspace (*s2)) while (isspace (*s2))
@ -1087,17 +1095,18 @@ parse_method (char *method, char *type, char **class,
nselector = s2; nselector = s2;
s1 = s2; s1 = s2;
for (;;) { for (;;)
if (isalnum (*s2) || (*s2 == '_') || (*s2 == ':')) {
*s1++ = *s2; if (isalnum (*s2) || (*s2 == '_') || (*s2 == ':'))
else if (isspace (*s2)) *s1++ = *s2;
; else if (isspace (*s2))
else if (*s2 == ']') ;
break; else if (*s2 == ']')
else break;
return NULL; else
s2++; return NULL;
} s2++;
}
*s1++ = '\0'; *s1++ = '\0';
s2++; s2++;
@ -1308,36 +1317,36 @@ char *find_imps (struct symtab *symtab, struct block *block,
strcpy (buf, method); strcpy (buf, method);
tmp = parse_method (buf, &type, &class, &category, &selector); tmp = parse_method (buf, &type, &class, &category, &selector);
if (tmp == NULL) { if (tmp == NULL)
{
struct symbol *sym = NULL; struct symbol *sym = NULL;
struct minimal_symbol *msym = 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_DOMAIN, 0);
if (sym != NULL)
{
if (syms)
syms[csym] = sym;
csym++;
cdebug++;
}
if (sym == NULL) strcpy (buf, method);
msym = lookup_minimal_symbol (selector, 0, 0); tmp = parse_selector (buf, &selector);
if (msym != NULL) if (tmp == NULL)
{ return NULL;
if (syms)
syms[csym] = (struct symbol *)msym; sym = lookup_symbol (selector, block, VAR_DOMAIN, 0);
csym++; 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) if (syms != NULL)
find_methods (symtab, type, class, category, selector, find_methods (symtab, type, class, category, selector,
@ -1499,26 +1508,29 @@ static void
find_objc_msgsend (void) find_objc_msgsend (void)
{ {
unsigned int i; unsigned int i;
for (i = 0; i < nmethcalls; i++) {
struct minimal_symbol *func; for (i = 0; i < nmethcalls; i++)
{
struct minimal_symbol *func;
/* Try both with and without underscore. */ /* Try both with and without underscore. */
func = lookup_minimal_symbol (methcalls[i].name, NULL, NULL); func = lookup_minimal_symbol (methcalls[i].name, NULL, NULL);
if ((func == NULL) && (methcalls[i].name[0] == '_')) { if ((func == NULL) && (methcalls[i].name[0] == '_'))
func = lookup_minimal_symbol (methcalls[i].name + 1, NULL, NULL); {
func = lookup_minimal_symbol (methcalls[i].name + 1, NULL, NULL);
}
if (func == NULL)
{
methcalls[i].begin = 0;
methcalls[i].end = 0;
continue;
}
methcalls[i].begin = SYMBOL_VALUE_ADDRESS (func);
do {
methcalls[i].end = SYMBOL_VALUE_ADDRESS (++func);
} while (methcalls[i].begin == methcalls[i].end);
} }
if (func == NULL) {
methcalls[i].begin = 0;
methcalls[i].end = 0;
continue;
}
methcalls[i].begin = SYMBOL_VALUE_ADDRESS (func);
do {
methcalls[i].end = SYMBOL_VALUE_ADDRESS (++func);
} while (methcalls[i].begin == methcalls[i].end);
}
} }
/* find_objc_msgcall (replaces pc_off_limits) /* find_objc_msgcall (replaces pc_off_limits)
@ -1618,6 +1630,7 @@ read_objc_method (struct gdbarch *gdbarch, CORE_ADDR addr,
struct objc_method *method) struct objc_method *method)
{ {
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); 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->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);
@ -1627,6 +1640,7 @@ static unsigned long
read_objc_methlist_nmethods (struct gdbarch *gdbarch, CORE_ADDR addr) read_objc_methlist_nmethods (struct gdbarch *gdbarch, CORE_ADDR addr)
{ {
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
return read_memory_unsigned_integer (addr + 4, 4, byte_order); return read_memory_unsigned_integer (addr + 4, 4, byte_order);
} }
@ -1643,6 +1657,7 @@ read_objc_object (struct gdbarch *gdbarch, CORE_ADDR addr,
struct objc_object *object) struct objc_object *object)
{ {
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
object->isa = read_memory_unsigned_integer (addr, 4, byte_order); object->isa = read_memory_unsigned_integer (addr, 4, byte_order);
} }
@ -1651,6 +1666,7 @@ read_objc_super (struct gdbarch *gdbarch, CORE_ADDR addr,
struct objc_super *super) struct objc_super *super)
{ {
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
super->receiver = read_memory_unsigned_integer (addr, 4, byte_order); super->receiver = read_memory_unsigned_integer (addr, 4, byte_order);
super->class = read_memory_unsigned_integer (addr + 4, 4, byte_order); super->class = read_memory_unsigned_integer (addr + 4, 4, byte_order);
}; };
@ -1660,6 +1676,7 @@ read_objc_class (struct gdbarch *gdbarch, CORE_ADDR addr,
struct objc_class *class) struct objc_class *class)
{ {
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
class->isa = read_memory_unsigned_integer (addr, 4, byte_order); class->isa = read_memory_unsigned_integer (addr, 4, byte_order);
class->super_class = read_memory_unsigned_integer (addr + 4, 4, byte_order); class->super_class = read_memory_unsigned_integer (addr + 4, 4, byte_order);
class->name = read_memory_unsigned_integer (addr + 8, 4, byte_order); class->name = read_memory_unsigned_integer (addr + 8, 4, byte_order);
@ -1704,8 +1721,8 @@ find_implementation_from_class (struct gdbarch *gdbarch,
for (i = 0; i < nmethods; i++) for (i = 0; i < nmethods; i++)
{ {
struct objc_method meth_str; struct objc_method meth_str;
read_objc_methlist_method (gdbarch, mlist, i, &meth_str);
read_objc_methlist_method (gdbarch, mlist, i, &meth_str);
#if 0 #if 0
fprintf (stderr, fprintf (stderr,
"checking method 0x%lx against selector 0x%lx\n", "checking method 0x%lx against selector 0x%lx\n",

View file

@ -707,26 +707,26 @@ free_all_objfiles (void)
Return non-zero iff any change happened. */ Return non-zero iff any change happened. */
static int static int
objfile_relocate1 (struct objfile *objfile, struct section_offsets *new_offsets) objfile_relocate1 (struct objfile *objfile,
struct section_offsets *new_offsets)
{ {
struct obj_section *s; struct obj_section *s;
struct section_offsets *delta = struct section_offsets *delta =
((struct section_offsets *) ((struct section_offsets *)
alloca (SIZEOF_N_SECTION_OFFSETS (objfile->num_sections))); alloca (SIZEOF_N_SECTION_OFFSETS (objfile->num_sections)));
{ int i;
int i; int something_changed = 0;
int something_changed = 0;
for (i = 0; i < objfile->num_sections; ++i) for (i = 0; i < objfile->num_sections; ++i)
{ {
delta->offsets[i] = delta->offsets[i] =
ANOFFSET (new_offsets, i) - ANOFFSET (objfile->section_offsets, i); ANOFFSET (new_offsets, i) - ANOFFSET (objfile->section_offsets, i);
if (ANOFFSET (delta, i) != 0) if (ANOFFSET (delta, i) != 0)
something_changed = 1; something_changed = 1;
} }
if (!something_changed) if (!something_changed)
return 0; return 0;
}
/* OK, get all the symtabs. */ /* OK, get all the symtabs. */
{ {
@ -794,6 +794,7 @@ objfile_relocate1 (struct objfile *objfile, struct section_offsets *new_offsets)
{ {
struct minimal_symbol *msym; struct minimal_symbol *msym;
ALL_OBJFILE_MSYMBOLS (objfile, msym) ALL_OBJFILE_MSYMBOLS (objfile, msym)
if (SYMBOL_SECTION (msym) >= 0) if (SYMBOL_SECTION (msym) >= 0)
SYMBOL_VALUE_ADDRESS (msym) += ANOFFSET (delta, SYMBOL_SECTION (msym)); SYMBOL_VALUE_ADDRESS (msym) += ANOFFSET (delta, SYMBOL_SECTION (msym));
@ -816,6 +817,7 @@ objfile_relocate1 (struct objfile *objfile, struct section_offsets *new_offsets)
{ {
int i; int i;
for (i = 0; i < objfile->num_sections; ++i) for (i = 0; i < objfile->num_sections; ++i)
(objfile->section_offsets)->offsets[i] = ANOFFSET (new_offsets, i); (objfile->section_offsets)->offsets[i] = ANOFFSET (new_offsets, i);
} }
@ -1009,65 +1011,64 @@ qsort_cmp (const void *a, const void *b)
else if (sect1_addr > sect2_addr) else if (sect1_addr > sect2_addr)
return 1; return 1;
else else
{ {
/* Sections are at the same address. This could happen if /* Sections are at the same address. This could happen if
A) we have an objfile and a separate debuginfo. A) we have an objfile and a separate debuginfo.
B) we are confused, and have added sections without proper relocation, B) we are confused, and have added sections without proper relocation,
or something like that. */ or something like that. */
const struct objfile *const objfile1 = sect1->objfile; const struct objfile *const objfile1 = sect1->objfile;
const struct objfile *const objfile2 = sect2->objfile; const struct objfile *const objfile2 = sect2->objfile;
if (objfile1->separate_debug_objfile == objfile2 if (objfile1->separate_debug_objfile == objfile2
|| objfile2->separate_debug_objfile == objfile1) || objfile2->separate_debug_objfile == objfile1)
{ {
/* Case A. The ordering doesn't matter: separate debuginfo files /* Case A. The ordering doesn't matter: separate debuginfo files
will be filtered out later. */ will be filtered out later. */
return 0; return 0;
} }
/* Case B. Maintain stable sort order, so bugs in GDB are easier to /* Case B. Maintain stable sort order, so bugs in GDB are easier to
triage. This section could be slow (since we iterate over all triage. This section could be slow (since we iterate over all
objfiles in each call to qsort_cmp), but this shouldn't happen objfiles in each call to qsort_cmp), but this shouldn't happen
very often (GDB is already in a confused state; one hopes this very often (GDB is already in a confused state; one hopes this
doesn't happen at all). If you discover that significant time is doesn't happen at all). If you discover that significant time is
spent in the loops below, do 'set complaints 100' and examine the spent in the loops below, do 'set complaints 100' and examine the
resulting complaints. */ resulting complaints. */
if (objfile1 == objfile2) if (objfile1 == objfile2)
{ {
/* Both sections came from the same objfile. We are really confused. /* Both sections came from the same objfile. We are really confused.
Sort on sequence order of sections within the objfile. */ Sort on sequence order of sections within the objfile. */
const struct obj_section *osect; const struct obj_section *osect;
ALL_OBJFILE_OSECTIONS (objfile1, osect) ALL_OBJFILE_OSECTIONS (objfile1, osect)
if (osect == sect1) if (osect == sect1)
return -1; return -1;
else if (osect == sect2) else if (osect == sect2)
return 1; return 1;
/* We should have found one of the sections before getting here. */ /* We should have found one of the sections before getting here. */
gdb_assert (0); gdb_assert (0);
} }
else else
{ {
/* Sort on sequence number of the objfile in the chain. */ /* Sort on sequence number of the objfile in the chain. */
const struct objfile *objfile; const struct objfile *objfile;
ALL_OBJFILES (objfile) ALL_OBJFILES (objfile)
if (objfile == objfile1) if (objfile == objfile1)
return -1; return -1;
else if (objfile == objfile2) else if (objfile == objfile2)
return 1; return 1;
/* We should have found one of the objfiles before getting here. */ /* We should have found one of the objfiles before getting here. */
gdb_assert (0); gdb_assert (0);
} }
}
}
/* Unreachable. */ /* Unreachable. */
gdb_assert (0); gdb_assert (0);

View file

@ -91,6 +91,7 @@ static struct observer_list *
xalloc_observer_list_node (void) xalloc_observer_list_node (void)
{ {
struct observer_list *node = XMALLOC (struct observer_list); struct observer_list *node = XMALLOC (struct observer_list);
node->observer = XMALLOC (struct observer); node->observer = XMALLOC (struct observer);
return node; return node;
} }

View file

@ -588,6 +588,7 @@ set_osabi (char *args, int from_tty, struct cmd_list_element *c)
else else
{ {
int i; int i;
for (i = 1; i < GDB_OSABI_INVALID; i++) for (i = 1; i < GDB_OSABI_INVALID; i++)
if (strcmp (set_osabi_string, gdbarch_osabi_name (i)) == 0) if (strcmp (set_osabi_string, gdbarch_osabi_name (i)) == 0)
{ {

View file

@ -83,6 +83,7 @@ osdata_start_item (struct gdb_xml_parser *parser,
{ {
struct osdata_parsing_data *data = user_data; struct osdata_parsing_data *data = user_data;
struct osdata_item item = { NULL }; struct osdata_item item = { NULL };
VEC_safe_push (osdata_item_s, data->osdata->items, &item); VEC_safe_push (osdata_item_s, data->osdata->items, &item);
} }
@ -95,6 +96,7 @@ osdata_start_column (struct gdb_xml_parser *parser,
{ {
struct osdata_parsing_data *data = user_data; struct osdata_parsing_data *data = user_data;
const char *name = VEC_index (gdb_xml_value_s, attributes, 0)->value; const char *name = VEC_index (gdb_xml_value_s, attributes, 0)->value;
data->property_name = xstrdup (name); data->property_name = xstrdup (name);
} }
@ -123,6 +125,7 @@ static void
clear_parsing_data (void *p) clear_parsing_data (void *p)
{ {
struct osdata_parsing_data *data = p; struct osdata_parsing_data *data = p;
osdata_free (data->osdata); osdata_free (data->osdata);
data->osdata = NULL; data->osdata = NULL;
xfree (data->property_name); xfree (data->property_name);
@ -192,6 +195,7 @@ osdata_item_clear (struct osdata_item *item)
{ {
struct osdata_column *col; struct osdata_column *col;
int ix; int ix;
for (ix = 0; for (ix = 0;
VEC_iterate (osdata_column_s, item->columns, VEC_iterate (osdata_column_s, item->columns,
ix, col); ix, col);
@ -215,6 +219,7 @@ osdata_free (struct osdata *osdata)
{ {
struct osdata_item *item; struct osdata_item *item;
int ix; int ix;
for (ix = 0; for (ix = 0;
VEC_iterate (osdata_item_s, osdata->items, VEC_iterate (osdata_item_s, osdata->items,
ix, item); ix, item);
@ -230,6 +235,7 @@ static void
osdata_free_cleanup (void *arg) osdata_free_cleanup (void *arg)
{ {
struct osdata *osdata = arg; struct osdata *osdata = arg;
osdata_free (osdata); osdata_free (osdata);
} }
@ -244,6 +250,7 @@ get_osdata (const char *type)
{ {
struct osdata *osdata = NULL; struct osdata *osdata = NULL;
char *xml = target_get_osdata (type); char *xml = target_get_osdata (type);
if (xml) if (xml)
{ {
struct cleanup *old_chain = make_cleanup (xfree, xml); struct cleanup *old_chain = make_cleanup (xfree, xml);
@ -309,6 +316,7 @@ info_osdata_command (char *type, int from_tty)
{ {
struct osdata_column *col; struct osdata_column *col;
int ix; int ix;
for (ix = 0; for (ix = 0;
VEC_iterate (osdata_column_s, last->columns, VEC_iterate (osdata_column_s, last->columns,
ix, col); ix, col);
@ -323,6 +331,7 @@ info_osdata_command (char *type, int from_tty)
{ {
struct osdata_item *item; struct osdata_item *item;
int ix_items; int ix_items;
for (ix_items = 0; for (ix_items = 0;
VEC_iterate (osdata_item_s, osdata->items, VEC_iterate (osdata_item_s, osdata->items,
ix_items, item); ix_items, item);