From: Kevin Buettner <kevinb@redhat.com>
To: gdb-patches@sourceware.org
Subject: Re: [patch] [v2] Enable dwarf unwind for AVR target
Date: Wed, 03 Feb 2016 16:45:00 -0000 [thread overview]
Message-ID: <20160203094534.0ec066aa@pinnacle.lan> (raw)
In-Reply-To: <CAC140656783604CABA6AE60C2A6D5A4CA3B7268@penmbx02.corp.atmel.com>
On Fri, 8 Jan 2016 08:52:33 +0000
"Sivanupandi, Pitchumani" <Pitchumani.Sivanupandi@atmel.com> wrote:
> Dwarf debug info generated by avr-gcc denotes the return address by register
> 36 which is not an actual register.
> e.g. .debug_frame
> (--snip--)
> 00000000 00000010 ffffffff CIE
> Version: 1
> Augmentation: ""
> Code alignment factor: 2
> Data alignment factor: -1
> Return address column: 36
>
> DW_CFA_def_cfa: r32 ofs 3
> DW_CFA_offset: r36 at cfa-2
> (--snip--)
>
> The fix is to add a pseudo register (36 - AVR_DWARF2_PC_REGNUM/LR) to gdb to
> map return address register. Register name is "LR" (link register). When dwarf
> frame unwind asks for PC, target function will read return address value from
> AVR_DWARF2_PC_REGNUM's CFA address.
The usual way to handle this problem is to define a dwarf2_reg_to_regnum
method which maps the index of DWARF's return address column to GDB's PC
register. So, for the AVR, you'd map 36 to 35.
If you do this, I think you can dispense with all of the stuff
which adds and manipulates the pseudo-register.
Here's an example (from rx-tdep.c) where this is done:
static int
rx_dwarf_reg_to_regnum (struct gdbarch *gdbarch, int reg)
{
if (0 <= reg && reg <= 15)
return reg;
else if (reg == 16)
return RX_PSW_REGNUM;
else if (reg == 17)
return RX_PC_REGNUM;
else
return -1;
}
Then, in rx_gdbarch_init, this function is registered as follows:
set_gdbarch_dwarf2_reg_to_regnum (gdbarch, rx_dwarf_reg_to_regnum);
Hope this helps...
Kevin
next prev parent reply other threads:[~2016-02-03 16:45 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-08 8:53 Sivanupandi, Pitchumani
2016-02-03 16:45 ` Kevin Buettner [this message]
2016-02-17 5:51 ` Pitchumani Sivanupandi
2016-01-19 6:40 Sivanupandi, Pitchumani
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=20160203094534.0ec066aa@pinnacle.lan \
--to=kevinb@redhat.com \
--cc=gdb-patches@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