From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15690 invoked by alias); 7 Mar 2012 18:46:57 -0000 Received: (qmail 15629 invoked by uid 22791); 7 Mar 2012 18:46:55 -0000 X-SWARE-Spam-Status: No, hits=-2.8 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_LOW,TW_SM,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail-vx0-f169.google.com (HELO mail-vx0-f169.google.com) (209.85.220.169) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 07 Mar 2012 18:46:40 +0000 Received: by vcbfk14 with SMTP id fk14so6624068vcb.0 for ; Wed, 07 Mar 2012 10:46:40 -0800 (PST) Received: by 10.52.25.107 with SMTP id b11mr4989520vdg.37.1331145999537; Wed, 07 Mar 2012 10:46:39 -0800 (PST) MIME-Version: 1.0 Received: by 10.52.25.107 with SMTP id b11mr4989505vdg.37.1331145999421; Wed, 07 Mar 2012 10:46:39 -0800 (PST) Received: by 10.220.201.140 with HTTP; Wed, 7 Mar 2012 10:46:39 -0800 (PST) In-Reply-To: <4F54D758.8020508@gmail.com> References: <4F54D758.8020508@gmail.com> Date: Wed, 07 Mar 2012 18:46:00 -0000 Message-ID: Subject: Re: [windows] patch to set breakpoint in a dll From: Doug Evans To: asmwarrior Cc: gdb-patches@sourceware.org, Chris Sutcliffe Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-System-Of-Record: true X-Gm-Message-State: ALoCoQlwvcpxSpc0m3a7ETuUfVmSHudhNoT9iFxxRhZbOZULmZDiS/GbalDStpamYsGuyupuYxoy8spWg1pz9Zta5zSJ1xQWdRn4Vs7RqBgM2wLZ54DTRzai5qoFnS+5lEtgqKivo6Z2Z9GS47NBPMhcZXd3tLB6JA== X-IsSubscribed: yes 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-03/txt/msg00232.txt.bz2 On Mon, Mar 5, 2012 at 7:10 AM, asmwarrior wrote: > Hi, all. Several months ago, I have propose and discuss this issue, but n= ow > I see no progress, so I just give a "Ping" like post. > > The patch is quite simple. (see the attachment), currently, the patch is > include in the MinGW's official gdb 7.4 release. > > Why we need this patch? It can let us debug dll(the dll is build with > relative file path under GCC) > The reason is below: this is my modified code > > int > find_and_open_source (const char *filename, > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0const char *dirname, > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0char **fullname) > { > =A0char *path =3D source_path; > =A0const char *p; > =A0int result; > =A0char *lpath; > > =A0/* Quick way out if we already know its full name. =A0*/ > > =A0if (*fullname) > =A0 =A0{ > =A0 =A0 =A0/* The user may have requested that source paths be rewritten > =A0 =A0 =A0 =A0 according to substitution rules he provided. =A0If a subs= titution > =A0 =A0 =A0 =A0 rule applies to this path, then apply it. =A0*/ > =A0 =A0 =A0char *rewritten_fullname =3D rewrite_source_path (*fullname); > > =A0 =A0 =A0if (rewritten_fullname !=3D NULL) > =A0 =A0 =A0 =A0{ > =A0 =A0 =A0 =A0 =A0xfree (*fullname); > =A0 =A0 =A0 =A0 =A0*fullname =3D rewritten_fullname; > =A0 =A0 =A0 =A0} > > =A0 =A0 =A0result =3D open (*fullname, OPEN_MODE); > =A0 =A0 =A0if (result >=3D 0) > =A0 =A0 =A0{ > =A0 =A0 =A0 =A0lpath =3D gdb_realpath(*fullname); > =A0 =A0 =A0 =A0xfree(*fullname); > =A0 =A0 =A0 =A0*fullname =3D lpath; > =A0 =A0 =A0 =A0return result; > =A0 =A0 =A0} > =A0 =A0 =A0/* Didn't work -- free old one, try again. =A0*/ > =A0 =A0 =A0xfree (*fullname); > =A0 =A0 =A0*fullname =3D NULL; > =A0 =A0} > > Here, > the *fullname =3D > E:\code\cb\wx\wxWidgets-2.8.12\build\msw/../../src/common/string.cpp > > And you set the break point by using this command: > break "E:/code/cb/wx/wxWidgets-2.8.12/src/common/string.cpp:164" > Without the patch, GDB can not set the breakpoint, no file name matches. > > Luckily, the second break command works: > break > E:\code\cb\wx\wxWidgets-2.8.12\build\msw/../../src/common/string.cpp:164 > But I think no body will wrote such kind of file path specification. > > > Now, In my patch, I add a function "gdb_realpath" which internally use > Windows API GetFullPathName() to calculate the canonized path. So, with t= his > patch, the first break command works. > > We have many discussion before: > http://sourceware.org/ml/gdb/2011-06/msg00074.html > > Thanks. The patch has a few nits that need to be fixed, but I like the idea: have find_and_open_source consistently return the canonicalized path. However, openp (called by find_and_open_source later on) uses xfullpath, so for consistency I think that should be used here too instead of gdb_realpath. What do others think?