Skip to content

Commit 189e566

Browse files
joyeecheungMylesBorins
authored andcommitted
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. Backport-PR-URL: #18550 PR-URL: #18653 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 35cddae commit 189e566

6 files changed

+7
-54
lines changed

src/base_object.h

+1
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ class BaseObject {
7070
// offsets and generate debug symbols for BaseObject, which assumes that the
7171
// position of members in memory are predictable. For more information please
7272
// refer to `doc/guides/node-postmortem-support.md`
73+
friend int GenDebugSymbols();
7374
v8::Persistent<v8::Object> persistent_handle_;
7475
Environment* env_;
7576
};

src/env.h

+1
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,7 @@ class Environment {
750750
// symbols for Environment, which assumes that the position of members in
751751
// memory are predictable. For more information please refer to
752752
// `doc/guides/node-postmortem-support.md`
753+
friend int GenDebugSymbols();
753754
HandleWrapQueue handle_wrap_queue_;
754755
ReqWrapQueue req_wrap_queue_;
755756
ListHead<HandleCleanup,

src/handle_wrap.h

+2
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,13 @@ class HandleWrap : public AsyncWrap {
8181
friend class Environment;
8282
friend void GetActiveHandles(const v8::FunctionCallbackInfo<v8::Value>&);
8383
static void OnClose(uv_handle_t* handle);
84+
8485
// handle_wrap_queue_ needs to be at a fixed offset from the start of the
8586
// class because it is used by src/node_postmortem_metadata.cc to calculate
8687
// offsets and generate debug symbols for HandleWrap, which assumes that the
8788
// position of members in memory are predictable. For more information please
8889
// refer to `doc/guides/node-postmortem-support.md`
90+
friend int GenDebugSymbols();
8991
ListNode<HandleWrap> handle_wrap_queue_;
9092
enum { kInitialized, kClosing, kClosingWithCallback, kClosed } state_;
9193
uv_handle_t* const handle_;

src/node_postmortem_metadata.cc

-54
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,3 @@
1-
// Need to import standard headers before redefining private, otherwise it
2-
// won't compile.
3-
#include <algorithm>
4-
#include <array>
5-
#include <atomic>
6-
#include <bitset>
7-
#include <cctype>
8-
#include <climits>
9-
#include <cmath>
10-
#include <cstdarg>
11-
#include <cstddef>
12-
#include <cstdint>
13-
#include <cstdio>
14-
#include <cstdlib>
15-
#include <cstring>
16-
#include <ctime>
17-
#include <deque>
18-
#include <exception>
19-
#include <forward_list>
20-
#include <fstream>
21-
#include <functional>
22-
#include <iomanip>
23-
#include <iosfwd>
24-
#include <iostream>
25-
#include <istream>
26-
#include <iterator>
27-
#include <limits>
28-
#include <list>
29-
#include <map>
30-
#include <memory>
31-
#include <new>
32-
#include <ostream>
33-
#include <queue>
34-
#include <set>
35-
#include <sstream>
36-
#include <stack>
37-
#include <streambuf>
38-
#include <string>
39-
#include <tuple>
40-
#include <type_traits>
41-
#include <typeinfo>
42-
#include <unordered_map>
43-
#include <unordered_set>
44-
#include <utility>
45-
#include <vector>
46-
47-
namespace node {
48-
// Forward declaration needed before redefining private.
49-
int GenDebugSymbols();
50-
} // namespace node
51-
52-
53-
#define private friend int GenDebugSymbols(); private
54-
551
#include "env.h"
562
#include "base_object-inl.h"
573
#include "handle_wrap.h"

src/req_wrap.h

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ class ReqWrap : public AsyncWrap {
2222

2323
private:
2424
friend class Environment;
25+
friend int GenDebugSymbols();
2526
ListNode<ReqWrap> req_wrap_queue_;
2627

2728
protected:

src/util.h

+2
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ class ListNode {
159159

160160
private:
161161
template <typename U, ListNode<U> (U::*M)> friend class ListHead;
162+
friend int GenDebugSymbols();
162163
ListNode* prev_;
163164
ListNode* next_;
164165
DISALLOW_COPY_AND_ASSIGN(ListNode);
@@ -189,6 +190,7 @@ class ListHead {
189190
inline Iterator end() const;
190191

191192
private:
193+
friend int GenDebugSymbols();
192194
ListNode<T> head_;
193195
DISALLOW_COPY_AND_ASSIGN(ListHead);
194196
};

0 commit comments

Comments
 (0)