This is an archive of the discontinued LLVM Phabricator instance.

[lldb/win] Improve check-lldb-shell with LLVM_ENABLE_DIA_SDK=NO
Needs ReviewPublic

Authored by thakis on Sep 15 2021, 9:15 AM.

Details

Reviewers
amccarth
Summary

Before this change, running check-lldb-shell with LLVM_ENABLE_DIA_SDK=NO would fail ~25 tests.

This change adds a lit feature based on if the DIA SDK is available and annotates
all tests that set breakpoints with this new feature. Now these tests are skipped
(with a warning message during test startup) instead of failing. This matches how
this is handled in check-llvm.

(This doesn't touch API or Unit tests for now.)

Diff Detail

Event Timeline

thakis requested review of this revision.Sep 15 2021, 9:15 AM
thakis created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptSep 15 2021, 9:15 AM
thakis added a project: Restricted Project.Sep 15 2021, 9:16 AM
labath added a subscriber: labath.Sep 15 2021, 11:46 PM

I fear this is going to be an endless whack-a-mole. There's no way every contributor will remember to (correctly) add this feature.

I fear this is going to be an endless whack-a-mole. There's no way every contributor will remember to (correctly) add this feature.

I think that's ok. 10/250 shell tests need it and there isn't a ton of churn in these tests, so folks on windows can update it as needed.

(If you have a better idea, I'm all ears of course.)

Hmm... is the (non native) SymbolFilePDB plugin actually capable of doing anything without the DIA SDK. If it can't set breakpoints, then I would guess the answer is: not much. Maybe we could automatically select the "Native" plugin in this case, just like we do on non-windows hosts?

It would actually be very interesting to know why the NativePDB/stack_unwinding01.cpp test fails without it, even though it forces the use of the native plugin.

I'm trying to understand why I've never seen the problem that this patch is trying to address.

I wasn't aware of LLVM_ENABLE_DIA_SDK so I've never turned it off. But I've run check lldb exclusively with LLDB_USE_NATIVE_PDB_READER=TRUE for a long time, so I'm surprised to hear that some tests somehow still depend on DIA. Is check-lldb-shell not a subset of check-lldb?

How exactly would I reproduce the problem here?

I don't find much meaning in the term host-breakpoints, but maybe that's because I don't understand the bug.

I suppose the meaning is "I can set breakpoints in host binaries", though if the entire symbol file plugin is not functional without the DIA SDK, then "I can parse host debug info" would be more correct, as the breakpoints are only the first thing you'll typically run into.

That said, if all test do pass with the Native pdb plugin, then I think that makes for an even stronger case to enable it if dia is unavailable. I might consider even enabling it by default. It's been in here for quite some time now.

Oh, that's a good idea. But even if I force on the native PDB reader if LLVM_ENABLE_DIA_SDK is false [1], I still get 15 failures. That's better than 27, but it's more than 0. Maybe LLDB_USE_NATIVE_PDB_READER doesn't hit all uses of DIA in lldb?

Failed Tests (15):
  lldb-shell :: Driver/TestSingleQuote.test
  lldb-shell :: Expr/nodefaultlib.cpp
  lldb-shell :: SymbolFile/NativePDB/stack_unwinding01.cpp
  lldb-shell :: SymbolFile/PDB/ast-restore.test
  lldb-shell :: SymbolFile/PDB/calling-conventions.test
  lldb-shell :: SymbolFile/PDB/class-layout.test
  lldb-shell :: SymbolFile/PDB/enums-layout.test
  lldb-shell :: SymbolFile/PDB/expressions.test
  lldb-shell :: SymbolFile/PDB/func-symbols.test
  lldb-shell :: SymbolFile/PDB/function-nested-block.test
  lldb-shell :: SymbolFile/PDB/pointers.test
  lldb-shell :: SymbolFile/PDB/type-quals.test
  lldb-shell :: SymbolFile/PDB/typedefs.test
  lldb-shell :: SymbolFile/PDB/udt-layout.test
  lldb-shell :: SymbolFile/PDB/variables.test


Testing Time: 38.91s
  Unsupported      : 1113
  Passed           :  263
  Expectedly Failed:   14
  Failed           :   15

1:

C:\src\llvm-project>git diff
diff --git a/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp b/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cppindex 794fab5f7309..51c74c59b137 100644
--- a/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
+++ b/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
@@ -52,6 +52,10 @@
 #include "Plugins/Language/CPlusPlus/MSVCUndecoratedNameParser.h"
 #include "Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h"

+#if defined(_WIN32)
+#include "llvm/Config/config.h"
+#endif
+
 using namespace lldb;
 using namespace lldb_private;
 using namespace llvm::pdb;
@@ -83,6 +87,7 @@ bool ShouldAddLine(uint32_t requested_line, uint32_t actual_line,

 static bool ShouldUseNativeReader() {
 #if defined(_WIN32)
+#if LLVM_ENABLE_DIA_SDK
   llvm::StringRef use_native = ::getenv("LLDB_USE_NATIVE_PDB_READER");
   return use_native.equals_insensitive("on") ||
          use_native.equals_insensitive("yes") ||
@@ -91,6 +96,9 @@ static bool ShouldUseNativeReader() {
 #else
   return true;
 #endif
+#else
+  return true;
+#endif
 }

 void SymbolFilePDB::Initialize() {

Well, it's a start, so let's land that part (D110172).

The SymbolFile/PDB tests are supposed to specifically test the (non-native) pdb plugin, so disabling them in this mode makes perfect sense to me. (though someone interested in pdb support may want to take a look at them to see whether they are failing just because they are testing some specific behavior of the non-native plugin, or because they are exposing some bugs in the native version).

That leaves us with just three tests. I'm not sure what's the deal with TestSingleQuote.test, but I think it could be just some simple bug, where the code balks at a filename with quotes in it. I have no idea what's the deal with the other two. The stack unwinding failure is particularly strange, as that one already forces the use of the native reader.

Is there any chance someone could take a look at those?