C Configuration Space and Tuning Library (CCS)
Loading...
Searching...
No Matches
Data Structures | Typedefs | Functions
error_stack.h File Reference

CCS rich error reporting. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  ccs_error_stack_elem_s
 An element of stack. More...
 

Typedefs

typedef struct ccs_error_stack_elem_s ccs_error_stack_elem_t
 A commodity type to represent a CCS stack element.
 

Functions

ccs_error_stack_t ccs_get_thread_error (void)
 Transfers ownership of thread error stack from CCS to the user.
 
ccs_result_t ccs_set_thread_error (ccs_error_stack_t error_stack)
 Transfers ownership of error stack from the user to CCS.
 
void ccs_clear_thread_error (void)
 Clears the error stack of the calling thread, releasing the current error if it existed.
 
ccs_result_t ccs_create_thread_error (ccs_result_t error_code, const char *msg,...)
 Creates a new error stack and sets it for the current thread, potentially replacing the previous one.
 
ccs_result_t ccs_thread_error_stack_push (const char *file, int line, const char *func)
 Pushes a stack trace element on the thread error stack.
 
ccs_result_t ccs_create_error_stack (ccs_error_stack_t *error_stack_ret, ccs_result_t error_code, const char *msg,...)
 Creates a new error stack object.
 
ccs_result_t ccs_error_stack_push (ccs_error_stack_t error_stack, const char *file, int line, const char *func)
 Pushes a stack trace element in an error stack.
 
ccs_result_t ccs_error_stack_get_message (ccs_error_stack_t error_stack, const char **message_ret)
 Retrieves the message from an error stack.
 
ccs_result_t ccs_error_stack_get_code (ccs_error_stack_t error_stack, ccs_result_t *error_code_ret)
 Retrieves the error code from an error stack.
 
ccs_result_t ccs_error_stack_get_elems (ccs_error_stack_t error_stack, size_t num_elems, ccs_error_stack_elem_t *elems, size_t *num_elems_ret)
 Retrieves the stack elements from an error stack.
 

Detailed Description

CCS rich error reporting.

Function Documentation

◆ ccs_clear_thread_error()

void ccs_clear_thread_error ( void  )
extern

Clears the error stack of the calling thread, releasing the current error if it existed.

Remarks
This function is thread-safe

◆ ccs_create_error_stack()

ccs_result_t ccs_create_error_stack ( ccs_error_stack_t error_stack_ret,
ccs_result_t  error_code,
const char *  msg,
  ... 
)
extern

Creates a new error stack object.

Parameters
[out]error_stack_reta pointer to the variable that will contain the newly created error stack.
[in]error_codethe CCS error code
[in]msga format string for the error message
[in]...a list of optional values to fill the format string
Returns
CCS_RESULT_SUCCESS on success
CCS_RESULT_ERROR_INVALID_VALUE if error_stack_ret is NULL
CCS_RESULT_ERROR_OUT_OF_MEMORY if there was not enough memory to allocate the error stack
Remarks
This function is thread-safe

◆ ccs_create_thread_error()

ccs_result_t ccs_create_thread_error ( ccs_result_t  error_code,
const char *  msg,
  ... 
)
extern

Creates a new error stack and sets it for the current thread, potentially replacing the previous one.

Parameters
[in]error_codethe CCS error code
[in]msga format string for the error message
[in]...a list of optional values to fill the format string
Returns
CCS_RESULT_SUCCESS on success
CCS_RESULT_ERROR_OUT_OF_MEMORY if there was not enough memory to allocate the error stack
Remarks
This function is thread-safe

◆ ccs_error_stack_get_code()

ccs_result_t ccs_error_stack_get_code ( ccs_error_stack_t  error_stack,
ccs_result_t error_code_ret 
)
extern

Retrieves the error code from an error stack.

Parameters
[in]error_stack
[out]error_code_reta pointer to a variable that will contain the error code.
Returns
CCS_RESULT_SUCCESS on success
CCS_RESULT_ERROR_INVALID_OBJECT if error_stack is not a valid CCS error stack
CCS_RESULT_ERROR_INVALID_VALUE if error_code_ret is NULL
Remarks
This function is thread-safe

◆ ccs_error_stack_get_elems()

ccs_result_t ccs_error_stack_get_elems ( ccs_error_stack_t  error_stack,
size_t  num_elems,
ccs_error_stack_elem_t elems,
size_t *  num_elems_ret 
)
extern

Retrieves the stack elements from an error stack.

Parameters
[in]error_stack
[in]num_elemsthe size of the elems array
[out]elemsan array of size num_elems to hold the returned stack elements, or NULL. If the array is too big, extra elements will be zeroed out
[out]num_elems_reta pointer to a variable that will contain the number of stack elements that are or would be returned. Can be NULL
Returns
CCS_RESULT_SUCCESS on success
CCS_RESULT_ERROR_INVALID_OBJECT if error_stack is not a valid CCS error stack
CCS_RESULT_ERROR_INVALID_VALUE if elems is NULL and num_elems is greater than 0; or if elems is NULL and num_elems_ret is NULL; or if num_elems is less than the number of elements that would be returned
Remarks
This function is thread-safe

◆ ccs_error_stack_get_message()

ccs_result_t ccs_error_stack_get_message ( ccs_error_stack_t  error_stack,
const char **  message_ret 
)
extern

Retrieves the message from an error stack.

Parameters
[in]error_stack
[out]message_reta pointer to a variable that will contain the message.
Returns
CCS_RESULT_SUCCESS on success
CCS_RESULT_ERROR_INVALID_OBJECT if error_stack is not a valid CCS error stack
CCS_RESULT_ERROR_INVALID_VALUE if message_ret is NULL
Remarks
This function is thread-safe

◆ ccs_error_stack_push()

ccs_result_t ccs_error_stack_push ( ccs_error_stack_t  error_stack,
const char *  file,
int  line,
const char *  func 
)
extern

Pushes a stack trace element in an error stack.

A call to this function may invalidate pointers obtained previously by ccs_error_stack_get_elems for this error stack.

Parameters
[in,out]error_stack
[in]filethe name of the file
[in]linethe line number
[in]functhe function name
Returns
CCS_RESULT_SUCCESS on success
CCS_RESULT_ERROR_INVALID_OBJECT if error_stack is not a valid CCS error stack
CCS_RESULT_ERROR_OUT_OF_MEMORY if there was not enough memory to allocate new stack elements
Remarks
This function is thread-safe

◆ ccs_get_thread_error()

ccs_error_stack_t ccs_get_thread_error ( void  )
extern

Transfers ownership of thread error stack from CCS to the user.

Returns
the thread specific error stack or NULL if none exist.
Remarks
This function is thread-safe

◆ ccs_set_thread_error()

ccs_result_t ccs_set_thread_error ( ccs_error_stack_t  error_stack)
extern

Transfers ownership of error stack from the user to CCS.

If a previous error was owned by the thread it will be released.

Parameters
[in]error_stackthe error stack to transfer
Returns
CCS_RESULT_SUCCESS on success
CCS_RESULT_ERROR_INVALID_OBJECT if error_stack is not a valid CCS error stack
Remarks
This function is thread-safe

◆ ccs_thread_error_stack_push()

ccs_result_t ccs_thread_error_stack_push ( const char *  file,
int  line,
const char *  func 
)
extern

Pushes a stack trace element on the thread error stack.

Parameters
[in]filethe name of the file
[in]linethe line number
[in]functhe function name
Returns
CCS_RESULT_SUCCESS on success
CCS_RESULT_ERROR_INVALID_OBJECT if the thread has no associated error stack
CCS_RESULT_ERROR_OUT_OF_MEMORY if there was not enough memory to allocate new stack elements
Remarks
This function is thread-safe