mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-05 13:20:47 -06:00
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:
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
33
Tests/CMakeLib/testDebuggerThread.cxx
Normal file
33
Tests/CMakeLib/testDebuggerThread.cxx
Normal 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,
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user