
    xKg                     :    d Z ddlmZmZ ddlZddlZddlmZ d Zy)zMiscellaneous inspection tools
    )NamedTemporaryFileTemporaryDirectoryN)NumbaWarningc                      	 ddl d fd	 G fddt              } |       S # t        $ r t        d      w xY w)z
    Gets the CFG of the disassembly of an ELF object, elf, at mangled name,
    mangled_symbol, and renders it appropriately depending on the execution
    environment (terminal/notebook).
    r   Nz$r2pipe package needed for disasm CFGc                    ddl m} | t        d      t               5 }t	        d|      5 }|j                         |j                          d d d        d}	 t        j                  j                  j                         d}t        j                  j                  ||      } |       }|j                  ||j                  f       |}d}	 g d
}j#                  ||      }|j%                  d       |r<d d }|j%                  d       |j%                  d| d       |j%                  d       |j%                  d| z        }|j'                          	 d d d        |S # 1 sw Y   xY w# t        $ r:}	d|	 d	}
t        j                  t!        |
             j                  }Y d }	~	d }	~	ww xY w# t        $ r!}	dt)        |	      v rd}
t+        |
      |	d }	~	ww xY w# 1 sw Y   S xY w)Nr   )	ToolchainzNo command givenF)deletedirz.soTzALinking the ELF object with the distutils toolchain failed with: z\. Disassembly will still work but might be less accurate and will not use DWARF information.)z-2z-e io.cache=truez-e scr.color=1z-e asm.dwarf=truez-e scr.utf8=true)flagsaaaaaa=   ze bin.demangle=falsezs `is~ z[1]`ze bin.demangle=truez%szradare2 in PATHzThis feature requires 'radare2' to be installed and available on the system see: https://github.com/radareorg/radare2. Cannot find 'radare2' in $PATH.)numba.pycc.platformr   
ValueErrorr   r   writeflushospathbasenamenamejoinlink_shared	Exceptionwarningswarnr   opencmdquitstrRuntimeError)r   r   tmpdirflinkedraw_dso_name
linked_dsotcobj_to_analyseemsgr   rmangled_symbol_61chardataelfmangled_symbolr2pipes                  Y/home/alanp/www/video.onchill/myenv/lib/python3.12/site-packages/numba/misc/inspection.pyget_renderingz-disassemble_elf_to_cfg.<locals>.get_rendering   s   1;/00!V#5f=	 >
 F("$''"2"2166":!;3?WW\\&,?
[zAFF95!+ KKeK<h ,:3B,?)EE01EEG$9#:$?@EE/0uuTCZ(a "t q >=  	(''(c *&& l3/0!"	(D  $A.=C 's++Gc "t sf   G$"E$
G$A4E1B
F7$E.	)G$1	F4:0F/*G$/F44G$7	G! GG!!G$$G.c                   "    e Zd Z fdZ fdZy))disassemble_elf_to_cfg.<locals>.DisasmCFGc                     	 dd l } d      }|j                  dd       |j	                  |      }|j                  d      j                  d      S # t        $ r t        d      w xY w)	Nr   z&graphviz package needed for disasm CFGagfdr   zfontname="Courier",zfontname="Courier",fontsize=6,svgzUTF-8)graphvizImportErrorr   replaceSourcepipedecode)selfr7   jupyter_renderingsrcr0   s       r/   
_repr_svg_z4disassemble_elf_to_cfg.<locals>.DisasmCFG._repr_svg_X   su    M !.& 9%%&;&FH//"34C88E?))'22  M"#KLLMs   A A(c                      d      S )Nagfr5    )r=   r0   s    r/   __repr__z2disassemble_elf_to_cfg.<locals>.DisasmCFG.__repr__d   s     U++    N)__name__
__module____qualname__r@   rD   )r0   s   r/   	DisasmCFGr2   V   s    
	3	,rE   rI   )N)r.   r8   r   object)r,   r-   rI   r0   r.   s   `` @@r/   disassemble_elf_to_cfgrK   
   sH    C?B,F ," ;k  CABBCs   * ?)	__doc__tempfiler   r   r   r   numba.core.errorsr   rK   rC   rE   r/   <module>rO      s    ; 	  *]rE   