1/*****************************************************************
2 * drkonqi - The KDE Crash Handler
3 *
4 * Copyright (C) 2000-2003 Hans Petter Bieker <bieker@kde.org>
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 *
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 *****************************************************************/
27
28#ifndef BACKTRACEGENERATOR_H
29#define BACKTRACEGENERATOR_H
30
31#include <KProcess>
32
33#include "debugger.h"
34
35class KTemporaryFile;
36class BacktraceParser;
37
38class BacktraceGenerator : public QObject
39{
40 Q_OBJECT
41
42public:
43 enum State { NotLoaded, Loading, Loaded, Failed, FailedToStart };
44
45 BacktraceGenerator(const Debugger & debugger, QObject *parent);
46 ~BacktraceGenerator();
47
48 State state() const {
49 return m_state;
50 }
51
52 BacktraceParser *parser() const {
53 return m_parser;
54 }
55
56 QString backtrace() const {
57 return m_parsedBacktrace;
58 }
59
60 const Debugger debugger() const {
61 return m_debugger;
62 }
63
64public Q_SLOTS:
65 bool start();
66
67Q_SIGNALS:
68 void starting();
69 void newLine(const QString &str); // emitted for every line
70 void someError();
71 void failedToStart();
72 void done();
73
74private Q_SLOTS:
75 void slotProcessExited(int exitCode, QProcess::ExitStatus exitStatus);
76 void slotReadInput();
77
78private:
79 const Debugger m_debugger;
80 KProcess * m_proc;
81 KTemporaryFile * m_temp;
82 QByteArray m_output;
83 State m_state;
84 BacktraceParser * m_parser;
85 QString m_parsedBacktrace;
86
87#ifdef BACKTRACE_PARSER_DEBUG
88 BacktraceParser * m_debugParser;
89#endif
90};
91
92#endif
93