ó
ýGpNc           @   se  d  Z  d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l	 Z	 d d l
 Z
 d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l m Z d d l Z d d l Z d d l Z d d l m Z e j j d d ƒ Z d e a d e a d	 a d
 a  d d d d d d d d d d d g Z! d „  Z" d „  Z# d „  Z$ e% e j& d „ Z' d „  Z( d „  Z) d „  Z* d e j+ f d „  ƒ  YZ, d d l- Z- d d l. Z. d d l/ Z/ d d l0 Z0 y d d l1 m2 Z2 Wn! e3 k
 r.d d l4 m2 Z2 n Xd  e- j5 f d! „  ƒ  YZ6 e7 d" k rae- j8 ƒ  n  d S(#   s;   Representation of and data collection for a problem report.iÿÿÿÿN(   t
   ExpatError(   t   implt   APPORT_DATA_DIRs   /usr/share/apports   %s/package-hooks/s   %s/general-hooks/s   ~/.apport-ignore.xmls   /etc/apport/blacklist.dt   sht   basht   dasht   csht   tcshs   python*s   ruby*t   phps   perl*s   mono*t   awkc         C   so   y t  j |  ƒ } Wn t k
 r' d SXx@ t  j |  ƒ D]/ } | | k r8 | j | ƒ t | | ƒ q8 q8 Wd S(   s7   Recursively add dependencies of package to depends_set.N(   t	   packagingt   get_versiont
   ValueErrort   get_dependenciest   addt   _transitive_dependencies(   t   packaget   depends_sett   cur_vert   d(    (    s1   /usr/lib/python2.7/dist-packages/apport/report.pyR   )   s    c         C   sE   y t  |  ƒ j ƒ  j ƒ  SWn$ t t f k
 r@ } d t | ƒ SXd S(   s\   Read file content.
    
    Return its content, or return a textual error if it failed.
    s   Error: N(   t   opent   readt   stript   OSErrort   IOErrort   str(   t   patht   e(    (    s1   /usr/lib/python2.7/dist-packages/apport/report.pyt
   _read_file5   s    c         C   sQ   d } y  t  d |  ƒ j ƒ  j ƒ  } Wn$ t t f k
 rL } d t | ƒ SX| S(   s   Read /proc/pid/maps.

    Since /proc/$pid/maps may become unreadable unless we are ptracing the
    process, detect this, and attempt to attach/detach.
    s%   Error: unable to read /proc maps files   /proc/%d/mapss   Error: (   R   R   R   R   R   R   (   t   pidt   mapsR   (    (    s1   /usr/lib/python2.7/dist-packages/apport/report.pyt
   _read_maps?   s     c         C   sr   t  j |  d t  j d | d t ƒ} | j | ƒ \ } } | j d k rL | St d t |  ƒ | j | f ƒ ‚ d S(   s™   Run command and capture its output.

    Try to execute given command (argv list) and return its stdout, or return
    a textual error if it failed.
    t   stdoutt   stderrt	   close_fdsi    s.   Error: command %s failed with exit code %i: %sN(   t
   subprocesst   Popent   PIPEt   Truet   communicatet
   returncodeR   R   (   t   commandt   inputR!   t   spt   outt   err(    (    s1   /usr/lib/python2.7/dist-packages/apport/report.pyt   _command_outputL   s    $c         C   sA  | j  j d ƒ s d Sx| j D]} | j t j j j k r  | j	 d k r  | j  j d ƒ r  | j  d j
 } |  j | ƒ s‚ d S| j ƒ  | j ƒ  r&| j d j t j j j k r&| j d j
 j d ƒ } yE |  | } t | t j ƒ rþ | j ƒ  } n  t j | | ƒ sd SWq#d SXq&q  q  W| j  d j
 j d ƒ S(   s|   Check if given report matches the given bug pattern XML DOM node.
    
    Return the bug URL on match, otherwise None.
    t   urlt   ret   keyi    s   UTF-8N(   t
   attributest   has_keyt   Nonet
   childNodest   nodeTypet   xmlt   domt   Nodet   ELEMENT_NODEt   nodeNamet	   nodeValuet	   normalizet   hasChildNodest	   TEXT_NODEt   encodet
   isinstancet   problem_reportt   CompressedValuet	   get_valueR0   t   search(   t   reportt   patternt   cR1   t   regexpt   v(    (    s1   /usr/lib/python2.7/dist-packages/apport/report.pyt   _check_bug_pattern[   s*    '

c         C   se   y t  j j j | ƒ } Wn t k
 r- d  SXx0 | j d ƒ D] } t |  | ƒ } | r> | Sq> Wd  S(   NRG   (   R7   R8   t   minidomt   parseStringR    R4   t   getElementsByTagNameRK   (   RF   t   patternsR8   RG   R/   (    (    s1   /usr/lib/python2.7/dist-packages/apport/report.pyt   _check_bug_patternsy   s    c         C   si   xb |  j  D]W } | j t j j j k rW | j j ƒ  d k rW | j ƒ  |  j	 | ƒ q
 t
 | ƒ q
 Wd S(   s6   Recursively remove whitespace from given XML DOM node.t    N(   R5   R6   R7   R8   R9   R?   R<   R   t   unlinkt   removeChildt   _dom_remove_space(   t   nodeRH   (    (    s1   /usr/lib/python2.7/dist-packages/apport/report.pyRT   †   s
    -
t   Reportc           B   sì   e  Z d  Z d d d „ Z d „  Z d d „ Z d „  Z d „  Z d „  Z	 d g  d „ Z
 d g  d	 „ Z d d
 „ Z d d „ Z d „  Z d d d „ Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   sŸ   A problem report specific to apport (crash or bug).

    This class wraps a standard ProblemReport and adds methods for collecting
    standard debugging data.t   Crashc         C   s#   t  j j |  | | ƒ d |  _ d S(   s,  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(   RB   t   ProblemReportt   __init__R4   R   (   t   selft   typet   date(    (    s1   /usr/lib/python2.7/dist-packages/apport/report.pyRY   š   s    	c         C   s.   t  j | ƒ } | r& d d j | ƒ Sd Sd S(   sÙ   Return 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.
        s    [modified: %s]t    RQ   N(   R
   t   get_modified_filest   join(   RZ   R   t   mod(    (    s1   /usr/lib/python2.7/dist-packages/apport/report.pyt   _pkg_modified_suffix¦   s    c         C   s€  | sR d |  k r/ |  d d k r/ |  d } n t  j j |  d ƒ } | sR d Sn  y t j | ƒ } Wn t k
 r~ d } n Xd | | pŽ d |  j | ƒ f |  d <t j | ƒ |  d <| sÂ d St j	 | ƒ |  d	 <t
 g  ƒ } t | | ƒ d
 |  d <x t | ƒ D]s } y t j | ƒ } Wn t k
 r4qn X|  d rR|  d c d 7<n  |  d c d | | |  j | ƒ f 7<qWd S(   s  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
        - 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
        t   ExecutablePatht   ProblemTypet   KernelCrasht   PackageNs   %s %s%ss   (not installed)t   SourcePackaget   PackageArchitectureRQ   t   Dependenciess   
(   t   apportt	   fileutilst   find_file_packageR
   R   R   R4   Ra   t
   get_sourcet   get_architecturet   setR   t   sorted(   RZ   R   t   versiont   dependenciest   depRJ   (    (    s1   /usr/lib/python2.7/dist-packages/apport/report.pyt   add_package_info²   s:    


c         C   s–   t  j d d g d t  j d t  j d t ƒ} | j ƒ  d j ƒ  j d d ƒ |  d	 <t j ƒ  } d
 | d | d | d f |  d <t	 j
 ƒ  |  d <d S(   sc  Add operating system information.

        This adds:
        - DistroRelease: lsb_release -sir output
        - Architecture: system architecture in distro specific notation
        - Uname: uname -srm output
        - NonfreeKernelModules: loaded kernel modules which are not free (if
            there are none, this field will not be present)
        t   lsb_releases   -sirR    R!   R"   i    s   
R]   t   DistroReleases   %s %s %si   i   t   Unamet   ArchitectureN(   R#   R$   R%   R&   R'   R   t   replacet   ost   unameR
   t   get_system_architecture(   RZ   t   pt   u(    (    s1   /usr/lib/python2.7/dist-packages/apport/report.pyt   add_os_infoè   s    
&#c         C   s|   t  j t j ƒ  ƒ j } g  t j ƒ  D]0 \ } } } } | | k r% | d k  r% | ^ q% } | j ƒ  d j | ƒ |  d <d S(   so   Add information about the user.

        This adds:
        - UserGroups: system groups the user is in
        iè  R]   t
   UserGroupsN(	   t   pwdt   getpwuidRy   t   getuidt   pw_namet   grpt   getgrallt   sortR_   (   RZ   t   usert   nameR|   t   gidt   membt   groups(    (    s1   /usr/lib/python2.7/dist-packages/apport/report.pyt   add_user_infoú   s
    $
c   	   	      s?  |  j  d ƒ s d St j j |  d ƒ ‰  t ‡  f d †  t ƒ sE d Sd } xa |  d j ƒ  D]O } y | j d d ƒ \ } } Wn t	 k
 r” q\ n X| d k r\ | } Pq\ q\ W| s¹ d S|  d j d	 ƒ } d
 d d d g } x0 t
 | ƒ d k r| d j d ƒ r| d =qá Wt
 | ƒ d k r±| d j d ƒ ri|  j  d ƒ rit j j |  d | d ƒ | d <n  t j | d t j ƒ r±|  d |  d <t j j | d ƒ |  d <d Sn  | ˆ  k r;t d „  g  | D] } | | d ^ qÍƒ } | r;t j j t j j | d ƒ ƒ | k r;|  d |  d <| d |  d <d Sn  d S(   sÈ   Check if process is a script.

        Use ExecutablePath, ProcStatus and ProcCmdline to determine if
        process is an interpreted script. If so, set InterpreterPath
        accordingly.
        Rb   Nc            s   t  j  ˆ  |  ƒ S(   N(   t   fnmatch(   t   i(   t   exebasename(    s1   /usr/lib/python2.7/dist-packages/apport/report.pyt   <lambda>  s    t
   ProcStatuss   	i   s   Name:t   ProcCmdlinet    s   /bin/s   /sbin/s	   /usr/bin/s
   /usr/sbin/i   t   -t   .t   ProcCwdt   InterpreterPathc         S   s   t  j |  t  j ƒ S(   N(   Ry   t   accesst   R_OK(   R|   (    (    s1   /usr/lib/python2.7/dist-packages/apport/report.pyR   8  s    i    (   R3   Ry   R   t   basenamet   filtert   interpretersR4   t
   splitlinest   splitR   t   lent
   startswithR_   R˜   R™   t   realpath(	   RZ   Rˆ   t   lt   kRJ   t   cmdargst   bindirsR|   t   argvexes(    (   R   s1   /usr/lib/python2.7/dist-packages/apport/report.pyt   _check_interpreted  sB    ("$-.c         C   s@  | s |  j  p t j ƒ  } n  |  j  s9 t | ƒ |  _  n  t | ƒ } y t j d | d ƒ |  d <Wn t k
 rw n X|  j | | ƒ t d | d ƒ |  d <t d | d ƒ j	 d ƒ |  d <t
 t | ƒ ƒ |  d	 <y t j d | d
 ƒ |  d <Wn7 t k
 r/} | j t j k r)t d ƒ ‚ q0‚  n XxE d D]= } |  d j d | ƒ r7|  d t d | ƒ |  d <Pq7q7Wt j j |  d ƒ s”t ‚ |  j ƒ  |  d j d d ƒ j d d ƒ j d d ƒ |  d <yR t j ƒ  d k r!t d | d ƒ j ƒ  j ƒ  } | d k r!| |  d <q!n  Wn t t f k
 r;n Xd S(   sv  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
        - 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"
        s   /proc/s   /cwdR–   s   /statusR‘   s   /cmdlineR“   R’   t   ProcMapss   /exeRb   s   invalid processt   rofst   rwfst	   squashmntt
   persistmnts   /%s/s   /%ss   \s   \\R]   s   \ i    s   /attr/currentt
   unconfinedt   ProcAttrCurrentN(   R©   Rª   R«   R¬   (   R   Ry   t   getpidt   intR   t   readlinkR   t   add_proc_environR   t   rstripR   t   errnot   ENOENTR   R    RŸ   R   t   existst   AssertionErrorR§   Rx   R‚   R   R   R   R   (   RZ   R   t   extraenvR   R|   t   val(    (    s1   /usr/lib/python2.7/dist-packages/apport/report.pyt   add_proc_info>  sB    	!
2 c         C   s·  d d d d d d d d d	 d
 d d d d d d g | } | sO t  j ƒ  } n  t | ƒ } d |  d <t d | d ƒ j d d ƒ } | j d ƒ r¡ | |  d <nx| j d ƒ D]þ } | j d d ƒ d | k r|  d rð |  d c d 7<n  |  d c | 7<q± | j d ƒ r± | j d d ƒ d } d | k s@d | k rp|  d r]|  d c d 7<n  |  d c d 7<q¯| d  k r¯|  d r™|  d c d 7<n  |  d c d! 7<q¯q± q± Wd" S(#   s`  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)
        t   SHELLt   LANGUAGEt   LANGt   LC_CTYPEt
   LC_COLLATEt   LC_TIMEt
   LC_NUMERICt   LC_MONETARYt   LC_MESSAGESt   LC_PAPERt   LC_NAMEt
   LC_ADDRESSt   LC_TELEPHONEt   LC_MEASUREMENTt   LC_IDENTIFICATIONt   LOCPATHRQ   t   ProcEnvirons   /proc/s   /environs   
s   \ns   Error:R“   t   =i   i    s   PATH=s   /homes   /tmps   PATH=(custom, user)sG   /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/gamess   PATH=(custom, no user)N(   Ry   R¯   R   R   Rx   R    Rž   (   RZ   R   R¸   t	   safe_varst   envR¢   R|   (    (    s1   /usr/lib/python2.7/dist-packages/apport/report.pyR²   ~  s4    

 


c   
      C   sn  |  j  d ƒ s d St } t } z1t |  d d ƒ rq t j ƒ  \ } } t j | |  d ƒ t j | ƒ t } n  |  d j	 ƒ  d } d d | | g } y. t
 j | d t
 j d	 t
 j d
 t
 j ƒ} Wn t k
 rÚ t SX| j j d ƒ | j j d ƒ | j j d ƒ | j j d ƒ | j j ƒ  }	 | j ƒ  d k } | rO|	 |  d <n  Wd | rit j | ƒ n  X| S(   sW   Add information from kernel crash.

        This needs a VmCore in the Report.
        t   VmCoreNt   findRv   i   t   crashs   /usr/lib/debug/boot/vmlinux-%st   stdinR    R!   s	   bt -a -f
s   ps
s   runq
s   quit
i    t
   Stacktrace(   R3   t   Falset   hasattrt   tempfilet   mkstempRy   t   writet   closeR&   Rž   R#   R$   R%   t   STDOUTR   RÒ   R    R   t   waitRR   (
   RZ   t   debugdirt   unlink_coret   rett   fdt   coret   kverR)   R|   R,   (    (    s1   /usr/lib/python2.7/dist-packages/apport/report.pyt   add_kernel_crash_info¦  s@    				c         C   s%  |  j  d ƒ s  |  j  d ƒ r$ d St } zNt |  d d ƒ r| t j ƒ  \ } } t } t j | |  d ƒ t j | ƒ nc t |  d d ƒ rÑ t j ƒ  \ } } t } t j | ƒ |  d j t	 | d ƒ ƒ n |  d d } i d d	 6d
 d 6d d 6d d 6d d 6} d d g } |  j
 d |  d ƒ } | r_| d d | d d | g 7} | d | } n  | d d | d d | g 7} | d d g 7} g  } x= | j ƒ  D]/ \ }	 }
 | j |	 ƒ | d d d |
 g 7} q Wt j j | ƒ sët ‚ y t | ƒ } Wn t k
 rd SXt j d t j ƒ } | j | ƒ } | j d ƒ x3 | D]+ } | j d d ƒ j ƒ  |  | j d ƒ <qHWWd | r‘t j | ƒ n  Xd |  k rt j d  |  d ƒ } | rû| j d! ƒ |  d <|  d j d" ƒ r|  d d d# !|  d <qq|  d =n  |  j  d ƒ r!|  j ƒ  n  d S($   sR  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, 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.
        t   CoreDumpRb   NRÐ   t	   gzipvaluet   wi    s   info registerst	   Registerss	   x/16i $pct   Disassemblys   bt fullRÓ   s   thread apply all bt fullt   ThreadStacktraces   print (char*) __abort_msgt   AssertionMessaget   gdbs   --batchR—   s   --exs)   set debug-file-directory %s/usr/lib/debugs   set solib-absolute-prefix t   /s   file s
   core-file s   set backtrace limit 2000s   p -99s   ^\$\d+\s*=\s*-99$s   

s   
.
s(   ^\$\d+\s+=\s+0x[0-9a-fA-F]+\s+"(.*)"\s*$i   s   \niþÿÿÿ(   R3   RÔ   RÕ   RÖ   R×   R&   Ry   RØ   RÙ   R   t   gett	   iteritemst   appendR   R¶   R·   R.   R   R0   t   compilet	   MULTILINERž   t   popRx   R   RR   t   matcht   groupt   endswitht   _gen_stacktrace_top(   RZ   t   rootdirRÝ   Rß   Rà   t   gdb_reportsR)   t
   executablet
   value_keysRˆ   t   cmdR,   t   part_ret   partst   partt   m(    (    s1   /usr/lib/python2.7/dist-packages/apport/report.pyt   add_gdb_infoÏ  sn     
-	
c         C   sž  t  d d d d d d d g ƒ } d g d	 } d
 } t } t } t j d ƒ } t j d ƒ } x |  d j ƒ  D]} | j | ƒ }	 |	 s¨ | j | ƒ }	 |	 s¨ qo q¨ n  | sµ | r<|	 j d ƒ rí |	 j d ƒ j ƒ  d
 j d ƒ d
 }
 n d }
 |	 j d ƒ s|
 | k r3t	 } d
 } d g d	 } t	 } qo q<t } n  | t
 | ƒ k  ro |	 j d ƒ pi|	 j d ƒ | | <| d 7} qo qo Wd j | ƒ j ƒ  |  d <d S(   sä   Build 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.
        t   g_logvt   g_logt	   IA__g_logt
   IA__g_logvt   g_assert_warningt   IA__g_assert_warningt
   __GI_abortRQ   i   i    sD   ^#(\d+)\s+(?:0x(?:\w+)\s+in\s+\*?(.*)|(<signal handler called>)\s*)$s0   ^#(\d+)\s+(?:(.*)|(<signal handler called>)\s*)$RÓ   i   t   (i   i   s   
t   StacktraceTopN(   Rn   RÔ   R0   Rï   R   Rò   Ró   Rž   R4   R&   RŸ   R_   R   (   RZ   t   unwind_functionst   toptracet   deptht   unwoundt	   unwindingt   bt_fn_ret   bt_fn_noaddr_ret   lineRþ   t   fn(    (    s1   /usr/lib/python2.7/dist-packages/apport/report.pyRõ   ,  s:    	)	"c         C   s  i  } x² t  j  t d ƒ D] } yb t | | ƒ y | d |  | ƒ Wn9 t k
 r€ } | j j d ƒ rz | d |  ƒ q ‚  n XWq t k
 r– t St j	 d | ƒ t
 j ƒ  q Xq W| sÓ |  j d ƒ } n  | r¢d t | j ƒ  d f } t j j | ƒ r¢yb t | | ƒ y | d |  | ƒ Wn9 t k
 re} | j j d ƒ r_| d |  ƒ qf‚  n XWqŸt k
 r{t St j	 d | ƒ t
 j ƒ  qŸXq¢n  | sº|  j d ƒ } n  | r‰d	 t | j ƒ  d f } t j j | ƒ r‰yb t | | ƒ y | d |  | ƒ Wn9 t k
 rL} | j j d ƒ rF| d |  ƒ qM‚  n XWq†t k
 rbt St j	 d | ƒ t
 j ƒ  q†Xq‰n  t S(
   s¤  Run hook script for collecting package specific data.

        A hook script needs to be in _hook_dir/<Package>.py or in
        _common_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.
        s   /*.pyt   add_infos
   add_info()s   hook %s crashed:Re   s   %s/%s.pyi    Rf   s   %s/source_%s.py(   t   globt   _common_hook_dirt   execfilet	   TypeErrort   messageR    t   StopIterationR&   Ri   t   errort	   tracebackt	   print_excRì   t	   _hook_dirRž   Ry   R   R¶   RÔ   (   RZ   t   uiR   t
   srcpackaget   symbt   hookR   (    (    s1   /usr/lib/python2.7/dist-packages/apport/report.pyt   add_hooks_infoU  sn    




c         C   s[   | s
 d Sy t  j | ƒ j ƒ  } Wn d SXd | k r> d St |  | ƒ } | rW | Sd S(   s  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>
        Ns   <title>404 Not Found(   t   urllibt   urlopenR   RP   R4   (   RZ   R/   RO   (    (    s1   /usr/lib/python2.7/dist-packages/apport/report.pyt   search_bug_patterns¨  s    c         C   sÊ   t  j j t ƒ } t  j | t  j ƒ s@ t  j j | ƒ d k ra t j j	 ƒ  j
 d d d ƒ } nK y t j j j | ƒ } Wn/ t k
 r« } t d t t | ƒ f ƒ ‚ n X| j j ƒ  t | j ƒ | S(   s¾   Read 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.
        i    Ri   s   %s has invalid format: %sN(   Ry   R   t
   expandusert   _ignore_fileR˜   R™   t   getsizeR7   R8   t   getDOMImplementationt   createDocumentR4   RL   t   parseR    R   R   t   documentElementR=   RT   (   RZ   t   ifpathR8   R   (    (    s1   /usr/lib/python2.7/dist-packages/apport/report.pyt   _get_ignore_domÑ  s    .! c         C   sB  |  j  d ƒ s t ‚ y xx t j t ƒ D]g } y t t j j t | ƒ ƒ } Wn t k
 rc q( n Xx( | D]  } | j	 ƒ  |  d k rk t
 Sqk Wq( WWn t k
 r§ n X|  j ƒ  } y  t t j |  d ƒ j ƒ } Wn t k
 rè t SXxR | j d ƒ D]A } | j d ƒ |  d k rù t | j d ƒ ƒ | k r:t
 Sqù qù Wt S(   sH  Check if current report should not be presented.

        Reports can be suppressed by per-user blacklisting in
        ~/.apport-ignore.xml (in the real UID's home) and
        /etc/apport/blacklist.d/.

        This requires the ExecutablePath attribute. Throws a ValueError if the
        file has an invalid format.
        Rb   t   ignoret   programt   mtime(   R3   R·   Ry   t   listdirt   _blacklist_dirR   R   R_   R   R   R&   R   R-  R°   t   statt   st_mtimeRÔ   RN   t   getAttributet   float(   RZ   t   fRß   R  R8   t	   cur_mtimeR.  (    (    s1   /usr/lib/python2.7/dist-packages/apport/report.pyt   check_ignoredé  s,    
 c         C   s	  |  j  d ƒ s t ‚ |  j ƒ  } t t t j |  d ƒ j ƒ ƒ } x‡ | j d ƒ D]3 } | j	 d ƒ |  d k rS | j
 d | ƒ PqS qS W| j d ƒ } | j
 d |  d ƒ | j
 d | ƒ | j j | ƒ | j t t j j t ƒ d ƒ d d d d	 ƒ| j ƒ  d
 S(   s>  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.
        Rb   R.  R/  R0  Rå   t	   addindents     t   newls   
N(   R3   R·   R-  R   R°   Ry   R3  R4  RN   R5  t   setAttributet   createElementR+  t   appendChildt   writexmlR   R   R%  R&  RR   (   RZ   R8   R0  R.  R   (    (    s1   /usr/lib/python2.7/dist-packages/apport/report.pyt   mark_ignore  s    
"!c         C   s   |  j  d ƒ s t Sg  |  d j ƒ  D] } | j d ƒ ^ q$ } t | ƒ d k  rd | j t ƒ d k S| j t ƒ t | ƒ d k S(   s  Check 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.
        R  s   ??i   i    g       @(   Rì   RÔ   R   R    RŸ   t   countR&   (   RZ   R7  t
   unknown_fn(    (    s1   /usr/lib/python2.7/dist-packages/apport/report.pyt   has_useful_stacktrace3  s    ,c         C   sÕ  |  j  d ƒ d k rU |  j d ƒ rU |  j d ƒ rU d t j j |  d ƒ |  d f S|  j d ƒ rž|  j d ƒ rž|  j d ƒ rži d d 6d	 d 6d
 d 6d d 6d d 6} d } xK |  d j ƒ  D]9 } | j d ƒ d j ƒ  } | d k rÂ d | } PqÂ qÂ Wd } |  j d ƒ rX|  j d ƒ rX|  d |  d k rX|  d d k rXd |  d } n  d t j j |  d ƒ | j  |  j  d ƒ d |  j  d ƒ ƒ | | f S|  j d ƒ ri|  j d ƒ ri|  d j ƒ  } t | ƒ d k  râd; St | ƒ d k  rd t j j |  d ƒ | d f St
 j d ƒ } t | ƒ d } d  }	 xU | d k r’| j | | ƒ }
 |
 r…|
 j d ƒ } |
 j d! ƒ }	 Pn  | d 8} q>Wt j j |  d ƒ } | d" } | j d# ƒ d } t
 j d$ t
 j | ƒ | ƒ }
 |
 rý|
 j d ƒ } n d; } |	 d% k r1| |  d k r(d& } q;| } n
 d' |	 } d( | | | f } | re| d) | 7} n  | S|  j  d* ƒ d+ k rÍ|  j d+ ƒ rÍd, |  d+ } |  j  d- ƒ rÉ| d. |  d- j ƒ  d" 7} n  | S|  j  d* ƒ d/ k r=|  j d0 ƒ r=|  d0 } | j d1 ƒ r#| j d2 d! ƒ d } n | j d2 d ƒ d } | S|  j  d* ƒ d/ k rÑ|  j d3 ƒ rÑd } d4 |  k rŒ| d5 |  d4 d6 7} n  | |  d3 d7 7} d8 |  k rÃ| d9 |  d8 d: 7} n  | d2 7} | Sd; S(<   sZ  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.
        t   Signalt   6Rb   Ré   s   %s assert failure: %sR  t   SIGILLt   4t   SIGABRTt   SIGFPEt   8t   SIGSEGVt   11t   SIGPIPEt   13RQ   R  i    s   ??s    in %s()Rw   Rg   t   alls    [non-native %s package]s   %s crashed with %s%s%ss   signal t	   Tracebacki   i   s   %s crashed with %ss   ^\s*File\s*"(\S+)".* in (.+)$t   unknowni   iÿÿÿÿt   :s
   ^%s: (.+)$s   <module>t   __main__s   %s()s   %s crashed with %s in %ss   : %sRc   Re   s$   package %s failed to install/upgradet   ErrorMessages   : t
   KernelOopst   OopsTexts$   ------------[ cut here ]------------s   
t   Failuret   MachineTypet   [s   ] s    failuret   NonfreeKernelModuless    [non-free: t   ]N(   Rì   R3   Ry   R   Rš   R   Rž   R   RŸ   R4   R0   Rï   Rò   Ró   t   escapeR    (   RZ   t   signal_namesR  R¢   t   fnamet   arch_mismatcht   tracet   trace_reRŽ   t   functionRþ   t   module_pathR   t	   last_linet	   exceptionR  t   contextt   titlet   oops(    (    s1   /usr/lib/python2.7/dist-packages/apport/report.pyt   standard_titleD  s¾    


		



c         C   s¾   g  } x± |  j  d d ƒ d |  j  d d ƒ j ƒ  D]ƒ } | sE q3 n  | j ƒ  d  \ } } t j | ƒ } | d k r3 | d k r3 | d k r3 t j | | ƒ d k  r3 | j | ƒ q3 q3 W| S(	   s=   Return list of obsolete packages in Package and Dependencies.Re   RQ   s   
Rh   i   R4   i    N(   Rì   R   Rž   R
   t   get_available_versionR4   t   compare_versionsRî   (   RZ   t   obsoleteR¢   t   pkgt   vert   avail(    (    s1   /usr/lib/python2.7/dist-packages/apport/report.pyt   obsolete_packagesÕ  s    3$c   	   
   C   s£  |  j  d ƒ r% |  d d k r% d S|  j  d ƒ r§ |  d d k r§ d } t j d ƒ } xG |  d j ƒ  D]5 } | j | ƒ } | rj | d | j d ƒ 7} qj qj W| S|  j d	 ƒ d
 k rô |  j  d ƒ rô |  d d |  d } t j d d | ƒ S|  j  d ƒ r¶|  j  d	 ƒ r¶d |  d |  d	 f } t j d ƒ } |  d j ƒ  } t	 | ƒ d k  r_d SxP | D]H } | j | ƒ } | rª| d | j d ƒ p¢| j d ƒ 7} qfd SqfW| S|  j  d ƒ rŸ|  d j ƒ  } d } t	 | ƒ d k r)t j d | d ƒ } | r"|  d d | j d ƒ Sd Sn t	 | ƒ d k  r?d Sx8 | D]0 } | j
 d ƒ rF| d | j ƒ  d 7} qFqFW|  d d | d j d ƒ d | Sd S(   sˆ  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.

        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.
        Rb   Rc   Rd   RÓ   t   kernels   ^\s*\#\d+\s\[\w+\]\s(\w+)RR  i   RD  RE  Ré   s   0x[0-9a-f]{6,}t   ADDRR  s   %s:%ss.   ^(?:([\w:~]+).*|(<signal handler called>)\s*)$i   RP  RQ   s   (\w+): i    i   s     FileiÿÿÿÿN(   R3   R4   R0   Rï   R   Rò   Ró   Rì   t   subRŸ   R    Rž   (	   RZ   t   sigt   regexR  Rþ   R  t   linesR`  R¢   (    (    s1   /usr/lib/python2.7/dist-packages/apport/report.pyt   crash_signatureã  sR    $)%c         C   s”  i  } t  j ƒ  d k r® t j t  j ƒ  ƒ } t | d ƒ d k rT d | | d <n  d | | d <xI | d j d ƒ D]1 } | j ƒ  } t | ƒ d k rv d | | <qv qv Wn  t  j ƒ  d	 } t | ƒ d k rÝ d
 | | <n  y |  d =Wn t k
 rû n Xx‘ |  D]‰ } | j	 d ƒ r$| d k s<d | k s<| d k rxM | j
 ƒ  D]< \ } } t |  | d ƒ rI|  | j | | ƒ |  | <qIqIWqqWd S(   sú   Remove 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.
        i    i   t   usernames   /home/usernamei   i   t   ,s	   User Namei   t   hostnameR–   t   Proct   ProcCpuinfoR¨   R‘   t   ProcInterruptst   ProcModulesRÓ   RP  t
   PythonArgst   isspaceN(   R|  s   ProcMapss
   ProcStatusR}  R~  (   s	   Tracebacks
   PythonArgs(   Ry   R‚   R€   R   RŸ   Rž   R   Rz   t   KeyErrorR    Rí   RÕ   Rx   (   RZ   t   replacementsR|   t   sRz  R£   t   oldt   new(    (    s1   /usr/lib/python2.7/dist-packages/apport/report.pyt	   anonymize0  s4    	N(   t   __name__t
   __module__t   __doc__R4   RY   Ra   Rs   R~   RŒ   R§   Rº   R²   Râ   Rÿ   Rõ   R!  R$  R-  R9  R@  RC  Ri  Rp  Rw  R†  (    (    (    s1   /usr/lib/python2.7/dist-packages/apport/report.pyRV   ”   s,   	6			8@()]	)S	)		)	!		‘		M(   t   StringIOt   _Tc           B   sæ   e  Z d  „  Z d „  Z d „  Z d „  Z d „  Z d „  Z e d d d d „ ƒ Z
 d	 „  Z d
 „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   c         C   sb  t  j d ƒ } t ƒ  } |  j t | j d ƒ | j d ƒ |  j | d d | j ƒ  ƒ |  j | d d ƒ |  j d | d k ƒ t ƒ  } |  j t	 | j ƒ d | d	 <| j ƒ  |  j | d d | j ƒ  ƒ |  j | d d ƒ |  j d | d k ƒ |  j d
 | d k ƒ |  j | j
 d ƒ ƒ t ƒ  } d | d	 <| j ƒ  |  j | j
 d ƒ ƒ d S(   s   add_package_info().R   t   nonexistant_packageRe   s   bash Rf   t   libcRh   s	   /bin/bashRb   s   

Rg   s   /nonexistingN(   R
   R   RV   t   assertRaisesR   Rs   t   assertEqualR   t
   assertTrueR  R3   (   RZ   t   bashversiont   pr(    (    s1   /usr/lib/python2.7/dist-packages/apport/report.pyt   test_add_package_infob  s(    		

	

c         C   se   t  ƒ  } | j ƒ  |  j | d j d ƒ ƒ |  j t | d ƒ t d ƒ k ƒ |  j | d ƒ d S(   s   add_os_info().Rv   t   LinuxRu   RQ   Rw   N(   RV   R~   R  R    R[   (   RZ   R’  (    (    s1   /usr/lib/python2.7/dist-packages/apport/report.pyt   test_add_os_info  s
    	
#c         C   s   t  ƒ  } | j ƒ  |  j | j d ƒ ƒ x7 | d j ƒ  D]% } |  j t j | ƒ j d k  ƒ q: W|  j t j t	 j
 ƒ  ƒ j | d k ƒ d S(   s   add_user_info().R   iè  N(   RV   RŒ   R  R3   Rž   R„   t   getgrnamt   gr_gidt   getgrgidRy   t   getgidt   gr_name(   RZ   R’  t   g(    (    s1   /usr/lib/python2.7/dist-packages/apport/report.pyt   test_add_user_infoŠ  s    	
#c      
   C   sa  t  j j d ƒ s t d ‚ t  j j d ƒ s6 t d ‚ t  j j d ƒ sQ t d ‚ t ƒ  } |  j | j d1 ƒ | j ƒ  |  j | j t  j	 ƒ  ƒ |  j
 t d d d	 d g ƒ j t | j ƒ  ƒ ƒ d
 ƒ |  j
 d t  j d | d k ƒ |  j
 d | d k ƒ |  j
 d | d k ƒ t ƒ  } | j d d g ƒ |  j
 d | d k ƒ |  j
 d t  j d | d k ƒ t  j ƒ  d k s‡t d ‚ t ƒ  } |  j t | j d ƒ |  j | j d ƒ |  j
 d | d k | d ƒ |  j
 | d j d ƒ | d ƒ |  j
 | j d ƒ ƒ t j d d d d d g d t j d t j d t j d t ƒ} | j s]t ‚ x* t d | j ƒ j ƒ  s‰t j d ƒ q`Wt ƒ  } | j d  | j ƒ |  j | j | j ƒ | j d! ƒ |  j | d	 d" ƒ |  j | d# d$ ƒ |  j
 | j d ƒ ƒ |  j
 d$ | d k ƒ |  j
 d% | d k ƒ t  j j d& ƒ sQt d' ‚ t j d( g d t j d t ƒ} | j st ‚ x* t d | j ƒ j ƒ  s­t j d ƒ q„Wt ƒ  } | j | _ | j ƒ  | j d) ƒ |  j | j d ƒ | j d ƒ ƒ |  j | d# t  j j d& ƒ ƒ t j d* d+ g d t j d t ƒ} | j sOt ‚ x* t d | j ƒ j ƒ  s{t j d ƒ qRWt ƒ  } | j d  | j ƒ | j d! ƒ |  j
 | d# j  d, ƒ ƒ |  j | d t  j j t | d# ƒ j! ƒ  j" ƒ  d- ƒ ƒ |  j
 d% | d k ƒ t# j$ ƒ  \ } } t  j% | d. ƒ t  j& | ƒ t  j' | d/ ƒ t j | g d t j d t j d t ƒ} | j sˆt ‚ x* t d | j ƒ j ƒ  s´t j d ƒ q‹Wt ƒ  } | j d  | j ƒ | j d! ƒ t  j( | ƒ |  j | d# | ƒ |  j
 d0 | d k ƒ |  j
 d0 | d k ƒ |  j
 d% | d k ƒ |  j t) | j | j ƒ d1 S(2   s   add_proc_info().R½   s   please set $LANG for this testt   USERs   please set $USER for this testt   PWDs   $PWD is not setRË   R¨   R’   s   report has required fieldss   LANG=R¸   s   PWD=i    s3   please do not run this test as root for this check.i   t   initR‘   s   Error:R—   t   cats   /foo bars   \hs   \ \R”   RÒ   R    R!   R"   s   /proc/%i/cmdlinegš™™™™™¹?R   s   
s   cat /foo\ bar \\h \\\ \\ -Rb   s   /bin/cats   [stack]s   /bin/shs+   /bin/sh needs to be a symlink for this testR   s   exit
t   zgrept   foos	   bin/zgrepi   s2   #!/usr/bin/python
import sys
sys.stdin.readline()
ií  t   pythonN(*   Ry   t   environR3   R·   RV   R  R   R4   Rº   R¯   R  Rn   t   issubsett   keysR‚   RŽ  R   R    R#   R$   R%   R&   R   R   t   timet   sleepR'   R   t   islinkt   assertFalseRì   R¡   Rô   t   readlineR   RÖ   R×   RØ   RÙ   t   chmodRR   R   (   RZ   R’  R|   Rß   t
   testscript(    (    s1   /usr/lib/python2.7/dist-packages/apport/report.pyt   test_add_proc_info–  s¢    	
%"	"	!			
" 		-		c         C   sl  t  j d g d t  j d i d d 6ƒ} t j d ƒ t ƒ  } | j d | j ƒ | j d ƒ |  j	 d | d	 k d
 ƒ t  j d g d t  j d i d d 6ƒ} t j d ƒ t ƒ  } | j d | j ƒ | j d ƒ |  j
 d | d	 k d ƒ t  j d g d t  j d i d d 6ƒ} t j d ƒ t ƒ  } | j d | j ƒ | j d ƒ |  j
 d | d	 k d ƒ d S(   s   classification of $PATH.R   RÒ   RÎ   sG   /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/gamest   PATHgš™™™™™¹?R   RQ   RË   s+   system default $PATH should be filtered outs   /usr/sbin:/usr/bin:/sbin:/bins   PATH=(custom, no user)s%   PATH is customized without user pathss)   /home/pitti:/usr/sbin:/usr/bin:/sbin:/bins   PATH=(custom, user)s"   PATH is customized with user pathsN(   R#   R$   R%   R§  R¨  RV   R²   R   R'   Rª  R  (   RZ   R|   t   r(    (    s1   /usr/lib/python2.7/dist-packages/apport/report.pyt   test_add_path_classification  s0    			c         C   s	  t  j ƒ  } t ƒ  } d | d <d | d <d | j | d <| j ƒ  |  j | d d ƒ |  j | j d ƒ ƒ | j ƒ  t ƒ  } d | d <d	 | d <d
 | d <| j ƒ  |  j | d d ƒ |  j | j d ƒ ƒ t ƒ  } d | d <d | d <d | d <| j ƒ  |  j | d d ƒ |  j | d d ƒ t ƒ  } d | d <d | d <d | d <| j ƒ  |  j | d d ƒ |  j | d d ƒ t ƒ  } d | d <d | d <d | d <| j ƒ  |  j | d d ƒ |  j | d d ƒ t ƒ  } d | d <d | d <d | d <| j ƒ  |  j | d d ƒ |  j | d d ƒ t ƒ  } d | d <d	 | d <d | d <| j ƒ  |  j | d d ƒ |  j | j d ƒ ƒ t ƒ  } d | d <d	 | d <d | d <| j ƒ  |  j | d d ƒ |  j | d d ƒ t ƒ  } d | d <d | d <d | d <| j ƒ  |  j | d d ƒ |  j | j d ƒ ƒ t ƒ  } d | d <d | d <d | d <| j ƒ  |  j | d d ƒ |  j | d d ƒ t ƒ  } d | d <d | d <d | d <| j ƒ  |  j | d d ƒ |  j | j d ƒ ƒ t ƒ  } d | d <d | d <d | d <| j ƒ  |  j | d d ƒ |  j | d d ƒ t ƒ  } d | d <d | d <d  | d <| j ƒ  |  j | d d ƒ |  j | d d ƒ t ƒ  } d! | d <d | d <d" | d <| j ƒ  |  j | d d! ƒ |  j | d d ƒ d# S($   s   _check_interpreted().s   /usr/bin/geditRb   s   Name:	geditR‘   t   gedit /R’   R—   s	   /bin/dashs   Name:	znonexistingt   nonexisting /foos   Name:	zgreps   /bin/sh /bin/zgrep foos
   /bin/zgreps
   Name:	dashs   /usr/bin/monot   zgrep --debug /bin/zgrept   zgrep /bin/zgreps   /usr/bin/pythont   python /etc/shadowt   python /etc/passwds   /etc/passwds   Name:	shadows   ../etc/shadows   Name:	passwds   ../etc/passwds   /bin/../etc/passwds   Name:	pythonR£  s
   Name:	basht   python /bin/bashs	   /bin/basht   python -OO /bin/bashs   /usr/bin/python2.7s   /usr/bin/python /bin/bashN(	   RÖ   t   NamedTemporaryFileRV   Rˆ   R§   R  Rª  R3   RÙ   (   RZ   R7  R’  (    (    s1   /usr/lib/python2.7/dist-packages/apport/report.pyt   test_check_interpreted#  sÈ    	



	



	



	



	



	



	



	



	



	



	



	



	



	



RL  sS   
int f(x) {
    int* p = 0; *p = x;
    return x+1;
}
int main() { return f(42); }
c         C   s‘  d } t j ƒ  } t ƒ  } zat j ƒ  } t j t j	 | ƒ t j
 | ƒ t d d ƒ j | ƒ t j d d d d d g ƒ d k sŠ t ‚ t j j d ƒ s¢ t ‚ t j d d	 d
 d d
 d d g d t j ƒt j j d ƒ så t ‚ t j d d d g d t j ƒd k st ‚ t j j | d ƒ | d <t j j | d ƒ f | d <| | d <| j ƒ  | r{| j | ƒ | j ƒ  n  Wd t j
 | ƒ X| S(   s  Create a test executable which will die with a SIGSEGV, generate a
        core dump for it, create a problem report with those two arguments
        (ExecutablePath and CoreDump) and call add_gdb_info().

        If file is given, the report is written into it. Return the Report.s   crash.cRå   t   gccs   -gs   -oRÑ   i    Rê   s   --batchs   --ext   runs   generate-core-file cores   ./crashR    Rà   t   readelfs   -nRb   Rã   RD  N(   R4   Ry   t   getcwdRV   RÖ   t   mkdtempt   atexitt   registert   shutilt   rmtreet   chdirR   RØ   R#   t   callR·   R   R¶   R%   R_   Rÿ   t   flush(   t   klasst   filet   signalt   codet   workdirt   orig_cwdR’  (    (    s1   /usr/lib/python2.7/dist-packages/apport/report.pyt   _generate_sigsegv_report¨  s0    	*

c         C   s[  |  j  | j d ƒ ƒ |  j  | j d ƒ ƒ |  j  | j d ƒ ƒ |  j  | j d ƒ ƒ |  j  | j d ƒ ƒ |  j  d | d k ƒ |  j  d | d k | d ƒ |  j  t j d | d ƒ ƒ |  j  d	 | d k ƒ |  j  d
 | d k ƒ |  j  d	 | d k ƒ |  j  d
 | d k ƒ |  j  d | d k ƒ |  j  t | d j ƒ  ƒ d k ƒ d  S(   NRÓ   Rè   R  Ræ   Rç   s   (no debugging symbols found)s   Core was generated bys   (?s)(^|.*\n)#0  [^\n]+\n#0  s   #0  0xs   #1  0xs
   Thread 1 (i   (   R  R3   R0   Rò   RŸ   R   (   RZ   R’  (    (    s1   /usr/lib/python2.7/dist-packages/apport/report.pyt   _validate_gdb_fields×  s    c         C   s®   t  ƒ  } | j ƒ  |  j ƒ  } |  j | ƒ |  j | d d | d ƒ |  j d | k ƒ |  j d d ƒ } |  j | ƒ |  j d | d k | d ƒ |  j d | k ƒ d S(	   s-   add_gdb_info() with core dump file reference.R  s*   f (x=42) at crash.c:3
main () at crash.c:6Ré   RË  sR   
int main() {
    void     (*function)(void);
    function = 0;
    function();
}
s#   Cannot access memory at address 0x0Rç   N(   RV   Rÿ   RÎ  RÏ  R  Rª  R  (   RZ   R’  (    (    s1   /usr/lib/python2.7/dist-packages/apport/report.pyt   test_add_gdb_infoè  s    	
		c         C   s`   t  j ƒ  } |  j | ƒ | j d ƒ t ƒ  } | j t | j ƒ ƒ | j ƒ  |  j	 | ƒ d S(   s%   add_gdb_info() with inline core dump.i    N(
   RÖ   Rº  RÎ  t   seekRV   t   loadR   Rˆ   Rÿ   RÏ  (   RZ   t   repR’  (    (    s1   /usr/lib/python2.7/dist-packages/apport/report.pyt   test_add_gdb_info_load  s    	
c         C   s-  t  j ƒ  } |  j | ƒ | j d ƒ t ƒ  } | j t | j ƒ ƒ d | d <| j d ƒ |  j	 d | j
 ƒ  k ƒ t ƒ  } | j t | j ƒ ƒ | j d ƒ |  j	 d | d k | d ƒ | j ƒ  | j d ƒ |  j	 d | d k | d ƒ | j ƒ  | j d ƒ |  j	 d | d k | d ƒ d	 S(
   s$   parse-segv produces sensible resultsi    t   1RD  t   fake_uit   SegvAnalysiss.   Skipped: missing required field "Architecture"s*   Skipped: missing required field "ProcMaps"s!   not located in a known VMA regionN(   RÖ   Rº  RÎ  RÑ  RV   RÒ  R   Rˆ   R!  R  R¦  R~   Rº   (   RZ   RÓ  R’  (    (    s1   /usr/lib/python2.7/dist-packages/apport/report.pyt   test_add_zz_parse_segv_details  s*    	
	

c         C   sX  t  j ƒ  \ } } t j j t j j | ƒ d ƒ } t j j | ƒ sL t ‚ z¶ t j | ƒ t	 | d ƒ j
 d ƒ t j | d ƒ t j | g ƒ d k s  t ‚ t j d d | g d t j ƒd k sÍ t ‚ t ƒ  } d	 | d
 <| | d <| f | d <| j ƒ  Wd t j | ƒ t j | ƒ X|  j | ƒ |  j d | d k pPd | d k ƒ d S(   s   add_gdb_info() with a script.Rà   Rå   s>   #!/bin/bash
cd `dirname $0`
ulimit -c unlimited
kill -SEGV $$
ií  i    R¾  s   -nR    s	   /bin/bashR—   Rb   Rã   Ns   libc.soRÓ   s   in execute_command(   RÖ   R×   Ry   R   R_   t   dirnameR¶   R·   RÙ   R   RØ   R¬  R#   RÆ  R%   RV   Rÿ   RR   RÏ  R  (   RZ   Rß   t   scriptt   coredumpR’  (    (    s1   /usr/lib/python2.7/dist-packages/apport/report.pyt   test_add_gdb_info_script*  s(    !	

c         C   s_  t  j ƒ  \ } } t j j d ƒ s+ t ‚ z­ t j | ƒ t | d ƒ j d ƒ t j	 | d ƒ t
 j | g ƒ d k s t ‚ t
 j d d d g d t
 j ƒd k s¬ t ‚ t ƒ  } | d	 | d
 <d | d <| j ƒ  Wd t j | ƒ t j | d	 ƒ t j d ƒ X|  j | ƒ |  j d | d k | d ƒ |  j | d j d ƒ | d ƒ |  j d | d k | d ƒ |  j | d j d ƒ | d ƒ t  j ƒ  \ } } t j j d ƒ s½t ‚ z­ t j | ƒ t | d ƒ j d ƒ t j	 | d ƒ t
 j | g ƒ d k st ‚ t
 j d d d g d t
 j ƒd k s>t ‚ t ƒ  } | d	 | d
 <d | d <| j ƒ  Wd t j | ƒ t j | d	 ƒ t j d ƒ X|  j | ƒ |  j d | | d k | d ƒ |  j | d j d ƒ | d ƒ |  j d | d k | d ƒ |  j | d j d ƒ | d ƒ t  j ƒ  \ } } t j j d ƒ sSt ‚ z­ t j | ƒ t | d ƒ j d ƒ t j	 | d ƒ t
 j | g ƒ d k s§t ‚ t
 j d d d g d t
 j ƒd k sÔt ‚ t ƒ  } | d	 | d
 <d | d <| j ƒ  Wd t j | ƒ t j | d	 ƒ t j d ƒ X|  j | ƒ |  j d | k | j d ƒ ƒ d S(   s½   add_gdb_info() with SIGABRT/assert()

        If these come from an assert(), the report should have the assertion
        message. Otherwise it should be marked as not reportable.
        Rà   Rå   s‚   #!/bin/sh
gcc -o $0.bin -x c - <<EOF
#include <assert.h>
int main() { assert(1 < 0); }
EOF
ulimit -c unlimited
$0.bin 2>/dev/null
ií  i    R¾  s   -nR    s   .binRb   Rã   Ns*   <stdin>:2: main: Assertion `1 < 0' failed.Ré   t   $s   = 0xs   \ns   #!/bin/sh
gcc -O2 -D_FORTIFY_SOURCE=2 -o $0.bin -x c - <<EOF
#include <string.h>
int main(int argc, char *argv[]) {
    char buf[8];
    strcpy(buf, argv[1]);
    return 0;
}
EOF
ulimit -c unlimited
LIBC_FATAL_STDERR_=1 $0.bin aaaaaaaaaaaaaaaa 2>/dev/null
s2   ** buffer overflow detected ***: %s.bin terminateds|   #!/bin/sh
gcc -o $0.bin -x c - <<EOF
#include <stdlib.h>
int main() { abort(); }
EOF
ulimit -c unlimited
$0.bin 2>/dev/null
(   s   core(   s   core(   s   core(   RÖ   R×   Ry   R   R¶   R·   RÙ   R   RØ   R¬  R#   RÆ  R%   RV   Rÿ   RR   RÏ  R  Rª  R    Rô   Rì   (   RZ   Rß   RÚ  R’  (    (    s1   /usr/lib/python2.7/dist-packages/apport/report.pyt   test_add_gdb_info_abortL  s‚    	
	!!	
!!	
c         C   s  t  j d d ƒ } | j d ƒ | j ƒ  t  j d d ƒ } | j d ƒ | j ƒ  t ƒ  } d | d <d | d <t ƒ  } d	 | d <d | d
 <d | d <t ƒ  } d | d <d | d <t ƒ  } d | d <|  j | j | j ƒ d ƒ d | d <|  j | j | j ƒ d ƒ |  j | j | j ƒ d ƒ |  j | j | j ƒ d ƒ | j ƒ  } t	 j
 d ƒ | d <|  j | j | j ƒ d ƒ d | d <|  j | j | j ƒ d* ƒ d | d <|  j | j | j ƒ d* d ƒ d | d <|  j | j | j ƒ d* d ƒ d | d <|  j | j | j ƒ d* d ƒ d | d
 <|  j | j | j ƒ d* d ƒ d | d <|  j | j | j ƒ d* d  ƒ | d =|  j | j | j ƒ d* d! ƒ |  j | j | j ƒ d* d" ƒ d# | d <|  j | j d$ ƒ d* d% ƒ |  j | j d& ƒ d* d' ƒ |  j | j d( ƒ d* d) ƒ d* S(+   s   search_bug_patterns().t   prefixs   apport-s  <?xml version="1.0"?>
<patterns>
    <pattern url="http://bugtracker.net/bugs/1">
        <re key="Package">^bash </re>
        <re key="Foo">ba.*r</re>
    </pattern>
    <pattern url="http://bugtracker.net/bugs/2">
        <re key="Package">^bash 1-2$</re>
        <re key="Foo">write_(hello|goodbye)</re>
    </pattern>
    <pattern url="http://bugtracker.net/bugs/3">
        <re key="Package">^coreutils </re>
        <re key="Bar">^1$</re>
    </pattern>
    <pattern url="http://bugtracker.net/bugs/4">
        <re key="Package">^coreutils </re>
        <re key="Bar">*</re> <!-- invalid RE -->
    </pattern>
    <pattern url="http://bugtracker.net/bugs/5">
        <re key="SourcePackage">^bazaar$</re>
        <re key="LogFile">AssertionError</re>
    </pattern>
</patterns>s!   <?xml version="1.0"?>
</patterns>s   bash 1-2Re   t   bazaart   Foos
   bazaar 2-1Rf   R·   t   LogFiles   coreutils 1RÕ  t   Bars	   invalid 1s   http://bugtracker.net/bugs/1t   write_goodbyes   http://bugtracker.net/bugs/2s   http://bugtracker.net/bugs/3s   http://bugtracker.net/bugs/5s   bash-static 1-2s	   bash 1-21s$   does not match on wrong bash versiont   zzs!   does not match on wrong Foo valueRL  s!   does not match on wrong Bar valuet	   launchpads&   does not match on wrong source packageRQ   s!   does not match on empty attributes!   does not match on nonexisting keys   gracefully handles invalid XMLs   other 2s   file:///nonexisting/directory/s(   gracefully handles nonexisting base paths   http://security.ubuntu.com/s1   gracefully handles base path without bug patternss   http://nonexisting.domain/s)   gracefully handles nonexisting URL domainN(   RÖ   Rº  RØ   RÇ  RV   R  R$  Rˆ   t   copyRB   RC   R4   (   RZ   RO   t   invalidt   r_basht   r_bazaart   r_coreutilst	   r_invalidt   r_bash_compressed(    (    s1   /usr/lib/python2.7/dist-packages/apport/report.pyt   test_search_bug_patternsÄ  sr    

	

	


	

	








c         C   sÌ  t  } t j ƒ  a  t } t j ƒ  a zzt t j j t  d ƒ d ƒ j d ƒ t t j j t d ƒ d ƒ j d ƒ t t j j t d ƒ d ƒ j d ƒ t t j j t d ƒ d ƒ j d	 ƒ t t j j t d
 ƒ d ƒ j d ƒ t	 ƒ  } d | d <|  j
 | j d ƒ t ƒ |  j
 t | j ƒ  ƒ t d d d d d d g ƒ d ƒ t	 ƒ  } d | d <|  j
 | j d ƒ t ƒ |  j
 t | j ƒ  ƒ t d d d d d d g ƒ d ƒ t	 ƒ  } d | d <|  j
 | j d ƒ t ƒ |  j
 t | j ƒ  ƒ t d d d d d d d d g ƒ d ƒ |  j
 | d d ƒ |  j
 | d d ƒ |  j
 | d d ƒ |  j
 | d d ƒ |  j
 | d d ƒ t	 ƒ  } d | d <|  j
 | j d ƒ t ƒ |  j
 t | j ƒ  ƒ t d d d d d d d d g ƒ d ƒ |  j
 | d d ƒ |  j
 | d d ƒ |  j
 | d d ƒ |  j
 | d d ƒ d | d <|  j
 | j d ƒ t ƒ t	 ƒ  } d  | d <|  j
 | j d ƒ t ƒ t t j j t  d! ƒ d ƒ j d" ƒ t	 ƒ  } d | d# <d$ | d <|  j
 | j d ƒ t ƒ |  j
 t | j ƒ  ƒ t d d d d# d d d d d g	 ƒ d ƒ |  j
 | d d ƒ |  j
 | d d ƒ |  j
 | d d ƒ |  j
 | d d ƒ |  j
 | d d ƒ d% | d <|  j
 | j d ƒ t ƒ Wd& t j t  ƒ t j t ƒ | a  | a Xd& S('   s   add_hooks_info().s   foo.pyRå   s¢   
import sys
def add_info(report):
    report['Field1'] = 'Field 1'
    report['Field2'] = 'Field 2\nBla'
    if 'Spethial' in report:
        raise StopIteration
s   foo1.pysŽ   
def add_info(report):
    report['CommonField1'] = 'CommonField 1'
    if report['Package'] == 'commonspethial':
        raise StopIteration
s   foo2.pysD   
def add_info(report):
    report['CommonField2'] = 'CommonField 2'
s   foo3.pys@   
def add_info(report, ui):
    report['CommonField3'] = str(ui)
t   notmes6   
def add_info(report):
    report['BadField'] = 'XXX'
t   barRe   RÖ  Rc   t   Datet   CommonField1t   CommonField2t   CommonField3s   report has required fieldss	   baz 1.2-3R¢  t   Field1t   Field2s   Field 1s   Field 2
Blas   CommonField 1s   CommonField 2s	   foo 4.5-6RÕ  t   Spethialt   commonspethials   source_foo.pys¦   
def add_info(report, ui):
    report['Field1'] = 'Field 1'
    report['Field2'] = 'Field 2\nBla'
    if report['Package'] == 'spethial':
        raise StopIteration
Rf   s   libfoo 3t   spethialN(   R  RÖ   RÀ  R  R   Ry   R   R_   RØ   RV   R  R!  RÔ   Rn   R¦  R&   RÃ  RÄ  (   RZ   t   orig_hook_dirt   orig_common_hook_dirR°  (    (    s1   /usr/lib/python2.7/dist-packages/apport/report.pyt   test_add_hooks_info)  s’    	
	
	
	

	
	


c         C   sœ  t  } t j ƒ  } t j j | d ƒ a  zZt t j j | d ƒ d ƒ j d ƒ t t j j | d ƒ d ƒ j d ƒ t ƒ  } t j j | d ƒ | d <t ƒ  } t j j | d ƒ | d <t ƒ  } t j j | d ƒ | d <|  j	 | j
 ƒ  t ƒ |  j	 | j
 ƒ  t ƒ |  j	 | j
 ƒ  t ƒ | j ƒ  |  j	 | j
 ƒ  t ƒ |  j	 | j
 ƒ  t ƒ |  j	 | j
 ƒ  t ƒ | j ƒ  |  j	 | j
 ƒ  t ƒ |  j	 | j
 ƒ  t ƒ |  j	 | j
 ƒ  t ƒ t j d ƒ t t j j | d ƒ d ƒ j d ƒ |  j	 | j
 ƒ  t ƒ |  j	 | j
 ƒ  t ƒ |  j	 | j
 ƒ  t ƒ t t  d ƒ j d	 ƒ |  j	 | j
 ƒ  t ƒ |  j	 | j
 ƒ  t ƒ |  j	 | j
 ƒ  t ƒ Wd
 t j | ƒ | a  Xd
 S(   s"   mark_ignore() and check_ignored().s
   ignore.xmlR   Rå   t   crapRb   t   cpi   t   crapnewRQ   N(   R&  RÖ   RÀ  Ry   R   R_   R   RØ   RV   R  R9  RÔ   R@  R&   R§  R¨  RÃ  RÄ  (   RZ   t   orig_ignore_fileRÌ  t   bash_rept   crap_rept   cp_rep(    (    s1   /usr/lib/python2.7/dist-packages/apport/report.pyt   test_ignoring  sD    %%			

%c         C   s­  t  } t j ƒ  a  t } d a znt ƒ  } d | d <t ƒ  } d | d <|  j | j ƒ  t ƒ |  j | j ƒ  t ƒ t t	 j
 j t  d ƒ d ƒ j d ƒ t t	 j
 j t  d ƒ d ƒ j d	 ƒ |  j | j ƒ  t ƒ |  j | j ƒ  t ƒ t t	 j
 j t  d
 ƒ d ƒ j d ƒ |  j | j ƒ  t ƒ |  j | j ƒ  t ƒ t t	 j
 j t  d ƒ d ƒ j d ƒ |  j | j ƒ  t ƒ |  j | j ƒ  t ƒ Wd t j t  ƒ | a  | a Xd S(   s*   check_ignored() for system-wise blacklist.s   /nonexistants	   /bin/bashRb   s	   /bin/crapt   READMERå   s   # Ignore file
#/bin/bash
t   bl1s"   /bin/bas
/bin/bashh
bash
bin/bash
t   bl_2s
   /bin/crap
t   as
   /bin/bash
N(   R2  RÖ   RÀ  R&  RV   R  R9  RÔ   R   Ry   R   R_   RØ   R&   RÃ  RÄ  (   RZ   t   orig_blacklist_dirR   R  R  (    (    s1   /usr/lib/python2.7/dist-packages/apport/report.pyt   test_blacklistingÑ  s8    	
	
c         C   s%  t  ƒ  } |  j | j ƒ  ƒ d | d <|  j | j ƒ  ƒ d | d <|  j | j ƒ  ƒ d | d <|  j | j ƒ  ƒ d | d <|  j | j ƒ  ƒ d | d <|  j | j ƒ  ƒ d | d <|  j | j ƒ  ƒ d | d <|  j | j ƒ  ƒ d	 | d <|  j | j ƒ  ƒ d
 | d <|  j | j ƒ  ƒ d S(   s   has_useful_stacktrace().RQ   R  s   ?? ()s   ?? ()
?? ()s!   read () from /lib/libc.6.so
?? ()s-   read () from /lib/libc.6.so
?? ()
?? ()
?? ()s=   read () from /lib/libc.6.so
foo (i=1) from /usr/lib/libfoo.sosC   read () from /lib/libc.6.so
foo (i=1) from /usr/lib/libfoo.so
?? ()sI   read () from /lib/libc.6.so
foo (i=1) from /usr/lib/libfoo.so
?? ()
?? ()sO   read () from /lib/libc.6.so
?? ()
foo (i=1) from /usr/lib/libfoo.so
?? ()
?? ()N(   RV   Rª  RC  R  (   RZ   R°  (    (    s1   /usr/lib/python2.7/dist-packages/apport/report.pyt   test_has_useful_stacktraceþ  s(    	








c         C   s  t  ƒ  } |  j | j ƒ  d3 ƒ d | d <d | d <d | d <|  j | j ƒ  d ƒ d | d <|  j | j ƒ  d	 ƒ d
 | d <|  j | j ƒ  d ƒ d | d <|  j | j ƒ  d	 ƒ d | d <|  j | j ƒ  d ƒ d | d <d | d <d | d <|  j | j ƒ  d ƒ t  ƒ  } d | d <d | d <|  j | j ƒ  d ƒ t  ƒ  } d | d <d | d <|  j | j ƒ  d ƒ t  ƒ  } d | d <d | d <|  j | j ƒ  d ƒ t  ƒ  } d | d <d | d <| j ƒ  } |  j | j d ƒ ƒ |  j | j d ƒ ƒ t  ƒ  } d | d <d | d <|  j | j ƒ  d ƒ t  ƒ  } d  | d <d! | d <|  j | j ƒ  d" ƒ t  d# ƒ } d$ | d# <|  j | j ƒ  d% ƒ d
 | d& <|  j | j ƒ  d% ƒ d' | d& <|  j | j ƒ  d( ƒ d | d <d | d <d | d <d) | d* <d) | d+ <|  j | j ƒ  d ƒ d, | d* <|  j | j ƒ  d- ƒ d. | d* <|  j | j ƒ  d ƒ t  d/ ƒ } d0 | d1 <|  j | j ƒ  d2 ƒ d3 S(4   s   standard_title().RL  RD  s	   /bin/bashRb   s   foo()
bar(x=3)
baz()
R  s"   bash crashed with SIGSEGV in foo()t   42s$   bash crashed with signal 42 in foo()RQ   s   bash crashed with signal 42s
   ??()
foo()s	   ??()
??()RE  s   foo.c:42 main: i > 0Ré   s)   bash assert failure: foo.c:42 main: i > 0s   /usr/share/apport/apport-gtksA  Traceback (most recent call last):
File "/usr/share/apport/apport-gtk", line 202, in <module>
app.run_argv()
File "/var/lib/python-support/python2.5/apport/ui.py", line 161, in run_argv
self.run_crashes()
File "/var/lib/python-support/python2.5/apport/ui.py", line 104, in run_crashes
self.run_crash(f)
File "/var/lib/python-support/python2.5/apport/ui.py", line 115, in run_crash
response = self.ui_present_crash(desktop_entry)
File "/usr/share/apport/apport-gtk", line 67, in ui_present_crash
subprocess.call(['pgrep', '-x',
NameError: global name 'subprocess' is not definedRP  s`   apport-gtk crashed with NameError in ui_present_crash(): global name 'subprocess' is not defineds|   TypeError: Cannot create a consistent method resolution
order (MRO) for bases GObject, CanvasGroupableIface, CanvasGroupablesO   apport-gtk crashed with TypeError: Cannot create a consistent method resolutionsk   Traceback (most recent call last):
  File "/x/foo.py", line 242, in setup_chooser
    raise "Moo"
Mo?o[a-1]s4   apport-gtk crashed with Mo?o[a-1] in setup_chooser()s  Traceback (most recent call last):
  File "/x/foo.py", line 242, in setup_chooser
    raise "
Key: "+key+" isn't set.
Restarting AWN usually solves this issue
"
 
Key: /apps/avant-window-navigator/app/active_png isn't set.
Restarting AWN usually solves this issues   apport-gtk crashed withs   setup_chooser()s   /usr/bin/gnome-aboutsí   Traceback (most recent call last):
  File "/usr/bin/gnome-about", line 30, in <module>
    import pygtk
  File "/usr/lib/pymodules/python2.6/pygtk.py", line 28, in <module>
    import nonexistent
ImportError: No module named nonexistent
sj   gnome-about crashed with ImportError in /usr/lib/pymodules/python2.6/pygtk.py: No module named nonexistents   /usr/bin/dcuts   Traceback (most recent call last):
  File "/usr/bin/dcut", line 28, in <module>
    import nonexistent
ImportError: No module named nonexistent
sF   dcut crashed with ImportError in __main__: No module named nonexistentRe   R   s&   package bash failed to install/upgradeRT  s   botched
not found
s1   package bash failed to install/upgrade: not foundt   amd64Rg   Rw   t   i386s<   bash crashed with SIGSEGV in foo() [non-native i386 package]RO  RU  s_   ------------[ cut here ]------------
kernel BUG at /tmp/oops.c:5!
invalid opcode: 0000 [#1] SMPRV  s   kernel BUG at /tmp/oops.c:5!N(   RV   R  Ri  R4   R  R    Rô   (   RZ   RF   t   t(    (    s1   /usr/lib/python2.7/dist-packages/apport/report.pyt   test_standard_title  s     	









	

	

	

	

	

	












c         C   s(  t  ƒ  } |  j | j ƒ  g  ƒ d | d <|  j | j ƒ  d g ƒ d | d <|  j | j ƒ  d g ƒ d t j d ƒ | d <|  j | j ƒ  g  ƒ d | d <|  j | j ƒ  d d	 g ƒ d
 t j d ƒ | d <|  j | j ƒ  d	 g ƒ d t j d ƒ t j d	 ƒ f | d <|  j | j ƒ  g  ƒ d S(   s   obsolete_packages().s   bash 0Re   R   s   bash 0 [modified: /bin/bash]s   bash s   coreutils 0
cron 0
Rh   t	   coreutilst   crons+   coreutils %s [modified: /bin/mount]
cron 0
s   coreutils %s
cron %s
N(   RV   R  Rp  R
   Rj  (   RZ   RF   (    (    s1   /usr/lib/python2.7/dist-packages/apport/report.pyt   test_obsolete_packagesÀ  s"    	


c         C   s[  t  ƒ  } d | d <| j ƒ  |  j | d d ƒ t  ƒ  } d | d <| j ƒ  |  j | d d ƒ t  ƒ  } d | d <| j ƒ  |  j | d d ƒ t  ƒ  } d | d <| j ƒ  |  j | d d ƒ t  ƒ  } d	 | d <| j ƒ  |  j | d d
 ƒ t  ƒ  } d | d <| j ƒ  |  j | d d ƒ t  ƒ  } d | d <| j ƒ  |  j | d d ƒ d S(   s   _gen_stacktrace_top().s   #0  0x10000488 in h (p=0x0) at crash.c:25
#1  0x100004c8 in g (x=1, y=42) at crash.c:26
#2  0x10000514 in f (x=1) at crash.c:27
#3  0x10000530 in e (x=1) at crash.c:28
#4  0x10000530 in d (x=1) at crash.c:29
#5  0x10000530 in c (x=1) at crash.c:30
#6  0x10000550 in main () at crash.c:31
RÓ   R  su   h (p=0x0) at crash.c:25
g (x=1, y=42) at crash.c:26
f (x=1) at crash.c:27
e (x=1) at crash.c:28
d (x=1) at crash.c:29s  #0 h (p=0x0) at crash.c:25
#1  0x100004c8 in g (x=1, y=42) at crash.c:26
#2 f (x=1) at crash.c:27
#3  0x10000530 in e (x=1) at crash.c:28
#4  0x10000530 in d (x=1) at crash.c:29
#5  0x10000530 in c (x=1) at crash.c:30
#6  0x10000550 in main () at crash.c:31
s  #0  0x10000488 in raise () from /lib/libpthread.so.0
#1  0x100004c8 in ??
#2  <signal handler called>
#3  0x10000530 in e (x=1) at crash.c:28
#4  0x10000530 in d (x=1) at crash.c:29
#5  0x10000530 in c (x=1) at crash.c:30
#6  0x10000550 in main () at crash.c:31
sW   e (x=1) at crash.c:28
d (x=1) at crash.c:29
c (x=1) at crash.c:30
main () at crash.c:31sê   #0  0x10000488 in raise () from /lib/libpthread.so.0
#1  ??
#2  <signal handler called>
#3  0x10000530 in e (x=1) at crash.c:28
#4  d (x=1) at crash.c:29
#5  0x10000530 in c (x=1) at crash.c:30
#6  0x10000550 in main () at crash.c:31
sW  #0  0x10000488 in raise () from /lib/libpthread.so.0
#1  0x100004c8 in ??
#2  <signal handler called>
#3  0x10000530 in e (x=1) at crash.c:28
#4  0x10000530 in d (x=1) at crash.c:29
#5  0x10000123 in raise () from /lib/libpthread.so.0
#6  <signal handler called>
#7  0x10000530 in c (x=1) at crash.c:30
#8  0x10000550 in main () at crash.c:31
s|   e (x=1) at crash.c:28
d (x=1) at crash.c:29
raise () from /lib/libpthread.so.0
<signal handler called>
c (x=1) at crash.c:30sW  #0  0xb7d39cab in IA__g_logv (log_domain=<value optimized out>, log_level=G_LOG_LEVEL_ERROR, 
    format=0xb7d825f0 "file %s: line %d (%s): assertion failed: (%s)", args1=0xbfee8e3c "xxx") at /build/buildd/glib2.0-2.13.5/glib/gmessages.c:493
#1  0xb7d39f29 in IA__g_log (log_domain=0xb7edbfd0 "libgnomevfs", log_level=G_LOG_LEVEL_ERROR, 
    format=0xb7d825f0 "file %s: line %d (%s): assertion failed: (%s)") at /build/buildd/glib2.0-2.13.5/glib/gmessages.c:517
#2  0xb7d39fa6 in IA__g_assert_warning (log_domain=0xb7edbfd0 "libgnomevfs", file=0xb7ee1a26 "gnome-vfs-volume.c", line=254, 
    pretty_function=0xb7ee1920 "gnome_vfs_volume_unset_drive_private", expression=0xb7ee1a39 "volume->priv->drive == drive")
    at /build/buildd/glib2.0-2.13.5/glib/gmessages.c:552
No locals.
#3  0xb7ec6c11 in gnome_vfs_volume_unset_drive_private (volume=0x8081a30, drive=0x8078f00) at gnome-vfs-volume.c:254
        __PRETTY_FUNCTION__ = "gnome_vfs_volume_unset_drive_private"
#4  0x08054db8 in _gnome_vfs_volume_monitor_disconnected (volume_monitor=0x8070400, drive=0x8078f00) at gnome-vfs-volume-monitor.c:963
        vol_list = (GList *) 0x8096d30
        current_vol = (GList *) 0x8097470
#5  0x0805951e in _hal_device_removed (hal_ctx=0x8074da8, udi=0x8093be4 "/org/freedesktop/Hal/devices/volume_uuid_92FC9DFBFC9DDA35")
    at gnome-vfs-hal-mounts.c:1316
        backing_udi = <value optimized out>
#6  0xb7ef1ead in filter_func (connection=0x8075288, message=0x80768d8, user_data=0x8074da8) at libhal.c:820
        udi = <value optimized out>
        object_path = 0x8076d40 "/org/freedesktop/Hal/Manager"
        error = {name = 0x0, message = 0x0, dummy1 = 1, dummy2 = 0, dummy3 = 0, dummy4 = 1, dummy5 = 0, padding1 = 0xb7e50c00}
#7  0xb7e071d2 in dbus_connection_dispatch (connection=0x8075288) at dbus-connection.c:4267
#8  0xb7e33dfd in ?? () from /usr/lib/libdbus-glib-1.so.2sï  gnome_vfs_volume_unset_drive_private (volume=0x8081a30, drive=0x8078f00) at gnome-vfs-volume.c:254
_gnome_vfs_volume_monitor_disconnected (volume_monitor=0x8070400, drive=0x8078f00) at gnome-vfs-volume-monitor.c:963
_hal_device_removed (hal_ctx=0x8074da8, udi=0x8093be4 "/org/freedesktop/Hal/devices/volume_uuid_92FC9DFBFC9DDA35")
filter_func (connection=0x8075288, message=0x80768d8, user_data=0x8074da8) at libhal.c:820
dbus_connection_dispatch (connection=0x8075288) at dbus-connection.c:4267sî   #0  0x00987416 in __kernel_vsyscall ()
No symbol table info available.
#1  0x00ebecb1 in *__GI_raise (sig=6)
        selftid = 945
#2  0x00ec218e in *__GI_abort () at abort.c:59
        save_stage = Unhandled dwarf expression opcode 0x9f
RQ   N(   RV   Rõ   R  (   RZ   R°  (    (    s1   /usr/lib/python2.7/dist-packages/apport/report.pyt   test_gen_stacktrace_topÚ  sD    	

	

	

	

	


	

	

c         C   se  t  ƒ  } |  j | j ƒ  d ƒ d | d <d | d <d | d <|  j | j ƒ  d ƒ d | d <|  j | j ƒ  d ƒ d	 | d <|  j | j ƒ  d ƒ | d =d
 | d <|  j | j ƒ  d ƒ d | d <|  j | j ƒ  d ƒ d | d <|  j | j ƒ  d ƒ d | d <d | d <|  j | j ƒ  d ƒ t  ƒ  } d | d <d | d <d | d <|  j | j ƒ  d ƒ d S(   s   crash_signature().R  RD  s
   /bin/crashRb   s   foo_bar (x=1) at crash.c:28
d01 (x=1) at crash.c:29
raise () from /lib/libpthread.so.0
<signal handler called>
__frob::~frob (x=1) at crash.c:30R  sE   /bin/crash:42:foo_bar:d01:raise:<signal handler called>:__frob::~frobst   foo_bar (x=1) at crash.c:28
??
raise () from /lib/libpthread.so.0
<signal handler called>
__frob (x=1) at crash.c:30RQ   sû   Traceback (most recent call last):
  File "test.py", line 7, in <module>
    print(_f(5))
  File "test.py", line 5, in _f
    return g_foo00(x+1)
  File "test.py", line 2, in g_foo00
    return x/0
ZeroDivisionError: integer division or modulo by zeroRP  s0   /bin/crash:ZeroDivisionError:<module>:_f:g_foo00s7   TypeError: function takes exactly 0 arguments (1 given)s   /bin/crash:TypeErrort   FooBarRd   Rc   sß  
crash 4.0-8.9
GNU gdb 6.1
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i686-pc-linux-gnu"...

      KERNEL: /usr/lib/debug/boot/vmlinux-2.6.31-2-generic
    DUMPFILE: /tmp/tmpRJZy_O
        CPUS: 1
        DATE: Thu Jul  9 12:58:08 2009
      UPTIME: 00:00:57
LOAD AVERAGE: 0.15, 0.05, 0.02
       TASKS: 173
    NODENAME: egon-desktop
     RELEASE: 2.6.31-2-generic
     VERSION: #16-Ubuntu SMP Mon Jul 6 20:38:51 UTC 2009
     MACHINE: i686  (2137 Mhz)
      MEMORY: 2 GB
       PANIC: "[   57.879776] Oops: 0002 [#1] SMP " (check log for details)
         PID: 0
     COMMAND: "swapper"
        TASK: c073c180  [THREAD_INFO: c0784000]
         CPU: 0
       STATE: TASK_RUNNING (PANIC)

PID: 0      TASK: c073c180  CPU: 0   COMMAND: "swapper"
 #0 [c0785ba0] sysrq_handle_crash at c03917a3
    [RA: c03919c6  SP: c0785ba0  FP: c0785ba0  SIZE: 4]
    c0785ba0: c03919c6  
 #1 [c0785ba0] __handle_sysrq at c03919c4
    [RA: c0391a91  SP: c0785ba4  FP: c0785bc8  SIZE: 40]
    c0785ba4: c06d4bab  c06d42d2  f6534000  00000004  
    c0785bb4: 00000086  0000002e  00000001  f6534000  
    c0785bc4: c0785bcc  c0391a91  
 #2 [c0785bc8] handle_sysrq at c0391a8c
    [RA: c0389961  SP: c0785bcc  FP: c0785bd0  SIZE: 8]
    c0785bcc: c0785c0c  c0389961  
 #3 [c0785bd0] kbd_keycode at c038995c
    [RA: c0389b8b  SP: c0785bd4  FP: c0785c10  SIZE: 64]
    c0785bd4: c056f96a  c0785be4  00000096  c07578c0  
    c0785be4: 00000001  f6ac6e00  f6ac6e00  00000001  
    c0785bf4: 00000000  00000000  0000002e  0000002e  
    c0785c04: 00000001  f70d6850  c0785c1c  c0389b8b  
 #4 [c0785c10] kbd_event at c0389b86
    [RA: c043140c  SP: c0785c14  FP: c0785c20  SIZE: 16]
    c0785c14: c0758040  f6910900  c0785c3c  c043140c  
 #5 [c0785c20] input_pass_event at c0431409
    [RA: c04332ce  SP: c0785c24  FP: c0785c40  SIZE: 32]
    c0785c24: 00000001  0000002e  00000001  f70d6000  
    c0785c34: 00000001  0000002e  c0785c64  c04332ce  
 #6 [c0785c40] input_handle_event at c04332c9
    [RA: c0433ac6  SP: c0785c44  FP: c0785c68  SIZE: 40]
    c0785c44: 00000001  ffff138d  0000003d  00000001  
    c0785c54: f70d6000  00000001  f70d6000  0000002e  
    c0785c64: c0785c84  c0433ac6  
 #7 [c0785c68] input_event at c0433ac1
    [RA: c0479806  SP: c0785c6c  FP: c0785c88  SIZE: 32]
    c0785c6c: 00000001  00000092  f70d677c  f70d70b4  
    c0785c7c: 0000002e  f70d7000  c0785ca8  c0479806  
 #8 [c0785c88] hidinput_hid_event at c0479801
    [RA: c0475b31  SP: c0785c8c  FP: c0785cac  SIZE: 36]
    c0785c8c: 00000001  00000007  c0785c00  f70d6000  
    c0785c9c: f70d70b4  f70d5000  f70d7000  c0785cc4  
    c0785cac: c0475b31  
    [RA: 0  SP: c0785ffc  FP: c0785ffc  SIZE: 0]
   PID    PPID  CPU   TASK    ST  %MEM     VSZ    RSS  COMM
>     0      0   0  c073c180  RU   0.0       0      0  [swapper]
      1      0   1  f7038000  IN   0.1    3096   1960  init
      2      0   0  f7038c90  IN   0.0       0      0  [kthreadd]
    271      2   1  f72bf110  IN   0.0       0      0  [bluetooth]
    325      2   1  f71c25b0  IN   0.0       0      0  [khungtaskd]
   1404      2   0  f6b5bed0  IN   0.0       0      0  [kpsmoused]
   1504      2   1  f649cb60  IN   0.0       0      0  [hd-audio0]
   2055      1   0  f6a18000  IN   0.0    1824    536  getty
   2056      1   0  f6a1d7f0  IN   0.0    1824    536  getty
   2061      1   0  f6a1f110  IN   0.1    3132   1604  login
   2062      1   1  f6a18c90  IN   0.0    1824    540  getty
   2063      1   1  f6b58c90  IN   0.0    1824    540  getty
   2130      1   0  f6b5f110  IN   0.0    2200   1032  acpid
   2169      1   0  f69ebed0  IN   0.0    2040    664  syslogd
   2192      1   1  f65b3ed0  IN   0.0    1976    532  dd
   2194      1   1  f6b5a5b0  IN   0.1    3996   2712  klogd
   2217      1   0  f6b74b60  IN   0.1    3008   1120  dbus-daemon
   2248      1   0  f65b7110  IN   0.2    6896   4304  hald
   2251      1   1  f65b3240  IN   0.1   19688   2604  console-kit-dae
RUNQUEUES[0]: c6002320
 RT PRIO_ARRAY: c60023c0
 CFS RB_ROOT: c600237c
  PID: 9      TASK: f703f110  CPU: 0   COMMAND: "events/0"
RÓ   sŽ   kernel:sysrq_handle_crash:__handle_sysrq:handle_sysrq:kbd_keycode:kbd_event:input_pass_event:input_handle_event:input_event:hidinput_hid_eventRE  s	   /bin/bashs   foo.c:42 main: i > 0Ré   s   /bin/bash:foo.c:42 main: i > 0N(   RV   R  Rw  R4   (   RZ   R°  (    (    s1   /usr/lib/python2.7/dist-packages/apport/report.pyt   test_crash_signature]	  s2    	








]
	


c         C   sç   t  ƒ  } d | d <d | d <d | d <| d | d <d | d	 <| j ƒ  t ƒ  } | j | ƒ | j d
 ƒ t  ƒ  } | j | d d ƒt | d d ƒ s¡ t ‚ |  j | j	 ƒ  t
 ƒ |  j | j ƒ  d ƒ |  j | j ƒ  d ƒ d S(   s#   methods get along with binary data.RL  RD  s   /bin/fooRb   sV   #0  0x10000488 in h (p="   ") at crash.c:25
#1  0x10000550 in main () at crash.c:31
RÓ   Rè   t   python -OO	 /bin/bashR’   i    t   binaryt
   compressedR  RD   s   /bin/foo:11:h:mains   foo crashed with SIGSEGV in h()N(   RV   Rõ   RŠ  RØ   RÑ  RÒ  RÕ   R·   R  RC  R&   Rw  Ri  (   RZ   R’  t   io(    (    s1   /usr/lib/python2.7/dist-packages/apport/report.pyt   test_binary_dataõ	  s     	




		N(   R‡  Rˆ  R“  R•  Rœ  R®  R±  R»  t   classmethodR4   RÎ  RÏ  RÐ  RÔ  RØ  RÜ  RÞ  Rî  Rü  R  R
  R  R  R  R  R  R  (    (    (    s1   /usr/lib/python2.7/dist-packages/apport/report.pyR‹  a  s2   					l	!	…(					"	x	e	t	4	-	!	¡		ƒ	˜RS  (9   R‰  R#   RÖ   t   os.pathRy   R"  R0   R€   R„   t   sysR   R  RÁ  R  R´   t   xml.domR7   t   xml.dom.minidomt   xml.parsers.expatR    RB   Ri   t   apport.fileutilst   apport.packaging_implR   R
   R¤  Rì   t	   _data_dirR  R  R&  R2  Rœ   R   R   R   R4   RÚ   R.   RK   RP   RT   RX   RV   t   unittestRÃ  RÊ  R§  t	   cStringIORŠ  t   ImportErrorR  t   TestCaseR‹  R‡  t   main(    (    (    s1   /usr/lib/python2.7/dist-packages/apport/report.pyt   <module>   sN   l<

		
				ÿ ÿ ÿ Ê0ÿ ÿ ÿ ÿ ÿ ²