From: Jim Wilson <jimw@sifive.com>
To: Andrew Burgess <andrew.burgess@embecosm.com>
Cc: gdb-patches@sourceware.org, Palmer Dabbelt <palmer@sifive.com>,
John Baldwin <jhb@freebsd.org>
Subject: Re: [PATCH 1/2] gdb/riscv: Stop prologue scan if instruction fetch/decode fails
Date: Mon, 05 Nov 2018 23:37:00 -0000 [thread overview]
Message-ID: <CAFyWVabUfOuBZ09BbgMbUie5M96YOxfwUEbPJ32x-XsCu_Rq1A@mail.gmail.com> (raw)
In-Reply-To: <1ab6341c3c73c6e0b501e7b25d6d64744d7cdbc0.1541459121.git.andrew.burgess@embecosm.com>
On Mon, Nov 5, 2018 at 3:10 PM Andrew Burgess
<andrew.burgess@embecosm.com> wrote:
> If the target has not yet had a program loaded into it, and the $pc
> value is pointing an unreadable memory, then the prologue scan would
> throw an error, this would then cause GDB to abandon its attempt to
> connect to the target. It was in fact impossible to connect to the
> target at all.
In my case, with openocd/spike, the pc value is actually correct and
there is a valid instruction there. The problem rather happens in
riscv_frame_cache which calls get_frame_func, and this returns 0
because there is no program loaded yet. This then causes a scan for
the prologue to start at address zero, which is wrong, and leads to
the null deref error that kills the connection. I have a simpler fix
based on code I found in mips-tdep.c, which just returns from
riscv_frame_cache if start_addr is zero, and also in
riscv_frame_this_id we don't set this_id if the frame_base is zero.
With your fix, riscv_scan_prologue will be run, the frame cache will
be filled with incorrect values, and we will try to compute a frame id
based on bad info. That doesn't look like the right solution to me.
My patch is a slightly cleaned up version of the workarounds I sent to
you last week, which I am testing now.
Jim
PS Did you see my code_elim testcase fix? Simon Marchi suggested that
you should review it.
next prev parent reply other threads:[~2018-11-05 23:37 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-05 23:10 [PATCH 0/2] RISC-V Prologue Scan And Test Improvement Andrew Burgess
2018-11-05 23:10 ` [PATCH 2/2] gdb/riscv: Update test to support targets without FP hardware Andrew Burgess
2018-11-05 23:10 ` [PATCH 1/2] gdb/riscv: Stop prologue scan if instruction fetch/decode fails Andrew Burgess
2018-11-05 23:37 ` Jim Wilson [this message]
2018-11-06 11:18 ` Andrew Burgess
2018-11-06 19:40 ` Jim Wilson
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=CAFyWVabUfOuBZ09BbgMbUie5M96YOxfwUEbPJ32x-XsCu_Rq1A@mail.gmail.com \
--to=jimw@sifive.com \
--cc=andrew.burgess@embecosm.com \
--cc=gdb-patches@sourceware.org \
--cc=jhb@freebsd.org \
--cc=palmer@sifive.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