From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com [209.85.221.47]) by sourceware.org (Postfix) with ESMTPS id 97FBB386C5BA for ; Fri, 17 Jun 2022 13:03:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 97FBB386C5BA Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=palves.net Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wr1-f47.google.com with SMTP id e25so1829981wrc.13 for ; Fri, 17 Jun 2022 06:03:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:references:from:in-reply-to :content-transfer-encoding; bh=0wR0D0+97Kw4bh6/+UITiJoMevJVYhlcqXpUsaF8Mmo=; b=UmS6MYCwTWc/dWZuvg2P3HSQ6/orvcVef7iYaByDUanDtOHjvTNWqSYD3lD4DTpoEl Fa7wTjZ6s0yVxUDXyOG8rJtCKvEiOlZ4UHZlKxOjlgbhZ9pL55yXyjxXIbykZV8Txr5c Ikw5/Z2WqjpxNy0T6X9HXwmluPrbIlHX8fuGJ2dSa+QCBXuO7rHF4Rh9b6kUuXz9Bgx2 enoCkbvnTJwr/T4MEliinKH/PvwheXYccyC/BxfRoFjbjvLfl6Axcc+IYws8Yo9ilYjG q10jvgpiuczl5IPvfIRzjgmktdZQFU+aMvpZA/PTYamJPxhcpEbXqaVtM12kX9p5brc9 TJkQ== X-Gm-Message-State: AJIora9hmG8RaLq3T0JXNr2NzEOHxepV5TqlEFODs0j3yWHaE83TXc3+ I0pPUTEhacHzQm7FTyRpaBE= X-Google-Smtp-Source: AGRyM1vpTK400cYdfjLMkff5J/zvtHrdcL/uMwsd0OxTJH+MXnVz2zZl5fkaqUfqMH9yDhfr7GuqIw== X-Received: by 2002:a5d:4889:0:b0:21b:293e:9e43 with SMTP id g9-20020a5d4889000000b0021b293e9e43mr2528649wrq.705.1655471024715; Fri, 17 Jun 2022 06:03:44 -0700 (PDT) Received: from ?IPV6:2001:8a0:f924:2600:209d:85e2:409e:8726? ([2001:8a0:f924:2600:209d:85e2:409e:8726]) by smtp.gmail.com with ESMTPSA id h8-20020a05600c350800b0039c50d2d28csm9369267wmq.44.2022.06.17.06.03.43 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 17 Jun 2022 06:03:43 -0700 (PDT) Message-ID: Date: Fri, 17 Jun 2022 14:03:38 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.10.0 Subject: Re: Some question about gdb unknown memory Content-Language: en-US To: Luis Machado , joe jo , "gdb@sourceware.org" References: <377d7fb9-445b-12d0-62f6-8c43c254bec8@arm.com> From: Pedro Alves In-Reply-To: <377d7fb9-445b-12d0-62f6-8c43c254bec8@arm.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-5.1 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 17 Jun 2022 13:03:48 -0000 On 2022-06-17 11:40, Luis Machado via Gdb wrote: > [switching to gdb@] > > On 5/20/22 07:51, joe jo wrote: >> Hi >> >> >> I met some questions when I used GDB to debugging my project. I'm writing this mail for some help. >> At first I set up my one gdb-server and use GDB to connect it. >> The problem happened when I use 'x' command to observe some unknown memory. >> In my design, when gdb ask for some unknown memorys or registers, my server will return '?' or some other signal. For instance, when my gdbserver receive command 'm90000000,4' and memory after 90000002 is unknown, the server will return XXXX????. Otherwise, the server will return unknown register like 1234???000?0000 when receive 'g' command >> However, when recieve ?, GDB will report errors like "Invalid hex digit 63". >> I have read the source code of binutils-gdb/gdb/remote.c to find the reason of error, but I still don't know how can I notice GDB about those unknown memory. >> In addition, I wonder how to use MI to sent the information about unknow memory to a eclipse-based front-end What do you mean exactly by "unknown memory"? Note this, here: https://sourceware.org/gdb/onlinedocs/gdb/Packets.html ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ‘m addr,length’ Read length addressable memory units starting at address addr (...). (...) Reply: ‘XX…’ Memory contents; each byte is transmitted as a two-digit hexadecimal number. The reply may contain ^^^^^^^^^^^^^^^^^^^^^ fewer addressable memory units than requested if the server was able to read only part ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ of the region of memory. ^^^^^^^^^^^^^^^^^^^^^^^^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ So if GDB sends 'm90000000,4', and there's only 2 bytes available to read, you can return those two bytes. If GDB really needs the remaining 2 bytes, then it will try to read the remaining bytes, with 'm90000002,2', and if memory at 90000002 isn't accessible, the stub should return an error reply, and GDB will say something like, "cannot access memory at $ADDR". >> >> >> I look forward to hearing from you soon. >> Joe Jo > > Only registers can have unknown/unavailable values, marked as lowercase 'x' in the register packet reply. Memory reads don't have such support, so '?' is essentially not recognized as something valid.