From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25813 invoked by alias); 22 Aug 2008 17:49:37 -0000 Received: (qmail 25801 invoked by uid 22791); 22 Aug 2008 17:49:35 -0000 X-Spam-Check-By: sourceware.org Received: from mtagate2.de.ibm.com (HELO mtagate2.de.ibm.com) (195.212.17.162) by sourceware.org (qpsmtpd/0.31) with ESMTP; Fri, 22 Aug 2008 17:48:53 +0000 Received: from d12nrmr1607.megacenter.de.ibm.com (d12nrmr1607.megacenter.de.ibm.com [9.149.167.49]) by mtagate2.de.ibm.com (8.13.1/8.13.1) with ESMTP id m7MHmnDZ019713 for ; Fri, 22 Aug 2008 17:48:49 GMT Received: from d12av02.megacenter.de.ibm.com (d12av02.megacenter.de.ibm.com [9.149.165.228]) by d12nrmr1607.megacenter.de.ibm.com (8.13.8/8.13.8/NCO v9.0) with ESMTP id m7MHmnLD4321306 for ; Fri, 22 Aug 2008 19:48:49 +0200 Received: from d12av02.megacenter.de.ibm.com (loopback [127.0.0.1]) by d12av02.megacenter.de.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id m7MHmkLT004837 for ; Fri, 22 Aug 2008 19:48:46 +0200 Received: from tuxmaker.boeblingen.de.ibm.com (tuxmaker.boeblingen.de.ibm.com [9.152.85.9]) by d12av02.megacenter.de.ibm.com (8.12.11.20060308/8.12.11) with SMTP id m7MHmkpd004832; Fri, 22 Aug 2008 19:48:46 +0200 Message-Id: <200808221748.m7MHmkpd004832@d12av02.megacenter.de.ibm.com> Received: by tuxmaker.boeblingen.de.ibm.com (sSMTP sendmail emulation); Fri, 22 Aug 2008 19:48:46 +0200 Subject: [rfc] Displaced stepping with wrong entry point address To: gdb-patches@sourceware.org Date: Fri, 22 Aug 2008 17:49:00 -0000 From: "Ulrich Weigand" Cc: pedro@codesourcery.com X-Mailer: ELM [version 2.5 PL2] MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2008-08/txt/msg00588.txt.bz2 Hello, displaced stepping caused a regression for the Cell multi-arch debugger. This is because the default displaced_step_at_entry_point routine uses entry_point_address to determine where to put the displaced instruction. This is a problem when debugging a stand-alone SPU executable using the multi-arch debugger, because entry_point_address will point to the SPU entry point, while we need a place in PowerPC address space to execute displaced PowerPC code. (SPU currently does not use displaced stepping, and this probably does not really matter, as a single SPU context is always single-threaded.) The following patch makes the multi-arch debugger work again, by using the AT_ENTRY auxiliary vector to find the entry point address. This will always point to the PowerPC-side entry point. I'm wondering whether this fix would be good for the general case too -- there may be situations where entry_point_address does not work (e.g. because the main executable file could not be loaded). The auxiliary vector, on targets where it is present, will probably be more reliable ... What do you think? Tested on powerpc-linux and powerpc64-linux. Bye, Ulrich ChangeLog: * arch-utils.c: Include "target.h", "auxv.h" and "elf/common.h". (displaced_step_at_entry_point): Use AT_ENTRY auxiliary vector to determine entry point address. diff -urNp src-orig/gdb/arch-utils.c src/gdb/arch-utils.c --- src-orig/gdb/arch-utils.c 2008-08-18 02:34:56.000000000 +0200 +++ src/gdb/arch-utils.c 2008-08-18 02:37:42.288892324 +0200 @@ -32,6 +32,9 @@ #include "osabi.h" #include "target-descriptions.h" #include "objfiles.h" +#include "target.h" +#include "auxv.h" +#include "elf/common.h" #include "version.h" @@ -74,7 +77,10 @@ displaced_step_at_entry_point (struct gd CORE_ADDR addr; int bp_len; - addr = entry_point_address (); + /* Determine entry point from target auxiliary vector. Fall back + to entry point from symbol file if not found. */ + if (target_auxv_search (¤t_target, AT_ENTRY, &addr) <= 0) + addr = entry_point_address (); /* Make certain that the address points at real code, and not a function descriptor. */ -- Dr. Ulrich Weigand GNU Toolchain for Linux on System z and Cell BE Ulrich.Weigand@de.ibm.com