mirror of
https://github.com/zeromq/libzmq.git
synced 2025-10-13 06:44:16 +02:00
Problem: exception thrown when debugging cl.exe x64 build with LLDB (#4129)
* Problem: exception thrown when debugging cl.exe x64 build with LLDB Solution: Use __try __except with cl.exe and use pthread_setname_np with MinGW. Remove usage of pushing exception handler to TIB->ExceptionList.
This commit is contained in:
15
RELICENSE/c-zhao-3g.md
Normal file
15
RELICENSE/c-zhao-3g.md
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
# Permission to Relicense under MPLv2 or any other OSI approved license chosen by the current ZeroMQ BDFL
|
||||||
|
|
||||||
|
This is a statement by Lingqiao Zhao
|
||||||
|
that grants permission to relicense its copyrights in the libzmq C++
|
||||||
|
library (ZeroMQ) under the Mozilla Public License v2 (MPLv2) or any other
|
||||||
|
Open Source Initiative approved license chosen by the current ZeroMQ
|
||||||
|
BDFL (Benevolent Dictator for Life).
|
||||||
|
|
||||||
|
A portion of the commits made by the Github handle "s-zhao-3g", with
|
||||||
|
commit author "s-zhao-3g <forever.3g@hotmail.com>", are copyright of Lingqiao Zhao.
|
||||||
|
This document hereby grants the libzmq project team to relicense libzmq,
|
||||||
|
including all past, present and future contributions of the author listed above.
|
||||||
|
|
||||||
|
Lingqiao Zhao
|
||||||
|
2021/01/26
|
@@ -36,6 +36,10 @@
|
|||||||
#include <winnt.h>
|
#include <winnt.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef __MINGW32__
|
||||||
|
#include "pthread.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
bool zmq::thread_t::get_started () const
|
bool zmq::thread_t::get_started () const
|
||||||
{
|
{
|
||||||
return _started;
|
return _started;
|
||||||
@@ -111,6 +115,8 @@ void zmq::thread_t::
|
|||||||
// not implemented
|
// not implemented
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
#pragma pack(push, 8)
|
#pragma pack(push, 8)
|
||||||
@@ -124,22 +130,7 @@ struct thread_info_t
|
|||||||
#pragma pack(pop)
|
#pragma pack(pop)
|
||||||
}
|
}
|
||||||
|
|
||||||
struct MY_EXCEPTION_REGISTRATION_RECORD
|
#endif
|
||||||
{
|
|
||||||
typedef EXCEPTION_DISPOSITION (NTAPI *HandlerFunctionType) (
|
|
||||||
EXCEPTION_RECORD *, void *, CONTEXT *, void *);
|
|
||||||
|
|
||||||
MY_EXCEPTION_REGISTRATION_RECORD *Next;
|
|
||||||
HandlerFunctionType Handler;
|
|
||||||
};
|
|
||||||
|
|
||||||
static EXCEPTION_DISPOSITION NTAPI continue_execution (EXCEPTION_RECORD *rec,
|
|
||||||
void *frame,
|
|
||||||
CONTEXT *ctx,
|
|
||||||
void *disp)
|
|
||||||
{
|
|
||||||
return ExceptionContinueExecution;
|
|
||||||
}
|
|
||||||
|
|
||||||
void zmq::thread_t::
|
void zmq::thread_t::
|
||||||
applyThreadName () // to be called in secondary thread context
|
applyThreadName () // to be called in secondary thread context
|
||||||
@@ -147,29 +138,37 @@ void zmq::thread_t::
|
|||||||
if (!_name[0] || !IsDebuggerPresent ())
|
if (!_name[0] || !IsDebuggerPresent ())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
|
||||||
thread_info_t thread_info;
|
thread_info_t thread_info;
|
||||||
thread_info._type = 0x1000;
|
thread_info._type = 0x1000;
|
||||||
thread_info._name = _name;
|
thread_info._name = _name;
|
||||||
thread_info._thread_id = -1;
|
thread_info._thread_id = -1;
|
||||||
thread_info._flags = 0;
|
thread_info._flags = 0;
|
||||||
|
|
||||||
NT_TIB *tib = ((NT_TIB *) NtCurrentTeb ());
|
__try {
|
||||||
|
const DWORD MS_VC_EXCEPTION = 0x406D1388;
|
||||||
|
RaiseException (MS_VC_EXCEPTION, 0,
|
||||||
|
sizeof (thread_info) / sizeof (ULONG_PTR),
|
||||||
|
(ULONG_PTR *) &thread_info);
|
||||||
|
}
|
||||||
|
__except (EXCEPTION_CONTINUE_EXECUTION) {
|
||||||
|
}
|
||||||
|
|
||||||
MY_EXCEPTION_REGISTRATION_RECORD rec;
|
#elif defined(__MINGW32__)
|
||||||
rec.Next = (MY_EXCEPTION_REGISTRATION_RECORD *) tib->ExceptionList;
|
|
||||||
rec.Handler = continue_execution;
|
|
||||||
|
|
||||||
// push our handler, raise, and finally pop our handler
|
int rc = pthread_setname_np (pthread_self (), _name);
|
||||||
tib->ExceptionList = (_EXCEPTION_REGISTRATION_RECORD *) &rec;
|
if (rc)
|
||||||
const DWORD MS_VC_EXCEPTION = 0x406D1388;
|
return;
|
||||||
RaiseException (MS_VC_EXCEPTION, 0,
|
|
||||||
sizeof (thread_info) / sizeof (ULONG_PTR),
|
#else
|
||||||
(ULONG_PTR *) &thread_info);
|
|
||||||
tib->ExceptionList =
|
// not implemented
|
||||||
(_EXCEPTION_REGISTRATION_RECORD
|
|
||||||
*) (((MY_EXCEPTION_REGISTRATION_RECORD *) tib->ExceptionList)->Next);
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#elif defined ZMQ_HAVE_VXWORKS
|
#elif defined ZMQ_HAVE_VXWORKS
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
Reference in New Issue
Block a user