Example #1
0
void ExtScript::readConfiguration()
{
    AbstractExtItem::readConfiguration();

    for (int i = directories().count() - 1; i >= 0; i--) {
        if (!QDir(directories().at(i))
                 .entryList(QDir::Files)
                 .contains(fileName()))
            continue;
        QSettings settings(
            QString("%1/%2").arg(directories().at(i)).arg(fileName()),
            QSettings::IniFormat);

        settings.beginGroup(QString("Desktop Entry"));
        setExecutable(settings.value(QString("Exec"), m_executable).toString());
        setPrefix(settings.value(QString("X-AW-Prefix"), m_prefix).toString());
        setStrRedirect(
            settings.value(QString("X-AW-Redirect"), strRedirect()).toString());
        // api == 3
        setFilters(settings.value(QString("X-AW-Filters"), m_filters)
                       .toString()
                       .split(QChar(','), QString::SkipEmptyParts));
        settings.endGroup();
    }

    // update for current API
    if ((apiVersion() > 0) && (apiVersion() < AWESAPI)) {
        qCWarning(LOG_LIB) << "Bump API version from" << apiVersion() << "to"
                           << AWESAPI;
        setApiVersion(AWESAPI);
        writeConfiguration();
    }
}
Example #2
0
void freeExec (void *addr)
{
    StgPtr p = (StgPtr)addr - 1;
    bdescr *bd = Bdescr((StgPtr)p);

    if ((bd->flags & BF_EXEC) == 0) {
        barf("freeExec: not executable");
    }

    if (*(StgPtr)p == 0) {
        barf("freeExec: already free?");
    }

    ACQUIRE_SM_LOCK;

    bd->gen_no -= *(StgPtr)p;
    *(StgPtr)p = 0;

    if (bd->gen_no == 0) {
        // Free the block if it is empty, but not if it is the block at
        // the head of the queue.
        if (bd != exec_block) {
            debugTrace(DEBUG_gc, "free exec block %p", bd->start);
            dbl_link_remove(bd, &exec_block);
            setExecutable(bd->start, bd->blocks * BLOCK_SIZE, rtsFalse);
            freeGroup(bd);
        } else {
            bd->free = bd->start;
        }
    }

    RELEASE_SM_LOCK
}
Example #3
0
void IdaFrontend::createSections(core::image::Image *image) {
    for (int i = 0; i < get_segm_qty(); i++) {
        segment_t *idaSegment = getnseg(i);

        assert(idaSegment != NULL);

        char segName[MAXSTR];
        ssize_t segNameSize = get_segm_name(idaSegment, segName, sizeof(segName) - 1);
        if(segNameSize < 0) {
            segName[0] = '\0';
        } else if(segNameSize > 0 && segName[0] == '_') {
            segName[0] = '.';
        }

        auto section = std::make_unique<core::image::Section>(
            segName,
            checked_cast<ByteAddr>(idaSegment->startEA),
            checked_cast<ByteSize>(idaSegment->size())
        );

        section->setReadable(idaSegment->perm & SEGPERM_READ);
        section->setWritable(idaSegment->perm & SEGPERM_WRITE);
        section->setExecutable(idaSegment->perm & SEGPERM_EXEC);
        section->setCode(idaSegment->type == SEG_CODE);
        section->setData(idaSegment->type == SEG_DATA);
        section->setBss(idaSegment->type == SEG_BSS);
        section->setAllocated(section->isCode() || section->isData() || section->isBss());
        section->setExternalByteSource(std::make_unique<IdaByteSource>());

        image->addSection(std::move(section));
    }
}
Example #4
0
static void processEvents(LLDBPlugin* plugin, PDReader* reader, PDWriter* writer)
{
    uint32_t event;

    while ((event = PDRead_get_event(reader)))
    {
        //printf("LLDBPlugin: %d Got event %s\n", event, eventTypes[event]);

        switch (event)
        {
            case PDEventType_GetExceptionLocation : setExceptionLocation(plugin, writer); break;
            case PDEventType_GetCallstack : setCallstack(plugin, writer); break;
            case PDEventType_SetExecutable : setExecutable(plugin, reader); break;
            case PDEventType_SelectThread : selectThread(plugin, reader, writer); break;
            case PDEventType_SelectFrame : selectFrame(plugin, reader, writer); break;
            case PDEventType_GetLocals : setLocals(plugin, writer); break;
            case PDEventType_GetThreads : setThreads(plugin, writer); break;
            case PDEventType_GetSourceFiles : setSourceFiles(plugin, writer); break;
            case PDEventType_SetBreakpoint : setBreakpoint(plugin, reader, writer); break;
            case PDEventType_Action : eventAction(plugin, reader); break;
        }
    }

    setTty(plugin, writer);
}
Example #5
0
void Updater::run() {
    connect(ai, SIGNAL(startUpdate(QList<FileUpdate>)), this, SLOT(startUpdate(QList<FileUpdate>)));
    connect(dm, SIGNAL(downloadsFinished(QList<FileUpdate>)), this, SLOT(downloadFinished(QList<FileUpdate>)));
    connect(ai, SIGNAL(applicationClosed(bool)), this, SLOT(startExchange(bool)));
    connect(ai, SIGNAL(executableChanged(QString)), this, SLOT(setExecutable(QString)));
    connect(fh, SIGNAL(exchangingFinished(bool)), this, SLOT(exchangeFinished(bool)));
    connect(dm, SIGNAL(error(QString)), ai, SLOT(sendError(QString)));
    connect(fh, SIGNAL(error(QString)), ai, SLOT(sendError(QString)));

    connect(ai, SIGNAL(close()), this, SLOT(closeRequested()));
}
Example #6
0
int ExtScript::showConfiguration(const QVariant args)
{
    Q_UNUSED(args)

    ui->lineEdit_name->setText(name());
    ui->lineEdit_comment->setText(comment());
    ui->label_numberValue->setText(QString("%1").arg(number()));
    ui->lineEdit_command->setText(m_executable);
    ui->lineEdit_prefix->setText(m_prefix);
    ui->checkBox_active->setCheckState(isActive() ? Qt::Checked
                                                  : Qt::Unchecked);
    ui->comboBox_redirect->setCurrentIndex(static_cast<int>(m_redirect));
    ui->spinBox_interval->setValue(interval());
    // filters
    ui->checkBox_colorFilter->setCheckState(
        m_filters.contains(QString("color")) ? Qt::Checked : Qt::Unchecked);
    ui->checkBox_linesFilter->setCheckState(
        m_filters.contains(QString("newline")) ? Qt::Checked : Qt::Unchecked);
    ui->checkBox_spaceFilter->setCheckState(
        m_filters.contains(QString("space")) ? Qt::Checked : Qt::Unchecked);

    int ret = exec();
    if (ret != 1)
        return ret;
    setName(ui->lineEdit_name->text());
    setComment(ui->lineEdit_comment->text());
    setNumber(ui->label_numberValue->text().toInt());
    setApiVersion(AWESAPI);
    setExecutable(ui->lineEdit_command->text());
    setPrefix(ui->lineEdit_prefix->text());
    setActive(ui->checkBox_active->checkState() == Qt::Checked);
    setStrRedirect(ui->comboBox_redirect->currentText());
    setInterval(ui->spinBox_interval->value());
    // filters
    updateFilter(QString("color"),
                 ui->checkBox_colorFilter->checkState() == Qt::Checked);
    updateFilter(QString("newline"),
                 ui->checkBox_linesFilter->checkState() == Qt::Checked);
    updateFilter(QString("space"),
                 ui->checkBox_spaceFilter->checkState() == Qt::Checked);

    writeConfiguration();
    return ret;
}
Example #7
0
void TExternalProgramFx::initialize(std::string name) {
  TFilePath fp = getExternFxPath() + (name + ".xml");
  TIStream is(fp);
  if (!is) return;

  std::string tagName;
  if (!is.matchTag(tagName) || tagName != "externFx") return;

  try {
    while (is.matchTag(tagName)) {
      if (tagName == "executable") {
        TFilePath executable = TFilePath(is.getTagAttribute("path"));
        std::string args     = is.getTagAttribute("args");
        if (executable == TFilePath())
          throw TException("missing executable path");
        if (args == "") throw TException("missing args string");
        setExecutable(executable, args);
      } else if (tagName == "inport" || tagName == "outport") {
        std::string portName = is.getTagAttribute("name");
        std::string ext      = is.getTagAttribute("ext");
        if (portName == "") throw TException("missing port name");
        if (ext == "") throw TException("missing port ext");
        addPort(portName, ext, tagName == "inport");
      } else if (tagName == "param") {
        std::string paramName = is.getTagAttribute("name");
        if (paramName == "") throw TException("missing param name");
        std::string type = is.getTagAttribute("type");
        if (type == "") throw TException("missing param type");
        if (type != "double")
          throw TException("param type not yet implemented");
        TDoubleParamP param = new TDoubleParam();
        param->setName(paramName);
        m_params.push_back(param);
      } else
        throw TException("unexpected tag " + tagName);
    }
    is.closeChild();

    for (int i = 0; i < (int)m_params.size(); i++)
      bindParam(this, m_params[i]->getName(), m_params[i]);

  } catch (...) {
  }
}
Example #8
0
AdjustorWritable allocateExec (W_ bytes, AdjustorExecutable *exec_ret)
{
    void *ret;
    W_ n;

    ACQUIRE_SM_LOCK;

    // round up to words.
    n  = (bytes + sizeof(W_) + 1) / sizeof(W_);

    if (n+1 > BLOCK_SIZE_W) {
        barf("allocateExec: can't handle large objects");
    }

    if (exec_block == NULL ||
        exec_block->free + n + 1 > exec_block->start + BLOCK_SIZE_W) {
        bdescr *bd;
        W_ pagesize = getPageSize();
        bd = allocGroup(stg_max(1, pagesize / BLOCK_SIZE));
        debugTrace(DEBUG_gc, "allocate exec block %p", bd->start);
        bd->gen_no = 0;
        bd->flags = BF_EXEC;
        bd->link = exec_block;
        if (exec_block != NULL) {
            exec_block->u.back = bd;
        }
        bd->u.back = NULL;
        setExecutable(bd->start, bd->blocks * BLOCK_SIZE, rtsTrue);
        exec_block = bd;
    }
    *(exec_block->free) = n;  // store the size of this chunk
    exec_block->gen_no += n;  // gen_no stores the number of words allocated
    ret = exec_block->free + 1;
    exec_block->free += n + 1;

    RELEASE_SM_LOCK
    *exec_ret = ret;
    return ret;
}
Example #9
0
static void processEvents(DbgEngPlugin* plugin, PDReader* reader, PDWriter* writer) {
    printf("DbgEngPlugin: processEvents\n");

    PDEventType event;

    while ((event = (PDEventType)PDRead_get_event(reader))) {
        printf("DbgEngPlugin: %d Got event %s\n", (int)event, eventTypes[event]);

        switch (event) {
            case PDEventType_getExceptionLocation:
                setExceptionLocation(plugin, writer); break;
            case PDEventType_getCallstack:
                setCallstack(plugin, writer); break;
            case PDEventType_setExecutable:
                setExecutable(plugin, reader); break;
            case PDEventType_getLocals:
                setLocals(plugin, writer); break;
            case PDEventType_setBreakpoint:
                setBreakpoint(plugin, reader, writer); break;
            case PDEventType_action:
                eventAction(plugin, reader); break;
        }
    }
}