MINGW-packages icon indicating copy to clipboard operation
MINGW-packages copied to clipboard

The mingw64 lldb-vscode works differently to the clang64 version

Open acotty opened this issue 2 years ago • 4 comments

The lldb-vscode.exe from the clang64 by default detects and intercepts an exception that then propagates to the DAP client as a stop, but the lldb-vscode.exe from the mingw64 does not detect or intercept an exception, so the app exits and the DAP client sees the app exit.

For detailed low level info on the investigation Eranif and myself have done on this have a look at the following wxWidget DAP client library issue: https://github.com/eranif/dbgd/issues/7

I would expect that both lldb-vscode.exe work the same and detect and intercept exceptions by default as this is how the Linux and MacOS versions work.

acotty avatar Jul 06 '22 10:07 acotty

The lldb-vscode.exe from the clang64 by default detects and intercepts an exception that then propagates to the DAP client as a stop, but the lldb-vscode.exe from the mingw64 does not detect or intercept an exception, so the app exits and the DAP client sees the app exit.

This is not the case, both programs work exactly the same in this regard.

I guess the problem is within libgcc and binaries built by Clang from CLANG64 subsystem do work because they use libunwind instead of libgcc. You should be able to easily confirm it by running both debuggers on exactly the same binary. IIUC you have tested mingw64/bin/lldb and clang64/bin/lldb on two different binaries.

mati865 avatar Jul 06 '22 15:07 mati865

I agree lldb.exe works correctly and have tested it as posted in the info in the link I included. The issue is with lldb-vscode.exe, which is for DAP debugging.

To test it you will need a DAP compatible debugger. The github repo link src includes one that can be used if you do not have one, but it requires Codelite.

acotty avatar Jul 06 '22 23:07 acotty

I did some more testing and found the following:

Mingw64 compiler Clang64 compiler
MingW64 lldb-vscode.exe FAILS PASS
Clang64 lldb-vscode.exe FAILS PASS

As such is it possible to change the MingW64 executable build to get it to work? Compiler flags, different library linked in code startup change. I am open to any potential changes.

acotty avatar Jul 08 '22 04:07 acotty

As such is it possible to change the MingW64 executable build to get it to work?

Hard to tell without knowing what makes it work.

Compiler flags, different library linked in code startup change. I am open to any potential changes.

You could try building LLDB in MINGW64 environment using:

  1. CC=clang CXX=clang++ LD=clang
  2. adding LDFLAGS=-fuse-ld=lld
  3. finally step 1 with CXXFLAGS=-stdlib=libc++ LDFLAGS='-fuse-ld=lld -stdlib=libc++'

mati865 avatar Jul 08 '22 15:07 mati865

I have been able work around the problem bty to solve this by using the DAP setExceptionBreakpoints request to enable the filters that were set to false.

acotty avatar Aug 30 '22 05:08 acotty