This is the mail archive of the
mailing list for the GDB project.
gdb not detecting function sections correctly for functions in overlays
- From: Arnab Bhaduri <arnab at cadence dot com>
- To: "gdb at sourceware dot org" <gdb at sourceware dot org>
- Date: Fri, 6 Sep 2013 13:01:56 -0700
- Subject: gdb not detecting function sections correctly for functions in overlays
- Authentication-results: sourceware.org; auth=none
I'm working with the Xtensa version of gdb, based off version 7.5.91. There are local patches applied, but as far as I can tell they do not affect the problem here.
While debugging overlays, I created an executable with two overlays, which are each in their own section (say .overlay0 and .overlay1). The first, .overlay0, has a function foo(), the second has a function bar(). Since the overlays are mapped at the same VMA, both functions have the same start address. When I set a breakpoint on bar(), gdb sets the breakpoint at the correct address. It also (correctly) does not set the breakpoint to the target right away. When it detects the overlay being changed, it sets the breakpoints, but in the wrong overlay. As far as I can tell, it does this because it looks up the function's address from its name, then uses the address to find the function's section (fixup_section() in symtab.c). But, since all the overlay sections share the same starting VMA address, this lookup finds the first matching section which is not always the correct one.
Since objdump --syms does show the section name for foo() and bar() correctly, I assume the information exists somewhere. It seems like gdb should be using somewhat different logic to map a function in an overlay to the correct section. Did I understand things correctly so far, or have I missed something else that is supposed to handle this case ? I am not very familiar with gdb sources so the latter is entirely possible. Any advice would be most welcome.