+
    oFj4                       R t ^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt	^ RI
t
^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RI t^ RI!H"t"H#t# ^ RI$t%^ RI&t%^ RI't'^ RI(H)t)H*t* ^ RI+H,t, ^ RI-H.t/ ]P`                  Pc                  RR4      t2]2 R2t3]2 R	2t4R
t5]P`                  Pc                  RR4      t6Rt7Rt8Rt9Rt:. R(Ot;R t<R R lt=R R lt>R R lt?R R lt@R tAR)R R lltBR tCR tDR tER  R! ltFR" tGR# tH ! R$ R%]I]J]J3,          4      tK ! R& R']'P                  4      tMR# )*z;Representation of and data collection for a problem report.N)IterableIterator)HookUINoninteractiveHookUI)kill_pkttyagent)implAPPORT_DATA_DIRz/usr/share/apportz/general-hooks/z/package-hooks/z/optAPPORT_IGNORE_FILEz~/.apport-ignore.xmlz/etc/apport/report-ignorez/etc/apport/report-onlyz/etc/apport/blacklist.dz/etc/apport/whitelist.dc                     \         P                  ! V 4       \         P                  ! T 4       F'  pY!9  g   K  TP	                  T4       \        Y!4       K)  	  R#   \         d     R# i ; i)z7Recursively add dependencies of package to depends_set.N)	packagingget_version
ValueErrorget_dependenciesadd_transitive_dependencies)packagedepends_setds   && //usr/lib/python3/dist-packages/apport/report.pyr   r   V   sZ    g& ''0OOA$Q4 1  s   A A*)A*c                F    V ^8  d   QhR\         R\        \         ,          /# )   	directoryreturn)strr   )formats   "r   __annotate__r   b   s      S Xc]     c              #    "    \         P                  ! V 4      P                  4        Fg  p VP                  RR7      ;_uu_ 4       pV F:  pVP	                  4       pV'       g   K  VP                  R4      '       d   K6  Vx  K<  	  RRR4       Ki  	  R#   + '       g   i     K~  ; i  \         d     K  i ; i  \         d     R# i ; i5i)z?Read every file in the directory and return each stripped line.utf-8encoding#N)pathlibPathiterdiropenstrip
startswithOSError)r   	list_filefdlinestrippeds   &    r   _read_list_files_in_directoryr-   b   s      i088:I^^W^55 "#'::<#8H,?,?,D,D"*N !# 65 ;555
   s{   C'B; B)B&B?BB)B; CB& B)$B; &B))B84B; 7B88B; ;C
C	C

Cc          	      V    V ^8  d   QhR\         R\        R\        R\         R,          /# )r   entry	fd_dir_fdfdinfo_dir_fdr   Nr   int)r   s   "r   r   r   r   s,      # # c cDj r   c                n  a  \         P                  ! WR7      pT  RT 2p \        T RRT3R lR7      ;_uu_ 4       pTP	                  4       pRRR4       X'       d    TRTP                  R4      ,           ,          pT#   \         d     R# i ; i  + '       g   i     LK; i  \
         d    Tu # i ; i)	zRead info for a single file descriptor entry.

Return formatted string with the FD's target path and fdinfo
metadata, or None if the FD no longer exists.
dir_fdN:UTF-8replacec                    < \         P                  ! V \         P                  \         P                  ,          \         P                  ,          SR 7      # r5   )osr%   O_RDONLY
O_NOFOLLOW	O_CLOEXEC)pathmoder1   s   &&r   <lambda> _read_fd_entry.<locals>.<lambda>   s+    bggbkkBMM1BLL@'r   )r    errorsopener
)r<   readlinkFileNotFoundErrorr%   readr(   rstrip)r/   r0   r1   targetr+   r*   infos   &&f    r   _read_fd_entryrM   r   s    U5 WAfXD	
 
 779D
 t{{4(((K)  
 
  s?   A? B$ BB$ ?BBB!	B$ !B$ $B43B4c                0    V ^8  d   QhR\         R\        /# )r   proc_pid_fdr   r3   r   )r   s   "r   r   r      s     ' ' ' 'r   c                    \         P                  ! R\         P                  \         P                  ,          \         P                  ,          \         P
                  ,          V R7      p \         P                  ! R\         P                  \         P                  ,          \         P                  ,          \         P
                  ,          T R7      p \         P                  ! T4      p. pT F&  p\        YaT4      pTf   K  TP                  T4       K(  	  RP                  T4      \         P                  ! T4       \         P                  ! T4       #   \         d   pR\        T4      ,           u Rp?# Rp?ii ; i  \         d3   p\         P                  ! T4       R\        T4      ,           u Rp?# Rp?ii ; i  \         dI   pR\        T4      ,           u Rp?\         P                  ! T4       \         P                  ! T4       # Rp?ii ; i  \         P                  ! T4       \         P                  ! T4       i ; i)zRead open file descriptors and their fdinfo from /proc/pid.

Return a formatted string with each FD's target path and fdinfo
metadata, or return a textual error if it failed.
r*   r5   Error: Nfdinfo

)r<   r%   r=   r>   r?   O_DIRECTORYr(   r   closelistdirrM   appendjoin)rO   r0   errorr1   entriespartsr/   parts   &       r   _read_open_fdsr^      s   &GGKK"--'",,6G
	&KK"--'",,6G
**Y'E!%MBDT" 
 {{5! 	
7  &3u:%%&  &
3u:%%&  &3u:%%

	& 	
ss   A&E )A&E; *F; ?%F; E8E3-E83E8;F8'F3-F83F8;HH	HH 	HH .H?c                <    V ^8  d   QhR\         R\        R\         /# )r   r@   r6   r   r2   )r   s   "r   r   r      s!     & &# &s &s &r   c                    \         P                  ! V \         P                  \         P                  ,          VR7      p\        P                  ! VR4      ;_uu_ 4       pVP                  4       P                  4       P                  RRR7      uuRRR4       #   + '       g   i     R# ; i  \         d   pR\        T4      ,           u Rp?# Rp?ii ; i)zPRead file content.

Return its content, or return a textual error if it failed.
r5   rbr8   r9   rD   NrR   )
r<   r%   r=   r?   iorI   r&   decoder(   r   )r@   r6   	proc_filer*   rZ   s   &&   r   _read_proc_filerf      s    
&GGD"++"<VL	WWY%%779??$++GI+F &%%% &3u:%%&s<   AB+ /B
B+ B(	"B+ (B+ +C6CCCc                  a  Rp \        RV 3R lRR7      ;_uu_ 4       pVP                  4       P                  4       pRRR4       V#   + '       g   i     T# ; i  \         d   pR\	        T4      ,           u Rp?# Rp?ii ; i)zRead /proc/pid/maps.

Since /proc/$pid/maps may become unreadable unless we are ptracing the
process, detect this, and attempt to attach/detach.
z%Error: unable to read /proc maps filemapsc                 4   < \         P                  ! WSR 7      # r;   )r<   r%   )r@   rA   rO   s   &&r   rB   _read_maps.<locals>.<lambda>   s    bggd&Mr   r   )rE   r    NrR   )r%   rI   r&   r(   r   )rO   rh   r*   rZ   s   f   r   
_read_mapsrk      sz     3D&M
 
 779??$D
 K
 
 K  &3u:%%&s9   A AA A	A A B'A>8B>Bc                    V ^8  d   QhR\         \        ,          R\        \        \        3,          R,          R\        R\        /# )r   commandenvNtimeoutr   )listr   dictfloat)r   s   "r   r   r      s=     # ##Y#!#s(^d2#DI##r   c                X    \         P                  ! V RRVR\         P                  \         P                  VR7      pTP                  ^ 8X  d   TP
                  P                  4       # \        RT  RTP                   RTP
                  P                  4        24      h  \         P                   dx   pTP
                  '       d-   RTP
                  P                  4       P                  4        2pMRp\        R\        TP                  4       RTP                   R	T 24      ThR
p?ii ; i)zRun command and capture its output.

Try to execute given command (argv list) and return its stdout, or return
a textual error if it failed.
Fr8   r9   )checkr    rn   rD   stdoutstderrro   : z with no stdoutzError: command z timed out after z secondsNz failed with exit code )
subprocessrunPIPESTDOUTTimeoutExpiredru   rd   rJ   r(   r   cmdro   
returncode)rm   rn   ro   sprZ   outputs   &&&   r   _command_outputr      s    ^^??$$	
& 
}}yy!!

'"9"-- III	!  $$ <<<%,,--/6689:F&Fc%))n- .mm_HVH6
 	s   :B D)2A2D$$D)c                :   RVP                   9  d   R# VP                   EF  pVP                  \        P                  P
                  P                  8X  g   K9  VP                  R8X  g   KL   VP                   R,          P                  pY09  d    R# TP                  4        TP                  4       '       g   K  TP                  ^ ,          P                  \        P                  P
                  P                  8X  g   K  TP                  ^ ,          P                  pY,          p\        T\        P                  4      '       d#   TP!                  4       pTP#                  R4      pM'\        T\$        4      '       d   TP#                  R4      p \&        P(                  ! T4      pTP1                  T4      '       d   EK   R# 	  VP                   R,          P                  #   \         d     EK  i ; i  \&        P*                  \,        \.        3 d     EK  i ; i)zpCheck if given report matches the given bug pattern XML DOM node.

Return the bug URL on match, otherwise None.
urlNrekeyr8   )
attributes
childNodesnodeTypexmldomNodeELEMENT_NODEnodeName	nodeValueKeyError	normalizehasChildNodes	TEXT_NODE
isinstanceproblem_reportCompressedValue	get_valueencodebytesr   compilerZ   	TypeErrorr   search)reportpatterncr   regexpvre_cs   &&     r   _check_bug_patternr     sx   
 G&&&::222qzzT7Ill5)33  KKM  Q\\!_%=%=AWAW%Wa22Ka!?!?@@A#]]73F5))#]]73F::f-D {{1~~/  2 e$...)   )Z8 s$   -G"G5"G21G25 HHc                 $    \         P                  P                  P                  V4      pTP                  R4       F  p\        Y4      pT'       g   K  Tu # 	  R #   \         P                  P
                  P                  \        3 d     R # i ; i)Nr   )
r   r   minidomparseStringparsersexpat
ExpatErrorUnicodeEncodeErrorgetElementsByTagNamer   )r   patternsr   r   r   s   &&   r   _check_bug_patternsr   )  sy    ggoo))(3 ++I6 13J 7
  KK((*<= s   )A /BBc                ,   V P                    F  pVP                  \        P                  P                  P
                  8X  dC   VP                  P                  4       R8X  d$   VP                  4        V P                  V4       Kx  \        V4       K  	  R# )z6Recursively remove whitespace from given XML DOM node. N)r   r   r   r   r   r   r   r&   unlinkremoveChild_dom_remove_space)noder   s   & r   r   r   7  s]    __::///AKK4E4E4G24MHHJQa  r   c                J    V ^8  d   QhR\         R,          R\        R\         /# )r   gdb_sandboxN	same_archr   )r   bool)r   s   "r   r   r   A  s%      sTz d s r   c                |   V '       d"   \         P                  P                  V RR4      MRp\        RV4      pV'       g>   \	        \
        P                  \         P                  ! \
        P                  4      R4      hV'       g8   \        RV4      pV'       d   TpV# \        P                  P                  R4       V# )zDetermine path to GDB.usrbinNgdbzgdb not found in retracing envzgdb-multiarchzWARNING: Please install gdb-multiarch for processing reports from foreign architectures. Results with "gdb" will be very poor.
)r<   r@   rY   _which_extrapathrH   errnoENOENTstrerrorsysrv   write)r   r   gdb_sandbox_bingdb_pathmas   &&   r   _get_gdb_pathr   A  s    ALbggll;u=RVO7HLL"++ell35U
 	
 o?H O JJ'
 Or   c           	      d   \         P                  P                  V4      '       g   R # / p \        VRR7      ;_uu_ 4       p\	        \        VP                  4       VR4      V4       RRR4        VR,          ! W4       R #   + '       g   i     L"; i  \         d;   p\        T4      P                  R4      '       d   TR,          ! T 4        Rp?M	h Rp?ii ; i R #   \         d     R# \         d    \         P                  P                  \         P                  P                  T4      4      ^ ,          P                  RR	4      p\        P                   ! 4       P#                  4       T R
T,           &   \$        P&                  P)                  RT4       \        P*                  ! 4         R # i ; i)Fr   r   execNadd_infoz
add_info()T-_
HookError_zhook %s crashed:)r<   r@   existsr%   r   r   rI   r   r   r'   StopIteration	Exceptionsplitextbasenamer9   	traceback
format_excr&   apportloggingrZ   	print_exc)r   uihooksymbr*   rZ   hooknames   &&&    r   	_run_hookr   X  sJ   77>>$D$))RD&148 *	V(  ) *)
  	5z$$\22 Z ((	 )    77##BGG$4$4T$:;A>FFsCP*3*>*>*@*F*F*H|h&'/6s`   C  &B &C /B  B	C C/CC CCC F/,F/5B6F/.F/c                    RpV'       d@   \         P                  P                  V\         P                  P	                  RR4      .4      p\
        P                  ! WR7      # )z.Return path of command, preferring extra_path.NPATHr   )r@   )r<   pathseprY   environgetshutilwhich)rm   
extra_pathr@   s   && r   r   r   u  s?    Dzz
BJJNN62,FGH<<++r   c                   X   a  ] tR tRt o RtV 3R lR ltV 3R lR lt]R 4       tRt	V t
R	# )
_Environmenti~  z)Wrapper around an environment dictionary.c                   < V ^8  d   QhRR/# r   r   N )r   __classdict__s   "r   r   _Environment.__annotate__  s     / / /r   c                    V P                  R4      pVf   R# VR8X  d   V R R# RV9   g   RV9   d   RV R&   R# RV R&   R# )z/Anonymize PATH environment variable if present.r   NzG/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/gamesz/homez/tmpz(custom, user)z(custom, no user)r   )selfr@   s   & r   anonymize_path_Environment.anonymize_path  sM    xx< 8 8 V_$+DL.DLr   c                4   < V ^8  d   QhRS[ S[,          RR/# )r   keysr   N)r   r   )r   r   s   "r   r   r     s     $ $8C= $T $r   c                0    V F  pW 9   g   K  RW&   K  	  R# )z1Anonymize given environment variables if present.z<set>Nr   )r   r   r   s   && r   anonymize_vars_Environment.anonymize_vars  s    C{#	 r   c           	         T ! VP                  R4       Uu. uF  pRV9   g   K  VP                  R^4      NK   	  up4      # u upi )zzRead environment variables from text representation.

The environment variables are expected to be separated by newlines.
rF   =)split)clsr   r/   s   && r   from_string_Environment.from_string  sE     .5mmD.AR.AUSE\ U[[a .AR
 	
Rs
   	AAr   N)__name__
__module____qualname____firstlineno____doc__r   r   classmethodr   __static_attributes____classdictcell__r   s   @r   r   r   ~  s0     3/ /$ $ 
 
r   r   c                     a  ] tR tRt o RtRiV 3R lR llt]V 3R lR l4       tV 3R lR	 ltV 3R
 lR lt	RjV 3R lR llt
R tV 3R lR ltV 3R lR ltV 3R lR ltV 3R lR ltV 3R lR lt]V 3R lR l4       tRkV 3R lR lltV 3R lR ltV 3R lR  ltV 3R! lR" ltRkV 3R# lR$ lltRjV 3R% lR& lltV 3R' lR( ltRlV 3R) lR* lltR+ tRkV 3R, lR- lltV 3R. lR/ ltV 3R0 lR1 lt]R2 4       tV 3R3 lR4 ltV 3R5 lR6 lt V 3R7 lR8 lt!V 3R9 lR: lt"V 3R; lR< lt#V 3R= lR> lt$V 3R? lR@ lt%V 3RA lRB lt&V 3RC lRD lt'V 3RE lRF lt(V 3RG lRH lt)V 3RI lRJ lt*V 3RK lRL lt+V 3RM lRN lt,V 3RO lRP lt-]V 3RQ lRR l4       t.V 3RS lRT lt/V 3RU lRV lt0V 3RW lRX lt1V 3RY lRZ lt2RjV 3R[ lR\ llt3V 3R] lR^ lt4V 3R_ lR` lt5V 3Ra lRb lt6V 3Rc lRd lt7V 3Re lRf lt8]9Rg 4       t:Rht;V t<R# )mReporti  zA problem report specific to apport (crash or bug).

This class wraps a standard ProblemReport and adds methods for collecting
standard debugging data.
Nc                8   < V ^8  d   QhRS[ RS[ R,          RR/# )r   problem_typedateNr   r   )r   r   s   "r   r   Report.__annotate__  s'     ? ?S ?#* ?PT ?r   c                b    \         P                  P                  WV4       RV n        . V n        R# )a  Initialize a fresh problem report.

date is the desired date/time string; if None (default), the current
local time is used.

If the report is attached to a process ID, this should be set in
self.pid, so that e. g. hooks can use it to collect additional data.
N)r   ProblemReport__init__pid_proc_maps_cache)r   r  r  s   &&&r   r  Report.__init__  s)     	$$--d$G#<>r   c                &   < V ^8  d   QhRS[ RS[ /# r   r   r   r  )r   r   s   "r   r   r    s      C C r   c                H   Rp\         P                  ! V 4      pV'       d   VRRP                  V4       R2,          p \         P                  ! V 4      '       g7   \         P                  ! V 4      pV'       d   VRV R2,          pV# VR,          pV#   \
         d     T# i ; i)zReturn a string suitable for appending to Package/Dependencies.

If package has only unmodified files, return the empty string. If not,
return ' [modified: ...]' with a list of modified files.
r   z [modified:  ]z
 [origin: z [origin: unknown])r   get_modified_filesrY   is_distro_packageget_package_originr   )r   suffixmodorigins   &   r   _customized_package_suffix!Report._customized_package_suffix  s     **73SXXc]O155F		..w77"55g>
6(!44F  22F
 	  			s#   B B 8B 	B B! B!c                4   < V ^8  d   QhRS[ RS[ R,          /# )r   r   r   Nr  )r   r   s   "r   r   r    s      3 3: r   c                     \         P                  ! V4      pT RT;'       g    R V P                  V4       2V R&   V#   \         d    Rp L6i ; i)zAdd Package: field.

Determine the version of the given package (uses "(not installed") for
uninstalled packages) and add Package: field to report.
This also checks for any modified files.

Return determined package version (None for uninstalled).
Nr  z(not installed)Package)r   r   r   r  r   r   versions   && r   add_packageReport.add_package  sj    	++G4G
 iq55$56..w78: 	Y
   	G	s   ? AAc                &   < V ^8  d   QhRS[ RS[ /# r  r  )r   r   s   "r   r   r    s      C C r   c                   \        4       p\        W4       R p\        V4       FI  p \        P                  ! V4      pT'       d
   TR,          pY4 RT T P                  T4       2,          pKK  	  V#   \
         d     K]  i ; i)r   rF   r  )setr   sortedr   r   r   r  )r   r   dependencies_setdependenciesdepr   s   &&    r   _get_transitive_dependencies#Report._get_transitive_dependencies  s    %(U ; *+C))#.
 $e1QC(G(G(L'MNNL ,   s   A22B Bc                2   < V ^8  d   QhRS[ R,          RR/# )r   r   Nr   r  )r   r   s   "r   r   r    s#     $N $Nd
 $Nd $Nr   c                   V'       gP   RV 9  d   V R,          R8X  d   V R,          pM&\         P                  P                  V R,          4      pV'       g   R# V P                  V4      pV'       g   RV 9  d    \        P
                  ! V4      V R&   V'       g   R# RV 9  d   \        P                  ! V4      V R&   RV 9  d   V P                  V4      V R&   R# R#   \         d     LVi ; i)	a  Add packaging information.

If package is not given, the report must have ExecutablePath.
This adds:
- Package: package name and installed version
- SourcePackage: source package name (if possible to determine)
- PackageArchitecture: processor architecture this package was built
  for
- Dependencies: package names and versions of all dependencies and
  pre-dependencies; this also checks if the files are unmodified and
  appends a list of all modified files
ExecutablePathProblemTypeKernelCrashr  NSourcePackagePackageArchitectureDependencies)	r   	fileutilsfind_file_packager!  r   
get_sourcer   get_architecturer*  r  s   && r   add_package_infoReport.add_package_info  s     t+]0C}0Ty/ **<<TBR=ST""7+oT1(1(<(<W(E_%  ,*3*D*DW*MD&'%#'#D#DW#MD  &  s   9C C)(C)c                R   VP                  R4       RVP                  R4       RVP                  RR4       R2V R&   VP                  R4      p\        R	R
RV.4      V R&   \        R	RV.4      V R&   \        R	RRV.4      V RV 2&   ^ RIp\        RV R2RR7      ;_uu_ 4       pVP	                  V4      pRRR4       RX9   d   VR,          p\        R	RRV.4      V RV 2&   . pRV9   dS   VR,           FE  pVR,          V,          P                  R4      p	V	'       g   K,  W9  g   K4  VP                  V	4       KG  	  V F  p
\        R	RRV
.4      V RV
 2&   K  	  VP                  R4      '       d#   V P                  VP                  R4      4       R# R#   + '       g   i     L; i)zAdd info about an installed Snap.

This adds a Snap: field, containing name, version and channel.
It adds a SnapSource: field, if the snap has a Launchpad contact
defined.
namer  r   z (channelunknown)Snapsnapchangesz
--abs-timeSnapChangesconnectionsSnapConnectionsrL   z	SnapInfo.Nz/snap/z/current/meta/snap.yamlr   r   baseplugszdefault-providercontact)r   r   yamlr%   	safe_loadrX   add_snap_contact_info)r   r@  snapnamerH  f	snap_metarE  	providersplugdpproviders   &&         r   add_snap_infoReport.add_snap_info   s    xx $((9"5!6)Y/03 	V 88F#-Yh7
] #26=(2S"T'6V\84(
y
#$ 	F8*$;<wOOSTq)I PYV$D'6t4(D9TF#$ 	i!'**w'-112DE2"-$$R( + "H+:x8,D9XJ'( "
 88I&&txx	':; % POs   #FF&	c                $   < V ^8  d   QhRS[ RR/# )r   snap_contactr   Nr  )r   r   s   "r   r   r  J  s     , ,# ,$ ,r   c                   Rp\         P                  ! V\        P                  P	                  V4      4      pV'       dW   VP                  ^4      '       d@   VP                  ^4      V R&   VP                  ^4      '       d   VP                  ^4      V R&   Rp\         P                  ! V\        P                  P	                  V4      4      pV'       d0   VP                  ^4      V R&   VP                  ^4      V R&   RV R&   R	# R	# )
zLoad report with information about where it should be filed.

Parse project (e.g. 'subiquity') or source package string
(e.g. 'ubuntu/+source/gnome-calculator') from snap 'contact'.
Additionally, extract any tag/tags defined in the contact URL.
ze^https?:\/\/.*launchpad\.net\/(?:distros/)?((?:[^\/]+\/\+source\/)?[^\/]+)(?:.*field\.tags?=([^&]+))?
SnapSourceSnapTagsz'^https?://.*github\.com/([^/]+)/([^/]+)SnapGitOwnerSnapGitNamezsnap-githubCrashDBN)r   r   urllibparseunquotegroup)r   rU  pms   &&  r   rJ  Report.add_snap_contact_infoJ  s    J 	
 IIa--l;<!"Dwwqzz#$771:Z  7IIa--l;<#$771:D "#''!*D+DO r   c                   < V ^8  d   QhRR/# r   r   )r   r   s   "r   r   r  d  s     G GT Gr   c                &   RV 9  d+   \         P                  P                  4       w  rV RV 2V R&   RV 9  d8   \        P                  ! 4       pV^ ,           RV^,           RV^,           2V R&   RV 9  d   \        P
                  ! 4       V R&   R# R# )zAdd operating system information.

This adds:
- DistroRelease: NAME and VERSION from /etc/os-release, or
  'lsb_release -sir' output
- Architecture: system architecture in distro specific notation
- Uname: uname -srm output
DistroReleaser  UnameArchitectureN)r   r   get_os_versionr<   unameget_system_architecture)r   osname	osversionus   &   r   add_os_infoReport.add_os_infod  s     $& & 0 0 ? ? AF'-ha	{$;D!$
A tfAadV1QqTF3DM%#,#D#D#FD  &r   c                   < V ^8  d   QhRR/# r   r   )r   r   s   "r   r   r  v  s     ' 't 'r   c           
         \         P                  ! \        P                  ! 4       4      ^ ,          p\
        P                  P                  4       p\        P                  ! 4        UUUUu. uF  w  r4rVY9   g   K  YR8:  g   K  TNK  	  pppppTP                  4        T'       d   RP                  T4      T R&   R# RT R&   R#   \         d     R# i ; iu uppppi )zWAdd information about the user.

This adds:
- UserGroups: system groups the user is in
Nr  
UserGroupszN/A)pwdgetpwuidr<   geteuidr   r   r4  get_sys_gid_maxgrpgetgrallsortrY   )r   usersys_gid_maxr;  r`  gidmembgroupss   &       r   add_user_infoReport.add_user_infov  s    	<<

-a0D &&668 '*lln
&4"|  # 2 D&4 	 

 	!$&!1D "'D  		
s#   0C *C
:C
C
CCc                   < V ^8  d   QhRR/# r   r   )r   r   s   "r   r   r    s     RV RVD RVr   c                  a RV 9  d   R# \         P                  P                  V R,          4      o\        \	        V3R l\
        4      4      '       g   R# RpV R,          P                  4        F#  p VP                  R^4      w  r4TR8X  g   K!  Tp M	  V'       g   R# V R,          P                  R4      p. ROp\        V4      ^8  d   V^,          P                  R	4      '       d~   VP                  R
4      '       db   V^,          R8X  dT   \        V4      ^8  dD   V P                  V^,          4      pV'       d   V R,          V R&   WpR&   R# RV^,           2V R&   R# V^ K  \        V4      ^8  d   V^,          P                  R4      '       d9   RV 9   d2   \         P                  P                  V R,          V^,          4      V^&   \         P                  ! V^,          \         P                  4      '       d6   V R,          V R&   \         P                  P                  V^,          4      V R&   RV 9  d   VS8w  d   V F  p\         P                  ! W^ ,          ,           \         P                  4      '       g   K=  W^ ,          ,           p	\         P                  P                  \         P                  P                  V	4      4      V8X  d   V R,          V R&   WR&    M	  RV 9   d_   \         P                  P                  V R,          4      R8X  d2   V R,          V R&   V P!                  4       p
V
'       d   WR&   R# RV R&   R# R# R#   \         d     EK  i ; i)zCheck if process is a script.

Use ExecutablePath, ProcStatus and ProcCmdline to determine if
process is an interpreted script. If so, set InterpreterPath
accordingly.
r.  Nc                 2   < \         P                   ! SV 4      # N)fnmatch)iexebasenames   &r   rB   +Report._check_interpreted.<locals>.<lambda>  s    GOOK$Cr   
ProcStatus	zName:ProcCmdline r   pythonz-mInterpreterPathz'Cannot determine path of python module UnreportableReason.ProcCwdtwistdz&Cannot determine twistd client program)z	/usr/bin/z
/usr/sbin/z/bin/z/sbin/)r<   r@   r   anyfilterinterpreters
splitlinesr   r   lenr'   _python_module_pathrY   accessR_OKrealpath_twistd_executable)r   r;  r+   kr   cmdargsbindirsr@   r`  argvexeexer  s   &          @r   _check_interpretedReport._check_interpreted  s    4'gg&&t,<'=>
 6C\RSS &113Dzz$* G| 4 }%++D1@ 'laGAJ$9$9#$>$>x((WQZ4-?CLTUDU//
;.23C.DD*+-1)*
  B'!*N -. 
 w<1qz$$S))i4.?WW\\$y/71:F
yyRWW--*./?*@&')+)9)9'!*)E%& D(T[-@99Q^RWW55!*nGww''(8(8(ABdJ267G2H./18-.  %  &6!78HD&*+;&<D"#))+C),%&-U)* E &c  s   3MMMc                .   < V ^8  d   QhRS[ R,          /# r   r  )r   r   s   "r   r   r    s      C$J r   c                   V R,          P                  R4      R,          pV'       Ed   V^ ,          P                  R^4      pV^ ,          P                  R4      '       g=   V^ ,          P                  R4      '       g   V^ ,          P                  R4      '       d#   \        V4      ^8X  d
   V^,          # V^,          # \        V^ ,          4      ^8  dY   V^ ,          ^ ,          R8X  dD   V^ ,          ^,          R8w  d/   V^ ,          R	,          pR
V9   g   RV9   g   RV9   d
   V^,          # VP                  ^ 4       EK!  R# )z5Determine the twistd client program from ProcCmdline.r  r  :r   NNr   z--filez--pythonz--sourcer   :   NNrL  ysN)r   r'   r  pop)r   argsargoptss   &   r   r  Report._twistd_executable  s    M"((.r2 dq'--Q'CA!!(++q6$$Z00q6$$Z00s8q=q6MAw3q6{Q3q6!9#3Aq	S8H1vbz$;#+7NHHQKr   c                4   < V ^8  d   QhRS[ RS[ R,          /# )r   moduler   Nr  )r   r   s   "r   r   r    s      C C$J r   c                     \         P                  P                  V 4      pTf   R# TP                  #   \         d     R# i ; i)z&Determine path of given Python module.N)	importlibutil	find_specImportErrorr  )r  specs   & r   r  Report._python_module_path  sC    	>>++F3D <{{	  		s   3 AAc                j   < V ^8  d   QhRS[ R,          RS[ R,          RS[S[,          R,          RR/# )r   r  NrO   extraenvr   r3   r   r   )r   r   s   "r   r   r    sJ     F+ F+4ZF+ 4ZF+ 3-$&	F+
 
F+r   c                   V'       g   V'       g*   V P                   ;'       g    \        P                  ! 4       pV P                   '       g   Wn          \        P                  ! RV 2\        P                  \        P
                  ,          \        P                  ,          4      p\        V4      V R&    \        P                  ! RVR7      V R&   V P                  WVR	7       \        R
V4      V R&   \        RV4      P!                  R4      V R&   \#        V4      V R&   V P%                  V4       \        P&                  P)                  V R,          4      '       g   \        V R,           R24      hV P+                  4        V P-                  4        V R,          P/                  RR4      P/                  RR4      P/                  RR4      V R&   V P1                  V4       R#   \         d   p\        R4      ThRp?i\         d2   pTP                  \        P                  8X  d   \        R4      Thh Rp?ii ; i  \         d     ELvi ; i)a  Add /proc/pid information.

If neither pid nor self.pid are given, it defaults to the process'
current pid and sets self.pid.

This adds the following fields:
- ExecutablePath: /proc/pid/exe contents; if the crashed process is
  interpreted, this contains the script path instead
- InterpreterPath: /proc/pid/exe contents if the crashed process is
  interpreted; otherwise this key does not exist
- ExecutableTimestamp: time stamp of ExecutablePath, for comparing at
  report time
- OpenFds: open file descriptors and their fdinfo metadata
- ProcEnviron: A subset of the process' environment (only some standard
  variables that do not disclose potentially sensitive information,
  plus the ones mentioned in extraenv)
- ProcCmdline: /proc/pid/cmdline contents
- ProcStatus: /proc/pid/status contents
- ProcMaps: /proc/pid/maps contents
- ProcAttrCurrent: /proc/pid/attr/current contents, if not "unconfined"
- CurrentDesktop: Value of $XDG_CURRENT_DESKTOP, if present
/proc/not accessibleNinvalid processOpenFdscwdr5   r  )r  rO   r  statusr  cmdliner  r  ProcMapsr.  z does not exist\z\\r  z\ )r  r<   getpidr%   r=   O_PATHrU   PermissionErrorr   r(   r   r   r^   rG   add_proc_environrf   rJ   rk   _add_executable_pathr@   r   r  _add_executable_timestampr9   _add_lsm_context)r   r  rO   r  rZ   s   &&&& r   add_proc_infoReport.add_proc_info  s   8 hh--"))+888	 ggSENBKK"))$;bnn$L )5Y	 kk%DDO 	#R,X{C\-iELLTR]%k2Z!!+.ww~~d#3455%5 67GHH 	!&&( WT6"WS% WT3	 	] 	k*C # > !12= ;;%,,.$%67UB  		s=   AG 4H7 H4)G55H4H4,H//H47IIc                $   < V ^8  d   QhRS[ RR/# r   rO   r   Nr3   )r   r   s   "r   r   r  O  s        r   c                   R V 9  d    \         P                  ! RVR7      V R &   R FC  pV R ,          P                  RV R24      '       g   K'  V R ,          \        RV 24      R V R &    R# 	  R#   \         d   p\        R4      ThRp?i\         d2   pTP
                  \
        P                  8X  d   \        R4      Thh Rp?ii ; i)r.  r  r5   r  Nr  /)rofsrwfs	squashmnt
persistmnt)	r<   rG   r  r   r(   r   r   r'   r  )r   rO   rZ   r`  s   &&  r   r  Report._add_executable_pathO  s    4')+U;)O%& =A$%001QCq::)-.>)?asG)O%& = # > !12= ;;%,,.$%67UBs)   A/ /C:BCC,C  Cc                   < V ^8  d   QhRR/# r   r   )r   r   s   "r   r   r  ^  s     B B4 Br   c                    V R ,          p \         P                  ! V4      p\        \	        TP
                  4      4      T R&   R#   \         d    RT R2T R&    R# i ; i)r.  zError: Executable 'z' not foundExecutableTimestampN)r<   statrH   r   r3   st_mtime)r   exe_pathexe_stats   &  r   r   Report._add_executable_timestamp^  se    ()	wwx(H '*#h.?.?*@&A"# ! 	,?z*UD&'	s   A AAc                $   < V ^8  d   QhRS[ RR/# r  r  )r   r   s   "r   r   r  g  s      C D r   c                     \         P                  ! 4       ^ 8X  d   \        RV4      pVR8w  d   W R&   R# R# R#   \         d     R# i ; i)    zattr/current
unconfinedProcAttrCurrentN)r<   getuidrf   r(   )r   rO   vals   && r   r  Report._add_lsm_contextg  sR    	 yy{a%nkB,&.1*+ '    		s   19 AAc                j   < V ^8  d   QhRS[ R,          RS[S[,          R,          RS[ R,          RR/# )r   r  Nr  rO   r   r  )r   r   s   "r   r   r  t  sD     - -4Z- 3-$&- 4Z	-
 
-r   c                   V'       gp   V'       g   \         P                  ! 4       p\         P                  ! RV 2\         P                  \         P                  ,          \         P
                  ,          4      p \        \        P                  P                  V4      4      pT P                  YB4       R#   \         d   pRT 2T R&    Rp?R# Rp?ii ; i)al  Add environment information.

If pid is not given, it defaults to the process' current pid.

This adds the following fields:
- ProcEnviron: A subset of the process' environment (only some standard
  variables that do not disclose potentially sensitive information,
  plus the ones mentioned in extraenv)
- CurrentDesktop: Value of $XDG_CURRENT_DESKTOP, if present
r  rR   ProcEnvironN)r<   r  r%   r=   r  rU   r   r   r4  get_process_environr(   _add_environ)r   r  r  rO   r   rZ   s   &&&&  r   r  Report.add_proc_environt  s      iik''bii 7".. HK	"6#3#3#G#G#TUG 	',  	$+E7"3D	s   9(B4 4C?CCc                H   < V ^8  d   QhRS[ RS[S[,          R,          RR/# )r   r   r  Nr   )r   r   r   )r   r   s   "r   r   r    s.     &
 &
#&
/7}t/C&
	&
r   c                   0 RmpV0 R	m,          pV'       d   V\        V4      ,          pVP                  4        VP                  V4       RV9   d   VR,          V R&   RP                  \	        VP                  4       4       UUu. uF)  w  rVWT9   g   K  V R2VP                  RR4      ,           NK+  	  upp4      V R&   R# u uppi )
LD_LIBRARY_PATHXDG_CURRENT_DESKTOPCurrentDesktoprF   r   \nr  N>   
LD_PRELOADr  XDG_RUNTIME_DIR>   LANGr   TERMSHELLLC_NAMELC_TIMELOCPATHLANGUAGELC_CTYPELC_PAPER
LC_ADDRESS
LC_COLLATE
LC_NUMERICLC_MESSAGESLC_MONETARYLC_TELEPHONELC_MEASUREMENTLC_IDENTIFICATION)r%  r   r   rY   r&  itemsr9   )r   r   r  r   	safe_varsr   values   &&&    r   r  Report._add_environ  s     N" &
 
	( X&I ~. G+%,-B%CD!""ii #)"9"9JC# 73%q	EMM$666"9
]s   
C
 C
c                    < V ^8  d   QhRS[ /# r   r   r   )r   r   s   "r   r   r    s      t r   c           
        RV 9  d   R# \         P                  ! RR7      ;_uu_ 4       p\        V R,          R4      '       d   V R,          P                  V4       MVP                  V R,          4       VP	                  4        V R,          P                  4       ^,          pRRV 2VP                  .p \        P                  ! VRR	\        P                  \        P                  R
7      pTP                  ^ 8H  pT'       d   TP                  T R&   RRR4       T#   \         d     RRR4       R# i ; i  + '       g   i     X# ; i)zGAdd information from kernel crash.

This needs a VmCore in the Report.
VmCoreFapport_vmcore_prefixr   rf  crashz/usr/lib/debug/boot/vmlinux-s   bt -a -f
ps
runq
quit
)rt   inputru   rv   N
Stacktrace)tempfileNamedTemporaryFilehasattrr   flushr   r;  rx   ry   rz   r{   r(   r~   ru   )r   corekverrm   r  rets   &     r   add_kernel_crash_infoReport.add_kernel_crash_info  s   
 4((0@AATtH~w//X$$T*

4>*JJL=&&(+D">tf EtyyQG	"7%??%,, ""a'C%*\\\"- B. 
  % BA"# BA. 
s6   BD657D,D6D6D3'D62D33D66E	c                F   < V ^8  d   QhRS[ R,          RS[ R,          RR/# )r   rootdirNr   r   r  )r   r   s   "r   r   r    s7     wD wDTzwD7:TzwD	wDr   c                n   RV 9  g   RV 9  d   R# RRRRRR	R
RRRRR/pV P                  W4      w  rERVR&   V. R'O,          p. pVP                  4        F#  w  rxVP                  V4       VRRRV.,          pK%  	  VP                  R4       VRR.,          p\        WER7      p	RV	9   g   RV	9   d   RV	9   d:   RP	                  V	P                  4        U
u. uF  p
RV
9   g   K  V
NK  	  up
4      pMWRV	9   d:   RP	                  V	P                  4        U
u. uF  p
RV
9   g   K  V
NK  	  up
4      pMV	P                  4       ^ ,          pRVP                  4       ,           pWR&   \        V4      hV	P                  R^R7      ^ ,          pVP                  R4      '       d>   \        \        P                  \        P                  ! \        P                  4      R4      h\        P                   ! R \        P"                  4      pVP                  V	4      pVP%                  ^ 4       V F4  pVP'                  R!R"4      P                  4       WP%                  ^ 4      &   K6  	  RV 9   d   R#V R,          9   d   V R,          V R&   V R RV 9   dl   \        P(                  ! R$V R,          4      pV'       dC   VP+                  ^4      V R&   V R,          P                  R%4      '       d   V R,          ^ R( V R&   MV R RV 9   d2   V P-                  4        V P/                  4       pV'       d   VV R&&   R# R# R# u up
i u up
i ))a  Add information from gdb.

This requires that the report has a CoreDump and an
ExecutablePath. This adds the following fields:
- Registers: Output of gdb's 'info registers' command
- Disassembly: Output of gdb's 'x/16i $pc' command
- Stacktrace: Output of gdb's 'bt full' command
- ThreadStacktrace: Output of gdb's 'thread apply all bt full' command
- StacktraceTop: simplified stacktrace (topmost 5 functions) for inline
  inclusion into bug reports and easier processing
- AssertionMessage: Value of __abort_msg or __glib_assert_msg
  if present

The optional rootdir can specify a root directory which has the
executable, libraries, and debug symbols. This does not require
chroot() or root privileges, it just instructs gdb to search for the
files there.

Raises a OSError if the core dump is invalid/truncated, or OSError if
calling gdb fails, or FileNotFoundError if gdb or the crashing
executable cannot be found.
CoreDumpr.  N	Registerszinfo registersDisassemblyz	x/16i $pcr  zbt fullThreadStacktracezthread apply all bt fullAssertionMessagezprint __abort_msg->msgGLibAssertionMessagezprint (char*) __glib_assert_msgz/nonexistentHOME--exzp -99	separator)rn   z%is truncated: expected core file sizezis not a core dumpzwarning:rF   zWarning:zInvalid core dump: r  )maxsplitzNo such file or directory.z&executable file for coredump not foundz^\$\d+\s*=\s*-99$rT   z
.
z"ERROR:z(^\$\d+\s+=\s+0x[0-9a-fA-F]+\s+"(.*)"\s*$r  StacktraceAddressSignature)z--batchr(  zset backtrace limit 2000z-iexzset debuginfod enable off)gdb_commandr  rX   r   rY   r  r&   r(   r   endswithrH   r   r   r<   r   r   r   	MULTILINEr  r9   matchr_  _gen_stacktrace_topcrash_signature_addresses)r   r  r   gdb_reportsgdb_cmdr   
value_keysr;  r}   outr+   warningsreason
first_linepart_rer\   r]   ra  addr_signatures   &&&                r   add_gdb_infoReport.add_gdb_info  s0   6 T!%5T%A );) : 8"$E
  ++GA( 
 	
 
$**,IDd#55G - 	+&FG$$g3 4s:#s*S 99&)nn&6M&6d*:LTT&6M s"99&)nn&6M&6d*:LTT&6M >>+A.*X^^-==F)/%&&/!YYtaY03
;<<#ELL)8  **12<<@c"		!D&*ll67&C&I&I&KD"# 
 "T)D!788+/0F+G'(+, %;TBT=UA +,771:'(*+44U;;/34F/G"/MD+,+,4$$&!;;=N5C12   a N Ns   	L-#L-	L2#L2c                ~   \        . RO4      pR.^,          p^ pRpRpRp\        P                  ! R4      p\        P                  ! R4      p\        P                  ! R4      p	V R,          P                  4        EF  p
VP	                  V
4      pV'       g   VP	                  V
4      pV'       g   K8  V'       d	   V'       d   VP                  ^4      '       d>   VP                  ^4      P                  4       ^ ,          P                  R4      ^ ,          pMR	pV'       d+   V'       d   VP                  R
4      '       g   VR9   d   K  RpVP                  ^4      '       g   W9   d4   Rp^ pR.^,          pVP                  ^4      '       d   RpVR8X  d   RpEK   RpVP                  ^4      ;'       g    VP                  ^4      pVP                  4       ^ ,          pV\        V4      8  g   EKv  V	P	                  V4      '       d   EK  WV&   V^,          pEK  	  RP                  V4      P                  4       V R&   R	# )zBuild field StacktraceTop as the top five functions of Stacktrace.

Signal handler invocations and related functions are skipped since they
are generally not useful for triaging and duplicate detection.
_XErrorr   FzD^#(\d+)\s+(?:0x(?:\w+)\s+in\s+\*?(.*)|(<signal handler called>)\s*)$z0^#(\d+)\s+(?:(.*)|(<signal handler called>)\s*)$z,^(__.*_s?sse\d+(?:_\w+)?|__kernel_vsyscall)$r  (N_XTrF   StacktraceTop)g_logvg_log	IA__g_log
IA__g_logvg_assert_warningIA__g_assert_warning
__GI_abortr?  >   XWindowEventhandle_errorhandle_response)r%  r   r   r  r0  r_  r   r'   r  rY   r&   )r   unwind_functionstoptracedepthunwound	unwindingunwinding_xerrorbt_fn_rebt_fn_noaddr_reignore_functions_rer+   ra  fnframefunctions   &              r   r1  Report._gen_stacktrace_topU  s    	
 4!8	 ::S
 **?
 !jj;
 &113Dt$A#))$/i771::))+A.44S9!<BB $MM$//!TT ',$771::!7 $IE "taxHwwqzz #'Y+/(!	GGAJ,,!''!*E{{}Q'Hs8}$-@-F-Fx-P-P"'
U 4V !%		( 3 9 9 ;_r   c                \   < V ^8  d   QhRS[ R,          RS[R,          RS[R,          RS[/# )r   r   Nr   
srcpackager   r   r   r   )r   r   s   "r   r   r    s?      TM t $J	
 
r   c                ~    Vf   \        4       pV P                  WV4      pV P                  RR4       \        4        V# )as  Run hook script for collecting package specific data.

A hook script needs to be in PACKAGE_HOOK_DIR/<Package>.py or in
GENERAL_HOOK_DIR/*.py and has to contain a function 'add_info(report,
ui)' that takes and modifies a Report, and gets an UserInterface
reference for interactivity.

return True if the hook requested to stop the report filing process,
False otherwise.
N	_HooksRun)r   _add_hooks_infor  r   )r   r   r   r[  r  s   &&&& r   add_hooks_infoReport.add_hooks_info  s<      :%'B""2
;d#
r   c                N   < V ^8  d   QhRS[ RS[R,          RS[R,          RS[/# )r   r   r   Nr[  r   r\  )r   r   s   "r   r   r    s;     B BB#&:B;>:B	Br   c                   V'       g   V P                  R 4      pV'       d)   VP                  4       ^ ,          pRV9   d   RV 2V R&   R# V'       g   V P                  R4      pV'       d)   VP                  4       ^ ,          pRV9   d   RV 2V R&   R# \        .pRp\        P                  P                  V P                  RR	4      4      pVP                  \        4      '       d   TpMvV'       do    \        P                  P                  V4       FI  pVP                  \        4      '       g   K   \        P                  P                  V4      '       g   KG  Tp M	   V'       dp   \        V4      \        \        4      8  dS   VP                  \        P                  P                  VR
RR4      4       \        P                  P!                  V4      pKo  \#        \$        P$                  ! \&        R,           4      4       F  p\)        WV4      '       g   K   R# 	  V'       dC   V F<  p	\)        W\        P                  P                  WR,           4      4      '       g   K;   R# 	  V'       dA   V F:  p	\)        W\        P                  P                  V	RV R24      4      '       g   K9   R# 	  R#   \         d     EL_i ; i)r  r  zinvalid Package: r  Fr1  zinvalid SourcePackage: Nr.  r   sharer   zpackage-hooksz/*.pyTz.pysource_)r   r   PACKAGE_HOOK_DIRr<   r@   r  r'   _OPT_DIRr   r   	get_filesisfiler   r  rX   rY   dirnamer&  globGENERAL_HOOK_DIRr   )
r   r   r   r[  	hook_dirsopt_path	exec_pathrL  r   hook_dirs
   &&&&      r   r_  Report._add_hooks_info  s    hhy)Gmmoa(Gg~/@	-J)*/2J#))+A.Jj /Fzl-S)*%&	GG$$TXX.>%CD	)) H))33G<A||H--"''..2C2C#$ = h-3x=0  GGLL7HoN 77??84 499%5%?@AD4(( B
 %Trww||Ho'NOO &
 %bggll8wzl#5NO   	 & =  s$   2:J0 1"J0 J0 J0 0J?>J?c                B   < V ^8  d   QhRS[ R,          RS[ R,          /# )r   r   Nr   r  )r   r   s   "r   r   r    s#     ) )sTz )cDj )r   c                D   V'       g   R#  \         P                  P                  V4      ;_uu_ 4       pVP                  4       P	                  RRR7      pRRR4       RX9   d   R# \        Y4      pT'       d   T# R#   + '       g   i     L0; i  \
         d     R# i ; i)a  Check bug patterns loaded from the specified url.

Return bug URL on match, or None otherwise.

The url must refer to a valid XML document with the following syntax:
root element := <patterns>
patterns := <pattern url="http://bug.url"> *
pattern := <re key="report_key">regular expression*</re> +

For example:
<?xml version="1.0"?>
<patterns>
    <pattern url="http://bugtracker.net/bugs/1">
        <re key="Foo">ba.*r</re>
    </pattern>
    <pattern url="http://bugtracker.net/bugs/2">
        <re key="Package">^\\S* 1-2$</re>
        <!-- test for a particular version -->
        <re key="Foo">write_(hello|goodbye)</re>
    </pattern>
</patterns>
Nr8   r9   rb   z<title>404 Not Found)r\  requesturlopenrI   rd   r(   r   )r   r   rt  r   s   &&  r   search_bug_patternsReport.search_bug_patterns  s    0 	'',,"<<>000K - "X-!$1J -, 		s.   'B "A=B =B	B B BBc                    \         P                  ! \        P                  ! 4       4      ^,          p \        P                  RV 4      pRpRpRp \        P                  ! V\        P                  \        P                  ,          4      p\        P                  ! V4      p\        P                  ! VP                  4      '       d)   \        P                  ! VR4      pVP                  R4      pTe   TP!                  4        MTe   \        P                   ! T4       TR8X  d1   \"        P$                  P'                  4       P)                  RRR4      pM* \"        P$                  P*                  P-                  T4      pTP8                  P;                  4        \=        TP8                  4       T#   \         d     Li ; i  Te   TP!                  4        i Te   \        P                   ! T4       i i ; i  \"        P.                  P0                  P2                   d$   p\5        \         R\7        T4       24      ThRp?ii ; i)zRead ignore list XML file and return a DOM tree.

Return an empty DOM tree if file does not exist.

Raises ValueError if the file exists but is invalid XML.
~r   NriP  r   z has invalid format: )rs  rt  r<   ru  _ignore_filer9   r%   r>   r=   fstatr  S_ISREGst_modefdopenrI   r(   rV   r   r   getDOMImplementationcreateDocumentr   r   r   r   r   r   r   documentElementr   r   )homedirifpathcontentsr*   rL  str   rZ   s           r   _get_ignore_domReport._get_ignore_dom*  s    ,,rzz|,Q/%%c73	!<=B"B||BJJ''IIb#&66%= }	r>''..0??hPTUCggoo11(; 	%%'#--.
1  		 }	   ;;$$//  #n$9#e*Fs=   BF- )G3 -F;8F> :F;;F> >2G03)H?H::H?c                    < V ^8  d   QhRS[ /# r  r  )r   r   s   "r   r   r  [  s     - -# -r   c                    \        V R ,          4      pV P                  R4      pV'       d   V#  \        P                  ! V4      P                  #   \
         d	    RT 2u # i ; i)Signal
SignalNamezsignal )r3   r   signalSignalsr;  r   )r   signal_numbersignal_names   &  r   _get_signal_nameReport._get_signal_name[  s]    DN+hh|,	->>-0555 	-]O,,	-s   A A"!A"c                    < V ^8  d   QhRS[ /# r  r  )r   r   s   "r   r   r  g  s     5 5t 5r   c                J   RV 9   g   Q hV R,          \        \        4      9   g   V R,          \        \        4      9   d   R# \        \        \        4      4      pV\        \        \
        4      4      ,          pV'       d   V R,          V9  d   R#  V P                  4       p \        \        P                   ! T R,          4      P"                  4      p TP'                  R4       FD  pTP)                  R4      T R,          8X  g   K"  \+        TP)                  R4      4      T8  g   KC   R# 	  R#   \        \        3 d9    \        P                  P                  R4       \        P                  ! 4         R# i ; i  \$         d     R# i ; i  \        \        3 d     R# i ; i)a  Check if current report should not be presented.

Reports can be suppressed by per-user denylisting in
~/.apport-ignore.xml (in the real UID's home) and
/etc/apport/report-ignore/. For environments where you are only
interested in crashes of some programs, you can also create an
allowlist in /etc/apport/report-only/, everything which does not
match gets ignored then.

This requires the ExecutablePath attribute. Throws a ValueError if the
file has an invalid format.

Privileges may need to be dropped before calling this.
r.  TzCould not get ignore file:Fignoreprogrammtime)r-   _DENYLIST_DIR_LEGACY_DENYLIST_DIRr%  _ALLOWLIST_DIR_LEGACY_ALLOWLIST_DIRr  r   r   r   r   rZ   r   r   r3   r<   r  r  r(   r   getAttributerr   )r   	allowlistr   	cur_mtimer  s   &    r   check_ignoredReport.check_ignoredg  sv     4'''  !%B&
 
"#'D (
 
  5nEF	S67LMNN	./y@	&&(C	BGGD)9$:;DDEI	228<&&y1T:J5KKV009:iG# = ) H% 	NN  !=>!	  		 H% 		sI   D/ #0E; .F F (F +F /AE87E8;F
	F
F"!F"c                   < V ^8  d   QhRR/# r   r   )r   r   s   "r   r   r    s     + +T +r   c                   RV 9   g   Q hV P                  4       p \        \        \        P                  ! V R,          4      P
                  4      4      pTP                  R4       F4  pTP                  R4      T R,          8X  g   K"  TP                  RT4        MY	  TP                  R4      pTP                  RT R,          4       TP                  RT4       TP                  P                  T4       \        P                   ! \        P"                  ! 4       4      ^,          p\$        P'                  RT4      p\)        TRRR	7      ;_uu_ 4       pTP+                  TR
RR7       RRR4       TP-                  4        R#   \         d,   pTP                  \        P                  8X  d    Rp?R# h Rp?ii ; i  + '       g   i     L[; i)aF  Ignore future crashes of this executable.

Add a ignore list entry for this report to ~/.apport-ignore.xml, so
that future reports for this ExecutablePath are not presented to the
user any more.

Throws a ValueError if the file already exists and has an invalid
format.

Privileges may need to be dropped before calling this.
r.  Nr  r  r  ry  wr   r   z  rF   )	addindentnewl)r  r   r3   r<   r  r  r(   r   r   r   r  setAttributecreateElementr  appendChildrs  rt  ru  r{  r9   r%   writexmlr   )	r   r   r  rZ   r  er  ignore_file_pathr*   s	   &        r   mark_ignoreReport.mark_ignore  sg     4'''""$	BGGD)9$:;DDEFE ..x8F""9-6F1GG##GU3 9 !!(+ANN9d+;&<=NN7E*++A. ,,rzz|,Q/'//W="C'::bLLt$L7 ; 	

5  	{{ell*		. ;:s)   9E? F8?F5
F0/F00F58G	c                    < V ^8  d   QhRS[ /# r  r  )r   r   s   "r   r   r    s     ? ?t ?r   c                6   V P                  R4      '       g   R# V R,          P                  4        Uu. uF  qP                  R4      NK  	  pp\        V4      ^8  d   VP	                  R4      ^ 8H  # VP	                  R4      \        V4      R,          8*  # u upi )zCheck whether StackTrace can be considered 'useful'.

The current heuristic is to consider it useless if it either is shorter
than three lines and has any unknown function, or for longer traces, a
minority of known functions.
rB  F??Tg       @)r   r  r'   r  count)r   rL  
unknown_fns   &  r   has_useful_stacktraceReport.has_useful_stacktrace  s     xx((262G2R2R2TU2TQll4(2T
Uz?Q##D)Q..%Z3)>>> Vs   Bc                .   < V ^8  d   QhRS[ R,          /# r   r  )r   r   s   "r   r   r    s      t r   c                    V P                  RR4      P                  4        F4  pVP                  R4      ^ ,          P                  4       pVR8w  g   K2  Vu # 	  R# )z)Return topmost function in StacktraceTop.rB  r   r@  r  N)r   r  r   r&   )r   r+   fnames   &  r   stacktrace_top_functionReport.stacktrace_top_function  sL    HH_b1<<>DJJsOA&,,.E} ?
 r   c                .   < V ^8  d   QhRS[ R,          /# r   r  )r   r   s   "r   r   r    s     - -S4Z -r   c                x   V R ,          P                  4       p\        V4      ^8  d   R# \        V4      ^8  d3   \        P                  P	                  V R,          4       RV^ ,           2# \
        P                  ! R4      p\        V4      ^,
          pRpV^ 8  dN   VP                  W,          4      pV'       d$   VP                  ^4      pVP                  ^4      pMV^,          pKT  \        P                  P	                  V R,          4      pVR,          pVP                  R4      ^ ,          p	\
        P                  ! R\
        P                  ! V	4       R2V4      pV'       d   VP                  ^4      p
MRp
VR	8X  d   XV R,          8X  d   R
pMTpMV R2pV RV	 RV 2pV
'       d   VRV
 2,          pV# )	TracebackNr.   crashed with z^\s*File\s*"(\S+)".* in (.+)$r=  r7   ^z: (.+)$<module>__main__() in rw   )r  r  r<   r@   r   r   r   r0  r_  r   escape)r   tracetrace_rer  rX  ra  module_pathr@   	last_line	exceptionmessagecontexttitles   &            r   _get_python_exception_title"Report._get_python_exception_title  s   [!,,.u:>u:>77##D)9$:;< q
,
 ::>?JN1fux(Aggaj771:FAww%5 67"I	OOC(+	HHq9-.g6	BggajGGz!d#344$ &!
"oG&ykgY?r'^#Er   c                .   < V ^8  d   QhRS[ R,          /# r   r  )r   r   s   "r   r   r    s     
 
t 
r   c                >   V P                  4       pV'       d   R V R2pMRpRpRV 9   d8   RV 9   d1   V R,          V R,          8w  d   V R,          R8w  d   RV R,           R2p\        P                  P                  V R,          4       R	V P	                  4        V V 2# )
r  r  r   rg  r2  allz [non-native z	 package]r.  r  )r  r<   r@   r   r  )r   rV  arch_mismatchs   &  r   _get_signal_crash_titleReport._get_signal_crash_title  s    ))+t2BBd"%-^$-B(CC*+u4+D1F,G+H	RM ww%5 678T2245bT-J	
r   c                .   < V ^8  d   QhRS[ R,          /# r   r  )r   r   s   "r   r   r  *  s     9 9d
 9r   c                   V P                  R4      R8X  dA   RV 9   d:   RV 9   d3   \        P                  P                  V R,          4       RV R,           2# RV 9   d   RV 9   d   RV 9   d   V P	                  4       # RV 9   d   RV 9   d   V P                  4       # V P                  R4      R	8X  dZ   R	V 9   dS   R
V R	,           R2pV P                  R4      '       d-   VRV R,          P                  4       R,          ,           ,          pV# V P                  R4      R8X  d^   RV 9   dW   V R,          pVP                  R4      '       d   VP                  R^4      ^,          pV# VP                  R^4      ^ ,          pV# V P                  R4      R8X  du   RV 9   dn   RpRV 9   d   VRV R,          ,           R,           ,          pWR,          R,           ,          pRV 9   d   VRV R,          ,           R,           ,          pVR,          pV# R# )a*  Create an appropriate title for a crash database entry.

This contains the topmost function name from the stack trace and the
signal (for signal crashes) or the Python exception (for unhandled
Python exceptions).

Return None if the report is not a crash or a default title could not
be generated.
r  6r.  r%  z assert failure: rB  r  r/  r  zpackage z failed to install/upgradeErrorMessagerw   
KernelOopsOopsTextz$------------[ cut here ]------------rF   Failurer   MachineType[z] z failureNonfreeKernelModulesz [non-free: r  Nr  )	r   r<   r@   r   r  r  r  r'   r   )r   r  oopss   &  r   standard_titleReport.standard_title*  s    HHX#% D("d* 77##D)9$:;< =+,-/
 t 0D 8_PT=T//11$#3t#;3355 88M"i/I4EtI//IJExx''^ 4 ? ? A" EEEL88M"l2zT7I
#DEFF

4+A. L 

4+A.L88M"l2yD7H E$tM22T99)_z11E%-$/E*FFLLTMELr   c                0   < V ^8  d   QhRS[ S[,          /# r  )rp   r   )r   r   s   "r   r   r  e  s      49 r   c                   . pV P                  RR4      R,           V P                  RR4      ,           P                  4        F  pV'       g   K  VP                  4       R,          w  r4\        P                  ! V4      pVf   KB  VR8w  g   KK  Vf   KQ  \        P
                  ! WE4      ^ 8  g   Kn  VP                  V4       K  	  V# )z=Return list of obsolete packages in Package and Dependencies.r  r   rF   r3  :Nr   NNone)r   r  r   r   get_available_versioncompare_versionsrX   )r   obsoleter+   pkgveravails   &     r   obsolete_packagesReport.obsolete_packagese  s    HHY#d*TXXnb-II
*,D zz|B'HC33C8E6M%..s:Q>$ r   c                .   < V ^8  d   QhRS[ R,          /# r   r  )r   r   s   "r   r   r  y  s     4 4t 4r   c                >   RV 9  d   V R,          R9  d   R# RV 9   d   V R,          R8X  d   V P                  4       # V P                  R4      R8X  d>   R	V 9   d7   V R,          R
,           V R	,          ,           p\        P                  ! RRV4      # RV 9   d   RV 9   d   V P	                  4       # RV 9   d   V P                  4       # V R,          R8X  d4   RV 9   d-   RV R,          9   g   RV R,          9   d   V P                  4       # RV 9   d   V P                  4       # R# )aP  Get a signature string for a crash.

This is suitable for identifying duplicates.

For signal crashes this the concatenation of ExecutablePath, Signal
number, and StacktraceTop function names, separated by a colon. If
StacktraceTop has unknown functions or the report lacks any of those
fields, return None. In this case, you can use
crash_signature_addresses() to get a less precise duplicate signature
based on addresses instead of symbol names.

For assertion failures, it is the concatenation of ExecutablePath
and assertion message, separated by colons.

For Python crashes, this concatenates the ExecutablePath, exception
name, and Traceback function names, again separated by a colon.

For suspend/resume failures, this concatenates whether it was a suspend
or resume failure with the hardware identifier and the BIOS version, if
it exists.
r.  r/  r0  r  Nr  r  r  r%  r7   z0x[0-9a-f]{6,}ADDRrB  r  r  suspendresumer  >   r  r0  )_crash_signature_kernel_crashr   r   sub_crash_signature_signal_crash!_crash_signature_python_traceback'_crash_signature_suspend_resume_failure_crash_signature_kernel_oopsr   sigs   & r   crash_signatureReport.crash_signaturey  s   , 4'M"*GG 4D$7=$H5577 88H$);t)C'(3.6H1IIC66+VS99 d"x4'75577 $99;;,.93DDO+x4	?/JCCEE 4466r   c                .   < V ^8  d   QhRS[ R,          /# r   r  )r   r   s   "r   r   r    s      sTz r   c                    R p\         P                  ! R4      pV R,          P                  4        F=  pVP                  V4      pV'       g   K  VRVP	                  ^4      ,           ,          pK?  	  V# )kernelz^\s*\#\d+\s\[\w+\]\s(\w+)r  r7   )r   r   r  r0  r_  )r   r  regexr+   ra  s   &    r   r  $Report._crash_signature_kernel_crash  s_    

78&113DD!Aqsaggaj)) 4 
r   c                .   < V ^8  d   QhRS[ R,          /# r   r  )r   r   s   "r   r   r    s      cDj r   c                   R p. pV R,          P                  R4       EF"  pVP                  R4      '       dT   \        P                  ! RV4      pV'       d5   VP	                  ^4      pV'       g   Q RV 24       hVP                  V4       VP                  R4      '       d/   V P                  V4      pV'       d   VP                  V4       K  K  VP                  R4      '       d   RpK  V'       g   K  R	pV'       d?   V^ ,          R
8X  d1   V P                  V4      pV'       d   VP                  V4       EK  EK   R pEK%  	  V'       d   RP                  V4      # R	# )Fr  rF   zBUG: unable to handlez^BUG: unable to handle (.*) at z,could not parse expected problem type line: zIP: zCall Trace:TNr  r7   )r   r'   r   r   r_  rX   _extract_function_and_addressrY   )r   in_trace_bodyr\   r+   parsedr0  s   &     r   r  #Report._crash_signature_kernel_oops  s   $**40D677#DdK"LLOE W$PQUPV"WW5LL'v&&::4@LL'  // $DGsN >>tDEU+  %*M/ 10 88E?"r   c                .   < V ^8  d   QhRS[ R,          /# r   r  )r   r   s   "r   r   r    s     "= "=3: "=r   c                   V R ,          P                  4       pRp\        V4      ^8X  dO   \        P                  ! RV^ ,          4      pV'       g   R# V R,          R,           VP	                  ^4      ,           # \        V4      ^8  d   R# \        P
                  ! R4      pV F  pVP                  V4      pV'       g   K  VP	                  ^4      R8w  d"   VRVP	                  ^4      ,           ,          pKU  VP	                  ^4      p\        P                  P                  V4      '       d    \        P                  P                  V4      pVRV RVP	                  ^4       2,          pK  	  VR,          P                  R4      ^ ,          p VR	V R
,           R2,          pV R,          R,           V,           V,           #   \         d     L+i ; i)r  r   z(\w+): Nr.  r7   z)^\s+File "([^"]+).*line (\d+).*\sin (.*)$r  @r@  _PythonExceptionQualifierr>  r  )r  r  r   r0  r_  r   r<   r@   islinkr  r   r   )r   r  r  ra  loc_rer+   rL  exc_names   &       r   r  (Report._crash_signature_python_traceback  s~   [!,,.u:?U1X.A()C/!''!*<<u:>HIDT"Aq 771:+3++C 
Aww~~a((GG,,Q/Qqc1771:,//C  9??3'*	!D!<=>a@@H $%+h6<<  		s   G   GGc                .   < V ^8  d   QhRS[ R,          /# r   r  )r   r   s   "r   r   r    s      sTz r   c                h   V R ,           RV R,           2p\         P                  ! R4      pV R,          P                  4       p\        V4      ^8  d   R# V FW  pVP	                  V4      pV'       d;   TRVP                  ^4      ;'       g    VP                  ^4      ,           ,          pKV   R# 	  V# )r.  r7   r  z.^(?:([\w:~]+).*|(<signal handler called>)\s*)$rB  N)r   r   r  r  r0  r_  )r   r  rS  linesr+   ra  s   &     r   r  $Report._crash_signature_signal_crash  s    &'($x.)9:::OP_%002u:>Dt$Asaggaj66AGGAJ77   
r   c                .   < V ^8  d   QhRS[ R,          /# r   r  )r   r   s   "r   r   r    s      t r   c                    V R ,          pV P                  R4      '       d   VRV R,           2,          pV P                  R4      '       d   VRV R,           2,          pV# )r  r  r7   zdmi.bios.versionr   r  s   & r   r  .Report._crash_signature_suspend_resume_failure  s^    9o88M""QtM*+,,C88&''Qt./011C
r   c                4   < V ^8  d   QhRS[ RS[ R,          /# )r   r+   r   Nr  )r   r   s   "r   r   r    s      C C$J r   c                    \         P                  ! R V 4      pV'       d4   VP                  ^4      pV'       g   Q RV  24       hV^ ,          R8w  d   V# R# )z\[.*\] (.*)$z*could not parse expected call trace line: ?N)r   r   r_  )r+   r  r0  s   &  r   r  $Report._extract_function_and_address  sJ    ?D1LLOEMFtfMM5Qx3r   c                .   < V ^8  d   QhRS[ R,          /# r   r  )r   r   s   "r   r   r    s     :N :N3: :Nr   c                   RV 9  g   RV 9  g   RV 9  d   R# V R,          P                  R4      '       d   R# . p^ pV R,          P                  4        F  pVP                  R4      '       d   VP                  4       ^,          pVP                  R4      '       g   KJ  \        V^4      pVR8  d   K_  V P	                  V4      pV'       d#   VP                  VP                  R	R
4      4       M	V^,          p\        V4      ^8  g   K   M	  V^ 8  d   \        V4      V,          ^8  d   R# V^ 8X  d   \        V4      ^8  g   V^ 8  d   \        V4      ^8  d   R# V R,           R	V R,           R	R	P                  V4       2# )a*  Compute heuristic duplicate signature for a signal crash.

This should be used if crash_signature() fails, i. e. Stacktrace does
not have enough symbols.

This approach only uses addresses in the stack trace and does not rely
on symbol resolution. As we can't unwind these stack traces, we cannot
limit them to the top five frames and thus will end up with several or
many different signatures for a particular crash. But these can be
computed and synchronously checked with a crash database at the client
side, which avoids having to upload and process the full report. So on
the server-side crash database we will only have to deal with all the
equivalence classes (i. e. same crash producing a number of possible
signatures) instead of every single report.

Return None when signature cannot be determined.
r  r  r  NrR   r!   0xi   r7   z..r.  )	r'   r  r   r3   _address_to_offsetrX   r9   r  rY   )r   stackfailedr+   addroffsets   &     r   r2   Report.crash_signature_addresses  sR   $ T!\%=QUAU
&&y11&113Ds##zz|At,,4} &=006LLT!:;aKF
 5zR- 44 A:#e*v-1 aKCJN
s5zA~'()4>*:!CHHUO;LMMr   c                   < V ^8  d   QhRR/# r   r   )r   r   s   "r   r   r  ]  s     7= 7=4 7=r   c           
        . p\         P                  ! 4       ^ 8  EdM   \        P                  ! \         P                  ! 4       4      p\        V^ ,          4      ^8  dG   VP                  \        P                  ! R\        P                  ! V^ ,          4       R24      R34       VP                  \        P                  ! R\        P                  ! V^,          4       R24      R34       V^,          P                  R4       Fd  pVP                  4       p\        V4      ^8  g   K%  VP                  \        P                  ! R\        P                  ! V4       R24      R34       Kf  	  \         P                  ! 4       ^,          p\        V4      ^8  d@   VP                  \        P                  ! R\        P                  ! V4       R24      R34        V R V  F  pVP                  R	4      ;'       d    VR9  pV'       g   R
V9   g
   VR9   g   K9  \        W,          R4      '       g   KS  V Fw  w  rx\!        W,          \"        4      '       d=   VP%                  WV,          P'                  RRR7      4      P)                  R4      W&   K]  VP%                  WV,          4      W&   Ky  	  K  	  R#   \         d     Li ; i)zRemove user identifying strings from the report.

This particularly removes the user name, host name, and IPs
from attributes which contain data read from the environment, and
removes the ProcCwd attribute completely.
z\busernamez/home/username,z(\b|\s)z\1User Namehostnamer  Procr  isspacer8   r9   rb   N)ProcCpuinfor  r  ProcInterruptsProcModules>   Titler  
PythonArgsJournalErrors)r<   r  rs  rt  ru  r  rX   r   r   r  r   r&   ri  r   r'   r  r   r   r  rd   r   )	r   replacementsr`  r  r'  r  is_proc_fieldr   repls	   &        r   	anonymizeReport.anonymize]  s$    99;?RZZ\*A1Q4yA~##RZZ2bii!o5Fb0I%JJ$WXr"))AaD/!2"568HI qTZZ_GGIq6A: ''wryy|nB$?@.Q % 88:a=x=Ar"))H2E1Fb,I!JJ WX	Y ALL0  Q ? 6M 1$MMtw	22%1MG!$'511")++ q'..."K# &/  #*++dG"< &2   		s   J1 1J?>J?c                    < V ^8  d   QhRS[ /# r  r  )r   r   s   "r   r   r    s      S r   c                   V R ,          p\        V\        4      '       d   Q h\        V\        4      '       dm   \        P                  ! RR7      w  r#\
        P                  ! \        P                  V4       \        P                  ! W!4       \        P                  ! V4       V# \        V\        P                  4      '       d   \        P                  ! RR7      w  r#\
        P                  ! \        P                  V4       \        P                  ! V4       \        VR4      ;_uu_ 4       pVP                  V4       RRR4       V# V^ ,          pV#   + '       g   i     T# ; i)r!  apport_core_r  wbN)r   r   r   r  mkstempatexitregisterr<   r   r   rV   r   r   r%   )r   coredumpr*   r  rL  s   &    r   #_provide_uncompressed_coredump_file*Report._provide_uncompressed_coredump_file  s    
#h,,,,h&&''~>HBOOBIIt,HHR"HHRL  ."@"@AA''~>HBOOBIIt,HHRLdD!!Qq! "
  A;D "!
 s   ,EE$	c                .   < V ^8  d   QhRS[ R,          /# r   r  )r   r   s   "r   r   r    s      #* r   c                X     \        V R,          4      #   \        \        3 d     R# i ; i)z-Get ExecutableTimestamp if present and valid.r  N)r3   r   r   )r   s   &r   get_executable_timestampReport.get_executable_timestamp  s/    	t1233*% 		s    ))c          
         < V ^8  d   QhRS[ R,          RS[ R,          RS[S[S[ ,          S[S[ S[ 3,          3,          /# )r   sandboxNr   r   )r   tuplerp   rq   )r   r   s   "r   r   r    sH     L  L TzL 03d
L 	tCy$sCx.(	)L r   c                   RV 9   g   Q hV P                  RV R,          4      pRpRV 9   d$   V R,          \        P                  ! 4       8X  d   Rp\        W$4      .p/ pV'       Ed   V P                  R4      pV'       d   VR8X  d   V P                  R4      p\        P                  ! V4      P                  R4       Uu. uF	  pV V 2NK  	  p	pVR	R
V R2R	RV,           R	RV,           R	RRP                  V	4       2.,          pV'       dw   \        P                  ! 4       P                  R4       Uu. uF	  pV V 2NK  	  p
pRP                  V
4      pV R2pVRVRVRVRV R2/,          pR.VR&   VR	RV R2.,          p\        P                  P                  W,           4      '       gS   VP                  R4      '       d<   \        P                  P                  WR,          ,           4      '       d
   VR,          pW,           pVR	RV R2.,          pRV 9   d#   V P                  4       pVR	RV,           .,          pWV3# u upi u upi )a  Build gdb command for this report.

This builds a gdb command for processing the given report, by setting
the file to the ExecutablePath/InterpreterPath, unpacking the core dump
and pointing "core-file" to it (if the report has a core dump), and
setting up the paths when calling gdb in a package sandbox.

When available, this calls "gdb-multiarch" instead of "gdb", for
processing crash reports from foreign architectures.

Return argv list for gdb and any environment variables.
r.  r  Frg  Tr2  r  r7   r(  zset debug-file-directory z/usr/lib/debugzset solib-absolute-prefix zadd-auto-load-safe-path zset solib-search-path z/usrr  r   
PYTHONHOME
GCONV_PATHz/usr/lib/x86_64-linux-gnu/gconvzld-linux-x86-64.so.2:Nr  Nzset data-directory z/usr/share/gdb:   NNzfile ""r!  z
core-file )r   r   rj  r   get_library_pathsr   rY   r<   r@   r   r'   r=  )r   rD  r   
executabler   rm   r   archr@   sandbox_library_pathsgdb_sandbox_library_pathsld_lib_pathpyhomer  s   &&&           r   r-  Report.gdb_command  sx     4'''XX/6F1GH
	d"^$	(I(I(KKI 89"$78812D45=xx/ &77=CCCH%HD )D6"H " %
 +G9NC,w6*W4(2G)H(IJ
 
G  !* ; ; = C CC H- H #mD6* H * - "hh'@A'=-%{K & [M1P"Q	   66F&9+n$UVV77>>'"677((00ww~~g2&>??%/^
 -JFfZL233;;=Dt 344GY%"-s   >I2Ic                4   < V ^8  d   QhRS[ RS[R,          /# )r   r   r   NrP   )r   r   s   "r   r   r    s      s sTz r   c                ~    V P                  4        F(  w  r#pY!u;8:  d
   V8:  g   K  M K  V RW,
          R 2u # 	  R# )a  Resolve a memory address to an ELF name and offset.

This can be used for building duplicate signatures from non-symbolic
stack traces. These often do not have enough symbols available to
resolve function names, but taking the raw addresses also is not
suitable due to ASLR. But the offsets within a library should be
constant between crashes (assuming the same version of all libraries).

This needs and uses the "ProcMaps" field to resolve addresses.

Return 'path+offset' when found, or None if address is not in any
mapped range.
+xN)_build_proc_maps_cache)r   r   startendelfs   &&   r   r  Report._address_to_offset  sD      $::<OE###aQ/00  = r   c                J   < V ^8  d   QhRS[ S[S[S[S[3,          ,          /# r  )rp   rE  r3   r   )r   r   s   "r   r   r    s$      %  %U3S=-A(B  %r   c           	        V P                   '       d   V P                   # RV 9   g   Q h. V n         \        P                  ! R4      p\        P                  ! R4      pV R,          P                  4        F  pVP	                  4       '       g   K  VP                  V4      pV'       g0   VP                  V4      '       d   KM  V'       g   Q RV,           4       hV P                   P                  \        VP                  ^4      ^4      \        VP                  ^4      ^4      VP                  ^4      34       K  	  V P                   # )zOGenerate self._proc_maps_cache from ProcMaps field.

This only gets done once.
r  z-^([0-9a-fA-F]+)-([0-9a-fA-F]+).*\s{2,}(\S.*$)z ^([0-9a-fA-F]+)-([0-9a-fA-F]+)\szcannot parse ProcMaps line: )	r  r   r   r  r&   r0  rX   r3   r_  )r   fmtfmt_unknownr+   ra  s   &    r   rW  Report._build_proc_maps_cache  s   
    (((T!!! " jjIJjj!DE$//1D::<<		$A$$T** ?84??q!!((QWWQZ$c!''!*b&91771:F 2 $$$r   c                F   < V ^8  d   QhRS[ S[S[3,          RS[RS[RR/# )r   r<  coredump_keyr   r   Nrq   r   object)r   r   s   "r   r   r  4  s6     # #S&[)#9<#CF#	#r   c                |    VP                  V4      p\        V\        4      '       g   Q hVP                  4       W&   R # r  )r   r   r   rJ   )r   r<  rb  r   r  s   &&&& r   _add_str_from_coredumpReport._add_str_from_coredump4  s2     \*%%%%%LLN	r   c                :   < V ^8  d   QhRS[ S[S[3,          RR/# r   r<  r   Nrc  )r   r   s   "r   r   r  ;  s(     D D$sF{2C D Dr   c                    VP                  R 4      pVf   R# \        V\        4      '       g   Q h\        P                  ! V\
        P                  R7      p\        P                  ! V^R7      V R&   R# )COREDUMP_PACKAGE_JSONN)object_pairs_hook)indentCoredumpPackageJson)r   r   r   jsonloadscollectionsOrderedDictdumps)r   r<  r  decodeds   &&  r   _add_elf_package_metadata Report._add_elf_package_metadata;  sZ    45=%%%%% **Uk6M6MN&*jj&C"#r   c                :   < V ^8  d   QhRS[ S[S[3,          RR/# ri  rc  )r   r   s   "r   r   r  E  s%      Df<M RV r   c                   VP                  R 4      pV'       d   \        V\        4      '       g   Q hW R&   R# VP                  R4      pV'       d5   \        V\        4      '       g   Q h \        P
                  ! V4      V R&   R# R#   \         d/    \        P                  ! \        4      P                  RT4        R# i ; i)COREDUMPr!  NCOREDUMP_FILENAMEz:Ignoring COREDUMP_FILENAME '%s' because it does not exist.)r   r   r   r   r   CompressedFilerH   r   	getLoggerr   warning)r   r<  dumpfilenames   &&  r   #_add_coredump_from_systemd_coredump*Report._add_coredump_from_systemd_coredumpE  s    ||J'dE****#<< 34h,,,,#1#@#@#JZ   % !!(+33Ps   *B 5C ?C c                   VP                  R4      p\        V\        P                  4      '       g   Q hV ! \        P                  ! VP                  4       4      R7      pVP                  R4      p\        V\        4      '       g   Q hWCn        VP                  R4      p\        V\        4      '       g   Q h\        V4      VR&   VP                  VRR4       VP                  VRR	4       VP                  VR
R4       VP                  VRR4       VP                  VRR4       VP                  VRR4       VP                  VRR4       VP                  V4       VP                  R4      p\        V\        4      '       g   Q hVP                  \        P                  V4      4       VP                  4        VP                  R4      R8w  d   VP                  V4       V# )ac  Convert the givin systemd coredump into a problem report.

The following keys are not used:
 * COREDUMP_CGROUP (str)
 * COREDUMP_COMM (str)
 * COREDUMP_CONTAINER_CMDLINE (str)
 * COREDUMP_GID (int)
 * COREDUMP_HOSTNAME (str)
 * COREDUMP_OWNER_UID (str)
 * COREDUMP_PACKAGE_NAME
 * COREDUMP_PACKAGE_VERSION
 * COREDUMP_PROC_AUXV (bytes)
 * COREDUMP_PROC_CGROUP (str)
 * COREDUMP_PROC_LIMITS (str)
 * COREDUMP_PROC_MOUNTINFO (str)
 * COREDUMP_RLIMIT (str)
 * COREDUMP_ROOT (str)
 * COREDUMP_SESSION
 * COREDUMP_SLICE (str)
 * COREDUMP_UID (int)
 * COREDUMP_UNIT (str)
 * COREDUMP_USER_UNIT (str)
 * MESSAGE (str)
COREDUMP_TIMESTAMP)r  COREDUMP_PIDCOREDUMP_SIGNALr  COREDUMP_SIGNAL_NAMEr  COREDUMP_CMDLINEr  COREDUMP_EXEr.  COREDUMP_CWDr  COREDUMP_OPEN_FDSr  COREDUMP_PROC_MAPSr  COREDUMP_PROC_STATUSr  COREDUMP_ENVIRONCOREDUMP_TRUNCATED1)r   r   datetimetimeasctime	timetupler3   r  r   rf  ru  r  r   r   r  r  )r   r<  r  r   r  r  r   s   &&     r   from_systemd_coredumpReport.from_systemd_coredumpW  s   4 ||01$ 1 12222$,,t~~'789ll>*#s####
 %67-----}-x%%h0FU%%h0BMR%%h@PQ%%h	J%%h0CYO%%h0DjQ%%h0FU((2,,12'3''''L44W=>((*::*+s266x@r   )r  r  )CrashNr  )NNN)NN)=r   r   r   r   r   r  staticmethodr  r!  r*  r8  rR  rJ  rn  r  r  r  r  r  r  r  r  r  r  r  r<  r1  r`  r_  rv  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r2  r3  r=  rA  r-  r  rW  rf  ru  r  r   r  r   r   r  s   @r   r  r    si    ? ?  . * &$N $NL(<T, ,4G G$' '4RV RVh 0  F+ F+P B B - -<&
 &
P @wD wDvM<^ .B BH) )V . .`- -5 5n+ +Z? ?" - -^
 
,9 9v (4 4l  @"= "=H "   :N :N|7= 7=r & L  L \ ( %  %D# #D D $ 6 6r   r  )shbashdashcshtcshzpython*zruby*phpzperl*zmono*awk)Ni  )Nr   r:  rq  r  r   r  rk  rw  importlib.utilr  rc   ro  r   r<   r"   rs  r   r   r  r  rx   r   r  r  r   urllib.errorr\  urllib.parseurllib.requestxml.domr   xml.dom.minidomxml.parsers.expatcollections.abcr   r   apport.fileutilsr   apport.loggingr   apport.hook_uir   r   apport.hookutilsr   apport.packaging_implr   r   r   r   	_data_dirrl  rf  rg  r{  r  r  r  r  r  r   r-   rM   r^   rf   rk   r   r   r   r   r   r   r   rq   r   r   r
  r  r   r   r   <module>r     sO   A       
  	   	  
 	     
          .    7 , 3JJNN,.AB	[0 [0  zz~~24JK ,*0 1 &	5 >'T&(#P!/H!.:, 
4S>  
Ph^)) hr   