From b78aff85857a3a356fdf11e1dbc4e5f52490676e Mon Sep 17 00:00:00 2001 From: bunnei Date: Mon, 2 Jun 2014 20:38:34 -0400 Subject: svc: added optional name field to Event and Mutex (used for debugging) --- src/core/hle/kernel/event.cpp | 11 ++++++++--- src/core/hle/kernel/event.h | 3 ++- src/core/hle/kernel/mutex.cpp | 12 +++++++++--- src/core/hle/kernel/mutex.h | 3 ++- 4 files changed, 21 insertions(+), 8 deletions(-) (limited to 'src/core/hle/kernel') diff --git a/src/core/hle/kernel/event.cpp b/src/core/hle/kernel/event.cpp index e84d0b49e..70e50115d 100644 --- a/src/core/hle/kernel/event.cpp +++ b/src/core/hle/kernel/event.cpp @@ -15,6 +15,7 @@ namespace Kernel { class Event : public Object { public: const char* GetTypeName() { return "Event"; } + const char* GetName() { return name.c_str(); } static Kernel::HandleType GetStaticHandleType() { return Kernel::HandleType::Event; } Kernel::HandleType GetHandleType() const { return Kernel::HandleType::Event; } @@ -24,6 +25,7 @@ public: bool locked; ///< Current locked state bool permanent_locked; ///< Hack - to set event permanent state (for easy passthrough) + std::string name; ///< Name of event (optional) /** * Synchronize kernel object @@ -98,9 +100,10 @@ Result ClearEvent(Handle handle) { * Creates an event * @param handle Reference to handle for the newly created mutex * @param reset_type ResetType describing how to create event + * @param name Optional name of event * @return Newly created Event object */ -Event* CreateEvent(Handle& handle, const ResetType reset_type) { +Event* CreateEvent(Handle& handle, const ResetType reset_type, const std::string name) { Event* evt = new Event; handle = Kernel::g_object_pool.Create(evt); @@ -108,6 +111,7 @@ Event* CreateEvent(Handle& handle, const ResetType reset_type) { evt->locked = true; evt->permanent_locked = false; evt->reset_type = evt->intitial_reset_type = reset_type; + evt->name = name; return evt; } @@ -115,11 +119,12 @@ Event* CreateEvent(Handle& handle, const ResetType reset_type) { /** * Creates an event * @param reset_type ResetType describing how to create event + * @param name Optional name of event * @return Handle to newly created Event object */ -Handle CreateEvent(const ResetType reset_type) { +Handle CreateEvent(const ResetType reset_type, const std::string name) { Handle handle; - Event* evt = CreateEvent(handle, reset_type); + Event* evt = CreateEvent(handle, reset_type, name); return handle; } diff --git a/src/core/hle/kernel/event.h b/src/core/hle/kernel/event.h index f91a72c1c..eed09f0e3 100644 --- a/src/core/hle/kernel/event.h +++ b/src/core/hle/kernel/event.h @@ -37,8 +37,9 @@ Result ClearEvent(Handle handle); /** * Creates an event * @param reset_type ResetType describing how to create event + * @param name Optional name of event * @return Handle to newly created Event object */ -Handle CreateEvent(const ResetType reset_type); +Handle CreateEvent(const ResetType reset_type, const std::string name="Unknown"); } // namespace diff --git a/src/core/hle/kernel/mutex.cpp b/src/core/hle/kernel/mutex.cpp index 5ac88cd85..7e60fbfe0 100644 --- a/src/core/hle/kernel/mutex.cpp +++ b/src/core/hle/kernel/mutex.cpp @@ -16,6 +16,7 @@ namespace Kernel { class Mutex : public Object { public: const char* GetTypeName() { return "Mutex"; } + const char* GetName() { return name.c_str(); } static Kernel::HandleType GetStaticHandleType() { return Kernel::HandleType::Mutex; } Kernel::HandleType GetHandleType() const { return Kernel::HandleType::Mutex; } @@ -24,6 +25,7 @@ public: bool locked; ///< Current locked state Handle lock_thread; ///< Handle to thread that currently has mutex std::vector waiting_threads; ///< Threads that are waiting for the mutex + std::string name; ///< Name of mutex (optional) /** * Synchronize kernel object @@ -128,13 +130,15 @@ Result ReleaseMutex(Handle handle) { * Creates a mutex * @param handle Reference to handle for the newly created mutex * @param initial_locked Specifies if the mutex should be locked initially + * @param name Optional name of mutex * @return Pointer to new Mutex object */ -Mutex* CreateMutex(Handle& handle, bool initial_locked) { +Mutex* CreateMutex(Handle& handle, bool initial_locked, const std::string name) { Mutex* mutex = new Mutex; handle = Kernel::g_object_pool.Create(mutex); mutex->locked = mutex->initial_locked = initial_locked; + mutex->name = name; // Acquire mutex with current thread if initialized as locked... if (mutex->locked) { @@ -150,10 +154,12 @@ Mutex* CreateMutex(Handle& handle, bool initial_locked) { /** * Creates a mutex * @param initial_locked Specifies if the mutex should be locked initially + * @param name Optional name of mutex + * @return Handle to newly created object */ -Handle CreateMutex(bool initial_locked) { +Handle CreateMutex(bool initial_locked, std::string name) { Handle handle; - Mutex* mutex = CreateMutex(handle, initial_locked); + Mutex* mutex = CreateMutex(handle, initial_locked, name); return handle; } diff --git a/src/core/hle/kernel/mutex.h b/src/core/hle/kernel/mutex.h index 4cd266725..fde5549fa 100644 --- a/src/core/hle/kernel/mutex.h +++ b/src/core/hle/kernel/mutex.h @@ -20,8 +20,9 @@ Result ReleaseMutex(Handle handle); /** * Creates a mutex * @param initial_locked Specifies if the mutex should be locked initially + * @param name Optional name of mutex * @return Handle to newly created object */ -Handle CreateMutex(bool initial_locked); +Handle CreateMutex(bool initial_locked, const std::string name="Unknown"); } // namespace -- cgit v1.2.3