Commit 6a7f5512 authored by Stephen Nusko's avatar Stephen Nusko Committed by Commit Bot

Reland "Add fake typed TRACE_EVENT macros for IOS and NACL builds."

This reverts commit efbba2c9.

Reason for revert: We've fixed the release iOS build in http://aosp/1209091

Original change's description:
> Revert "Add fake typed TRACE_EVENT macros for IOS and NACL builds."
> 
> This reverts commit 60dfcf2f.
> 
> Reason for revert:
> 
> FAILED: 
> ../../third_party/perfetto/src/protozero/message_unittest.cc:298:40: error: expected '(' for function-style cast or type construction
>         MessageHandle<FakeRootMessage> handle(msg);
>         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
> ../../third_party/perfetto/src/base/test/utils.h:34:30: note: expanded from macro 'EXPECT_DCHECK_DEATH'
>     GTEST_EXECUTE_STATEMENT_(statement, "PERFETTO_CHECK")
>                              ^~~~~~~~~
> 1 error generated.
> 
> https://logs.chromium.org/logs/chromium/buildbucket/cr-buildbucket.appspot.com/8891267197314487504/+/steps/compile/0/stdout
> 
> Original change's description:
> > Add fake typed TRACE_EVENT macros for IOS and NACL builds.
> > 
> > This allows users to not care if tracing is supported on their system.
> > 
> > Bug: 916074
> > Change-Id: I69aa8178bb19f1a65186a2aba4f08699b6ba6ee3
> > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1953210
> > Reviewed-by: Stephen Nusko <nuskos@chromium.org>
> > Reviewed-by: Eric Seckler <eseckler@chromium.org>
> > Commit-Queue: Stephen Nusko <nuskos@chromium.org>
> > Auto-Submit: Stephen Nusko <nuskos@chromium.org>
> > Cr-Commit-Position: refs/heads/master@{#731514}
> 
> TBR=eseckler@chromium.org,nuskos@chromium.org
> 
> Change-Id: Ia0cc5d2a330a408898c6248378726e43ddd8a732
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: 916074
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2000964
> Reviewed-by: Dan Beam <dbeam@chromium.org>
> Commit-Queue: Dan Beam <dbeam@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#731531}

TBR=dbeam@chromium.org,eseckler@chromium.org,nuskos@chromium.org

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: 916074
Change-Id: Ide0558b46058869eb252f1ff7be8b10c99dac13c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2003678Reviewed-by: default avatarStephen Nusko <nuskos@chromium.org>
Reviewed-by: default avatarEric Seckler <eseckler@chromium.org>
Commit-Queue: Stephen Nusko <nuskos@chromium.org>
Auto-Submit: Stephen Nusko <nuskos@chromium.org>
Cr-Commit-Position: refs/heads/master@{#733606}
parent b06677fe
......@@ -17,14 +17,42 @@ source_set("traced_process") {
public_deps = [ "//services/tracing/public/mojom" ]
if (!is_nacl && !is_ios) {
deps = [ ":cpp" ]
}
deps = [ ":cpp" ]
}
# On IOS and NACL we don't support tracing so we only include the minimum needed
# to support a fake typed TRACE_EVENT macro. However this means we don't have
# any .cc files and thus on iOS and NaCl it needs to be a source_set and not a
# component. |tracing_lib_type| decides which version to build.
if (!is_nacl && !is_ios) {
component("cpp") {
sources = [
tracing_lib_type = "component"
} else {
tracing_lib_type = "source_set"
}
target(tracing_lib_type, "cpp") {
sources = [
"perfetto/event_context.h",
"perfetto/macros.h",
"perfetto/macros_internal.h",
]
defines = [ "IS_TRACING_CPP_IMPL" ]
output_name = "tracing_cpp"
configs += [ "//build/config/compiler:wexit_time_destructors" ]
public_deps = [
"//base",
"//third_party/perfetto:libperfetto",
]
deps = [ "//third_party/perfetto/include/perfetto/protozero" ]
all_dependent_configs = [ "//third_party/perfetto/gn:public_config" ]
if (!is_nacl && !is_ios) {
sources += [
"base_agent.cc",
"base_agent.h",
"perfetto/dummy_producer.cc",
......@@ -40,9 +68,7 @@ if (!is_nacl && !is_ios) {
"perfetto/java_heap_profiler/hprof_parser_android.h",
"perfetto/java_heap_profiler/java_heap_profiler_android.cc",
"perfetto/java_heap_profiler/java_heap_profiler_android.h",
"perfetto/macros.h",
"perfetto/macros_internal.cc",
"perfetto/macros_internal.h",
"perfetto/perfetto_config.cc",
"perfetto/perfetto_config.h",
"perfetto/perfetto_producer.cc",
......@@ -79,24 +105,14 @@ if (!is_nacl && !is_ios) {
"tracing_features.h",
]
defines = [ "IS_TRACING_CPP_IMPL" ]
output_name = "tracing_cpp"
configs += [ "//build/config/compiler:wexit_time_destructors" ]
public_deps = [
"//base",
public_deps += [
"//components/tracing:startup_tracing",
"//mojo/public/cpp/bindings",
"//services/tracing/public/mojom",
"//third_party/perfetto:libperfetto",
]
all_dependent_configs = [ "//third_party/perfetto/gn:public_config" ]
deps = [
deps += [
"//build:chromecast_buildflags",
"//third_party/perfetto/include/perfetto/protozero",
"//third_party/perfetto/protos/perfetto/trace/chrome:minimal_complete_lite",
]
......@@ -122,5 +138,5 @@ if (!is_nacl && !is_ios) {
# stack_unwinder_android.cc overrides the dl_unwind_find_exidx function.
all_dependent_configs += [ ":wrap_find_exidx" ]
}
}
} # !is_nacl && !is_ios
} # !is_ios && !is_nacl
}
......@@ -8,6 +8,11 @@
#include "base/trace_event/trace_event.h"
#include "services/tracing/public/cpp/perfetto/macros_internal.h"
// Needed not for this file but for every user of the TRACE_EVENT macros for the
// lambda definition. So included here for convenience.
#include "services/tracing/public/cpp/perfetto/event_context.h"
#include "third_party/perfetto/protos/perfetto/trace/track_event/track_event.pbzero.h"
#if defined(TRACE_EVENT_BEGIN)
#error "Another copy of perfetto tracing macros have been included"
#endif
......
......@@ -5,14 +5,18 @@
#ifndef SERVICES_TRACING_PUBLIC_CPP_PERFETTO_MACROS_INTERNAL_H_
#define SERVICES_TRACING_PUBLIC_CPP_PERFETTO_MACROS_INTERNAL_H_
#include "base/component_export.h"
#include "base/trace_event/trace_event.h"
#include "services/tracing/public/cpp/perfetto/trace_event_data_source.h"
#include "build/build_config.h"
namespace perfetto {
class TrackEventContext;
class EventContext;
}
#if !defined(OS_IOS) && !defined(OS_NACL)
#include "base/component_export.h"
#include "base/trace_event/trace_event.h"
#include "services/tracing/public/cpp/perfetto/trace_event_data_source.h"
namespace tracing {
namespace internal {
base::Optional<base::trace_event::TraceEvent> COMPONENT_EXPORT(TRACING_CPP)
......@@ -24,7 +28,7 @@ base::Optional<base::trace_event::TraceEvent> COMPONENT_EXPORT(TRACING_CPP)
// A simple function that will add the TraceEvent requested and will call the
// |argument_func| after the track_event has been filled in.
template <
typename TrackEventArgumentFunction = void (*)(perfetto::TrackEventContext)>
typename TrackEventArgumentFunction = void (*)(perfetto::EventContext)>
static inline base::trace_event::TraceEventHandle AddTraceEvent(
char phase,
const unsigned char* category_group_enabled,
......@@ -87,4 +91,33 @@ static inline base::trace_event::TraceEventHandle AddTraceEvent(
return 0; \
}()};
#else // !defined(OS_IOS) && !defined(OS_NACL)
// Tracing isn't supported on IOS or NACL so we just black hole all the
// parameters into a function that doesn't do anything. This ensures that no
// warnings about unused parameters are generated.
namespace tracing {
namespace internal {
template <
typename TrackEventArgumentFunction = void (*)(perfetto::EventContext)>
static inline base::trace_event::TraceEventHandle AddTraceEvent(
char,
const unsigned char*,
const char*,
unsigned int,
TrackEventArgumentFunction) {
return {0, 0, 0};
}
} // namespace internal
} // namespace tracing
#define TRACING_INTERNAL_ADD_TRACE_EVENT(phase, category, name, flags, ...) \
tracing::internal::AddTraceEvent(phase, nullptr, name, flags, ##__VA_ARGS__);
#define TRACING_INTERNAL_SCOPED_ADD_TRACE_EVENT(category, name, ...) \
TRACING_INTERNAL_ADD_TRACE_EVENT('B', category, name, TRACE_EVENT_FLAG_NONE, \
##__VA_ARGS__);
#endif // else of !defined(OS_IOS) && !defined(OS_NACL)
#endif // SERVICES_TRACING_PUBLIC_CPP_PERFETTO_MACROS_INTERNAL_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment