summaryrefslogtreecommitdiff
path: root/gdb/objc-lang.c
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2010-04-19 19:51:38 +0000
committerMike Frysinger <vapier@gentoo.org>2010-04-19 19:51:38 +0000
commit237c2dc7c52137e20f901b7f99d9c7510a529e24 (patch)
tree26bd31c19e27ba4e37a741ade3ff6376cc5c2033 /gdb/objc-lang.c
parent59c88a4654dc522a78e35349afc22b01ee6b9c58 (diff)
downloadgdb-237c2dc7c52137e20f901b7f99d9c7510a529e24.tar.gz
gdb: objc-lang: check symbol name before accessing memory
The current ObjC logic will check both the symbol name and the target address space when trying to locate an appropriate selector. The problem is that first the target address space is checked before the symbol name. This may lead to a lot of unnecessary host<->target transactions when dealing with a non-OjbC target that does use function descriptors to describe functions as every symbol will have its FD read just to have the result thrown away with non-matching symbol names. It also may lead to problems when a non-FD symbol is found that points near the end of the address space as the target will throw up a memory_error(). One such example are symbols that are not functions, smaller than a FD, and are the last valid location. Obviously treating it as a larger data struct can cause memory overflows. So to speed things up and not screw over such targets, check the symbol name (which we already have locally) first before attempting to read the function's descriptor. This fixes breakpoints with Blackfin Linux FDPIC ELFs, and seems to cause no native regressions on my x86_64/Linux system. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Diffstat (limited to 'gdb/objc-lang.c')
-rw-r--r--gdb/objc-lang.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/gdb/objc-lang.c b/gdb/objc-lang.c
index a050f154ce6..1731fa72012 100644
--- a/gdb/objc-lang.c
+++ b/gdb/objc-lang.c
@@ -1178,6 +1178,16 @@ find_methods (struct symtab *symtab, char type,
QUIT;
+ /* Check the symbol name first as this can be done entirely without
+ sending any query to the target. */
+ symname = SYMBOL_NATURAL_NAME (msymbol);
+ if (symname == NULL)
+ continue;
+
+ if ((symname[0] != '-' && symname[0] != '+') || (symname[1] != '['))
+ /* Not a method name. */
+ continue;
+
/* The minimal symbol might point to a function descriptor;
resolve it to the actual code address instead. */
pc = gdbarch_convert_from_func_ptr_addr (gdbarch, pc,
@@ -1188,14 +1198,7 @@ find_methods (struct symtab *symtab, char type,
/* Not in the specified symtab. */
continue;
- symname = SYMBOL_NATURAL_NAME (msymbol);
- if (symname == NULL)
- continue;
-
- if ((symname[0] != '-' && symname[0] != '+') || (symname[1] != '['))
- /* Not a method name. */
- continue;
-
+ /* Now that thinks are a bit sane, clean up the symname. */
while ((strlen (symname) + 1) >= tmplen)
{
tmplen = (tmplen == 0) ? 1024 : tmplen * 2;