This is an archive of the discontinued LLVM Phabricator instance.

[lit, pdb] Fix two failing PDB tests on Windows
ClosedPublic

Authored by stella.stamenova on Jun 1 2018, 2:14 PM.

Details

Summary

One of the tests is failing to build because it needs GS-, the second test does not correctly match all the expected function names because newer DIA SDKs annotate the function names with their return type and inputs (e.g. "static long `anonymous namespace'::StaticFunction(int)")

Diff Detail

Repository
rL LLVM

Event Timeline

zturner accepted this revision.Jun 1 2018, 2:23 PM
This revision is now accepted and ready to land.Jun 1 2018, 2:23 PM
This revision was automatically updated to reflect the committed changes.
labath added a subscriber: labath.Jun 4 2018, 1:52 AM

newer DIA SDKs annotate the function names with their return type and inputs

Does this mean that the tests will now fail for people who happen to have older/different versions of MSVS/DIA SDK installed?

newer DIA SDKs annotate the function names with their return type and inputs

Does this mean that the tests will now fail for people who happen to have older/different versions of MSVS/DIA SDK installed?

It should not fail for people with newer versions because I updated the matching pattern to include both.

One thing I did notice, though, is that the order in which some of the symbol sections are generated differs but FileCheck looks for matches in the order in the test file. Do you know of a way to make it match either order? Right now the section for FuncSymbols.cpp is sometimes before and sometimes after the section for FuncSymbolsTestMain.cpp

newer DIA SDKs annotate the function names with their return type and inputs

Does this mean that the tests will now fail for people who happen to have older/different versions of MSVS/DIA SDK installed?

It should not fail for people with newer versions because I updated the matching pattern to include both.

One thing I did notice, though, is that the order in which some of the symbol sections are generated differs but FileCheck looks for matches in the order in the test file. Do you know of a way to make it match either order? Right now the section for FuncSymbols.cpp is sometimes before and sometimes after the section for FuncSymbolsTestMain.cpp

Can you give a concrete example? CHECK-DAG should work with any order. If you mean that the order of the files themselves are different, then yea I could see that being a problem. In that case you'd need multiple filecheck lines, one for each file. This way it would run the command multiple times but each time only match the output of a single file.

These two sections switch order between builds. It looks like the CHECK command checks in order, so the two CHECKs will fail based on the order in which the symbols are produced in the output. I could make them both CHECK-DAG, but I assume they are CHECK on purpose.

CHECK: {{.*}}:   CompileUnit{{.*}}, language = "c++", file = '{{.*}}\FuncSymbols.cpp'
CHECK-DAG: Function{[[UID30]]}, mangled = ?FunctionCall@@YAXXZ, demangled = {{.*}}, type = [[TY30]]
CHECK-DAG: Function{[[UID31]]}, demangled = {{.*}}`anonymous namespace'::StaticFunction{{.*}}, type = [[TY31]]
CHECK-DAG: Function{[[UID32]]}, demangled = {{.*}}InlinedFunction{{.*}}, type = [[TY32]]

CHECK: {{.*}}:   CompileUnit{{.*}}, language = "c++", file = '{{.*}}\FuncSymbolsTestMain.cpp'
CHECK-DAG: Function{[[UID0]]}, mangled = ?Func_arg_array@@YAHQAH@Z, demangled = {{.*}}, type = [[TY0]]
CHECK-DAG: Function{[[UID1]]}, mangled = ?Func_arg_void@@YAXXZ, demangled = {{.*}}, type = [[TY1]]
CHECK-DAG: Function{[[UID2]]}, mangled = ?Func_arg_none@@YAXXZ, demangled = {{.*}}, type = [[TY2]]

These two sections switch order between builds. It looks like the CHECK command checks in order, so the two CHECKs will fail based on the order in which the symbols are produced in the output. I could make them both CHECK-DAG, but I assume they are CHECK on purpose.

CHECK: {{.*}}:   CompileUnit{{.*}}, language = "c++", file = '{{.*}}\FuncSymbols.cpp'
CHECK-DAG: Function{[[UID30]]}, mangled = ?FunctionCall@@YAXXZ, demangled = {{.*}}, type = [[TY30]]
CHECK-DAG: Function{[[UID31]]}, demangled = {{.*}}`anonymous namespace'::StaticFunction{{.*}}, type = [[TY31]]
CHECK-DAG: Function{[[UID32]]}, demangled = {{.*}}InlinedFunction{{.*}}, type = [[TY32]]

CHECK: {{.*}}:   CompileUnit{{.*}}, language = "c++", file = '{{.*}}\FuncSymbolsTestMain.cpp'
CHECK-DAG: Function{[[UID0]]}, mangled = ?Func_arg_array@@YAHQAH@Z, demangled = {{.*}}, type = [[TY0]]
CHECK-DAG: Function{[[UID1]]}, mangled = ?Func_arg_void@@YAXXZ, demangled = {{.*}}, type = [[TY1]]
CHECK-DAG: Function{[[UID2]]}, mangled = ?Func_arg_none@@YAXXZ, demangled = {{.*}}, type = [[TY2]]

Yea all adjacent CHECK-DAGs form a single group, and items in a group can appear in any order. So if those were made dag, then the symbols could show up with the wrong source file and it would pass.

The way to fix this is to run FileCheck multiple times, and make a different check label for each file. E.g.

RUN: lldb-test symbols %T/FuncSymbolsTest.exe | FileCheck --check-label=CHECK-ONE %s
RUN: lldb-test symbols %T/FuncSymbolsTest.exe | FileCheck --check-label=CHECK-TWO %s

CHECK-ONE: {{.*}}:   CompileUnit{{.*}}, language = "c++", file = '{{.*}}\FuncSymbols.cpp'
CHECK-ONE-DAG: Function{[[UID30]]}, mangled = ?FunctionCall@@YAXXZ, demangled = {{.*}}, type = [[TY30]]
CHECK-ONE-DAG: Function{[[UID31]]}, demangled = {{.*}}`anonymous namespace'::StaticFunction{{.*}}, type = [[TY31]]
CHECK-ONE-DAG: Function{[[UID32]]}, demangled = {{.*}}InlinedFunction{{.*}}, type = [[TY32]]

CHECK-TWO: {{.*}}:   CompileUnit{{.*}}, language = "c++", file = '{{.*}}\FuncSymbolsTestMain.cpp'
CHECK-TWO-DAG: Function{[[UID0]]}, mangled = ?Func_arg_array@@YAHQAH@Z, demangled = {{.*}}, type = [[TY0]]
CHECK-TWO-DAG: Function{[[UID1]]}, mangled = ?Func_arg_void@@YAXXZ, demangled = {{.*}}, type = [[TY1]]
CHECK-TWO-DAG: Function{[[UID2]]}, mangled = ?Func_arg_none@@YAXXZ, demangled = {{.*}}, type = [[TY2]]

Thanks!

In that case, will FileCheck only match the label that was specified or will it also match just CHECK and CHECK-DAG as well?

Thanks!

In that case, will FileCheck only match the label that was specified or will it also match just CHECK and CHECK-DAG as well?

There's nothing special about CHECK, it's just the default label for when you don't specify anything, and is identical to specifying --check-prefix=CHECK. So to answer your question, it will only match the label you specify.