all repos — mgba @ c4b38790f211b65cb15af26cebe9fc25e3c19914

mGBA Game Boy Advance Emulator

src/platform/qt/GDBController.cpp (view raw)

 1/* Copyright (c) 2013-2014 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#include "GDBController.h"
 7
 8#include "CoreController.h"
 9
10using namespace QGBA;
11
12GDBController::GDBController(QObject* parent)
13	: DebuggerController(&m_gdbStub.d, parent)
14	, m_bindAddress({ IPV4, {0} })
15{
16	GDBStubCreate(&m_gdbStub);
17}
18
19ushort GDBController::port() {
20	return m_port;
21}
22
23bool GDBController::isAttached() {
24	return m_gameController && m_gameController->debugger() == &m_gdbStub.d;
25}
26
27void GDBController::setPort(ushort port) {
28	m_port = port;
29}
30
31void GDBController::setBindAddress(const Address& address) {
32	m_bindAddress = address;
33}
34
35void GDBController::listen() {
36	if (GDBStubListen(&m_gdbStub, m_port, &m_bindAddress)) {
37		if (!isAttached()) {
38			attach();
39		}
40		emit listening();
41	} else {
42		detach();
43		emit listenFailed();
44	}
45}
46
47void GDBController::shutdownInternal() {
48	GDBStubShutdown(&m_gdbStub);
49}