Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/dotnet/runtime.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdeel Mujahid <3840695+am11@users.noreply.github.com>2021-11-24 19:52:12 +0300
committerGitHub <noreply@github.com>2021-11-24 19:52:12 +0300
commit4da6b9a8d55913c0ea560d63590d35dc942425be (patch)
treeb202be0c76bcd3b68591c73bd9e3a7e559e1fe85 /src/native/eventpipe
parent292632fd04671aed0b302195f05834a01db474fa (diff)
Unify ARRAY_SIZE/STRING_LENGTH-like macros (#61537)
* Unify ARRAY_SIZE/STRING_LENGTH-like macros * Cleanup trailing whitespaces in changeset files * Use ArrLen in the JIT * Keep using G_N_ELEMENTS in mono * Resolve name conflict in test
Diffstat (limited to 'src/native/eventpipe')
-rw-r--r--src/native/eventpipe/ds-ipc.c6
-rw-r--r--src/native/eventpipe/ds-profiler-protocol.c8
-rw-r--r--src/native/eventpipe/ep-block.c2
-rw-r--r--src/native/eventpipe/ep-event-instance.c4
-rw-r--r--src/native/eventpipe/ep-event-source.c4
-rw-r--r--src/native/eventpipe/ep-file.c2
-rw-r--r--src/native/eventpipe/ep-json-file.c16
-rw-r--r--src/native/eventpipe/ep-rt.h3
-rw-r--r--src/native/eventpipe/ep-session.c2
-rw-r--r--src/native/eventpipe/ep-stream.c2
-rw-r--r--src/native/eventpipe/ep.c4
11 files changed, 27 insertions, 26 deletions
diff --git a/src/native/eventpipe/ds-ipc.c b/src/native/eventpipe/ds-ipc.c
index 063b98b84ae..b9c00030e69 100644
--- a/src/native/eventpipe/ds-ipc.c
+++ b/src/native/eventpipe/ds-ipc.c
@@ -218,11 +218,11 @@ ipc_log_poll_handles (ds_rt_ipc_poll_handle_array_t *ipc_poll_handles)
while (!ds_rt_ipc_poll_handle_array_iterator_end (ipc_poll_handles, &ipc_poll_handles_iterator)) {
ipc_poll_handle = ds_rt_ipc_poll_handle_array_iterator_value (&ipc_poll_handles_iterator);
if (ipc_poll_handle.ipc) {
- if (!(ds_ipc_to_string (ipc_poll_handle.ipc, buffer, (uint32_t)EP_ARRAY_SIZE (buffer)) > 0))
+ if (!(ds_ipc_to_string (ipc_poll_handle.ipc, buffer, (uint32_t)ARRAY_SIZE (buffer)) > 0))
buffer [0] = '\0';
DS_LOG_DEBUG_2 ("\tSERVER IpcPollHandle[%d] = %s", connection_id, buffer);
} else {
- if (!(ds_ipc_stream_to_string (ipc_poll_handle.stream, buffer, (uint32_t)EP_ARRAY_SIZE (buffer))))
+ if (!(ds_ipc_stream_to_string (ipc_poll_handle.stream, buffer, (uint32_t)ARRAY_SIZE (buffer))))
buffer [0] = '\0';
DS_LOG_DEBUG_2 ("\tCLIENT IpcPollHandle[%d] = %s", connection_id, buffer);
}
@@ -703,7 +703,7 @@ connect_port_get_ipc_poll_handle_func (
}
ep_char8_t buffer [DS_IPC_MAX_TO_STRING_LEN];
- if (!(ds_ipc_stream_to_string (connection, buffer, (uint32_t)EP_ARRAY_SIZE (buffer))))
+ if (!(ds_ipc_stream_to_string (connection, buffer, (uint32_t)ARRAY_SIZE (buffer))))
buffer [0] = '\0';
DS_LOG_DEBUG_1 ("connect_port_get_ipc_poll_handle - returned connection %s", buffer);
diff --git a/src/native/eventpipe/ds-profiler-protocol.c b/src/native/eventpipe/ds-profiler-protocol.c
index 73999ffe429..56cc5a559fd 100644
--- a/src/native/eventpipe/ds-profiler-protocol.c
+++ b/src/native/eventpipe/ds-profiler-protocol.c
@@ -67,7 +67,7 @@ attach_profiler_command_try_parse_payload (
instance->incoming_buffer = buffer;
if (!ds_ipc_message_try_parse_uint32_t (&buffer_cursor, &buffer_cursor_len, &instance->attach_timeout ) ||
- !ds_ipc_message_try_parse_value (&buffer_cursor, &buffer_cursor_len, (uint8_t *)&instance->profiler_guid, (uint32_t)EP_ARRAY_SIZE (instance->profiler_guid)) ||
+ !ds_ipc_message_try_parse_value (&buffer_cursor, &buffer_cursor_len, (uint8_t *)&instance->profiler_guid, (uint32_t)ARRAY_SIZE (instance->profiler_guid)) ||
!ds_ipc_message_try_parse_string_utf16_t (&buffer_cursor, &buffer_cursor_len, &instance->profiler_path) ||
!ds_ipc_message_try_parse_uint32_t (&buffer_cursor, &buffer_cursor_len, &instance->client_data_len) ||
!(buffer_cursor_len <= instance->client_data_len))
@@ -193,7 +193,7 @@ startup_profiler_command_try_parse_payload (
instance->incoming_buffer = buffer;
- if (!ds_ipc_message_try_parse_value (&buffer_cursor, &buffer_cursor_len, (uint8_t *)&instance->profiler_guid, (uint32_t)EP_ARRAY_SIZE (instance->profiler_guid)) ||
+ if (!ds_ipc_message_try_parse_value (&buffer_cursor, &buffer_cursor_len, (uint8_t *)&instance->profiler_guid, (uint32_t)ARRAY_SIZE (instance->profiler_guid)) ||
!ds_ipc_message_try_parse_string_utf16_t (&buffer_cursor, &buffer_cursor_len, &instance->profiler_path))
ep_raise_error ();
@@ -223,7 +223,7 @@ profiler_protocol_helper_startup_profiler (
if (!ds_server_is_paused_in_startup()) {
ds_ipc_message_send_error (stream, DS_IPC_E_INVALIDARG);
ep_raise_error ();
- }
+ }
payload = (DiagnosticsStartupProfilerCommandPayload *)ds_ipc_message_try_parse_payload (message, startup_profiler_command_try_parse_payload);
@@ -294,7 +294,7 @@ ds_profiler_protocol_helper_handle_ipc_message (
return true;
}
-#endif // PROFILING_SUPPORTED
+#endif // PROFILING_SUPPORTED
#endif /* !defined(DS_INCLUDE_SOURCE_FILES) || defined(DS_FORCE_INCLUDE_SOURCE_FILES) */
#endif /* ENABLE_PERFTRACING */
diff --git a/src/native/eventpipe/ep-block.c b/src/native/eventpipe/ep-block.c
index 267ce30cbbd..0bd7d1e941a 100644
--- a/src/native/eventpipe/ep-block.c
+++ b/src/native/eventpipe/ep-block.c
@@ -441,7 +441,7 @@ ep_event_block_base_init (
event_block_base->use_header_compression = use_header_compression;
- memset (event_block_base->compressed_header, 0, EP_ARRAY_SIZE (event_block_base->compressed_header));
+ memset (event_block_base->compressed_header, 0, ARRAY_SIZE (event_block_base->compressed_header));
ep_event_block_base_clear (event_block_base);
ep_on_exit:
diff --git a/src/native/eventpipe/ep-event-instance.c b/src/native/eventpipe/ep-event-instance.c
index b021ca39999..4266d2bbcf2 100644
--- a/src/native/eventpipe/ep-event-instance.c
+++ b/src/native/eventpipe/ep-event-instance.c
@@ -200,13 +200,13 @@ ep_event_instance_serialize_to_json_file (
int32_t characters_written = -1;
characters_written = ep_rt_utf8_string_snprintf (
buffer,
- EP_ARRAY_SIZE (buffer),
+ ARRAY_SIZE (buffer),
"Provider=%s/EventID=%d/Version=%d",
ep_provider_get_provider_name (ep_event_get_provider (ep_event_instance->ep_event)),
ep_event_get_event_id (ep_event_instance->ep_event),
ep_event_get_event_version (ep_event_instance->ep_event));
- if (characters_written > 0 && characters_written < (int32_t)EP_ARRAY_SIZE (buffer))
+ if (characters_written > 0 && characters_written < (int32_t)ARRAY_SIZE (buffer))
ep_json_file_write_event_data (json_file, ep_event_instance->timestamp, ep_rt_uint64_t_to_thread_id_t (ep_event_instance->thread_id), buffer, &ep_event_instance->stack_contents);
}
#else
diff --git a/src/native/eventpipe/ep-event-source.c b/src/native/eventpipe/ep-event-source.c
index 237f0346128..36eac2dcbbf 100644
--- a/src/native/eventpipe/ep-event-source.c
+++ b/src/native/eventpipe/ep-event-source.c
@@ -100,7 +100,7 @@ ep_event_source_init (EventPipeEventSource *event_source)
// Generate metadata.
EventPipeParameterDesc params [3];
uint32_t params_len;
- params_len = (uint32_t)EP_ARRAY_SIZE (params);
+ params_len = (uint32_t)ARRAY_SIZE (params);
command_line_arg_utf16 = ep_rt_utf8_to_utf16_string ("CommandLine", -1);
ep_raise_error_if_nok (command_line_arg_utf16 != NULL);
@@ -221,7 +221,7 @@ ep_event_source_send_process_info (
if (arch_info_utf16)
ep_event_data_init (&data[2], (uint64_t)arch_info_utf16, (uint32_t)((ep_rt_utf16_string_len (arch_info_utf16) + 1) * sizeof (ep_char16_t)), 0);
- ep_write_event_2 (event_source->process_info_event, data, (uint32_t)EP_ARRAY_SIZE (data), NULL, NULL);
+ ep_write_event_2 (event_source->process_info_event, data, (uint32_t)ARRAY_SIZE (data), NULL, NULL);
ep_rt_utf16_string_free (arch_info_utf16);
ep_rt_utf16_string_free (os_info_utf16);
diff --git a/src/native/eventpipe/ep-file.c b/src/native/eventpipe/ep-file.c
index 40acec0a839..1606d7a9c2f 100644
--- a/src/native/eventpipe/ep-file.c
+++ b/src/native/eventpipe/ep-file.c
@@ -398,7 +398,7 @@ ep_file_initialize_file (EventPipeFile *file)
bool success = true;
if (file->format >= EP_SERIALIZATION_FORMAT_NETTRACE_V4) {
const ep_char8_t header[] = "Nettrace";
- const uint32_t bytes_to_write = (uint32_t)(EP_ARRAY_SIZE (header) - 1);
+ const uint32_t bytes_to_write = (uint32_t)(STRING_LENGTH (header));
uint32_t bytes_written = 0;
success = ep_stream_writer_write (file->stream_writer, (const uint8_t *)header, bytes_to_write, &bytes_written) && bytes_written == bytes_to_write;
}
diff --git a/src/native/eventpipe/ep-json-file.c b/src/native/eventpipe/ep-json-file.c
index 35d33b3026d..5340895424b 100644
--- a/src/native/eventpipe/ep-json-file.c
+++ b/src/native/eventpipe/ep-json-file.c
@@ -111,8 +111,8 @@ ep_json_file_write_event_data (
ep_char8_t buffer [MAX_BUFFER_SIZE];
int32_t characters_written = -1;
- characters_written = ep_rt_utf8_string_snprintf (buffer, EP_ARRAY_SIZE (buffer), "{\"Time\" : \"%f\", \"Metric\" : \"1\",\n\"Stack\": [\n\"", millis_since_trace_start);
- if (characters_written > 0 && characters_written < (int32_t)EP_ARRAY_SIZE (buffer))
+ characters_written = ep_rt_utf8_string_snprintf (buffer, ARRAY_SIZE (buffer), "{\"Time\" : \"%f\", \"Metric\" : \"1\",\n\"Stack\": [\n\"", millis_since_trace_start);
+ if (characters_written > 0 && characters_written < (int32_t)ARRAY_SIZE (buffer))
json_file_write_string (json_file, buffer);
if (message)
@@ -126,23 +126,23 @@ ep_json_file_write_event_data (
for (uint32_t i = 0; i < ep_stack_contents_get_length (stack_contents); ++i) {
ep_rt_method_desc_t *method = ep_stack_contents_get_method (stack_contents, i);
- if (!ep_rt_method_get_simple_assembly_name (method, assembly_name, EP_ARRAY_SIZE (assembly_name))) {
+ if (!ep_rt_method_get_simple_assembly_name (method, assembly_name, ARRAY_SIZE (assembly_name))) {
assembly_name [0] = '?';
assembly_name [1] = 0;
}
- if (!ep_rt_method_get_full_name (method, method_name, EP_ARRAY_SIZE (method_name))) {
+ if (!ep_rt_method_get_full_name (method, method_name, ARRAY_SIZE (method_name))) {
method_name [0] = '?';
method_name [1] = 0;
}
- characters_written = ep_rt_utf8_string_snprintf (buffer, EP_ARRAY_SIZE (buffer), "\"%s!%s\",\n", assembly_name, method_name);
- if (characters_written > 0 && characters_written < (int32_t)EP_ARRAY_SIZE (buffer))
+ characters_written = ep_rt_utf8_string_snprintf (buffer, ARRAY_SIZE (buffer), "\"%s!%s\",\n", assembly_name, method_name);
+ if (characters_written > 0 && characters_written < (int32_t)ARRAY_SIZE (buffer))
json_file_write_string (json_file, buffer);
}
- characters_written = ep_rt_utf8_string_snprintf (buffer, EP_ARRAY_SIZE (buffer), "\"Thread (%" PRIu64 ")\"]},", ep_rt_thread_id_t_to_uint64_t (thread_id));
- if (characters_written > 0 && characters_written < (int32_t)EP_ARRAY_SIZE (buffer))
+ characters_written = ep_rt_utf8_string_snprintf (buffer, ARRAY_SIZE (buffer), "\"Thread (%" PRIu64 ")\"]},", ep_rt_thread_id_t_to_uint64_t (thread_id));
+ if (characters_written > 0 && characters_written < (int32_t)ARRAY_SIZE (buffer))
json_file_write_string (json_file, buffer);
}
diff --git a/src/native/eventpipe/ep-rt.h b/src/native/eventpipe/ep-rt.h
index d043710f46c..4fc22632c6c 100644
--- a/src/native/eventpipe/ep-rt.h
+++ b/src/native/eventpipe/ep-rt.h
@@ -3,10 +3,11 @@
#include "ep-rt-config.h"
+#include <minipal/utils.h>
+
#ifdef ENABLE_PERFTRACING
#include "ep-types.h"
-#define EP_ARRAY_SIZE(expr) ep_rt_redefine
#define EP_INFINITE_WAIT ep_rt_redefine
#define EP_GCX_PREEMP_ENTER ep_rt_redefine
diff --git a/src/native/eventpipe/ep-session.c b/src/native/eventpipe/ep-session.c
index dc3a259cae2..4f572f98b49 100644
--- a/src/native/eventpipe/ep-session.c
+++ b/src/native/eventpipe/ep-session.c
@@ -276,7 +276,7 @@ ep_session_enable_rundown (EventPipeSession *session)
const EventPipeEventLevel verbose_logging_level = EP_EVENT_LEVEL_VERBOSE;
EventPipeProviderConfiguration rundown_providers [2];
- uint32_t rundown_providers_len = (uint32_t)EP_ARRAY_SIZE (rundown_providers);
+ uint32_t rundown_providers_len = (uint32_t)ARRAY_SIZE (rundown_providers);
ep_provider_config_init (&rundown_providers [0], ep_config_get_public_provider_name_utf8 (), keywords, verbose_logging_level, NULL); // Public provider.
ep_provider_config_init (&rundown_providers [1], ep_config_get_rundown_provider_name_utf8 (), keywords, verbose_logging_level, NULL); // Rundown provider.
diff --git a/src/native/eventpipe/ep-stream.c b/src/native/eventpipe/ep-stream.c
index f650dd61427..fafe72b06db 100644
--- a/src/native/eventpipe/ep-stream.c
+++ b/src/native/eventpipe/ep-stream.c
@@ -167,7 +167,7 @@ ep_fast_serializer_alloc (StreamWriter *stream_writer)
EP_ASSERT (stream_writer != NULL);
const ep_char8_t signature[] = "!FastSerialization.1"; // the consumer lib expects exactly the same string, it must not be changed
- uint32_t signature_len = (uint32_t)(EP_ARRAY_SIZE (signature) - 1);
+ uint32_t signature_len = (uint32_t)(STRING_LENGTH (signature));
FastSerializer *instance = ep_rt_object_alloc (FastSerializer);
ep_raise_error_if_nok (instance != NULL);
diff --git a/src/native/eventpipe/ep.c b/src/native/eventpipe/ep.c
index ae8f3ce24f6..bdac36b3eff 100644
--- a/src/native/eventpipe/ep.c
+++ b/src/native/eventpipe/ep.c
@@ -868,7 +868,7 @@ enable_default_session_via_env_variables (void)
ep_config_output_path = ep_rt_config_value_get_output_path ();
ep_char8_t pidStr[24];
- ep_rt_utf8_string_snprintf(pidStr, EP_ARRAY_SIZE (pidStr), "%u", (unsigned)ep_rt_current_process_get_id());
+ ep_rt_utf8_string_snprintf(pidStr, ARRAY_SIZE (pidStr), "%u", (unsigned)ep_rt_current_process_get_id());
while (true)
{
@@ -1115,7 +1115,7 @@ ep_disable (EventPipeSessionID id)
// single threaded. HOWEVER, if the runtime was suspended during startup,
// then ep_finish_init might not have executed yet. Disabling a session
// needs to either happen before we resume or after initialization. We briefly take the
- // lock to check _ep_can_start_threads to check whether we've finished initialization. We
+ // lock to check _ep_can_start_threads to check whether we've finished initialization. We
// also check whether we are still suspended in which case we can safely disable the session
// without deferral.
EP_LOCK_ENTER (section1)