OpenCores
URL https://opencores.org/ocsvn/riscv_vhdl/riscv_vhdl/trunk

Subversion Repositories riscv_vhdl

[/] [riscv_vhdl/] [trunk/] [debugger/] [src/] [gui_plugin/] [gui_plugin.cpp] - Diff between revs 2 and 3

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 2 Rev 3
Line 8... Line 8...
#include "api_core.h"
#include "api_core.h"
#include "gui_plugin.h"
#include "gui_plugin.h"
#include "coreservices/iserial.h"
#include "coreservices/iserial.h"
#include "coreservices/irawlistener.h"
#include "coreservices/irawlistener.h"
#include <string>
#include <string>
#include <QtWidgets/QApplication>
 
 
 
namespace debugger {
namespace debugger {
 
 
void GuiPlugin::UiThreadType::busyLoop() {
 
    int argc = 0;
 
    char *argv[] = {0};
 
 
 
    // Only one instance of QApplication is possible that is accessible
 
    // via global pointer qApp for all widgets.
 
    if (!qApp) {
 
        // Creating GUI thread
 
        QApplication app(argc, argv);
 
        app.setQuitOnLastWindowClosed(true);
 
 
 
        mainWindow_ = new DbgMainWindow(igui_, eventInitDone_);
 
        mainWindow_->show();
 
 
 
        // Start its'own event thread
 
        app.exec();
 
        QMainWindow *t = mainWindow_;
 
        mainWindow_ = 0;
 
        delete t;
 
    }
 
    threadInit_.Handle = 0;
 
    RISCV_break_simulation();
 
}
 
 
 
GuiPlugin::GuiPlugin(const char *name)
GuiPlugin::GuiPlugin(const char *name)
    : IService(name), IHap(HAP_ConfigDone) {
    : IService(name), IHap(HAP_ConfigDone) {
    registerInterface(static_cast<IGui *>(this));
    registerInterface(static_cast<IGui *>(this));
    registerInterface(static_cast<IThread *>(this));
    registerInterface(static_cast<IThread *>(this));
    registerInterface(static_cast<IHap *>(this));
    registerInterface(static_cast<IHap *>(this));
Line 57... Line 32...
    QResource::registerResource(
    QResource::registerResource(
        topDir + "resources/gui.rcc");
        topDir + "resources/gui.rcc");
 
 
    info_ = 0;
    info_ = 0;
    ui_ = NULL;
    ui_ = NULL;
    RISCV_event_create(&eventUiInitDone_, "eventUiInitDone_");
 
    RISCV_event_create(&eventCommandAvailable_, "eventCommandAvailable_");
    RISCV_event_create(&eventCommandAvailable_, "eventCommandAvailable_");
    RISCV_event_create(&config_done_, "eventGuiGonfigGone");
    RISCV_event_create(&config_done_, "eventGuiGonfigGone");
    RISCV_register_hap(static_cast<IHap *>(this));
    RISCV_register_hap(static_cast<IHap *>(this));
    RISCV_mutex_init(&mutexCommand_);
    RISCV_mutex_init(&mutexCommand_);
 
 
Line 82... Line 56...
    paths.append(QString(qt_lib_path.c_str()));
    paths.append(QString(qt_lib_path.c_str()));
 
 
    paths.append(QString("platforms"));
    paths.append(QString("platforms"));
    QApplication::setLibraryPaths(paths);
    QApplication::setLibraryPaths(paths);
 
 
    ui_ = new UiThreadType(static_cast<IGui *>(this),
    ui_ = new QtWrapper(static_cast<IGui *>(this));
                            &eventUiInitDone_);
 
    ui_->run();
 
}
}
 
 
GuiPlugin::~GuiPlugin() {
GuiPlugin::~GuiPlugin() {
    if (ui_) {
 
        delete ui_;
 
    }
 
    RISCV_event_close(&config_done_);
    RISCV_event_close(&config_done_);
    RISCV_event_close(&eventUiInitDone_);
 
    RISCV_event_close(&eventCommandAvailable_);
    RISCV_event_close(&eventCommandAvailable_);
    RISCV_mutex_destroy(&mutexCommand_);
    RISCV_mutex_destroy(&mutexCommand_);
}
}
 
 
void GuiPlugin::initService(const AttributeType *args) {
 
    IService::initService(args);
 
    RISCV_event_wait(&eventUiInitDone_);
 
}
 
 
 
void GuiPlugin::postinitService() {
void GuiPlugin::postinitService() {
    iexec_ = static_cast<ICmdExecutor *>(
    iexec_ = static_cast<ICmdExecutor *>(
        RISCV_get_service_iface(cmdExecutor_.to_string(), IFACE_CMD_EXECUTOR));
        RISCV_get_service_iface(cmdExecutor_.to_string(), IFACE_CMD_EXECUTOR));
    if (!iexec_) {
    if (!iexec_) {
        RISCV_error("ICmdExecutor interface of %s not found.",
        RISCV_error("ICmdExecutor interface of %s not found.",
Line 117... Line 80...
    if (!iexec_) {
    if (!iexec_) {
        RISCV_error("ISocInfo interface of %s not found.",
        RISCV_error("ISocInfo interface of %s not found.",
                    socInfo_.to_string());
                    socInfo_.to_string());
    }
    }
 
 
    if (ui_->mainWindow()) {
    ui_->postInit(&guiConfig_);
        ui_->mainWindow()->postInit(&guiConfig_);
 
    }
 
    run();
    run();
}
}
 
 
IFace *GuiPlugin::getSocInfo() {
IFace *GuiPlugin::getSocInfo() {
    return info_;
    return info_;
}
}
 
 
void GuiPlugin::getWidgetsAttribute(const char *name, AttributeType *out) {
const AttributeType *GuiPlugin::getpConfig() {
    out->make_nil();
    return &guiConfig_;
    if (guiConfig_.has_key(name)) {
 
        *out = guiConfig_[name];
 
    }
 
}
}
 
 
void GuiPlugin::registerCommand(IGuiCmdHandler *src,
void GuiPlugin::registerCommand(IGuiCmdHandler *src,
                                AttributeType *cmd,
                                AttributeType *cmd,
                                bool silent) {
                                bool silent) {
Line 182... Line 140...
            continue;
            continue;
        }
        }
 
 
        processCmdQueue();
        processCmdQueue();
    }
    }
 
    ui_->gracefulClose();
 
    delete ui_;
}
}
 
 
bool GuiPlugin::processCmdQueue() {
bool GuiPlugin::processCmdQueue() {
    AttributeType resp;
    AttributeType resp;
    while (cmdQueueCntTotal_ > 0) {
    while (cmdQueueCntTotal_ > 0) {
Line 206... Line 166...
    }
    }
    return false;
    return false;
}
}
 
 
void GuiPlugin::stop() {
void GuiPlugin::stop() {
    if (ui_->mainWindow()) {
 
        ui_->mainWindow()->callExit();
 
    }
 
    ui_->stop();
 
    IThread::stop();
    IThread::stop();
}
}
 
 
extern "C" void plugin_init(void) {
extern "C" void plugin_init(void) {
    REGISTER_CLASS(GuiPlugin);
    REGISTER_CLASS(GuiPlugin);

powered by: WebSVN 2.1.0

© copyright 1999-2025 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.