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/time.hpp"
|
||||
#include "utils/translation.hpp"
|
||||
#include "utils/vs.hpp"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
@ -93,6 +94,7 @@ void NewsManager::init(bool force_refresh)
|
||||
*/
|
||||
void* NewsManager::downloadNews(void *obj)
|
||||
{
|
||||
VS::setThreadName("downloadNews");
|
||||
NewsManager *me = (NewsManager*)obj;
|
||||
me->clearErrorMessage();
|
||||
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "io/file_manager.hpp"
|
||||
#include "modes/world.hpp"
|
||||
#include "race/race_manager.hpp"
|
||||
#include "utils/vs.hpp"
|
||||
|
||||
#include <pthread.h>
|
||||
#include <stdexcept>
|
||||
@ -295,6 +296,7 @@ void SFXManager::stopThread()
|
||||
*/
|
||||
void* SFXManager::mainLoop(void *obj)
|
||||
{
|
||||
VS::setThreadName("SFXManager");
|
||||
SFXManager *me = (SFXManager*)obj;
|
||||
|
||||
pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include "utils/string_utils.hpp"
|
||||
#include "utils/time.hpp"
|
||||
#include "utils/translation.hpp"
|
||||
#include "utils/vs.hpp"
|
||||
|
||||
#include "wiiuse.h"
|
||||
|
||||
@ -373,6 +374,7 @@ void WiimoteManager::threadFunc()
|
||||
*/
|
||||
void* WiimoteManager::threadFuncWrapper(void *data)
|
||||
{
|
||||
VS::setThreadName("WiimoteManager");
|
||||
((WiimoteManager*)data)->threadFunc();
|
||||
return NULL;
|
||||
} // threadFuncWrapper
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include "network/stk_peer.hpp"
|
||||
#include "utils/log.hpp"
|
||||
#include "utils/time.hpp"
|
||||
#include "utils/vs.hpp"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
@ -58,6 +59,7 @@ void NetworkConsole::run()
|
||||
// ----------------------------------------------------------------------------
|
||||
void* NetworkConsole::mainLoop(void* data)
|
||||
{
|
||||
VS::setThreadName("NetworkConsole");
|
||||
NetworkConsole *me = static_cast<NetworkConsole*>(data);
|
||||
std::string str = "";
|
||||
bool stop = false;
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "network/stk_peer.hpp"
|
||||
#include "utils/log.hpp"
|
||||
#include "utils/time.hpp"
|
||||
#include "utils/vs.hpp"
|
||||
|
||||
#include <assert.h>
|
||||
#include <cstdlib>
|
||||
@ -50,6 +51,8 @@ ProtocolManager::ProtocolManager()
|
||||
|
||||
void* ProtocolManager::mainLoop(void* data)
|
||||
{
|
||||
VS::setThreadName("ProtocolManager");
|
||||
|
||||
ProtocolManager* manager = static_cast<ProtocolManager*>(data);
|
||||
manager->m_asynchronous_thread_running = true;
|
||||
while(manager && !manager->exit())
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include "network/stk_peer.hpp"
|
||||
#include "utils/log.hpp"
|
||||
#include "utils/time.hpp"
|
||||
#include "utils/vs.hpp"
|
||||
|
||||
#include <string.h>
|
||||
#if defined(WIN32)
|
||||
@ -452,6 +453,7 @@ bool STKHost::isAuthorisedToControl(const STKPeer *peer) const
|
||||
*/
|
||||
void* STKHost::mainLoop(void* self)
|
||||
{
|
||||
VS::setThreadName("STKHost");
|
||||
ENetEvent event;
|
||||
STKHost* myself = (STKHost*)(self);
|
||||
ENetHost* host = myself->m_network->getENetHost();
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "config/player_manager.hpp"
|
||||
#include "config/user_config.hpp"
|
||||
#include "states_screens/state_manager.hpp"
|
||||
#include "utils/vs.hpp"
|
||||
|
||||
#include <iostream>
|
||||
#include <stdio.h>
|
||||
@ -184,6 +185,7 @@ namespace Online
|
||||
*/
|
||||
void *RequestManager::mainLoop(void *obj)
|
||||
{
|
||||
VS::setThreadName("RequestManager");
|
||||
RequestManager *me = (RequestManager*) obj;
|
||||
|
||||
pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
|
||||
|
@ -15,6 +15,9 @@
|
||||
// along with this program; if not, write to the Free Software
|
||||
// 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
|
||||
* Note that Visual Studio 2013 does have the maths functions defined,
|
||||
* so we define the work arounds only for compiler versions before 18.00
|
||||
@ -32,3 +35,49 @@
|
||||
#include <cmath>
|
||||
using std::isnan;
|
||||
#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