all repos — mgba @ 6d898542c765f4efc4a094c5ebd3f3465c36f417

mGBA Game Boy Advance Emulator

src/platform/qt/DebuggerConsoleController.h (view raw)

 1/* Copyright (c) 2013-2016 Jeffrey Pfau
 2 *
 3 * This Source Code Form is subject to the terms of the Mozilla Public
 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 6#ifndef QGBA_DEBUGGER_CONSOLE_CONTROLLER
 7#define QGBA_DEBUGGER_CONSOLE_CONTROLLER
 8
 9#include "DebuggerController.h"
10
11#include <QMutex>
12#include <QStringList>
13#include <QWaitCondition>
14
15#include "debugger/cli-debugger.h"
16
17namespace QGBA {
18
19class GameController;
20
21class DebuggerConsoleController : public DebuggerController {
22Q_OBJECT
23
24public:
25	DebuggerConsoleController(GameController* controller, QObject* parent = nullptr);
26
27signals:
28	void log(const QString&);
29	void lineAppend(const QString&);
30
31public slots:
32	void enterLine(const QString&);
33
34protected:
35	virtual void attachInternal() override;
36
37private:
38	static void printf(struct CLIDebuggerBackend* be, const char* fmt, ...);
39	static void init(struct CLIDebuggerBackend* be);
40	static void deinit(struct CLIDebuggerBackend* be);
41	static const char* readLine(struct CLIDebuggerBackend* be, size_t* len);
42	static void lineAppend(struct CLIDebuggerBackend* be, const char* line);
43	static const char* historyLast(struct CLIDebuggerBackend* be, size_t* len);
44	static void historyAppend(struct CLIDebuggerBackend* be, const char* line);
45
46	CLIDebugger m_cliDebugger;
47
48	QMutex m_mutex;
49	QWaitCondition m_cond;
50	QStringList m_history;
51	QStringList m_lines;
52	QByteArray m_last;
53
54	struct Backend {
55		CLIDebuggerBackend d;
56		DebuggerConsoleController* self;
57	} m_backend;
58};
59
60}
61
62#endif