403Webshell
Server IP : 118.27.122.248  /  Your IP : 216.73.216.15
Web Server : Apache
System : Linux web0264.sh.tyo1 4.18.0-553.79.1.lve.el7h.x86_64 #1 SMP Wed Oct 15 16:34:46 UTC 2025 x86_64
User : c9415830 ( 11735)
PHP Version : 8.4.17
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /opt/alt/python36/lib64/python3.6/test/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /opt/alt/python36/lib64/python3.6/test/__pycache__/test_gdb.cpython-36.pyc
3

�w2_X��
@s*ddlZddlZddlZddlZddlZddlZddlZddlZddlZyddl	Z	Wne
k
rldZ	YnXddlmZddl
mZmZmZdd�Ze�\ZZZedkr�ejdeeef��ej�s�ejd��d	ej�kr�ejd
kr�ejd��ejjejjej�d�Zd
Zdd�Ze�Zdd�Z e d�\Z!Z"e!�s>ejd��e dej�\Z"Z#de#k�rndZ$eje$e#j%���dd�Z&e&�Z'dZ(ej)ej*d�Gdd�dej+��Z,Gdd�de,�Z-ej)e�d�Gd d!�d!e,��Z.Gd"d#�d#e,�Z/Gd$d%�d%e,�Z0Gd&d'�d'e,�Z1Gd(d)�d)e,�Z2d*d+�Z3e4d,k�r&e3�dS)-�N)�support)�run_unittest�findfile�python_is_optimizedcCs�y<tjdddgtjtjdd�}|�|j�d}WdQRXWntk
rZtjd��YnXtjd|�}|dkr|t	d	|��|t
|jd
��t
|jd��fS)N�gdbz-nxz	--versionT)�stdout�stderrZuniversal_newlinesrzCouldn't find gdb on the pathz^GNU gdb.*?\b(\d+)\.(\d+)zunable to parse GDB version: %r��)�
subprocess�Popen�PIPE�communicate�OSError�unittest�SkipTest�re�search�	Exception�int�group)�proc�version�match�r�2/opt/alt/python36/lib64/python3.6/test/test_gdb.py�get_gdb_versionsr�zFgdb versions before 7.0 didn't support python embedding. Saw %s.%s:
%sz3test_gdb only works on source builds at the moment.ZClang�darwinzDtest_gdb doesn't work correctly when python is built with LLVM clangz
python-gdb.pyZ123cCs4tjd�}|sdS|j�}d|ko2tdd�|D��S)N�CFLAGSFz-mcetcss$|]}|jd�o|jd�VqdS)z-fcf-protection�=none�=returnN)r r!)�
startswith�endswith)�.0�flagrrr�	<genexpr>Msz!cet_protection.<locals>.<genexpr>)�	sysconfig�get_config_var�split�any)Zcflags�flagsrrr�cet_protectionEs
r,cOs�|rtjj�}|j|�nd}d}ttfd
kr>|ddtf7}tj||tj	tj	tj	|d	�}|�|j
�\}}WdQRX|jd
d�|jd
d�fS)z�Runs gdb in --batch mode with the additional arguments given by *args.

    Returns its (stdout, stderr) decoded from utf-8 using the replace handler.
    Nr�--batch�-nxr�z-iexzadd-auto-load-safe-path )�stdinrr�envzutf-8�replace)rr-r.)rr/)�os�environ�copy�update�gdb_major_version�gdb_minor_version�checkout_hook_pathrrr
r�decode)�argsZenv_varsr1Zbase_cmdr�out�errrrr�run_gdbUs

r>z9--eval-command=python import sys; print(sys.version_info)z*gdb not built with embedded python supportz--argszauto-loading has been declinedz3gdb security settings prevent use of custom hooks: cCs>td�\}}tjd|�}|s&tjd��|jd�jd�}d|kS)Nz+--eval-command=python print(dir(gdb.Frame))z.*\[(.*)\].*z1Unable to parse output from gdb.Frame.select testr	z, z'select')r>rrrrrr))r�_�mZ
gdb_frame_dirrrr�gdb_has_frame_select{s
rA�
builtin_idznot useful for PGOc@sFeZdZdZddeddfdd�Zddd�Zdd	�Zd
d�Zdd
�Z	dS)�
DebuggerTestsz(Test that the debugger can debug Python.NFcCsdd|ddg}ttfdkr&|dg7}|rBtr8|dg7}||7}n
|d	g7}d
d�|D�}|dtjg7}|jtj��|s�|d
g7}|r�|d|g7}n|r�||g7}t|dt	i�\}}	|	j
�}
g}d|dddf}x8|
D]0}
|
s�q�d|
kr�tjd��|
j
|�s�|j|
�q�W|j|g�|S)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 offZrunrr/zset print entry-values no�next�	backtracecSsg|]}d|�qS)z--eval-command=%sr)r$�cmdrrr�
<listcomp>�sz1DebuggerTests.get_stack_trace.<locals>.<listcomp>z--argsz-Sz-c�PYTHONHASHSEEDzFunction "%s" not defined.z5Do you need "set solib-search-path" or "set sysroot"?zBFD: z	warning: zPC not savedzKgdb cannot walk the frame object because the Program Counter is not present)rr/)r7r8�CET_PROTECTION�sys�
executable�extendrZ_args_from_interpreter_flagsr>rH�
splitlinesrrr"�append�assertEqual)�self�source�script�
breakpoint�cmds_after_breakpoint�import_siteZcommandsr;r<r=ZerrlinesZunexpected_errlinesZignore_patterns�linerrr�get_stack_trace�sJ










zDebuggerTests.get_stack_tracecCsP|pdg}|j|t||d�}tjd|tj�}|sB|jd||f�|jd�|fS)Nzbacktrace 1)rSrTrUzO.*#0\s+builtin_id\s+\(self\=.*,\s+v=\s*(.*?)\)\s+at\s+\S*Python/bltinmodule.c.*zUnexpected gdb output: %r
%sr	)rW�
BREAKPOINT_FNrr�DOTALL�failr)rPrQrTrU�
gdb_outputr@rrr�get_gdb_reprs

zDebuggerTests.get_gdb_reprcCs |j|j|�d||fd�dS)z9Ensure that the given "actual" string ends with "exp_end"z%r did not end with %r)�msgN)�
assertTruer#)rP�actualZexp_endrrr�assertEndsWith szDebuggerTests.assertEndsWithcCs,tj||tj�}|s(|jd||fd�dS)Nz%r did not match %r)r])rrrYrZ)rPr_�patternr@rrr�assertMultilineMatches%sz$DebuggerTests.assertMultilineMatchescCstd�S)Nz
gdb_sample.py)r)rPrrr�get_sample_script*szDebuggerTests.get_sample_script)NF)
�__name__�
__module__�__qualname__�__doc__rXrWr\r`rbrcrrrrrC�st
rCc@s�eZdZdd�Zd<dd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zd=d d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Zd2d3�Zd4d5�Zd6d7�Zd8d9�Zd:d;�ZdS)>�PrettyPrintTestscCs|jd�}|jt|k�dS)Nzid(42))rWr^rX)rPr[rrr�test_getting_backtrace.s
z'PrettyPrintTests.test_getting_backtraceNcCsB|jdt|�d�\}}|s&t|�}|j||d|||f�dS)Nzid(�)z1%r did not equal expected %r; full output was:
%s)r\�ascii�reprrO)rP�valZexp_repr�gdb_reprr[rrr�
assertGdbRepr2szPrettyPrintTests.assertGdbReprcCs6|jd�|jd�|jd�|jd�|jd�dS)	z0Verify the pretty-printing of various int values�*rrlJ)�l�I�5Ni����l�����I�5)ro)rPrrr�test_int<s




zPrettyPrintTests.test_intcCs"|jd�|jd�|jd�dS)z2Verify the pretty-printing of True, False and NoneTFN)ro)rPrrr�test_singletonsDs

z PrettyPrintTests.test_singletonscCs0|ji�|jddid�|jddd�d�dS)z*Verify the pretty-printing of dictionaries�foo�barz{'foo': 'bar'}rp)rsZdouglasz{'foo': 'bar', 'douglas': 42}N)ro)rPrrr�
test_dictsJs
zPrettyPrintTests.test_dictscCs |jg�|jttd���dS)z#Verify the pretty-printing of lists�N)ro�list�range)rPrrr�
test_listsQs
zPrettyPrintTests.test_listscCsR|jd�|jd�|jd�|jd�|jd�|jtdd�td�D���d	S)
z#Verify the pretty-printing of bytes�s(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:�cSsg|]}|�qSrr)r$�brrrrGbsz/PrettyPrintTests.test_bytes.<locals>.<listcomp>�N)ro�bytesrx)rPrrr�
test_bytesVs




zPrettyPrintTests.test_bytescsTtj����fdd�}�jd��jd��jd�|d�|d�|td��d	S)
z-Verify the pretty-printing of unicode stringscsFy|j��d}Wn$tk
r6�j|t|��YnX�j|�dS)NT)�encode�UnicodeEncodeErrorrork)�textZ	printable)�encodingrPrr�
check_reprgs
z1PrettyPrintTests.test_strings.<locals>.check_repr�z(And now for something hopefully the samez7string with embedded NUL here  and then some more textu☠u文字化けi!�N)�locale�getpreferredencodingro�chr)rPr�r)r�rPr�test_stringsds	


zPrettyPrintTests.test_stringscCs(|jt�d�|jdd�|jd	�dS)
z$Verify the pretty-printing of tuplesz()r	z(1,)rsrt�bazN)r	)rsrtr�)ro�tuple)rPrrr�test_tuples�szPrettyPrintTests.test_tuplescCs�ttfdkr|jd�|jt�d�|jtdg�d�tjjsh|jtddg�d�|jtd	d
dg�d�|jd
�\}}|j	|d�dS)z"Verify the pretty-printing of setsr�z.pretty-printing of sets needs gdb 7.3 or laterzset()�az{'a'}r{z
{'a', 'b'}r/rv�z	{4, 5, 6}z&s = set(['a','b'])
s.remove('a')
id(s)z{'b'}N)rr�)
r7r8�skipTestro�setrJr+�ignore_environmentr\rO)rPrnr[rrr�	test_sets�s

zPrettyPrintTests.test_setscCslttfdkr|jd�|jt�d�|jtdg�d�tjjsh|jtddg�d�|jtd	d
dg�d�d
S)z(Verify the pretty-printing of frozensetsrr�z4pretty-printing of frozensets needs gdb 7.3 or laterzfrozenset()r�zfrozenset({'a'})r{zfrozenset({'a', 'b'})r/rvr�zfrozenset({4, 5, 6})N)rr�)r7r8r�ro�	frozensetrJr+r�)rPrrr�test_frozensets�s
z PrettyPrintTests.test_frozensetscCs8|jd�\}}|j|d�|jd�\}}|j|d�dS)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',))r\rO)rPrnr[rrr�test_exceptions�s

z PrettyPrintTests.test_exceptionscCs0|jd�\}}tjd|�}|j|d|d�dS)z7Verify the pretty-printing of new-style class instancesz8
class Foo:
    pass
foo = Foo()
foo.an_int = 42
id(foo)z*<Foo\(an_int=42\) at remote 0x-?[0-9a-f]+>z'Unexpected new-style class rendering %r)r]N)r\rrr^)rPrnr[r@rrr�test_modern_class�s

z"PrettyPrintTests.test_modern_classcCs0|jd�\}}tjd|�}|j|d|d�dS)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)z*<Foo\(an_int=42\) at remote 0x-?[0-9a-f]+>z'Unexpected new-style class rendering %r)r]N)r\rrr^)rPrnr[r@rrr�test_subclassing_list�s

z&PrettyPrintTests.test_subclassing_listcCs0|jd�\}}tjd|�}|j|d|d�dS)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)z*<Foo\(an_int=42\) at remote 0x-?[0-9a-f]+>z'Unexpected new-style class rendering %r)r]N)r\rrr^)rPrnr[r@rrr�test_subclassing_tuple�s

z'PrettyPrintTests.test_subclassing_tuplec	Cs`|r|dg}ndg}|j||d�\}}|r6||kr6dSd}tj||�}|s\|jd||f�dS)z�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
        representationrE)rTNz<.* at remote 0x-?[0-9a-f]+>z$Unexpected gdb representation: %r
%s)r\rrrZ)	rPrQZ
corruption�expreprrTrnr[rar@rrr�
assertSane�s
zPrettyPrintTests.assertSanecCs&|jdddgd�\}}|j|d�dS)z2Ensure that a NULL PyObject* is handled gracefullyzid(42)zset variable v=0rE)rTZ0x0N)r\rO)rPrnr[rrr�
test_NULL_ptrszPrettyPrintTests.test_NULL_ptrcCs|jdd�dS)z?Ensure that a PyObject* with NULL ob_type is handled gracefullyzid(42)zset v->ob_type=0N)r�)rPrrr�test_NULL_ob_type
sz"PrettyPrintTests.test_NULL_ob_typecCs|jdddd�dS)zDEnsure that a PyObject* with a corrupt ob_type is handled gracefullyzid(42)zset v->ob_type=0xDEADBEEF�42)r�N)r�)rPrrr�test_corrupt_ob_typesz%PrettyPrintTests.test_corrupt_ob_typecCs|jdddd�dS)zDEnsure that a PyObject* with a type with corrupt tp_flags is handledzid(42)zset v->ob_type->tp_flags=0x0r�)r�N)r�)rPrrr�test_corrupt_tp_flagssz&PrettyPrintTests.test_corrupt_tp_flagscCs|jdddd�dS)zCEnsure that a PyObject* with a type with corrupt tp_name is handledzid(42)z"set v->ob_type->tp_name=0xDEADBEEFr�)r�N)r�)rPrrr�test_corrupt_tp_namesz%PrettyPrintTests.test_corrupt_tp_namecCsFtjjr|jd�|jddd�\}}tjd|�}|j|d|d�dS)	zAEnsure that the new-style class _Helper in site.py can be handledz(need site module, but -S option was usedzid(__builtins__.help)T)rUz!<_Helper at remote 0x-?[0-9a-f]+>zUnexpected rendering %r)r]N)rJr+�no_siter�r\rrr^)rPrnr[r@rrr�test_builtins_help$s
z#PrettyPrintTests.test_builtins_helpcCs8|jd�\}}|j|d�|jd�\}}|j|d�dS)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, [[...]]]N)r\rO)rPrnr[rrr�test_selfreferential_list2sz*PrettyPrintTests.test_selfreferential_listcCs|jd�\}}|j|d�dS)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': {...}}}N)r\rO)rPrnr[rrr�test_selfreferential_dict=sz*PrettyPrintTests.test_selfreferential_dictcCs.|jd�\}}|jtjd|�d||f�dS)Nz:
class Foo:
    pass
foo = Foo()
foo.an_attr = foo
id(foo)z1<Foo\(an_attr=<\.\.\.>\) at remote 0x-?[0-9a-f]+>z$Unexpected gdb representation: %r
%s)r\r^rr)rPrnr[rrr�'test_selfreferential_old_style_instanceEs

z8PrettyPrintTests.test_selfreferential_old_style_instancecCsX|jd�\}}|jtjd|�d||f�|jd�\}}|jtjd|�d||f�dS)NzB
class Foo(object):
    pass
foo = Foo()
foo.an_attr = foo
id(foo)z1<Foo\(an_attr=<\.\.\.>\) at remote 0x-?[0-9a-f]+>z$Unexpected gdb representation: %r
%szR
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^rr)rPrnr[rrr�'test_selfreferential_new_style_instanceRs



z8PrettyPrintTests.test_selfreferential_new_style_instancecCs6|jd�\}}|j|d�|jt|�dtd��dS)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)r\rO�len)rPrnr[rrr�test_truncationms

z PrettyPrintTests.test_truncationcCs.|jd�\}}|jtjd|�d||f�dS)Nz$import sys; id(sys.stdout.readlines)zO<built-in method readlines of _io.TextIOWrapper object at remote 0x-?[0-9a-f]+>z$Unexpected gdb representation: %r
%s)r\r^rr)rPrnr[rrr�test_builtin_method�s

z$PrettyPrintTests.test_builtin_methodcCs6|jdddgd�}|jtjd|tj�d||f�dS)Nz:
def foo(a, b, c):
    pass

foo(3, 4, 5)
id(foo.__code__)rBz:print (PyFrameObject*)(((PyCodeObject*)v)->co_zombieframe))rSrTzM.*\s+\$1 =\s+Frame 0x-?[0-9a-f]+, for file <string>, line 3, in foo \(\)\s+.*z$Unexpected gdb representation: %r
%s)rWr^rrrY)rPr[rrr�test_frames�s

zPrettyPrintTests.test_frames)N)N) rdrerfrirorqrrruryr~r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrrh-s:

 


rhz&Python was compiled with optimizationsc@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�PyListTestscCs|j||�dS)N)r`)rPZexpectedr_rrr�
assertListing�szPyListTests.assertListingcCs$|j|j�dgd�}|jd|�dS)z'Verify that the "py-list" command workszpy-list)rRrTz�   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)
N)rWrcr�)rP�btrrr�test_basic_command�s

zPyListTests.test_basic_commandcCs$|j|j�dgd�}|jd|�dS)z7Verify the "py-list" command with one absolute argumentz	py-list 9)rRrTzI   9    def baz(*args):
 >10        id(42)
  11    
  12    foo(1, 2, 3)
N)rWrcr�)rPr�rrr�test_one_abs_arg�s

zPyListTests.test_one_abs_argcCs$|j|j�dgd�}|jd|�dS)z8Verify the "py-list" command with two absolute argumentszpy-list 1,3)rRrTzR   1    # Sample script for use by test_gdb.py
   2    
   3    def foo(a, b, c):
N)rWrcr�)rPr�rrr�test_two_abs_args�s

zPyListTests.test_two_abs_argsN)rdrerfr�r�r�r�rrrrr��sr�c@sxeZdZejed�eje�d�dd���Zejed�dd��Z	ejed�dd��Z
ejed�eje�d�d	d
���ZdS)�StackNavigationTestsz$test requires py-up/py-down commandsz&Python was compiled with optimizationscCs&|j|j�ddgd�}|j|d�dS)z%Verify that the "py-up" command workszpy-up)rRrTzp^.*
#[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)rWrcrb)rPr�rrr�test_pyup_command�s
z&StackNavigationTests.test_pyup_commandcCs$|j|j�dgd�}|j|d�dS)z7Verify handling of "py-down" at the bottom of the stackzpy-down)rRrTz$Unable to find a newer python frame
N)rWrcr`)rPr�rrr�test_down_at_bottom�s

z(StackNavigationTests.test_down_at_bottomcCs(|j|j�dgdd�}|j|d�dS)z2Verify handling of "py-up" at the top of the stackzpy-uprv)rRrTz%Unable to find an older python frame
N)rWrcr`)rPr�rrr�test_up_at_top�s
z#StackNavigationTests.test_up_at_topcCs(|j|j�dddgd�}|j|d�dS)z$Verify "py-up" followed by "py-down"zpy-upzpy-down)rRrTz�^.*
#[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\)
$N)rWrcrb)rPr�rrr�test_up_then_down�s
z&StackNavigationTests.test_up_then_downN)rdrerfr�
skipUnless�HAS_PYUP_PYDOWN�skipIfrr�r�r�r�rrrrr��s

r�c@s�eZdZeje�d�dd��Zeje�d�dd��Zeje	d�dd��Z
eje�d�eje	d�d	d
���Zeje�d�eje	d�dd���Zeje�d�d
d��Z
dS)�	PyBtTestsz&Python was compiled with optimizationscCs$|j|j�dgd�}|j|d�dS)z%Verify that the "py-bt" command workszpy-bt)rRrTaF^.*
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\)
N)rWrcrb)rPr�rrr�test_bt�s

zPyBtTests.test_btcCs$|j|j�dgd�}|j|d�dS)z*Verify that the "py-bt-full" command worksz
py-bt-full)rRrTa>^.*
#[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)rWrcrb)rPr�rrr�test_bt_fulls

zPyBtTests.test_bt_fullz*Python was compiled without thread supportcCs@d}|j|dgd�}|jd|�|j|dgd�}|jd|�dS)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-bt)rTzWaiting for the GILzthread apply all py-bt-fullN)rW�assertIn)rPrFr[rrr�test_threadss

zPyBtTests.test_threadscCsHd}|j|dddgd�}|jd|�|j|dddgd�}|jd|�dS)	z?Verify that "py-bt" indicates if a thread is garbage-collectingzRfrom gc import collect
id(42)
def foo():
    collect()
def bar():
    foo()
bar()
zbreak update_refs�continuezpy-bt)rTzGarbage-collectingz
py-bt-fullN)rWr�)rPrFr[rrr�test_gc=s	zPyBtTests.test_gccCsFd}|j|dddgd�}|jd|�|j|ddgd�}|jd|�d	S)
zAVerify that "py-bt" displays invocations of PyCFunction instanceszLfrom time import gmtime
def foo():
    gmtime(1)
def bar():
    foo()
bar()
Ztime_gmtimer�zpy-bt)rSrTz<built-in method gmtimez
py-bt-fullz#1 <built-in method gmtimeN)rWr�)rPrFr[rrr�test_pycfunctionYs
zPyBtTests.test_pycfunctioncCsHtjd�}ddg}tr |jd�|jd�|j||d�}|j|d�dS)Nz�
            class MyList(list):
                def __init__(self):
                    super().__init__()   # wrapper_call()

            id("first break point")
            l = MyList()
        zbreak wrapper_callr�rDzpy-bt)rTz1<method-wrapper u?'__init__' of MyList object at )�textwrap�dedentrIrNrWZassertRegex)rPrFrTr[rrr�test_wrapper_callxs

zPyBtTests.test_wrapper_callN)rdrerfrr�rr�r�r��_threadr�r�r�r�rrrrr��s !r�c@speZdZeje�d�dd��Zeje�d�ejed�dd���Z	eje�d�dd��Z
eje�d�d	d
��ZdS)�PyPrintTestsz&Python was compiled with optimizationscCs&|j|j�ddgd�}|j|d�dS)z(Verify that the "py-print" command workszpy-upz
py-print args)rRrTz".*\nlocal 'args' = \(1, 2, 3\)\n.*N)rWrcrb)rPr�rrrr��s
zPyPrintTests.test_basic_commandz$test requires py-up/py-down commandscCs,|j|j�dddddgd�}|j|d�dS)Nzpy-upz
py-print cz
py-print bz
py-print a)rRrTz3.*\nlocal 'c' = 3\nlocal 'b' = 2\nlocal 'a' = 1\n.*)rWrcrb)rPr�rrr�test_print_after_up�s
z PyPrintTests.test_print_after_upcCs&|j|j�ddgd�}|j|d�dS)Nzpy-upzpy-print __name__)rRrTz&.*\nglobal '__name__' = '__main__'\n.*)rWrcrb)rPr�rrr�test_printing_global�s
z!PyPrintTests.test_printing_globalcCs&|j|j�ddgd�}|j|d�dS)Nzpy-upzpy-print len)rRrTzV.*\nbuiltin 'len' = <built-in method len of module object at remote 0x-?[0-9a-f]+>\n.*)rWrcrb)rPr�rrr�test_printing_builtin�s
z"PyPrintTests.test_printing_builtinN)rdrerfrr�rr�r�r�r�r�r�rrrrr��sr�c@sDeZdZeje�d�dd��Zejed�eje�d�dd���Z	dS)�
PyLocalsTestsz&Python was compiled with optimizationscCs&|j|j�ddgd�}|j|d�dS)Nzpy-upz	py-locals)rRrTz.*\nargs = \(1, 2, 3\)\n.*)rWrcrb)rPr�rrrr��s
z PyLocalsTests.test_basic_commandz$test requires py-up/py-down commandscCs(|j|j�dddgd�}|j|d�dS)Nzpy-upz	py-locals)rRrTz.*\na = 1\nb = 2\nc = 3\n.*)rWrcrb)rPr�rrr�test_locals_after_up�s
z"PyLocalsTests.test_locals_after_upN)
rdrerfrr�rr�r�r�r�rrrrr��s

r�cCsJtjr4tdttf�xtj�D]}td|�q Wttt	t
ttt
�dS)NzGDB version %s.%s:� r/z    )r�verbose�printr7r8�gdb_versionrMrrhr�r�r�r�r�)rVrrr�	test_main�sr��__main__)5r�r3�platformrrrJr'r�rr��ImportErrorZtestrZtest.supportrrrrr�r7r8r�is_python_buildZpython_compiler�path�join�dirnamerKr9rHr,rIr>Z
gdbpy_versionr?Zgdbpy_errorsr]�rstriprAr�rXr�ZPGOZTestCaserCrhr�r�r�r�r�r�rdrrrr�<module>sr






	
%t(-#


Youez - 2016 - github.com/yon3zu
LinuXploit