LLDB
mainline
llvm-project
lldb
source
Interpreter
OptionValueFormat.cpp
Go to the documentation of this file.
1
//===-- OptionValueFormat.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/OptionValueFormat.h
"
10
11
#include "
lldb/DataFormatters/FormatManager.h
"
12
#include "
lldb/Interpreter/OptionArgParser.h
"
13
#include "
lldb/Utility/Stream.h
"
14
15
using namespace
lldb
;
16
using namespace
lldb_private
;
17
18
void
OptionValueFormat::DumpValue
(
const
ExecutionContext
*exe_ctx,
Stream
&strm,
19
uint32_t dump_mask) {
20
if
(dump_mask &
eDumpOptionType
)
21
strm.
Printf
(
"(%s)"
,
GetTypeAsCString
());
22
if
(dump_mask &
eDumpOptionValue
) {
23
if
(dump_mask &
eDumpOptionType
)
24
strm.
PutCString
(
" = "
);
25
strm.
PutCString
(
FormatManager::GetFormatAsCString
(
m_current_value
));
26
}
27
}
28
29
llvm::json::Value
OptionValueFormat::ToJSON
(
const
ExecutionContext
*exe_ctx) {
30
return
FormatManager::GetFormatAsCString
(
m_current_value
);
31
}
32
33
Status
OptionValueFormat::SetValueFromString
(llvm::StringRef value,
34
VarSetOperationType
op) {
35
Status
error
;
36
switch
(op) {
37
case
eVarSetOperationClear
:
38
Clear
();
39
NotifyValueChanged
();
40
break
;
41
42
case
eVarSetOperationReplace
:
43
case
eVarSetOperationAssign
: {
44
Format
new_format;
45
error
=
OptionArgParser::ToFormat
(value.str().c_str(), new_format,
nullptr
);
46
if
(
error
.Success()) {
47
m_value_was_set
=
true
;
48
m_current_value
= new_format;
49
NotifyValueChanged
();
50
}
51
}
break
;
52
53
case
eVarSetOperationInsertBefore
:
54
case
eVarSetOperationInsertAfter
:
55
case
eVarSetOperationRemove
:
56
case
eVarSetOperationAppend
:
57
case
eVarSetOperationInvalid
:
58
error
=
OptionValue::SetValueFromString
(value, op);
59
break
;
60
}
61
return
error
;
62
}
error
static llvm::raw_ostream & error(Stream &strm)
Definition:
CommandReturnObject.cpp:17
FormatManager.h
OptionArgParser.h
OptionValueFormat.h
Stream.h
lldb_private::ExecutionContext
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
Definition:
ExecutionContext.h:292
lldb_private::FormatManager::GetFormatAsCString
static const char * GetFormatAsCString(lldb::Format format)
Definition:
FormatManager.cpp:150
lldb_private::OptionValueFormat::m_current_value
lldb::Format m_current_value
Definition:
OptionValueFormat.h:56
lldb_private::OptionValueFormat::ToJSON
llvm::json::Value ToJSON(const ExecutionContext *exe_ctx) override
Definition:
OptionValueFormat.cpp:29
lldb_private::OptionValueFormat::SetValueFromString
Status SetValueFromString(llvm::StringRef value, VarSetOperationType op=eVarSetOperationAssign) override
Definition:
OptionValueFormat.cpp:33
lldb_private::OptionValueFormat::DumpValue
void DumpValue(const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask) override
Definition:
OptionValueFormat.cpp:18
lldb_private::OptionValueFormat::Clear
void Clear() override
Definition:
OptionValueFormat.h:40
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
lldb::Format
Format
Display format definitions.
Definition:
lldb-enumerations.h:156
lldb_private::OptionArgParser::ToFormat
static Status ToFormat(const char *s, lldb::Format &format, size_t *byte_size_ptr)
Definition:
OptionArgParser.cpp:95
Generated on Tue Dec 3 2024 06:26:55 for LLDB by
1.9.6