LLDB mainline
CommandObjectVersion.cpp
Go to the documentation of this file.
1//===-- CommandObjectVersion.cpp ------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
10
11#include "lldb/Core/Debugger.h"
14#include "llvm/ADT/StringExtras.h"
15
16using namespace lldb;
17using namespace lldb_private;
18
19#define LLDB_OPTIONS_version
20#include "CommandOptions.inc"
21
22llvm::ArrayRef<OptionDefinition>
24 return llvm::ArrayRef(g_version_options);
25}
26
28 : CommandObjectParsed(interpreter, "version",
29 "Show the LLDB debugger version.", "version") {}
30
32
33// Dump the array values on a single line.
34static void dump(const StructuredData::Array &array, Stream &s) {
35 std::vector<std::string> values;
36 array.ForEach([&](StructuredData::Object *object) -> bool {
37 values.emplace_back(object->GetStringValue().str());
38 return true;
39 });
40
41 s << '[' << llvm::join(values, ", ") << ']';
42}
43
44// The default dump output is too verbose.
45static void dump(const StructuredData::Dictionary &config, Stream &s) {
46 config.ForEach(
47 [&](llvm::StringRef key, StructuredData::Object *object) -> bool {
48 assert(object);
49
50 StructuredData::Dictionary *value_dict = object->GetAsDictionary();
51 assert(value_dict);
52
53 StructuredData::ObjectSP value_sp = value_dict->GetValueForKey("value");
54 assert(value_sp);
55
56 s << " " << key << ": ";
57 if (StructuredData::Boolean *boolean = value_sp->GetAsBoolean())
58 s << (boolean ? "yes" : "no");
59 else if (StructuredData::Array *array = value_sp->GetAsArray())
60 dump(*array, s);
61 s << '\n';
62
63 return true;
64 });
65}
66
static void dump(const StructuredData::Array &array, Stream &s)
A command line argument class.
Definition Args.h:33
CommandObjectParsed(CommandInterpreter &interpreter, const char *name, const char *help=nullptr, const char *syntax=nullptr, uint32_t flags=0)
llvm::ArrayRef< OptionDefinition > GetDefinitions() override
void DoExecute(Args &args, CommandReturnObject &result) override
CommandObjectVersion(CommandInterpreter &interpreter)
void SetStatus(lldb::ReturnStatus status)
void AppendMessageWithFormat(const char *format,...) __attribute__((format(printf
static StructuredData::DictionarySP GetBuildConfiguration()
Get the build configuration as structured data.
A stream class that can stream formatted output to a file.
Definition Stream.h:28
bool ForEach(std::function< bool(Object *object)> const &foreach_callback) const
ObjectSP GetValueForKey(llvm::StringRef key) const
void ForEach(std::function< bool(llvm::StringRef key, Object *object)> const &callback) const
std::shared_ptr< Object > ObjectSP
A class that represents a running process on the host machine.
const char * GetVersion()
Retrieves a string representing the complete LLDB version, which includes the lldb version number,...
Definition Version.cpp:38
@ eReturnStatusSuccessFinishResult