2 Skelton for retropc emulator
4 Author : K.Ohta <whatisthis.sowhat _at_ gmail.com>
6 History: 09 Apr, 2015 : Initial from Takeda.Toshiya's w32_debugger.cpp.
16 #include <QMetaObject>
18 //#include "res/resource.h"
19 #include "../../emu.h"
20 #include "../../vm/device.h"
21 #include "../../vm/debugger.h"
22 #include "../../vm/vm.h"
23 #include "../../fileio.h"
24 #include "qt_debugger.h"
26 //#include <QMainWindow>
31 void CSP_Debugger::put_string(QString s)
33 text->insertPlainText(s);
34 text->moveCursor(QTextCursor::End);
37 void CSP_Debugger::cmd_clear()
39 text_command->clear();
40 text->moveCursor(QTextCursor::End);
44 void CSP_Debugger::doExit2(void)
46 emit sig_close_debugger();
49 void CSP_Debugger::doExit(void)
51 DEVICE *cpu = debugger_thread_param.vm->get_cpu(debugger_thread_param.cpu_index);
52 DEBUGGER *debugger = (DEBUGGER *)cpu->get_debugger();
53 debugger_thread_param.request_terminate = true;
56 debugger->now_debugging = debugger->now_going = debugger->now_suspended = false;
60 debugger_thread_param.running = false;
64 void CSP_Debugger::stop_polling()
69 void CSP_Debugger::call_debugger(void)
71 //emit sig_call_debugger(text_command->text());
72 main_thread->call_debugger(text_command->text());
75 void CSP_Debugger::run(void)
77 main_thread = new CSP_DebuggerThread(NULL, &debugger_thread_param);
78 main_thread->setObjectName(QString::fromUtf8("Debugger"));
79 main_thread->moveToThread(main_thread);
80 //main_thread = new CSP_DebuggerThread(this, &debugger_thread_param);
82 connect(text_command, SIGNAL(editingFinished()), this, SLOT(call_debugger()));
83 connect(this, SIGNAL(sig_call_debugger(QString)), main_thread, SLOT(call_debugger(QString)));
85 connect(main_thread, SIGNAL(sig_text_clear()), this, SLOT(cmd_clear()));
86 connect(main_thread, SIGNAL(sig_put_string(QString)), this, SLOT(put_string(QString)));
88 connect(main_thread, SIGNAL(finished()), this, SLOT(doExit()));
89 connect(main_thread, SIGNAL(quit_debugger_thread()), this, SLOT(doExit()));
91 connect(this, SIGNAL(sig_finished()), this, SLOT(close()));
92 connect(this, SIGNAL(destroyed()), this, SLOT(doExit()));
93 connect(this, SIGNAL(sig_close_debugger()), main_thread, SLOT(quit_debugger()));
95 //connect(parent_object, SIGNAL(quit_debugger_thread()), this, SLOT(doExit2()));
96 connect(parent_object, SIGNAL(quit_debugger_thread()), this, SLOT(close()));
98 connect(this, SIGNAL(sig_start_debugger()), main_thread, SLOT(start()));
100 //emit sig_start_debugger();
103 void CSP_Debugger::closeEvent(QCloseEvent *event)
105 main_thread->terminate();
109 CSP_Debugger::CSP_Debugger(QWidget *parent) : QWidget(parent, Qt::Window)
113 parent_object = parent;
114 text = new QTextEdit(this);
115 text->setReadOnly(true);
116 text->setLineWrapMode(QTextEdit::WidgetWidth);
117 //text->setCenterOnScroll(true);
119 text_command = new QLineEdit(this);
120 text_command->setEchoMode(QLineEdit::Normal);
121 text_command->setMaxLength(1024);
122 text_command->setReadOnly(false);
123 text_command->setEnabled(true);
124 text_command->clear();
125 //connect(text_command, SIGNAL(editingFinished()), this, SLOT(call_debugger()));
127 VBoxWindow = new QVBoxLayout;
129 VBoxWindow->addWidget(text);
130 VBoxWindow->addWidget(text_command);
131 this->setLayout(VBoxWindow);
132 this->resize(640, 500);
136 CSP_Debugger::~CSP_Debugger()