
    xKg}                      X   d Z ddlZddl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	m
Z
mZmZmZmZ ddlmZ ddl	mZ ddlmZmZmZmZ ddlmZ ddlZej                  Zej7                  d	      xs ej7                  d
      xs dev Z ej:                  ed      Z ej>                  ed      Z  ejB                         Z"e"dv Z# ej>                  e#d      Z$ejJ                  jM                  dd      dk(  Z' ej:                  e'd      Z( ed      Z) e
d      Z* edd      Z+d Z,d Z-d Z.e$e G d de                    Z/e$ee G d de                           Z0e0jc                          e$ee G d de                           Z2e  G d  d!e             Z3e4d"k(  r ejj                          yy)#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                 ^    t        dddddd       | dz   }| dz  }| ||f}t        | |||       y N-exset confirm offcq   Q@)r   printabr   ds       a/home/alanp/www/video.onchill/myenv/lib/python3.12/site-packages/numba/tests/test_gdb_bindings.pyimpl_gdb_callr(   ,   s@     %eS9	AA	DA	
Aq	A	!Q1    c                 r    t        dddddd       | dz   }| dz  }| ||f}t                t        | |||       y r   )r   r   r"   r#   s       r'   impl_gdb_call_w_bpr+   4   sF    U%uc5#>	AA	DA	
Aq	A	!Q1r)   c                     t        dddddd       | dz  } t        d      D ])  }| dz   }| dz  }| ||f}t                t        | |||       + y )	Nr   r   r   r         r    r!   )r   r   r   r"   )r$   ir%   r   r&   s        r'   (impl_gdb_split_init_and_break_w_parallelr0   =   s]    U%uc5#>FAAYEH1IaAq r)   c                       e Zd ZdZed        Zed        Zed        Zed        Zed        Z	ed        Z
eed               Zeed	               Zeed
               Zy)TestGdbBindImplsa  
    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                 X    t               5  t        d       d d d        y # 1 sw Y   y xY wN
   )r   r(   selfs    r'   $test_gdb_cmd_lang_cpython_quick_implz5TestGdbBindImpls.test_gdb_cmd_lang_cpython_quick_implU   s    "     )c                 l    t               5   t        t              d       d d d        y # 1 sw Y   y xY wr4   )r   	_dbg_njitr(   r6   s    r'   %test_gdb_cmd_lang_nopython_quick_implz6TestGdbBindImpls.test_gdb_cmd_lang_nopython_quick_implZ   s#    $Im$R(    *3c                 l    t               5   t        t              d       d d d        y # 1 sw Y   y xY wr4   )r   _dbg_jitr(   r6   s    r'   $test_gdb_cmd_lang_objmode_quick_implz5TestGdbBindImpls.test_gdb_cmd_lang_objmode_quick_impl_   s#    #H]#B' r=   c                 X    t               5  t        d       d d d        y # 1 sw Y   y xY wr4   )r   r+   r6   s    r'   *test_gdb_split_init_and_break_cpython_implz;TestGdbBindImpls.test_gdb_split_init_and_break_cpython_impld   s    r" r9   c                 l    t               5   t        t              d       d d d        y # 1 sw Y   y xY wr4   )r   r;   r+   r6   s    r'   +test_gdb_split_init_and_break_nopython_implz<TestGdbBindImpls.test_gdb_split_init_and_break_nopython_impli   s$    )I()"- r=   c                 l    t               5   t        t              d       d d d        y # 1 sw Y   y xY wr4   )r   r?   r+   r6   s    r'   *test_gdb_split_init_and_break_objmode_implz;TestGdbBindImpls.test_gdb_split_init_and_break_objmode_impln   s$    (H'(, r=   c                 X    t               5  t        d       d d d        y # 1 sw Y   y xY wr4   )r   r0   r6   s    r'   5test_gdb_split_init_and_break_w_parallel_cpython_implzFTestGdbBindImpls.test_gdb_split_init_and_break_w_parallel_cpython_impls   s     4R8 r9   c                 l    t               5   t        t              d       d d d        y # 1 sw Y   y xY wr4   )r   r;   r0   r6   s    r'   6test_gdb_split_init_and_break_w_parallel_nopython_implzGTestGdbBindImpls.test_gdb_split_init_and_break_w_parallel_nopython_imply   s&     ?I>?C r=   c                 l    t               5   t        t              d       d d d        y # 1 sw Y   y xY wr4   )r   r?   r0   r6   s    r'   5test_gdb_split_init_and_break_w_parallel_objmode_implzFTestGdbBindImpls.test_gdb_split_init_and_break_w_parallel_objmode_impl   s&     >H=>rB r=   N)__name__
__module____qualname____doc__needs_gdb_harnessr8   r<   r@   rB   rD   rF   r   rH   rJ   rL    r)   r'   r2   r2   H   s       ) ) ( ( # # . . - - 9  9 D  D C  Cr)   r2   c                   F    e Zd ZdZdZdZd	dZd Zed        Z	ed        Z
y)
TestGdbBindingz
    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           	        	 t        j                  |t         j                  t         j                  |d      		fd}t        j                  d|      }	 |j                          	j                         \  }}	j                  }|dk7  r0t        d|d|j                         d|j                               |j                         |j                         f|j                          S # |j                          w xY w)	NT)stdoutstderrenvshellc                       j                   j                           j                  j                           j                          y N)rV   flushrW   kill)popens   r'   r]   z$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)
r7   cmdlinerX   
kill_is_okr]   timeoutouterrretcoder^   s
            @r'   run_cmdzTestGdbBinding.run_cmd   s      (2(2%('+	-	 //#t,	MMO((*HC&&G!|$ %,SZZ\3::<IJ J ::<-NNGNNs   BC( (C:c                     t         j                  j                         }d|d<   d|d<   t        j                  dd|g} | j
                  dj                  |      |fi |S )Nr   	NUMBA_OPTr   z-mznumba.runtests )osenvironcopysys
executablerp   join)r7   testkwargsenv_copyrj   s        r'   run_test_in_separate_processz+TestGdbBinding.run_test_in_separate_process   s\    ::??$ #  #>>4)94@t||CHHW-xB6BBr)   c                     t         j                  }t         j                  }|j                  d      sJ |j	                  dd      }|d|d|fd}d|v rt        | ||       y t        | |t        |             y )N_impl .c                 P   | j                        \  }}d| d| d}t        j                  d|      }| | j                  |j	                  d             | j                  d||       | j                  d||       | j                  d	||       | j                  d
||       y )Nz
STDOUT=z
STDERR=
z\.\.\. skipped '(.*?)'r    zGNU gdb)msgOKFAILERROR)r}   researchskipTestgroupassertInassertNotIn)r7   oedbgmsgminjected_methods        r'   test_templatez-TestGdbBinding._inject.<locals>.test_template   s    44_EDAq 9QCr2F 		3Q7A}aggaj)MM)QFM3MM$vM.VQF3WaV4r)   quick)r2   rN   rM   endswithreplacesetattrr   )clsnamethemodtheclsmethnamer   r   s         @r'   _injectzTestGdbBinding._inject   sr    !,,!**}}W%%%<<,(.=	5 d?C=1C<#>?r)   c                 r    t        t              D ]%  }|j                  d      s| j                  |       ' y )Ntest_gdb)dirr2   
startswithr   )r   r   s     r'   generatezTestGdbBinding.generate   s*    ()Dz*D! *r)   N)F)rM   rN   rO   rP   _numba_parallel_test__DEBUGrp   r}   classmethodr   r   rR   r)   r'   rT   rT      sI     "F6C @ @2 " "r)   rT   c                       e Zd Zed        Zy)TestGdbMiscc                      d }d fd}t        t        t        g      D ]  \  }} |||      } ||        t        d        } ||       y )Nc                 (     t          fd       }|S )Nc                  2    d}          d}         | |z   S Nr       rR   )r$   r%   f1f2s     r'   implz:TestGdbMisc.test_call_gdb_twice.<locals>.gen.<locals>.impl   s     1ur)   )r   )r   r   r   s   `` r'   genz,TestGdbMisc.test_call_gdb_twice.<locals>.gen   s      Kr)   z8Calling either numba.gdb() or numba.gdb_init() more thanc                     j                  t        j                        5 } |         d d d        j                  t	        j
                               y # 1 sw Y   /xY wr[   )assertRaisesr	   UnsupportedErrorr   str	exception)funcraisesmsg_headr7   s     r'   checkz.TestGdbMisc.test_call_gdb_twice.<locals>.check   sE    ""6#:#:;v <MM(C(8(8$9: <;s   AA c                  <    d} t                d}t                | |z   S r   )r   r   )r$   r%   s     r'   use_globalsz4TestGdbMisc.test_call_gdb_twice.<locals>.use_globals   s    AEAJq5Lr)   )r   r   r   r   )r7   r   r   g1g2r   r   r   s   `      @r'   test_call_gdb_twicezTestGdbMisc.test_call_gdb_twice   s^    	 N	;
 #C?3FBr2;D$K 4 
	 
	 	kr)   N)rM   rN   rO   r   r   rR   r)   r'   r   r      s    
  r)   r   c                       e Zd Zd Zy)TestGdbExceptionsc                 8   d }|t        d      t        fD ]t  }t        t        fD ]c  fd}| j	                  t
        j                        5 }  ||              d d d        d}| j                  |t        j                               e v y # 1 sw Y   5xY w)Nc                     | S r[   rR   )xs    r'   nop_compilerz5TestGdbExceptions.test_call_gdb.<locals>.nop_compiler  s    Hr)   T)r   c                                y r[   rR   )meths   r'   python_funcz4TestGdbExceptions.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   )r7   r   compilerr   r   r   r   s         @r'   test_call_gdbzTestGdbExceptions.test_call_gdb  s    	%sD'94@Hh&&v'9'9:f)H[)+ ;Jc3v'7'7#89 ( A ;:s   BBN)rM   rN   rO   r   rR   r)   r'   r   r     s    
:r)   r   __main__)6rP   rt   platformr   r_   rw   rb   	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_armru   get	_gdb_condrQ   r   r;   r?   r(   r+   r0   r2   rT   r   r   r   rM   mainrR   r)   r'   <module>r      s   
  	  
  " = =  ; ; -  LL	""7+ &%%h/&9$   H
,FG	8??:'EFX

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