From b996001770025fb0088947a18cfaa5084c97ee00 Mon Sep 17 00:00:00 2001 From: Steve MacLean Date: Wed, 15 Apr 2020 16:15:35 -0400 Subject: [PATCH 1/5] Fix .gitignore --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index a9a3cae8e94553..88165cf3073fd2 100644 --- a/.gitignore +++ b/.gitignore @@ -348,3 +348,6 @@ linker # ln -s $(pwd)/src/libraries/Common/src src/coreclr/src/System.Private.CoreLib/common src/coreclr/src/System.Private.CoreLib/shared src/coreclr/src/System.Private.CoreLib/common + +# The debug directory should not be ignored +!src/coreclr/src/debug From 8de120429bea5a2d5be314b097abea6abd34dd6a Mon Sep 17 00:00:00 2001 From: Steve MacLean Date: Wed, 15 Apr 2020 15:20:20 -0400 Subject: [PATCH 2/5] Enable cross OS DBI build --- src/coreclr/crosscomponents.cmake | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/coreclr/crosscomponents.cmake b/src/coreclr/crosscomponents.cmake index 30d53d585dff58..f8ea417471ca6e 100644 --- a/src/coreclr/crosscomponents.cmake +++ b/src/coreclr/crosscomponents.cmake @@ -14,10 +14,6 @@ endif() if(NOT CLR_CMAKE_HOST_LINUX AND NOT FEATURE_CROSSBITNESS) list (APPEND CLR_CROSS_COMPONENTS_LIST mscordaccore + mscordbi ) - if (CLR_CMAKE_HOST_OS STREQUAL CLR_CMAKE_TARGET_OS) - list (APPEND CLR_CROSS_COMPONENTS_LIST - mscordbi - ) - endif (CLR_CMAKE_HOST_OS STREQUAL CLR_CMAKE_TARGET_OS) endif() From dc75e154e828b91306bcc6e1232fb70fc3459ea9 Mon Sep 17 00:00:00 2001 From: Steve MacLean Date: Wed, 15 Apr 2020 16:17:16 -0400 Subject: [PATCH 3/5] Fix Cross OS DBI compilation issues --- .../src/debug/debug-pal/CMakeLists.txt | 16 ++-- .../src/debug/debug-pal/dummy/twowaypipe.cpp | 81 +++++++++++++++++++ src/coreclr/src/debug/di/cordb.cpp | 2 +- src/coreclr/src/dlls/mscordbi/CMakeLists.txt | 6 +- src/coreclr/src/md/CMakeLists.txt | 4 +- src/coreclr/src/md/hotdata/CMakeLists.txt | 4 +- src/coreclr/src/md/winmd/CMakeLists.txt | 8 +- 7 files changed, 105 insertions(+), 16 deletions(-) create mode 100644 src/coreclr/src/debug/debug-pal/dummy/twowaypipe.cpp diff --git a/src/coreclr/src/debug/debug-pal/CMakeLists.txt b/src/coreclr/src/debug/debug-pal/CMakeLists.txt index b06e46092caba1..b86432c7fd506a 100644 --- a/src/coreclr/src/debug/debug-pal/CMakeLists.txt +++ b/src/coreclr/src/debug/debug-pal/CMakeLists.txt @@ -8,11 +8,17 @@ if(CLR_CMAKE_HOST_WIN32) add_definitions(-DWIN32_LEAN_AND_MEAN) include_directories(../../inc) #needed for warning control - set(TWO_WAY_PIPE_SOURCES - win/diagnosticsipc.cpp - win/twowaypipe.cpp - win/processdescriptor.cpp - ) + if(CLR_CMAKE_TARGET_WIN32) + set(TWO_WAY_PIPE_SOURCES + win/diagnosticsipc.cpp + win/twowaypipe.cpp + win/processdescriptor.cpp + ) + else(CLR_CMAKE_TARGET_WIN32) + set(TWO_WAY_PIPE_SOURCES + dummy/twowaypipe.cpp + ) + endif(CLR_CMAKE_TARGET_WIN32) endif(CLR_CMAKE_HOST_WIN32) if(CLR_CMAKE_HOST_UNIX) diff --git a/src/coreclr/src/debug/debug-pal/dummy/twowaypipe.cpp b/src/coreclr/src/debug/debug-pal/dummy/twowaypipe.cpp new file mode 100644 index 00000000000000..d97479af0a5ec6 --- /dev/null +++ b/src/coreclr/src/debug/debug-pal/dummy/twowaypipe.cpp @@ -0,0 +1,81 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +#include +#include +#include +#include +#include "twowaypipe.h" + +#define _ASSERTE assert + +// This file contains implementation of a simple IPC mechanism - bidirectional named pipe. +// It is implemented on top of two one-directional names pipes (fifos on UNIX) + + +// Creates a server side of the pipe. +// Id is used to create pipes names and uniquely identify the pipe on the machine. +// true - success, false - failure (use GetLastError() for more details) +bool TwoWayPipe::CreateServer(const ProcessDescriptor& pd) +{ + return false; +} + + +// Connects to a previously opened server side of the pipe. +// Id is used to locate the pipe on the machine. +// true - success, false - failure (use GetLastError() for more details) +bool TwoWayPipe::Connect(const ProcessDescriptor& pd) +{ + return false; +} + +// Waits for incoming client connections, assumes GetState() == Created +// true - success, false - failure (use GetLastError() for more details) +bool TwoWayPipe::WaitForConnection() +{ + return false; +} + +// Reads data from pipe. Returns number of bytes read or a negative number in case of an error. +// use GetLastError() for more details +int TwoWayPipe::Read(void *buffer, DWORD bufferSize) +{ + return -1; +} + +// Writes data to pipe. Returns number of bytes written or a negative number in case of an error. +// use GetLastError() for more details +int TwoWayPipe::Write(const void *data, DWORD dataSize) +{ + return -1; +} + +// Disconnect server or client side of the pipe. +// true - success, false - failure (use GetLastError() for more details) +bool TwoWayPipe::Disconnect() +{ + return false; +} + +// Connects to a one sided pipe previously created by CreateOneWayPipe. +// In order to successfully connect id and inbound flag should be the same. +HANDLE TwoWayPipe::OpenOneWayPipe(DWORD id, bool inbound) +{ + return NULL; +} + + +// Creates a one way pipe, id and inboud flag are used for naming. +// Created pipe is supposed to be connected to by OpenOneWayPipe. +HANDLE TwoWayPipe::CreateOneWayPipe(DWORD id, bool inbound) +{ + return NULL; +} + +// Used by debugger side (RS) to cleanup the target (LS) named pipes +// and semaphores when the debugger detects the debuggee process exited. +void TwoWayPipe::CleanupTargetProcess() +{ +} diff --git a/src/coreclr/src/debug/di/cordb.cpp b/src/coreclr/src/debug/di/cordb.cpp index df6679040d1964..280cda4ef5a8f9 100644 --- a/src/coreclr/src/debug/di/cordb.cpp +++ b/src/coreclr/src/debug/di/cordb.cpp @@ -28,7 +28,7 @@ #endif //********** Globals. ********************************************************* -#ifndef TARGET_UNIX +#ifndef HOST_UNIX HINSTANCE g_hInst; // Instance handle to this piece of code. #endif diff --git a/src/coreclr/src/dlls/mscordbi/CMakeLists.txt b/src/coreclr/src/dlls/mscordbi/CMakeLists.txt index 3f4568fa75d62f..0b5eb203bac952 100644 --- a/src/coreclr/src/dlls/mscordbi/CMakeLists.txt +++ b/src/coreclr/src/dlls/mscordbi/CMakeLists.txt @@ -19,7 +19,7 @@ if(CLR_CMAKE_HOST_LINUX) list(APPEND MSCORDBI_SOURCES ${PAL_REDEFINES_FILE}) endif(CLR_CMAKE_HOST_LINUX) -if(CLR_CMAKE_TARGET_WIN32) +if(CLR_CMAKE_HOST_WIN32) add_definitions(-DFX_VER_INTERNALNAME_STR=mscordbi.dll) list(APPEND MSCORDBI_SOURCES @@ -35,11 +35,11 @@ if(CLR_CMAKE_TARGET_WIN32) preprocess_file(${DEF_SOURCES} ${CMAKE_CURRENT_BINARY_DIR}/mscordbi.def) list(APPEND MSCORDBI_SOURCES ${CMAKE_CURRENT_BINARY_DIR}/mscordbi.def) -else(CLR_CMAKE_TARGET_WIN32) +else(CLR_CMAKE_HOST_WIN32) set(DEF_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/mscordbi_unixexports.src) set(EXPORTS_FILE ${CMAKE_CURRENT_BINARY_DIR}/mscordbi.exports) generate_exports_file(${DEF_SOURCES} ${EXPORTS_FILE}) -endif(CLR_CMAKE_TARGET_WIN32) +endif(CLR_CMAKE_HOST_WIN32) if(CLR_CMAKE_HOST_LINUX OR CLR_CMAKE_HOST_FREEBSD OR CLR_CMAKE_HOST_NETBSD) # This option is necessary to ensure that the overloaded new/delete operators defined inside diff --git a/src/coreclr/src/md/CMakeLists.txt b/src/coreclr/src/md/CMakeLists.txt index bfc4efa10d5268..51ba8448a011f8 100644 --- a/src/coreclr/src/md/CMakeLists.txt +++ b/src/coreclr/src/md/CMakeLists.txt @@ -20,6 +20,6 @@ add_subdirectory(hotdata) add_subdirectory(ceefilegen) add_subdirectory(datasource) add_subdirectory(staticmd) -if(CLR_CMAKE_TARGET_WIN32) +if(CLR_CMAKE_HOST_WIN32) add_subdirectory(winmd) -endif(CLR_CMAKE_TARGET_WIN32) +endif(CLR_CMAKE_HOST_WIN32) diff --git a/src/coreclr/src/md/hotdata/CMakeLists.txt b/src/coreclr/src/md/hotdata/CMakeLists.txt index fdcf90aabc2acc..c6168d2a4b0c27 100644 --- a/src/coreclr/src/md/hotdata/CMakeLists.txt +++ b/src/coreclr/src/md/hotdata/CMakeLists.txt @@ -40,7 +40,7 @@ add_library_clr(mdhotdata_crossgen ${MDHOTDATA_SOURCES}) set_target_properties(mdhotdata_crossgen PROPERTIES CROSSGEN_COMPONENT TRUE) target_precompile_header(TARGET mdhotdata_crossgen HEADER external.h) -if(CLR_CMAKE_TARGET_WIN32) +if(CLR_CMAKE_HOST_WIN32) add_library_clr(mdhotdata-staticcrt ${MDHOTDATA_SOURCES}) target_precompile_header(TARGET mdhotdata-staticcrt HEADER external.h) -endif(CLR_CMAKE_TARGET_WIN32) +endif(CLR_CMAKE_HOST_WIN32) diff --git a/src/coreclr/src/md/winmd/CMakeLists.txt b/src/coreclr/src/md/winmd/CMakeLists.txt index 3b52f312efc3ea..0510a2b9042b7f 100644 --- a/src/coreclr/src/md/winmd/CMakeLists.txt +++ b/src/coreclr/src/md/winmd/CMakeLists.txt @@ -20,9 +20,9 @@ set(MDWINMD_HEADERS convert_to_absolute_path(MDWINMD_HEADERS ${MDWINMD_HEADERS}) convert_to_absolute_path(MDWINMD_SOURCES ${MDWINMD_SOURCES}) -if (CLR_CMAKE_TARGET_WIN32) +if (CLR_CMAKE_HOST_WIN32) list(APPEND MDWINMD_SOURCES ${MDWINMD_HEADERS}) -endif (CLR_CMAKE_TARGET_WIN32) +endif (CLR_CMAKE_HOST_WIN32) add_library_clr(mdwinmd_dac ${MDWINMD_SOURCES}) @@ -33,11 +33,13 @@ add_library_clr(mdwinmd_wks ${MDWINMD_SOURCES}) target_compile_definitions(mdwinmd_wks PRIVATE FEATURE_METADATA_EMIT_ALL) target_precompile_header(TARGET mdwinmd_wks HEADER stdafx.h) -if(CLR_CMAKE_TARGET_WIN32) +if(CLR_CMAKE_HOST_WIN32) add_library_clr(mdwinmd_dbi ${MDWINMD_SOURCES}) set_target_properties(mdwinmd_dbi PROPERTIES DBI_COMPONENT TRUE) target_precompile_header(TARGET mdwinmd_dbi HEADER stdafx.h) +endif(CLR_CMAKE_HOST_WIN32) +if(CLR_CMAKE_TARGET_WIN32) add_library_clr(mdwinmd_crossgen ${MDWINMD_SOURCES}) set_target_properties(mdwinmd_crossgen PROPERTIES CROSSGEN_COMPONENT TRUE) target_precompile_header(TARGET mdwinmd_crossgen HEADER stdafx.h) From eabadba514134e183680768e2c9d90536ccd3a69 Mon Sep 17 00:00:00 2001 From: Steve MacLean Date: Wed, 15 Apr 2020 18:01:54 -0400 Subject: [PATCH 4/5] Review feedback --- src/coreclr/src/debug/debug-pal/dummy/twowaypipe.cpp | 10 +++++----- src/coreclr/src/dlls/mscordbi/CMakeLists.txt | 6 +++++- src/coreclr/src/md/CMakeLists.txt | 4 ++-- src/coreclr/src/md/winmd/CMakeLists.txt | 8 +++----- 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/coreclr/src/debug/debug-pal/dummy/twowaypipe.cpp b/src/coreclr/src/debug/debug-pal/dummy/twowaypipe.cpp index d97479af0a5ec6..9307c50944d7e1 100644 --- a/src/coreclr/src/debug/debug-pal/dummy/twowaypipe.cpp +++ b/src/coreclr/src/debug/debug-pal/dummy/twowaypipe.cpp @@ -10,8 +10,8 @@ #define _ASSERTE assert -// This file contains implementation of a simple IPC mechanism - bidirectional named pipe. -// It is implemented on top of two one-directional names pipes (fifos on UNIX) +// This file contains a dummy implementation of the simple IPC mechanism - bidirectional named pipe. +// It is used for the cross OS DBI where IPC is not supported. // Creates a server side of the pipe. @@ -19,7 +19,7 @@ // true - success, false - failure (use GetLastError() for more details) bool TwoWayPipe::CreateServer(const ProcessDescriptor& pd) { - return false; + return false; } @@ -42,14 +42,14 @@ bool TwoWayPipe::WaitForConnection() // use GetLastError() for more details int TwoWayPipe::Read(void *buffer, DWORD bufferSize) { - return -1; + return -1; } // Writes data to pipe. Returns number of bytes written or a negative number in case of an error. // use GetLastError() for more details int TwoWayPipe::Write(const void *data, DWORD dataSize) { - return -1; + return -1; } // Disconnect server or client side of the pipe. diff --git a/src/coreclr/src/dlls/mscordbi/CMakeLists.txt b/src/coreclr/src/dlls/mscordbi/CMakeLists.txt index 0b5eb203bac952..6d189272c75ae5 100644 --- a/src/coreclr/src/dlls/mscordbi/CMakeLists.txt +++ b/src/coreclr/src/dlls/mscordbi/CMakeLists.txt @@ -79,9 +79,13 @@ set(COREDBI_LIBRARIES ) if(CLR_CMAKE_HOST_WIN32) + if(CLR_CMAKE_TARGET_WIN32) + set(COREDBI_TARGET_WIN32_LIBRARIES mdwinmd_dbi) + endif(CLR_CMAKE_TARGET_WIN32) + list(APPEND COREDBI_LIBRARIES mdhotdata-staticcrt - mdwinmd_dbi + ${COREDBI_TARGET_WIN32_LIBRARIES} kernel32.lib advapi32.lib ole32.lib diff --git a/src/coreclr/src/md/CMakeLists.txt b/src/coreclr/src/md/CMakeLists.txt index 51ba8448a011f8..bfc4efa10d5268 100644 --- a/src/coreclr/src/md/CMakeLists.txt +++ b/src/coreclr/src/md/CMakeLists.txt @@ -20,6 +20,6 @@ add_subdirectory(hotdata) add_subdirectory(ceefilegen) add_subdirectory(datasource) add_subdirectory(staticmd) -if(CLR_CMAKE_HOST_WIN32) +if(CLR_CMAKE_TARGET_WIN32) add_subdirectory(winmd) -endif(CLR_CMAKE_HOST_WIN32) +endif(CLR_CMAKE_TARGET_WIN32) diff --git a/src/coreclr/src/md/winmd/CMakeLists.txt b/src/coreclr/src/md/winmd/CMakeLists.txt index 0510a2b9042b7f..3b52f312efc3ea 100644 --- a/src/coreclr/src/md/winmd/CMakeLists.txt +++ b/src/coreclr/src/md/winmd/CMakeLists.txt @@ -20,9 +20,9 @@ set(MDWINMD_HEADERS convert_to_absolute_path(MDWINMD_HEADERS ${MDWINMD_HEADERS}) convert_to_absolute_path(MDWINMD_SOURCES ${MDWINMD_SOURCES}) -if (CLR_CMAKE_HOST_WIN32) +if (CLR_CMAKE_TARGET_WIN32) list(APPEND MDWINMD_SOURCES ${MDWINMD_HEADERS}) -endif (CLR_CMAKE_HOST_WIN32) +endif (CLR_CMAKE_TARGET_WIN32) add_library_clr(mdwinmd_dac ${MDWINMD_SOURCES}) @@ -33,13 +33,11 @@ add_library_clr(mdwinmd_wks ${MDWINMD_SOURCES}) target_compile_definitions(mdwinmd_wks PRIVATE FEATURE_METADATA_EMIT_ALL) target_precompile_header(TARGET mdwinmd_wks HEADER stdafx.h) -if(CLR_CMAKE_HOST_WIN32) +if(CLR_CMAKE_TARGET_WIN32) add_library_clr(mdwinmd_dbi ${MDWINMD_SOURCES}) set_target_properties(mdwinmd_dbi PROPERTIES DBI_COMPONENT TRUE) target_precompile_header(TARGET mdwinmd_dbi HEADER stdafx.h) -endif(CLR_CMAKE_HOST_WIN32) -if(CLR_CMAKE_TARGET_WIN32) add_library_clr(mdwinmd_crossgen ${MDWINMD_SOURCES}) set_target_properties(mdwinmd_crossgen PROPERTIES CROSSGEN_COMPONENT TRUE) target_precompile_header(TARGET mdwinmd_crossgen HEADER stdafx.h) From 45c2f67f884dd8c92c322db5289b831b1901d8e4 Mon Sep 17 00:00:00 2001 From: Steve MacLean Date: Fri, 17 Apr 2020 13:05:42 -0400 Subject: [PATCH 5/5] Cleanup dummy/twowaypipe.cpp --- .../src/debug/debug-pal/CMakeLists.txt | 22 +++++++++---------- .../src/debug/debug-pal/dummy/twowaypipe.cpp | 5 ----- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/src/coreclr/src/debug/debug-pal/CMakeLists.txt b/src/coreclr/src/debug/debug-pal/CMakeLists.txt index b86432c7fd506a..ac1e48fb5fb4d8 100644 --- a/src/coreclr/src/debug/debug-pal/CMakeLists.txt +++ b/src/coreclr/src/debug/debug-pal/CMakeLists.txt @@ -8,17 +8,17 @@ if(CLR_CMAKE_HOST_WIN32) add_definitions(-DWIN32_LEAN_AND_MEAN) include_directories(../../inc) #needed for warning control - if(CLR_CMAKE_TARGET_WIN32) - set(TWO_WAY_PIPE_SOURCES - win/diagnosticsipc.cpp - win/twowaypipe.cpp - win/processdescriptor.cpp - ) - else(CLR_CMAKE_TARGET_WIN32) - set(TWO_WAY_PIPE_SOURCES - dummy/twowaypipe.cpp - ) - endif(CLR_CMAKE_TARGET_WIN32) + if(CLR_CMAKE_TARGET_WIN32) + set(TWO_WAY_PIPE_SOURCES + win/diagnosticsipc.cpp + win/twowaypipe.cpp + win/processdescriptor.cpp + ) + else(CLR_CMAKE_TARGET_WIN32) + set(TWO_WAY_PIPE_SOURCES + dummy/twowaypipe.cpp + ) + endif(CLR_CMAKE_TARGET_WIN32) endif(CLR_CMAKE_HOST_WIN32) if(CLR_CMAKE_HOST_UNIX) diff --git a/src/coreclr/src/debug/debug-pal/dummy/twowaypipe.cpp b/src/coreclr/src/debug/debug-pal/dummy/twowaypipe.cpp index 9307c50944d7e1..ed73fd75cf1731 100644 --- a/src/coreclr/src/debug/debug-pal/dummy/twowaypipe.cpp +++ b/src/coreclr/src/debug/debug-pal/dummy/twowaypipe.cpp @@ -3,13 +3,8 @@ // See the LICENSE file in the project root for more information. #include -#include -#include -#include #include "twowaypipe.h" -#define _ASSERTE assert - // This file contains a dummy implementation of the simple IPC mechanism - bidirectional named pipe. // It is used for the cross OS DBI where IPC is not supported.