ATLAS Offline Software
Loading...
Searching...
No Matches
stackstash.h File Reference
#include <stddef.h>
Include dependency graph for stackstash.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  StackHandle_
 Unique reference for a stack trace. More...
struct  StackNode_
 Node used to store trace data. More...
struct  StackCursor_
 Cursor object used to move between nodes of the tree. More...

Macros

#define STACK_ELEMENT_BEGIN_P(element)
 Is the element pointed to by ELEMENT the first one in its node?
#define STACK_ELEMENT_NODE(element)
 ELEMENT should be a pointer to the first element in a node.
#define STACK_ELEMENT_NODEPARENT(element)
 ELEMENT should be a pointer to the first element in a node.
#define STACK_NODE_NTH_ELEMENT(node, n)
 Return the Nth element stored in a node.
#define STACK_NODE_NTH_CHILD(node, n)
 Return a pointer to the Nth child stored in a node.
#define STACK_ELEMENT_NONNULL(elt)
 We can't store a null element in a trace; fold them to 1.
#define STACK_NODE_SET_ELEMENT(node, n, elt)
 Set the Nth element stored in a node.
#define STACK_HANDLE_ELEMENT(handle)
 Return a pointer to the first element in the handle's trace.
#define STACK_HANDLE_ADDR(handle)
 Return the first element in the handle's trace.
#define STACK_HANDLE_PARENT(handle)
 Return a pointer to the second in the handle's trace.
#define STACK_HANDLE_IS_ROOT(handle)
 Test to see if a handle represents the root of the call tree.
#define STACK_ELEMENT_ADDR(element)
 Given a pointer to an element, return the element.
#define STACK_ELEMENT_PARENT(element)
 Given a pointer to an element, return a pointer to the element's parent.
#define STACK_ELEMENT_IS_ROOT(element)
 Test if an element is the root of trace.
#define STACK_CURSOR_ELEMENT(cursor)
 Return the address of the element referenced by the cursor.
#define STACK_CURSOR_ELEMENT_ADDR(cursor)
 Return the element referenced by the cursor.
#define STACK_CURSOR_INIT_ROOT(cursor)
 Initialize a cursor to point at the root of the tree.
#define STACK_CURSOR_INIT_HANDLE(cursor, handle)
 Initialize a cursor from a handle.
#define STACK_CURSOR_IS_ROOT(cursor)
 Does the cursor reference the root of the tree?
#define STACK_CURSOR_PARENT(cursor)
 Move to the cursor to the parent node.
#define STACK_CURSOR_NCHILDREN(cursor)
 Return the number of children.
#define STACK_CURSOR_CHILD(cursor, n)
 Move to the cursor to the nth child.
#define STACK_CURSOR_NEXT(cursor)
 Visit next element in depth-first order.

Typedefs

typedef void * StackElement
 One element of a stack trace.
typedef struct StackHandle_ StackHandle
typedef struct StackNode_ StackNode
typedef struct StackCursor_ StackCursor

Functions

StackHandlehhh_stackstash_store (const StackElement *addresses, int n_addresses)
 Return the handle for a stack trace.
StackElementhhh_stack_element_parent (StackElement *elt)
 Function interface to iterate over a trace.
void hhh_Cursor_initRoot (StackCursor *cursor)
 Initialize a cursor to point at the root of the tree.
void hhh_Cursor_initHandle (StackCursor *cursor, StackHandle *handle)
 Initialize a cursor from a handle.
void hhh_Cursor_parent (StackCursor *cursor)
 Move to the cursor to the parent node.
void hhh_Cursor_child (StackCursor *cursor, int n)
 Move to the cursor to the nth child.
int hhh_Cursor_nchildren (StackCursor *cursor)
 Return the number of children.
void hhh_Cursor_next (StackCursor *cursor)
 Visit next element in depth-first order.

Macro Definition Documentation

◆ STACK_CURSOR_CHILD

#define STACK_CURSOR_CHILD ( cursor,
n )
Value:
hhh_Cursor_child(&cursor, n)
void hhh_Cursor_child(StackCursor *cursor, int n)
Move to the cursor to the nth child.

Move to the cursor to the nth child.

Definition at line 252 of file stackstash.h.

◆ STACK_CURSOR_ELEMENT

#define STACK_CURSOR_ELEMENT ( cursor)
Value:
((cursor).elt)

Return the address of the element referenced by the cursor.

Definition at line 231 of file stackstash.h.

◆ STACK_CURSOR_ELEMENT_ADDR

#define STACK_CURSOR_ELEMENT_ADDR ( cursor)
Value:
#define STACK_CURSOR_ELEMENT(cursor)
Return the address of the element referenced by the cursor.
Definition stackstash.h:231
#define STACK_ELEMENT_ADDR(element)
Given a pointer to an element, return the element.
Definition stackstash.h:217

Return the element referenced by the cursor.

Definition at line 234 of file stackstash.h.

◆ STACK_CURSOR_INIT_HANDLE

#define STACK_CURSOR_INIT_HANDLE ( cursor,
handle )
Value:
hhh_Cursor_initHandle(&cursor, handle)
void hhh_Cursor_initHandle(StackCursor *cursor, StackHandle *handle)
Initialize a cursor from a handle.

Initialize a cursor from a handle.

Definition at line 240 of file stackstash.h.

◆ STACK_CURSOR_INIT_ROOT

#define STACK_CURSOR_INIT_ROOT ( cursor)
Value:
void hhh_Cursor_initRoot(StackCursor *cursor)
Initialize a cursor to point at the root of the tree.

Initialize a cursor to point at the root of the tree.

Definition at line 237 of file stackstash.h.

◆ STACK_CURSOR_IS_ROOT

#define STACK_CURSOR_IS_ROOT ( cursor)
Value:
#define STACK_ELEMENT_IS_ROOT(element)
Test if an element is the root of trace.
Definition stackstash.h:224

Does the cursor reference the root of the tree?

Definition at line 243 of file stackstash.h.

◆ STACK_CURSOR_NCHILDREN

#define STACK_CURSOR_NCHILDREN ( cursor)
Value:
int hhh_Cursor_nchildren(StackCursor *cursor)
Return the number of children.

Return the number of children.

Definition at line 249 of file stackstash.h.

◆ STACK_CURSOR_NEXT

#define STACK_CURSOR_NEXT ( cursor)
Value:
void hhh_Cursor_next(StackCursor *cursor)
Visit next element in depth-first order.

Visit next element in depth-first order.

Definition at line 255 of file stackstash.h.

◆ STACK_CURSOR_PARENT

#define STACK_CURSOR_PARENT ( cursor)
Value:
void hhh_Cursor_parent(StackCursor *cursor)
Move to the cursor to the parent node.

Move to the cursor to the parent node.

Definition at line 246 of file stackstash.h.

◆ STACK_ELEMENT_ADDR

#define STACK_ELEMENT_ADDR ( element)
Value:
(*(element))

Given a pointer to an element, return the element.

Definition at line 217 of file stackstash.h.

◆ STACK_ELEMENT_BEGIN_P

#define STACK_ELEMENT_BEGIN_P ( element)
Value:
(*((element)-1) == 0)

Is the element pointed to by ELEMENT the first one in its node?

Definition at line 164 of file stackstash.h.

◆ STACK_ELEMENT_IS_ROOT

#define STACK_ELEMENT_IS_ROOT ( element)
Value:
(*(element) == 0)

Test if an element is the root of trace.

Definition at line 224 of file stackstash.h.

◆ STACK_ELEMENT_NODE

#define STACK_ELEMENT_NODE ( element)
Value:
((StackNode*)((char*)((element)-1) - offsetof(StackNode, p)))
struct StackNode_ StackNode
Definition stackstash.h:102

ELEMENT should be a pointer to the first element in a node.

Returns a pointer to the node itself.

Definition at line 168 of file stackstash.h.

168#define STACK_ELEMENT_NODE(element) \
169 ((StackNode*)((char*)((element)-1) - offsetof(StackNode, p)))

◆ STACK_ELEMENT_NODEPARENT

#define STACK_ELEMENT_NODEPARENT ( element)
Value:
(STACK_ELEMENT_NODE(element)->parent)
#define STACK_ELEMENT_NODE(element)
ELEMENT should be a pointer to the first element in a node.
Definition stackstash.h:168

ELEMENT should be a pointer to the first element in a node.

Returns a pointer to the parent of this node.

Definition at line 173 of file stackstash.h.

◆ STACK_ELEMENT_NONNULL

#define STACK_ELEMENT_NONNULL ( elt)
Value:
((elt) ? (elt) : (StackElement)1)
void * StackElement
One element of a stack trace.
Definition stackstash.h:74

We can't store a null element in a trace; fold them to 1.

Definition at line 183 of file stackstash.h.

◆ STACK_ELEMENT_PARENT

#define STACK_ELEMENT_PARENT ( element)
Value:
StackElement * hhh_stack_element_parent(StackElement *elt)
Function interface to iterate over a trace.

Given a pointer to an element, return a pointer to the element's parent.

Gives 0 if element referred to the root.

Definition at line 221 of file stackstash.h.

◆ STACK_HANDLE_ADDR

#define STACK_HANDLE_ADDR ( handle)
Value:
#define STACK_HANDLE_ELEMENT(handle)
Return a pointer to the first element in the handle's trace.
Definition stackstash.h:198

Return the first element in the handle's trace.

Definition at line 201 of file stackstash.h.

201#define STACK_HANDLE_ADDR(handle) \
202 STACK_ELEMENT_ADDR(STACK_HANDLE_ELEMENT(handle))

◆ STACK_HANDLE_ELEMENT

#define STACK_HANDLE_ELEMENT ( handle)
Value:
((handle)->element)

Return a pointer to the first element in the handle's trace.

Definition at line 198 of file stackstash.h.

◆ STACK_HANDLE_IS_ROOT

#define STACK_HANDLE_IS_ROOT ( handle)
Value:

Test to see if a handle represents the root of the call tree.

Definition at line 209 of file stackstash.h.

209#define STACK_HANDLE_IS_ROOT(handle) \
210 STACK_ELEMENT_IS_ROOT(STACK_HANDLE_ELEMENT(handle))

◆ STACK_HANDLE_PARENT

#define STACK_HANDLE_PARENT ( handle)
Value:
#define STACK_ELEMENT_PARENT(element)
Given a pointer to an element, return a pointer to the element's parent.
Definition stackstash.h:221

Return a pointer to the second in the handle's trace.

Definition at line 205 of file stackstash.h.

205#define STACK_HANDLE_PARENT(handle) \
206 STACK_ELEMENT_PARENT(STACK_HANDLE_ELEMENT(handle))

◆ STACK_NODE_NTH_CHILD

#define STACK_NODE_NTH_CHILD ( node,
n )
Value:
(*(StackNode**)&((node)->p[n+1+(node)->nelts]))
Definition node.h:24

Return a pointer to the Nth child stored in a node.

Definition at line 179 of file stackstash.h.

179#define STACK_NODE_NTH_CHILD(node, n) \
180 (*(StackNode**)&((node)->p[n+1+(node)->nelts]))

◆ STACK_NODE_NTH_ELEMENT

#define STACK_NODE_NTH_ELEMENT ( node,
n )
Value:
((node)->p[n+1])

Return the Nth element stored in a node.

Definition at line 176 of file stackstash.h.

◆ STACK_NODE_SET_ELEMENT

#define STACK_NODE_SET_ELEMENT ( node,
n,
elt )
Value:
do{ (node)->p[n+1] = STACK_ELEMENT_NONNULL(elt); } while(0)
#define STACK_ELEMENT_NONNULL(elt)
We can't store a null element in a trace; fold them to 1.
Definition stackstash.h:183

Set the Nth element stored in a node.

Definition at line 186 of file stackstash.h.

Typedef Documentation

◆ StackCursor

typedef struct StackCursor_ StackCursor

Definition at line 114 of file stackstash.h.

◆ StackElement

typedef void* StackElement

One element of a stack trace.

Definition at line 74 of file stackstash.h.

◆ StackHandle

typedef struct StackHandle_ StackHandle

Definition at line 86 of file stackstash.h.

◆ StackNode

typedef struct StackNode_ StackNode

Definition at line 102 of file stackstash.h.

Function Documentation

◆ hhh_Cursor_child()

void hhh_Cursor_child ( StackCursor * cursor,
int n )

Move to the cursor to the nth child.

◆ hhh_Cursor_initHandle()

void hhh_Cursor_initHandle ( StackCursor * cursor,
StackHandle * handle )

Initialize a cursor from a handle.

◆ hhh_Cursor_initRoot()

void hhh_Cursor_initRoot ( StackCursor * cursor)

Initialize a cursor to point at the root of the tree.

◆ hhh_Cursor_nchildren()

int hhh_Cursor_nchildren ( StackCursor * cursor)

Return the number of children.

◆ hhh_Cursor_next()

void hhh_Cursor_next ( StackCursor * cursor)

Visit next element in depth-first order.

◆ hhh_Cursor_parent()

void hhh_Cursor_parent ( StackCursor * cursor)

Move to the cursor to the parent node.

◆ hhh_stack_element_parent()

StackElement * hhh_stack_element_parent ( StackElement * elt)

Function interface to iterate over a trace.

Parameters
eltPointer to an element of a trace.

Returns a pointer to the previous element of the trace (the caller). Returns 0 if we're at the root of the trace.

◆ hhh_stackstash_store()

StackHandle * hhh_stackstash_store ( const StackElement * addresses,
int n_addresses )

Return the handle for a stack trace.

Parameters
addressesStack trace to store.
n_addressesLength of the trace.

Returns the unique Handle object representing this trace. If this trace has been seen before, the existing Handle object will be returned; otherwise, a new Handle object will be made and returned.