Clean up StackFrame

Reviewed-by: hjk
This commit is contained in:
Arvid Ephraim Picciani
2010-10-15 11:17:32 +02:00
parent 728ef58b16
commit 270cd904f8
2 changed files with 20 additions and 21 deletions

View File

@@ -28,15 +28,12 @@
**************************************************************************/ **************************************************************************/
#include "stackframe.h" #include "stackframe.h"
#include "stackhandler.h"
#include <QtCore/QFileInfo> #include <QtCore/QFileInfo>
#include <QtCore/QDebug> #include <QtCore/QDebug>
#include <QtCore/QDir> #include <QtCore/QDir>
#include <QtCore/QTextStream> #include <QtCore/QTextStream>
#include <QtCore/QCoreApplication>
#include <QtGui/QToolTip>
#include <QtGui/QFontMetrics>
namespace Debugger { namespace Debugger {
namespace Internal { namespace Internal {
@@ -48,12 +45,12 @@ namespace Internal {
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
StackFrame::StackFrame() StackFrame::StackFrame()
: level(0), line(0), address(0) : level(-1), line(-1), address(0)
{} {}
void StackFrame::clear() void StackFrame::clear()
{ {
line = level = 0; line = level = -1;
function.clear(); function.clear();
file.clear(); file.clear();
from.clear(); from.clear();
@@ -70,16 +67,16 @@ QString StackFrame::toString() const
{ {
QString res; QString res;
QTextStream str(&res); QTextStream str(&res);
str << StackHandler::tr("Address:") << ' '; str << tr("Address:") << ' ';
str.setIntegerBase(16); str.setIntegerBase(16);
str << address; str << address;
str.setIntegerBase(10); str.setIntegerBase(10);
str << ' ' str << ' '
<< StackHandler::tr("Function:") << ' ' << function << ' ' << tr("Function:") << ' ' << function << ' '
<< StackHandler::tr("File:") << ' ' << file << ' ' << tr("File:") << ' ' << file << ' '
<< StackHandler::tr("Line:") << ' ' << line << ' ' << tr("Line:") << ' ' << line << ' '
<< StackHandler::tr("From:") << ' ' << from << ' ' << tr("From:") << ' ' << from << ' '
<< StackHandler::tr("To:") << ' ' << to; << tr("To:") << ' ' << to;
return res; return res;
} }
@@ -89,17 +86,16 @@ QString StackFrame::toToolTip() const
QString res; QString res;
QTextStream str(&res); QTextStream str(&res);
str << "<html><body><table>" str << "<html><body><table>"
<< "<tr><td>" << StackHandler::tr("Address:") << "</td><td>0x"; << "<tr><td>" << tr("Address:") << "</td><td>0x";
str.setIntegerBase(16); str.setIntegerBase(16);
str << address; str << address;
str.setIntegerBase(10); str.setIntegerBase(10);
str << "</td></tr>" str << "</td></tr>"
<< "<tr><td>" << StackHandler::tr("Function:") << "</td><td>" << function << "</td></tr>" << "<tr><td>" << tr("Function:") << "</td><td>" << function << "</td></tr>"
<< "<tr><td>" << StackHandler::tr("File:") << "</td><td width=" << "<tr><td>" << tr("File:") << "</td><td>" << filePath << "</td></tr>"
<< QFontMetrics(QToolTip::font()).width(filePath) << ">" << filePath << "</td></tr>" << "<tr><td>" << tr("Line:") << "</td><td>" << line << "</td></tr>"
<< "<tr><td>" << StackHandler::tr("Line:") << "</td><td>" << line << "</td></tr>" << "<tr><td>" << tr("From:") << "</td><td>" << from << "</td></tr>"
<< "<tr><td>" << StackHandler::tr("From:") << "</td><td>" << from << "</td></tr>" << "<tr><td>" << tr("To:") << "</td><td>" << to << "</td></tr>"
<< "<tr><td>" << StackHandler::tr("To:") << "</td><td>" << to << "</td></tr>"
<< "</table></body></html>"; << "</table></body></html>";
return res; return res;
} }

View File

@@ -33,6 +33,7 @@
#include <QtCore/QList> #include <QtCore/QList>
#include <QtCore/QMetaType> #include <QtCore/QMetaType>
#include <QtCore/QString> #include <QtCore/QString>
#include <QtCore/QCoreApplication>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QDebug; class QDebug;
@@ -51,13 +52,15 @@ public:
QString toString() const; QString toString() const;
public: public:
int level; qint32 level;
QString function; QString function;
QString file; // We try to put an absolute file name in there. QString file; // We try to put an absolute file name in there.
QString from; // Sometimes something like "/usr/lib/libstdc++.so.6" QString from; // Sometimes something like "/usr/lib/libstdc++.so.6"
QString to; // Used in ScriptEngine only. QString to; // Used in ScriptEngine only.
int line; qint32 line;
quint64 address; quint64 address;
Q_DECLARE_TR_FUNCTIONS(StackHandler)
}; };
QDebug operator<<(QDebug d, const StackFrame &frame); QDebug operator<<(QDebug d, const StackFrame &frame);