Commit 2e9755e5 authored by Henri Chain's avatar Henri Chain 🛰
Browse files

remove friend

parent e6274ae8
......@@ -22,9 +22,32 @@
#include <KToolInvocation>
CrashedApplication::CrashedApplication(QObject *parent)
CrashedApplication::CrashedApplication(int pid,
int thread,
int signalNumber,
const QFileInfo &executable,
const QString &version,
const BugReportAddress &reportAddress,
const QString &name,
const QDateTime &datetime,
bool restarted,
bool hasDeletedFiles,
const QString &fakeBaseName,
QObject *parent)
: QObject(parent)
, m_restarted(false)
, m_pid(pid)
, m_signalNumber(signalNumber)
, m_name(name)
, m_executable(executable)
, m_fakeBaseName(fakeBaseName)
, m_version(version)
, m_reportAddress(reportAddress)
, m_restarted(restarted)
, m_thread(thread)
, m_datetime(datetime)
, m_hasDeletedFiles(hasDeletedFiles)
{
}
......
......@@ -18,6 +18,19 @@ class CrashedApplication : public QObject
{
Q_OBJECT
public:
CrashedApplication(int pid,
int thread,
int signalNumber,
const QFileInfo &executable,
const QString &version,
const BugReportAddress &reportAddress,
const QString &name = QString(),
const QDateTime &datetime = QDateTime::currentDateTime(),
bool restarted = false,
bool hasDeletedFiles = false,
const QString &fakeBaseName = QString(),
QObject *parent = nullptr);
~CrashedApplication() override;
/** Returns the crashed program's name, possibly translated (ex. "The KDE Crash Handler") */
......@@ -65,9 +78,6 @@ Q_SIGNALS:
void restarted(bool success);
protected:
friend class KCrashBackend;
CrashedApplication(QObject *parent = nullptr);
int m_pid;
int m_signalNumber;
QString m_name;
......
......@@ -105,27 +105,22 @@ bool KCrashBackend::init()
CrashedApplication *KCrashBackend::constructCrashedApplication()
{
CrashedApplication *a = new CrashedApplication(this);
a->m_datetime = QDateTime::currentDateTime();
a->m_name = DrKonqi::programName();
a->m_version = DrKonqi::appVersion();
a->m_reportAddress = BugReportAddress(DrKonqi::bugAddress());
a->m_pid = DrKonqi::pid();
a->m_signalNumber = DrKonqi::signal();
a->m_restarted = DrKonqi::isRestarted();
a->m_thread = DrKonqi::thread();
const auto pid = DrKonqi::pid();
QFileInfo executable;
QString fakeBaseName;
bool hasDeletedFiles = false;
// try to determine the executable that crashed
const QString procPath(QStringLiteral("/proc/%1").arg(a->m_pid));
const QString procPath(QStringLiteral("/proc/%1").arg(pid));
const QString exeProcPath(procPath + QStringLiteral("/exe"));
if (QFileInfo(exeProcPath).exists()) {
// on linux, the fastest and most reliable way is to get the path from /proc
qCDebug(DRKONQI_LOG) << "Using /proc to determine executable path";
const QString exePath = QFile::symLinkTarget(exeProcPath);
a->m_executable.setFile(exePath);
if (DrKonqi::isKdeinit() || a->m_executable.fileName().startsWith(QLatin1String("python"))) {
a->m_fakeBaseName = DrKonqi::appName();
executable.setFile(exePath);
if (DrKonqi::isKdeinit() || executable.fileName().startsWith(QLatin1String("python"))) {
fakeBaseName = DrKonqi::appName();
}
QDir mapFilesDir(procPath + QStringLiteral("/map_files"));
......@@ -142,8 +137,6 @@ CrashedApplication *KCrashBackend::constructCrashedApplication()
// a degree
QRegularExpression soExpression(QStringLiteral("(?<path>.+\\.(so|py)([^/]*)) \\(deleted\\)$"));
bool hasDeletedFiles = false;
const auto exeMatch = expression.match(exePath);
if (exeMatch.isValid() && exeMatch.hasMatch()) {
hasDeletedFiles = true;
......@@ -163,30 +156,39 @@ CrashedApplication *KCrashBackend::constructCrashedApplication()
hasDeletedFiles = true;
}
a->m_hasDeletedFiles = hasDeletedFiles;
qCDebug(DRKONQI_LOG) << "exe" << exePath << "has deleted files:" << hasDeletedFiles;
} else {
if (DrKonqi::isKdeinit()) {
a->m_executable = QFileInfo(QStandardPaths::findExecutable(QStringLiteral("kdeinit5")));
a->m_fakeBaseName = DrKonqi::appName();
executable = QFileInfo(QStandardPaths::findExecutable(QStringLiteral("kdeinit5")));
fakeBaseName = DrKonqi::appName();
} else {
QFileInfo execPath(DrKonqi::appName());
if (execPath.isAbsolute()) {
a->m_executable = execPath;
executable = execPath;
} else if (!DrKonqi::appPath().isEmpty()) {
QDir execDir(DrKonqi::appPath());
a->m_executable = execDir.absoluteFilePath(execPath.fileName());
executable = execDir.absoluteFilePath(execPath.fileName());
} else {
a->m_executable = QFileInfo(QStandardPaths::findExecutable(execPath.fileName()));
executable = QFileInfo(QStandardPaths::findExecutable(execPath.fileName()));
}
}
}
qCDebug(DRKONQI_LOG) << "Executable is:" << a->m_executable.absoluteFilePath();
qCDebug(DRKONQI_LOG) << "Executable exists:" << a->m_executable.exists();
return a;
qCDebug(DRKONQI_LOG) << "Executable is:" << executable.absoluteFilePath();
qCDebug(DRKONQI_LOG) << "Executable exists:" << executable.exists();
return new CrashedApplication(pid,
DrKonqi::thread(),
DrKonqi::signal(),
executable,
DrKonqi::appVersion(),
BugReportAddress(DrKonqi::bugAddress()),
DrKonqi::programName(),
QDateTime::currentDateTime(),
DrKonqi::isRestarted(),
hasDeletedFiles,
fakeBaseName,
this);
}
DebuggerManager *KCrashBackend::constructDebuggerManager()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment