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 
11 #include "lldb/Utility/Stream.h"
12 
13 using namespace lldb;
14 using namespace lldb_private;
15 
16 lldb::OptionValueSP OptionValueUInt64::Create(llvm::StringRef value_str,
17  Status &error) {
18  lldb::OptionValueSP value_sp(new OptionValueUInt64());
19  error = value_sp->SetValueFromString(value_str);
20  if (error.Fail())
21  value_sp.reset();
22  return value_sp;
23 }
24 
26  uint32_t dump_mask) {
27  if (dump_mask & eDumpOptionType)
28  strm.Printf("(%s)", GetTypeAsCString());
29  if (dump_mask & eDumpOptionValue) {
30  if (dump_mask & eDumpOptionType)
31  strm.PutCString(" = ");
32  strm.Printf("%" PRIu64, m_current_value);
33  }
34 }
35 
36 Status OptionValueUInt64::SetValueFromString(llvm::StringRef value_ref,
38  Status error;
39  switch (op) {
41  Clear();
42  NotifyValueChanged();
43  break;
44 
47  llvm::StringRef value_trimmed = value_ref.trim();
48  uint64_t value;
49  if (llvm::to_integer(value_trimmed, value)) {
50  m_value_was_set = true;
51  m_current_value = value;
52  NotifyValueChanged();
53  } else {
54  error.SetErrorStringWithFormat("invalid uint64_t string value: '%s'",
55  value_ref.str().c_str());
56  }
57  } break;
58 
64  error = OptionValue::SetValueFromString(value_ref, op);
65  break;
66  }
67  return error;
68 }
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:292
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
lldb_private::eVarSetOperationAppend
@ eVarSetOperationAppend
Definition: lldb-private-enumerations.h:88
lldb_private::Status
Definition: Status.h:44
uint32_t
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