我正在尝试调试Python2.7以了解有关python如何工作的更多信息。
当我尝试在第4399行调试ceval.c时,我注意到我无法在IDE中看到arg
的值,我检查了优化已禁用且/ DEBUG选项已启用。
arg
有一个值,代码是
执行。dv
命令尝试使用WinDbg,它仍然无法看到任何内容
局部变量我的编译命令是:
/GS /analyze- /W3 /Gy /Zc:wchar_t /I"H:\project\cpython-2.7\Include" /I"H:\project\cpython-2.7\PC" /Zi /Gm- /Od /Fd"H:\project\cpython-2.7\PCbuild\obj\win32_Debug\python\vc120.pdb" /fp:precise /D "_CONSOLE" /D "WIN32" /D "_WIN32" /D "_DEBUG" /D "_MBCS" /errorReport:prompt /GF /WX- /Zc:forScope /Gd /Oy- /MDd /Fa"H:\project\cpython-2.7\PCbuild\obj\win32_Debug\python\" /nologo /Fo"H:\project\cpython-2.7\PCbuild\obj\win32_Debug\python\" /Fp"H:\project\cpython-2.7\PCbuild\obj\win32_Debug\python\python_d.pch"
我的链接命令是:
/OUT:"H:\project\cpython-2.7\PCBuild\python_d.exe" /MANIFEST:NO /NXCOMPAT /PDB:"H:\project\cpython-2.7\PCBuild\python_d.pdb" /DYNAMICBASE "kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib" "comdlg32.lib" "advapi32.lib" "shell32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib" "odbc32.lib" "odbccp32.lib" "H:\project\cpython-2.7\PCBuild\python27_d.lib" /STACK:"2000000" /DEBUG /BASE:"0x1d000000" /MACHINE:X86 /NODEFAULTLIB:"LIBC" /SAFESEH /PGD:"H:\project\cpython-2.7\PCBuild\python_d.pgd" /SUBSYSTEM:CONSOLE /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /ManifestFile:"H:\project\cpython-2.7\PCbuild\obj\win32_Debug\python\python_d.exe.intermediate.manifest" /ERRORREPORT:PROMPT /NOLOGO /LIBPATH:"H:\project\cpython-2.7\PCBuild\" /TLBID:1
到目前为止,我只能阅读pp_stack
和oparg
,我无法读取任何局部变量的值
static PyObject *
call_function(PyObject ***pp_stack, int oparg
#ifdef WITH_TSC
, uint64* pintr0, uint64* pintr1
#endif
)
{
int na = oparg & 0xff;
int nk = (oparg>>8) & 0xff;
int n = na + 2 * nk;
PyObject **pfunc = (*pp_stack) - n - 1;
PyObject *func = *pfunc;
PyObject *x, *w;
/* Always dispatch PyCFunction first, because these are
presumed to be the most frequent callable object.
*/
if (PyCFunction_Check(func) && nk == 0) {
int flags = PyCFunction_GET_FLAGS(func);
PyThreadState *tstate = PyThreadState_GET();
PCALL(PCALL_CFUNCTION);
if (flags & (METH_NOARGS | METH_O)) {
PyCFunction meth = PyCFunction_GET_FUNCTION(func);
PyObject *self = PyCFunction_GET_SELF(func);
if (flags & METH_NOARGS && na == 0) {
C_TRACE(x, (*meth)(self,NULL));
}
else if (flags & METH_O && na == 1) {
//PyObject *arg = EXT_POP(*pp_stack);
//EXT_POP-------------------
PyObject *arg = (PyObject*)((void)(lltrace && prtrace((*pp_stack)[-1], "ext_pop")), *--(*pp_stack));
所以在这种情况下,问题出在哪里?为什么我看不到IDE的价值?