LLDB  mainline
OptionValueSInt64.cpp
Go to the documentation of this file.
1 //===-- OptionValueSInt64.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 
18  uint32_t dump_mask) {
19  // printf ("%p: DumpValue (exe_ctx=%p, strm, mask) m_current_value = %"
20  // PRIi64
21  // "\n", this, exe_ctx, m_current_value);
22  if (dump_mask & eDumpOptionType)
23  strm.Printf("(%s)", GetTypeAsCString());
24  // if (dump_mask & eDumpOptionName)
25  // DumpQualifiedName (strm);
26  if (dump_mask & eDumpOptionValue) {
27  if (dump_mask & eDumpOptionType)
28  strm.PutCString(" = ");
29  strm.Printf("%" PRIi64, m_current_value);
30  }
31 }
32 
33 Status OptionValueSInt64::SetValueFromString(llvm::StringRef value_ref,
35  Status error;
36  switch (op) {
38  Clear();
39  NotifyValueChanged();
40  break;
41 
44  bool success = false;
45  std::string value_str = value_ref.trim().str();
46  int64_t value = StringConvert::ToSInt64(value_str.c_str(), 0, 0, &success);
47  if (success) {
48  if (value >= m_min_value && value <= m_max_value) {
49  m_value_was_set = true;
50  m_current_value = value;
51  NotifyValueChanged();
52  } else
53  error.SetErrorStringWithFormat(
54  "%" PRIi64 " is out of range, valid values must be between %" PRIi64
55  " and %" PRIi64 ".",
56  value, m_min_value, m_max_value);
57  } else {
58  error.SetErrorStringWithFormat("invalid int64_t string value: '%s'",
59  value_ref.str().c_str());
60  }
61  } break;
62 
68  error = OptionValue::SetValueFromString(value_ref, op);
69  break;
70  }
71  return error;
72 }
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
lldb_private::StringConvert::ToSInt64
int64_t ToSInt64(const char *s, int64_t fail_value=0, int base=0, bool *success_ptr=nullptr)
Definition: StringConvert.cpp:48
OptionValueSInt64.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::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::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