grthtrhthjhtyjytjytkergtrhtrjytjerhrfh4:24 29/09/2026a ,-Þi#$ã@s�ddlmZddlZddlZddlmZmZmZm Z m Z m Z Gdd„de ƒZ Gdd„deƒZGd d „d eƒZGd d „d eƒZGd d„deƒZdS)é)Úprint_functionNé)ÚlibÚ_USDT_CBÚ_USDT_PROBE_CBÚbcc_usdt_locationÚbcc_usdt_argumentÚBCC_USDT_ARGUMENT_FLAGSc@s eZdZdS)Ú USDTExceptionN)Ú__name__Ú __module__Ú __qualname__©rrú,/usr/lib/python3.9/site-packages/bcc/usdt.pyr sr c@s,eZdZdd„Zdd„Zdd„Zdd„Zd S) ÚUSDTProbeArgumentcCs´|jdk|_t|jƒ|_|j|_|jtj@dkr8|j|_|jtj@dkrP|j|_|jtj @dkrh|j |_ |jtj @dkr€|j |_ |jtj @dkr˜|j|_|jtj@dkr°|j|_dS)Nr)ÚsizeÚsignedÚabsÚvalidr ÚCONSTANTÚconstantÚ DEREF_OFFSETÚ deref_offsetÚ DEREF_IDENTÚ deref_identÚBASE_REGISTER_NAMEÚbase_register_nameÚINDEX_REGISTER_NAMEÚindex_register_nameÚSCALEÚscale)ÚselfÚargumentrrrÚ__init__s  zUSDTProbeArgument.__init__cCsd|j|jrdndfS)Nz %d %s byteszsigned Zunsigned)rr©r!rrrÚ _size_prefix+sÿzUSDTProbeArgument._size_prefixcCsB|jtj@dkrd|jS|jtj@dkr8d|j ¡S|jtj@dkrÈ|jtj@dkrÈ|jtj@dkr–d|j  ¡}|jtj @dkrš|d|j 7}nd}|j dkr¨dnd}d |j ¡|t |j ƒ|fS|jtj@dk�r8|jtj@dk�r8|jtj@dk�r8|jd k�r8|j dk�rdnd}d |j ¡|t |j ƒfSd |jS) Nrz%dz%sz + %sz * %dÚú+ú-z *(%s %s %d%s)Úipz *(&%s %s %d)z&unrecognized argument format, flags %d)rr rrrrÚdecoderrrrr rrrr)r!Z index_offsetÚsignrrrÚ_format/s8 ÿ  ÿÿþý  ÿzUSDTProbeArgument._formatcCsd| ¡| ¡fS)Nz%s @ %s)r%r,r$rrrÚ__str__MszUSDTProbeArgument.__str__N)r r r r#r%r,r-rrrrrsrc@s$eZdZdd„Zdd„Zdd„ZdS)ÚUSDTProbeLocationcCs(||_||_|j|_|j|_|j|_dS©N)ÚprobeÚindexÚ num_argumentsÚaddressÚbin_path)r!r0r1Úlocationrrrr#Qs zUSDTProbeLocation.__init__cCsd|j ¡|jfS)Nz%s 0x%x)r4r*r3r$rrrr-XszUSDTProbeLocation.__str__c CsPtƒ}t |jj|jj|jj|j|t  |¡¡}|dkrHt d||jfƒ‚t |ƒS)Nrz.error retrieving probe argument %d location %d) rrZbcc_usdt_get_argumentr0ÚcontextÚproviderÚnamer1ÚctÚbyrefr r)r!r1ÚargÚresrrrÚ get_argument[sþÿÿzUSDTProbeLocation.get_argumentN)r r r r#r-r=rrrrr.Psr.c@s,eZdZdd„Zdd„Zdd„Zdd„Zd S) Ú USDTProbecCs:||_|j|_|j|_|j|_|j|_|j|_|j|_dSr/)r6r7r8r4Ú semaphoreZ num_locationsr2)r!r6r0rrrr#gszUSDTProbe.__init__cCsd|j ¡|j ¡|jfS)Nz%s:%s [sema 0x%x])r7r*r8r?r$rrrr-psÿzUSDTProbe.__str__cCsd|j ¡|j ¡fS)Nz%s:%s)r7r*r8r$rrrÚ short_nametszUSDTProbe.short_namec CsDtƒ}t |j|j|j|t |¡¡}|dkr8td|ƒ‚t |||ƒS)Nrz"error retrieving probe location %d) rrZbcc_usdt_get_locationr6r7r8r9r:r r.)r!r1Úlocr<rrrÚ get_locationws ÿ zUSDTProbe.get_locationN)r r r r#r-r@rBrrrrr>fs r>c@s^eZdZddd„Zdd„Zdd„Zdd „Zd d „Zd d „Zdd„Z dd„Z dd„Z dd„Z dS)ÚUSDTNcCs˜|rX|dkrX||_|r,t || d¡¡|_nt |t d¡¡|_|jdkr”td|ƒ‚n<|rŒ||_t  | d¡¡|_|jdkr”td|ƒ‚ntdƒ‚dS)NéÿÿÿÿÚasciirz USDT failed to instrument PID %dz!USDT failed to instrument path %sz/either a pid or a binary path must be specified) ÚpidrZbcc_usdt_new_frompidÚencoder6r9Zc_char_pr ÚpathZbcc_usdt_new_frompath)r!rFrHrrrr#€s   ÿz USDT.__init__cCst |j¡dSr/)rZbcc_usdt_closer6r$rrrÚ__del__’sz USDT.__del__cCsz| dd¡}t|ƒdkr6t |j| d¡| d¡¡}n,|\}}t |j| d¡| d¡| d¡¡}|dkrvtd|ƒ‚dS)Nú:rrEra.Failed to enable USDT probe '%s': the specified pid might not contain the given language's runtime, or the runtime was not built with the required USDT probes. Look for a configure flag similar to --with-dtrace or --enable-dtrace. To check which probes are present in the process, use the tplist tool. )ÚsplitÚlenrZbcc_usdt_enable_prober6rGZ%bcc_usdt_enable_fully_specified_prober )r!r0Úfn_nameÚ probe_partsÚretÚ provider_nameÚ probe_namerrrÚ enable_probe•s   ÿþûÿzUSDT.enable_probec CsRz| ||¡Wn<tyL}z$t|tjd�t d¡WYd}~n d}~00dS)N)Úfiler)rRr ÚprintÚsysÚstderrÚexit)r!r0rMÚerrrÚenable_probe_or_bail©s zUSDT.enable_probe_or_bailcCs|jSr/)r6r$rrrÚ get_context°szUSDT.get_contextcCs,tjdƒ}t |j¡|d<t |d¡ ¡S)Nrr)r9Zc_void_pr6rZbcc_usdt_genargsr*)r!Z ctx_arrayrrrÚget_text³s z USDT.get_textcCs`| dd¡}t|ƒdkr2t |j| d¡|¡ ¡S|\}}t |j| d¡| d¡|¡ ¡SdS)NrJrrE)rKrLrZbcc_usdt_get_probe_argctyper6rGr*Z+bcc_usdt_get_fully_specified_probe_argctype)r!rQZ arg_indexrNrPr0rrrÚget_probe_arg_ctype¸s  ÿÿzUSDT.get_probe_arg_ctypecs(g‰‡‡fdd„}t ˆjt|ƒ¡ˆS)Ncsˆ tˆj|jƒ¡dSr/)Úappendr>r6Úcontents)r0©Úprobesr!rrÚ _add_probeÄsz)USDT.enumerate_probes.._add_probe)rZbcc_usdt_foreachr6r©r!rarr_rÚenumerate_probesÂszUSDT.enumerate_probescCs8| ¡}|D]&\}}}}|r d}|j||||d�q dS)NrD)r8rMÚaddrrF)Úenumerate_active_probesZ attach_uprobe)r!ZbpfZattach_usdt_ignore_pidr`ÚbinpathrMrdrFrrrÚattach_uprobesÌsÿzUSDT.attach_uprobescs&g‰‡fdd„}t |jt|ƒ¡ˆS)Ncsˆ ||||f¡dSr/)r])rfrMrdrF©r`rrraÖsz0USDT.enumerate_active_probes.._add_probe)rZbcc_usdt_foreach_uprober6rrbrrhrreÔs zUSDT.enumerate_active_probes)NN) r r r r#rIrRrYrZr[r\rcrgrerrrrrCs   rC)Z __future__rZctypesr9rUZlibbccrrrrrr Ú Exceptionr Úobjectrr.r>rCrrrrÚs  7