jrfonseca / drmingw

Postmortem debugging tools for MinGW.
GNU Lesser General Public License v2.1
273 stars 53 forks source link

No source code is showing for projects built with MSYS2 #60

Closed Zero3K closed 2 years ago

Zero3K commented 2 years ago

The project at https://github.com/Zero3K/hpsx64/ is not showing the source code responsible for a crash when one happens, and it catches it and displays the error and stack trace even though I built the debug version of either of its programs.

jrfonseca commented 2 years ago

I see MSYS mentioned on the project. Perhaps MSYS GCC is being used?

MSYS uses Unix path emulation like CygWin, so the paths for the source files included on the debugging information are not the same as Window paths.

If you paste the stack trace, that should be clear.

DrMinGW could try to automatically convert MSYS paths (or Cygwin) paths to Windows paths..

Zero3K commented 2 years ago

The source code isn't even showing up when using GDB. I am using MSYS2 under Windows.

jrfonseca commented 2 years ago

Like I said in https://github.com/jrfonseca/drmingw/issues/59#issuecomment-1094381262 perhaps the problem is not MSYS2 per se, but the JIT generated x86 code.

gdb is particularly bad with JIT x86 code. gdb will even ignore frame pointer (RBP), therefore if it can't find the stack unwind tables, the stack back trace is useless.

gdb has some provisions for dealing with JIT code but it is all very complex.

Rather than making gdb working on Windows with JIT, I'd recommend you to use Visual Studio Community edition, so you can use WinDbg debugger. I believe it will be a less of a struggle with Microsoft tooling. Just make sure you setup the frame pointer register on the x86 code you generate, as that will help WinDbg unwind the stack.

I hope this helps. I'm going to close both bugs, as there's nothing I can see that can be done from DrMinGW side here. But feel free to comment if you have further questions.

carlkl commented 2 years ago

Maybe this is simply because msys2 uses gcc-11 and since gcc-11 DWARF-5 is the default. I got a similar problem and could solve it with the following flag: gcc -gdwarf-4 during DEBUG compilation. EDIT: msys2 still uses drmingw-0.9.3 in its repositories. Using version 0.9.5 from here seems to support dwarf-5.