public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
From: "jlebon at redhat dot com" <sourceware-bugzilla@sourceware.org>
To: systemtap@sourceware.org
Subject: [Bug translator/13420] prologue detection fails for function parameters in unoptimized (-g only, no -O) code
Date: Wed, 12 Feb 2014 16:42:00 -0000	[thread overview]
Message-ID: <bug-13420-6586-5DwxzOYewI@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-13420-6586@http.sourceware.org/bugzilla/>

https://sourceware.org/bugzilla/show_bug.cgi?id=13420

Jonathan Lebon <jlebon at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jlebon at redhat dot com

--- Comment #6 from Jonathan Lebon <jlebon at redhat dot com> ---
(In reply to Frank Ch. Eigler from comment #4)
> We should attempt to work around the gcc bug in systemtap, but will need
> to improve the prologue-searching heuristics already in effect.

One of the issues here is that our current heuristics rely on srclines to guess
the prologue end. This can cause problems, because line numbers are completely
independent of the prologue. For example, the following examples will cause
different behaviours when run through resolve_prologue_endings(), even though
the prologue ends at the same address in all cases (all variations of the
example given in comment 5):

---------------

// All on different lines
int foo (int j)
{
printf("%d", j);
}
// Result: thinks there's no prologue (naked), because the line advance to
// '{' is for the same addr (as we saw in comment 5). As a result, we get
// bad j values

// Opening brace on same line as decl
int foo (int j) {
printf("%d", j);
}
// Result: correctly finds the prologue end because the first line advance
// occurs at the same time as the addr change

// All on same line
int foo (int j) { printf("%d", j); }
// Result: correctly finds the prologue end (for the wrong reasons). It goes
// through the line records, and seeing no line advances, runs off the 
// function's highpc, so then goes back one step. What saves us here is the
// 0-line advance GCC adds to mark the end of the prologue. We normally ignore
// it since the lineno doesn't change. (The 0-line advance is also mentioned
// here: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51358#c1).

// Split lines
int foo (int j) { printf("%d", j);
printf("%d", j*2);
}
// Result: thinks the prologue end is at 0x4005f4, which actually corresponds
to
// the addr of the second printf call. Happens because that's where the first
// line advance occurs.

---------------

I think part of the solution here is to take advantage of the 0-line advance
when it is present (which I think only occurs when the prologue end doesn't
correspond to a line advance). This might mean simply always skipping the first
line record, regardless of actual line advances.

I'm also looking into GDB's way of handling the problem. It seems like there is
also arch-specific code to find specific opcodes in the prologue if line number
information fails to provide a clear answer (see e.g. amd64_analyze_prologue():
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=blob;f=gdb/amd64-tdep.c;h=72d748e;hb=HEAD#l2129).
Depending on how often/likely lineno info can fail, we might not need to go
that far.

To be continued...

-- 
You are receiving this mail because:
You are the assignee for the bug.

  parent reply	other threads:[~2014-02-12 16:42 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-21 12:22 [Bug translator/13420] New: prologue detection fails for unoptimized 64bit cast-scope.exp testcase mjw at redhat dot com
2011-11-21 12:44 ` [Bug translator/13420] " mjw at redhat dot com
2011-11-29 17:19 ` mjw at redhat dot com
2011-11-30 16:36 ` mjw at redhat dot com
2013-12-26 12:54 ` [Bug translator/13420] prologue detection fails for function parameters in unoptimized (-g only, no -O) code fche at redhat dot com
2013-12-26 13:04 ` fche at redhat dot com
2014-02-12 16:42 ` jlebon at redhat dot com [this message]
2014-02-27 19:56 ` jlebon at redhat dot com
2014-02-28 20:09 ` jlebon at redhat dot com

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=bug-13420-6586-5DwxzOYewI@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=systemtap@sourceware.org \
    /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).