mirror of
https://github.com/ivellioscolin/pykd.git
synced 2025-04-19 19:13:22 +08:00
[0.3.x] fixed : cannot find symbols with msdia120.dll
git-svn-id: https://pykd.svn.codeplex.com/svn@90398 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
parent
1724a42cdb
commit
bc38bf259e
@ -91,7 +91,7 @@
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<TargetExt>.pyd</TargetExt>
|
||||
<TargetName>$(ProjectName)</TargetName>
|
||||
<IntDir>$(SolutionDir)out\$(Platform)\$(Configuration)\</IntDir>
|
||||
<IntDir>$(Platform)\$(Configuration)\</IntDir>
|
||||
<OutDir>$(SolutionDir)out\$(Platform)\$(Configuration)\</OutDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release_2.7|x64'">
|
||||
@ -99,7 +99,7 @@
|
||||
<TargetExt>.pyd</TargetExt>
|
||||
<TargetName>$(ProjectName)</TargetName>
|
||||
<OutDir>$(SolutionDir)out\$(Platform)\$(Configuration)\</OutDir>
|
||||
<IntDir>$(SolutionDir)out\$(Platform)\$(Configuration)\</IntDir>
|
||||
<IntDir>$(Platform)\$(Configuration)\</IntDir>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug_2.7|Win32'">
|
||||
<ClCompile>
|
||||
|
@ -2,7 +2,7 @@
|
||||
#define PYKD_VERSION_MAJOR 0
|
||||
#define PYKD_VERSION_MINOR 3
|
||||
#define PYKD_VERSION_SUBVERSION 0
|
||||
#define PYKD_VERSION_BUILDNO 22
|
||||
#define PYKD_VERSION_BUILDNO 23
|
||||
|
||||
#define __VER_STR2__(x) #x
|
||||
#define __VER_STR1__(x) __VER_STR2__(x)
|
||||
|
@ -3,7 +3,7 @@
|
||||
#define PYKDEXT_VERSION_MAJOR 1
|
||||
#define PYKDEXT_VERSION_MINOR 0
|
||||
#define PYKDEXT_VERSION_SUBVERSION 1
|
||||
#define PYKDEXT_VERSION_BUILDNO 3
|
||||
#define PYKDEXT_VERSION_BUILDNO 5
|
||||
|
||||
#define __VER_STR2__(x) #x
|
||||
#define __VER_STR1__(x) __VER_STR2__(x)
|
||||
|
@ -24,8 +24,6 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
void startConsole();
|
||||
|
||||
void printUsage();
|
||||
|
||||
void printException();
|
||||
@ -154,17 +152,17 @@ KDLIB_EXT_COMMAND_METHOD_IMPL(PykdBootsTrapper, py)
|
||||
return;
|
||||
}
|
||||
else
|
||||
if (args[0] == "-g" || args[0] == "--global")
|
||||
{
|
||||
global = true;
|
||||
args.erase(args.begin());
|
||||
}
|
||||
else
|
||||
if (args[0] == "-l" || args[0] == "--local")
|
||||
{
|
||||
local = true;
|
||||
args.erase(args.begin());
|
||||
}
|
||||
if (args[0] == "-g" || args[0] == "--global")
|
||||
{
|
||||
global = true;
|
||||
args.erase(args.begin());
|
||||
}
|
||||
else
|
||||
if (args[0] == "-l" || args[0] == "--local")
|
||||
{
|
||||
local = true;
|
||||
args.erase(args.begin());
|
||||
}
|
||||
}
|
||||
|
||||
PyThreadState *localState = NULL;
|
||||
@ -172,88 +170,93 @@ KDLIB_EXT_COMMAND_METHOD_IMPL(PykdBootsTrapper, py)
|
||||
|
||||
PyEval_RestoreThread(m_pyState);
|
||||
|
||||
python::handle<> pykdHandle(python::allow_null(PyImport_ImportModule("pykd")));
|
||||
if (!pykdHandle)
|
||||
{
|
||||
m_pyState = PyEval_SaveThread();
|
||||
kdlib::eprintln(L"Pykd package is not installed. You can install it by command \"!pykd.install\"");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
|
||||
std::string scriptFileName;
|
||||
if (args.size() > 0)
|
||||
{
|
||||
scriptFileName = getScriptFileName(args[0]);
|
||||
InterruptWatch interruptWatch;
|
||||
|
||||
if (scriptFileName.empty())
|
||||
|
||||
std::string scriptFileName;
|
||||
if (args.size() > 0)
|
||||
{
|
||||
m_pyState = PyEval_SaveThread();
|
||||
kdlib::eprintln(L"script file not found");
|
||||
return;
|
||||
}
|
||||
scriptFileName = getScriptFileName(args[0]);
|
||||
|
||||
global = !(global || local) ? false : global; //set local by default
|
||||
}
|
||||
else
|
||||
{
|
||||
global = !(global || local) ? true : global; //set global by default
|
||||
}
|
||||
|
||||
if (!global)
|
||||
{
|
||||
globalState = PyThreadState_Swap(NULL);
|
||||
|
||||
Py_NewInterpreter();
|
||||
|
||||
localState = PyThreadState_Get();
|
||||
|
||||
python::object sys = python::import("sys");
|
||||
|
||||
sys.attr("stdout") = python::object(::DbgOut());
|
||||
sys.attr("stderr") = python::object(::DbgOut());
|
||||
sys.attr("stdin") = python::object(::DbgIn());
|
||||
}
|
||||
|
||||
if (args.size() == 0)
|
||||
{
|
||||
startConsole();
|
||||
}
|
||||
else
|
||||
{
|
||||
// óñòàíàâèëèâàåì ïèòîíîâñêèå àðãóìåíòû
|
||||
char **pythonArgs = new char*[args.size()];
|
||||
|
||||
pythonArgs[0] = const_cast<char*>(scriptFileName.c_str());
|
||||
|
||||
for (size_t i = 1; i < args.size(); ++i)
|
||||
pythonArgs[i] = const_cast<char*>(args[i].c_str());
|
||||
|
||||
PySys_SetArgv((int)args.size(), pythonArgs);
|
||||
|
||||
delete[] pythonArgs;
|
||||
|
||||
// ïîëó÷àåì äîñòïó ê ãëîáàëüíîìó ìàïó ( íóæåí äëÿ âûçîâà exec_file )
|
||||
python::object main = python::import("__main__");
|
||||
|
||||
python::object global(main.attr("__dict__"));
|
||||
|
||||
try {
|
||||
InterruptWatch interruptWatch;
|
||||
|
||||
if (!m_pykdInitialized)
|
||||
if (scriptFileName.empty())
|
||||
{
|
||||
python::exec("__import__('pykd').initialize()", global);
|
||||
m_pykdInitialized = true;
|
||||
m_pyState = PyEval_SaveThread();
|
||||
|
||||
kdlib::eprintln(L"script file not found");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
python::exec_file(scriptFileName.c_str(), global);
|
||||
global = !(global || local) ? false : global; //set local by default
|
||||
}
|
||||
catch (python::error_already_set const &)
|
||||
else
|
||||
{
|
||||
printException();
|
||||
global = !(global || local) ? true : global; //set global by default
|
||||
}
|
||||
|
||||
if (!global)
|
||||
{
|
||||
globalState = PyThreadState_Swap(NULL);
|
||||
|
||||
Py_NewInterpreter();
|
||||
|
||||
localState = PyThreadState_Get();
|
||||
|
||||
python::object sys = python::import("sys");
|
||||
|
||||
sys.attr("stdout") = python::object(::DbgOut());
|
||||
sys.attr("stderr") = python::object(::DbgOut());
|
||||
sys.attr("stdin") = python::object(::DbgIn());
|
||||
}
|
||||
|
||||
// ïîëó÷àåì äîñòóï ê ãëîáàëüíîìó ìàïó ( íóæåí äëÿ âûçîâà exec_file )
|
||||
python::object main = python::import("__main__");
|
||||
python::object globalScope(main.attr("__dict__"));
|
||||
|
||||
|
||||
if (!m_pykdInitialized)
|
||||
{
|
||||
python::handle<> pykdHandle(python::allow_null(PyImport_ImportModule("pykd")));
|
||||
if (!pykdHandle)
|
||||
{
|
||||
PyErr_SetString(PyExc_Exception, "Pykd package is not installed. You can install it by command \"!pykd.install\"");
|
||||
python::throw_error_already_set();
|
||||
}
|
||||
|
||||
python::exec("__import__('pykd').initialize()", globalScope);
|
||||
m_pykdInitialized = true;
|
||||
}
|
||||
|
||||
if (args.size() == 0)
|
||||
{
|
||||
python::exec("import pykd", globalScope);
|
||||
python::exec("from pykd import *", globalScope);
|
||||
python::exec("__import__('code').InteractiveConsole(__import__('__main__').__dict__).interact()", globalScope);
|
||||
}
|
||||
else
|
||||
{
|
||||
// óñòàíàâèëèâàåì ïèòîíîâñêèå àðãóìåíòû
|
||||
char **pythonArgs = new char*[args.size()];
|
||||
|
||||
pythonArgs[0] = const_cast<char*>(scriptFileName.c_str());
|
||||
|
||||
for (size_t i = 1; i < args.size(); ++i)
|
||||
pythonArgs[i] = const_cast<char*>(args[i].c_str());
|
||||
|
||||
PySys_SetArgv((int)args.size(), pythonArgs);
|
||||
|
||||
delete[] pythonArgs;
|
||||
|
||||
python::exec_file(scriptFileName.c_str(), globalScope);
|
||||
}
|
||||
}
|
||||
|
||||
catch (python::error_already_set const &)
|
||||
{
|
||||
printException();
|
||||
}
|
||||
|
||||
if (!global)
|
||||
{
|
||||
PyInterpreterState *interpreter = localState->interp;
|
||||
@ -277,6 +280,7 @@ KDLIB_EXT_COMMAND_METHOD_IMPL(PykdBootsTrapper, py)
|
||||
}
|
||||
|
||||
m_pyState = PyEval_SaveThread();
|
||||
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
@ -285,12 +289,13 @@ KDLIB_EXT_COMMAND_METHOD_IMPL(PykdBootsTrapper, install)
|
||||
{
|
||||
PyEval_RestoreThread(m_pyState);
|
||||
|
||||
// ïîëó÷àåì äîñòóï ê ãëîáàëüíîìó ìàïó ( íóæåí äëÿ âûçîâà exec_file )
|
||||
python::object main = python::import("__main__");
|
||||
|
||||
python::object global(main.attr("__dict__"));
|
||||
|
||||
try {
|
||||
|
||||
// ïîëó÷àåì äîñòóï ê ãëîáàëüíîìó ìàïó ( íóæåí äëÿ âûçîâà exec_file )
|
||||
python::object main = python::import("__main__");
|
||||
|
||||
python::object global(main.attr("__dict__"));
|
||||
|
||||
InterruptWatch interruptWatch;
|
||||
|
||||
python::exec("import pip\n", global);
|
||||
@ -312,14 +317,15 @@ KDLIB_EXT_COMMAND_METHOD_IMPL(PykdBootsTrapper, upgrade)
|
||||
{
|
||||
PyEval_RestoreThread(m_pyState);
|
||||
|
||||
// ïîëó÷àåì äîñòóï ê ãëîáàëüíîìó ìàïó ( íóæåí äëÿ âûçîâà exec_file )
|
||||
python::object main = python::import("__main__");
|
||||
|
||||
python::object global(main.attr("__dict__"));
|
||||
|
||||
try {
|
||||
|
||||
InterruptWatch interruptWatch;
|
||||
|
||||
// ïîëó÷àåì äîñòóï ê ãëîáàëüíîìó ìàïó ( íóæåí äëÿ âûçîâà exec_file )
|
||||
python::object main = python::import("__main__");
|
||||
|
||||
python::object global(main.attr("__dict__"));
|
||||
|
||||
python::exec("import pip\n", global);
|
||||
python::exec("pip.logger.consumers = []\n", global);
|
||||
python::exec("pip.main(['install', '--upgrade', 'pykd'])\n", global);
|
||||
@ -372,41 +378,21 @@ void PykdBootsTrapper::tearDown()
|
||||
{
|
||||
PyEval_RestoreThread(m_pyState);
|
||||
|
||||
Py_Finalize();
|
||||
if (m_pykdInitialized)
|
||||
{
|
||||
python::object main = python::import("__main__");
|
||||
python::object globalScope(main.attr("__dict__"));
|
||||
python::exec("__import__('pykd').deinitialize()", globalScope);
|
||||
m_pykdInitialized = false;
|
||||
}
|
||||
|
||||
// Py_Finalize();
|
||||
|
||||
WindbgExtension::tearDown();
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void PykdBootsTrapper::startConsole()
|
||||
{
|
||||
|
||||
// ïîëó÷àåì äîñòóï ê ãëîáàëüíîìó ìàïó ( íóæåí äëÿ âûçîâà exec_file )
|
||||
python::object main = python::import("__main__");
|
||||
|
||||
python::object global(main.attr("__dict__"));
|
||||
|
||||
try {
|
||||
InterruptWatch interruptWatch;
|
||||
|
||||
python::exec("import pykd", global);
|
||||
python::exec("from pykd import *", global);
|
||||
if (!m_pykdInitialized)
|
||||
{
|
||||
python::exec("pykd.initialize()", global);
|
||||
m_pykdInitialized = true;
|
||||
}
|
||||
python::exec("__import__('code').InteractiveConsole(__import__('__main__').__dict__).interact()\n", global);
|
||||
}
|
||||
catch (python::error_already_set const &)
|
||||
{
|
||||
printException();
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void PykdBootsTrapper::printUsage()
|
||||
{
|
||||
kdlib::dprintln(L"usage:");
|
||||
|
Loading…
Reference in New Issue
Block a user