8199197: Set _NT_SYMBOL_PATH when running tests on windows
authorerikj
Wed, 07 Mar 2018 22:30:39 +0100
changeset 49147 af37d9997bd6
parent 49146 02b821c5df93
child 49148 323fc55ebe73
8199197: Set _NT_SYMBOL_PATH when running tests on windows Reviewed-by: ihse, ctornqvi
make/RunTests.gmk
make/RunTestsPrebuilt.gmk
make/conf/jib-profiles.js
test/TestCommon.gmk
--- a/make/RunTests.gmk	Wed Mar 07 19:14:36 2018 +0100
+++ b/make/RunTests.gmk	Wed Mar 07 22:30:39 2018 +0100
@@ -60,6 +60,18 @@
   endif
 endef
 
+# Setup _NT_SYMBOL_PATH on Windows
+ifeq ($(OPENJDK_TARGET_OS), windows)
+  ifndef _NT_SYMBOL_PATH
+    # Can't use PathList here as it adds quotes around the value.
+    _NT_SYMBOL_PATH := \
+        $(subst $(SPACE),;, $(foreach p, $(sort $(dir $(wildcard \
+        $(addprefix $(SYMBOLS_IMAGE_DIR)/bin/, *.pdb */*.pdb)))), $(call FixPath, $p)))
+    export _NT_SYMBOL_PATH
+    $(info _NT_SYMBOL_PATH $(_NT_SYMBOL_PATH))
+  endif
+endif
+
 ################################################################################
 # Hook to include the corresponding custom file, if present.
 $(eval $(call IncludeCustomExtension, RunTests.gmk))
@@ -496,6 +508,11 @@
   $1_JTREG_BASIC_OPTIONS += -e:JIB_DATA_DIR
   # Some tests needs to find a boot JDK using the JDK8_HOME variable.
   $1_JTREG_BASIC_OPTIONS += -e:JDK8_HOME=$$(BOOT_JDK)
+  # If running on Windows, propagate the _NT_SYMBOL_PATH to enable
+  # symbol lookup in hserr files
+  ifeq ($$(OPENJDK_TARGET_OS), windows)
+    $1_JTREG_BASIC_OPTIONS += -e:_NT_SYMBOL_PATH
+  endif
 
   $1_JTREG_BASIC_OPTIONS += \
       $$(addprefix -javaoption:, $$(JTREG_JAVA_OPTIONS)) \
--- a/make/RunTestsPrebuilt.gmk	Wed Mar 07 19:14:36 2018 +0100
+++ b/make/RunTestsPrebuilt.gmk	Wed Mar 07 22:30:39 2018 +0100
@@ -113,6 +113,7 @@
 # These can have default values based on the ones above
 $(eval $(call SetupVariable,JDK_IMAGE_DIR,$(OUTPUTDIR)/images/jdk))
 $(eval $(call SetupVariable,TEST_IMAGE_DIR,$(OUTPUTDIR)/images/test))
+$(eval $(call SetupVariable,SYMBOLS_IMAGE_DIR,$(OUTPUTDIR)/images/symbols))
 
 # Provide default values for tools that we need
 $(eval $(call SetupVariable,MAKE,make,NO_CHECK))
@@ -245,6 +246,7 @@
     JT_HOME := $(JT_HOME), \
     JDK_IMAGE_DIR := $(JDK_IMAGE_DIR), \
     TEST_IMAGE_DIR := $(TEST_IMAGE_DIR), \
+    SYMBOLS_IMAGE_DIR := $(SYMBOLS_IMAGE_DIR), \
     MAKE := $(MAKE), \
     BASH := $(BASH), \
     JIB_JAR := $(JIB_JAR), \
--- a/make/conf/jib-profiles.js	Wed Mar 07 19:14:36 2018 +0100
+++ b/make/conf/jib-profiles.js	Wed Mar 07 22:30:39 2018 +0100
@@ -743,11 +743,22 @@
             dependencies: [ "devkit" ],
             environment_path: input.get("devkit", "install_path")
                 + "/Xcode.app/Contents/Developer/usr/bin"
-        }
+        };
         profiles["run-test"] = concatObjects(profiles["run-test"], macosxRunTestExtra);
         profiles["run-test-jprt"] = concatObjects(profiles["run-test-jprt"], macosxRunTestExtra);
         profiles["run-test-prebuilt"] = concatObjects(profiles["run-test-prebuilt"], macosxRunTestExtra);
     }
+    // On windows we want the debug symbols available at test time
+    if (input.build_os == "windows") {
+        windowsRunTestPrebuiltExtra = {
+            dependencies: [ testedProfile + ".jdk_symbols" ],
+            environment: {
+                "PRODUCT_SYMBOLS_HOME": input.get(testedProfile + ".jdk_symbols", "home_path"),
+            }
+        };
+        profiles["run-test-prebuilt"] = concatObjects(profiles["run-test-prebuilt"],
+            windowsRunTestPrebuiltExtra);
+    }
 
     // Generate the missing platform attributes
     profiles = generatePlatformAttributes(profiles);
--- a/test/TestCommon.gmk	Wed Mar 07 19:14:36 2018 +0100
+++ b/test/TestCommon.gmk	Wed Mar 07 22:30:39 2018 +0100
@@ -34,6 +34,9 @@
 USE_JTREG_ASSERT ?= true
 LIMIT_JTREG_VM_MEMORY ?= true
 
+X:=
+SPACE:=$(X) $(X)
+
 .DEFAULT : all
 
 # Empty these to get rid of some default rules
@@ -87,6 +90,11 @@
   endif
 endif
 
+# convert list of directories to dos paths
+define MixedDirs
+$(foreach i,$1,$(shell $(GETMIXEDPATH) "${i}"))
+endef
+
 ifdef ALT_SLASH_JAVA
   SLASH_JAVA = $(ALT_SLASH_JAVA)
 endif
@@ -124,6 +132,19 @@
   PRODUCT_HOME := $(PRODUCT_HOME)
 endif
 
+# On Windows, setup the _NT_SYMBOL_PATH if possible.
+ifeq ($(PLATFORM), windows)
+  ifndef _NT_SYMBOL_PATH
+    ifdef PRODUCT_SYMBOLS_HOME
+      _NT_SYMBOL_PATH := \
+          $(subst $(SPACE),;,$(strip $(call MixedDirs, $(sort $(dir $(wildcard \
+          $(addprefix $(PRODUCT_SYMBOLS_HOME)/bin/, *.pdb */*.pdb)))))))
+      export _NT_SYMBOL_PATH
+    endif
+  endif
+  JTREG_BASIC_OPTIONS += -e:_NT_SYMBOL_PATH='$(_NT_SYMBOL_PATH)'
+endif
+
 # Expect JPRT to set JPRT_PRODUCT_ARGS (e.g. -server etc.)
 #   Should be passed into 'java' only.
 #   Could include: -d64 -server -client OR any java option
@@ -334,11 +355,6 @@
   JTREG_EXCLUSIONS = $(PROBLEM_LISTS:%=-exclude:%)
 endif
 
-# convert list of directories to dos paths
-define MixedDirs
-$(foreach i,$1,$(shell $(GETMIXEDPATH) "${i}"))
-endef
-
 # ------------------------------------------------------------------
 
 # When called from JPRT the TESTDIRS variable is set to the jtreg tests to run