Upgrade to VS2019 (#2448)

Updates DR to the latest 6431fc4f5 for VS2019 support and to fix DynamoRIO/dynamorio#5432.

Updates GA CI jobs to use the 2019 image.

Defines VS2019-required defines, just like DR does.

Avoids dup symbol errors for strtol in libucrtd and ntdll_imports via /force:multiple (xref #1805).

Issue: DynamoRIO/dynamorio#5195, #1805, DynamoRIO/dynamorio#5432
diff --git a/.github/workflows/ci-package.yml b/.github/workflows/ci-package.yml
index 641ac12..042fcc4 100644
--- a/.github/workflows/ci-package.yml
+++ b/.github/workflows/ci-package.yml
@@ -1,5 +1,5 @@
 # **********************************************************
-# Copyright (c) 2020-2021 Google, Inc.  All rights reserved.
+# Copyright (c) 2020-2022 Google, Inc.  All rights reserved.
 # **********************************************************
 
 # Dr. Memory: the memory debugger
@@ -165,7 +165,7 @@
   ###########################################################################
   # Windows .zip and .msi with 32-bit and 64-bit x86 builds:
   windows:
-    runs-on: windows-2016
+    runs-on: windows-2019
 
     steps:
     - uses: actions/checkout@v2
@@ -209,7 +209,7 @@
         set PATH=c:\projects\install\doxygen;%PATH%
         dir "c:\Program Files (x86)\WiX Toolset"*
         set PATH=C:\Program Files (x86)\WiX Toolset v3.11\bin;%PATH%
-        call "C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/VC/Auxiliary/Build/vcvars32.bat"
+        call "C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Auxiliary/Build/vcvars32.bat"
         echo ------ Running suite ------
         echo PATH is "%PATH%"
         echo Running in directory "%CD%"
diff --git a/.github/workflows/ci-windows.yml b/.github/workflows/ci-windows.yml
index 9a0f8e7..e6e09aa 100644
--- a/.github/workflows/ci-windows.yml
+++ b/.github/workflows/ci-windows.yml
@@ -1,5 +1,5 @@
 # **********************************************************
-# Copyright (c) 2020 Google, Inc.  All rights reserved.
+# Copyright (c) 2020-2022 Google, Inc.  All rights reserved.
 # **********************************************************
 
 # Dr. Memory: the memory debugger
@@ -38,9 +38,9 @@
     shell: cmd
 
 jobs:
-  # 32-bit VS2017 and tests:
-  vs2017-32:
-    runs-on: windows-2016
+  # 32-bit VS2019 and tests:
+  vs2019-32:
+    runs-on: windows-2019
 
     steps:
     - uses: actions/checkout@v2
@@ -73,15 +73,15 @@
         set PATH=c:\projects\install\doxygen;%PATH%
         dir "c:\Program Files (x86)\WiX Toolset"*
         set PATH=C:\Program Files (x86)\WiX Toolset v3.11\bin;%PATH%
-        call "C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/VC/Auxiliary/Build/vcvars32.bat"
+        call "C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Auxiliary/Build/vcvars32.bat"
         echo ------ Running suite ------
         echo PATH is "%PATH%"
         echo Running in directory "%CD%"
         perl tests/runsuite_wrapper.pl travis use_ninja 32_only drmemory_only debug_only
 
-  # 64-bit VS2017 and tests:
-  vs2017-64:
-    runs-on: windows-2016
+  # 64-bit VS2019 and tests:
+  vs2019-64:
+    runs-on: windows-2019
 
     steps:
     - uses: actions/checkout@v2
@@ -114,15 +114,15 @@
         set PATH=c:\projects\install\doxygen;%PATH%
         dir "c:\Program Files (x86)\WiX Toolset"*
         set PATH=C:\Program Files (x86)\WiX Toolset v3.11\bin;%PATH%
-        call "C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/VC/Auxiliary/Build/vcvars32.bat"
+        call "C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Auxiliary/Build/vcvars32.bat"
         echo ------ Running suite ------
         echo PATH is "%PATH%"
         echo Running in directory "%CD%"
         perl tests/runsuite_wrapper.pl travis use_ninja 64_only debug_only
 
   # drheapstat and release builds:
-  vs2017-builds:
-    runs-on: windows-2016
+  vs2019-builds:
+    runs-on: windows-2019
 
     steps:
     - uses: actions/checkout@v2
@@ -155,7 +155,7 @@
         set PATH=c:\projects\install\doxygen;%PATH%
         dir "c:\Program Files (x86)\WiX Toolset"*
         set PATH=C:\Program Files (x86)\WiX Toolset v3.11\bin;%PATH%
-        call "C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/VC/Auxiliary/Build/vcvars32.bat"
+        call "C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Auxiliary/Build/vcvars32.bat"
         echo ------ Running suite ------
         echo PATH is "%PATH%"
         echo Running in directory "%CD%"
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a341795..a0935c0 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,5 +1,5 @@
 # **********************************************************
-# Copyright (c) 2010-2021 Google, Inc.  All rights reserved.
+# Copyright (c) 2010-2022 Google, Inc.  All rights reserved.
 # Copyright (c) 2009-2010 VMware, Inc.  All rights reserved.
 # **********************************************************
 
@@ -462,6 +462,14 @@
 endif (UNIX)
 
 if (WIN32)
+  # Ensure that _AMD64_ or _X86_ are defined on Microsoft Windows, as otherwise
+  # um/winnt.h provided since Windows 10.0.22000 will error.
+  if (X64)
+    add_definitions(-D_AMD64_)
+  else (X64)
+    add_definitions(-D_X86_)
+  endif (X64)
+
   # Use convention of DynamoRIO sources: DDKROOT env var (or DDK_ROOT cmake var).
   # We don't require the DDK as dbghelp and symsrv are in the SDK as well, and
   # we get ntdll_imports.lib from DR.
@@ -1319,6 +1327,9 @@
   # This flag is added by VS generators so we may as well add for Ninja
   set(new_flags "/nxcompat")
 
+  # i#1805: avoid strtol dup symbol errors (libucrtd vs ntdll_imports).
+  set(new_flags "${new_flags} /force:multiple")
+
   # Reduce size by stripping out unused code (we don't seem to need /Gy for this,
   # and VS generators seem to set it already, so we add here for Ninja).
   # XXX: DRi#2167 is adding this for all clients so we can remove this once
@@ -1858,6 +1869,10 @@
     add_executable(unit_tests ${srcs})
     _DR_append_property_list(TARGET unit_tests COMPILE_DEFINITIONS
       "${DEFINES_NO_D};BUILD_UNIT_TESTS;RC_IS_UNITTESTS")
+    if (WIN32)
+      # i#1805: avoid strtol dup symbol errors (libucrtd vs ntdll_imports).
+      append_property_string(TARGET unit_tests LINK_FLAGS "/force:multiple")
+    endif ()
     if ("${CMAKE_GENERATOR}" MATCHES "Visual Studio")
       # ensure race-free parallel builds
       add_dependencies(unit_tests ${asm_utils_tgt})
diff --git a/dynamorio b/dynamorio
index 5e27a98..6431fc4 160000
--- a/dynamorio
+++ b/dynamorio
@@ -1 +1 @@
-Subproject commit 5e27a98213a18575ade3c3e089dc1cd0dacdc696
+Subproject commit 6431fc4f525b9b7ea6cbc7b274c476212be2ddc9