mirror of
https://github.com/ivellioscolin/pykd.git
synced 2025-04-21 04:13:22 +08:00
[0.2.x] fixed : issue # 12324 ( windbg crash after exception in the multithreading script )
git-svn-id: https://pykd.svn.codeplex.com/svn@85785 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
parent
843ab7ac07
commit
16dc23f44f
@ -192,10 +192,12 @@ HRESULT
|
|||||||
CALLBACK
|
CALLBACK
|
||||||
py( PDEBUG_CLIENT4 client, PCSTR args )
|
py( PDEBUG_CLIENT4 client, PCSTR args )
|
||||||
{
|
{
|
||||||
|
|
||||||
WindbgGlobalSession::RestorePyState();
|
WindbgGlobalSession::RestorePyState();
|
||||||
|
|
||||||
PyThreadState *globalInterpreter = PyThreadState_Swap( NULL );
|
PyThreadState *globalInterpreter = PyThreadState_Swap( NULL );
|
||||||
PyThreadState *localInterpreter = Py_NewInterpreter();
|
|
||||||
|
PyThreadState *localState = Py_NewInterpreter();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
@ -235,7 +237,8 @@ py( PDEBUG_CLIENT4 client, PCSTR args )
|
|||||||
|
|
||||||
if ( argsList.size() == 0 )
|
if ( argsList.size() == 0 )
|
||||||
{
|
{
|
||||||
Py_EndInterpreter( localInterpreter );
|
Py_EndInterpreter( localState );
|
||||||
|
|
||||||
PyThreadState_Swap( globalInterpreter );
|
PyThreadState_Swap( globalInterpreter );
|
||||||
|
|
||||||
WindbgGlobalSession::SavePyState();
|
WindbgGlobalSession::SavePyState();
|
||||||
@ -243,33 +246,37 @@ py( PDEBUG_CLIENT4 client, PCSTR args )
|
|||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
char **pythonArgs = new char* [ argsList.size() ];
|
|
||||||
|
|
||||||
for ( size_t i = 0; i < argsList.size(); ++i )
|
|
||||||
pythonArgs[i] = const_cast<char*>( argsList[i].c_str() );
|
|
||||||
|
|
||||||
PySys_SetArgv( (int)argsList.size(), pythonArgs );
|
|
||||||
|
|
||||||
delete[] pythonArgs;
|
|
||||||
|
|
||||||
// íàéòè ïóòü ê ôàéëó
|
// íàéòè ïóòü ê ôàéëó
|
||||||
std::string fullScriptName;
|
std::string fullScriptName;
|
||||||
DbgPythonPath dbgPythonPath;
|
DbgPythonPath dbgPythonPath;
|
||||||
|
|
||||||
if ( !dbgPythonPath.getFullFileName( argsList[0], fullScriptName ) )
|
if ( dbgPythonPath.getFullFileName( argsList[0], fullScriptName ) )
|
||||||
{
|
{
|
||||||
eprintln( L"script file not found" );
|
char **pythonArgs = new char* [ argsList.size() ];
|
||||||
|
|
||||||
|
for ( size_t i = 1; i < argsList.size(); ++i )
|
||||||
|
pythonArgs[i] = const_cast<char*>( argsList[i].c_str() );
|
||||||
|
|
||||||
|
pythonArgs[0] = const_cast<char*>( fullScriptName.c_str() );
|
||||||
|
|
||||||
|
PySys_SetArgv( (int)argsList.size(), pythonArgs );
|
||||||
|
|
||||||
|
delete[] pythonArgs;
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
python::object result;
|
||||||
|
|
||||||
|
result = python::exec_file( fullScriptName.c_str(), global, global );
|
||||||
|
}
|
||||||
|
catch( boost::python::error_already_set const & )
|
||||||
|
{
|
||||||
|
printException();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
try {
|
|
||||||
|
|
||||||
python::object result;
|
|
||||||
|
|
||||||
result = python::exec_file( fullScriptName.c_str(), global, global );
|
|
||||||
}
|
|
||||||
catch( boost::python::error_already_set const & )
|
|
||||||
{
|
{
|
||||||
printException();
|
eprintln( L"script file not found" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch(...)
|
catch(...)
|
||||||
@ -277,7 +284,41 @@ py( PDEBUG_CLIENT4 client, PCSTR args )
|
|||||||
eprintln( L"unexpected error" );
|
eprintln( L"unexpected error" );
|
||||||
}
|
}
|
||||||
|
|
||||||
Py_EndInterpreter( localInterpreter );
|
PyInterpreterState *interpreter = localState->interp;
|
||||||
|
|
||||||
|
while( interpreter->tstate_head != NULL )
|
||||||
|
{
|
||||||
|
PyThreadState *threadState = (PyThreadState*)(interpreter->tstate_head);
|
||||||
|
|
||||||
|
PyThreadState_Clear(threadState);
|
||||||
|
|
||||||
|
PyThreadState_Swap( NULL );
|
||||||
|
|
||||||
|
//interpreter->tstate_head = threadState->next;
|
||||||
|
|
||||||
|
PyThreadState_Delete(threadState);
|
||||||
|
}
|
||||||
|
|
||||||
|
PyInterpreterState_Clear(interpreter);
|
||||||
|
|
||||||
|
PyInterpreterState_Delete(interpreter);
|
||||||
|
|
||||||
|
//Py_EndInterpreter( localInterpreter );
|
||||||
|
|
||||||
|
//std::list<PyThreadState*> localThreadsState;
|
||||||
|
//localThread = PyInterpreterState_ThreadHead( localInterpreter );
|
||||||
|
//while( localThread )
|
||||||
|
//{
|
||||||
|
// localThreadsState.push_back(localThread);
|
||||||
|
// localThread = PyThreadState_Next(localThread);
|
||||||
|
//}
|
||||||
|
|
||||||
|
//std::for_each( localThreadsState.begin(), localThreadsState.end(), PyThreadState_Clear );
|
||||||
|
//std::for_each( localThreadsState.begin(), localThreadsState.end(), PyThreadState_Delete );
|
||||||
|
|
||||||
|
//PyInterpreterState_Clear( localInterpreter );
|
||||||
|
//PyInterpreterState_Delete( localInterpreter );
|
||||||
|
|
||||||
PyThreadState_Swap( globalInterpreter );
|
PyThreadState_Swap( globalInterpreter );
|
||||||
|
|
||||||
WindbgGlobalSession::SavePyState();
|
WindbgGlobalSession::SavePyState();
|
||||||
|
Loading…
Reference in New Issue
Block a user