Function

Gjsgjs/systembreakpoint

  • 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 --args gjs script.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
    tarting program: /usr/bin/gjs -m script.js
    ...
    Thread 1 "gjs" received signal SIGTRAP, Trace/breakpoint trap.
    (gdb) call gjs_dumpstack()
    == Stack trace for context 0x5555555b7180 ==
    #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.

    Returns void