[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gdb-patches
Subject:    [PATCH v2 3/4] Fix handling of DW_AT_entry_pc of inlined subroutines
From:       Bernd Edlinger <bernd.edlinger () hotmail ! de>
Date:       2021-05-30 13:58:51
Message-ID: AM8PR10MB4708ED8173B75A4AF5C1F965E4209 () AM8PR10MB4708 ! EURPRD10 ! PROD ! OUTLOOK ! COM
[Download RAW message or body]

It may happen that the inline entry point is not the
start address of the first sub-range of an inline
function.

But the PC for a breakpoint on an inlined subroutine
is always the start address of the first sub-range.

This patch moves the sub-range starting at the entry
point to the first position of the block list.

Therefore the breakpoint on an inlined function
changes in rare cases from the start address of
the first sub-range to the real entry point.

There should always be a subrange that starts at the
entry point, even if that is an empty sub-range.

2021-01-01  Bernd Edlinger  <bernd.edlinger@hotmail.de>

	* dwarf2/read.c (dwarf2_record_block_ranges): Move range beginning
	at DW_AT_entry_pc to the first block range.


Thanks,
Bernd.

["0003-Fix-handling-of-DW_AT_entry_pc-of-inlined-subroutine.patch" (text/x-patch)]

From e654a4ac797636580167d9745dcf29532d5c90de Mon Sep 17 00:00:00 2001
From: Bernd Edlinger <bernd.edlinger@hotmail.de>
Date: Tue, 3 Nov 2020 18:41:43 +0100
Subject: [PATCH v2 3/4] Fix handling of DW_AT_entry_pc of inlined subroutines

It may happen that the inline entry point is not the
start address of the first sub-range of an inline
function.

But the PC for a breakpoint on an inlined subroutine
is always the start address of the first sub-range.

This patch moves the sub-range starting at the entry
point to the first position of the block list.

Therefore the breakpoint on an inlined function
changes in rare cases from the start address of
the first sub-range to the real entry point.

There should always be a subrange that starts at the
entry point, even if that is an empty sub-range.

2021-01-01  Bernd Edlinger  <bernd.edlinger@hotmail.de>

	* dwarf2/read.c (dwarf2_record_block_ranges): Move range beginning
	at DW_AT_entry_pc to the first block range.
---
 gdb/dwarf2/read.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 25d9d96..6168d5e 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -14177,6 +14177,18 @@ class process_die_scope
       if (die->tag != DW_TAG_compile_unit)
 	ranges_offset += cu->gnu_ranges_base;
 
+      CORE_ADDR entry_pc = (CORE_ADDR) -1;
+      if (die->tag == DW_TAG_inlined_subroutine)
+	{
+	  attr = dwarf2_attr (die, DW_AT_entry_pc, cu);
+	  if (attr != nullptr)
+	    {
+	      entry_pc = attr->as_address ();
+	      entry_pc += baseaddr;
+	      entry_pc = gdbarch_adjust_dwarf2_addr (gdbarch, entry_pc);
+	    }
+	}
+
       std::vector<blockrange> blockvec;
       dwarf2_ranges_process (ranges_offset, cu, die->tag,
 	[&] (CORE_ADDR start, CORE_ADDR end)
@@ -14187,6 +14199,8 @@ class process_die_scope
 	  end = gdbarch_adjust_dwarf2_addr (gdbarch, end);
 	  cu->get_builder ()->record_block_range (block, start, end - 1);
 	  blockvec.emplace_back (start, end);
+	  if (entry_pc == start && blockvec.size () > 1)
+	    std::swap (blockvec[0], blockvec[blockvec.size () - 1]);
 	});
 
       BLOCK_RANGES(block) = make_blockranges (objfile, blockvec);
-- 
1.9.1



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic