all repos — mgba @ f6f3cb5d3d8b91dd603772ea0eebb2513562a0cf

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 "GameController.h"
 9
10using namespace QGBA;
11
12GDBController::GDBController(GameController* controller, QObject* parent)
13	: DebuggerController(controller, &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->debugger() == &m_gdbStub.d;
25}
26
27void GDBController::setPort(ushort port) {
28	m_port = port;
29}
30
31void GDBController::setBindAddress(uint32_t bindAddress) {
32	m_bindAddress.version = IPV4;
33	m_bindAddress.ipv4 = htonl(bindAddress);
34}
35
36void GDBController::listen() {
37	GameController::Interrupter interrupter(m_gameController);
38	if (!isAttached()) {
39		attach();
40	}
41	if (GDBStubListen(&m_gdbStub, m_port, &m_bindAddress)) {
42		emit listening();
43	} else {
44		detach();
45		emit listenFailed();
46	}
47}
48
49void GDBController::shutdownInternal() {
50	GDBStubShutdown(&m_gdbStub);
51}