f#$ddlmZddlZddlZddlmZmZmZm Z m Z m Z Gdde Z GddeZGd d eZGd d eZGd deZy))print_functionN)lib_USDT_CB_USDT_PROBE_CBbcc_usdt_locationbcc_usdt_argumentBCC_USDT_ARGUMENT_FLAGSc eZdZy) USDTExceptionN)__name__ __module__ __qualname__*/usr/lib/python3/dist-packages/bcc/usdt.pyr r srr c$eZdZdZdZdZdZy)USDTProbeArgumentc|jdk|_t|j|_|j|_|jtj zdk7r|j |_|jtjzdk7r|j|_|jtjzdk7r|j|_ |jtjzdk7r|j|_ |jtjzdk7r|j|_|jtjzdk7r|j |_yy)Nr)sizesignedabsvalidr CONSTANTconstant DEREF_OFFSET deref_offset DEREF_IDENT deref_identBASE_REGISTER_NAMEbase_register_nameINDEX_REGISTER_NAMEindex_register_nameSCALEscale)selfarguments r__init__zUSDTProbeArgument.__init__smma'  & ^^ ::/88 8A =$--DM ::/<< < A ( 5 5D  ::/;; ;q @'33D  ::/BB Ba G&.&A&AD # ::/CC Cq H'/'C'CD $ ::/55 5 :!DJ ;rcFd|j|jrdfzSdfzS)Nz %d %s byteszsigned unsigned)rrr&s r _size_prefixzUSDTProbeArgument._size_prefix+s5$++JFG G;EFG GrcT|jtjzdk7rd|jzS|jtjzdk(rd|j j zS|jtjzdk7r|jtjzdk(r|jtjzdk7rPd|jj z}|jtjzdk7r|d|jzz }nd}|jdk\rdnd}d |j j |t|j|fzS|jtjzdk7r|jtjzdk7ru|jtjzdk7rU|j d k(rF|jdk\rdnd}d |jj |t|jfzSd |jzS) Nrz%dz%sz + %sz * %d+-z *(%s %s %d%s)ipz *(&%s %s %d)z&unrecognized argument format, flags %d)rr rrrr!decoderr"r#r$r%rrr r)r& index_offsetsigns r_formatzUSDTProbeArgument._format/s ::/88 8A =$--' ' ::/<< < A$1188:: : ::/<< < A ::/;; ;q @zz3GGG1L&)A)A)H)H)JJ :: 7 = ==B Gdjj$88L! ++q03cD"d&=&=&D&D&F&*C0A0A,BL&RR R ::/<< < A ::/;; ;q @ ::/BB Ba G  " "d *++q03cD!T%5%5%<%<%>%)3t/@/@+A%CC C 8$**DDrcH|jd|jS)Nz @ )r,r5r+s r__str__zUSDTProbeArgument.__str__Ms --/@@rN)r rrr(r,r5r7rrrrrs("GE<ArrceZdZdZdZdZy)USDTProbeLocationc||_||_|j|_|j|_|j|_yN)probeindex num_argumentsaddressbin_path)r&r<r=locations rr(zUSDTProbeLocation.__init__Qs8  "00''  )) rcTd|jj|jfzS)Nz%s 0x%x)r@r2r?r+s rr7zUSDTProbeLocation.__str__Xs#DMM002DLLAAArc Pt}tj|jj|jj |jj |j|tj|}|dk7rtd||jfzt|S)Nrz.error retrieving probe argument %d location %d) r rbcc_usdt_get_argumentr<contextprovidernamer=ctbyrefr r)r&r=argress r get_argumentzUSDTProbeLocation.get_argument[s!'' (:(:DJJ)r&rEr<s rr(zUSDTProbe.__init__gsQ  JJ  "00"00rcd|jj|jj|jfzS)Nz%s:%s [sema 0x%x])rFr2rGrPr+s rr7zUSDTProbe.__str__ps9" $$& (8(8(:DNNKL Lrcp|jjd|jjS)N:)rFr2rGr+s r short_namezUSDTProbe.short_namets'--..0$))2B2B2DEErc t}tj|j|j|j |t j|}|dk7rtd|zt|||S)Nrz"error retrieving probe location %d) rrbcc_usdt_get_locationrErFrGrHrIr r9)r&r=locrKs r get_locationzUSDTProbe.get_locationws`!'' dmmTYY(-rxx}> !8 Du LM M uc22rN)r rrr(r7rUrYrrrrNrNfs1LF3rrNcJeZdZd dZdZdZdZdZdZdZ d Z d Z d Z y) USDTNc|r|dk7r||_|r+tj||jd|_n.tj|t j d|_|jdk(rtd|zy|rN||_tj|jd|_|jdk(rtd|zytd)Nasciirz USDT failed to instrument PID %dz!USDT failed to instrument path %sz/either a pid or a binary path must be specified) pidrbcc_usdt_new_frompidencoderErHc_char_pr pathbcc_usdt_new_frompath)r&r_rcs rr(z USDT.__init__s 3"9DH"77T[[=QR "77R[[^L ||t##$F$LMM$ DI44T[[5IJDL||t##$G$$NOO$ EG GrcBtj|jyr;)rbcc_usdt_closerEr+s r__del__z USDT.__del__s 4<<(rc|jdd}t|dk(r@tj|j|j d|j d}nT|\}}tj |j|j d|j d|j d}|dk7rtd|zy)NrTrr^ra.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. )splitlenrbcc_usdt_enable_proberEra%bcc_usdt_enable_fully_specified_prober )r&r<fn_name probe_partsret provider_name probe_names r enable_probezUSDT.enable_probeskk#q) { q ++ ell73W^^G5LNC+6 ']J;; m227;Z=N=Nw=Ww')C !8      rc |j||y#t$r:}t|tjtj dYd}~yd}~wwxYw)N)filer)rrr printsysstderrexit)r&r<rmes renable_probe_or_bailzUSDT.enable_probe_or_bailsB    eW -  !#** % HHQKK s A0AAc|jSr;)rEr+s r get_contextzUSDT.get_contexts ||rctjdz}tj|j|d<tj|dj S)Nrr)rHc_void_prErbcc_usdt_genargsr2)r& ctx_arrays rget_textz USDT.get_textsD[[1_' {{4<<0 ! ##Iq188::rcd|jdd}t|dk(r>tj|j|j d|j S|\}}tj|j|j d|j d|j S)NrTrr^)rirjrbcc_usdt_get_probe_argctyperErar2+bcc_usdt_get_fully_specified_probe_argctype)r&rq arg_indexrnrpr<s rget_probe_arg_ctypezUSDT.get_probe_arg_ctypes &&sA. { q 22 j//8)EEKVX N&1 "]EBB m227;U\\'=RT]__e_e_g hrclgfd}tjjt|S)Ncdjtj|jyr;)appendrNrEcontents)r<probesr&s r _add_probez)USDT.enumerate_probes.._add_probes MM)DLL%..A Br)rbcc_usdt_foreachrErr&rrs` @renumerate_probeszUSDT.enumerate_probess. C T\\8J+?@ rcn|j}|D] \}}}}|rd}|j||||"y)Nr])rGrmaddrr_)enumerate_active_probes attach_uprobe)r&bpfattach_usdt_ignore_pidrbinpathrmrr_s rattach_uprobeszUSDT.attach_uprobessL--/-3 2 )WgtS%   7G#'S  2 2rchgfd}tj|jt|S)Nc0j||||fyr;)r)rrmrr_rs rrz0USDT.enumerate_active_probes.._add_probes MM7GT37 8r)rbcc_usdt_foreach_uproberErrs @rrzUSDT.enumerate_active_probess- 9 ##DLL.2LM r)NN) r rrr(rgrrrzr|rrrrrrrrr[r[s6G$) (; h2rr[) __future__rctypesrHrvlibbccrrrrr r Exceptionr objectrr9rNr[rrrrs[& ,, I 5A5An&&,332[6[r