Set a name for each thread in VS.
This commit is contained in:
parent
1755f22663
commit
1969ee0b1f
@ -26,6 +26,7 @@
|
|||||||
#include "utils/string_utils.hpp"
|
#include "utils/string_utils.hpp"
|
||||||
#include "utils/time.hpp"
|
#include "utils/time.hpp"
|
||||||
#include "utils/translation.hpp"
|
#include "utils/translation.hpp"
|
||||||
|
#include "utils/vs.hpp"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
@ -93,6 +94,7 @@ void NewsManager::init(bool force_refresh)
|
|||||||
*/
|
*/
|
||||||
void* NewsManager::downloadNews(void *obj)
|
void* NewsManager::downloadNews(void *obj)
|
||||||
{
|
{
|
||||||
|
VS::setThreadName("downloadNews");
|
||||||
NewsManager *me = (NewsManager*)obj;
|
NewsManager *me = (NewsManager*)obj;
|
||||||
me->clearErrorMessage();
|
me->clearErrorMessage();
|
||||||
|
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
#include "io/file_manager.hpp"
|
#include "io/file_manager.hpp"
|
||||||
#include "modes/world.hpp"
|
#include "modes/world.hpp"
|
||||||
#include "race/race_manager.hpp"
|
#include "race/race_manager.hpp"
|
||||||
|
#include "utils/vs.hpp"
|
||||||
|
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
@ -295,6 +296,7 @@ void SFXManager::stopThread()
|
|||||||
*/
|
*/
|
||||||
void* SFXManager::mainLoop(void *obj)
|
void* SFXManager::mainLoop(void *obj)
|
||||||
{
|
{
|
||||||
|
VS::setThreadName("SFXManager");
|
||||||
SFXManager *me = (SFXManager*)obj;
|
SFXManager *me = (SFXManager*)obj;
|
||||||
|
|
||||||
pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
|
pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
#include "utils/string_utils.hpp"
|
#include "utils/string_utils.hpp"
|
||||||
#include "utils/time.hpp"
|
#include "utils/time.hpp"
|
||||||
#include "utils/translation.hpp"
|
#include "utils/translation.hpp"
|
||||||
|
#include "utils/vs.hpp"
|
||||||
|
|
||||||
#include "wiiuse.h"
|
#include "wiiuse.h"
|
||||||
|
|
||||||
@ -373,6 +374,7 @@ void WiimoteManager::threadFunc()
|
|||||||
*/
|
*/
|
||||||
void* WiimoteManager::threadFuncWrapper(void *data)
|
void* WiimoteManager::threadFuncWrapper(void *data)
|
||||||
{
|
{
|
||||||
|
VS::setThreadName("WiimoteManager");
|
||||||
((WiimoteManager*)data)->threadFunc();
|
((WiimoteManager*)data)->threadFunc();
|
||||||
return NULL;
|
return NULL;
|
||||||
} // threadFuncWrapper
|
} // threadFuncWrapper
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
#include "network/stk_peer.hpp"
|
#include "network/stk_peer.hpp"
|
||||||
#include "utils/log.hpp"
|
#include "utils/log.hpp"
|
||||||
#include "utils/time.hpp"
|
#include "utils/time.hpp"
|
||||||
|
#include "utils/vs.hpp"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
@ -58,6 +59,7 @@ void NetworkConsole::run()
|
|||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
void* NetworkConsole::mainLoop(void* data)
|
void* NetworkConsole::mainLoop(void* data)
|
||||||
{
|
{
|
||||||
|
VS::setThreadName("NetworkConsole");
|
||||||
NetworkConsole *me = static_cast<NetworkConsole*>(data);
|
NetworkConsole *me = static_cast<NetworkConsole*>(data);
|
||||||
std::string str = "";
|
std::string str = "";
|
||||||
bool stop = false;
|
bool stop = false;
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
#include "network/stk_peer.hpp"
|
#include "network/stk_peer.hpp"
|
||||||
#include "utils/log.hpp"
|
#include "utils/log.hpp"
|
||||||
#include "utils/time.hpp"
|
#include "utils/time.hpp"
|
||||||
|
#include "utils/vs.hpp"
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
@ -50,6 +51,8 @@ ProtocolManager::ProtocolManager()
|
|||||||
|
|
||||||
void* ProtocolManager::mainLoop(void* data)
|
void* ProtocolManager::mainLoop(void* data)
|
||||||
{
|
{
|
||||||
|
VS::setThreadName("ProtocolManager");
|
||||||
|
|
||||||
ProtocolManager* manager = static_cast<ProtocolManager*>(data);
|
ProtocolManager* manager = static_cast<ProtocolManager*>(data);
|
||||||
manager->m_asynchronous_thread_running = true;
|
manager->m_asynchronous_thread_running = true;
|
||||||
while(manager && !manager->exit())
|
while(manager && !manager->exit())
|
||||||
|
@ -32,6 +32,7 @@
|
|||||||
#include "network/stk_peer.hpp"
|
#include "network/stk_peer.hpp"
|
||||||
#include "utils/log.hpp"
|
#include "utils/log.hpp"
|
||||||
#include "utils/time.hpp"
|
#include "utils/time.hpp"
|
||||||
|
#include "utils/vs.hpp"
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#if defined(WIN32)
|
#if defined(WIN32)
|
||||||
@ -452,6 +453,7 @@ bool STKHost::isAuthorisedToControl(const STKPeer *peer) const
|
|||||||
*/
|
*/
|
||||||
void* STKHost::mainLoop(void* self)
|
void* STKHost::mainLoop(void* self)
|
||||||
{
|
{
|
||||||
|
VS::setThreadName("STKHost");
|
||||||
ENetEvent event;
|
ENetEvent event;
|
||||||
STKHost* myself = (STKHost*)(self);
|
STKHost* myself = (STKHost*)(self);
|
||||||
ENetHost* host = myself->m_network->getENetHost();
|
ENetHost* host = myself->m_network->getENetHost();
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
#include "config/player_manager.hpp"
|
#include "config/player_manager.hpp"
|
||||||
#include "config/user_config.hpp"
|
#include "config/user_config.hpp"
|
||||||
#include "states_screens/state_manager.hpp"
|
#include "states_screens/state_manager.hpp"
|
||||||
|
#include "utils/vs.hpp"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@ -184,6 +185,7 @@ namespace Online
|
|||||||
*/
|
*/
|
||||||
void *RequestManager::mainLoop(void *obj)
|
void *RequestManager::mainLoop(void *obj)
|
||||||
{
|
{
|
||||||
|
VS::setThreadName("RequestManager");
|
||||||
RequestManager *me = (RequestManager*) obj;
|
RequestManager *me = (RequestManager*) obj;
|
||||||
|
|
||||||
pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
|
pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
|
||||||
|
@ -15,6 +15,9 @@
|
|||||||
// along with this program; if not, write to the Free Software
|
// along with this program; if not, write to the Free Software
|
||||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef HEADER_VS_HPP
|
||||||
|
#define HEADER_VS_HPP
|
||||||
/** Visual studio workarounds in one place
|
/** Visual studio workarounds in one place
|
||||||
* Note that Visual Studio 2013 does have the maths functions defined,
|
* Note that Visual Studio 2013 does have the maths functions defined,
|
||||||
* so we define the work arounds only for compiler versions before 18.00
|
* so we define the work arounds only for compiler versions before 18.00
|
||||||
@ -32,3 +35,49 @@
|
|||||||
#include <cmath>
|
#include <cmath>
|
||||||
using std::isnan;
|
using std::isnan;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(WIN32) && defined(DEBUG)
|
||||||
|
# define WIN32_LEAN_AND_MEAN
|
||||||
|
# include <Windows.h>
|
||||||
|
|
||||||
|
namespace VS
|
||||||
|
{
|
||||||
|
/** This function sets the name of this thread in the VS debugger.
|
||||||
|
* \param name Name of the thread.
|
||||||
|
*/
|
||||||
|
static void setThreadName(const char *name)
|
||||||
|
{
|
||||||
|
const DWORD MS_VC_EXCEPTION=0x406D1388;
|
||||||
|
#pragma pack(push,8)
|
||||||
|
typedef struct tagTHREADNAME_INFO
|
||||||
|
{
|
||||||
|
DWORD dwType; // Must be 0x1000.
|
||||||
|
LPCSTR szName; // Pointer to name (in user addr space).
|
||||||
|
DWORD dwThreadID; // Thread ID (-1=caller thread).
|
||||||
|
DWORD dwFlags; // Reserved for future use, must be zero.
|
||||||
|
} THREADNAME_INFO;
|
||||||
|
#pragma pack(pop)
|
||||||
|
|
||||||
|
THREADNAME_INFO info;
|
||||||
|
info.dwType = 0x1000;
|
||||||
|
info.szName = name;
|
||||||
|
info.dwThreadID = -1;
|
||||||
|
info.dwFlags = 0;
|
||||||
|
|
||||||
|
__try
|
||||||
|
{
|
||||||
|
RaiseException( MS_VC_EXCEPTION, 0, sizeof(info)/sizeof(ULONG_PTR),
|
||||||
|
(ULONG_PTR*)&info );
|
||||||
|
}
|
||||||
|
__except(EXCEPTION_EXECUTE_HANDLER)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
} // setThreadName
|
||||||
|
#else
|
||||||
|
static void setThreadName(const char* name)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
} // namespace VS
|
||||||
|
#endif // HEADER_VS_HPP
|
Loading…
x
Reference in New Issue
Block a user