forked from qt-creator/qt-creator
Merge branch 'master' of git@scm.dev.nokia.troll.no:creator/mainline
This commit is contained in:
@@ -5,6 +5,7 @@ language = Cpp
|
|||||||
|
|
||||||
headerdirs = . \
|
headerdirs = . \
|
||||||
../../src/libs/aggregation \
|
../../src/libs/aggregation \
|
||||||
|
../../src/libs/cplusplus \
|
||||||
../../src/libs/extensionsystem \
|
../../src/libs/extensionsystem \
|
||||||
../../src/plugins/coreplugin \
|
../../src/plugins/coreplugin \
|
||||||
../../src/plugins/find \
|
../../src/plugins/find \
|
||||||
@@ -12,6 +13,7 @@ headerdirs = . \
|
|||||||
|
|
||||||
sourcedirs = . \
|
sourcedirs = . \
|
||||||
../../src/libs/aggregation \
|
../../src/libs/aggregation \
|
||||||
|
../../src/libs/cplusplus \
|
||||||
../../src/libs/extensionsystem \
|
../../src/libs/extensionsystem \
|
||||||
../../src/plugins/coreplugin \
|
../../src/plugins/coreplugin \
|
||||||
../../src/plugins/find \
|
../../src/plugins/find \
|
||||||
|
|||||||
1343
doc/doxygen/Doxyfile
1343
doc/doxygen/Doxyfile
File diff suppressed because it is too large
Load Diff
@@ -44,6 +44,11 @@
|
|||||||
#include <QtCore/QBitArray>
|
#include <QtCore/QBitArray>
|
||||||
#include <QtCore/QtDebug>
|
#include <QtCore/QtDebug>
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\namespace CPlusPlus
|
||||||
|
The namespace for C++ related tools.
|
||||||
|
*/
|
||||||
|
|
||||||
using namespace CPlusPlus;
|
using namespace CPlusPlus;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
@@ -101,6 +106,7 @@ private:
|
|||||||
|
|
||||||
} // anonymous namespace
|
} // anonymous namespace
|
||||||
|
|
||||||
|
|
||||||
Document::Document(const QString &fileName)
|
Document::Document(const QString &fileName)
|
||||||
: _fileName(fileName),
|
: _fileName(fileName),
|
||||||
_globalNamespace(0),
|
_globalNamespace(0),
|
||||||
@@ -166,9 +172,10 @@ void Document::appendMacro(const Macro ¯o)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Document::addMacroUse(const Macro ¯o, unsigned offset, unsigned length,
|
void Document::addMacroUse(const Macro ¯o, unsigned offset, unsigned length,
|
||||||
const QVector<MacroArgumentReference> &actuals)
|
const QVector<MacroArgumentReference> &actuals, bool inCondition)
|
||||||
{
|
{
|
||||||
MacroUse use(macro, offset, offset + length);
|
MacroUse use(macro, offset, offset + length);
|
||||||
|
use.setInCondition(inCondition);
|
||||||
|
|
||||||
foreach (const MacroArgumentReference &actual, actuals) {
|
foreach (const MacroArgumentReference &actual, actuals) {
|
||||||
const Block arg(actual.position(), actual.position() + actual.length());
|
const Block arg(actual.position(), actual.position() + actual.length());
|
||||||
@@ -179,6 +186,60 @@ void Document::addMacroUse(const Macro ¯o, unsigned offset, unsigned length,
|
|||||||
_macroUses.append(use);
|
_macroUses.append(use);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Document::addUndefinedMacroUse(const QByteArray &name, unsigned offset)
|
||||||
|
{
|
||||||
|
QByteArray copy(name.data(), name.size());
|
||||||
|
UndefinedMacroUse use(copy, offset);
|
||||||
|
_undefinedMacroUses.append(use);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\class Document::MacroUse
|
||||||
|
\brief Represents the usage of a macro in a \l {Document}.
|
||||||
|
\sa Document::UndefinedMacroUse
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\class Document::UndefinedMacroUse
|
||||||
|
\brief Represents a macro that was looked up, but not found.
|
||||||
|
|
||||||
|
Holds data about the reference to a macro in an \tt{#ifdef} or \tt{#ifndef}
|
||||||
|
or argument to the \tt{defined} operator inside an \tt{#if} or \tt{#elif} that does
|
||||||
|
not exist.
|
||||||
|
|
||||||
|
\sa Document::undefinedMacroUses(), Document::MacroUse, Macro
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\fn QByteArray Document::UndefinedMacroUse::name() const
|
||||||
|
|
||||||
|
Returns the name of the macro that was not found.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\fn QList<UndefinedMacroUse> Document::undefinedMacroUses() const
|
||||||
|
|
||||||
|
Returns a list of referenced but undefined macros.
|
||||||
|
|
||||||
|
\sa Document::macroUses(), Document::definedMacros(), Macro
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\fn QList<MacroUse> Document::macroUses() const
|
||||||
|
|
||||||
|
Returns a list of macros used.
|
||||||
|
|
||||||
|
\sa Document::undefinedMacroUses(), Document::definedMacros(), Macro
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\fn QList<Macro> Document::definedMacros() const
|
||||||
|
|
||||||
|
Returns the list of macros defined.
|
||||||
|
|
||||||
|
\sa Document::macroUses(), Document::undefinedMacroUses()
|
||||||
|
*/
|
||||||
|
|
||||||
TranslationUnit *Document::translationUnit() const
|
TranslationUnit *Document::translationUnit() const
|
||||||
{
|
{
|
||||||
return _translationUnit;
|
return _translationUnit;
|
||||||
|
|||||||
@@ -70,7 +70,8 @@ public:
|
|||||||
|
|
||||||
void appendMacro(const Macro ¯o);
|
void appendMacro(const Macro ¯o);
|
||||||
void addMacroUse(const Macro ¯o, unsigned offset, unsigned length,
|
void addMacroUse(const Macro ¯o, unsigned offset, unsigned length,
|
||||||
const QVector<MacroArgumentReference> &range);
|
const QVector<MacroArgumentReference> &range, bool inCondition);
|
||||||
|
void addUndefinedMacroUse(const QByteArray &name, unsigned offset);
|
||||||
|
|
||||||
Control *control() const;
|
Control *control() const;
|
||||||
TranslationUnit *translationUnit() const;
|
TranslationUnit *translationUnit() const;
|
||||||
@@ -220,13 +221,15 @@ public:
|
|||||||
class MacroUse: public Block {
|
class MacroUse: public Block {
|
||||||
Macro _macro;
|
Macro _macro;
|
||||||
QVector<Block> _arguments;
|
QVector<Block> _arguments;
|
||||||
|
bool _inCondition;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
inline MacroUse(const Macro ¯o,
|
inline MacroUse(const Macro ¯o,
|
||||||
unsigned begin = 0,
|
unsigned begin = 0,
|
||||||
unsigned end = 0)
|
unsigned end = 0)
|
||||||
: Block(begin, end),
|
: Block(begin, end),
|
||||||
_macro(macro)
|
_macro(macro),
|
||||||
|
_inCondition(false)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
const Macro ¯o() const
|
const Macro ¯o() const
|
||||||
@@ -238,11 +241,37 @@ public:
|
|||||||
QVector<Block> arguments() const
|
QVector<Block> arguments() const
|
||||||
{ return _arguments; }
|
{ return _arguments; }
|
||||||
|
|
||||||
|
bool isInCondition() const
|
||||||
|
{ return _inCondition; }
|
||||||
|
|
||||||
|
private:
|
||||||
void setArguments(const QVector<Block> &arguments)
|
void setArguments(const QVector<Block> &arguments)
|
||||||
{ _arguments = arguments; }
|
{ _arguments = arguments; }
|
||||||
|
|
||||||
void addArgument(const Block &block)
|
void addArgument(const Block &block)
|
||||||
{ _arguments.append(block); }
|
{ _arguments.append(block); }
|
||||||
|
|
||||||
|
void setInCondition(bool set)
|
||||||
|
{ _inCondition = set; }
|
||||||
|
|
||||||
|
friend class Document;
|
||||||
|
};
|
||||||
|
|
||||||
|
class UndefinedMacroUse: public Block {
|
||||||
|
QByteArray _name;
|
||||||
|
|
||||||
|
public:
|
||||||
|
inline UndefinedMacroUse(
|
||||||
|
const QByteArray &name,
|
||||||
|
unsigned begin = 0)
|
||||||
|
: Block(begin, begin + name.length()),
|
||||||
|
_name(name)
|
||||||
|
{ }
|
||||||
|
|
||||||
|
QByteArray name() const
|
||||||
|
{
|
||||||
|
return _name;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
QList<Include> includes() const
|
QList<Include> includes() const
|
||||||
@@ -254,6 +283,9 @@ public:
|
|||||||
QList<MacroUse> macroUses() const
|
QList<MacroUse> macroUses() const
|
||||||
{ return _macroUses; }
|
{ return _macroUses; }
|
||||||
|
|
||||||
|
QList<UndefinedMacroUse> undefinedMacroUses() const
|
||||||
|
{ return _undefinedMacroUses; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Symbol *findSymbolAt(unsigned line, unsigned column, Scope *scope) const;
|
Symbol *findSymbolAt(unsigned line, unsigned column, Scope *scope) const;
|
||||||
|
|
||||||
@@ -267,6 +299,7 @@ private:
|
|||||||
QList<Macro> _definedMacros;
|
QList<Macro> _definedMacros;
|
||||||
QList<Block> _skippedBlocks;
|
QList<Block> _skippedBlocks;
|
||||||
QList<MacroUse> _macroUses;
|
QList<MacroUse> _macroUses;
|
||||||
|
QList<UndefinedMacroUse> _undefinedMacroUses;
|
||||||
QByteArray _source;
|
QByteArray _source;
|
||||||
unsigned _revision;
|
unsigned _revision;
|
||||||
|
|
||||||
|
|||||||
@@ -58,9 +58,13 @@ public:
|
|||||||
|
|
||||||
virtual void macroAdded(const Macro &) {}
|
virtual void macroAdded(const Macro &) {}
|
||||||
|
|
||||||
|
virtual void passedMacroDefinitionCheck(unsigned, const Macro &) {}
|
||||||
|
virtual void failedMacroDefinitionCheck(unsigned, const QByteArray &) {}
|
||||||
|
|
||||||
virtual void startExpandingMacro(unsigned,
|
virtual void startExpandingMacro(unsigned,
|
||||||
const Macro &,
|
const Macro &,
|
||||||
const QByteArray &,
|
const QByteArray &,
|
||||||
|
bool,
|
||||||
const QVector<MacroArgumentReference> &) {}
|
const QVector<MacroArgumentReference> &) {}
|
||||||
|
|
||||||
virtual void stopExpandingMacro(unsigned, const Macro &) {}
|
virtual void stopExpandingMacro(unsigned, const Macro &) {}
|
||||||
|
|||||||
@@ -467,7 +467,7 @@ void LookupContext::expandFunction(Function *function,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void LookupContext::expandObjCMethod(ObjCMethod *method,
|
void LookupContext::expandObjCMethod(ObjCMethod *method,
|
||||||
const QList<Scope *> &visibleScopes,
|
const QList<Scope *> &,
|
||||||
QList<Scope *> *expandedScopes) const
|
QList<Scope *> *expandedScopes) const
|
||||||
{
|
{
|
||||||
if (! expandedScopes->contains(method->arguments()))
|
if (! expandedScopes->contains(method->arguments()))
|
||||||
@@ -495,3 +495,51 @@ void LookupContext::expand(Scope *scope,
|
|||||||
expandObjCMethod(meth, visibleScopes, expandedScopes);
|
expandObjCMethod(meth, visibleScopes, expandedScopes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Symbol *LookupContext::canonicalSymbol(Symbol *symbol)
|
||||||
|
{
|
||||||
|
Symbol *canonical = symbol;
|
||||||
|
for (; symbol; symbol = symbol->next()) {
|
||||||
|
if (symbol->name() == canonical->name())
|
||||||
|
canonical = symbol;
|
||||||
|
}
|
||||||
|
return canonical;
|
||||||
|
}
|
||||||
|
|
||||||
|
Symbol *LookupContext::canonicalSymbol(const QList<Symbol *> &candidates)
|
||||||
|
{
|
||||||
|
if (candidates.isEmpty())
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
Symbol *candidate = candidates.first();
|
||||||
|
if (candidate->scope()->isClassScope() && candidate->type()->isFunctionType()) {
|
||||||
|
Function *function = 0;
|
||||||
|
|
||||||
|
for (int i = 0; i < candidates.size(); ++i) {
|
||||||
|
Symbol *c = candidates.at(i);
|
||||||
|
|
||||||
|
if (! c->scope()->isClassScope())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
else if (Function *f = c->type()->asFunctionType()) {
|
||||||
|
if (f->isVirtual())
|
||||||
|
function = f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (function)
|
||||||
|
return canonicalSymbol(function);
|
||||||
|
}
|
||||||
|
|
||||||
|
return canonicalSymbol(candidate);
|
||||||
|
}
|
||||||
|
|
||||||
|
Symbol *LookupContext::canonicalSymbol(const QList<QPair<FullySpecifiedType, Symbol *> > &results)
|
||||||
|
{
|
||||||
|
QList<Symbol *> candidates;
|
||||||
|
QPair<FullySpecifiedType, Symbol *> result;
|
||||||
|
foreach (result, results) {
|
||||||
|
candidates.append(result.second); // ### not exacly.
|
||||||
|
}
|
||||||
|
return canonicalSymbol(candidates);
|
||||||
|
}
|
||||||
|
|||||||
@@ -54,6 +54,10 @@ public:
|
|||||||
Document::Ptr document(const QString &fileName) const;
|
Document::Ptr document(const QString &fileName) const;
|
||||||
Snapshot snapshot() const;
|
Snapshot snapshot() const;
|
||||||
|
|
||||||
|
static Symbol *canonicalSymbol(Symbol *symbol);
|
||||||
|
static Symbol *canonicalSymbol(const QList<Symbol *> &candidates);
|
||||||
|
static Symbol *canonicalSymbol(const QList<QPair<FullySpecifiedType, Symbol *> > &candidates); // ### FIXME
|
||||||
|
|
||||||
QList<Symbol *> resolve(Name *name) const
|
QList<Symbol *> resolve(Name *name) const
|
||||||
{ return resolve(name, visibleScopes()); }
|
{ return resolve(name, visibleScopes()); }
|
||||||
|
|
||||||
|
|||||||
@@ -31,6 +31,44 @@
|
|||||||
|
|
||||||
using namespace CPlusPlus;
|
using namespace CPlusPlus;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\class Client
|
||||||
|
\brief A notification interface for for C++ preprocessor.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\fn void Client::macroAdded(const Macro ¯o)
|
||||||
|
|
||||||
|
Called whenever a new macro is defined.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\fn void Client::passedMacroDefinitionCheck(unsigned offset, const Macro ¯o)
|
||||||
|
|
||||||
|
Called when the preprocessor checks whether a macro is defined or not and the
|
||||||
|
result is positive.
|
||||||
|
|
||||||
|
\sa failedMacroDefinitionCheck()
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\fn void Client::failedMacroDefinitionCheck(unsigned offset, const QByteArray &name)
|
||||||
|
|
||||||
|
Called when the preprocessor checks whether a macro is defined or not and the
|
||||||
|
result is negative.
|
||||||
|
|
||||||
|
\sa passedMacroDefinitionCheck()
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\fn void Client::startExpandingMacro(unsigned offset, const Macro ¯o, const QByteArray &originalText, bool inCondition = false, const QVector<MacroArgumentReference> &actuals = QVector<MacroArgumentReference>())
|
||||||
|
|
||||||
|
Called when starting to expand a macro. The parameter \a inCondition indicates whether the
|
||||||
|
expansion is happening inside a preprocessor conditional.
|
||||||
|
|
||||||
|
\sa stopExpandingMacro()
|
||||||
|
*/
|
||||||
|
|
||||||
Client::Client()
|
Client::Client()
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
|
|||||||
@@ -75,12 +75,14 @@ public:
|
|||||||
virtual ~Client();
|
virtual ~Client();
|
||||||
|
|
||||||
virtual void macroAdded(const Macro ¯o) = 0;
|
virtual void macroAdded(const Macro ¯o) = 0;
|
||||||
virtual void sourceNeeded(QString &fileName, IncludeType mode,
|
|
||||||
unsigned line) = 0; // ### FIX the signature.
|
virtual void passedMacroDefinitionCheck(unsigned offset, const Macro ¯o) = 0;
|
||||||
|
virtual void failedMacroDefinitionCheck(unsigned offset, const QByteArray &name) = 0;
|
||||||
|
|
||||||
virtual void startExpandingMacro(unsigned offset,
|
virtual void startExpandingMacro(unsigned offset,
|
||||||
const Macro ¯o,
|
const Macro ¯o,
|
||||||
const QByteArray &originalText,
|
const QByteArray &originalText,
|
||||||
|
bool inCondition = false,
|
||||||
const QVector<MacroArgumentReference> &actuals
|
const QVector<MacroArgumentReference> &actuals
|
||||||
= QVector<MacroArgumentReference>()) = 0;
|
= QVector<MacroArgumentReference>()) = 0;
|
||||||
|
|
||||||
@@ -89,6 +91,9 @@ public:
|
|||||||
|
|
||||||
virtual void startSkippingBlocks(unsigned offset) = 0;
|
virtual void startSkippingBlocks(unsigned offset) = 0;
|
||||||
virtual void stopSkippingBlocks(unsigned offset) = 0;
|
virtual void stopSkippingBlocks(unsigned offset) = 0;
|
||||||
|
|
||||||
|
virtual void sourceNeeded(QString &fileName, IncludeType mode,
|
||||||
|
unsigned line) = 0; // ### FIX the signature.
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace CPlusPlus
|
} // namespace CPlusPlus
|
||||||
|
|||||||
@@ -138,6 +138,18 @@ using namespace CPlusPlus;
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
bool isMacroDefined(QByteArray name, unsigned offset, Environment *env, Client *client)
|
||||||
|
{
|
||||||
|
Macro *m = env->resolve(name);
|
||||||
|
if (client) {
|
||||||
|
if (m)
|
||||||
|
client->passedMacroDefinitionCheck(offset, *m);
|
||||||
|
else
|
||||||
|
client->failedMacroDefinitionCheck(offset, name);
|
||||||
|
}
|
||||||
|
return m != 0;
|
||||||
|
}
|
||||||
|
|
||||||
class RangeLexer
|
class RangeLexer
|
||||||
{
|
{
|
||||||
const Token *first;
|
const Token *first;
|
||||||
@@ -193,8 +205,8 @@ class ExpressionEvaluator
|
|||||||
void operator = (const ExpressionEvaluator &other);
|
void operator = (const ExpressionEvaluator &other);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ExpressionEvaluator(Environment *env)
|
ExpressionEvaluator(Client *client, Environment *env)
|
||||||
: env(env), _lex(0)
|
: client(client), env(env), _lex(0)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
Value operator()(const Token *firstToken, const Token *lastToken,
|
Value operator()(const Token *firstToken, const Token *lastToken,
|
||||||
@@ -255,13 +267,13 @@ protected:
|
|||||||
} else if (isTokenDefined()) {
|
} else if (isTokenDefined()) {
|
||||||
++(*_lex);
|
++(*_lex);
|
||||||
if ((*_lex)->is(T_IDENTIFIER)) {
|
if ((*_lex)->is(T_IDENTIFIER)) {
|
||||||
_value.set_long(env->resolve(tokenSpell()) != 0);
|
_value.set_long(isMacroDefined(tokenSpell(), (*_lex)->offset, env, client));
|
||||||
++(*_lex);
|
++(*_lex);
|
||||||
return true;
|
return true;
|
||||||
} else if ((*_lex)->is(T_LPAREN)) {
|
} else if ((*_lex)->is(T_LPAREN)) {
|
||||||
++(*_lex);
|
++(*_lex);
|
||||||
if ((*_lex)->is(T_IDENTIFIER)) {
|
if ((*_lex)->is(T_IDENTIFIER)) {
|
||||||
_value.set_long(env->resolve(tokenSpell()) != 0);
|
_value.set_long(isMacroDefined(tokenSpell(), (*_lex)->offset, env, client));
|
||||||
++(*_lex);
|
++(*_lex);
|
||||||
if ((*_lex)->is(T_RPAREN)) {
|
if ((*_lex)->is(T_RPAREN)) {
|
||||||
++(*_lex);
|
++(*_lex);
|
||||||
@@ -519,6 +531,7 @@ protected:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Client *client;
|
||||||
Environment *env;
|
Environment *env;
|
||||||
QByteArray source;
|
QByteArray source;
|
||||||
RangeLexer *_lex;
|
RangeLexer *_lex;
|
||||||
@@ -983,7 +996,7 @@ void Preprocessor::expandObjectLikeMacro(TokenIterator identifierToken,
|
|||||||
{
|
{
|
||||||
if (client)
|
if (client)
|
||||||
client->startExpandingMacro(identifierToken->offset,
|
client->startExpandingMacro(identifierToken->offset,
|
||||||
*m, spell);
|
*m, spell, false);
|
||||||
|
|
||||||
m->setHidden(true);
|
m->setHidden(true);
|
||||||
expand(m->definition(), result);
|
expand(m->definition(), result);
|
||||||
@@ -1007,7 +1020,7 @@ void Preprocessor::expandFunctionLikeMacro(TokenIterator identifierToken,
|
|||||||
endOfText - beginOfText);
|
endOfText - beginOfText);
|
||||||
|
|
||||||
client->startExpandingMacro(identifierToken->offset,
|
client->startExpandingMacro(identifierToken->offset,
|
||||||
*m, text, actuals);
|
*m, text, false, actuals);
|
||||||
}
|
}
|
||||||
|
|
||||||
const bool was = markGeneratedTokens(true, identifierToken);
|
const bool was = markGeneratedTokens(true, identifierToken);
|
||||||
@@ -1253,7 +1266,7 @@ void Preprocessor::processIf(TokenIterator firstToken, TokenIterator lastToken)
|
|||||||
const char *first = startOfToken(*tk);
|
const char *first = startOfToken(*tk);
|
||||||
const char *last = startOfToken(*lastToken);
|
const char *last = startOfToken(*lastToken);
|
||||||
|
|
||||||
MacroExpander expandCondition (env);
|
MacroExpander expandCondition (env, 0, client, tk.dot()->offset);
|
||||||
QByteArray condition;
|
QByteArray condition;
|
||||||
condition.reserve(256);
|
condition.reserve(256);
|
||||||
expandCondition(first, last, &condition);
|
expandCondition(first, last, &condition);
|
||||||
@@ -1297,7 +1310,7 @@ void Preprocessor::processElif(TokenIterator firstToken, TokenIterator lastToken
|
|||||||
const char *first = startOfToken(*tk);
|
const char *first = startOfToken(*tk);
|
||||||
const char *last = startOfToken(*lastToken);
|
const char *last = startOfToken(*lastToken);
|
||||||
|
|
||||||
MacroExpander expandCondition (env);
|
MacroExpander expandCondition (env, 0, client, tk.dot()->offset);
|
||||||
QByteArray condition;
|
QByteArray condition;
|
||||||
condition.reserve(256);
|
condition.reserve(256);
|
||||||
expandCondition(first, last, &condition);
|
expandCondition(first, last, &condition);
|
||||||
@@ -1338,7 +1351,7 @@ void Preprocessor::processIfdef(bool checkUndefined,
|
|||||||
if (testIfLevel()) {
|
if (testIfLevel()) {
|
||||||
if (tk->is(T_IDENTIFIER)) {
|
if (tk->is(T_IDENTIFIER)) {
|
||||||
const QByteArray macroName = tokenSpell(*tk);
|
const QByteArray macroName = tokenSpell(*tk);
|
||||||
bool value = env->resolve(macroName) != 0 || env->isBuiltinMacro(macroName);
|
bool value = isMacroDefined(macroName, tk->offset, env, client) || env->isBuiltinMacro(macroName);
|
||||||
|
|
||||||
if (checkUndefined)
|
if (checkUndefined)
|
||||||
value = ! value;
|
value = ! value;
|
||||||
@@ -1437,7 +1450,7 @@ int Preprocessor::skipping() const
|
|||||||
Value Preprocessor::evalExpression(TokenIterator firstToken, TokenIterator lastToken,
|
Value Preprocessor::evalExpression(TokenIterator firstToken, TokenIterator lastToken,
|
||||||
const QByteArray &source) const
|
const QByteArray &source) const
|
||||||
{
|
{
|
||||||
ExpressionEvaluator eval(env);
|
ExpressionEvaluator eval(client, env);
|
||||||
const Value result = eval(firstToken, lastToken, source);
|
const Value result = eval(firstToken, lastToken, source);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,9 +66,11 @@ inline static bool comment_p (const char *__first, const char *__last)
|
|||||||
return (*__first == '/' || *__first == '*');
|
return (*__first == '/' || *__first == '*');
|
||||||
}
|
}
|
||||||
|
|
||||||
MacroExpander::MacroExpander(Environment *env, pp_frame *frame)
|
MacroExpander::MacroExpander(Environment *env, pp_frame *frame, Client *client, unsigned start_offset)
|
||||||
: env(env),
|
: env(env),
|
||||||
frame(frame),
|
frame(frame),
|
||||||
|
client(client),
|
||||||
|
start_offset(start_offset),
|
||||||
lines(0)
|
lines(0)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
@@ -97,6 +99,7 @@ const char *MacroExpander::operator()(const char *first, const char *last,
|
|||||||
const char *MacroExpander::expand(const char *__first, const char *__last,
|
const char *MacroExpander::expand(const char *__first, const char *__last,
|
||||||
QByteArray *__result)
|
QByteArray *__result)
|
||||||
{
|
{
|
||||||
|
const char *start = __first;
|
||||||
__first = skip_blanks (__first, __last);
|
__first = skip_blanks (__first, __last);
|
||||||
lines = skip_blanks.lines;
|
lines = skip_blanks.lines;
|
||||||
|
|
||||||
@@ -284,6 +287,9 @@ const char *MacroExpander::expand(const char *__first, const char *__last,
|
|||||||
|
|
||||||
if (! macro->definition().isEmpty())
|
if (! macro->definition().isEmpty())
|
||||||
{
|
{
|
||||||
|
if (client)
|
||||||
|
client->startExpandingMacro(start_offset + (name_begin-start), *macro, fast_name, true);
|
||||||
|
|
||||||
macro->setHidden(true);
|
macro->setHidden(true);
|
||||||
|
|
||||||
QByteArray __tmp;
|
QByteArray __tmp;
|
||||||
@@ -310,6 +316,9 @@ const char *MacroExpander::expand(const char *__first, const char *__last,
|
|||||||
}
|
}
|
||||||
|
|
||||||
macro->setHidden(false);
|
macro->setHidden(false);
|
||||||
|
|
||||||
|
if (client)
|
||||||
|
client->stopExpandingMacro(start_offset + (name_begin-start), *macro);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! m)
|
if (! m)
|
||||||
@@ -330,6 +339,7 @@ const char *MacroExpander::expand(const char *__first, const char *__last,
|
|||||||
}
|
}
|
||||||
|
|
||||||
QVector<QByteArray> actuals;
|
QVector<QByteArray> actuals;
|
||||||
|
QVector<MacroArgumentReference> actuals_ref;
|
||||||
actuals.reserve (5);
|
actuals.reserve (5);
|
||||||
++arg_it; // skip '('
|
++arg_it; // skip '('
|
||||||
|
|
||||||
@@ -338,6 +348,7 @@ const char *MacroExpander::expand(const char *__first, const char *__last,
|
|||||||
const char *arg_end = skip_argument_variadics (actuals, macro, arg_it, __last);
|
const char *arg_end = skip_argument_variadics (actuals, macro, arg_it, __last);
|
||||||
if (arg_it != arg_end)
|
if (arg_it != arg_end)
|
||||||
{
|
{
|
||||||
|
actuals_ref.append(MacroArgumentReference(start_offset + (arg_it-start), arg_end - arg_it));
|
||||||
const QByteArray actual (arg_it, arg_end - arg_it);
|
const QByteArray actual (arg_it, arg_end - arg_it);
|
||||||
QByteArray expanded;
|
QByteArray expanded;
|
||||||
expand_actual (actual.constBegin (), actual.constEnd (), &expanded);
|
expand_actual (actual.constBegin (), actual.constEnd (), &expanded);
|
||||||
@@ -350,6 +361,7 @@ const char *MacroExpander::expand(const char *__first, const char *__last,
|
|||||||
++arg_it; // skip ','
|
++arg_it; // skip ','
|
||||||
|
|
||||||
arg_end = skip_argument_variadics (actuals, macro, arg_it, __last);
|
arg_end = skip_argument_variadics (actuals, macro, arg_it, __last);
|
||||||
|
actuals_ref.append(MacroArgumentReference(start_offset + (arg_it-start), arg_end - arg_it));
|
||||||
const QByteArray actual (arg_it, arg_end - arg_it);
|
const QByteArray actual (arg_it, arg_end - arg_it);
|
||||||
QByteArray expanded;
|
QByteArray expanded;
|
||||||
expand_actual (actual.constBegin (), actual.constEnd (), &expanded);
|
expand_actual (actual.constBegin (), actual.constEnd (), &expanded);
|
||||||
@@ -363,11 +375,17 @@ const char *MacroExpander::expand(const char *__first, const char *__last,
|
|||||||
++arg_it; // skip ')'
|
++arg_it; // skip ')'
|
||||||
__first = arg_it;
|
__first = arg_it;
|
||||||
|
|
||||||
|
if (client)
|
||||||
|
client->startExpandingMacro(start_offset + (name_begin-start), *macro, fast_name, true, actuals_ref);
|
||||||
|
|
||||||
pp_frame frame (macro, actuals);
|
pp_frame frame (macro, actuals);
|
||||||
MacroExpander expand_macro (env, &frame);
|
MacroExpander expand_macro (env, &frame);
|
||||||
macro->setHidden(true);
|
macro->setHidden(true);
|
||||||
expand_macro (macro->definition(), __result);
|
expand_macro (macro->definition(), __result);
|
||||||
macro->setHidden(false);
|
macro->setHidden(false);
|
||||||
|
|
||||||
|
if (client)
|
||||||
|
client->stopExpandingMacro(start_offset + (name_begin-start), *macro);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
__result->append(*__first++);
|
__result->append(*__first++);
|
||||||
|
|||||||
@@ -56,6 +56,7 @@
|
|||||||
namespace CPlusPlus {
|
namespace CPlusPlus {
|
||||||
|
|
||||||
class Environment;
|
class Environment;
|
||||||
|
class Client;
|
||||||
|
|
||||||
struct pp_frame;
|
struct pp_frame;
|
||||||
|
|
||||||
@@ -63,6 +64,8 @@ class MacroExpander
|
|||||||
{
|
{
|
||||||
Environment *env;
|
Environment *env;
|
||||||
pp_frame *frame;
|
pp_frame *frame;
|
||||||
|
Client *client;
|
||||||
|
unsigned start_offset;
|
||||||
|
|
||||||
pp_skip_number skip_number;
|
pp_skip_number skip_number;
|
||||||
pp_skip_identifier skip_identifier;
|
pp_skip_identifier skip_identifier;
|
||||||
@@ -76,7 +79,7 @@ class MacroExpander
|
|||||||
const QByteArray *resolve_formal(const QByteArray &name);
|
const QByteArray *resolve_formal(const QByteArray &name);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MacroExpander(Environment *env, pp_frame *frame = 0);
|
MacroExpander(Environment *env, pp_frame *frame = 0, Client *client = 0, unsigned start_offset = 0);
|
||||||
|
|
||||||
const char *operator()(const char *first, const char *last,
|
const char *operator()(const char *first, const char *last,
|
||||||
QByteArray *result);
|
QByteArray *result);
|
||||||
|
|||||||
@@ -205,17 +205,17 @@ public slots:
|
|||||||
bool closeAllEditors(bool askAboutModifiedEditors = true);
|
bool closeAllEditors(bool askAboutModifiedEditors = true);
|
||||||
void openInExternalEditor();
|
void openInExternalEditor();
|
||||||
|
|
||||||
private slots:
|
|
||||||
bool saveFile(Core::IEditor *editor = 0);
|
bool saveFile(Core::IEditor *editor = 0);
|
||||||
bool saveFileAs(Core::IEditor *editor = 0);
|
bool saveFileAs(Core::IEditor *editor = 0);
|
||||||
|
void revertToSaved();
|
||||||
void closeEditor();
|
void closeEditor();
|
||||||
void closeOtherEditors();
|
void closeOtherEditors();
|
||||||
|
|
||||||
|
private slots:
|
||||||
void gotoNextDocHistory();
|
void gotoNextDocHistory();
|
||||||
void gotoPreviousDocHistory();
|
void gotoPreviousDocHistory();
|
||||||
void handleContextChange(Core::IContext *context);
|
void handleContextChange(Core::IContext *context);
|
||||||
void updateActions();
|
void updateActions();
|
||||||
void revertToSaved();
|
|
||||||
void makeCurrentEditorWritable();
|
void makeCurrentEditorWritable();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|||||||
@@ -857,22 +857,9 @@ void CPPEditor::findReferences()
|
|||||||
lastVisibleSymbol,
|
lastVisibleSymbol,
|
||||||
TypeOfExpression::Preprocess);
|
TypeOfExpression::Preprocess);
|
||||||
|
|
||||||
if (! results.isEmpty()) {
|
if (Symbol *canonicalSymbol = LookupContext::canonicalSymbol(results)) {
|
||||||
TypeOfExpression::Result result = results.first();
|
m_modelManager->findReferences(canonicalSymbol);
|
||||||
Symbol *symbol = result.second;
|
|
||||||
qDebug() << "result:" << symbol->fileName() << symbol->line() << symbol->column();
|
|
||||||
m_modelManager->findReferences(symbol);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
LookupContext context(
|
|
||||||
Overview oo;
|
|
||||||
qDebug() << "==============> filename:" << symbol->fileName()
|
|
||||||
<< "name:" << oo(symbol->name());
|
|
||||||
m_modelManager->findReferences(symbol);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPPEditor::renameSymbolUnderCursor()
|
void CPPEditor::renameSymbolUnderCursor()
|
||||||
@@ -1345,6 +1332,39 @@ bool CPPEditor::isElectricCharacter(const QChar &ch) const
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void countBracket(QChar open, QChar close, QChar c, int *errors, int *stillopen)
|
||||||
|
{
|
||||||
|
if (c == open)
|
||||||
|
++*stillopen;
|
||||||
|
else if (c == close)
|
||||||
|
--*stillopen;
|
||||||
|
|
||||||
|
if (*stillopen < 0) {
|
||||||
|
*errors += -1 * (*stillopen);
|
||||||
|
*stillopen = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void countBrackets(QTextCursor cursor, int from, int end, QChar open, QChar close, int *errors, int *stillopen)
|
||||||
|
{
|
||||||
|
cursor.setPosition(from);
|
||||||
|
QTextBlock block = cursor.block();
|
||||||
|
while (block.isValid() && block.position() < end) {
|
||||||
|
TextEditor::Parentheses parenList = TextEditor::TextEditDocumentLayout::parentheses(block);
|
||||||
|
if (!parenList.isEmpty() && !TextEditor::TextEditDocumentLayout::ifdefedOut(block)) {
|
||||||
|
for (int i = 0; i < parenList.count(); ++i) {
|
||||||
|
TextEditor::Parenthesis paren = parenList.at(i);
|
||||||
|
int position = block.position() + paren.pos;
|
||||||
|
if (position < from || position >= end)
|
||||||
|
continue;
|
||||||
|
countBracket(open, close, paren.chr, errors, stillopen);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
block = block.next();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QString CPPEditor::autoComplete(QTextCursor &cursor, const QString &textToInsert) const
|
QString CPPEditor::autoComplete(QTextCursor &cursor, const QString &textToInsert) const
|
||||||
{
|
{
|
||||||
const bool checkBlockEnd = m_allowSkippingOfBlockEnd;
|
const bool checkBlockEnd = m_allowSkippingOfBlockEnd;
|
||||||
@@ -1356,6 +1376,33 @@ QString CPPEditor::autoComplete(QTextCursor &cursor, const QString &textToInsert
|
|||||||
QString text = textToInsert;
|
QString text = textToInsert;
|
||||||
const QChar lookAhead = characterAt(cursor.selectionEnd());
|
const QChar lookAhead = characterAt(cursor.selectionEnd());
|
||||||
|
|
||||||
|
QChar character = textToInsert.at(0);
|
||||||
|
QString parentheses = QLatin1String("()");
|
||||||
|
QString brackets = QLatin1String("[]");
|
||||||
|
if (parentheses.contains(character) || brackets.contains(character)) {
|
||||||
|
QTextCursor tmp= cursor;
|
||||||
|
TextEditor::TextBlockUserData::findPreviousBlockOpenParenthesis(&tmp);
|
||||||
|
int blockStart = tmp.isNull() ? 0 : tmp.position();
|
||||||
|
tmp = cursor;
|
||||||
|
TextEditor::TextBlockUserData::findNextBlockClosingParenthesis(&tmp);
|
||||||
|
int blockEnd = tmp.isNull() ? (cursor.document()->characterCount()-1) : tmp.position();
|
||||||
|
QChar openChar = parentheses.contains(character) ? QLatin1Char('(') : QLatin1Char('[');
|
||||||
|
QChar closeChar = parentheses.contains(character) ? QLatin1Char(')') : QLatin1Char(']');
|
||||||
|
|
||||||
|
int errors = 0;
|
||||||
|
int stillopen = 0;
|
||||||
|
countBrackets(cursor, blockStart, blockEnd, openChar, closeChar, &errors, &stillopen);
|
||||||
|
int errorsBeforeInsertion = errors + stillopen;
|
||||||
|
errors = 0;
|
||||||
|
stillopen = 0;
|
||||||
|
countBrackets(cursor, blockStart, cursor.position(), openChar, closeChar, &errors, &stillopen);
|
||||||
|
countBracket(openChar, closeChar, character, &errors, &stillopen);
|
||||||
|
countBrackets(cursor, cursor.position(), blockEnd, openChar, closeChar, &errors, &stillopen);
|
||||||
|
int errorsAfterInsertion = errors + stillopen;
|
||||||
|
if (errorsAfterInsertion < errorsBeforeInsertion)
|
||||||
|
return QString(); // insertion fixes parentheses or bracket errors, do not auto complete
|
||||||
|
}
|
||||||
|
|
||||||
MatchingText matchingText;
|
MatchingText matchingText;
|
||||||
int skippedChars = 0;
|
int skippedChars = 0;
|
||||||
const QString autoText = matchingText.insertMatchingBrace(cursor, text, lookAhead, &skippedChars);
|
const QString autoText = matchingText.insertMatchingBrace(cursor, text, lookAhead, &skippedChars);
|
||||||
@@ -1392,6 +1439,32 @@ bool CPPEditor::autoBackspace(QTextCursor &cursor)
|
|||||||
QChar lookAhead = characterAt(pos);
|
QChar lookAhead = characterAt(pos);
|
||||||
QChar lookBehind = characterAt(pos-1);
|
QChar lookBehind = characterAt(pos-1);
|
||||||
QChar lookFurtherBehind = characterAt(pos-2);
|
QChar lookFurtherBehind = characterAt(pos-2);
|
||||||
|
|
||||||
|
QChar character = lookBehind;
|
||||||
|
if (character == QLatin1Char('(') || character == QLatin1Char('[')) {
|
||||||
|
QTextCursor tmp = cursor;
|
||||||
|
TextEditor::TextBlockUserData::findPreviousBlockOpenParenthesis(&tmp);
|
||||||
|
int blockStart = tmp.isNull() ? 0 : tmp.position();
|
||||||
|
tmp = cursor;
|
||||||
|
TextEditor::TextBlockUserData::findNextBlockClosingParenthesis(&tmp);
|
||||||
|
int blockEnd = tmp.isNull() ? (cursor.document()->characterCount()-1) : tmp.position();
|
||||||
|
QChar openChar = character;
|
||||||
|
QChar closeChar = (character == QLatin1Char('(')) ? QLatin1Char(')') : QLatin1Char(']');
|
||||||
|
|
||||||
|
int errors = 0;
|
||||||
|
int stillopen = 0;
|
||||||
|
countBrackets(cursor, blockStart, blockEnd, openChar, closeChar, &errors, &stillopen);
|
||||||
|
int errorsBeforeDeletion = errors + stillopen;
|
||||||
|
errors = 0;
|
||||||
|
stillopen = 0;
|
||||||
|
countBrackets(cursor, blockStart, pos - 1, openChar, closeChar, &errors, &stillopen);
|
||||||
|
countBrackets(cursor, pos, blockEnd, openChar, closeChar, &errors, &stillopen);
|
||||||
|
int errorsAfterDeletion = errors + stillopen;
|
||||||
|
|
||||||
|
if (errorsAfterDeletion < errorsBeforeDeletion)
|
||||||
|
return false; // insertion fixes parentheses or bracket errors, do not auto complete
|
||||||
|
}
|
||||||
|
|
||||||
if ((lookBehind == QLatin1Char('(') && lookAhead == QLatin1Char(')'))
|
if ((lookBehind == QLatin1Char('(') && lookAhead == QLatin1Char(')'))
|
||||||
|| (lookBehind == QLatin1Char('[') && lookAhead == QLatin1Char(']'))
|
|| (lookBehind == QLatin1Char('[') && lookAhead == QLatin1Char(']'))
|
||||||
|| (lookBehind == QLatin1Char('"') && lookAhead == QLatin1Char('"')
|
|| (lookBehind == QLatin1Char('"') && lookAhead == QLatin1Char('"')
|
||||||
|
|||||||
@@ -52,12 +52,13 @@ void CppHighlighter::highlightBlock(const QString &text)
|
|||||||
QTextCharFormat emptyFormat;
|
QTextCharFormat emptyFormat;
|
||||||
|
|
||||||
const int previousState = previousBlockState();
|
const int previousState = previousBlockState();
|
||||||
int state = 0, braceDepth = 0;
|
int state = 0, initialBraceDepth = 0;
|
||||||
if (previousState != -1) {
|
if (previousState != -1) {
|
||||||
state = previousState & 0xff;
|
state = previousState & 0xff;
|
||||||
braceDepth = previousState >> 8;
|
initialBraceDepth = previousState >> 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int braceDepth = initialBraceDepth;
|
||||||
|
|
||||||
SimpleLexer tokenize;
|
SimpleLexer tokenize;
|
||||||
tokenize.setQtMocRunEnabled(false);
|
tokenize.setQtMocRunEnabled(false);
|
||||||
@@ -211,6 +212,10 @@ void CppHighlighter::highlightBlock(const QString &text)
|
|||||||
|
|
||||||
TextEditDocumentLayout::setParentheses(currentBlock(), parentheses);
|
TextEditDocumentLayout::setParentheses(currentBlock(), parentheses);
|
||||||
|
|
||||||
|
// if the block is ifdefed out, we only store the parentheses, but
|
||||||
|
// do not adjust the brace depth.
|
||||||
|
if (TextEditDocumentLayout::ifdefedOut(currentBlock()))
|
||||||
|
braceDepth = initialBraceDepth;
|
||||||
|
|
||||||
// optimization: if only the brace depth changes, we adjust subsequent blocks
|
// optimization: if only the brace depth changes, we adjust subsequent blocks
|
||||||
// to have QSyntaxHighlighter stop the rehighlighting
|
// to have QSyntaxHighlighter stop the rehighlighting
|
||||||
@@ -222,12 +227,7 @@ void CppHighlighter::highlightBlock(const QString &text)
|
|||||||
int delta = braceDepth - oldBraceDepth;
|
int delta = braceDepth - oldBraceDepth;
|
||||||
QTextBlock block = currentBlock().next();
|
QTextBlock block = currentBlock().next();
|
||||||
while (block.isValid()) {
|
while (block.isValid()) {
|
||||||
currentState = block.userState();
|
TextEditDocumentLayout::changeBraceDepth(block, delta);
|
||||||
if (currentState != -1) {
|
|
||||||
oldState = currentState & 0xff;
|
|
||||||
oldBraceDepth = currentState >> 8;
|
|
||||||
block.setUserState(((oldBraceDepth + delta) << 8 ) | oldState);
|
|
||||||
}
|
|
||||||
block = block.next();
|
block = block.next();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,10 +44,13 @@
|
|||||||
#include <Literals.h>
|
#include <Literals.h>
|
||||||
#include <TranslationUnit.h>
|
#include <TranslationUnit.h>
|
||||||
#include <Symbols.h>
|
#include <Symbols.h>
|
||||||
|
#include <Names.h>
|
||||||
|
#include <Scope.h>
|
||||||
|
|
||||||
#include <cplusplus/CppDocument.h>
|
#include <cplusplus/CppDocument.h>
|
||||||
#include <cplusplus/ExpressionUnderCursor.h>
|
#include <cplusplus/ExpressionUnderCursor.h>
|
||||||
#include <cplusplus/ResolveExpression.h>
|
#include <cplusplus/ResolveExpression.h>
|
||||||
|
#include <cplusplus/Overview.h>
|
||||||
|
|
||||||
#include <QtCore/QTime>
|
#include <QtCore/QTime>
|
||||||
#include <QtCore/QtConcurrentRun>
|
#include <QtCore/QtConcurrentRun>
|
||||||
@@ -69,13 +72,16 @@ public:
|
|||||||
_future(future),
|
_future(future),
|
||||||
_doc(doc),
|
_doc(doc),
|
||||||
_snapshot(snapshot),
|
_snapshot(snapshot),
|
||||||
_source(_doc->source())
|
_source(_doc->source()),
|
||||||
{ }
|
_sem(doc->control())
|
||||||
|
|
||||||
void operator()(Identifier *id, AST *ast)
|
|
||||||
{
|
{
|
||||||
|
_snapshot.insert(_doc);
|
||||||
|
}
|
||||||
|
|
||||||
|
void operator()(Symbol *symbol, Identifier *id, AST *ast)
|
||||||
|
{
|
||||||
|
_declSymbol = symbol;
|
||||||
_id = id;
|
_id = id;
|
||||||
_currentSymbol = _doc->globalNamespace();
|
|
||||||
_exprDoc = Document::create("<references>");
|
_exprDoc = Document::create("<references>");
|
||||||
accept(ast);
|
accept(ast);
|
||||||
}
|
}
|
||||||
@@ -122,55 +128,63 @@ protected:
|
|||||||
line, lineText, col, len));
|
line, lineText, col, len));
|
||||||
}
|
}
|
||||||
|
|
||||||
LookupContext currentContext() const
|
bool checkCandidates(const QList<Symbol *> &candidates) const
|
||||||
{
|
{
|
||||||
return LookupContext(_currentSymbol, _exprDoc, _doc, _snapshot);
|
// ### FIXME return isDeclSymbol(LookupContext::canonicalSymbol(candidates));
|
||||||
}
|
|
||||||
|
|
||||||
virtual bool visit(ClassSpecifierAST *ast)
|
|
||||||
{
|
|
||||||
_currentSymbol = ast->symbol;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool visit(NamespaceAST *ast)
|
bool isDeclSymbol(Symbol *symbol) const
|
||||||
{
|
{
|
||||||
_currentSymbol = ast->symbol;
|
if (! symbol)
|
||||||
return true;
|
return false;
|
||||||
|
|
||||||
|
else if (symbol == _declSymbol)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
else if (symbol->line() == _declSymbol->line() && symbol->column() == _declSymbol->column()) {
|
||||||
|
if (! qstrcmp(symbol->fileName(), _declSymbol->fileName()))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool visit(CompoundStatementAST *ast)
|
LookupContext currentContext(AST *ast) const
|
||||||
{
|
{
|
||||||
_currentSymbol = ast->symbol;
|
unsigned line, column;
|
||||||
return true;
|
getTokenStartPosition(ast->firstToken(), &line, &column);
|
||||||
}
|
Symbol *lastVisibleSymbol = _doc->findSymbolAt(line, column);
|
||||||
|
return LookupContext(lastVisibleSymbol, _exprDoc, _doc, _snapshot);
|
||||||
virtual bool visit(FunctionDefinitionAST *ast)
|
|
||||||
{
|
|
||||||
_currentSymbol = ast->symbol;
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool visit(QualifiedNameAST *ast)
|
virtual bool visit(QualifiedNameAST *ast)
|
||||||
{
|
{
|
||||||
return true;
|
if (! ast->name) {
|
||||||
|
//qWarning() << "invalid AST at" << _doc->fileName() << line << column;
|
||||||
|
ast->name = _sem.check(ast, /*scope */ static_cast<Scope *>(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
Q_ASSERT(ast->name != 0);
|
||||||
|
Identifier *id = ast->name->identifier();
|
||||||
|
if (id == _id && ast->unqualified_name) {
|
||||||
|
LookupContext context = currentContext(ast);
|
||||||
|
const QList<Symbol *> candidates = context.resolve(ast->name);
|
||||||
|
if (checkCandidates(candidates))
|
||||||
|
reportResult(ast->unqualified_name->firstToken());
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool visit(SimpleNameAST *ast)
|
virtual bool visit(SimpleNameAST *ast)
|
||||||
{
|
{
|
||||||
Identifier *id = identifier(ast->identifier_token);
|
Identifier *id = identifier(ast->identifier_token);
|
||||||
if (id == _id) {
|
if (id == _id) {
|
||||||
#if 0
|
LookupContext context = currentContext(ast);
|
||||||
LookupContext context = currentContext();
|
const QList<Symbol *> candidates = context.resolve(ast->name);
|
||||||
ResolveExpression resolveExpression(context);
|
if (checkCandidates(candidates))
|
||||||
QList<ResolveExpression::Result> results = resolveExpression(ast);
|
reportResult(ast->identifier_token);
|
||||||
if (! results.isEmpty()) {
|
|
||||||
ResolveExpression::Result result = results.first();
|
|
||||||
Symbol *resolvedSymbol = result.second;
|
|
||||||
qDebug() << "resolves to:" << resolvedSymbol->fileName() << resolvedSymbol->line();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
reportResult(ast->identifier_token);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@@ -179,20 +193,25 @@ protected:
|
|||||||
virtual bool visit(TemplateIdAST *ast)
|
virtual bool visit(TemplateIdAST *ast)
|
||||||
{
|
{
|
||||||
Identifier *id = identifier(ast->identifier_token);
|
Identifier *id = identifier(ast->identifier_token);
|
||||||
if (id == _id)
|
if (id == _id) {
|
||||||
reportResult(ast->identifier_token);
|
LookupContext context = currentContext(ast);
|
||||||
|
const QList<Symbol *> candidates = context.resolve(ast->name);
|
||||||
|
if (checkCandidates(candidates))
|
||||||
|
reportResult(ast->identifier_token);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QFutureInterface<Core::Utils::FileSearchResult> &_future;
|
QFutureInterface<Core::Utils::FileSearchResult> &_future;
|
||||||
Identifier *_id;
|
Identifier *_id; // ### remove me
|
||||||
|
Symbol *_declSymbol;
|
||||||
Document::Ptr _doc;
|
Document::Ptr _doc;
|
||||||
Snapshot _snapshot;
|
Snapshot _snapshot;
|
||||||
QByteArray _source;
|
QByteArray _source;
|
||||||
Symbol *_currentSymbol;
|
|
||||||
Document::Ptr _exprDoc;
|
Document::Ptr _exprDoc;
|
||||||
|
Semantic _sem;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // end of anonymous namespace
|
} // end of anonymous namespace
|
||||||
@@ -217,6 +236,9 @@ static void find_helper(QFutureInterface<Core::Utils::FileSearchResult> &future,
|
|||||||
QTime tm;
|
QTime tm;
|
||||||
tm.start();
|
tm.start();
|
||||||
|
|
||||||
|
Identifier *symbolId = symbol->identifier();
|
||||||
|
Q_ASSERT(symbolId != 0);
|
||||||
|
|
||||||
const QString fileName = QString::fromUtf8(symbol->fileName(), symbol->fileNameLength());
|
const QString fileName = QString::fromUtf8(symbol->fileName(), symbol->fileNameLength());
|
||||||
|
|
||||||
QStringList files(fileName);
|
QStringList files(fileName);
|
||||||
@@ -229,24 +251,30 @@ static void find_helper(QFutureInterface<Core::Utils::FileSearchResult> &future,
|
|||||||
for (int i = 0; i < files.size(); ++i) {
|
for (int i = 0; i < files.size(); ++i) {
|
||||||
const QString &fn = files.at(i);
|
const QString &fn = files.at(i);
|
||||||
future.setProgressValueAndText(i, QFileInfo(fn).fileName());
|
future.setProgressValueAndText(i, QFileInfo(fn).fileName());
|
||||||
|
|
||||||
|
Document::Ptr previousDoc = snapshot.value(fn);
|
||||||
|
if (previousDoc) {
|
||||||
|
Control *control = previousDoc->control();
|
||||||
|
Identifier *id = control->findIdentifier(symbolId->chars(), symbolId->size());
|
||||||
|
if (! id)
|
||||||
|
continue; // skip this document, it's not using symbolId.
|
||||||
|
}
|
||||||
|
|
||||||
QFile f(fn);
|
QFile f(fn);
|
||||||
if (! f.open(QFile::ReadOnly))
|
if (! f.open(QFile::ReadOnly))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
const QString source = QTextStream(&f).readAll();
|
const QString source = QTextStream(&f).readAll(); // ### FIXME
|
||||||
const QByteArray preprocessedCode = snapshot.preprocessedCode(source, fn);
|
const QByteArray preprocessedCode = snapshot.preprocessedCode(source, fn);
|
||||||
Document::Ptr doc = snapshot.documentFromSource(preprocessedCode, fn);
|
Document::Ptr doc = snapshot.documentFromSource(preprocessedCode, fn);
|
||||||
doc->tokenize();
|
doc->tokenize();
|
||||||
|
|
||||||
Identifier *symbolId = symbol->identifier();
|
|
||||||
Q_ASSERT(symbolId != 0);
|
|
||||||
|
|
||||||
Control *control = doc->control();
|
Control *control = doc->control();
|
||||||
if (Identifier *id = control->findIdentifier(symbolId->chars(), symbolId->size())) {
|
if (Identifier *id = control->findIdentifier(symbolId->chars(), symbolId->size())) {
|
||||||
doc->check();
|
doc->check();
|
||||||
TranslationUnit *unit = doc->translationUnit();
|
TranslationUnit *unit = doc->translationUnit();
|
||||||
Process process(future, doc, snapshot);
|
Process process(future, doc, snapshot);
|
||||||
process(id, unit->ast());
|
process(symbol, id, unit->ast());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
future.setProgressValue(files.size());
|
future.setProgressValue(files.size());
|
||||||
@@ -259,9 +287,7 @@ void CppFindReferences::findAll(const Snapshot &snapshot, Symbol *symbol)
|
|||||||
|
|
||||||
Core::ProgressManager *progressManager = Core::ICore::instance()->progressManager();
|
Core::ProgressManager *progressManager = Core::ICore::instance()->progressManager();
|
||||||
|
|
||||||
QFuture<Core::Utils::FileSearchResult> result =
|
QFuture<Core::Utils::FileSearchResult> result = QtConcurrent::run(&find_helper, snapshot, symbol);
|
||||||
QtConcurrent::run(&find_helper, snapshot, symbol);
|
|
||||||
|
|
||||||
m_watcher.setFuture(result);
|
m_watcher.setFuture(result);
|
||||||
|
|
||||||
Core::FutureProgress *progress = progressManager->addTask(result, tr("Searching..."),
|
Core::FutureProgress *progress = progressManager->addTask(result, tr("Searching..."),
|
||||||
|
|||||||
@@ -196,9 +196,12 @@ protected:
|
|||||||
void mergeEnvironment(CPlusPlus::Document::Ptr doc);
|
void mergeEnvironment(CPlusPlus::Document::Ptr doc);
|
||||||
|
|
||||||
virtual void macroAdded(const Macro ¯o);
|
virtual void macroAdded(const Macro ¯o);
|
||||||
|
virtual void passedMacroDefinitionCheck(unsigned offset, const Macro ¯o);
|
||||||
|
virtual void failedMacroDefinitionCheck(unsigned offset, const QByteArray &name);
|
||||||
virtual void startExpandingMacro(unsigned offset,
|
virtual void startExpandingMacro(unsigned offset,
|
||||||
const Macro ¯o,
|
const Macro ¯o,
|
||||||
const QByteArray &originalText,
|
const QByteArray &originalText,
|
||||||
|
bool inCondition,
|
||||||
const QVector<MacroArgumentReference> &actuals);
|
const QVector<MacroArgumentReference> &actuals);
|
||||||
virtual void stopExpandingMacro(unsigned offset, const Macro ¯o);
|
virtual void stopExpandingMacro(unsigned offset, const Macro ¯o);
|
||||||
virtual void startSkippingBlocks(unsigned offset);
|
virtual void startSkippingBlocks(unsigned offset);
|
||||||
@@ -446,16 +449,34 @@ void CppPreprocessor::macroAdded(const Macro ¯o)
|
|||||||
m_currentDoc->appendMacro(macro);
|
m_currentDoc->appendMacro(macro);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CppPreprocessor::passedMacroDefinitionCheck(unsigned offset, const Macro ¯o)
|
||||||
|
{
|
||||||
|
if (! m_currentDoc)
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_currentDoc->addMacroUse(macro, offset, macro.name().length(),
|
||||||
|
QVector<MacroArgumentReference>(), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CppPreprocessor::failedMacroDefinitionCheck(unsigned offset, const QByteArray &name)
|
||||||
|
{
|
||||||
|
if (! m_currentDoc)
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_currentDoc->addUndefinedMacroUse(name, offset);
|
||||||
|
}
|
||||||
|
|
||||||
void CppPreprocessor::startExpandingMacro(unsigned offset,
|
void CppPreprocessor::startExpandingMacro(unsigned offset,
|
||||||
const Macro ¯o,
|
const Macro ¯o,
|
||||||
const QByteArray &originalText,
|
const QByteArray &originalText,
|
||||||
|
bool inCondition,
|
||||||
const QVector<MacroArgumentReference> &actuals)
|
const QVector<MacroArgumentReference> &actuals)
|
||||||
{
|
{
|
||||||
if (! m_currentDoc)
|
if (! m_currentDoc)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
//qDebug() << "start expanding:" << macro.name << "text:" << originalText;
|
//qDebug() << "start expanding:" << macro.name() << "text:" << originalText;
|
||||||
m_currentDoc->addMacroUse(macro, offset, originalText.length(), actuals);
|
m_currentDoc->addMacroUse(macro, offset, originalText.length(), actuals, inCondition);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppPreprocessor::stopExpandingMacro(unsigned, const Macro &)
|
void CppPreprocessor::stopExpandingMacro(unsigned, const Macro &)
|
||||||
|
|||||||
@@ -36,11 +36,11 @@
|
|||||||
#include <QtCore/QAbstractItemModel>
|
#include <QtCore/QAbstractItemModel>
|
||||||
|
|
||||||
namespace Debugger {
|
namespace Debugger {
|
||||||
|
class DebuggerManager;
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
class BreakpointMarker;
|
class BreakpointMarker;
|
||||||
class BreakHandler;
|
class BreakHandler;
|
||||||
class DebuggerManager;
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -52,6 +52,7 @@
|
|||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
#include <utils/winutils.h>
|
#include <utils/winutils.h>
|
||||||
#include <utils/consoleprocess.h>
|
#include <utils/consoleprocess.h>
|
||||||
|
#include <utils/fancymainwindow.h>
|
||||||
#include <texteditor/itexteditor.h>
|
#include <texteditor/itexteditor.h>
|
||||||
|
|
||||||
#include <QtCore/QDebug>
|
#include <QtCore/QDebug>
|
||||||
@@ -367,7 +368,7 @@ bool CdbDebugEnginePrivate::init(QString *errorMessage)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
IDebuggerEngine *CdbDebugEngine::create(DebuggerManager *manager,
|
IDebuggerEngine *CdbDebugEngine::create(Debugger::DebuggerManager *manager,
|
||||||
const QSharedPointer<CdbOptions> &options,
|
const QSharedPointer<CdbOptions> &options,
|
||||||
QString *errorMessage)
|
QString *errorMessage)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -36,9 +36,10 @@
|
|||||||
#include <QtCore/QSharedPointer>
|
#include <QtCore/QSharedPointer>
|
||||||
|
|
||||||
namespace Debugger {
|
namespace Debugger {
|
||||||
|
class DebuggerManager;
|
||||||
|
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
class DebuggerManager;
|
|
||||||
class DisassemblerViewAgent;
|
class DisassemblerViewAgent;
|
||||||
class CdbDebugEventCallback;
|
class CdbDebugEventCallback;
|
||||||
class CdbDebugOutput;
|
class CdbDebugOutput;
|
||||||
|
|||||||
@@ -42,9 +42,10 @@
|
|||||||
#include <QtCore/QMap>
|
#include <QtCore/QMap>
|
||||||
|
|
||||||
namespace Debugger {
|
namespace Debugger {
|
||||||
|
class DebuggerManager;
|
||||||
|
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
class DebuggerManager;
|
|
||||||
class WatchHandler;
|
class WatchHandler;
|
||||||
class CdbStackFrameContext;
|
class CdbStackFrameContext;
|
||||||
class CdbStackTraceContext;
|
class CdbStackTraceContext;
|
||||||
|
|||||||
@@ -35,8 +35,10 @@
|
|||||||
#include <QtCore/QStringList>
|
#include <QtCore/QStringList>
|
||||||
|
|
||||||
namespace Debugger {
|
namespace Debugger {
|
||||||
namespace Internal {
|
|
||||||
class DebuggerManager;
|
class DebuggerManager;
|
||||||
|
|
||||||
|
namespace Internal {
|
||||||
|
|
||||||
class CdbDebugEngine;
|
class CdbDebugEngine;
|
||||||
|
|
||||||
// Base class for event callbacks that takes care
|
// Base class for event callbacks that takes care
|
||||||
|
|||||||
@@ -37,11 +37,11 @@
|
|||||||
#include <QtCore/QMap>
|
#include <QtCore/QMap>
|
||||||
|
|
||||||
namespace Debugger {
|
namespace Debugger {
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
struct CdbComInterfaces;
|
|
||||||
class DebuggerManager;
|
class DebuggerManager;
|
||||||
|
|
||||||
|
namespace Internal {
|
||||||
|
struct CdbComInterfaces;
|
||||||
|
|
||||||
/* For code clarity, all the stuff related to custom dumpers goes here.
|
/* For code clarity, all the stuff related to custom dumpers goes here.
|
||||||
* "Custom dumper" is a library compiled against the current
|
* "Custom dumper" is a library compiled against the current
|
||||||
* Qt containing functions to evaluate values of Qt classes
|
* Qt containing functions to evaluate values of Qt classes
|
||||||
|
|||||||
@@ -4,14 +4,12 @@ TARGET = Debugger
|
|||||||
# DEFINES += QT_USE_FAST_OPERATOR_PLUS
|
# DEFINES += QT_USE_FAST_OPERATOR_PLUS
|
||||||
# DEFINES += QT_USE_FAST_CONCATENATION
|
# DEFINES += QT_USE_FAST_CONCATENATION
|
||||||
# CONFIG += single
|
# CONFIG += single
|
||||||
|
|
||||||
include(../../qtcreatorplugin.pri)
|
include(../../qtcreatorplugin.pri)
|
||||||
include(../../plugins/coreplugin/coreplugin.pri)
|
include(debugger_dependencies.pri)
|
||||||
include(../../plugins/cpptools/cpptools.pri)
|
|
||||||
include(../../plugins/find/find.pri)
|
DEFINES += DEBUGGER_LIBRARY
|
||||||
include(../../plugins/projectexplorer/projectexplorer.pri)
|
|
||||||
include(../../plugins/texteditor/texteditor.pri)
|
|
||||||
include(../../libs/cplusplus/cplusplus.pri)
|
|
||||||
include(../../libs/utils/utils.pri)
|
|
||||||
INCLUDEPATH += $$PWD/../../libs/utils
|
INCLUDEPATH += $$PWD/../../libs/utils
|
||||||
QT += gui \
|
QT += gui \
|
||||||
network \
|
network \
|
||||||
@@ -23,10 +21,12 @@ HEADERS += breakhandler.h \
|
|||||||
debuggerconstants.h \
|
debuggerconstants.h \
|
||||||
debuggerdialogs.h \
|
debuggerdialogs.h \
|
||||||
debuggermanager.h \
|
debuggermanager.h \
|
||||||
|
debugger_global.h \
|
||||||
debuggeroutputwindow.h \
|
debuggeroutputwindow.h \
|
||||||
debuggerplugin.h \
|
debuggerplugin.h \
|
||||||
debuggerrunner.h \
|
debuggerrunner.h \
|
||||||
debuggertooltip.h \
|
debuggertooltip.h \
|
||||||
|
debuggerstringutils.h \
|
||||||
watchutils.h \
|
watchutils.h \
|
||||||
idebuggerengine.h \
|
idebuggerengine.h \
|
||||||
imports.h \
|
imports.h \
|
||||||
|
|||||||
7
src/plugins/debugger/debugger_dependencies.pri
Normal file
7
src/plugins/debugger/debugger_dependencies.pri
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
include(../../plugins/coreplugin/coreplugin.pri)
|
||||||
|
include(../../plugins/cpptools/cpptools.pri)
|
||||||
|
include(../../plugins/find/find.pri)
|
||||||
|
include(../../plugins/projectexplorer/projectexplorer.pri)
|
||||||
|
include(../../plugins/texteditor/texteditor.pri)
|
||||||
|
include(../../libs/cplusplus/cplusplus.pri)
|
||||||
|
include(../../libs/utils/utils.pri)
|
||||||
41
src/plugins/debugger/debugger_global.h
Normal file
41
src/plugins/debugger/debugger_global.h
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
/**************************************************************************
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator
|
||||||
|
**
|
||||||
|
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||||
|
**
|
||||||
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||||
|
**
|
||||||
|
** Commercial Usage
|
||||||
|
**
|
||||||
|
** Licensees holding valid Qt Commercial licenses may use this file in
|
||||||
|
** accordance with the Qt Commercial License Agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Nokia.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
**
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 as published by the Free Software
|
||||||
|
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||||
|
** packaging of this file. Please review the following information to
|
||||||
|
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||||
|
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** If you are unsure which license is appropriate for your use, please
|
||||||
|
** contact the sales department at http://qt.nokia.com/contact.
|
||||||
|
**
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
|
#ifndef DEBUGGERGLOBAL_H
|
||||||
|
#define DEBUGGERGLOBAL_H
|
||||||
|
|
||||||
|
#include <QtCore/QtGlobal>
|
||||||
|
|
||||||
|
#if defined(DEBUGGER_LIBRARY)
|
||||||
|
# define DEBUGGER_EXPORT Q_DECL_EXPORT
|
||||||
|
#else
|
||||||
|
# define DEBUGGER_EXPORT Q_DECL_IMPORT
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // DEBUGGERGLOBAL_H
|
||||||
@@ -127,6 +127,22 @@ Core::Utils::SavedAction *theDebuggerAction(int code);
|
|||||||
bool theDebuggerBoolSetting(int code);
|
bool theDebuggerBoolSetting(int code);
|
||||||
QString theDebuggerStringSetting(int code);
|
QString theDebuggerStringSetting(int code);
|
||||||
|
|
||||||
|
struct DebuggerManagerActions {
|
||||||
|
QAction *continueAction;
|
||||||
|
QAction *stopAction;
|
||||||
|
QAction *resetAction; // FIXME: Should not be needed in a stable release
|
||||||
|
QAction *stepAction;
|
||||||
|
QAction *stepOutAction;
|
||||||
|
QAction *runToLineAction;
|
||||||
|
QAction *runToFunctionAction;
|
||||||
|
QAction *jumpToLineAction;
|
||||||
|
QAction *nextAction;
|
||||||
|
QAction *watchAction;
|
||||||
|
QAction *breakAction;
|
||||||
|
QAction *sepAction;
|
||||||
|
QAction *reverseDirectionAction;
|
||||||
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
} // namespace Debugger
|
} // namespace Debugger
|
||||||
|
|
||||||
|
|||||||
@@ -28,6 +28,7 @@
|
|||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
#include "debuggeragents.h"
|
#include "debuggeragents.h"
|
||||||
|
#include "debuggerstringutils.h"
|
||||||
#include "idebuggerengine.h"
|
#include "idebuggerengine.h"
|
||||||
|
|
||||||
#include <coreplugin/coreconstants.h>
|
#include <coreplugin/coreconstants.h>
|
||||||
@@ -193,6 +194,7 @@ DisassemblerViewAgent::~DisassemblerViewAgent()
|
|||||||
if (d->editor)
|
if (d->editor)
|
||||||
d->editor->deleteLater();
|
d->editor->deleteLater();
|
||||||
delete d;
|
delete d;
|
||||||
|
d = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DisassemblerViewAgent::setFrame(const StackFrame &frame)
|
void DisassemblerViewAgent::setFrame(const StackFrame &frame)
|
||||||
@@ -206,12 +208,10 @@ void DisassemblerViewAgent::setFrame(const StackFrame &frame)
|
|||||||
|
|
||||||
void DisassemblerViewAgent::setContents(const QString &contents)
|
void DisassemblerViewAgent::setContents(const QString &contents)
|
||||||
{
|
{
|
||||||
|
QTC_ASSERT(d, return);
|
||||||
using namespace Core;
|
using namespace Core;
|
||||||
using namespace TextEditor;
|
using namespace TextEditor;
|
||||||
|
|
||||||
if (!d->editor)
|
|
||||||
return;
|
|
||||||
|
|
||||||
QPlainTextEdit *plainTextEdit = 0;
|
QPlainTextEdit *plainTextEdit = 0;
|
||||||
EditorManager *editorManager = EditorManager::instance();
|
EditorManager *editorManager = EditorManager::instance();
|
||||||
if (!d->editor) {
|
if (!d->editor) {
|
||||||
|
|||||||
@@ -42,9 +42,9 @@
|
|||||||
|
|
||||||
|
|
||||||
namespace Debugger {
|
namespace Debugger {
|
||||||
|
class DebuggerManager;
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
class DebuggerManager;
|
|
||||||
struct DisassemblerViewAgentPrivate;
|
struct DisassemblerViewAgentPrivate;
|
||||||
|
|
||||||
class MemoryViewAgent : public QObject
|
class MemoryViewAgent : public QObject
|
||||||
|
|||||||
@@ -60,8 +60,6 @@ namespace Internal {
|
|||||||
}
|
}
|
||||||
} // namespace Constants
|
} // namespace Constants
|
||||||
|
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
enum DebuggerState
|
enum DebuggerState
|
||||||
{
|
{
|
||||||
DebuggerNotReady, // Debugger not started
|
DebuggerNotReady, // Debugger not started
|
||||||
@@ -118,7 +116,6 @@ enum LogChannel
|
|||||||
LogMisc
|
LogMisc
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
|
||||||
} // namespace Debugger
|
} // namespace Debugger
|
||||||
|
|
||||||
#endif // DEBUGGERCONSTANTS_H
|
#endif // DEBUGGERCONSTANTS_H
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -30,31 +30,29 @@
|
|||||||
#ifndef DEBUGGER_DEBUGGERMANAGER_H
|
#ifndef DEBUGGER_DEBUGGERMANAGER_H
|
||||||
#define DEBUGGER_DEBUGGERMANAGER_H
|
#define DEBUGGER_DEBUGGERMANAGER_H
|
||||||
|
|
||||||
|
#include "debugger_global.h"
|
||||||
#include "debuggerconstants.h"
|
#include "debuggerconstants.h"
|
||||||
|
|
||||||
#include <utils/fancymainwindow.h>
|
|
||||||
|
|
||||||
#include <QtCore/QByteArray>
|
|
||||||
#include <QtCore/QObject>
|
#include <QtCore/QObject>
|
||||||
|
#include <QtCore/QSharedPointer>
|
||||||
#include <QtCore/QStringList>
|
#include <QtCore/QStringList>
|
||||||
#include <QtCore/QVariant>
|
#include <QtCore/QVariant>
|
||||||
#include <QtCore/QSharedPointer>
|
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
class QAction;
|
class QAction;
|
||||||
class QAbstractItemModel;
|
|
||||||
class QDockWidget;
|
class QDockWidget;
|
||||||
class QLabel;
|
class QLabel;
|
||||||
class QMessageBox;
|
|
||||||
class QModelIndex;
|
|
||||||
class QPoint;
|
|
||||||
class QTimer;
|
|
||||||
class QWidget;
|
|
||||||
class QDebug;
|
class QDebug;
|
||||||
|
class QAbstractItemModel;
|
||||||
|
class QPoint;
|
||||||
|
class QVariant;
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
class IOptionsPage;
|
class IOptionsPage;
|
||||||
|
namespace Utils {
|
||||||
|
class FancyMainWindow;
|
||||||
|
}
|
||||||
} // namespace Core
|
} // namespace Core
|
||||||
|
|
||||||
namespace TextEditor {
|
namespace TextEditor {
|
||||||
@@ -64,15 +62,8 @@ class ITextEditor;
|
|||||||
namespace Debugger {
|
namespace Debugger {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
typedef QLatin1Char _c;
|
|
||||||
typedef QLatin1String __;
|
|
||||||
inline QString _(const char *s) { return QString::fromLatin1(s); }
|
|
||||||
inline QString _(const QByteArray &ba) { return QString::fromLatin1(ba, ba.size()); }
|
|
||||||
|
|
||||||
class DebuggerOutputWindow;
|
class DebuggerOutputWindow;
|
||||||
class DebuggerRunControl;
|
|
||||||
class DebuggerPlugin;
|
class DebuggerPlugin;
|
||||||
class DebugMode;
|
|
||||||
|
|
||||||
class BreakHandler;
|
class BreakHandler;
|
||||||
class BreakpointData;
|
class BreakpointData;
|
||||||
@@ -85,8 +76,23 @@ class Symbol;
|
|||||||
class ThreadsHandler;
|
class ThreadsHandler;
|
||||||
class WatchData;
|
class WatchData;
|
||||||
class WatchHandler;
|
class WatchHandler;
|
||||||
|
class IDebuggerEngine;
|
||||||
|
class GdbEngine;
|
||||||
|
class ScriptEngine;
|
||||||
|
class CdbDebugEngine;
|
||||||
|
struct CdbDebugEnginePrivate;
|
||||||
|
struct DebuggerManagerActions;
|
||||||
|
class DebuggerPlugin;
|
||||||
|
class CdbDebugEventCallback;
|
||||||
|
class CdbDumperHelper;
|
||||||
|
class CdbExceptionLoggerEventCallback;
|
||||||
|
class GdbEngine;
|
||||||
|
class TcfEngine;
|
||||||
|
class CdbDebugEngine;
|
||||||
|
struct CdbDebugEnginePrivate;
|
||||||
|
} // namespace Internal
|
||||||
|
|
||||||
class DebuggerStartParameters
|
class DEBUGGER_EXPORT DebuggerStartParameters
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DebuggerStartParameters();
|
DebuggerStartParameters();
|
||||||
@@ -113,13 +119,8 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
typedef QSharedPointer<DebuggerStartParameters> DebuggerStartParametersPtr;
|
typedef QSharedPointer<DebuggerStartParameters> DebuggerStartParametersPtr;
|
||||||
QDebug operator<<(QDebug str, const DebuggerStartParameters &);
|
|
||||||
|
|
||||||
class IDebuggerEngine;
|
DEBUGGER_EXPORT QDebug operator<<(QDebug str, const DebuggerStartParameters &);
|
||||||
class GdbEngine;
|
|
||||||
class ScriptEngine;
|
|
||||||
class CdbDebugEngine;
|
|
||||||
struct CdbDebugEnginePrivate;
|
|
||||||
|
|
||||||
// Flags for initialization
|
// Flags for initialization
|
||||||
enum DebuggerEngineTypeFlags
|
enum DebuggerEngineTypeFlags
|
||||||
@@ -140,7 +141,9 @@ QDebug operator<<(QDebug d, DebuggerState state);
|
|||||||
// DebuggerManager
|
// DebuggerManager
|
||||||
//
|
//
|
||||||
|
|
||||||
class DebuggerManager : public QObject
|
struct DebuggerManagerPrivate;
|
||||||
|
|
||||||
|
class DEBUGGER_EXPORT DebuggerManager : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@@ -148,26 +151,30 @@ public:
|
|||||||
DebuggerManager();
|
DebuggerManager();
|
||||||
~DebuggerManager();
|
~DebuggerManager();
|
||||||
|
|
||||||
friend class CdbDebugEngine;
|
friend class Internal::IDebuggerEngine;
|
||||||
friend class CdbDebugEventCallback;
|
friend class Internal::DebuggerPlugin;
|
||||||
friend class CdbDumperHelper;
|
friend class Internal::CdbDebugEventCallback;
|
||||||
friend class CdbExceptionLoggerEventCallback;
|
friend class Internal::CdbDumperHelper;
|
||||||
friend class GdbEngine;
|
friend class Internal::CdbExceptionLoggerEventCallback;
|
||||||
friend class ScriptEngine;
|
friend class Internal::GdbEngine;
|
||||||
friend class TcfEngine;
|
friend class Internal::ScriptEngine;
|
||||||
friend struct CdbDebugEnginePrivate;
|
friend class Internal::TcfEngine;
|
||||||
|
friend class Internal::CdbDebugEngine;
|
||||||
|
friend struct Internal::CdbDebugEnginePrivate;
|
||||||
|
|
||||||
QList<Core::IOptionsPage*> initializeEngines(unsigned enabledTypeFlags);
|
QList<Core::IOptionsPage*> initializeEngines(unsigned enabledTypeFlags);
|
||||||
|
|
||||||
Core::Utils::FancyMainWindow *mainWindow() const { return m_mainWindow; }
|
Core::Utils::FancyMainWindow *mainWindow() const;
|
||||||
QLabel *statusLabel() const { return m_statusLabel; }
|
QLabel *statusLabel() const;
|
||||||
IDebuggerEngine *currentEngine() const { return m_engine; }
|
Internal::IDebuggerEngine *currentEngine() const;
|
||||||
|
|
||||||
virtual DebuggerStartParametersPtr startParameters() const;
|
DebuggerStartParametersPtr startParameters() const;
|
||||||
virtual qint64 inferiorPid() const;
|
qint64 inferiorPid() const;
|
||||||
|
|
||||||
void showMessageBox(int icon, const QString &title, const QString &text);
|
void showMessageBox(int icon, const QString &title, const QString &text);
|
||||||
|
|
||||||
|
static DebuggerManager *instance();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void startNewDebugger(const DebuggerStartParametersPtr &sp);
|
void startNewDebugger(const DebuggerStartParametersPtr &sp);
|
||||||
void exitDebugger();
|
void exitDebugger();
|
||||||
@@ -177,7 +184,7 @@ public slots:
|
|||||||
void setBusyCursor(bool on);
|
void setBusyCursor(bool on);
|
||||||
void queryCurrentTextEditor(QString *fileName, int *lineNumber, QObject **ed);
|
void queryCurrentTextEditor(QString *fileName, int *lineNumber, QObject **ed);
|
||||||
|
|
||||||
void gotoLocation(const StackFrame &frame, bool setLocationMarker);
|
void gotoLocation(const Debugger::Internal::StackFrame &frame, bool setLocationMarker);
|
||||||
void fileOpen(const QString &file);
|
void fileOpen(const QString &file);
|
||||||
void resetLocation();
|
void resetLocation();
|
||||||
|
|
||||||
@@ -200,7 +207,7 @@ public slots:
|
|||||||
void detachDebugger();
|
void detachDebugger();
|
||||||
|
|
||||||
void addToWatchWindow();
|
void addToWatchWindow();
|
||||||
void updateWatchData(const WatchData &data);
|
void updateWatchData(const Debugger::Internal::WatchData &data);
|
||||||
|
|
||||||
void sessionLoaded();
|
void sessionLoaded();
|
||||||
void aboutToUnloadSession();
|
void aboutToUnloadSession();
|
||||||
@@ -243,14 +250,15 @@ private slots:
|
|||||||
void startFailed();
|
void startFailed();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ModulesHandler *modulesHandler() { return m_modulesHandler; }
|
Internal::ModulesHandler *modulesHandler() const;
|
||||||
BreakHandler *breakHandler() { return m_breakHandler; }
|
Internal::BreakHandler *breakHandler() const;
|
||||||
RegisterHandler *registerHandler() { return m_registerHandler; }
|
Internal::RegisterHandler *registerHandler() const;
|
||||||
StackHandler *stackHandler() { return m_stackHandler; }
|
Internal::StackHandler *stackHandler() const;
|
||||||
ThreadsHandler *threadsHandler() { return m_threadsHandler; }
|
Internal::ThreadsHandler *threadsHandler() const;
|
||||||
WatchHandler *watchHandler() { return m_watchHandler; }
|
Internal::WatchHandler *watchHandler() const;
|
||||||
SourceFilesWindow *sourceFileWindow() { return m_sourceFilesWindow; }
|
Internal::SourceFilesWindow *sourceFileWindow() const;
|
||||||
QWidget *threadsWindow() const { return m_threadsWindow; }
|
QWidget *threadsWindow() const;
|
||||||
|
Internal::DebuggerManagerActions debuggerManagerActions() const;
|
||||||
|
|
||||||
void notifyInferiorStopped();
|
void notifyInferiorStopped();
|
||||||
void notifyInferiorRunning();
|
void notifyInferiorRunning();
|
||||||
@@ -261,7 +269,6 @@ private:
|
|||||||
|
|
||||||
DebuggerState state() const;
|
DebuggerState state() const;
|
||||||
void setState(DebuggerState state);
|
void setState(DebuggerState state);
|
||||||
DebuggerState m_state;
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// internal implementation
|
// internal implementation
|
||||||
@@ -280,8 +287,7 @@ private:
|
|||||||
public:
|
public:
|
||||||
// stuff in this block should be made private by moving it to
|
// stuff in this block should be made private by moving it to
|
||||||
// one of the interfaces
|
// one of the interfaces
|
||||||
int status() const { return m_status; }
|
QList<Internal::Symbol> moduleSymbols(const QString &moduleName);
|
||||||
QList<Symbol> moduleSymbols(const QString &moduleName);
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void debuggingFinished();
|
void debuggingFinished();
|
||||||
@@ -290,7 +296,7 @@ signals:
|
|||||||
void debugModeRequested();
|
void debugModeRequested();
|
||||||
void previousModeRequested();
|
void previousModeRequested();
|
||||||
void statusMessageRequested(const QString &msg, int timeout); // -1 for 'forever'
|
void statusMessageRequested(const QString &msg, int timeout); // -1 for 'forever'
|
||||||
void gotoLocationRequested(const StackFrame &frame, bool setLocationMarker);
|
void gotoLocationRequested(const Debugger::Internal::StackFrame &frame, bool setLocationMarker);
|
||||||
void resetLocationRequested();
|
void resetLocationRequested();
|
||||||
void currentTextEditorRequested(QString *fileName, int *lineNumber, QObject **ob);
|
void currentTextEditorRequested(QString *fileName, int *lineNumber, QObject **ob);
|
||||||
void sessionValueRequested(const QString &name, QVariant *value);
|
void sessionValueRequested(const QString &name, QVariant *value);
|
||||||
@@ -308,71 +314,13 @@ private:
|
|||||||
|
|
||||||
void toggleBreakpoint(const QString &fileName, int lineNumber);
|
void toggleBreakpoint(const QString &fileName, int lineNumber);
|
||||||
void toggleBreakpointEnabled(const QString &fileName, int lineNumber);
|
void toggleBreakpointEnabled(const QString &fileName, int lineNumber);
|
||||||
BreakpointData *findBreakpoint(const QString &fileName, int lineNumber);
|
Internal::BreakpointData *findBreakpoint(const QString &fileName, int lineNumber);
|
||||||
void setToolTipExpression(const QPoint &mousePos,
|
void setToolTipExpression(const QPoint &mousePos,
|
||||||
TextEditor::ITextEditor *editor, int cursorPos);
|
TextEditor::ITextEditor *editor, int cursorPos);
|
||||||
|
|
||||||
// FIXME: Remove engine-specific state
|
DebuggerManagerPrivate *d;
|
||||||
DebuggerStartParametersPtr m_startParameters;
|
|
||||||
qint64 m_inferiorPid;
|
|
||||||
|
|
||||||
|
|
||||||
/// Views
|
|
||||||
Core::Utils::FancyMainWindow *m_mainWindow;
|
|
||||||
QLabel *m_statusLabel;
|
|
||||||
QDockWidget *m_breakDock;
|
|
||||||
QDockWidget *m_modulesDock;
|
|
||||||
QDockWidget *m_outputDock;
|
|
||||||
QDockWidget *m_registerDock;
|
|
||||||
QDockWidget *m_stackDock;
|
|
||||||
QDockWidget *m_sourceFilesDock;
|
|
||||||
QDockWidget *m_threadsDock;
|
|
||||||
QDockWidget *m_watchDock;
|
|
||||||
|
|
||||||
BreakHandler *m_breakHandler;
|
|
||||||
ModulesHandler *m_modulesHandler;
|
|
||||||
RegisterHandler *m_registerHandler;
|
|
||||||
StackHandler *m_stackHandler;
|
|
||||||
ThreadsHandler *m_threadsHandler;
|
|
||||||
WatchHandler *m_watchHandler;
|
|
||||||
SourceFilesWindow *m_sourceFilesWindow;
|
|
||||||
|
|
||||||
/// Actions
|
|
||||||
friend class DebuggerPlugin;
|
|
||||||
friend class IDebuggerEngine;
|
|
||||||
QAction *m_continueAction;
|
|
||||||
QAction *m_stopAction;
|
|
||||||
QAction *m_resetAction; // FIXME: Should not be needed in a stable release
|
|
||||||
QAction *m_stepAction;
|
|
||||||
QAction *m_stepOutAction;
|
|
||||||
QAction *m_runToLineAction;
|
|
||||||
QAction *m_runToFunctionAction;
|
|
||||||
QAction *m_jumpToLineAction;
|
|
||||||
QAction *m_nextAction;
|
|
||||||
QAction *m_watchAction;
|
|
||||||
QAction *m_breakAction;
|
|
||||||
QAction *m_sepAction;
|
|
||||||
QAction *m_reverseDirectionAction;
|
|
||||||
|
|
||||||
QWidget *m_breakWindow;
|
|
||||||
QWidget *m_localsWindow;
|
|
||||||
QWidget *m_registerWindow;
|
|
||||||
QWidget *m_modulesWindow;
|
|
||||||
QWidget *m_stackWindow;
|
|
||||||
QWidget *m_threadsWindow;
|
|
||||||
QWidget *m_watchersWindow;
|
|
||||||
DebuggerOutputWindow *m_outputWindow;
|
|
||||||
|
|
||||||
int m_status;
|
|
||||||
bool m_busy;
|
|
||||||
QTimer *m_statusTimer;
|
|
||||||
QString m_lastPermanentStatusMessage;
|
|
||||||
|
|
||||||
IDebuggerEngine *engine();
|
|
||||||
IDebuggerEngine *m_engine;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
|
||||||
} // namespace Debugger
|
} // namespace Debugger
|
||||||
|
|
||||||
#endif // DEBUGGER_DEBUGGERMANAGER_H
|
#endif // DEBUGGER_DEBUGGERMANAGER_H
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ using namespace Find;
|
|||||||
|
|
||||||
#endif // GDBDEBUGGERLEAN
|
#endif // GDBDEBUGGERLEAN
|
||||||
|
|
||||||
|
using namespace Debugger;
|
||||||
using namespace Debugger::Internal;
|
using namespace Debugger::Internal;
|
||||||
|
|
||||||
static QChar charForChannel(int channel)
|
static QChar charForChannel(int channel)
|
||||||
|
|||||||
@@ -37,6 +37,7 @@
|
|||||||
#include "debuggermanager.h"
|
#include "debuggermanager.h"
|
||||||
#include "debuggerrunner.h"
|
#include "debuggerrunner.h"
|
||||||
#include "stackframe.h"
|
#include "stackframe.h"
|
||||||
|
#include "debuggerstringutils.h"
|
||||||
|
|
||||||
#include "ui_commonoptionspage.h"
|
#include "ui_commonoptionspage.h"
|
||||||
#include "ui_dumperoptionpage.h"
|
#include "ui_dumperoptionpage.h"
|
||||||
@@ -619,7 +620,8 @@ bool DebuggerPlugin::initialize(const QStringList &arguments, QString *errorMess
|
|||||||
am->actionContainer(ProjectExplorer::Constants::M_DEBUG_STARTDEBUGGING);
|
am->actionContainer(ProjectExplorer::Constants::M_DEBUG_STARTDEBUGGING);
|
||||||
|
|
||||||
Core::Command *cmd = 0;
|
Core::Command *cmd = 0;
|
||||||
cmd = am->registerAction(m_manager->m_continueAction,
|
const DebuggerManagerActions actions = m_manager->debuggerManagerActions();
|
||||||
|
cmd = am->registerAction(actions.continueAction,
|
||||||
ProjectExplorer::Constants::DEBUG, QList<int>() << m_gdbRunningContext);
|
ProjectExplorer::Constants::DEBUG, QList<int>() << m_gdbRunningContext);
|
||||||
mstart->addAction(cmd, Core::Constants::G_DEFAULT_ONE);
|
mstart->addAction(cmd, Core::Constants::G_DEFAULT_ONE);
|
||||||
|
|
||||||
@@ -648,7 +650,7 @@ bool DebuggerPlugin::initialize(const QStringList &arguments, QString *errorMess
|
|||||||
Constants::DETACH, globalcontext);
|
Constants::DETACH, globalcontext);
|
||||||
mdebug->addAction(cmd, Core::Constants::G_DEFAULT_ONE);
|
mdebug->addAction(cmd, Core::Constants::G_DEFAULT_ONE);
|
||||||
|
|
||||||
cmd = am->registerAction(m_manager->m_stopAction,
|
cmd = am->registerAction(actions.stopAction,
|
||||||
Constants::INTERRUPT, globalcontext);
|
Constants::INTERRUPT, globalcontext);
|
||||||
cmd->setAttribute(Core::Command::CA_UpdateText);
|
cmd->setAttribute(Core::Command::CA_UpdateText);
|
||||||
cmd->setAttribute(Core::Command::CA_UpdateIcon);
|
cmd->setAttribute(Core::Command::CA_UpdateIcon);
|
||||||
@@ -656,7 +658,7 @@ bool DebuggerPlugin::initialize(const QStringList &arguments, QString *errorMess
|
|||||||
cmd->setDefaultText(tr("Stop Debugger/Interrupt Debugger"));
|
cmd->setDefaultText(tr("Stop Debugger/Interrupt Debugger"));
|
||||||
mdebug->addAction(cmd, Core::Constants::G_DEFAULT_ONE);
|
mdebug->addAction(cmd, Core::Constants::G_DEFAULT_ONE);
|
||||||
|
|
||||||
cmd = am->registerAction(m_manager->m_resetAction,
|
cmd = am->registerAction(actions.resetAction,
|
||||||
Constants::RESET, globalcontext);
|
Constants::RESET, globalcontext);
|
||||||
cmd->setAttribute(Core::Command::CA_UpdateText);
|
cmd->setAttribute(Core::Command::CA_UpdateText);
|
||||||
cmd->setDefaultKeySequence(QKeySequence(Constants::RESET_KEY));
|
cmd->setDefaultKeySequence(QKeySequence(Constants::RESET_KEY));
|
||||||
@@ -668,17 +670,17 @@ bool DebuggerPlugin::initialize(const QStringList &arguments, QString *errorMess
|
|||||||
cmd = am->registerAction(sep, QLatin1String("Debugger.Sep.Step"), globalcontext);
|
cmd = am->registerAction(sep, QLatin1String("Debugger.Sep.Step"), globalcontext);
|
||||||
mdebug->addAction(cmd);
|
mdebug->addAction(cmd);
|
||||||
|
|
||||||
cmd = am->registerAction(m_manager->m_nextAction,
|
cmd = am->registerAction(actions.nextAction,
|
||||||
Constants::NEXT, debuggercontext);
|
Constants::NEXT, debuggercontext);
|
||||||
cmd->setDefaultKeySequence(QKeySequence(Constants::NEXT_KEY));
|
cmd->setDefaultKeySequence(QKeySequence(Constants::NEXT_KEY));
|
||||||
mdebug->addAction(cmd);
|
mdebug->addAction(cmd);
|
||||||
|
|
||||||
cmd = am->registerAction(m_manager->m_stepAction,
|
cmd = am->registerAction(actions.stepAction,
|
||||||
Constants::STEP, debuggercontext);
|
Constants::STEP, debuggercontext);
|
||||||
cmd->setDefaultKeySequence(QKeySequence(Constants::STEP_KEY));
|
cmd->setDefaultKeySequence(QKeySequence(Constants::STEP_KEY));
|
||||||
mdebug->addAction(cmd);
|
mdebug->addAction(cmd);
|
||||||
|
|
||||||
cmd = am->registerAction(m_manager->m_stepOutAction,
|
cmd = am->registerAction(actions.stepOutAction,
|
||||||
Constants::STEPOUT, debuggercontext);
|
Constants::STEPOUT, debuggercontext);
|
||||||
cmd->setDefaultKeySequence(QKeySequence(Constants::STEPOUT_KEY));
|
cmd->setDefaultKeySequence(QKeySequence(Constants::STEPOUT_KEY));
|
||||||
mdebug->addAction(cmd);
|
mdebug->addAction(cmd);
|
||||||
@@ -687,22 +689,22 @@ bool DebuggerPlugin::initialize(const QStringList &arguments, QString *errorMess
|
|||||||
Constants::STEP_BY_INSTRUCTION, debuggercontext);
|
Constants::STEP_BY_INSTRUCTION, debuggercontext);
|
||||||
mdebug->addAction(cmd);
|
mdebug->addAction(cmd);
|
||||||
|
|
||||||
cmd = am->registerAction(m_manager->m_runToLineAction,
|
cmd = am->registerAction(actions.runToLineAction,
|
||||||
Constants::RUN_TO_LINE, debuggercontext);
|
Constants::RUN_TO_LINE, debuggercontext);
|
||||||
cmd->setDefaultKeySequence(QKeySequence(Constants::RUN_TO_LINE_KEY));
|
cmd->setDefaultKeySequence(QKeySequence(Constants::RUN_TO_LINE_KEY));
|
||||||
mdebug->addAction(cmd);
|
mdebug->addAction(cmd);
|
||||||
|
|
||||||
cmd = am->registerAction(m_manager->m_runToFunctionAction,
|
cmd = am->registerAction(actions.runToFunctionAction,
|
||||||
Constants::RUN_TO_FUNCTION, debuggercontext);
|
Constants::RUN_TO_FUNCTION, debuggercontext);
|
||||||
cmd->setDefaultKeySequence(QKeySequence(Constants::RUN_TO_FUNCTION_KEY));
|
cmd->setDefaultKeySequence(QKeySequence(Constants::RUN_TO_FUNCTION_KEY));
|
||||||
mdebug->addAction(cmd);
|
mdebug->addAction(cmd);
|
||||||
|
|
||||||
cmd = am->registerAction(m_manager->m_jumpToLineAction,
|
cmd = am->registerAction(actions.jumpToLineAction,
|
||||||
Constants::JUMP_TO_LINE, debuggercontext);
|
Constants::JUMP_TO_LINE, debuggercontext);
|
||||||
mdebug->addAction(cmd);
|
mdebug->addAction(cmd);
|
||||||
|
|
||||||
#ifdef USE_REVERSE_DEBUGGING
|
#ifdef USE_REVERSE_DEBUGGING
|
||||||
cmd = am->registerAction(m_manager->m_reverseDirectionAction,
|
cmd = am->registerAction(actions.reverseDirectionAction,
|
||||||
Constants::REVERSE, debuggercontext);
|
Constants::REVERSE, debuggercontext);
|
||||||
cmd->setDefaultKeySequence(QKeySequence(Constants::REVERSE_KEY));
|
cmd->setDefaultKeySequence(QKeySequence(Constants::REVERSE_KEY));
|
||||||
mdebug->addAction(cmd);
|
mdebug->addAction(cmd);
|
||||||
@@ -713,7 +715,7 @@ bool DebuggerPlugin::initialize(const QStringList &arguments, QString *errorMess
|
|||||||
cmd = am->registerAction(sep, QLatin1String("Debugger.Sep.Break"), globalcontext);
|
cmd = am->registerAction(sep, QLatin1String("Debugger.Sep.Break"), globalcontext);
|
||||||
mdebug->addAction(cmd);
|
mdebug->addAction(cmd);
|
||||||
|
|
||||||
cmd = am->registerAction(m_manager->m_breakAction,
|
cmd = am->registerAction(actions.breakAction,
|
||||||
Constants::TOGGLE_BREAK, cppeditorcontext);
|
Constants::TOGGLE_BREAK, cppeditorcontext);
|
||||||
cmd->setDefaultKeySequence(QKeySequence(Constants::TOGGLE_BREAK_KEY));
|
cmd->setDefaultKeySequence(QKeySequence(Constants::TOGGLE_BREAK_KEY));
|
||||||
mdebug->addAction(cmd);
|
mdebug->addAction(cmd);
|
||||||
@@ -724,7 +726,7 @@ bool DebuggerPlugin::initialize(const QStringList &arguments, QString *errorMess
|
|||||||
cmd = am->registerAction(sep, QLatin1String("Debugger.Sep.Watch"), globalcontext);
|
cmd = am->registerAction(sep, QLatin1String("Debugger.Sep.Watch"), globalcontext);
|
||||||
mdebug->addAction(cmd);
|
mdebug->addAction(cmd);
|
||||||
|
|
||||||
cmd = am->registerAction(m_manager->m_watchAction,
|
cmd = am->registerAction(actions.watchAction,
|
||||||
Constants::ADD_TO_WATCH, cppeditorcontext);
|
Constants::ADD_TO_WATCH, cppeditorcontext);
|
||||||
//cmd->setDefaultKeySequence(QKeySequence(tr("ALT+D,ALT+W")));
|
//cmd->setDefaultKeySequence(QKeySequence(tr("ALT+D,ALT+W")));
|
||||||
mdebug->addAction(cmd);
|
mdebug->addAction(cmd);
|
||||||
@@ -885,8 +887,8 @@ bool DebuggerPlugin::initialize(const QStringList &arguments, QString *errorMess
|
|||||||
|
|
||||||
connect(m_manager, SIGNAL(resetLocationRequested()),
|
connect(m_manager, SIGNAL(resetLocationRequested()),
|
||||||
this, SLOT(resetLocation()));
|
this, SLOT(resetLocation()));
|
||||||
connect(m_manager, SIGNAL(gotoLocationRequested(StackFrame,bool)),
|
connect(m_manager, SIGNAL(gotoLocationRequested(Debugger::Internal::StackFrame,bool)),
|
||||||
this, SLOT(gotoLocation(StackFrame,bool)));
|
this, SLOT(gotoLocation(Debugger::Internal::StackFrame,bool)));
|
||||||
connect(m_manager, SIGNAL(stateChanged(int)),
|
connect(m_manager, SIGNAL(stateChanged(int)),
|
||||||
this, SLOT(handleStateChanged(int)));
|
this, SLOT(handleStateChanged(int)));
|
||||||
connect(m_manager, SIGNAL(previousModeRequested()),
|
connect(m_manager, SIGNAL(previousModeRequested()),
|
||||||
@@ -1088,7 +1090,7 @@ void DebuggerPlugin::resetLocation()
|
|||||||
m_locationMark = 0;
|
m_locationMark = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebuggerPlugin::gotoLocation(const StackFrame &frame, bool setMarker)
|
void DebuggerPlugin::gotoLocation(const Debugger::Internal::StackFrame &frame, bool setMarker)
|
||||||
{
|
{
|
||||||
if (theDebuggerBoolSetting(StepByInstruction) || !frame.isUsable()) {
|
if (theDebuggerBoolSetting(StepByInstruction) || !frame.isUsable()) {
|
||||||
if (!m_disassemblerViewAgent)
|
if (!m_disassemblerViewAgent)
|
||||||
|
|||||||
@@ -55,10 +55,11 @@ class BaseTextMark;
|
|||||||
}
|
}
|
||||||
|
|
||||||
namespace Debugger {
|
namespace Debugger {
|
||||||
|
class DebuggerManager;
|
||||||
|
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
class BreakpointData;
|
class BreakpointData;
|
||||||
class DebuggerManager;
|
|
||||||
class DebuggerRunControlFactory;
|
class DebuggerRunControlFactory;
|
||||||
class DebugMode;
|
class DebugMode;
|
||||||
class DisassemblerViewAgent;
|
class DisassemblerViewAgent;
|
||||||
@@ -96,7 +97,7 @@ private slots:
|
|||||||
int lineNumber, QMenu *menu);
|
int lineNumber, QMenu *menu);
|
||||||
|
|
||||||
void resetLocation();
|
void resetLocation();
|
||||||
void gotoLocation(const StackFrame &frame, bool setMarker);
|
void gotoLocation(const Debugger::Internal::StackFrame &frame, bool setMarker);
|
||||||
|
|
||||||
void breakpointSetRemoveMarginActionTriggered();
|
void breakpointSetRemoveMarginActionTriggered();
|
||||||
void breakpointEnableDisableMarginActionTriggered();
|
void breakpointEnableDisableMarginActionTriggered();
|
||||||
@@ -119,10 +120,10 @@ private:
|
|||||||
QString *errorMessage);
|
QString *errorMessage);
|
||||||
void attachExternalApplication(qint64 pid, const QString &crashParameter = QString());
|
void attachExternalApplication(qint64 pid, const QString &crashParameter = QString());
|
||||||
|
|
||||||
friend class DebuggerManager;
|
friend class Debugger::DebuggerManager;
|
||||||
friend class GdbOptionPage;
|
friend class GdbOptionPage;
|
||||||
friend class DebuggingHelperOptionPage;
|
friend class DebuggingHelperOptionPage;
|
||||||
friend class DebugMode; // FIXME: Just a hack now so that it can access the views
|
friend class Debugger::Internal::DebugMode; // FIXME: Just a hack now so that it can access the views
|
||||||
|
|
||||||
DebuggerManager *m_manager;
|
DebuggerManager *m_manager;
|
||||||
DebugMode *m_debugMode;
|
DebugMode *m_debugMode;
|
||||||
|
|||||||
@@ -40,9 +40,9 @@ class LocalApplicationRunConfiguration;
|
|||||||
}
|
}
|
||||||
|
|
||||||
namespace Debugger {
|
namespace Debugger {
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
class DebuggerManager;
|
class DebuggerManager;
|
||||||
|
|
||||||
|
namespace Internal {
|
||||||
class StartData;
|
class StartData;
|
||||||
|
|
||||||
typedef QSharedPointer<ProjectExplorer::RunConfiguration>
|
typedef QSharedPointer<ProjectExplorer::RunConfiguration>
|
||||||
|
|||||||
45
src/plugins/debugger/debuggerstringutils.h
Normal file
45
src/plugins/debugger/debuggerstringutils.h
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
/**************************************************************************
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator
|
||||||
|
**
|
||||||
|
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||||
|
**
|
||||||
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||||
|
**
|
||||||
|
** Commercial Usage
|
||||||
|
**
|
||||||
|
** Licensees holding valid Qt Commercial licenses may use this file in
|
||||||
|
** accordance with the Qt Commercial License Agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Nokia.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
**
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 as published by the Free Software
|
||||||
|
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||||
|
** packaging of this file. Please review the following information to
|
||||||
|
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||||
|
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** If you are unsure which license is appropriate for your use, please
|
||||||
|
** contact the sales department at http://qt.nokia.com/contact.
|
||||||
|
**
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
|
#ifndef DEBUGGERSTRINGUTILS_H
|
||||||
|
#define DEBUGGERSTRINGUTILS_H
|
||||||
|
|
||||||
|
#include <QtCore/QString>
|
||||||
|
|
||||||
|
namespace Debugger {
|
||||||
|
namespace Internal {
|
||||||
|
|
||||||
|
typedef QLatin1Char _c;
|
||||||
|
typedef QLatin1String __;
|
||||||
|
inline QString _(const char *s) { return QString::fromLatin1(s); }
|
||||||
|
inline QString _(const QByteArray &ba) { return QString::fromLatin1(ba, ba.size()); }
|
||||||
|
|
||||||
|
} // namespace Internal
|
||||||
|
} // namespace Debugger
|
||||||
|
#endif // DEBUGGERSTRINGUTILS_H
|
||||||
@@ -32,6 +32,7 @@
|
|||||||
#include "debuggeractions.h"
|
#include "debuggeractions.h"
|
||||||
#include "gdbengine.h"
|
#include "gdbengine.h"
|
||||||
#include "procinterrupt.h"
|
#include "procinterrupt.h"
|
||||||
|
#include "debuggerstringutils.h"
|
||||||
|
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
|
|||||||
@@ -31,6 +31,7 @@
|
|||||||
|
|
||||||
#include "debuggeractions.h"
|
#include "debuggeractions.h"
|
||||||
#include "gdbengine.h"
|
#include "gdbengine.h"
|
||||||
|
#include "debuggerstringutils.h"
|
||||||
|
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
|
|||||||
@@ -46,6 +46,7 @@
|
|||||||
#include "debuggerconstants.h"
|
#include "debuggerconstants.h"
|
||||||
#include "debuggermanager.h"
|
#include "debuggermanager.h"
|
||||||
#include "debuggertooltip.h"
|
#include "debuggertooltip.h"
|
||||||
|
#include "debuggerstringutils.h"
|
||||||
#include "gdbmi.h"
|
#include "gdbmi.h"
|
||||||
|
|
||||||
#include "breakhandler.h"
|
#include "breakhandler.h"
|
||||||
@@ -58,6 +59,7 @@
|
|||||||
#include "debuggerdialogs.h"
|
#include "debuggerdialogs.h"
|
||||||
|
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
#include <utils/fancymainwindow.h>
|
||||||
#include <texteditor/itexteditor.h>
|
#include <texteditor/itexteditor.h>
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
|
|
||||||
@@ -224,6 +226,11 @@ DebuggerStartMode GdbEngine::startMode() const
|
|||||||
return m_startParameters->startMode;
|
return m_startParameters->startMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QMainWindow *GdbEngine::mainWindow() const
|
||||||
|
{
|
||||||
|
return m_manager->mainWindow();
|
||||||
|
}
|
||||||
|
|
||||||
GdbEngine::~GdbEngine()
|
GdbEngine::~GdbEngine()
|
||||||
{
|
{
|
||||||
// prevent sending error messages afterwards
|
// prevent sending error messages afterwards
|
||||||
@@ -783,15 +790,22 @@ void GdbEngine::handleResultRecord(const GdbResponse &response)
|
|||||||
// In theory this should not happen, in practice it does.
|
// In theory this should not happen, in practice it does.
|
||||||
debugMessage(_("COOKIE FOR TOKEN %1 ALREADY EATEN. "
|
debugMessage(_("COOKIE FOR TOKEN %1 ALREADY EATEN. "
|
||||||
"TWO RESPONSES FOR ONE COMMAND?").arg(token));
|
"TWO RESPONSES FOR ONE COMMAND?").arg(token));
|
||||||
// Handle a case known to occur on Linux/gdb 6.8 when debugging moc
|
|
||||||
// with helpers enabled. In this case we get a second response with
|
|
||||||
// msg="Cannot find new threads: generic error"
|
|
||||||
if (response.resultClass == GdbResultError) {
|
if (response.resultClass == GdbResultError) {
|
||||||
QByteArray msg = response.data.findChild("msg").data();
|
QByteArray msg = response.data.findChild("msg").data();
|
||||||
showMessageBox(QMessageBox::Critical,
|
showMessageBox(QMessageBox::Critical,
|
||||||
tr("Executable failed"), QString::fromLocal8Bit(msg));
|
tr("Executable failed"), QString::fromLocal8Bit(msg));
|
||||||
showStatusMessage(tr("Process failed to start."));
|
showStatusMessage(tr("Process failed to start."));
|
||||||
shutdown();
|
// Handle a case known to occur on Linux/gdb 6.8 when debugging moc
|
||||||
|
// with helpers enabled. In this case we get a second response with
|
||||||
|
// msg="Cannot find new threads: generic error"
|
||||||
|
if (msg == "Cannot find new threads: generic error")
|
||||||
|
shutdown();
|
||||||
|
// Handle a case known to appear on gdb 6.4 symbianelf when
|
||||||
|
// the stack is cut due to access to protected memory.
|
||||||
|
if (msg == "\"finish\" not meaningful in the outermost frame.") {
|
||||||
|
setState(InferiorStopping);
|
||||||
|
setState(InferiorStopped);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1303,6 +1317,11 @@ void GdbEngine::handleStop2(const GdbResponse &response)
|
|||||||
|
|
||||||
void GdbEngine::handleStop2(const GdbMi &data)
|
void GdbEngine::handleStop2(const GdbMi &data)
|
||||||
{
|
{
|
||||||
|
if (state() == InferiorRunning) {
|
||||||
|
// Stop triggered by a breakpoint or otherwise not directly
|
||||||
|
// initiated by the user.
|
||||||
|
setState(InferiorStopping);
|
||||||
|
}
|
||||||
setState(InferiorStopped);
|
setState(InferiorStopped);
|
||||||
showStatusMessage(tr("Stopped."), 5000);
|
showStatusMessage(tr("Stopped."), 5000);
|
||||||
|
|
||||||
@@ -3808,7 +3827,7 @@ struct MemoryAgentCookie
|
|||||||
MemoryAgentCookie(MemoryViewAgent *agent_, quint64 address_)
|
MemoryAgentCookie(MemoryViewAgent *agent_, quint64 address_)
|
||||||
: agent(agent_), address(address_)
|
: agent(agent_), address(address_)
|
||||||
{}
|
{}
|
||||||
MemoryViewAgent *agent;
|
QPointer<MemoryViewAgent> agent;
|
||||||
quint64 address;
|
quint64 address;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -3851,7 +3870,7 @@ struct DisassemblerAgentCookie
|
|||||||
DisassemblerAgentCookie(DisassemblerViewAgent *agent_)
|
DisassemblerAgentCookie(DisassemblerViewAgent *agent_)
|
||||||
: agent(agent_)
|
: agent(agent_)
|
||||||
{}
|
{}
|
||||||
DisassemblerViewAgent *agent;
|
QPointer<DisassemblerViewAgent> agent;
|
||||||
};
|
};
|
||||||
|
|
||||||
void GdbEngine::fetchDisassembler(DisassemblerViewAgent *agent,
|
void GdbEngine::fetchDisassembler(DisassemblerViewAgent *agent,
|
||||||
|
|||||||
@@ -51,14 +51,14 @@ QT_BEGIN_NAMESPACE
|
|||||||
class QAction;
|
class QAction;
|
||||||
class QAbstractItemModel;
|
class QAbstractItemModel;
|
||||||
class QWidget;
|
class QWidget;
|
||||||
|
class QMainWindow;
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
namespace Debugger {
|
namespace Debugger {
|
||||||
|
class DebuggerManager;
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
class AbstractGdbAdapter;
|
class AbstractGdbAdapter;
|
||||||
class DebuggerManager;
|
|
||||||
class IDebuggerManagerAccessForEngines;
|
|
||||||
class GdbResponse;
|
class GdbResponse;
|
||||||
class GdbMi;
|
class GdbMi;
|
||||||
|
|
||||||
@@ -271,7 +271,7 @@ private:
|
|||||||
bool showToolTip();
|
bool showToolTip();
|
||||||
|
|
||||||
// Convenience
|
// Convenience
|
||||||
QMainWindow *mainWindow() const { return m_manager->mainWindow(); }
|
QMainWindow *mainWindow() const;
|
||||||
DebuggerStartMode startMode() const;
|
DebuggerStartMode startMode() const;
|
||||||
qint64 inferiorPid() const { return m_manager->inferiorPid(); }
|
qint64 inferiorPid() const { return m_manager->inferiorPid(); }
|
||||||
|
|
||||||
|
|||||||
@@ -32,11 +32,14 @@
|
|||||||
#include "debuggeractions.h"
|
#include "debuggeractions.h"
|
||||||
#include "gdbengine.h"
|
#include "gdbengine.h"
|
||||||
#include "procinterrupt.h"
|
#include "procinterrupt.h"
|
||||||
|
#include "debuggerstringutils.h"
|
||||||
|
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
#include <utils/fancymainwindow.h>
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
|
|
||||||
#include <QtCore/QFileInfo>
|
#include <QtCore/QFileInfo>
|
||||||
|
#include <QtCore/QVariant>
|
||||||
#include <QtGui/QMessageBox>
|
#include <QtGui/QMessageBox>
|
||||||
|
|
||||||
namespace Debugger {
|
namespace Debugger {
|
||||||
|
|||||||
@@ -28,11 +28,12 @@
|
|||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
#include "remotegdbadapter.h"
|
#include "remotegdbadapter.h"
|
||||||
|
#include "debuggerstringutils.h"
|
||||||
#include "debuggeractions.h"
|
#include "debuggeractions.h"
|
||||||
#include "gdbengine.h"
|
#include "gdbengine.h"
|
||||||
|
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
#include <utils/fancymainwindow.h>
|
||||||
|
|
||||||
#include <QtCore/QFileInfo>
|
#include <QtCore/QFileInfo>
|
||||||
#include <QtGui/QMessageBox>
|
#include <QtGui/QMessageBox>
|
||||||
|
|||||||
@@ -29,6 +29,7 @@
|
|||||||
|
|
||||||
#include "trkgdbadapter.h"
|
#include "trkgdbadapter.h"
|
||||||
#include "trkoptions.h"
|
#include "trkoptions.h"
|
||||||
|
#include "debuggerstringutils.h"
|
||||||
#ifndef STANDALONE_RUNNER
|
#ifndef STANDALONE_RUNNER
|
||||||
#include "gdbengine.h"
|
#include "gdbengine.h"
|
||||||
#endif
|
#endif
|
||||||
@@ -199,7 +200,7 @@ QByteArray TrkGdbAdapter::trkContinueMessage()
|
|||||||
return ba;
|
return ba;
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArray TrkGdbAdapter::trkReadRegisterMessage()
|
QByteArray TrkGdbAdapter::trkReadRegistersMessage()
|
||||||
{
|
{
|
||||||
QByteArray ba;
|
QByteArray ba;
|
||||||
appendByte(&ba, 0); // Register set, only 0 supported
|
appendByte(&ba, 0); // Register set, only 0 supported
|
||||||
@@ -210,6 +211,18 @@ QByteArray TrkGdbAdapter::trkReadRegisterMessage()
|
|||||||
return ba;
|
return ba;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QByteArray TrkGdbAdapter::trkWriteRegisterMessage(byte reg, uint value)
|
||||||
|
{
|
||||||
|
QByteArray ba;
|
||||||
|
appendByte(&ba, 0); // ?
|
||||||
|
appendShort(&ba, reg);
|
||||||
|
appendShort(&ba, reg);
|
||||||
|
appendInt(&ba, m_session.pid);
|
||||||
|
appendInt(&ba, m_session.tid);
|
||||||
|
appendInt(&ba, value);
|
||||||
|
return ba;
|
||||||
|
}
|
||||||
|
|
||||||
QByteArray TrkGdbAdapter::trkReadMemoryMessage(uint addr, uint len)
|
QByteArray TrkGdbAdapter::trkReadMemoryMessage(uint addr, uint len)
|
||||||
{
|
{
|
||||||
QByteArray ba;
|
QByteArray ba;
|
||||||
@@ -574,6 +587,7 @@ void TrkGdbAdapter::handleGdbServerCommand(const QByteArray &cmd)
|
|||||||
sendGdbServerMessage("E20", "Error " + cmd);
|
sendGdbServerMessage("E20", "Error " + cmd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (cmd.startsWith("p")) {
|
else if (cmd.startsWith("p")) {
|
||||||
logMessage(msgGdbPacket(QLatin1String("read register")));
|
logMessage(msgGdbPacket(QLatin1String("read register")));
|
||||||
// 0xf == current instruction pointer?
|
// 0xf == current instruction pointer?
|
||||||
@@ -599,6 +613,21 @@ void TrkGdbAdapter::handleGdbServerCommand(const QByteArray &cmd)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
else if (cmd.startsWith("P")) {
|
||||||
|
logMessage(msgGdbPacket(QLatin1String("write register")));
|
||||||
|
// $Pe=70f96678#d3
|
||||||
|
sendGdbServerAck();
|
||||||
|
int pos = cmd.indexOf('=');
|
||||||
|
QByteArray regName = cmd.mid(1, pos - 1);
|
||||||
|
QByteArray valueName = cmd.mid(pos + 1);
|
||||||
|
bool ok = false;
|
||||||
|
const uint registerNumber = regName.toInt(&ok, 16);
|
||||||
|
const uint value = swapEndian(valueName.toInt(&ok, 16));
|
||||||
|
QByteArray ba = trkWriteRegisterMessage(registerNumber, value);
|
||||||
|
sendTrkMessage(0x13, TrkCB(handleWriteRegister), ba, "Write register");
|
||||||
|
// Note that App TRK refuses to write registers 13 and 14
|
||||||
|
}
|
||||||
|
|
||||||
else if (cmd == "qAttached") {
|
else if (cmd == "qAttached") {
|
||||||
//$qAttached#8f
|
//$qAttached#8f
|
||||||
// 1: attached to an existing process
|
// 1: attached to an existing process
|
||||||
@@ -861,7 +890,7 @@ void TrkGdbAdapter::handleTrkResult(const TrkResult &result)
|
|||||||
//sendGdbServerMessage("S05", "Target stopped");
|
//sendGdbServerMessage("S05", "Target stopped");
|
||||||
sendTrkMessage(0x12,
|
sendTrkMessage(0x12,
|
||||||
TrkCB(handleAndReportReadRegistersAfterStop),
|
TrkCB(handleAndReportReadRegistersAfterStop),
|
||||||
trkReadRegisterMessage());
|
trkReadRegistersMessage());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 0x91: { // Notify Exception (obsolete)
|
case 0x91: { // Notify Exception (obsolete)
|
||||||
@@ -1020,6 +1049,17 @@ void TrkGdbAdapter::handleReadRegisters(const TrkResult &result)
|
|||||||
m_snapshot.registers[i] = extractInt(data + 4 * i);
|
m_snapshot.registers[i] = extractInt(data + 4 * i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TrkGdbAdapter::handleWriteRegister(const TrkResult &result)
|
||||||
|
{
|
||||||
|
logMessage(" RESULT: " + result.toString() + result.cookie.toString());
|
||||||
|
if (result.errorCode()) {
|
||||||
|
logMessage("ERROR: " + result.errorString());
|
||||||
|
sendGdbServerMessage("E01");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
sendGdbServerMessage("OK");
|
||||||
|
}
|
||||||
|
|
||||||
void TrkGdbAdapter::reportRegisters()
|
void TrkGdbAdapter::reportRegisters()
|
||||||
{
|
{
|
||||||
QByteArray ba;
|
QByteArray ba;
|
||||||
|
|||||||
@@ -156,7 +156,8 @@ public:
|
|||||||
void reportRegisters();
|
void reportRegisters();
|
||||||
QByteArray memoryReadLogMessage(uint addr, uint len, const QByteArray &ba) const;
|
QByteArray memoryReadLogMessage(uint addr, uint len, const QByteArray &ba) const;
|
||||||
QByteArray trkContinueMessage();
|
QByteArray trkContinueMessage();
|
||||||
QByteArray trkReadRegisterMessage();
|
QByteArray trkReadRegistersMessage();
|
||||||
|
QByteArray trkWriteRegisterMessage(byte reg, uint value);
|
||||||
QByteArray trkReadMemoryMessage(uint addr, uint len);
|
QByteArray trkReadMemoryMessage(uint addr, uint len);
|
||||||
QByteArray trkBreakpointMessage(uint addr, uint len, bool armMode = true);
|
QByteArray trkBreakpointMessage(uint addr, uint len, bool armMode = true);
|
||||||
QByteArray trkStepRangeMessage(byte option);
|
QByteArray trkStepRangeMessage(byte option);
|
||||||
@@ -169,6 +170,7 @@ public:
|
|||||||
void handleStepOver2(const TrkResult &result);
|
void handleStepOver2(const TrkResult &result);
|
||||||
void handleReadRegisters(const TrkResult &result);
|
void handleReadRegisters(const TrkResult &result);
|
||||||
void reportReadMemoryBuffered(const TrkResult &result);
|
void reportReadMemoryBuffered(const TrkResult &result);
|
||||||
|
void handleWriteRegister(const TrkResult &result);
|
||||||
void reportToGdb(const TrkResult &result);
|
void reportToGdb(const TrkResult &result);
|
||||||
|
|
||||||
void readMemory(uint addr, uint len);
|
void readMemory(uint addr, uint len);
|
||||||
|
|||||||
@@ -50,22 +50,23 @@ class IOptionsPage;
|
|||||||
}
|
}
|
||||||
|
|
||||||
namespace Debugger {
|
namespace Debugger {
|
||||||
|
class DebuggerManager;
|
||||||
|
class DebuggerStartParameters;
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
class DebuggerStartParameters;
|
|
||||||
class DebuggerManager;
|
|
||||||
class DisassemblerViewAgent;
|
class DisassemblerViewAgent;
|
||||||
class MemoryViewAgent;
|
class MemoryViewAgent;
|
||||||
struct StackFrame;
|
struct StackFrame;
|
||||||
class Symbol;
|
class Symbol;
|
||||||
class WatchData;
|
class WatchData;
|
||||||
typedef QSharedPointer<DebuggerStartParameters> DebuggerStartParametersPtr;
|
|
||||||
|
|
||||||
class IDebuggerEngine : public QObject
|
class IDebuggerEngine : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
typedef QSharedPointer<DebuggerStartParameters> DebuggerStartParametersPtr;
|
||||||
|
|
||||||
IDebuggerEngine(DebuggerManager *manager, QObject *parent = 0)
|
IDebuggerEngine(DebuggerManager *manager, QObject *parent = 0)
|
||||||
: QObject(parent), m_manager(manager)
|
: QObject(parent), m_manager(manager)
|
||||||
{}
|
{}
|
||||||
|
|||||||
@@ -33,10 +33,10 @@
|
|||||||
#include <QTreeView>
|
#include <QTreeView>
|
||||||
|
|
||||||
namespace Debugger {
|
namespace Debugger {
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
class DebuggerManager;
|
class DebuggerManager;
|
||||||
|
|
||||||
|
namespace Internal {
|
||||||
|
|
||||||
class ModulesWindow : public QTreeView
|
class ModulesWindow : public QTreeView
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|||||||
@@ -30,13 +30,12 @@
|
|||||||
#ifndef DEBUGGER_REGISTERWINDOW_H
|
#ifndef DEBUGGER_REGISTERWINDOW_H
|
||||||
#define DEBUGGER_REGISTERWINDOW_H
|
#define DEBUGGER_REGISTERWINDOW_H
|
||||||
|
|
||||||
#include <QTreeView>
|
#include <QtGui/QTreeView>
|
||||||
|
|
||||||
namespace Debugger {
|
namespace Debugger {
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
class DebuggerManager;
|
class DebuggerManager;
|
||||||
|
|
||||||
|
namespace Internal {
|
||||||
class RegisterWindow : public QTreeView
|
class RegisterWindow : public QTreeView
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|||||||
@@ -39,9 +39,9 @@ class QModelIndex;
|
|||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
namespace Debugger {
|
namespace Debugger {
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
class DebuggerManager;
|
class DebuggerManager;
|
||||||
|
|
||||||
|
namespace Internal {
|
||||||
class DisassemblerViewAgent;
|
class DisassemblerViewAgent;
|
||||||
|
|
||||||
class StackWindow : public QTreeView
|
class StackWindow : public QTreeView
|
||||||
|
|||||||
@@ -29,6 +29,7 @@
|
|||||||
|
|
||||||
#include "tcfengine.h"
|
#include "tcfengine.h"
|
||||||
|
|
||||||
|
#include "debuggerstringutils.h"
|
||||||
#include "debuggerdialogs.h"
|
#include "debuggerdialogs.h"
|
||||||
#include "breakhandler.h"
|
#include "breakhandler.h"
|
||||||
#include "debuggerconstants.h"
|
#include "debuggerconstants.h"
|
||||||
|
|||||||
@@ -262,7 +262,7 @@ public:
|
|||||||
static QString watcherEditPlaceHolder();
|
static QString watcherEditPlaceHolder();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void watchDataUpdateNeeded(const WatchData &data);
|
void watchDataUpdateNeeded(const Debugger::Internal::WatchData &data);
|
||||||
void sessionValueRequested(const QString &name, QVariant *value);
|
void sessionValueRequested(const QString &name, QVariant *value);
|
||||||
void setSessionValueRequested(const QString &name, const QVariant &value);
|
void setSessionValueRequested(const QString &name, const QVariant &value);
|
||||||
|
|
||||||
|
|||||||
@@ -33,6 +33,7 @@
|
|||||||
#include "debuggeractions.h"
|
#include "debuggeractions.h"
|
||||||
#include "debuggeragents.h"
|
#include "debuggeragents.h"
|
||||||
#include "debuggerdialogs.h"
|
#include "debuggerdialogs.h"
|
||||||
|
#include "debuggermanager.h"
|
||||||
|
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
@@ -50,6 +51,7 @@
|
|||||||
#include <QtGui/QMenu>
|
#include <QtGui/QMenu>
|
||||||
#include <QtGui/QResizeEvent>
|
#include <QtGui/QResizeEvent>
|
||||||
|
|
||||||
|
using namespace Debugger;
|
||||||
using namespace Debugger::Internal;
|
using namespace Debugger::Internal;
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////
|
||||||
|
|||||||
@@ -33,6 +33,8 @@
|
|||||||
#include <QtGui/QTreeView>
|
#include <QtGui/QTreeView>
|
||||||
|
|
||||||
namespace Debugger {
|
namespace Debugger {
|
||||||
|
class DebuggerManager;
|
||||||
|
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////
|
||||||
@@ -41,8 +43,6 @@ namespace Internal {
|
|||||||
//
|
//
|
||||||
/////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
class DebuggerManager;
|
|
||||||
|
|
||||||
class WatchWindow : public QTreeView
|
class WatchWindow : public QTreeView
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|||||||
@@ -129,7 +129,6 @@ GitPlugin::GitPlugin() :
|
|||||||
m_showAction(0),
|
m_showAction(0),
|
||||||
m_stageAction(0),
|
m_stageAction(0),
|
||||||
m_unstageAction(0),
|
m_unstageAction(0),
|
||||||
m_revertAction(0),
|
|
||||||
m_commitAction(0),
|
m_commitAction(0),
|
||||||
m_pullAction(0),
|
m_pullAction(0),
|
||||||
m_pushAction(0),
|
m_pushAction(0),
|
||||||
@@ -298,12 +297,6 @@ bool GitPlugin::initialize(const QStringList &arguments, QString *errorMessage)
|
|||||||
connect(m_unstageAction, SIGNAL(triggered()), this, SLOT(unstageFile()));
|
connect(m_unstageAction, SIGNAL(triggered()), this, SLOT(unstageFile()));
|
||||||
gitContainer->addAction(command);
|
gitContainer->addAction(command);
|
||||||
|
|
||||||
m_revertAction = new Core::Utils::ParameterAction(tr("Revert..."), tr("Revert \"%1\"..."), Core::Utils::ParameterAction::AlwaysEnabled, this);
|
|
||||||
command = actionManager->registerAction(m_revertAction, "Git.Revert", globalcontext);
|
|
||||||
command->setAttribute(Core::Command::CA_UpdateText);
|
|
||||||
connect(m_revertAction, SIGNAL(triggered()), this, SLOT(revertFile()));
|
|
||||||
gitContainer->addAction(command);
|
|
||||||
|
|
||||||
gitContainer->addAction(createSeparator(actionManager, globalcontext, QLatin1String("Git.Sep.Project"), this));
|
gitContainer->addAction(createSeparator(actionManager, globalcontext, QLatin1String("Git.Sep.Project"), this));
|
||||||
|
|
||||||
m_diffProjectAction = new Core::Utils::ParameterAction(tr("Diff Current Project"), tr("Diff Project \"%1\""), Core::Utils::ParameterAction::AlwaysEnabled, this);
|
m_diffProjectAction = new Core::Utils::ParameterAction(tr("Diff Current Project"), tr("Diff Project \"%1\""), Core::Utils::ParameterAction::AlwaysEnabled, this);
|
||||||
@@ -756,7 +749,6 @@ void GitPlugin::updateActions()
|
|||||||
m_undoFileAction->setParameter(fileName);
|
m_undoFileAction->setParameter(fileName);
|
||||||
m_stageAction->setParameter(fileName);
|
m_stageAction->setParameter(fileName);
|
||||||
m_unstageAction->setParameter(fileName);
|
m_unstageAction->setParameter(fileName);
|
||||||
m_revertAction->setParameter(fileName);
|
|
||||||
|
|
||||||
bool enabled = !fileName.isEmpty() && !repository.isEmpty();
|
bool enabled = !fileName.isEmpty() && !repository.isEmpty();
|
||||||
m_diffAction->setEnabled(enabled);
|
m_diffAction->setEnabled(enabled);
|
||||||
@@ -766,7 +758,6 @@ void GitPlugin::updateActions()
|
|||||||
m_undoFileAction->setEnabled(enabled);
|
m_undoFileAction->setEnabled(enabled);
|
||||||
m_stageAction->setEnabled(enabled);
|
m_stageAction->setEnabled(enabled);
|
||||||
m_unstageAction->setEnabled(enabled);
|
m_unstageAction->setEnabled(enabled);
|
||||||
m_revertAction->setEnabled(enabled);
|
|
||||||
|
|
||||||
if (repository.isEmpty()) {
|
if (repository.isEmpty()) {
|
||||||
// If the file is not in a repository, the corresponding project will
|
// If the file is not in a repository, the corresponding project will
|
||||||
|
|||||||
@@ -145,7 +145,6 @@ private:
|
|||||||
QAction *m_showAction;
|
QAction *m_showAction;
|
||||||
Core::Utils::ParameterAction *m_stageAction;
|
Core::Utils::ParameterAction *m_stageAction;
|
||||||
Core::Utils::ParameterAction *m_unstageAction;
|
Core::Utils::ParameterAction *m_unstageAction;
|
||||||
Core::Utils::ParameterAction *m_revertAction;
|
|
||||||
QAction *m_commitAction;
|
QAction *m_commitAction;
|
||||||
QAction *m_pullAction;
|
QAction *m_pullAction;
|
||||||
QAction *m_pushAction;
|
QAction *m_pushAction;
|
||||||
|
|||||||
@@ -122,9 +122,5 @@ void ProFileReader::errorMessage(const QString &message)
|
|||||||
|
|
||||||
ProFile *ProFileReader::proFileFor(const QString &name)
|
ProFile *ProFileReader::proFileFor(const QString &name)
|
||||||
{
|
{
|
||||||
QMap<QString, ProFile *>::const_iterator it = m_includeFiles.constFind(name);
|
return m_includeFiles.value(name);
|
||||||
if (it == m_includeFiles.constEnd())
|
|
||||||
return 0;
|
|
||||||
else
|
|
||||||
return it.value();
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -644,6 +644,7 @@ void S60DeviceRunControl::signsisProcessFinished()
|
|||||||
connect(m_launcher, SIGNAL(installingStarted()), this, SLOT(printInstallingNotice()));
|
connect(m_launcher, SIGNAL(installingStarted()), this, SLOT(printInstallingNotice()));
|
||||||
connect(m_launcher, SIGNAL(startingApplication()), this, SLOT(printStartingNotice()));
|
connect(m_launcher, SIGNAL(startingApplication()), this, SLOT(printStartingNotice()));
|
||||||
connect(m_launcher, SIGNAL(applicationRunning(uint)), this, SLOT(printRunNotice(uint)));
|
connect(m_launcher, SIGNAL(applicationRunning(uint)), this, SLOT(printRunNotice(uint)));
|
||||||
|
connect(m_launcher, SIGNAL(canNotRun(QString)), this, SLOT(printRunFailNotice(QString)));
|
||||||
connect(m_launcher, SIGNAL(applicationOutputReceived(QString)), this, SLOT(printApplicationOutput(QString)));
|
connect(m_launcher, SIGNAL(applicationOutputReceived(QString)), this, SLOT(printApplicationOutput(QString)));
|
||||||
connect(m_launcher, SIGNAL(copyProgress(int)), this, SLOT(printCopyProgress(int)));
|
connect(m_launcher, SIGNAL(copyProgress(int)), this, SLOT(printCopyProgress(int)));
|
||||||
|
|
||||||
@@ -692,6 +693,10 @@ void S60DeviceRunControl::printRunNotice(uint pid)
|
|||||||
emit addToOutputWindow(this, tr("Application running with pid %1.").arg(pid));
|
emit addToOutputWindow(this, tr("Application running with pid %1.").arg(pid));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void S60DeviceRunControl::printRunFailNotice(const QString &errorMessage) {
|
||||||
|
emit addToOutputWindow(this, tr("Could not start application: %1").arg(errorMessage));
|
||||||
|
}
|
||||||
|
|
||||||
void S60DeviceRunControl::printApplicationOutput(const QString &output)
|
void S60DeviceRunControl::printApplicationOutput(const QString &output)
|
||||||
{
|
{
|
||||||
emit addToOutputWindowInline(this, output);
|
emit addToOutputWindowInline(this, output);
|
||||||
|
|||||||
@@ -164,6 +164,7 @@ private slots:
|
|||||||
void printInstallingNotice();
|
void printInstallingNotice();
|
||||||
void printStartingNotice();
|
void printStartingNotice();
|
||||||
void printRunNotice(uint pid);
|
void printRunNotice(uint pid);
|
||||||
|
void printRunFailNotice(const QString &errorMessage);
|
||||||
void printApplicationOutput(const QString &output);
|
void printApplicationOutput(const QString &output);
|
||||||
void runFinished();
|
void runFinished();
|
||||||
|
|
||||||
|
|||||||
@@ -1528,6 +1528,18 @@ int TextBlockUserData::collapseAtPos() const
|
|||||||
return Parenthesis::collapseAtPos(m_parentheses);
|
return Parenthesis::collapseAtPos(m_parentheses);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int TextBlockUserData::braceDepthDelta() const
|
||||||
|
{
|
||||||
|
int delta = 0;
|
||||||
|
for (int i = 0; i < m_parentheses.size(); ++i) {
|
||||||
|
switch (m_parentheses.at(i).chr.unicode()) {
|
||||||
|
case '{': case '+': ++delta; break;
|
||||||
|
case '}': case '-': --delta; break;
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return delta;
|
||||||
|
}
|
||||||
|
|
||||||
void TextEditDocumentLayout::setParentheses(const QTextBlock &block, const Parentheses &parentheses)
|
void TextEditDocumentLayout::setParentheses(const QTextBlock &block, const Parentheses &parentheses)
|
||||||
{
|
{
|
||||||
@@ -1553,6 +1565,35 @@ bool TextEditDocumentLayout::hasParentheses(const QTextBlock &block)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int TextEditDocumentLayout::braceDepthDelta(const QTextBlock &block)
|
||||||
|
{
|
||||||
|
if (TextBlockUserData *userData = testUserData(block))
|
||||||
|
return userData->braceDepthDelta();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int TextEditDocumentLayout::braceDepth(const QTextBlock &block)
|
||||||
|
{
|
||||||
|
int state = block.userState();
|
||||||
|
if (state == -1)
|
||||||
|
return 0;
|
||||||
|
return state >> 8;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TextEditDocumentLayout::setBraceDepth(QTextBlock &block, int depth)
|
||||||
|
{
|
||||||
|
int state = block.userState();
|
||||||
|
if (state == -1)
|
||||||
|
state = 0;
|
||||||
|
state = state & 0xff;
|
||||||
|
block.setUserState((depth << 8) | state);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TextEditDocumentLayout::changeBraceDepth(QTextBlock &block, int delta)
|
||||||
|
{
|
||||||
|
if (delta)
|
||||||
|
setBraceDepth(block, braceDepth(block) + delta);
|
||||||
|
}
|
||||||
|
|
||||||
bool TextEditDocumentLayout::setIfdefedOut(const QTextBlock &block)
|
bool TextEditDocumentLayout::setIfdefedOut(const QTextBlock &block)
|
||||||
{
|
{
|
||||||
@@ -2683,6 +2724,11 @@ void BaseTextEditor::updateCurrentLineHighlight()
|
|||||||
|
|
||||||
void BaseTextEditor::slotCursorPositionChanged()
|
void BaseTextEditor::slotCursorPositionChanged()
|
||||||
{
|
{
|
||||||
|
#if 0
|
||||||
|
qDebug() << "block" << textCursor().blockNumber()+1
|
||||||
|
<< "depth:" << TextEditDocumentLayout::braceDepth(textCursor().block())
|
||||||
|
<< "/" << TextEditDocumentLayout::braceDepth(document()->lastBlock());
|
||||||
|
#endif
|
||||||
if (!d->m_contentsChanged && d->m_lastCursorChangeWasInteresting) {
|
if (!d->m_contentsChanged && d->m_lastCursorChangeWasInteresting) {
|
||||||
Core::EditorManager::instance()->addCurrentPositionToNavigationHistory(editableInterface(), d->m_tempNavigationState);
|
Core::EditorManager::instance()->addCurrentPositionToNavigationHistory(editableInterface(), d->m_tempNavigationState);
|
||||||
d->m_lastCursorChangeWasInteresting = false;
|
d->m_lastCursorChangeWasInteresting = false;
|
||||||
@@ -4026,21 +4072,36 @@ void BaseTextEditor::setIfdefedOutBlocks(const QList<BaseTextEditor::BlockRange>
|
|||||||
QTextBlock block = doc->firstBlock();
|
QTextBlock block = doc->firstBlock();
|
||||||
|
|
||||||
int rangeNumber = 0;
|
int rangeNumber = 0;
|
||||||
|
int braceDepthDelta = 0;
|
||||||
while (block.isValid()) {
|
while (block.isValid()) {
|
||||||
|
bool cleared = false;
|
||||||
|
bool set = false;
|
||||||
if (rangeNumber < blocks.size()) {
|
if (rangeNumber < blocks.size()) {
|
||||||
const BlockRange &range = blocks.at(rangeNumber);
|
const BlockRange &range = blocks.at(rangeNumber);
|
||||||
|
|
||||||
if (block.position() >= range.first && (block.position() <= range.last || !range.last)) {
|
if (block.position() >= range.first && (block.position() <= range.last || !range.last)) {
|
||||||
needUpdate |= TextEditDocumentLayout::setIfdefedOut(block);
|
set = TextEditDocumentLayout::setIfdefedOut(block);
|
||||||
} else {
|
} else {
|
||||||
needUpdate |= TextEditDocumentLayout::clearIfdefedOut(block);
|
cleared = TextEditDocumentLayout::clearIfdefedOut(block);
|
||||||
}
|
}
|
||||||
if (block.contains(range.last))
|
if (block.contains(range.last))
|
||||||
++rangeNumber;
|
++rangeNumber;
|
||||||
} else {
|
} else {
|
||||||
needUpdate |= TextEditDocumentLayout::clearIfdefedOut(block);
|
cleared = TextEditDocumentLayout::clearIfdefedOut(block);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (cleared || set) {
|
||||||
|
needUpdate = true;
|
||||||
|
int delta = TextEditDocumentLayout::braceDepthDelta(block);
|
||||||
|
if (cleared)
|
||||||
|
braceDepthDelta += delta;
|
||||||
|
else if (set)
|
||||||
|
braceDepthDelta -= delta;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (braceDepthDelta)
|
||||||
|
TextEditDocumentLayout::changeBraceDepth(block,braceDepthDelta);
|
||||||
|
|
||||||
block = block.next();
|
block = block.next();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -128,6 +128,7 @@ public:
|
|||||||
inline void clearParentheses() { m_parentheses.clear(); }
|
inline void clearParentheses() { m_parentheses.clear(); }
|
||||||
inline const Parentheses &parentheses() const { return m_parentheses; }
|
inline const Parentheses &parentheses() const { return m_parentheses; }
|
||||||
inline bool hasParentheses() const { return !m_parentheses.isEmpty(); }
|
inline bool hasParentheses() const { return !m_parentheses.isEmpty(); }
|
||||||
|
int braceDepthDelta() const;
|
||||||
|
|
||||||
inline bool setIfdefedOut() { bool result = m_ifdefedOut; m_ifdefedOut = true; return !result; }
|
inline bool setIfdefedOut() { bool result = m_ifdefedOut; m_ifdefedOut = true; return !result; }
|
||||||
inline bool clearIfdefedOut() { bool result = m_ifdefedOut; m_ifdefedOut = false; return result;}
|
inline bool clearIfdefedOut() { bool result = m_ifdefedOut; m_ifdefedOut = false; return result;}
|
||||||
@@ -215,6 +216,10 @@ public:
|
|||||||
static bool setIfdefedOut(const QTextBlock &block);
|
static bool setIfdefedOut(const QTextBlock &block);
|
||||||
static bool clearIfdefedOut(const QTextBlock &block);
|
static bool clearIfdefedOut(const QTextBlock &block);
|
||||||
static bool ifdefedOut(const QTextBlock &block);
|
static bool ifdefedOut(const QTextBlock &block);
|
||||||
|
static int braceDepthDelta(const QTextBlock &block);
|
||||||
|
static int braceDepth(const QTextBlock &block);
|
||||||
|
static void setBraceDepth(QTextBlock &block, int depth);
|
||||||
|
static void changeBraceDepth(QTextBlock &block, int delta);
|
||||||
|
|
||||||
static TextBlockUserData *testUserData(const QTextBlock &block) {
|
static TextBlockUserData *testUserData(const QTextBlock &block) {
|
||||||
return static_cast<TextBlockUserData*>(block.userData());
|
return static_cast<TextBlockUserData*>(block.userData());
|
||||||
|
|||||||
@@ -316,6 +316,7 @@ bool CheckDeclaration::visit(FunctionDefinitionAST *ast)
|
|||||||
translationUnit()->error(ast->ctor_initializer->firstToken(),
|
translationUnit()->error(ast->ctor_initializer->firstToken(),
|
||||||
"only constructors take base initializers");
|
"only constructors take base initializers");
|
||||||
}
|
}
|
||||||
|
accept(ast->ctor_initializer);
|
||||||
}
|
}
|
||||||
|
|
||||||
const int previousVisibility = semantic()->switchVisibility(Symbol::Public);
|
const int previousVisibility = semantic()->switchVisibility(Symbol::Public);
|
||||||
|
|||||||
@@ -168,6 +168,9 @@ bool CheckDeclarator::visit(FunctionDeclaratorAST *ast)
|
|||||||
ast->symbol = fun;
|
ast->symbol = fun;
|
||||||
fun->setReturnType(_fullySpecifiedType);
|
fun->setReturnType(_fullySpecifiedType);
|
||||||
|
|
||||||
|
if (_fullySpecifiedType.isVirtual())
|
||||||
|
fun->setVirtual(true);
|
||||||
|
|
||||||
if (ast->parameters) {
|
if (ast->parameters) {
|
||||||
DeclarationListAST *parameter_declarations = ast->parameters->parameter_declarations;
|
DeclarationListAST *parameter_declarations = ast->parameters->parameter_declarations;
|
||||||
for (DeclarationListAST *decl = parameter_declarations; decl; decl = decl->next) {
|
for (DeclarationListAST *decl = parameter_declarations; decl; decl = decl->next) {
|
||||||
|
|||||||
@@ -259,6 +259,12 @@ bool Function::hasArguments() const
|
|||||||
(argumentCount() == 1 && argumentAt(0)->type()->isVoidType()));
|
(argumentCount() == 1 && argumentAt(0)->type()->isVoidType()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Function::isVirtual() const
|
||||||
|
{ return f._isVirtual; }
|
||||||
|
|
||||||
|
void Function::setVirtual(bool isVirtual)
|
||||||
|
{ f._isVirtual = isVirtual; }
|
||||||
|
|
||||||
bool Function::isVariadic() const
|
bool Function::isVariadic() const
|
||||||
{ return f._isVariadic; }
|
{ return f._isVariadic; }
|
||||||
|
|
||||||
|
|||||||
@@ -307,6 +307,9 @@ public:
|
|||||||
/** Convenience function that returns whether the function receives any arguments. */
|
/** Convenience function that returns whether the function receives any arguments. */
|
||||||
bool hasArguments() const;
|
bool hasArguments() const;
|
||||||
|
|
||||||
|
bool isVirtual() const;
|
||||||
|
void setVirtual(bool isVirtual);
|
||||||
|
|
||||||
bool isVariadic() const;
|
bool isVariadic() const;
|
||||||
void setVariadic(bool isVariadic);
|
void setVariadic(bool isVariadic);
|
||||||
|
|
||||||
@@ -348,6 +351,7 @@ private:
|
|||||||
TemplateParameters *_templateParameters;
|
TemplateParameters *_templateParameters;
|
||||||
FullySpecifiedType _returnType;
|
FullySpecifiedType _returnType;
|
||||||
struct Flags {
|
struct Flags {
|
||||||
|
unsigned _isVirtual: 1;
|
||||||
unsigned _isVariadic: 1;
|
unsigned _isVariadic: 1;
|
||||||
unsigned _isPureVirtual: 1;
|
unsigned _isPureVirtual: 1;
|
||||||
unsigned _isConst: 1;
|
unsigned _isConst: 1;
|
||||||
|
|||||||
@@ -368,6 +368,11 @@ void Launcher::handleCpuType(const TrkResult &result)
|
|||||||
|
|
||||||
void Launcher::handleCreateProcess(const TrkResult &result)
|
void Launcher::handleCreateProcess(const TrkResult &result)
|
||||||
{
|
{
|
||||||
|
if (result.errorCode()) {
|
||||||
|
emit canNotRun(errorMessage(result.errorCode()));
|
||||||
|
emit finished();
|
||||||
|
return;
|
||||||
|
}
|
||||||
// 40 00 00]
|
// 40 00 00]
|
||||||
//logMessage(" RESULT: " + result.toString());
|
//logMessage(" RESULT: " + result.toString());
|
||||||
// [80 08 00 00 00 01 B5 00 00 01 B6 78 67 40 00 00 40 00 00]
|
// [80 08 00 00 00 01 B5 00 00 01 B6 78 67 40 00 00 40 00 00]
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ signals:
|
|||||||
void installingStarted();
|
void installingStarted();
|
||||||
void startingApplication();
|
void startingApplication();
|
||||||
void applicationRunning(uint pid);
|
void applicationRunning(uint pid);
|
||||||
|
void canNotRun(const QString &errorMessage);
|
||||||
void finished();
|
void finished();
|
||||||
void applicationOutputReceived(const QString &output);
|
void applicationOutputReceived(const QString &output);
|
||||||
void copyProgress(int percent);
|
void copyProgress(int percent);
|
||||||
@@ -71,8 +72,6 @@ private slots:
|
|||||||
void handleResult(const trk::TrkResult &data);
|
void handleResult(const trk::TrkResult &data);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void tryTrkRead();
|
|
||||||
|
|
||||||
// kill process and breakpoints
|
// kill process and breakpoints
|
||||||
void cleanUp();
|
void cleanUp();
|
||||||
|
|
||||||
@@ -89,7 +88,6 @@ private:
|
|||||||
void handleTrkVersion(const TrkResult &result);
|
void handleTrkVersion(const TrkResult &result);
|
||||||
void waitForTrkFinished(const TrkResult &data);
|
void waitForTrkFinished(const TrkResult &data);
|
||||||
|
|
||||||
void handleAndReportCreateProcess(const TrkResult &result);
|
|
||||||
void copyFileToRemote();
|
void copyFileToRemote();
|
||||||
void installRemotePackageSilently(const QString &filename);
|
void installRemotePackageSilently(const QString &filename);
|
||||||
void installAndRun();
|
void installAndRun();
|
||||||
|
|||||||
@@ -119,6 +119,7 @@ TrkMessage::TrkMessage(byte c, byte t, TrkCallback cb) :
|
|||||||
} // namespace trk
|
} // namespace trk
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(trk::TrkMessage)
|
Q_DECLARE_METATYPE(trk::TrkMessage)
|
||||||
|
Q_DECLARE_METATYPE(trk::TrkResult)
|
||||||
|
|
||||||
namespace trk {
|
namespace trk {
|
||||||
|
|
||||||
@@ -408,7 +409,7 @@ static inline bool overlappedSyncWrite(HANDLE file, const char *data,
|
|||||||
|
|
||||||
bool WriterThread::write(const QByteArray &data, QString *errorMessage)
|
bool WriterThread::write(const QByteArray &data, QString *errorMessage)
|
||||||
{
|
{
|
||||||
QMutexLocker(&m_context->mutex);
|
QMutexLocker locker(&m_context->mutex);
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
DWORD charsWritten;
|
DWORD charsWritten;
|
||||||
if (!overlappedSyncWrite(m_context->device, data.data(), data.size(), &charsWritten, &m_context->writeOverlapped)) {
|
if (!overlappedSyncWrite(m_context->device, data.data(), data.size(), &charsWritten, &m_context->writeOverlapped)) {
|
||||||
@@ -465,6 +466,65 @@ void WriterThread::slotHandleResult(const TrkResult &result)
|
|||||||
tryWrite(); // Have messages been enqueued in-between?
|
tryWrite(); // Have messages been enqueued in-between?
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// ReaderThreadBase: Base class for a thread that reads data from
|
||||||
|
// the device, decodes the messages and emit signals for the messages.
|
||||||
|
// A Qt::BlockingQueuedConnection should be used for the message signal
|
||||||
|
// to ensure messages are processed in the correct sequence.
|
||||||
|
//
|
||||||
|
///////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
class ReaderThreadBase : public QThread {
|
||||||
|
Q_OBJECT
|
||||||
|
Q_DISABLE_COPY(ReaderThreadBase)
|
||||||
|
public:
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void messageReceived(const trk::TrkResult &result, const QByteArray &rawData);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
explicit ReaderThreadBase(const QSharedPointer<DeviceContext> &context);
|
||||||
|
void processData(const QByteArray &a);
|
||||||
|
void processData(char c);
|
||||||
|
|
||||||
|
const QSharedPointer<DeviceContext> m_context;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void readMessages();
|
||||||
|
|
||||||
|
QByteArray m_trkReadBuffer;
|
||||||
|
};
|
||||||
|
|
||||||
|
ReaderThreadBase::ReaderThreadBase(const QSharedPointer<DeviceContext> &context) :
|
||||||
|
m_context(context)
|
||||||
|
{
|
||||||
|
static const int trkResultMetaId = qRegisterMetaType<trk::TrkResult>();
|
||||||
|
Q_UNUSED(trkResultMetaId)
|
||||||
|
}
|
||||||
|
|
||||||
|
void ReaderThreadBase::processData(const QByteArray &a)
|
||||||
|
{
|
||||||
|
m_trkReadBuffer += a;
|
||||||
|
readMessages();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ReaderThreadBase::processData(char c)
|
||||||
|
{
|
||||||
|
m_trkReadBuffer += c;
|
||||||
|
if (m_trkReadBuffer.size() > 1)
|
||||||
|
readMessages();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ReaderThreadBase::readMessages()
|
||||||
|
{
|
||||||
|
TrkResult r;
|
||||||
|
QByteArray rawData;
|
||||||
|
while (extractResult(&m_trkReadBuffer, m_context->serialFrame, &r, &rawData)) {
|
||||||
|
emit messageReceived(r, rawData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
///////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
@@ -474,7 +534,7 @@ void WriterThread::slotHandleResult(const TrkResult &result)
|
|||||||
//
|
//
|
||||||
///////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
class WinReaderThread : public QThread {
|
class WinReaderThread : public ReaderThreadBase {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_DISABLE_COPY(WinReaderThread)
|
Q_DISABLE_COPY(WinReaderThread)
|
||||||
public:
|
public:
|
||||||
@@ -485,8 +545,6 @@ public:
|
|||||||
|
|
||||||
signals:
|
signals:
|
||||||
void error(const QString &);
|
void error(const QString &);
|
||||||
void dataReceived(char c);
|
|
||||||
void dataReceived(const QByteArray &data);
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void terminate();
|
void terminate();
|
||||||
@@ -496,12 +554,11 @@ private:
|
|||||||
|
|
||||||
inline int tryRead();
|
inline int tryRead();
|
||||||
|
|
||||||
const QSharedPointer<DeviceContext> m_context;
|
|
||||||
HANDLE m_handles[HandleCount];
|
HANDLE m_handles[HandleCount];
|
||||||
};
|
};
|
||||||
|
|
||||||
WinReaderThread::WinReaderThread(const QSharedPointer<DeviceContext> &context) :
|
WinReaderThread::WinReaderThread(const QSharedPointer<DeviceContext> &context) :
|
||||||
m_context(context)
|
ReaderThreadBase(context)
|
||||||
{
|
{
|
||||||
m_handles[FileHandle] = NULL;
|
m_handles[FileHandle] = NULL;
|
||||||
m_handles[TerminateEventHandle] = CreateEvent(NULL, FALSE, FALSE, NULL);
|
m_handles[TerminateEventHandle] = CreateEvent(NULL, FALSE, FALSE, NULL);
|
||||||
@@ -528,9 +585,9 @@ int WinReaderThread::tryRead()
|
|||||||
DWORD bytesRead = 0;
|
DWORD bytesRead = 0;
|
||||||
if (ReadFile(m_context->device, &buffer, bytesToRead, &bytesRead, &m_context->readOverlapped)) {
|
if (ReadFile(m_context->device, &buffer, bytesToRead, &bytesRead, &m_context->readOverlapped)) {
|
||||||
if (bytesRead == 1) {
|
if (bytesRead == 1) {
|
||||||
emit dataReceived(buffer[0]);
|
processData(buffer[0]);
|
||||||
} else {
|
} else {
|
||||||
emit dataReceived(QByteArray(buffer, bytesRead));
|
processData(QByteArray(buffer, bytesRead));
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -554,9 +611,9 @@ int WinReaderThread::tryRead()
|
|||||||
return -3;
|
return -3;
|
||||||
}
|
}
|
||||||
if (bytesRead == 1) {
|
if (bytesRead == 1) {
|
||||||
emit dataReceived(buffer[0]);
|
processData(buffer[0]);
|
||||||
} else {
|
} else {
|
||||||
emit dataReceived(QByteArray(buffer, bytesRead));
|
processData(QByteArray(buffer, bytesRead));
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -564,8 +621,7 @@ int WinReaderThread::tryRead()
|
|||||||
void WinReaderThread::run()
|
void WinReaderThread::run()
|
||||||
{
|
{
|
||||||
m_handles[FileHandle] = m_context->readOverlapped.hEvent;
|
m_handles[FileHandle] = m_context->readOverlapped.hEvent;
|
||||||
int readResult;
|
while ( tryRead() == 0) ;
|
||||||
while ( (readResult = tryRead()) == 0) ;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WinReaderThread::terminate()
|
void WinReaderThread::terminate()
|
||||||
@@ -593,7 +649,7 @@ static inline QString msgUnixCallFailedErrno(const char *func, int errorNumber)
|
|||||||
return QString::fromLatin1("Call to %1() failed: %2").arg(QLatin1String(func), QString::fromLocal8Bit(strerror(errorNumber)));
|
return QString::fromLatin1("Call to %1() failed: %2").arg(QLatin1String(func), QString::fromLocal8Bit(strerror(errorNumber)));
|
||||||
}
|
}
|
||||||
|
|
||||||
class UnixReaderThread : public QThread {
|
class UnixReaderThread : public ReaderThreadBase {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_DISABLE_COPY(UnixReaderThread)
|
Q_DISABLE_COPY(UnixReaderThread)
|
||||||
public:
|
public:
|
||||||
@@ -604,7 +660,6 @@ public:
|
|||||||
|
|
||||||
signals:
|
signals:
|
||||||
void error(const QString &);
|
void error(const QString &);
|
||||||
void dataReceived(const QByteArray &);
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void terminate();
|
void terminate();
|
||||||
@@ -612,12 +667,11 @@ public slots:
|
|||||||
private:
|
private:
|
||||||
inline int tryRead();
|
inline int tryRead();
|
||||||
|
|
||||||
const QSharedPointer<DeviceContext> m_context;
|
|
||||||
int m_terminatePipeFileDescriptors[2];
|
int m_terminatePipeFileDescriptors[2];
|
||||||
};
|
};
|
||||||
|
|
||||||
UnixReaderThread::UnixReaderThread(const QSharedPointer<DeviceContext> &context) :
|
UnixReaderThread::UnixReaderThread(const QSharedPointer<DeviceContext> &context) :
|
||||||
m_context(context)
|
ReaderThreadBase(context)
|
||||||
{
|
{
|
||||||
m_terminatePipeFileDescriptors[0] = m_terminatePipeFileDescriptors[1] = -1;
|
m_terminatePipeFileDescriptors[0] = m_terminatePipeFileDescriptors[1] = -1;
|
||||||
// Set up pipes for termination. Should not fail
|
// Set up pipes for termination. Should not fail
|
||||||
@@ -675,15 +729,14 @@ int UnixReaderThread::tryRead()
|
|||||||
m_context->mutex.lock();
|
m_context->mutex.lock();
|
||||||
const QByteArray data = m_context->file.read(numBytes);
|
const QByteArray data = m_context->file.read(numBytes);
|
||||||
m_context->mutex.unlock();
|
m_context->mutex.unlock();
|
||||||
emit dataReceived(data);
|
processData(data);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnixReaderThread::run()
|
void UnixReaderThread::run()
|
||||||
{
|
{
|
||||||
int readResult;
|
|
||||||
// Read loop
|
// Read loop
|
||||||
while ( (readResult = tryRead()) == 0) ;
|
while ( tryRead() == 0) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnixReaderThread::terminate()
|
void UnixReaderThread::terminate()
|
||||||
@@ -801,12 +854,9 @@ bool TrkDevice::open(const QString &port, QString *errorMessage)
|
|||||||
d->readerThread = QSharedPointer<ReaderThread>(new ReaderThread(d->deviceContext));
|
d->readerThread = QSharedPointer<ReaderThread>(new ReaderThread(d->deviceContext));
|
||||||
connect(d->readerThread.data(), SIGNAL(error(QString)), this, SLOT(emitError(QString)),
|
connect(d->readerThread.data(), SIGNAL(error(QString)), this, SLOT(emitError(QString)),
|
||||||
Qt::QueuedConnection);
|
Qt::QueuedConnection);
|
||||||
#ifdef Q_OS_WIN
|
connect(d->readerThread.data(), SIGNAL(messageReceived(trk::TrkResult,QByteArray)),
|
||||||
connect(d->readerThread.data(), SIGNAL(dataReceived(char)),
|
this, SLOT(slotMessageReceived(trk::TrkResult,QByteArray)),
|
||||||
this, SLOT(dataReceived(char)), Qt::QueuedConnection);
|
Qt::BlockingQueuedConnection);
|
||||||
#endif
|
|
||||||
connect(d->readerThread.data(), SIGNAL(dataReceived(QByteArray)),
|
|
||||||
this, SLOT(dataReceived(QByteArray)), Qt::QueuedConnection);
|
|
||||||
d->readerThread->start();
|
d->readerThread->start();
|
||||||
|
|
||||||
d->writerThread = QSharedPointer<WriterThread>(new WriterThread(d->deviceContext));
|
d->writerThread = QSharedPointer<WriterThread>(new WriterThread(d->deviceContext));
|
||||||
@@ -872,30 +922,12 @@ void TrkDevice::setVerbose(int b)
|
|||||||
d->verbose = b;
|
d->verbose = b;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrkDevice::dataReceived(char c)
|
void TrkDevice::slotMessageReceived(const trk::TrkResult &result, const QByteArray &rawData)
|
||||||
{
|
{
|
||||||
d->trkReadBuffer += c;
|
d->writerThread->slotHandleResult(result);
|
||||||
readMessages();
|
emit messageReceived(result);
|
||||||
}
|
if (!rawData.isEmpty())
|
||||||
|
emit rawDataReceived(rawData);
|
||||||
void TrkDevice::dataReceived(const QByteArray &data)
|
|
||||||
{
|
|
||||||
d->trkReadBuffer += data;
|
|
||||||
readMessages();
|
|
||||||
}
|
|
||||||
|
|
||||||
void TrkDevice::readMessages()
|
|
||||||
{
|
|
||||||
TrkResult r;
|
|
||||||
QByteArray rawData;
|
|
||||||
while (extractResult(&d->trkReadBuffer, d->deviceContext->serialFrame, &r, &rawData)) {
|
|
||||||
if (d->verbose > 1)
|
|
||||||
emitLogMessage("Read TrkResult " + r.data.toHex());
|
|
||||||
d->writerThread->slotHandleResult(r);
|
|
||||||
emit messageReceived(r);
|
|
||||||
if (!rawData.isEmpty())
|
|
||||||
emit rawDataReceived(rawData);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrkDevice::emitError(const QString &s)
|
void TrkDevice::emitError(const QString &s)
|
||||||
@@ -908,8 +940,11 @@ void TrkDevice::emitError(const QString &s)
|
|||||||
void TrkDevice::sendTrkMessage(byte code, TrkCallback callback,
|
void TrkDevice::sendTrkMessage(byte code, TrkCallback callback,
|
||||||
const QByteArray &data, const QVariant &cookie)
|
const QByteArray &data, const QVariant &cookie)
|
||||||
{
|
{
|
||||||
if (!d->writerThread.isNull())
|
if (!d->writerThread.isNull()) {
|
||||||
|
if (d->verbose > 1)
|
||||||
|
qDebug() << "Sending " << code << data.toHex();
|
||||||
d->writerThread->queueTrkMessage(code, callback, data, cookie);
|
d->writerThread->queueTrkMessage(code, callback, data, cookie);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrkDevice::sendTrkInitialPing()
|
void TrkDevice::sendTrkInitialPing()
|
||||||
|
|||||||
@@ -95,8 +95,6 @@ public:
|
|||||||
// Send an Ack synchronously, bypassing the queue
|
// Send an Ack synchronously, bypassing the queue
|
||||||
bool sendTrkAck(unsigned char token);
|
bool sendTrkAck(unsigned char token);
|
||||||
|
|
||||||
void tryTrkRead(); // TODO: Why public?
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void messageReceived(const trk::TrkResult &result);
|
void messageReceived(const trk::TrkResult &result);
|
||||||
// Emitted with the contents of messages enclosed in 07e, not for log output
|
// Emitted with the contents of messages enclosed in 07e, not for log output
|
||||||
@@ -105,8 +103,7 @@ signals:
|
|||||||
void logMessage(const QString &msg);
|
void logMessage(const QString &msg);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void dataReceived(char c);
|
void slotMessageReceived(const trk::TrkResult &result, const QByteArray &a);
|
||||||
void dataReceived(const QByteArray &a);
|
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
void emitError(const QString &msg);
|
void emitError(const QString &msg);
|
||||||
|
|||||||
Reference in New Issue
Block a user