libGimbal 0.1.0
C17-Based Extended Standard Library and Cross-Language Runtime Framework
Loading...
Searching...
No Matches
gimbal_stack_frame.h File Reference

Go to the source code of this file.

Data Structures

struct  GblSourceLocation
 
struct  GblCallRecord
 
struct  GblStackFrame
 

Functions

static void GblCallRecord_construct (GblCallRecord *pRecord, GBL_RESULT resultCode, GblSourceLocation source, const char *pFmt,...)
 
static GBL_RESULT GblStackFrame_construct (GblStackFrame *pFrame, GblObject *pObject, GBL_RESULT initialResult)
 

Detailed Description

Stack frame, call record, source capture debug utilities.

Author
Falco Girgis

Definition in file gimbal_stack_frame.h.

Function Documentation

◆ GblCallRecord_construct()

static void GblCallRecord_construct ( GblCallRecord * pRecord,
GBL_RESULT resultCode,
GblSourceLocation source,
const char * pFmt,
... )
inlinestatic

Definition at line 105 of file gimbal_stack_frame.h.

105 {
106 va_list varArgs;
107 va_start(varArgs, pFmt);
108 pRecord->result = GBL_RESULT_UNKNOWN;
109 pRecord->message[0] = '\0';
110 pRecord->srcLocation.pFile = pRecord->srcLocation.pFunc = GBL_NULL;
111 if GBL_UNLIKELY(pFmt) vsprintf(pRecord->message, pFmt, varArgs);
112 va_end(varArgs);
113 pRecord->srcLocation = source;
114 pRecord->result = resultCode;
115}
GblSourceLocation srcLocation
Source location where the result + message had been set.
GBL_RESULT result
Result code from a previous stack frame.
const char * pFile
Current Source file.
const char * pFunc
Current function.

◆ GblStackFrame_construct()

static GBL_RESULT GblStackFrame_construct ( GblStackFrame * pFrame,
GblObject * pObject,
GBL_RESULT initialResult )
inlinestatic

Definition at line 117 of file gimbal_stack_frame.h.

117 {
118 GBL_RESULT result = GBL_RESULT_SUCCESS;
119 GblContext* pContext = GBL_NULL;
120
121 if GBL_UNLIKELY(pObject) {
122 const GblStackFrame* pPrev = GblThd_stackFrameTop(NULL);
123 if GBL_LIKELY(pPrev && pPrev->pObject == pObject) {
124 pContext = pPrev->pContext;
125 } else {
126 pContext = GblObject_findContext(pObject);
127 }
128 }
129
130 if GBL_LIKELY(!pContext) {
131 pContext = GblThd_context(NULL);
132 }
133
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;
142 return result;
143}
GblContext * GblObject_findContext(GblObject *pSelf)
GBL_RESULT
Top-level context object.
Represents a single function's stack frame, from GBL_CTX_BEGIN() to GBL_CTX_END()