From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11468 invoked by alias); 5 Mar 2006 11:59:03 -0000 Received: (qmail 11455 invoked by uid 22791); 5 Mar 2006 11:59:03 -0000 X-Spam-Check-By: sourceware.org Received: from mta08-winn.ispmail.ntl.com (HELO mta08-winn.ispmail.ntl.com) (81.103.221.48) by sourceware.org (qpsmtpd/0.31) with ESMTP; Sun, 05 Mar 2006 11:59:00 +0000 Received: from aamta10-winn.ispmail.ntl.com ([81.103.221.35]) by mta08-winn.ispmail.ntl.com with ESMTP id <20060305115858.SJQM29066.mta08-winn.ispmail.ntl.com@aamta10-winn.ispmail.ntl.com>; Sun, 5 Mar 2006 11:58:58 +0000 Received: from localhost.localdomain ([80.6.83.112]) by aamta10-winn.ispmail.ntl.com with ESMTP id <20060305115857.PHZO20857.aamta10-winn.ispmail.ntl.com@localhost.localdomain>; Sun, 5 Mar 2006 11:58:57 +0000 Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by localhost.localdomain (8.13.4/8.13.4) with ESMTP id k25Bwhxm020623; Sun, 5 Mar 2006 11:58:44 GMT Subject: Re: Fix powerpc64-linux inferior function calls From: David Lecomber To: gdb , patches Content-Type: multipart/mixed; boundary="=-79Fd3efZS1PHnQWjk85m" Date: Sun, 05 Mar 2006 11:59:00 -0000 Message-Id: <1141559923.3098.51.camel@localhost.localdomain> Mime-Version: 1.0 X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2006-03/txt/msg00038.txt.bz2 --=-79Fd3efZS1PHnQWjk85m Content-Type: text/plain Content-Transfer-Encoding: 7bit Content-length: 1543 This is not a request for patch approval.. more for assistance in getting the right patch given what this tells us.. The problem, is evaluating malloc in the target of a gcc -m64 compiled binary.. "p (((void* (*) (int)) &malloc) (sizeof(int)))" will cause a segfault in the inferior (certainly if malloc is not used by the target). I have discovered.. that the problem is when reading using get_target_memory_unsigned inside ppc64_linux_convert_from_func_ptr_addr. This goes down to target_read, which doesn't go through the whole checking down the stack of targets for a better reader., so when presented with current_target, it goes for default_xfer_partial - which, for some reason related to deprecated_xfer_partial, means it never goes to linux_nat_xfer_partial.. Moving to target_memory_read instead of get_target_memory inside get_target_memory_unsigned is a non-winner --- because this is used with a "temporary bfd" target to set a breakpoint whilst things are starting (I think..). So, any attempt to moving to using proper memory reading hierarchy is doomed by that. So, my attached patch, checks to see whether the target provided to ppc64_linux_convert_from_func_ptr_addr is the current target (not the bfd temp one). If it is, then it goes and uses the "nice" memory readers. Otherwise it falls back to the old.. It's a classic fixing the symptom, not the cause.. I'd prefer to fix the cause (hence I'm not suggesting including this, unless anyone really wants me to). d. -- David Lecomber --=-79Fd3efZS1PHnQWjk85m Content-Disposition: attachment; filename=target-read.patch Content-Type: text/x-patch; name=target-read.patch; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-length: 1544 *** /home/mark/skyride.sw/gdb-6.3.50.20051116/gdb/ppc-linux-tdep.c 2005-07-13 17:29:04.000000000 +0100 --- gdb/ppc-linux-tdep.c 2006-03-05 11:39:13.012233208 +0000 *************** *** 38,43 **** --- 38,44 ---- #include "trad-frame.h" #include "frame-unwind.h" #include "tramp-frame.h" + #include "gdb_assert.h" /* The following instructions are used in the signal trampoline code on GNU/Linux PPC. The kernel used to use magic syscalls 0x6666 and *************** ppc64_linux_convert_from_func_ptr_addr ( *** 794,805 **** CORE_ADDR addr, struct target_ops *targ) { 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 get_target_memory_unsigned (targ, addr, 8); ! return addr; } --- 795,816 ---- CORE_ADDR addr, struct target_ops *targ) { + char buf[sizeof (ULONGEST)]; 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) ! { ! if (targ != ¤t_target) ! return get_target_memory_unsigned (targ, addr, 8); ! else ! { ! gdb_assert (8 <= sizeof (buf)); ! target_read_memory(addr, buf, 8); ! return extract_unsigned_integer (buf, 8); ! } ! } return addr; } --=-79Fd3efZS1PHnQWjk85m--