A small guide on how to get source level debugging of Windows application compiled with MSVC with debug info, with Wine and LLDB.

Not sure, but just in case, use matching architecture on all steps. If the target program is 32-bit, make 32-bit Wine prefix and use 32-bit tools.

1. Install LLVM for Windows, at the moment of writing it is 18.1.8.

2. For some reason, LLVM distribution doesn't include Python 3.10 on which liblldb.dll is dependent on. Just go straight to Python website and find "embeddable package" matching 3.10 version and unpack the archive into "bin" directory of LLVM installation. It might ask about "vcruntime140.dll" collision, just keep the one that comes with LLVM.

3. This is some hacker bullshit, but you need to go to your favorite search engine, enter "msdia140.dll download" and find it somewhere. You can also get it from Visual Studio installation, but we can't install Visual Studio on Wine (?) yet.

4. Register it with "wine regsvr32 msdia140.dll". This is important otherwise LLDB won't even consider parsing PDBs and it's own PDB parser isn't super stable. You can check that it works with "llvm-pdbutil.exe pretty --all program.pdb". If it correctly dumps the data, then it's fine. If it says something about missing "e6756135-1e65-4d17-8576-610761398c3c" class, then registering DLL didn't worked.

5. Start your program with wine in one terminal. Don't start it within LLDB because it won't find main thread for some reason.

6. Start "wine <LLVM_install_path>/bin/lldb.exe --attach-name program.exe" in the same folder with your application in another terminal.

7. Crash your program. LLDB now should properly show function names, arguments, source file and line.