Your IP : 172.28.240.42


Current Path : /usr/lib/python2.7/dist-packages/apport/
Upload File :
Current File : //usr/lib/python2.7/dist-packages/apport/report.pyc


Yc@sdZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlZddlmZddlZddlZddlZddlmZejjddZdeZdeZd	Zd
Z dZ!dd
dddddddddgZ"dZ#dZ$dZ%dej'dZ(dZ)dZ*dZ+dej,fdYZ-dS( s;Representation of and data collection for a problem report.iN(t
ExpatError(timpltAPPORT_DATA_DIRs/usr/share/apports%s/package-hooks/s%s/general-hooks/s~/.apport-ignore.xmls/etc/apport/blacklist.ds/etc/apport/whitelist.dtshtbashtdashtcshttcshspython*sruby*tphpsperl*smono*tawkcCsmytj|Wntk
r%dSXx@tj|D]/}||kr6|j|t||q6q6WdS(s7Recursively add dependencies of package to depends_set.N(t	packagingtget_versiont
ValueErrortget_dependenciestaddt_transitive_dependencies(tpackagetdepends_settd((s1/usr/lib/python2.7/dist-packages/apport/report.pyR*s

cCsTy)t|}|jjSWdQXWn$ttfk
rO}dt|SXdS(sXRead file content.

    Return its content, or return a textual error if it failed.
    NsError: (topentreadtstriptOSErrortIOErrortstr(tpathtfdte((s1/usr/lib/python2.7/dist-packages/apport/report.pyt
_read_file6s
cCs`d}y/td|}|jj}WdQXWn$ttfk
r[}dt|SX|S(sRead /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/mapsNsError: (RRRRRR(tpidtmapsRR((s1/usr/lib/python2.7/dist-packages/apport/report.pyt
_read_mapsAscCstj|dtjd|dt}|j|\}}|jdkrL|S|rj|jddd}nd}td	t||j|fd
S(sRun command and capture its output.

    Try to execute given command (argv list) and return its stdout, or return
    a textual error if it failed.
    tstdouttstderrt	close_fdsisUTF-8terrorstreplacets.Error: command %s failed with exit code %i: %sN(	t
subprocesstPopentPIPEtTruetcommunicatet
returncodetdecodeRR(tcommandtinputR!tsptoutterr((s1/usr/lib/python2.7/dist-packages/apport/report.pyt_command_outputOs$cCs>|jjdsdSx|jD]}|jtjjjkr |j	dkr |jjdr |jdj
}||krdS|j|jr#|jdjtjjj
kr#|jdj
jd}yE||}t|tjr|j}ntj||sdSWq dSXq#q q W|jdj
jdS(sxCheck if given report matches the given bug pattern XML DOM node.

    Return the bug URL on match, otherwise None.
    turltretkeyisUTF-8N(t
attributesthas_keytNonet
childNodestnodeTypetxmltdomtNodetELEMENT_NODEtnodeNamet	nodeValuet	normalizet
hasChildNodest	TEXT_NODEtencodet
isinstancetproblem_reporttCompressedValuet	get_valueR4tsearch(treporttpatterntcR5tregexptv((s1/usr/lib/python2.7/dist-packages/apport/report.pyt_check_bug_patternbs*'

cCseytjjj|}Wntk
r-dSXx0|jdD]}t||}|r>|Sq>WdS(NRK(R;R<tminidomtparseStringRR8tgetElementsByTagNameRO(RJtpatternsR<RKR3((s1/usr/lib/python2.7/dist-packages/apport/report.pyt_check_bug_patternss
cCsixb|jD]W}|jtjjjkrW|jjdkrW|j|j	|q
t
|q
WdS(s6Recursively remove whitespace from given XML DOM node.R%N(R9R:R;R<R=RCR@RtunlinktremoveChildt_dom_remove_space(tnodeRL((s1/usr/lib/python2.7/dist-packages/apport/report.pyRWs
-
tReportcBs(eZdZdddZdZddZdZdZdZ	dZ
ed	Zdgd
Z
dgdZddZdd
ZdZdddZdZdZdZdZdZdZdZdZdZdZdZdZdZRS(sA problem report specific to apport (crash or bug).

    This class wraps a standard ProblemReport and adds methods for collecting
    standard debugging data.tCrashcCs,tjj|||d|_d|_dS(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(RFt
ProblemReportt__init__R8Rt_proc_maps_cache(tselfttypetdate((s1/usr/lib/python2.7/dist-packages/apport/report.pyR\s		cCsd}tj|}|r5|ddj|7}nyFtj|sztj|}|rm|d|7}qz|d7}nWntk
rnX|S(sReturn 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%s [modified: %s]t s
 [origin: %s]s [origin: unknown](R
tget_modified_filestjointis_distro_packagetget_package_originR(R^Rtsuffixtmodtorigin((s1/usr/lib/python2.7/dist-packages/apport/report.pyt_customized_package_suffixs
cCs|sRd|kr/|ddkr/|d}ntjj|d}|sRdSnytj|}Wntk
r~d}nXd||pd|j|f|d<|sd|krtj||d<n|sdStj	||d	<t
g}t||d
|d<xt|D]s}ytj|}Wntk
rIqnX|drg|dcd7<n|dcd|||j|f7<qWdS(
sAdd 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
        tExecutablePathtProblemTypetKernelCrashtPackageNs%s %s%ss(not installed)t
SourcePackagetPackageArchitectureR%tDependenciess
(
tapportt	fileutilstfind_file_packageR
RRR8Rit
get_sourcetget_architecturetsetRtsorted(R^RtversiontdependenciestdepRN((s1/usr/lib/python2.7/dist-packages/apport/report.pytadd_package_infos<







cCstjddgdtjdtjdt}|jdjjjdd|d	<tj	}d
|d|d|df|d
<t
j|d<dS(scAdd 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)
        tlsb_releases-sirR R!R"is
Rat
DistroReleases%s %s %siitUnametArchitectureN(R&R'R(R)R*R,RR$tostunameR
tget_system_architecture(R^tptu((s1/usr/lib/python2.7/dist-packages/apport/report.pytadd_os_infos
,#cCs|tjtjj}gtjD]0\}}}}||kr%|dkr%|^q%}|jdj||d<dS(soAdd information about the user.

        This adds:
        - UserGroups: system groups the user is in
        iRat
UserGroupsN(	tpwdtgetpwuidRtgetuidtpw_nametgrptgetgralltsortRc(R^tusertnameRtgidtmembtgroups((s1/usr/lib/python2.7/dist-packages/apport/report.pyt
add_user_infos
$
c
s d|krdStjj|dtfdtsBdSd}xa|djD]O}y|jdd\}}Wntk
rqYnX|dkrY|}PqYqYW|sdS|djd	}d
ddd
g}xt	|dkr|dj
dr|j
dr~|ddkr~t	|dkr~|j|d}|rh|d|d<||d<nd|d|d<dS|d=qWt	|dkr%|dj
drd|krtjj|d|d|d<ntj
|dtjr%|d|d<tjj|d|d<q%nd|kr|krtdg|D]}||d^qM}	|	rtjjtjj|	d|kr|d|d<|	d|d<qnd|krtjj|ddkr|d|d<|j}
|
r|
|d<qd|d<ndS(sCheck if process is a script.

        Use ExecutablePath, ProcStatus and ProcCmdline to determine if
        process is an interpreted script. If so, set InterpreterPath
        accordingly.
        RjNcstj|S(N(tfnmatch(ti(texebasename(s1/usr/lib/python2.7/dist-packages/apport/report.pyt<lambda>)st
ProcStatuss	isName:tProcCmdlinets/bin/s/sbin/s	/usr/bin/s
/usr/sbin/it-tpythons-mitInterpreterPaths)Cannot determine path of python module %stUnreportableReasont.tProcCwdcSstj|tjS(N(RtaccesstR_OK(R((s1/usr/lib/python2.7/dist-packages/apport/report.pyRUsittwistds&Cannot determine twistd client program(RRtbasenametfiltertinterpretersR8t
splitlinestsplitRtlent
startswitht_python_module_pathRcRRtrealpatht_twistd_executable(R^RtltkRNtcmdargstbindirsRRtargvexestexe((Rs1/usr/lib/python2.7/dist-packages/apport/report.pyt_check_interpretedsX
(1
$ -.(
cCs$|djdd}x|r|djdd}|djdso|djdso|djd	rt|dkr|dS|dSn{t|ddkr|ddd
kr|ddd
kr|dd}d|ksd|ksd
|kr|dSn|jdqWdS(s5Determine the twistd client program from ProcCmdline.RRiit=is--files--pythons--sourceRtftytsN(RRRtpopR8(R^targstargtopts((s1/usr/lib/python2.7/dist-packages/apport/report.pyRds	&>$cCs|jddjd}tj}d}x|r|jd}ytj||\}}}Wntk
r{d}PnX|r|j	n|g}|r-|dtj
kr-dg}q-q-W|r|jdr|d }n|S(	s%Determine path of given Python modulet/RiiR\s.pyciN(R$RtsysRR8Rtimptfind_moduletImportErrortcloset
PKG_DIRECTORYtendswith(tklasstmoduletpathlistRRRtdesc((s1/usr/lib/python2.7/dist-packages/apport/report.pyR{s$		

	
cCsu|s|jptj}n|js9t||_nt|}ytjd|d|d<Wntk
rwnX|j||td|d|d<td|dj	d|d<t
t||d	<ytjd|d
|d<Wn7tk
r/}|jtjkr)t
dq0nXxEdD]=}|djd|r7|dtd||d<Pq7q7Wtjj|dst|jtttj|dj|d<|djddjddjdd|d<yatjdkrVtd|d}|jj}WdQX|dkrV||d<qVnWnttfk
rpnXdS(sAdd /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
        - 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/cwdRs/statusRs/cmdlineRRtProcMapss/exeRjsinvalid processtrofstrwfst	squashmntt
persistmnts/%s/s/%stExecutableTimestamps\s\\Ras\ is
/attr/currentNt
unconfinedtProcAttrCurrent(RRRR(RRtgetpidtintRtreadlinkRtadd_proc_environRtrstripRterrnotENOENTRRRRtexiststAssertionErrorRtstattst_mtimeR$RRRRR(R^RtextraenvRRRtval((s1/usr/lib/python2.7/dist-packages/apport/report.pyt
add_proc_infosF	
!

&2cCsddddddddd	d
ddd
ddddg|}|sRtj}nt|}d|d<td|djdd}|jdr||d<nx|jdD]}|jddd|kr|dr|dcd7<n|dc|7<q|jdr|jddd}d|ksCd|krs|dr`|dcd7<n|dcd 7<q|d!kr|dr|dcd7<n|dcd"7<qqqWd#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)
        tSHELLtTERMtLANGUAGEtLANGtLC_CTYPEt
LC_COLLATEtLC_TIMEt
LC_NUMERICtLC_MONETARYtLC_MESSAGEStLC_PAPERtLC_NAMEt
LC_ADDRESStLC_TELEPHONEtLC_MEASUREMENTtLC_IDENTIFICATIONtLOCPATHR%tProcEnvirons/proc/s/environs
s\nsError:RRiisPATH=s/homes/tmpsPATH=(custom, user)sG/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/gamessPATH=(custom, no user)N(RRRRR$RR(R^RRt	safe_varstenvRR((s1/usr/lib/python2.7/dist-packages/apport/report.pyRs4

 



c
Cskd|krdSt}t}z1t|ddrntj\}}tj||dtj|t}n|djd}dd||g}y.t	j
|dt	jd	t	jd
t	j}Wnt
k
rtSX|jjd|jjd|jjd
|jjd|jj}	|jdk}|rL|	|d<nWd|rftj|nX|S(sWAdd information from kernel crash.

        This needs a VmCore in the Report.
        tVmCoreNtfindR~itcrashs/usr/lib/debug/boot/vmlinux-%ststdinR R!s	bt -a -f
sps
srunq
squit
it
Stacktrace(tFalsethasattrttempfiletmkstempRtwriteRR)RR&R'R(tSTDOUTRRR RtwaitRU(
R^tdebugdirtunlink_coretretRtcoretkverR-RR0((s1/usr/lib/python2.7/dist-packages/apport/report.pytadd_kernel_crash_infos@
				
cCsd|ksd|krdSt}zt|ddrttj\}}t}tj||dtj|nct|ddrtj\}}t}tj||djt|dn|dd}idd	6d
d6dd
6dd6dd6}ddg}|j	d|d}|rW|dd|dd|g7}|d|}n|dd|dd|g7}|ddg7}g}x=|j
D]/\}	}
|j|	|ddd|
g7}qWtjj
|styt|jddd}Wntk
rdSXd |ks/d!|krd"jg|jD]}d#|krB|^qB}
d$|
j}||d%<t|ntjd&tj}|j|}|jdx3|D]+}|jd'd(j||jd<qWWd|r
tj|nXd|krtjd)|d}|rw|jd*|d<|djd+r~|ddd,!|d<q~q|d=nd
|kr|j |j!}|r||d-<qndS(.sAdd 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.

        Raises a IOError if the core dump is invalid/truncated.
        tCoreDumpRjNRt	gzipvaluetwisinfo registerst	Registerss	x/16i $pctDisassemblysbt fullRsthread apply all bt fulltThreadStacktracesprint __abort_msg->msgtAssertionMessagetgdbs--batchRs--exs)set debug-file-directory %s/usr/lib/debugsset solib-absolute-prefix Rsfile s
core-file sset backtrace limit 2000sp -99sUTF-8R#R$s%is truncated: expected core file sizes+not a core dump: File format not recognizeds
sWarning:sInvalid core dump: Rs^\$\d+\s*=\s*-99$s

s
.
s(^\$\d+\s+=\s+0x[0-9a-fA-F]+\s+"(.*)"\s*$is\nitStacktraceAddressSignature("RRRRR)RRRRtgettitemstappendRRRR2R,RRcRRRR4tcompilet	MULTILINERRR$RUtmatchtgroupRt_gen_stacktrace_toptcrash_signature_addresses(R^trootdirRRRtgdb_reportsR-t
executablet
value_keysRtcmdR0Rtwarningstreasontpart_retpartstparttmtaddr_signature((s1/usr/lib/python2.7/dist-packages/apport/report.pytadd_gdb_info,s




4


-	


c	Cs3tddddddddg}d	gd
}d}t}t}t}tjd}tjd
}tjd}	x|djD]}
|j|
}|s|j|
}|sqqn|s|r|jdr|jdjdjdd}nd}|r;|j	ds|dkr2qq;t}n|jdsV||krt
}d}d	gd
}|jdrt
}n|dkrt
}qqqt}n|jdp|jd}
|
jd}|t|kr|	j|r|
||<|d7}qqWdj|j
|d<dS(sBuild 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.
        tg_logvtg_logt	IA__g_logt
IA__g_logvtg_assert_warningtIA__g_assert_warningt
__GI_abortt_XErrorR%iisD^#(\d+)\s+(?:0x(?:\w+)\s+in\s+\*?(.*)|(<signal handler called>)\s*)$s0^#(\d+)\s+(?:(.*)|(<signal handler called>)\s*)$s,^(__.*_s?sse\d+(?:_\w+)?|__kernel_vsyscall)$Rit(t_Xthandle_responsethandle_errortXWindowEventiis
t
StacktraceTopN(R.R/R0(RvRR4RRRRRR8RR)RRcR(R^tunwind_functionsttoptracetdepthtunwoundt	unwindingtunwinding_xerrortbt_fn_retbt_fn_noaddr_retignore_functions_retlineR!tfntframetfunction((s1/usr/lib/python2.7/dist-packages/apport/report.pyRsP
	
)	
			"
c	BsVi}xejedD]}ye|'}e|j|d|fdUWdQXy|d||Wn<ek
r}e|jdr|d|qnXWqek
re	Se
jd|ej
qXqW|s|jd}n|r|jd}d	|kr2d
||d<dSde|f}ejj|rye|'}e|j|d|fdUWdQXy|d||Wn<ek
r}e|jdr|d|qnXWqek
re	Se
jd|ej
qXqn|s4|jd
}n|rR|jd}d	|krhd||d<dSde|f}ejj|rRye|'}e|j|d|fdUWdQXy|d||Wn<ek
r}e|jdr|d|qnXWqOek
r+e	Se
jd|ej
qOXqRneS(sRun 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/*.pytexecNtadd_infos
add_info()shook %s crashed:RmiRsinvalid Package: %sRs%s/%s.pyRnsinvalid SourcePackage: %ss%s/source_%s.py(tglobt_common_hook_dirRRRt	TypeErrorRRt
StopIterationR)Rqterrort	tracebackt	print_excRRt	_hook_dirRRRR(R^tuiRt
srcpackagetsymbthookRR((s1/usr/lib/python2.7/dist-packages/apport/report.pytadd_hooks_infos&

&


&


cCs[|s
dSytj|j}WndSXd|kr>dSt||}|rW|SdS(sCheck 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(turllibturlopenRRTR8(R^R3RS((s1/usr/lib/python2.7/dist-packages/apport/report.pytsearch_bug_patterns1scCstjjt}tj|tjs@tjj|dkratjj	j
ddd}nKytjjj
|}Wn/tk
r}tdtt|fnX|jjt|j|S(sRead 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.
        iRqs%s has invalid format: %sN(RRt
expandusert_ignore_fileRRtgetsizeR;R<tgetDOMImplementationtcreateDocumentR8RPtparseRRRtdocumentElementRARW(R^tifpathR<R((s1/usr/lib/python2.7/dist-packages/apport/report.pyt_get_ignore_domZs.! 

c	Csd|kstyxtjtD]p}ySttjjt|2}x(|D] }|j|dkrStSqSWWdQXWq%t	k
rq%q%Xq%WWnt
k
rnXyt}xztjtD]i}yLttjjt|+}x!|D]}|j
|jqWWdQXWqt	k
r2qqXqW|rQ|d|krQtSWnt
k
renX|j}y ttj|dj}Wnt
k
rtSXxR|jdD]A}|jd|dkrt|jd|krtSqqWtS(sCheck 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/. For environments where you are only
        interested in crashes of some programs, you can also create a whitelist
        in /etc/apport/whitelist.d/, everything which does not match gets
        ignored then.

        This requires the ExecutablePath attribute. Throws a ValueError if the
        file has an invalid format.
        RjNtignoretprogramtmtime(RRtlistdirt_blacklist_dirRRRcRR)RRRvt_whitelist_dirRRYRRRRRRtgetAttributetfloat(R^RRR;t	whitelistR<t	cur_mtimeRZ((s1/usr/lib/python2.7/dist-packages/apport/report.pyt
check_ignoredrsF



	
!

 
c
CsHd|kst|j}y&tttj|dj}Wn,tk
rr}|jtj	krldSnXx|j
dD]3}|jd|dkr|jd|PqqW|j
d}|jd|d|jd||jj|ttjjtd }|j|ddd	d
WdQX|jdS(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.
        RjNRZR[R\Rt	addindents  tnewls
(RRYRRRRRRRRRRR`tsetAttributet
createElementRWtappendChildRRRQRRtwritexmlRU(R^R<R\RRZR((s1/usr/lib/python2.7/dist-packages/apport/report.pytmark_ignores&
&cCs|jdstSg|djD]}|jd^q$}t|dkrd|jtdkS|jtt|dkS(sCheck 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.
        R1s??iig@(RRRRRtcountR)(R^Rt
unknown_fn((s1/usr/lib/python2.7/dist-packages/apport/report.pythas_useful_stacktraces,cCsPxI|jddjD]/}|jddj}|dkr|SqWdS(s(Return topmost function in StacktraceTopR1R%R,is??N(RRRRR8(R^Rtfname((s1/usr/lib/python2.7/dist-packages/apport/report.pytstacktrace_top_functions
cCs|jddkrOd|krOd|krOdtjj|d|dfSd|krZd|krZd|krZidd6d	d6d
d6dd
6dd6}|j}|rd|}nd}d}d|krd|kr|d|dkr|ddkrd|d}ndtjj|d|j|jdd|jd||fSd|krd|kr|dj}t|dkrd9St|dkrdtjj|d|dfStj	d}t|d}d}xU|dkrH|j
||}|r;|jd}	|jd}Pn|d8}qWtjj|d}
|d }|jd!d}tj
d"tj
||}|r|jd}
nd9}
|d#kr|	|dkrd$}q|	}n
d%|}d&|
||f}|
r|d'|
7}n|S|jd(d)krd)|krd*|d)}|jd+r||d,|d+jd 7}n|S|jd(d-krd.|kr|d.}|jd/r|jd0dd}n|jd0dd}|S|jd(d-kr~d1|kr~d}d2|kr9|d3|d2d47}n||d1d57}d6|krp|d7|d6d87}n|d07}|Sd9S(:sZCreate 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.
        tSignalt6RjRs%s assert failure: %sR1tSIGILLt4tSIGABRTtSIGFPEt8tSIGSEGVt11tSIGPIPEt13s in %s()R%RRotalls [non-native %s package]s%s crashed with %s%s%sssignal t	Tracebackiis%s crashed with %sis^\s*File\s*"(\S+)".* in (.+)$tunknowniit:s
^%s: (.+)$s<module>t__main__s%s()s%s crashed with %s in %ss: %sRkRms$package %s failed to install/upgradetErrorMessages: t
KernelOopstOopsTexts$------------[ cut here ]------------s
tFailuretMachineTypet[s] s failuretNonfreeKernelModuless [non-free: t]N(RRRRRpRRR8R4RRRRtescapeR(R^tsignal_namesR<t
arch_mismatchttracettrace_reRR>R!tmodule_pathRt	last_linet	exceptiontmessagetcontextttitletoops((s1/usr/lib/python2.7/dist-packages/apport/report.pytstandard_titles


		



cCsg}x|jddd|jddjD]}|sEq3n|jd \}}tj|}|dkr3|dkr3|dkr3tj||dkr3|j|q3q3W|S(	s=Return list of obsolete packages in Package and Dependencies.RmR%s
RpiR8iN(RRRR
tget_available_versionR8tcompare_versionsR(R^tobsoleteRtpkgtvertavail((s1/usr/lib/python2.7/dist-packages/apport/report.pytobsolete_packagess3$c

Csd|kr!|ddkr!dSd|kr|ddkrd}tjd}xG|djD]5}|j|}|rc|d|jd7}qcqcW|S|jd	d
krd|kr|dd|d}tjdd
|Sd|krd	|krd|d|d	f}tjd}|dj}t|dkrOdSxP|D]H}|j|}|r|d|jdp|jd7}qVdSqVW|Sd|kr|dj}d}t|dkrtjd|d}|r|dd|jdSdSnt|dkr,dStjd}x{|D]s}	|j|	}|rB|jddkr|d|jd7}q|d|jd|jdf7}qBqBW|dd|dj	dd|SdS(sGet 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.
        RjRkRlRtkernels^\s*\#\d+\s\[\w+\]\s(\w+)RiRqRrRs0x[0-9a-f]{6,}tADDRR1s%s:%ss.^(?:([\w:~]+).*|(<signal handler called>)\s*)$iR}R%s(\w+): iis)^\s+File "([^"]+).*line (\d+).*\sin (.*)$s<module>s:%s@%siN(
R8R4RRRRRtsubRR(
R^tsigtregexR;R!R8tlinesRtloc_reR((s1/usr/lib/python2.7/dist-packages/apport/report.pytcrash_signaturesZ!
)
-%cCsd|ks$d|ks$d|kr(dSg}d}x|djD]}|jdr|jd}|jdsqEnt|d}|d	krqEn|j|}|r|j|jd
dq|d7}nt|dkrEPqEqEW|dkrt||d
krdS|dkr<t|dksZ|dkr^t|dkr^dSd|d|dt	j
d
d
j|fS(sCompute 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.
        RRRqit#it0xiiRs..iiiis%s:%s:%s:%sRjN(R8RRRRt_address_to_offsetRR$RRRRc(R^tstacktfailedR;taddrtoffset((s1/usr/lib/python2.7/dist-packages/apport/report.pyRs6$
"<
c	Cs4g}tjdkrtjtj}t|ddkrj|jtjd|ddfn|jtjd|ddfx_|djdD]G}|j	}t|dkr|jtjd|d	fqqWntj
d
}t|dkr5|jtjd|dfny|d=Wntk
rSnXx|D]}|jd
r||dksd|ks|dkr[t
||dsq[nx||D]q\}}t||tdkr|j|||||<q|j|||jdjd||<qWq[q[WdS(sRemove 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.
        iis\b%s\btusernameis/home/usernameit,s	User NameithostnameRtProctProcCpuinfoRRtProcInterruptstProcModulesRR}t
PythonArgstTitletisspaceR%sUTF-8N(RsProcMapss
ProcStatusRR(s	Tracebacks
PythonArgsR(RRRRRRR4RRRRtKeyErrorRRR_RRDR,(R^treplacementsRRRRRKtrepl((s1/usr/lib/python2.7/dist-packages/apport/report.pyt	anonymize#s:'$*#

	cCsU|jxD|jD]9\}}}||kr||krd|||fSqWdS(s^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.
        s%s+%xN(t_build_proc_maps_cacheR]R8(R^Rtstarttendtelf((s1/usr/lib/python2.7/dist-packages/apport/report.pyRNs

cCs|jr
dSd|kstg|_tjd}tjd}x|djD]}|jsoqWn|j|}|s|j|rqWn|std|n|jjt|j	ddt|j	dd|j	d	fqWWdS(
s_Generate self._proc_maps_cache from ProcMaps field.

        This only gets done once.
        NRs-^([0-9a-fA-F]+)-([0-9a-fA-F]+).*\s{4,}(\S.*$)s ^([0-9a-fA-F]+)-([0-9a-fA-F]+)\sscannot parse ProcMaps line: iiii(
R]RR4RRRRRRR(R^tfmttfmt_unknownR;R!((s1/usr/lib/python2.7/dist-packages/apport/report.pyRds 		N( t__name__t
__module__t__doc__R8R\RiR{RRRRtclassmethodRRRRR#RRMRPRYRdRkRnRpRRRRRRR(((s1/usr/lib/python2.7/dist-packages/apport/report.pyRYs8
	7			J	E()j	=^	)		<	(		
			W	=	+	(.RR&Rtos.pathRRNR4RRRRARFRRRtxml.domR;txml.dom.minidomtxml.parsers.expatRRFRqtapport.fileutilstapport.packaging_implRR
tenvironRt	_data_dirRHRBRRR^R_RRRRR8RR2RORTRWR[RY(((s1/usr/lib/python2.7/dist-packages/apport/report.pyt<module>s0`H