python (3.12.0)

(root)/
lib/
python3.12/
test/
__pycache__/
test_gdb.cpython-312.pyc

ΑeavddlZddlZddlZddlZddlZddlZddlZddlZddlm	Z	ddl
mZmZdZ
e
\ZZZedkrej"dededeej$sej"d	ej&d
xsdej&dxsd
vrej"dej(j+ej(j-ej.dZdZdZeZdZed\ZZesej"ddevrej"dedej.\ZZdevr%dZ ej"e ejCzdZ"e"Z#dZ$ejJe	jLdGddejNZ(Gdd e(Z)ejJed!Gd"d#e(Z*d$Z+Gd%d&e(Z,Gd'd(e(Z-Gd)d*e(Z.Gd+d,e(Z/d-Z0e1d.k(rejdyy)/N)support)findfilepython_is_optimizedc
>	gd}tj|tjtjd}|5|j\}}ddd|jr0tddj
|d|jdd	tjd
}|td|z|t|jdt|jd
fS#1swYxYw#t$rtjd	wxYw)N)gdb-nxz	--versionT)stdoutstderruniversal_newlineszCommand  z failed with exit code z	: stdout=z stderr=zCouldn't find gdb on the pathz ^(?:GNU|HP) gdb.*?\b(\d+)\.(\d+)zunable to parse GDB version: %r)
subprocessPopenPIPEcommunicate
returncode	ExceptionjoinOSErrorunittestSkipTestresearchintgroup)cmdprocversionr
matchs     A/BuggyBox/python/3.12.0/bootstrap/lib/python3.12/test/test_gdb.pyget_gdb_versionr"s#A)'1'1379	1"..0OGV	1??hsxx}&78..2oo->?&&-[
DE
E
II97CE}9GCDDSQ(#ekk!n*=>>+	1	1A ?@@As#;C=C1AC=1C:6C==Dz=gdb versions before 7.0 didn't support python embedding. Saw .z:
z3test_gdb only works on source builds at the moment.PGO_PROF_USE_FLAGxxxPY_CORE_CFLAGSz&test_gdb is not reliable on PGO buildsz
python-gdb.py123ctjd}|sy|j}d|vxrtd|DS)NCFLAGSFz-mcetc3fK|])}|jdxr|jd+yw)z-fcf-protection)z=nonez=returnN)
startswithendswith).0flags  r!	<genexpr>z!cet_protection.<locals>.<genexpr>Ms>'__%67A!]]+?@@A's/1)	sysconfigget_config_varsplitany)cflagsflagss  r!cet_protectionr8EsL

%
%h
/FLLNE

'' %''(c|r0tjj}|j|nd}d}tt
fdk\r|ddtzfz
}tj||ztjtjtj|}|5|j\}}dddjddjddfS#1swY-xYw)	zRuns gdb in --batch mode with the additional arguments given by *args.

    Returns its (stdout, stderr) decoded from utf-8 using the replace handler.
    N)rz--batchrr#z-iexzadd-auto-load-safe-path )stdinr	r
envzutf-8replace)osenvironcopyupdategdb_major_versiongdb_minor_versioncheckout_hook_pathrrrrdecode)argsenv_varsr>base_cmdrouterrs       r!run_gdbrMUs
jjoo

8)H,-7V7:LLMMHtO#-//#-??#-?? #
%D
&##%S&::gy)3::gy+III&&sCC&z9--eval-command=python import sys; print(sys.version_info)z*gdb not built with embedded python supportzmajor=2zgdb built with Python 2--argszauto-loading has been declinedz3gdb security settings prevent use of custom hooks: ctd\}}tjd|}|stjd|jdj
d}d|vS)Nz+--eval-command=python print(dir(gdb.Frame))z.*\[(.*)\].*z1Unable to parse output from gdb.Frame.select testr
z, z'select')rMrr rrrr4)r	_m
gdb_frame_dirs    r!gdb_has_frame_selectrS~sYEFIFA
&)A STTGGAJ$$T*M&&r9
builtin_idznot useful for PGOcBeZdZdZddedddfdZ		d	dZdZdZdZ	y)

DebuggerTestsz(Test that the debugger can debug Python.NFcHdd|zddg}ttfdk\r|dgz
}|rtr|dgz
}||z
}n|dgz
}|Dcgc]}d	|z	}	}|	d
tjgz
}	|	jt
j|s|	dgz
}	|r|	d|gz
}	n|r|	|gz
}	t|	d
ti\}
}|s0|jD]}t|tjd|vrtjddD]}
|
|
vstj|
d|
Scc}w)z
        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
        zset breakpoint pending yeszbreak %szset print address offrunr;zset print entry-values nonext	backtracez--eval-command=%srNz-Sz-cPYTHONHASHSEED)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)(unable to read python frame information)z,Backtrace stopped: frame did not save the PCz ?? ()z found in gdb output)rDrECET_PROTECTIONsys
executableextendr_args_from_interpreter_flagsrMr[
splitlinesprintr
rr)selfsourcescript
breakpointcmds_after_breakpointimport_site
ignore_stderrcommandsrrHrKrLlinepatterns              r!get_stack_tracezDebuggerTests.get_stack_traces}81+,
*
01V;455H 
VH$--H
%H
6>>c#c)>>!	!J;;=>TFNDT6N"D
VHDD@@S(
-d,
-S ##%34
4
	LG#~''7+5I(JKK!	L$
g?sDc|xsdg}|j|t||}tjd|tj}|s|jd|d||j
d|fS)Nzbacktrace 1)rgrhrizS#0\s+builtin_id\s+\(self\=.*,\s+v=\s*(.*?)?\)\s+at\s+\S*[A-Za-z]+/[A-Za-z0-9_-]+\.czUnexpected gdb output: 
r
)rn
BREAKPOINT_FNrrDOTALLfailr)rdrerhri
gdb_outputrQs      r!get_gdb_reprzDebuggerTests.get_gdb_reprsz !6 H-))&]@U6A*C

II
6
		
#IIZPQwwqz:%%r9cR|j|j||d|y)z9Ensure that the given "actual" string ends with "exp_end"z did not end with msgN)
assertTruer.)rdactualexp_ends   r!assertEndsWithzDebuggerTests.assertEndsWith+s'08>H		Jr9ctj||tj}|s|j|d|yy)Nz did not match rw)rr rrrs)rdrzrmrQs    r!assertMultilineMatchesz$DebuggerTests.assertMultilineMatches0s3HHWfbii0II67CIDr9ctdS)Nz
gdb_sample.py)rrds r!get_sample_scriptzDebuggerTests.get_sample_script5s
((r9)NF)
__name__
__module____qualname____doc__rqrnrur|r~rr9r!rVrVs>3%)$#0.2$)&+	up,0!&"&HJ
E
)r9rVceZdZdZd dZejddZdZdZ	dZ
ejdd	Zejdd
ZdZ
ejddZejdd
ZdZdZdZdZd dZdZdZdZdZdZdZdZdZdZdZdZdZ dZ!y)!PrettyPrintTestscT|jd}|jt|vy)Nid(42))rnryrqrdrts  r!test_getting_backtracez'PrettyPrintTests.test_getting_backtrace9s#))(3

34r9Nc	|jdt|zdz\}}|st|}|j|||d|d|y)Nzid()z did not equal expected z; full output was:
)ruasciireprassertEqual)rdvalexp_reprgdb_reprrts     r!
assertGdbReprzPrettyPrintTests.assertGdbRepr=sQ $00s1Cc1IJ*CyH8%x=	?r9cpuc|jd|jd|jd|jd|jdy)z0Verify the pretty-printing of various int values*rilJ)lI5Nrrs r!test_intzPrettyPrintTests.test_intGsK	
212=),-r9cj|jd|jd|jdy)z2Verify the pretty-printing of True, False and NoneTFNrrs r!test_singletonsz PrettyPrintTests.test_singletonsPs,4 5!4 r9cx|ji|jddid|jddddy)z*Verify the pretty-printing of dictionariesfoobarz{'foo': 'bar'}r)rdouglasz{'foo': 'bar', 'douglas': 42}Nrrs r!
test_dictszPrettyPrintTests.test_dictsVs;2E5>+;<5R8:YZr9cl|jg|jttdy)z#Verify the pretty-printing of listsN)rlistrangers r!
test_listszPrettyPrintTests.test_lists]s&24a>*r9c|jd|jd|jd|jd|jd|jttdDcgc]}|c}ycc}w)z#Verify the pretty-printing of bytesr9s(And now for something hopefully the sames7string with embedded NUL here  and then some more texts7this is a tab:	 this is a slash-N:
 this is a slash-R:
s!this is byte 255: and byte 128:N)rbytesr)rdbs  r!
test_byteszPrettyPrintTests.test_bytesbsy	
3FGVW4	
	
EF5U3Z!8!!89:!8s3	Bctdd\}}|j|sstd|fd}jdjdjd|d|d	|t	d
y)z-Verify the pretty-printing of unicode stringsz--eval-commandz:python import locale; print(locale.getpreferredencoding())zFunable to determine the preferred encoding of embedded Python in GDB: c	|jj|y#t$rj|t|YywxYwN)encoderUnicodeEncodeErrorr)textencodingrds r!
check_reprz1PrettyPrintTests.test_strings.<locals>.check_reprsI
)H%""4(&
6""4t5
6s&$A
A
r(z(And now for something hopefully the samez7string with embedded NUL here  and then some more textu☠u文字化けi!N)rMrstripRuntimeErrorrchr)rdrKrLrrs`   @r!test_stringszPrettyPrintTests.test_stringsqsHJS::<h..1U45
5	)	
2EFUV	8
	-.	3w< r9c~|jtd|jdd|jdy)z$Verify the pretty-printing of tuplesz())r
z(1,))rrbazN)rtuplers r!test_tupleszPrettyPrintTests.test_tupless357D)4(01r9cttfdkr|jd|jt	d|jt	dgdt
jjs:|jt	ddgd|jt	gdd	|jd
\}}|j|dy)
z"Verify the pretty-printing of setsr#z.pretty-printing of sets needs gdb 7.3 or laterzset()az{'a'}rz
{'a', 'b'}r<rz	{4, 5, 6}z&s = set(['a','b'])
s.remove('a')
id(s)z{'b'}N)
rDrEskipTestrsetr^r7ignore_environmentrurrdrrts   r!	test_setszPrettyPrintTests.test_setss
01F:MMJK35'*3u:w/yy++sC:=s9~{; $002	 
*	
7+r9cZttfdkr|jd|jt	d|jt	dgdt
jjs;|jt	ddgd|jt	gdd	y
y
)z(Verify the pretty-printing of frozensetsrz4pretty-printing of frozensets needs gdb 7.3 or laterzfrozenset()rzfrozenset({'a'})rzfrozenset({'a', 'b'})rzfrozenset({4, 5, 6})N)rDrErr	frozensetr^r7rrs r!test_frozensetsz PrettyPrintTests.test_frozensetss
01F:MMPQ9;
69cU+-?@yy++y#s46MNy35KL,r9c|jd\}}|j|d|jd\}}|j|dy)NzR
try:
    raise RuntimeError("I am an error")
except RuntimeError as e:
    id(e)
zRuntimeError('I am an error',)z=
try:
    a = 1 / 0
except ZeroDivisionError as e:
    id(e)
z&ZeroDivisionError('division by zero',)rurrs   r!test_exceptionsz PrettyPrintTests.test_exceptionssc#002 *	
9	;
 $002 *	
A	Cr9c|jd\}}tjd|}|j|d|zy)z7Verify the pretty-printing of new-style class instancesz8
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 %rrwNrurr ryrdrrtrQs    r!test_modern_classz"PrettyPrintTests.test_modern_classsK#002 *
HHBHMEP		Rr9c|jd\}}tjd|}|j|d|zy)z<Verify the pretty-printing of an instance of a list subclasszO
class Foo(list):
    pass
foo = Foo()
foo += [1, 2, 3]
foo.an_int = 42
id(foo)rrrwNrrs    r!test_subclassing_listz&PrettyPrintTests.test_subclassing_listsK#002 *
HHBHMEP		Rr9c|jd\}}tjd|}|j|d|zy)z=Verify the pretty-printing of an instance of a tuple subclasszH
class Foo(tuple):
    pass
foo = Foo((1, 2, 3))
foo.an_int = 42
id(foo)rrrwNrrs    r!test_subclassing_tuplez'PrettyPrintTests.test_subclassing_tuplesM $002 *
HHBHMEP		Rr9c|r|dg}ndg}|j||\}}|r||k(ryd}tj||}|s|jd|d|yy)zRun Python under gdb, corrupting variables in the inferior process
        immediately before taking a backtrace.

        Verify that the variable's representation is the expected failsafe
        representationrZrhNz<.* at remote 0x-?[0-9a-f]+>Unexpected gdb representation: rp)rurr rs)	rdre
corruptionexpreprrhrrtrmrQs	         r!
assertSanezPrettyPrintTests.assertSanes#-{";!#.-!
f4I

K	*7"1HHWh'II#Z1
2r9cX|jdddg\}}|j|dy)z2Ensure that a NULL PyObject* is handled gracefullyrzset variable v=0rZr0x0Nrrs   r!
test_NULL_ptrzPrettyPrintTests.test_NULL_ptrsA
h5G5@5B

C	*	
5)r9c(|jddy)z?Ensure that a PyObject* with NULL ob_type is handled gracefullyrzset v->ob_type=0Nrrs r!test_NULL_ob_typez"PrettyPrintTests.test_NULL_ob_type)s*	,r9c,|jdddy)zDEnsure that a PyObject* with a corrupt ob_type is handled gracefullyrzset v->ob_type=0xDEADBEEF42rNrrs r!test_corrupt_ob_typez%PrettyPrintTests.test_corrupt_ob_type.s3 $		&r9c,|jdddy)zDEnsure that a PyObject* with a type with corrupt tp_flags is handledrzset v->ob_type->tp_flags=0x0rrNrrs r!test_corrupt_tp_flagsz&PrettyPrintTests.test_corrupt_tp_flags4s6 $		&r9c,|jdddy)zCEnsure that a PyObject* with a type with corrupt tp_name is handledrz"set v->ob_type->tp_name=0xDEADBEEFrrNrrs r!test_corrupt_tp_namez%PrettyPrintTests.test_corrupt_tp_name:s< $		&r9ctjjr|jd|j	dd\}}tjd|}|j|d|zy)	zAEnsure that the new-style class _Helper in site.py can be handledz(need site module, but -S option was usedzid(__builtins__.help)T)riz%<_Helper\(\) at remote 0x-?[0-9a-f]+>zUnexpected rendering %rrwN)r^r7no_siterrurr ryrs    r!test_builtins_helpz#PrettyPrintTests.test_builtins_help@si99MMDE $001HVZ0[*HH=xH5@		Br9c|jd\}}|j|d|jd\}}|j|dy)zbEnsure that a reference loop involving a list doesn't lead proxyval
        into an infinite loop:z#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, [[...]]]Nrrs   r!test_selfreferential_listz*PrettyPrintTests.test_selfreferential_listNsX
CD	*#56
MN	*#78r9cP|jd\}}|j|dy)zbEnsure that a reference loop involving a dict doesn't lead proxyval
        into an infinite loop:z-a = {} ; b = {'bar':a} ; a['foo'] = b ; id(a)z{'foo': {'bar': {...}}}Nrrs   r!test_selfreferential_dictz*PrettyPrintTests.test_selfreferential_dictYs/
MN	*	
#<=r9c|jd\}}|jtjd|d|d|y)Nz:
class Foo:
    pass
foo = Foo()
foo.an_attr = foo
id(foo)1<Foo\(an_attr=<\.\.\.>\) at remote 0x-?[0-9a-f]+>rrpruryrr rs   r!'test_selfreferential_old_style_instancez8PrettyPrintTests.test_selfreferential_old_style_instanceasI
	*	
!U!)+&z3	4r9c|jd\}}|jtjd|d|d||jd\}}|jtjd|d|d|y)NzB
class Foo(object):
    pass
foo = Foo()
foo.an_attr = foo
id(foo)rrrpzR
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]+>rrs   r!'test_selfreferential_new_style_instancez8PrettyPrintTests.test_selfreferential_new_style_instancens
	*	
!U!)+&z3	4
	
	*	
!~!)+&z3	4r9c|jd\}}|j|d|jt|dtdzy)z)Verify that very long output is truncatedzid(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)iz...(truncated)N)rurlenrs   r!test_truncationz PrettyPrintTests.test_truncationsQ#001HI*7	8,	
X$4 55	7r9c|jd\}}|jtjd|d|d|y)Nz$import sys; id(sys.stdout.readlines)zO<built-in method readlines of _io.TextIOWrapper object at remote 0x-?[0-9a-f]+>rrprrs   r!test_builtin_methodz$PrettyPrintTests.test_builtin_methodsA#001WX*!s!)+&z3	4r9c|jdddg}|jtjd|tjd|d|y)NzQ
import sys
def foo(a, b, c):
    return sys._getframe(0)

f = foo(3, 4, 5)
id(f)rTzprint (PyFrameObject*)v)rgrhzK.*\s+\$1 =\s+Frame 0x-?[0-9a-f]+, for file <string>, line 4, in foo \(a=3.*rrp)rnryrr rrrs  r!test_frameszPrettyPrintTests.test_framess[))+	6BAZ@[*	,
	
!o!+!#,DNzZ	\r9r)"rrrrrrrequires_resourcerrrrrrrrrrrrrrrrrrrrrrrrrrrrr9r!rr8s)5?Wu%.&.![+
Wu%;&;Wu%*!&*!X2Wu%,&,$Wu%	M&	MC,
RR
R2:*,
&&&B	9>446784\r9r&Python was compiled with optimizationsc$eZdZdZdZdZdZy)PyListTestsc(|j||yr)r|)rdexpectedrzs   r!
assertListingzPyListTests.assertListingsFH-r9cl|j|jdg}|jd|y)z'Verify that the "py-list" command workszpy-listrfrhz   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)
Nrnrrrdbts  r!test_basic_commandzPyListTests.test_basic_commandsB

!
!)?)?)A9B"E	
4	r9cl|j|jdg}|jd|y)z7Verify the "py-list" command with one absolute argumentz	py-list 9rzI   9    def baz(*args):
 >10        id(42)
  11    
  12    foo(1, 2, 3)
Nrr	s  r!test_one_abs_argzPyListTests.test_one_abs_argsB

!
!)?)?)A9D
"G	
4		r9cl|j|jdg}|jd|y)z8Verify the "py-list" command with two absolute argumentszpy-list 1,3rzR   1    # Sample script for use by test_gdb.py
   2    
   3    def foo(a, b, c):
Nrr	s  r!test_two_abs_argszPyListTests.test_two_abs_argssB

!
!)?)?)A9F"I	
9	r9N)rrrrrr
rrr9r!rrs.
	r9rz

from _testcapi import pyobject_fastcall

def foo(a, b, c):
    bar(a, b, c)

def bar(a, b, c):
    pyobject_fastcall(baz, (a, b, c))

def baz(*args):
    id(42)

foo(1, 2, 3)

c@eZdZejedejeddZejeddZ	ejeddZ
ejedejeddZy)StackNavigationTests$test requires py-up/py-down commandsrcZ|jtddg}|j|dy)z%Verify that the "py-up" command workspy-uprerhz^.*
#[0-9]+ Frame 0x-?[0-9a-f]+, for file <string>, line 12, in baz \(args=\(1, 2, 3\)\)
#[0-9]+ <built-in method pyobject_fastcall of module object at remote 0x[0-9a-f]+>
$NrnSAMPLE_WITH_C_CALLr~r	s  r!test_pyup_commandz&StackNavigationTests.test_pyup_commands:

!
!);9@'8J"L##B%	r9cl|j|jdg}|j|dy)z7Verify handling of "py-down" at the bottom of the stackpy-downrz$Unable to find a newer python frame
Nrnrr|r	s  r!test_down_at_bottomz(StackNavigationTests.test_down_at_bottoms>
!
!)?)?)A9B"EBC	Er9cr|j|jdgdz}|j|dy)z2Verify handling of "py-up" at the top of the stackrrrz%Unable to find an older python frame
Nrr	s  r!test_up_at_topz#StackNavigationTests.test_up_at_topsB
!
!)?)?)A9@	A
"GBD	Fr9cZ|jtgd}|j|dy)z$Verify "py-up" followed by "py-down")rrrra^.*
#[0-9]+ Frame 0x-?[0-9a-f]+, for file <string>, line 12, in baz \(args=\(1, 2, 3\)\)
#[0-9]+ <built-in method pyobject_fastcall of module object at remote 0x[0-9a-f]+>
#[0-9]+ Frame 0x-?[0-9a-f]+, for file <string>, line 12, in baz \(args=\(1, 2, 3\)\)
$Nrr	s  r!test_up_then_downz&StackNavigationTests.test_up_then_downs5

!
!);8U"W##B%	r9N)rrrr
skipUnlessHAS_PYUP_PYDOWNskipIfrrrrr rr9r!rrsX*PQX__(*=??RX*PQEREX*PQFRFX*PQX__(*=?	?R	r9rceZdZejeddZejeddZejedejddZ
ejeddZejedejddZejeddZ
y	)
	PyBtTestsrcl|j|jdg}|j|dy)z%Verify that the "py-bt" command workspy-btraL^.*
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=a, b=b, c=c\)
  File ".*gdb_sample.py", line 12, in <module>
    foo\(1, 2, 3\)
Nrnrr~r	s  r!test_btzPyBtTests.test_bt%s?
!
!)?)?)A9@	"C##B%	r9cl|j|jdg}|j|dy)z*Verify that the "py-bt-full" command works
py-bt-fullraD^.*
#[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=a, b=b, c=c\)
#[0-9]+ Frame 0x-?[0-9a-f]+, for file .*gdb_sample.py, line 12, in <module> \(\)
    foo\(1, 2, 3\)
Nr(r	s  r!test_bt_fullzPyBtTests.test_bt_full9s?
!
!)?)?)A9E"H##B%	r9rcd}|j|dg}|jd||j|dg}|jd|y)zBVerify that "py-bt" indicates threads that are waiting for the GILaN
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)

zthread apply all py-btrzWaiting for the GILzthread apply all py-bt-fullNrnassertInrdrrts   r!test_threadszPyBtTests.test_threadsIsg
*))#AY@Z*\


+Z8))#A^@_*a


+Z8r9cd}|j|gd}|jd||j|gd}|jd|y)z?Verify that "py-bt" indicates if a thread is garbage-collectingzRfrom gc import collect
id(42)
def foo():
    collect()
def bar():
    foo()
bar()
)break update_refscontinuer'rzGarbage-collecting)r3r4r+Nr.r0s   r!test_gczPyBtTests.test_gclsc))#@j*,
	


*J7))#@o*,
	


*J7r9cd}dD]\}}dD]}|j|d|5tjd|d|d|d}|j||dd	gd
}|j	d|||j||d
gd
}|}|tjd|z
}|j||dddy#1swYxYw)zAVerify that "py-bt" displays invocations of PyCFunction instancesz#(1|2)))meth_varargsr()meth_varargs_keywordsr()meth_oz[])meth_noargsr()
meth_fastcallr()meth_fastcall_keywordsr()	_testcapiz_testcapi.MethClassz_testcapi.MethClass()z_testcapi.MethStatic()r$zi
                        import _testcapi
                        def foo():
                            (zy)
                        def bar():
                            foo()
                        bar()
                    r
r'T)rgrhrjz<built-in method r+z <built-in method N)subTesttextwrapdedentrnr/rescapeassertRegex)rdexpected_frame	func_namerHobjrrtregexs        r!test_pycfunctionzPyBtTests.test_pycfunctions,"# 
0	8OIt(
8\\SE9+"678"///!E9+Qtf5+C"&!5!5#,/3Wo'+
"6"JMM$5i["A:N"&!5!5#,/;n'+
"6"J+ERYY);I;'GHHE$$Z7?88(
80	8"88sBCC
ctjd}ddg}tr|jd|jd|j	||}|j|dy)Nz
            class MyList(list):
                def __init__(self):
                    super(*[]).__init__()   # wrapper_call()

            id("first break point")
            l = MyList()
        zbreak wrapper_callr4rYr'rz1<method-wrapper u?'__init__' of MyList object at )r@rAr]appendrnrC)rdrrhrts    r!test_wrapper_callzPyBtTests.test_wrapper_callsvoo
"6z B
"((0$$W-))#@U*W
M	Or9N)rrrrr#rr)r,rrr1r5rHrKrr9r!r%r%$sX__(*=??$X__(*=??X__(*=?Wu%9&?9@X__(*=?
8?
8,X__(*=?Wu%88&?88tX__(*=?O?Or9r%c(eZdZejeddZejedejeddZ	ejeddZ
ejeddZy)PyPrintTestsrcZ|jtddg}|j|dy)z(Verify that the "py-print" command worksrz
py-print argsrz".*\nlocal 'args' = \(1, 2, 3\)\n.*Nrr	s  r!rzPyPrintTests.test_basic_commands9
!
!);9@/8R"T##B$I	Kr9rcZ|jtgd}|j|dy)N)rrz
py-print cz
py-print bz
py-print arz3.*\nlocal 'c' = 3\nlocal 'b' = 2\nlocal 'a' = 1\n.*rr	s  r!test_print_after_upz PyPrintTests.test_print_after_ups4
!
!);8t"v##B$Z	\r9cn|j|jddg}|j|dy)Nrzpy-print __name__rz&.*\nglobal '__name__' = '__main__'\n.*r(r	s  r!test_printing_globalz!PyPrintTests.test_printing_globalsB
!
!)?)?)A9@BU8V"X##B$M	Or9cn|j|jddg}|j|dy)Nrzpy-print lenrzV.*\nbuiltin 'len' = <built-in method len of module object at remote 0x-?[0-9a-f]+>\n.*r(r	s  r!test_printing_builtinz"PyPrintTests.test_printing_builtinsA
!
!)?)?)A9@.8Q"S##B$}	r9N)rrrrr#rrr!r"rPrRrTrr9r!rMrMsX__(*=?K?KX__(*=?X*PQ\R?\X__(*=?O?OX__(*=??r9rMceZdZejeddZejedejeddZ	y)
PyLocalsTestsrcn|j|jddg}|j|dy)Nr	py-localsrz.*\nargs = \(1, 2, 3\)\n.*r(r	s  r!rz PyLocalsTests.test_basic_command
sA
!
!)?)?)A9@+8N"P##B$A	Cr9rcn|j|jgd}|j|dy)N)rrrXrz<^.*
Locals for foo
a = 1
b = 2
c = 3
Locals for <module>
.*$r(r	s  r!test_locals_after_upz"PyLocalsTests.test_locals_after_ups=
!
!)?)?)A8W"Y##B%	r9N)
rrrrr#rrr!r"rZrr9r!rVrV	skX__(*=?C?CX*PQX__(*=?
?R
r9rVctjrBtdtdtdt
j
D]}td|zyy)NzGDB version r$:z    )rverbosercrDrEgdb_versionrb)rls r!setUpModuler_"sA
&79JKL**,	"D'D.!	"r9__main__)3r@platformrrr^r2r@rtestrtest.supportrrr"r^rDrEris_python_buildr3pathrdirnamer_rFr[r8r]rM
gdbpy_versionrPgdbpy_errorsrxrrSr"rqr#PGOTestCaserVrrrrr%rMrVr_rmainrr9r!<module>rls
	
6?<5D4E1
 1q
(

02C*,--
!y  "
(

Q
RRY12;eY./527
(

D
EEWW\\"''//#.."A"13
( !J6VW
q
(

H
II

(

5
66(CNN3<#|3
?C
(

C,"5"5"77
88''(
23j)H%%j)4j)XB\}B\H$&9;&-&;&P$*=*X@O
@OD!=!FM2"zHMMOr9