HEX
Server: LiteSpeed
System: Linux br-asc-web1845.main-hosting.eu 5.14.0-611.42.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Mar 24 05:30:20 EDT 2026 x86_64
User: u790421558 (790421558)
PHP: 8.2.30
Disabled: system, exec, shell_exec, passthru, mysql_list_dbs, ini_alter, dl, symlink, link, chgrp, leak, popen, apache_child_terminate, virtual, mb_send_mail
Upload Files
File: //lib/python3.9/site-packages/elftools/dwarf/__pycache__/compileunit.cpython-39.pyc
a

�#�_B!�@s8ddlmZddlmZddlmZGdd�de�ZdS)	�)�bisect_right�)�DIE�)�dwarf_assertc@sleZdZdZdd�Zdd�Zdd�Zdd	�Zed
d��Z	dd
�Z
dd�Zdd�Zdd�Z
dd�Zdd�ZdS)�CompileUnita� A DWARF compilation unit (CU).

            A normal compilation unit typically represents the text and data
            contributed to an executable by a single relocatable object file.
            It may be derived from several source files,
            including pre-processed "include files"

        Serves as a container and context to DIEs that describe objects and code
        belonging to a compilation unit.

        CU header entries can be accessed as dict keys from this object, i.e.
           cu = CompileUnit(...)
           cu['version']  # version field of the CU header

        To get the top-level DIE describing the compilation unit, call the
        get_top_DIE method.
    cCs4||_||_||_||_||_d|_g|_g|_dS)a� header:
                CU header for this compile unit

            dwarfinfo:
                The DWARFInfo context object which created this one

            structs:
                A DWARFStructs instance suitable for this compile unit

            cu_offset:
                Offset in the stream to the beginning of this CU (its header)

            cu_die_offset:
                Offset in the stream of the top DIE of this CU
        N)�	dwarfinfo�header�structs�	cu_offset�
cu_die_offset�
_abbrev_table�_dielist�_diemap)�selfr	rr
rr�r�>/usr/lib/python3.9/site-packages/elftools/dwarf/compileunit.py�__init__ szCompileUnit.__init__cCs|jjS)z5 Get the DWARF format (32 or 64) for this CU
        )r
�dwarf_format�rrrrrEszCompileUnit.dwarf_formatcCs"|jdur|j�|d�|_|jS)zE Get the abbreviation table (AbbrevTable object) for this CU
        NZdebug_abbrev_offset)r
r�get_abbrev_tablerrrrrJs

�zCompileUnit.get_abbrev_tablecCsPt|j�dkr|jdSt||jjj|jd�}|j�d|�|j�d|j�|S)zo Get the top DIE (which is either a DW_TAG_compile_unit or
            DW_TAG_partial_unit) of this CU
        r�Zcu�stream�offset)	�lenrrrrZdebug_info_secrr�insert)r�toprrr�get_top_DIERs
�zCompileUnit.get_top_DIEcCs|d|j��S)NZunit_length)r
Zinitial_length_field_sizerrrr�sizefszCompileUnit.sizecCs<t|j|ko|j|jknd||jf�|�|�S)a� Obtain a DIE contained in this CU from a reference.

            refaddr:
                The offset into the .debug_info section, which must be
                contained in this CU or a DWARFError will be raised.

            When using a reference class attribute with a form that is
            relative to the compile unit, add unit add the compile unit's
            .cu_addr before calling this function.
        z$refaddr %s not in DIE range of CU %s)rrrr�_get_cached_DIE)rZrefaddrrrr�get_DIE_from_refaddrjs
 �z CompileUnit.get_DIE_from_refaddrcCs|�|���S)z� Iterate over all the DIEs in the CU, in order of their appearance.
            Note that null DIEs will also be returned.
        )�_iter_DIE_subtreerrrrr�	iter_DIEs|szCompileUnit.iter_DIEsccs�|js
dS|j|j}|�|�}|�|�|��r<||_dS|V|jsT||j7}qd|jvrv|jd}|j|j	}q|jdur�|�
|�D]}q�|jj|jj}qdS)z� Given a DIE, yields either its children, without null DIE list
            terminator, or nothing, if that DIE has no children.

            The null DIE terminator is saved in that DIE when iteration ended.
        NZ
DW_AT_sibling)�has_childrenrrrZ
set_parentZis_null�_terminatorZ
attributes�valuer�iter_DIE_children)r�dieZ
cur_offset�childZsibling�_rrrr&�s$




zCompileUnit.iter_DIE_childrencCs
|j|S)z6 Implement dict-like access to header entries
        )r	)r�namerrr�__getitem__�szCompileUnit.__getitem__ccs<|V|jr8|��D]}|�|�D]
}|Vq"q|jVdS)zp Given a DIE, this yields it with its subtree including null DIEs
            (child list terminators).
        N)r#Z
iter_childrenr!r$)rr'�c�drrrr!�s
zCompileUnit._iter_DIE_subtreecCsf|��j}t|j|�}||j|dkr8|j|d}n*t|||d�}|j�||�|j�||�|S)a� Given a DIE offset, look it up in the cache.  If not present,
            parse the DIE and insert it into the cache.

            offset:
                The offset of the DIE in the debug_info section to retrieve.

            The stream reference is copied from the top DIE.  The top die will
            also be parsed and cached if needed.

            See also get_DIE_from_refaddr(self, refaddr).
        rr)rrrrrrr)rrZtop_die_stream�ir'rrrr�s
zCompileUnit._get_cached_DIEN)�__name__�
__module__�__qualname__�__doc__rrrr�propertyrr r"r&r+r!rrrrrrs%
/rN)Zbisectrr'rZcommon.utilsr�objectrrrrr�<module>	s