From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 127424 invoked by alias); 26 Jun 2018 20:32:26 -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 127414 invoked by uid 89); 26 Jun 2018 20:32:25 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM,KAM_SHORT,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=uploaded, Hx-languages-length:2893, all, HX-Received:sk:w13-v6m X-HELO: mail-wr0-f177.google.com Received: from mail-wr0-f177.google.com (HELO mail-wr0-f177.google.com) (209.85.128.177) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 26 Jun 2018 20:32:24 +0000 Received: by mail-wr0-f177.google.com with SMTP id p1-v6so2914187wrs.9 for ; Tue, 26 Jun 2018 13:32:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:subject:from:to:cc:date:in-reply-to:references :mime-version:content-transfer-encoding; bh=MKHj03lkHQ040EFYfeQ9vZ9j1tZexFL6H/y9++16rQU=; b=Cygq/1T+0O59kS4oXT1Os3NSHrqOCyy0/rCDpaeiEL7Zo3bilW6KG5CFc9xgbVkHxS gY/OwxeXvMYbb0/lTHNL/HkW7zyShKwB2tKMDr+vBz4oR2JSTLJko1hmb3e/7h6oRE+d li8f4pGzMcTwykIfVkz9UgtGddY4bwU7E+OCAT6A4eJdpOYZ+l05XNljXwrjnBm+Ukbs IgckjpM0p2pnOt6FOuYJa3r7NvGcxT+pAWxfn8k/+PP/8bPHU4o0H6l64/dF8gMpZLhi hZGp1zbyWAurG9OVoza8xGRfbxCgsgOIjEZSjv1WG9o22yeZdJCzb6jR1ZTcwT1opZUd Y2hQ== Return-Path: Received: from [192.168.1.11] ([105.184.225.243]) by smtp.gmail.com with ESMTPSA id 203-v6sm4681136wmp.23.2018.06.26.13.32.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 26 Jun 2018 13:32:21 -0700 (PDT) Message-ID: <1530045135.6272.16.camel@gmail.com> Subject: Re: AVR - invalid address used when evaluating a variable From: Christo To: Simon Marchi Cc: gdb@sourceware.org, christo.crause@gmail.com Date: Tue, 26 Jun 2018 20:32:00 -0000 In-Reply-To: <9371449a502b565344361885fd86c980@polymtl.ca> References: <1529868512.24104.26.camel@gmail.com> <9371449a502b565344361885fd86c980@polymtl.ca> Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: 8bit X-IsSubscribed: yes X-SW-Source: 2018-06/txt/msg00012.txt.bz2 On Mon, 2018-06-25 at 21:02 -0400, Simon Marchi wrote: > I am not proficient in Pascal.  Can you provide a test program, with all  > the command lines needed to reproduce? Hi Simon, I'm using the development version of the Freepascal compiler to get the latest AVR support, so bootstrapping a compiler to compile my test program may be too much hassle. Anyway, the example code can be seen here: https://github.com/ccrause/fpc-avr/blob/master/src/examples/blink2/blink. pp I've also uploaded the compiled elf file in case you rather want to use this instead of compiling it: https://github.com/ccrause/fpc-avr/blob/master/src/examples/blink2/bin/blink.elf Anyway the compiler command line: fpc/3.1.1/compiler/ppcrossavr -Tembedded -Pavr -CpAVR25 -MObjFPC -Scghi -O4 -g -l -vewnhibq -Filib/avr-embedded -Fu../../library -Fu. -FUlib/avr-embedded -FE. -oblink -Wpattiny45 -g -a -XPavr- -al -Sm -Si -dF_CPU:=8000000 An example of a gdb session: ~/fpc/fpc-avr/src/examples/blink2 $ ~/gdb/gdb-8.1/gdb/avr-gdb-8.1.0-original  GNU gdb (GDB) 8.1 Copyright (C) 2018 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.  Type "show copying" and "show warranty" for details. This GDB was configured as "--host=x86_64-pc-linux-gnu --target=avr". Type "show configuration" for configuration details. For bug reporting instructions, please see: . Find the GDB manual and other documentation resources online at: . For help, type "help". Type "apropos word" to search for commands related to "word". (gdb) file bin/blink.elf  Reading symbols from bin/blink.elf...done. (gdb) target remote :2345 Remote debugging using :2345 0x00000000 in _START () (gdb) load Loading section .text, size 0xb2 lma 0x0 Loading section .data, size 0x2 lma 0xb2 Start address 0x0, load size 180 Transfer rate: 505 bytes/sec, 25 bytes/write. (gdb) set language pascal (gdb) set debug remote 1 (gdb) print i Sending packet: $m60,1#30...Ack Packet received: 20 $1 = 32 (gdb) print @i $2 = (^Sending packet: $m800060,8#ff...Ack Packet received: 04000A00F6777DD2 Byte) 0x800060 #4 (gdb) print (@i)^ Sending packet: $m800060,1#f8...Ack Packet received: 04 $3 = 4 (gdb) >From the above "print i" instruction one can see that gdb requests the memory content of address 0x60 which is in flash.  The "print @i" instruction should print the address of variable i, which is correct, 0x800060. I have also tested an equivalent C program compiled with avr-gcc, with gdb reading the correct SRAM address for the value of i.  This makes me wonder if the symbol information generated by Freepascal is correct?