LLDB
mainline
llvm-project
lldb
source
Plugins
SymbolFile
DWARF
DWARFFormValue.h
Go to the documentation of this file.
1
//===-- DWARFFormValue.h ----------------------------------------*- C++ -*-===//
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
#ifndef LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFFORMVALUE_H
10
#define LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFFORMVALUE_H
11
12
#include "
DWARFDataExtractor.h
"
13
#include <cstddef>
14
#include <optional>
15
16
namespace
lldb_private::plugin
{
17
namespace
dwarf
{
18
class
DWARFUnit;
19
class
SymbolFileDWARF;
20
class
DWARFDIE;
21
22
class
DWARFFormValue
{
23
public
:
24
typedef
struct
ValueTypeTag
{
25
ValueTypeTag
() :
value
() {
value
.uval = 0; }
26
27
union
{
28
uint64_t
uval
;
29
int64_t
sval
;
30
const
char
*
cstr
;
31
}
value
;
32
const
uint8_t *
data
=
nullptr
;
33
}
ValueType
;
34
35
enum
{
36
eValueTypeInvalid
= 0,
37
eValueTypeUnsigned
,
38
eValueTypeSigned
,
39
eValueTypeCStr
,
40
eValueTypeBlock
41
};
42
43
DWARFFormValue
() =
default
;
44
DWARFFormValue
(
const
DWARFUnit
*unit) :
m_unit
(unit) {}
45
DWARFFormValue
(
const
DWARFUnit
*unit,
dw_form_t
form)
46
:
m_unit
(unit),
m_form
(form) {}
47
const
DWARFUnit
*
GetUnit
()
const
{
return
m_unit
; }
48
void
SetUnit
(
const
DWARFUnit
*unit) {
m_unit
= unit; }
49
dw_form_t
Form
()
const
{
return
m_form
; }
50
dw_form_t
&
FormRef
() {
return
m_form
; }
51
void
SetForm
(
dw_form_t
form) {
m_form
= form; }
52
const
ValueType
&
Value
()
const
{
return
m_value
; }
53
ValueType
&
ValueRef
() {
return
m_value
; }
54
void
SetValue
(
const
ValueType
&val) {
m_value
= val; }
55
56
void
Dump
(
Stream
&s)
const
;
57
bool
ExtractValue
(
const
DWARFDataExtractor
&data,
lldb::offset_t
*offset_ptr);
58
const
uint8_t *
BlockData
()
const
;
59
static
std::optional<uint8_t>
GetFixedSize
(
dw_form_t
form,
60
const
DWARFUnit
*u);
61
std::optional<uint8_t>
GetFixedSize
()
const
;
62
DWARFDIE
Reference
()
const
;
63
64
/// If this is a reference to another DIE, return the corresponding DWARFUnit
65
/// and DIE offset such that Unit->GetDIE(offset) produces the desired DIE.
66
/// Otherwise, a nullptr and unspecified offset are returned.
67
std::pair<DWARFUnit *, uint64_t>
ReferencedUnitAndOffset
()
const
;
68
69
uint64_t
Reference
(
dw_offset_t
offset)
const
;
70
bool
Boolean
()
const
{
return
m_value
.
value
.
uval
!= 0; }
71
uint64_t
Unsigned
()
const
{
return
m_value
.
value
.
uval
; }
72
void
SetUnsigned
(uint64_t uval) {
m_value
.
value
.
uval
= uval; }
73
int64_t
Signed
()
const
{
return
m_value
.
value
.
sval
; }
74
void
SetSigned
(int64_t sval) {
m_value
.
value
.
sval
= sval; }
75
const
char
*
AsCString
()
const
;
76
dw_addr_t
Address
()
const
;
77
bool
IsValid
()
const
{
return
m_form
!= 0; }
78
bool
SkipValue
(
const
DWARFDataExtractor
&debug_info_data,
79
lldb::offset_t
*offset_ptr)
const
;
80
static
bool
SkipValue
(
const
dw_form_t
form,
81
const
DWARFDataExtractor
&debug_info_data,
82
lldb::offset_t
*offset_ptr,
const
DWARFUnit
*unit);
83
static
bool
IsBlockForm
(
const
dw_form_t
form);
84
static
bool
IsDataForm
(
const
dw_form_t
form);
85
static
int
Compare
(
const
DWARFFormValue
&a,
const
DWARFFormValue
&b);
86
void
Clear
();
87
static
bool
FormIsSupported
(
dw_form_t
form);
88
89
protected
:
90
// Compile unit where m_value was located.
91
// It may be different from compile unit where m_value refers to.
92
const
DWARFUnit
*
m_unit
=
nullptr
;
// Unit for this form
93
dw_form_t
m_form
=
dw_form_t
(0);
// Form for this value
94
ValueType
m_value
;
// Contains all data for the form
95
};
96
}
// namespace dwarf
97
}
// namespace lldb_private::plugin
98
99
#endif
// LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFFORMVALUE_H
DWARFDataExtractor.h
lldb_private::DWARFDataExtractor
Definition:
DWARFDataExtractor.h:18
lldb_private::Stream
A stream class that can stream formatted output to a file.
Definition:
Stream.h:28
lldb_private::plugin::dwarf::DWARFDIE
Definition:
DWARFDIE.h:18
lldb_private::plugin::dwarf::DWARFFormValue
Definition:
DWARFFormValue.h:22
lldb_private::plugin::dwarf::DWARFFormValue::Reference
DWARFDIE Reference() const
Definition:
DWARFFormValue.cpp:547
lldb_private::plugin::dwarf::DWARFFormValue::FormRef
dw_form_t & FormRef()
Definition:
DWARFFormValue.h:50
lldb_private::plugin::dwarf::DWARFFormValue::ExtractValue
bool ExtractValue(const DWARFDataExtractor &data, lldb::offset_t *offset_ptr)
Definition:
DWARFFormValue.cpp:31
lldb_private::plugin::dwarf::DWARFFormValue::FormIsSupported
static bool FormIsSupported(dw_form_t form)
Definition:
DWARFFormValue.cpp:603
lldb_private::plugin::dwarf::DWARFFormValue::SetValue
void SetValue(const ValueType &val)
Definition:
DWARFFormValue.h:54
lldb_private::plugin::dwarf::DWARFFormValue::Value
const ValueType & Value() const
Definition:
DWARFFormValue.h:52
lldb_private::plugin::dwarf::DWARFFormValue::m_unit
const DWARFUnit * m_unit
Definition:
DWARFFormValue.h:92
lldb_private::plugin::dwarf::DWARFFormValue::Dump
void Dump(Stream &s) const
Definition:
DWARFFormValue.cpp:335
lldb_private::plugin::dwarf::DWARFFormValue::AsCString
const char * AsCString() const
Definition:
DWARFFormValue.cpp:460
lldb_private::plugin::dwarf::DWARFFormValue::SetSigned
void SetSigned(int64_t sval)
Definition:
DWARFFormValue.h:74
lldb_private::plugin::dwarf::DWARFFormValue::ValueType
struct lldb_private::plugin::dwarf::DWARFFormValue::ValueTypeTag ValueType
lldb_private::plugin::dwarf::DWARFFormValue::Clear
void Clear()
Definition:
DWARFFormValue.cpp:25
lldb_private::plugin::dwarf::DWARFFormValue::Boolean
bool Boolean() const
Definition:
DWARFFormValue.h:70
lldb_private::plugin::dwarf::DWARFFormValue::IsDataForm
static bool IsDataForm(const dw_form_t form)
Definition:
DWARFFormValue.cpp:588
lldb_private::plugin::dwarf::DWARFFormValue::SetUnit
void SetUnit(const DWARFUnit *unit)
Definition:
DWARFFormValue.h:48
lldb_private::plugin::dwarf::DWARFFormValue::BlockData
const uint8_t * BlockData() const
Definition:
DWARFFormValue.cpp:572
lldb_private::plugin::dwarf::DWARFFormValue::SetUnsigned
void SetUnsigned(uint64_t uval)
Definition:
DWARFFormValue.h:72
lldb_private::plugin::dwarf::DWARFFormValue::Signed
int64_t Signed() const
Definition:
DWARFFormValue.h:73
lldb_private::plugin::dwarf::DWARFFormValue::Address
dw_addr_t Address() const
Definition:
DWARFFormValue.cpp:485
lldb_private::plugin::dwarf::DWARFFormValue::m_form
dw_form_t m_form
Definition:
DWARFFormValue.h:93
lldb_private::plugin::dwarf::DWARFFormValue::GetFixedSize
std::optional< uint8_t > GetFixedSize() const
Definition:
DWARFFormValue.cpp:199
lldb_private::plugin::dwarf::DWARFFormValue::ReferencedUnitAndOffset
std::pair< DWARFUnit *, uint64_t > ReferencedUnitAndOffset() const
If this is a reference to another DIE, return the corresponding DWARFUnit and DIE offset such that Un...
Definition:
DWARFFormValue.cpp:504
lldb_private::plugin::dwarf::DWARFFormValue::IsValid
bool IsValid() const
Definition:
DWARFFormValue.h:77
lldb_private::plugin::dwarf::DWARFFormValue::DWARFFormValue
DWARFFormValue(const DWARFUnit *unit)
Definition:
DWARFFormValue.h:44
lldb_private::plugin::dwarf::DWARFFormValue::Compare
static int Compare(const DWARFFormValue &a, const DWARFFormValue &b)
lldb_private::plugin::dwarf::DWARFFormValue::SkipValue
bool SkipValue(const DWARFDataExtractor &debug_info_data, lldb::offset_t *offset_ptr) const
Definition:
DWARFFormValue.cpp:203
lldb_private::plugin::dwarf::DWARFFormValue::Unsigned
uint64_t Unsigned() const
Definition:
DWARFFormValue.h:71
lldb_private::plugin::dwarf::DWARFFormValue::Form
dw_form_t Form() const
Definition:
DWARFFormValue.h:49
lldb_private::plugin::dwarf::DWARFFormValue::ValueRef
ValueType & ValueRef()
Definition:
DWARFFormValue.h:53
lldb_private::plugin::dwarf::DWARFFormValue::IsBlockForm
static bool IsBlockForm(const dw_form_t form)
Definition:
DWARFFormValue.cpp:574
lldb_private::plugin::dwarf::DWARFFormValue::SetForm
void SetForm(dw_form_t form)
Definition:
DWARFFormValue.h:51
lldb_private::plugin::dwarf::DWARFFormValue::GetUnit
const DWARFUnit * GetUnit() const
Definition:
DWARFFormValue.h:47
lldb_private::plugin::dwarf::DWARFFormValue::DWARFFormValue
DWARFFormValue(const DWARFUnit *unit, dw_form_t form)
Definition:
DWARFFormValue.h:45
lldb_private::plugin::dwarf::DWARFFormValue::DWARFFormValue
DWARFFormValue()=default
lldb_private::plugin::dwarf::DWARFFormValue::eValueTypeBlock
@ eValueTypeBlock
Definition:
DWARFFormValue.h:40
lldb_private::plugin::dwarf::DWARFFormValue::eValueTypeCStr
@ eValueTypeCStr
Definition:
DWARFFormValue.h:39
lldb_private::plugin::dwarf::DWARFFormValue::eValueTypeUnsigned
@ eValueTypeUnsigned
Definition:
DWARFFormValue.h:37
lldb_private::plugin::dwarf::DWARFFormValue::eValueTypeSigned
@ eValueTypeSigned
Definition:
DWARFFormValue.h:38
lldb_private::plugin::dwarf::DWARFFormValue::eValueTypeInvalid
@ eValueTypeInvalid
Definition:
DWARFFormValue.h:36
lldb_private::plugin::dwarf::DWARFFormValue::m_value
ValueType m_value
Definition:
DWARFFormValue.h:94
lldb_private::plugin::dwarf::DWARFUnit
Definition:
DWARFUnit.h:41
dw_offset_t
uint64_t dw_offset_t
Definition:
dwarf.h:31
dw_addr_t
uint64_t dw_addr_t
Definition:
dwarf.h:27
dw_form_t
llvm::dwarf::Form dw_form_t
Definition:
dwarf.h:25
dwarf
Definition:
ABISysV_arc.cpp:61
lldb_private::plugin
Definition:
DWARFExpression.h:23
lldb::offset_t
uint64_t offset_t
Definition:
lldb-types.h:85
lldb_private::plugin::dwarf::DWARFFormValue::ValueTypeTag
Definition:
DWARFFormValue.h:24
lldb_private::plugin::dwarf::DWARFFormValue::ValueTypeTag::data
const uint8_t * data
Definition:
DWARFFormValue.h:32
lldb_private::plugin::dwarf::DWARFFormValue::ValueTypeTag::sval
int64_t sval
Definition:
DWARFFormValue.h:29
lldb_private::plugin::dwarf::DWARFFormValue::ValueTypeTag::value
union lldb_private::plugin::dwarf::DWARFFormValue::ValueTypeTag::@159 value
lldb_private::plugin::dwarf::DWARFFormValue::ValueTypeTag::cstr
const char * cstr
Definition:
DWARFFormValue.h:30
lldb_private::plugin::dwarf::DWARFFormValue::ValueTypeTag::uval
uint64_t uval
Definition:
DWARFFormValue.h:28
lldb_private::plugin::dwarf::DWARFFormValue::ValueTypeTag::ValueTypeTag
ValueTypeTag()
Definition:
DWARFFormValue.h:25
Generated on Fri Dec 6 2024 16:45:13 for LLDB by
1.9.6