LLDB mainline
OptionValueUUID.cpp
Go to the documentation of this file.
1//===-- OptionValueUUID.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/Module.h"
13#include "lldb/Utility/Stream.h"
15
16using namespace lldb;
17using namespace lldb_private;
18
20 uint32_t dump_mask) {
21 if (dump_mask & eDumpOptionType)
22 strm.Printf("(%s)", GetTypeAsCString());
23 if (dump_mask & eDumpOptionValue) {
24 if (dump_mask & eDumpOptionType)
25 strm.PutCString(" = ");
26 m_uuid.Dump(&strm);
27 }
28}
29
33 switch (op) {
35 Clear();
37 break;
38
41 if (!m_uuid.SetFromStringRef(value))
42 error.SetErrorStringWithFormat("invalid uuid string value '%s'",
43 value.str().c_str());
44 else {
45 m_value_was_set = true;
47 }
48 } break;
49
56 break;
57 }
58 return error;
59}
60
62 CompletionRequest &request) {
63 ExecutionContext exe_ctx(interpreter.GetExecutionContext());
64 Target *target = exe_ctx.GetTargetPtr();
65 if (!target)
66 return;
67 auto prefix = request.GetCursorArgumentPrefix();
68 llvm::SmallVector<uint8_t, 20> uuid_bytes;
69 if (!UUID::DecodeUUIDBytesFromString(prefix, uuid_bytes).empty())
70 return;
71 const size_t num_modules = target->GetImages().GetSize();
72 for (size_t i = 0; i < num_modules; ++i) {
73 ModuleSP module_sp(target->GetImages().GetModuleAtIndex(i));
74 if (!module_sp)
75 continue;
76 const UUID &module_uuid = module_sp->GetUUID();
77 if (!module_uuid.IsValid())
78 continue;
79 request.TryCompleteCurrentArg(module_uuid.GetAsString());
80 }
81}
static llvm::raw_ostream & error(Stream &strm)
ExecutionContext GetExecutionContext() const
"lldb/Utility/ArgCompletionRequest.h"
llvm::StringRef GetCursorArgumentPrefix() const
void TryCompleteCurrentArg(llvm::StringRef completion, llvm::StringRef description="")
Adds a possible completion string if the completion would complete the current argument.
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
Target * GetTargetPtr() const
Returns a pointer to the target object.
lldb::ModuleSP GetModuleAtIndex(size_t idx) const
Get the module shared pointer for the module at index idx.
Definition: ModuleList.cpp:411
size_t GetSize() const
Gets the size of the module list.
Definition: ModuleList.cpp:635
Status SetValueFromString(llvm::StringRef value, VarSetOperationType op=eVarSetOperationAssign) override
void DumpValue(const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask) override
void AutoComplete(CommandInterpreter &interpreter, CompletionRequest &request) override
virtual Status SetValueFromString(llvm::StringRef value, VarSetOperationType op=eVarSetOperationAssign)
virtual const char * GetTypeAsCString() const
Definition: OptionValue.h:77
An error handling class.
Definition: Status.h:44
A stream class that can stream formatted output to a file.
Definition: Stream.h:28
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
Definition: Stream.cpp:107
size_t PutCString(llvm::StringRef cstr)
Output a C string to the stream.
Definition: Stream.cpp:63
const ModuleList & GetImages() const
Get accessor for the images for this process.
Definition: Target.h:946
bool SetFromStringRef(llvm::StringRef str)
Definition: UUID.cpp:97
std::string GetAsString(llvm::StringRef separator="-") const
Definition: UUID.cpp:49
void Dump(Stream *s) const
Definition: UUID.cpp:64
bool IsValid() const
Definition: UUID.h:69
static llvm::StringRef DecodeUUIDBytesFromString(llvm::StringRef str, llvm::SmallVectorImpl< uint8_t > &uuid_bytes)
Decode as many UUID bytes as possible from the C string cstr.
Definition: UUID.cpp:74
A class that represents a running process on the host machine.
VarSetOperationType
Settable state variable types.
Definition: SBAddress.h:15