diff options
author | James M Snell <jasnell@gmail.com> | 2019-03-07 16:51:36 +0000 |
---|---|---|
committer | James M Snell <jasnell@gmail.com> | 2019-03-13 15:50:32 +0000 |
commit | 5f38797ea51886708fbde22527fc54e64382925c (patch) | |
tree | 23d3fe878077b09d7cfe502c48fd9e2a03f35800 /src/node_internals.h | |
parent | 024842f8f4f139a4af310976e7f78dff51f12654 (diff) | |
download | android-node-v8-5f38797ea51886708fbde22527fc54e64382925c.tar.gz android-node-v8-5f38797ea51886708fbde22527fc54e64382925c.tar.bz2 android-node-v8-5f38797ea51886708fbde22527fc54e64382925c.zip |
v8: integrate node-heapdump into core
Adds `v8.writeHeapSnapshot(filename)` with impl adapted
from the `node-heapdump` module.
Also, adds a v8.getHeapSnapshot() alternative that returns
a Readable Stream
PR-URL: https://github.com/nodejs/node/pull/26501
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Diffstat (limited to 'src/node_internals.h')
-rw-r--r-- | src/node_internals.h | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/node_internals.h b/src/node_internals.h index 355e4ae9fd..d2eadf5109 100644 --- a/src/node_internals.h +++ b/src/node_internals.h @@ -299,6 +299,41 @@ v8::MaybeLocal<v8::Value> StartExecution(Environment* env, namespace profiler { void StartCoverageCollection(Environment* env); } + +#ifdef _WIN32 +typedef SYSTEMTIME TIME_TYPE; +#else // UNIX, OSX +typedef struct tm TIME_TYPE; +#endif + +class DiagnosticFilename { + public: + static void LocalTime(TIME_TYPE* tm_struct); + + DiagnosticFilename(Environment* env, + const char* prefix, + const char* ext, + int seq = -1) : + filename_(MakeFilename(env->thread_id(), prefix, ext, seq)) {} + + DiagnosticFilename(uint64_t thread_id, + const char* prefix, + const char* ext, + int seq = -1) : + filename_(MakeFilename(thread_id, prefix, ext, seq)) {} + + const char* operator*() const { return filename_.c_str(); } + + private: + static std::string MakeFilename( + uint64_t thread_id, + const char* prefix, + const char* ext, + int seq = -1); + + std::string filename_; +}; + } // namespace node #endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS |