From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 33978 invoked by alias); 26 Jun 2018 01:02:30 -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 33967 invoked by uid 89); 26 Jun 2018 01:02:29 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-1.1 required=5.0 tests=AWL,BAYES_05,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 spammy=H*u:Webmail, H*UA:Roundcube, H*u:Roundcube, avr X-HELO: smtp.polymtl.ca Received: from smtp.polymtl.ca (HELO smtp.polymtl.ca) (132.207.4.11) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 26 Jun 2018 01:02:28 +0000 Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id w5Q12LQr014040 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 25 Jun 2018 21:02:26 -0400 Received: by simark.ca (Postfix, from userid 112) id 639621EF29; Mon, 25 Jun 2018 21:02:21 -0400 (EDT) Received: from simark.ca (localhost [127.0.0.1]) by simark.ca (Postfix) with ESMTP id 86BA81E529; Mon, 25 Jun 2018 21:02:19 -0400 (EDT) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Date: Tue, 26 Jun 2018 01:02:00 -0000 From: Simon Marchi To: Christo Cc: gdb@sourceware.org Subject: Re: AVR - invalid address used when evaluating a variable In-Reply-To: <1529868512.24104.26.camel@gmail.com> References: <1529868512.24104.26.camel@gmail.com> Message-ID: <9371449a502b565344361885fd86c980@polymtl.ca> X-Sender: simon.marchi@polymtl.ca User-Agent: Roundcube Webmail/1.3.6 X-IsSubscribed: yes X-SW-Source: 2018-06/txt/msg00009.txt.bz2 On 2018-06-24 15:28, Christo wrote: > I am testing the debugging of AVR microcontrollers over debugWIRE with > gdb. When evaluating the > value of a variable I noticed an incorrect value. On closer inspection > I realized that gdb (8.1 > compiled for AVR support) was reading flash memory, not SRAM.  When I > evaluate the pointer to > the variable, gdb correctly reports the SRAM address. When reading the > memory pointed to by this > pointer the correct value is returned.  This leads me to postulate > that there is a > mistake/omission when gdb evaluates/prints a variable, resolve its > address and then reads it > from flash rather than SRAM. > > Below a short excerpt of debugging a simple program with a variable > "i" which the compiler > located at address 0 in SRAM (which should be mapped to 0x800060, > right after the io registers). > The program was compiled with Freepascal and debugged using a > debugWIRE server.  I've called > "set debug remote 1" so that the rsp requests can be seen: > > (gdb) print i > Sending packet: $m60,1#30...Ack > Packet received: 20 > $7 = 32 ' ' > (gdb) print &i > $8 = (Byte *) 0x800060 Sending packet: > $m800060,8#ff...Ack > Packet received: 020003B8F6777DD2 > "\002" > (gdb) print *&i > Sending packet: $m800060,1#f8...Ack > Packet received: 02 > $9 = 2 '\002' > > Can anyone confirm this behaviour is indeed wrong/unexpected? Hi Christo, I am not proficient in Pascal. Can you provide a test program, with all the command lines needed to reproduce? Thanks, Simon