1 //===-- OptionValueUUID.cpp ------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "lldb/lldb-python.h"
12 #include "lldb/Interpreter/OptionValueUUID.h"
16 // Other libraries and framework includes
18 #include "lldb/Core/Module.h"
19 #include "lldb/Core/Stream.h"
20 #include "lldb/Core/StringList.h"
21 #include "lldb/Interpreter/CommandInterpreter.h"
24 using namespace lldb_private;
27 OptionValueUUID::DumpValue (const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask)
29 if (dump_mask & eDumpOptionType)
30 strm.Printf ("(%s)", GetTypeAsCString ());
31 if (dump_mask & eDumpOptionValue)
33 if (dump_mask & eDumpOptionType)
34 strm.PutCString (" = ");
40 OptionValueUUID::SetValueFromCString (const char *value_cstr,
41 VarSetOperationType op)
46 case eVarSetOperationClear:
50 case eVarSetOperationReplace:
51 case eVarSetOperationAssign:
53 if (m_uuid.SetFromCString(value_cstr) == 0)
54 error.SetErrorStringWithFormat ("invalid uuid string value '%s'", value_cstr);
56 m_value_was_set = true;
60 case eVarSetOperationInsertBefore:
61 case eVarSetOperationInsertAfter:
62 case eVarSetOperationRemove:
63 case eVarSetOperationAppend:
64 case eVarSetOperationInvalid:
65 error = OptionValue::SetValueFromCString (value_cstr, op);
72 OptionValueUUID::DeepCopy () const
74 return OptionValueSP(new OptionValueUUID(*this));
78 OptionValueUUID::AutoComplete (CommandInterpreter &interpreter,
80 int match_start_point,
81 int max_return_elements,
85 word_complete = false;
87 ExecutionContext exe_ctx(interpreter.GetExecutionContext());
88 Target *target = exe_ctx.GetTargetPtr();
91 const size_t num_modules = target->GetImages().GetSize();
94 UUID::ValueType uuid_bytes;
95 const size_t num_bytes_decoded = UUID::DecodeUUIDBytesFromCString(s, uuid_bytes, NULL);
96 for (size_t i=0; i<num_modules; ++i)
98 ModuleSP module_sp (target->GetImages().GetModuleAtIndex(i));
101 const UUID &module_uuid = module_sp->GetUUID();
102 if (module_uuid.IsValid())
104 bool add_uuid = false;
105 if (num_bytes_decoded == 0)
108 add_uuid = ::memcmp(module_uuid.GetBytes(), uuid_bytes, num_bytes_decoded) == 0;
111 std::string uuid_str;
112 uuid_str = module_uuid.GetAsString();
113 if (!uuid_str.empty())
114 matches.AppendString(uuid_str.c_str());
121 return matches.GetSize();