My patch: 2007-05-24 Danny Smith <[EMAIL PROTECTED]>
PR target/27067 * doc/tm.texi (TARGET_MANGLE_DECL_ASSEMBLER_NAME): Document. * targhooks.h (default_mangle_decl_assembler_name): Declare default hook. * targhooks.c (default_mangle_decl_assembler_name): Define default hook. * target-def.h (TARGET_MANGLE_DECL_ASSEMBLER_NAME) New. Set to default hook. * target.h (struct gcc_target): Add mangle_decl_assembler_name field. * langhooks.c (lhd_set_decl_assembler_name): Call targetm.mangle_decl_assembler_name for names with global scope. breaks gdb usage for setting breakpoints on __stdcall functions in C (but not C++) The problem appear to derive from a difference between the DECL_NAME and DECL_ASSEMBLER_NAME which was introduced by the patch. Windows targets decorate stdcall assembler identifiers with an @n suffix. Before this patch, the assembler decoration was only added to RTL names in encode_section_info; after the patch the decoration is added upfront to DECL_ASSEMBLER_NAME, because the extern assembler name is really the decorated name. Here is an example: =================== /* foo.c */ int __stdcall bar() { return 1; } int main() { return bar(); } =================== Compiling with gcc -g -xc foo.c then C:\develop\bugs>gdb a GNU gdb 6.5.50.20060706-cvs (cygwin-special) Copyright (C) 2006 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you ar welcome to change it and/or distribute copies of it under certain condition Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "i686-pc-cygwin"... (gdb) break bar Function "bar" not defined. However, there are no problems in C++ where there is also (and because of name mangling, generally) a difference between the the DECL_NAME and the DECL_ASSEMBLER_NAME. compiling with gcc -g -xc++ foo.c then C:\develop\bugs>gdb a GNU gdb 6.5.50.20060706-cvs (cygwin-special) Copyright (C) 2006 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "i686-pc-cygwin"... (gdb) break bar Breakpoint 1 at 0x4013a3: file foo.c, line 3. Reverting this part of the patch * langhooks.c (lhd_set_decl_assembler_name): Call targetm.mangle_decl_assembler_name for names with global scope. avoids the C debugging problem. gdb knows how to handle C++ mangling diffs between DECL_NAME and DECL_ASSEMBLER_NAME, so the C++ part of the patch: * cp/mangle.c (mangle_decl): Call targetm.mangle_decl_assembler_name. doesn't cause any problems. Danny -- Summary: _stdcall assembler names in win32 vs gdb Product: gcc Version: 4.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: debug AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: dannysmith at users dot sourceforge dot net GCC build triplet: i386-pc-mingw32 GCC host triplet: i386-pc-mingw32 GCC target triplet: i386-pc-mingw32 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33155