LLDB
mainline
llvm-project
lldb
source
Interpreter
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
9
#include "
lldb/Interpreter/OptionValueSInt64.h
"
10
11
#include "
lldb/Utility/Stream.h
"
12
13
using namespace
lldb
;
14
using namespace
lldb_private
;
15
16
void
OptionValueSInt64::DumpValue
(
const
ExecutionContext
*exe_ctx,
Stream
&strm,
17
uint32_t dump_mask) {
18
// printf ("%p: DumpValue (exe_ctx=%p, strm, mask) m_current_value = %"
19
// PRIi64
20
// "\n", this, exe_ctx, m_current_value);
21
if
(dump_mask &
eDumpOptionType
)
22
strm.
Printf
(
"(%s)"
,
GetTypeAsCString
());
23
// if (dump_mask & eDumpOptionName)
24
// DumpQualifiedName (strm);
25
if
(dump_mask &
eDumpOptionValue
) {
26
if
(dump_mask &
eDumpOptionType
)
27
strm.
PutCString
(
" = "
);
28
strm.
Printf
(
"%"
PRIi64,
m_current_value
);
29
}
30
}
31
32
Status
OptionValueSInt64::SetValueFromString
(llvm::StringRef value_ref,
33
VarSetOperationType
op) {
34
Status
error
;
35
switch
(op) {
36
case
eVarSetOperationClear
:
37
Clear
();
38
NotifyValueChanged
();
39
break
;
40
41
case
eVarSetOperationReplace
:
42
case
eVarSetOperationAssign
: {
43
llvm::StringRef value_trimmed = value_ref.trim();
44
int64_t value;
45
if
(llvm::to_integer(value_trimmed, value)) {
46
if
(value >=
m_min_value
&& value <=
m_max_value
) {
47
m_value_was_set
=
true
;
48
m_current_value
= value;
49
NotifyValueChanged
();
50
}
else
51
error
.SetErrorStringWithFormat(
52
"%"
PRIi64
" is out of range, valid values must be between %"
PRIi64
53
" and %"
PRIi64
"."
,
54
value,
m_min_value
,
m_max_value
);
55
}
else
{
56
error
.SetErrorStringWithFormat(
"invalid int64_t string value: '%s'"
,
57
value_ref.str().c_str());
58
}
59
}
break
;
60
61
case
eVarSetOperationInsertBefore
:
62
case
eVarSetOperationInsertAfter
:
63
case
eVarSetOperationRemove
:
64
case
eVarSetOperationAppend
:
65
case
eVarSetOperationInvalid
:
66
error
=
OptionValue::SetValueFromString
(value_ref, op);
67
break
;
68
}
69
return
error
;
70
}
error
static llvm::raw_ostream & error(Stream &strm)
Definition:
CommandReturnObject.cpp:17
OptionValueSInt64.h
Stream.h
lldb_private::ExecutionContext
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
Definition:
ExecutionContext.h:292
lldb_private::OptionValueSInt64::m_max_value
int64_t m_max_value
Definition:
OptionValueSInt64.h:90
lldb_private::OptionValueSInt64::m_current_value
int64_t m_current_value
Definition:
OptionValueSInt64.h:87
lldb_private::OptionValueSInt64::DumpValue
void DumpValue(const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask) override
Definition:
OptionValueSInt64.cpp:16
lldb_private::OptionValueSInt64::Clear
void Clear() override
Definition:
OptionValueSInt64.h:46
lldb_private::OptionValueSInt64::SetValueFromString
Status SetValueFromString(llvm::StringRef value, VarSetOperationType op=eVarSetOperationAssign) override
Definition:
OptionValueSInt64.cpp:32
lldb_private::OptionValueSInt64::m_min_value
int64_t m_min_value
Definition:
OptionValueSInt64.h:89
lldb_private::OptionValue::SetValueFromString
virtual Status SetValueFromString(llvm::StringRef value, VarSetOperationType op=eVarSetOperationAssign)
Definition:
OptionValue.cpp:602
lldb_private::OptionValue::eDumpOptionType
@ eDumpOptionType
Definition:
OptionValue.h:59
lldb_private::OptionValue::eDumpOptionValue
@ eDumpOptionValue
Definition:
OptionValue.h:60
lldb_private::OptionValue::m_value_was_set
bool m_value_was_set
Definition:
OptionValue.h:346
lldb_private::OptionValue::NotifyValueChanged
void NotifyValueChanged()
Definition:
OptionValue.h:267
lldb_private::OptionValue::GetTypeAsCString
virtual const char * GetTypeAsCString() const
Definition:
OptionValue.h:87
lldb_private::Status
An error handling class.
Definition:
Status.h:44
lldb_private::Stream
A stream class that can stream formatted output to a file.
Definition:
Stream.h:28
lldb_private::Stream::Printf
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
Definition:
Stream.cpp:134
lldb_private::Stream::PutCString
size_t PutCString(llvm::StringRef cstr)
Output a C string to the stream.
Definition:
Stream.cpp:65
lldb_private
A class that represents a running process on the host machine.
Definition:
SBAddressRange.h:14
lldb_private::VarSetOperationType
VarSetOperationType
Settable state variable types.
Definition:
lldb-private-enumerations.h:85
lldb_private::eVarSetOperationRemove
@ eVarSetOperationRemove
Definition:
lldb-private-enumerations.h:89
lldb_private::eVarSetOperationAppend
@ eVarSetOperationAppend
Definition:
lldb-private-enumerations.h:90
lldb_private::eVarSetOperationAssign
@ eVarSetOperationAssign
Definition:
lldb-private-enumerations.h:92
lldb_private::eVarSetOperationReplace
@ eVarSetOperationReplace
Definition:
lldb-private-enumerations.h:86
lldb_private::eVarSetOperationInvalid
@ eVarSetOperationInvalid
Definition:
lldb-private-enumerations.h:93
lldb_private::eVarSetOperationInsertBefore
@ eVarSetOperationInsertBefore
Definition:
lldb-private-enumerations.h:87
lldb_private::eVarSetOperationClear
@ eVarSetOperationClear
Definition:
lldb-private-enumerations.h:91
lldb_private::eVarSetOperationInsertAfter
@ eVarSetOperationInsertAfter
Definition:
lldb-private-enumerations.h:88
lldb
Definition:
SBAddress.h:15
Generated on Sun Oct 13 2024 11:31:05 for LLDB by
1.9.6