1 /**************************************************************************
3 ** This file is part of Qt Creator
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
7 ** Contact: Nokia Corporation (qt-info@nokia.com)
11 ** This file contains pre-release code and may not be distributed.
12 ** You may use this file in accordance with the terms and conditions
13 ** contained in the Technology Preview License Agreement accompanying
16 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25 ** In addition, as a special exception, Nokia gives you certain additional
26 ** rights. These rights are described in the Nokia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29 ** If you have questions regarding the use of this file, please contact
30 ** Nokia at qt-info@nokia.com.
32 **************************************************************************/
34 #ifndef DEBUGGER_GDBMI_H
35 #define DEBUGGER_GDBMI_H
37 #include <QtCore/QByteArray>
38 #include <QtCore/QList>
39 #include <QtCore/QVariant>
47 ( out-of-band-record )* [ result-record ] "(gdb)" nl
49 [ token ] "^" result-class ( "," result )* nl
50 out-of-band-record ==>
51 async-record | stream-record
53 exec-async-output | status-async-output | notify-async-output
55 [ token ] "*" async-output
56 status-async-output ==>
57 [ token ] "+" async-output
58 notify-async-output ==>
59 [ token ] "=" async-output
61 async-class ( "," result )* nl
63 "done" | "running" | "connected" | "error" | "exit"
65 "stopped" | others (where others will be added depending on the needs--this is still in development).
75 "{}" | "{" result ( "," result )* "}"
77 "[]" | "[" value ( "," value )* "]" | "[" result ( "," result )* "]"
79 console-stream-output | target-stream-output | log-stream-output
80 console-stream-output ==>
82 target-stream-output ==>
89 any sequence of digits.
93 // FIXME: rename into GdbMiValue
97 GdbMi() : m_type(Invalid) {}
101 QList<GdbMi> m_children;
112 inline Type type() const { return m_type; }
113 inline QByteArray name() const { return m_name; }
114 inline bool hasName(const char *name) const { return m_name == name; }
116 inline bool isValid() const { return m_type != Invalid; }
117 inline bool isConst() const { return m_type == Const; }
118 inline bool isTuple() const { return m_type == Tuple; }
119 inline bool isList() const { return m_type == List; }
122 inline QByteArray data() const { return m_data; }
123 inline const QList<GdbMi> &children() const { return m_children; }
124 inline int childCount() const { return m_children.size(); }
126 const GdbMi &childAt(int index) const { return m_children[index]; }
127 GdbMi &childAt(int index) { return m_children[index]; }
128 GdbMi findChild(const char *name) const;
130 QByteArray toString(bool multiline = false, int indent = 0) const;
131 void fromString(const QByteArray &str);
132 void fromStringMultiple(const QByteArray &str);
133 void setStreamOutput(const QByteArray &name, const QByteArray &content);
136 friend class GdbResponse;
137 friend class GdbEngine;
139 static QByteArray parseCString(const char *&from, const char *to);
140 static QByteArray escapeCString(const QByteArray &ba);
141 static QString escapeCString(const QString &ba);
142 void parseResultOrValue(const char *&from, const char *to);
143 void parseValue(const char *&from, const char *to);
144 void parseTuple(const char *&from, const char *to);
145 void parseTuple_helper(const char *&from, const char *to);
146 void parseList(const char *&from, const char *to);
148 void dumpChildren(QByteArray *str, bool multiline, int indent) const;
153 // "done" | "running" | "connected" | "error" | "exit"
165 GdbResponse() : token(-1), resultClass(GdbResultUnknown) {}
166 QByteArray toString() const;
167 static QByteArray stringFromResultClass(GdbResultClass resultClass);
170 GdbResultClass resultClass;
175 void extractGdbVersion(const QString &msg,
176 int *gdbVersion, int *gdbBuildVersion, bool *isMacGdb);
178 } // namespace Internal
179 } // namespace Debugger
181 //Q_DECLARE_METATYPE(GdbDebugger::Internal::GdbMi)
183 #endif // DEBUGGER_GDBMI_H