From: Simon Marchi <simon.marchi@ericsson.com>
To: Bartosz Nitka <niteria@gmail.com>, <gdb-patches@sourceware.org>
Subject: Re: [PATCH] Don't rewind PC for GHC generated frames
Date: Thu, 01 Feb 2018 21:22:00 -0000 [thread overview]
Message-ID: <7e10d4f7-79f4-175c-b45a-33d698fd0ad6@ericsson.com> (raw)
In-Reply-To: <CAOSxnRgHDYy6pz0NqBxcC9Mrq2eMm4UdLAkAc63uibTJFe-rsg@mail.gmail.com>
On 2018-02-01 01:54 PM, Bartosz Nitka wrote:
> GHC - the Haskell compiler generates code that violates one of
> GDB's assumptions.
>
> GDB assumes that the address in a frame was generated by the call
> instruction and that it is the address of the call instruction
> plus 1 (I'm rephrasing the comment in get_frame_address_in_block).
> So to get the real address, one has to substract 1. This is doubly
> beneficial because some functions are "noreturn" and don't have
> further instructions after call, so GDB would be looking at gibberish.
> All in all, this is good for C-like languages.
>
> GHC generates completely different code. It uses jumps instead of call
> and manages the stack itself. Furthermore every piece of code is preceeded
> by some metadata called the Info Table. If we substract from the
> program counter it ends up pointing to the metadata, which is undesirable.
> GHC has a workaround for this [1] that works most of the time, it basically
> lies in the DWARF data and extends the function one byte backwards.
> That helps with making unwinding succeed most of the time, but then the
> address is also used for looking up symbols and they can't be resolved.
>
> This change disables program counter rewinding for GHC generated compilation
> units.
>
> Some additional context can be found here [2].
>
> [1] https://phabricator.haskell.org/diffusion/GHC/browse/master/compiler/nativeGen/Dwarf/Types.hs;e9ae0cae9eb6a340473b339b5711ae76c6bdd045$399-417
> [2] https://ghc.haskell.org/trac/ghc/wiki/DWARF
Hi Bartosz,
I am unable to apply your patch, it seems that your mail client messed
up the formatting (among other things, replaced some tabs with spaces).
Would it be possible for you to send it using git-send-email? There are
instructions on setting up git-send-email with gmail here, if needed:
https://www.kernel.org/pub/software/scm/git/docs/git-send-email.html
Thanks,
Simon
prev parent reply other threads:[~2018-02-01 21:22 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-01 18:55 Bartosz Nitka
2018-02-01 21:22 ` Simon Marchi [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=7e10d4f7-79f4-175c-b45a-33d698fd0ad6@ericsson.com \
--to=simon.marchi@ericsson.com \
--cc=gdb-patches@sourceware.org \
--cc=niteria@gmail.com \
/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