aboutsummaryrefslogtreecommitdiff
path: root/gdb/minsyms.c
diff options
context:
space:
mode:
authorKevin Buettner <kevinb@redhat.com>2015-11-14 13:15:45 -0700
committerKevin Buettner <kevinb@redhat.com>2015-11-23 15:42:44 -0700
commit5506f9f67ec105b0059a0b3a66fbde82cb5a0a15 (patch)
tree5fb4e75f78efea617b0e89d367d720d9b3309e06 /gdb/minsyms.c
parent16c3b12f199a7ec99a0b51bd83b66942547bba87 (diff)
minsyms.c: Scan backwards over all zero sized symbols.
The comment for the code in question says: /* If the minimal symbol has a zero size, save it but keep scanning backwards looking for one with a non-zero size. A zero size may mean that the symbol isn't an object or function (e.g. a label), or it may just mean that the size was not specified. */ As written, the code in question will only scan past the first symbol of zero size. My change fixes the implementation to match the comment. Having this correct is important when the compiler generates several local labels that are left in place by the linker. (I've been told that the linker should eliminate these symbols, but I know of one architecture for which this is not happening.) I've created a test case called asmlabel.c. It's pretty simple: main (int argc, char **argv) { asm ("L0:"); v = 0; asm ("L1:"); v = 1; /* set L1 breakpoint here */ asm ("L2:"); v = 2; /* set L2 breakpoint here */ return 0; } If breakpoints are placed on the lines indicated by the comments, this is the behavior of GDB built without my patch: (gdb) continue Continuing. Breakpoint 2, L1 () at asmlabel.c:26 26 v = 1; /* set L1 breakpoint here */ Note that L1 appears as the function instead of main. This is not what we want to happen. With my patch in place, we see the desired behavior instead: (gdb) continue Continuing. Breakpoint 2, main (argc=1, argv=0x7fffffffdb88) at asmlabel.c:26 26 v = 1; /* set L1 breakpoint here */ gdb/ChangeLog: * minsyms.c (lookup_minimal_symbol_by_pc_section_1): Scan backwards over all zero-sized symbols. gdb/testsuite/ChangeLog: * gdb.base/asmlabel.exp: New test. * gdb.base/asmlabel.c: New test case.
Diffstat (limited to 'gdb/minsyms.c')
-rw-r--r--gdb/minsyms.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/gdb/minsyms.c b/gdb/minsyms.c
index d7097a9394..5def1eee4f 100644
--- a/gdb/minsyms.c
+++ b/gdb/minsyms.c
@@ -697,10 +697,10 @@ lookup_minimal_symbol_by_pc_section_1 (CORE_ADDR pc_in,
symbol isn't an object or function (e.g. a
label), or it may just mean that the size was not
specified. */
- if (MSYMBOL_SIZE (&msymbol[hi]) == 0
- && best_zero_sized == -1)
+ if (MSYMBOL_SIZE (&msymbol[hi]) == 0)
{
- best_zero_sized = hi;
+ if (best_zero_sized == -1)
+ best_zero_sized = hi;
hi--;
continue;
}