[0.1.x] + classification of data symbol: data kind

git-svn-id: https://pykd.svn.codeplex.com/svn@72739 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
SND\EreTIk_cp 2011-12-28 13:32:50 +00:00 committed by Mikhail I. Izmestev
parent 73cbf9b728
commit 932fc93926
6 changed files with 104 additions and 0 deletions

View File

@ -625,6 +625,8 @@ BOOST_PYTHON_MODULE( pykd )
"Retrieves the unique symbol identifier")
.def( "udtKind", &pyDia::Symbol::getUdtKind,
"Retrieves the variety of a user-defined type")
.def( "dataKind", &pyDia::Symbol::getDataKind,
"Retrieves the variable classification of a data symbol")
.def("registerId", &pyDia::Symbol::getRegisterId,
"Retrieves the register designator of the location:\n"
"CV_REG_XXX (for IMAGE_FILE_MACHINE_I386) or CV_AMD64_XXX (for IMAGE_FILE_MACHINE_AMD64)")
@ -682,6 +684,19 @@ BOOST_PYTHON_MODULE( pykd )
python::scope().attr("diaSymTagName") =
genDict(pyDia::Symbol::symTagName, _countof(pyDia::Symbol::symTagName));
DEF_PY_CONST_ULONG(DataIsUnknown);
DEF_PY_CONST_ULONG(DataIsLocal);
DEF_PY_CONST_ULONG(DataIsStaticLocal);
DEF_PY_CONST_ULONG(DataIsParam);
DEF_PY_CONST_ULONG(DataIsObjectPtr);
DEF_PY_CONST_ULONG(DataIsFileStatic);
DEF_PY_CONST_ULONG(DataIsGlobal);
DEF_PY_CONST_ULONG(DataIsMember);
DEF_PY_CONST_ULONG(DataIsStaticMember);
DEF_PY_CONST_ULONG(DataIsConstant);
python::scope().attr("diaDataKind") =
genDict(pyDia::Symbol::dataKindName, _countof(pyDia::Symbol::dataKindName));
// search options for symbol and file names
DEF_PY_CONST_ULONG(nsfCaseSensitive);
DEF_PY_CONST_ULONG(nsfCaseInsensitive);

View File

@ -43,6 +43,24 @@ const Symbol::ValueNameEntry Symbol::symTagName[SymTagMax] = {
};
#undef _DEF_SYM_TAG_VAL
////////////////////////////////////////////////////////////////////////////////
#define _DEF_DATA_KIND_VAL(x) Symbol::ValueNameEntry(DataIs##x, #x)
const Symbol::ValueNameEntry Symbol::dataKindName[DataIsConstant + 1] = {
_DEF_DATA_KIND_VAL(Unknown),
_DEF_DATA_KIND_VAL(Local),
_DEF_DATA_KIND_VAL(StaticLocal),
_DEF_DATA_KIND_VAL(Param),
_DEF_DATA_KIND_VAL(ObjectPtr),
_DEF_DATA_KIND_VAL(FileStatic),
_DEF_DATA_KIND_VAL(Global),
_DEF_DATA_KIND_VAL(Member),
_DEF_DATA_KIND_VAL(StaticMember),
_DEF_DATA_KIND_VAL(Constant)
};
#undef _DEF_DATA_KIND_VAL
////////////////////////////////////////////////////////////////////////////////
#define _DEF_LOC_TYPE(x) Symbol::ValueNameEntry(LocIs##x, #x)

View File

@ -202,6 +202,13 @@ std::string Symbol::printImpl(
bFuncDebugRange =
(SymTagFuncDebugStart == symTagName[dwValue].first) ||
(SymTagFuncDebugEnd == symTagName[dwValue].first);
hres = _symbol->get_dataKind(&dwValue);
if ((S_OK == hres) && (DataIsUnknown != dwValue))
{
if (dwValue < _countof(dataKindName))
sstream << ", " << dataKindName[dwValue].second;
}
}
else
{

View File

@ -151,6 +151,8 @@ public:
public:
typedef std::pair<ULONG, const char *> ValueNameEntry;
static const ValueNameEntry dataKindName[DataIsConstant + 1];
static const ValueNameEntry symTagName[SymTagMax];
static const ValueNameEntry locTypeName[LocTypeMax];

View File

@ -227,3 +227,12 @@ class DiaTest( unittest.TestCase ):
except pykd.DiaException as diaExcept:
print diaExcept
self.assertTrue(False)
def testDataKind(self):
try:
gScope = pykd.diaLoadPdb( str(target.module.pdb()) )
self.assertEqual( pykd.DataIsGlobal, gScope["g_structTest"].dataKind() )
self.assertEqual( pykd.DataIsParam, gScope["EnumWindowsProc"]["hWindow"].dataKind() )
except pykd.DiaException as diaExcept:
print diaExcept
self.assertTrue(False)

View File

@ -146,6 +146,16 @@ struct listStruct1 {
struct listStruct1 *next;
};
class classWithDestructor
{
public:
classWithDestructor(DWORD errCode) : m_errCode(errCode) {}
virtual ~classWithDestructor() {::SetLastError(m_errCode);}
private:
DWORD m_errCode;
};
listStruct1 g_listItem11 = { 100 };
listStruct1 g_listItem12 = { 200 };
listStruct1 g_listItem13 = { 300 };
@ -217,6 +227,47 @@ void FuncWithName1(int a)
std::cout << g_string;
}
void FuncWithVolatileArg(volatile long *arg1)
{
InterlockedIncrement(arg1);
}
BOOL CALLBACK EnumWindowsProc(
HWND hWindow,
LPARAM lParam
)
{
if (hWindow)
std::cout << lParam;
switch(lParam)
{
case 1:
std::cout << "case 1";
break;
case 2:
std::cout << "case 2";
break;
case 3:
std::cout << "case 2";
break;
default:
{
DWORD dwProccessId = 0;
DWORD dwThreadId = ::GetWindowThreadProcessId(hWindow, &dwProccessId);
std::cout << dwProccessId << dwThreadId;
classWithDestructor classInstance(dwProccessId);
std::cout << GetWindowLong(hWindow, GWL_STYLE);
}
}
return FALSE;
}
#pragma pack( pop )
////////////////////////////////////////////////////////////////////////////////
@ -261,6 +312,8 @@ int _tmain(int argc, _TCHAR* argv[])
__debugbreak();
FuncWithName0();
FuncWithName1(2);
EnumWindows(&::EnumWindowsProc, 6);
}
catch(std::exception & ex)
{