aboutsummaryrefslogtreecommitdiff
path: root/gdb/minsyms.c
diff options
context:
space:
mode:
authorTom Tromey <tromey@redhat.com>2013-08-19 07:58:44 -0600
committerTom Tromey <tromey@redhat.com>2014-02-26 12:11:16 -0700
commit50e65b1713256487d50514b50b38b3fd1080b93e (patch)
tree180a4e6ef0445feb91e27e0980bbe01130262d23 /gdb/minsyms.c
parent1b588015839caafc608a6944a78aea170f5fb2f6 (diff)
introduce minimal_symbol_upper_bound
This introduces minimal_symbol_upper_bound and changes various bits of code to use it. Since this function is intimately tied to the implementation of minimal symbol tables, I believe it belongs in minsyms.c. The new function is extracted from find_pc_partial_function_gnu_ifunc. This isn't a "clean" move because the old function interleaved the caching and the computation; but this doesn't make sense for the new code. 2014-02-26 Tom Tromey <tromey@redhat.com> * blockframe.c (find_pc_partial_function_gnu_ifunc): Use bound minimal symbols. Move code that knows about minsym table layout... * minsyms.c (minimal_symbol_upper_bound): ... here. New function. * minsyms.h (minimal_symbol_upper_bound): Declare. * objc-lang.c (find_objc_msgsend): Use bound minimal symbols, minimal_symbol_upper_bound.
Diffstat (limited to 'gdb/minsyms.c')
-rw-r--r--gdb/minsyms.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/gdb/minsyms.c b/gdb/minsyms.c
index c7ae981605..0981e3dcfa 100644
--- a/gdb/minsyms.c
+++ b/gdb/minsyms.c
@@ -1358,3 +1358,48 @@ find_solib_trampoline_target (struct frame_info *frame, CORE_ADDR pc)
}
return 0;
}
+
+/* See minsyms.h. */
+
+CORE_ADDR
+minimal_symbol_upper_bound (struct bound_minimal_symbol minsym)
+{
+ int i;
+ short section;
+ struct obj_section *obj_section;
+ CORE_ADDR result;
+ struct minimal_symbol *msymbol;
+
+ gdb_assert (minsym.minsym != NULL);
+
+ /* If the minimal symbol has a size, use it. Otherwise use the
+ lesser of the next minimal symbol in the same section, or the end
+ of the section, as the end of the function. */
+
+ if (MSYMBOL_SIZE (minsym.minsym) != 0)
+ return SYMBOL_VALUE_ADDRESS (minsym.minsym) + MSYMBOL_SIZE (minsym.minsym);
+
+ /* Step over other symbols at this same address, and symbols in
+ other sections, to find the next symbol in this section with a
+ different address. */
+
+ msymbol = minsym.minsym;
+ section = SYMBOL_SECTION (msymbol);
+ for (i = 1; SYMBOL_LINKAGE_NAME (msymbol + i) != NULL; i++)
+ {
+ if (SYMBOL_VALUE_ADDRESS (msymbol + i) != SYMBOL_VALUE_ADDRESS (msymbol)
+ && SYMBOL_SECTION (msymbol + i) == section)
+ break;
+ }
+
+ obj_section = SYMBOL_OBJ_SECTION (minsym.objfile, minsym.minsym);
+ if (SYMBOL_LINKAGE_NAME (msymbol + i) != NULL
+ && SYMBOL_VALUE_ADDRESS (msymbol + i) < obj_section_endaddr (obj_section))
+ result = SYMBOL_VALUE_ADDRESS (msymbol + i);
+ else
+ /* We got the start address from the last msymbol in the objfile.
+ So the end address is the end of the section. */
+ result = obj_section_endaddr (obj_section);
+
+ return result;
+}