From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5374 invoked by alias); 8 Mar 2011 17:04:24 -0000 Received: (qmail 5357 invoked by uid 22791); 8 Mar 2011 17:04:23 -0000 X-SWARE-Spam-Status: No, hits=-2.0 required=5.0 tests=AWL,BAYES_00,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from sibelius.xs4all.nl (HELO glazunov.sibelius.xs4all.nl) (83.163.83.176) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 08 Mar 2011 17:04:17 +0000 Received: from glazunov.sibelius.xs4all.nl (kettenis@localhost [127.0.0.1]) by glazunov.sibelius.xs4all.nl (8.14.3/8.14.3) with ESMTP id p28H3wP2006349; Tue, 8 Mar 2011 18:03:58 +0100 (CET) Received: (from kettenis@localhost) by glazunov.sibelius.xs4all.nl (8.14.3/8.14.3/Submit) id p28H3u7q027427; Tue, 8 Mar 2011 18:03:56 +0100 (CET) Date: Tue, 08 Mar 2011 17:04:00 -0000 Message-Id: <201103081703.p28H3u7q027427@glazunov.sibelius.xs4all.nl> From: Mark Kettenis To: eager@eagerm.com CC: tromey@redhat.com, gdb@sourceware.org In-reply-to: <4D765DB9.5000708@eagerm.com> (message from Michael Eager on Tue, 08 Mar 2011 08:47:53 -0800) Subject: Re: Translate memory addresses References: <4D741E53.2090104@eagerm.com> <4D765DB9.5000708@eagerm.com> 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: 2011-03/txt/msg00058.txt.bz2 > Date: Tue, 08 Mar 2011 08:47:53 -0800 > From: Michael Eager > > Tom Tromey wrote: > >>>>>> "Michael" == Michael Eager writes: > > > > Michael> I'm working with a target which needs to translate > > Michael> a virtual memory addresses to a physical address > > Michael> before accessing the target's memory or the core file. > > > > Michael> Core_ops is defined in corelow.c, and there doesn't appear > > Michael> to be an obvious hook for the target code to modify it to > > Michael> add the translation routine. > > > > Michael> Any suggestions on the best way to add a hook or how to specify > > Michael> a target routine to do address translations for core files? > > > > I am not an expert in this area, but couldn't you make a new > > arch_stratum target that does the translation? > > > > With this approach maybe you don't even need a hook -- just do the > > translation and call the target beneath. > > Interesting idea. I didn't think of adding a stratum for translation. > > I took a clue from the way that sol-thread.c prevents corelow.c > from calling add_target to install core_ops. I added the following > to corelow.c: > > CORE_ADDR (*target_translate_address) (struct target_ops *, CORE_ADDR addr); > > and in init_core_ops(): > > core_ops.to_translate_address = target_translate_address; > > The target code contains a definition for target_translate_address > which is initialized to point to the translation routine. For other > targets, this will be zero. > > It's inelegant, what can I say, but functional. Did you look at how the BSD kvm target does things? It does a physical to virtual address translation (by using the system-provided libkvm), and seems to get away with this without having such a hook.