MCPcopy Create free account
hub / github.com/Kitware/CMake / GetStackTraceResponse

Function GetStackTraceResponse

Source/cmDebuggerThread.cxx:120–187  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

118}
119
120dap::StackTraceResponse GetStackTraceResponse(
121 std::shared_ptr<cmDebuggerThread> const& thread,
122 dap::optional<dap::StackFrameFormat> format)
123{
124 dap::boolean showParameters = false;
125 dap::boolean showParameterValues = false;
126 dap::boolean showLine = false;
127 if (format.has_value()) {
128 auto formatValue = format.value();
129 if (formatValue.parameters.has_value()) {
130 showParameters = formatValue.parameters.value();
131 }
132
133 if (formatValue.parameterValues.has_value()) {
134 showParameterValues = formatValue.parameterValues.value();
135 }
136
137 if (formatValue.line.has_value()) {
138 showLine = formatValue.line.value();
139 }
140 }
141
142 dap::StackTraceResponse response;
143 std::unique_lock<std::mutex> lock(thread->Mutex);
144 for (int i = static_cast<int>(thread->Frames.size()) - 1; i >= 0; --i) {
145 dap::Source source;
146 source.name = thread->Frames[i]->GetFileName();
147 source.path = source.name;
148
149#ifdef __GNUC__
150# pragma GCC diagnostic push
151# pragma GCC diagnostic ignored "-Warray-bounds"
152#endif
153 dap::StackFrame stackFrame;
154#ifdef __GNUC__
155# pragma GCC diagnostic pop
156#endif
157 stackFrame.line = thread->Frames[i]->GetLine();
158 stackFrame.column = 1;
159 stackFrame.id = thread->Frames[i]->GetId();
160 stackFrame.source = source;
161
162 auto stackName = thread->Frames[i]->GetFunction().OriginalName();
163 if (showParameters) {
164 stackName.push_back('(');
165 if (showParameterValues && !thread->Frames[i]->GetArguments().empty()) {
166 for (auto const& arg : thread->Frames[i]->GetArguments()) {
167 stackName = cmStrCat(stackName, arg.Value, ", ");
168 }
169
170 stackName.erase(stackName.end() - 2, stackName.end());
171 }
172
173 stackName.push_back(')');
174 }
175
176 if (showLine) {
177 stackName =

Callers 2

Calls 12

has_valueMethod · 0.80
valueMethod · 0.80
GetFunctionMethod · 0.80
push_backMethod · 0.80
eraseMethod · 0.80
cmStrCatFunction · 0.70
sizeMethod · 0.45
GetFileNameMethod · 0.45
GetLineMethod · 0.45
GetIdMethod · 0.45
emptyMethod · 0.45
endMethod · 0.45

Tested by 1

Used in the wild real call sites across dependent graphs

searching dependent graphs…