GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — doc: add conditional example for setBreakpoint() · nodejs/node@34d6ca3

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • doc/api
    • debugger.md
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎doc/api/debugger.md‎

Copy file name to clipboardExpand all lines: doc/api/debugger.md
+39Lines changed: 39 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,9 @@ To begin watching an expression, type `watch('my_expression')`. The command
118118
functions body
119119
* `setBreakpoint('script.js', 1)`, `sb(...)`: Set breakpoint on first line of
120120
`script.js`
121+
* `setBreakpoint('script.js', 1, 'num < 4')`, `sb(...)`: Set conditional
122+
breakpoint on first line of `script.js` that only breaks when `num < 4`
123+
evaluates to `true`
121124
* `clearBreakpoint('script.js', 1)`, `cb(...)`: Clear breakpoint in `script.js`
122125
on line 1
123126

@@ -145,6 +148,42 @@ break in mod.js:22
145148
debug>
146149
```
147150

151+
It is also possible to set a conditional breakpoint that only breaks when a
152+
given expression evaluates to `true`:
153+
154+
```console
155+
$ node inspect main.js
156+
< Debugger listening on ws://127.0.0.1:9229/ce24daa8-3816-44d4-b8ab-8273c8a66d35
157+
< For help, see: https://nodejs.org/en/docs/inspector
158+
< Debugger attached.
159+
Break on start in main.js:7
160+
5 }
161+
6
162+
> 7 addOne(10);
163+
8 addOne(-1);
164+
9
165+
debug> setBreakpoint('main.js', 4, 'num < 0')
166+
1 'use strict';
167+
2
168+
3 function addOne(num) {
169+
> 4 return num + 1;
170+
5 }
171+
6
172+
7 addOne(10);
173+
8 addOne(-1);
174+
9
175+
debug> cont
176+
break in main.js:4
177+
2
178+
3 function addOne(num) {
179+
> 4 return num + 1;
180+
5 }
181+
6
182+
debug> exec('num')
183+
-1
184+
debug>
185+
```
186+
148187
### Information
149188

150189
* `backtrace`, `bt`: Print backtrace of current execution frame

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.