Inserts a breakpoint instruction into the code.
Warning: Using this function in code run outside of GDB will abort the process.
With System.breakpoint() calls in your code, a GJS program can be debugged by
running it in GDB:
gdb--argsgjsscript.js
Once GDB has started, you can start the program with run. When the debugger
hits a breakpoint it will pause execution of the process and return to the
prompt. You can then use the standard backtrace command to print a C++ stack
trace, or use call gjs_dumpstack() to print a JavaScript stack trace:
(gdb) run tartingprogram:/usr/bin/gjs-mscript.js ... Thread1"gjs"receivedsignalSIGTRAP,Trace/breakpointtrap. (gdb) callgjs_dumpstack() ==Stacktraceforcontext0x5555555b7180== #0 555555640548 i file:///path/to/script.js:4 (394b8c3cc060 @ 12) #1 5555556404c8 i file:///path/to/script.js:7 (394b8c3cc0b0 @ 6) #2 7fffffffd3a0 b self-hosted:2408 (394b8c3a9650 @ 753) #3 5555556403e8 i self-hosted:2355 (394b8c3a9600 @ 375) (gdb)
To continue executing the program, you can use the continue (or cont) to
resume the process and debug further.
Remember that if you run the program outside of GDB, it will abort at the
breakpoint, so make sure to remove any calls to System.breakpoint() when
you're done debugging.
Inserts a breakpoint instruction into the code. Warning: Using this function in code run outside of GDB will abort the process. With
System.breakpoint()calls in your code, a GJS program can be debugged by running it in GDB:Once GDB has started, you can start the program with run. When the debugger hits a breakpoint it will pause execution of the process and return to the prompt. You can then use the standard
backtracecommand to print a C++ stack trace, or usecall gjs_dumpstack()to print a JavaScript stack trace:To continue executing the program, you can use the
continue(orcont) to resume the process and debug further. Remember that if you run the program outside of GDB, it will abort at the breakpoint, so make sure to remove any calls toSystem.breakpoint()when you're done debugging.