lmi
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lmi] Debugging with Wine (was: perf+wine)


From: Vadim Zeitlin
Subject: Re: [lmi] Debugging with Wine (was: perf+wine)
Date: Wed, 7 Mar 2018 14:35:38 +0100

On Wed, 7 Mar 2018 01:13:04 +0000 Greg Chicares <address@hidden> wrote:

GC> One thing I'm pretty sure about is that I never ran 'gdbserver'...

 In principle, you don't have to: you could also run gdb natively in Wine.
But I regularly have trouble with gdb under MSW even when running it in a
"real" VM, so I prefer doing it like this.

GC> >  If you'd like, I could describe what I do exactly, but there is really
GC> > nothing surprising there, i.e. it's just:
GC> > 
GC> > 1. Install the packages.
GC> > 2. Run gdbserver under Wine.
GC> > 3. Run gdb and connect to it.
GC> > 
GC> >  Please let me know if you'd like to have more details,
GC> 
GC> Yes, please. Searching online for the most elementary steps, I'm already
GC> confused. Which port should I pick?

 It doesn't matter, on your own personal LAN you can use whichever port you
prefer.

GC> Or, because I guess I'll be running the debugger in the same chroot as
GC> the program I'll be debugging, should I use use 'stdio'?

 Unfortunately this doesn't seem to work with i686-w64-mingw32-gdb,
attempts to do it result in "Only <host>:<port> is supported on this
platform.", so you need to use a socket. In practice, I don't see any real
problems (i.e. it's not slow or anything) with this, even if using a pipe
would be more elegant.

GC> Or am I to run gdbserver on my "host", and the lmi binary in the chroot
GC> that has wine installed?

 gdbserver needs to be run by Wine, as it's a MSW binary, so in chroot. The
debugger itself can run anywhere you want, including in the same chroot, on
the same machine outside of chroot or even a completely different machine.
To keep it simple and self-contained, I run it inside the chroot in the
instructions below, but there is no requirement to do it like this.

 So, without farther ado, here are the detailed instructions:

1. Install the packages

   You need to run "apt get gdb-mingw-w64{,-target}" in chroot to get the
   debugger itself and gdbserver, which is in the "-target" package. To
   finish the installation, copy /usr/share/win32/gdbserver.exe to some
   directory in your Wine path, e.g. I use ~/msw/i686-w64-mingw32/bin.

   Note that you could also install gdb-mingw-w64 on the main system, and
   then run i686-w64-mingw-gdb outside of chroot. It would then have a
   different version from gdbserver but IME this doesn't really matter,
   gdbserver protocol is stable. I do it inside chroot to just get the
   latest and, hopefully, greatest, gdb version.

2. Run gdbserver under Wine

   You need to choose a port, pick whichever one you like, e.g. 7167 to
   match your initials and then just give the full command line to
   gdbserver. Note that you need to use a full (absolute or relative) path
   name here, i.e. it doesn't seem to use PATH to find the program to run,
   so it's

        wine gdbserver localhost:7167 ~/msw/i686-w64-mingw32/bin/lmi_wx.exe 
--data_path=...

   for me. This should tell you that the process has been launched (but
   it's not running yet) and that gdbserver is listening on the given port.
   Note that you could also put this command in the background, by
   appending "&" to it, as you're not really going to interact with it, and
   it gives relatively few messages, so running it in the background
   doesn't mess up the console too much and frees you from the need to open
   another tab/window.

3. Run gdb and connect to it

   As you're going to do this often, it's nice to have a command line doing 
   both at once, which is, in my case:

           i686-w64-mingw32-gdb -q -ex 'target remote localhost:7167' 
~/msw/i686-w64-mingw32/bin/lmi_wx.exe

   (note that you don't need to specify any arguments here). As previously
   mentioned, this can be run either inside or outside of chroot, I do it
   inside.

   gdb will give you a few messages, including the one about "set sysroot"
   to speed up file transfers. This is indeed a bit slow, so you may want
   to insert "-ex 'set sysroot ~/.wine/drive_c'" into the command above to
   let access the files directly.

   In any case, you should now be able to debug normally, including being
   able to press Ctrl-C to break into the program at any time -- which is
   something that never worked reliably for me with native gdb under MSW.


 To summarize these long instructions, the actual command in my history is

        wine gdbserver localhost:7167 ~/msw/i686-w64-mingw32/bin/lmi_wx.exe 
[...] & i686-w64-mingw32-gdb -q -ex 'set sysroot ~/.wine/drive_c' -ex 'target 
remote localhost:7167' ~/msw/i686-w64-mingw32/bin/lmi_wx.exe

where I only redacted the lmi command line options and, except for the
path to lmi_wx.exe used, exactly the same command should work for you too.

 Please let me know if you have any problems with it,
VZ


reply via email to

[Prev in Thread] Current Thread [Next in Thread]