node-oom-heapdump 2.1.0-progress.0 → 3.0.0-beta

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/Makefile DELETED
@@ -1,324 +0,0 @@
1
- # We borrow heavily from the kernel build setup, though we are simpler since
2
- # we don't have Kconfig tweaking settings on us.
3
-
4
- # The implicit make rules have it looking for RCS files, among other things.
5
- # We instead explicitly write all the rules we care about.
6
- # It's even quicker (saves ~200ms) to pass -r on the command line.
7
- MAKEFLAGS=-r
8
-
9
- # The source directory tree.
10
- srcdir := ..
11
- abs_srcdir := $(abspath $(srcdir))
12
-
13
- # The name of the builddir.
14
- builddir_name ?= .
15
-
16
- # The V=1 flag on command line makes us verbosely print command lines.
17
- ifdef V
18
- quiet=
19
- else
20
- quiet=quiet_
21
- endif
22
-
23
- # Specify BUILDTYPE=Release on the command line for a release build.
24
- BUILDTYPE ?= Release
25
-
26
- # Directory all our build output goes into.
27
- # Note that this must be two directories beneath src/ for unit tests to pass,
28
- # as they reach into the src/ directory for data with relative paths.
29
- builddir ?= $(builddir_name)/$(BUILDTYPE)
30
- abs_builddir := $(abspath $(builddir))
31
- depsdir := $(builddir)/.deps
32
-
33
- # Object output directory.
34
- obj := $(builddir)/obj
35
- abs_obj := $(abspath $(obj))
36
-
37
- # We build up a list of every single one of the targets so we can slurp in the
38
- # generated dependency rule Makefiles in one pass.
39
- all_deps :=
40
-
41
-
42
-
43
- CC.target ?= $(CC)
44
- CFLAGS.target ?= $(CPPFLAGS) $(CFLAGS)
45
- CXX.target ?= $(CXX)
46
- CXXFLAGS.target ?= $(CPPFLAGS) $(CXXFLAGS)
47
- LINK.target ?= $(LINK)
48
- LDFLAGS.target ?= $(LDFLAGS)
49
- AR.target ?= $(AR)
50
-
51
- # C++ apps need to be linked with g++.
52
- LINK ?= $(CXX.target)
53
-
54
- # TODO(evan): move all cross-compilation logic to gyp-time so we don't need
55
- # to replicate this environment fallback in make as well.
56
- CC.host ?= gcc
57
- CFLAGS.host ?= $(CPPFLAGS_host) $(CFLAGS_host)
58
- CXX.host ?= g++
59
- CXXFLAGS.host ?= $(CPPFLAGS_host) $(CXXFLAGS_host)
60
- LINK.host ?= $(CXX.host)
61
- LDFLAGS.host ?=
62
- AR.host ?= ar
63
-
64
- # Define a dir function that can handle spaces.
65
- # http://www.gnu.org/software/make/manual/make.html#Syntax-of-Functions
66
- # "leading spaces cannot appear in the text of the first argument as written.
67
- # These characters can be put into the argument value by variable substitution."
68
- empty :=
69
- space := $(empty) $(empty)
70
-
71
- # http://stackoverflow.com/questions/1189781/using-make-dir-or-notdir-on-a-path-with-spaces
72
- replace_spaces = $(subst $(space),?,$1)
73
- unreplace_spaces = $(subst ?,$(space),$1)
74
- dirx = $(call unreplace_spaces,$(dir $(call replace_spaces,$1)))
75
-
76
- # Flags to make gcc output dependency info. Note that you need to be
77
- # careful here to use the flags that ccache and distcc can understand.
78
- # We write to a dep file on the side first and then rename at the end
79
- # so we can't end up with a broken dep file.
80
- depfile = $(depsdir)/$(call replace_spaces,$@).d
81
- DEPFLAGS = -MMD -MF $(depfile).raw
82
-
83
- # We have to fixup the deps output in a few ways.
84
- # (1) the file output should mention the proper .o file.
85
- # ccache or distcc lose the path to the target, so we convert a rule of
86
- # the form:
87
- # foobar.o: DEP1 DEP2
88
- # into
89
- # path/to/foobar.o: DEP1 DEP2
90
- # (2) we want missing files not to cause us to fail to build.
91
- # We want to rewrite
92
- # foobar.o: DEP1 DEP2 \
93
- # DEP3
94
- # to
95
- # DEP1:
96
- # DEP2:
97
- # DEP3:
98
- # so if the files are missing, they're just considered phony rules.
99
- # We have to do some pretty insane escaping to get those backslashes
100
- # and dollar signs past make, the shell, and sed at the same time.
101
- # Doesn't work with spaces, but that's fine: .d files have spaces in
102
- # their names replaced with other characters.
103
- define fixup_dep
104
- # The depfile may not exist if the input file didn't have any #includes.
105
- touch $(depfile).raw
106
- # Fixup path as in (1).
107
- sed -e "s|^$(notdir $@)|$@|" $(depfile).raw >> $(depfile)
108
- # Add extra rules as in (2).
109
- # We remove slashes and replace spaces with new lines;
110
- # remove blank lines;
111
- # delete the first line and append a colon to the remaining lines.
112
- sed -e 's|\\||' -e 'y| |\n|' $(depfile).raw |\
113
- grep -v '^$$' |\
114
- sed -e 1d -e 's|$$|:|' \
115
- >> $(depfile)
116
- rm $(depfile).raw
117
- endef
118
-
119
- # Command definitions:
120
- # - cmd_foo is the actual command to run;
121
- # - quiet_cmd_foo is the brief-output summary of the command.
122
-
123
- quiet_cmd_cc = CC($(TOOLSET)) $@
124
- cmd_cc = $(CC.$(TOOLSET)) $(GYP_CFLAGS) $(DEPFLAGS) $(CFLAGS.$(TOOLSET)) -c -o $@ $<
125
-
126
- quiet_cmd_cxx = CXX($(TOOLSET)) $@
127
- cmd_cxx = $(CXX.$(TOOLSET)) $(GYP_CXXFLAGS) $(DEPFLAGS) $(CXXFLAGS.$(TOOLSET)) -c -o $@ $<
128
-
129
- quiet_cmd_touch = TOUCH $@
130
- cmd_touch = touch $@
131
-
132
- quiet_cmd_copy = COPY $@
133
- # send stderr to /dev/null to ignore messages when linking directories.
134
- cmd_copy = rm -rf "$@" && cp -af "$<" "$@"
135
-
136
- quiet_cmd_alink = AR($(TOOLSET)) $@
137
- cmd_alink = rm -f $@ && $(AR.$(TOOLSET)) crs $@ $(filter %.o,$^)
138
-
139
- quiet_cmd_alink_thin = AR($(TOOLSET)) $@
140
- cmd_alink_thin = rm -f $@ && $(AR.$(TOOLSET)) crsT $@ $(filter %.o,$^)
141
-
142
- # Due to circular dependencies between libraries :(, we wrap the
143
- # special "figure out circular dependencies" flags around the entire
144
- # input list during linking.
145
- quiet_cmd_link = LINK($(TOOLSET)) $@
146
- cmd_link = $(LINK.$(TOOLSET)) $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ -Wl,--start-group $(LD_INPUTS) $(LIBS) -Wl,--end-group
147
-
148
- # We support two kinds of shared objects (.so):
149
- # 1) shared_library, which is just bundling together many dependent libraries
150
- # into a link line.
151
- # 2) loadable_module, which is generating a module intended for dlopen().
152
- #
153
- # They differ only slightly:
154
- # In the former case, we want to package all dependent code into the .so.
155
- # In the latter case, we want to package just the API exposed by the
156
- # outermost module.
157
- # This means shared_library uses --whole-archive, while loadable_module doesn't.
158
- # (Note that --whole-archive is incompatible with the --start-group used in
159
- # normal linking.)
160
-
161
- # Other shared-object link notes:
162
- # - Set SONAME to the library filename so our binaries don't reference
163
- # the local, absolute paths used on the link command-line.
164
- quiet_cmd_solink = SOLINK($(TOOLSET)) $@
165
- cmd_solink = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -Wl,-soname=$(@F) -o $@ -Wl,--whole-archive $(LD_INPUTS) -Wl,--no-whole-archive $(LIBS)
166
-
167
- quiet_cmd_solink_module = SOLINK_MODULE($(TOOLSET)) $@
168
- cmd_solink_module = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -Wl,-soname=$(@F) -o $@ -Wl,--start-group $(filter-out FORCE_DO_CMD, $^) -Wl,--end-group $(LIBS)
169
-
170
-
171
- # Define an escape_quotes function to escape single quotes.
172
- # This allows us to handle quotes properly as long as we always use
173
- # use single quotes and escape_quotes.
174
- escape_quotes = $(subst ','\'',$(1))
175
- # This comment is here just to include a ' to unconfuse syntax highlighting.
176
- # Define an escape_vars function to escape '$' variable syntax.
177
- # This allows us to read/write command lines with shell variables (e.g.
178
- # $LD_LIBRARY_PATH), without triggering make substitution.
179
- escape_vars = $(subst $$,$$$$,$(1))
180
- # Helper that expands to a shell command to echo a string exactly as it is in
181
- # make. This uses printf instead of echo because printf's behaviour with respect
182
- # to escape sequences is more portable than echo's across different shells
183
- # (e.g., dash, bash).
184
- exact_echo = printf '%s\n' '$(call escape_quotes,$(1))'
185
-
186
- # Helper to compare the command we're about to run against the command
187
- # we logged the last time we ran the command. Produces an empty
188
- # string (false) when the commands match.
189
- # Tricky point: Make has no string-equality test function.
190
- # The kernel uses the following, but it seems like it would have false
191
- # positives, where one string reordered its arguments.
192
- # arg_check = $(strip $(filter-out $(cmd_$(1)), $(cmd_$@)) \
193
- # $(filter-out $(cmd_$@), $(cmd_$(1))))
194
- # We instead substitute each for the empty string into the other, and
195
- # say they're equal if both substitutions produce the empty string.
196
- # .d files contain ? instead of spaces, take that into account.
197
- command_changed = $(or $(subst $(cmd_$(1)),,$(cmd_$(call replace_spaces,$@))),\
198
- $(subst $(cmd_$(call replace_spaces,$@)),,$(cmd_$(1))))
199
-
200
- # Helper that is non-empty when a prerequisite changes.
201
- # Normally make does this implicitly, but we force rules to always run
202
- # so we can check their command lines.
203
- # $? -- new prerequisites
204
- # $| -- order-only dependencies
205
- prereq_changed = $(filter-out FORCE_DO_CMD,$(filter-out $|,$?))
206
-
207
- # Helper that executes all postbuilds until one fails.
208
- define do_postbuilds
209
- @E=0;\
210
- for p in $(POSTBUILDS); do\
211
- eval $$p;\
212
- E=$$?;\
213
- if [ $$E -ne 0 ]; then\
214
- break;\
215
- fi;\
216
- done;\
217
- if [ $$E -ne 0 ]; then\
218
- rm -rf "$@";\
219
- exit $$E;\
220
- fi
221
- endef
222
-
223
- # do_cmd: run a command via the above cmd_foo names, if necessary.
224
- # Should always run for a given target to handle command-line changes.
225
- # Second argument, if non-zero, makes it do asm/C/C++ dependency munging.
226
- # Third argument, if non-zero, makes it do POSTBUILDS processing.
227
- # Note: We intentionally do NOT call dirx for depfile, since it contains ? for
228
- # spaces already and dirx strips the ? characters.
229
- define do_cmd
230
- $(if $(or $(command_changed),$(prereq_changed)),
231
- @$(call exact_echo, $($(quiet)cmd_$(1)))
232
- @mkdir -p "$(call dirx,$@)" "$(dir $(depfile))"
233
- $(if $(findstring flock,$(word 1,$(cmd_$1))),
234
- @$(cmd_$(1))
235
- @echo " $(quiet_cmd_$(1)): Finished",
236
- @$(cmd_$(1))
237
- )
238
- @$(call exact_echo,$(call escape_vars,cmd_$(call replace_spaces,$@) := $(cmd_$(1)))) > $(depfile)
239
- @$(if $(2),$(fixup_dep))
240
- $(if $(and $(3), $(POSTBUILDS)),
241
- $(call do_postbuilds)
242
- )
243
- )
244
- endef
245
-
246
- # Declare the "all" target first so it is the default,
247
- # even though we don't have the deps yet.
248
- .PHONY: all
249
- all:
250
-
251
- # make looks for ways to re-generate included makefiles, but in our case, we
252
- # don't have a direct way. Explicitly telling make that it has nothing to do
253
- # for them makes it go faster.
254
- %.d: ;
255
-
256
- # Use FORCE_DO_CMD to force a target to run. Should be coupled with
257
- # do_cmd.
258
- .PHONY: FORCE_DO_CMD
259
- FORCE_DO_CMD:
260
-
261
- TOOLSET := target
262
- # Suffix rules, putting all outputs into $(obj).
263
- $(obj).$(TOOLSET)/%.o: $(srcdir)/%.c FORCE_DO_CMD
264
- @$(call do_cmd,cc,1)
265
- $(obj).$(TOOLSET)/%.o: $(srcdir)/%.cc FORCE_DO_CMD
266
- @$(call do_cmd,cxx,1)
267
- $(obj).$(TOOLSET)/%.o: $(srcdir)/%.cpp FORCE_DO_CMD
268
- @$(call do_cmd,cxx,1)
269
- $(obj).$(TOOLSET)/%.o: $(srcdir)/%.cxx FORCE_DO_CMD
270
- @$(call do_cmd,cxx,1)
271
- $(obj).$(TOOLSET)/%.o: $(srcdir)/%.S FORCE_DO_CMD
272
- @$(call do_cmd,cc,1)
273
- $(obj).$(TOOLSET)/%.o: $(srcdir)/%.s FORCE_DO_CMD
274
- @$(call do_cmd,cc,1)
275
-
276
- # Try building from generated source, too.
277
- $(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.c FORCE_DO_CMD
278
- @$(call do_cmd,cc,1)
279
- $(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.cc FORCE_DO_CMD
280
- @$(call do_cmd,cxx,1)
281
- $(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.cpp FORCE_DO_CMD
282
- @$(call do_cmd,cxx,1)
283
- $(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.cxx FORCE_DO_CMD
284
- @$(call do_cmd,cxx,1)
285
- $(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.S FORCE_DO_CMD
286
- @$(call do_cmd,cc,1)
287
- $(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.s FORCE_DO_CMD
288
- @$(call do_cmd,cc,1)
289
-
290
- $(obj).$(TOOLSET)/%.o: $(obj)/%.c FORCE_DO_CMD
291
- @$(call do_cmd,cc,1)
292
- $(obj).$(TOOLSET)/%.o: $(obj)/%.cc FORCE_DO_CMD
293
- @$(call do_cmd,cxx,1)
294
- $(obj).$(TOOLSET)/%.o: $(obj)/%.cpp FORCE_DO_CMD
295
- @$(call do_cmd,cxx,1)
296
- $(obj).$(TOOLSET)/%.o: $(obj)/%.cxx FORCE_DO_CMD
297
- @$(call do_cmd,cxx,1)
298
- $(obj).$(TOOLSET)/%.o: $(obj)/%.S FORCE_DO_CMD
299
- @$(call do_cmd,cc,1)
300
- $(obj).$(TOOLSET)/%.o: $(obj)/%.s FORCE_DO_CMD
301
- @$(call do_cmd,cc,1)
302
-
303
-
304
- ifeq ($(strip $(foreach prefix,$(NO_LOAD),\
305
- $(findstring $(join ^,$(prefix)),\
306
- $(join ^,node_oom_heapdump_native.target.mk)))),)
307
- include node_oom_heapdump_native.target.mk
308
- endif
309
-
310
- quiet_cmd_regen_makefile = ACTION Regenerating $@
311
- cmd_regen_makefile = cd $(srcdir); /usr/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py -fmake --ignore-environment "--toplevel-dir=." -I/home/renskepaul/node-oom-heapdump/node-oom-heapdump/build/config.gypi -I/usr/lib/node_modules/npm/node_modules/node-gyp/addon.gypi -I/home/renskepaul/.cache/node-gyp/12.14.1/include/node/common.gypi "--depth=." "-Goutput_dir=." "--generator-output=build" "-Dlibrary=shared_library" "-Dvisibility=default" "-Dnode_root_dir=/home/renskepaul/.cache/node-gyp/12.14.1" "-Dnode_gyp_dir=/usr/lib/node_modules/npm/node_modules/node-gyp" "-Dnode_lib_file=/home/renskepaul/.cache/node-gyp/12.14.1/<(target_arch)/node.lib" "-Dmodule_root_dir=/home/renskepaul/node-oom-heapdump/node-oom-heapdump" "-Dnode_engine=v8" binding.gyp
312
- Makefile: $(srcdir)/../../.cache/node-gyp/12.14.1/include/node/common.gypi $(srcdir)/build/config.gypi $(srcdir)/binding.gyp $(srcdir)/../../../../usr/lib/node_modules/npm/node_modules/node-gyp/addon.gypi
313
- $(call do_cmd,regen_makefile)
314
-
315
- # "all" is a concatenation of the "all" targets from all the included
316
- # sub-makefiles. This is just here to clarify.
317
- all:
318
-
319
- # Add in dependency-tracking rules. $(all_deps) is the list of every single
320
- # target in our tree. Only consider the ones with .d (dependency) info:
321
- d_files := $(wildcard $(foreach f,$(all_deps),$(depsdir)/$(f).d))
322
- ifneq ($(d_files),)
323
- include $(d_files)
324
- endif
@@ -1,6 +0,0 @@
1
- # This file is generated by gyp; do not edit.
2
-
3
- export builddir_name ?= ./build/.
4
- .PHONY: all
5
- all:
6
- $(MAKE) node_oom_heapdump_native
@@ -1,157 +0,0 @@
1
- # This file is generated by gyp; do not edit.
2
-
3
- TOOLSET := target
4
- TARGET := node_oom_heapdump_native
5
- DEFS_Debug := \
6
- '-DNODE_GYP_MODULE_NAME=node_oom_heapdump_native' \
7
- '-DUSING_UV_SHARED=1' \
8
- '-DUSING_V8_SHARED=1' \
9
- '-DV8_DEPRECATION_WARNINGS=1' \
10
- '-DV8_DEPRECATION_WARNINGS' \
11
- '-DV8_IMMINENT_DEPRECATION_WARNINGS' \
12
- '-D_LARGEFILE_SOURCE' \
13
- '-D_FILE_OFFSET_BITS=64' \
14
- '-DOPENSSL_NO_PINSHARED' \
15
- '-DOPENSSL_THREADS' \
16
- '-DBUILDING_NODE_EXTENSION' \
17
- '-DDEBUG' \
18
- '-D_DEBUG' \
19
- '-DV8_ENABLE_CHECKS'
20
-
21
- # Flags passed to all source files.
22
- CFLAGS_Debug := \
23
- -fPIC \
24
- -pthread \
25
- -Wall \
26
- -Wextra \
27
- -Wno-unused-parameter \
28
- -m64 \
29
- -g \
30
- -O0
31
-
32
- # Flags passed to only C files.
33
- CFLAGS_C_Debug :=
34
-
35
- # Flags passed to only C++ files.
36
- CFLAGS_CC_Debug := \
37
- -fno-rtti \
38
- -fno-exceptions \
39
- -std=gnu++1y
40
-
41
- INCS_Debug := \
42
- -I/home/renskepaul/.cache/node-gyp/12.14.1/include/node \
43
- -I/home/renskepaul/.cache/node-gyp/12.14.1/src \
44
- -I/home/renskepaul/.cache/node-gyp/12.14.1/deps/openssl/config \
45
- -I/home/renskepaul/.cache/node-gyp/12.14.1/deps/openssl/openssl/include \
46
- -I/home/renskepaul/.cache/node-gyp/12.14.1/deps/uv/include \
47
- -I/home/renskepaul/.cache/node-gyp/12.14.1/deps/zlib \
48
- -I/home/renskepaul/.cache/node-gyp/12.14.1/deps/v8/include \
49
- -I$(srcdir)/node_modules/nan
50
-
51
- DEFS_Release := \
52
- '-DNODE_GYP_MODULE_NAME=node_oom_heapdump_native' \
53
- '-DUSING_UV_SHARED=1' \
54
- '-DUSING_V8_SHARED=1' \
55
- '-DV8_DEPRECATION_WARNINGS=1' \
56
- '-DV8_DEPRECATION_WARNINGS' \
57
- '-DV8_IMMINENT_DEPRECATION_WARNINGS' \
58
- '-D_LARGEFILE_SOURCE' \
59
- '-D_FILE_OFFSET_BITS=64' \
60
- '-DOPENSSL_NO_PINSHARED' \
61
- '-DOPENSSL_THREADS' \
62
- '-DBUILDING_NODE_EXTENSION'
63
-
64
- # Flags passed to all source files.
65
- CFLAGS_Release := \
66
- -fPIC \
67
- -pthread \
68
- -Wall \
69
- -Wextra \
70
- -Wno-unused-parameter \
71
- -m64 \
72
- -O3 \
73
- -fno-omit-frame-pointer
74
-
75
- # Flags passed to only C files.
76
- CFLAGS_C_Release :=
77
-
78
- # Flags passed to only C++ files.
79
- CFLAGS_CC_Release := \
80
- -fno-rtti \
81
- -fno-exceptions \
82
- -std=gnu++1y
83
-
84
- INCS_Release := \
85
- -I/home/renskepaul/.cache/node-gyp/12.14.1/include/node \
86
- -I/home/renskepaul/.cache/node-gyp/12.14.1/src \
87
- -I/home/renskepaul/.cache/node-gyp/12.14.1/deps/openssl/config \
88
- -I/home/renskepaul/.cache/node-gyp/12.14.1/deps/openssl/openssl/include \
89
- -I/home/renskepaul/.cache/node-gyp/12.14.1/deps/uv/include \
90
- -I/home/renskepaul/.cache/node-gyp/12.14.1/deps/zlib \
91
- -I/home/renskepaul/.cache/node-gyp/12.14.1/deps/v8/include \
92
- -I$(srcdir)/node_modules/nan
93
-
94
- OBJS := \
95
- $(obj).target/$(TARGET)/lib/node_oom_heapdump_native.o
96
-
97
- # Add to the list of files we specially track dependencies for.
98
- all_deps += $(OBJS)
99
-
100
- # CFLAGS et al overrides must be target-local.
101
- # See "Target-specific Variable Values" in the GNU Make manual.
102
- $(OBJS): TOOLSET := $(TOOLSET)
103
- $(OBJS): GYP_CFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE))
104
- $(OBJS): GYP_CXXFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE))
105
-
106
- # Suffix rules, putting all outputs into $(obj).
107
-
108
- $(obj).$(TOOLSET)/$(TARGET)/%.o: $(srcdir)/%.cc FORCE_DO_CMD
109
- @$(call do_cmd,cxx,1)
110
-
111
- # Try building from generated source, too.
112
-
113
- $(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj).$(TOOLSET)/%.cc FORCE_DO_CMD
114
- @$(call do_cmd,cxx,1)
115
-
116
- $(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj)/%.cc FORCE_DO_CMD
117
- @$(call do_cmd,cxx,1)
118
-
119
- # End of this set of suffix rules
120
- ### Rules for final target.
121
- LDFLAGS_Debug := \
122
- -pthread \
123
- -rdynamic \
124
- -m64
125
-
126
- LDFLAGS_Release := \
127
- -pthread \
128
- -rdynamic \
129
- -m64
130
-
131
- LIBS :=
132
-
133
- $(obj).target/node_oom_heapdump_native.node: GYP_LDFLAGS := $(LDFLAGS_$(BUILDTYPE))
134
- $(obj).target/node_oom_heapdump_native.node: LIBS := $(LIBS)
135
- $(obj).target/node_oom_heapdump_native.node: TOOLSET := $(TOOLSET)
136
- $(obj).target/node_oom_heapdump_native.node: $(OBJS) FORCE_DO_CMD
137
- $(call do_cmd,solink_module)
138
-
139
- all_deps += $(obj).target/node_oom_heapdump_native.node
140
- # Add target alias
141
- .PHONY: node_oom_heapdump_native
142
- node_oom_heapdump_native: $(builddir)/node_oom_heapdump_native.node
143
-
144
- # Copy this to the executable output path.
145
- $(builddir)/node_oom_heapdump_native.node: TOOLSET := $(TOOLSET)
146
- $(builddir)/node_oom_heapdump_native.node: $(obj).target/node_oom_heapdump_native.node FORCE_DO_CMD
147
- $(call do_cmd,copy)
148
-
149
- all_deps += $(builddir)/node_oom_heapdump_native.node
150
- # Short alias for building this executable.
151
- .PHONY: node_oom_heapdump_native.node
152
- node_oom_heapdump_native.node: $(obj).target/node_oom_heapdump_native.node $(builddir)/node_oom_heapdump_native.node
153
-
154
- # Add executable to "all" target.
155
- .PHONY: all
156
- all: $(builddir)/node_oom_heapdump_native.node
157
-
@@ -1,110 +0,0 @@
1
- #include <nan.h>
2
- #include <v8-profiler.h>
3
- #include <stdlib.h>
4
- #if defined(_WIN32)
5
- #include <time.h>
6
- #define snprintf _snprintf
7
- #else
8
- #include <sys/time.h>
9
- #endif
10
-
11
- using namespace v8;
12
-
13
- char filename[256];
14
- bool addTimestamp;
15
-
16
- class FileOutputStream: public OutputStream {
17
- public:
18
- FileOutputStream(FILE* stream): stream_(stream) { }
19
- virtual int GetChunkSize() {
20
- return 65536;
21
- }
22
- virtual void EndOfStream() { }
23
- virtual WriteResult WriteAsciiChunk(char* data, int size) {
24
- const size_t len = static_cast<size_t>(size);
25
- size_t off = 0;
26
- while (off < len && !feof(stream_) && !ferror(stream_))
27
- off += fwrite(data + off, 1, len - off, stream_);
28
- return off == len ? kContinue : kAbort;
29
- }
30
-
31
- private:
32
- FILE* stream_;
33
- };
34
-
35
- class ActivityControlAdapter : public ActivityControl {
36
- public:
37
- ActivityControlAdapter()
38
- {}
39
-
40
- ControlOption ReportProgressValue(int done, int total) {
41
- printf("\nProgress of heapdump: %d, %d", done, total);
42
- return kContinue;
43
- }
44
- };
45
-
46
- void OnOOMError(const char *location, bool is_heap_oom) {
47
- if (addTimestamp) {
48
- // Add timestamp to filename
49
- time_t rawtime;
50
- struct tm* timeinfo;
51
- time(&rawtime);
52
- timeinfo = localtime(&rawtime);
53
-
54
- char * pch;
55
- pch = strstr (filename,".heapsnapshot");
56
- strncpy (pch,"",1);
57
- strcat (filename, "-%Y%m%dT%H%M%S.heapsnapshot");
58
-
59
- char newFilename[256];
60
- strftime(newFilename, sizeof(filename), filename, timeinfo);
61
- strcpy(filename, newFilename);
62
- }
63
-
64
- fprintf(stderr, "Generating Heapdump to '%s' now...\n", filename);
65
- FILE* fp = fopen(filename, "w");
66
- if (fp == NULL) abort();
67
-
68
- // Create heapdump, depending on which Node.js version this can differ
69
- // for now, just support Node.js 7 and higher
70
-
71
- ActivityControlAdapter* control = new ActivityControlAdapter();
72
- const HeapSnapshot* snap = v8::Isolate::GetCurrent()->GetHeapProfiler()->TakeHeapSnapshot(control);
73
-
74
- FileOutputStream stream(fp);
75
- snap->Serialize(&stream, HeapSnapshot::kJSON);
76
- fclose(fp);
77
-
78
- fprintf(stderr, "Done! Exiting process now.\n");
79
- exit(1);
80
-
81
- }
82
-
83
- void ParseArgumentsAndSetErrorHandler(const FunctionCallbackInfo<Value>& args) {
84
- Isolate* isolate = args.GetIsolate();
85
- isolate->SetOOMErrorHandler(OnOOMError);
86
-
87
- // parse JS arguments
88
- // 1: filename
89
- // 2: addTimestamp boolean
90
- #if NODE_VERSION_AT_LEAST(12, 0, 0)
91
- String::Utf8Value fArg(isolate, args[0]->ToString(isolate));
92
- #elif NODE_VERSION_AT_LEAST(9, 0, 0)
93
- String::Utf8Value fArg(isolate, args[0]->ToString());
94
- #else
95
- String::Utf8Value fArg(args[0]->ToString());
96
- #endif
97
- strncpy(filename, (const char*)(*fArg), sizeof(filename) - 1);
98
-
99
- #if NODE_VERSION_AT_LEAST(12, 0, 0)
100
- addTimestamp = args[1]->BooleanValue(isolate);
101
- #else
102
- addTimestamp = args[1]->BooleanValue();
103
- #endif
104
- }
105
-
106
- void init(Local<Object> exports) {
107
- NODE_SET_METHOD(exports, "call", ParseArgumentsAndSetErrorHandler);
108
- }
109
-
110
- NODE_MODULE(NODE_OOM_HEAPDUMP_NATIVE, init)
package/tests/index.js DELETED
@@ -1,27 +0,0 @@
1
- let cp = require("child_process");
2
- let fs = require("fs");
3
- let path = require("path");
4
-
5
- describe('Heapdumps', function () {
6
- it('should be created in x seconds', function (done) {
7
- this.timeout(250000);
8
-
9
- let child = cp.fork(path.resolve(__dirname, './oom_app.js'), null, {
10
- cmd: path.dirname(require.main.filename),
11
- stdio: 'inherit',
12
- execArgv: ["--max_old_space_size=40", "--optimize_for_size", "--always_compact", "--inspect=9229"]
13
- });
14
-
15
- setTimeout(function () {
16
- child.kill();
17
- fs.lstat(path.resolve(__dirname, "../abc.heapsnapshot"), (err, stats) => {
18
- if (!err && stats.isFile()) {
19
- done();
20
- } else {
21
- done(err);
22
- }
23
- clearTimeout(handle);
24
- })
25
- }, 20000);
26
- });
27
- });
@@ -1,27 +0,0 @@
1
- let oomLib = require("../index.js")({
2
- heapdumpOnOOM: false
3
- });
4
-
5
- var i = 0;
6
- var path = "";
7
-
8
- var handle = setInterval(function () {
9
- i++;
10
-
11
- oomLib.createHeapSnapshot(require("path").resolve("../", "myName")).then((p) => {
12
- path = p;
13
- }).catch((err) => {
14
- console.error(err);
15
- });
16
-
17
- if (i === 3) {
18
- oomLib.deleteHeapSnapshot(path).then(() => {
19
- //
20
- }).catch((err) => {
21
- console.error("err", err);
22
- });
23
- setTimeout(function () {
24
- process.exit(0);
25
- }, 100);
26
- }
27
- }, 2000);
@@ -1,35 +0,0 @@
1
- let oomLib = require("../index.js")({
2
- heapdumpOnOOM: false
3
- });
4
-
5
- var i = 0;
6
- var path = "";
7
-
8
- oomLib.createCpuProfile(require("path").resolve("myCPU.cpuprofile"), 3000).then((p) => {
9
- console.error("CPU profile", p);
10
-
11
- //oomLib.deleteAllCpuProfiles();
12
- }).catch((err) => {
13
- console.error(err);
14
- });
15
-
16
- var handle = setInterval(function () {
17
- i++;
18
-
19
- oomLib.createHeapSnapshot(require("path").resolve("../", "myName")).then((p) => {
20
- path = p;
21
- }).catch((err) => {
22
- console.error(err);
23
- });
24
-
25
- if (i === 5) {
26
- /* oomLib.deleteHeapSnapshot(path).then(() => {
27
- //
28
- }).catch((err) => {
29
- console.error("err", err);
30
- });*/
31
- setTimeout(function () {
32
- process.exit(0);
33
- }, 100);
34
- }
35
- }, 1000);