public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
From: Mark Wielaard <mark@klomp.org>
To: "Martin Liška" <mliska@suse.cz>, elfutils-devel@sourceware.org
Subject: Re: tests/backtrace-dwarf.c failure due to -freorder-blocks-and-partition
Date: Tue, 11 Sep 2018 11:02:00 -0000	[thread overview]
Message-ID: <1536663766.7622.1.camel@klomp.org> (raw)
In-Reply-To: <1535645755.5475.9.camel@klomp.org>

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

On Thu, 2018-08-30 at 18:15 +0200, Mark Wielaard wrote:
> Sorry for dropping this after you provided such an excellent analysis.
> So the problem really is that main gets split into main.cold which is
> jumped into, so a simple backtrace won't see the "hot" main anymore. If
> we would use the debuginfo we might be able to get the "correct"
> function name, but that isn't really the purpose of this testcase.
> 
> The only problem is that I haven't been able to replicate this in the
> testsuite (I do see the partitioning in the standalone testcase you
> posted).
> 
> Is it just run-backtrace-dwarf that is a problem for you?
> In that case, does the attached patch help? It puts all of main in its
> own section, which should prevent gcc from partitioning it.

I pushed the attached to master assuming it helps and doesn't cause any
issues.

Cheers,

Mark

[-- Attachment #2: Type: text/x-patch, Size: 1392 bytes --]

From a1e892e920bbde60a9daa1f98c105c227ee7427d Mon Sep 17 00:00:00 2001
From: Mark Wielaard <mark@klomp.org>
Date: Tue, 11 Sep 2018 12:58:14 +0200
Subject: [PATCH] tests: Add section attribute to defeat
 -freorder-blocks-and-partition.

GCC could partition main into an cold and hot block causing our symbol
lookup to fail in the backtrace-dwarf testcase. Add a section attribute
on "main" so that it will be kept together.

Signed-off-by: Mark Wielaard <mark@klomp.org>
---
 tests/ChangeLog         | 4 ++++
 tests/backtrace-dwarf.c | 1 +
 2 files changed, 5 insertions(+)

diff --git a/tests/ChangeLog b/tests/ChangeLog
index 2a20ffa..8d70891 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,7 @@
+2018-09-11  Mark Wielaard  <mark@klomp.org>
+
+	* backtrace-dwarf.c (main): Add section attribute.
+
 2018-07-24  Mark Wielaard  <mark@klomp.org>
 
 	* run-annobingroup.sh: Add testfile-annobingroup-i386.o tests.
diff --git a/tests/backtrace-dwarf.c b/tests/backtrace-dwarf.c
index e1eb492..35f25ed 100644
--- a/tests/backtrace-dwarf.c
+++ b/tests/backtrace-dwarf.c
@@ -124,6 +124,7 @@ thread_callback (Dwfl_Thread *thread, void *thread_arg)
 }
 
 int
+__attribute__((section(".main"))) /* Defeat -freorder-blocks-and-partition  */
 main (int argc __attribute__ ((unused)), char **argv)
 {
   /* We use no threads here which can interfere with handling a stream.  */
-- 
1.8.3.1


      reply	other threads:[~2018-09-11 11:02 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-03  7:41 Martin Liška
2018-08-03  9:46 ` Mark Wielaard
2018-08-03 10:07   ` Martin Liška
2018-08-30 16:16     ` Mark Wielaard
2018-09-11 11:02       ` Mark Wielaard [this message]

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=1536663766.7622.1.camel@klomp.org \
    --to=mark@klomp.org \
    --cc=elfutils-devel@sourceware.org \
    --cc=mliska@suse.cz \
    /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).