问题
I am trying to debug Python2.7 to understand more about how python works.
when I trying to debug ceval.c at line 4399, I noticed I cant see value of arg
in my IDE, I checked optimization is disabled and /DEBUG option is on.
- I looked disassembly and I do see
arg
have a value, code was executed. - I tried to debug in both VS2013 and VS2017, both are the same even PDB is loaded
- I tried with WinDbg using
dv
command ,it's still unable to see any local variables
my compile command is :
/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"
my link command is :
/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
so far I can only read pp_stack
and oparg
,I can't read value of any local variables
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));
so in this case, where is the problem at? why I cant see the value from IDE?
来源:https://stackoverflow.com/questions/50727989/debugging-with-vs2013-on-a-program-with-no-optimization-but-still-there-is-no-sy