summaryrefslogtreecommitdiffstats
path: root/Source/cmMakefile.cxx
diff options
context:
space:
mode:
authorGlen Chung <kuchung@microsoft.com>2023-03-16 00:50:08 (GMT)
committerBrad King <brad.king@kitware.com>2023-05-30 13:46:12 (GMT)
commita9a592f96e6498da302f8e968be1db0ad3c32123 (patch)
tree0d75f16ee2eae99b1a3f063e575b3f5f8f2ee931 /Source/cmMakefile.cxx
parentb0d1ddb7234950374977b83f8dbded806c15b356 (diff)
downloadCMake-a9a592f96e6498da302f8e968be1db0ad3c32123.zip
CMake-a9a592f96e6498da302f8e968be1db0ad3c32123.tar.gz
CMake-a9a592f96e6498da302f8e968be1db0ad3c32123.tar.bz2
cmake: Add debugger
- Depends on cppdap and jsoncpp. - Add --debugger argument to enable the Debugger. - Add --debugger-pipe argument for DAP traffics over named pipes. - Support breakpoints by filenames and line numbers. - Support exception breakpoints. - Call stack shows filenames and line numbers. - Show Cache Variables. - Show the state of currently defined targets, tests and directories with their properties. - Add cmakeVersion to DAP initialize response. - Include unit tests. Co-authored-by: Ben McMorran <bemcmorr@microsoft.com>
Diffstat (limited to 'Source/cmMakefile.cxx')
-rw-r--r--Source/cmMakefile.cxx95
1 files changed, 95 insertions, 0 deletions
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 585924d..92ba2d4 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -68,6 +68,10 @@
# include "cmVariableWatch.h"
#endif
+#ifdef CMake_ENABLE_DEBUGGER
+# include "cmDebuggerAdapter.h"
+#endif
+
#ifndef __has_feature
# define __has_feature(x) 0
#endif
@@ -424,6 +428,13 @@ public:
return argsValue;
});
#endif
+#ifdef CMake_ENABLE_DEBUGGER
+ if (this->Makefile->GetCMakeInstance()->GetDebugAdapter() != nullptr) {
+ this->Makefile->GetCMakeInstance()
+ ->GetDebugAdapter()
+ ->OnBeginFunctionCall(mf, lfc.FilePath, lff);
+ }
+#endif
}
~cmMakefileCall()
@@ -434,6 +445,13 @@ public:
this->Makefile->ExecutionStatusStack.pop_back();
--this->Makefile->RecursionDepth;
this->Makefile->Backtrace = this->Makefile->Backtrace.Pop();
+#ifdef CMake_ENABLE_DEBUGGER
+ if (this->Makefile->GetCMakeInstance()->GetDebugAdapter() != nullptr) {
+ this->Makefile->GetCMakeInstance()
+ ->GetDebugAdapter()
+ ->OnEndFunctionCall();
+ }
+#endif
}
cmMakefileCall(const cmMakefileCall&) = delete;
@@ -663,12 +681,33 @@ bool cmMakefile::ReadDependentFile(const std::string& filename,
IncludeScope incScope(this, filenametoread, noPolicyScope);
+#ifdef CMake_ENABLE_DEBUGGER
+ if (this->GetCMakeInstance()->GetDebugAdapter() != nullptr) {
+ this->GetCMakeInstance()->GetDebugAdapter()->OnBeginFileParse(
+ this, filenametoread);
+ }
+#endif
+
cmListFile listFile;
if (!listFile.ParseFile(filenametoread.c_str(), this->GetMessenger(),
this->Backtrace)) {
+#ifdef CMake_ENABLE_DEBUGGER
+ if (this->GetCMakeInstance()->GetDebugAdapter() != nullptr) {
+ this->GetCMakeInstance()->GetDebugAdapter()->OnEndFileParse();
+ }
+#endif
+
return false;
}
+#ifdef CMake_ENABLE_DEBUGGER
+ if (this->GetCMakeInstance()->GetDebugAdapter() != nullptr) {
+ this->GetCMakeInstance()->GetDebugAdapter()->OnEndFileParse();
+ this->GetCMakeInstance()->GetDebugAdapter()->OnFileParsedSuccessfully(
+ filenametoread, listFile.Functions);
+ }
+#endif
+
this->RunListFile(listFile, filenametoread);
if (cmSystemTools::GetFatalErrorOccurred()) {
incScope.Quiet();
@@ -764,12 +803,33 @@ bool cmMakefile::ReadListFile(const std::string& filename)
ListFileScope scope(this, filenametoread);
+#ifdef CMake_ENABLE_DEBUGGER
+ if (this->GetCMakeInstance()->GetDebugAdapter() != nullptr) {
+ this->GetCMakeInstance()->GetDebugAdapter()->OnBeginFileParse(
+ this, filenametoread);
+ }
+#endif
+
cmListFile listFile;
if (!listFile.ParseFile(filenametoread.c_str(), this->GetMessenger(),
this->Backtrace)) {
+#ifdef CMake_ENABLE_DEBUGGER
+ if (this->GetCMakeInstance()->GetDebugAdapter() != nullptr) {
+ this->GetCMakeInstance()->GetDebugAdapter()->OnEndFileParse();
+ }
+#endif
+
return false;
}
+#ifdef CMake_ENABLE_DEBUGGER
+ if (this->GetCMakeInstance()->GetDebugAdapter() != nullptr) {
+ this->GetCMakeInstance()->GetDebugAdapter()->OnEndFileParse();
+ this->GetCMakeInstance()->GetDebugAdapter()->OnFileParsedSuccessfully(
+ filenametoread, listFile.Functions);
+ }
+#endif
+
this->RunListFile(listFile, filenametoread);
if (cmSystemTools::GetFatalErrorOccurred()) {
scope.Quiet();
@@ -791,6 +851,13 @@ bool cmMakefile::ReadListFileAsString(const std::string& content,
return false;
}
+#ifdef CMake_ENABLE_DEBUGGER
+ if (this->GetCMakeInstance()->GetDebugAdapter() != nullptr) {
+ this->GetCMakeInstance()->GetDebugAdapter()->OnFileParsedSuccessfully(
+ filenametoread, listFile.Functions);
+ }
+#endif
+
this->RunListFile(listFile, filenametoread);
if (cmSystemTools::GetFatalErrorOccurred()) {
scope.Quiet();
@@ -1658,11 +1725,33 @@ void cmMakefile::Configure()
assert(cmSystemTools::FileExists(currentStart, true));
this->AddDefinition("CMAKE_PARENT_LIST_FILE", currentStart);
+#ifdef CMake_ENABLE_DEBUGGER
+ if (this->GetCMakeInstance()->GetDebugAdapter() != nullptr) {
+ this->GetCMakeInstance()->GetDebugAdapter()->OnBeginFileParse(
+ this, currentStart);
+ }
+#endif
+
cmListFile listFile;
if (!listFile.ParseFile(currentStart.c_str(), this->GetMessenger(),
this->Backtrace)) {
+#ifdef CMake_ENABLE_DEBUGGER
+ if (this->GetCMakeInstance()->GetDebugAdapter() != nullptr) {
+ this->GetCMakeInstance()->GetDebugAdapter()->OnEndFileParse();
+ }
+#endif
+
return;
}
+
+#ifdef CMake_ENABLE_DEBUGGER
+ if (this->GetCMakeInstance()->GetDebugAdapter() != nullptr) {
+ this->GetCMakeInstance()->GetDebugAdapter()->OnEndFileParse();
+ this->GetCMakeInstance()->GetDebugAdapter()->OnFileParsedSuccessfully(
+ currentStart, listFile.Functions);
+ }
+#endif
+
if (this->IsRootMakefile()) {
bool hasVersion = false;
// search for the right policy command
@@ -3769,6 +3858,12 @@ void cmMakefile::DisplayStatus(const std::string& message, float s) const
return;
}
cm->UpdateProgress(message, s);
+
+#ifdef CMake_ENABLE_DEBUGGER
+ if (cm->GetDebugAdapter() != nullptr) {
+ cm->GetDebugAdapter()->OnMessageOutput(MessageType::MESSAGE, message);
+ }
+#endif
}
std::string cmMakefile::GetModulesFile(const std::string& filename,