Line data Source code
1 0 : // Distributed under the MIT License. 2 : // See LICENSE.txt for details. 3 : 4 : #pragma once 5 : 6 : namespace sys { 7 : /*! 8 : * \brief Provide an infinite loop to attach a debugger during startup. Useful 9 : * for debugging MPI runs. 10 : * 11 : * Each MPI rank writes a file name `spectre_pid_#_host_NAME` to the working 12 : * directory. This allows you to attach GDB to the running process using 13 : * `gdb --pid=PID`, once for each MPI rank. You must then halt the program 14 : * using `C-c` and then call `set var i = 7` inside GDB. Once you've done this 15 : * on each MPI rank, you can have each MPI rank `continue`. 16 : * 17 : * To add support for attaching to a debugger in an executable, you must add 18 : * `sys::attach_debugger` to the 19 : * `Parallel::charmxx::register_init_node_and_proc` init node functions. Then, 20 : * when you launch the executable launch it as 21 : * ```shell 22 : * SPECTRE_ATTACH_DEBUGGER=1 mpirun -np N ... 23 : * ``` 24 : * The environment variable `SPECTRE_ATTACH_DEBUGGER` being set tells the code 25 : * to allow attaching from a debugger. 26 : */ 27 1 : void attach_debugger(); 28 : } // namespace sys