示例#1
0
wxDebugReport::wxDebugReport()
{
    // get a temporary directory name
    wxString appname = GetReportName();

    // we can't use CreateTempFileName() because it creates a file, not a
    // directory, so do our best to create a unique name ourselves
    //
    // of course, this doesn't protect us against malicious users...
    wxFileName fn;
    fn.AssignTempFileName(appname);
#if wxUSE_DATETIME
    m_dir.Printf(wxT("%s%c%s_dbgrpt-%lu-%s"),
                 fn.GetPath().c_str(), wxFILE_SEP_PATH, appname.c_str(),
                 wxGetProcessId(),
                 wxDateTime::Now().Format(wxT("%Y%m%dT%H%M%S")).c_str());
#else
    m_dir.Printf(wxT("%s%c%s_dbgrpt-%lu"),
                 fn.GetPath().c_str(), wxFILE_SEP_PATH, appname.c_str(),
                 wxGetProcessId());
#endif

    // as we are going to save the process state there use restrictive
    // permissions
    if ( !wxMkdir(m_dir, 0700) )
    {
        wxLogSysError(_("Failed to create directory \"%s\""), m_dir.c_str());
        wxLogError(_("Debug report couldn't be created."));

        Reset();
    }
}
void CQAParams::UpdateReport() {
   CString reportFileName = GetReportName();

   CMainFrame* mainFrame;
   mainFrame=(CMainFrame *)AfxGetMainWnd();
   if(mainFrame->m_Lic[LIC_QAREPORT]>0 && IsReportAvailable()) {
		m_Reporter.Navigate(reportFileName,NULL,NULL,NULL,NULL);
   }
}
示例#3
0
    virtual bool DoProcess()
    {
        if ( !wxDebugReportCompress::DoProcess() )
            return false;
        wxMailMessage msg(GetReportName() + wxT(" crash report"),
                          wxT("*****@*****.**"),
                          wxEmptyString, // mail body
                          wxEmptyString, // from address
                          GetCompressedFileName(),
                          wxT("crashreport.zip"));

        return wxEmail::Send(msg);
    }
示例#4
0
bool wxDebugReport::AddDump(Context ctx)
{
    wxCHECK_MSG( IsOk(), false, wxT("use IsOk() first") );

    wxFileName fn(m_dir, GetReportName(), wxT("dmp"));
    wxCrashReport::SetFileName(fn.GetFullPath());

    if ( !(ctx == Context_Exception ? wxCrashReport::Generate()
                                    : wxCrashReport::GenerateNow()) )
            return false;

    AddFile(fn.GetFullName(), _("dump of the process state (binary)"));

    return true;
}
示例#5
0
bool wxDebugReportCompress::DoProcess()
{
    const size_t count = GetFilesCount();
    if ( !count )
        return false;

    // create the streams
    wxFileName fn(GetDirectory(), GetReportName(), _T("zip"));
    wxFFileOutputStream os(fn.GetFullPath(), _T("wb"));
    wxZipOutputStream zos(os, 9);

    // add all files to the ZIP one
    wxString name, desc;
    for ( size_t n = 0; n < count; n++ )
    {
        GetFile(n, &name, &desc);

        wxZipEntry *ze = new wxZipEntry(name);
        ze->SetComment(desc);

        if ( !zos.PutNextEntry(ze) )
            return false;

        wxFileName filename(fn.GetPath(), name);
        wxFFileInputStream is(filename.GetFullPath());
        if ( !is.IsOk() || !zos.Write(is).IsOk() )
            return false;
    }

    if ( !zos.Close() )
        return false;

    m_zipfile = fn.GetFullPath();

    return true;
}
示例#6
0
bool wxDebugReport::AddContext(wxDebugReport::Context ctx)
{
    wxCHECK_MSG( IsOk(), false, wxT("use IsOk() first") );

    // create XML dump of current context
    wxXmlDocument xmldoc;
    wxXmlNode *nodeRoot = new wxXmlNode(wxXML_ELEMENT_NODE, wxT("report"));
    xmldoc.SetRoot(nodeRoot);
    nodeRoot->AddAttribute(wxT("version"), wxT("1.0"));
    nodeRoot->AddAttribute(wxT("kind"), ctx == Context_Current ? wxT("user")
                                                             : wxT("exception"));

    // add system information
    wxXmlNode *nodeSystemInfo = new wxXmlNode(wxXML_ELEMENT_NODE, wxT("system"));
    if ( DoAddSystemInfo(nodeSystemInfo) )
        nodeRoot->AddChild(nodeSystemInfo);
    else
        delete nodeSystemInfo;

    // add information about the loaded modules
    wxXmlNode *nodeModules = new wxXmlNode(wxXML_ELEMENT_NODE, wxT("modules"));
    if ( DoAddLoadedModules(nodeModules) )
        nodeRoot->AddChild(nodeModules);
    else
        delete nodeModules;

    // add CPU context information: this only makes sense for exceptions as our
    // current context is not very interesting otherwise
    if ( ctx == Context_Exception )
    {
        wxXmlNode *nodeContext = new wxXmlNode(wxXML_ELEMENT_NODE, wxT("context"));
        if ( DoAddExceptionInfo(nodeContext) )
            nodeRoot->AddChild(nodeContext);
        else
            delete nodeContext;
    }

    // add stack traceback
#if wxUSE_STACKWALKER
    wxXmlNode *nodeStack = new wxXmlNode(wxXML_ELEMENT_NODE, wxT("stack"));
    XmlStackWalker sw(nodeStack);
#if wxUSE_ON_FATAL_EXCEPTION
    if ( ctx == Context_Exception )
    {
        sw.WalkFromException();
    }
    else // Context_Current
#endif // wxUSE_ON_FATAL_EXCEPTION
    {
        sw.Walk();
    }

    if ( sw.IsOk() )
        nodeRoot->AddChild(nodeStack);
    else
        delete nodeStack;
#endif // wxUSE_STACKWALKER

    // finally let the user add any extra information he needs
    DoAddCustomContext(nodeRoot);


    // save the entire context dump in a file
    wxFileName fn(m_dir, GetReportName(), wxT("xml"));

    if ( !xmldoc.Save(fn.GetFullPath()) )
        return false;

    AddFile(fn.GetFullName(), _("process context description"));

    return true;
}
bool CQAParams::IsReportAvailable() {
   CString reportFileName = GetReportName();
   return GetFileAttributes(reportFileName) != (DWORD)-1;
}