From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5616 invoked by alias); 7 Dec 2012 15:41:16 -0000 Received: (qmail 5549 invoked by uid 22791); 7 Dec 2012 15:41:14 -0000 X-SWARE-Spam-Status: No, hits=-1.7 required=5.0 tests=AWL,BAYES_00,KHOP_THREADED,MSGID_MULTIPLE_AT,TW_FC,TW_GD,TW_YM X-Spam-Check-By: sourceware.org Received: from mailhost.u-strasbg.fr (HELO mailhost.u-strasbg.fr) (130.79.200.156) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 07 Dec 2012 15:41:06 +0000 Received: from md15.u-strasbg.fr (md15.u-strasbg.fr [130.79.200.204]) by mailhost.u-strasbg.fr (8.14.3/jtpda-5.5pre1) with ESMTP id qB7FehuQ083222 ; Fri, 7 Dec 2012 16:40:43 +0100 (CET) (envelope-from pierre.muller@ics-cnrs.unistra.fr) Received: from mailserver.u-strasbg.fr (ms18.u-strasbg.fr [130.79.204.118]) by md15.u-strasbg.fr (8.14.3/jtpda-5.5pre1) with ESMTP id qB7FehJW026276 ; Fri, 7 Dec 2012 16:40:43 +0100 (envelope-from pierre.muller@ics-cnrs.unistra.fr) Received: from E6510Muller (gw-ics.u-strasbg.fr [130.79.210.225]) (user=mullerp mech=LOGIN) by mailserver.u-strasbg.fr (8.14.3/jtpda-5.5pre1) with ESMTP id qB7Feg73000643 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NO) ; Fri, 7 Dec 2012 16:40:42 +0100 (envelope-from pierre.muller@ics-cnrs.unistra.fr) From: "Pierre Muller" To: "'asmwarrior'" , "'Joel Brobecker'" Cc: "'Eli Zaretskii'" , References: <20121024194517.GK3555@adacore.com> <011901cdb2ab$48076b90$d81642b0$@muller@ics-cnrs.unistra.fr> <20121105171121.GA2972@adacore.com> <50991f5f.8382440a.1100.ffff82abSMTPIN_ADDED@mx.google.com> <509ABA17.30507@redhat.com> <000301cdbd96$f5cd9f10$e168dd30$@muller@ics-cnrs.unistra.fr> <20121122173019.GF9964@adacore.com> <15690.5992342674$1353883881@news.gmane.org> <87624si9ur.fsf@fleche.redhat.com> <001501cdccaf$ad85e9b0$0891bd10$@muller@ics-cnrs.unistra.fr> <20121207071035.GG31477@adacore.com> <50C20A66.70002@gmail.com> In-Reply-To: <50C20A66.70002@gmail.com> Subject: RE: [RFC-v5] Fix .text section offset for windows DLL (was Calling __stdcall functions in the inferior) Date: Fri, 07 Dec 2012 15:41:00 -0000 Message-ID: <004a01cdd491$3752eba0$a5f8c2e0$@muller@ics-cnrs.unistra.fr> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" 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: 2012-12/txt/msg00180.txt.bz2 Hi Yuanhui, thanks for trying to debug this... First, concerning the optimized out problems, it would be easier if you would recompile GDB without optimization: make clean all CFLAGS="-gdwarf-2 -O0" After that, you should get optimized out variables... > Program received signal SIGSEGV, Segmentation fault. > 0x77c47740 in strcmp () from C:\WINDOWS\system32\msvcrt.dll > (gdb) bt > #0 0x77c47740 in strcmp () from C:\WINDOWS\system32\msvcrt.dll > #1 0x00535669 in get_pe_section_index (nb_sections=5, > sections=, section_name=0x576b410 ".data") > at ../../gdb/gdb/coff-pe-read.c:112 > #2 get_section_vmas (abfd=0x30543d0, sectp=0x576c4c0, context=0x2a7f894) > at ../../gdb/gdb/coff-pe-read.c:133 > #3 0x005f9672 in bfd_map_over_sections (abfd=0x30543d0, > operation=0x535630 , user_storage=0x2a7f894) > at ../../gdb/bfd/section.c:1329 > #4 0x00536066 in read_pe_exported_syms (objfile=0x5834090) > at ../../gdb/gdb/coff-pe-read.c:524 > #5 0x00535408 in coff_symtab_read (objfile=0x5834090, nsyms=0, > symtab_offset=) at ../../gdb/gdb/coffread.c:1127 > #6 coff_symfile_read (objfile=0x5834090, symfile_flags=8) > at ../../gdb/gdb/coffread.c:610 > #7 0x004d3967 in read_symbols (objfile=0x5834090, add_flags=8) > at ../../gdb/gdb/symfile.c:885 > #8 0x004d340e in syms_from_objfile (objfile=0x5834090, > addrs=, offsets=0x0, num_offsets=0, add_flags=8) > at ../../gdb/gdb/symfile.c:1020 > #9 0x004d36f0 in symbol_file_add_with_addrs_or_offsets ( > abfd=, add_flags=8, addrs=0x4d9d640, > flags=, parent=0x0, num_offsets=0, offsets=0x0) > at ../../gdb/gdb/symfile.c:1123 > #10 0x005c2df7 in solib_read_symbols (so=0x2ff7ff8, flags=8) > at ../../gdb/gdb/solib.c:608 > #11 0x005c322a in solib_add (pattern=0x0, from_tty=0, > target=0x96efa0 , readsyms=1) at > ../../gdb/gdb/solib.c:919 > #12 0x004dfcce in post_create_inferior (target=0x96efa0 , > from_tty=0) at ../../gdb/gdb/infcmd.c:477 > #13 0x004dfe7c in run_command_1 (args=0x0, from_tty=, > tbreak_at_main=) at ../../gdb/gdb/infcmd.c:631 > #14 0x005ada85 in execute_command (p=0x4cfa1b9 "", from_tty=1) > at ../../gdb/gdb/top.c:491 > #15 0x004fda16 in command_handler (command=0x4cfa1b8 "") > at ../../gdb/gdb/event-top.c:429 > #16 0x004fe1c3 in command_line_handler (rl=0x292888 " ") > at ../../gdb/gdb/event-top.c:630 > #17 0x005df1c1 in rl_callback_read_char () > at ../../gdb/readline/callback.c:220 > #18 0x004fda88 in rl_callback_read_char_wrapper (client_data=0x0) > at ../../gdb/gdb/event-top.c:163 > #19 0x004fcd84 in handle_file_event (data=...) > at ../../gdb/gdb/event-loop.c:827 > #20 0x004fcd13 in process_event () at ../../gdb/gdb/event-loop.c:401 > #21 process_event () at ../../gdb/gdb/event-loop.c:351 > #22 0x004fd095 in gdb_do_one_event () at ../../gdb/gdb/event-loop.c:465 > #23 0x004fd1ec in start_event_loop () at ../../gdb/gdb/event-loop.c:490 > #24 0x004f79c2 in captured_command_loop (data=0x0) at > ../../gdb/gdb/main.c:256 > #25 0x004f66eb in catch_errors (func=0x4f79b0 , > func_args=0x0, errstring=0x736c0d <__PRETTY_FUNCTION__.12471+203> "", > mask=6) at ../../gdb/gdb/exceptions.c:546 > #26 0x004f84c6 in captured_main (data=0x2a7fee0) at > ../../gdb/gdb/main.c:1032 > #27 0x004f66eb in catch_errors (func=0x4f7b70 , > func_args=0x2a7fee0, > errstring=0x736c0d <__PRETTY_FUNCTION__.12471+203> "", mask=6) > at ../../gdb/gdb/exceptions.c:546 > #28 0x004f8ab0 in gdb_main (args=0x2a7fee0) at ../../gdb/gdb/main.c:1041 > #29 0x006d0878 in main (argc=1, argv=0x293fe0) at ../../gdb/gdb/gdb.c:34 > (gdb) frame 1 > #1 0x00535669 in get_pe_section_index (nb_sections=5, > sections=, section_name=0x576b410 ".data") > at ../../gdb/gdb/coff-pe-read.c:112 > 112 if (strcmp (sections[i].section_name, section_name) == 0) > (gdb) p i > $1 = > (gdb) p sections[i] > value has been optimized out > (gdb) p section_name > $2 = 0x576b410 ".data" > (gdb) p sections[i].section_name > value has been optimized out > (gdb) p nb_sections > $3 = 5 > (gdb) p sections > $4 = > (gdb) > > --------------------------------------------------- > But it looks like a lot of variables were optimized out. > > But it looks like the crash happens here: > > static int > get_pe_section_index (const char *section_name, > struct read_pe_section_data *sections, > int nb_sections) > { > int i; > for (i = 0; i < nb_sections; i++) > if (strcmp (sections[i].section_name, section_name) == 0) > return i; > return PE_SECTION_INDEX_INVALID; > } I also installed CodeBlocks to test if I can reproduce your crash, but I never got any ... Could it be that some weird DLL's have unnamed sections? Could you try to insert if (sections[i] && section[i].name) before > if (strcmp (sections[i].section_name, section_name) == 0) > return i; to confirm that the problem originates here? Thanks again, Pierre