CURRENT PATH:
/
usr
/
lib
/
python3.9
/
site-packages
/
elftools
/
dwarf
/
__pycache__
/
[ ⬅ KEMBALI ]
|
[ HOME ]
Upload File:
Upload Ke Sini
Dir Baru
File Baru
Editing:
die.cpython-39.pyc
a �#�_�( � @ sn d dl mZmZ d dlZddlmZ ddlmZmZ ddl m Z mZ ddlm Z ed d �ZG dd� de�ZdS ) � )� namedtuple�OrderedDictN� )� DWARFError)� bytes2str� iteritems)�struct_parse�preserve_stream_pos� )�DW_FORM_raw2name�AttributeValuez name form value raw_value offsetc @ sx e Zd ZdZdd� Zdd� Zdd� Zdd � Zd d� Zdd � Z dd� Z dd� Zdd� Zdd� Z dd� Zdd� Zdd� ZdS )�DIEa� A DWARF debugging information entry. On creation, parses itself from the stream. Each DIE is held by a CU. Accessible attributes: tag: The DIE tag size: The size this DIE occupies in the section offset: The offset of this DIE in the stream attributes: An ordered dictionary mapping attribute names to values. It's ordered to preserve the order of attributes in the section has_children: Specifies whether this DIE has children abbrev_code: The abbreviation code pointing to an abbreviation entry (note that this is for informational pusposes only - this object interacts with its abbreviation table transparently). See also the public methods. c C sT || _ | j j| _|| _|| _t� | _d| _d| _d| _d| _ d| _ d| _| �� dS )a cu: CompileUnit object this DIE belongs to. Used to obtain context information (structs, abbrev table, etc.) stream, offset: The stream and offset into it where this DIE's data is located Nr ) �cu� dwarfinfo�stream�offsetr � attributes�tag�has_children�abbrev_code�size�_terminator�_parent� _parse_DIE)�selfr r r � r �6/usr/lib/python3.9/site-packages/elftools/dwarf/die.py�__init__G s zDIE.__init__c C s | j du S )z Is this a null entry? N)r �r r r r �is_null` s zDIE.is_nullc C s� | j | }|jdv r.| jj|j }| j�|�S |jdv rH| jj�|j�S |jdv rbtd|j ��n&|jdv r|td|j ��ntd| ��dS ) z� Return the DIE referenced by the named attribute of this DIE. The attribute must be in the reference attribute class. name: The name of the attribute in the reference class. )ZDW_FORM_ref1ZDW_FORM_ref2ZDW_FORM_ref4ZDW_FORM_ref8ZDW_FORM_refZDW_FORM_ref_addrZDW_FORM_ref_sig8z%s (type unit by signature))ZDW_FORM_ref_sup4ZDW_FORM_ref_sup8z %s to dwoz*%s is not a reference class form attributeN) r �formr � cu_offset� raw_valueZget_DIE_from_refaddrr �NotImplementedErrorr )r �name�attrZrefaddrr r r �get_DIE_from_attributee s zDIE.get_DIE_from_attributec C s | j du r| �� | j S )zt Return the parent DIE of this DIE, or None if the DIE has no parent (i.e. is a top-level DIE). N)r �_search_ancestor_offspringr r r r � get_parent{ s zDIE.get_parentc C sN | j �dd�}|rt|j�nd}| j �dd�}|r<t|j�nd}tj�||�S )aF Return the full path filename for the DIE. The filename is the join of 'DW_AT_comp_dir' and 'DW_AT_name', either of which may be missing in practice. Note that its value is usually a string taken from the .debug_string section and the returned value will be a string. ZDW_AT_comp_dirN� Z DW_AT_name)r �getr �value�os�path�join)r Z comp_dir_attrZcomp_dirZ fname_attr�fnamer r r � get_full_path� s zDIE.get_full_pathc C s | j �| �S )z+ Iterates all children of this DIE )r Ziter_DIE_childrenr r r r � iter_children� s zDIE.iter_childrenc c s4 | � � }|r*|�� D ]}|| ur|V qnt� �dS )z( Yield all siblings of this DIE N)r( r1 � StopIteration)r �parentZsiblingr r r � iter_siblings� s zDIE.iter_siblingsc C s || _ d S �N)r )r Zdier r r � set_parent� s zDIE.set_parentc C s� | j �� }|j| jk r�|}|�� D ]}|�|� |j| jkr"|}q"|jr\|jj| jkr\|j}||u rztd| j| j jf ��|}q dS )a� Search our ancestors identifying their offspring to find our parent. DIEs are stored as a flattened tree. The top DIE is the ancestor of all DIEs in the unit. Each parent is guaranteed to be at an offset less than their children. In each generation of children the sibling with the closest offset not greater than our offset is our ancestor. zoffset %s not in CU %s DIE treeN) r Zget_top_DIEr r1 r6 r r � ValueErrorr! )r �search�prev�childr r r r'