MCPcopy Create free account
hub / github.com/alliedmodders/sourcemod / GetStackTrace

Method GetStackTrace

core/logic/DebugReporter.cpp:167–209  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

165}
166
167std::vector<std::string> DebugReport::GetStackTrace(IFrameIterator *iter)
168{
169 char temp[3072];
170 std::vector<std::string> trace;
171 iter->Reset();
172
173 if (!iter->Done())
174 {
175 trace.push_back("[SM] Call stack trace:");
176
177 for (int index = 0; !iter->Done(); iter->Next(), index++)
178 {
179 const char *fn = iter->FunctionName();
180 if (!fn)
181 {
182 fn = "<unknown function>";
183 }
184 if (iter->IsNativeFrame())
185 {
186 g_pSM->Format(temp, sizeof(temp), "[SM] [%d] %s", index, fn);
187 trace.push_back(temp);
188 continue;
189 }
190 if (iter->IsScriptedFrame())
191 {
192 const char *file = iter->FilePath();
193 if (!file)
194 {
195 file = "<unknown>";
196 }
197 g_pSM->Format(temp, sizeof(temp), "[SM] [%d] Line %d, %s::%s",
198 index,
199 iter->LineNumber(),
200 file,
201 fn);
202
203 trace.push_back(temp);
204 }
205 }
206 }
207
208 return trace;
209}

Callers 1

LogStackTraceFunction · 0.80

Calls 8

DoneMethod · 0.80
push_backMethod · 0.80
FunctionNameMethod · 0.80
FormatMethod · 0.80
FilePathMethod · 0.80
ResetMethod · 0.45
NextMethod · 0.45
LineNumberMethod · 0.45

Tested by

no test coverage detected