1 /**************************************************************************
3 ** This file is part of Qt Creator
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
7 ** Contact: Nokia Corporation (info@qt.nokia.com)
10 ** GNU Lesser General Public License Usage
12 ** This file may be used under the terms of the GNU Lesser General Public
13 ** License version 2.1 as published by the Free Software Foundation and
14 ** appearing in the file LICENSE.LGPL included in the packaging of this file.
15 ** Please review the following information to ensure the GNU Lesser General
16 ** Public License version 2.1 requirements will be met:
17 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
19 ** In addition, as a special exception, Nokia gives you certain additional
20 ** rights. These rights are described in the Nokia Qt LGPL Exception
21 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
25 ** Alternatively, this file may be used in accordance with the terms and
26 ** conditions contained in a signed written agreement between you and Nokia.
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
31 **************************************************************************/
33 #include "stackframe.h"
35 #include <QtCore/QFileInfo>
36 #include <QtCore/QDebug>
37 #include <QtCore/QDir>
38 #include <QtCore/QTextStream>
39 #include <QtCore/QCoreApplication>
44 ////////////////////////////////////////////////////////////////////////
48 ////////////////////////////////////////////////////////////////////////
50 StackFrame::StackFrame()
51 : level(-1), line(-1), address(0), usable(false)
54 void StackFrame::clear()
64 bool StackFrame::isUsable() const
69 QString StackFrame::toString() const
72 QTextStream str(&res);
73 str << tr("Address:") << ' ';
74 str.setIntegerBase(16);
76 str.setIntegerBase(10);
78 << tr("Function:") << ' ' << function << ' '
79 << tr("File:") << ' ' << file << ' '
80 << tr("Line:") << ' ' << line << ' '
81 << tr("From:") << ' ' << from << ' '
82 << tr("To:") << ' ' << to;
86 QString StackFrame::toToolTip() const
88 const QString filePath = QDir::toNativeSeparators(file);
90 QTextStream str(&res);
91 str << "<html><body><table>"
92 << "<tr><td>" << tr("Address:") << "</td><td>0x";
93 str.setIntegerBase(16);
95 str.setIntegerBase(10);
97 << "<tr><td>" << tr("Function:") << "</td><td>" << function << "</td></tr>"
98 << "<tr><td>" << tr("File:") << "</td><td>" << filePath << "</td></tr>"
99 << "<tr><td>" << tr("Line:") << "</td><td>" << line << "</td></tr>"
100 << "<tr><td>" << tr("From:") << "</td><td>" << from << "</td></tr>"
101 << "<tr><td>" << tr("To:") << "</td><td>" << to << "</td></tr>"
102 << "</table></body></html>";
106 QDebug operator<<(QDebug d, const StackFrame &f)
109 QTextStream str(&res);
110 str << "level=" << f.level << " address=" << f.address;
111 if (!f.function.isEmpty())
112 str << ' ' << f.function;
113 if (!f.file.isEmpty())
114 str << ' ' << f.file << ':' << f.line;
115 if (!f.from.isEmpty())
116 str << " from=" << f.from;
118 str << " to=" << f.to;
123 } // namespace Internal
124 } // namespace Debugger