Skip to content

[lldb] Show target.debug-file-search-paths setting from python SBDebugger #131683

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

Merged
merged 5 commits into from
Mar 21, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lldb/include/lldb/Interpreter/OptionValueFileSpecList.h
Original file line number Diff line number Diff line change
@@ -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;
11 changes: 11 additions & 0 deletions lldb/include/lldb/Utility/FileSpec.h
Original file line number Diff line number Diff line change
@@ -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,16 @@ 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.
9 changes: 9 additions & 0 deletions lldb/source/Interpreter/OptionValueFileSpecList.cpp
Original file line number Diff line number Diff line change
@@ -41,6 +41,15 @@ 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 array;
for (const auto &file_spec : m_current_value)
array.emplace_back(file_spec.ToJSON());
return array;
}

Status OptionValueFileSpecList::SetValueFromString(llvm::StringRef value,
VarSetOperationType op) {
std::lock_guard<std::recursive_mutex> lock(m_mutex);
7 changes: 7 additions & 0 deletions lldb/source/Utility/FileSpec.cpp
Original file line number Diff line number Diff line change
@@ -330,6 +330,13 @@ void FileSpec::Dump(llvm::raw_ostream &s) const {
s << path_separator;
}

llvm::json::Value FileSpec::ToJSON() const {
std::string str;
llvm::raw_string_ostream stream(str);
this->Dump(stream);
return llvm::json::Value(std::move(str));
}

FileSpec::Style FileSpec::GetPathStyle() const { return m_style; }

void FileSpec::SetDirectory(ConstString directory) {
7 changes: 7 additions & 0 deletions lldb/test/API/commands/settings/TestSettings.py
Original file line number Diff line number Diff line change
@@ -1016,6 +1016,13 @@ def test_settings_api(self):
settings_json = self.get_setting_json(setting_path)
self.assertEqual(settings_json, setting_value)

# Test OptionValueFileSpec and OptionValueFileSpecList
setting_path = "target.debug-file-search-paths"
setting_value = ["/tmp" "/tmp2"]
self.runCmd("settings set %s %s" % (setting_path, " ".join(setting_value)))
settings_json = self.get_setting_json(setting_path)
self.assertEqual(settings_json, setting_value)

# Test OptionValueFormatEntity
setting_value = """thread #${thread.index}{, name = \\'${thread.name}\\
'}{, queue = ${ansi.fg.green}\\'${thread.queue}\\'${ansi.normal}}{,