diff --git a/pykd/dbgext.cpp b/pykd/dbgext.cpp index a98d1ab..77cb8fc 100644 --- a/pykd/dbgext.cpp +++ b/pykd/dbgext.cpp @@ -260,29 +260,22 @@ py( PDEBUG_CLIENT4 client, PCSTR args) } if ( argsList.size() == 0 ) - return S_OK; + return S_OK; - if ( argsList.size() > 1 ) - { - char **pythonArgs = new char* [ argsList.size() - 1 ]; - - for ( size_t i = 0; i < argsList.size() - 1; ++i ) - pythonArgs[i] = const_cast( argsList[i+1].c_str() ); - - PySys_SetArgv( (int)argsList.size() - 1, pythonArgs ); + char **pythonArgs = new char* [ argsList.size() ]; + + for ( size_t i = 0; i < argsList.size(); ++i ) + pythonArgs[i] = const_cast( argsList[i].c_str() ); + + PySys_SetArgv( (int)argsList.size(), pythonArgs ); + + delete[] pythonArgs; - delete[] pythonArgs; - } - else - { - char *emptyParam = ""; - - PySys_SetArgv( 1, &emptyParam ); - } // найти путь к файлу std::string fullFileName; std::string filePath; + DbgPythonPath dbgPythonPath; if ( dbgPythonPath.findPath( argsList[0], fullFileName, filePath ) ) { @@ -453,7 +446,7 @@ pythonpath( PDEBUG_CLIENT4 client, PCSTR args ) SetupDebugEngine( client, &ext ); dbgExt = &ext; - DbgPrint::dprintln( dbgPythonPath.getStr() ); + //DbgPrint::dprintln( dbgPythonPath.getStr() ); return S_OK; } diff --git a/pykd/dbgpath.cpp b/pykd/dbgpath.cpp index d975e8d..9cf549c 100644 --- a/pykd/dbgpath.cpp +++ b/pykd/dbgpath.cpp @@ -3,14 +3,12 @@ #include "dbgpath.h" #include +#include /////////////////////////////////////////////////////////////////////////////// -DbgPythonPath &dbgPythonPath = DbgPythonPath(); -/////////////////////////////////////////////////////////////////////////////// - DbgPythonPath::DbgPythonPath() { DWORD enviromentSize = 0; @@ -62,6 +60,16 @@ DbgPythonPath::findPath( std::string &fullFileName, std::string &filePath ) const { + std::vector< std::string > extPathList; + + boost::python::object sys = boost::python::import( "sys"); + + boost::python::list pathList( sys.attr("path") ); + + boost::python::ssize_t n = boost::python::len(pathList); + for(boost::python::ssize_t i=0;i( pathList[i] ) ); + bool pyExt = fileName.rfind( ".py" ) == fileName.length() - 3; // 1. Ищем в рабочей директории @@ -97,9 +105,9 @@ DbgPythonPath::findPath( // 2. Ищем во всех директориях, указанных в m_pathList - std::vector::const_iterator it = m_pathList.begin(); + std::vector::const_iterator it = extPathList.begin(); - for ( ; it != m_pathList.end(); ++it ) + for ( ; it != extPathList.end(); ++it ) { DWORD bufSize = SearchPathA( diff --git a/pykd/dbgpath.h b/pykd/dbgpath.h index 17a59f2..5ba7051 100644 --- a/pykd/dbgpath.h +++ b/pykd/dbgpath.h @@ -27,7 +27,7 @@ private: }; -extern DbgPythonPath& dbgPythonPath; +//extern DbgPythonPath& dbgPythonPath; /////////////////////////////////////////////////////////////////////////////// \ No newline at end of file