From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3205 invoked by alias); 21 Jul 2008 22:54:16 -0000 Received: (qmail 3196 invoked by uid 22791); 21 Jul 2008 22:54:15 -0000 X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (66.187.233.31) by sourceware.org (qpsmtpd/0.31) with ESMTP; Mon, 21 Jul 2008 22:53:58 +0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id m6LMruO0006554 for ; Mon, 21 Jul 2008 18:53:56 -0400 Received: from pobox.corp.redhat.com (pobox.corp.redhat.com [10.11.255.20]) by int-mx1.corp.redhat.com (8.13.1/8.13.1) with ESMTP id m6LMruDO006476 for ; Mon, 21 Jul 2008 18:53:56 -0400 Received: from mesquite.lan (vpn-12-135.rdu.redhat.com [10.11.12.135]) by pobox.corp.redhat.com (8.13.1/8.13.1) with ESMTP id m6LMrtqB009727 for ; Mon, 21 Jul 2008 18:53:56 -0400 Date: Mon, 21 Jul 2008 22:54:00 -0000 From: Kevin Buettner To: gdb-patches@sourceware.org Subject: [RFC] PPC: Skip call to __eabi in main() Message-ID: <20080721155343.404977d3@mesquite.lan> X-Mailer: Claws Mail 3.4.0 (GTK+ 2.12.11; i386-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-IsSubscribed: yes 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-07/txt/msg00397.txt.bz2 Some versions of gcc now generate a call to __eabi in main() for the powerpc-eabi and powerpc-eabispe targets. The patch below causes this call to be skipped when placing a breakpoint at the first line of main(), thus fixing quite a few failures when running the test suite. I've tested this patch against powerpc-eabi and powerpc-eabispe running on the simulator. Comments? * rs6000-tdep.c (rs6000_skip_main_prologue): New function. (rs6000_gdb_arch_init): Register rs6000_skip_main_prologue. Index: rs6000-tdep.c =================================================================== RCS file: /cvs/src/src/gdb/rs6000-tdep.c,v retrieving revision 1.318 diff -u -p -r1.318 rs6000-tdep.c --- rs6000-tdep.c 15 Jul 2008 18:32:06 -0000 1.318 +++ rs6000-tdep.c 21 Jul 2008 22:39:00 -0000 @@ -1769,6 +1769,32 @@ rs6000_skip_prologue (struct gdbarch *gd return pc; } +/* Check that the code pointed to by PC corresponds to a call to + __eabi, skip it if so. Return PC otherwise. */ + +CORE_ADDR +rs6000_skip_main_prologue (struct gdbarch *gdbarch, CORE_ADDR pc) +{ + gdb_byte buf[4]; + unsigned long op; + + if (target_read_memory (pc, buf, 4)) + return pc; + op = extract_unsigned_integer (buf, 4); + + if ((op & 0xfc000001) == 0x48000001) + { + CORE_ADDR displ = op & 0x03fffffc; + CORE_ADDR call_dest = pc + 4 + displ; + struct minimal_symbol *s = lookup_minimal_symbol_by_pc (call_dest); + + if (s != NULL + && SYMBOL_LINKAGE_NAME (s) != NULL + && strcmp (SYMBOL_LINKAGE_NAME (s), "__eabi") == 0) + pc += 4; + } + return pc; +} /* All the ABI's require 16 byte alignment. */ static CORE_ADDR @@ -3238,6 +3264,7 @@ rs6000_gdbarch_init (struct gdbarch_info set_gdbarch_skip_prologue (gdbarch, rs6000_skip_prologue); set_gdbarch_in_function_epilogue_p (gdbarch, rs6000_in_function_epilogue_p); + set_gdbarch_skip_main_prologue (gdbarch, rs6000_skip_main_prologue); set_gdbarch_inner_than (gdbarch, core_addr_lessthan); set_gdbarch_breakpoint_from_pc (gdbarch, rs6000_breakpoint_from_pc);