Commit 1883baa5 authored by hjk's avatar hjk
Browse files

debuggger: code cosmetics

parent acc4563f
......@@ -34,6 +34,7 @@
#include "stackframe.h"
#include <texteditor/basetextmark.h>
#include <utils/qtcassert.h>
#include <QtCore/QDebug>
#include <QtCore/QTextStream>
......@@ -203,32 +204,35 @@ QString BreakpointData::toToolTip() const
{
QString rc;
QTextStream str(&rc);
str << "<html><body><table>";
str << "<tr><td>" << BreakHandler::tr("Marker File:")
<< "</td><td>" << markerFileName << "</td></tr>";
str << "<tr><td>" << BreakHandler::tr("Marker Line:")
<< "</td><td>" << markerLineNumber << "</td></tr>";
str << "<tr><td>" << BreakHandler::tr("Breakpoint Number:")
<< "</td><td>" << bpNumber << "</td></tr>";
str << "<tr><td>" << BreakHandler::tr("Breakpoint Address:")
<< "</td><td>" << bpAddress << "</td></tr>";
str << "</table><br><hr><table>";
str << "<tr><th>" << BreakHandler::tr("Property")
str << "<html><body><table>"
<< "<tr><td>" << BreakHandler::tr("Marker File:")
<< "</td><td>" << markerFileName << "</td></tr>"
<< "<tr><td>" << BreakHandler::tr("Marker Line:")
<< "</td><td>" << markerLineNumber << "</td></tr>"
<< "<tr><td>" << BreakHandler::tr("Breakpoint Number:")
<< "</td><td>" << bpNumber << "</td></tr>"
<< "<tr><td>" << BreakHandler::tr("Breakpoint Address:")
<< "</td><td>" << bpAddress << "</td></tr>"
<< "</table><br><hr><table>"
<< "<tr><th>" << BreakHandler::tr("Property")
<< "</th><th>" << BreakHandler::tr("Requested")
<< "</th><th>" << BreakHandler::tr("Obtained") << "</th></tr>";
str << "<tr><td>" << BreakHandler::tr("Internal Number:")
<< "</td><td>&mdash;</td><td>" << bpNumber << "</td></tr>";
str << "<tr><td>" << BreakHandler::tr("File Name:")
<< "</td><td>" << fileName << "</td><td>" << bpFileName << "</td></tr>";
str << "<tr><td>" << BreakHandler::tr("Function Name:")
<< "</td><td>" << funcName << "</td><td>" << bpFuncName << "</td></tr>";
str << "<tr><td>" << BreakHandler::tr("Line Number:")
<< "</td><td>" << lineNumber << "</td><td>" << bpLineNumber << "</td></tr>";
str << "<tr><td>" << BreakHandler::tr("Condition:")
<< "</td><td>" << condition << "</td><td>" << bpCondition << "</td></tr>";
str << "<tr><td>" << BreakHandler::tr("Ignore Count:")
<< "</td><td>" << ignoreCount << "</td><td>" << bpIgnoreCount << "</td></tr>";
str << "</table></body></html>";
<< "</th><th>" << BreakHandler::tr("Obtained") << "</th></tr>"
<< "<tr><td>" << BreakHandler::tr("Internal Number:")
<< "</td><td>&mdash;</td><td>" << bpNumber << "</td></tr>"
<< "<tr><td>" << BreakHandler::tr("File Name:")
<< "</td><td>" << fileName << "</td><td>" << bpFileName << "</td></tr>"
<< "<tr><td>" << BreakHandler::tr("Function Name:")
<< "</td><td>" << funcName << "</td><td>" << bpFuncName << "</td></tr>"
<< "<tr><td>" << BreakHandler::tr("Line Number:")
<< "</td><td>" << lineNumber << "</td><td>" << bpLineNumber << "</td></tr>"
<< "<tr><td>" << BreakHandler::tr("Corrected Line Number:")
<< "</td><td>" << lineNumber
<< "</td><td>" << bpCorrectedLineNumber << "</td></tr>"
<< "<tr><td>" << BreakHandler::tr("Condition:")
<< "</td><td>" << condition << "</td><td>" << bpCondition << "</td></tr>"
<< "<tr><td>" << BreakHandler::tr("Ignore Count:")
<< "</td><td>" << ignoreCount << "</td><td>" << bpIgnoreCount << "</td></tr>"
<< "</table></body></html>";
return rc;
}
......@@ -236,19 +240,19 @@ QString BreakpointData::toString() const
{
QString rc;
QTextStream str(&rc);
str << BreakHandler::tr("Marker File:") << markerFileName << ' ';
str << BreakHandler::tr("Marker Line:") << markerLineNumber << ' ';
str << BreakHandler::tr("Breakpoint Number:") << bpNumber << ' ';
str << BreakHandler::tr("Breakpoint Address:") << bpAddress << '\n';
str << BreakHandler::tr("File Name:")
<< fileName << " -- " << bpFileName << '\n';
str << BreakHandler::tr("Function Name:")
<< funcName << " -- " << bpFuncName << '\n';
str << BreakHandler::tr("Line Number:")
<< lineNumber << " -- " << bpLineNumber << '\n';
str << BreakHandler::tr("Condition:")
<< condition << " -- " << bpCondition << '\n';
str << BreakHandler::tr("Ignore Count:")
str << BreakHandler::tr("Marker File:") << markerFileName << ' '
<< BreakHandler::tr("Marker Line:") << markerLineNumber << ' '
<< BreakHandler::tr("Breakpoint Number:") << bpNumber << ' '
<< BreakHandler::tr("Breakpoint Address:") << bpAddress << '\n'
<< BreakHandler::tr("File Name:")
<< fileName << " -- " << bpFileName << '\n'
<< BreakHandler::tr("Function Name:")
<< funcName << " -- " << bpFuncName << '\n'
<< BreakHandler::tr("Line Number:")
<< lineNumber << " -- " << bpLineNumber << '\n'
<< BreakHandler::tr("Condition:")
<< condition << " -- " << bpCondition << '\n'
<< BreakHandler::tr("Ignore Count:")
<< ignoreCount << " -- " << bpIgnoreCount << '\n';
return rc;
}
......@@ -269,7 +273,7 @@ bool BreakpointData::isLocatedAt(const QString &fileName_, int lineNumber_) cons
bool BreakpointData::conditionsMatch() const
{
// same versions of gdb "beautify" the passed condition
// Some versions of gdb "beautify" the passed condition.
QString s1 = condition;
s1.remove(QChar(' '));
QString s2 = bpCondition;
......@@ -316,6 +320,12 @@ bool BreakHandler::hasPendingBreakpoints() const
return false;
}
BreakpointData *BreakHandler::at(int index) const
{
QTC_ASSERT(index < size(), return 0);
return m_bp.at(index);
}
void BreakHandler::removeAt(int index)
{
BreakpointData *data = at(index);
......@@ -443,7 +453,7 @@ void BreakHandler::resetBreakpoints()
data->bpCondition.clear();
data->bpIgnoreCount.clear();
data->bpAddress.clear();
// keep marker data if it was primary
// Keep marker data if it was primary.
if (data->markerFileName != data->fileName)
data->markerFileName.clear();
if (data->markerLineNumber != data->lineNumber.toInt())
......@@ -728,7 +738,6 @@ void BreakHandler::loadSessionData()
void BreakHandler::activateBreakpoint(int index)
{
const BreakpointData *data = at(index);
//qDebug() << "BREAKPOINT ACTIVATED: " << data->fileName;
if (!data->markerFileName.isEmpty()) {
StackFrame frame;
frame.file = data->markerFileName;
......@@ -739,7 +748,8 @@ void BreakHandler::activateBreakpoint(int index)
void BreakHandler::breakByFunction(const QString &functionName)
{
// One per function is enough for now
// One breakpoint per function is enough for now. This does not handle
// combinations of multiple conditions and ignore counts, though.
for (int index = size(); --index >= 0;) {
const BreakpointData *data = at(index);
QTC_ASSERT(data, break);
......
......@@ -30,8 +30,6 @@
#ifndef DEBUGGER_BREAKHANDLER_H
#define DEBUGGER_BREAKHANDLER_H
#include <utils/qtcassert.h>
#include <QtCore/QObject>
#include <QtCore/QAbstractTableModel>
#include <QtGui/QIcon>
......@@ -66,41 +64,42 @@ public:
private:
// Intentionally unimplemented.
// Making it copiable is tricky because of the markers.
// Making it copyable is tricky because of the markers.
void operator=(const BreakpointData &);
BreakpointData(const BreakpointData &);
// Our owner
BreakHandler *m_handler; // not owned.
BreakHandler *m_handler; // Not owned.
public:
bool enabled; // should we talk to the debugger engine?
bool pending; // does the debugger engine know about us already?
// this "user requested information". will get stored in the session
QString fileName; // short name of source file
QByteArray condition; // condition associated with breakpoint
QByteArray ignoreCount; // ignore count associated with breakpoint
QByteArray lineNumber; // line in source file
QString funcName; // name of containing function
bool useFullPath; // should we use the full path when setting the bp?
// this is what gdb produced in response
QByteArray bpNumber; // breakpoint number assigned by the debugger engine
QByteArray bpCondition; // condition acknowledged by the debugger engine
QByteArray bpIgnoreCount;// ignore count acknowledged by the debugger engine
QString bpFileName; // file name acknowledged by the debugger engine
QByteArray bpLineNumber; // line number acknowledged by the debugger engine
QString bpFuncName; // function name acknowledged by the debugger engine
QByteArray bpAddress; // address acknowledged by the debugger engine
bool bpMultiple; // happens in constructors/gdb
bool bpEnabled; // enable/disable command sent
// taken from either user input or gdb responses
QString markerFileName; // used to locate the marker
bool enabled; // Should we talk to the debugger engine?
bool pending; // Does the debugger engine know about us already?
// This "user requested information" will get stored in the session.
QString fileName; // Short name of source file.
QByteArray condition; // Condition associated with breakpoint.
QByteArray ignoreCount; // Ignore count associated with breakpoint.
QByteArray lineNumber; // Line in source file.
QString funcName; // Name of containing function.
bool useFullPath; // Should we use the full path when setting the bp?
// This is what gdb produced in response.
QByteArray bpNumber; // Breakpoint number assigned by the debugger engine.
QByteArray bpCondition; // Condition acknowledged by the debugger engine.
QByteArray bpIgnoreCount;// Ignore count acknowledged by the debugger engine.
QString bpFileName; // File name acknowledged by the debugger engine.
QByteArray bpLineNumber; // Line number acknowledged by the debugger engine.
QByteArray bpCorrectedLineNumber; // Acknowledged by the debugger engine.
QString bpFuncName; // Function name acknowledged by the debugger engine.
QByteArray bpAddress; // Address acknowledged by the debugger engine.
bool bpMultiple; // Happens in constructors/gdb.
bool bpEnabled; // Enable/disable command sent.
// Taken from either user input or gdb responses.
QString markerFileName; // Used to locate the marker.
int markerLineNumber;
// our red blob in the editor
// Our red blob in the editor.
BreakpointMarker *marker;
};
......@@ -126,23 +125,23 @@ public:
QAbstractItemModel *model() { return this; }
BreakpointData *at(int index) const { QTC_ASSERT(index < size(), return 0); return m_bp.at(index); }
BreakpointData *at(int index) const;
int size() const { return m_bp.size(); }
bool hasPendingBreakpoints() const;
void append(BreakpointData *data);
void removeAt(int index); // also deletes the marker
void clear(); // also deletes all the marker
void removeAt(int index); // This also deletes the marker.
void clear(); // This also deletes all the marker.
int indexOf(BreakpointData *data) { return m_bp.indexOf(data); }
int findBreakpoint(const QString &fileName, int lineNumber);
int findBreakpoint(const BreakpointData &data); // returns index
int findBreakpoint(int bpNumber); // returns index
int findBreakpoint(const BreakpointData &data); // Returns index.
int findBreakpoint(int bpNumber); // Returns index.
void updateMarkers();
QList<BreakpointData *> insertedBreakpoints() const;
void takeInsertedBreakPoint(BreakpointData *);
QList<BreakpointData *> takeRemovedBreakpoints(); // owned
QList<BreakpointData *> takeEnabledBreakpoints(); // not owned
QList<BreakpointData *> takeDisabledBreakpoints(); // not owned
QList<BreakpointData *> takeRemovedBreakpoints(); // Owned.
QList<BreakpointData *> takeEnabledBreakpoints(); // Not owned.
QList<BreakpointData *> takeDisabledBreakpoints(); // Not owned.
QIcon breakpointIcon() const { return m_breakpointIcon; }
QIcon disabledBreakpointIcon() const { return m_disabledBreakpointIcon; }
......@@ -177,12 +176,12 @@ private:
const QIcon m_disabledBreakpointIcon;
const QIcon m_pendingBreakPointIcon;
DebuggerManager *m_manager; // not owned
DebuggerManager *m_manager; // Not owned.
QList<BreakpointData *> m_bp;
QList<BreakpointData *> m_inserted; // lately inserted breakpoints
QList<BreakpointData *> m_removed; // lately removed breakpoints
QList<BreakpointData *> m_enabled; // lately enabled breakpoints
QList<BreakpointData *> m_disabled; // lately disabled breakpoints
QList<BreakpointData *> m_inserted; // Lately inserted breakpoints.
QList<BreakpointData *> m_removed; // Lately removed breakpoints.
QList<BreakpointData *> m_enabled; // Lately enabled breakpoints.
QList<BreakpointData *> m_disabled; // Lately disabled breakpoints.
};
} // namespace Internal
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment