[Lldb-commits] [lldb] r374335 - [lldb] Make sure import-std-module/sysroot actually passes for the right reasons

Raphael Isemann via lldb-commits lldb-commits at lists.llvm.org
Thu Oct 10 05:57:14 PDT 2019


Author: teemperor
Date: Thu Oct 10 05:57:14 2019
New Revision: 374335

URL: http://llvm.org/viewvc/llvm-project?rev=374335&view=rev
Log:
[lldb] Make sure import-std-module/sysroot actually passes for the right reasons

This test was previously passing because myabs was actually emitted into the
debug information and we called that. The test itself was broken as it didn't
use the libc++ directory structure (the /v1/ directory was just called /include/).

This patch gives myabs a default argument which we can't get from debug information
and inlines the function to make sure we can't call it from LLDB without loading
the C++ module.

Added:
    lldb/trunk/packages/Python/lldbsuite/test/commands/expression/import-std-module/sysroot/root/usr/include/c++/v1/
    lldb/trunk/packages/Python/lldbsuite/test/commands/expression/import-std-module/sysroot/root/usr/include/c++/v1/algorithm
    lldb/trunk/packages/Python/lldbsuite/test/commands/expression/import-std-module/sysroot/root/usr/include/c++/v1/module.modulemap
Removed:
    lldb/trunk/packages/Python/lldbsuite/test/commands/expression/import-std-module/sysroot/root/usr/include/c++/include/
Modified:
    lldb/trunk/packages/Python/lldbsuite/test/commands/expression/import-std-module/sysroot/Makefile
    lldb/trunk/packages/Python/lldbsuite/test/commands/expression/import-std-module/sysroot/TestStdModuleSysroot.py
    lldb/trunk/packages/Python/lldbsuite/test/commands/expression/import-std-module/sysroot/main.cpp

Modified: lldb/trunk/packages/Python/lldbsuite/test/commands/expression/import-std-module/sysroot/Makefile
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/commands/expression/import-std-module/sysroot/Makefile?rev=374335&r1=374334&r2=374335&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/commands/expression/import-std-module/sysroot/Makefile (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/commands/expression/import-std-module/sysroot/Makefile Thu Oct 10 05:57:14 2019
@@ -3,7 +3,7 @@
 # system headers.
 NO_TEST_COMMON_H := 1
 
-CXXFLAGS_EXTRAS = -I $(SRCDIR)/root/usr/include/c++/include/ -I $(SRCDIR)/root/usr/include/ -nostdinc -nostdinc++
+CXXFLAGS_EXTRAS = -I $(SRCDIR)/root/usr/include/c++/v1/ -I $(SRCDIR)/root/usr/include/ -nostdinc -nostdinc++
 CXX_SOURCES := main.cpp
 
 include Makefile.rules

Modified: lldb/trunk/packages/Python/lldbsuite/test/commands/expression/import-std-module/sysroot/TestStdModuleSysroot.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/commands/expression/import-std-module/sysroot/TestStdModuleSysroot.py?rev=374335&r1=374334&r2=374335&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/commands/expression/import-std-module/sysroot/TestStdModuleSysroot.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/commands/expression/import-std-module/sysroot/TestStdModuleSysroot.py Thu Oct 10 05:57:14 2019
@@ -27,4 +27,6 @@ class ImportStdModule(TestBase):
 
         # Call our custom function in our sysroot std module.
         # If this gives us the correct result, then we used the sysroot.
-        self.expect("expr std::myabs(-42)", substrs=['(int) $0 = 42'])
+        # We rely on the default argument of -123 to make sure we actually have the C++ module.
+        # (We don't have default arguments in the debug information).
+        self.expect("expr std::myabs()", substrs=['(int) $0 = 123'])

Modified: lldb/trunk/packages/Python/lldbsuite/test/commands/expression/import-std-module/sysroot/main.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/commands/expression/import-std-module/sysroot/main.cpp?rev=374335&r1=374334&r2=374335&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/commands/expression/import-std-module/sysroot/main.cpp (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/commands/expression/import-std-module/sysroot/main.cpp Thu Oct 10 05:57:14 2019
@@ -2,5 +2,6 @@
 
 int main(int argc, char **argv) {
   libc_struct s;
+  std::vector v;
   return 0; // Set break point at this line.
 }

Added: lldb/trunk/packages/Python/lldbsuite/test/commands/expression/import-std-module/sysroot/root/usr/include/c++/v1/algorithm
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/commands/expression/import-std-module/sysroot/root/usr/include/c%2B%2B/v1/algorithm?rev=374335&view=auto
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/commands/expression/import-std-module/sysroot/root/usr/include/c++/v1/algorithm (added)
+++ lldb/trunk/packages/Python/lldbsuite/test/commands/expression/import-std-module/sysroot/root/usr/include/c++/v1/algorithm Thu Oct 10 05:57:14 2019
@@ -0,0 +1,11 @@
+#include "libc_header.h"
+
+namespace std {
+  // Makes sure we get a support file for this header.
+  struct vector { int i; };
+
+  inline int myabs(int i = -123) {
+    double nil;
+    return i < 0 ? -i : i;
+  }
+}

Added: lldb/trunk/packages/Python/lldbsuite/test/commands/expression/import-std-module/sysroot/root/usr/include/c++/v1/module.modulemap
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/commands/expression/import-std-module/sysroot/root/usr/include/c%2B%2B/v1/module.modulemap?rev=374335&view=auto
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/commands/expression/import-std-module/sysroot/root/usr/include/c++/v1/module.modulemap (added)
+++ lldb/trunk/packages/Python/lldbsuite/test/commands/expression/import-std-module/sysroot/root/usr/include/c++/v1/module.modulemap Thu Oct 10 05:57:14 2019
@@ -0,0 +1,3 @@
+module std {
+  module "algorithm" { header "algorithm" export * }
+}




More information about the lldb-commits mailing list