o
    HXhҦ                     @   s   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Zd dlZd dlm	Z	 d dl
mZmZ dd Ze \ZZZedk rFedeeef e sOedd	e v r_ejd
kr_ededpededpkdv rrede je jejdZdZdd Ze Zdd Zed\ZZesededej\ZZ de v rdZ!ee!e "  dd Z#e# Z$dZ%e&e	j'dG d d! d!ej(Z)G d"d# d#e)Z*e&e d$G d%d& d&e)Z+G d'd( d(e)Z,G d)d* d*e)Z-G d+d, d,e)Z.G d-d. d.e)Z/d/d0 Z0e1d1kre2  dS dS )2    N)support)findfilepython_is_optimizedc               	   C   s   z@g d} t j| t jt jdd}| | \}}W d    n1 s#w   Y  |jr?tdd| d|j d|d|W n tyL   t	d	w t
d
|}|d u r]td| |t|dt|dfS )N)gdb-nxz	--versionT)stdoutstderruniversal_newlineszCommand  z failed with exit code z	: stdout=z stderr=zCouldn't find gdb on the pathz ^(?:GNU|HP) gdb.*?\b(\d+)\.(\d+)zunable to parse GDB version: %r      )
subprocessPopenPIPEcommunicate
returncode	ExceptionjoinOSErrorunittestSkipTestresearchintgroup)cmdprocversionr   match r   7/opt/python-3.10.19/usr/lib/python3.10/test/test_gdb.pyget_gdb_version   s4   
r!      zFgdb versions before 7.0 didn't support python embedding. Saw %s.%s:
%sz3test_gdb only works on source builds at the moment.ZClangdarwinzDtest_gdb doesn't work correctly when python is built with LLVM clangZPGO_PROF_USE_FLAGZxxxZPY_CORE_CFLAGS z&test_gdb is not reliable on PGO buildszpython-gdb.pyZ123c                  C   s4   t d} | s	dS |  }d|v otdd |D S )NZCFLAGSFz-mcetc                 s   s&    | ]}| d o|d V  qdS )z-fcf-protection)z=nonez=returnN)
startswithendswith).0flagr   r   r    	<genexpr>Q   s    


z!cet_protection.<locals>.<genexpr>)	sysconfigget_config_varsplitany)Zcflagsflagsr   r   r    cet_protectionI   s   
r/   c                  O   s   	 |rt j }|| nd }d}ttfdkr |ddt f7 }tj||  tj	tj	tj	|d}| |
 \}}W d    n1 sBw   Y  |dd|ddfS )N)r   z--batchr   r"      z-iexzadd-auto-load-safe-path )stdinr   r   envzutf-8replace)osenvironcopyupdategdb_major_versiongdb_minor_versioncheckout_hook_pathr   r   r   r   decode)argsZenv_varsr3   Zbase_cmdr   outerrr   r   r    run_gdbY   s$   

r@   z9--eval-command=python import sys; print(sys.version_info)z*gdb not built with embedded python support--argszauto-loading has been declinedz3gdb security settings prevent use of custom hooks: c                  C   s>   t d\} }td| }|std|dd}d|v S )Nz+--eval-command=python print(dir(gdb.Frame))z.*\[(.*)\].*z1Unable to parse output from gdb.Frame.select testr   z, z'select')r@   r   r   r   r   r   r,   )r   _mZgdb_frame_dirr   r   r    gdb_has_frame_select   s   
rD   
builtin_idznot useful for PGOc                   @   sJ   e Zd Z	 ddedddfddZ		dddZdd Zd	d
 Zdd ZdS )DebuggerTestsNFc                 C   s  	 dd| ddg}t tfdkr|dg7 }|r"tr|dg7 }||7 }n|dg7 }d	d
 |D }|dtjg7 }|t  |sC|dg7 }|rL|d|g7 }n|rS||g7 }t|dt	i\}	}
|sl|

 D ]	}t|tjd qbd|
v rutddD ]}||	v rt|dqw|	S )Nzset breakpoint pending yeszbreak %szset print address offrunr0   zset print entry-values nonext	backtracec                 S   s   g | ]}d | qS )z--eval-command=%sr   )r'   r   r   r   r    
<listcomp>   s    z1DebuggerTests.get_stack_trace.<locals>.<listcomp>rA   z-Sz-cPYTHONHASHSEED)filezPC not savedzKgdb cannot walk the frame object because the Program Counter is not present)z!(frame information optimized out)z*Unable to read information on python framez found in gdb output)r9   r:   CET_PROTECTIONsys
executableextendr   _args_from_interpreter_flagsr@   rK   
splitlinesprintr   r   r   )selfsourcescript
breakpointcmds_after_breakpointimport_siteignore_stderrcommandsr=   r>   r?   linepatternr   r   r    get_stack_trace   sF   







zDebuggerTests.get_stack_tracec                 C   sP   |pdg}| j |t||d}td|tj}|s!| d||f  |d|fS )Nzbacktrace 1)rW   rX   rY   zS#0\s+builtin_id\s+\(self\=.*,\s+v=\s*(.*?)?\)\s+at\s+\S*[A-Za-z]+/[A-Za-z0-9_-]+\.czUnexpected gdb output: %r
%sr   )r^   BREAKPOINT_FNr   r   DOTALLfailr   )rT   rU   rX   rY   
gdb_outputrC   r   r   r    get_gdb_repr   s   
	zDebuggerTests.get_gdb_reprc                 C   s"   	 | j ||d||f d d S )Nz%r did not end with %rmsg)
assertTruer&   )rT   actualZexp_endr   r   r    assertEndsWith!  s   

zDebuggerTests.assertEndsWithc                 C   s0   t ||t j}|s| jd||f d d S d S )Nz%r did not match %rrd   )r   r   r`   ra   )rT   rg   r]   rC   r   r   r    assertMultilineMatches&  s   z$DebuggerTests.assertMultilineMatchesc                 C   s   t dS )Nzgdb_sample.py)r   rT   r   r   r    get_sample_script+  s   zDebuggerTests.get_sample_script)NF)	__name__
__module____qualname__r_   r^   rc   rh   ri   rk   r   r   r   r    rF      s    
m
$rF   c                   @   s   e Zd Zdd Z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d Zdd Zdd Zdd Zdd Z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d0d1 Zd2d3 Zd4d5 Zd6d7 Zd8d9 Zd:d; ZdS )=PrettyPrintTestsc                 C   s   |  d}| t|v  d S )Nid(42))r^   rf   r_   rT   rb   r   r   r    test_getting_backtrace/  s   
z'PrettyPrintTests.test_getting_backtraceNc                 C   sB   |  dt| d \}}|st|}| ||d|||f  d S )Nzid()z1%r did not equal expected %r; full output was:
%s)rc   asciireprassertEqual)rT   valZexp_reprgdb_reprrb   r   r   r    assertGdbRepr3  s   zPrettyPrintTests.assertGdbReprc                 C   s8   	 |  d |  d |  d |  d |  d d S )N*   r   il    J)l  I5 ry   rj   r   r   r    test_int=  s   



zPrettyPrintTests.test_intc                 C   s$   	 |  d |  d |  d  d S )NTFr{   rj   r   r   r    test_singletonsE  s   

z PrettyPrintTests.test_singletonsc                 C   s2   	 |  i  |  ddid |  dddd d S )Nfoobarz{'foo': 'bar'}rz   )r~   Zdouglasz{'foo': 'bar', 'douglas': 42}r{   rj   r   r   r    
test_dictsK  s   
zPrettyPrintTests.test_dictsc                 C   s"   	 |  g  |  ttd d S )N   )ry   listrangerj   r   r   r    
test_listsR  s   
zPrettyPrintTests.test_listsc                 C   sT   	 |  d |  d |  d |  d |  d |  tdd tdD  d S )	N    s(   And now for something hopefully the sames7   string with embedded NUL here   and then some more texts7   this is a tab:	 this is a slash-N:
 this is a slash-R:s!   this is byte 255: and byte 128:c                 S   s   g | ]}|qS r   r   )r'   br   r   r    rJ   c  s    z/PrettyPrintTests.test_bytes.<locals>.<listcomp>   )ry   bytesr   rj   r   r   r    
test_bytesW  s   




 zPrettyPrintTests.test_bytesc                    sz   	 t dd\}}|  |s std|  fdd}d d d |d	 |d
 |td d S )Nz--eval-commandz:python import locale; print(locale.getpreferredencoding())zFunable to determine the preferred encoding of embedded Python in GDB: c                    sB   z|    W n ty   | t|  Y d S w |  d S N)encodeUnicodeEncodeErrorry   rt   )textencodingrT   r   r    
check_repru  s   z1PrettyPrintTests.test_strings.<locals>.check_reprr$   z(And now for something hopefully the samez7string with embedded NUL here   and then some more textu   ☠u   文字化けi! )r@   rstripRuntimeErrorry   chr)rT   r>   r?   r   r   r   r    test_stringse  s&   


zPrettyPrintTests.test_stringsc                 C   s*   	 |  t d |  dd |  d d S )Nz())r   z(1,))r~   r   Zbaz)ry   tuplerj   r   r   r    test_tuples  s   zPrettyPrintTests.test_tuplesc                 C   s   	 t tfdk r| d | t d | tdgd tjjs4| tddgd | tg dd	 | d
\}}| 	|d d S )Nr"      z.pretty-printing of sets needs gdb 7.3 or laterzset()az{'a'}r   z
{'a', 'b'}r1   r      z	{4, 5, 6}z&s = set(['a','b'])
s.remove('a')
id(s)z{'b'})
r9   r:   skipTestry   setrN   r.   ignore_environmentrc   rv   rT   rx   rb   r   r   r    	test_sets  s   
zPrettyPrintTests.test_setsc                 C   sp   	 t tfdk r| d | t d | tdgd tjjs6| tddgd | tg dd	 d S d S )
Nr   z4pretty-printing of frozensets needs gdb 7.3 or laterzfrozenset()r   zfrozenset({'a'})r   zfrozenset({'a', 'b'})r   zfrozenset({4, 5, 6}))r9   r:   r   ry   	frozensetrN   r.   r   rj   r   r   r    test_frozensets  s   
z PrettyPrintTests.test_frozensetsc                 C   s8   |  d\}}| |d |  d\}}| |d d S )NzR
try:
    raise RuntimeError("I am an error")
except RuntimeError as e:
    id(e)
zRuntimeError('I am an error',)z=
try:
    a = 1 / 0
except ZeroDivisionError as e:
    id(e)
z&ZeroDivisionError('division by zero',)rc   rv   r   r   r   r    test_exceptions  s   z PrettyPrintTests.test_exceptionsc                 C   2   	 |  d\}}td|}| j|d| d d S )Nz8
class Foo:
    pass
foo = Foo()
foo.an_int = 42
id(foo)*<Foo\(an_int=42\) at remote 0x-?[0-9a-f]+>'Unexpected new-style class rendering %rrd   rc   r   r   rf   rT   rx   rb   rC   r   r   r    test_modern_class  s   
z"PrettyPrintTests.test_modern_classc                 C   r   )NzO
class Foo(list):
    pass
foo = Foo()
foo += [1, 2, 3]
foo.an_int = 42
id(foo)r   r   rd   r   r   r   r   r    test_subclassing_list  s   
z&PrettyPrintTests.test_subclassing_listc                 C   r   )NzH
class Foo(tuple):
    pass
foo = Foo((1, 2, 3))
foo.an_int = 42
id(foo)r   r   rd   r   r   r   r   r    test_subclassing_tuple  s   
z'PrettyPrintTests.test_subclassing_tuplec           	      C   sf   	 |r|dg}ndg}| j ||d\}}|r||krd S d}t||}|s1| d||f  d S d S )NrI   rX   z<.* at remote 0x-?[0-9a-f]+>$Unexpected gdb representation: %r
%s)rc   r   r   ra   )	rT   rU   Z
corruptionexpreprrX   rx   rb   r]   rC   r   r   r    
assertSane  s$   

zPrettyPrintTests.assertSanec                 C   s(   	 | j dddgd\}}| |d d S )Nrp   zset variable v=0rI   r   Z0x0r   r   r   r   r    test_NULL_ptr  s   zPrettyPrintTests.test_NULL_ptrc                 C   s   	 |  dd d S )Nrp   zset v->ob_type=0r   rj   r   r   r    test_NULL_ob_type  s   z"PrettyPrintTests.test_NULL_ob_typec                 C      	 | j dddd d S )Nrp   zset v->ob_type=0xDEADBEEF42r   r   rj   r   r   r    test_corrupt_ob_type  
   
z%PrettyPrintTests.test_corrupt_ob_typec                 C   r   )Nrp   zset v->ob_type->tp_flags=0x0r   r   r   rj   r   r   r    test_corrupt_tp_flags%  r   z&PrettyPrintTests.test_corrupt_tp_flagsc                 C   r   )Nrp   z"set v->ob_type->tp_name=0xDEADBEEFr   r   r   rj   r   r   r    test_corrupt_tp_name+  r   z%PrettyPrintTests.test_corrupt_tp_namec                 C   sH   	 t jjr
| d | jddd\}}td|}| j|d| d d S )Nz(need site module, but -S option was usedzid(__builtins__.help)T)rY   z!<_Helper at remote 0x-?[0-9a-f]+>zUnexpected rendering %rrd   )rN   r.   no_siter   rc   r   r   rf   r   r   r   r    test_builtins_help1  s   

z#PrettyPrintTests.test_builtins_helpc                 C   s:   	 |  d\}}| |d |  d\}}| |d d S )Nz#a = [3, 4, 5] ; a.append(a) ; id(a)z[3, 4, 5, [...]]z-a = [3, 4, 5] ; b = [a] ; a.append(b) ; id(a)z[3, 4, 5, [[...]]]r   r   r   r   r    test_selfreferential_list?  s   z*PrettyPrintTests.test_selfreferential_listc                 C   s    	 |  d\}}| |d d S )Nz-a = {} ; b = {'bar':a} ; a['foo'] = b ; id(a)z{'foo': {'bar': {...}}}r   r   r   r   r    test_selfreferential_dictJ  s   z*PrettyPrintTests.test_selfreferential_dictc                 C   .   |  d\}}| td|d||f  d S )Nz:
class Foo:
    pass
foo = Foo()
foo.an_attr = foo
id(foo)1<Foo\(an_attr=<\.\.\.>\) at remote 0x-?[0-9a-f]+>r   rc   rf   r   r   r   r   r   r    'test_selfreferential_old_style_instanceR  s   
z8PrettyPrintTests.test_selfreferential_old_style_instancec                 C   sX   |  d\}}| td|d||f  |  d\}}| td|d||f  d S )NzB
class Foo(object):
    pass
foo = Foo()
foo.an_attr = foo
id(foo)r   r   zR
class Foo(object):
    pass
a = Foo()
b = Foo()
a.an_attr = b
b.an_attr = a
id(a)zZ<Foo\(an_attr=<Foo\(an_attr=<\.\.\.>\) at remote 0x-?[0-9a-f]+>\) at remote 0x-?[0-9a-f]+>r   r   r   r   r    'test_selfreferential_new_style_instance_  s$   

	z8PrettyPrintTests.test_selfreferential_new_style_instancec                 C   s8   	 |  d\}}| |d | t|dtd  d S )Nzid(list(range(1000)))a  [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226...(truncated)i   z...(truncated))rc   rv   lenr   r   r   r    test_truncationz  s   

z PrettyPrintTests.test_truncationc                 C   r   )Nz$import sys; id(sys.stdout.readlines)zO<built-in method readlines of _io.TextIOWrapper object at remote 0x-?[0-9a-f]+>r   r   r   r   r   r    test_builtin_method  s   
z$PrettyPrintTests.test_builtin_methodc                 C   s6   | j dddgd}| td|tjd||f  d S )Nz:
def foo(a, b, c):
    pass

foo(3, 4, 5)
id(foo.__code__)rE   z:print (PyFrameObject*)(((PyCodeObject*)v)->co_zombieframe))rW   rX   zM.*\s+\$1 =\s+Frame 0x-?[0-9a-f]+, for file <string>, line 3, in foo \(\)\s+.*r   )r^   rf   r   r   r`   rq   r   r   r    test_frames  s   
	
zPrettyPrintTests.test_framesr   ) rl   rm   rn   rr   ry   r|   r}   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r    ro   .  s<    

,

ro   &Python was compiled with optimizationsc                   @   s,   e Zd Zdd Zdd Zdd Zdd Zd	S )
PyListTestsc                 C   s   |  || d S r   )rh   )rT   Zexpectedrg   r   r   r    assertListing  s   zPyListTests.assertListingc                 C   &   	 | j |  dgd}| d| d S )Nzpy-listrV   rX   z   5    
   6    def bar(a, b, c):
   7        baz(a, b, c)
   8    
   9    def baz(*args):
 >10        id(42)
  11    
  12    foo(1, 2, 3)
r^   rk   r   rT   btr   r   r    test_basic_command  s   
zPyListTests.test_basic_commandc                 C   r   )Nz	py-list 9r   zI   9    def baz(*args):
 >10        id(42)
  11    
  12    foo(1, 2, 3)
r   r   r   r   r    test_one_abs_arg  s   
zPyListTests.test_one_abs_argc                 C   r   )Nzpy-list 1,3r   zR   1    # Sample script for use by test_gdb.py
   2    
   3    def foo(a, b, c):
r   r   r   r   r    test_two_abs_args  s   
zPyListTests.test_two_abs_argsN)rl   rm   rn   r   r   r   r   r   r   r   r    r     s
    r   c                   @   sx   e Zd Zeedee ddd Zeeddd Z	eeddd Z
eedee dd	d
 ZdS )StackNavigationTests$test requires py-up/py-down commandsr   c                 C   s(   	 | j |  ddgd}| |d d S )Npy-upr   zp^.*
#[0-9]+ Frame 0x-?[0-9a-f]+, for file .*gdb_sample.py, line 7, in bar \(a=1, b=2, c=3\)
    baz\(a, b, c\)
$r^   rk   ri   r   r   r   r    test_pyup_command     
z&StackNavigationTests.test_pyup_commandc                 C   &   	 | j |  dgd}| |d d S )Npy-downr   z$Unable to find a newer python frame
r^   rk   rh   r   r   r   r    test_down_at_bottom  s   
z(StackNavigationTests.test_down_at_bottomc                 C   s*   	 | j |  dgd d}| |d d S )Nr   r   r   z%Unable to find an older python frame
r   r   r   r   r    test_up_at_top  s   
z#StackNavigationTests.test_up_at_topc                 C   s(   	 | j |  g dd}| |d d S )N)r   r   r   r   z^.*
#[0-9]+ Frame 0x-?[0-9a-f]+, for file .*gdb_sample.py, line 7, in bar \(a=1, b=2, c=3\)
    baz\(a, b, c\)
#[0-9]+ Frame 0x-?[0-9a-f]+, for file .*gdb_sample.py, line 10, in baz \(args=\(1, 2, 3\)\)
    id\(42\)
$r   r   r   r   r    test_up_then_down  r   z&StackNavigationTests.test_up_then_downN)rl   rm   rn   r   
skipUnlessHAS_PYUP_PYDOWNskipIfr   r   r   r   r   r   r   r   r    r     s    






r   c                   @   s   e Zd Zee ddd Zee ddd Zdd Zee ddd	 Z	ee dd
d Z
ee ddd ZdS )	PyBtTestsr   c                 C   r   )Npy-btr   aF  ^.*
Traceback \(most recent call first\):
  <built-in method id of module object .*>
  File ".*gdb_sample.py", line 10, in baz
    id\(42\)
  File ".*gdb_sample.py", line 7, in bar
    baz\(a, b, c\)
  File ".*gdb_sample.py", line 4, in foo
    bar\(a, b, c\)
  File ".*gdb_sample.py", line 12, in <module>
    foo\(1, 2, 3\)
r   r   r   r   r    test_bt     
zPyBtTests.test_btc                 C   r   )N
py-bt-fullr   a>  ^.*
#[0-9]+ Frame 0x-?[0-9a-f]+, for file .*gdb_sample.py, line 7, in bar \(a=1, b=2, c=3\)
    baz\(a, b, c\)
#[0-9]+ Frame 0x-?[0-9a-f]+, for file .*gdb_sample.py, line 4, in foo \(a=1, b=2, c=3\)
    bar\(a, b, c\)
#[0-9]+ Frame 0x-?[0-9a-f]+, for file .*gdb_sample.py, line 12, in <module> \(\)
    foo\(1, 2, 3\)
r   r   r   r   r    test_bt_full  r   zPyBtTests.test_bt_fullc                 C   sB   	 d}| j |dgd}| d| | j |dgd}| d| d S )NaN  
from threading import Thread

class TestThread(Thread):
    # These threads would run forever, but we'll interrupt things with the
    # debugger
    def run(self):
        i = 0
        while 1:
             i += 1

t = {}
for i in range(4):
   t[i] = TestThread()
   t[i].start()

# Trigger a breakpoint on the main thread
id(42)

zthread apply all py-btr   zWaiting for the GILzthread apply all py-bt-fullr^   assertInrT   r   rb   r   r   r    test_threads(  s   zPyBtTests.test_threadsc                 C   sF   	 d}| j |g dd}| d| | j |g dd}| d| d S )NzRfrom gc import collect
id(42)
def foo():
    collect()
def bar():
    foo()
bar()
)break update_refscontinuer   r   zGarbage-collecting)r   r   r   r   r   r   r   r    test_gcH  s   zPyBtTests.test_gcc                 C   s   	 dD ]]\}}}dD ]U}|  | d| A td| d| d| d}| j||ddgd	d
}| d| | | j||dgd	d
}| d| d| | W d    n1 sZw   Y  q
qd S )N))Zmeth_varargsr$   r   )Zmeth_varargs_keywordsr$   r   )Zmeth_oz[]r   )Zmeth_noargsr$   r   )Zmeth_fastcallr$   r   )Zmeth_fastcall_keywordsr$   r   )Z	_testcapiz_testcapi.MethClassz_testcapi.MethClass()z_testcapi.MethStatic().zi
                        import _testcapi
                        def foo():
                            (zy)
                        def bar():
                            foo()
                        bar()
                    r   r   T)rW   rX   rZ   z<built-in method r   #z <built-in method )ZsubTesttextwrapdedentr^   r   )rT   	func_namer=   Zexpected_frameobjr   rb   r   r   r    test_pycfunctionc  s@   	
	zPyBtTests.test_pycfunctionc                 C   sH   t d}ddg}tr|d |d | j||d}| |d d S )Nz
            class MyList(list):
                def __init__(self):
                    super().__init__()   # wrapper_call()

            id("first break point")
            l = MyList()
        zbreak wrapper_callr   rH   r   r   z1<method-wrapper u?'__init__' of MyList object at )r   r   rM   appendr^   ZassertRegex)rT   r   rX   rb   r   r   r    test_wrapper_call  s   


zPyBtTests.test_wrapper_callN)rl   rm   rn   r   r   r   r   r   r   r   r   r   r   r   r   r    r     s,    

 

7r   c                   @   sp   e Zd Zee ddd Zee deeddd Z	ee ddd Z
ee dd	d
 ZdS )PyPrintTestsr   c                 C   s(   	 | j |  ddgd}| |d d S )Nr   zpy-print argsr   z".*\nlocal 'args' = \(1, 2, 3\)\n.*r   r   r   r   r    r     s   
zPyPrintTests.test_basic_commandr   c                 C   &   | j |  g dd}| |d d S )N)r   r   z
py-print cz
py-print bz
py-print ar   z3.*\nlocal 'c' = 3\nlocal 'b' = 2\nlocal 'a' = 1\n.*r   r   r   r   r    test_print_after_up     
z PyPrintTests.test_print_after_upc                 C   &   | j |  ddgd}| |d d S )Nr   zpy-print __name__r   z&.*\nglobal '__name__' = '__main__'\n.*r   r   r   r   r    test_printing_global     
z!PyPrintTests.test_printing_globalc                 C   r   )Nr   zpy-print lenr   zV.*\nbuiltin 'len' = <built-in method len of module object at remote 0x-?[0-9a-f]+>\n.*r   r   r   r   r    test_printing_builtin  r   z"PyPrintTests.test_printing_builtinN)rl   rm   rn   r   r   r   r   r   r   r   r   r   r   r   r   r    r     s$    


r   c                   @   sD   e Zd Zee ddd Zeedee ddd Z	dS )PyLocalsTestsr   c                 C   r   )Nr   	py-localsr   z.*\nargs = \(1, 2, 3\)\n.*r   r   r   r   r    r     r   z PyLocalsTests.test_basic_commandr   c                 C   r   )N)r   r   r  r   z.*\na = 1\nb = 2\nc = 3\n.*r   r   r   r   r    test_locals_after_up  r   z"PyLocalsTests.test_locals_after_upN)
rl   rm   rn   r   r   r   r   r   r   r  r   r   r   r    r    s    

r  c                  C   s8   t jrtdttf  t D ]
} td|   qd S d S )NzGDB version %s.%s:z    )r   verboserS   r9   r:   gdb_versionrR   )r\   r   r   r    setUpModule  s   r  __main__)3r5   platformr   r   rN   r*   r   r   testr   Ztest.supportr   r   r!   r  r9   r:   r   Zis_python_buildZpython_compilerr+   pathr   dirnamerO   r;   rK   r/   rM   r@   Zgdbpy_versionrB   Zgdbpy_errorsre   r   rD   r   r_   r   ZPGOZTestCaserF   ro   r   r   r   r   r  r  rl   mainr   r   r   r    <module>   s~   



	 "   (- =#
