mate_query.cpg.models.node.dwarf module

Nodes in the source-level AST (as recovered from DWARF debug info)

At runtime, the models here are accessed via attributes on a CPG, not directly.

class mate_query.cpg.models.node.dwarf.ArrayType(uuid: str, kind: NodeKind, attributes: Dict[str, Any] = {})

Bases: mate_query.cpg.models.node.dwarf.DWARFType

A DWARF array type, corresponding to a C or C++ array type.

Parameters
  • uuid (str) –

  • kind (NodeKind) –

  • attributes (Dict[str, Any]) –

property base_type: sqlalchemy.orm.relationships.RelationshipProperty
subrange

Returns a DWARFSubrange for this array type’s subrange.

The subrange can be a CountSubrange, GlobalVariableSubrange, or LocalVariableSubrange.

class mate_query.cpg.models.node.dwarf.BasicType(uuid: str, kind: NodeKind, attributes: Dict[str, Any] = {})

Bases: mate_query.cpg.models.node.dwarf.DWARFType

A basic DWARF type, corresponding to basic C or C++ types like int.

Parameters
  • uuid (str) –

  • kind (NodeKind) –

  • attributes (Dict[str, Any]) –

is_unsigned

Whether this type is unsigned.

class mate_query.cpg.models.node.dwarf.ClassType(uuid: str, kind: NodeKind, attributes: Dict[str, Any] = {})

Bases: mate_query.cpg.models.node.dwarf.DWARFType

A DWARF class type, corresponding to a C++ class.

Parameters
  • uuid (str) –

  • kind (NodeKind) –

  • attributes (Dict[str, Any]) –

property base_type: sqlalchemy.orm.relationships.RelationshipProperty
property members: sqlalchemy.orm.relationships.RelationshipProperty

Returns the member types of this class.

property template_params: sqlalchemy.orm.relationships.RelationshipProperty

Returns the template parameter types for this class.

class mate_query.cpg.models.node.dwarf.CompositeCachedType(uuid: str, kind: NodeKind, attributes: Dict[str, Any] = {})

Bases: mate_query.cpg.models.node.dwarf.DWARFType

A composite cached DWARF type.

Parameters
  • uuid (str) –

  • kind (NodeKind) –

  • attributes (Dict[str, Any]) –

property recursive_type: sqlalchemy.orm.relationships.RelationshipProperty
class mate_query.cpg.models.node.dwarf.CompositeType(uuid: str, kind: NodeKind, attributes: Dict[str, Any] = {})

Bases: mate_query.cpg.models.node.dwarf.DWARFType

A composite DWARF type.

Parameters
  • uuid (str) –

  • kind (NodeKind) –

  • attributes (Dict[str, Any]) –

property base_type: sqlalchemy.orm.relationships.RelationshipProperty

The base type.

property elements: sqlalchemy.orm.relationships.RelationshipProperty

The member elements of this composite type.

class mate_query.cpg.models.node.dwarf.DWARFArgument(uuid: str, kind: NodeKind, attributes: Dict[str, Any] = {})

Bases: mate_query.cpg.models.node._typechecking.NodeMixin

A DWARF-level formal parameter to a function

Parameters
  • uuid (str) –

  • kind (NodeKind) –

  • attributes (Dict[str, Any]) –

arg
Return type

int

artificial
Return type

bool

dwarf_location

Location of this variable in memory, expressed as either an absolute address or an offset from a register

Return type

list

property dwarf_scope: mate_common.models.cpg_types.dwarf.DWARFScope

Returns the DWARFScope for this function argument.

from_variadic_template

True if this parameter is from a variadic template expansion; does not exist otherwise

Return type

bool

name

The source-level name of this formal parameter

Return type

str

original_name

The original name of this argument, with no variadic index suffix

Return type

str

parameter
Return type

bool

parameter_index

The index of this argument into the overall list of arguments to the enclosing function

Return type

int

source_location

The source location for a program feature

Return type

dict

source_scope

Source scoping information using DWARF

Return type

dict

template_index

The index of this argument into the variadic arguments of its group (i.e., those with the same name)

Return type

int

type_id
Return type

str

variadic_index

The index of this argument into all variadic arguments of this function

Return type

int

class mate_query.cpg.models.node.dwarf.DWARFLocalVariable(uuid: str, kind: NodeKind, attributes: Dict[str, Any] = {})

Bases: mate_query.cpg.models.node._typechecking.NodeMixin

A DWARF-level stack-local variable

Parameters
  • uuid (str) –

  • kind (NodeKind) –

  • attributes (Dict[str, Any]) –

arg
Return type

int

artificial

Whether the variable is artificial

Return type

bool

dwarf_location

Location of this variable in memory, expressed as either an absolute address or an offset from a register

Return type

list

property dwarf_scope: mate_common.models.cpg_types.dwarf.DWARFScope

Returns the DWARFScope for this local variable.

name
Return type

str

parameter
Return type

bool

source_location

The source location for a program feature

Return type

dict

source_scope

Source scoping information using DWARF

Return type

dict

type_id

A compressed representation of the function’s DWARF type

Return type

str

class mate_query.cpg.models.node.dwarf.DWARFType(uuid: str, kind: NodeKind, attributes: Dict[str, Any] = {})

Bases: mate_query.cpg.models.node._typechecking.NodeMixin

The DWARF representation of a type in the program

Parameters
  • uuid (str) –

  • kind (NodeKind) –

  • attributes (Dict[str, Any]) –

all_derived_types

Returns a list of all DWARFType instances that derive from this type, including indirect derivations (e.g. T -> T* -> const T*).

property arguments: sqlalchemy.orm.relationships.RelationshipProperty

A list of DWARFArgument instances that have this type.

property children: sqlalchemy.orm.relationships.RelationshipProperty

The child types of this type.

common

A DWARFTypeCommonInfo model of this type’s baseline information.

property deriving_types: sqlalchemy.orm.relationships.RelationshipProperty

Any types that derive directly from this type.

For the fully expanded derivation set, use all_derived_types.

dwarf_type

A structured representation of C types, using DWARF identifiers.

Return type

dict

is_array

Whether this type is an array type.

is_basic

Whether this type is basic, i.e. DWARFTypeKind.BASIC.

is_class

Whether this type is a class type.

is_composite
is_const

Whether this type is const.

is_derived

Whether this type is derived from another type.

is_enum

Whether this type is an enum type.

is_member

Whether this type is a member type.

is_pointer

Whether this type is a pointer type.

is_reference

Whether this type is an (lvalue) reference.

is_rvalue_reference

Whether this type is an rvalue reference.

is_structure

Whether this type is a struct type.

is_subroutine

Whether this type is a subroutine (i.e., function) type.

is_union

Whether this type is a union type.

is_varargs

Whether this type is a variable argument (vaarg) type.

is_void

Whether this type is a void type.

property local_variables: sqlalchemy.orm.relationships.RelationshipProperty

A list of DWARFLocalVariable instances that have this type.

name

The type’s name.

property parents: sqlalchemy.orm.relationships.RelationshipProperty

The parent types of this type.

pretty_string
Return type

str

tag

The type’s tag (i.e., DW_TAG_*).

type_kind

The type’s DWARFTypeKind

class mate_query.cpg.models.node.dwarf.DerivedType(uuid: str, kind: NodeKind, attributes: Dict[str, Any] = {})

Bases: mate_query.cpg.models.node.dwarf.DWARFType

A DWARF derived type.

Parameters
  • uuid (str) –

  • kind (NodeKind) –

  • attributes (Dict[str, Any]) –

property base_type: sqlalchemy.orm.relationships.RelationshipProperty
class mate_query.cpg.models.node.dwarf.EnumType(uuid: str, kind: NodeKind, attributes: Dict[str, Any] = {})

Bases: mate_query.cpg.models.node.dwarf.DWARFType

A DWARF enumeration type, corresponding to a C or C++ enum type.

Parameters
  • uuid (str) –

  • kind (NodeKind) –

  • attributes (Dict[str, Any]) –

property base_type: sqlalchemy.orm.relationships.RelationshipProperty
enumerators

Returns a list of DWARFEnumerator variants.

class mate_query.cpg.models.node.dwarf.StructureType(uuid: str, kind: NodeKind, attributes: Dict[str, Any] = {})

Bases: mate_query.cpg.models.node.dwarf.DWARFType

A DWARF struct type, corresponding to a C or C++ struct.

Parameters
  • uuid (str) –

  • kind (NodeKind) –

  • attributes (Dict[str, Any]) –

property base_type: sqlalchemy.orm.relationships.RelationshipProperty
property members: sqlalchemy.orm.relationships.RelationshipProperty
class mate_query.cpg.models.node.dwarf.SubroutineType(uuid: str, kind: NodeKind, attributes: Dict[str, Any] = {})

Bases: mate_query.cpg.models.node.dwarf.DWARFType

A DWARF subroutine type, corresponding to a C or C++ function or method type.

Parameters
  • uuid (str) –

  • kind (NodeKind) –

  • attributes (Dict[str, Any]) –

has_varargs

Returns whether the subroutine has a variable number of arguments.

property param_types: sqlalchemy.orm.relationships.RelationshipProperty

Returns the parameter type for each parameter in the subroutine.

property return_type: sqlalchemy.orm.relationships.RelationshipProperty

Returns the subroutine’s return type.

class mate_query.cpg.models.node.dwarf.UnionType(uuid: str, kind: NodeKind, attributes: Dict[str, Any] = {})

Bases: mate_query.cpg.models.node.dwarf.DWARFType

A DWARF union type, corresponding to a C or C++ union type.

Parameters
  • uuid (str) –

  • kind (NodeKind) –

  • attributes (Dict[str, Any]) –

property base_type: sqlalchemy.orm.relationships.RelationshipProperty
property members: sqlalchemy.orm.relationships.RelationshipProperty

Returns the member types of this union.