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.

PR-URL: https://github.com/nodejs/node/pull/18653
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
Joyee Cheung 2018-02-09 03:34:50 +08:00
parent e9ba0cfd46
commit 18d23aa36e
No known key found for this signature in database
GPG Key ID: F586868AAD831D0C
6 changed files with 7 additions and 54 deletions

View File

@ -70,6 +70,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<v8::Object> persistent_handle_;
Environment* env_;
};

View File

@ -782,6 +782,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<HandleCleanup,

View File

@ -81,11 +81,13 @@ class HandleWrap : public AsyncWrap {
friend class Environment;
friend void GetActiveHandles(const v8::FunctionCallbackInfo<v8::Value>&);
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<HandleWrap> handle_wrap_queue_;
enum { kInitialized, kClosing, kClosingWithCallback, kClosed } state_;
uv_handle_t* const handle_;

View File

@ -1,57 +1,3 @@
// Need to import standard headers before redefining private, otherwise it
// won't compile.
#include <algorithm>
#include <array>
#include <atomic>
#include <bitset>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdarg>
#include <cstddef>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <exception>
#include <forward_list>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <new>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <streambuf>
#include <string>
#include <tuple>
#include <type_traits>
#include <typeinfo>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
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"

View File

@ -22,6 +22,7 @@ class ReqWrap : public AsyncWrap {
private:
friend class Environment;
friend int GenDebugSymbols();
ListNode<ReqWrap> req_wrap_queue_;
protected:

View File

@ -159,6 +159,7 @@ class ListNode {
private:
template <typename U, ListNode<U> (U::*M)> friend class ListHead;
friend int GenDebugSymbols();
ListNode* prev_;
ListNode* next_;
DISALLOW_COPY_AND_ASSIGN(ListNode);
@ -189,6 +190,7 @@ class ListHead {
inline Iterator end() const;
private:
friend int GenDebugSymbols();
ListNode<T> head_;
DISALLOW_COPY_AND_ASSIGN(ListHead);
};