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 
14 using namespace lldb;
15 using namespace lldb_private;
16 
17 lldb::OptionValueSP OptionValueUInt64::Create(llvm::StringRef value_str,
18  Status &error) {
19  lldb::OptionValueSP value_sp(new OptionValueUInt64());
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  }
35 }
36 
37 Status OptionValueUInt64::SetValueFromString(llvm::StringRef value_ref,
39  Status error;
40  switch (op) {
42  Clear();
43  NotifyValueChanged();
44  break;
45 
48  bool success = false;
49  std::string value_str = value_ref.trim().str();
50  uint64_t value = StringConvert::ToUInt64(value_str.c_str(), 0, 0, &success);
51  if (success) {
52  m_value_was_set = true;
53  m_current_value = value;
54  NotifyValueChanged();
55  } else {
56  error.SetErrorStringWithFormat("invalid uint64_t string value: '%s'",
57  value_str.c_str());
58  }
59  } break;
60 
66  error = OptionValue::SetValueFromString(value_ref, op);
67  break;
68  }
69  return error;
70 }
lldb_private::eVarSetOperationInsertBefore
@ eVarSetOperationInsertBefore
Definition: lldb-private-enumerations.h:85
lldb_private::eVarSetOperationReplace
@ eVarSetOperationReplace
Definition: lldb-private-enumerations.h:84
lldb_private::ExecutionContext
Definition: ExecutionContext.h:291
OptionValueUInt64.h
lldb_private::Stream
Definition: Stream.h:28
error
static llvm::raw_ostream & error(Stream &strm)
Definition: CommandReturnObject.cpp:17
lldb_private::VarSetOperationType
VarSetOperationType
Settable state variable types.
Definition: lldb-private-enumerations.h:83
StringConvert.h
lldb_private::eVarSetOperationAppend
@ eVarSetOperationAppend
Definition: lldb-private-enumerations.h:88
string
string(SUBSTRING ${p} 10 -1 pStripped) if($
Definition: Plugins/CMakeLists.txt:38
lldb_private::Status
Definition: Status.h:44
uint32_t
lldb_private::StringConvert::ToUInt64
uint64_t ToUInt64(const char *s, uint64_t fail_value=0, int base=0, bool *success_ptr=nullptr)
Definition: StringConvert.cpp:64
lldb_private::eVarSetOperationRemove
@ eVarSetOperationRemove
Definition: lldb-private-enumerations.h:87
lldb_private::Stream::Printf
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
Definition: Stream.cpp:107
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb_private::OptionValueUInt64
Definition: OptionValueUInt64.h:17
lldb_private::eVarSetOperationInvalid
@ eVarSetOperationInvalid
Definition: lldb-private-enumerations.h:91
Stream.h
lldb_private::Stream::PutCString
size_t PutCString(llvm::StringRef cstr)
Output a C string to the stream.
Definition: Stream.cpp:63
lldb
Definition: SBAddress.h:15
lldb_private::eVarSetOperationClear
@ eVarSetOperationClear
Definition: lldb-private-enumerations.h:89
DumpValue
static bool DumpValue(Stream &s, const SymbolContext *sc, const ExecutionContext *exe_ctx, const FormatEntity::Entry &entry, ValueObject *valobj)
Definition: FormatEntity.cpp:673
lldb_private::eVarSetOperationInsertAfter
@ eVarSetOperationInsertAfter
Definition: lldb-private-enumerations.h:86
lldb_private::eVarSetOperationAssign
@ eVarSetOperationAssign
Definition: lldb-private-enumerations.h:90