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(uint32_t bindAddress) {
32 m_bindAddress.version = IPV4;
33 m_bindAddress.ipv4 = htonl(bindAddress);
34}
35
36void GDBController::listen() {
37 if (GDBStubListen(&m_gdbStub, m_port, &m_bindAddress)) {
38 if (!isAttached()) {
39 attach();
40 }
41 emit listening();
42 } else {
43 detach();
44 emit listenFailed();
45 }
46}
47
48void GDBController::shutdownInternal() {
49 GDBStubShutdown(&m_gdbStub);
50}