U
    iâËdr  ã                   @   sÐ   d dl mZ d dlZd dlZd dlZd dlZd dlmZ d dl	Z	d dl
Z
d dlmZmZmZ d dlmZmZ d dlmZ d dlmZ d dlmZ d dlmZ G d	d
„ d
eƒZG dd„ deƒZedkrÌe	 ¡  dS )é    )Ú
namedtupleN)Údedent)ÚTestCaseÚoverride_configÚignore_internal_warnings)ÚjitÚnjit)Útypes)Údefault_manager)ÚNumbaDebugInfoWarningc                   @   s@   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
d„ Zdd„ Z	dS )ÚTestDebugInfozF
    These tests only checks the compiled assembly for debuginfo.
    c                 C   s   |  |¡ | |¡S ©N)ÚcompileZinspect_asm©ÚselfÚfnÚsig© r   úS/home/sam/Atlas/atlas_env/lib/python3.8/site-packages/numba/tests/test_debuginfo.pyÚ_getasm   s    
zTestDebugInfo._getasmc                 C   s>   | j ||d�}t d|tj¡}|d k	}| j||d| d� d S )N©r   z\.section.+debugzdebug info not found in:
%s)Úmsg)r   ÚreÚsearchÚIÚassertEqual)r   r   r   ÚexpectÚasmÚmÚgotr   r   r   Ú_check    s    zTestDebugInfo._checkc                 C   s,   t ddd�dd„ ƒ}| j|tjfdd� d S )NTF©ÚnopythonÚdebugc                 S   s   | S r   r   ©Úxr   r   r   Úfoo'   s    z3TestDebugInfo.test_no_debuginfo_in_asm.<locals>.foo©r   r   ©r   r    r	   Úint32©r   r&   r   r   r   Útest_no_debuginfo_in_asm&   s    

z&TestDebugInfo.test_no_debuginfo_in_asmc                 C   s,   t ddd�dd„ ƒ}| j|tjfdd� d S )NTr!   c                 S   s   | S r   r   r$   r   r   r   r&   .   s    z0TestDebugInfo.test_debuginfo_in_asm.<locals>.foor'   r(   r*   r   r   r   Útest_debuginfo_in_asm-   s    

z#TestDebugInfo.test_debuginfo_in_asmc              	   C   sh   t ddƒ�T tdd�dd„ ƒ}| j|tjfdd� tddd	�d
d„ ƒ}| j|tjfdd� W 5 Q R X d S )NÚDEBUGINFO_DEFAULTé   T)r"   c                 S   s   | S r   r   r$   r   r   r   r&   7   s    z4TestDebugInfo.test_environment_override.<locals>.foor'   Fr!   c                 S   s   | S r   r   r$   r   r   r   Úbar=   s    z4TestDebugInfo.test_environment_override.<locals>.bar)r   r   r    r	   r)   )r   r&   r/   r   r   r   Útest_environment_override4   s    


z'TestDebugInfo.test_environment_overridec              	      st  t dd�dd„ ƒ‰ t dd�dd„ ƒ‰t ‡ ‡fdd	„ƒ}td
dƒ� |tjƒ}W 5 Q R X |  || tj¡¡ | |jd ¡}t 	|¡}|j
|jd  jj‰‡fdd„|jD ƒ}|  t|ƒd¡ |d }g }|jD ],}|jD ] }	|	jdkrØ| t|	ƒ ¡ ¡ qØqÎd}
d}ˆj
ˆjd  jj}|D ]>}|
�s8t d|¡�r8d}
|�st d|› d�|¡�rd}�q|  |
¡ |  |¡ d S )NT)Úforceinlinec                 S   s
   t  | ¡S r   )ÚmathÚsinr$   r   r   r   r/   G   s    z:TestDebugInfo.test_llvm_inliner_flag_conflict.<locals>.barFc                 S   s
   t  | ¡S r   )r2   Úcosr$   r   r   r   ÚbazK   s    z:TestDebugInfo.test_llvm_inliner_flag_conflict.<locals>.bazc                    s   ˆ | ƒ}ˆ| ƒ}||fS r   r   )r%   ÚaÚb)r/   r5   r   r   r&   O   s    z:TestDebugInfo.test_llvm_inliner_flag_conflict.<locals>.foor-   r.   r   c                    s   g | ]}|j ˆ kr|‘qS r   ©Úname©Ú.0r%   r8   r   r   Ú
<listcomp>_   s     
 zATestDebugInfo.test_llvm_inliner_flag_conflict.<locals>.<listcomp>Úcallz.*llvm.sin.f64.*z.*)r   r   ÚnpÚpiZassertPreciseEqualÚpy_funcÚinspect_llvmÚ
signaturesÚllvmÚparse_assemblyÚ	overloadsÚfndescÚmangled_nameÚ	functionsr   ÚlenÚblocksÚinstructionsÚopcodeÚappendÚstrÚstripr   ÚmatchÚ
assertTrue)r   r&   ÚresultÚfull_irÚmoduleÚfuncsÚfuncZf_namesZblkÚstmtZ	found_sinZ	found_bazZbaz_namer%   r   )r/   r5   r9   r   Útest_llvm_inliner_flag_conflictB   s<    






z-TestDebugInfo.test_llvm_inliner_flag_conflictN)
Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r    r+   r,   r0   rX   r   r   r   r   r      s   r   c                   @   s°   e Zd ZdZddiZdd„ Zdd„ Zdd	„ Zd
d„ Zdd„ Z	dd„ Z
ejed�dd„ ƒZejed�dd„ ƒZdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd „ Zd!d"„ Zd#d$„ Zd%S )&ÚTestDebugInfoEmissionz1 Tests that debug info is emitted correctly.
    Z	NUMBA_OPTÚ0c              
   C   s6   t ddƒ�" | |¡ | |¡W  5 Q R £ S Q R X d S )NÚOPTr   )r   r   rA   r   r   r   r   Ú_get_llvmir�   s    
z!TestDebugInfoEmission._get_llvmirc                 C   s@   |   ||¡ ¡ }t d¡}g }|D ]}| |¡r"| |¡ q"|S )Nz![0-9]+ =.*)r`   Ú
splitlinesr   r   rP   rM   )r   r   r   ÚllZmeta_reÚmetadataÚliner   r   r   Ú_get_metadata†   s    

z#TestDebugInfoEmission._get_metadatac                 C   s@   t ƒ }t d¡}|D ]&}| |¡}|r| ¡ \}}|||< q|S )zdGets the map of DI label to md, e.g.
        '!33' -> '!{!"branch_weights", i32 1, i32 99}'
        z(![0-9]+) = (.*))Údictr   r   rP   Úgroups)r   rc   Úmetadata_definition_mapZmeta_definition_splitrd   ÚmatchedÚdbg_valÚinfor   r   r   Ú_get_metadata_map�   s    


z'TestDebugInfoEmission._get_metadata_mapc                 C   sJ   |   |¡}tƒ }| ¡ D ],}t d|¡}|rt| d¡ƒ}| |¡ q|S )Nz!DILocation\(line: (\d+),r.   )rl   ÚsetÚvaluesr   rP   ÚintÚgroupÚadd)r   rc   Z
md_def_mapÚlinesÚmdr   Úlnr   r   r   Ú_get_lines_from_debuginfoœ   s    
z/TestDebugInfoEmission._get_lines_from_debuginfoc                 C   sX   t dd�dd„ ƒ}| j|dd�}|d }|  d|d d	… ¡ |  d
|¡ |  d|¡ d S )NT©r#   c                   S   s   d S r   r   r   r   r   r   r&   ª   s    z/TestDebugInfoEmission.test_DW_LANG.<locals>.foor   r   r   z!0é   z,!DICompileUnit(language: DW_LANG_C_plus_pluszproducer: "clang (Numba)")r   re   r   ÚassertIn)r   r&   rc   ZDICompileUnitr   r   r   Útest_DW_LANG¨   s    
ÿz"TestDebugInfoEmission.test_DW_LANGc           #         s®  t ddd�dd„ ƒ}tjf}| j||d�}| j||d�}t |¡}|j|jd  j	j
‰‡fdd	„|jD ƒ}|  t|ƒd
¡ |d }dd	„ |jD ƒ}|  t|ƒd
¡ |d }	dd	„ |	jD ƒ}
dddh}d}|
D ]6}|j|krð| |j¡ |sîd}qÌ|rÌ|rÌ|  d¡ qÌ|  |d¡ tƒ }t d¡}d}|
D ]˜}t|ƒ‰ | ˆ ¡}|�shd}|  t‡ fdd	„|D ƒƒ¡ �q(| ¡ }|  t|ƒd
¡ |d }t|d
d… ƒ}|dk�r°|  ||k¡ |}| |¡ �q(t  |¡\}‰|  !|¡}dd
ddg}‡fdd	„|D ƒ}t"t#|dd„ d�|ƒD ]$\}}|| }|  $d|› �|¡ �qd}t |¡}| %¡ D ]T} | | ¡}|�rJ| ¡ }|  t|ƒd
¡ t|d ƒ}!ˆd
 }"|  |!|"¡  �qª�qJ|  d ¡ dS )!z: Tests that DILocation information is reasonable.
        TÚnumpy)r#   Zerror_modelc                 S   s$   | d }|d }|| }t |ƒ |S )Ng®Gáz®ó?g¸…ëQ¸@)Úprint)r6   r7   ÚcÚdr   r   r   r&   ¸   s
    z2TestDebugInfoEmission.test_DILocation.<locals>.foor   r   c                    s   g | ]}|j ˆ kr|‘qS r   r8   r:   r8   r   r   r<   Ù   s     
 z9TestDebugInfoEmission.test_DILocation.<locals>.<listcomp>r.   c                 S   s   g | ]}|‘qS r   r   r:   r   r   r   r<   Ü   s     c                 S   s   g | ]}|j d kr|‘qS )r=   )rL   r:   r   r   r   r<   á   s     
 ZfaddZfmulZfdivFzMath opcodes are not contiguouszMath opcodes were not foundz.*!dbg (![0-9]+).*$éÿÿÿÿ)zalloca zstore c                    s   g | ]}|ˆ k‘qS r   r   r:   )Úinst_as_strr   r   r<   û   s     Nrw   é   c                    s   g | ]}ˆ d  | ‘qS )rw   r   r:   )Úpysrc_line_startr   r   r<     s     c                 S   s   t | dd … ƒS ©Nr.   )ro   r$   r   r   r   Ú<lambda>  ó    z7TestDebugInfoEmission.test_DILocation.<locals>.<lambda>)Úkeyzline: z1.*!DILocalVariable\(name: "a",.*line: ([0-9]+),.*z%Assertion on DILocalVariable not made)&r   r	   Úfloat64re   r`   rC   rD   rE   rB   rF   rG   rH   r   rI   rJ   ÚassertGreaterrK   rL   ÚremoveZfailÚassertFalserm   r   r   rN   rP   rQ   Úanyrg   ro   rq   ÚinspectÚgetsourcelinesrl   ÚzipÚsortedrx   rn   )#r   r&   r   rc   rS   rT   rU   rV   rJ   ÚblockZinstrsZ	op_expectÚstartedr%   Zline2dbgZ
re_dbg_refÚfoundÚinstrri   Úacceptedrg   rj   Zint_dbg_valÚpysrcrh   ÚoffsetsZ
pyln_rangeÚkÚline_noZdilocation_infoÚexprZmatch_local_var_aÚentryZdbg_lineZdefliner   )r   r9   r�   r   Útest_DILocationµ   s†    








ýÿ


z%TestDebugInfoEmission.test_DILocation)Úenvvarsc                    s&  t dd�dd„ ƒ}|dƒ | |jd ¡}t |¡}|j|jd  jj‰ ‡ fdd„|jD ƒ}|  	t
|ƒd	¡ |d }d
d„ |jD ƒ}|  	t
|ƒd¡ |\}}dd„ |jD ƒ}	|	d }
|  	|
jd¡ dd„ |
jD ƒ}|  	t
|ƒd	¡ |d }t|ƒ d¡d  ¡ }|  	||j¡ |  t|
ƒ |¡¡ d S )NTrv   c                 S   s   | d S r‚   r   ©r6   r   r   r   r&   @  s    z<TestDebugInfoEmission.test_DILocation_entry_blk.<locals>.fooé{   r   c                    s   g | ]}|j ˆ kr|‘qS r   r8   r:   r8   r   r   r<   T  s     
 zCTestDebugInfoEmission.test_DILocation_entry_blk.<locals>.<listcomp>r.   c                 S   s   g | ]}|‘qS r   r   r:   r   r   r   r<   W  s     rw   c                 S   s   g | ]}|‘qS r   r   r:   r   r   r   r<   ]  s     r~   Úbrc                 S   s   g | ]}|‘qS r   r   r:   r   r   r   r<   `  s     ú:)r   rA   rB   rC   rD   rE   rF   rG   rH   r   rI   rJ   rK   rL   ZoperandsrN   ÚsplitrO   r9   rQ   Úendswith)r   r&   rS   rT   rU   rV   rJ   Zentry_blockZ
body_blockZentry_instrZujmpZujmp_operandsZtarget_dataÚtargetr   r8   r   Útest_DILocation_entry_blk0  s*    

z/TestDebugInfoEmission.test_DILocation_entry_blkc                    s�   t dd�dd„ ƒ‰ t dd�‡ fdd„ƒ}tjddd… f}| j||d	�}d
}| ¡ D ]*}| ¡ }| d¡rT|  |d¡ |d7 }qT|  |d
¡ dS )zË This tests that decref's generated from `ir.Del`s as variables go
        out of scope do not have debuginfo associated with them (the location of
        `ir.Del` is an implementation detail).
        Trv   c                  W   s   d S r   r   r$   r   r   r   Úsinkp  s    z:TestDebugInfoEmission.test_DILocation_decref.<locals>.sinkc                    s0   | | f}| d dkr ˆ |ƒ dS |d d }|S )Nr   é   r   )r6   r%   Úz©r¤   r   r   r&   u  s    z9TestDebugInfoEmission.test_DILocation_decref.<locals>.fooNr.   r   r   zcall void @NRT_decrefz.*meminfo\.[0-9]+\)$)	r   r	   r†   r`   ra   rO   Ú
startswithÚassertRegexr‡   )r   r&   r   rS   Úcountrd   Zline_strippedr   r§   r   Útest_DILocation_decrefi  s    


z,TestDebugInfoEmission.test_DILocation_decrefc                 C   s¬   t dd�dd„ ƒ}tjf}| j||d�}t |¡\}}d}t |¡}tƒ }|D ]<}	| 	|	¡}
|
rN|
 
¡ }|  t|ƒd¡ | t|d ƒ¡ qN|  t|ƒd	¡ |  ||¡ d
S )z� Tests that DILocation information for undefined vars is associated
        with the line of the function definition (so it ends up in the prologue)
        Trv   c                 S   s$   | r| dkrd}|S |d7 }|S d S )Nr   r.   r   )Únr|   r   r   r   r&   Ž  s    z<TestDebugInfoEmission.test_DILocation_undefined.<locals>.foor   z:.*!DILocalVariable\(name: "c\$?[0-9]?",.*line: ([0-9]+),.*r.   r   r€   N)r   r	   Úintpre   r‹   rŒ   r   r   rm   rP   rg   r   rI   rq   ro   rx   )r   r&   r   rc   r”   r�   r˜   ÚmatcherÚassociated_linesrs   rP   rg   r   r   r   Útest_DILocation_undefinedŠ  s     



z/TestDebugInfoEmission.test_DILocation_undefinedc                 C   sê   t dd�dd„ ƒ}tjf}| j||d�}t |¡\}}d}t |¡}tƒ }|D ]<}	| 	|	¡}
|
rN|
 
¡ }|  t|ƒd¡ | t|d ƒ¡ qN|  t|ƒd	¡ tƒ }t|ƒD ]\}}d
|krª| || ¡ qª|  t|ƒd	¡ |  ||¡ dS )zi Tests that DILocation information for versions of variables matches
        up to their definition site.Trv   c                 S   s"   | r
d}nd}d}d}d}d}|S )Né   r.   rw   r€   é   r   )r¬   r|   Zpy310_defeat1Zpy310_defeat2Zpy310_defeat3Zpy310_defeat4r   r   r   r&   °  s    zFTestDebugInfoEmission.test_DILocation_versioned_variables.<locals>.foor   z9.*!DILocalVariable\(name: "c\$[0-9]?",.*line: ([0-9]+),.*r.   r   rw   zc = N)r   r	   r­   re   r‹   rŒ   r   r   rm   rP   rg   r   rI   rq   ro   Ú	enumerate)r   r&   r   rc   r”   r�   r˜   r®   r¯   rs   rP   rg   Zpy_linesÚixZpylnr   r   r   Ú#test_DILocation_versioned_variablesª  s*    


z9TestDebugInfoEmission.test_DILocation_versioned_variablesc                    sÎ  t ddƒ}tj|dddƒtj|dddƒtj|dd	d
ƒtj|ddd
ƒtj|ddd
ƒtj|ddd
ƒtj|dd	dƒtj	|dddƒtj
|dddƒtj|dddƒtj|dddƒtj|dddƒi}| ¡ D �]\‰ }tdd�‡ fdd„ƒ}| j|dd�}|  |¡}| ¡ D ]\}}d|krþ|| }	 �q,qþd�s,td ƒ‚t d!|	¡ ¡ d }
||
 }d"|jk�r€d#|j› d$|j› d%|j› d&�}|  ||¡ q¾|jdk�r�d'nd(}d)|j› d*|j› d+|› d,|› d-|j› �
}|  ||¡ q¾d.S )/z@ Tests that dwarf info is correctly emitted for numeric scalars.ÚDIzname bits encodingÚfloat32é    ZDW_ATE_floatr†   é@   Úint8é   ZDW_ATE_signedÚint16é   r)   Úint64Úuint8ZDW_ATE_unsignedÚuint16Úuint32Úuint64Ú	complex64ZDW_TAG_structure_typeÚ
complex128é€   Trv   c                     s   ˆ dƒ} | S )Né
   r   rœ   ©Útyr   r   r&   î  s    z7TestDebugInfoEmission.test_numeric_scalars.<locals>.foor   r   úDILocalVariable(name: "a"r   úmissing DILocalVariable 'a'ú.*type: (![0-9]+).*ZDW_ATEz!DIBasicType(name: "ú	", size: z, encoding: ú)ÚfloatÚdoublezdistinct !DICompositeType(tag: z	, name: "z ({z, z})", size: N)r   r>   r·   r†   rº   r¼   r)   r¾   r¿   rÀ   rÁ   rÂ   rÃ   rÄ   Úitemsr   re   rl   ÚAssertionErrorr   rP   rg   Úencodingr9   Úbitsr   rx   )r   r¶   Z
type_infosZ
dwarf_infor&   rc   rh   r–   ÚvÚlvarÚtype_markerÚ	type_declÚexpectedZraw_fltr   rÇ   r   Útest_numeric_scalarsØ  s^    
 
 
 
 
 
 
 
 
 
 ÿ ÿô
(z*TestDebugInfoEmission.test_numeric_scalarsc              	   C   s6  t dd�dd„ ƒ}| j|dd�}|  |¡}| ¡ D ]\}}d|kr2|| } q\q2ds\td	ƒ‚t d
|¡ ¡ d }|| }|  d|¡ |  dt	t
jd d …d d d…f ƒ› �|¡ t d¡}	|	 |¡ ¡ }
|  t|
ƒd¡ |
d }|| }d}t |¡}| |¡ ¡ }|  |d k	¡ t t
jd d …d d d…f ¡}|  t|ƒt|jƒ¡ t
jj}d|› d�}d|› d|› d�}d|› d|› dd| › d|› d�	}|||||||dœ}d}t |¡}t|jƒD ]x\}}|||  }|  d|¡ |  d|› d�|¡ | |¡}| ¡ }|  t|ƒd¡ |d }|| }|  ||| ¡ �q¸d S )NTrv   c                  S   s   t jdt jd�} | S )N)rw   r€   )Zdtype)r>   Zonesr†   rœ   r   r   r   r&     s    z.TestDebugInfoEmission.test_arrays.<locals>.foor   r   rÉ   r   rÊ   rË   z+!DICompositeType(tag: DW_TAG_structure_typezname: "r.   z.*elements: (![0-9]+),.*zN!{(![0-9]+), (![0-9]+), (![0-9]+), (![0-9]+), (![0-9]+), (![0-9]+), (![0-9]+)}zC!DIDerivedType\(tag: DW_TAG_pointer_type, baseType: ![0-9]+, size: z\)z!DIBasicType\(name: "intrÌ   z, encoding: DW_ATE_signed\)z>!DICompositeType\(tag: DW_TAG_array_type, name: "UniTuple\(intz x 2\) \(\[2 x iz \]\)", baseType: ![0-9]+, size: rw   z), elements: ![0-9]+, identifier: "\[2 x iz\]"\))ZmeminfoÚparentZnitemsÚitemsizeÚdataÚshapeÚstridesz*!DIDerivedType\(.*, baseType: (![0-9]+),.*ZDIDerivedTypeú")r   re   rl   rÐ   rÑ   r   rP   rg   rx   rN   r	   r†   r   r   rI   ÚassertIsNotNoner
   ÚlookupÚ_fieldsr­   Zbitwidthr³   r©   )r   r&   rc   rh   r–   rÔ   rÕ   rÖ   r×   Zmatch_elementsZelem_matchesZ
elem_matchZstruct_markersZstruct_patternZmatch_structZstruct_member_matchesZ
data_modelZptr_sizeZptr_reZint_reZ	utuple_rerØ   Zbase_type_patternZbase_type_matcherr´   ÚfieldZderived_typeZbase_type_matchZbase_type_matchesZbase_type_markerZ	data_typer   r   r   Útest_arrays  s`    

*

"ú	

z!TestDebugInfoEmission.test_arraysc              
      s\  ‡ fdd„}dd„ }dd„ }t dd�|ƒ}t ddd	�|ƒ}t dddd
�|ƒ}|jj}i }td|d htƒ tdgƒd�||< ttt|d |d ƒƒtdgƒtƒ d�||< td|d htdgƒtdgƒd�||< |ƒ }	| ¡ D ]|\}
}ˆ  |
j¡�b |
ƒ }ˆ  	||	¡ ˆ  	||
ƒ|d ¡ ||
ƒ}|d }ˆ  	||@ |¡ |d }ˆ  
||@ ¡ W 5 Q R X qÚd S )Nc                    s    ˆ   | | jd ¡}ˆ  |¡}|S )Nr   )re   rB   ru   )r   rc   rr   ©r   r   r   Úget_debug_linesZ  s    
zATestDebugInfoEmission.test_debug_optnone.<locals>.get_debug_linesc                 S   s>   | j | jd  }|j}|j |jj¡} td | j	¡ 
¡ ƒ}|S )Nr   ó    )rE   rB   ZlibraryZ_final_moduleZget_functionrF   rG   rm   ÚjoinÚ
attributesr    )r   ZcresÚlibÚattrsr   r   r   Úget_func_attrs_  s
    z@TestDebugInfoEmission.test_debug_optnone.<locals>.get_func_attrsc                  S   s"   d} d}t | ƒD ]}||7 }q|S )NrÆ   r   )Úrange)r¬   r|   Úir   r   r   r&   f  s
    
z5TestDebugInfoEmission.test_debug_optnone.<locals>.fooTrv   )r#   Ú_dbg_optnone)r#   rï   r1   r   r±   s   optnone)rr   Úmust_have_attrsÚmust_not_have_attrsr.   é   s   alwaysinlinerr   rð   rñ   )r   Ú__code__Úco_firstlinenorf   rm   rí   rÐ   ZsubTestZtargetoptionsr   r‰   )r   ræ   rì   r&   Z	foo_debugZfoo_debug_optnoneZfoo_debug_optnone_inlineÚ	firstlineZexpected_infoZexpected_retZudtrØ   r   rë   Z	must_haveZmust_not_haver   rå   r   Útest_debug_optnoneY  sL    ÿÿ
ü
ü

û
z(TestDebugInfoEmission.test_debug_optnonec              	   C   sT  t dd�ddd„ƒ}tddƒ� |ƒ  W 5 Q R X | j|t d ¡fd�}|  |¡}g }|D ]}d|krX| |¡ qX|  t|ƒd¡ | 	¡ }t
 d	|¡}|  |¡ | ¡ }|  t|ƒd¡ |d
 }	||	 }
t
 d|
¡}|  |¡ | ¡ }|  t|ƒd¡ dd„ |d
  d¡D ƒd }|| }d}|  ||¡ t
 ||¡ ¡ d
 }|| }|  |d¡ d S )NTrv   c                 S   s   d S r   r   )Úmissingr   r   r   r&   œ  s    z3TestDebugInfoEmission.test_omitted_arg.<locals>.foor-   r.   r   ZDISubroutineTypez(.*!DISubroutineType\(types: ([!0-9]+)\)$r   z!{(.*)}c                 S   s   g | ]}|  ¡ ‘qS r   )rO   r:   r   r   r   r<   ¾  s     z:TestDebugInfoEmission.test_omitted_arg.<locals>.<listcomp>ú,r~   zy^.*!DICompositeType\(tag: DW_TAG_structure_type, name: "Anonymous struct \({}\)", elements: (![0-9]+), identifier: "{}"\)z!{})N)r   r   re   r	   ZOmittedrl   rM   r   rI   Úpopr   rP   rà   rg   r    r©   )r   r&   rc   rh   Z
tmp_disubrrs   ZdisubrZdisubr_matchedZdisubr_groupsZdisubr_metaZdisubr_typesZdisubr_types_matchedZdisubr_types_groupsZ	md_fn_argZarg_tyZexpected_arg_tyZ
md_base_tyZbase_tyr   r   r   Útest_omitted_argš  s>    
ÿ

z&TestDebugInfoEmission.test_omitted_argc              	   C   s®   d}t ƒ }tt|ƒi |ƒ tdd�|d ƒ}tjdd��}t dt¡ tƒ  |ƒ  W 5 Q R X |  	t
|ƒd¡ |d }|  	|jt¡ t|jƒ}|  d	|¡ |  t|jƒ|¡ d S )
Nz1
        def foo():
            return 1
        Trv   r&   ©ÚrecordÚalwaysr.   r   z"Could not find source for function)rf   Úexecr   r   ÚwarningsÚcatch_warningsÚsimplefilterr   r   r   rI   ÚcategoryrN   Úmessagerx   r@   )r   ZstrsrcÚlr&   Úwr‘   r   r   r   r   Útest_missing_sourceÉ  s    
z)TestDebugInfoEmission.test_missing_sourcec              	   C   s‚   t dd�dd„ ƒ}tjdd��}t dt¡ tƒ  |ƒ  W 5 Q R X |  t|ƒd¡ |  ||j	d ¡}|  
|¡}|  t|ƒd¡ d S )	NTrv   c                   S   s   dS r‚   r   r   r   r   r   r&   â  s    zCTestDebugInfoEmission.test_irregularly_indented_source.<locals>.foorû   rý   r   r.   )r   rÿ   r   r  r   r   r   rI   re   rB   ru   )r   r&   r  rc   rr   r   r   r   Ú test_irregularly_indented_sourceà  s    

z6TestDebugInfoEmission.test_irregularly_indented_sourceN)rY   rZ   r[   r\   Z_NUMBA_OPT_0_ENVr`   re   rl   ru   ry   rš   r   Zrun_test_in_subprocessr£   r«   r°   rµ   rÙ   rä   rö   rú   r  r  r   r   r   r   r]   {   s(   	{

8

  .7JA/r]   Ú__main__)Úcollectionsr   r‹   r   rz   r>   r2   Útextwrapr   Zunittestrÿ   Znumba.tests.supportr   r   r   Znumbar   r   Z
numba.corer	   Znumba.core.datamodelr
   Znumba.core.errorsr   Zllvmlite.bindingZbindingrC   r   r]   rY   Úmainr   r   r   r   Ú<module>   s*   d    ~