diff mbox

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

Message ID 20180625235326.2aa421f2@pinnacle.lan
State New
Headers show

Commit Message

Kevin Buettner June 26, 2018, 6:53 a.m. UTC
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(-)

Comments

Simon Marchi Aug. 1, 2018, 2:27 a.m. UTC | #1
On 2018-06-26 02:53 AM, Kevin Buettner wrote:
> 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).

This one looks good to me, given how the stop_func_start field seems to
be used.  From what I understand, it is used as the entry point of the
function, therefore BLOCK_ENTRY_PC seems appropriate.

> @@ -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)

block != nullptr

Simon
diff mbox

Patch

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);