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(pFmt) GBL_UNLIKELY 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(pObject) GBL_UNLIKELY {
122 const GblStackFrame* pPrev = GblThd_stackFrameTop(NULL);
123 if(pPrev && pPrev->pObject == pObject) GBL_LIKELY {
124 pContext = pPrev->pContext;
125 } else GBL_UNLIKELY {
126 pContext = GblObject_findContext(pObject);
127 }
128 }
129
130 if(!pContext) GBL_LIKELY {
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}
GBL_RESULT
Top-level context object.
Represents a single function's stack frame, from GBL_CTX_BEGIN() to GBL_CTX_END()