From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16496 invoked by alias); 14 Dec 2016 17:02:05 -0000 Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org Received: (qmail 16482 invoked by uid 89); 14 Dec 2016 17:02:05 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=H*MI:CAGDihe, H*f:sk:wwokeg1, H*i:sk:wwokeg1, life X-HELO: mail-io0-f175.google.com Received: from mail-io0-f175.google.com (HELO mail-io0-f175.google.com) (209.85.223.175) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 14 Dec 2016 17:01:55 +0000 Received: by mail-io0-f175.google.com with SMTP id p42so45651504ioo.1 for ; Wed, 14 Dec 2016 09:01:55 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=RC6VHwWYBMjSgTsqyo8/Dv3e4tz7wGlNVzV/9i5/u2Q=; b=gOifEPv8rEK8BRC4EVXSLcq202vBss3BJf5MEmGaginwg2fTrdqCXlyQqcTuvNV/VC wVWbUs4sIP39gdQ0fuq77GbucOVfEeJiZYMzURTowzD+UtlggvMfPWLUioAKhGKxv/4c pF0Bt/A46zdX7pODUFkzi6uVRIpqfdDmrLOKdGZ19qNKkRxoGwIWhSj3B2Y9D3oSS06R 6g1eehIq9pomrSND7ca1DREkRGzi3xrxZrrS5FDEyyMckNnWDvHVdme0oZuzaYIwQCU/ xjm0XBkpK+OoyfYhp+zNT3qwtBKaJwTsuMe5PO5CcnQE+4/siCUVoXczSelashWNlCJv bwgQ== X-Gm-Message-State: AKaTC00nWL5goopD1AHYT5YJJVow07uimXSdpIRpzp9c6poYJvk7qkLXniL0V6t91QlQbzWcf0PeTWeg/X+AVg== X-Received: by 10.107.145.69 with SMTP id t66mr91256619iod.203.1481734913590; Wed, 14 Dec 2016 09:01:53 -0800 (PST) MIME-Version: 1.0 Received: by 10.107.173.17 with HTTP; Wed, 14 Dec 2016 09:01:53 -0800 (PST) In-Reply-To: References: <20161214091811.GH25542@E107787-LIN> From: Tim Newsome Date: Wed, 14 Dec 2016 17:02:00 -0000 Message-ID: Subject: Re: read target register to decide breakpoint size To: Antoine Tremblay Cc: Yao Qi , gdb Content-Type: text/plain; charset=UTF-8 X-IsSubscribed: yes X-SW-Source: 2016-12/txt/msg00022.txt.bz2 On Wed, Dec 14, 2016 at 4:32 AM, Antoine Tremblay wrote: > > Yao Qi writes: > >> On 16-12-13 13:30:02, Tim Newsome wrote: >>> Actually, this seems to work inside breakpoint_kind_from_pc(): >>> ``` >>> struct frame_info *frame = get_current_frame (); >>> uint32_t misa = get_frame_register_unsigned (frame, RISCV_CSR_MISA_REGNUM); >>> ``` >>> >>> Is that kosher? If so, is there any reason for me to implement >>> breakpoint_kind_from_current_state? >> >> I'd like not to do so. Can't you decode the instruction to see whether >> it is compressed or uncompressed? I also think it is a good idea to >> make a decision based on ELF info, as you mentioned in the first email. > > Correct me if I'm wrong but reading the RISC-V arch manual, it seems > like the MISA register information is static. > > So unlike arm where the ISA might change, on RISC-V it is static for the > life of the program ? That's right. MISA doesn't ever change. > If that's true, and that you can't decode the instruction, it doesn't > seem that bad to use the register in kind_from_pc ? I could take a stab at decoding the instruction, but that seems a lot more painful. 1. It's more code to write. 2. RISC-V encourages people adding custom instructions, which gdb shouldn't have to know about. 3. Decoding the instruction might force a memory read, which is slow. I only need to read MISA once. > Yao, was your concern that this would be non-static, or there is another > reason ? > > However thinking about the ELF info, could you elaborate on why it may > not reflect what is actually being executed ? And how this is a problem > ? In the simplest case, I can connect to my target using OpenOCD, and not tell gdb what file is being executed. It should still be possible to debug at the assembly level in that case. > A note about _from_current_state too this is used while single_stepping > since GDB knows it's about to set a breakpoint from a known state to > the next location, this differs from from_pc which is used to set a pc from > any state to any location. > > So in your case it's really from_pc that you want. I see. So that's a case for ARM where it could look at cpsr. Thank you, sounds like reading MISA from kind_from_pc should work out fine then (unless Yao has an objection we didn't consider). Tim