Debugger: Use Utils::Text::Position instead of int line number

The column is currently unused.

Change-Id: Iabc57c8d21e807187783071efe9a82e9c1877181
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
hjk
2023-06-06 15:44:59 +02:00
parent a3fb6a3a1c
commit 0d4a546397
17 changed files with 101 additions and 92 deletions

View File

@@ -84,9 +84,9 @@ public:
{
TextMark::updateLineNumber(lineNumber);
QTC_ASSERT(m_bp, return);
m_bp->setLineNumber(lineNumber);
m_bp->setTextPosition({lineNumber, -1});
if (GlobalBreakpoint gbp = m_bp->globalBreakpoint())
gbp->m_params.lineNumber = lineNumber;
gbp->m_params.textPosition.line = lineNumber;
}
void updateFilePath(const FilePath &fileName) final
@@ -107,7 +107,7 @@ public:
if (!gbp)
return;
BreakpointParameters params = gbp->m_params;
params.lineNumber = line;
params.textPosition.line = line;
gbp->deleteBreakpoint();
BreakpointManager::createBreakpoint(params);
}
@@ -643,7 +643,7 @@ void BreakpointDialog::getParts(unsigned partsMask, BreakpointParameters *data)
data->enabled = m_checkBoxEnabled->isChecked();
if (partsMask & FileAndLinePart) {
data->lineNumber = m_lineEditLineNumber->text().toInt();
data->textPosition.line = m_lineEditLineNumber->text().toInt();
data->pathUsage = static_cast<BreakpointPathUsage>(m_comboBoxPathUsage->currentIndex());
data->fileName = m_pathChooserFileName->filePath();
}
@@ -683,7 +683,7 @@ void BreakpointDialog::setParts(unsigned mask, const BreakpointParameters &data)
if (mask & FileAndLinePart) {
m_pathChooserFileName->setFilePath(data.fileName);
m_lineEditLineNumber->setText(QString::number(data.lineNumber));
m_lineEditLineNumber->setText(QString::number(data.textPosition.line));
}
if (mask & FunctionPart)
@@ -889,7 +889,7 @@ BreakHandler::BreakHandler(DebuggerEngine *engine)
bool BreakpointParameters::isLocatedAt(const FilePath &file, int line, const FilePath &markerFile) const
{
return lineNumber == line && (fileName == file || fileName == markerFile);
return textPosition.line == line && (fileName == file || fileName == markerFile);
}
static bool isSimilarTo(const BreakpointParameters &params, const BreakpointParameters &needle)
@@ -911,7 +911,7 @@ static bool isSimilarTo(const BreakpointParameters &params, const BreakpointPara
// FIXME: breaks multiple breakpoints at the same location
if (!params.fileName.isEmpty()
&& params.fileName == needle.fileName
&& params.lineNumber == needle.lineNumber)
&& params.textPosition == needle.textPosition)
return true;
return false;
@@ -1064,7 +1064,7 @@ QVariant BreakpointItem::data(int column, int role) const
return empty;
}
if (role == Qt::UserRole + 1)
return m_parameters.lineNumber;
return m_parameters.textPosition.line;
break;
case BreakpointAddressColumn:
if (role == Qt::DisplayRole) {
@@ -1121,7 +1121,7 @@ void BreakpointItem::addToCommand(DebuggerCommand *cmd) const
cmd->arg("oneshot", requested.oneShot);
cmd->arg("enabled", requested.enabled);
cmd->arg("file", requested.fileName.path());
cmd->arg("line", requested.lineNumber);
cmd->arg("line", requested.textPosition.line);
cmd->arg("address", requested.address);
cmd->arg("expression", requested.expression);
}
@@ -1186,12 +1186,13 @@ void BreakHandler::requestSubBreakpointEnabling(const SubBreakpoint &sbp, bool e
}
}
void BreakpointItem::setMarkerFileAndLine(const FilePath &fileName, int lineNumber)
void BreakpointItem::setMarkerFileAndPosition(const FilePath &fileName,
const Text::Position &textPosition)
{
if (m_parameters.fileName == fileName && m_parameters.lineNumber == lineNumber)
if (m_parameters.fileName == fileName && m_parameters.textPosition == textPosition)
return;
m_parameters.fileName = fileName;
m_parameters.lineNumber = lineNumber;
m_parameters.textPosition = textPosition;
destroyMarker();
updateMarker();
update();
@@ -1258,7 +1259,8 @@ void BreakHandler::removeDisassemblerMarker(const Breakpoint &bp)
static bool matches(const Location &loc, const BreakpointParameters &bp)
{
if (loc.fileName() == bp.fileName && loc.lineNumber() == bp.lineNumber && bp.lineNumber > 0)
if (loc.fileName() == bp.fileName && loc.textPosition() == bp.textPosition
&& bp.textPosition.line > 0)
return true;
if (loc.address() == bp.address && bp.address > 0)
return true;
@@ -1836,9 +1838,9 @@ FilePath BreakpointItem::markerFileName() const
int BreakpointItem::markerLineNumber() const
{
if (m_parameters.lineNumber > 0)
return m_parameters.lineNumber;
return requestedParameters().lineNumber;
if (m_parameters.textPosition.line > 0)
return m_parameters.textPosition.line;
return requestedParameters().textPosition.line;
}
const BreakpointParameters &BreakpointItem::requestedParameters() const
@@ -1869,7 +1871,7 @@ bool BreakpointItem::needsChange() const
return true;
if (oparams.command != m_parameters.command)
return true;
if (oparams.type == BreakpointByFileAndLine && oparams.lineNumber != m_parameters.lineNumber)
if (oparams.type == BreakpointByFileAndLine && oparams.textPosition != m_parameters.textPosition)
return true;
// FIXME: Too strict, functions may have parameter lists, or not.
// if (m_params.type == BreakpointByFunction && m_params.functionName != m_response.functionName)
@@ -1950,8 +1952,8 @@ QString BreakpointItem::toolTip() const
<< "</td><td>" << m_parameters.fileName.toUserOutput()
<< "</td></tr>"
<< "<tr><td>" << Tr::tr("Line Number:")
<< "</td><td>" << requested.lineNumber
<< "</td><td>" << m_parameters.lineNumber << "</td></tr>";
<< "</td><td>" << requested.textPosition.line
<< "</td><td>" << m_parameters.textPosition.line << "</td></tr>";
}
if (requested.type == BreakpointByFunction || m_parameters.type == BreakpointByFileAndLine) {
str << "<tr><td>" << Tr::tr("Module:")
@@ -2163,12 +2165,12 @@ QVariant GlobalBreakpointItem::data(int column, int role) const
break;
case BreakpointLineColumn:
if (role == Qt::DisplayRole) {
if (m_params.lineNumber > 0)
return m_params.lineNumber;
if (m_params.textPosition.line > 0)
return m_params.textPosition.line;
return empty;
}
if (role == Qt::UserRole + 1)
return m_params.lineNumber;
return m_params.textPosition.line;
break;
case BreakpointAddressColumn:
if (role == Qt::DisplayRole) {
@@ -2270,9 +2272,9 @@ void GlobalBreakpointItem::removeBreakpointFromModel()
void GlobalBreakpointItem::updateLineNumber(int lineNumber)
{
if (m_params.lineNumber == lineNumber)
if (m_params.textPosition.line == lineNumber)
return;
m_params.lineNumber = lineNumber;
m_params.textPosition.line = lineNumber;
update();
}
@@ -2294,7 +2296,7 @@ FilePath GlobalBreakpointItem::markerFileName() const
int GlobalBreakpointItem::markerLineNumber() const
{
return m_params.lineNumber;
return m_params.textPosition.line;
}
void GlobalBreakpointItem::updateMarker()
@@ -2306,7 +2308,7 @@ void GlobalBreakpointItem::updateMarker()
return;
}
const int line = m_params.lineNumber;
const int line = m_params.textPosition.line;
if (m_marker) {
if (m_params.fileName != m_marker->filePath())
m_marker->updateFilePath(m_params.fileName);
@@ -2373,7 +2375,7 @@ QString GlobalBreakpointItem::toolTip() const
<< "</td><td>" << m_params.fileName.toUserOutput()
<< "</td></tr>"
<< "<tr><td>" << Tr::tr("Line Number:")
<< "</td><td>" << m_params.lineNumber;
<< "</td><td>" << m_params.textPosition.line;
}
if (m_params.type == BreakpointByFunction || m_params.type == BreakpointByFileAndLine) {
str << "<tr><td>" << Tr::tr("Module:")
@@ -2487,7 +2489,7 @@ void BreakpointManager::setOrRemoveBreakpoint(const ContextData &location, const
data.tracepoint = !tracePointMessage.isEmpty();
data.message = tracePointMessage;
data.fileName = location.fileName;
data.lineNumber = location.lineNumber;
data.textPosition = location.textPosition;
} else if (location.type == LocationByAddress) {
data.type = BreakpointByAddress;
data.tracepoint = !tracePointMessage.isEmpty();
@@ -2513,7 +2515,7 @@ GlobalBreakpoint BreakpointManager::findBreakpointFromContext(const ContextData
GlobalBreakpoint bestMatch;
theBreakpointManager->forItemsAtLevel<1>([&](const GlobalBreakpoint &gbp) {
if (location.type == LocationByFile) {
if (gbp->m_params.isLocatedAt(location.fileName, location.lineNumber, FilePath())) {
if (gbp->m_params.isLocatedAt(location.fileName, location.textPosition.line, FilePath())) {
matchLevel = 2;
bestMatch = gbp;
} else if (matchLevel < 2) {
@@ -2522,7 +2524,7 @@ GlobalBreakpoint BreakpointManager::findBreakpointFromContext(const ContextData
for (Breakpoint bp : handler->breakpoints()) {
if (bp->globalBreakpoint() == gbp) {
if (bp->fileName() == location.fileName
&& bp->lineNumber() == location.lineNumber) {
&& bp->textPosition() == location.textPosition) {
matchLevel = 1;
bestMatch = gbp;
}
@@ -2768,8 +2770,8 @@ void BreakpointManager::saveSessionData()
map.insert("type", params.type);
if (!params.fileName.isEmpty())
map.insert("filename", params.fileName.toSettings());
if (params.lineNumber)
map.insert("linenumber", params.lineNumber);
if (params.textPosition.line)
map.insert("linenumber", params.textPosition.line);
if (!params.functionName.isEmpty())
map.insert("funcname", params.functionName);
if (params.address)
@@ -2815,7 +2817,7 @@ void BreakpointManager::loadSessionData()
params.fileName = FilePath::fromSettings(v);
v = map.value("linenumber");
if (v.isValid())
params.lineNumber = v.toString().toInt();
params.textPosition.line = v.toString().toInt();
v = map.value("condition");
if (v.isValid())
params.condition = v.toString();

View File

@@ -98,7 +98,8 @@ public:
QIcon icon(bool withLocationMarker = false) const;
void setMarkerFileAndLine(const Utils::FilePath &fileName, int lineNumber);
void setMarkerFileAndPosition(const Utils::FilePath &fileName,
const Utils::Text::Position &textPosition);
bool needsChange() const;
SubBreakpoint findOrCreateSubBreakpoint(const QString &responseId);
@@ -128,14 +129,14 @@ public:
QString message() const { return m_parameters.message; }
QString command() const { return m_parameters.command; }
quint64 address() const { return m_parameters.address; }
int lineNumber() const { return m_parameters.lineNumber; }
Utils::Text::Position textPosition() const { return m_parameters.textPosition; }
bool isEnabled() const { return m_parameters.enabled; }
bool isWatchpoint() const { return m_parameters.isWatchpoint(); }
bool isTracepoint() const { return m_parameters.isTracepoint(); }
bool isOneShot() const { return m_parameters.oneShot; }
bool isPending() const { return m_parameters.pending; }
void setLineNumber(int lineNumber) { m_parameters.lineNumber = lineNumber; }
void setTextPosition(const Utils::Text::Position pos) { m_parameters.textPosition = pos; }
void setFileName(const Utils::FilePath &fileName) { m_parameters.fileName = fileName; }
void setFunctionName(const QString &functionName) { m_parameters.functionName = functionName; }
void setPending(bool pending);

View File

@@ -27,7 +27,7 @@ namespace Internal {
BreakpointParameters::BreakpointParameters(BreakpointType t)
: type(t), enabled(true), pathUsage(BreakpointPathUsageEngineDefault),
ignoreCount(0), lineNumber(0), address(0), size(0),
ignoreCount(0), address(0), size(0),
bitpos(0), bitsize(0), threadSpec(-1),
tracepoint(false), oneShot(false)
{}
@@ -48,7 +48,7 @@ BreakpointParts BreakpointParameters::differencesTo
parts |= ConditionPart;
if (ignoreCount != rhs.ignoreCount)
parts |= IgnoreCountPart;
if (lineNumber != rhs.lineNumber)
if (textPosition != rhs.textPosition)
parts |= FileAndLinePart;
if (address != rhs.address)
parts |= AddressPart;
@@ -73,7 +73,7 @@ bool BreakpointParameters::isValid() const
{
switch (type) {
case BreakpointByFileAndLine:
return !fileName.isEmpty() && lineNumber > 0;
return !fileName.isEmpty() && textPosition.line > 0;
case BreakpointByFunction:
return !functionName.isEmpty();
case WatchpointAtAddress:
@@ -116,7 +116,7 @@ void BreakpointParameters::updateLocation(const QString &location)
{
if (!location.isEmpty()) {
int pos = location.indexOf(':');
lineNumber = location.mid(pos + 1).toInt();
textPosition.line = location.mid(pos + 1).toInt(); // FIXME: Handle column
QString file = location.left(pos);
if (file.startsWith('"') && file.endsWith('"'))
file = file.mid(1, file.size() - 2);
@@ -164,8 +164,8 @@ QString BreakpointParameters::toString() const
ts << "Type: " << type;
switch (type) {
case BreakpointByFileAndLine:
ts << " FileName: " << fileName << ':' << lineNumber
<< " PathUsage: " << pathUsage;
ts << " FileName: " << fileName << ':' << textPosition.line;
ts << " PathUsage: " << pathUsage;
break;
case BreakpointByFunction:
case BreakpointOnQmlSignalEmit:
@@ -295,7 +295,7 @@ void BreakpointParameters::updateFromGdbOutput(const GdbMi &bkpt, const Utils::F
} else if (child.hasName("fullname")) {
fullName = child.data();
} else if (child.hasName("line")) {
lineNumber = child.toInt();
textPosition.line = child.toInt();
} else if (child.hasName("cond")) {
// gdb 6.3 likes to "rewrite" conditions. Just accept that fact.
condition = child.data();

View File

@@ -7,6 +7,7 @@
#include <QString>
#include <utils/filepath.h>
#include <utils/textutils.h>
namespace Debugger {
namespace Internal {
@@ -139,7 +140,7 @@ public:
Utils::FilePath fileName;//!< Short name of source file.
QString condition; //!< Condition associated with breakpoint.
int ignoreCount; //!< Ignore count associated with breakpoint.
int lineNumber; //!< Line in source file.
Utils::Text::Position textPosition; //!< Line and column in source file.
quint64 address; //!< Address for address based data breakpoints.
QString expression; //!< Expression for expression based data breakpoints.
uint size; //!< Size of watched area for data breakpoints.

View File

@@ -818,7 +818,7 @@ void CdbEngine::executeRunToLine(const ContextData &data)
} else {
bp.type =BreakpointByFileAndLine;
bp.fileName = data.fileName;
bp.lineNumber = data.lineNumber;
bp.textPosition = data.textPosition;
}
runCommand({cdbAddBreakpointCommand(bp, m_sourcePathMappings), BuiltinCommand,
@@ -854,7 +854,7 @@ void CdbEngine::executeJumpToLine(const ContextData &data)
// Jump to source line: Resolve source line address and go to that location
QString cmd;
StringInputStream str(cmd);
str << "? `" << data.fileName.toUserOutput() << ':' << data.lineNumber << '`';
str << "? `" << data.fileName.toUserOutput() << ':' << data.textPosition.line << '`';
runCommand({cmd, BuiltinCommand, [this, data](const DebuggerResponse &r) {
handleJumpToLineAddressResolution(r, data); }});
}
@@ -891,7 +891,7 @@ void CdbEngine::handleJumpToLineAddressResolution(const DebuggerResponse &respon
const quint64 address = answer.toULongLong(&ok, 16);
if (ok && address) {
jumpToAddress(address);
gotoLocation(Location(context.fileName, context.lineNumber));
gotoLocation(Location(context.fileName, context.textPosition));
}
}
@@ -2505,8 +2505,9 @@ void CdbEngine::insertBreakpoint(const Breakpoint &bp)
if (!m_autoBreakPointCorrection
&& parameters.type == BreakpointByFileAndLine
&& debuggerSettings()->cdbBreakPointCorrection.value()) {
response.lineNumber = int(lineCorrection->fixLineNumber(parameters.fileName,
unsigned(parameters.lineNumber)));
response.textPosition.line =
int(lineCorrection->fixLineNumber(parameters.fileName,
unsigned(parameters.textPosition.line)));
QString cmd = cdbAddBreakpointCommand(response, m_sourcePathMappings, responseId);
runCommand({cmd, BuiltinCommand, handleBreakInsertCB});
} else {
@@ -2979,7 +2980,7 @@ BreakpointParameters CdbEngine::parseBreakPoint(const GdbMi &gdbmi)
result.fileName = Utils::FilePath::fromUserInput(mappedFile.fileName);
const GdbMi lineNumber = gdbmi["srcline"];
if (lineNumber.isValid())
result.lineNumber = lineNumber.data().toULongLong(nullptr, 0);
result.textPosition.line = lineNumber.data().toULongLong(nullptr, 0);
}
const GdbMi addressG = gdbmi["address"];
if (addressG.isValid())
@@ -3036,7 +3037,7 @@ void CdbEngine::handleBreakPoints(const DebuggerResponse &response)
currentResponse.pending = reportedResponse.pending;
currentResponse.enabled = reportedResponse.enabled;
currentResponse.fileName = reportedResponse.fileName;
currentResponse.lineNumber = reportedResponse.lineNumber;
currentResponse.textPosition = reportedResponse.textPosition;
formatCdbBreakPointResponse(bp->modelId(), responseId, currentResponse, str);
if (debugBreakpoints)
qDebug(" Setting for %s: %s\n", qPrintable(responseId),
@@ -3053,7 +3054,7 @@ void CdbEngine::handleBreakPoints(const DebuggerResponse &response)
currentResponse.pending = reportedResponse.pending;
currentResponse.enabled = reportedResponse.enabled;
currentResponse.fileName = reportedResponse.fileName;
currentResponse.lineNumber = reportedResponse.lineNumber;
currentResponse.textPosition = reportedResponse.textPosition;
Breakpoint bp = sub->breakpoint();
QTC_ASSERT(bp, continue);
formatCdbBreakPointResponse(bp->modelId(), responseId, currentResponse, str);

View File

@@ -161,7 +161,8 @@ QString cdbAddBreakpointCommand(const BreakpointParameters &bpIn,
str << '`';
if (!params.module.isEmpty())
str << params.module << '!';
str << cdbBreakPointFileName(params, sourcePathMapping) << ':' << params.lineNumber << '`';
str << cdbBreakPointFileName(params, sourcePathMapping)
<< ':' << params.textPosition.line << '`';
break;
case WatchpointAtAddress: { // Read/write, no space here
const unsigned size = params.size ? params.size : 1;

View File

@@ -281,7 +281,7 @@ static QJsonObject createBreakpoint(const Breakpoint &breakpoint)
return QJsonObject();
QJsonObject bp;
bp["line"] = params.lineNumber;
bp["line"] = params.textPosition.line;
bp["source"] = QJsonObject{{"name", params.fileName.fileName()},
{"path", params.fileName.path()}};
return bp;
@@ -622,7 +622,7 @@ void DapEngine::handleOutput(const QJsonDocument &data)
QString id = QString::number(body.value("hitBreakpointIds").toArray().first().toInteger());
const BreakpointParameters &params
= breakHandler()->findBreakpointByResponseId(id)->requestedParameters();
gotoLocation(Location(params.fileName, params.lineNumber));
gotoLocation(Location(params.fileName, params.textPosition));
}
if (state() == InferiorStopRequested)

View File

@@ -142,7 +142,7 @@ static bool debuggerActionsEnabledHelper(DebuggerState state)
Location::Location(const StackFrame &frame, bool marker)
{
m_fileName = frame.file;
m_lineNumber = frame.line;
m_textPosition = {frame.line, -1};
m_needsMarker = marker;
m_functionName = frame.function;
m_hasDebugInfo = frame.isUsable();
@@ -1075,7 +1075,7 @@ void DebuggerEngine::gotoLocation(const Location &loc)
return;
}
const FilePath file = loc.fileName();
const int line = loc.lineNumber();
const int line = loc.textPosition().line;
bool newEditor = false;
IEditor *editor = EditorManager::openEditor(file,
Id(),

View File

@@ -219,12 +219,14 @@ public:
Location(quint64 address) { m_address = address; }
Location(const Utils::FilePath &file) { m_fileName = file; }
Location(const Utils::FilePath &file, int line, bool marker = true)
{ m_lineNumber = line; m_fileName = file; m_needsMarker = marker; }
{ m_textPosition = {line, -1}; m_fileName = file; m_needsMarker = marker; }
Location(const Utils::FilePath &file, const Utils::Text::Position &pos, bool marker = true)
{ m_textPosition = pos; m_fileName = file; m_needsMarker = marker; }
Location(const StackFrame &frame, bool marker = true);
Utils::FilePath fileName() const { return m_fileName; }
QString functionName() const { return m_functionName; }
QString from() const { return m_from; }
int lineNumber() const { return m_lineNumber; }
Utils::Text::Position textPosition() const { return m_textPosition; }
void setNeedsRaise(bool on) { m_needsRaise = on; }
void setNeedsMarker(bool on) { m_needsMarker = on; }
void setFileName(const Utils::FilePath &fileName) { m_fileName = fileName; }
@@ -240,7 +242,7 @@ private:
bool m_needsMarker = false;
bool m_needsRaise = true;
bool m_hasDebugInfo = true;
int m_lineNumber = -1;
Utils::Text::Position m_textPosition;
Utils::FilePath m_fileName;
QString m_functionName;
QString m_from;

View File

@@ -603,8 +603,8 @@ public:
} else {
//: Message tracepoint: %1 file, %2 line %3 function hit.
message = Tr::tr("%1:%2 %3() hit").arg(data.fileName.fileName()).
arg(data.lineNumber).
arg(cppFunctionAt(data.fileName, data.lineNumber));
arg(data.textPosition.line).
arg(cppFunctionAt(data.fileName, data.textPosition.line));
}
QInputDialog dialog; // Create wide input dialog.
dialog.setWindowFlags(dialog.windowFlags() & ~(Qt::MSWindowsFixedSizeDialogHint));
@@ -1881,7 +1881,7 @@ void DebuggerPluginPrivate::requestContextMenu(TextEditorWidget *widget,
if (engine->hasCapability(RunToLineCapability)) {
auto act = menu->addAction(args.address
? Tr::tr("Run to Address 0x%1").arg(args.address, 0, 16)
: Tr::tr("Run to Line %1").arg(args.lineNumber));
: Tr::tr("Run to Line %1").arg(args.textPosition.line));
connect(act, &QAction::triggered, this, [args, engine] {
QTC_ASSERT(engine, return);
engine->executeRunToLine(args);
@@ -1890,7 +1890,7 @@ void DebuggerPluginPrivate::requestContextMenu(TextEditorWidget *widget,
if (engine->hasCapability(JumpToLineCapability)) {
auto act = menu->addAction(args.address
? Tr::tr("Jump to Address 0x%1").arg(args.address, 0, 16)
: Tr::tr("Jump to Line %1").arg(args.lineNumber));
: Tr::tr("Jump to Line %1").arg(args.textPosition.line));
connect(act, &QAction::triggered, this, [args, engine] {
QTC_ASSERT(engine, return);
engine->executeJumpToLine(args);

View File

@@ -12,6 +12,7 @@
#include <QVector>
#include <utils/filepath.h>
#include <utils/textutils.h>
namespace Utils { class ProcessHandle; }
@@ -326,7 +327,7 @@ public:
public:
LocationType type = UnknownLocation;
Utils::FilePath fileName;
int lineNumber = 0;
Utils::Text::Position textPosition;
quint64 address = 0;
};

View File

@@ -1211,9 +1211,9 @@ void GdbEngine::handleStopResponse(const GdbMi &data)
if (Breakpoint bp = breakHandler()->findBreakpointByResponseId(nr)) {
const FilePath &bpFileName = bp->fileName();
if (!bpFileName.isEmpty())
bp->setMarkerFileAndLine(bpFileName, lineNumber);
bp->setMarkerFileAndPosition(bpFileName, {lineNumber, -1});
else if (!fileName.isEmpty())
bp->setMarkerFileAndLine(fileName, lineNumber);
bp->setMarkerFileAndPosition(fileName, {lineNumber, -1});
}
}
@@ -1946,13 +1946,13 @@ void GdbEngine::executeRunToLine(const ContextData &data)
CHECK_STATE(InferiorStopOk);
setTokenBarrier();
notifyInferiorRunRequested();
showStatusMessage(Tr::tr("Run to line %1 requested...").arg(data.lineNumber), 5000);
showStatusMessage(Tr::tr("Run to line %1 requested...").arg(data.textPosition.line), 5000);
#if 1
QString loc;
if (data.address)
loc = addressSpec(data.address);
else
loc = '"' + breakLocation(data.fileName) + '"' + ':' + QString::number(data.lineNumber);
loc = '"' + breakLocation(data.fileName) + '"' + ':' + QString::number(data.textPosition.line);
runCommand({"tbreak " + loc});
runCommand({"continue", NativeCommand|RunRequest, CB(handleExecuteRunToLine)});
@@ -1980,7 +1980,7 @@ void GdbEngine::executeJumpToLine(const ContextData &data)
if (data.address)
loc = addressSpec(data.address);
else
loc = '"' + breakLocation(data.fileName) + '"' + ':' + QString::number(data.lineNumber);
loc = '"' + breakLocation(data.fileName) + '"' + ':' + QString::number(data.textPosition.line);
runCommand({"tbreak " + loc});
notifyInferiorRunRequested();
@@ -2086,7 +2086,7 @@ QString GdbEngine::breakpointLocation(const BreakpointParameters &data)
// The argument is simply a C-quoted version of the argument to the
// non-MI "break" command, including the "original" quoting it wants.
return "\"\\\"" + GdbMi::escapeCString(fileName) + "\\\":"
+ QString::number(data.lineNumber) + '"';
+ QString::number(data.textPosition.line) + '"';
}
QString GdbEngine::breakpointLocation2(const BreakpointParameters &data)
@@ -2097,7 +2097,7 @@ QString GdbEngine::breakpointLocation2(const BreakpointParameters &data)
const QString fileName = usage == BreakpointUseFullPath
? data.fileName.path() : breakLocation(data.fileName);
return GdbMi::escapeCString(fileName) + ':' + QString::number(data.lineNumber);
return GdbMi::escapeCString(fileName) + ':' + QString::number(data.textPosition.line);
}
void GdbEngine::handleInsertInterpreterBreakpoint(const DebuggerResponse &response,
@@ -2236,7 +2236,7 @@ void GdbEngine::handleBreakInsert1(const DebuggerResponse &response, const Break
// Older version of gdb don't know the -a option to set tracepoints
// ^error,msg="mi_cmd_break_insert: Unknown option ``a''"
const QString fileName = bp->fileName().toString();
const int lineNumber = bp->lineNumber();
const int lineNumber = bp->textPosition().line;
DebuggerCommand cmd("trace \"" + GdbMi::escapeCString(fileName) + "\":"
+ QString::number(lineNumber),
NeedsTemporaryStop);

View File

@@ -416,7 +416,7 @@ void LldbEngine::executeRunToLine(const ContextData &data)
notifyInferiorRunRequested();
DebuggerCommand cmd("executeRunToLocation");
cmd.arg("file", data.fileName.path());
cmd.arg("line", data.lineNumber);
cmd.arg("line", data.textPosition.line);
cmd.arg("address", data.address);
runCommand(cmd);
}
@@ -433,7 +433,7 @@ void LldbEngine::executeJumpToLine(const ContextData &data)
{
DebuggerCommand cmd("executeJumpToLocation");
cmd.arg("file", data.fileName.path());
cmd.arg("line", data.lineNumber);
cmd.arg("line", data.textPosition.line);
cmd.arg("address", data.address);
runCommand(cmd);
}
@@ -561,7 +561,7 @@ void LldbEngine::updateBreakpointData(const Breakpoint &bp, const GdbMi &bkpt, b
bp->setCondition(fromHex(bkpt["condition"].data()));
bp->setHitCount(bkpt["hitcount"].toInt());
bp->setFileName(FilePath::fromUserInput(bkpt["file"].data()));
bp->setLineNumber(bkpt["line"].toInt());
bp->setTextPosition({bkpt["line"].toInt(), -1});
GdbMi locations = bkpt["locations"];
const int numChild = locations.childCount();
@@ -574,7 +574,7 @@ void LldbEngine::updateBreakpointData(const Breakpoint &bp, const GdbMi &bkpt, b
loc->params.address = location["addr"].toAddress();
loc->params.functionName = location["function"].data();
loc->params.fileName = FilePath::fromUserInput(location["file"].data());
loc->params.lineNumber = location["line"].toInt();
loc->params.textPosition.line = location["line"].toInt();
loc->displayName = QString("%1.%2").arg(bp->responseId()).arg(locid);
}
bp->setPending(false);

View File

@@ -220,7 +220,7 @@ void PdbEngine::insertBreakpoint(const Breakpoint &bp)
if (params.type == BreakpointByFunction)
loc = params.functionName;
else
loc = params.fileName.toString() + ':' + QString::number(params.lineNumber);
loc = params.fileName.toString() + ':' + QString::number(params.textPosition.line);
postDirectCommand("break " + loc);
}
@@ -476,7 +476,7 @@ void PdbEngine::handleOutput2(const QString &data)
QTC_ASSERT(bp, continue);
bp->setResponseId(bpnr);
bp->setFileName(fileName);
bp->setLineNumber(lineNumber);
bp->setTextPosition({lineNumber, -1});
bp->adjustMarker();
bp->setPending(false);
notifyBreakpointInsertOk(bp);

View File

@@ -603,10 +603,10 @@ void QmlEngine::executeRunToLine(const ContextData &data)
{
QTC_ASSERT(state() == InferiorStopOk, qDebug() << state());
showStatusMessage(Tr::tr("Run to line %1 (%2) requested...")
.arg(data.lineNumber)
.arg(data.textPosition.line)
.arg(data.fileName.toString()),
5000);
d->setBreakpoint(SCRIPTREGEXP, data.fileName.toString(), true, data.lineNumber);
d->setBreakpoint(SCRIPTREGEXP, data.fileName.toString(), true, data.textPosition.line);
clearExceptionSelection();
d->continueDebugging(Continue);
@@ -658,7 +658,7 @@ void QmlEngine::insertBreakpoint(const Breakpoint &bp)
} else if (requested.type == BreakpointByFileAndLine) {
d->setBreakpoint(SCRIPTREGEXP, requested.fileName.toString(),
requested.enabled, requested.lineNumber, 0,
requested.enabled, requested.textPosition.line, 0,
requested.condition, requested.ignoreCount);
} else if (requested.type == BreakpointOnQmlSignalEmit) {
@@ -716,7 +716,7 @@ void QmlEngine::updateBreakpoint(const Breakpoint &bp)
} else {
d->clearBreakpoint(bp);
d->setBreakpoint(SCRIPTREGEXP, requested.fileName.toString(),
requested.enabled, requested.lineNumber, 0,
requested.enabled, requested.textPosition.line, 0,
requested.condition, requested.ignoreCount);
d->breakpointsSync.insert(d->sequence, bp);
}
@@ -1727,7 +1727,7 @@ void QmlEnginePrivate::messageReceived(const QByteArray &data)
//The breakpoint requested line should be same as
//actual line
if (bp && bp->state() != BreakpointInserted) {
bp->setLineNumber(line);
bp->setTextPosition({line, -1});
bp->setPending(false);
engine->notifyBreakpointInsertOk(bp);
}
@@ -1865,7 +1865,7 @@ void QmlEnginePrivate::messageReceived(const QByteArray &data)
setBreakpoint(SCRIPTREGEXP,
params.fileName.toString(),
params.enabled,
params.lineNumber,
params.textPosition.line,
newColumn,
params.condition,
params.ignoreCount);
@@ -1889,7 +1889,7 @@ void QmlEnginePrivate::messageReceived(const QByteArray &data)
bp->setFunctionName(invocationText);
}
if (bp->state() != BreakpointInserted) {
bp->setLineNumber(breakData.value("sourceLine").toInt() + 1);
bp->setTextPosition({breakData.value("sourceLine").toInt() + 1, -1});
bp->setPending(false);
engine->notifyBreakpointInsertOk(bp);
}

View File

@@ -315,14 +315,14 @@ ContextData getLocationContext(TextDocument *document, int lineNumber)
if (ln > 0) {
data.type = LocationByFile;
data.fileName = Utils::FilePath::fromString(fileName);
data.lineNumber = ln;
data.textPosition.line = ln;
}
}
}
} else {
data.type = LocationByFile;
data.fileName = document->filePath();
data.lineNumber = lineNumber;
data.textPosition.line = lineNumber;
}
return data;
}
@@ -381,13 +381,13 @@ static void setValueAnnotationsHelper(BaseTextEditor *textEditor,
if (!cppDocument) // For non-C++ documents.
return;
const int firstLine = firstRelevantLine(cppDocument, loc.lineNumber(), 1);
const int firstLine = firstRelevantLine(cppDocument, loc.textPosition().line, 1);
if (firstLine < 1)
return;
CPlusPlus::ExpressionUnderCursor expressionUnderCursor(cppDocument->languageFeatures());
QTextCursor tc = widget->textCursor();
for (int lineNumber = loc.lineNumber(); lineNumber >= firstLine; --lineNumber) {
for (int lineNumber = loc.textPosition().line; lineNumber >= firstLine; --lineNumber) {
const QTextBlock block = textDocument->document()->findBlockByNumber(lineNumber - 1);
tc.setPosition(block.position());
for (; !tc.atBlockEnd(); tc.movePosition(QTextCursor::NextCharacter)) {

View File

@@ -359,7 +359,7 @@ void UvscEngine::insertBreakpoint(const Breakpoint &bp)
// Add file name.
expression += "\\" + requested.fileName.toString();
// Add line number.
expression += "\\" + QString::number(requested.lineNumber);
expression += "\\" + QString::number(requested.textPosition.line);
}
handleInsertBreakpoint(expression, bp);
@@ -777,7 +777,7 @@ void UvscEngine::handleInsertBreakpoint(const QString &exp, const Breakpoint &bp
bp->setPending(false);
bp->setResponseId(QString::number(tickMark));
bp->setAddress(address);
bp->setLineNumber(line);
bp->setTextPosition(Text::Position{int(line), -1});
bp->setFileName(FilePath::fromString(fileName));
bp->setFunctionName(function);
notifyBreakpointInsertOk(bp);