Commit 47b00e53 authored by Vlas Puhov's avatar Vlas Puhov
Browse files

Don't set the same breakpoint multiple times when starting.

It was implemented only for file:line cases, now function cases
supported too(e.g. main.cpp:10 and main). Also added unit test for it.

BUG: 270970
parent 6be3dbe5
......@@ -223,6 +223,13 @@ void BreakpointController::handleBreakpointListInitial(const GDBMI::ResultRecord
updateBreakpoint = b;
}
} else if (b->kind() == KDevelop::Breakpoint::CodeBreakpoint) {
QString condition;
if (mi_b.hasField("cond")) {
condition = mi_b["cond"].literal();
}
if (condition != b->condition())
continue;
QString location = mi_b["original-location"].literal();
kDebug() << "location" << location;
QRegExp rx("^(.+):(\\d+)$");
......@@ -232,6 +239,8 @@ void BreakpointController::handleBreakpointListInitial(const GDBMI::ResultRecord
} else {
kDebug() << "!=" << b->location();
}
} else if (location == b->location()) {
updateBreakpoint = b;
}
}
if (updateBreakpoint) break;
......
......@@ -1333,23 +1333,29 @@ void GdbTest::testPickupManuallyInsertedBreakpointOnlyOnce()
TestLaunchConfiguration cfg;
breakpoints()->addCodeBreakpoint(KUrl("debugee.cpp"), 31);
breakpoints()->addCodeBreakpoint(KUrl("debugee.cpp"), 21);
QVERIFY(session->startProgram(&cfg, m_iface));
//inject here, so it behaves similar like a command from .gdbinit
session->addCommandToFront(new GDBCommand(GDBMI::NonMI, "break debugee.cpp:32"));
session->addCommandToFront(new GDBCommand(GDBMI::NonMI, "break foo"));
WAIT_FOR_STATE(session, DebugSession::PausedState);
session->stepInto();
WAIT_FOR_STATE(session, DebugSession::PausedState);
QTest::qWait(1000); //wait for breakpoints update
QCOMPARE(breakpoints()->breakpoints().count(), 1);
QCOMPARE(breakpoints()->rowCount(), 1+1);
QCOMPARE(breakpoints()->breakpoints().count(), 2);
KDevelop::Breakpoint *b = breakpoints()->breakpoint(0);
QVERIFY(b);
QCOMPARE(b->line(), 31); //we start with 0, gdb with 1
QCOMPARE(b->url().url(), QString("debugee.cpp"));
b = breakpoints()->breakpoint(1);
QVERIFY(b);
QCOMPARE(b->line(), 21);
QCOMPARE(b->url().url(), QString("debugee.cpp"));
}
void GdbTest::testRunGdbScript()
......
Supports Markdown
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