work save
This commit is contained in:
parent
c6080cdf59
commit
aa17415b15
|
@ -63,6 +63,8 @@ bool Debugger::start()
|
|||
connect(this, &Debugger::localsReady,pMainWindow,&MainWindow::onLocalsReady);
|
||||
connect(mReader, &DebugReader::cmdStarted,pMainWindow, &MainWindow::disableDebugActions);
|
||||
connect(mReader, &DebugReader::cmdFinished,pMainWindow, &MainWindow::enableDebugActions);
|
||||
connect(mReader, &DebugReader::breakpointInfoGetted, mBreakpointModel,
|
||||
&BreakpointModel::updateBreakpointNumber);
|
||||
|
||||
mReader->start();
|
||||
mReader->waitStart();
|
||||
|
@ -1713,24 +1715,13 @@ QStringList DebugReader::tokenize(const QString &s)
|
|||
return result;
|
||||
}
|
||||
|
||||
void DebugReader::handleBreakpoint(const QByteArray &breakpointRecord)
|
||||
void DebugReader::handleBreakpoint(const GDBMIResultParser::ParseObject& breakpoint)
|
||||
{
|
||||
//we have to convert record from local encoding to utf8
|
||||
//because QJsonDocument only handle utf8-encoded json strings
|
||||
QString temp = QString::fromLocal8Bit(breakpointRecord);
|
||||
QByteArray record = temp.toUtf8();
|
||||
GDBMIResultParser parser;
|
||||
GDBMIR
|
||||
parser.parse(breakpointRecord,)
|
||||
QJsonParseError error;
|
||||
QJsonDocument doc = QJsonDocument::fromJson(record,&error);
|
||||
if (error.error!=QJsonParseError::NoError) {
|
||||
mConsoleOutput.append(QString("Error when parsing breakpoint record \"%1\":").arg(temp));
|
||||
mConsoleOutput.append(error.errorString());
|
||||
return;
|
||||
}
|
||||
QJsonObject obj = doc.object();
|
||||
|
||||
// gdb use system encoding for file path
|
||||
QString filename = QString::fromLocal8Bit(breakpoint["filename"].value());
|
||||
int line = breakpoint["line"].intValue();
|
||||
int number = breakpoint["number"].intValue();
|
||||
emit breakpointInfoGetted(filename, line , number);
|
||||
}
|
||||
|
||||
QByteArray DebugReader::removeToken(const QByteArray &line)
|
||||
|
@ -1966,6 +1957,14 @@ void BreakpointModel::removeBreakpoint(int row)
|
|||
endRemoveRows();
|
||||
}
|
||||
|
||||
void BreakpointModel::invalidateAllBreakpointNumbers()
|
||||
{
|
||||
foreach (PBreakpoint bp,mList) {
|
||||
bp->number = -1;
|
||||
}
|
||||
//emit dateChanged(createIndex(0,0),)
|
||||
}
|
||||
|
||||
PBreakpoint BreakpointModel::setBreakPointCondition(int index, const QString &condition)
|
||||
{
|
||||
PBreakpoint breakpoint = mList[index];
|
||||
|
@ -2045,6 +2044,17 @@ void BreakpointModel::load(const QString &filename)
|
|||
}
|
||||
}
|
||||
|
||||
void BreakpointModel::updateBreakpointNumber(const QString &filename, int line, int number)
|
||||
{
|
||||
QFileInfo file(filename);
|
||||
QString fn = file.absoluteFilePath();
|
||||
foreach (PBreakpoint bp, mList) {
|
||||
if (bp->filename == fn && bp->line == line) {
|
||||
bp->number = number;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void BreakpointModel::onFileDeleteLines(const QString &filename, int startLine, int count)
|
||||
{
|
||||
for (int i = mList.count()-1;i>=0;i--){
|
||||
|
|
|
@ -100,6 +100,8 @@ public:
|
|||
void save(const QString& filename);
|
||||
void load(const QString& filename);
|
||||
public slots:
|
||||
void updateBreakpointNumber(const QString& filename, int line, int number);
|
||||
void invalidateAllBreakpointNumbers(); // call this when gdb is stopped
|
||||
void onFileDeleteLines(const QString& filename, int startLine, int count);
|
||||
void onFileInsertLines(const QString& filename, int startLine, int count);
|
||||
private:
|
||||
|
@ -291,6 +293,8 @@ signals:
|
|||
void changeDebugConsoleLastLine(const QString& text);
|
||||
void cmdStarted();
|
||||
void cmdFinished();
|
||||
|
||||
void breakpointInfoGetted(const QString& filename, int line, int number);
|
||||
private:
|
||||
void clearCmdQueue();
|
||||
bool outputTerminated(QByteArray& text);
|
||||
|
|
|
@ -194,21 +194,35 @@ void GDBMIResultParser::skipSpaces(const char *&p)
|
|||
p++;
|
||||
}
|
||||
|
||||
const QString &GDBMIResultParser::ParseValue::value() const
|
||||
const QByteArray &GDBMIResultParser::ParseValue::value() const
|
||||
{
|
||||
Q_ASSERT(mType == ParseValueType::Value);
|
||||
return mValue;
|
||||
}
|
||||
|
||||
const QList<::GDBMIResultParser::ParseObject> &GDBMIResultParser::ParseValue::array() const
|
||||
{
|
||||
Q_ASSERT(mType == ParseValueType::Array);
|
||||
return mArray;
|
||||
}
|
||||
|
||||
const GDBMIResultParser::ParseObject &GDBMIResultParser::ParseValue::object() const
|
||||
{
|
||||
Q_ASSERT(mType == ParseValueType::Object);
|
||||
return mObject;
|
||||
}
|
||||
|
||||
int GDBMIResultParser::ParseValue::intValue(int defaultValue) const
|
||||
{
|
||||
Q_ASSERT(mType == ParseValueType::Value);
|
||||
bool ok;
|
||||
int value = QString(mValue).toInt(&ok);
|
||||
if (ok)
|
||||
return value;
|
||||
else
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
GDBMIResultParser::ParseValueType GDBMIResultParser::ParseValue::type() const
|
||||
{
|
||||
return mType;
|
||||
|
@ -219,7 +233,7 @@ GDBMIResultParser::ParseValue::ParseValue():
|
|||
|
||||
}
|
||||
|
||||
GDBMIResultParser::ParseValue::ParseValue(const QString &value):
|
||||
GDBMIResultParser::ParseValue::ParseValue(const QByteArray &value):
|
||||
mValue(value),
|
||||
mType(ParseValueType::Value)
|
||||
{
|
||||
|
@ -237,7 +251,7 @@ GDBMIResultParser::ParseValue::ParseValue(const QList<ParseObject> &array):
|
|||
{
|
||||
}
|
||||
|
||||
GDBMIResultParser::ParseValue &GDBMIResultParser::ParseValue::operator=(const QString &value)
|
||||
GDBMIResultParser::ParseValue &GDBMIResultParser::ParseValue::operator=(const QByteArray &value)
|
||||
{
|
||||
Q_ASSERT(mType == ParseValueType::NotAssigned);
|
||||
mType = ParseValueType::Value;
|
||||
|
|
|
@ -46,20 +46,20 @@ public:
|
|||
class ParseValue {
|
||||
public:
|
||||
explicit ParseValue();
|
||||
explicit ParseValue(const QString& value);
|
||||
explicit ParseValue(const QByteArray& value);
|
||||
explicit ParseValue(const ParseObject &object);
|
||||
explicit ParseValue(const QList<ParseObject>& array);
|
||||
ParseValue(const ParseValue&) = delete;
|
||||
const QString &value() const;
|
||||
const QByteArray &value() const;
|
||||
const QList<ParseObject> &array() const;
|
||||
const ParseObject &object() const;
|
||||
ParseValueType type() const;
|
||||
ParseValue& operator=(const QString& value);
|
||||
ParseValue& operator=(const QByteArray& value);
|
||||
ParseValue& operator=(const ParseObject& object);
|
||||
ParseValue& operator=(const QList<ParseObject>& array);
|
||||
ParseValue& operator=(const ParseValue& value);
|
||||
private:
|
||||
QString mValue;
|
||||
QByteArray mValue;
|
||||
QList<ParseObject> mArray;
|
||||
ParseObject mObject;
|
||||
ParseValueType mType;
|
||||
|
|
Loading…
Reference in New Issue