From cce09c31411187790824716948f655abf0d9985a Mon Sep 17 00:00:00 2001 From: Joyee Cheung Date: Fri, 9 Feb 2018 03:34:50 +0800 Subject: [PATCH 1/3] src: do not redefine private for GenDebugSymbols Redefining private breaks any private inheritance in the included files. We can simply declare GenDebugSymbols() as friends in related classes to gain the access that we need. --- src/base_object.h | 3 +++ src/env.h | 3 +++ src/handle_wrap.h | 4 ++++ src/node_postmortem_metadata.cc | 8 -------- src/req_wrap.h | 3 +++ src/util.h | 4 ++++ 6 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/base_object.h b/src/base_object.h index 5852f764066fbc..e6977739625092 100644 --- a/src/base_object.h +++ b/src/base_object.h @@ -28,6 +28,8 @@ namespace node { +int GenDebugSymbols(); + class Environment; class BaseObject { @@ -70,6 +72,7 @@ class BaseObject { // offsets and generate debug symbols for BaseObject, which assumes that the // position of members in memory are predictable. For more information please // refer to `doc/guides/node-postmortem-support.md` + friend int GenDebugSymbols(); v8::Persistent persistent_handle_; Environment* env_; }; diff --git a/src/env.h b/src/env.h index b621a54e3780cd..d887543eeb612e 100644 --- a/src/env.h +++ b/src/env.h @@ -48,6 +48,8 @@ struct nghttp2_rcbuf; namespace node { +int GenDebugSymbols(); + namespace performance { class performance_state; } @@ -781,6 +783,7 @@ class Environment { // symbols for Environment, which assumes that the position of members in // memory are predictable. For more information please refer to // `doc/guides/node-postmortem-support.md` + friend int GenDebugSymbols(); HandleWrapQueue handle_wrap_queue_; ReqWrapQueue req_wrap_queue_; ListHead&); static void OnClose(uv_handle_t* handle); + // handle_wrap_queue_ needs to be at a fixed offset from the start of the // class because it is used by src/node_postmortem_metadata.cc to calculate // offsets and generate debug symbols for HandleWrap, which assumes that the // position of members in memory are predictable. For more information please // refer to `doc/guides/node-postmortem-support.md` + friend int GenDebugSymbols(); ListNode handle_wrap_queue_; enum { kInitialized, kClosing, kClosingWithCallback, kClosed } state_; uv_handle_t* const handle_; diff --git a/src/node_postmortem_metadata.cc b/src/node_postmortem_metadata.cc index 4a463958f54509..9039a7b2e380d9 100644 --- a/src/node_postmortem_metadata.cc +++ b/src/node_postmortem_metadata.cc @@ -44,14 +44,6 @@ #include #include -namespace node { -// Forward declaration needed before redefining private. -int GenDebugSymbols(); -} // namespace node - - -#define private friend int GenDebugSymbols(); private - #include "env.h" #include "base_object-inl.h" #include "handle_wrap.h" diff --git a/src/req_wrap.h b/src/req_wrap.h index 05bc558570abf1..2e9fb3e47e9832 100644 --- a/src/req_wrap.h +++ b/src/req_wrap.h @@ -10,6 +10,8 @@ namespace node { +int GenDebugSymbols(); + template class ReqWrap : public AsyncWrap { public: @@ -22,6 +24,7 @@ class ReqWrap : public AsyncWrap { private: friend class Environment; + friend int GenDebugSymbols(); ListNode req_wrap_queue_; protected: diff --git a/src/util.h b/src/util.h index 47bdf27c307109..785e74fc0ded40 100644 --- a/src/util.h +++ b/src/util.h @@ -37,6 +37,8 @@ namespace node { +int GenDebugSymbols(); + // These should be used in our code as opposed to the native // versions as they abstract out some platform and or // compiler version specific functionality @@ -159,6 +161,7 @@ class ListNode { private: template (U::*M)> friend class ListHead; + friend int GenDebugSymbols(); ListNode* prev_; ListNode* next_; DISALLOW_COPY_AND_ASSIGN(ListNode); @@ -189,6 +192,7 @@ class ListHead { inline Iterator end() const; private: + friend int GenDebugSymbols(); ListNode head_; DISALLOW_COPY_AND_ASSIGN(ListHead); }; From b56fc10617ef6cdff9b3079f675ca68c90fbdb0d Mon Sep 17 00:00:00 2001 From: Joyee Cheung Date: Fri, 9 Feb 2018 04:33:11 +0800 Subject: [PATCH 2/3] squash! remove unnecessary std lib includes --- src/node_postmortem_metadata.cc | 46 --------------------------------- 1 file changed, 46 deletions(-) diff --git a/src/node_postmortem_metadata.cc b/src/node_postmortem_metadata.cc index 9039a7b2e380d9..b335e7fbf818c6 100644 --- a/src/node_postmortem_metadata.cc +++ b/src/node_postmortem_metadata.cc @@ -1,49 +1,3 @@ -// Need to import standard headers before redefining private, otherwise it -// won't compile. -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - #include "env.h" #include "base_object-inl.h" #include "handle_wrap.h" From b37013cd5a618185ec5a05154ca60de34baaa366 Mon Sep 17 00:00:00 2001 From: Joyee Cheung Date: Fri, 9 Feb 2018 05:55:37 +0800 Subject: [PATCH 3/3] squash! remove unnecessary forward declaration --- src/base_object.h | 2 -- src/env.h | 2 -- src/handle_wrap.h | 2 -- src/req_wrap.h | 2 -- src/util.h | 2 -- 5 files changed, 10 deletions(-) diff --git a/src/base_object.h b/src/base_object.h index e6977739625092..965683d029e43e 100644 --- a/src/base_object.h +++ b/src/base_object.h @@ -28,8 +28,6 @@ namespace node { -int GenDebugSymbols(); - class Environment; class BaseObject { diff --git a/src/env.h b/src/env.h index d887543eeb612e..b8a93fac4f769c 100644 --- a/src/env.h +++ b/src/env.h @@ -48,8 +48,6 @@ struct nghttp2_rcbuf; namespace node { -int GenDebugSymbols(); - namespace performance { class performance_state; } diff --git a/src/handle_wrap.h b/src/handle_wrap.h index bbf21613d21c2f..19fd36891a2fed 100644 --- a/src/handle_wrap.h +++ b/src/handle_wrap.h @@ -31,8 +31,6 @@ namespace node { -int GenDebugSymbols(); - class Environment; // Rules: diff --git a/src/req_wrap.h b/src/req_wrap.h index 2e9fb3e47e9832..ddd0840aad2ab6 100644 --- a/src/req_wrap.h +++ b/src/req_wrap.h @@ -10,8 +10,6 @@ namespace node { -int GenDebugSymbols(); - template class ReqWrap : public AsyncWrap { public: diff --git a/src/util.h b/src/util.h index 785e74fc0ded40..21c566a4ca6cd6 100644 --- a/src/util.h +++ b/src/util.h @@ -37,8 +37,6 @@ namespace node { -int GenDebugSymbols(); - // These should be used in our code as opposed to the native // versions as they abstract out some platform and or // compiler version specific functionality