Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
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: Tue, 06 Nov 2018 19:40:00 -0000	[thread overview]
Message-ID: <CAFyWVaZHwOMPqDP63tju-tP=8qZBc3SHeMm3DQSr5D40NVVPHw@mail.gmail.com> (raw)
In-Reply-To: <20181106111845.GI16539@embecosm.com>

On Tue, Nov 6, 2018 at 3:18 AM Andrew Burgess
<andrew.burgess@embecosm.com> wrote:
> Interesting, does it actually kill the connection for you?  I too am
> testing against openocd/spike, and what I see is that GDB
> disconnects, but the target is still running, and I can try to connect
> again, and again, and again.....

The target remote command fails.  I'm not actually sure about the
underlying 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.
>
> We really shouldn't do that.  I've worked on too many embeded targets
> where 0 is a valid address, and every time I hit a "zero is special"
> case in GDB I die a little inside.

Yes, I'm not entirely happy with that either, it just seemed
acceptable for now.  Your solution in the decoder just looked funny to
me, because it isn't a bug in the decoder if it is given a bogus
address to decode.  We should avoid giving it a bogus address in the
first place.

get_frame_func is calling get_pc_function_start which returns 0 if it
can't find the correct value.  Perhaps there should be a better way
for this function to indicate an error, and then we can avoid passing
a bogus 0 address into the decoder.  Maybe also
get_frame_func_if_available should avoid setting prev_func.p to 1 when
get_pc_function_start fails.  This would generate an exception from
get_frame_func which we could catch.

> Yeah, OK.  I don't think I see this as being as big a problem as you
> do, the targets in an undefined state, we see undefined things.  I can
> live with that.  I'm pretty sure that even with you special case zero
> fix, you still see undefined state, its just that some of the value
> are undefined to zero....  That said, I do agree a little that leaving
> the frame cache partially initialised probably isn't that great.

I don't know if this is a problem or not.  It just seemed unwise to
have some possibly wrong info in there.

> The revised patch below achieves the result you would like (not
> setting the frame id) but does so without special casing address
> zero.  How do you feel about this?

>         * riscv-tdep.c (riscv_insn::decode): Update header comment.
>         (riscv_frame_this_id): Catch errors thrown while building the
>         frame cache, leave the frame id as the default, which is the outer
>         frame id.

Yes, I like this better, because the fix is closer to where the real
problem is, in the riscv frame cache code.

Jim


      reply	other threads:[~2018-11-06 19:40 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
2018-11-06 11:18     ` Andrew Burgess
2018-11-06 19:40       ` Jim Wilson [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='CAFyWVaZHwOMPqDP63tju-tP=8qZBc3SHeMm3DQSr5D40NVVPHw@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