Your IP : 216.73.216.103


Current Path : /lib64/python2.7/test/
Upload Files:
Current File: //lib64/python2.7/test/test_gdb.pyc

�
zfc@s6ddlZddlZddlZddlZddlZddlZddlZddlZddlm	Z	ddl
mZmZyddl
Z
Wnek
r�eZ
nXd�Ze�\ZZZedkr�ejdeeef��nejjd�rejd��nejjejjej�d	�Zd
�Ze�Zd�Zej�rxejd��ned
�\Z Z!e r�ejd��ndejgZ"edej�\Z!Z#de#kr�dZ$eje$e#j%���nd�Z&d�Z'e'�Z(d�Z)e)�Z*dej+fd��YZ,ej-e&�d�de,fd��Y�Z.ej-e&�d�de,fd��Y�Z/ej0e(d�ej-e&�d�de,fd��Y��Z1de,fd ��YZ2d!e,fd"��YZ3d#e,fd$��YZ4d%�Z5e6d&kr2e5�ndS('i����N(ttest_support(trun_unittesttfindfilecCs�yDtjdddgdtjdtjdt�}|j�d}Wn tk
rftjd��nXtj	d	|�}|dkr�td
|��n|t|j
d��t|j
d��fS(
Ntgdbs-nxs	--versiontstdouttstderrtuniversal_newlinesisCouldn't find gdb on the paths^GNU gdb.*?\b(\d+)\.(\d+)sunable to parse GDB version: %rii(t
subprocesstPopentPIPEtTruetcommunicatetOSErrortunittesttSkipTesttretsearchtNonet	Exceptiontinttgroup(tproctversiontmatch((s%/usr/lib64/python2.7/test/test_gdb.pytget_gdb_versions			
isFgdb versions before 7.0 didn't support python embedding. Saw %s.%s:
%stsunoss&test doesn't work very well on Solariss
python-gdb.pycCsEtjd�}|stS|j�}d|koDtd�|D��S(NtCFLAGSs-mcetcss.|]$}|jd�o%|jd�VqdS(s-fcf-protections=nones=returnN(s=nones=return(t
startswithtendswith(t.0tflag((s%/usr/lib64/python2.7/test/test_gdb.pys	<genexpr>Fs(t	sysconfigtget_config_vartFalsetsplittany(tcflagstflags((s%/usr/lib64/python2.7/test/test_gdb.pytcet_protection>s	c
Os�|r%tjj�}|j|�nd}d
}ttfdkrZ|ddtf7}ntj	||dtj
d	tj
d
tj
d|�j�\}}||fS(skRuns gdb in batch mode with the additional arguments given by *args.

    Returns its (stdout, stderr)
    Rs--batchs-nxiis-iexsadd-auto-load-safe-path tstdinRRtenvN(Rs--batchs-nx(ii(tostenvirontcopytupdateRtgdb_major_versiontgdb_minor_versiontcheckout_hook_pathRRR	R(targstenv_varsR(tbase_cmdtoutterr((s%/usr/lib64/python2.7/test/test_gdb.pytrun_gdbNs	's3test_gdb only works on source builds at the moment.s9--eval-command=python import sys; print(sys.version_info)s*gdb not built with embedded python supports--argssauto-loading has been declineds3gdb security settings prevent use of custom hooks: cCsOtj�d}d}x,|j�D]}|jd�r#|}q#q#W|dkS(Nt	PY_CFLAGSts-Os-O0s-Og(R7s-O0s-Og(Rtget_config_varsR"R(R$t	final_opttopt((s%/usr/lib64/python2.7/test/test_gdb.pytpython_is_optimizedts
cCs^td�\}}tjd|�}|s<tjd��n|jd�jd�}d|kS(Ns+--eval-command=python print(dir(gdb.Frame))s.*\[(.*)\].*s1Unable to parse output from gdb.Frame.select testis, s'select'(R5RRR
RRR"(Rt_tmt
gdb_frame_dir((s%/usr/lib64/python2.7/test/test_gdb.pytgdb_has_frame_select|scCsCd}tjdd|gdtj�}|j�\}}d|kS(Ns(--eval-command=set auto-load safe-path /Rs--batchRs"on" or "off" expected.(RRR	R(tcmdtpR<R((s%/usr/lib64/python2.7/test/test_gdb.pytgdb_has_autoload_safepath�s
t
DebuggerTestscBsPeZdZdddded�Zded�Zd�Zd�Zd�Z	RS(s(Test that the debugger can debug Python.tPyObject_Printc
Cs�dd|ddg}tr(dg}ng}ttfdkrP|dg7}n|rytrl|d	g7}n||7}n
|d
g7}ddd
g}|g|D]}	d|	^q�7}|g|D]}	d|	^q�7}|dtjg7}|s|dg7}n|r|d|g7}n|r/||g7}ntdd|�\}
}x!|j�D]}tj|IJqTWd|kr�t	j
d��n|
S(s�
        Run 'python -c SOURCE' under gdb with a breakpoint.

        Support injecting commands after the breakpoint is reached

        Returns the stdout from gdb

        cmds_after_breakpoint: if provided, a list of strings: gdb commands
        sset breakpoint pending yessbreak %ssset print address offtrunsset auto-load safe-path /iisset print entry-values notnextt	backtraceRs--batchs-nxs--init-eval-command=%ss--eval-command=%ss--argss-Ss-ctPYTHONHASHSEEDt0sPC not savedsKgdb cannot walk the frame object because the Program Counter is not present(ii(tHAS_AUTOLOAD_SAFEPATHR-R.tCET_PROTECTIONtsyst
executableR5t
splitlinesRR
R(
tselftsourcetscriptt
breakpointtcmds_after_breakpointtimport_sitetcommandst
init_commandsR0R@R3R4tline((s%/usr/lib64/python2.7/test/test_gdb.pytget_stack_trace�s>
		

!!
cCs{|pdg}|j|ddd|d|�}tjd|tj�}|sh|jd||f�n|jd�|fS(	Nsbacktrace 1RRRDRSRTs6.*#0\s+PyObject_Print\s+\(\s*op\=\s*(.*?),\s+fp=.*\).*sUnexpected gdb output: %r
%si(RXRRtDOTALLtfailR(RORPRSRTt
gdb_outputR=((s%/usr/lib64/python2.7/test/test_gdb.pytget_gdb_reprs		cCs*|j|j|�dd||f�dS(s9Ensure that the given "actual" string ends with "exp_end"tmsgs%r did not end with %rN(t
assertTrueR(ROtactualtexp_end((s%/usr/lib64/python2.7/test/test_gdb.pytassertEndsWith scCs9tj||tj�}|j|dd||f�dS(NR]s%r did not match %r(RRRYR^(ROR_tpatternR=((s%/usr/lib64/python2.7/test/test_gdb.pytassertMultilineMatches%scCs
td�S(Ns
gdb_sample.py(R(RO((s%/usr/lib64/python2.7/test/test_gdb.pytget_sample_script)sN(
t__name__t
__module__t__doc__RR!RXR\RaRcRd(((s%/usr/lib64/python2.7/test/test_gdb.pyRC�sk		s&Python was compiled with optimizationstPrettyPrintTestscBs:eZd�Zd!d�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d�Zd	�Zd
�Z
d�Zd�Zd
�Zd�Zd�Zd�Zd!d!d�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z!d�Z"d �Z#RS("cCs&|jd�}|jd|k�dS(Nsprint 42RD(RXR^(ROR[((s%/usr/lib64/python2.7/test/test_gdb.pyttest_getting_backtrace0scCs<|jdt|�|�\}}|j|t|��dS(Nsprint (R\treprtassertEqual(ROtvalRStgdb_reprR[((s%/usr/lib64/python2.7/test/test_gdb.pyt
assertGdbRepr4scCsL|jd�|jd�|jd�|jtj�|jtj�dS(s2Verify the pretty-printing of various "int" valuesi*ii����N(RnRLtmaxint(RO((s%/usr/lib64/python2.7/test/test_gdb.pyttest_int;s



cCs8|jd�|jd�|jd�|jd�dS(s3Verify the pretty-printing of various "long" valuesllJ)�l����l�����I�5N(Rn(RO((s%/usr/lib64/python2.7/test/test_gdb.pyt	test_longCs


cCs+|jt�|jt�|jd�dS(s2Verify the pretty-printing of True, False and NoneN(RnR
R!R(RO((s%/usr/lib64/python2.7/test/test_gdb.pyttest_singletonsJs

cCs2|ji�|jidd6�|jd�dS(s*Verify the pretty-printing of dictionariestbartfoos{'foo': 'bar', 'douglas':42}N(Rn(RO((s%/usr/lib64/python2.7/test/test_gdb.pyt
test_dictsPs
cCs$|jg�|jtd��dS(s#Verify the pretty-printing of listsiN(Rntrange(RO((s%/usr/lib64/python2.7/test/test_gdb.pyt
test_listsVs
cCs8|jd�|jd�|jd�|jd�dS(s%Verify the pretty-printing of stringsR7s(And now for something hopefully the sames7string with embedded NUL here  and then some more texts!this is byte 255:� and byte 128:�N(Rn(RO((s%/usr/lib64/python2.7/test/test_gdb.pyttest_strings[s


cCs.|jt��|jd�|jd�dS(s$Verify the pretty-printing of tuplesiRtRstbazN(i(RtRsRy(Rnttuple(RO((s%/usr/lib64/python2.7/test/test_gdb.pyttest_tuplesbs
cCsE|jd�|jd�|jd�|jd�|jd�dS(s,Verify the pretty-printing of unicode valuesuuhello worldu☠u文字化けu𝄡N(Rn(RO((s%/usr/lib64/python2.7/test/test_gdb.pyttest_unicodehs




cCs�|jt��|jd�d}|j|jd��|j|jd��|jt|�ddh�|jd�d}|j|jd��|j|jd��|jt|�dd	h�|jd
�\}}|j|d�dS(
s"Verify the pretty-printing of setssprint set(['a', 'b'])isset([s])tatbsprint set([4, 5])iis"s = set(['a','b'])
s.pop()
print ss
set(['b'])N(RntsetR\R^RRRkteval(ROtrepRmR[((s%/usr/lib64/python2.7/test/test_gdb.pyt	test_sets�scCs�|jt��|jd�d}|j|jd��|j|jd��|jt|�ddh�|jd�d}|j|jd��|j|jd��|jt|�dd	h�d
S(s(Verify the pretty-printing of frozensetssprint frozenset(['a', 'b'])isfrozenset([s])R}R~sprint frozenset([4, 5])iiN(Rnt	frozensetR\R^RRRkR�(ROR�((s%/usr/lib64/python2.7/test/test_gdb.pyttest_frozensets�scCsN|jd�\}}|j|d�|jd�\}}|j|d�dS(NsR
try:
    raise RuntimeError("I am an error")
except RuntimeError, e:
    print e
s)exceptions.RuntimeError('I am an error',)s>
try:
    a = 1 // 0
except ZeroDivisionError, e:
    print e
sCexceptions.ZeroDivisionError('integer division or modulo by zero',)(R\Rk(RORmR[((s%/usr/lib64/python2.7/test/test_gdb.pyttest_exceptions�s		cCsB|jd�\}}tjd|�}|j|dd|�dS(s5Verify the pretty-printing of classic class instancess:
class Foo:
    pass
foo = Foo()
foo.an_int = 42
print foos(<Foo\(an_int=42\) at remote 0x[0-9a-f]+>R]s%Unexpected classic-class rendering %rN(R\RRR^(RORmR[R=((s%/usr/lib64/python2.7/test/test_gdb.pyttest_classic_class�s
cCsB|jd�\}}tjd|�}|j|dd|�dS(s7Verify the pretty-printing of new-style class instancessB
class Foo(object):
    pass
foo = Foo()
foo.an_int = 42
print foos(<Foo\(an_int=42\) at remote 0x[0-9a-f]+>R]s'Unexpected new-style class rendering %rN(R\RRR^(RORmR[R=((s%/usr/lib64/python2.7/test/test_gdb.pyttest_modern_class�s
cCsB|jd�\}}tjd|�}|j|dd|�dS(s<Verify the pretty-printing of an instance of a list subclasssQ
class Foo(list):
    pass
foo = Foo()
foo += [1, 2, 3]
foo.an_int = 42
print foos(<Foo\(an_int=42\) at remote 0x[0-9a-f]+>R]s'Unexpected new-style class rendering %rN(R\RRR^(RORmR[R=((s%/usr/lib64/python2.7/test/test_gdb.pyttest_subclassing_list�s
cCsB|jd�\}}tjd|�}|j|dd|�dS(s=Verify the pretty-printing of an instance of a tuple subclasssJ
class Foo(tuple):
    pass
foo = Foo((1, 2, 3))
foo.an_int = 42
print foos(<Foo\(an_int=42\) at remote 0x[0-9a-f]+>R]s'Unexpected new-style class rendering %rN(R\RRR^(RORmR[R=((s%/usr/lib64/python2.7/test/test_gdb.pyttest_subclassing_tuple�s
c
Cs�|r|dg}n	dg}|j|d|�\}}|rX|t|�krXdSn|rod|d}nd}tj||�}	|	s�|jd||f�ndS(s�Run Python under gdb, corrupting variables in the inferior process
        immediately before taking a backtrace.

        Verify that the variable's representation is the expected failsafe
        representationRGRSNt<s at remote 0x[0-9a-f]+>s<.* at remote 0x[0-9a-f]+>s$Unexpected gdb representation: %r
%s(R\RjRRRZ(
RORPt
corruptiontexpvaluetexptypeRSRmR[RbR=((s%/usr/lib64/python2.7/test/test_gdb.pyt
assertSane�s		cCs5|jddddg�\}}|j|d�dS(s2Ensure that a NULL PyObject* is handled gracefullysprint 42RSsset variable op=0RGt0x0N(R\Rk(RORmR[((s%/usr/lib64/python2.7/test/test_gdb.pyt
test_NULL_ptr	scCs|jdd�dS(s?Ensure that a PyObject* with NULL ob_type is handled gracefullysprint 42sset op->ob_type=0N(R�(RO((s%/usr/lib64/python2.7/test/test_gdb.pyttest_NULL_ob_types	cCs|jdddd�dS(sDEnsure that a PyObject* with a corrupt ob_type is handled gracefullysprint 42sset op->ob_type=0xDEADBEEFR�i*N(R�(RO((s%/usr/lib64/python2.7/test/test_gdb.pyttest_corrupt_ob_types	cCs|jdddd�dS(sDEnsure that a PyObject* with a type with corrupt tp_flags is handledsprint 42sset op->ob_type->tp_flags=0x0R�i*N(R�(RO((s%/usr/lib64/python2.7/test/test_gdb.pyttest_corrupt_tp_flagss	cCs|jdddd�dS(sCEnsure that a PyObject* with a type with corrupt tp_name is handledsprint 42s#set op->ob_type->tp_name=0xDEADBEEFR�i*N(R�(RO((s%/usr/lib64/python2.7/test/test_gdb.pyttest_corrupt_tp_name$s	cCs|jdddd�dS(sBEnsure that a PyInstanceObject with with a NULL in_dict is handleds:
class Foo:
    pass
foo = Foo()
foo.an_int = 42
print foos(set ((PyInstanceObject*)op)->in_dict = 0R�tFooN(R�(RO((s%/usr/lib64/python2.7/test/test_gdb.pyttest_NULL_instance_dict*scCsH|jddt�\}}tjd|�}|j|dd|�dS(sAEnsure that the new-style class _Helper in site.py can be handledsprint __builtins__.helpRTs<_Helper at remote 0x[0-9a-f]+>R]sUnexpected rendering %rN(R\R
RRR^(RORmR[R=((s%/usr/lib64/python2.7/test/test_gdb.pyttest_builtins_help5scCsN|jd�\}}|j|d�|jd�\}}|j|d�dS(sbEnsure that a reference loop involving a list doesn't lead proxyval
        into an infinite loop:s%a = [3, 4, 5] ; a.append(a) ; print as[3, 4, 5, [...]]s/a = [3, 4, 5] ; b = [a] ; a.append(b) ; print as[3, 4, 5, [[...]]]N(R\Rk(RORmR[((s%/usr/lib64/python2.7/test/test_gdb.pyttest_selfreferential_list?scCs)|jd�\}}|j|d�dS(sbEnsure that a reference loop involving a dict doesn't lead proxyval
        into an infinite loop:s/a = {} ; b = {'bar':a} ; a['foo'] = b ; print as{'foo': {'bar': {...}}}N(R\Rk(RORmR[((s%/usr/lib64/python2.7/test/test_gdb.pyttest_selfreferential_dictLscCs?|jd�\}}|jtjd|�d||f�dS(Ns<
class Foo:
    pass
foo = Foo()
foo.an_attr = foo
print foos/<Foo\(an_attr=<\.\.\.>\) at remote 0x[0-9a-f]+>s$Unexpected gdb representation: %r
%s(R\R^RR(RORmR[((s%/usr/lib64/python2.7/test/test_gdb.pyt'test_selfreferential_old_style_instanceTscCsz|jd�\}}|jtjd|�d||f�|jd�\}}|jtjd|�d||f�dS(NsD
class Foo(object):
    pass
foo = Foo()
foo.an_attr = foo
print foos/<Foo\(an_attr=<\.\.\.>\) at remote 0x[0-9a-f]+>s$Unexpected gdb representation: %r
%ssT
class Foo(object):
    pass
a = Foo()
b = Foo()
a.an_attr = b
b.an_attr = a
print asV<Foo\(an_attr=<Foo\(an_attr=<\.\.\.>\) at remote 0x[0-9a-f]+>\) at remote 0x[0-9a-f]+>(R\R^RR(RORmR[((s%/usr/lib64/python2.7/test/test_gdb.pyt'test_selfreferential_new_style_instanceascCsI|jd�\}}|j|d�|jt|�dtd��dS(s)Verify that very long output is truncatedsprint range(1000)s[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)is...(truncated)N(R\Rktlen(RORmR[((s%/usr/lib64/python2.7/test/test_gdb.pyttest_truncation|s
	cCs)|jd�\}}|j|d�dS(Ns	print lens<built-in function len>(R\Rk(RORmR[((s%/usr/lib64/python2.7/test/test_gdb.pyttest_builtin_function�scCs?|jd�\}}|jtjd|�d||f�dS(Ns&import sys; print sys.stdout.readliness@<built-in method readlines of file object at remote 0x[0-9a-f]+>s$Unexpected gdb representation: %r
%s(R\R^RR(RORmR[((s%/usr/lib64/python2.7/test/test_gdb.pyttest_builtin_method�s
cCsN|jdddddg�}|jtjd|tj�d||f�dS(Ns<
def foo(a, b, c):
    pass

foo(3, 4, 5)
print foo.__code__RRRDRSs;print (PyFrameObject*)(((PyCodeObject*)op)->co_zombieframe)sK.*\s+\$1 =\s+Frame 0x[0-9a-f]+, for file <string>, line 3, in foo \(\)\s+.*s$Unexpected gdb representation: %r
%s(RXR^RRRY(ROR[((s%/usr/lib64/python2.7/test/test_gdb.pyttest_frames�s	N($ReRfRiRRnRpRqRrRuRwRxR{R|R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�(((s%/usr/lib64/python2.7/test/test_gdb.pyRh-sB															
	!	
						
	
		
				tPyListTestscBs,eZd�Zd�Zd�Zd�ZRS(cCs|j||�dS(N(Ra(ROtexpectedR_((s%/usr/lib64/python2.7/test/test_gdb.pyt
assertListing�scCs5|jd|j�ddg�}|jd|�dS(s'Verify that the "py-list" command worksRQRSspy-lists�   5    
   6    def bar(a, b, c):
   7        baz(a, b, c)
   8    
   9    def baz(*args):
 >10        print(42)
  11    
  12    foo(1, 2, 3)
N(RXRdR�(ROtbt((s%/usr/lib64/python2.7/test/test_gdb.pyttest_basic_command�s	cCs5|jd|j�ddg�}|jd|�dS(s7Verify the "py-list" command with one absolute argumentRQRSs	py-list 9sL   9    def baz(*args):
 >10        print(42)
  11    
  12    foo(1, 2, 3)
N(RXRdR�(ROR�((s%/usr/lib64/python2.7/test/test_gdb.pyttest_one_abs_arg�s	cCs5|jd|j�ddg�}|jd|�dS(s8Verify the "py-list" command with two absolute argumentsRQRSspy-list 1,3sR   1    # Sample script for use by test_gdb.py
   2    
   3    def foo(a, b, c):
N(RXRdR�(ROR�((s%/usr/lib64/python2.7/test/test_gdb.pyttest_two_abs_args�s	(ReRfR�R�R�R�(((s%/usr/lib64/python2.7/test/test_gdb.pyR��s			s$test requires py-up/py-down commandstStackNavigationTestscBs,eZd�Zd�Zd�Zd�ZRS(cCs5|jd|j�ddg�}|j|d�dS(s%Verify that the "py-up" command worksRQRSspy-upsn^.*
#[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\)
$N(RXRdRc(ROR�((s%/usr/lib64/python2.7/test/test_gdb.pyttest_pyup_command�s	cCs5|jd|j�ddg�}|j|d�dS(s7Verify handling of "py-down" at the bottom of the stackRQRSspy-downs$Unable to find a newer python frame
N(RXRdRa(ROR�((s%/usr/lib64/python2.7/test/test_gdb.pyttest_down_at_bottom�s	cCs9|jd|j�ddgd�}|j|d�dS(s2Verify handling of "py-up" at the top of the stackRQRSspy-upis%Unable to find an older python frame
N(RXRdRa(ROR�((s%/usr/lib64/python2.7/test/test_gdb.pyttest_up_at_top�s	cCs8|jd|j�dddg�}|j|d�dS(s$Verify "py-up" followed by "py-down"RQRSspy-upspy-downs�^.*
#[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\)\)
    print\(42\)
$N(RXRdRc(ROR�((s%/usr/lib64/python2.7/test/test_gdb.pyttest_up_then_down�s	(ReRfR�R�R�R�(((s%/usr/lib64/python2.7/test/test_gdb.pyR��s	
		t	PyBtTestscBs�eZeje�d�d��Zeje�d�d��Zejed�eje�d�d���Z	eje�d�ejed�d���Z
eje�d�ejed�d���Zeje�d�d��ZRS(s&Python was compiled with optimizationscCs5|jd|j�ddg�}|j|d�dS(s%Verify that the "py-bt" command worksRQRSspy-bts^.*
Traceback \(most recent call first\):
  File ".*gdb_sample.py", line 10, in baz
    print\(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\)
N(RXRdRc(ROR�((s%/usr/lib64/python2.7/test/test_gdb.pyttest_bts	cCs5|jd|j�ddg�}|j|d�dS(s*Verify that the "py-bt-full" command worksRQRSs
py-bt-fulls>^.*
#[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\)
N(RXRdRc(ROR�((s%/usr/lib64/python2.7/test/test_gdb.pyttest_bt_fulls	s*Python was compiled without thread supportcCsZd}|j|ddg�}|jd|�|j|ddg�}|jd|�dS(sBVerify that "py-bt" indicates threads that are waiting for the GILsP
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
print 42

RSsthread apply all py-btsWaiting for the GILsthread apply all py-bt-fullN(RXtassertIn(ROR@R[((s%/usr/lib64/python2.7/test/test_gdb.pyttest_threads'scCsfd}|j|ddddg�}|jd|�|j|ddddg�}|jd|�dS(	s?Verify that "py-bt" indicates if a thread is garbage-collectingsTfrom gc import collect
print 42
def foo():
    collect()
def bar():
    foo()
bar()
RSsbreak update_refstcontinuespy-btsGarbage-collectings
py-bt-fullN(RXR�(ROR@R[((s%/usr/lib64/python2.7/test/test_gdb.pyttest_gcKs	cCsid}|j|dddddg�}|jd|�|j|ddddg�}|jd	|�d
S(sAVerify that "py-bt" displays invocations of PyCFunction instancessLfrom time import gmtime
def foo():
    gmtime(1)
def bar():
    foo()
bar()
RRttime_gmtimeRSR�spy-bts<built-in function gmtimes
py-bt-fulls#1 <built-in function gmtimeN(RXR�(ROR@R[((s%/usr/lib64/python2.7/test/test_gdb.pyttest_pycfunctiongscCsgtjd�}ddg}tr1|jd�n|jd�|j|d|�}|j|d�dS(Ns�
            class MyList(list):
                def __init__(self):
                    super(MyList, self).__init__()   # wrapper_call()

            print("first break point")
            l = MyList()
        sbreak wrapper_callR�RFspy-btRSs1<method-wrapper u?'__init__' of MyList object at (ttextwraptdedentRKtappendRXtassertRegexpMatches(ROR@RSR[((s%/usr/lib64/python2.7/test/test_gdb.pyttest_wrapper_call�s	
		(
ReRfR
tskipIfR;R�R�t
skipUnlesstthreadR�R�R�R�(((s%/usr/lib64/python2.7/test/test_gdb.pyR�s$	!		tPyPrintTestscBs�eZeje�d�d��Zejed�eje�d�d���Zeje�d�d��Z	eje�d�d��Z
RS(s&Python was compiled with optimizationscCs5|jd|j�ddg�}|j|d�dS(s(Verify that the "py-print" command worksRQRSs
py-print argss".*\nlocal 'args' = \(1, 2, 3\)\n.*N(RXRdRc(ROR�((s%/usr/lib64/python2.7/test/test_gdb.pyR��s	s$test requires py-up/py-down commandscCs>|jd|j�dddddg�}|j|d�dS(NRQRSspy-ups
py-print cs
py-print bs
py-print as3.*\nlocal 'c' = 3\nlocal 'b' = 2\nlocal 'a' = 1\n.*(RXRdRc(ROR�((s%/usr/lib64/python2.7/test/test_gdb.pyttest_print_after_up�s	cCs5|jd|j�ddg�}|j|d�dS(NRQRSspy-print __name__s&.*\nglobal '__name__' = '__main__'\n.*(RXRdRc(ROR�((s%/usr/lib64/python2.7/test/test_gdb.pyttest_printing_global�s	cCs5|jd|j�ddg�}|j|d�dS(NRQRSspy-print lens/.*\nbuiltin 'len' = <built-in function len>\n.*(RXRdRc(ROR�((s%/usr/lib64/python2.7/test/test_gdb.pyttest_printing_builtin�s	(ReRfR
R�R;R�R�tHAS_PYUP_PYDOWNR�R�R�(((s%/usr/lib64/python2.7/test/test_gdb.pyR��st
PyLocalsTestscBsVeZeje�d�d��Zejed�eje�d�d���ZRS(s&Python was compiled with optimizationscCs5|jd|j�ddg�}|j|d�dS(NRQRSs	py-localss.*\nargs = \(1, 2, 3\)\n.*(RXRdRc(ROR�((s%/usr/lib64/python2.7/test/test_gdb.pyR��s	s$test requires py-up/py-down commandscCs8|jd|j�dddg�}|j|d�dS(NRQRSspy-ups	py-localss.*\na = 1\nb = 2\nc = 3\n.*(RXRdRc(ROR�((s%/usr/lib64/python2.7/test/test_gdb.pyttest_locals_after_up�s	(	ReRfR
R�R;R�R�R�R�(((s%/usr/lib64/python2.7/test/test_gdb.pyR��s
cCsXtjr;dttfGHx tj�D]}d|GHq%Wntttt	t
tt�dS(NsGDB version %s.%s:t is    (
RtverboseR-R.tgdb_versionRNRRhR�R�R�R�R�(RW((s%/usr/lib64/python2.7/test/test_gdb.pyt	test_main�s	t__main__(7tlocaleR)RRRLRR�R
ttestRttest.test_supportRRR�tImportErrorRRR�R-R.RtplatformRtpathtjointdirnameRMR/R&RKR5tis_python_buildt
gdbpy_versionR<R@tgdbpy_errorsR]trstripR;R?R�RBRJtTestCaseRCR�RhR�R�R�R�R�R�R�Re(((s%/usr/lib64/python2.7/test/test_gdb.pyt<module>sv

				
		
						�	��	'	%�#