From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5950 invoked by alias); 30 May 2008 11:19:05 -0000 Received: (qmail 5939 invoked by uid 22791); 30 May 2008 11:19:02 -0000 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.31) with ESMTP; Fri, 30 May 2008 11:18:33 +0000 Received: from baal.u-strasbg.fr (baal.u-strasbg.fr [IPv6:2001:660:2402::41]) by mailhost.u-strasbg.fr (8.14.2/jtpda-5.5pre1) with ESMTP id m4UBIKW6021847 ; Fri, 30 May 2008 13:18:20 +0200 (CEST) Received: from mailserver.u-strasbg.fr (ms2.u-strasbg.fr [IPv6:2001:660:2402::142]) by baal.u-strasbg.fr (8.14.0/jtpda-5.5pre1) with ESMTP id m4UBIKeF088950 ; Fri, 30 May 2008 13:18:20 +0200 (CEST) Received: from d620muller (laocoon.u-strasbg.fr [130.79.112.72]) by mailserver.u-strasbg.fr (8.13.8/jtpda-5.5pre1) with ESMTP id m4UBIGWT048637 ; Fri, 30 May 2008 13:18:20 +0200 (CEST) From: "Pierre Muller" To: "'Pierre Muller'" , "'Pedro Alves'" , "'Daniel Jacobowitz'" , Cc: "'Mark Kettenis'" References: <004f01c8ac58$06a1ddb0$13e59910$@u-strasbg.fr> In-Reply-To: <004f01c8ac58$06a1ddb0$13e59910$@u-strasbg.fr> Subject: [PING2] : [RFC/RFA] PING: skip __main Date: Fri, 30 May 2008 15:56:00 -0000 Message-ID: <000c01c8c246$de300f50$9a902df0$@u-strasbg.fr> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Mailer: Microsoft Office Outlook 12.0 Content-Language: en-us X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.0 (mailhost.u-strasbg.fr [IPv6:2001:660:2402::157]); Fri, 30 May 2008 13:18:21 +0200 (CEST) X-Virus-Status: Clean 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-05/txt/msg00769.txt.bz2 Hi, is there any chance that someone will have the time to review this patch? Pierre Muller Pascal language support maintainer for GDB -----Message d'origine----- De=A0: gdb-patches-owner@sourceware.org [mailto:gdb-patches-owner@sourceware.org] De la part de Pierre Muller Envoy=E9=A0: Friday, May 02, 2008 3:26 PM =C0=A0: 'Pedro Alves'; 'Daniel Jacobowitz'; gdb-patches@sourceware.org Cc=A0: 'Mark Kettenis' Objet=A0: [RFC/RFA] PING: skip __main Pedro submitted this patch end of January, but the 6.8 release pushed it to a later date. http://sourceware.org/ml/gdb-patches/2008-01/msg00665.html =20=20 Now that GDB 6.8 is out,=20 I would really like to get this patch in. Pedro, this is your work, but you seem to be much more involved in other things lately, thus, if you don't mind, I can try to push this through.=20 I updated the patch from the first message referenced and just followed Daniel's advice in http://sourceware.org/ml/gdb-patches/2008-01/msg00883.html to change skip___main into skip_main_constructor. This __main call seems to be a common feature for coff format, thus=20 I suppose that it applies to other targets, go32v2 djgpp is probably one of them. For cygwin target, I get this: =3D=3D=3D gdb Summary =3D=3D=3D =09 -# of expected passes 10733 -# of unexpected failures 560 +# of expected passes 10928 +# of unexpected failures 363 # of expected failures 59 # of unknown successes 2 -# of known failures 21 +# of known failures 23 # of unresolved testcases 40 # of untested testcases 14 # of unsupported tests 23 Almost 200 failures less... Daniel wanted to get a comment from Mark in his last email in that thread, that is the reason why I added Mark Kettenis to the list of recipients. Does this patch look OK now? One point that should still be discussed is if we should call main_name function rather than hardcoded "main" in find_function_start_sal in symtab.c. Pierre Muller Pascal language support maintainer for GDB 2008-05-02 Pedro Alves Pierre Muller * gdbarch.sh (gdbarch_skip_main_constructor_call): New. * gdbarch.h, gdbarch.c: Regenerate. * i386-tdep.h (i386_skip_main_constructor_call): Declare. * i386-tdep.c (i386_skip_main_constructor_call): New. * i386-cygwin-tdep.c (i386_cygwin_init_abi): Register i386_skip_main_constructor_call as gdbarch_skip_main_constructor_call=20 gdbarch callback. * symtab.c (find_function_start_sal): When pc points at the "main" function, call gdbarch_skip_main_constructor_call. Index: gdb/gdbarch.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/gdbarch.c,v retrieving revision 1.422 diff -u -p -r1.422 gdbarch.c --- gdb/gdbarch.c 22 Apr 2008 11:03:41 -0000 1.422 +++ gdb/gdbarch.c 30 Apr 2008 13:01:33 -0000 @@ -184,6 +184,7 @@ struct gdbarch gdbarch_integer_to_address_ftype *integer_to_address; gdbarch_return_value_ftype *return_value; gdbarch_skip_prologue_ftype *skip_prologue; + gdbarch_skip_main_constructor_call_ftype *skip_main_constructor_call; gdbarch_inner_than_ftype *inner_than; gdbarch_breakpoint_from_pc_ftype *breakpoint_from_pc; gdbarch_adjust_breakpoint_address_ftype *adjust_breakpoint_address; @@ -306,6 +307,7 @@ struct gdbarch startup_gdbarch =3D 0, /* integer_to_address */ 0, /* return_value */ 0, /* skip_prologue */ + 0, /* skip_main_constructor_call */ 0, /* inner_than */ 0, /* breakpoint_from_pc */ 0, /* adjust_breakpoint_address */ @@ -542,6 +544,7 @@ verify_gdbarch (struct gdbarch *gdbarch) /* Skip verify of return_value, has predicate */ if (gdbarch->skip_prologue =3D=3D 0) fprintf_unfiltered (log, "\n\tskip_prologue"); + /* Skip verify of skip_main_constructor_call, has predicate */ if (gdbarch->inner_than =3D=3D 0) fprintf_unfiltered (log, "\n\tinner_than"); if (gdbarch->breakpoint_from_pc =3D=3D 0) @@ -934,6 +937,12 @@ gdbarch_dump (struct gdbarch *gdbarch, s "gdbarch_dump: single_step_through_delay =3D <0x%lx>\n", (long) gdbarch->single_step_through_delay); fprintf_unfiltered (file, + "gdbarch_dump: gdbarch_skip_main_constructor_call_p() =3D %d\n", + gdbarch_skip_main_constructor_call_p (gdbarch)); + fprintf_unfiltered (file, + "gdbarch_dump: skip_main_constructor_call =3D <0x%lx>\n", + (long) gdbarch->skip_main_constructor_call); + fprintf_unfiltered (file, "gdbarch_dump: gdbarch_skip_permanent_breakpoint_p() =3D %d\n", gdbarch_skip_permanent_breakpoint_p (gdbarch)); fprintf_unfiltered (file, @@ -2075,6 +2084,30 @@ set_gdbarch_skip_prologue (struct gdbarc } =20 int +gdbarch_skip_main_constructor_call_p (struct gdbarch *gdbarch) +{ + gdb_assert (gdbarch !=3D NULL); + return gdbarch->skip_main_constructor_call !=3D NULL; +} + +CORE_ADDR +gdbarch_skip_main_constructor_call (struct gdbarch *gdbarch, CORE_ADDR ip) +{ + gdb_assert (gdbarch !=3D NULL); + gdb_assert (gdbarch->skip_main_constructor_call !=3D NULL); + if (gdbarch_debug >=3D 2) + fprintf_unfiltered (gdb_stdlog, "gdbarch_skip_main_constructor_call called\n"); + return gdbarch->skip_main_constructor_call (gdbarch, ip); +} + +void +set_gdbarch_skip_main_constructor_call (struct gdbarch *gdbarch, + gdbarch_skip_main_constructor_call_ftype skip_main_constructor_call) +{ + gdbarch->skip_main_constructor_call =3D skip_main_constructor_call; +} + +int gdbarch_inner_than (struct gdbarch *gdbarch, CORE_ADDR lhs, CORE_ADDR rhs) { gdb_assert (gdbarch !=3D NULL); Index: gdb/gdbarch.h =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/gdbarch.h,v retrieving revision 1.377 diff -u -p -r1.377 gdbarch.h --- gdb/gdbarch.h 29 Apr 2008 16:06:07 -0000 1.377 +++ gdb/gdbarch.h 30 Apr 2008 13:01:33 -0000 @@ -381,6 +381,12 @@ typedef CORE_ADDR (gdbarch_skip_prologue extern CORE_ADDR gdbarch_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR ip); extern void set_gdbarch_skip_prologue (struct gdbarch *gdbarch, gdbarch_skip_prologue_ftype *skip_prologue); =20 +extern int gdbarch_skip_main_constructor_call_p (struct gdbarch *gdbarch); + +typedef CORE_ADDR (gdbarch_skip_main_constructor_call_ftype) (struct gdbarch *gdbarch, CORE_ADDR ip); +extern CORE_ADDR gdbarch_skip_main_constructor_call (struct gdbarch *gdbarch, CORE_ADDR ip); +extern void set_gdbarch_skip_main_constructor_call (struct gdbarch *gdbarch, gdbarch_skip_main_constructor_call_ftype *skip_main_constructor_call); + typedef int (gdbarch_inner_than_ftype) (CORE_ADDR lhs, CORE_ADDR rhs); extern int gdbarch_inner_than (struct gdbarch *gdbarch, CORE_ADDR lhs, CORE_ADDR rhs); extern void set_gdbarch_inner_than (struct gdbarch *gdbarch, gdbarch_inner_than_ftype *inner_than); Index: gdb/gdbarch.sh =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/gdbarch.sh,v retrieving revision 1.463 diff -u -p -r1.463 gdbarch.sh --- gdb/gdbarch.sh 29 Apr 2008 16:06:06 -0000 1.463 +++ gdb/gdbarch.sh 30 Apr 2008 13:01:34 -0000 @@ -483,6 +483,7 @@ M:CORE_ADDR:integer_to_address:struct ty M:enum return_value_convention:return_value:struct type *functype, struct type *valtype, struct regcache *regcache, gdb_byte *readbuf, const gdb_byte *writebuf:functype, valtype, regcache, readbuf, writebuf =20 m:CORE_ADDR:skip_prologue:CORE_ADDR ip:ip:0:0 +M:CORE_ADDR:skip_main_constructor_call:CORE_ADDR ip:ip f:int:inner_than:CORE_ADDR lhs, CORE_ADDR rhs:lhs, rhs:0:0 m:const gdb_byte *:breakpoint_from_pc:CORE_ADDR *pcptr, int *lenptr:pcptr, lenptr::0: M:CORE_ADDR:adjust_breakpoint_address:CORE_ADDR bpaddr:bpaddr Index: gdb/i386-cygwin-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/i386-cygwin-tdep.c,v retrieving revision 1.16 diff -u -p -r1.16 i386-cygwin-tdep.c --- gdb/i386-cygwin-tdep.c 1 Jan 2008 22:53:10 -0000 1.16 +++ gdb/i386-cygwin-tdep.c 30 Apr 2008 13:01:34 -0000 @@ -227,6 +227,8 @@ i386_cygwin_init_abi (struct gdbarch_inf =20 set_gdbarch_skip_trampoline_code (gdbarch, i386_cygwin_skip_trampoline_code); =20 + set_gdbarch_skip_main_constructor_call (gdbarch, i386_skip_main_constructor_call); + tdep->struct_return =3D reg_struct_return; =20 tdep->gregset_reg_offset =3D i386_win32_gregset_reg_offset; Index: gdb/i386-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/i386-tdep.c,v retrieving revision 1.255 diff -u -p -r1.255 i386-tdep.c --- gdb/i386-tdep.c 25 Apr 2008 14:57:30 -0000 1.255 +++ gdb/i386-tdep.c 30 Apr 2008 13:01:35 -0000 @@ -941,6 +941,33 @@ i386_skip_prologue (struct gdbarch *gdba return pc; } =20 +/* Check that the code pointed to by PC corresponds to a call to + __main, skip it if so. Return PC otherwise. */ + +CORE_ADDR +i386_skip_main_constructor_call (struct gdbarch *gdbarch, CORE_ADDR pc) +{ + 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) + { + CORE_ADDR call_dest =3D pc + 5 + extract_unsigned_integer (buf, 4); + + struct minimal_symbol *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; +} + /* This function is 64-bit safe. */ =20 static CORE_ADDR Index: gdb/i386-tdep.h =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/i386-tdep.h,v retrieving revision 1.53 diff -u -p -r1.53 i386-tdep.h --- gdb/i386-tdep.h 11 Mar 2008 05:21:38 -0000 1.53 +++ gdb/i386-tdep.h 30 Apr 2008 13:01:35 -0000 @@ -166,6 +166,7 @@ extern struct type *i386_sse_type (struc =20 /* Functions exported from i386-tdep.c. */ extern CORE_ADDR i386_pe_skip_trampoline_code (CORE_ADDR pc, char *name); +extern CORE_ADDR i386_skip_main_constructor_call (struct gdbarch *gdbarch, CORE_ADDR pc); =20 /* Return the name of register REGNUM. */ extern char const *i386_register_name (struct gdbarch * gdbarch, int regnum); Index: gdb/symtab.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/symtab.c,v retrieving revision 1.177 diff -u -p -r1.177 symtab.c --- gdb/symtab.c 19 Apr 2008 11:39:50 -0000 1.177 +++ gdb/symtab.c 30 Apr 2008 13:01:36 -0000 @@ -2572,6 +2572,21 @@ find_function_start_sal (struct symbol * /* Recalculate the line number (might not be N+1). */ sal =3D find_pc_sect_line (pc, SYMBOL_BFD_SECTION (sym), 0); } + + /* On targets with executable formats that don't have a concept of + constructors (ELF with .init has, PE doesn't), gcc emits a call + to `__main' in `main' between the prologue and before user + code. */ + if (funfirstline + && gdbarch_skip_main_constructor_call_p (current_gdbarch) + && SYMBOL_LINKAGE_NAME (sym) + && strcmp (SYMBOL_LINKAGE_NAME (sym), "main") =3D=3D 0) + { + pc =3D gdbarch_skip_main_constructor_call (current_gdbarch, pc); + /* Recalculate the line number (might not be N+1). */ + sal =3D find_pc_sect_line (pc, SYMBOL_BFD_SECTION (sym), 0); + } + sal.pc =3D pc; =20 return sal;