The restrictions on function calls and show_self are
as follows:
- They cannot call exec().
- They cannot terminate either the thread or the process.
- They cannot raise a signal.
- They cannot call longjmp() unless the target
of longjmp() is within the function.
- They cannot raise a C++ exception unless the exception is handled
within the function.
- They must terminate within a reasonable amount of time. This can
be controlled with the DER_DBG_SHOWSELF_TIMEOUT environment
variable. The default value is 10 seconds.
- In a multithreaded application, the function cannot make assumptions
about which thread it is running on - and it and must assume that
all other threads in the process have been suspended. In particular:
- It cannot depend on other threads, and must assume that other
threads may be holding required resources. Specifically, calling pthread_mutex_lock() may
cause the function to hang.
- Not all C/C++ library functions are reentrant. Many thread-safe
functions in libc.a, including the memory allocation
and input/output functions, are not reentrant. They are serially
reusable. These functions use pthread_mutex_lock() to
implement the serial reusability, so calling them does have a low
probability of hanging the debug session.
- All changes that the function makes to the global state of the
process being debugged will continue after the function returns.
- The effects of calling pthread_create() are undefined.
- The show_self function includes calls that direct
output to the console. These calls include printf(), fprintf() and
the cout class. The debugger runs the show_self function
on one arbitrary thread of the debuggee when evaluating these functions,
while all other threads are frozen. Therefore, any calls requiring
that other threads be running will fail.
- Calls that output to the console fail in a relatively benign way,
as there is simply no output.
- There is a small chance of getting into a deadlock, as many C/C++
library functions (including the input/output and memory allocation
functions) need to call non-reentrant code that is protected by a
mutex.
- The function cannot call or exec() -
and it cannot terminate the thread
The debugger will attempt to recover should one of these restrictions
not be met. However, it cannot guarantee that the state of the application
being debugged will not be irrevocably changed.