public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Bernd Edlinger <bernd.edlinger@hotmail.de>
To: Simon Marchi <simon.marchi@polymtl.ca>,
	"gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Subject: [PATCH] Fix handling of DW_AT_entry_pc of inlined subroutines
Date: Fri, 1 Jan 2021 10:59:09 +0100	[thread overview]
Message-ID: <HE1PR0602MB341701363AEC9894B63FC691E4D50@HE1PR0602MB3417.eurprd06.prod.outlook.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 627 bytes --]

Hi,


this was previously a part of the "[PATCH v5] Fix range end handling of inlined subroutines"
but this change can be considered to be independent of the range end handling.

It is sometimes the case that the entry_pc points at an empty sub-range, and therefore
this change makes more sense when the range end handling (including empty sub-ranges)
is applied first.

Unfortunately I have no test case for it.

This is similar to the "[PATCHv2] Fix partial symbols"
https://sourceware.org/pipermail/gdb-patches/2020-December/174175.html

Where I have no test case either, nevertheless I am sure it happens.


Thanks
Bernd.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0003-Fix-handling-of-DW_AT_entry_pc-of-inlined-subroutine.patch --]
[-- Type: text/x-patch; name="0003-Fix-handling-of-DW_AT_entry_pc-of-inlined-subroutine.patch", Size: 2203 bytes --]

From b61ad6070d8ddb13aefaffe56aaf9c09450fb5a0 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] 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 a48beab..bb050e6 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -14844,6 +14844,18 @@ class process_die_scope
       unsigned long offset = (attr->as_unsigned ()
 			      + (need_ranges_base ? cu->ranges_base : 0));
 
+      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 (offset, cu, die->tag,
 	[&] (CORE_ADDR start, CORE_ADDR end)
@@ -14854,6 +14866,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


             reply	other threads:[~2021-01-01  9:59 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-01  9:59 Bernd Edlinger [this message]
2024-03-31 10:49 Bernd Edlinger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=HE1PR0602MB341701363AEC9894B63FC691E4D50@HE1PR0602MB3417.eurprd06.prod.outlook.com \
    --to=bernd.edlinger@hotmail.de \
    --cc=gdb-patches@sourceware.org \
    --cc=simon.marchi@polymtl.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).