2012-08-23 01:17:09 +08:00
|
|
|
//===-- OptionValueUUID.cpp ------------------------------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "lldb/Interpreter/OptionValueUUID.h"
|
|
|
|
|
|
|
|
// C Includes
|
|
|
|
// C++ Includes
|
|
|
|
// Other libraries and framework includes
|
|
|
|
// Project includes
|
2012-09-28 06:26:11 +08:00
|
|
|
#include "lldb/Core/Module.h"
|
|
|
|
#include "lldb/Interpreter/CommandInterpreter.h"
|
2017-02-03 05:39:50 +08:00
|
|
|
#include "lldb/Utility/Stream.h"
|
2017-03-22 02:25:04 +08:00
|
|
|
#include "lldb/Utility/StringList.h"
|
2012-08-23 01:17:09 +08:00
|
|
|
|
|
|
|
using namespace lldb;
|
|
|
|
using namespace lldb_private;
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
void OptionValueUUID::DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
|
|
|
|
uint32_t dump_mask) {
|
|
|
|
if (dump_mask & eDumpOptionType)
|
|
|
|
strm.Printf("(%s)", GetTypeAsCString());
|
|
|
|
if (dump_mask & eDumpOptionValue) {
|
2012-08-23 01:17:09 +08:00
|
|
|
if (dump_mask & eDumpOptionType)
|
2016-09-07 04:57:50 +08:00
|
|
|
strm.PutCString(" = ");
|
|
|
|
m_uuid.Dump(&strm);
|
|
|
|
}
|
2012-08-23 01:17:09 +08:00
|
|
|
}
|
|
|
|
|
2017-05-12 12:51:55 +08:00
|
|
|
Status OptionValueUUID::SetValueFromString(llvm::StringRef value,
|
|
|
|
VarSetOperationType op) {
|
|
|
|
Status error;
|
2016-09-07 04:57:50 +08:00
|
|
|
switch (op) {
|
|
|
|
case eVarSetOperationClear:
|
|
|
|
Clear();
|
|
|
|
NotifyValueChanged();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eVarSetOperationReplace:
|
|
|
|
case eVarSetOperationAssign: {
|
2018-06-21 23:24:39 +08:00
|
|
|
if (m_uuid.SetFromStringRef(value) == 0)
|
2016-09-07 04:57:50 +08:00
|
|
|
error.SetErrorStringWithFormat("invalid uuid string value '%s'",
|
|
|
|
value.str().c_str());
|
|
|
|
else {
|
|
|
|
m_value_was_set = true;
|
|
|
|
NotifyValueChanged();
|
2012-08-23 01:17:09 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
} break;
|
|
|
|
|
|
|
|
case eVarSetOperationInsertBefore:
|
|
|
|
case eVarSetOperationInsertAfter:
|
|
|
|
case eVarSetOperationRemove:
|
|
|
|
case eVarSetOperationAppend:
|
|
|
|
case eVarSetOperationInvalid:
|
|
|
|
error = OptionValue::SetValueFromString(value, op);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return error;
|
2012-08-23 01:17:09 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
lldb::OptionValueSP OptionValueUUID::DeepCopy() const {
|
|
|
|
return OptionValueSP(new OptionValueUUID(*this));
|
2012-08-23 01:17:09 +08:00
|
|
|
}
|
2012-09-28 06:26:11 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
size_t OptionValueUUID::AutoComplete(CommandInterpreter &interpreter,
|
2018-07-14 02:28:14 +08:00
|
|
|
CompletionRequest &request) {
|
|
|
|
request.SetWordComplete(false);
|
2016-09-07 04:57:50 +08:00
|
|
|
ExecutionContext exe_ctx(interpreter.GetExecutionContext());
|
|
|
|
Target *target = exe_ctx.GetTargetPtr();
|
|
|
|
if (target) {
|
2018-07-14 02:28:14 +08:00
|
|
|
auto prefix = request.GetCursorArgumentPrefix();
|
UUID: Add support for arbitrary-sized module IDs
Summary:
The data structure is optimized for the case where the UUID size is <=
20 bytes (standard length emitted by the GNU linkers), but larger sizes
are also possible.
I've modified the string conversion function to support the new sizes as
well. For standard UUIDs it maintains the traditional formatting
(4-2-2-2-6). If a UUID is shorter, we just cut this sequence short, and
for longer UUIDs it will just repeat the last 6-byte block as long as
necessary.
I've also modified ObjectFileELF to take advantage of the new UUIDs and
avoid manually padding the UUID to 16 bytes. While there, I also made
sure the computed UUID does not depend on host endianness.
Reviewers: clayborg, lemo, sas, davide, espindola
Subscribers: emaste, arichardson, lldb-commits
Differential Revision: https://reviews.llvm.org/D48633
llvm-svn: 335963
2018-06-29 19:20:29 +08:00
|
|
|
llvm::SmallVector<uint8_t, 20> uuid_bytes;
|
2018-07-14 02:28:14 +08:00
|
|
|
if (UUID::DecodeUUIDBytesFromString(prefix, uuid_bytes).empty()) {
|
UUID: Add support for arbitrary-sized module IDs
Summary:
The data structure is optimized for the case where the UUID size is <=
20 bytes (standard length emitted by the GNU linkers), but larger sizes
are also possible.
I've modified the string conversion function to support the new sizes as
well. For standard UUIDs it maintains the traditional formatting
(4-2-2-2-6). If a UUID is shorter, we just cut this sequence short, and
for longer UUIDs it will just repeat the last 6-byte block as long as
necessary.
I've also modified ObjectFileELF to take advantage of the new UUIDs and
avoid manually padding the UUID to 16 bytes. While there, I also made
sure the computed UUID does not depend on host endianness.
Reviewers: clayborg, lemo, sas, davide, espindola
Subscribers: emaste, arichardson, lldb-commits
Differential Revision: https://reviews.llvm.org/D48633
llvm-svn: 335963
2018-06-29 19:20:29 +08:00
|
|
|
const size_t num_modules = target->GetImages().GetSize();
|
2016-09-07 04:57:50 +08:00
|
|
|
for (size_t i = 0; i < num_modules; ++i) {
|
|
|
|
ModuleSP module_sp(target->GetImages().GetModuleAtIndex(i));
|
|
|
|
if (module_sp) {
|
|
|
|
const UUID &module_uuid = module_sp->GetUUID();
|
|
|
|
if (module_uuid.IsValid()) {
|
2018-06-21 23:07:43 +08:00
|
|
|
llvm::ArrayRef<uint8_t> module_bytes = module_uuid.GetBytes();
|
UUID: Add support for arbitrary-sized module IDs
Summary:
The data structure is optimized for the case where the UUID size is <=
20 bytes (standard length emitted by the GNU linkers), but larger sizes
are also possible.
I've modified the string conversion function to support the new sizes as
well. For standard UUIDs it maintains the traditional formatting
(4-2-2-2-6). If a UUID is shorter, we just cut this sequence short, and
for longer UUIDs it will just repeat the last 6-byte block as long as
necessary.
I've also modified ObjectFileELF to take advantage of the new UUIDs and
avoid manually padding the UUID to 16 bytes. While there, I also made
sure the computed UUID does not depend on host endianness.
Reviewers: clayborg, lemo, sas, davide, espindola
Subscribers: emaste, arichardson, lldb-commits
Differential Revision: https://reviews.llvm.org/D48633
llvm-svn: 335963
2018-06-29 19:20:29 +08:00
|
|
|
if (module_bytes.size() >= uuid_bytes.size() &&
|
|
|
|
module_bytes.take_front(uuid_bytes.size()).equals(uuid_bytes)) {
|
2018-07-28 02:42:46 +08:00
|
|
|
request.AddCompletion(module_uuid.GetAsString());
|
2012-09-28 06:26:11 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2012-09-28 06:26:11 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2012-09-28 06:26:11 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2018-07-28 02:42:46 +08:00
|
|
|
return request.GetNumberOfMatches();
|
2012-09-28 06:26:11 +08:00
|
|
|
}
|