diff --git a/zircon/docs/ddk/tracing.md b/zircon/docs/ddk/tracing.md index a4808b3ecc30e8606a6babd7b39844960474a52a..c3ae45d91c89958d75e9da76117b0f1cf33c8409 100644 --- a/zircon/docs/ddk/tracing.md +++ b/zircon/docs/ddk/tracing.md @@ -62,35 +62,21 @@ unrelated data from a different trace provider. The event name is included in the trace to describe what the event is about. It is typically unique for each event. -Note that currently the default is that no code will be generated -by the addition of these `TRACE_*()` macros. Akin to <assert.h>'s use of -`#define NDEBUG` to disable `assert()`s, tracing uses `#define NTRACE` to -disable tracing. `NTRACE` is currently defined by default unless -`ENABLE_DRIVER_TRACING=true` is passed to `make`. See below. - ### Makefile additions The following addition to your driver's `rules.mk` file is needed to pick up tracing support: ```make -ifeq ($(call TOBOOL,$(ENABLE_DRIVER_TRACING)),true) MODULE_STATIC_LIBS += system/ulib/trace.driver -endif MODULE_HEADER_DEPS += system/ulib/trace system/ulib/trace-engine ``` ## Booting with tracing -To be super conservative, not only does tracing currently require a special -compile flag to enable it: `ENABLE_DRIVER_TRACING=true`, -it also requires an extra kernel command line flag to enable it: -`driver.tracing.enable=1` - -`ENABLE_DRIVER_TRACING=true` is now the default. To disable compiling in -driver tracing support, pass `ENABLE_DRIVER_TRACING=false` to make. - -`driver.tracing.enable=1` is also now the default. To disable partipation +To be conservative, tracing uses a kernel command line flag to enable it: +`driver.tracing.enable=1`. +`driver.tracing.enable=1` is the default. To disable partipation of drivers in Fuchsia tracing, boot the kernel with `driver.tracing.enable=0`. Example: diff --git a/zircon/make/engine.mk b/zircon/make/engine.mk index cdcc727d097f229a34d36ad5e53d3362e592483b..7cfb40582f30212606ee9e9a5e90f9221f3dff13 100644 --- a/zircon/make/engine.mk +++ b/zircon/make/engine.mk @@ -29,8 +29,6 @@ ENABLE_LOCK_DEP ?= false ENABLE_LOCK_DEP_TESTS ?= $(ENABLE_LOCK_DEP) DISABLE_UTEST ?= false ENABLE_ULIB_ONLY ?= false -ENABLE_DRIVER_TRACING ?= true -ENABLE_DRIVER_TRACING := $(call TOBOOL,$(ENABLE_DRIVER_TRACING)) USE_ASAN ?= false USE_SANCOV ?= false USE_PROFILE ?= false @@ -218,11 +216,6 @@ USER_CFLAGS := USER_CPPFLAGS := USER_ASMFLAGS := -# Allow driver tracing to be completely disabled (as if it didn't exist). -ifeq ($(call TOBOOL,$(ENABLE_DRIVER_TRACING)),true) -USER_COMPILEFLAGS += -DENABLE_DRIVER_TRACING=1 -endif - # Additional flags for dynamic linking, both for dynamically-linked # executables and for shared libraries. USER_LDFLAGS := \ diff --git a/zircon/system/core/devmgr/devhost/devhost.cpp b/zircon/system/core/devmgr/devhost/devhost.cpp index 0bc58560ece3577a714bbe4392e5d3f595c5bf11..fe94cb76356ff245d093c777114743b1aca2d308 100644 --- a/zircon/system/core/devmgr/devhost/devhost.cpp +++ b/zircon/system/core/devmgr/devhost/devhost.cpp @@ -42,9 +42,7 @@ #include "../shared/async-loop-owned-rpc-handler.h" #include "main.h" -#if ENABLE_DRIVER_TRACING #include "tracing.h" -#endif #include "../shared/env.h" #include "../shared/fidl_txn.h" #include "../shared/log.h" @@ -1209,17 +1207,14 @@ __EXPORT int device_host_main(int argc, char** argv) { zx_status_t r; -#if ENABLE_DRIVER_TRACING - { - if (getenv_bool("driver.tracing.enable", true)) { - r = devhost_start_trace_provider(); - if (r != ZX_OK) { - log(INFO, "devhost: error registering as trace provider: %d\n", r); - // This is not a fatal error. - } + if (getenv_bool("driver.tracing.enable", true)) { + r = devhost_start_trace_provider(); + if (r != ZX_OK) { + log(INFO, "devhost: error registering as trace provider: %d\n", r); + // This is not a fatal error. } } -#endif + if ((r = SetupRootDevcoordinatorConnection(std::move(root_conn_channel))) != ZX_OK) { log(ERROR, "devhost: could not watch rpc channel: %d\n", r); return -1; diff --git a/zircon/system/dev/block/sdmmc/rules.mk b/zircon/system/dev/block/sdmmc/rules.mk index eac40c68f9cf2318d06e251b3e69578919ca6a42..cd9ea3442e5424c918c573711ca74ace0a718515 100644 --- a/zircon/system/dev/block/sdmmc/rules.mk +++ b/zircon/system/dev/block/sdmmc/rules.mk @@ -32,9 +32,8 @@ MODULE_BANJO_LIBS := \ system/banjo/ddk-protocol-sdio \ system/banjo/ddk-protocol-sdmmc \ -ifeq ($(call TOBOOL,$(ENABLE_DRIVER_TRACING)),true) +# Driver tracing additions. MODULE_STATIC_LIBS += system/ulib/trace.driver -endif MODULE_HEADER_DEPS += system/ulib/trace system/ulib/trace-engine include make/module.mk diff --git a/zircon/system/dev/display/display/rules.mk b/zircon/system/dev/display/display/rules.mk index 8b327f3dc56b50798a129731c04fc560f6a54e96..e5aace4f2839c5f7d989a6ed2ce4b5a353113221 100644 --- a/zircon/system/dev/display/display/rules.mk +++ b/zircon/system/dev/display/display/rules.mk @@ -44,9 +44,8 @@ MODULE_BANJO_LIBS := \ system/banjo/ddk-protocol-display-controller \ system/banjo/ddk-protocol-i2cimpl \ -ifeq ($(call TOBOOL,$(ENABLE_DRIVER_TRACING)),true) +# Driver tracing additions. MODULE_STATIC_LIBS += system/ulib/trace.driver -endif MODULE_HEADER_DEPS += system/ulib/trace system/ulib/trace-engine include make/module.mk diff --git a/zircon/system/dev/input/hid/rules.mk b/zircon/system/dev/input/hid/rules.mk index cd7423eb04acfcdaf985713c383c122147aa2425..510c0a8b3a0da5488eb29b8c429940d2c251d0b8 100644 --- a/zircon/system/dev/input/hid/rules.mk +++ b/zircon/system/dev/input/hid/rules.mk @@ -30,9 +30,8 @@ MODULE_LIBS := \ MODULE_BANJO_LIBS := \ system/banjo/ddk-protocol-hidbus \ -ifeq ($(call TOBOOL,$(ENABLE_DRIVER_TRACING)),true) +# Driver tracing additions. MODULE_STATIC_LIBS += system/ulib/trace.driver -endif MODULE_HEADER_DEPS += system/ulib/trace system/ulib/trace-engine include make/module.mk diff --git a/zircon/system/dev/input/i2c-hid/rules.mk b/zircon/system/dev/input/i2c-hid/rules.mk index 78e26173a05039f345bec55e4a3780a3ee12022b..f49a1d37487d17da28b0f0858bde8c5befd2c30a 100644 --- a/zircon/system/dev/input/i2c-hid/rules.mk +++ b/zircon/system/dev/input/i2c-hid/rules.mk @@ -18,9 +18,8 @@ MODULE_BANJO_LIBS := \ system/banjo/ddk-protocol-hidbus \ system/banjo/ddk-protocol-i2c \ -ifeq ($(call TOBOOL,$(ENABLE_DRIVER_TRACING)),true) +# Driver tracing additions. MODULE_STATIC_LIBS += system/ulib/trace.driver -endif MODULE_HEADER_DEPS += system/ulib/trace system/ulib/trace-engine include make/module.mk diff --git a/zircon/system/ulib/ddk/include/ddk/trace/event.h b/zircon/system/ulib/ddk/include/ddk/trace/event.h index af557cf32352e881d1c722eefc851f0b1b3f2e22..6d4bc15e902aede59baa2c6f34fe4d723230f206 100644 --- a/zircon/system/ulib/ddk/include/ddk/trace/event.h +++ b/zircon/system/ulib/ddk/include/ddk/trace/event.h @@ -23,13 +23,6 @@ #ifndef DDK_TRACE_EVENT_H_ #define DDK_TRACE_EVENT_H_ -// While driver tracing support is under development, -// one must pass ENABLE_DRIVER_TRACING=true to make. -#if !ENABLE_DRIVER_TRACING -#undef NTRACE -#define NTRACE -#endif - // For now userspace and DDK tracing share the same API and implementation. #include <trace/internal/event_common.h> diff --git a/zircon/system/ulib/driver/rules.mk b/zircon/system/ulib/driver/rules.mk index 4a05fdc31fa93ff6b18176c9a44d0a630c6fa7f8..76184f6710faee344408a87cbeb161df3722f40c 100644 --- a/zircon/system/ulib/driver/rules.mk +++ b/zircon/system/ulib/driver/rules.mk @@ -26,12 +26,10 @@ MODULE_SRCS := \ $(LOCAL_DEVHOST_SRCS)/zx-device.cpp \ $(LOCAL_DEVMGR_ROOT)/shared/env.cpp \ -ifeq ($(call TOBOOL,$(ENABLE_DRIVER_TRACING)),true) MODULE_SRCS += \ $(LOCAL_DEVHOST_SRCS)/tracing.cpp MODULE_HEADER_DEPS := \ system/ulib/trace-provider -endif MODULE_FIDL_LIBS := \ system/fidl/fuchsia-device \ @@ -61,8 +59,6 @@ MODULE_STATIC_LIBS := \ MODULE_STATIC_LIBS += \ system/ulib/trace-engine.driver -ifeq ($(call TOBOOL,$(ENABLE_DRIVER_TRACING)),true) - MODULE_FIDL_LIBS += \ system/fidl/fuchsia-tracelink \ @@ -74,14 +70,6 @@ MODULE_STATIC_LIBS += \ # references to ensure everything is present. MODULE_EXTRA_OBJS := system/ulib/trace-engine/ddk-exports.ld -else - -# Some symbols still need to be present even if tracing is disabled. -# See the linker script for details. -MODULE_EXTRA_OBJS := system/ulib/trace-engine/ddk-disabled-exports.ld - -endif - MODULE_LIBS := system/ulib/fdio system/ulib/zircon system/ulib/c include make/module.mk diff --git a/zircon/system/ulib/trace-engine/ddk-disabled-exports.ld b/zircon/system/ulib/trace-engine/ddk-disabled-exports.ld deleted file mode 100644 index 8e5b6b6297d51800d109dcc11727ad5f45a97eb2..0000000000000000000000000000000000000000 --- a/zircon/system/ulib/trace-engine/ddk-disabled-exports.ld +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright 2018 The Fuchsia Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* - * This is an input linker script used in linking libdriver.so. - * The linker is pulling in our symbols from an archive, thus they won't get - * pulled in unless they are referenced. - * This file injects synthetic references to keep the symbols alive. - * - * N.B. This file is used when tracing is disabled in the DDK because these - * symbols can be used by tracing clients even when tracing is disabled with - * #define NTRACE. - */ - -EXTERN(trace_generate_nonce) diff --git a/zircon/system/ulib/trace-engine/rules.mk b/zircon/system/ulib/trace-engine/rules.mk index 455461ad6b9be6f2a8a5524db77977a3948452be..418f45982f69a6ebc4d0f33e084bb1a43ff3b8a7 100644 --- a/zircon/system/ulib/trace-engine/rules.mk +++ b/zircon/system/ulib/trace-engine/rules.mk @@ -82,25 +82,18 @@ MODULE_TYPE := userlib MODULE_COMPILEFLAGS += -fvisibility=hidden MODULE_COMPILEFLAGS += -DDDK_TRACING -# trace_generate_nonce() exists even when driver tracing is disabled MODULE_SRCS := \ - $(LOCAL_DIR)/nonce.cpp - -MODULE_STATIC_LIBS := \ - system/ulib/fbl - -ifeq ($(call TOBOOL,$(ENABLE_DRIVER_TRACING)),true) -MODULE_SRCS += \ $(LOCAL_DIR)/context.cpp \ $(LOCAL_DIR)/context_api.cpp \ - $(LOCAL_DIR)/engine.cpp + $(LOCAL_DIR)/engine.cpp \ + $(LOCAL_DIR)/nonce.cpp -MODULE_STATIC_LIBS += \ +MODULE_STATIC_LIBS := \ system/ulib/async.cpp \ system/ulib/async \ + system/ulib/fbl \ system/ulib/zx \ system/ulib/zxcpp -endif MODULE_LIBS := $(LOCAL_LIBS)