public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Yao Qi <qiyaoltc@gmail.com>
To: Andrew Burgess <andrew.burgess@embecosm.com>
Cc: Simon Marchi <simark@simark.ca>,
	 gdb-patches@sourceware.org,  Eli Zaretskii <eliz@gnu.org>
Subject: Re: [PATCHv4 2/2] gdb: Initial baremetal riscv support
Date: Tue, 06 Mar 2018 11:35:00 -0000	[thread overview]
Message-ID: <86a7vl309q.fsf@gmail.com> (raw)
In-Reply-To: <20180305104543.GA2612@embecosm.com> (Andrew Burgess's message of	"Mon, 5 Mar 2018 10:45:44 +0000")

Andrew Burgess <andrew.burgess@embecosm.com> writes:

> +/* Read the MISA register from the target.  The register will only be read
> +   once, and the value read will be cached.  If the register can't be read
> +   from the target then a default value (0) will be returned.  If the

I don't understand the rationale that we maintain MISA register in a
per-inferior data.  Why don't we put it into regcache?  I know MISA
won't change, but it makes few sense to me to maintain register out of
regcache.

> +   pointer READ_P is not null, then the bool pointed to is updated  to
> +   indicate if the value returned was read from the target (true) or is the
> +   default (false).  */
> +
> +static uint32_t
> +riscv_read_misa_reg (bool *read_p)
> +{
> +  struct riscv_inferior_data *inf_data
> +    = riscv_inferior_data (current_inferior ());
> +
> +  if (!inf_data->misa_read && target_has_registers)
> +    {
> +      uint32_t value = 0;
> +      struct frame_info *frame = get_current_frame ();
> +
> +      TRY
> +	{
> +	  value = get_frame_register_unsigned (frame, RISCV_CSR_MISA_REGNUM);
> +	}
> +      CATCH (ex, RETURN_MASK_ERROR)
> +	{
> +	  /* Old cores might have MISA located at a different offset.  */
> +	  value = get_frame_register_unsigned (frame,
> +					       RISCV_CSR_LEGACY_MISA_REGNUM);
> +	}
> +      END_CATCH
> +
> +      inf_data->misa_read = true;
> +      inf_data->misa_value = value;
> +    }
> +
> +  if (read_p != nullptr)
> +    *read_p = inf_data->misa_read;
> +
> +  return inf_data->misa_value;
> +}

-- 
Yao (齐尧)

  parent reply	other threads:[~2018-03-06 11:35 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-13 19:15 [PATCH] " Andrew Burgess
2018-02-13 19:49 ` Eli Zaretskii
2018-02-19 20:01 ` Simon Marchi
2018-02-27  1:09 ` [PATCHv2] " Andrew Burgess
2018-02-27  3:33   ` Simon Marchi
2018-03-02 20:09     ` [PATCHv3 0/2] Initial RiscV Support Andrew Burgess
2018-03-02 20:10     ` [PATCHv3 2/2] gdb: Initial baremetal riscv support Andrew Burgess
2018-03-03  6:27       ` Simon Marchi
2018-03-05 10:46         ` [PATCHv4 " Andrew Burgess
2018-03-05 22:35           ` Simon Marchi
2018-03-06 11:06           ` Yao Qi
2018-03-06 11:35           ` Yao Qi [this message]
2018-03-03  7:40       ` [PATCHv3 " Eli Zaretskii
2018-03-02 20:10     ` [PATCHv3 1/2] gdb/amd64: Ignore zero sized fields when calling functions Andrew Burgess
2018-03-03  6:29       ` Simon Marchi
2018-02-27  3:37   ` [PATCHv2] gdb: Initial baremetal riscv support Simon Marchi

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=86a7vl309q.fsf@gmail.com \
    --to=qiyaoltc@gmail.com \
    --cc=andrew.burgess@embecosm.com \
    --cc=eliz@gnu.org \
    --cc=gdb-patches@sourceware.org \
    --cc=simark@simark.ca \
    /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).