Merge branch 'master' of git@scm.dev.nokia.troll.no:creator/mainline

This commit is contained in:
Erik Verbruggen
2009-09-28 11:46:20 +02:00
68 changed files with 2139 additions and 1230 deletions

View File

@@ -5,6 +5,7 @@ language = Cpp
headerdirs = . \
../../src/libs/aggregation \
../../src/libs/cplusplus \
../../src/libs/extensionsystem \
../../src/plugins/coreplugin \
../../src/plugins/find \
@@ -12,6 +13,7 @@ headerdirs = . \
sourcedirs = . \
../../src/libs/aggregation \
../../src/libs/cplusplus \
../../src/libs/extensionsystem \
../../src/plugins/coreplugin \
../../src/plugins/find \

File diff suppressed because it is too large Load Diff

View File

@@ -44,6 +44,11 @@
#include <QtCore/QBitArray>
#include <QtCore/QtDebug>
/*!
\namespace CPlusPlus
The namespace for C++ related tools.
*/
using namespace CPlusPlus;
namespace {
@@ -101,6 +106,7 @@ private:
} // anonymous namespace
Document::Document(const QString &fileName)
: _fileName(fileName),
_globalNamespace(0),
@@ -166,9 +172,10 @@ void Document::appendMacro(const Macro &macro)
}
void Document::addMacroUse(const Macro &macro, unsigned offset, unsigned length,
const QVector<MacroArgumentReference> &actuals)
const QVector<MacroArgumentReference> &actuals, bool inCondition)
{
MacroUse use(macro, offset, offset + length);
use.setInCondition(inCondition);
foreach (const MacroArgumentReference &actual, actuals) {
const Block arg(actual.position(), actual.position() + actual.length());
@@ -179,6 +186,60 @@ void Document::addMacroUse(const Macro &macro, unsigned offset, unsigned length,
_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
{
return _translationUnit;

View File

@@ -70,7 +70,8 @@ public:
void appendMacro(const Macro &macro);
void addMacroUse(const Macro &macro, unsigned offset, unsigned length,
const QVector<MacroArgumentReference> &range);
const QVector<MacroArgumentReference> &range, bool inCondition);
void addUndefinedMacroUse(const QByteArray &name, unsigned offset);
Control *control() const;
TranslationUnit *translationUnit() const;
@@ -220,13 +221,15 @@ public:
class MacroUse: public Block {
Macro _macro;
QVector<Block> _arguments;
bool _inCondition;
public:
inline MacroUse(const Macro &macro,
unsigned begin = 0,
unsigned end = 0)
: Block(begin, end),
_macro(macro)
_macro(macro),
_inCondition(false)
{ }
const Macro &macro() const
@@ -238,11 +241,37 @@ public:
QVector<Block> arguments() const
{ return _arguments; }
bool isInCondition() const
{ return _inCondition; }
private:
void setArguments(const QVector<Block> &arguments)
{ _arguments = arguments; }
void addArgument(const Block &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
@@ -254,6 +283,9 @@ public:
QList<MacroUse> macroUses() const
{ return _macroUses; }
QList<UndefinedMacroUse> undefinedMacroUses() const
{ return _undefinedMacroUses; }
private:
Symbol *findSymbolAt(unsigned line, unsigned column, Scope *scope) const;
@@ -267,6 +299,7 @@ private:
QList<Macro> _definedMacros;
QList<Block> _skippedBlocks;
QList<MacroUse> _macroUses;
QList<UndefinedMacroUse> _undefinedMacroUses;
QByteArray _source;
unsigned _revision;

View File

@@ -58,9 +58,13 @@ public:
virtual void macroAdded(const Macro &) {}
virtual void passedMacroDefinitionCheck(unsigned, const Macro &) {}
virtual void failedMacroDefinitionCheck(unsigned, const QByteArray &) {}
virtual void startExpandingMacro(unsigned,
const Macro &,
const QByteArray &,
bool,
const QVector<MacroArgumentReference> &) {}
virtual void stopExpandingMacro(unsigned, const Macro &) {}

View File

@@ -467,7 +467,7 @@ void LookupContext::expandFunction(Function *function,
}
void LookupContext::expandObjCMethod(ObjCMethod *method,
const QList<Scope *> &visibleScopes,
const QList<Scope *> &,
QList<Scope *> *expandedScopes) const
{
if (! expandedScopes->contains(method->arguments()))
@@ -495,3 +495,51 @@ void LookupContext::expand(Scope *scope,
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);
}

View File

@@ -54,6 +54,10 @@ public:
Document::Ptr document(const QString &fileName) 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
{ return resolve(name, visibleScopes()); }

View File

@@ -31,6 +31,44 @@
using namespace CPlusPlus;
/*!
\class Client
\brief A notification interface for for C++ preprocessor.
*/
/*!
\fn void Client::macroAdded(const Macro &macro)
Called whenever a new macro is defined.
*/
/*!
\fn void Client::passedMacroDefinitionCheck(unsigned offset, const Macro &macro)
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 &macro, 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()
{ }

View File

@@ -75,12 +75,14 @@ public:
virtual ~Client();
virtual void macroAdded(const Macro &macro) = 0;
virtual void sourceNeeded(QString &fileName, IncludeType mode,
unsigned line) = 0; // ### FIX the signature.
virtual void passedMacroDefinitionCheck(unsigned offset, const Macro &macro) = 0;
virtual void failedMacroDefinitionCheck(unsigned offset, const QByteArray &name) = 0;
virtual void startExpandingMacro(unsigned offset,
const Macro &macro,
const QByteArray &originalText,
bool inCondition = false,
const QVector<MacroArgumentReference> &actuals
= QVector<MacroArgumentReference>()) = 0;
@@ -89,6 +91,9 @@ public:
virtual void startSkippingBlocks(unsigned offset) = 0;
virtual void stopSkippingBlocks(unsigned offset) = 0;
virtual void sourceNeeded(QString &fileName, IncludeType mode,
unsigned line) = 0; // ### FIX the signature.
};
} // namespace CPlusPlus

View File

@@ -138,6 +138,18 @@ using namespace CPlusPlus;
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
{
const Token *first;
@@ -193,8 +205,8 @@ class ExpressionEvaluator
void operator = (const ExpressionEvaluator &other);
public:
ExpressionEvaluator(Environment *env)
: env(env), _lex(0)
ExpressionEvaluator(Client *client, Environment *env)
: client(client), env(env), _lex(0)
{ }
Value operator()(const Token *firstToken, const Token *lastToken,
@@ -255,13 +267,13 @@ protected:
} else if (isTokenDefined()) {
++(*_lex);
if ((*_lex)->is(T_IDENTIFIER)) {
_value.set_long(env->resolve(tokenSpell()) != 0);
_value.set_long(isMacroDefined(tokenSpell(), (*_lex)->offset, env, client));
++(*_lex);
return true;
} else if ((*_lex)->is(T_LPAREN)) {
++(*_lex);
if ((*_lex)->is(T_IDENTIFIER)) {
_value.set_long(env->resolve(tokenSpell()) != 0);
_value.set_long(isMacroDefined(tokenSpell(), (*_lex)->offset, env, client));
++(*_lex);
if ((*_lex)->is(T_RPAREN)) {
++(*_lex);
@@ -519,6 +531,7 @@ protected:
}
private:
Client *client;
Environment *env;
QByteArray source;
RangeLexer *_lex;
@@ -983,7 +996,7 @@ void Preprocessor::expandObjectLikeMacro(TokenIterator identifierToken,
{
if (client)
client->startExpandingMacro(identifierToken->offset,
*m, spell);
*m, spell, false);
m->setHidden(true);
expand(m->definition(), result);
@@ -1007,7 +1020,7 @@ void Preprocessor::expandFunctionLikeMacro(TokenIterator identifierToken,
endOfText - beginOfText);
client->startExpandingMacro(identifierToken->offset,
*m, text, actuals);
*m, text, false, actuals);
}
const bool was = markGeneratedTokens(true, identifierToken);
@@ -1253,7 +1266,7 @@ void Preprocessor::processIf(TokenIterator firstToken, TokenIterator lastToken)
const char *first = startOfToken(*tk);
const char *last = startOfToken(*lastToken);
MacroExpander expandCondition (env);
MacroExpander expandCondition (env, 0, client, tk.dot()->offset);
QByteArray condition;
condition.reserve(256);
expandCondition(first, last, &condition);
@@ -1297,7 +1310,7 @@ void Preprocessor::processElif(TokenIterator firstToken, TokenIterator lastToken
const char *first = startOfToken(*tk);
const char *last = startOfToken(*lastToken);
MacroExpander expandCondition (env);
MacroExpander expandCondition (env, 0, client, tk.dot()->offset);
QByteArray condition;
condition.reserve(256);
expandCondition(first, last, &condition);
@@ -1338,7 +1351,7 @@ void Preprocessor::processIfdef(bool checkUndefined,
if (testIfLevel()) {
if (tk->is(T_IDENTIFIER)) {
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)
value = ! value;
@@ -1437,7 +1450,7 @@ int Preprocessor::skipping() const
Value Preprocessor::evalExpression(TokenIterator firstToken, TokenIterator lastToken,
const QByteArray &source) const
{
ExpressionEvaluator eval(env);
ExpressionEvaluator eval(client, env);
const Value result = eval(firstToken, lastToken, source);
return result;
}

View File

@@ -66,9 +66,11 @@ inline static bool comment_p (const char *__first, const char *__last)
return (*__first == '/' || *__first == '*');
}
MacroExpander::MacroExpander(Environment *env, pp_frame *frame)
MacroExpander::MacroExpander(Environment *env, pp_frame *frame, Client *client, unsigned start_offset)
: env(env),
frame(frame),
client(client),
start_offset(start_offset),
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,
QByteArray *__result)
{
const char *start = __first;
__first = skip_blanks (__first, __last);
lines = skip_blanks.lines;
@@ -284,6 +287,9 @@ const char *MacroExpander::expand(const char *__first, const char *__last,
if (! macro->definition().isEmpty())
{
if (client)
client->startExpandingMacro(start_offset + (name_begin-start), *macro, fast_name, true);
macro->setHidden(true);
QByteArray __tmp;
@@ -310,6 +316,9 @@ const char *MacroExpander::expand(const char *__first, const char *__last,
}
macro->setHidden(false);
if (client)
client->stopExpandingMacro(start_offset + (name_begin-start), *macro);
}
if (! m)
@@ -330,6 +339,7 @@ const char *MacroExpander::expand(const char *__first, const char *__last,
}
QVector<QByteArray> actuals;
QVector<MacroArgumentReference> actuals_ref;
actuals.reserve (5);
++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);
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);
QByteArray 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_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);
QByteArray 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 ')'
__first = arg_it;
if (client)
client->startExpandingMacro(start_offset + (name_begin-start), *macro, fast_name, true, actuals_ref);
pp_frame frame (macro, actuals);
MacroExpander expand_macro (env, &frame);
macro->setHidden(true);
expand_macro (macro->definition(), __result);
macro->setHidden(false);
if (client)
client->stopExpandingMacro(start_offset + (name_begin-start), *macro);
}
else
__result->append(*__first++);

View File

@@ -56,6 +56,7 @@
namespace CPlusPlus {
class Environment;
class Client;
struct pp_frame;
@@ -63,6 +64,8 @@ class MacroExpander
{
Environment *env;
pp_frame *frame;
Client *client;
unsigned start_offset;
pp_skip_number skip_number;
pp_skip_identifier skip_identifier;
@@ -76,7 +79,7 @@ class MacroExpander
const QByteArray *resolve_formal(const QByteArray &name);
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,
QByteArray *result);

View File

@@ -205,17 +205,17 @@ public slots:
bool closeAllEditors(bool askAboutModifiedEditors = true);
void openInExternalEditor();
private slots:
bool saveFile(Core::IEditor *editor = 0);
bool saveFileAs(Core::IEditor *editor = 0);
void revertToSaved();
void closeEditor();
void closeOtherEditors();
private slots:
void gotoNextDocHistory();
void gotoPreviousDocHistory();
void handleContextChange(Core::IContext *context);
void updateActions();
void revertToSaved();
void makeCurrentEditorWritable();
public slots:

View File

@@ -857,22 +857,9 @@ void CPPEditor::findReferences()
lastVisibleSymbol,
TypeOfExpression::Preprocess);
if (! results.isEmpty()) {
TypeOfExpression::Result result = results.first();
Symbol *symbol = result.second;
qDebug() << "result:" << symbol->fileName() << symbol->line() << symbol->column();
m_modelManager->findReferences(symbol);
if (Symbol *canonicalSymbol = LookupContext::canonicalSymbol(results)) {
m_modelManager->findReferences(canonicalSymbol);
}
#if 0
LookupContext context(
Overview oo;
qDebug() << "==============> filename:" << symbol->fileName()
<< "name:" << oo(symbol->name());
m_modelManager->findReferences(symbol);
}
#endif
}
void CPPEditor::renameSymbolUnderCursor()
@@ -1345,6 +1332,39 @@ bool CPPEditor::isElectricCharacter(const QChar &ch) const
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
{
const bool checkBlockEnd = m_allowSkippingOfBlockEnd;
@@ -1356,6 +1376,33 @@ QString CPPEditor::autoComplete(QTextCursor &cursor, const QString &textToInsert
QString text = textToInsert;
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;
int skippedChars = 0;
const QString autoText = matchingText.insertMatchingBrace(cursor, text, lookAhead, &skippedChars);
@@ -1392,6 +1439,32 @@ bool CPPEditor::autoBackspace(QTextCursor &cursor)
QChar lookAhead = characterAt(pos);
QChar lookBehind = characterAt(pos-1);
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(')'))
|| (lookBehind == QLatin1Char('[') && lookAhead == QLatin1Char(']'))
|| (lookBehind == QLatin1Char('"') && lookAhead == QLatin1Char('"')

View File

@@ -52,12 +52,13 @@ void CppHighlighter::highlightBlock(const QString &text)
QTextCharFormat emptyFormat;
const int previousState = previousBlockState();
int state = 0, braceDepth = 0;
int state = 0, initialBraceDepth = 0;
if (previousState != -1) {
state = previousState & 0xff;
braceDepth = previousState >> 8;
initialBraceDepth = previousState >> 8;
}
int braceDepth = initialBraceDepth;
SimpleLexer tokenize;
tokenize.setQtMocRunEnabled(false);
@@ -211,6 +212,10 @@ void CppHighlighter::highlightBlock(const QString &text)
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
// to have QSyntaxHighlighter stop the rehighlighting
@@ -222,12 +227,7 @@ void CppHighlighter::highlightBlock(const QString &text)
int delta = braceDepth - oldBraceDepth;
QTextBlock block = currentBlock().next();
while (block.isValid()) {
currentState = block.userState();
if (currentState != -1) {
oldState = currentState & 0xff;
oldBraceDepth = currentState >> 8;
block.setUserState(((oldBraceDepth + delta) << 8 ) | oldState);
}
TextEditDocumentLayout::changeBraceDepth(block, delta);
block = block.next();
}
}

View File

@@ -44,10 +44,13 @@
#include <Literals.h>
#include <TranslationUnit.h>
#include <Symbols.h>
#include <Names.h>
#include <Scope.h>
#include <cplusplus/CppDocument.h>
#include <cplusplus/ExpressionUnderCursor.h>
#include <cplusplus/ResolveExpression.h>
#include <cplusplus/Overview.h>
#include <QtCore/QTime>
#include <QtCore/QtConcurrentRun>
@@ -69,13 +72,16 @@ public:
_future(future),
_doc(doc),
_snapshot(snapshot),
_source(_doc->source())
{ }
void operator()(Identifier *id, AST *ast)
_source(_doc->source()),
_sem(doc->control())
{
_snapshot.insert(_doc);
}
void operator()(Symbol *symbol, Identifier *id, AST *ast)
{
_declSymbol = symbol;
_id = id;
_currentSymbol = _doc->globalNamespace();
_exprDoc = Document::create("<references>");
accept(ast);
}
@@ -122,55 +128,63 @@ protected:
line, lineText, col, len));
}
LookupContext currentContext() const
bool checkCandidates(const QList<Symbol *> &candidates) const
{
return LookupContext(_currentSymbol, _exprDoc, _doc, _snapshot);
}
virtual bool visit(ClassSpecifierAST *ast)
{
_currentSymbol = ast->symbol;
// ### FIXME return isDeclSymbol(LookupContext::canonicalSymbol(candidates));
return true;
}
virtual bool visit(NamespaceAST *ast)
bool isDeclSymbol(Symbol *symbol) const
{
_currentSymbol = ast->symbol;
return true;
if (! symbol)
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;
return true;
}
virtual bool visit(FunctionDefinitionAST *ast)
{
_currentSymbol = ast->symbol;
return true;
unsigned line, column;
getTokenStartPosition(ast->firstToken(), &line, &column);
Symbol *lastVisibleSymbol = _doc->findSymbolAt(line, column);
return LookupContext(lastVisibleSymbol, _exprDoc, _doc, _snapshot);
}
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)
{
Identifier *id = identifier(ast->identifier_token);
if (id == _id) {
#if 0
LookupContext context = currentContext();
ResolveExpression resolveExpression(context);
QList<ResolveExpression::Result> results = resolveExpression(ast);
if (! results.isEmpty()) {
ResolveExpression::Result result = results.first();
Symbol *resolvedSymbol = result.second;
qDebug() << "resolves to:" << resolvedSymbol->fileName() << resolvedSymbol->line();
}
#endif
reportResult(ast->identifier_token);
LookupContext context = currentContext(ast);
const QList<Symbol *> candidates = context.resolve(ast->name);
if (checkCandidates(candidates))
reportResult(ast->identifier_token);
}
return false;
@@ -179,20 +193,25 @@ protected:
virtual bool visit(TemplateIdAST *ast)
{
Identifier *id = identifier(ast->identifier_token);
if (id == _id)
reportResult(ast->identifier_token);
if (id == _id) {
LookupContext context = currentContext(ast);
const QList<Symbol *> candidates = context.resolve(ast->name);
if (checkCandidates(candidates))
reportResult(ast->identifier_token);
}
return true;
return false;
}
private:
QFutureInterface<Core::Utils::FileSearchResult> &_future;
Identifier *_id;
Identifier *_id; // ### remove me
Symbol *_declSymbol;
Document::Ptr _doc;
Snapshot _snapshot;
QByteArray _source;
Symbol *_currentSymbol;
Document::Ptr _exprDoc;
Semantic _sem;
};
} // end of anonymous namespace
@@ -217,6 +236,9 @@ static void find_helper(QFutureInterface<Core::Utils::FileSearchResult> &future,
QTime tm;
tm.start();
Identifier *symbolId = symbol->identifier();
Q_ASSERT(symbolId != 0);
const QString fileName = QString::fromUtf8(symbol->fileName(), symbol->fileNameLength());
QStringList files(fileName);
@@ -229,24 +251,30 @@ static void find_helper(QFutureInterface<Core::Utils::FileSearchResult> &future,
for (int i = 0; i < files.size(); ++i) {
const QString &fn = files.at(i);
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);
if (! f.open(QFile::ReadOnly))
continue;
const QString source = QTextStream(&f).readAll();
const QString source = QTextStream(&f).readAll(); // ### FIXME
const QByteArray preprocessedCode = snapshot.preprocessedCode(source, fn);
Document::Ptr doc = snapshot.documentFromSource(preprocessedCode, fn);
doc->tokenize();
Identifier *symbolId = symbol->identifier();
Q_ASSERT(symbolId != 0);
Control *control = doc->control();
if (Identifier *id = control->findIdentifier(symbolId->chars(), symbolId->size())) {
doc->check();
TranslationUnit *unit = doc->translationUnit();
Process process(future, doc, snapshot);
process(id, unit->ast());
process(symbol, id, unit->ast());
}
}
future.setProgressValue(files.size());
@@ -259,9 +287,7 @@ void CppFindReferences::findAll(const Snapshot &snapshot, Symbol *symbol)
Core::ProgressManager *progressManager = Core::ICore::instance()->progressManager();
QFuture<Core::Utils::FileSearchResult> result =
QtConcurrent::run(&find_helper, snapshot, symbol);
QFuture<Core::Utils::FileSearchResult> result = QtConcurrent::run(&find_helper, snapshot, symbol);
m_watcher.setFuture(result);
Core::FutureProgress *progress = progressManager->addTask(result, tr("Searching..."),

View File

@@ -196,9 +196,12 @@ protected:
void mergeEnvironment(CPlusPlus::Document::Ptr doc);
virtual void macroAdded(const Macro &macro);
virtual void passedMacroDefinitionCheck(unsigned offset, const Macro &macro);
virtual void failedMacroDefinitionCheck(unsigned offset, const QByteArray &name);
virtual void startExpandingMacro(unsigned offset,
const Macro &macro,
const QByteArray &originalText,
bool inCondition,
const QVector<MacroArgumentReference> &actuals);
virtual void stopExpandingMacro(unsigned offset, const Macro &macro);
virtual void startSkippingBlocks(unsigned offset);
@@ -446,16 +449,34 @@ void CppPreprocessor::macroAdded(const Macro &macro)
m_currentDoc->appendMacro(macro);
}
void CppPreprocessor::passedMacroDefinitionCheck(unsigned offset, const Macro &macro)
{
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,
const Macro &macro,
const QByteArray &originalText,
bool inCondition,
const QVector<MacroArgumentReference> &actuals)
{
if (! m_currentDoc)
return;
//qDebug() << "start expanding:" << macro.name << "text:" << originalText;
m_currentDoc->addMacroUse(macro, offset, originalText.length(), actuals);
//qDebug() << "start expanding:" << macro.name() << "text:" << originalText;
m_currentDoc->addMacroUse(macro, offset, originalText.length(), actuals, inCondition);
}
void CppPreprocessor::stopExpandingMacro(unsigned, const Macro &)

View File

@@ -36,11 +36,11 @@
#include <QtCore/QAbstractItemModel>
namespace Debugger {
class DebuggerManager;
namespace Internal {
class BreakpointMarker;
class BreakHandler;
class DebuggerManager;
//////////////////////////////////////////////////////////////////
//

View File

@@ -52,6 +52,7 @@
#include <utils/qtcassert.h>
#include <utils/winutils.h>
#include <utils/consoleprocess.h>
#include <utils/fancymainwindow.h>
#include <texteditor/itexteditor.h>
#include <QtCore/QDebug>
@@ -367,7 +368,7 @@ bool CdbDebugEnginePrivate::init(QString *errorMessage)
return true;
}
IDebuggerEngine *CdbDebugEngine::create(DebuggerManager *manager,
IDebuggerEngine *CdbDebugEngine::create(Debugger::DebuggerManager *manager,
const QSharedPointer<CdbOptions> &options,
QString *errorMessage)
{

View File

@@ -36,9 +36,10 @@
#include <QtCore/QSharedPointer>
namespace Debugger {
class DebuggerManager;
namespace Internal {
class DebuggerManager;
class DisassemblerViewAgent;
class CdbDebugEventCallback;
class CdbDebugOutput;

View File

@@ -42,9 +42,10 @@
#include <QtCore/QMap>
namespace Debugger {
class DebuggerManager;
namespace Internal {
class DebuggerManager;
class WatchHandler;
class CdbStackFrameContext;
class CdbStackTraceContext;

View File

@@ -35,8 +35,10 @@
#include <QtCore/QStringList>
namespace Debugger {
namespace Internal {
class DebuggerManager;
namespace Internal {
class CdbDebugEngine;
// Base class for event callbacks that takes care

View File

@@ -37,11 +37,11 @@
#include <QtCore/QMap>
namespace Debugger {
namespace Internal {
struct CdbComInterfaces;
class DebuggerManager;
namespace Internal {
struct CdbComInterfaces;
/* For code clarity, all the stuff related to custom dumpers goes here.
* "Custom dumper" is a library compiled against the current
* Qt containing functions to evaluate values of Qt classes

View File

@@ -4,14 +4,12 @@ TARGET = Debugger
# DEFINES += QT_USE_FAST_OPERATOR_PLUS
# DEFINES += QT_USE_FAST_CONCATENATION
# CONFIG += single
include(../../qtcreatorplugin.pri)
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)
include(debugger_dependencies.pri)
DEFINES += DEBUGGER_LIBRARY
INCLUDEPATH += $$PWD/../../libs/utils
QT += gui \
network \
@@ -23,10 +21,12 @@ HEADERS += breakhandler.h \
debuggerconstants.h \
debuggerdialogs.h \
debuggermanager.h \
debugger_global.h \
debuggeroutputwindow.h \
debuggerplugin.h \
debuggerrunner.h \
debuggertooltip.h \
debuggerstringutils.h \
watchutils.h \
idebuggerengine.h \
imports.h \

View 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)

View 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

View File

@@ -127,6 +127,22 @@ Core::Utils::SavedAction *theDebuggerAction(int code);
bool theDebuggerBoolSetting(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 Debugger

View File

@@ -28,6 +28,7 @@
**************************************************************************/
#include "debuggeragents.h"
#include "debuggerstringutils.h"
#include "idebuggerengine.h"
#include <coreplugin/coreconstants.h>
@@ -193,6 +194,7 @@ DisassemblerViewAgent::~DisassemblerViewAgent()
if (d->editor)
d->editor->deleteLater();
delete d;
d = 0;
}
void DisassemblerViewAgent::setFrame(const StackFrame &frame)
@@ -206,12 +208,10 @@ void DisassemblerViewAgent::setFrame(const StackFrame &frame)
void DisassemblerViewAgent::setContents(const QString &contents)
{
QTC_ASSERT(d, return);
using namespace Core;
using namespace TextEditor;
if (!d->editor)
return;
QPlainTextEdit *plainTextEdit = 0;
EditorManager *editorManager = EditorManager::instance();
if (!d->editor) {

View File

@@ -42,9 +42,9 @@
namespace Debugger {
class DebuggerManager;
namespace Internal {
class DebuggerManager;
struct DisassemblerViewAgentPrivate;
class MemoryViewAgent : public QObject

View File

@@ -60,8 +60,6 @@ namespace Internal {
}
} // namespace Constants
namespace Internal {
enum DebuggerState
{
DebuggerNotReady, // Debugger not started
@@ -118,7 +116,6 @@ enum LogChannel
LogMisc
};
} // namespace Internal
} // namespace Debugger
#endif // DEBUGGERCONSTANTS_H

File diff suppressed because it is too large Load Diff

View File

@@ -30,31 +30,29 @@
#ifndef DEBUGGER_DEBUGGERMANAGER_H
#define DEBUGGER_DEBUGGERMANAGER_H
#include "debugger_global.h"
#include "debuggerconstants.h"
#include <utils/fancymainwindow.h>
#include <QtCore/QByteArray>
#include <QtCore/QObject>
#include <QtCore/QSharedPointer>
#include <QtCore/QStringList>
#include <QtCore/QVariant>
#include <QtCore/QSharedPointer>
QT_BEGIN_NAMESPACE
class QAction;
class QAbstractItemModel;
class QDockWidget;
class QLabel;
class QMessageBox;
class QModelIndex;
class QPoint;
class QTimer;
class QWidget;
class QDebug;
class QAbstractItemModel;
class QPoint;
class QVariant;
QT_END_NAMESPACE
namespace Core {
class IOptionsPage;
namespace Utils {
class FancyMainWindow;
}
} // namespace Core
namespace TextEditor {
@@ -64,15 +62,8 @@ class ITextEditor;
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()); }
class DebuggerOutputWindow;
class DebuggerRunControl;
class DebuggerPlugin;
class DebugMode;
class BreakHandler;
class BreakpointData;
@@ -85,8 +76,23 @@ class Symbol;
class ThreadsHandler;
class WatchData;
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:
DebuggerStartParameters();
@@ -113,13 +119,8 @@ public:
};
typedef QSharedPointer<DebuggerStartParameters> DebuggerStartParametersPtr;
QDebug operator<<(QDebug str, const DebuggerStartParameters &);
class IDebuggerEngine;
class GdbEngine;
class ScriptEngine;
class CdbDebugEngine;
struct CdbDebugEnginePrivate;
DEBUGGER_EXPORT QDebug operator<<(QDebug str, const DebuggerStartParameters &);
// Flags for initialization
enum DebuggerEngineTypeFlags
@@ -140,7 +141,9 @@ QDebug operator<<(QDebug d, DebuggerState state);
// DebuggerManager
//
class DebuggerManager : public QObject
struct DebuggerManagerPrivate;
class DEBUGGER_EXPORT DebuggerManager : public QObject
{
Q_OBJECT
@@ -148,26 +151,30 @@ public:
DebuggerManager();
~DebuggerManager();
friend class CdbDebugEngine;
friend class CdbDebugEventCallback;
friend class CdbDumperHelper;
friend class CdbExceptionLoggerEventCallback;
friend class GdbEngine;
friend class ScriptEngine;
friend class TcfEngine;
friend struct CdbDebugEnginePrivate;
friend class Internal::IDebuggerEngine;
friend class Internal::DebuggerPlugin;
friend class Internal::CdbDebugEventCallback;
friend class Internal::CdbDumperHelper;
friend class Internal::CdbExceptionLoggerEventCallback;
friend class Internal::GdbEngine;
friend class Internal::ScriptEngine;
friend class Internal::TcfEngine;
friend class Internal::CdbDebugEngine;
friend struct Internal::CdbDebugEnginePrivate;
QList<Core::IOptionsPage*> initializeEngines(unsigned enabledTypeFlags);
Core::Utils::FancyMainWindow *mainWindow() const { return m_mainWindow; }
QLabel *statusLabel() const { return m_statusLabel; }
IDebuggerEngine *currentEngine() const { return m_engine; }
Core::Utils::FancyMainWindow *mainWindow() const;
QLabel *statusLabel() const;
Internal::IDebuggerEngine *currentEngine() const;
virtual DebuggerStartParametersPtr startParameters() const;
virtual qint64 inferiorPid() const;
DebuggerStartParametersPtr startParameters() const;
qint64 inferiorPid() const;
void showMessageBox(int icon, const QString &title, const QString &text);
static DebuggerManager *instance();
public slots:
void startNewDebugger(const DebuggerStartParametersPtr &sp);
void exitDebugger();
@@ -177,7 +184,7 @@ public slots:
void setBusyCursor(bool on);
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 resetLocation();
@@ -200,7 +207,7 @@ public slots:
void detachDebugger();
void addToWatchWindow();
void updateWatchData(const WatchData &data);
void updateWatchData(const Debugger::Internal::WatchData &data);
void sessionLoaded();
void aboutToUnloadSession();
@@ -243,14 +250,15 @@ private slots:
void startFailed();
private:
ModulesHandler *modulesHandler() { return m_modulesHandler; }
BreakHandler *breakHandler() { return m_breakHandler; }
RegisterHandler *registerHandler() { return m_registerHandler; }
StackHandler *stackHandler() { return m_stackHandler; }
ThreadsHandler *threadsHandler() { return m_threadsHandler; }
WatchHandler *watchHandler() { return m_watchHandler; }
SourceFilesWindow *sourceFileWindow() { return m_sourceFilesWindow; }
QWidget *threadsWindow() const { return m_threadsWindow; }
Internal::ModulesHandler *modulesHandler() const;
Internal::BreakHandler *breakHandler() const;
Internal::RegisterHandler *registerHandler() const;
Internal::StackHandler *stackHandler() const;
Internal::ThreadsHandler *threadsHandler() const;
Internal::WatchHandler *watchHandler() const;
Internal::SourceFilesWindow *sourceFileWindow() const;
QWidget *threadsWindow() const;
Internal::DebuggerManagerActions debuggerManagerActions() const;
void notifyInferiorStopped();
void notifyInferiorRunning();
@@ -261,7 +269,6 @@ private:
DebuggerState state() const;
void setState(DebuggerState state);
DebuggerState m_state;
//
// internal implementation
@@ -280,8 +287,7 @@ private:
public:
// stuff in this block should be made private by moving it to
// one of the interfaces
int status() const { return m_status; }
QList<Symbol> moduleSymbols(const QString &moduleName);
QList<Internal::Symbol> moduleSymbols(const QString &moduleName);
signals:
void debuggingFinished();
@@ -290,7 +296,7 @@ signals:
void debugModeRequested();
void previousModeRequested();
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 currentTextEditorRequested(QString *fileName, int *lineNumber, QObject **ob);
void sessionValueRequested(const QString &name, QVariant *value);
@@ -308,71 +314,13 @@ private:
void toggleBreakpoint(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,
TextEditor::ITextEditor *editor, int cursorPos);
// FIXME: Remove engine-specific state
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;
DebuggerManagerPrivate *d;
};
} // namespace Internal
} // namespace Debugger
#endif // DEBUGGER_DEBUGGERMANAGER_H

View File

@@ -55,6 +55,7 @@ using namespace Find;
#endif // GDBDEBUGGERLEAN
using namespace Debugger;
using namespace Debugger::Internal;
static QChar charForChannel(int channel)

View File

@@ -37,6 +37,7 @@
#include "debuggermanager.h"
#include "debuggerrunner.h"
#include "stackframe.h"
#include "debuggerstringutils.h"
#include "ui_commonoptionspage.h"
#include "ui_dumperoptionpage.h"
@@ -619,7 +620,8 @@ bool DebuggerPlugin::initialize(const QStringList &arguments, QString *errorMess
am->actionContainer(ProjectExplorer::Constants::M_DEBUG_STARTDEBUGGING);
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);
mstart->addAction(cmd, Core::Constants::G_DEFAULT_ONE);
@@ -648,7 +650,7 @@ bool DebuggerPlugin::initialize(const QStringList &arguments, QString *errorMess
Constants::DETACH, globalcontext);
mdebug->addAction(cmd, Core::Constants::G_DEFAULT_ONE);
cmd = am->registerAction(m_manager->m_stopAction,
cmd = am->registerAction(actions.stopAction,
Constants::INTERRUPT, globalcontext);
cmd->setAttribute(Core::Command::CA_UpdateText);
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"));
mdebug->addAction(cmd, Core::Constants::G_DEFAULT_ONE);
cmd = am->registerAction(m_manager->m_resetAction,
cmd = am->registerAction(actions.resetAction,
Constants::RESET, globalcontext);
cmd->setAttribute(Core::Command::CA_UpdateText);
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);
mdebug->addAction(cmd);
cmd = am->registerAction(m_manager->m_nextAction,
cmd = am->registerAction(actions.nextAction,
Constants::NEXT, debuggercontext);
cmd->setDefaultKeySequence(QKeySequence(Constants::NEXT_KEY));
mdebug->addAction(cmd);
cmd = am->registerAction(m_manager->m_stepAction,
cmd = am->registerAction(actions.stepAction,
Constants::STEP, debuggercontext);
cmd->setDefaultKeySequence(QKeySequence(Constants::STEP_KEY));
mdebug->addAction(cmd);
cmd = am->registerAction(m_manager->m_stepOutAction,
cmd = am->registerAction(actions.stepOutAction,
Constants::STEPOUT, debuggercontext);
cmd->setDefaultKeySequence(QKeySequence(Constants::STEPOUT_KEY));
mdebug->addAction(cmd);
@@ -687,22 +689,22 @@ bool DebuggerPlugin::initialize(const QStringList &arguments, QString *errorMess
Constants::STEP_BY_INSTRUCTION, debuggercontext);
mdebug->addAction(cmd);
cmd = am->registerAction(m_manager->m_runToLineAction,
cmd = am->registerAction(actions.runToLineAction,
Constants::RUN_TO_LINE, debuggercontext);
cmd->setDefaultKeySequence(QKeySequence(Constants::RUN_TO_LINE_KEY));
mdebug->addAction(cmd);
cmd = am->registerAction(m_manager->m_runToFunctionAction,
cmd = am->registerAction(actions.runToFunctionAction,
Constants::RUN_TO_FUNCTION, debuggercontext);
cmd->setDefaultKeySequence(QKeySequence(Constants::RUN_TO_FUNCTION_KEY));
mdebug->addAction(cmd);
cmd = am->registerAction(m_manager->m_jumpToLineAction,
cmd = am->registerAction(actions.jumpToLineAction,
Constants::JUMP_TO_LINE, debuggercontext);
mdebug->addAction(cmd);
#ifdef USE_REVERSE_DEBUGGING
cmd = am->registerAction(m_manager->m_reverseDirectionAction,
cmd = am->registerAction(actions.reverseDirectionAction,
Constants::REVERSE, debuggercontext);
cmd->setDefaultKeySequence(QKeySequence(Constants::REVERSE_KEY));
mdebug->addAction(cmd);
@@ -713,7 +715,7 @@ bool DebuggerPlugin::initialize(const QStringList &arguments, QString *errorMess
cmd = am->registerAction(sep, QLatin1String("Debugger.Sep.Break"), globalcontext);
mdebug->addAction(cmd);
cmd = am->registerAction(m_manager->m_breakAction,
cmd = am->registerAction(actions.breakAction,
Constants::TOGGLE_BREAK, cppeditorcontext);
cmd->setDefaultKeySequence(QKeySequence(Constants::TOGGLE_BREAK_KEY));
mdebug->addAction(cmd);
@@ -724,7 +726,7 @@ bool DebuggerPlugin::initialize(const QStringList &arguments, QString *errorMess
cmd = am->registerAction(sep, QLatin1String("Debugger.Sep.Watch"), globalcontext);
mdebug->addAction(cmd);
cmd = am->registerAction(m_manager->m_watchAction,
cmd = am->registerAction(actions.watchAction,
Constants::ADD_TO_WATCH, cppeditorcontext);
//cmd->setDefaultKeySequence(QKeySequence(tr("ALT+D,ALT+W")));
mdebug->addAction(cmd);
@@ -885,8 +887,8 @@ bool DebuggerPlugin::initialize(const QStringList &arguments, QString *errorMess
connect(m_manager, SIGNAL(resetLocationRequested()),
this, SLOT(resetLocation()));
connect(m_manager, SIGNAL(gotoLocationRequested(StackFrame,bool)),
this, SLOT(gotoLocation(StackFrame,bool)));
connect(m_manager, SIGNAL(gotoLocationRequested(Debugger::Internal::StackFrame,bool)),
this, SLOT(gotoLocation(Debugger::Internal::StackFrame,bool)));
connect(m_manager, SIGNAL(stateChanged(int)),
this, SLOT(handleStateChanged(int)));
connect(m_manager, SIGNAL(previousModeRequested()),
@@ -1088,7 +1090,7 @@ void DebuggerPlugin::resetLocation()
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 (!m_disassemblerViewAgent)

View File

@@ -55,10 +55,11 @@ class BaseTextMark;
}
namespace Debugger {
class DebuggerManager;
namespace Internal {
class BreakpointData;
class DebuggerManager;
class DebuggerRunControlFactory;
class DebugMode;
class DisassemblerViewAgent;
@@ -96,7 +97,7 @@ private slots:
int lineNumber, QMenu *menu);
void resetLocation();
void gotoLocation(const StackFrame &frame, bool setMarker);
void gotoLocation(const Debugger::Internal::StackFrame &frame, bool setMarker);
void breakpointSetRemoveMarginActionTriggered();
void breakpointEnableDisableMarginActionTriggered();
@@ -119,10 +120,10 @@ private:
QString *errorMessage);
void attachExternalApplication(qint64 pid, const QString &crashParameter = QString());
friend class DebuggerManager;
friend class Debugger::DebuggerManager;
friend class GdbOptionPage;
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;
DebugMode *m_debugMode;

View File

@@ -40,9 +40,9 @@ class LocalApplicationRunConfiguration;
}
namespace Debugger {
namespace Internal {
class DebuggerManager;
namespace Internal {
class StartData;
typedef QSharedPointer<ProjectExplorer::RunConfiguration>

View 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

View File

@@ -32,6 +32,7 @@
#include "debuggeractions.h"
#include "gdbengine.h"
#include "procinterrupt.h"
#include "debuggerstringutils.h"
#include <utils/qtcassert.h>

View File

@@ -31,6 +31,7 @@
#include "debuggeractions.h"
#include "gdbengine.h"
#include "debuggerstringutils.h"
#include <utils/qtcassert.h>

View File

@@ -46,6 +46,7 @@
#include "debuggerconstants.h"
#include "debuggermanager.h"
#include "debuggertooltip.h"
#include "debuggerstringutils.h"
#include "gdbmi.h"
#include "breakhandler.h"
@@ -58,6 +59,7 @@
#include "debuggerdialogs.h"
#include <utils/qtcassert.h>
#include <utils/fancymainwindow.h>
#include <texteditor/itexteditor.h>
#include <coreplugin/icore.h>
@@ -224,6 +226,11 @@ DebuggerStartMode GdbEngine::startMode() const
return m_startParameters->startMode;
}
QMainWindow *GdbEngine::mainWindow() const
{
return m_manager->mainWindow();
}
GdbEngine::~GdbEngine()
{
// 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.
debugMessage(_("COOKIE FOR TOKEN %1 ALREADY EATEN. "
"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) {
QByteArray msg = response.data.findChild("msg").data();
showMessageBox(QMessageBox::Critical,
tr("Executable failed"), QString::fromLocal8Bit(msg));
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;
}
@@ -1303,6 +1317,11 @@ void GdbEngine::handleStop2(const GdbResponse &response)
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);
showStatusMessage(tr("Stopped."), 5000);
@@ -3808,7 +3827,7 @@ struct MemoryAgentCookie
MemoryAgentCookie(MemoryViewAgent *agent_, quint64 address_)
: agent(agent_), address(address_)
{}
MemoryViewAgent *agent;
QPointer<MemoryViewAgent> agent;
quint64 address;
};
@@ -3851,7 +3870,7 @@ struct DisassemblerAgentCookie
DisassemblerAgentCookie(DisassemblerViewAgent *agent_)
: agent(agent_)
{}
DisassemblerViewAgent *agent;
QPointer<DisassemblerViewAgent> agent;
};
void GdbEngine::fetchDisassembler(DisassemblerViewAgent *agent,

View File

@@ -51,14 +51,14 @@ QT_BEGIN_NAMESPACE
class QAction;
class QAbstractItemModel;
class QWidget;
class QMainWindow;
QT_END_NAMESPACE
namespace Debugger {
class DebuggerManager;
namespace Internal {
class AbstractGdbAdapter;
class DebuggerManager;
class IDebuggerManagerAccessForEngines;
class GdbResponse;
class GdbMi;
@@ -271,7 +271,7 @@ private:
bool showToolTip();
// Convenience
QMainWindow *mainWindow() const { return m_manager->mainWindow(); }
QMainWindow *mainWindow() const;
DebuggerStartMode startMode() const;
qint64 inferiorPid() const { return m_manager->inferiorPid(); }

View File

@@ -32,11 +32,14 @@
#include "debuggeractions.h"
#include "gdbengine.h"
#include "procinterrupt.h"
#include "debuggerstringutils.h"
#include <utils/qtcassert.h>
#include <utils/fancymainwindow.h>
#include <coreplugin/icore.h>
#include <QtCore/QFileInfo>
#include <QtCore/QVariant>
#include <QtGui/QMessageBox>
namespace Debugger {

View File

@@ -28,11 +28,12 @@
**************************************************************************/
#include "remotegdbadapter.h"
#include "debuggerstringutils.h"
#include "debuggeractions.h"
#include "gdbengine.h"
#include <utils/qtcassert.h>
#include <utils/fancymainwindow.h>
#include <QtCore/QFileInfo>
#include <QtGui/QMessageBox>

View File

@@ -29,6 +29,7 @@
#include "trkgdbadapter.h"
#include "trkoptions.h"
#include "debuggerstringutils.h"
#ifndef STANDALONE_RUNNER
#include "gdbengine.h"
#endif
@@ -199,7 +200,7 @@ QByteArray TrkGdbAdapter::trkContinueMessage()
return ba;
}
QByteArray TrkGdbAdapter::trkReadRegisterMessage()
QByteArray TrkGdbAdapter::trkReadRegistersMessage()
{
QByteArray ba;
appendByte(&ba, 0); // Register set, only 0 supported
@@ -210,6 +211,18 @@ QByteArray TrkGdbAdapter::trkReadRegisterMessage()
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 ba;
@@ -574,6 +587,7 @@ void TrkGdbAdapter::handleGdbServerCommand(const QByteArray &cmd)
sendGdbServerMessage("E20", "Error " + cmd);
}
}
else if (cmd.startsWith("p")) {
logMessage(msgGdbPacket(QLatin1String("read register")));
// 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") {
//$qAttached#8f
// 1: attached to an existing process
@@ -861,7 +890,7 @@ void TrkGdbAdapter::handleTrkResult(const TrkResult &result)
//sendGdbServerMessage("S05", "Target stopped");
sendTrkMessage(0x12,
TrkCB(handleAndReportReadRegistersAfterStop),
trkReadRegisterMessage());
trkReadRegistersMessage());
break;
}
case 0x91: { // Notify Exception (obsolete)
@@ -1020,6 +1049,17 @@ void TrkGdbAdapter::handleReadRegisters(const TrkResult &result)
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()
{
QByteArray ba;

View File

@@ -156,7 +156,8 @@ public:
void reportRegisters();
QByteArray memoryReadLogMessage(uint addr, uint len, const QByteArray &ba) const;
QByteArray trkContinueMessage();
QByteArray trkReadRegisterMessage();
QByteArray trkReadRegistersMessage();
QByteArray trkWriteRegisterMessage(byte reg, uint value);
QByteArray trkReadMemoryMessage(uint addr, uint len);
QByteArray trkBreakpointMessage(uint addr, uint len, bool armMode = true);
QByteArray trkStepRangeMessage(byte option);
@@ -169,6 +170,7 @@ public:
void handleStepOver2(const TrkResult &result);
void handleReadRegisters(const TrkResult &result);
void reportReadMemoryBuffered(const TrkResult &result);
void handleWriteRegister(const TrkResult &result);
void reportToGdb(const TrkResult &result);
void readMemory(uint addr, uint len);

View File

@@ -50,22 +50,23 @@ class IOptionsPage;
}
namespace Debugger {
class DebuggerManager;
class DebuggerStartParameters;
namespace Internal {
class DebuggerStartParameters;
class DebuggerManager;
class DisassemblerViewAgent;
class MemoryViewAgent;
struct StackFrame;
class Symbol;
class WatchData;
typedef QSharedPointer<DebuggerStartParameters> DebuggerStartParametersPtr;
class IDebuggerEngine : public QObject
{
Q_OBJECT
public:
typedef QSharedPointer<DebuggerStartParameters> DebuggerStartParametersPtr;
IDebuggerEngine(DebuggerManager *manager, QObject *parent = 0)
: QObject(parent), m_manager(manager)
{}

View File

@@ -33,10 +33,10 @@
#include <QTreeView>
namespace Debugger {
namespace Internal {
class DebuggerManager;
namespace Internal {
class ModulesWindow : public QTreeView
{
Q_OBJECT

View File

@@ -30,13 +30,12 @@
#ifndef DEBUGGER_REGISTERWINDOW_H
#define DEBUGGER_REGISTERWINDOW_H
#include <QTreeView>
#include <QtGui/QTreeView>
namespace Debugger {
namespace Internal {
class DebuggerManager;
namespace Internal {
class RegisterWindow : public QTreeView
{
Q_OBJECT

View File

@@ -39,9 +39,9 @@ class QModelIndex;
QT_END_NAMESPACE
namespace Debugger {
namespace Internal {
class DebuggerManager;
namespace Internal {
class DisassemblerViewAgent;
class StackWindow : public QTreeView

View File

@@ -29,6 +29,7 @@
#include "tcfengine.h"
#include "debuggerstringutils.h"
#include "debuggerdialogs.h"
#include "breakhandler.h"
#include "debuggerconstants.h"

View File

@@ -262,7 +262,7 @@ public:
static QString watcherEditPlaceHolder();
signals:
void watchDataUpdateNeeded(const WatchData &data);
void watchDataUpdateNeeded(const Debugger::Internal::WatchData &data);
void sessionValueRequested(const QString &name, QVariant *value);
void setSessionValueRequested(const QString &name, const QVariant &value);

View File

@@ -33,6 +33,7 @@
#include "debuggeractions.h"
#include "debuggeragents.h"
#include "debuggerdialogs.h"
#include "debuggermanager.h"
#include <utils/qtcassert.h>
@@ -50,6 +51,7 @@
#include <QtGui/QMenu>
#include <QtGui/QResizeEvent>
using namespace Debugger;
using namespace Debugger::Internal;
/////////////////////////////////////////////////////////////////////

View File

@@ -33,6 +33,8 @@
#include <QtGui/QTreeView>
namespace Debugger {
class DebuggerManager;
namespace Internal {
/////////////////////////////////////////////////////////////////////
@@ -41,8 +43,6 @@ namespace Internal {
//
/////////////////////////////////////////////////////////////////////
class DebuggerManager;
class WatchWindow : public QTreeView
{
Q_OBJECT

View File

@@ -129,7 +129,6 @@ GitPlugin::GitPlugin() :
m_showAction(0),
m_stageAction(0),
m_unstageAction(0),
m_revertAction(0),
m_commitAction(0),
m_pullAction(0),
m_pushAction(0),
@@ -298,12 +297,6 @@ bool GitPlugin::initialize(const QStringList &arguments, QString *errorMessage)
connect(m_unstageAction, SIGNAL(triggered()), this, SLOT(unstageFile()));
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));
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_stageAction->setParameter(fileName);
m_unstageAction->setParameter(fileName);
m_revertAction->setParameter(fileName);
bool enabled = !fileName.isEmpty() && !repository.isEmpty();
m_diffAction->setEnabled(enabled);
@@ -766,7 +758,6 @@ void GitPlugin::updateActions()
m_undoFileAction->setEnabled(enabled);
m_stageAction->setEnabled(enabled);
m_unstageAction->setEnabled(enabled);
m_revertAction->setEnabled(enabled);
if (repository.isEmpty()) {
// If the file is not in a repository, the corresponding project will

View File

@@ -145,7 +145,6 @@ private:
QAction *m_showAction;
Core::Utils::ParameterAction *m_stageAction;
Core::Utils::ParameterAction *m_unstageAction;
Core::Utils::ParameterAction *m_revertAction;
QAction *m_commitAction;
QAction *m_pullAction;
QAction *m_pushAction;

View File

@@ -122,9 +122,5 @@ void ProFileReader::errorMessage(const QString &message)
ProFile *ProFileReader::proFileFor(const QString &name)
{
QMap<QString, ProFile *>::const_iterator it = m_includeFiles.constFind(name);
if (it == m_includeFiles.constEnd())
return 0;
else
return it.value();
return m_includeFiles.value(name);
}

View File

@@ -644,6 +644,7 @@ void S60DeviceRunControl::signsisProcessFinished()
connect(m_launcher, SIGNAL(installingStarted()), this, SLOT(printInstallingNotice()));
connect(m_launcher, SIGNAL(startingApplication()), this, SLOT(printStartingNotice()));
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(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));
}
void S60DeviceRunControl::printRunFailNotice(const QString &errorMessage) {
emit addToOutputWindow(this, tr("Could not start application: %1").arg(errorMessage));
}
void S60DeviceRunControl::printApplicationOutput(const QString &output)
{
emit addToOutputWindowInline(this, output);

View File

@@ -164,6 +164,7 @@ private slots:
void printInstallingNotice();
void printStartingNotice();
void printRunNotice(uint pid);
void printRunFailNotice(const QString &errorMessage);
void printApplicationOutput(const QString &output);
void runFinished();

View File

@@ -1528,6 +1528,18 @@ int TextBlockUserData::collapseAtPos() const
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)
{
@@ -1553,6 +1565,35 @@ bool TextEditDocumentLayout::hasParentheses(const QTextBlock &block)
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)
{
@@ -2683,6 +2724,11 @@ void BaseTextEditor::updateCurrentLineHighlight()
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) {
Core::EditorManager::instance()->addCurrentPositionToNavigationHistory(editableInterface(), d->m_tempNavigationState);
d->m_lastCursorChangeWasInteresting = false;
@@ -4026,21 +4072,36 @@ void BaseTextEditor::setIfdefedOutBlocks(const QList<BaseTextEditor::BlockRange>
QTextBlock block = doc->firstBlock();
int rangeNumber = 0;
int braceDepthDelta = 0;
while (block.isValid()) {
bool cleared = false;
bool set = false;
if (rangeNumber < blocks.size()) {
const BlockRange &range = blocks.at(rangeNumber);
if (block.position() >= range.first && (block.position() <= range.last || !range.last)) {
needUpdate |= TextEditDocumentLayout::setIfdefedOut(block);
set = TextEditDocumentLayout::setIfdefedOut(block);
} else {
needUpdate |= TextEditDocumentLayout::clearIfdefedOut(block);
cleared = TextEditDocumentLayout::clearIfdefedOut(block);
}
if (block.contains(range.last))
++rangeNumber;
} 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();
}

View File

@@ -128,6 +128,7 @@ public:
inline void clearParentheses() { m_parentheses.clear(); }
inline const Parentheses &parentheses() const { return m_parentheses; }
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 clearIfdefedOut() { bool result = m_ifdefedOut; m_ifdefedOut = false; return result;}
@@ -215,6 +216,10 @@ public:
static bool setIfdefedOut(const QTextBlock &block);
static bool clearIfdefedOut(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) {
return static_cast<TextBlockUserData*>(block.userData());

View File

@@ -316,6 +316,7 @@ bool CheckDeclaration::visit(FunctionDefinitionAST *ast)
translationUnit()->error(ast->ctor_initializer->firstToken(),
"only constructors take base initializers");
}
accept(ast->ctor_initializer);
}
const int previousVisibility = semantic()->switchVisibility(Symbol::Public);

View File

@@ -168,6 +168,9 @@ bool CheckDeclarator::visit(FunctionDeclaratorAST *ast)
ast->symbol = fun;
fun->setReturnType(_fullySpecifiedType);
if (_fullySpecifiedType.isVirtual())
fun->setVirtual(true);
if (ast->parameters) {
DeclarationListAST *parameter_declarations = ast->parameters->parameter_declarations;
for (DeclarationListAST *decl = parameter_declarations; decl; decl = decl->next) {

View File

@@ -259,6 +259,12 @@ bool Function::hasArguments() const
(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
{ return f._isVariadic; }

View File

@@ -307,6 +307,9 @@ public:
/** Convenience function that returns whether the function receives any arguments. */
bool hasArguments() const;
bool isVirtual() const;
void setVirtual(bool isVirtual);
bool isVariadic() const;
void setVariadic(bool isVariadic);
@@ -348,6 +351,7 @@ private:
TemplateParameters *_templateParameters;
FullySpecifiedType _returnType;
struct Flags {
unsigned _isVirtual: 1;
unsigned _isVariadic: 1;
unsigned _isPureVirtual: 1;
unsigned _isConst: 1;

View File

@@ -368,6 +368,11 @@ void Launcher::handleCpuType(const TrkResult &result)
void Launcher::handleCreateProcess(const TrkResult &result)
{
if (result.errorCode()) {
emit canNotRun(errorMessage(result.errorCode()));
emit finished();
return;
}
// 40 00 00]
//logMessage(" RESULT: " + result.toString());
// [80 08 00 00 00 01 B5 00 00 01 B6 78 67 40 00 00 40 00 00]

View File

@@ -60,6 +60,7 @@ signals:
void installingStarted();
void startingApplication();
void applicationRunning(uint pid);
void canNotRun(const QString &errorMessage);
void finished();
void applicationOutputReceived(const QString &output);
void copyProgress(int percent);
@@ -71,8 +72,6 @@ private slots:
void handleResult(const trk::TrkResult &data);
private:
void tryTrkRead();
// kill process and breakpoints
void cleanUp();
@@ -89,7 +88,6 @@ private:
void handleTrkVersion(const TrkResult &result);
void waitForTrkFinished(const TrkResult &data);
void handleAndReportCreateProcess(const TrkResult &result);
void copyFileToRemote();
void installRemotePackageSilently(const QString &filename);
void installAndRun();

View File

@@ -119,6 +119,7 @@ TrkMessage::TrkMessage(byte c, byte t, TrkCallback cb) :
} // namespace trk
Q_DECLARE_METATYPE(trk::TrkMessage)
Q_DECLARE_METATYPE(trk::TrkResult)
namespace trk {
@@ -408,7 +409,7 @@ static inline bool overlappedSyncWrite(HANDLE file, const char *data,
bool WriterThread::write(const QByteArray &data, QString *errorMessage)
{
QMutexLocker(&m_context->mutex);
QMutexLocker locker(&m_context->mutex);
#ifdef Q_OS_WIN
DWORD charsWritten;
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?
}
///////////////////////////////////////////////////////////////////////
//
// 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
///////////////////////////////////////////////////////////////////////
//
@@ -474,7 +534,7 @@ void WriterThread::slotHandleResult(const TrkResult &result)
//
///////////////////////////////////////////////////////////////////////
class WinReaderThread : public QThread {
class WinReaderThread : public ReaderThreadBase {
Q_OBJECT
Q_DISABLE_COPY(WinReaderThread)
public:
@@ -485,8 +545,6 @@ public:
signals:
void error(const QString &);
void dataReceived(char c);
void dataReceived(const QByteArray &data);
public slots:
void terminate();
@@ -496,12 +554,11 @@ private:
inline int tryRead();
const QSharedPointer<DeviceContext> m_context;
HANDLE m_handles[HandleCount];
};
WinReaderThread::WinReaderThread(const QSharedPointer<DeviceContext> &context) :
m_context(context)
ReaderThreadBase(context)
{
m_handles[FileHandle] = NULL;
m_handles[TerminateEventHandle] = CreateEvent(NULL, FALSE, FALSE, NULL);
@@ -528,9 +585,9 @@ int WinReaderThread::tryRead()
DWORD bytesRead = 0;
if (ReadFile(m_context->device, &buffer, bytesToRead, &bytesRead, &m_context->readOverlapped)) {
if (bytesRead == 1) {
emit dataReceived(buffer[0]);
processData(buffer[0]);
} else {
emit dataReceived(QByteArray(buffer, bytesRead));
processData(QByteArray(buffer, bytesRead));
}
return 0;
}
@@ -554,9 +611,9 @@ int WinReaderThread::tryRead()
return -3;
}
if (bytesRead == 1) {
emit dataReceived(buffer[0]);
processData(buffer[0]);
} else {
emit dataReceived(QByteArray(buffer, bytesRead));
processData(QByteArray(buffer, bytesRead));
}
return 0;
}
@@ -564,8 +621,7 @@ int WinReaderThread::tryRead()
void WinReaderThread::run()
{
m_handles[FileHandle] = m_context->readOverlapped.hEvent;
int readResult;
while ( (readResult = tryRead()) == 0) ;
while ( tryRead() == 0) ;
}
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)));
}
class UnixReaderThread : public QThread {
class UnixReaderThread : public ReaderThreadBase {
Q_OBJECT
Q_DISABLE_COPY(UnixReaderThread)
public:
@@ -604,7 +660,6 @@ public:
signals:
void error(const QString &);
void dataReceived(const QByteArray &);
public slots:
void terminate();
@@ -612,12 +667,11 @@ public slots:
private:
inline int tryRead();
const QSharedPointer<DeviceContext> m_context;
int m_terminatePipeFileDescriptors[2];
};
UnixReaderThread::UnixReaderThread(const QSharedPointer<DeviceContext> &context) :
m_context(context)
UnixReaderThread::UnixReaderThread(const QSharedPointer<DeviceContext> &context) :
ReaderThreadBase(context)
{
m_terminatePipeFileDescriptors[0] = m_terminatePipeFileDescriptors[1] = -1;
// Set up pipes for termination. Should not fail
@@ -675,15 +729,14 @@ int UnixReaderThread::tryRead()
m_context->mutex.lock();
const QByteArray data = m_context->file.read(numBytes);
m_context->mutex.unlock();
emit dataReceived(data);
processData(data);
return 0;
}
void UnixReaderThread::run()
{
int readResult;
// Read loop
while ( (readResult = tryRead()) == 0) ;
while ( tryRead() == 0) ;
}
void UnixReaderThread::terminate()
@@ -801,12 +854,9 @@ bool TrkDevice::open(const QString &port, QString *errorMessage)
d->readerThread = QSharedPointer<ReaderThread>(new ReaderThread(d->deviceContext));
connect(d->readerThread.data(), SIGNAL(error(QString)), this, SLOT(emitError(QString)),
Qt::QueuedConnection);
#ifdef Q_OS_WIN
connect(d->readerThread.data(), SIGNAL(dataReceived(char)),
this, SLOT(dataReceived(char)), Qt::QueuedConnection);
#endif
connect(d->readerThread.data(), SIGNAL(dataReceived(QByteArray)),
this, SLOT(dataReceived(QByteArray)), Qt::QueuedConnection);
connect(d->readerThread.data(), SIGNAL(messageReceived(trk::TrkResult,QByteArray)),
this, SLOT(slotMessageReceived(trk::TrkResult,QByteArray)),
Qt::BlockingQueuedConnection);
d->readerThread->start();
d->writerThread = QSharedPointer<WriterThread>(new WriterThread(d->deviceContext));
@@ -872,30 +922,12 @@ void TrkDevice::setVerbose(int b)
d->verbose = b;
}
void TrkDevice::dataReceived(char c)
void TrkDevice::slotMessageReceived(const trk::TrkResult &result, const QByteArray &rawData)
{
d->trkReadBuffer += c;
readMessages();
}
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);
}
d->writerThread->slotHandleResult(result);
emit messageReceived(result);
if (!rawData.isEmpty())
emit rawDataReceived(rawData);
}
void TrkDevice::emitError(const QString &s)
@@ -908,8 +940,11 @@ void TrkDevice::emitError(const QString &s)
void TrkDevice::sendTrkMessage(byte code, TrkCallback callback,
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);
}
}
void TrkDevice::sendTrkInitialPing()

View File

@@ -95,8 +95,6 @@ public:
// Send an Ack synchronously, bypassing the queue
bool sendTrkAck(unsigned char token);
void tryTrkRead(); // TODO: Why public?
signals:
void messageReceived(const trk::TrkResult &result);
// Emitted with the contents of messages enclosed in 07e, not for log output
@@ -105,8 +103,7 @@ signals:
void logMessage(const QString &msg);
private slots:
void dataReceived(char c);
void dataReceived(const QByteArray &a);
void slotMessageReceived(const trk::TrkResult &result, const QByteArray &a);
protected slots:
void emitError(const QString &msg);