Actual source code: adebug.c
1: /*
2: Code to handle PETSc starting up in debuggers,etc.
3: */
4: #define PETSC_DESIRE_FEATURE_TEST_MACROS /* for fileno() */
5: #include <petscsys.h>
6: #include <signal.h>
7: #if PetscDefined(HAVE_UNISTD_H)
8: #include <unistd.h>
9: #endif
11: /*
12: These are the debugger and display used if the debugger is started up
13: */
14: static char PetscDebugger[PETSC_MAX_PATH_LEN];
15: static char DebugTerminal[PETSC_MAX_PATH_LEN];
16: static PetscBool UseDebugTerminal = PETSC_TRUE;
17: PetscBool petscwaitonerrorflg = PETSC_FALSE;
18: PetscBool petscindebugger = PETSC_FALSE;
20: /*@
21: PetscSetDebugTerminal - Sets the terminal to use for debugging.
23: Not Collective; No Fortran Support
25: Input Parameter:
26: . terminal - name of terminal and any flags required to execute a program.
27: For example "xterm", "urxvt -e", "gnome-terminal -x".
28: On Apple macOS you can use "Terminal" (note the capital T)
30: Options Database Key:
31: . -debug_terminal terminal - use this terminal instead of the default
33: Level: developer
35: Notes:
36: You can start the debugger for all processes in the same GNU screen session.
37: .vb
38: mpiexec -n 4 ./myapp -start_in_debugger -debug_terminal "screen -X -S debug screen"
39: .ve
41: will open 4 windows in the session named "debug".
43: The default terminal on Apple is Terminal, on other systems the default is xterm
45: .seealso: `PetscSetDebugger()`, `PetscAttachDebugger()`
46: @*/
47: PetscErrorCode PetscSetDebugTerminal(const char terminal[])
48: {
49: PetscBool xterm;
51: PetscFunctionBegin;
52: PetscCall(PetscStrncpy(DebugTerminal, terminal, sizeof(DebugTerminal)));
53: PetscCall(PetscStrcmp(terminal, "xterm", &xterm));
54: if (xterm) PetscCall(PetscStrlcat(DebugTerminal, " -e", sizeof(DebugTerminal)));
55: PetscFunctionReturn(PETSC_SUCCESS);
56: }
58: /*@
59: PetscSetDebugger - Sets options associated with the debugger.
61: Not Collective; No Fortran Support
63: Input Parameters:
64: + debugger - name of debugger, which should be in your path,
65: usually "lldb", "dbx", "gdb", "cuda-gdb", "idb", "xxgdb", "kdgb" or "ddd". Also, HP-UX
66: supports "xdb".
68: - usedebugterminal - flag to indicate debugger window, set to either `PETSC_TRUE` (to indicate
69: debugger should be started in a new terminal window) or `PETSC_FALSE` (to start debugger
70: in initial window (the option `PETSC_FALSE` makes no sense when using more
71: than one MPI process.)
73: Level: developer
75: .seealso: `PetscAttachDebugger()`, `PetscAttachDebuggerErrorHandler()`, `PetscSetDebugTerminal()`
76: @*/
77: PetscErrorCode PetscSetDebugger(const char debugger[], PetscBool usedebugterminal)
78: {
79: PetscFunctionBegin;
80: if (debugger) PetscCall(PetscStrncpy(PetscDebugger, debugger, sizeof(PetscDebugger)));
81: if (UseDebugTerminal) UseDebugTerminal = usedebugterminal;
82: PetscFunctionReturn(PETSC_SUCCESS);
83: }
85: /*@
86: PetscSetDefaultDebugger - Causes PETSc to use its default debugger and output terminal
88: Not Collective, No Fortran Support
90: Level: developer
92: .seealso: `PetscSetDebugger()`, `PetscSetDebuggerFromString()`, `PetscAttachDebugger()`
93: @*/
94: PetscErrorCode PetscSetDefaultDebugger(void)
95: {
96: PetscFunctionBegin;
97: #if defined(PETSC_USE_DEBUGGER)
98: PetscCall(PetscSetDebugger(PETSC_USE_DEBUGGER, PETSC_TRUE));
99: #endif
100: #if defined(__APPLE__)
101: PetscCall(PetscSetDebugTerminal("Terminal"));
102: #else
103: PetscCall(PetscSetDebugTerminal("xterm"));
104: #endif
105: PetscFunctionReturn(PETSC_SUCCESS);
106: }
108: static PetscErrorCode PetscCheckDebugger_Private(const char defaultDbg[], const char string[], const char *debugger[])
109: {
110: char *f = NULL;
112: PetscFunctionBegin;
113: PetscCall(PetscStrstr(string, defaultDbg, &f));
114: if (f) {
115: PetscBool exists;
117: PetscCall(PetscTestFile(string, 'x', &exists));
118: if (exists) *debugger = string;
119: else *debugger = defaultDbg;
120: }
121: PetscFunctionReturn(PETSC_SUCCESS);
122: }
124: /*@
125: PetscSetDebuggerFromString - Set the complete path for the
126: debugger for PETSc to use.
128: Not Collective
130: Input Parameter:
131: . string - the name of the debugger, for example "gdb"
133: Level: developer
135: .seealso: `PetscSetDebugger()`, `PetscSetDefaultDebugger()`, `PetscAttachDebugger()`
136: @*/
137: PetscErrorCode PetscSetDebuggerFromString(const char string[])
138: {
139: const char *debugger = NULL;
140: PetscBool useterminal = PETSC_TRUE;
141: char *f = NULL;
143: PetscFunctionBegin;
144: PetscCall(PetscStrstr(string, "noxterm", &f));
145: if (f) useterminal = PETSC_FALSE;
146: PetscCall(PetscStrstr(string, "ddd", &f));
147: if (f) useterminal = PETSC_FALSE;
148: PetscCall(PetscStrstr(string, "noterminal", &f));
149: if (f) useterminal = PETSC_FALSE;
150: PetscCall(PetscCheckDebugger_Private("xdb", string, &debugger));
151: PetscCall(PetscCheckDebugger_Private("dbx", string, &debugger));
152: PetscCall(PetscCheckDebugger_Private("gdb", string, &debugger));
153: PetscCall(PetscCheckDebugger_Private("cuda-gdb", string, &debugger));
154: PetscCall(PetscCheckDebugger_Private("idb", string, &debugger));
155: PetscCall(PetscCheckDebugger_Private("xxgdb", string, &debugger));
156: PetscCall(PetscCheckDebugger_Private("ddd", string, &debugger));
157: PetscCall(PetscCheckDebugger_Private("kdbg", string, &debugger));
158: PetscCall(PetscCheckDebugger_Private("ups", string, &debugger));
159: PetscCall(PetscCheckDebugger_Private("workshop", string, &debugger));
160: PetscCall(PetscCheckDebugger_Private("pgdbg", string, &debugger));
161: PetscCall(PetscCheckDebugger_Private("pathdb", string, &debugger));
162: PetscCall(PetscCheckDebugger_Private("lldb", string, &debugger));
163: PetscCall(PetscSetDebugger(debugger, useterminal));
164: PetscFunctionReturn(PETSC_SUCCESS);
165: }
167: /*@
168: PetscWaitOnError - If an error is detected and the process would normally exit the main program with `MPI_Abort()` sleep instead
169: of exiting.
171: Not Collective
173: Level: advanced
175: Note:
176: When `-start_in_debugger -debugger_ranks x,y,z` is used this prevents the processes NOT listed in x,y,z from calling `MPI_Abort()` and
177: killing the user's debugging sessions.
179: .seealso: `PetscSetDebugger()`, `PetscAttachDebugger()`
180: @*/
181: PetscErrorCode PetscWaitOnError(void)
182: {
183: petscwaitonerrorflg = PETSC_TRUE;
184: return PETSC_SUCCESS;
185: }
187: /*@
188: PetscAttachDebugger - Attaches the debugger to the running process.
190: Not Collective
192: Options Database Keys:
193: + -start_in_debugger [(noxterm)],[(lldb|gdb|...)] - Set debugger debug_terminal xterm or Terminal (for Apple)
194: . -display name - XDisplay to open xterm in
195: . -debugger_ranks m,n - Which MPI ranks on which to start the debugger, defaults to all
196: . -stop_for_debugger - Print a message on how to attach the process with a debugger and then wait for the user to attach
197: - -debugger_pause secs - Wait secs before attaching the debugger. This is useful for slow connections
198: that take a long time for the Terminal window or xterm to start up.
200: Level: advanced
202: Note:
203: If you get the message "`stdin` is not a `tty`, hence unable to attach debugger, see `PetscAttachDebugger()`", this means the application
204: is likely running in a batch system and you do not have terminal access to the process. You can try
205: running with `-start_in_debugger` without the `noxterm` argument or `-stop_for_debugger`
207: Developer Note:
208: Since this can be called by the error handler, should it be calling `SETERRQ()` and `PetscCall()`?
210: .seealso: `PetscSetDebugger()`, `PetscSetDefaultDebugger()`, `PetscSetDebugTerminal()`, `PetscAttachDebuggerErrorHandler()`, `PetscStopForDebugger()`
211: @*/
212: PetscErrorCode PetscAttachDebugger(void)
213: {
214: PetscErrorCode PETSC_UNUSED ierr;
215: #if !PetscDefined(CANNOT_START_DEBUGGER) && PetscDefined(HAVE_FORK)
216: int child = 0;
217: PetscReal sleeptime = 0;
218: char program[PETSC_MAX_PATH_LEN], display[256], hostname[64];
219: #endif
221: #if PetscDefined(CANNOT_START_DEBUGGER) || !PetscDefined(HAVE_FORK)
222: ierr = (*PetscErrorPrintf)("System cannot start debugger\n");
223: ierr = (*PetscErrorPrintf)("On Cray run program in Totalview debugger\n");
224: ierr = (*PetscErrorPrintf)("On Windows use Developer Studio(MSDEV)\n");
225: PETSCABORT(PETSC_COMM_WORLD, PETSC_ERR_SUP_SYS);
226: #else
227: if (PetscUnlikely(PetscGetDisplay(display, sizeof(display)))) {
228: ierr = (*PetscErrorPrintf)("PetscAttachDebugger: Cannot determine display\n");
229: return PETSC_ERR_SYS;
230: }
231: if (PetscUnlikely(PetscGetProgramName(program, sizeof(program)))) {
232: ierr = (*PetscErrorPrintf)("PetscAttachDebugger: Cannot determine program name needed to attach debugger\n");
233: return PETSC_ERR_SYS;
234: }
235: if (PetscUnlikely(!program[0])) {
236: ierr = (*PetscErrorPrintf)("PetscAttachDebugger: Cannot determine program name needed to attach debugger\n");
237: return PETSC_ERR_SYS;
238: }
239: if (PetscUnlikely(!isatty(fileno(stdin))) && !UseDebugTerminal) printf("If the debugger exits immediately or hangs, this indicates you cannot use PetscAttachDebugger() in this situation\n\n");
240: child = fork();
241: if (PetscUnlikely(child < 0)) {
242: ierr = (*PetscErrorPrintf)("PetscAttachDebugger: Error in fork() prior to attaching debugger\n");
243: return PETSC_ERR_SYS;
244: }
245: petscindebugger = PETSC_TRUE;
247: /*
248: Swap role the parent and child. This is (I think) so that control c typed
249: in the debugger goes to the correct process.
250: */
251: #if !PetscDefined(DO_NOT_SWAP_CHILD_FOR_DEBUGGER)
252: child = child ? 0 : getppid();
253: #endif
255: if (child) { /* I am the parent, will run the debugger */
256: const char *args[10];
257: char pid[10];
258: PetscInt j, jj;
259: PetscBool isdbx, isidb, isxxgdb, isups, isxdb, isworkshop, isddd, iskdbg, islldb;
261: PetscCall(PetscGetHostName(hostname, sizeof(hostname)));
262: /*
263: We need to send a continue signal to the "child" process on the
264: alpha, otherwise it just stays off forever
265: */
266: #if PetscDefined(NEED_KILL_FOR_DEBUGGER)
267: kill(child, SIGCONT);
268: #endif
269: PetscCall(PetscSNPrintf(pid, PETSC_STATIC_ARRAY_LENGTH(pid), "%d", child));
271: PetscCall(PetscStrcmp(PetscDebugger, "xxgdb", &isxxgdb));
272: PetscCall(PetscStrcmp(PetscDebugger, "ddd", &isddd));
273: PetscCall(PetscStrcmp(PetscDebugger, "kdbg", &iskdbg));
274: PetscCall(PetscStrcmp(PetscDebugger, "ups", &isups));
275: PetscCall(PetscStrcmp(PetscDebugger, "xdb", &isxdb));
276: PetscCall(PetscStrcmp(PetscDebugger, "dbx", &isdbx));
277: PetscCall(PetscStrcmp(PetscDebugger, "idb", &isidb));
278: PetscCall(PetscStrcmp(PetscDebugger, "workshop", &isworkshop));
279: PetscCall(PetscStrcmp(PetscDebugger, "lldb", &islldb));
281: if (isxxgdb || isups || isddd) {
282: args[1] = program;
283: args[2] = pid;
284: args[3] = "-display";
285: args[0] = PetscDebugger;
286: args[4] = display;
287: args[5] = NULL;
288: printf("PETSC: Attaching %s to %s %s on %s\n", args[0], args[1], pid, hostname);
289: if (execvp(args[0], (char **)args) < 0) {
290: perror("Unable to start debugger");
291: exit(0);
292: }
293: } else if (iskdbg) {
294: args[1] = "-p";
295: args[2] = pid;
296: args[3] = program;
297: args[4] = "-display";
298: args[0] = PetscDebugger;
299: args[5] = display;
300: args[6] = NULL;
301: printf("PETSC: Attaching %s to %s %s on %s\n", args[0], args[3], pid, hostname);
302: if (execvp(args[0], (char **)args) < 0) {
303: perror("Unable to start debugger");
304: exit(0);
305: }
306: } else if (isworkshop) {
307: args[1] = "-s";
308: args[2] = pid;
309: args[3] = "-D";
310: args[4] = "-";
311: args[0] = PetscDebugger;
312: args[5] = pid;
313: args[6] = "-display";
314: args[7] = display;
315: args[8] = NULL;
316: printf("PETSC: Attaching %s to %s on %s\n", args[0], pid, hostname);
317: if (execvp(args[0], (char **)args) < 0) {
318: perror("Unable to start debugger");
319: exit(0);
320: }
321: } else {
322: j = 0;
323: if (UseDebugTerminal) {
324: PetscBool cmp;
325: char *tmp, *tmp1 = NULL;
326: PetscCall(PetscStrncmp(DebugTerminal, "Terminal", 8, &cmp));
327: if (cmp) {
328: char command[1024];
329: if (islldb) PetscCall(PetscSNPrintf(command, sizeof(command), "osascript -e 'tell app \"Terminal\" to do script \"lldb -p %s \"'\n", pid));
330: else {
331: char fullprogram[PETSC_MAX_PATH_LEN];
332: PetscCall(PetscGetFullPath(program, fullprogram, sizeof(fullprogram)));
333: PetscCall(PetscSNPrintf(command, sizeof(command), "osascript -e 'tell app \"Terminal\" to do script \"%s %s %s \"'\n", PetscDebugger, fullprogram, pid));
334: }
335: #if PetscDefined(HAVE_POPEN)
336: PetscCall(PetscPOpen(PETSC_COMM_SELF, NULL, command, "r", NULL));
337: #else
338: printf("-debug_terminal Terminal is not available on this system since PETSC_HAVE_POPEN is not defined in this configuration\n");
339: #endif
340: exit(0);
341: }
343: PetscCall(PetscStrncmp(DebugTerminal, "screen", 6, &cmp));
344: if (!cmp) PetscCall(PetscStrncmp(DebugTerminal, "gnome-terminal", 6, &cmp));
345: if (cmp) display[0] = 0; /* when using screen, we never pass -display */
346: args[j++] = tmp = DebugTerminal;
347: if (display[0]) {
348: args[j++] = "-display";
349: args[j++] = display;
350: }
351: while (*tmp) {
352: PetscCall(PetscStrchr(tmp, ' ', &tmp1));
353: if (!tmp1) break;
354: *tmp1 = 0;
355: tmp = tmp1 + 1;
356: args[j++] = tmp;
357: }
358: }
359: args[j++] = PetscDebugger;
360: jj = j;
361: /* this is for default gdb */
362: args[j++] = program;
363: args[j++] = pid;
364: args[j++] = NULL;
366: if (isidb) {
367: j = jj;
368: args[j++] = "-pid";
369: args[j++] = pid;
370: args[j++] = "-gdb";
371: args[j++] = program;
372: args[j++] = NULL;
373: }
374: if (islldb) {
375: j = jj;
376: args[j++] = "-p";
377: args[j++] = pid;
378: args[j++] = NULL;
379: }
380: if (isdbx) {
381: j = jj;
382: #if PetscDefined(USE_P_FOR_DEBUGGER)
383: args[j++] = "-p";
384: args[j++] = pid;
385: args[j++] = program;
386: #elif PetscDefined(USE_LARGEP_FOR_DEBUGGER)
387: args[j++] = "-l";
388: args[j++] = "ALL";
389: args[j++] = "-P";
390: args[j++] = pid;
391: args[j++] = program;
392: #elif PetscDefined(USE_A_FOR_DEBUGGER)
393: args[j++] = "-a";
394: args[j++] = pid;
395: #elif PetscDefined(USE_PID_FOR_DEBUGGER)
396: args[j++] = "-pid";
397: args[j++] = pid;
398: args[j++] = program;
399: #else
400: args[j++] = program;
401: args[j++] = pid;
402: #endif
403: args[j++] = NULL;
404: }
405: if (UseDebugTerminal) {
406: if (display[0]) printf("PETSC: Attaching %s to %s of pid %s on display %s on machine %s\n", PetscDebugger, program, pid, display, hostname);
407: else printf("PETSC: Attaching %s to %s on pid %s on %s\n", PetscDebugger, program, pid, hostname);
409: if (execvp(args[0], (char **)args) < 0) {
410: perror("Unable to start debugger in xterm");
411: exit(0);
412: }
413: } else {
414: printf("PETSC: Attaching %s to %s of pid %s on %s\n", PetscDebugger, program, pid, hostname);
415: if (execvp(args[0], (char **)args) < 0) {
416: perror("Unable to start debugger");
417: exit(0);
418: }
419: }
420: }
421: } else { /* I am the child, continue with user code */
422: sleeptime = 10; /* default to sleep waiting for debugger */
423: PetscCall(PetscOptionsGetReal(NULL, NULL, "-debugger_pause", &sleeptime, NULL));
424: if (sleeptime < 0) sleeptime = -sleeptime;
425: PetscCall(PetscSleep(sleeptime));
426: }
427: #endif
428: return PETSC_SUCCESS;
429: }
431: /*@
432: PetscAttachDebuggerErrorHandler - Error handler that attaches
433: a debugger to a running process when an error is detected.
434: This routine is useful for examining variables, etc.
436: Not Collective, No Fortran Support
438: Input Parameters:
439: + comm - communicator over which error occurred
440: . line - the line number of the error (usually indicated by `__LINE__` in the calling routine)
441: . fun - the function name of the calling routine
442: . file - the file in which the error was detected (usually indicated by `__FILE__` in the calling routine)
443: . mess - an error text string, usually just printed to the screen
444: . num - the generic error number
445: . p - `PETSC_ERROR_INITIAL` if error just detected, otherwise `PETSC_ERROR_REPEAT`
446: - ctx - error handler context
448: Level: developer
450: Notes:
451: By default the GNU debugger, gdb, is used except on macOS where lldb is used. Alternatives are cuda-gdb, lldb, dbx,
452: xxgdb, and xdb (on HP-UX).
454: Most users need not directly employ this routine and the other error
455: handlers, but can instead use the simplified interface SETERR, which has
456: the calling sequence
457: .vb
458: SETERRQ(PETSC_COMM_SELF, number, p, message)
459: .ve
461: Use `PetscPushErrorHandler()` to set the desired error handler. The
462: currently available PETSc error handlers are
463: .vb
464: PetscTraceBackErrorHandler()
465: PetscAttachDebuggerErrorHandler()
466: PetscAbortErrorHandler()
467: .ve
468: or you may write your own.
470: Developer Note:
471: This routine calls abort instead of returning because if it returned then `MPI_Abort()` would get called which can generate an exception
472: causing the debugger to be attached again in a cycle.
474: .seealso: `PetscSetDebuggerFromString()`, `PetscSetDebugger()`, `PetscSetDefaultDebugger()`, `PetscError()`, `PetscPushErrorHandler()`, `PetscPopErrorHandler()`, `PetscTraceBackErrorHandler()`,
475: `PetscAbortErrorHandler()`, `PetscMPIAbortErrorHandler()`, `PetscEmacsClientErrorHandler()`, `PetscReturnErrorHandler()`, `PetscSetDebugTerminal()`
476: @*/
477: PetscErrorCode PetscAttachDebuggerErrorHandler(MPI_Comm comm, int line, const char *fun, const char *file, PetscErrorCode num, PetscErrorType p, const char *mess, PetscCtx ctx)
478: {
479: (void)comm;
480: (void)num;
481: (void)p;
482: (void)ctx;
483: if (!mess) mess = " ";
485: if (fun) (void)(*PetscErrorPrintf)("%s() at %s:%d %s\n", fun, file, line, mess);
486: else (void)(*PetscErrorPrintf)("%s:%d %s\n", file, line, mess);
488: (void)PetscAttachDebugger();
489: abort(); /* call abort because don't want to kill other MPI processes that may successfully attach to debugger */
490: PetscFunctionReturn(PETSC_SUCCESS);
491: }
493: /*@
494: PetscStopForDebugger - Prints a message to the screen indicating how to
495: attach to the process with the debugger and then waits for the
496: debugger to attach.
498: Not Collective, No Fortran Support
500: Options Database Key:
501: . -stop_for_debugger - will stop for you to attach the debugger when `PetscInitialize()` is called
503: Level: developer
505: Note:
506: This is likely never needed since `PetscAttachDebugger()` is easier to use and seems to always work.
508: Developer Note:
509: Since this can be called by the error handler, should it be calling `SETERRQ()` and `PetscCall()`?
511: .seealso: `PetscSetDebugger()`, `PetscAttachDebugger()`
512: @*/
513: PetscErrorCode PetscStopForDebugger(void)
514: {
515: PetscErrorCode ierr;
516: PetscReal sleeptime = 0;
517: #if !PetscDefined(CANNOT_START_DEBUGGER)
518: int ppid;
519: PetscMPIInt rank;
520: char program[PETSC_MAX_PATH_LEN], hostname[256];
521: PetscBool isdbx, isxxgdb, isddd, iskdbg, isups, isxdb, islldb;
522: #endif
524: PetscFunctionBegin;
525: #if PetscDefined(CANNOT_START_DEBUGGER)
526: PetscCall((*PetscErrorPrintf)("System cannot start debugger; just continuing program\n"));
527: #else
528: if (MPI_Comm_rank(PETSC_COMM_WORLD, &rank)) rank = 0; /* ignore error since this may be already in error handler */
529: ierr = PetscGetHostName(hostname, sizeof(hostname));
530: if (ierr) {
531: PetscCall((*PetscErrorPrintf)("Cannot determine hostname; just continuing program\n"));
532: PetscFunctionReturn(PETSC_SUCCESS);
533: }
535: ierr = PetscGetProgramName(program, sizeof(program));
536: if (ierr) {
537: PetscCall((*PetscErrorPrintf)("Cannot determine program name; just continuing program\n"));
538: PetscFunctionReturn(PETSC_SUCCESS);
539: }
540: if (!program[0]) {
541: PetscCall((*PetscErrorPrintf)("Cannot determine program name; just continuing program\n"));
542: PetscFunctionReturn(PETSC_SUCCESS);
543: }
545: ppid = getpid();
547: PetscCall(PetscStrcmp(PetscDebugger, "xxgdb", &isxxgdb));
548: PetscCall(PetscStrcmp(PetscDebugger, "ddd", &isddd));
549: PetscCall(PetscStrcmp(PetscDebugger, "kdbg", &iskdbg));
550: PetscCall(PetscStrcmp(PetscDebugger, "ups", &isups));
551: PetscCall(PetscStrcmp(PetscDebugger, "xdb", &isxdb));
552: PetscCall(PetscStrcmp(PetscDebugger, "dbx", &isdbx));
553: PetscCall(PetscStrcmp(PetscDebugger, "lldb", &islldb));
555: if (isxxgdb || isups || isddd || iskdbg) printf("[%d]%s>>%s %s %d\n", rank, hostname, PetscDebugger, program, ppid);
556: else if (islldb) printf("[%d]%s>>%s -p %d\n", rank, hostname, PetscDebugger, ppid);
557: else if (isdbx) {
558: #if PetscDefined(USE_P_FOR_DEBUGGER)
559: printf("[%d]%s>>%s -p %d %s\n", rank, hostname, PetscDebugger, ppid, program);
560: #elif PetscDefined(USE_LARGEP_FOR_DEBUGGER)
561: printf("[%d]%s>>%s -l ALL -P %d %s\n", rank, hostname, PetscDebugger, ppid, program);
562: #elif PetscDefined(USE_A_FOR_DEBUGGER)
563: printf("[%d]%s>>%s -a %d\n", rank, hostname, PetscDebugger, ppid);
564: #elif PetscDefined(USE_PID_FOR_DEBUGGER)
565: printf("[%d]%s>>%s -pid %d %s\n", rank, hostname, PetscDebugger, ppid, program);
566: #else
567: printf("[%d]%s>>%s %s %d\n", rank, hostname, PetscDebugger, program, ppid);
568: #endif
569: }
570: #endif /* PETSC_CANNOT_START_DEBUGGER */
572: fflush(stdout); /* ignore error because may already be in error handler */
574: sleeptime = 25; /* default to sleep waiting for debugger */
575: PetscCallContinue(PetscOptionsGetReal(NULL, NULL, "-debugger_pause", &sleeptime, NULL)); /* ignore error because may already be in error handler */
576: if (sleeptime < 0) sleeptime = -sleeptime;
577: PetscCall(PetscSleep(sleeptime));
578: PetscFunctionReturn(PETSC_SUCCESS);
579: }