[PATCH 6/8] Use BLOCK_ENTRY_PC to find function entry pc in infrun.c

Kevin Buettner
2018-06-26T06:53:31Z

find_pc_partial_function() still returns the lowest and highest address
of a function even when that function contains non-contiguous ranges.
In cases where greater discrimination is required, the BLOCK parameter
may be examined to determine the actual entry PC.

This patch uses the BLOCK return value from find_pc_partial_function()
to obtain the entry PC. If no block is found - which can happen when
only minimal symbols are available - then the start address provided
by find_pc_partial_function() will still be used (as before).

gdb/ChangeLog:

* infrun.c (fill_in_stop_func): Use BLOCK_ENTRY_PC to
determine stop_func_start in the execution control state.
---
gdb/infrun.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/gdb/infrun.c b/gdb/infrun.c
index f455af2..88d8fdc 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -4297,10 +4297,20 @@ fill_in_stop_func (struct gdbarch *gdbarch,
{
if (!ecs->stop_func_filled_in)
{
+ const struct block *block;
+
/* Don't care about return value; stop_func_start and stop_func_name
will both be 0 if it doesn't work. */
find_pc_partial_function (stop_pc, &ecs->stop_func_name,
- &ecs->stop_func_start, &ecs->stop_func_end);
+ &ecs->stop_func_start, &ecs->stop_func_end,
+ &block);
+
+ /* If a block is returned, prefer the block's entry point instead of
+ the lowest address of the block - these aren't necessarily the
+ same. */
+ if (block)
+ ecs->stop_func_start = BLOCK_ENTRY_PC (block);
+
ecs->stop_func_start
+= gdbarch_deprecated_function_start_offset (gdbarch);