Commit Graph

32 Commits

Author SHA1 Message Date
LiviaMedeiros
2a0e5de163 debugger: use internal/url.URL instead of url.parse
PR-URL: https://github.com/nodejs/node/pull/49590
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2023-09-13 18:03:14 +00:00
Michael Bianco
9497665d19
doc: add description for --port flag of node inspect
PR-URL: https://github.com/nodejs/node/pull/48785
Reviewed-By: Kohei Ueno <kohei.ueno119@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2023-08-11 17:31:04 +02:00
Joyee Cheung
e1fa85133f
src: implement natives binding without special casing
This patch removes special case in the internal binding loader
for natives, and implements it using the builtins internal
binding. Internally we do not actually need the natives binding,
so implement it as a legacy wrapper instead.

PR-URL: https://github.com/nodejs/node/pull/48186
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
2023-06-09 15:32:55 +02:00
Eungyu Lee
f8bf4987e9
debugger: improve validations and documents for watch and unwatch
- debugger: add string validation for watch(expr)
- debugger: add help document for watch(index)
- test: add test for watch(index) command
- doc: add information on unwatch(index) option

PR-URL: https://github.com/nodejs/node/pull/46947
Reviewed-By: Kohei Ueno <kohei.ueno119@gmail.com>
2023-03-13 04:29:53 +00:00
Eungyu Lee
7f2ab4e629
debugger: add a command to set which lines to check for context
PR-URL: https://github.com/nodejs/node/pull/46812
Reviewed-By: Kohei Ueno <kohei.ueno119@gmail.com>
2023-03-12 04:47:18 +00:00
Debadree Chatterjee
5b5898ac86
lib,src: update exit codes as per todos
Refs: https://github.com/nodejs/node/pull/44746
PR-URL: https://github.com/nodejs/node/pull/45841
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2023-02-26 17:03:06 +00:00
Antoine du Hamel
655b070d31
debugger: add trailing commas in source files
PR-URL: https://github.com/nodejs/node/pull/46714
Reviewed-By: Kohei Ueno <kohei.ueno119@gmail.com>
Reviewed-By: Debadree Chatterjee <debadree333@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: James M Snell <jasnell@gmail.com>
2023-02-22 01:26:44 +01:00
Antoine du Hamel
fe514bf960
lib: enforce use of trailing commas for functions
PR-URL: https://github.com/nodejs/node/pull/46629
Reviewed-By: Jacob Smith <jacob@frende.me>
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com>
2023-02-14 18:45:16 +01:00
Debadree Chatterjee
17cb655561
debugger: refactor console in lib/internal/debugger/inspect.js
Refs: https://github.com/nodejs/node/pull/38406/
PR-URL: https://github.com/nodejs/node/pull/45847
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Kohei Ueno <kohei.ueno119@gmail.com>
2022-12-28 11:59:41 +00:00
Antoine du Hamel
ca2ec902e9
tools: add ArrayPrototypeConcat to the list of primordials to avoid
PR-URL: https://github.com/nodejs/node/pull/44445
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
2022-12-17 19:15:24 +00:00
Antoine du Hamel
1c3ba4c5fa
repl: improve robustness wrt to prototype pollution
PR-URL: https://github.com/nodejs/node/pull/45604
Reviewed-By: James M Snell <jasnell@gmail.com>
2022-12-14 15:48:50 +01:00
Joyee Cheung
be525d7d04
src: consolidate exit codes in the code base
Add an ExitCode enum class and use it throughout the code base
instead of hard-coding the exit codes everywhere. At the moment,
the exit codes used in many places do not actually conform to
what the documentation describes. With the new enums (which
are also available to the JS land as constants in an internal
binding) we could migrate to a more consistent usage of the
codes, and eventually expose the constants to the user land
when they are stable enough.

PR-URL: https://github.com/nodejs/node/pull/44746
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Jacob Smith <jacob@frende.me>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
2022-10-06 12:41:16 +00:00
Antoine du Hamel
ce639629dd
lib: use safe Promise alternatives when available
PR-URL: https://github.com/nodejs/node/pull/43476
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
2022-08-27 11:37:01 +02:00
Joyee Cheung
83cd484d77
debugger: decrease timeout used to wait for the port to be free
By default, the debugger would query the specified inspector
sever port to see if it's available before starting the server,
and it would keep retrying until a timeout (previously 9999 ms)
is reached. This timeout seems to be longer than necessary. This
patch decreases the timeout to 3 seconds.

PR-URL: https://github.com/nodejs/node/pull/44359
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Richard Lau <rlau@redhat.com>
2022-08-24 13:52:54 +00:00
Joyee Cheung
472edc775d
src: disambiguate terms used to refer to builtins and addons
The term "native module" dates back to some of the oldest code
in the code base. Within the context of Node.js core it usually
refers to modules that are native to Node.js (e.g. fs, http),
but it can cause confusion for people who don't work on this
part of the code base, as "native module" can also refer to
native addons - which is even the case in some of the API
docs and error messages.

This patch tries to make the usage of these terms more consistent.
Now within the context of Node.js core:

- JavaScript scripts that are built-in to Node.js are now referred
  to as "built-in(s)". If they are available as modules,
  they can also be referred to as "built-in module(s)".
- Dynamically-linked shared objects that are loaded into
  the Node.js processes are referred to as "addons".

We will try to avoid using the term "native modules" because it could
be ambiguous.

Changes in this patch:

File names:
- node_native_module.h -> node_builtins.h,
- node_native_module.cc -> node_builtins.cc

C++ binding names:
- `native_module` -> `builtins`

`node::Environment`:
- `native_modules_without_cache` -> `builtins_without_cache`
- `native_modules_with_cache` -> `builtins_with_cache`
- `native_modules_in_snapshot` -> `builtins_in_cache`
- `native_module_require` -> `builtin_module_require`

`node::EnvSerializeInfo`:
- `native_modules` -> `builtins

`node::native_module::NativeModuleLoader`:
- `native_module` namespace -> `builtins` namespace
- `NativeModuleLoader` -> `BuiltinLoader`
- `NativeModuleRecordMap` -> `BuiltinSourceMap`
- `NativeModuleCacheMap` -> `BuiltinCodeCacheMap`
- `ModuleIds` -> `BuiltinIds`
- `ModuleCategories` -> `BuiltinCategories`
- `LoadBuiltinModuleSource` -> `LoadBuiltinSource`

`loader.js`:
- `NativeModule` -> `BuiltinModule` (the `NativeModule` name used in
  `process.moduleLoadList` is kept for compatibility)

And other clarifications in the documentation and comments.

PR-URL: https://github.com/nodejs/node/pull/44135
Fixes: https://github.com/nodejs/node/issues/44036
Reviewed-By: Jacob Smith <jacob@frende.me>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Michael Dawson <midawson@redhat.com>
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Jan Krems <jan.krems@gmail.com>
2022-08-09 01:36:49 +08:00
Antoine du Hamel
d7f193434a
lib: add Promise methods to avoid-prototype-pollution lint rule
PR-URL: https://github.com/nodejs/node/pull/43849
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
2022-07-26 23:38:24 +01:00
Antoine du Hamel
feb3aa205b
repl: use SafePromiseAll and SafePromiseRace
PR-URL: https://github.com/nodejs/node/pull/43758
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2022-07-12 22:50:35 +01:00
Antoine du Hamel
a055337a02
lib: refactor to avoid unsafe regex primordials
PR-URL: https://github.com/nodejs/node/pull/43475
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
2022-06-27 17:16:06 +02:00
Antoine du Hamel
358008f473
tools,doc: add guards against prototype pollution when creating proxies
PR-URL: https://github.com/nodejs/node/pull/43391
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: LiviaMedeiros <livia@cirno.name>
Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
2022-06-16 00:26:48 +02:00
Antoine du Hamel
06d8606960
lib: use null-prototype objects for property descriptors
Refs: https://github.com/nodejs/node/pull/42921

PR-URL: https://github.com/nodejs/node/pull/43270
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
2022-06-03 09:23:58 +01:00
Kohei Ueno
cbb92b0dde
debugger: throw a more useful error when the frame is missing
PR-URL: https://github.com/nodejs/node/pull/42776
Fixes: https://github.com/nodejs/node/issues/42775
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2022-05-22 15:09:14 +02:00
Kohei Ueno
f890ef5306
debugger: fix inconsistent inspector output of exec new Map()
PR-URL: https://github.com/nodejs/node/pull/42423
Reviewed-By: Jan Krems <jan.krems@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2022-05-08 20:51:38 +01:00
Kohei Ueno
1f638376c7
debugger: correct typo in inspect_repl.js
PR-URL: https://github.com/nodejs/node/pull/42267
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Mestery <mestery@protonmail.com>
2022-03-09 19:34:39 +00:00
Xuguang Mei
7d75e3f542
debugger: add debugger alias for exec(expr)
https://github.com/nodejs/node/issues/41794

PR-URL: https://github.com/nodejs/node/pull/41907
Reviewed-By: Jan Krems <jan.krems@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
2022-02-17 19:23:20 +00:00
Balakrishna Avulapati
937288aeab
debugger: remove duplicate setPauseOnException call
Removes the duplicate call of setPauseOnException() inside
initAfterStart().

Fixes: https://github.com/nodejs/node/issues/41795

PR-URL: https://github.com/nodejs/node/pull/41838
Reviewed-By: Jan Krems <jan.krems@gmail.com>
2022-02-11 11:47:20 +00:00
gdccwxx
ac4f5e2437 lib: refactor to use let
move variable into each for loop

PR-URL: https://github.com/nodejs/node/pull/40364
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Zijian Liu <lxxyxzj@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
2021-10-09 17:22:56 +00:00
Rich Trott
16a9ab142c debugger: prevent simultaneous heap snapshots
Fixes: https://github.com/nodejs/node/issues/39555

PR-URL: https://github.com/nodejs/node/pull/39638
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2021-08-05 11:52:55 +00:00
Rich Trott
1c6f26d347 debugger: remove undefined parameter
The data parameter of unpackError() is typically undefined.

PR-URL: https://github.com/nodejs/node/pull/39570
Refs: https://github.com/nodejs/node-inspect/issues/101
Reviewed-By: Jan Krems <jan.krems@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
2021-08-01 14:24:35 +00:00
Chris Opperwall
f52da9484d debugger: validate sec-websocket-accept response header
This addresses a TODO to validate that the sec-websocket-accept header
in the WebSocket handshake response is valid. To do this we need to
append the WebSocket GUID to the original key sent in sec-websocket-key,
sha1 hash it, and then compare the base64 encoding with the value sent
in the sec-websocket-accept response header.

If they don't match, an error is thrown.

PR-URL: https://github.com/nodejs/node/pull/39357
Refs: https://github.com/nodejs/node-inspect/pull/93
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2021-07-18 14:53:23 -07:00
Rich Trott
c12db606ee debugger: rename internal module
All other files in `lib/internal` do not start with `_`. For
consistency, move `lib/internal/debugger/_inspect.js` to
`lib/internal/debugger/inspect.js`.

PR-URL: https://github.com/nodejs/node/pull/39378
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
2021-07-15 17:19:07 -07:00
Rich Trott
3c099874aa debugger: remove final lint exceptions in inspect_repl.js
Adding a return when it's not really a getter is kind of misleading, but
so is using a getter for something that doesn't return anything, so
¯\_(ツ)_/¯.

PR-URL: https://github.com/nodejs/node/pull/39078
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
2021-06-25 22:05:18 -07:00
Rich Trott
4330fb757f debugger: rename internal library for clarity
When I moved these files from node-inspect to Node.js core, I put them
in lib/internal/inspector. That was a mistake. They should be in
lib/internal/debugger.

PR-URL: https://github.com/nodejs/node/pull/39080
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2021-06-20 22:33:32 -07:00