+
    öÙ†jÜ  ã                   óR  € ^ RI t ^ RIt^ RIt^ RIt^ RIt^ RIHt ^ RIHt ^ RI	H
t
 ^ RIHt Rt] P                  ! R4      t] P                  ! R4      t] ! R	 R
4      4       t] ! R R4      4       tR tR t]
P*                  ! 4       RR l4       tR tRR lt]R 4       tR t. ROtR# )é    N)Ú	dataclass)Úcache)Úsupport)Úrun_python_until_endz/usr/bin/stracez@(?P<syscall>[^(]*)\((?P<args>[^)]*)\)\s*[=]\s*(?P<returncode>.+)s-   \+\+\+ exited with (?P<returncode>\d+) \+\+\+c                   ó,   a € ] tR t^t o V 3R ltRtV tR# )ÚStraceEventc                óN   <€ V ^8„  d   Qh/ S[ ;R&   S[S[ ,          ;R&   S[ ;R&   # )é   ÚsyscallÚargsÚ
returncode)ÚstrÚlist)ÚformatÚ__classdict__s   "€Ú1/usr/lib/python3.14/test/support/strace_helper.pyÚ__annotate__ÚStraceEvent.__annotate__   s+   ø‡ ‚ á�Lñ ñ ‰s�)�Oñ ñ �Oò	 ó    © N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__annotate_func__Ú__static_attributes__Ú__classdictcell__©r   s   @r   r   r      s   ø‡ ‡ „ r   r   c                   ó:   a € ] tR t^t o  R tR tV 3R ltRtV tR# )ÚStraceResultc                ó�  € V P                   P                  RR4      pVP                  4        Uu. uF  p\        P	                  V4      NK  	  ppV UUu. uFZ  qD'       g   K  \        VR,          VR,          P                  R4       Uu. uF  qUP                  4       NK  	  upVR,          4      NK\  	  upp# u upi u upi u uppi )zµParse event_bytes data into system calls for easier processing.

This assumes the program under inspection doesn't print any non-utf8
strings which would mix into the strace output.úutf-8Úsurrogateescaper   r   Ú,r   )Úevent_bytesÚdecodeÚ
splitlinesÚ_syscall_regexÚmatchr   ÚsplitÚstrip)ÚselfÚdecoded_eventsÚeventÚmatchesr)   Úargs   &     r   ÚeventsÚStraceResult.events$   sÈ   € ð
 ×)Ñ)×0Ñ0°Ð:KÓLˆð (×2Ñ2Ô4ó
á4�ô × Ñ  Ö'Ù4ð 	ð 
ñ ;Bô
ñ ;B°ÃUô-ŒK˜˜iÕ(Ø16°vµ×1DÑ1DÀSÔ1IÓKÑ1I¨Ÿ™žÑ1IÑKØ˜lÕ+ö-á:Aò
ð 	
ùò	
ùò Lùó
s#   ¯B8Á	CÁ"'CÂ	B=Â!CÂ=Cc                ó²  € RpV. /pV P                  4        F¼  pVP                  R8X  d’   \        VP                  4      ^8”  dx   VP                  ^,          P	                  R4      '       dP   VP                  ^,          P                  R^4      ^,          P                  R4      pW9  d   \        4       W!&   K£  K¥  W!,          P                  V4       K¾  	  V# )zåFind all "MARK <X>" writes and use them to make groups of events.

This is useful to avoid variable / overhead events, like those at
interpreter startup or when opening a file so a test can verify just
the small case under study.Ú	__startupÚwritez"MARK Ú z\n")	r1   r   Úlenr   Ú
startswithr*   Úremovesuffixr   Úappend)r,   Úcurrent_sectionÚsectionsr.   s   &   r   r<   ÚStraceResult.sections4   sÁ   € ð &ˆØ# RÐ(ˆØ—[‘[–]ˆEØ�}‰} Ô'¬CØ—J‘Jó- Ø"#ô-$Ø(-¯
©
°1­×(@Ñ(@À×(KÒ(Kð #(§*¡*¨Q¥-×"5Ñ"5Ø˜ó#Øõ#ß+™|¨FÓ3ð  à"Ô2Ü04³�HÓ-ñ 3ð Õ)×0Ñ0°Ö7ñ #ð ˆr   c                óV   <€ V ^8„  d   Qh/ S[ ;R&   S[ ;R&   S[;R&   S[;R&   S[;R&   # )r
   Ústrace_returncodeÚpython_returncoder%   ÚstdoutÚstderr)ÚintÚbytes)r   r   s   "€r   r   ÚStraceResult.__annotate__   sB   ø‡ ‚ áÑñ ñ Ññ ñ Ññ ñ �Mñ ñ �Mò r   r   N)	r   r   r   r   r1   r<   r   r   r   r   s   @r   r    r       s   ø‡ € ð
Fò
ò ÷7 ƒ r   r    c                 ó‚   € V P                   R 8X  d   RV P                  ^,          9   d   R# V P                   R9   d   R# R# )ÚmmapÚMAP_ANONTF)ÚmunmapÚmprotect)r   r   )Úcalls   &r   Ú_filter_memory_callrL   J   s5   € ð ‡|�|�vÔ *°·	±	¸!µÔ"<Ùà‡|�|Ð-Ô-Ùár   c                óV   € V  Uu. uF  p\        V4      '       d   K  VNK  	  up# u upi )zÙFilter out memory allocation calls from File I/O calls.

Some calls (mmap, munmap, etc) can be used on files or to just get a block
of memory. Use this function to filter out the memory related calls from
other calls.)rL   )ÚsyscallsrK   s   & r   Úfilter_memoryrO   V   s&   € ñ &ÓG™X�TÔ-@À×-F�DˆD™XÑGÐGùÒGs   …&�&c                óæ  a
€ Ro
V
3R lp \        R\        P                  ! V 4      \        .V,           R7      w  o
pT'       d$   S
P
                  '       d   S
P                  T4       S
P                  P                  4       pTP                  R^4      p\        T4      ^8w  d   T! RTRR 4      # \        P                  T^,          4      pT'       g   T! RT^,          R	,          4      # \        TR
,          4      p	T'       d   T	'       d   S
P                  T4       \        S
P
                  T	T^ ,          S
P                  S
P                  R7      #   \         d   pT! RT4      u Rp?# Rp?ii ; i)z`Run strace and return the trace.

Sets strace_returncode and python_returncode to `-1` on error.Nc           	      ó¬   <€ \        RRRV  RV: R2P                  R4      S'       d   SP                  MRS'       d   SP                  R7      # RR7      # )é   zerror(z	,details=z) = -1r"   r   ©r?   r@   r%   rA   rB   éÿÿÿÿ)r    ÚencodeÚoutÚerr)ÚreasonÚdetailsÚress   &&€r   Ú_make_errorÚ"strace_python.<locals>._make_errorg   sV   ø€ ÜØ Ø Ø! & ¨°7±+¸VÐD×KÑKÈGÓTß!�3—7’7 sß!�3—7‘7ô,ð 	,ð
 (+ô,ð 	,r   z-c)Ú__run_using_commandzCaught OSErroró   
z)Expected strace events and exit code linez)Expected to find returncode in last line.:Né2   Nr   rS   iÎÿÿÿ)r   ÚtextwrapÚdedentÚ_strace_binaryÚOSErrorÚrcÚfailrW   r+   Úrsplitr7   Ú_returncode_regexr)   rC   r    rV   )ÚcodeÚstrace_flagsÚcheckr[   Úcmd_linerW   ÚstrippedÚoutputÚreturncode_matchr@   rZ   s   &&&       @r   Ústrace_pythonro   `   s@  ø€ ð
 €Cõ,ð2Ü,ØÜ�OŠO˜DÓ!Ü!/Ð 0°<Õ ?ô
‰ˆˆX÷ �——�Ø�‰�Ôð �w‰w�}‰}‹€HØ�_‰_˜U AÓ&€FÜ
ˆ6ƒ{�aÔÙÐFØ# C D˜>ó+ð 	+ô )×.Ñ.¨v°a­yÓ9ÐßÙÐFØ! !�9 S�>ó+ð 	+ô Ð,¨\Õ:Ó;Ðß×"Ø�‰�Ôä¨#¯&©&Ø*;Ø$*¨1¥IØ"Ÿw™wØ"Ÿw™wô	(ð (øô- ô 2ÙÐ+¨SÓ1Õ1ûð2ús   ‹1E ÅE0ÅE+Å%E0Å+E0c                 óæ   € \         P                  ! V4      p\         P                  ! V 4      p \         P                  ! V4      pR V RV  RV R2p\        WA4      pVP                  4       pVR,          # )z#
print("MARK prelude", flush=True)
z 
print("MARK code", flush=True)
z#
print("MARK cleanup", flush=True)
z*
print("MARK __shutdown", flush=True)
    rh   )r`   ra   ro   r<   )rh   ri   ÚpreludeÚcleanupÚto_runÚtraceÚall_sectionss   &&&&   r   Ú
get_eventsrv   “   s{   € ô �oŠo˜gÓ&€GÜ�?Š?˜4Ó €DÜ�oŠo˜gÓ&€Gðà€	ð 
à€ð à€	ð 
ð€Fô ˜&Ó/€EØ—>‘>Ó#€LØ˜ÕÐr   c                ó‚   € \        WW#R7      pV'       d   \        V4      pV Uu. uF  qfP                  NK  	  up# u upi )z=Get the syscalls which a given chunk of python code generates)rq   rr   )rv   rO   r   )rh   ri   rq   rr   Úignore_memoryr1   Úevs   &&&&&  r   Úget_syscallsrz   §   s7   € ô ˜°GÔM€FçÜ˜vÓ&ˆá!'Ó(¡˜2�JŒJ¡Ñ(Ð(ùÒ(s   ¥<c                  ó¦   € \        R R.RR7      p V P                  ^ 8X  d1   V P                  ^ 8X  d    V P                  4       '       g   Q R4       hR# R# )zimport sys; sys.exit(0)z--trace=%processF)rj   z!Should have parsed multiple callsT)ro   r?   r@   r1   )rZ   s    r   Ú_can_stracer|   ³   sQ   € ä
Ð1à+Ð,Ø#ô%€Cð ×Ñ Ô! c×&;Ñ&;¸qÔ&@Ø�z‰z�|Š|Ð@Ð@Ó@ˆ|ÙÙr   c                  óT  € \         P                  R 8w  d   \        P                  ! R4      # R\        P
                  9   d   \        P                  ! R4      # \        P                  ! RRR7      '       d   \        P                  ! R4      # \        P                  ! \        4       R4      # )ÚlinuxzLinux only, requires strace.Ú
LD_PRELOADz;Not supported when LD_PRELOAD is intercepting system calls.T)ÚaddressÚmemoryz;LeakSanitizer does not work under ptrace (strace, gdb, etc)zRequires working strace)
ÚsysÚplatformÚunittestÚskipÚosÚenvironr   Úcheck_sanitizerÚ
skipUnlessr|   r   r   r   Úrequires_stracerŠ   ¿   su   € Ü
‡|�|�wÔÜ�}Š}Ð;Ó<Ð<à”r—z‘zÔ!ô
 �}Š}ÐZÓ[Ð[ä×Ò t°D×9Ó9Ü�}Š}ÐZÓ[Ð[ä×Òœ{›}Ð.GÓHÐHr   )T)Ú r‹   T)rO   rv   rz   rŠ   ro   r   r    )Úrer‚   r`   r†   r„   Údataclassesr   Ú	functoolsr   Útestr   Útest.support.script_helperr   rb   Úcompiler(   rg   r   r    rL   rO   Úrequires_subprocessro   rv   rz   r|   rŠ   Ú__all__r   r   r   Ú<module>r”      sÐ   ðÛ 	Û 
Û Û 	Û Ý !Ý Ý Ý ;à"€Ø—’ØGóI€à—J’JØ5ó7Ð ð ÷ð ó ðð ÷.ð .ó ð.ò`	òHð 	×ÒÓó/(ó ð/(òd ô()ð ñó ðòIò";‚r   