2020-01-14 02:09:51 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2019 Atmosphère-NX
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms and conditions of the GNU General Public License,
|
|
|
|
* version 2, as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
|
|
* more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2020-02-24 00:21:26 +00:00
|
|
|
//#include "exceptions.h"
|
|
|
|
struct ExceptionStackFrame;
|
2020-02-07 02:08:03 +00:00
|
|
|
//#include "gdb/hvisor_context.h"
|
2020-01-31 02:53:40 +00:00
|
|
|
#include "transport_interface.h"
|
2020-01-27 22:17:25 +00:00
|
|
|
|
2020-02-07 02:08:03 +00:00
|
|
|
//extern GDBContext g_gdbContext;
|
2020-01-14 02:09:51 +00:00
|
|
|
|
2020-01-27 00:46:00 +00:00
|
|
|
typedef enum DebugEventType {
|
2020-01-28 00:38:53 +00:00
|
|
|
DBGEVENT_NONE = 0,
|
|
|
|
DBGEVENT_DEBUGGER_BREAK,
|
2020-01-27 00:46:00 +00:00
|
|
|
DBGEVENT_EXCEPTION,
|
|
|
|
DBGEVENT_CORE_ON,
|
|
|
|
DBGEVENT_CORE_OFF,
|
|
|
|
DBGEVENT_EXIT,
|
|
|
|
DBGEVENT_OUTPUT_STRING,
|
|
|
|
} DebugEventType;
|
|
|
|
|
|
|
|
typedef struct OutputStringDebugEventInfo {
|
|
|
|
uintptr_t address;
|
|
|
|
size_t size;
|
|
|
|
} OutputStringDebugEventInfo;
|
|
|
|
|
|
|
|
typedef struct DebugEventInfo {
|
|
|
|
DebugEventType type;
|
2020-01-31 01:12:59 +00:00
|
|
|
bool preprocessed;
|
2020-01-27 22:17:25 +00:00
|
|
|
bool handled;
|
2020-01-27 00:46:00 +00:00
|
|
|
u32 coreId;
|
2020-02-24 00:21:26 +00:00
|
|
|
struct ExceptionStackFrame *frame;
|
2020-01-27 00:46:00 +00:00
|
|
|
union {
|
|
|
|
OutputStringDebugEventInfo outputString;
|
|
|
|
};
|
|
|
|
} DebugEventInfo;
|
|
|
|
|
|
|
|
void debugManagerPauseSgiHandler(void);
|
2020-01-16 01:18:34 +00:00
|
|
|
|
2020-01-31 02:53:40 +00:00
|
|
|
void debugManagerInit(TransportInterfaceType gdbIfaceType, u32 gdbIfaceId, u32 gdbIfaceFlags);
|
|
|
|
|
2020-01-31 00:28:05 +00:00
|
|
|
void debugManagerSetReportingEnabled(bool enabled);
|
|
|
|
|
2020-01-16 01:18:34 +00:00
|
|
|
// Hypervisor interrupts will be serviced during the pause-wait
|
2020-01-28 00:38:53 +00:00
|
|
|
bool debugManagerHandlePause(void);
|
2020-01-14 02:09:51 +00:00
|
|
|
|
2020-02-02 17:46:17 +00:00
|
|
|
DebugEventInfo *debugManagerGetDebugEvent(u32 coreId);
|
|
|
|
bool debugManagerHasDebugEvent(u32 coreId);
|
|
|
|
|
2020-01-22 20:26:14 +00:00
|
|
|
// Note: these functions are not reentrant EXCEPT debugPauseCores(1 << currentCoreId)
|
2020-01-14 02:09:51 +00:00
|
|
|
// "Pause" makes sure all cores reaches the pause function before proceeding.
|
|
|
|
// "Unpause" doesn't synchronize, it just makes sure the core resumes & that "pause" can be called again.
|
2020-01-27 00:46:00 +00:00
|
|
|
void debugManagerPauseCores(u32 coreList);
|
2020-01-30 01:22:37 +00:00
|
|
|
void debugManagerUnpauseCores(u32 coreList);
|
|
|
|
void debugManagerSetSingleStepCoreList(u32 coreList);
|
2020-01-27 22:17:25 +00:00
|
|
|
|
2020-01-28 01:13:21 +00:00
|
|
|
void debugManagerSetSteppingRange(u32 coreId, uintptr_t startAddr, uintptr_t endAddr);
|
|
|
|
|
2020-01-27 22:17:25 +00:00
|
|
|
u32 debugManagerGetPausedCoreList(void);
|
|
|
|
|
2020-01-29 01:19:38 +00:00
|
|
|
|
|
|
|
void debugManagerReportEvent(DebugEventType type, ...);
|
|
|
|
|
|
|
|
void debugManagerBreakCores(u32 coreList);
|
2020-01-30 01:22:37 +00:00
|
|
|
void debugManagerContinueCores(u32 coreList);
|
2020-01-27 22:17:25 +00:00
|
|
|
|
|
|
|
static inline bool debugManagerIsCorePaused(u32 coreId)
|
|
|
|
{
|
|
|
|
return (debugManagerGetPausedCoreList() & BIT(coreId)) != 0;
|
|
|
|
}
|