
    shRr                         S SK Jr  S SKrS SKrS SKrS SKrS SKJr  S SK	r	S SK
r
S SKJrJrJr  S SKJrJr  S SKJr  S SKJr  S SKJr  S SKJr   " S	 S
\5      r " S S\5      r\S:X  a  \	R<                  " 5         gg)    )
namedtupleN)dedent)TestCaseoverride_configignore_internal_warnings)jitnjit)types)default_manager)NumbaDebugInfoWarningc                   <    \ rS rSrSrS rS rS rS rS r	S r
S	rg
)TestDebugInfo   z>
These tests only checks the compiled assembly for debuginfo.
c                 F    UR                  U5        UR                  U5      $ N)compileinspect_asmselffnsigs      n/Users/tiagomarins/Projetos/claudeai/copy_bank/venv/lib/python3.13/site-packages/numba/tests/test_debuginfo.py_getasmTestDebugInfo._getasm   s    


3~~c""    c                     U R                  XS9n[        R                  " SU[        R                  5      nUS LnU R	                  X6SU-  S9  g )Nr   z\.section.+debugzdebug info not found in:
%s)msg)r   researchIassertEqual)r   r   r   expectasmmgots          r   _checkTestDebugInfo._check    sK    ll2l'II)35tm*H3*NOr   c                 d    [        SSS9S 5       nU R                  U[        R                  4SS9  g )NTFnopythondebugc                     U $ r    xs    r   foo3TestDebugInfo.test_no_debuginfo_in_asm.<locals>.foo'       Hr   r   r#   r   r'   r
   int32r   r1   s     r   test_no_debuginfo_in_asm&TestDebugInfo.test_no_debuginfo_in_asm&   s5    	d%	(	 
)	 	Cekk^E:r   c                 d    [        SSS9S 5       nU R                  U[        R                  4SS9  g )NTr*   c                     U $ r   r.   r/   s    r   r1   0TestDebugInfo.test_debuginfo_in_asm.<locals>.foo.   r3   r   r4   r5   r7   s     r   test_debuginfo_in_asm#TestDebugInfo.test_debuginfo_in_asm-   s5    	d$	'	 
(	 	Cekk^D9r   c                    [        SS5         [        SS9S 5       nU R                  U[        R                  4SS9  [        SSS9S	 5       nU R                  U[        R                  4SS9  S S S 5        g ! , (       d  f       g = f)
NDEBUGINFO_DEFAULT   T)r+   c                     U $ r   r.   r/   s    r   r1   4TestDebugInfo.test_environment_override.<locals>.foo7       r   r4   Fr*   c                     U $ r   r.   r/   s    r   bar4TestDebugInfo.test_environment_override.<locals>.bar=   rD   r   )r   r   r'   r
   r6   )r   r1   rF   s      r   test_environment_override'TestDebugInfo.test_environment_override4   s{    0!4$  KK%++K= $e, -KK%++K> 544s   A A66
Bc                   ^^ [        SS9S 5       m[        SS9S 5       m[         UU4S j5       n[        SS5         U" [        R                  5      nS S S 5        U R	                  WUR                  [        R                  5      5        UR                  UR                  S	   5      n[        R                  " U5      nUR                  UR                  S	      R                  R                  nUR                   Vs/ s H  ofR                  U:X  d  M  UPM     nnU R                  [!        U5      S5        US	   n/ n	UR"                   HP  n
U
R$                   H=  nUR&                  S
:X  d  M  U	R)                  [+        U5      R-                  5       5        M?     MR     SnSnTR                  TR                  S	      R                  R                  nU	 HU  nU(       d  [.        R0                  " SU5      (       a  SnU(       a  M1  [.        R0                  " SU S3U5      (       d  MS  SnMW     U R3                  U5        U R3                  U5        g ! , (       d  f       GN= fs  snf )NT)forceinlinec                 .    [         R                  " U 5      $ r   )mathsinr/   s    r   rF   :TestDebugInfo.test_llvm_inliner_flag_conflict.<locals>.barG       88A;r   Fc                 .    [         R                  " U 5      $ r   )rM   cosr/   s    r   baz:TestDebugInfo.test_llvm_inliner_flag_conflict.<locals>.bazK   rP   r   c                 *   > T" U 5      nT" U 5      nX4$ r   r.   )r0   abrF   rS   s      r   r1   :TestDebugInfo.test_llvm_inliner_flag_conflict.<locals>.fooO   s    AAAA4Kr   r@   rA   r   callz.*llvm.sin.f64.*z.*)r	   r   nppiassertPreciseEqualpy_funcinspect_llvm
signaturesllvmparse_assembly	overloadsfndescmangled_name	functionsnamer"   lenblocksinstructionsopcodeappendstrstripr   match
assertTrue)r   r1   resultfull_irmodulerf   r0   funcsfuncf_namesblkstmt	found_sin	found_bazbaz_namerF   rS   s                  @@r   test_llvm_inliner_flag_conflict-TestDebugInfo.test_llvm_inliner_flag_conflictB   s   
 
$		 
 	 
%	 	 
!	 
	 
	 0!4ZF 5 	BEE(:; ""3>>!#45$$W-}}S^^A./66CC",,?,q$,?UQ'Qx ;;C((;;&(NN3t9??#45 )  		==!23::GGA*<a!@!@ 	9Bxj*;Q!?!? 		  		"	"E 54 @s   I=I"I"
Ir.   N)__name__
__module____qualname____firstlineno____doc__r   r'   r8   r=   rH   r{   __static_attributes__r.   r   r   r   r      s&    #P;:?6#r   r   c                       \ rS rSrSrSS0rS rS rS rS r	S	 r
S
 r\R                  " \S9S 5       r\R                  " \S9S 5       rS rS rS rS rS rS rS rS rSrg)TestDebugInfoEmission{   z0Tests that debug info is emitted correctly.
    	NUMBA_OPT0c                     [        SS5         UR                  U5        UR                  U5      sS S S 5        $ ! , (       d  f       g = f)NOPTr   )r   r   r^   r   s      r   _get_llvmir!TestDebugInfoEmission._get_llvmir   s/    UA&JJsO??3' '&&s	   "9
Ac                     U R                  X5      R                  5       n[        R                  " S5      n/ nU H,  nUR	                  U5      (       d  M  UR                  U5        M.     U$ )Nz![0-9]+ =.*)r   
splitlinesr   r   rn   rk   )r   r   r   llmeta_remetadatalines          r   _get_metadata#TestDebugInfoEmission._get_metadata   sZ    b&113**^,D}}T""%  r   c                     [        5       n[        R                  " S5      nU H3  nUR                  U5      nU(       d  M  UR	                  5       u  pgXrU'   M5     U$ )zTGets the map of DI label to md, e.g.
'!33' -> '!{!"branch_weights", i32 1, i32 99}'
z(![0-9]+) = (.*))dictr   r   rn   groups)r   r   metadata_definition_mapmeta_definition_splitr   matcheddbg_valinfos           r   _get_metadata_map'TestDebugInfoEmission._get_metadata_map   sY     #'& "

+> ?D+11$7Gw ' 0370	 
 '&r   c                     U R                  U5      n[        5       nUR                  5        HN  n[        R                  " SU5      nU(       d  M#  [        UR                  S5      5      nUR                  U5        MP     U$ )Nz!DILocation\(line: (\d+),rA   )r   setvaluesr   rn   intgroupadd)r   r   
md_def_maplinesmdr%   lns          r   _get_lines_from_debuginfo/TestDebugInfoEmission._get_lines_from_debuginfo   se    ++H5
##%B5r:Aq_		"	 &
 r   c                     [        SS9S 5       nU R                  USS9nUS   nU R                  SUS S 5        U R                  S	U5        U R                  S
U5        g )NTr,   c                      g r   r.   r.   r   r   r1   /TestDebugInfoEmission.test_DW_LANG.<locals>.foo       r   r.   r   r   z!0   z,!DICompileUnit(language: DW_LANG_C_plus_pluszproducer: "clang (Numba)")r	   r   r"   assertIn)r   r1   r   DICompileUnits       r   test_DW_LANG"TestDebugInfoEmission.test_DW_LANG   sq    	D		 
	 %%cr%2 }Ra01D#	%1=Ar   c           
         [        SSS9S 5       n[        R                  4nU R                  XS9nU R	                  XS9n[
        R                  " U5      nUR                  UR                  S      R                  R                  nUR                   Vs/ s H  owR                  U:X  d  M  UPM     nnU R                  [        U5      S5        US   n	U	R                   Vs/ s H  owPM     n
nU R!                  [        U
5      S5        U
S   nUR"                   Vs/ s H  owR$                  S;  d  M  UPM     nn1 S	knS
nU H^  nUR$                  U;   a(  UR'                  UR$                  5        U(       d  SnM9  M;  U(       d  MD  U(       d  MM  U R)                  S5        M`     U R+                  US5        [-        5       n[.        R0                  " S5      nSnU H  n[3        U5      nUR5                  U5      nU(       d1  SnU R7                  [9        U Vs/ s H  owU;   PM	     sn5      5        MW  UR;                  5       nU R                  [        U5      S5        US   n[=        USS 5      nUS:  a  U R7                  UU:  5        UnUR?                  U5        M     [@        RB                  " U5      u  nnU RE                  U5      n/ SQnU Vs/ s H  nUS-   U-   PM     nn[G        [I        US S9U5       H   u  nnUU   n U RK                  SU 3U 5        M"     Sn![.        R0                  " U!5      n"URM                  5        Hm  n#U"R5                  U#5      nU(       d  M  UR;                  5       nU R                  [        U5      S5        [=        US   5      n$US-   n%U R                  U$U%5          g   U R)                  S5        gs  snf s  snf s  snf s  snf s  snf )z9Tests that DILocation information is reasonable.
        Tnumpy)r,   error_modelc                 8    U S-   nUS-  nX-  n[        U5        U$ )NgGz?gQ@)print)rV   rW   cds       r   r1   2TestDebugInfoEmission.test_DILocation.<locals>.foo   s'    DADAA!HHr   r   r   rA   )rY   loadstore>   faddfdivfmulFzMath opcodes are not contiguouszMath opcodes were not foundz.*!dbg (![0-9]+).*$)zalloca zstore N)r   rA   r      r   c                     [        U SS  5      $ NrA   )r   r/   s    r   <lambda>7TestDebugInfoEmission.test_DILocation.<locals>.<lambda>  s    s1QR5zr   )keyzline: z1.*!DILocalVariable\(name: "a",.*line: ([0-9]+),.*z%Assertion on DILocalVariable not made)'r	   r
   float64r   r   r`   ra   rb   r_   rc   rd   re   rf   r"   rg   rh   assertGreaterri   rj   removefailassertFalser   r   r   rl   rn   ro   anyr   r   r   inspectgetsourcelinesr   zipsortedr   r   )&r   r1   r   r   rq   rr   rf   r0   rs   rt   rh   blockinstrs	op_expectstartedline2dbg
re_dbg_reffoundinstrinst_as_strr   acceptedr   r   int_dbg_valpysrcpysrc_line_startr   offsets
pyln_rangekline_nodilocation_infoexprmatch_local_var_aentrydbg_linedeflines&                                         r   test_DILocation%TestDebugInfoEmission.test_DILocation   s    
Dg	.	 
/	2 }}%%c%3""3"0$$W-}}S^^A./66CC",,?,q$,?UQ'Qx![[)[![)3v;*q	 #// -/88+4,!/ -,	Axx9$  *"G ww		;<  	$AB
 5ZZ 67
Ee*K &&{3G 1x$Hx!+%5x$H IJ^^%FS[!,QiGgabk*Kzu 45E LL!' * #*"8"8"= #'"8"8"B

 9@@1&*Q.
@  x5I J *,LQ5a8OMMF7),o>, DJJt,,335E'--e4Gw )  Va0vay> +Q.  73 6 II=>m @ *
-6 %I4 As*   O+O!OO3OOO)envvarsc                    [        SS9S 5       nU" S5        UR                  UR                  S   5      n[        R                  " U5      nUR
                  UR                  S      R                  R                  nUR                   Vs/ s H  oUR                  U:X  d  M  UPM     nnU R                  [        U5      S5        US   nUR                   Vs/ s H  oUPM     nnU R                  [        U5      S5        Uu  pU	R                   Vs/ s H  oUPM     nnUS   nU R                  UR                  S	5        UR                   Vs/ s H  oUPM     nnU R                  [        U5      S5        US   n[!        U5      R#                  S
5      S   R%                  5       nU R                  XR                  5        U R'                  [!        U5      R)                  U5      5        g s  snf s  snf s  snf s  snf )NTr   c                     U S-   $ r   r.   rV   s    r   r1   <TestDebugInfoEmission.test_DILocation_entry_blk.<locals>.fooA  s    q5Lr   r   r   rA   r   r   br:)r	   r^   r_   r`   ra   rb   rc   rd   re   rf   r"   rg   rh   ri   rj   operandsrl   splitrm   ro   endswith)r   r1   rq   rr   rf   r0   rs   rt   rh   entry_block
body_blockentry_instrujmpujmp_operandstarget_datatargets                   r   test_DILocation_entry_blk/TestDebugInfoEmission.test_DILocation_entry_blk1  s     
D		 
	C""3>>!#45 $$W-}}S^^A./66CC",,?,q$,?UQ'Qx![[)[![)Va("( #.":":;":Qq":;2d+$(MM2MqM2]+Q/#A&[!'',Q/5571D	**623' @ * < 3s   
G*!G*G/G4G9c                 h  ^ [        SS9S 5       m[        SS9U4S j5       n[        R                  SSS2   4nU R                  XS9nSnUR	                  5        HB  nUR                  5       nUR                  S	5      (       d  M+  U R                  US
5        US-  nMD     U R                  US5        g)zThis 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).
Tr   c                      g r   r.   r/   s    r   sink:TestDebugInfoEmission.test_DILocation_decref.<locals>.sinkq  r   r   c                 B   > X 4nU S   S:X  a	  T" U5        gUS   S   nU$ )Nr      r.   )rV   r0   zr   s      r   r1   9TestDebugInfoEmission.test_DILocation_decref.<locals>.foov  s1    AtqyQ!QAHr   NrA   r   r   zcall void @NRT_decrefz.*meminfo\.[0-9]+\)$)	r	   r
   r   r   r   rm   
startswithassertRegexr   )r   r1   r   rq   countr   line_strippedr   s          @r   test_DILocation_decref,TestDebugInfoEmission.test_DILocation_decrefj  s     
D		 
	 
D		 
	 }}SqS!#""3"0 &&(D JJLM''(?@@  '>?
	 )
 	5!$r   c                    [        SS9S 5       n[        R                  4nU R                  XS9n[        R
                  " U5      u  pESn[        R                  " U5      n[        5       nU He  n	UR                  U	5      n
U
(       d  M  U
R                  5       nU R                  [        U5      S5        UR                  [        US   5      5        Mg     U R                  [        U5      S5        U R                  XX5        g	)
zTests that DILocation information for undefined vars is associated
with the line of the function definition (so it ends up in the prologue)
Tr   c                 2    U (       a
  U S:  a  SnW$ WS-  nU$ )Nr   rA   r.   )nr   s     r   r1   <TestDebugInfoEmission.test_DILocation_undefined.<locals>.foo  s&    q5A Qr   r   z:.*!DILocalVariable\(name: "c\$?[0-9]?",.*line: ([0-9]+),.*rA   r   r   N)r	   r
   intpr   r   r   r   r   r   rn   r   r"   rg   r   r   r   )r   r1   r   r   r   r   r   matcherassociated_linesr   rn   r   s               r   test_DILocation_undefined/TestDebugInfoEmission.test_DILocation_undefined  s     
D		 
	 zzm%%c%3")"8"8"=L**T"5BMM"%Eu  Va0 $$S^4  	-.2&9r   c                    [        SS9S 5       n[        R                  4nU R                  XS9n[        R
                  " U5      u  pESn[        R                  " U5      n[        5       nU He  n	UR                  U	5      n
U
(       d  M  U
R                  5       nU R                  [        U5      S5        UR                  [        US   5      5        Mg     U R                  [        U5      S5        [        5       n[        U5       H   u  pS	U;   d  M  UR                  X-   5        M"     U R                  [        U5      S5        U R                  X5        g
)z`Tests that DILocation information for versions of variables matches
up to their definition site.Tr   c                 .    U (       a  SnOSnSnSnSnSnU$ )N   rA   r   r      r.   )r  r   py310_defeat1py310_defeat2py310_defeat3py310_defeat4s         r   r1   FTestDebugInfoEmission.test_DILocation_versioned_variables.<locals>.foo  s(    MMMMHr   r   z9.*!DILocalVariable\(name: "c\$[0-9]?",.*line: ([0-9]+),.*rA   r   r   zc = N)r	   r
   r  r   r   r   r   r   r   rn   r   r"   rg   r   r   	enumerate)r   r1   r   r   r   r   r   r  r  r   rn   r   py_linesixpylns                  r   #test_DILocation_versioned_variables9TestDebugInfoEmission.test_DILocation_versioned_variables  s-    
D	
	 

	 zzm%%c%3")"8"8"= L**T"5BMM"%Eu  Va0 $$S^4  	-.2 5!%(HB~R23 ) 	X* 	)4r   c                   ^ [        SS5      n[        R                  U" SSS5      [        R                  U" SSS5      [        R                  U" SS	S
5      [        R
                  U" SSS
5      [        R                  U" SSS
5      [        R                  U" SSS
5      [        R                  U" SS	S5      [        R                  U" SSS5      [        R                  U" SSS5      [        R                  U" SSS5      [        R                  U" SSS5      [        R                  U" SSS5      0nUR                  5        GH3  u  mn[        SS9U4S j5       nU R!                  USS9nU R#                  U5      nUR                  5        H  u  pxSU;   d  M  Xg   n	  O	    S5       e[$        R&                  " S U	5      R)                  5       S   n
Xj   nS!UR*                  ;   a=  S"UR,                   S#UR.                   S$UR*                   S%3nU R1                  X5        M  UR.                  S:X  a  S&OS'nS(UR*                   S)UR,                   S*U S+U S,UR.                   3
nU R3                  X5        GM6     g-).z?Tests that dwarf info is correctly emitted for numeric scalars.DIzname bits encodingfloat32    DW_ATE_floatr   @   int8   DW_ATE_signedint16   r6   int64uint8DW_ATE_unsigneduint16uint32uint64	complex64DW_TAG_structure_type
complex128   Tr   c                     > T" S5      n U $ )N
   r.   )rV   tys    r   r1   7TestDebugInfoEmission.test_numeric_scalars.<locals>.foo  s    rFr   r.   r   DILocalVariable(name: "a"r   missing DILocalVariable 'a'.*type: (![0-9]+).*DW_ATEz!DIBasicType(name: "	", size: z, encoding: )floatdoublezdistinct !DICompositeType(tag: z	, name: "z ({z, z})", size: N)r   rZ   r&  r   r*  r-  r6   r/  r0  r2  r3  r4  r5  r7  itemsr	   r   r   r   rn   r   encodingrf   bitsr"   r   )r   r%  
type_infos
dwarf_infor1   r   r   r   vlvartype_marker	type_declexpectedraw_fltr;  s                 @r   test_numeric_scalars*TestDebugInfoEmission.test_numeric_scalars  sp    23jj"YN"Cjj"YN"Cggr&!_=hh7B @hh7B @hh7B @hh7A/@ AiiHb2C!DiiHb2C!DiiHb2C!DllB{B'>%@mmRc(?&AC
 )..0NB
  ))#2)6H&*&<&<X&F#/557.!325D 8
 877q((#8$?FFHKK/<I:...2:??2C D%%/__$5 6))3)<)<(=Q@   5 &0__%:'$$.$7$7#8 9&&0oo%6 7"")"WI 6%%/__$5	7
 h2C 1r   c           
         [        SS9S 5       nU R                  USS9nU R                  U5      nUR                  5        H  u  pESU;   d  M  X4   n  O	    S5       e[        R
                  " S	U5      R                  5       S   nX7   nU R                  S
U5        U R                  S[        [        R                  S S 2S S S24   5       3U5        [        R                  " S5      n	U	R                  U5      R                  5       n
U R                  [        U
5      S5        U
S   nX;   nSn[        R                  " U5      nUR                  U5      R                  5       nU R                  US L5        [        R                   " [        R                  S S 2S S S24   5      nU R                  [        U5      [        UR"                  5      5        [        R$                  R&                  nSU S3nSU SU S3nSU SU SSU-   SU S3	nUUUUUUUS.nSn[        R                  " U5      n[)        UR"                  5       H  u  nnX?U      nU R                  SU5        U R                  SU S3U5        UR                  U5      nUR                  5       nU R                  [        U5      S5        US   nUU   nU R+                  UUU   5        M     g )NTr   c                  L    [         R                  " S[         R                  S9n U $ )N)r   r   )dtype)rZ   onesr   r   s    r   r1   .TestDebugInfoEmission.test_arrays.<locals>.foo  s    bjj1AHr   r.   r   r=  r   r>  r?  z+!DICompositeType(tag: DW_TAG_structure_typezname: "rA   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: "intrA  z, encoding: DW_ATE_signed\)z>!DICompositeType\(tag: DW_TAG_array_type, name: "UniTuple\(intz x 2\) \(\[2 x iz \]\)", baseType: ![0-9]+, size: r   z), elements: ![0-9]+, identifier: "\[2 x iz\]"\))meminfoparentnitemsitemsizedatashapestridesz*!DIDerivedType\(.*, baseType: (![0-9]+),.*DIDerivedType")r	   r   r   rE  r   rn   r   r   rl   r
   r   r   r"   rg   assertIsNotNoner   lookup_fieldsr  bitwidthr  r  )r   r1   r   r   r   rJ  rK  rL  rM  match_elementselem_matches
elem_matchstruct_markersstruct_patternmatch_structstruct_member_matches
data_modelptr_sizeptr_reint_re	utuple_rerN  base_type_patternbase_type_matcherr   fieldderived_typebase_type_matchbase_type_matchesbase_type_marker	data_types                                  r   test_arrays!TestDebugInfoEmission.test_arrays  s   	D		 
	 %%cr%2"&"8"8"B+113DA*a/.1 4
 4331hh4d;BBDQG+8	 	CYOEMM!SqS&$9 :;<iH $?@%++I6==?\*A.!!_
 1<@zz.1 , 2 2> B I I K2$>?$++EMM!SqS&,AB
23S9K9K5LM::&&//7j<-hZy
 K/ /--5J 7""* , 8|n ---5Je	=	
  &$$ &"&(* JJJ'89":#5#56IB23LMLMM/<8MMGE7!,l;/55lCO / 6 6 8S!23Q703/0@AIY8 7r   c           	      6  ^  U 4S jnS nS n[        SS9" U5      n[        SSS9" U5      n[        SSSS9" U5      nUR                  R                  n0 n[        SUS	-   1[	        5       [	        S
/5      S9X'   [        [	        [        US-   US-   5      5      [	        S
/5      [	        5       S9X'   [        SUS	-   1[	        S/5      [	        S
/5      S9X'   U" 5       n	UR                  5        H  u  pT R                  U
R                  5         U
" 5       nT R                  X5        T R                  U" U
5      US   5        U" U
5      nUS   nT R                  X-  U5        US   nT R                  X-  5        S S S 5        M     g ! , (       d  f       M  = f)Nc                 f   > TR                  X R                  S   5      nTR                  U5      nU$ )Nr   )r   r_   r   )r   r   r   r   s      r   get_debug_linesATestDebugInfoEmission.test_debug_optnone.<locals>.get_debug_lines[  s1    ))"mmA.>?H228<ELr   c                    U R                   U R                  S      nUR                  nUR                  R	                  UR
                  R                  5      n [        SR                  U R                  5      R                  5       5      nU$ )Nr       )rb   r_   library_final_moduleget_functionrc   rd   r   join
attributesr   )r   creslibattrss       r   get_func_attrs@TestDebugInfoEmission.test_debug_optnone.<locals>.get_func_attrs`  sg    <<a 01D,,C""//0H0HIB		"--06689ELr   c                  :    Sn Sn[        U 5       H  nX-  nM	     U$ )Nr:  r   )range)r  r   is      r   r1   5TestDebugInfoEmission.test_debug_optnone.<locals>.foog  s&    AA1X Hr   Tr   )r,   _dbg_optnone)r,   r  rK   r   r  s   optnone)r   must_have_attrsmust_not_have_attrsrA      s   alwaysinliner   r  r  )r	   __code__co_firstlinenor   r   r  rE  subTesttargetoptionsr"   r   )r   r|  r  r1   	foo_debugfoo_debug_optnonefoo_debug_optnone_inline	firstlineexpected_infoexpected_retudtrN  r&   r  	must_havemust_not_haves   `               r   test_debug_optnone(TestDebugInfoEmission.test_debug_optnoneZ  s   	
		 t$S)	 t$?D#'d48$::=$?  LL//	#'i!m$E #ZL 1	$
  ,0eIM9q=9:- #	,
( 37 i!m$ 12 #ZL 13
/ u*002MCc//0e  3   !5x7HI 's+$%67	  !2I> ()> ?  !67 10 300s   A-F		
F	c                    [        SS9SS j5       n[        SS5         U" 5         S S S 5        U R                  U[        R                  " S 5      4S9nU R                  U5      n/ nU H  nSU;   d  M  UR                  U5        M     U R                  [        U5      S5        UR                  5       n[        R                  " SU5      nU R                  U5        UR                  5       nU R                  [        U5      S5        US	   n	X9   n
[        R                  " S
U
5      nU R                  U5        UR                  5       nU R                  [        U5      S5        US	   R                  S5       Vs/ s H  oR                  5       PM     snS   nX>   nSnU R!                  UU5        [        R                  " UU5      R                  5       S	   nUU   nU R                  US5        g ! , (       d  f       GN= fs  snf )NTr   c                     g r   r.   )missings    r   r1   3TestDebugInfoEmission.test_omitted_arg.<locals>.foo  r   r   r@   rA   r   DISubroutineTypez(.*!DISubroutineType\(types: ([!0-9]+)\)$r   z!{(.*)},r   zy^.*!DICompositeType\(tag: DW_TAG_structure_type, name: "Anonymous struct \({}\)", elements: (![0-9]+), identifier: "{}"\)z!{}r   )r	   r   r   r
   Omittedr   rk   r"   rg   popr   rn   r`  r   r   rm   r  )r   r1   r   r   
tmp_disubrr   disubrdisubr_matcheddisubr_groupsdisubr_metadisubr_typesdisubr_types_matcheddisubr_types_groupsr0   	md_fn_argarg_tyexpected_arg_ty
md_base_tybase_tys                      r   test_omitted_arg&TestDebugInfoEmission.test_omitted_arg  s   	D		 
	 0!4E 5 %%cd0C/E%F"&"8"8"B 
B!R'!!"%  	Z!,!"M"(*^,&--/]+Q/#A& /;!xx
LA^,299;0115 )<A(>(D(DS(IJ(I1WWY(IJ2N	(3< 	1XXov6==?B
)*55*M 54: Ks   G/8H/
G>c                 8   Sn[        5       n[        [        U5      0 U5        [        SS9" US   5      n[        R
                  " SS9 n[        R                  " S[        5        [        5         U" 5         S S S 5        U R                  [        W5      S5        US   nU R                  UR                  [        5        [        UR                  5      nU R                  S	U5        U R                  [        UR                  5      U5        g ! , (       d  f       N= f)
Nz1
        def foo():
            return 1
        Tr   r1   recordalwaysrA   r   z"Could not find source for function)r   execr   r	   warningscatch_warningssimplefilterr   r   r"   rg   categoryrl   messager   r]   )r   strsrclr1   wr   r   s          r   test_missing_source)TestDebugInfoEmission.test_missing_source  s     FVF^R#qx($$D1Q!!(,AB$&E 2
 	Q#!)>?%-- :C@c#++&, 21s   	-D
Dc                    [        SS9S 5       n[        R                  " SS9 n[        R                  " S[        5        [        5         U" 5         S S S 5        U R                  [        W5      S5        U R                  XR                  S   5      nU R                  U5      nU R                  [        U5      S5        g ! , (       d  f       Nt= f)NTr   c                      gr   r.   r.   r   r   r1   CTestDebugInfoEmission.test_irregularly_indented_source.<locals>.foo  s     r   r  r  r   rA   )r	   r  r  r  r   r   r"   rg   r   r_   r   )r   r1   r  r   r   s        r    test_irregularly_indented_source6TestDebugInfoEmission.test_irregularly_indented_source  s    	D		 
	 $$D1Q!!(,AB$&E 2 	Q#%%c>>!+<=..x8UQ' 21s   -B??
Cr.   N)r}   r~   r   r   r   _NUMBA_OPT_0_ENVr   r   r   r   r   r   r   run_test_in_subprocessr   r
  r  r"  rP  rx  r  r  r  r  r   r.   r   r   r   r   {   s     $S)(
'
Bz?x $$-=>64 ?64p $$-=>% ?%@:@,5\53nH9T?8B-+^-.(r   r   __main__)collectionsr   r   r   r   rZ   rM   textwrapr   unittestr  numba.tests.supportr   r   r   numbar   r	   
numba.corer
   numba.core.datamodelr   numba.core.errorsr   llvmlite.bindingbindingr`   r   r   r}   mainr.   r   r   <module>r     sl    "  	     ; ;   0 3 a#H a#Hx	(H x	(v zMMO r   