diff options
author | Anna Henningsen <anna@addaleax.net> | 2018-05-27 16:37:30 +0200 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2018-05-31 09:54:48 +0200 |
commit | bd85844c4e80c7aa1fc02a986c7619c3956b0061 (patch) | |
tree | d476c4d0b3469dfee41913b9a76ff39ab1deabfe /src/env.h | |
parent | eadcee11372d8228bcb203a9ab97a5f7d61d4809 (diff) | |
download | android-node-v8-bd85844c4e80c7aa1fc02a986c7619c3956b0061.tar.gz android-node-v8-bd85844c4e80c7aa1fc02a986c7619c3956b0061.tar.bz2 android-node-v8-bd85844c4e80c7aa1fc02a986c7619c3956b0061.zip |
src: implement debug output utilities
Implement utilities for easier debugging of Node.js core code,
inspired by the HTTP/2 debugging code. Debugging is, however,
implemented at runtime rather than at compile time, controlled
through a new `NODE_DEBUG_NATIVE=categories` environment variable.
The runtime overhead in the debugging-disabled case amounts to
1 well-cachable one-byte read per debug call.
PR-URL: https://github.com/nodejs/node/pull/20987
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Minwoo Jung <minwoo@nodesource.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'src/env.h')
-rw-r--r-- | src/env.h | 19 |
1 files changed, 19 insertions, 0 deletions
@@ -398,6 +398,19 @@ struct ContextInfo { bool is_default = false; }; +// Listing the AsyncWrap provider types first enables us to cast directly +// from a provider type to a debug category. Currently no other debug +// categories are available. +#define DEBUG_CATEGORY_NAMES(V) \ + NODE_ASYNC_PROVIDER_TYPES(V) + +enum class DebugCategory { +#define V(name) name, + DEBUG_CATEGORY_NAMES(V) +#undef V + CATEGORY_COUNT +}; + class Environment { public: class AsyncHooks { @@ -654,6 +667,10 @@ class Environment { inline http2::Http2State* http2_state() const; inline void set_http2_state(std::unique_ptr<http2::Http2State> state); + inline bool debug_enabled(DebugCategory category) const; + inline void set_debug_enabled(DebugCategory category, bool enabled); + void set_debug_categories(const std::string& cats, bool enabled); + inline AliasedBuffer<double, v8::Float64Array>* fs_stats_field_array(); // stat fields contains twice the number of entries because `fs.StatWatcher` @@ -853,6 +870,8 @@ class Environment { bool http_parser_buffer_in_use_ = false; std::unique_ptr<http2::Http2State> http2_state_; + bool debug_enabled_[static_cast<int>(DebugCategory::CATEGORY_COUNT)] = {0}; + AliasedBuffer<double, v8::Float64Array> fs_stats_field_array_; std::vector<std::unique_ptr<fs::FileHandleReadWrap>> |