From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32541 invoked by alias); 2 Nov 2009 16:04:34 -0000 Received: (qmail 32360 invoked by uid 22791); 2 Nov 2009 16:04:33 -0000 X-SWARE-Spam-Status: No, hits=-2.3 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from mel.act-europe.fr (HELO mel.act-europe.fr) (212.99.106.210) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 02 Nov 2009 16:04:29 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 2FEEF290059; Mon, 2 Nov 2009 17:04:27 +0100 (CET) Received: from mel.act-europe.fr ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id TgZeJVci-IMp; Mon, 2 Nov 2009 17:04:26 +0100 (CET) Received: from ulanbator.act-europe.fr (ulanbator.act-europe.fr [10.10.1.67]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by mel.act-europe.fr (Postfix) with ESMTP id 8962C290009; Mon, 2 Nov 2009 17:04:26 +0100 (CET) Subject: Re: Help: address vs pointer Mime-Version: 1.0 (Apple Message framework v1076) Content-Type: text/plain; charset=us-ascii; format=flowed; delsp=yes From: Tristan Gingold In-Reply-To: <20091102154836.GG4573@adacore.com> Date: Mon, 02 Nov 2009 16:04:00 -0000 Cc: gdb@sourceware.org Content-Transfer-Encoding: 7bit Message-Id: <6B38A90C-7D7C-40C8-94DC-C4564F4A22AE@adacore.com> References: <26EF10E2-E2F3-4822-9CD6-4B90CF7B2CE3@adacore.com> <20091102154836.GG4573@adacore.com> To: Joel Brobecker X-IsSubscribed: yes 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 X-SW-Source: 2009-11/txt/msg00009.txt.bz2 On Nov 2, 2009, at 4:48 PM, Joel Brobecker wrote: >> So what should be the type of the pc register ? If it is a pointer >> to >> instructions, 'print $pc' would be wrong as it would be multiplied >> by >> 4 (once by read_pc and once during evaluation). > > My not-so-educated feeling on this issue is that PC should be a > pointer > to instruction. What seems strange is that the PC value gets doubled > twice. I understand why during the read, but not why during the eval. > Perhaps there is something we can do there? I was able to work-around this issue by creating a pseudo-register named 'pc'. This pseudo register is a pointer to instruction whose value is really the program counter (not multiplied by 2). Using this pseudo-register, everything work well. So I think this is the simplest solution! However it is still difficult to set a breakpoint to a 'random' address: break *0x1234 doesn't work because 0x1234 is interpreted as an integer which is converted to a pointer in the data space. Unfortunately, break *(void (*)())0x1234 works only when addresses are in the lower 64KW instruction address space (because a pointer is 16 bits). But some AVR have 128KW/ 256KB of instructions... But we can still use 'break *(&func + 0x1234)' ! Tristan.