mirror of
https://github.com/Atmosphere-NX/Atmosphere-libs.git
synced 2025-06-30 06:52:39 +02:00
dmnt2: detect thread name, add monitor get mapping(s), increase buffer sizes
This commit is contained in:
parent
1c7ae0d066
commit
54783b86f1
@ -19,7 +19,7 @@ namespace ams::kern {
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
constexpr std::tuple<KMemoryState, const char *> MemoryStateNames[] = {
|
constexpr const std::pair<KMemoryState, const char *> MemoryStateNames[] = {
|
||||||
{KMemoryState_Free , "----- Free -----"},
|
{KMemoryState_Free , "----- Free -----"},
|
||||||
{KMemoryState_Io , "Io "},
|
{KMemoryState_Io , "Io "},
|
||||||
{KMemoryState_Static , "Static "},
|
{KMemoryState_Static , "Static "},
|
||||||
@ -41,6 +41,7 @@ namespace ams::kern {
|
|||||||
{KMemoryState_Kernel , "Kernel "},
|
{KMemoryState_Kernel , "Kernel "},
|
||||||
{KMemoryState_GeneratedCode , "GeneratedCode "},
|
{KMemoryState_GeneratedCode , "GeneratedCode "},
|
||||||
{KMemoryState_CodeOut , "CodeOut "},
|
{KMemoryState_CodeOut , "CodeOut "},
|
||||||
|
{KMemoryState_Coverage , "Coverage "},
|
||||||
};
|
};
|
||||||
|
|
||||||
constexpr const char *GetMemoryStateName(KMemoryState state) {
|
constexpr const char *GetMemoryStateName(KMemoryState state) {
|
||||||
|
@ -52,6 +52,26 @@ namespace ams::os::impl {
|
|||||||
/* Get the thread impl object from libnx. */
|
/* Get the thread impl object from libnx. */
|
||||||
ThreadImpl *thread_impl = ::threadGetSelf();
|
ThreadImpl *thread_impl = ::threadGetSelf();
|
||||||
|
|
||||||
|
/* Hack around libnx's main thread, to ensure stratosphere thread type consistency. */
|
||||||
|
{
|
||||||
|
auto *tlr = reinterpret_cast<uintptr_t *>(svc::GetThreadLocalRegion());
|
||||||
|
for (size_t i = sizeof(svc::ThreadLocalRegion) / sizeof(uintptr_t); i > 0; --i) {
|
||||||
|
if (auto *candidate = reinterpret_cast<ThreadImpl *>(tlr[i - 1]); candidate == thread_impl) {
|
||||||
|
ThreadImpl *embedded_thread = std::addressof(main_thread->thread_impl_storage);
|
||||||
|
|
||||||
|
*embedded_thread = *thread_impl;
|
||||||
|
|
||||||
|
if (embedded_thread->next) {
|
||||||
|
embedded_thread->next->prev_next = std::addressof(embedded_thread->next);
|
||||||
|
}
|
||||||
|
|
||||||
|
thread_impl = embedded_thread;
|
||||||
|
tlr[i-1] = reinterpret_cast<uintptr_t>(thread_impl);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Get the thread priority. */
|
/* Get the thread priority. */
|
||||||
s32 horizon_priority;
|
s32 horizon_priority;
|
||||||
R_ABORT_UNLESS(svc::GetThreadPriority(std::addressof(horizon_priority), thread_impl->handle));
|
R_ABORT_UNLESS(svc::GetThreadPriority(std::addressof(horizon_priority), thread_impl->handle));
|
||||||
|
@ -54,7 +54,7 @@ namespace ams::osdbg::impl {
|
|||||||
static_assert(AMS_OFFSETOF(ThreadLocalRegionIlp32, tls) == 0x1C0);
|
static_assert(AMS_OFFSETOF(ThreadLocalRegionIlp32, tls) == 0x1C0);
|
||||||
|
|
||||||
struct LibnxThreadVars {
|
struct LibnxThreadVars {
|
||||||
static constexpr u32 Magic = util::FourCC<'!','T','V','$'>::Code;
|
static constexpr u32 Magic = util::ReverseFourCC<'!','T','V','$'>::Code;
|
||||||
|
|
||||||
u32 magic;
|
u32 magic;
|
||||||
::Handle handle;
|
::Handle handle;
|
||||||
@ -69,11 +69,11 @@ namespace ams::osdbg::impl {
|
|||||||
volatile u16 disable_counter;
|
volatile u16 disable_counter;
|
||||||
volatile u16 interrupt_flag;
|
volatile u16 interrupt_flag;
|
||||||
u32 reserved0;
|
u32 reserved0;
|
||||||
u64 tls[(0x1E0 - 0x108) / sizeof(u64)];
|
u64 tls[(0x200 - sizeof(LibnxThreadVars) - 0x108) / sizeof(u64)];
|
||||||
LibnxThreadVars thread_vars;
|
LibnxThreadVars thread_vars;
|
||||||
};
|
};
|
||||||
static_assert(sizeof(ThreadLocalRegionLibnx) == sizeof(svc::ThreadLocalRegion));
|
static_assert(sizeof(ThreadLocalRegionLibnx) == sizeof(svc::ThreadLocalRegion));
|
||||||
static_assert(AMS_OFFSETOF(ThreadLocalRegionLibnx, thread_vars) == 0x1E0);
|
static_assert(AMS_OFFSETOF(ThreadLocalRegionLibnx, thread_vars) == 0x200 - sizeof(LibnxThreadVars));
|
||||||
|
|
||||||
struct LibnxThreadEntryArgs {
|
struct LibnxThreadEntryArgs {
|
||||||
u64 t;
|
u64 t;
|
||||||
|
@ -50,9 +50,9 @@ namespace ams::osdbg {
|
|||||||
} else {
|
} else {
|
||||||
/* Special-case libnx threads. */
|
/* Special-case libnx threads. */
|
||||||
if (thread_info->_thread_type_type == ThreadTypeType_Libnx) {
|
if (thread_info->_thread_type_type == ThreadTypeType_Libnx) {
|
||||||
util::TSNPrintf(dst, os::ThreadNameLengthMax, "libnx Thread_0x%p", reinterpret_cast<void *>(thread_info->_thread_type));
|
util::TSNPrintf(dst, os::ThreadNameLengthMax, "libnx Thread_%p", reinterpret_cast<void *>(thread_info->_thread_type));
|
||||||
} else {
|
} else {
|
||||||
util::TSNPrintf(dst, os::ThreadNameLengthMax, "Thread_0x%p", reinterpret_cast<void *>(thread_info->_thread_type));
|
util::TSNPrintf(dst, os::ThreadNameLengthMax, "Thread_%p", reinterpret_cast<void *>(thread_info->_thread_type));
|
||||||
}
|
}
|
||||||
|
|
||||||
return ResultSuccess();
|
return ResultSuccess();
|
||||||
|
Loading…
Reference in New Issue
Block a user