Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
Expand Up @@ -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;
Expand Down
11 changes: 11 additions & 0 deletions lldb/include/lldb/Utility/FileSpec.h
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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.
Expand Down
9 changes: 9 additions & 0 deletions lldb/source/Interpreter/OptionValueFileSpecList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
7 changes: 7 additions & 0 deletions lldb/source/Utility/FileSpec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down