Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"type": "prerelease",
"comment": "Fix Support For SysTraceSection",
"packageName": "react-native-windows",
"email": "ngerlem@microsoft.com",
"commit": "6745910fa922e880c314c9581419a6a2cc3f2e2a",
"dependentChangeType": "patch",
"date": "2020-03-07T14:25:07.210Z"
}
2 changes: 1 addition & 1 deletion vnext/PropertySheets/React.Cpp.props
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
<ItemDefinitionGroup>
<ClCompile>
<PreprocessorDefinitions Condition="'$(ENABLE_ETW_TRACING)'=='true'">ENABLE_ETW_TRACING;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'$(ENABLE_JS_SYSTRACE_TO_ETW)'=='true' AND '$PATCH_RN'=='true'">ENABLE_JS_SYSTRACE_TO_ETW;WITH_FBSYSTRACE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'$(ENABLE_JS_SYSTRACE_TO_ETW)'=='true'">ENABLE_JS_SYSTRACE_TO_ETW;WITH_FBSYSTRACE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
</ItemDefinitionGroup>

Expand Down
47 changes: 20 additions & 27 deletions vnext/ReactWindowsCore/tracing/fbsystrace.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

#pragma once

#include <stdint.h>
Expand All @@ -6,6 +9,7 @@
#include <chrono>
#include <mutex>
#include <string>
#include <type_traits>
#include <unordered_map>

#define TRACE_TAG_REACT_CXX_BRIDGE 1 << 10
Expand Down Expand Up @@ -51,44 +55,33 @@ class FbSystraceSection {
.count());
}

void init(std::string &&v) {
args_[index_++] = std::move(v);
begin_section();
template <typename... RestArg>
FbSystraceSection(uint64_t tag, std::string &&profileName, RestArg &&... rest)
: tag_(tag), profile_name_(std::move(profileName)) {
id_ = s_id_counter++;
init(std::forward<RestArg>(rest)...);
}

void init(const std::string &v) {
args_[index_++] = v; // copy
begin_section();
~FbSystraceSection() {
end_section();
}

private:
void init() {
begin_section();
}

template <typename... ConvertsToStringPiece>
void init(std::string &&v, ConvertsToStringPiece &&... rest) {
args_[index_++] = std::move(v);
init(std::forward<ConvertsToStringPiece>(rest)...);
}

template <typename... ConvertsToStringPiece>
void init(const std::string &v, ConvertsToStringPiece &&... rest) {
args_[index_++] = v; // copy
init(std::forward<ConvertsToStringPiece>(rest)...);
}

template <typename... ConvertsToStringPiece>
FbSystraceSection(uint64_t tag, std::string &&v, ConvertsToStringPiece &&... rest)
: tag_(tag), profile_name_(std::move(v)) {
id_ = s_id_counter++;
init(std::forward<ConvertsToStringPiece>(rest)...);
}
template <typename Arg, typename... RestArg>
void init(Arg &&arg, RestArg &&... rest) {
if constexpr (std::is_convertible_v<Arg, std::string>) {
args_[index_++] = std::forward<Arg>(arg);
} else {
args_[index_++] = std::to_string(std::forward<Arg>(arg));
}

~FbSystraceSection() {
end_section();
init(std::forward<RestArg>(rest)...);
}

private:
std::array<std::string, SYSTRACE_SECTION_MAX_ARGS> args_;
uint64_t tag_{0};

Expand Down