LLDB  mainline
OptionValueUInt64.cpp
Go to the documentation of this file.
1 //===-- OptionValueUInt64.cpp ------------------------------------*- C++
2 //-*-===//
3 //
4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 // See https://llvm.org/LICENSE.txt for license information.
6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //
8 //===----------------------------------------------------------------------===//
9 
11 
13 #include "lldb/Utility/Stream.h"
14 
15 using namespace lldb;
16 using namespace lldb_private;
17 
18 lldb::OptionValueSP OptionValueUInt64::Create(llvm::StringRef value_str,
19  Status &error) {
20  lldb::OptionValueSP value_sp(new OptionValueUInt64());
21  error = value_sp->SetValueFromString(value_str);
22  if (error.Fail())
23  value_sp.reset();
24  return value_sp;
25 }
26 
28  uint32_t dump_mask) {
29  if (dump_mask & eDumpOptionType)
30  strm.Printf("(%s)", GetTypeAsCString());
31  if (dump_mask & eDumpOptionValue) {
32  if (dump_mask & eDumpOptionType)
33  strm.PutCString(" = ");
34  strm.Printf("%" PRIu64, m_current_value);
35  }
36 }
37 
38 Status OptionValueUInt64::SetValueFromString(llvm::StringRef value_ref,
40  Status error;
41  switch (op) {
43  Clear();
44  NotifyValueChanged();
45  break;
46 
49  bool success = false;
50  std::string value_str = value_ref.trim().str();
51  uint64_t value = StringConvert::ToUInt64(value_str.c_str(), 0, 0, &success);
52  if (success) {
53  m_value_was_set = true;
54  m_current_value = value;
55  NotifyValueChanged();
56  } else {
57  error.SetErrorStringWithFormat("invalid uint64_t string value: '%s'",
58  value_str.c_str());
59  }
60  } break;
61 
67  error = OptionValue::SetValueFromString(value_ref, op);
68  break;
69  }
70  return error;
71 }
72 
73 lldb::OptionValueSP OptionValueUInt64::DeepCopy() const {
74  return OptionValueSP(new OptionValueUInt64(*this));
75 }
size_t PutCString(llvm::StringRef cstr)
Output a C string to the stream.
Definition: Stream.cpp:61
Enumerations for broadcasting.
Definition: SBLaunchInfo.h:14
A stream class that can stream formatted output to a file.
Definition: Stream.h:28
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
VarSetOperationType
Settable state variable types.
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
Definition: Stream.cpp:106
bool Fail() const
Test for error condition.
Definition: Status.cpp:181
Definition: SBAddress.h:15
int SetErrorStringWithFormat(const char *format,...) __attribute__((format(printf
Set the current error string to a formatted error string.
Definition: Status.cpp:255
uint64_t ToUInt64(const char *s, uint64_t fail_value=0, int base=0, bool *success_ptr=nullptr)
static bool DumpValue(Stream &s, const SymbolContext *sc, const ExecutionContext *exe_ctx, const FormatEntity::Entry &entry, ValueObject *valobj)
An error handling class.
Definition: Status.h:44