Merge topic 'debugger-function-name-in-stacktrace'

c028425df9 Debugger: report function name in DAP stackframes

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !8913
This commit is contained in:
Brad King
2023-10-27 13:03:55 +00:00
committed by Kitware Robot
4 changed files with 40 additions and 2 deletions

View File

@@ -28,6 +28,10 @@ public:
std::string const& GetFileName() const noexcept { return this->FileName; }
int64_t GetLine() const noexcept;
cmMakefile* GetMakefile() const noexcept { return this->Makefile; }
cmListFileFunction const& GetFunction() const noexcept
{
return this->Function;
}
};
} // namespace cmDebugger

View File

@@ -13,6 +13,7 @@
#include "cmDebuggerVariables.h"
#include "cmDebuggerVariablesHelper.h"
#include "cmDebuggerVariablesManager.h"
#include "cmListFileCache.h"
namespace cmDebugger {
@@ -135,8 +136,7 @@ dap::StackTraceResponse GetStackTraceResponse(
#endif
stackFrame.line = thread->Frames[i]->GetLine();
stackFrame.column = 1;
stackFrame.name = thread->Frames[i]->GetFileName() + " Line " +
std::to_string(stackFrame.line);
stackFrame.name = thread->Frames[i]->GetFunction().OriginalName();
stackFrame.id = thread->Frames[i]->GetId();
stackFrame.source = source;

View File

@@ -42,6 +42,7 @@ if(CMake_ENABLE_DEBUGGER)
testDebuggerVariables.cxx
testDebuggerVariablesHelper.cxx
testDebuggerVariablesManager.cxx
testDebuggerThread.cxx
)
endif()
if (CMake_TEST_FILESYSTEM_PATH OR NOT CMake_HAVE_CXX_FILESYSTEM)

View File

@@ -0,0 +1,33 @@
#include <functional>
#include <memory>
#include <string>
#include <vector>
#include <cm3p/cppdap/protocol.h>
#include <cm3p/cppdap/types.h>
#include "cmDebuggerThread.h"
#include "cmListFileCache.h"
#include "testCommon.h"
static bool testStackFrameFunctionName()
{
auto thread = std::make_shared<cmDebugger::cmDebuggerThread>(0, "name");
const auto* functionName = "function_name";
auto arguments = std::vector<cmListFileArgument>{};
cmListFileFunction func(functionName, 10, 20, arguments);
thread->PushStackFrame(nullptr, "CMakeLists.txt", func);
auto stackTrace = GetStackTraceResponse(thread);
ASSERT_TRUE(stackTrace.stackFrames[0].name == functionName);
return true;
}
int testDebuggerThread(int, char*[])
{
return runTests(std::vector<std::function<bool()>>{
testStackFrameFunctionName,
});
}