| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 70563b5 commit 91ef427
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -27,15 +27,9 @@ constexpr int NODE_REPORT_VERSION = 2; | |||
| 27 | 27 | constexpr int NANOS_PER_SEC = 1000 * 1000 * 1000; | |
| 28 | 28 | constexpr double SEC_PER_MICROS = 1e-6; | |
| 29 | 29 | ||
| 30 | + namespace node { | ||
| 30 | 31 | namespace report { | |
| 31 | - using node::arraysize; | ||
| 32 | - using node::ConditionVariable; | ||
| 33 | - using node::DiagnosticFilename; | ||
| 34 | - using node::Environment; | ||
| 35 | - using node::JSONWriter; | ||
| 36 | - using node::Mutex; | ||
| 37 | - using node::NativeSymbolDebuggingContext; | ||
| 38 | - using node::TIME_TYPE; | ||
| 32 | + | ||
| 39 | 33 | using node::worker::Worker; | |
| 40 | 34 | using v8::Array; | |
| 41 | 35 | using v8::Context; | |
@@ -54,8 +48,6 @@ using v8::TryCatch; | |||
| 54 | 48 | using v8::V8; | |
| 55 | 49 | using v8::Value; | |
| 56 | 50 | ||
| 57 | - namespace per_process = node::per_process; | ||
| 58 | - | ||
| 59 | 51 | // Internal/static function declarations | |
| 60 | 52 | static void WriteNodeReport(Isolate* isolate, | |
| 61 | 53 | Environment* env, | |
@@ -129,7 +121,7 @@ std::string TriggerNodeReport(Isolate* isolate, | |||
| 129 | 121 | // Regular file. Append filename to directory path if one was specified | |
| 130 | 122 | if (report_directory.length() > 0) { | |
| 131 | 123 | std::string pathname = report_directory; | |
| 132 | - pathname += node::kPathSeparator; | ||
| 124 | + pathname += kPathSeparator; | ||
| 133 | 125 | pathname += filename; | |
| 134 | 126 | outfile.open(pathname, std::ios::out | std::ios::binary); | |
| 135 | 127 | } else { | |
@@ -260,9 +252,9 @@ static void WriteNodeReport(Isolate* isolate, | |||
| 260 | 252 | } | |
| 261 | 253 | ||
| 262 | 254 | // Report out the command line. | |
| 263 | - if (!node::per_process::cli_options->cmdline.empty()) { | ||
| 255 | + if (!per_process::cli_options->cmdline.empty()) { | ||
| 264 | 256 | writer.json_arraystart("commandLine"); | |
| 265 | - for (const std::string& arg : node::per_process::cli_options->cmdline) { | ||
| 257 | + for (const std::string& arg : per_process::cli_options->cmdline) { | ||
| 266 | 258 | writer.json_element(arg); | |
| 267 | 259 | } | |
| 268 | 260 | writer.json_arrayend(); | |
@@ -377,8 +369,8 @@ static void PrintVersionInformation(JSONWriter* writer) { | |||
| 377 | 369 | ||
| 378 | 370 | // Report Process word size | |
| 379 | 371 | writer->json_keyvalue("wordSize", sizeof(void*) * 8); | |
| 380 | - writer->json_keyvalue("arch", node::per_process::metadata.arch); | ||
| 381 | - writer->json_keyvalue("platform", node::per_process::metadata.platform); | ||
| 372 | + writer->json_keyvalue("arch", per_process::metadata.arch); | ||
| 373 | + writer->json_keyvalue("platform", per_process::metadata.platform); | ||
| 382 | 374 | ||
| 383 | 375 | // Report deps component versions | |
| 384 | 376 | PrintComponentVersions(writer); | |
@@ -528,7 +520,7 @@ static Maybe<std::string> ErrorToString(Isolate* isolate, | |||
| 528 | 520 | maybe_str = error->ToString(context); | |
| 529 | 521 | } else if (error->IsObject()) { | |
| 530 | 522 | MaybeLocal<Value> stack = error.As<Object>()->Get( | |
| 531 | - context, node::FIXED_ONE_BYTE_STRING(isolate, "stack")); | ||
| 523 | + context, FIXED_ONE_BYTE_STRING(isolate, "stack")); | ||
| 532 | 524 | if (!stack.IsEmpty() && stack.ToLocalChecked()->IsString()) { | |
| 533 | 525 | maybe_str = stack.ToLocalChecked().As<String>(); | |
| 534 | 526 | } | |
@@ -656,7 +648,7 @@ static void PrintGCStatistics(JSONWriter* writer, Isolate* isolate) { | |||
| 656 | 648 | static void PrintResourceUsage(JSONWriter* writer) { | |
| 657 | 649 | // Get process uptime in seconds | |
| 658 | 650 | uint64_t uptime = | |
| 659 | - (uv_hrtime() - node::per_process::node_start_time) / (NANOS_PER_SEC); | ||
| 651 | + (uv_hrtime() - per_process::node_start_time) / (NANOS_PER_SEC); | ||
| 660 | 652 | if (uptime == 0) uptime = 1; // avoid division by zero. | |
| 661 | 653 | ||
| 662 | 654 | // Process and current thread usage statistics | |
@@ -714,7 +706,7 @@ static void PrintSystemInformation(JSONWriter* writer) { | |||
| 714 | 706 | writer->json_objectstart("environmentVariables"); | |
| 715 | 707 | ||
| 716 | 708 | { | |
| 717 | - Mutex::ScopedLock lock(node::per_process::env_var_mutex); | ||
| 709 | + Mutex::ScopedLock lock(per_process::env_var_mutex); | ||
| 718 | 710 | r = uv_os_environ(&envitems, &envcount); | |
| 719 | 711 | } | |
| 720 | 712 | ||
@@ -794,8 +786,7 @@ static void PrintComponentVersions(JSONWriter* writer) { | |||
| 794 | 786 | ||
| 795 | 787 | writer->json_objectstart("componentVersions"); | |
| 796 | 788 | ||
| 797 | - #define V(key) \ | ||
| 798 | - writer->json_keyvalue(#key, node::per_process::metadata.versions.key); | ||
| 789 | + #define V(key) writer->json_keyvalue(#key, per_process::metadata.versions.key); | ||
| 799 | 790 | NODE_VERSIONS_KEYS(V) | |
| 800 | 791 | #undef V | |
| 801 | 792 | ||
@@ -805,22 +796,22 @@ static void PrintComponentVersions(JSONWriter* writer) { | |||
| 805 | 796 | // Report runtime release information. | |
| 806 | 797 | static void PrintRelease(JSONWriter* writer) { | |
| 807 | 798 | writer->json_objectstart("release"); | |
| 808 | - writer->json_keyvalue("name", node::per_process::metadata.release.name); | ||
| 799 | + writer->json_keyvalue("name", per_process::metadata.release.name); | ||
| 809 | 800 | #if NODE_VERSION_IS_LTS | |
| 810 | - writer->json_keyvalue("lts", node::per_process::metadata.release.lts); | ||
| 801 | + writer->json_keyvalue("lts", per_process::metadata.release.lts); | ||
| 811 | 802 | #endif | |
| 812 | 803 | ||
| 813 | 804 | #ifdef NODE_HAS_RELEASE_URLS | |
| 814 | 805 | writer->json_keyvalue("headersUrl", | |
| 815 | - node::per_process::metadata.release.headers_url); | ||
| 816 | - writer->json_keyvalue("sourceUrl", | ||
| 817 | - node::per_process::metadata.release.source_url); | ||
| 806 | + per_process::metadata.release.headers_url); | ||
| 807 | + writer->json_keyvalue("sourceUrl", per_process::metadata.release.source_url); | ||
| 818 | 808 | #ifdef _WIN32 | |
| 819 | - writer->json_keyvalue("libUrl", node::per_process::metadata.release.lib_url); | ||
| 809 | + writer->json_keyvalue("libUrl", per_process::metadata.release.lib_url); | ||
| 820 | 810 | #endif // _WIN32 | |
| 821 | 811 | #endif // NODE_HAS_RELEASE_URLS | |
| 822 | 812 | ||
| 823 | 813 | writer->json_objectend(); | |
| 824 | 814 | } | |
| 825 | 815 | ||
| 826 | 816 | } // namespace report | |
| 817 | + } // namespace node | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,4 +1,7 @@ | |||
| 1 | - #pragma once | ||
| 1 | + #ifndef SRC_NODE_REPORT_H_ | ||
| 2 | + #define SRC_NODE_REPORT_H_ | ||
| 3 | + | ||
| 4 | + #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS | ||
| 2 | 5 | ||
| 3 | 6 | #include "node.h" | |
| 4 | 7 | #include "node_buffer.h" | |
@@ -12,17 +15,18 @@ | |||
| 12 | 15 | ||
| 13 | 16 | #include <iomanip> | |
| 14 | 17 | ||
| 18 | + namespace node { | ||
| 15 | 19 | namespace report { | |
| 16 | 20 | ||
| 17 | 21 | // Function declarations - functions in src/node_report.cc | |
| 18 | 22 | std::string TriggerNodeReport(v8::Isolate* isolate, | |
| 19 | - node::Environment* env, | ||
| 23 | + Environment* env, | ||
| 20 | 24 | const char* message, | |
| 21 | 25 | const char* trigger, | |
| 22 | 26 | const std::string& name, | |
| 23 | 27 | v8::Local<v8::Value> error); | |
| 24 | 28 | void GetNodeReport(v8::Isolate* isolate, | |
| 25 | - node::Environment* env, | ||
| 29 | + Environment* env, | ||
| 26 | 30 | const char* message, | |
| 27 | 31 | const char* trigger, | |
| 28 | 32 | v8::Local<v8::Value> error, | |
@@ -45,3 +49,8 @@ void WriteReport(const v8::FunctionCallbackInfo<v8::Value>& info); | |||
| 45 | 49 | void GetReport(const v8::FunctionCallbackInfo<v8::Value>& info); | |
| 46 | 50 | ||
| 47 | 51 | } // namespace report | |
| 52 | + } // namespace node | ||
| 53 | + | ||
| 54 | + #endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS | ||
| 55 | + | ||
| 56 | + #endif // SRC_NODE_REPORT_H_ | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -15,6 +15,7 @@ | |||
| 15 | 15 | #include <atomic> | |
| 16 | 16 | #include <sstream> | |
| 17 | 17 | ||
| 18 | + namespace node { | ||
| 18 | 19 | namespace report { | |
| 19 | 20 | using node::Environment; | |
| 20 | 21 | using node::Mutex; | |
@@ -76,48 +77,48 @@ void GetReport(const FunctionCallbackInfo<Value>& info) { | |||
| 76 | 77 | } | |
| 77 | 78 | ||
| 78 | 79 | static void GetCompact(const FunctionCallbackInfo<Value>& info) { | |
| 79 | - node::Mutex::ScopedLock lock(node::per_process::cli_options_mutex); | ||
| 80 | - info.GetReturnValue().Set(node::per_process::cli_options->report_compact); | ||
| 80 | + Mutex::ScopedLock lock(per_process::cli_options_mutex); | ||
| 81 | + info.GetReturnValue().Set(per_process::cli_options->report_compact); | ||
| 81 | 82 | } | |
| 82 | 83 | ||
| 83 | 84 | static void SetCompact(const FunctionCallbackInfo<Value>& info) { | |
| 84 | - node::Mutex::ScopedLock lock(node::per_process::cli_options_mutex); | ||
| 85 | + Mutex::ScopedLock lock(per_process::cli_options_mutex); | ||
| 85 | 86 | Environment* env = Environment::GetCurrent(info); | |
| 86 | 87 | Isolate* isolate = env->isolate(); | |
| 87 | 88 | bool compact = info[0]->ToBoolean(isolate)->Value(); | |
| 88 | - node::per_process::cli_options->report_compact = compact; | ||
| 89 | + per_process::cli_options->report_compact = compact; | ||
| 89 | 90 | } | |
| 90 | 91 | ||
| 91 | 92 | static void GetDirectory(const FunctionCallbackInfo<Value>& info) { | |
| 92 | - node::Mutex::ScopedLock lock(node::per_process::cli_options_mutex); | ||
| 93 | + Mutex::ScopedLock lock(per_process::cli_options_mutex); | ||
| 93 | 94 | Environment* env = Environment::GetCurrent(info); | |
| 94 | - std::string directory = node::per_process::cli_options->report_directory; | ||
| 95 | + std::string directory = per_process::cli_options->report_directory; | ||
| 95 | 96 | auto result = String::NewFromUtf8(env->isolate(), directory.c_str()); | |
| 96 | 97 | info.GetReturnValue().Set(result.ToLocalChecked()); | |
| 97 | 98 | } | |
| 98 | 99 | ||
| 99 | 100 | static void SetDirectory(const FunctionCallbackInfo<Value>& info) { | |
| 100 | - node::Mutex::ScopedLock lock(node::per_process::cli_options_mutex); | ||
| 101 | + Mutex::ScopedLock lock(per_process::cli_options_mutex); | ||
| 101 | 102 | Environment* env = Environment::GetCurrent(info); | |
| 102 | 103 | CHECK(info[0]->IsString()); | |
| 103 | 104 | Utf8Value dir(env->isolate(), info[0].As<String>()); | |
| 104 | - node::per_process::cli_options->report_directory = *dir; | ||
| 105 | + per_process::cli_options->report_directory = *dir; | ||
| 105 | 106 | } | |
| 106 | 107 | ||
| 107 | 108 | static void GetFilename(const FunctionCallbackInfo<Value>& info) { | |
| 108 | - node::Mutex::ScopedLock lock(node::per_process::cli_options_mutex); | ||
| 109 | + Mutex::ScopedLock lock(per_process::cli_options_mutex); | ||
| 109 | 110 | Environment* env = Environment::GetCurrent(info); | |
| 110 | - std::string filename = node::per_process::cli_options->report_filename; | ||
| 111 | + std::string filename = per_process::cli_options->report_filename; | ||
| 111 | 112 | auto result = String::NewFromUtf8(env->isolate(), filename.c_str()); | |
| 112 | 113 | info.GetReturnValue().Set(result.ToLocalChecked()); | |
| 113 | 114 | } | |
| 114 | 115 | ||
| 115 | 116 | static void SetFilename(const FunctionCallbackInfo<Value>& info) { | |
| 116 | - node::Mutex::ScopedLock lock(node::per_process::cli_options_mutex); | ||
| 117 | + Mutex::ScopedLock lock(per_process::cli_options_mutex); | ||
| 117 | 118 | Environment* env = Environment::GetCurrent(info); | |
| 118 | 119 | CHECK(info[0]->IsString()); | |
| 119 | 120 | Utf8Value name(env->isolate(), info[0].As<String>()); | |
| 120 | - node::per_process::cli_options->report_filename = *name; | ||
| 121 | + per_process::cli_options->report_filename = *name; | ||
| 121 | 122 | } | |
| 122 | 123 | ||
| 123 | 124 | static void GetSignal(const FunctionCallbackInfo<Value>& info) { | |
@@ -135,15 +136,14 @@ static void SetSignal(const FunctionCallbackInfo<Value>& info) { | |||
| 135 | 136 | } | |
| 136 | 137 | ||
| 137 | 138 | static void ShouldReportOnFatalError(const FunctionCallbackInfo<Value>& info) { | |
| 138 | - Mutex::ScopedLock lock(node::per_process::cli_options_mutex); | ||
| 139 | - info.GetReturnValue().Set( | ||
| 140 | - node::per_process::cli_options->report_on_fatalerror); | ||
| 139 | + Mutex::ScopedLock lock(per_process::cli_options_mutex); | ||
| 140 | + info.GetReturnValue().Set(per_process::cli_options->report_on_fatalerror); | ||
| 141 | 141 | } | |
| 142 | 142 | ||
| 143 | 143 | static void SetReportOnFatalError(const FunctionCallbackInfo<Value>& info) { | |
| 144 | 144 | CHECK(info[0]->IsBoolean()); | |
| 145 | - Mutex::ScopedLock lock(node::per_process::cli_options_mutex); | ||
| 146 | - node::per_process::cli_options->report_on_fatalerror = info[0]->IsTrue(); | ||
| 145 | + Mutex::ScopedLock lock(per_process::cli_options_mutex); | ||
| 146 | + per_process::cli_options->report_on_fatalerror = info[0]->IsTrue(); | ||
| 147 | 147 | } | |
| 148 | 148 | ||
| 149 | 149 | static void ShouldReportOnSignal(const FunctionCallbackInfo<Value>& info) { | |
@@ -197,7 +197,7 @@ static void Initialize(Local<Object> exports, | |||
| 197 | 197 | SetReportOnUncaughtException); | |
| 198 | 198 | } | |
| 199 | 199 | ||
| 200 | - void RegisterExternalReferences(node::ExternalReferenceRegistry* registry) { | ||
| 200 | + void RegisterExternalReferences(ExternalReferenceRegistry* registry) { | ||
| 201 | 201 | registry->Register(WriteReport); | |
| 202 | 202 | registry->Register(GetReport); | |
| 203 | 203 | registry->Register(GetCompact); | |
@@ -217,6 +217,7 @@ void RegisterExternalReferences(node::ExternalReferenceRegistry* registry) { | |||
| 217 | 217 | } | |
| 218 | 218 | ||
| 219 | 219 | } // namespace report | |
| 220 | + } // namespace node | ||
| 220 | 221 | ||
| 221 | - NODE_MODULE_CONTEXT_AWARE_INTERNAL(report, report::Initialize) | ||
| 222 | - NODE_MODULE_EXTERNAL_REFERENCE(report, report::RegisterExternalReferences) | ||
| 222 | + NODE_MODULE_CONTEXT_AWARE_INTERNAL(report, node::report::Initialize) | ||
| 223 | + NODE_MODULE_EXTERNAL_REFERENCE(report, node::report::RegisterExternalReferences) | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,11 +3,9 @@ | |||
| 3 | 3 | #include "node_report.h" | |
| 4 | 4 | #include "util-inl.h" | |
| 5 | 5 | ||
| 6 | + namespace node { | ||
| 6 | 7 | namespace report { | |
| 7 | 8 | ||
| 8 | - using node::JSONWriter; | ||
| 9 | - using node::MallocedBuffer; | ||
| 10 | - | ||
| 11 | 9 | static constexpr auto null = JSONWriter::Null{}; | |
| 12 | 10 | ||
| 13 | 11 | // Utility function to format socket information. | |
@@ -210,8 +208,7 @@ void WalkHandle(uv_handle_t* h, void* arg) { | |||
| 210 | 208 | // SIGWINCH is used by libuv so always appears. | |
| 211 | 209 | // See http://docs.libuv.org/en/v1.x/signal.html | |
| 212 | 210 | writer->json_keyvalue("signum", handle->signal.signum); | |
| 213 | - writer->json_keyvalue("signal", | ||
| 214 | - node::signo_string(handle->signal.signum)); | ||
| 211 | + writer->json_keyvalue("signal", signo_string(handle->signal.signum)); | ||
| 215 | 212 | break; | |
| 216 | 213 | default: | |
| 217 | 214 | break; | |
@@ -276,3 +273,4 @@ void WalkHandle(uv_handle_t* h, void* arg) { | |||
| 276 | 273 | } | |
| 277 | 274 | ||
| 278 | 275 | } // namespace report | |
| 276 | + } // namespace node | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments