Beispiel #1
0
DebugPanel::DebugPanel(QWidget *parent) :
    QDockWidget(parent),
    ui(new Ui::DebugPanel)
{
    ui->setupUi(this);

    ui->breakpointTableWidget->setShowGrid(false);

    connect(ui->runButton, SIGNAL(toggled(bool)),
            this, SLOT(runToggle(bool)));
    connect(ui->pauseButton, SIGNAL(released()),
            this, SLOT(pause()));
    connect(ui->continueButton, SIGNAL(released()),
            this, SLOT(continueDebug()));
    connect(ui->nextButton, SIGNAL(released()),
            this, SLOT(next()));
    connect(ui->newBreakpointToolButton, SIGNAL(released()),
            this, SLOT(newBreakpoint()));
    connect(ui->deleteBreakpointToolButton, SIGNAL(released()),
            this, SLOT(deleteBreakpoint()));

    connect(ui->breakpointTableWidget, SIGNAL(cellChanged(int,int)),
            this, SLOT(cellChanged(int,int)));
    connect(ui->breakpointTableWidget, SIGNAL(currentCellChanged(int,int,int,int)),
            this, SLOT(currentCellChanged(int,int,int,int)));
}
Beispiel #2
0
/*!
  Delete all a breakpoint.
  Slot activated when mpDeleteAllBreakpointsAction triggered signal is raised.
  */
void BreakpointsTreeView::deleteAllBreakpoints()
{
  int i = 0;
  BreakpointTreeItem *pRootBreakpointTreeItem = mpBreakpointsWidget->getBreakpointsTreeModel()->getRootBreakpointTreeItem();

  while(i < pRootBreakpointTreeItem->getChildren().size())
  {
    deleteBreakpoint(pRootBreakpointTreeItem->child(i));
    i = 0;  //Restart iteration
  }
}
Beispiel #3
0
/*!
  Defines the actions used by the BreakpointsTreeView context menu.
  */
void BreakpointsTreeView::createActions()
{
  /* Go to file action */
  mpGotoFileAction = new QAction(QIcon(":/Resources/icons/next.svg"), tr("Go to File"), this);
  mpGotoFileAction->setStatusTip(tr("Goto file location"));
  connect(mpGotoFileAction, SIGNAL(triggered()), SLOT(gotoFile()));
  /* Add breakpoint action */
  mpAddBreakpointAction = new QAction(QIcon(":/Resources/icons/add-icon.svg"), Helper::add, this);
  mpAddBreakpointAction->setStatusTip(tr("Adds a breakpoint"));
  connect(mpAddBreakpointAction, SIGNAL(triggered()), SLOT(addBreakpoint()));
  /* Edit breakpoint action */
  mpEditBreakpointAction = new QAction(QIcon(":/Resources/icons/edit-icon.svg"), Helper::edit, this);
  mpEditBreakpointAction->setStatusTip(tr("Edits a breakpoint"));
  connect(mpEditBreakpointAction, SIGNAL(triggered()), SLOT(editBreakpoint()));
  /* Remove breakpoint action */
  mpDeleteBreakpointAction = new QAction(QIcon(":/Resources/icons/delete.svg"), Helper::deleteStr, this);
  mpDeleteBreakpointAction->setStatusTip(tr("Deletes a breakpoint"));
  connect(mpDeleteBreakpointAction, SIGNAL(triggered()), SLOT(deleteBreakpoint()));
  /* remove all breakpoints action */
  mpDeleteAllBreakpointsAction = new QAction(tr("Delete All"), this);
  mpDeleteAllBreakpointsAction->setStatusTip(tr("Deletes all the breakpoints"));
  connect(mpDeleteAllBreakpointsAction, SIGNAL(triggered()), SLOT(deleteAllBreakpoints()));
}
/*!
  \reimp
*/
void QScriptDebuggerAgent::positionChange(qint64 scriptId,
                                          int lineNumber, int columnNumber)
{
    Q_D(QScriptDebuggerAgent);
    if (engine()->processEventsInterval() == -1) {
        // see if it's time to call processEvents()
        if ((++d->statementCounter % 25000) == 0) {
            if (!d->processEventsTimer.isNull()) {
                if (d->processEventsTimer.elapsed() > 30) {
                    QCoreApplication::processEvents();
                    d->processEventsTimer.restart();
                }
            } else {
                d->processEventsTimer.start();
            }
        }
    }

    // check breakpoints
    {
        QList<int> lst = d->resolvedBreakpoints.value(scriptId);
        for (int i = 0; i < lst.size(); ++i) {
            int id = lst.at(i);
            QScriptBreakpointData &data = d->breakpoints[id];
            if (!data.isEnabled())
                continue;
            if (data.lineNumber() != lineNumber)
                continue;
            if (!data.condition().isEmpty()) {
                // ### careful, evaluate() can cause an exception
                // ### disable callbacks in nested evaluate?
                QScriptDebuggerAgentPrivate::State was = d->state;
                d->state = QScriptDebuggerAgentPrivate::NoState;
                QScriptValue ret = engine()->evaluate(
                    data.condition(),
                    QString::fromLatin1("Breakpoint %0 condition checker").arg(id));
                if (!ret.isError())
                    d->state = was;
                if (!ret.toBoolean())
                    continue;
            }
            if (!data.hit())
                continue;
            d->hitBreakpointId = id;
            d->state = QScriptDebuggerAgentPrivate::BreakpointState;
        }
    }

    switch (d->state) {
    case QScriptDebuggerAgentPrivate::NoState:
    case QScriptDebuggerAgentPrivate::SteppingOutState:
    case QScriptDebuggerAgentPrivate::ReturningByForceState:
        // Do nothing
        break;

    case QScriptDebuggerAgentPrivate::SteppingIntoState:
        if (--d->stepCount == 0) {
            d->state = QScriptDebuggerAgentPrivate::NoState;
            if (d->backend)
                d->backend->stepped(scriptId, lineNumber, columnNumber, QScriptValue());
        }
        break;

    case QScriptDebuggerAgentPrivate::SteppingOverState:
        if ((d->stepDepth > 0) || (--d->stepCount != 0))
            break;
        // fallthrough
    case QScriptDebuggerAgentPrivate::SteppedOverState:
        d->state = QScriptDebuggerAgentPrivate::NoState;
        if (d->backend)
            d->backend->stepped(scriptId, lineNumber, columnNumber, d->stepResult);
        break;

    case QScriptDebuggerAgentPrivate::SteppedOutState:
        d->state = QScriptDebuggerAgentPrivate::NoState;
        if (d->backend)
            d->backend->stepped(scriptId, lineNumber, columnNumber, d->stepResult);
        break;

    case QScriptDebuggerAgentPrivate::RunningToLocationState:
        if (((lineNumber == d->targetLineNumber) || (d->targetLineNumber == -1))
            && (scriptId == d->targetScriptId)) {
            d->state = QScriptDebuggerAgentPrivate::NoState;
            if (d->backend)
                d->backend->locationReached(scriptId, lineNumber, columnNumber);
        }
        break;

    case QScriptDebuggerAgentPrivate::InterruptingState:
        d->state = QScriptDebuggerAgentPrivate::NoState;
        if (d->backend)
            d->backend->interrupted(scriptId, lineNumber, columnNumber);
        break;

    case QScriptDebuggerAgentPrivate::BreakpointState:
        d->state = QScriptDebuggerAgentPrivate::NoState;
        if (d->backend)
            d->backend->breakpoint(scriptId, lineNumber, columnNumber, d->hitBreakpointId);
        if (d->breakpoints.value(d->hitBreakpointId).isSingleShot())
            deleteBreakpoint(d->hitBreakpointId);
        break;

    case QScriptDebuggerAgentPrivate::ReturnedByForceState:
        d->state = QScriptDebuggerAgentPrivate::NoState;
        if (d->backend)
            d->backend->forcedReturn(scriptId, lineNumber, columnNumber, d->returnValue);
        break;

    case QScriptDebuggerAgentPrivate::SteppedIntoState:
    case QScriptDebuggerAgentPrivate::ReachedLocationState:
    case QScriptDebuggerAgentPrivate::InterruptedState:
// ### deal with the case when code is evaluated while we're already paused
//        Q_ASSERT(false);
        break;
    }
}
	void DebugCLI::enterDebugger()
	{	
		setCurrentSource( (core->callStack) ? (core->callStack->filename()) : 0 );
		if (currentSource == NULL)
		{
			stepInto();
			return;
		}

		for (;;) {
			printIP();
			
			core->console << "(asdb) ";
			fflush(stdout);
			fgets(commandLine, kMaxCommandLine, stdin);

			commandLine[strlen(commandLine)-1] = 0;
			
			if (!commandLine[0]) {
				strcpy(commandLine, lastCommand);
			} else {
				strcpy(lastCommand, commandLine);
			}
				
			currentToken = commandLine;
		
			char *command = nextToken();
			int cmd = commandFor(command);

			switch (cmd) {
			case -1:
				// ambiguous, we already printed error message
				break;
			case CMD_INFO:
				info();
				break;
			case CMD_BREAK:
				breakpoint(nextToken());
				break;
			case CMD_DELETE:
				deleteBreakpoint(nextToken());
				break;
			case CMD_LIST:
				list(nextToken());
				break;
			case CMD_UNKNOWN:
				core->console << "Unknown command.\n";
				break;
			case CMD_QUIT:
				exit(0);
				break;
			case CMD_CONTINUE:
				return;
			case CMD_PRINT:
				print(nextToken());
				break;
			case CMD_NEXT:
				stepOver();
				return;
			case INFO_STACK_CMD:
				bt();
				break;
			case CMD_FINISH:
				stepOut();
				return;
			case CMD_STEP:
				stepInto();
				return;
			case CMD_SET:
				set();
				break;
			default:
				core->console << "Command not implemented.\n";
				break;
			}
		}
	}
Beispiel #6
0
/*!
  Deletes a breakpoint.
  Slot activated when mpDeleteBreakpointAction triggered signal is raised.
  */
void BreakpointsTreeView::deleteBreakpoint()
{
  deleteBreakpoint(getSelectedBreakpointTreeItem());
}