LLDB mainline
OptionValueUInt64.cpp
Go to the documentation of this file.
1//===-- OptionValueUInt64.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
12#include "lldb/Utility/Stream.h"
13
14using namespace lldb;
15using namespace lldb_private;
16
18 Status &error) {
20 error = value_sp->SetValueFromString(value_str);
21 if (error.Fail())
22 value_sp.reset();
23 return value_sp;
24}
25
27 uint32_t dump_mask) {
28 if (dump_mask & eDumpOptionType)
29 strm.Printf("(%s)", GetTypeAsCString());
30 if (dump_mask & eDumpOptionValue) {
31 if (dump_mask & eDumpOptionType)
32 strm.PutCString(" = ");
33 strm.Printf("%" PRIu64, m_current_value);
34 if (dump_mask & eDumpOptionDefaultValue &&
36 DefaultValueFormat label(strm);
37 strm.Printf("%" PRIu64, m_default_value);
38 }
39 }
40}
41
45 switch (op) {
47 Clear();
49 break;
50
53 llvm::StringRef value_trimmed = value_ref.trim();
54 uint64_t value;
55 if (llvm::to_integer(value_trimmed, value)) {
56 if (value >= m_min_value && value <= m_max_value) {
57 m_value_was_set = true;
58 m_current_value = value;
60 } else {
62 "%" PRIu64 " is out of range, valid values must be between %" PRIu64
63 " and %" PRIu64 ".",
64 value, m_min_value, m_max_value);
65 }
66 } else {
68 "invalid uint64_t string value: '%s'", value_ref.str().c_str());
69 }
70 } break;
71
78 break;
79 }
80 return error;
81}
static llvm::raw_ostream & error(Stream &strm)
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
static lldb::OptionValueSP Create(llvm::StringRef value_str, Status &error)
Status SetValueFromString(llvm::StringRef value, VarSetOperationType op=eVarSetOperationAssign) override
void DumpValue(const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask) override
virtual Status SetValueFromString(llvm::StringRef value, VarSetOperationType op=eVarSetOperationAssign)
virtual const char * GetTypeAsCString() const
Definition OptionValue.h:89
An error handling class.
Definition Status.h:118
static Status FromErrorStringWithFormat(const char *format,...) __attribute__((format(printf
Definition Status.cpp:106
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:134
size_t PutCString(llvm::StringRef cstr)
Output a C string to the stream.
Definition Stream.cpp:65
A class that represents a running process on the host machine.
VarSetOperationType
Settable state variable types.
std::shared_ptr< lldb_private::OptionValue > OptionValueSP