OSDN Git Service

Update license.
[qt-creator-jp/qt-creator-jp.git] / src / plugins / debugger / stackframe.cpp
1 /**************************************************************************
2 **
3 ** This file is part of Qt Creator
4 **
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
6 **
7 ** Contact: Nokia Corporation (info@qt.nokia.com)
8 **
9 **
10 ** GNU Lesser General Public License Usage
11 **
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.
18 **
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.
22 **
23 ** Other Usage
24 **
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.
27 **
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
30 **
31 **************************************************************************/
32
33 #include "stackframe.h"
34
35 #include <QtCore/QFileInfo>
36 #include <QtCore/QDebug>
37 #include <QtCore/QDir>
38 #include <QtCore/QTextStream>
39 #include <QtCore/QCoreApplication>
40
41 namespace Debugger {
42 namespace Internal {
43
44 ////////////////////////////////////////////////////////////////////////
45 //
46 // StackFrame
47 //
48 ////////////////////////////////////////////////////////////////////////
49
50 StackFrame::StackFrame()
51   : level(-1), line(-1), address(0), usable(false)
52 {}
53
54 void StackFrame::clear()
55 {
56     line = level = -1;
57     function.clear();
58     file.clear();
59     from.clear();
60     to.clear();
61     address = 0;
62 }
63
64 bool StackFrame::isUsable() const
65 {
66     return usable;
67 }
68
69 QString StackFrame::toString() const
70 {
71     QString res;
72     QTextStream str(&res);
73     str << tr("Address:") << ' ';
74     str.setIntegerBase(16);
75     str << address;
76     str.setIntegerBase(10);
77     str << ' '
78         << tr("Function:") << ' ' << function << ' '
79         << tr("File:") << ' ' << file << ' '
80         << tr("Line:") << ' ' << line << ' '
81         << tr("From:") << ' ' << from << ' '
82         << tr("To:") << ' ' << to;
83     return res;
84 }
85
86 QString StackFrame::toToolTip() const
87 {
88     const QString filePath = QDir::toNativeSeparators(file);
89     QString res;
90     QTextStream str(&res);
91     str << "<html><body><table>"
92         << "<tr><td>" << tr("Address:") << "</td><td>0x";
93     str.setIntegerBase(16);
94     str <<  address;
95     str.setIntegerBase(10);
96     str << "</td></tr>"
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>";
103     return res;
104 }
105
106 QDebug operator<<(QDebug d, const  StackFrame &f)
107 {
108     QString res;
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;
117     if (!f.to.isEmpty())
118         str << " to=" << f.to;
119     d.nospace() << res;
120     return d;
121 }
122
123 } // namespace Internal
124 } // namespace Debugger