PetscStack#

Fixed-size record of the chain of PETSc functions that are currently active on the calling thread; maintained by PetscFunctionBegin/PetscFunctionReturn to provide meaningful PETSc-level back traces and to drive the SAWs stack viewer

Synopsis#

typedef struct {
  const char *function[PETSCSTACKSIZE];
  const char *file[PETSCSTACKSIZE];
  int         line[PETSCSTACKSIZE];
  int         petscroutine[PETSCSTACKSIZE]; /* 0 external called from PETSc, 1 PETSc functions, 2 PETSc user functions */
  int         currentsize;
  int         hotdepth;
  PetscBool3  check; /* check Push/Pop semantics; UNKNOWN initializes petscstack from the process-wide default */
} PetscStack;

Notes#

The default stack is a global variable called petscstack. It is maintained only when PETSc is configured --with-debugging; otherwise the stack-manipulation macros become no-ops. With thread safety enabled, petscstack is declared with PETSC_TLS, which gives each thread its own instance using thread-local storage. Inspect a stack with PetscStackView() or PetscStackViewSAWs().

Only the first PETSCSTACKSIZE frames are stored; the currentsize field counts all active calls, including frames that are not stored, so that the stack unwinds correctly.

See Also#

PetscFunctionBegin, PetscFunctionBeginUser, PetscFunctionReturn(), PetscStackView(), PetscStackViewSAWs(), PetscMallocGetStack(), PETSC_TLS

Level#

developer

Location#

include/petscerror.h

Examples#

src/sys/tests/ex33.c


Index of all Sys routines
Table of Contents for all manual pages
Index of all manual pages