Skip to content

callstack.h

mhahnFr edited this page Oct 10, 2022 · 13 revisions

In this header the general access to the library can be found.

struct callstack

The structure of a callstack. It consists of the translation type and status, the backtrace and the translated callstack.

struct callstack * callstack_new(void)

Creates a callstack of the calling function. The backtrace of the calling function is created. The struct is allocated and needs to be freed using the function callstack_delete(struct callstack *.

void callstack_emplace(struct callstack *)

Constructs the given callstack object. Stores the backtrace of the calling function. The callstack object needs to be destructed using the function callstack_delete() after use.

void callstack_emplaceWithBacktrace(struct callstack *, void *[], size_t)

Constructs the given callstack object. Copies the given callstack into the given object. If the trace is longer than CALLSTACK_BACKTRACE_SIZE, only the first addresses are copied. The callstack object needs to be destructed using the function callstack_delete() after use.

char ** callstack_toArray(struct callstack *)

Creates an array of strings out of the backtrace and returns it. The backtrace is only constructed if it has ot already been created. Returns NULL if an error happens.
The returned string array must not be freed.

const char * callstack_toString(struct callstack *, char)

Creates a single string out of the backtrace and returns it. The given separator character is used to separate the lines. The string is allocated and needs to be freed. Returns NULL if an error happens.

size_t callstack_getFrameCount(struct callstack *)

Returns the number of frames stored in the given callstack.

enum callstack_type callstack_getType(struct callstack *)

Returns the type of the given callstack. See callstack_type.h for more information about the possible values.

bool callstack_isTranslated(struct callstack *)

Returns whether the given callstack is already translated.

void callstack_destroy(struct callstack *)

Destroys the contents of the given callstack object.

void callstack_delete(struct callstack *)

Destroys and deallocates the given callstack object.

Clone this wiki locally