Skip to content

Commit

Permalink
Fix mono builds
Browse files Browse the repository at this point in the history
  • Loading branch information
davmason committed May 10, 2021
1 parent 59a9b5d commit 1bb4fe9
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 25 deletions.
8 changes: 4 additions & 4 deletions src/coreclr/vm/eventing/eventpipe/ds-rt-coreclr.h
Original file line number Diff line number Diff line change
Expand Up @@ -323,20 +323,20 @@ ds_rt_profiler_startup (DiagnosticsStartupProfilerCommandPayload *payload)

static
uint32_t
ds_rt_set_environment_variable (DiagnosticsSetEnvironmentVariablePayload *payload)
ds_rt_set_environment_variable (const ep_char16_t *name, const ep_char16_t *value)
{
return SetEnvironmentVariableW(reinterpret_cast<LPCWSTR>(payload->name), reinterpret_cast<LPCWSTR>(payload->value)) ? S_OK : HRESULT_FROM_WIN32(GetLastError());
return SetEnvironmentVariableW(reinterpret_cast<LPCWSTR>(name), reinterpret_cast<LPCWSTR>(value)) ? S_OK : HRESULT_FROM_WIN32(GetLastError());
}

static
uint32_t
ds_rt_get_environment_variable (DiagnosticsGetEnvironmentVariablePayload *payload,
ds_rt_get_environment_variable (const ep_char16_t *name,
uint32_t valueBufferLength,
uint32_t *valueLengthOut,
ep_char16_t *valueBuffer)
{
HRESULT hr = S_OK;
uint32_t trueLen = GetEnvironmentVariableW(reinterpret_cast<LPCWSTR>(payload->name), reinterpret_cast<LPWSTR>(valueBuffer), valueBufferLength);
uint32_t trueLen = GetEnvironmentVariableW(reinterpret_cast<LPCWSTR>(name), reinterpret_cast<LPWSTR>(valueBuffer), valueBufferLength);
if (trueLen == 0)
{
hr = HRESULT_FROM_WIN32(GetLastError());
Expand Down
13 changes: 6 additions & 7 deletions src/mono/mono/eventpipe/ds-rt-mono.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

#ifdef ENABLE_PERFTRACING
#include "ep-rt-mono.h"
#include "ds-process-protocol.h"
#include <mono/utils/mono-logger-internals.h>

#undef DS_LOG_ALWAYS_0
Expand Down Expand Up @@ -251,10 +250,10 @@ ds_rt_profiler_startup (DiagnosticsStartupProfilerCommandPayload *payload)

static
uint32_t
ds_rt_set_environment_variable (DiagnosticsSetEnvironmentVariablePayload *payload)
ds_rt_set_environment_variable (const ep_char16_t *name, const ep_char16_t *value)
{
gchar *nameNarrow = u16to8 (payload->name);
gchar *valueNarrow = u16to8 (payload->value);
gchar *nameNarrow = ep_rt_utf16_to_utf8_string (name, ep_rt_utf16_string_len (name));
gchar *valueNarrow = ep_rt_utf16_to_utf8_string (value, ep_rt_utf16_string_len (value));

gboolean success = g_setenv(nameNarrow, valueNarrow, true);

Expand All @@ -266,16 +265,16 @@ ds_rt_set_environment_variable (DiagnosticsSetEnvironmentVariablePayload *payloa

static
uint32_t
ds_rt_get_environment_variable (DiagnosticsGetEnvironmentVariablePayload *payload,
ds_rt_get_environment_variable (const ep_char16_t *name,
uint32_t valueBufferLength,
uint32_t *valueLengthOut,
ep_char16_t *valueBuffer)
{
gchar *nameNarrow = u16to8 (payload->name);
gchar *nameNarrow = ep_rt_utf16_to_utf8_string (name, ep_rt_utf16_string_len (name));
gchar *valueNarrow = g_getenv(nameNarrow);

uint32_t valueLength = strlen(valueNarrow);
if (valueLength > valueBufferLength && valueBuffer != NULL);
if (valueLength > valueBufferLength && valueBuffer != NULL)
{
g_free (nameNarrow);
g_free (valueNarrow);
Expand Down
14 changes: 5 additions & 9 deletions src/native/eventpipe/ds-process-protocol.c
Original file line number Diff line number Diff line change
Expand Up @@ -455,14 +455,12 @@ process_protocol_helper_resume_runtime_startup (
return result;
}

static
DiagnosticsSetEnvironmentVariablePayload *
ds_set_environment_variable_payload_alloc ()
ds_set_environment_variable_payload_alloc (void)
{
return ep_rt_object_alloc (DiagnosticsSetEnvironmentVariablePayload);
}

static
void
ds_set_environment_variable_payload_free (DiagnosticsSetEnvironmentVariablePayload *payload)
{
Expand Down Expand Up @@ -520,7 +518,7 @@ process_protocol_helper_set_environment_variable (
}

ds_ipc_result_t ipc_result;
ipc_result = ds_rt_set_environment_variable (payload);
ipc_result = ds_rt_set_environment_variable (payload->name, payload->value);
if (ipc_result != DS_IPC_S_OK) {
ds_ipc_message_send_error (stream, ipc_result);
ep_raise_error ();
Expand Down Expand Up @@ -574,9 +572,8 @@ get_environment_variable_payload_flatten (
return success;
}

static
DiagnosticsGetEnvironmentVariablePayload *
ds_get_environment_variable_payload_alloc ()
ds_get_environment_variable_payload_alloc (void)
{
return ep_rt_object_alloc (DiagnosticsGetEnvironmentVariablePayload);
}
Expand Down Expand Up @@ -630,7 +627,6 @@ process_protocol_helper_get_environment_variable (
return false;

ep_char16_t *valueBuffer = NULL;
uint8_t *messageBuffer = NULL;
uint32_t bufferSize = 0;
uint32_t realLength;
bool result = false;
Expand All @@ -641,7 +637,7 @@ process_protocol_helper_get_environment_variable (
}

ds_ipc_result_t ipc_result;
ipc_result = ds_rt_get_environment_variable (payload, 0, &realLength, NULL);
ipc_result = ds_rt_get_environment_variable (payload->name, 0, &realLength, NULL);
if (ipc_result != DS_IPC_S_OK) {
ds_ipc_message_send_error (stream, ipc_result);
ep_raise_error ();
Expand All @@ -655,7 +651,7 @@ process_protocol_helper_get_environment_variable (
ep_raise_error ();
}

ipc_result = ds_rt_get_environment_variable (payload, realLength, &realLength, valueBuffer);
ipc_result = ds_rt_get_environment_variable (payload->name, realLength, &realLength, valueBuffer);
if (ipc_result != DS_IPC_S_OK) {
ds_ipc_message_send_error (stream, ipc_result);
ep_raise_error ();
Expand Down
4 changes: 2 additions & 2 deletions src/native/eventpipe/ds-process-protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ struct _DiagnosticsSetEnvironmentVariablePayload {
#endif

DiagnosticsSetEnvironmentVariablePayload *
ds_set_environment_variable_payload_alloc ();
ds_set_environment_variable_payload_alloc (void);

void
ds_set_environment_variable_payload_free (DiagnosticsSetEnvironmentVariablePayload *payload);
Expand All @@ -135,7 +135,7 @@ struct _DiagnosticsGetEnvironmentVariablePayload {
#endif

DiagnosticsGetEnvironmentVariablePayload *
ds_get_environment_variable_payload_alloc ();
ds_get_environment_variable_payload_alloc (void);

void
ds_get_environment_variable_payload_free (DiagnosticsGetEnvironmentVariablePayload *payload);
Expand Down
4 changes: 2 additions & 2 deletions src/native/eventpipe/ds-rt.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,11 @@ ds_rt_profiler_startup (DiagnosticsStartupProfilerCommandPayload *payload);

static
uint32_t
ds_rt_set_environment_variable (DiagnosticsSetEnvironmentVariablePayload *payload);
ds_rt_set_environment_variable (const ep_char16_t *name, const ep_char16_t *value);

static
uint32_t
ds_rt_get_environment_variable (DiagnosticsGetEnvironmentVariablePayload *payload,
ds_rt_get_environment_variable (const ep_char16_t *name,
uint32_t valueBufferLength,
uint32_t *valueLengthOut,
ep_char16_t *valueBuffer);
Expand Down
2 changes: 1 addition & 1 deletion src/tests/profiler/native/nullprofiler/nullprofiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ HRESULT NullProfiler::Initialize(IUnknown* pICorProfilerInfoUnk)
return E_FAIL;
}
// ERROR_ENVVAR_NOT_FOUND hr
else if (hr != 0x800700CB)
else if (hr != (HRESULT)0x800700CB)
{
wcout << L"ReverseServerTest_ClearMe returned an HR other than ENVVAR_NOT_FOUND" << std::hex << hr << endl;
_failures++;
Expand Down

0 comments on commit 1bb4fe9

Please sign in to comment.