Basic API

These functions are for getting the C stack of a thread once.

stacktrace.print_stack([file, maxdepth, …]) Print the stack of the current thread.
stacktrace.print_thread_stack(tid[, file, …]) Print the stack of the target thread
stacktrace.get_thread_stack(tid[, maxdepth, …]) Get the stack of the target thread
stacktrace.print_stack(file=None, maxdepth=100, show_python=True, _bufsize=4096)[source]

Print the stack of the current thread.

Parameters:
file : fileobj

The file object to print to. Defaults to sys.stdout.

maxdepth : int

Maximum stack depth.

show_python : bool

Whether to filter out python stack entries.

stacktrace.print_thread_stack(tid, file=None, maxdepth=100, show_python=True)[source]

Print the stack of the target thread

Parameters:
tid : int

The target thread-id.

file : fileobj

The file object to print to. Defaults to sys.stdout.

maxdepth : int

Maximum stack depth.

show_python : bool

Whether to filter out python stack entries.

stacktrace.get_thread_stack(tid, maxdepth=100, show_python=True)[source]

Get the stack of the target thread

Parameters:
tid : int

The target thread-id.

file : fileobj

The file object to print to. Defaults to sys.stdout.

maxdepth : int

Maximum stack depth.

show_python : bool

Whether to filter out python stack entries.

Returns:
stacktrace : list

A list of namedtuples (addr, name, offset, is_python)