Skip to content

Commit

Permalink
src: do not redefine private for GenDebugSymbols
Browse files Browse the repository at this point in the history
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: #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>
  • Loading branch information
joyeecheung authored and MylesBorins committed May 22, 2018
1 parent 3b8e2d0 commit 5ac4bac
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 54 deletions.
1 change: 1 addition & 0 deletions src/base-object.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_;
};
Expand Down
1 change: 1 addition & 0 deletions src/env.h
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,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,
Expand Down
2 changes: 2 additions & 0 deletions src/handle_wrap.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_;
Expand Down
54 changes: 0 additions & 54 deletions src/node_postmortem_metadata.cc
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
1 change: 1 addition & 0 deletions src/req-wrap.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class ReqWrap : public AsyncWrap {

private:
friend class Environment;
friend int GenDebugSymbols();
ListNode<ReqWrap> req_wrap_queue_;

protected:
Expand Down
2 changes: 2 additions & 0 deletions src/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -190,6 +191,7 @@ class ListHead {
inline Iterator end() const;

private:
friend int GenDebugSymbols();
ListNode<T> head_;
DISALLOW_COPY_AND_ASSIGN(ListHead);
};
Expand Down

0 comments on commit 5ac4bac

Please sign in to comment.