From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9170 invoked by alias); 24 Oct 2003 20:27:02 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 9153 invoked from network); 24 Oct 2003 20:27:01 -0000 Received: from unknown (HELO localhost.redhat.com) (207.219.125.105) by sources.redhat.com with SMTP; 24 Oct 2003 20:27:01 -0000 Received: from redhat.com (localhost [127.0.0.1]) by localhost.redhat.com (Postfix) with ESMTP id 6D57E2B89; Fri, 24 Oct 2003 16:27:02 -0400 (EDT) Message-ID: <3F998B16.4090407@redhat.com> Date: Fri, 24 Oct 2003 20:27:00 -0000 From: Andrew Cagney User-Agent: Mozilla/5.0 (X11; U; NetBSD macppc; en-US; rv:1.0.2) Gecko/20030820 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Kevin Buettner , gdb-patches@sources.redhat.com Subject: [commit] Add get_target_memory ... + Use target in convert_from_func_ptr_addr References: <3F9730C3.1040308@redhat.com> <1031023160017.ZM13795@localhost.localdomain> <3F980124.6050409@redhat.com> <1031023171155.ZM14125@localhost.localdomain> <3F9841E0.5080700@redhat.com> <1031023212255.ZM1334@localhost.localdomain> Content-Type: multipart/mixed; boundary="------------060708030209000302010605" X-SW-Source: 2003-10/txt/msg00751.txt.bz2 This is a multi-part message in MIME format. --------------060708030209000302010605 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Content-length: 568 > On Oct 23, 5:02pm, Andrew Cagney wrote: > > >> If you want I can add a wrapper method, reducing the actual change to >> just the modification of: >> >> - return read_memory_unsigned_integer (addr, 8); >> >> to: >> >> + return get_target_memory_unsigned (targ, addr, 8); > > > That'd be great. (With this change, consider it approved.) I've committed the attached. It also adds the new target wrapper methods: get_target_memory and get_target_memory_unsigned (I'm wondering about putting them in a separate file, but that's separate ...) Andrew --------------060708030209000302010605 Content-Type: text/plain; name="diffs" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="diffs" Content-length: 3944 2003-10-24 Andrew Cagney * target.c: Include "gdbcore.h". (get_target_memory, get_target_memory_unsigned): New functions. * target.h (get_target_memory, get_target_memory_unsigned): Declare. * ppc-linux-tdep.c (ppc64_linux_convert_from_func_ptr_addr): Use get_target_memory_unsigned. * Makefile.in (target.o): Update dependencies. Index: Makefile.in =================================================================== RCS file: /cvs/src/src/gdb/Makefile.in,v retrieving revision 1.462 diff -u -r1.462 Makefile.in --- Makefile.in 23 Oct 2003 22:36:14 -0000 1.462 +++ Makefile.in 24 Oct 2003 20:21:53 -0000 @@ -2367,7 +2367,8 @@ $(block_h) $(dictionary_h) $(gdb_string_h) $(gdb_stat_h) $(cp_abi_h) target.o: target.c $(defs_h) $(gdb_string_h) $(target_h) $(gdbcmd_h) \ $(symtab_h) $(inferior_h) $(bfd_h) $(symfile_h) $(objfiles_h) \ - $(gdb_wait_h) $(dcache_h) $(regcache_h) $(gdb_assert_h) + $(gdb_wait_h) $(dcache_h) $(regcache_h) $(gdb_assert_h) \ + $(gdbcore_h) thread.o: thread.c $(defs_h) $(symtab_h) $(frame_h) $(inferior_h) \ $(environ_h) $(value_h) $(target_h) $(gdbthread_h) $(command_h) \ $(gdbcmd_h) $(regcache_h) $(gdb_h) $(gdb_string_h) $(ui_out_h) Index: ppc-linux-tdep.c =================================================================== RCS file: /cvs/src/src/gdb/ppc-linux-tdep.c,v retrieving revision 1.44 diff -u -r1.44 ppc-linux-tdep.c --- ppc-linux-tdep.c 22 Oct 2003 23:54:11 -0000 1.44 +++ ppc-linux-tdep.c 24 Oct 2003 20:21:54 -0000 @@ -936,13 +936,11 @@ CORE_ADDR addr, struct target_ops *targ) { - struct obj_section *s; - - s = find_pc_section (addr); + struct section_table *s = target_section_by_addr (targ, addr); /* Check if ADDR points to a function descriptor. */ if (s && strcmp (s->the_bfd_section->name, ".opd") == 0) - return read_memory_unsigned_integer (addr, 8); + return get_target_memory_unsigned (targ, addr, 8); return addr; } Index: target.c =================================================================== RCS file: /cvs/src/src/gdb/target.c,v retrieving revision 1.62 diff -u -r1.62 target.c --- target.c 23 Oct 2003 00:13:53 -0000 1.62 +++ target.c 24 Oct 2003 20:21:54 -0000 @@ -37,6 +37,7 @@ #include #include "regcache.h" #include "gdb_assert.h" +#include "gdbcore.h" static void target_info (char *, int); @@ -1212,6 +1213,28 @@ QUIT; } return len; +} + +/* Memory transfer methods. */ + +void +get_target_memory (struct target_ops *ops, CORE_ADDR addr, void *buf, + LONGEST len) +{ + if (target_read (ops, TARGET_OBJECT_MEMORY, NULL, buf, addr, len) + != len) + memory_error (EIO, addr); +} + +ULONGEST +get_target_memory_unsigned (struct target_ops *ops, + CORE_ADDR addr, int len) +{ + char buf[sizeof (ULONGEST)]; + + gdb_assert (len <= sizeof (buf)); + get_target_memory (ops, addr, buf, len); + return extract_unsigned_integer (buf, len); } static void Index: target.h =================================================================== RCS file: /cvs/src/src/gdb/target.h,v retrieving revision 1.48 diff -u -r1.48 target.h --- target.h 23 Oct 2003 03:01:55 -0000 1.48 +++ target.h 24 Oct 2003 20:21:54 -0000 @@ -248,6 +248,18 @@ enum target_object object, const char *annex, const void *buf, ULONGEST offset, LONGEST len); + +/* Wrappers to target read/write that perform memory transfers. They + throw an error if the memory transfer fails. + + NOTE: cagney/2003-10-23: The naming schema is lifted from + "frame.h". The parameter order is lifted from get_frame_memory, + which in turn lifted it from read_memory. */ + +extern void get_target_memory (struct target_ops *ops, CORE_ADDR addr, + void *buf, LONGEST len); +extern ULONGEST get_target_memory_unsigned (struct target_ops *ops, + CORE_ADDR addr, int len); /* If certain kinds of activity happen, target_wait should perform --------------060708030209000302010605--