From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22382 invoked by alias); 27 Sep 2010 16:25:37 -0000 Received: (qmail 22331 invoked by uid 22791); 27 Sep 2010 16:25:35 -0000 X-SWARE-Spam-Status: No, hits=-0.5 required=5.0 tests=AWL,BAYES_00,KAM_STOCKGEN,MSGID_MULTIPLE_AT X-Spam-Check-By: sourceware.org Received: from mailhost.u-strasbg.fr (HELO mailhost.u-strasbg.fr) (130.79.200.157) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 27 Sep 2010 16:25:29 +0000 Received: from md1.u-strasbg.fr (md1.u-strasbg.fr [IPv6:2001:660:2402::186]) by mailhost.u-strasbg.fr (8.14.3/jtpda-5.5pre1) with ESMTP id o8RGPPwh025205 for ; Mon, 27 Sep 2010 18:25:26 +0200 (CEST) (envelope-from pierre.muller@ics-cnrs.unistra.fr) Received: from mailserver.u-strasbg.fr (ms8.u-strasbg.fr [IPv6:2001:660:2402:d::17]) by md1.u-strasbg.fr (8.14.4/jtpda-5.5pre1) with ESMTP id o8RGPP38030620 for ; Mon, 27 Sep 2010 18:25:25 +0200 (CEST) (envelope-from pierre.muller@ics-cnrs.unistra.fr) Received: from d620muller (gw-ics.u-strasbg.fr [130.79.210.225]) (user=mullerp mech=LOGIN) by mailserver.u-strasbg.fr (8.14.4/jtpda-5.5pre1) with ESMTP id o8RGPOFB006332 (version=TLSv1/SSLv3 cipher=RC4-MD5 bits=128 verify=NO) for ; Mon, 27 Sep 2010 18:25:25 +0200 (CEST) (envelope-from pierre.muller@ics-cnrs.unistra.fr) From: "Pierre Muller" To: Subject: [RFA] mingw64: Skip over __main in main Date: Mon, 27 Sep 2010 17:43:00 -0000 Message-ID: <007f01cb5e60$971b6f20$c5524d60$@muller@ics-cnrs.unistra.fr> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable 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: 2010-09/txt/msg00450.txt.bz2 This patch enables recognition of call to __main as part of the prologue of main for mingw64 binaries. It's almost a copy of the i386-tdep.c counterpart (expect that I removed the 32-bit specific overflow code). It makes things more consistent with the way 32-bit binaries are treated and allows to run testsuite on Cygwin (after a few tricks ...). Is this patch OK? 2010-09-27 Pierre Muller * src/gdb/amd64-windows-tdep.c (amd64_skip_main_prologue): New function. (amd64_windows_init_abi): Register amd64_skip_main_prologue as gdbarch skip_main_prologue method. Index: src/gdb/amd64-windows-tdep.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvs/src/src/gdb/amd64-windows-tdep.c,v retrieving revision 1.6 diff -u -p -r1.6 amd64-windows-tdep.c --- src/gdb/amd64-windows-tdep.c 29 Jan 2010 05:29:21 -0000 1.6 +++ src/gdb/amd64-windows-tdep.c 27 Sep 2010 16:15:28 -0000 @@ -122,6 +122,38 @@ amd64_windows_return_value (struct gdbar } } =20 +/* Check that the code pointed to by PC corresponds to a call to + __main, skip it if so. Return PC otherwise. */ + +static CORE_ADDR +amd64_skip_main_prologue (struct gdbarch *gdbarch, CORE_ADDR pc) +{ + enum bfd_endian byte_order =3D gdbarch_byte_order (gdbarch); + gdb_byte op; + + target_read_memory (pc, &op, 1); + if (op =3D=3D 0xe8) + { + gdb_byte buf[4]; + + if (target_read_memory (pc + 1, buf, sizeof buf) =3D=3D 0) + { + struct minimal_symbol *s; + CORE_ADDR call_dest; + + call_dest =3D pc + 5 + extract_signed_integer (buf, 4, byte_order); + s =3D lookup_minimal_symbol_by_pc (call_dest); + if (s !=3D NULL + && SYMBOL_LINKAGE_NAME (s) !=3D NULL + && strcmp (SYMBOL_LINKAGE_NAME (s), "__main") =3D=3D 0) + pc +=3D 5; + } + } + + return pc; +} + + static void amd64_windows_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) { @@ -140,6 +172,7 @@ amd64_windows_init_abi (struct gdbarch_i tdep->memory_args_by_pointer =3D 1; tdep->integer_param_regs_saved_in_caller_frame =3D 1; set_gdbarch_return_value (gdbarch, amd64_windows_return_value); + set_gdbarch_skip_main_prologue (gdbarch, amd64_skip_main_prologue); =20 set_solib_ops (gdbarch, &solib_target_so_ops); }