
    3hhX                         S SK r S SKrS SKJr  SSKJrJrJrJr  S r	S r
\
" 5       r\R                  " \" 5       S5       " S S	\5      5       rS
r " S S\5      r " S S\5      r " S S\5      rg)    N)python_is_optimized   )run_gdbsetup_moduleDebuggerTestsSAMPLE_SCRIPTc                      [        5         g N)r        @/opt/python-3.13.8/usr/lib/python3.13/test/test_gdb/test_misc.pysetUpModuler      s    Nr   c                      [        S5      u  p[        R                  " SU 5      nU(       d  [        R                  " SU < SU< S35      eUR                  S5      R                  S5      nSU;   $ )	Nz+--eval-command=python print(dir(gdb.Frame))z.*\[(.*)\].*z9Unable to parse output from gdb.Frame.select test
stdout=z
stderr=
r   z, z'select')r   rematchunittestSkipTestgroupsplit)stdoutstderrmgdb_frame_dirs       r   gdb_has_frame_selectr      su    JKNF
&)AZ  Zr#$ 	$ GGAJ$$T*M&&r   &Python was compiled with optimizationsc                   ,    \ rS rSrS rS rS rS rSrg)PyListTests   c                 &    U R                  X!5        g r
   )assertEndsWith)selfexpectedactuals      r   assertListingPyListTests.assertListing   s    F-r   c                 R    U R                  [        S/S9nU R                  SU5        g )Nzpy-listscriptcmds_after_breakpointz   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)
get_stack_tracer   r%   r"   bts     r   test_basic_commandPyListTests.test_basic_command!   s9    !!9B " E 	 4 	r   c                 R    U R                  [        S/S9nU R                  SU5        g )Nz	py-list 9r(   zI   9    def baz(*args):
 >10        id(42)
  11    
  12    foo(1, 2, 3)
r+   r-   s     r   test_one_abs_argPyListTests.test_one_abs_arg0   s9    !!9D " G 	 4 		r   c                 R    U R                  [        S/S9nU R                  SU5        g )Nzpy-list 1,3r(   zO   1    # Sample script for use by test_gdb
   2    
   3    def foo(a, b, c):
r+   r-   s     r   test_two_abs_argsPyListTests.test_two_abs_args;   s9    !!9F " I 	 9 	r   r   N)	__name__
__module____qualname____firstlineno__r%   r/   r2   r5   __static_attributes__r   r   r   r   r      s    .	r   r   z

from _testcapi import pyobject_vectorcall

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

def bar(a, b, c):
    pyobject_vectorcall(baz, (a, b, c), None)

def baz(*args):
    id(42)

foo(1, 2, 3)

c                   H   \ rS rSr\R
                  " \S5      \R                  " \" 5       S5      S 5       5       r	\R
                  " \S5      S 5       r
\R
                  " \S5      S 5       r\R
                  " \S5      \R                  " \" 5       S5      S 5       5       rSrg	)
StackNavigationTestsW   $test requires py-up/py-down commandsr   c                 T    U R                  [        SS/S9nU R                  US5        g )Npy-upsourcer*   z^.*
#[0-9]+ Frame 0x-?[0-9a-f]+, for file <string>, line 12, in baz \(args=\(1, 2, 3\)\)
#[0-9]+ <built-in method pyobject_vectorcall of module object at remote 0x[0-9a-f]+>
$r,   SAMPLE_WITH_C_CALLassertMultilineMatchesr-   s     r   test_pyup_command&StackNavigationTests.test_pyup_commandX   s:    
 !!);9@'8J " L##B%	r   c                 R    U R                  [        S/S9nU R                  US5        g )Npy-downr(   z$Unable to find a newer python frame
r,   r   r!   r-   s     r   test_down_at_bottom(StackNavigationTests.test_down_at_bottome   s5     !!9B " EBC	Er   c                 X    U R                  [        S/S-  S9nU R                  US5        g )NrA      r(   z%Unable to find an older python frame
rK   r-   s     r   test_up_at_top#StackNavigationTests.test_up_at_topm   s9     !!9@	A " GBD	Fr   c                 T    U R                  [        / SQS9nU R                  US5        g )N)rA   rA   rJ   rB   a  ^.*
#[0-9]+ Frame 0x-?[0-9a-f]+, for file <string>, line 12, in baz \(args=\(1, 2, 3\)\)
#[0-9]+ <built-in method pyobject_vectorcall 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\)\)
$rD   r-   s     r   test_up_then_down&StackNavigationTests.test_up_then_downu   s5    
 !!);8U " W##B%	r   r   N)r7   r8   r9   r:   r   
skipUnlessHAS_PYUP_PYDOWNskipIfr   rG   rL   rP   rS   r;   r   r   r   r=   r=   W   s    *PQ__(*=?? R *PQE RE *PQF RF *PQ__(*=?	? R	r   r=   c                   0   \ rS rSr\R
                  " \" 5       S5      S 5       r\R
                  " \" 5       S5      \R                  " \	S5      S 5       5       r
\R
                  " \" 5       S5      S 5       r\R
                  " \" 5       S5      S 5       rSrg	)
PyPrintTests   r   c                 T    U R                  [        SS/S9nU R                  US5        g )NrA   zpy-print argsrB   z".*\nlocal 'args' = \(1, 2, 3\)\n.*rD   r-   s     r   r/   PyPrintTests.test_basic_command   s9     !!);9@/8R " T##B$I	Kr   r?   c                 T    U R                  [        / SQS9nU R                  US5        g )N)rA   rA   z
py-print cz
py-print bz
py-print arB   z3.*\nlocal 'c' = 3\nlocal 'b' = 2\nlocal 'a' = 1\n.*rD   r-   s     r   test_print_after_up PyPrintTests.test_print_after_up   s4     !!);8t " v##B$Z	\r   c                 T    U R                  [        SS/S9nU R                  US5        g )NrA   zpy-print __name__r(   z&.*\nglobal '__name__' = '__main__'\n.*r,   r   rF   r-   s     r   test_printing_global!PyPrintTests.test_printing_global   s9     !!9@BU8V " X##B$M	Or   c                 T    U R                  [        SS/S9nU R                  US5        g )NrA   zpy-print lenr(   zV.*\nbuiltin 'len' = <built-in method len of module object at remote 0x-?[0-9a-f]+>\n.*ra   r-   s     r   test_printing_builtin"PyPrintTests.test_printing_builtin   s8     !!9@.8Q " S##B$}	r   r   N)r7   r8   r9   r:   r   rW   r   r/   rU   rV   r^   rb   re   r;   r   r   r   rY   rY      s    __(*=?K?K __(*=?*PQ\ R?\ __(*=?O?O __(*=??r   rY   c                       \ rS rSr\R
                  " \" 5       S5      S 5       r\R                  " \	S5      \R
                  " \" 5       S5      S 5       5       r
Srg)PyLocalsTests   r   c                 T    U R                  [        SS/S9nU R                  US5        g )NrA   	py-localsr(   z.*\nargs = \(1, 2, 3\)\n.*ra   r-   s     r   r/    PyLocalsTests.test_basic_command   s8     !!9@+8N " P##B$A	Cr   r?   c                 T    U R                  [        / SQS9nU R                  US5        g )N)rA   rA   rk   r(   z<^.*
Locals for foo
a = 1
b = 2
c = 3
Locals for <module>
.*$ra   r-   s     r   test_locals_after_up"PyLocalsTests.test_locals_after_up   s4     !!8W " Y##B%	r   r   N)r7   r8   r9   r:   r   rW   r   r/   rU   rV   rn   r;   r   r   r   rh   rh      se    __(*=?C?C *PQ__(*=?
? R
r   rh   )r   r   test.supportr   utilr   r   r   r   r   r   rV   rW   r   rE   r=   rY   rh   r   r   r   <module>rr      s    	  , E E
' '( 
$&9;&- &;&P $*= *X!= !FM r   