From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26656 invoked by alias); 24 Jun 2004 00:23:07 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 26647 invoked from network); 24 Jun 2004 00:23:06 -0000 Received: from unknown (HELO takamaka.act-europe.fr) (142.179.108.108) by sourceware.org with SMTP; 24 Jun 2004 00:23:06 -0000 Received: by takamaka.act-europe.fr (Postfix, from userid 507) id 7DF8147D8D; Wed, 23 Jun 2004 17:23:05 -0700 (PDT) Date: Thu, 24 Jun 2004 00:23:00 -0000 From: Joel Brobecker To: gdb-patches@sources.redhat.com Subject: Re: [RFA] Pb stepping inside DLL function Message-ID: <20040624002305.GL1143@gnat.com> References: <20040624002220.GK1143@gnat.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="h31gzZEtNLTqOjlF" Content-Disposition: inline In-Reply-To: <20040624002220.GK1143@gnat.com> User-Agent: Mutt/1.4i X-SW-Source: 2004-06/txt/msg00510.txt.bz2 --h31gzZEtNLTqOjlF Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 1482 [Sigh... With the patch, this time...] Hello, We have the following little C program (a.c): #include extern _stdcall int sub (); main () { int a = 0; a = sub (); printf ("%d\n", a); } ``sub()'' is a function provided by a DLL. It has all the necessary debug information. The following transcript shows that GDB is currently unable to step into sub(): (gdb) start Breakpoint 1 at 0x4012d2: file a.c, line 7. Starting program: /[...]/a.exe main () at a.c:7 7 int a = 0; (gdb) step 9 a = sub (); (gdb) p a $1 = 0 (gdb) step 10 printf ("%d\n", a); (gdb) print a $2 = 5 During the step, GDB lands inside sub@0, which is the trampoline for sub(), but doesn't realize it. The fix is to teach GDB how to recognize them, and hand to find where they will eventually take us. For that, I found a function that was actually dead but did exactly what I needed, so I reused it. 2004-06-23 Joel Brobecker * i386-cygwin-tdep.c (i386-cygwin-tdep.c): New function. (i386_cygwin_in_solib_call_trampoline): New function. (i386_cygwin_init_abi): Initialize the in_solib_call_trampoline and skip_trampoline_code gdbarch methods. Tested on x86-windows (XP), no regression. OK to apply? Thanks, -- Joel --h31gzZEtNLTqOjlF Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="step-dll.diff" Content-length: 1032 Index: i386-cygwin-tdep.c =================================================================== RCS file: /cvs/src/src/gdb/i386-cygwin-tdep.c,v retrieving revision 1.5 diff -u -p -r1.5 i386-cygwin-tdep.c --- i386-cygwin-tdep.c 30 Apr 2004 21:13:58 -0000 1.5 +++ i386-cygwin-tdep.c 24 Jun 2004 00:12:25 -0000 @@ -26,11 +26,27 @@ #include "i386-tdep.h" +static CORE_ADDR +i386_cygwin_skip_trampoline_code (CORE_ADDR pc) +{ + return i386_pe_skip_trampoline_code (pc, NULL); +} + +static int +i386_cygwin_in_solib_call_trampoline (CORE_ADDR pc, char *name) +{ + return (i386_pe_skip_trampoline_code (pc, name) != 0); +} + static void i386_cygwin_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) { struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + set_gdbarch_in_solib_call_trampoline (gdbarch, + i386_cygwin_in_solib_call_trampoline); + set_gdbarch_skip_trampoline_code (gdbarch, i386_cygwin_skip_trampoline_code); + tdep->struct_return = reg_struct_return; } --h31gzZEtNLTqOjlF--