2
3
4
5
6
8#ifndef GIMBAL_CALL_STACK_H
9#define GIMBAL_CALL_STACK_H
11#include "../core/gimbal_result.h"
42 uint32_t sourceCurrentCaptureDepth;
50GBL_INLINE void GblCallRecord_construct (GblCallRecord* pRecord,
51 GBL_RESULT resultCode,
52 GblSourceLocation source,
55GBL_INLINE GBL_RESULT GblStackFrame_construct (GblStackFrame* pFrame,
68GBL_EXPORT GBL_RESULT GblContext_memAlloc_ (GblContext* pSelf,
69 const GblStackFrame* pFrame,
75GBL_EXPORT GBL_RESULT GblContext_memRealloc_ (GblContext* pSelf,
76 const GblStackFrame* pFrame,
82GBL_EXPORT GBL_RESULT GblContext_memFree_ (GblContext* pSelf,
83 const GblStackFrame* pFrame,
86GBL_EXPORT GBL_RESULT GblContext_logWrite_ (GblContext* pSelf,
87 const GblStackFrame* pFrame,
92GBL_EXPORT GBL_RESULT GblContext_logPush_ (GblContext* pSelf,
95GBL_EXPORT GBL_RESULT GblContext_logPop_ (GblContext* pSelf,
96 const GblStackFrame* pFrame,
99GBL_EXPORT GBL_RESULT GblContext_callRecordSet_ (GblContext* pSelf,
100 const GblStackFrame* pFrame,
105GBL_INLINE void GblCallRecord_construct(GblCallRecord* pRecord, GBL_RESULT resultCode, GblSourceLocation source,
const char* pFmt, ...)
GBL_NOEXCEPT {
107 va_start(varArgs, pFmt);
108 pRecord
->result = GBL_RESULT_UNKNOWN;
109 pRecord->message[0] =
'\0';
111 if GBL_UNLIKELY(pFmt) vsprintf(pRecord->message, pFmt, varArgs);
117GBL_INLINE GBL_RESULT GblStackFrame_construct(GblStackFrame* pFrame, GblObject* pObject, GBL_RESULT initialResult)
GBL_NOEXCEPT {
118 GBL_RESULT result = GBL_RESULT_SUCCESS;
122 const GblStackFrame* pPrev = GblThd_stackFrameTop(NULL);
123 if GBL_LIKELY(pPrev && pPrev->pObject == pObject) {
124 pContext = pPrev->pContext;
131 pContext = GblThd_context(NULL);
134 pFrame->record.srcLocation.pFile =
GBL_NULL;
135 pFrame->record.srcLocation.pFunc =
GBL_NULL;
136 pFrame->record.result = initialResult;
137 pFrame->stackDepth = 0;
138 pFrame->sourceCurrentCaptureDepth = 0;
139 pFrame->pObject = pObject;
140 pFrame->pContext = pContext;
141 pFrame->pPrevFrame = NULL;
#define GBL_UNLIKELY(exp)
#define GBL_FORWARD_DECLARE_STRUCT(S)
GblContext * GblObject_findContext(GblObject *pSelf)
uint32_t GblFlags
Standard-sized flags type, 32-bits across platforms.
Captures a result, its stringified message, and a source context.
GblSourceLocation srcLocation
Source location where the result + message had been set.
GBL_RESULT result
Result code from a previous stack frame.
Source code context (file, function, line)
const char * pFile
Current Source file.
const char * pFunc
Current function.
size_t line
Current line of code.
Represents a single function's stack frame, from GBL_CTX_BEGIN() to GBL_CTX_END()