Changeset View
Changeset View
Standalone View
Standalone View
debuggers/common/midebugsession.cpp
Show First 20 Lines • Show All 215 Lines • ▼ Show 20 Line(s) | 184 | { | |||
---|---|---|---|---|---|
216 | } | 216 | } | ||
217 | QString tty(m_tty->getSlave()); | 217 | QString tty(m_tty->getSlave()); | ||
218 | if (tty.isEmpty()) { | 218 | if (tty.isEmpty()) { | ||
219 | KMessageBox::information(qApp->activeWindow(), m_tty->lastError(), i18n("warning")); | 219 | KMessageBox::information(qApp->activeWindow(), m_tty->lastError(), i18n("warning")); | ||
220 | 220 | | |||
221 | m_tty.reset(nullptr); | 221 | m_tty.reset(nullptr); | ||
222 | return false; | 222 | return false; | ||
223 | } | 223 | } | ||
224 | queueCmd(new MICommand(InferiorTtySet, tty)); | 224 | addCommand(InferiorTtySet, tty); | ||
225 | 225 | | |||
226 | // Only dummy err here, actual erros have been checked already in the job and we don't get here if there were any | 226 | // Only dummy err here, actual erros have been checked already in the job and we don't get here if there were any | ||
227 | QString err; | 227 | QString err; | ||
228 | QString executable = iexec->executable(cfg, err).toLocalFile(); | 228 | QString executable = iexec->executable(cfg, err).toLocalFile(); | ||
229 | QStringList arguments = iexec->arguments(cfg, err); | 229 | QStringList arguments = iexec->arguments(cfg, err); | ||
230 | // Change the working directory to the correct one | 230 | // Change the working directory to the correct one | ||
231 | QString dir = iexec->workingDirectory(cfg).toLocalFile(); | 231 | QString dir = iexec->workingDirectory(cfg).toLocalFile(); | ||
232 | if (dir.isEmpty()) { | 232 | if (dir.isEmpty()) { | ||
233 | dir = QFileInfo(executable).absolutePath(); | 233 | dir = QFileInfo(executable).absolutePath(); | ||
234 | } | 234 | } | ||
235 | queueCmd(new MICommand(MI::EnvironmentCd, '"' + dir + '"')); | 235 | addCommand(EnvironmentCd, '"' + dir + '"'); | ||
236 | 236 | | |||
237 | // Set the environment variables | 237 | // Set the environment variables | ||
238 | EnvironmentGroupList l(KSharedConfig::openConfig()); | 238 | EnvironmentGroupList l(KSharedConfig::openConfig()); | ||
239 | QString envgrp = iexec->environmentGroup(cfg); | 239 | QString envgrp = iexec->environmentGroup(cfg); | ||
240 | if (envgrp.isEmpty()) { | 240 | if (envgrp.isEmpty()) { | ||
241 | qCWarning(DEBUGGERCOMMON) << i18n("No environment group specified, looks like a broken " | 241 | qCWarning(DEBUGGERCOMMON) << i18n("No environment group specified, looks like a broken " | ||
242 | "configuration, please check run configuration '%1'. " | 242 | "configuration, please check run configuration '%1'. " | ||
243 | "Using default environment group.", cfg->name()); | 243 | "Using default environment group.", cfg->name()); | ||
244 | envgrp = l.defaultGroup(); | 244 | envgrp = l.defaultGroup(); | ||
245 | } | 245 | } | ||
246 | for (const auto &envvar : l.createEnvironment(envgrp, {})) { | 246 | for (const auto &envvar : l.createEnvironment(envgrp, {})) { | ||
247 | queueCmd(new MICommand(MI::GdbSet, "environment " + envvar)); | 247 | addCommand(GdbSet, "environment " + envvar); | ||
248 | } | 248 | } | ||
249 | 249 | | |||
250 | // Set the run arguments | 250 | // Set the run arguments | ||
251 | if (!arguments.isEmpty()) | 251 | if (!arguments.isEmpty()) | ||
252 | queueCmd(new MICommand(MI::ExecArguments, KShell::joinArgs(arguments))); | 252 | addCommand(ExecArguments, KShell::joinArgs(arguments)); | ||
253 | 253 | | |||
254 | // Do other debugger specific config options and actually start the inferior program | 254 | // Do other debugger specific config options and actually start the inferior program | ||
255 | if (!execInferior(cfg, executable)) { | 255 | if (!execInferior(cfg, executable)) { | ||
256 | return false; | 256 | return false; | ||
257 | } | 257 | } | ||
258 | 258 | | |||
259 | QString config_startWith = cfg->config().readEntry(startWithEntry, QStringLiteral("ApplicationOutput")); | 259 | QString config_startWith = cfg->config().readEntry(startWithEntry, QStringLiteral("ApplicationOutput")); | ||
260 | if (config_startWith == "GdbConsole") { | 260 | if (config_startWith == "GdbConsole") { | ||
Show All 25 Lines | 273 | { | |||
286 | setDebuggerStateOn(s_appRunning); | 286 | setDebuggerStateOn(s_appRunning); | ||
287 | 287 | | |||
288 | // Currently, we always start debugger with a name of binary, | 288 | // Currently, we always start debugger with a name of binary, | ||
289 | // we might be connecting to a different binary completely, | 289 | // we might be connecting to a different binary completely, | ||
290 | // so cancel all symbol tables gdb has. | 290 | // so cancel all symbol tables gdb has. | ||
291 | // We can't omit application name from gdb invocation | 291 | // We can't omit application name from gdb invocation | ||
292 | // because for libtool binaries, we have no way to guess | 292 | // because for libtool binaries, we have no way to guess | ||
293 | // real binary name. | 293 | // real binary name. | ||
294 | queueCmd(new MICommand(MI::FileExecAndSymbols)); | 294 | addCommand(MI::FileExecAndSymbols); | ||
295 | 295 | | |||
296 | queueCmd(new MICommand(MI::TargetAttach, QString::number(pid), | 296 | addCommand(TargetAttach, QString::number(pid), | ||
297 | this, &MIDebugSession::handleTargetAttach, | 297 | this, &MIDebugSession::handleTargetAttach, | ||
298 | CmdHandlesError)); | 298 | CmdHandlesError); | ||
299 | 299 | | |||
300 | queueCmd(new SentinelCommand(breakpointController(), | 300 | addCommand(new SentinelCommand(breakpointController(), | ||
301 | &MIBreakpointController::initSendBreakpoints)); | 301 | &MIBreakpointController::initSendBreakpoints)); | ||
302 | 302 | | |||
303 | raiseEvent(connected_to_program); | 303 | raiseEvent(connected_to_program); | ||
304 | 304 | | |||
305 | emit raiseFramestackViews(); | 305 | emit raiseFramestackViews(); | ||
306 | 306 | | |||
307 | return true; | 307 | return true; | ||
308 | } | 308 | } | ||
Show All 15 Lines | 323 | { | |||
324 | if (debuggerStateIsOn(s_dbgNotStarted)) { | 324 | if (debuggerStateIsOn(s_dbgNotStarted)) { | ||
325 | // FIXME: use global launch configuration rather than nullptr | 325 | // FIXME: use global launch configuration rather than nullptr | ||
326 | if (!startDebugger(nullptr)) { | 326 | if (!startDebugger(nullptr)) { | ||
327 | return false; | 327 | return false; | ||
328 | } | 328 | } | ||
329 | } | 329 | } | ||
330 | 330 | | |||
331 | // FIXME: support non-local URLs | 331 | // FIXME: support non-local URLs | ||
332 | queueCmd(new MICommand(MI::FileExecAndSymbols, debugee.toLocalFile())); | 332 | addCommand(FileExecAndSymbols, debugee.toLocalFile()); | ||
333 | queueCmd(new MICommand(MI::NonMI, "core " + coreFile.toLocalFile(), | 333 | addCommand(NonMI, "core " + coreFile.toLocalFile(), | ||
334 | this, &MIDebugSession::handleCoreFile, CmdHandlesError)); | 334 | this, &MIDebugSession::handleCoreFile, | ||
335 | CmdHandlesError); | ||||
335 | 336 | | |||
336 | raiseEvent(connected_to_program); | 337 | raiseEvent(connected_to_program); | ||
337 | raiseEvent(program_state_changed); | 338 | raiseEvent(program_state_changed); | ||
338 | 339 | | |||
339 | return true; | 340 | return true; | ||
340 | } | 341 | } | ||
341 | 342 | | |||
342 | void MIDebugSession::handleCoreFile(const MI::ResultRecord& r) | 343 | void MIDebugSession::handleCoreFile(const MI::ResultRecord& r) | ||
▲ Show 20 Lines • Show All 169 Lines • ▼ Show 20 Line(s) | 504 | { | |||
512 | // Had we used plain 'run' command, restart for remote debugging simply | 513 | // Had we used plain 'run' command, restart for remote debugging simply | ||
513 | // would not work. | 514 | // would not work. | ||
514 | if (!debuggerStateIsOn(s_dbgNotStarted|s_shuttingDown)) { | 515 | if (!debuggerStateIsOn(s_dbgNotStarted|s_shuttingDown)) { | ||
515 | // FIXME: s_dbgBusy or m_debugger->isReady()? | 516 | // FIXME: s_dbgBusy or m_debugger->isReady()? | ||
516 | if (debuggerStateIsOn(s_dbgBusy)) { | 517 | if (debuggerStateIsOn(s_dbgBusy)) { | ||
517 | interruptDebugger(); | 518 | interruptDebugger(); | ||
518 | } | 519 | } | ||
519 | // The -exec-abort is not implemented in gdb | 520 | // The -exec-abort is not implemented in gdb | ||
520 | // queueCmd(new MICommand(MI::ExecAbort)); | 521 | // addCommand(ExecAbort); | ||
521 | queueCmd(new MICommand(MI::NonMI, "kill")); | 522 | addCommand(NonMI, "kill"); | ||
522 | } | 523 | } | ||
523 | run(); | 524 | run(); | ||
524 | } | 525 | } | ||
525 | 526 | | |||
526 | void MIDebugSession::stopDebugger() | 527 | void MIDebugSession::stopDebugger() | ||
527 | { | 528 | { | ||
528 | m_commandQueue->clear(); | 529 | m_commandQueue->clear(); | ||
529 | 530 | | |||
Show All 9 Lines | |||||
539 | if (!m_debugger->isReady()) { | 540 | if (!m_debugger->isReady()) { | ||
540 | qCDebug(DEBUGGERCOMMON) << "debugger busy on shutdown - interruping"; | 541 | qCDebug(DEBUGGERCOMMON) << "debugger busy on shutdown - interruping"; | ||
541 | interruptDebugger(); | 542 | interruptDebugger(); | ||
542 | } | 543 | } | ||
543 | 544 | | |||
544 | // If the app is attached then we release it here. This doesn't stop | 545 | // If the app is attached then we release it here. This doesn't stop | ||
545 | // the app running. | 546 | // the app running. | ||
546 | if (debuggerStateIsOn(s_attached)) { | 547 | if (debuggerStateIsOn(s_attached)) { | ||
547 | queueCmd(new MICommand(MI::TargetDetach)); | 548 | addCommand(TargetDetach); | ||
548 | emit debuggerUserCommandOutput("(gdb) detach\n"); | 549 | emit debuggerUserCommandOutput("(gdb) detach\n"); | ||
549 | } | 550 | } | ||
550 | 551 | | |||
551 | // Now try to stop debugger running. | 552 | // Now try to stop debugger running. | ||
552 | queueCmd(new MICommand(MI::GdbExit)); | 553 | addCommand(GdbExit); | ||
553 | emit debuggerUserCommandOutput("(gdb) quit"); | 554 | emit debuggerUserCommandOutput("(gdb) quit"); | ||
554 | 555 | | |||
555 | // We cannot wait forever, kill gdb after 5 seconds if it's not yet quit | 556 | // We cannot wait forever, kill gdb after 5 seconds if it's not yet quit | ||
556 | QPointer<MIDebugSession> guarded_this(this); | 557 | QPointer<MIDebugSession> guarded_this(this); | ||
557 | QTimer::singleShot(5000, [guarded_this](){ | 558 | QTimer::singleShot(5000, [guarded_this](){ | ||
558 | if (guarded_this) { | 559 | if (guarded_this) { | ||
559 | if (!guarded_this->debuggerStateIsOn(s_programExited) | 560 | if (!guarded_this->debuggerStateIsOn(s_programExited) | ||
560 | && guarded_this->debuggerStateIsOn(s_shuttingDown)) { | 561 | && guarded_this->debuggerStateIsOn(s_shuttingDown)) { | ||
Show All 10 Lines | |||||
571 | 572 | | |||
572 | void MIDebugSession::interruptDebugger() | 573 | void MIDebugSession::interruptDebugger() | ||
573 | { | 574 | { | ||
574 | Q_ASSERT(m_debugger); | 575 | Q_ASSERT(m_debugger); | ||
575 | 576 | | |||
576 | // Explicitly send the interrupt in case something went wrong with the usual | 577 | // Explicitly send the interrupt in case something went wrong with the usual | ||
577 | // ensureGdbListening logic. | 578 | // ensureGdbListening logic. | ||
578 | m_debugger->interrupt(); | 579 | m_debugger->interrupt(); | ||
579 | queueCmd(new MICommand(MI::ExecInterrupt, QString(), CmdInterrupt)); | 580 | addCommand(ExecInterrupt, QString(), CmdInterrupt); | ||
580 | } | 581 | } | ||
581 | 582 | | |||
582 | void MIDebugSession::run() | 583 | void MIDebugSession::run() | ||
583 | { | 584 | { | ||
584 | if (debuggerStateIsOn(s_appNotStarted|s_dbgNotStarted|s_shuttingDown)) | 585 | if (debuggerStateIsOn(s_appNotStarted|s_dbgNotStarted|s_shuttingDown)) | ||
585 | return; | 586 | return; | ||
586 | 587 | | |||
587 | queueCmd(new MICommand(MI::ExecContinue, QString(), CmdMaybeStartsRunning)); | 588 | addCommand(MI::ExecContinue, QString(), CmdMaybeStartsRunning); | ||
588 | } | 589 | } | ||
589 | 590 | | |||
590 | void MIDebugSession::runToCursor() | 591 | void MIDebugSession::runToCursor() | ||
591 | { | 592 | { | ||
592 | if (IDocument* doc = ICore::self()->documentController()->activeDocument()) { | 593 | if (IDocument* doc = ICore::self()->documentController()->activeDocument()) { | ||
593 | KTextEditor::Cursor cursor = doc->cursorPosition(); | 594 | KTextEditor::Cursor cursor = doc->cursorPosition(); | ||
594 | if (cursor.isValid()) | 595 | if (cursor.isValid()) | ||
595 | runUntil(doc->url(), cursor.line() + 1); | 596 | runUntil(doc->url(), cursor.line() + 1); | ||
Show All 9 Lines | 601 | { | |||
605 | } | 606 | } | ||
606 | } | 607 | } | ||
607 | 608 | | |||
608 | void MIDebugSession::stepOver() | 609 | void MIDebugSession::stepOver() | ||
609 | { | 610 | { | ||
610 | if (debuggerStateIsOn(s_appNotStarted|s_shuttingDown)) | 611 | if (debuggerStateIsOn(s_appNotStarted|s_shuttingDown)) | ||
611 | return; | 612 | return; | ||
612 | 613 | | |||
613 | queueCmd(new MICommand(MI::ExecNext, QString(), CmdMaybeStartsRunning | CmdTemporaryRun)); | 614 | addCommand(ExecNext, QString(), CmdMaybeStartsRunning | CmdTemporaryRun); | ||
614 | } | 615 | } | ||
615 | 616 | | |||
616 | void MIDebugSession::stepIntoInstruction() | 617 | void MIDebugSession::stepIntoInstruction() | ||
617 | { | 618 | { | ||
618 | if (debuggerStateIsOn(s_appNotStarted|s_shuttingDown)) | 619 | if (debuggerStateIsOn(s_appNotStarted|s_shuttingDown)) | ||
619 | return; | 620 | return; | ||
620 | 621 | | |||
621 | queueCmd(new MICommand(MI::ExecStepInstruction, QString(), | 622 | addCommand(ExecStepInstruction, QString(), | ||
622 | CmdMaybeStartsRunning | CmdTemporaryRun)); | 623 | CmdMaybeStartsRunning | CmdTemporaryRun); | ||
623 | } | 624 | } | ||
624 | 625 | | |||
625 | void MIDebugSession::stepInto() | 626 | void MIDebugSession::stepInto() | ||
626 | { | 627 | { | ||
627 | if (debuggerStateIsOn(s_appNotStarted|s_shuttingDown)) | 628 | if (debuggerStateIsOn(s_appNotStarted|s_shuttingDown)) | ||
628 | return; | 629 | return; | ||
629 | 630 | | |||
630 | queueCmd(new MICommand(MI::ExecStep, QString(), CmdMaybeStartsRunning | CmdTemporaryRun)); | 631 | addCommand(ExecStep, QString(), CmdMaybeStartsRunning | CmdTemporaryRun); | ||
631 | } | 632 | } | ||
632 | 633 | | |||
633 | void MIDebugSession::stepOverInstruction() | 634 | void MIDebugSession::stepOverInstruction() | ||
634 | { | 635 | { | ||
635 | if (debuggerStateIsOn(s_appNotStarted|s_shuttingDown)) | 636 | if (debuggerStateIsOn(s_appNotStarted|s_shuttingDown)) | ||
636 | return; | 637 | return; | ||
637 | 638 | | |||
638 | queueCmd(new MICommand(MI::ExecNextInstruction, QString(), | 639 | addCommand(ExecNextInstruction, QString(), | ||
639 | CmdMaybeStartsRunning | CmdTemporaryRun)); | 640 | CmdMaybeStartsRunning | CmdTemporaryRun); | ||
640 | } | 641 | } | ||
641 | 642 | | |||
642 | void MIDebugSession::stepOut() | 643 | void MIDebugSession::stepOut() | ||
643 | { | 644 | { | ||
644 | if (debuggerStateIsOn(s_appNotStarted|s_shuttingDown)) | 645 | if (debuggerStateIsOn(s_appNotStarted|s_shuttingDown)) | ||
645 | return; | 646 | return; | ||
646 | 647 | | |||
647 | queueCmd(new MICommand(MI::ExecFinish, QString(), CmdMaybeStartsRunning | CmdTemporaryRun)); | 648 | addCommand(ExecFinish, QString(), CmdMaybeStartsRunning | CmdTemporaryRun); | ||
648 | } | 649 | } | ||
649 | 650 | | |||
650 | void MIDebugSession::runUntil(const QUrl& url, int line) | 651 | void MIDebugSession::runUntil(const QUrl& url, int line) | ||
651 | { | 652 | { | ||
652 | if (debuggerStateIsOn(s_dbgNotStarted|s_shuttingDown)) | 653 | if (debuggerStateIsOn(s_dbgNotStarted|s_shuttingDown)) | ||
653 | return; | 654 | return; | ||
654 | 655 | | |||
655 | if (!url.isValid()) { | 656 | if (!url.isValid()) { | ||
656 | queueCmd(new MICommand(MI::ExecUntil, QString::number(line), | 657 | addCommand(ExecUntil, QString::number(line), | ||
657 | CmdMaybeStartsRunning | CmdTemporaryRun)); | 658 | CmdMaybeStartsRunning | CmdTemporaryRun); | ||
658 | } else { | 659 | } else { | ||
659 | queueCmd(new MICommand(MI::ExecUntil, | 660 | addCommand(ExecUntil, | ||
660 | QString("%1:%2").arg(url.toLocalFile()).arg(line), | 661 | QString("%1:%2").arg(url.toLocalFile()).arg(line), | ||
661 | CmdMaybeStartsRunning | CmdTemporaryRun)); | 662 | CmdMaybeStartsRunning | CmdTemporaryRun); | ||
662 | } | 663 | } | ||
663 | } | 664 | } | ||
664 | 665 | | |||
665 | void MIDebugSession::runUntil(const QString& address) | 666 | void MIDebugSession::runUntil(const QString& address) | ||
666 | { | 667 | { | ||
667 | if (debuggerStateIsOn(s_dbgNotStarted|s_shuttingDown)) | 668 | if (debuggerStateIsOn(s_dbgNotStarted|s_shuttingDown)) | ||
668 | return; | 669 | return; | ||
669 | 670 | | |||
670 | if (!address.isEmpty()) { | 671 | if (!address.isEmpty()) { | ||
671 | queueCmd(new MICommand(MI::ExecUntil, QString("*%1").arg(address), | 672 | addCommand(ExecUntil, QString("*%1").arg(address), | ||
672 | CmdMaybeStartsRunning | CmdTemporaryRun)); | 673 | CmdMaybeStartsRunning | CmdTemporaryRun); | ||
673 | } | 674 | } | ||
674 | } | 675 | } | ||
675 | 676 | | |||
676 | void MIDebugSession::jumpTo(const QUrl& url, int line) | 677 | void MIDebugSession::jumpTo(const QUrl& url, int line) | ||
677 | { | 678 | { | ||
678 | if (debuggerStateIsOn(s_dbgNotStarted|s_shuttingDown)) | 679 | if (debuggerStateIsOn(s_dbgNotStarted|s_shuttingDown)) | ||
679 | return; | 680 | return; | ||
680 | 681 | | |||
681 | if (url.isValid()) { | 682 | if (url.isValid()) { | ||
682 | queueCmd(new MICommand(MI::NonMI, | 683 | addCommand(NonMI, QString("tbreak %1:%2").arg(url.toLocalFile()).arg(line)); | ||
683 | QString("tbreak %1:%2").arg(url.toLocalFile()).arg(line))); | 684 | addCommand(NonMI, QString("jump %1:%2").arg(url.toLocalFile()).arg(line)); | ||
684 | queueCmd(new MICommand(MI::NonMI, | | |||
685 | QString("jump %1:%2").arg(url.toLocalFile()).arg(line))); | | |||
686 | } | 685 | } | ||
687 | } | 686 | } | ||
688 | 687 | | |||
689 | void MIDebugSession::jumpToMemoryAddress(const QString& address) | 688 | void MIDebugSession::jumpToMemoryAddress(const QString& address) | ||
690 | { | 689 | { | ||
691 | if (debuggerStateIsOn(s_dbgNotStarted|s_shuttingDown)) | 690 | if (debuggerStateIsOn(s_dbgNotStarted|s_shuttingDown)) | ||
692 | return; | 691 | return; | ||
693 | 692 | | |||
694 | if (!address.isEmpty()) { | 693 | if (!address.isEmpty()) { | ||
695 | queueCmd(new MICommand(MI::NonMI, QString("tbreak *%1").arg(address))); | 694 | addCommand(NonMI, QString("tbreak *%1").arg(address)); | ||
696 | queueCmd(new MICommand(MI::NonMI, QString("jump *%1").arg(address))); | 695 | addCommand(NonMI, QString("jump *%1").arg(address)); | ||
697 | } | 696 | } | ||
698 | } | 697 | } | ||
699 | 698 | | |||
700 | void MIDebugSession::addUserCommand(const QString& cmd) | 699 | void MIDebugSession::addUserCommand(const QString& cmd) | ||
701 | { | 700 | { | ||
702 | queueCmd(new UserCommand(MI::NonMI, cmd)); | 701 | queueCmd(new UserCommand(MI::NonMI, cmd)); | ||
703 | 702 | | |||
704 | // User command can theoreticall modify absolutely everything, | 703 | // User command can theoreticall modify absolutely everything, | ||
705 | // so need to force a reload. | 704 | // so need to force a reload. | ||
706 | 705 | | |||
707 | // We can do it right now, and don't wait for user command to finish | 706 | // We can do it right now, and don't wait for user command to finish | ||
708 | // since commands used to reload all view will be executed after | 707 | // since commands used to reload all view will be executed after | ||
709 | // user command anyway. | 708 | // user command anyway. | ||
710 | if (!debuggerStateIsOn(s_appNotStarted) && !debuggerStateIsOn(s_programExited)) | 709 | if (!debuggerStateIsOn(s_appNotStarted) && !debuggerStateIsOn(s_programExited)) | ||
711 | raiseEvent(program_state_changed); | 710 | raiseEvent(program_state_changed); | ||
712 | } | 711 | } | ||
713 | 712 | | |||
713 | MICommand *MIDebugSession::createCommand(CommandType type, const QString& arguments, | ||||
714 | CommandFlags flags) const | ||||
715 | { | ||||
716 | return new MICommand(type, arguments, flags); | ||||
717 | } | ||||
718 | | ||||
714 | void MIDebugSession::addCommand(MICommand* cmd) | 719 | void MIDebugSession::addCommand(MICommand* cmd) | ||
715 | { | 720 | { | ||
716 | queueCmd(cmd); | 721 | queueCmd(cmd); | ||
717 | } | 722 | } | ||
718 | 723 | | |||
719 | void MIDebugSession::addCommand(MI::CommandType type, const QString& str) | 724 | void MIDebugSession::addCommand(MI::CommandType type, const QString& arguments, MI::CommandFlags flags) | ||
725 | { | ||||
726 | queueCmd(createCommand(type, arguments, flags)); | ||||
727 | } | ||||
728 | | ||||
729 | void MIDebugSession::addCommand(MI::CommandType type, const QString& arguments, | ||||
730 | MI::MICommandHandler *handler, | ||||
731 | MI::CommandFlags flags) | ||||
720 | { | 732 | { | ||
721 | queueCmd(new MICommand(type, str)); | 733 | auto cmd = createCommand(type, arguments, flags); | ||
734 | cmd->setHandler(handler); | ||||
735 | queueCmd(cmd); | ||||
736 | } | ||||
737 | | ||||
738 | void MIDebugSession::addCommand(MI::CommandType type, const QString& arguments, | ||||
739 | const MI::FunctionCommandHandler::Function& callback, | ||||
740 | MI::CommandFlags flags) | ||||
741 | { | ||||
742 | auto cmd = createCommand(type, arguments, flags); | ||||
743 | cmd->setHandler(callback); | ||||
744 | queueCmd(cmd); | ||||
722 | } | 745 | } | ||
723 | 746 | | |||
724 | // Fairly obvious that we'll add whatever command you give me to a queue | 747 | // Fairly obvious that we'll add whatever command you give me to a queue | ||
725 | // Not quite so obvious though is that if we are going to run again. then any | 748 | // Not quite so obvious though is that if we are going to run again. then any | ||
726 | // information requests become redundent and must be removed. | 749 | // information requests become redundent and must be removed. | ||
727 | // We also try and run whatever command happens to be at the head of | 750 | // We also try and run whatever command happens to be at the head of | ||
728 | // the queue. | 751 | // the queue. | ||
729 | void MIDebugSession::queueCmd(MICommand *cmd) | 752 | void MIDebugSession::queueCmd(MICommand *cmd) | ||
▲ Show 20 Lines • Show All 177 Lines • ▼ Show 20 Line(s) | 927 | { | |||
907 | m_stateReloadInProgress = false; | 930 | m_stateReloadInProgress = false; | ||
908 | 931 | | |||
909 | executeCmd(); | 932 | executeCmd(); | ||
910 | if (m_debugger->isReady()) { | 933 | if (m_debugger->isReady()) { | ||
911 | /* There is nothing in the command queue and no command is currently executing. */ | 934 | /* There is nothing in the command queue and no command is currently executing. */ | ||
912 | if (debuggerStateIsOn(s_automaticContinue)) { | 935 | if (debuggerStateIsOn(s_automaticContinue)) { | ||
913 | if (!debuggerStateIsOn(s_appRunning)) { | 936 | if (!debuggerStateIsOn(s_appRunning)) { | ||
914 | qCDebug(DEBUGGERCOMMON) << "Posting automatic continue"; | 937 | qCDebug(DEBUGGERCOMMON) << "Posting automatic continue"; | ||
915 | queueCmd(new MICommand(MI::ExecContinue, QString(), CmdMaybeStartsRunning)); | 938 | addCommand(ExecContinue, QString(), CmdMaybeStartsRunning); | ||
916 | } | 939 | } | ||
917 | setDebuggerStateOff(s_automaticContinue); | 940 | setDebuggerStateOff(s_automaticContinue); | ||
918 | return; | 941 | return; | ||
919 | } | 942 | } | ||
920 | 943 | | |||
921 | if (m_stateReloadNeeded && !debuggerStateIsOn(s_appRunning)) { | 944 | if (m_stateReloadNeeded && !debuggerStateIsOn(s_appRunning)) { | ||
922 | qCDebug(DEBUGGERCOMMON) << "Finishing program stop"; | 945 | qCDebug(DEBUGGERCOMMON) << "Finishing program stop"; | ||
923 | // Set to false right now, so that if 'actOnProgramPauseMI_part2' | 946 | // Set to false right now, so that if 'actOnProgramPauseMI_part2' | ||
▲ Show 20 Lines • Show All 74 Lines • ▼ Show 20 Line(s) | 996 | { | |||
998 | if (reason == "watchpoint-scope") { | 1021 | if (reason == "watchpoint-scope") { | ||
999 | QString number = r["wpnum"].literal(); | 1022 | QString number = r["wpnum"].literal(); | ||
1000 | 1023 | | |||
1001 | // FIXME: shuld remove this watchpoint | 1024 | // FIXME: shuld remove this watchpoint | ||
1002 | // But first, we should consider if removing all | 1025 | // But first, we should consider if removing all | ||
1003 | // watchpoinst on program exit is the right thing to | 1026 | // watchpoinst on program exit is the right thing to | ||
1004 | // do. | 1027 | // do. | ||
1005 | 1028 | | |||
1006 | queueCmd(new MICommand(MI::ExecContinue, QString(), CmdMaybeStartsRunning)); | 1029 | addCommand(ExecContinue, QString(), CmdMaybeStartsRunning); | ||
1007 | 1030 | | |||
1008 | m_stateReloadNeeded = false; | 1031 | m_stateReloadNeeded = false; | ||
1009 | return; | 1032 | return; | ||
1010 | } | 1033 | } | ||
1011 | 1034 | | |||
1012 | bool wasInterrupt = false; | 1035 | bool wasInterrupt = false; | ||
1013 | 1036 | | |||
1014 | if (reason == "signal-received") { | 1037 | if (reason == "signal-received") { | ||
▲ Show 20 Lines • Show All 254 Lines • Show Last 20 Lines |