2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2016 The Qt Company Ltd.
|
2022-12-21 10:12:09 +01:00
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
2011-03-04 12:15:18 +01:00
|
|
|
|
|
|
|
|
#include "modelhelpers.h"
|
|
|
|
|
#include "frame.h"
|
2022-07-08 16:08:27 +02:00
|
|
|
#include "../valgrindtr.h"
|
2011-03-04 12:15:18 +01:00
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QString>
|
|
|
|
|
#include <QDir>
|
|
|
|
|
#include <QPair>
|
2011-03-07 17:20:10 +01:00
|
|
|
|
2011-03-04 12:15:18 +01:00
|
|
|
namespace Valgrind {
|
|
|
|
|
namespace XmlProtocol {
|
|
|
|
|
|
|
|
|
|
QString toolTipForFrame(const Frame &frame)
|
|
|
|
|
{
|
2011-05-18 17:05:49 +02:00
|
|
|
QString location;
|
2015-06-26 14:12:33 +02:00
|
|
|
if (!frame.fileName().isEmpty()) {
|
|
|
|
|
location = frame.filePath();
|
2011-05-18 17:05:49 +02:00
|
|
|
if (frame.line() > 0)
|
2018-12-01 20:56:21 +02:00
|
|
|
location += ':' + QString::number(frame.line());
|
2011-05-18 17:05:49 +02:00
|
|
|
}
|
2011-03-04 12:15:18 +01:00
|
|
|
|
2018-12-10 08:11:18 +01:00
|
|
|
using StringPair = QPair<QString, QString>;
|
2011-05-18 17:05:49 +02:00
|
|
|
QList<StringPair> lines;
|
2011-03-04 12:15:18 +01:00
|
|
|
|
2011-05-18 17:05:49 +02:00
|
|
|
if (!frame.functionName().isEmpty())
|
2022-07-08 16:08:27 +02:00
|
|
|
lines << qMakePair(Tr::tr("Function:"), frame.functionName());
|
2011-05-18 17:05:49 +02:00
|
|
|
if (!location.isEmpty())
|
2022-07-08 16:08:27 +02:00
|
|
|
lines << qMakePair(Tr::tr("Location:"), location);
|
2011-05-18 17:05:49 +02:00
|
|
|
if (frame.instructionPointer())
|
2022-07-08 16:08:27 +02:00
|
|
|
lines << qMakePair(Tr::tr("Instruction pointer:"),
|
|
|
|
|
QString("0x%1").arg(frame.instructionPointer(), 0, 16));
|
2011-05-18 17:05:49 +02:00
|
|
|
if (!frame.object().isEmpty())
|
2022-07-08 16:08:27 +02:00
|
|
|
lines << qMakePair(Tr::tr("Object:"), frame.object());
|
2011-03-04 12:15:18 +01:00
|
|
|
|
2018-12-01 20:56:21 +02:00
|
|
|
QString html = "<html><head>"
|
2011-05-18 17:05:49 +02:00
|
|
|
"<style>dt { font-weight:bold; } dd { font-family: monospace; }</style>\n"
|
2018-12-01 20:56:21 +02:00
|
|
|
"</head><body><dl>";
|
2011-03-04 12:15:18 +01:00
|
|
|
|
2022-10-07 14:46:06 +02:00
|
|
|
for (const StringPair &pair : std::as_const(lines)) {
|
2018-12-01 20:56:21 +02:00
|
|
|
html += "<dt>";
|
2011-05-18 17:05:49 +02:00
|
|
|
html += pair.first;
|
2018-12-01 20:56:21 +02:00
|
|
|
html += "</dt><dd>";
|
2011-05-18 17:05:49 +02:00
|
|
|
html += pair.second;
|
2018-12-01 20:56:21 +02:00
|
|
|
html += "</dd>\n";
|
2011-05-18 17:05:49 +02:00
|
|
|
}
|
2018-12-01 20:56:21 +02:00
|
|
|
html += "</dl></body></html>";
|
2011-05-18 17:05:49 +02:00
|
|
|
return html;
|
2011-03-04 12:15:18 +01:00
|
|
|
}
|
|
|
|
|
|
2011-05-18 17:05:49 +02:00
|
|
|
} // namespace XmlProtocol
|
|
|
|
|
} // namespace Valgrind
|