
    sh}                      f   S r SSKrSSK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	J
r
JrJrJrJr  SSKJr  SSK	Jr  SSKJrJrJrJr  SSKJr  SSKr\R                  r\R7                  S	5      =(       d    \R7                  S
5      =(       d    S\;   r\R:                  " \S5      r\R>                  " \S5      r \RB                  " 5       r"\"S;   r#\R>                  " \#S5      r$\RJ                  RM                  SS5      S:H  r'\R:                  " \'S5      r(\" S5      r)\
" SS9r*\" SSS9r+S r,S r-S r.\$\ " S S\5      5       5       r/\$\\ " S S\5      5       5       5       r0\0Rc                  5         \$\\ " S S\5      5       5       5       r2\  " S  S!\5      5       r3\4S":X  a  \Rj                  " 5         gg)#z
Tests gdb bindings
    N)permutations)njitgdbgdb_initgdb_breakpointprange)errors)jit)TestCasecaptured_stdouttagskip_parfors_unsupported)	needs_gdblinuxdarwinbsdzunix-like OS is requiredznon unix-like OS is required>   armv7laarch64ztesting disabled on ARMGDB_TEST1zneeds gdb harnesslong_runningT)debug)forceobjr   c                 X    [        SSSSSS5        U S-   nU S-  nXU4n[        XX#5        g N-exset confirm offcq   Q@)r   printabr   ds       q/Users/tiagomarins/Projetos/claudeai/copy_bank/venv/lib/python3.13/site-packages/numba/tests/test_gdb_bindings.pyimpl_gdb_callr(   ,   s:     %eS9	AA	DA	
q	A	!    c                 l    [        SSSSSS5        U S-   nU S-  nXU4n[        5         [        XX#5        g r   )r   r   r"   r#   s       r'   impl_gdb_call_w_bpr+   4   s@    U%uc5#>	AA	DA	
q	A	!r)   c                     [        SSSSSS5        U S-  n [        S5       H'  nU S-   nU S-  nXU4n[        5         [        XX45        M)     g )	Nr   r   r   r         r    r!   )r   r   r   r"   )r$   ir%   r   r&   s        r'   (impl_gdb_split_init_and_break_w_parallelr0   =   sW    U%uc5#>FAAYEH1IaA r)   c                       \ rS rSrSr\S 5       r\S 5       r\S 5       r\S 5       r	\S 5       r
\S 5       r\\S	 5       5       r\\S
 5       5       r\\S 5       5       rSrg)TestGdbBindImplsH   a  
Contains unit test implementations for gdb binding testing. Test must be
decorated with `@needs_gdb_harness` to prevent their running under normal
test conditions, the test methods must also end with `_impl` to be
considered for execution. The tests themselves are invoked by the
`TestGdbBinding` test class through the parsing of this class for test
methods and then running the discovered tests in a separate process. Test
names not including the word `quick` will be tagged as @tag('long_running')
c                 b    [        5          [        S5        S S S 5        g ! , (       d  f       g = fN
   )r   r(   selfs    r'   $test_gdb_cmd_lang_cpython_quick_impl5TestGdbBindImpls.test_gdb_cmd_lang_cpython_quick_implU   s    "     
.c                 v    [        5          [        [        5      " S5        S S S 5        g ! , (       d  f       g = fr5   )r   	_dbg_njitr(   r7   s    r'   %test_gdb_cmd_lang_nopython_quick_impl6TestGdbBindImpls.test_gdb_cmd_lang_nopython_quick_implZ   s!    m$R(    *
8c                 v    [        5          [        [        5      " S5        S S S 5        g ! , (       d  f       g = fr5   )r   _dbg_jitr(   r7   s    r'   $test_gdb_cmd_lang_objmode_quick_impl5TestGdbBindImpls.test_gdb_cmd_lang_objmode_quick_impl_   s!    ]#B' r@   c                 b    [        5          [        S5        S S S 5        g ! , (       d  f       g = fr5   )r   r+   r7   s    r'   *test_gdb_split_init_and_break_cpython_impl;TestGdbBindImpls.test_gdb_split_init_and_break_cpython_impld   s    r" r;   c                 v    [        5          [        [        5      " S5        S S S 5        g ! , (       d  f       g = fr5   )r   r=   r+   r7   s    r'   +test_gdb_split_init_and_break_nopython_impl<TestGdbBindImpls.test_gdb_split_init_and_break_nopython_impli   s"    ()"- r@   c                 v    [        5          [        [        5      " S5        S S S 5        g ! , (       d  f       g = fr5   )r   rB   r+   r7   s    r'   *test_gdb_split_init_and_break_objmode_impl;TestGdbBindImpls.test_gdb_split_init_and_break_objmode_impln   s"    '(, r@   c                 b    [        5          [        S5        S S S 5        g ! , (       d  f       g = fr5   )r   r0   r7   s    r'   5test_gdb_split_init_and_break_w_parallel_cpython_implFTestGdbBindImpls.test_gdb_split_init_and_break_w_parallel_cpython_impls   s     4R8 r;   c                 v    [        5          [        [        5      " S5        S S S 5        g ! , (       d  f       g = fr5   )r   r=   r0   r7   s    r'   6test_gdb_split_init_and_break_w_parallel_nopython_implGTestGdbBindImpls.test_gdb_split_init_and_break_w_parallel_nopython_imply   s$     >?C r@   c                 v    [        5          [        [        5      " S5        S S S 5        g ! , (       d  f       g = fr5   )r   rB   r0   r7   s    r'   5test_gdb_split_init_and_break_w_parallel_objmode_implFTestGdbBindImpls.test_gdb_split_init_and_break_w_parallel_objmode_impl   s$     =>rB r@    N)__name__
__module____qualname____firstlineno____doc__needs_gdb_harnessr9   r>   rC   rF   rI   rL   r   rO   rR   rU   __static_attributes__rW   r)   r'   r2   r2   H   s       ) ) ( ( # # . . - - 9  9 D  D C  Cr)   r2   c                   P    \ rS rSrSrSrSrSS jrS r\	S 5       r
\	S 5       rS	rg
)TestGdbBinding   z
This test class is used to generate tests which will run the test cases
defined in TestGdbBindImpls in isolated subprocesses, this is for safety
in case something goes awry.
FTc           	         ^	 [         R                  " U[         R                  [         R                  USS9m	U	4S jn[        R                  " SU5      n UR                  5         T	R                  5       u  pgT	R                  nUS:w  a3  [        SU< SUR                  5       < SUR                  5       < 35      eUR                  5       UR                  5       4UR                  5         $ ! UR                  5         f = f)	NT)stdoutstderrenvshellc                     > T R                   R                  5         T R                  R                  5         T R                  5         g N)rc   flushrd   kill)popens   r'   rj   $TestGdbBinding.run_cmd.<locals>.kill   s,    LL LL JJLr)   g      4@r   zprocess failed with code z: stderr follows
z	
stdout :)
subprocessPopenPIPE	threadingTimerstartcommunicate
returncodeAssertionErrordecodecancel)
r8   cmdlinere   
kill_is_okrj   timeoutouterrretcoderk   s
            @r'   run_cmdTestGdbBinding.run_cmd   s      (2(2%('+	-	 //#t,	MMO((*HC&&G!|$ %,SZZ\3::<IJ J ::<-NNGNNs   BC+ +C=c                     [         R                  R                  5       nSUS'   SUS'   [        R                  SSU/nU R
                  " SR                  U5      U40 UD6$ )Nr   	NUMBA_OPTr   z-mznumba.runtests )osenvironcopysys
executabler~   join)r8   testkwargsenv_copyrx   s        r'   run_test_in_separate_process+TestGdbBinding.run_test_in_separate_process   sZ    ::??$ #  #>>4)94@||CHHW-xB6BBr)   c                   ^ [         R                  n[         R                  nUR                  S5      (       d   eUR	                  SS5      nU< SU< SU< 3mU4S jnSU;   a  [        XU5        g [        X[        U5      5        g )N_impl .c                 2  > U R                  T5      u  pSU SU S3n[        R                  " SU5      nUb   U R                  UR	                  S5      5        U R                  SXS9  U R                  SX#S9  U R                  S	X#S9  U R                  S
X#S9  g )Nz
STDOUT=z
STDERR=
z\.\.\. skipped '(.*?)'r    zGNU gdb)msgOKFAILERROR)r   researchskipTestgroupassertInassertNotIn)r8   oedbgmsgminjected_methods        r'   test_template-TestGdbBinding._inject.<locals>.test_template   s    44_EDA 9QCr2F 		3Q7A}aggaj)MM)QM3MM$M.VQ3Wa4r)   quick)r2   rY   rX   endswithreplacesetattrr   )clsnamethemodtheclsmethnamer   r   s         @r'   _injectTestGdbBinding._inject   sq    !,,!**}}W%%%%<<,(.=	5 d?C=1C<#>?r)   c                     [        [        5       H,  nUR                  S5      (       d  M  U R                  U5        M.     g )Ntest_gdb)dirr2   
startswithr   )r   r   s     r'   generateTestGdbBinding.generate   s-    ()Dz**D! *r)   rW   N)F)rX   rY   rZ   r[   r\   _numba_parallel_test__DEBUGr~   r   classmethodr   r   r^   rW   r)   r'   r`   r`      sI     "F6C @ @2 " "r)   r`   c                   $    \ rS rSr\S 5       rSrg)TestGdbMisc   c                    ^ ^ S nSmUU 4S jn[        [        [        /5       H  u  p4U" X45      nU" U5        M     [        S 5       nU" U5        g )Nc                 *   ^ ^ [         U U4S j5       nU$ )Nc                  0   > Sn T" 5         SnT" 5         X-   $ Nr       rW   )r$   r%   f1f2s     r'   impl:TestGdbMisc.test_call_gdb_twice.<locals>.gen.<locals>.impl   s    ur)   )r   )r   r   r   s   `` r'   gen,TestGdbMisc.test_call_gdb_twice.<locals>.gen   s      Kr)   z8Calling either numba.gdb() or numba.gdb_init() more thanc                    > TR                  [        R                  5       nU " 5         S S S 5        TR                  T[	        WR
                  5      5        g ! , (       d  f       N4= frh   )assertRaisesr	   UnsupportedErrorr   str	exception)funcraisesmsg_headr8   s     r'   check.TestGdbMisc.test_call_gdb_twice.<locals>.check   sE    ""6#:#:;v <MM(C(8(8$9: <;s   A
A%c                  :    Sn [        5         Sn[        5         X-   $ r   )r   r   )r$   r%   s     r'   use_globals4TestGdbMisc.test_call_gdb_twice.<locals>.use_globals   s    AEAJ5Lr)   )r   r   r   r   )r8   r   r   g1g2r   r   r   s   `      @r'   test_call_gdb_twiceTestGdbMisc.test_call_gdb_twice   sZ    	 N	;
 #C?3FBr;D$K 4 
	 
	 	kr)   rW   N)rX   rY   rZ   r[   r   r   r^   rW   r)   r'   r   r      s    
  r)   r   c                       \ rS rSrS rSrg)TestGdbExceptionsi  c                 F  ^ S nU[        SS9[        4 Hx  n[        [        4 He  mU4S jnU R	                  [
        R                  5       nU" U5      " 5         S S S 5        SnU R                  U[        WR                  5      5        Mg     Mz     g ! , (       d  f       N>= f)Nc                     U $ rh   rW   )xs    r'   nop_compiler5TestGdbExceptions.test_call_gdb.<locals>.nop_compiler  s    Hr)   T)r   c                     > T " 5         g rh   rW   )meths   r'   python_func4TestGdbExceptions.test_call_gdb.<locals>.python_func  s    Fr)   z2gdb support is only available on unix-like systems)
r
   r   r   r   r   r	   TypingErrorr   r   r   )r8   r   compilerr   r   r   r   s         @r'   test_call_gdbTestGdbExceptions.test_call_gdb  s    	%sD'94@Hh&&v'9'9:f[)+ ;Jc3v'7'7#89 ( A ;:s   B
B rW   N)rX   rY   rZ   r[   r   r^   rW   r)   r'   r   r     s    
:r)   r   __main__)6r\   r   platformr   rm   r   rp   	itertoolsr   numbar   r   r   r   r   
numba.corer	   r
   numba.tests.supportr   r   r   r   numba.tests.gdb_supportr   unittest	_platformr   
_unix_like
skipUnless	unix_onlyskipIfnot_unixmachine
_arch_name_is_armnot_armr   get	_gdb_condr]   r   r=   rB   r(   r+   r0   r2   r`   r   r   r   rX   mainrW   r)   r'   <module>r      s   
  	  
  " = =  ; ; -  LL	""7+ &%%h/&9$  
,FG	??:'EF

-
-
//'#<
=JJNN:t,3	''	3FG >"t	D) 	
9Cx 9C  	9Cx 	

N"X N"   	N"b     	

!( !   	!H 
: : 
: zMMO r)   