a
    –§»a“  ã                   @   s   d Z ddlmZ dd„ ZdS )zMiscellaneous inspection tools
é    )ÚNamedTemporaryFilec                    sR   zddl ‰W n ty&   tdƒ‚Y n0 d‡ ‡fdd„	‰G ‡fdd„dtƒ}|ƒ S )	z�
    Gets the CFG of the disassembly of an ELF object, elf, and renders it
    appropriately depending on the execution environment (terminal/notebook).
    r   Nz$r2pipe package needed for disasm CFGc                    sÆ   | d u rt dƒ‚tdd��˜}| ˆ ¡ | ¡  z2ddg}ˆj|j|d�}| d|  ¡}| ¡  W nB ty¢ } z*dt	|ƒv rŠd	}t
|ƒ‚n|‚W Y d }~n
d }~0 0 W d   ƒ n1 s¸0    Y  |S )
NzNo command givenF)Údeletez-e io.cache=truez-e scr.color=1)Úflagszaf;%szradare2 in PATHz–This feature requires 'radare2' to be installed and available on the system see: https://github.com/radareorg/radare2. Cannot find 'radare2' in $PATH.)Ú
ValueErrorr   ÚwriteÚflushÚopenÚnameÚcmdÚquitÚ	ExceptionÚstrÚRuntimeError)r
   Úfr   ÚrÚdataÚeÚmsg)ÚelfÚr2pipe© úO/home/yuhw/wc/pochoir/venv/lib/python3.9/site-packages/numba/misc/inspection.pyÚget_rendering   s$    
ÿ
8z-disassemble_elf_to_cfg.<locals>.get_renderingc                       s$   e Zd Z‡ fdd„Z‡ fdd„ZdS )z)disassemble_elf_to_cfg.<locals>.DisasmCFGc                    sX   zdd l }W n ty&   tdƒ‚Y n0 ˆ dd�}| dd¡ | |¡}| d¡ d¡S )	Nr   z&graphviz package needed for disasm CFGZagfd©r
   zfontname="Courier",zfontname="Courier",fontsize=6,ÚsvgzUTF-8)ÚgraphvizÚImportErrorr   ÚreplaceZSourceÚpipeÚdecode)Úselfr   Zjupyter_renderingÚsrc©r   r   r   Ú
_repr_svg_-   s    
ÿ
z4disassemble_elf_to_cfg.<locals>.DisasmCFG._repr_svg_c                    s
   ˆ dd�S )NZagfr   r   )r    r"   r   r   Ú__repr__9   s    z2disassemble_elf_to_cfg.<locals>.DisasmCFG.__repr__N)Ú__name__Ú
__module__Ú__qualname__r#   r$   r   r"   r   r   Ú	DisasmCFG+   s   r(   )N)r   r   r   Úobject)r   r(   r   )r   r   r   r   Údisassemble_elf_to_cfg   s    r*   N)Ú__doc__Útempfiler   r*   r   r   r   r   Ú<module>   s   