LIEF: Library to Instrument Executable Formats Version 2.0.0
Loading...
Searching...
No Matches
LIEF::dwarf::Variable Class Reference

This class represents a DWARF variable which can be owned by a dwarf::Function or a dwarf::CompilationUnit. More...

#include <Variable.hpp>

Classes

class  Iterator

Public Member Functions

 Variable (std::unique_ptr< details::Variable > impl)
std::string_view name () const
 Name of the variable (usually demangled).
std::string_view linkage_name () const
 The name of the variable which is used for linking (DW_AT_linkage_name).
result< int64_t > address () const
 Address of the variable.
result< uint64_t > size () const
 Return the size of the variable (or a lief_errors if it can't be resolved).
bool is_constexpr () const
 Whether it's a constexpr variable.
bool is_stack_based () const
 Whether this variable is allocated on the stack.
std::unique_ptr< Location > location () const
 Location of this variable.
std::unique_ptr< Location > location (uint64_t pc) const
 Location of this variable when PC is at the given address.
std::vector< LocationEntry > locations () const
 All the location entries of this variable.
debug_location_t debug_location () const
 The original source location where the variable is defined.
std::unique_ptr< Type > type () const
 Return the type of this variable.
std::unique_ptr< Scope > scope () const
 Return the scope in which this variable is defined.
std::string_view description () const
 Description (DW_AT_description) of the variable or an empty string.
std::string to_decl (const DeclOpt &opt=DeclOpt()) const
 Generates a C/C++ definition for this variable.
 ~Variable ()

Detailed Description

This class represents a DWARF variable which can be owned by a dwarf::Function or a dwarf::CompilationUnit.

Constructor & Destructor Documentation

◆ Variable()

LIEF::dwarf::Variable::Variable ( std::unique_ptr< details::Variable > impl)

◆ ~Variable()

LIEF::dwarf::Variable::~Variable ( )

References Variable().

Member Function Documentation

◆ address()

result< int64_t > LIEF::dwarf::Variable::address ( ) const

Address of the variable.

If the variable is static, it returns the virtual address where it is defined. If the variable is stack-based, it returns the relative offset from the frame based register.

If the address can't be resolved, it returns a lief_errors.

References address().

Referenced by address().

◆ debug_location()

debug_location_t LIEF::dwarf::Variable::debug_location ( ) const

The original source location where the variable is defined.

References debug_location().

Referenced by debug_location().

◆ description()

std::string_view LIEF::dwarf::Variable::description ( ) const

Description (DW_AT_description) of the variable or an empty string.

References description(), and LIEF_LIFETIMEBOUND.

Referenced by description().

◆ is_constexpr()

bool LIEF::dwarf::Variable::is_constexpr ( ) const

Whether it's a constexpr variable.

References is_constexpr().

Referenced by is_constexpr().

◆ is_stack_based()

bool LIEF::dwarf::Variable::is_stack_based ( ) const

Whether this variable is allocated on the stack.

References is_stack_based().

Referenced by is_stack_based().

◆ linkage_name()

std::string_view LIEF::dwarf::Variable::linkage_name ( ) const

The name of the variable which is used for linking (DW_AT_linkage_name).

This name differs from name() as it is usually mangled. The function returns an empty string if the linkage name is not available.

References LIEF_LIFETIMEBOUND, and linkage_name().

Referenced by linkage_name().

◆ location() [1/2]

std::unique_ptr< Location > LIEF::dwarf::Variable::location ( ) const

Location of this variable.

References location().

Referenced by location(), and location().

◆ location() [2/2]

std::unique_ptr< Location > LIEF::dwarf::Variable::location ( uint64_t pc) const

Location of this variable when PC is at the given address.

References location().

◆ locations()

std::vector< LocationEntry > LIEF::dwarf::Variable::locations ( ) const

All the location entries of this variable.

References locations().

Referenced by locations().

◆ name()

std::string_view LIEF::dwarf::Variable::name ( ) const

Name of the variable (usually demangled).

References LIEF_LIFETIMEBOUND, and name().

Referenced by name().

◆ scope()

std::unique_ptr< Scope > LIEF::dwarf::Variable::scope ( ) const

Return the scope in which this variable is defined.

References LIEF_LIFETIMEBOUND, and scope().

Referenced by scope().

◆ size()

result< uint64_t > LIEF::dwarf::Variable::size ( ) const

Return the size of the variable (or a lief_errors if it can't be resolved).

This size is defined by its type.

References size().

Referenced by size().

◆ to_decl()

std::string LIEF::dwarf::Variable::to_decl ( const DeclOpt & opt = DeclOpt()) const

Generates a C/C++ definition for this variable.

References to_decl().

Referenced by to_decl().

◆ type()

std::unique_ptr< Type > LIEF::dwarf::Variable::type ( ) const

Return the type of this variable.

References LIEF_LIFETIMEBOUND, and type().

Referenced by type().


The documentation for this class was generated from the following file: