[PATCH] Improve strace to log most Windows debug events

Jon TURNEY jon.turney@dronecode.org.uk
Wed Jun 10 18:47:00 GMT 2015

On 10/06/2015 18:23, Corinna Vinschen wrote:
> On Jun 10 17:44, Corinna Vinschen wrote:
>> On Jun 10 16:18, Corinna Vinschen wrote:
>>> On Jun 10 16:11, Corinna Vinschen wrote:
>>>> Hi Jon,
>>>> On Jun 10 13:05, Jon TURNEY wrote:
>>>>> Not sure if this is wanted, but on a couple of occasions recently I have been
>>>>> presented with strace output which contains an exception at an address in an
>>>>> unknown module (i.e. not in the cygwin DLL or the main executable), so here is a
>>>>> patch which adds some more information, including DLL load addresses, to help
>>>>> interpret such straces.
>>>> That's a nice addition.  Two points, though:
>>>> - Do we *always* want that output or do we want a way to switch it on
>>>>    and off?  If the latter, we can simply add another _STRACE_foo option
>>>>    for it.

I'm not sure it makes much sense to use a _STRACE_foo flag, since those 
form a mask applied to a set of flags emitted by the cygwin DLL.

I added a command line option to turn this additional logging off.

>>>> - The GetFileNameFromHandle function could be much simpler.  Rather than
>>>>    opening a mapping object for ev.u.LoadDll.hFile, just use the existing
>>>>    mapping object from ev.u.LoadDll.lpBaseOfDll.
>>>      ...with the process handle taken from get_child(ev.dwProcessId).
>> And since I'm generally fuzzy and unclear in my first reply:
>> Of course, ev.u.LoadDll.lpBaseOfDll is not the mapping *object*, but the
>> mapping *address*.  So you neither have to call CreateFileMapping nor
>> MapViewOfFile.  Just call GetMappedFileNameW (get_child (ev.dwProcessId),
>> ev.u.LoadDll.lpBaseOfDll, ...)
> This works for me resulting in Win32 pathnames.  These are only the
> affected diff hunks, I omited the rest.  Does that work for you?
> Btw., I don't like using MAX_PATH as maximum path length, but I think
> DLL paths can't be longer anyway, so that should be ok...
> diff --git a/winsup/utils/strace.cc b/winsup/utils/strace.cc
> index 73096ab..0661e17 100644
> --- a/winsup/utils/strace.cc
> +++ b/winsup/utils/strace.cc

Yes, that seems to work.

More information about the Cygwin-patches mailing list