From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 41050 invoked by alias); 6 Mar 2018 11:35:08 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 41024 invoked by uid 89); 6 Mar 2018 11:35:07 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=rationale, H*r:sk:static. X-HELO: mail-wr0-f196.google.com Received: from mail-wr0-f196.google.com (HELO mail-wr0-f196.google.com) (209.85.128.196) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 06 Mar 2018 11:35:06 +0000 Received: by mail-wr0-f196.google.com with SMTP id n7so20579795wrn.5 for ; Tue, 06 Mar 2018 03:35:05 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references :user-agent:date:message-id:mime-version:content-transfer-encoding; bh=NC3NGomZiMPVK6oUg+3NwSunzhP734EIvetBoH6kBb8=; b=E8uk85CFei7gZle7hJDScffxQPU45pWNG1iDt6HoJ27MmuixDCHtaOymQi0xFnfsp9 8M0eCCbzFkpSEZZ/LmHkjXAJ68a34huE0nRWQBvBKTHQ9L8Id2XUMTBisE1YaUcmdTOX WnsFWIuO2dvoZuLWKdTU3gUucw0CpfkKbtj3rOsYQaep4nHfn6opLcHuqy+lmPKXDhW6 BNdL28fxgQr7uZf375rfFoGkZiAsv9H/aUCxDSn5k0K7FhqB1uETJUiiWTudVKKl7kIT HcYDTjGA8OonGASFLBEWRy9KRf5Jl7vWurG5nH2pCjiF4GgcKZAJIQUMsQt+jtgbFRg8 vtcw== X-Gm-Message-State: APf1xPAJBfKSPCsgKg/+FBnl+TgCB0E6NjxELY23bL6TVRwwpl2/m4Ru MIL5qRBNw80tLduXTLrJUdo= X-Google-Smtp-Source: AG47ELuPD+BZunNMOI+QmiKFOGpJ36hYOSn2DNxU1waBVvj18Ur7HCCjK8XkwoOlMei96jHM7J1nmw== X-Received: by 10.223.149.70 with SMTP id 64mr15216198wrs.76.1520336104297; Tue, 06 Mar 2018 03:35:04 -0800 (PST) Received: from E107787-LIN (static.42.136.251.148.clients.your-server.de. [148.251.136.42]) by smtp.gmail.com with ESMTPSA id y145sm8306672wmd.43.2018.03.06.03.35.03 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Tue, 06 Mar 2018 03:35:03 -0800 (PST) From: Yao Qi To: Andrew Burgess Cc: Simon Marchi , gdb-patches@sourceware.org, Eli Zaretskii Subject: Re: [PATCHv4 2/2] gdb: Initial baremetal riscv support In-Reply-To: <20180305104543.GA2612@embecosm.com> (Andrew Burgess's message of "Mon, 5 Mar 2018 10:45:44 +0000") References: <430dd07a2ed6520ad17108eb156935ec86cec826.1520021226.git.andrew.burgess@embecosm.com> <3e083125-4a39-04ee-45cc-0152ced1e259@simark.ca> <20180305104543.GA2612@embecosm.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) Date: Tue, 06 Mar 2018 11:35:00 -0000 Message-ID: <86a7vl309q.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes X-SW-Source: 2018-03/txt/msg00136.txt.bz2 Andrew Burgess writes: > +/* Read the MISA register from the target. The register will only be re= ad > + once, and the value read will be cached. If the register can't be re= ad > + 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 > + =3D riscv_inferior_data (current_inferior ()); > + > + if (!inf_data->misa_read && target_has_registers) > + { > + uint32_t value =3D 0; > + struct frame_info *frame =3D get_current_frame (); > + > + TRY > + { > + value =3D 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 =3D get_frame_register_unsigned (frame, > + RISCV_CSR_LEGACY_MISA_REGNUM); > + } > + END_CATCH > + > + inf_data->misa_read =3D true; > + inf_data->misa_value =3D value; > + } > + > + if (read_p !=3D nullptr) > + *read_p =3D inf_data->misa_read; > + > + return inf_data->misa_value; > +} --=20 Yao (=E9=BD=90=E5=B0=A7)