-
Notifications
You must be signed in to change notification settings - Fork 13.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[lldb] Show target.debug-file-search-paths setting from python SBDebugger #131683
[lldb] Show target.debug-file-search-paths setting from python SBDebugger #131683
Conversation
@llvm/pr-subscribers-lldb Author: Ebuka Ezike (da-viper) ChangesFixes #110756 Full diff: https://github.com/llvm/llvm-project/pull/131683.diff 5 Files Affected:
diff --git a/lldb/include/lldb/Interpreter/OptionValueFileSpecList.h b/lldb/include/lldb/Interpreter/OptionValueFileSpecList.h
index bda6b5071d599..200ce701cb922 100644
--- a/lldb/include/lldb/Interpreter/OptionValueFileSpecList.h
+++ b/lldb/include/lldb/Interpreter/OptionValueFileSpecList.h
@@ -33,6 +33,8 @@ class OptionValueFileSpecList
void DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
uint32_t dump_mask) override;
+ llvm::json::Value ToJSON(const ExecutionContext *exe_ctx) override;
+
Status
SetValueFromString(llvm::StringRef value,
VarSetOperationType op = eVarSetOperationAssign) override;
diff --git a/lldb/include/lldb/Utility/FileSpec.h b/lldb/include/lldb/Utility/FileSpec.h
index 2e867b2b40b94..adb544b5e09d7 100644
--- a/lldb/include/lldb/Utility/FileSpec.h
+++ b/lldb/include/lldb/Utility/FileSpec.h
@@ -18,6 +18,7 @@
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/FormatVariadic.h"
+#include "llvm/Support/JSON.h"
#include "llvm/Support/Path.h"
#include <cstddef>
@@ -214,6 +215,17 @@ class FileSpec {
/// The stream to which to dump the object description.
void Dump(llvm::raw_ostream &s) const;
+ ///
+ /// Convert the filespec object to a json value.
+ ///
+ /// Convert the filespec object to a json value. If the object contains a
+ /// valid directory name, it will be displayed followed by a directory
+ /// delimiter, and the filename.
+ ///
+ /// \return
+ /// A json value representation of a filespec.
+ llvm::json::Value ToJSON() const;
+
Style GetPathStyle() const;
/// Directory string const get accessor.
@@ -232,7 +244,6 @@ class FileSpec {
/// Clear the directory in this object.
void ClearDirectory();
-
/// Filename string const get accessor.
///
/// \return
@@ -413,11 +424,7 @@ class FileSpec {
/// state in this object.
void PathWasModified() { m_absolute = Absolute::Calculate; }
- enum class Absolute : uint8_t {
- Calculate,
- Yes,
- No
- };
+ enum class Absolute : uint8_t { Calculate, Yes, No };
/// The unique'd directory path.
ConstString m_directory;
diff --git a/lldb/source/Interpreter/OptionValueFileSpecList.cpp b/lldb/source/Interpreter/OptionValueFileSpecList.cpp
index 98f4938fc6c19..9877d5033a88f 100644
--- a/lldb/source/Interpreter/OptionValueFileSpecList.cpp
+++ b/lldb/source/Interpreter/OptionValueFileSpecList.cpp
@@ -41,6 +41,16 @@ void OptionValueFileSpecList::DumpValue(const ExecutionContext *exe_ctx,
}
}
+llvm::json::Value
+OptionValueFileSpecList::ToJSON(const ExecutionContext *exe_ctx) {
+ std::lock_guard<std::recursive_mutex> lock(m_mutex);
+ llvm::json::Array spec_list;
+ for (const auto &file_spec : m_current_value) {
+ spec_list.emplace_back(file_spec.ToJSON());
+ }
+ return spec_list;
+}
+
Status OptionValueFileSpecList::SetValueFromString(llvm::StringRef value,
VarSetOperationType op) {
std::lock_guard<std::recursive_mutex> lock(m_mutex);
diff --git a/lldb/source/Utility/FileSpec.cpp b/lldb/source/Utility/FileSpec.cpp
index 4bebbc9ff175f..1ad08546a97a3 100644
--- a/lldb/source/Utility/FileSpec.cpp
+++ b/lldb/source/Utility/FileSpec.cpp
@@ -118,53 +118,55 @@ bool needsNormalization(const llvm::StringRef &path) {
return true;
for (auto i = path.find_first_of("\\/"); i != llvm::StringRef::npos;
i = path.find_first_of("\\/", i + 1)) {
- const auto next = safeCharAtIndex(path, i+1);
+ const auto next = safeCharAtIndex(path, i + 1);
switch (next) {
+ case 0:
+ // path separator char at the end of the string which should be
+ // stripped unless it is the one and only character
+ return i > 0;
+ case '/':
+ case '\\':
+ // two path separator chars in the middle of a path needs to be
+ // normalized
+ if (i > 0)
+ return true;
+ ++i;
+ break;
+
+ case '.': {
+ const auto next_next = safeCharAtIndex(path, i + 2);
+ switch (next_next) {
+ default:
+ break;
case 0:
- // path separator char at the end of the string which should be
- // stripped unless it is the one and only character
- return i > 0;
+ return true; // ends with "/."
case '/':
case '\\':
- // two path separator chars in the middle of a path needs to be
- // normalized
- if (i > 0)
- return true;
- ++i;
- break;
-
+ return true; // contains "/./"
case '.': {
- const auto next_next = safeCharAtIndex(path, i+2);
- switch (next_next) {
- default: break;
- case 0: return true; // ends with "/."
- case '/':
- case '\\':
- return true; // contains "/./"
- case '.': {
- const auto next_next_next = safeCharAtIndex(path, i+3);
- switch (next_next_next) {
- default: break;
- case 0: return true; // ends with "/.."
- case '/':
- case '\\':
- return true; // contains "/../"
- }
- break;
- }
- }
+ const auto next_next_next = safeCharAtIndex(path, i + 3);
+ switch (next_next_next) {
+ default:
+ break;
+ case 0:
+ return true; // ends with "/.."
+ case '/':
+ case '\\':
+ return true; // contains "/../"
}
break;
+ }
+ }
+ } break;
- default:
- break;
+ default:
+ break;
}
}
return false;
}
-
-}
+} // namespace
void FileSpec::SetFile(llvm::StringRef pathname) { SetFile(pathname, m_style); }
@@ -199,11 +201,11 @@ void FileSpec::SetFile(llvm::StringRef pathname, Style style) {
// Split path into filename and directory. We rely on the underlying char
// pointer to be nullptr when the components are empty.
llvm::StringRef filename = llvm::sys::path::filename(resolved, m_style);
- if(!filename.empty())
+ if (!filename.empty())
m_filename.SetString(filename);
llvm::StringRef directory = llvm::sys::path::parent_path(resolved, m_style);
- if(!directory.empty())
+ if (!directory.empty())
m_directory.SetString(directory);
}
@@ -330,6 +332,13 @@ void FileSpec::Dump(llvm::raw_ostream &s) const {
s << path_separator;
}
+llvm::json::Value FileSpec::ToJSON() const {
+ std::string file_spec{};
+ llvm::raw_string_ostream stream(file_spec);
+ this->Dump(stream);
+ return llvm::json::Value(std::move(file_spec));
+}
+
FileSpec::Style FileSpec::GetPathStyle() const { return m_style; }
void FileSpec::SetDirectory(ConstString directory) {
@@ -504,9 +513,7 @@ bool FileSpec::IsSourceImplementationFile() const {
return g_source_file_regex.Execute(extension);
}
-bool FileSpec::IsRelative() const {
- return !IsAbsolute();
-}
+bool FileSpec::IsRelative() const { return !IsAbsolute(); }
bool FileSpec::IsAbsolute() const {
// Check if we have cached if this path is absolute to avoid recalculating.
diff --git a/lldb/tools/lldb-dap/Transport.cpp b/lldb/tools/lldb-dap/Transport.cpp
index db2d7228d3fb7..a721662a345eb 100644
--- a/lldb/tools/lldb-dap/Transport.cpp
+++ b/lldb/tools/lldb-dap/Transport.cpp
@@ -103,7 +103,7 @@ Expected<std::optional<Message>> Transport::Read() {
if (raw_json->length() != length)
return createStringError("unexpected EOF parse DAP message body");
- DAP_LOG(m_log, "<-- ({0}) {1}", m_client_name, *raw_json);
+ DAP_LOG(m_log, "--> ({0}) {1}", m_client_name, *raw_json);
return json::parse<Message>(*raw_json);
}
@@ -114,7 +114,7 @@ Error Transport::Write(const Message &message) {
std::string json = formatv("{0}", toJSON(message)).str();
- DAP_LOG(m_log, "--> ({0}) {1}", m_client_name, json);
+ DAP_LOG(m_log, "<-- ({0}) {1}", m_client_name, json);
std::string Output;
raw_string_ostream OS(Output);
|
0cd2218
to
adaf8ad
Compare
For the test I wanted to confirm this goes into the the path |
Add a `ToJSON` method in FileSpec and OptionValueFileSpecList to enable JSON serialization.
adaf8ad
to
6d9b82b
Compare
Co-authored-by: Jonas Devlieghere <jonas@devlieghere.com>
Co-authored-by: Jonas Devlieghere <jonas@devlieghere.com>
✅ With the latest revision this PR passed the C/C++ code formatter. |
This will need a test. |
Signed-off-by: Ebuka Ezike <yerimyah1@gmail.com>
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/197/builds/2978 Here is the relevant piece of the build log for the reference
|
Now https://lab.llvm.org/buildbot/#/builders/162/builds/18611 and https://lab.llvm.org/buildbot/#/builders/195/builds/6519 are broken too. Please fix them ASAP. |
Sent the commit |
Fixes #110756