mirror of
https://github.com/ivellioscolin/pykd.git
synced 2025-04-20 03:23:23 +08:00
[0.1.x] issue #10393: name of poiner to void, name of pointer to function
git-svn-id: https://pykd.svn.codeplex.com/svn@74349 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
parent
2b989073cb
commit
f15f01a155
@ -218,14 +218,33 @@ BitFieldTypeInfo::BitFieldTypeInfo( pyDia::SymbolPtr &symbol )
|
|||||||
|
|
||||||
PointerTypeInfo::PointerTypeInfo( pyDia::SymbolPtr &symbol )
|
PointerTypeInfo::PointerTypeInfo( pyDia::SymbolPtr &symbol )
|
||||||
{
|
{
|
||||||
|
pyDia::SymbolPtr pointTo = symbol->getType();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
m_derefType = TypeInfo::getTypeInfo( symbol->getType() );
|
m_derefType = TypeInfo::getTypeInfo( pointTo );
|
||||||
}
|
}
|
||||||
catch (const SymbolException &)
|
catch (const SymbolException &)
|
||||||
{
|
{
|
||||||
m_derefType.swap( TypeInfoPtr() );
|
m_derefType.swap( TypeInfoPtr() );
|
||||||
}
|
}
|
||||||
|
if (!derefPossible())
|
||||||
|
{
|
||||||
|
// special cases:
|
||||||
|
const ULONG symTag = pointTo->getSymTag();
|
||||||
|
switch (symTag)
|
||||||
|
{
|
||||||
|
// * pointer to function
|
||||||
|
case SymTagFunctionType:
|
||||||
|
m_derefName = "<function>";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SymTagBaseType:
|
||||||
|
// * pointer to Void
|
||||||
|
if (btVoid == static_cast<BasicType>(pointTo->getBaseType()))
|
||||||
|
m_derefName = "Void";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
m_size = (ULONG)symbol->getSize();
|
m_size = (ULONG)symbol->getSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -295,6 +314,7 @@ std::string TypeInfo::getComplexName()
|
|||||||
std::string name;
|
std::string name;
|
||||||
TypeInfo *typeInfo = this;
|
TypeInfo *typeInfo = this;
|
||||||
|
|
||||||
|
std::string tiName;
|
||||||
do {
|
do {
|
||||||
|
|
||||||
if ( typeInfo->isArray() )
|
if ( typeInfo->isArray() )
|
||||||
@ -326,16 +346,24 @@ std::string TypeInfo::getComplexName()
|
|||||||
{
|
{
|
||||||
name.insert( 0, 1, '*' );
|
name.insert( 0, 1, '*' );
|
||||||
|
|
||||||
typeInfo = dynamic_cast<PointerTypeInfo*>(typeInfo)->getDerefType().get();
|
PointerTypeInfo *ptrTypeInfo = dynamic_cast<PointerTypeInfo*>(typeInfo);
|
||||||
|
if (!ptrTypeInfo->derefPossible())
|
||||||
|
{
|
||||||
|
tiName = ptrTypeInfo->getDerefName();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
typeInfo = ptrTypeInfo->getDerefType().get();
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tiName = typeInfo->getName();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
} while ( true );
|
} while ( true );
|
||||||
|
|
||||||
name.insert( 0, typeInfo->getName() );
|
name.insert( 0, tiName );
|
||||||
|
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
@ -285,9 +285,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
virtual TypeInfoPtr deref() {
|
virtual TypeInfoPtr deref() {
|
||||||
if (!m_derefType)
|
return getDerefType();
|
||||||
throw TypeException("<ptr>", "this pointer can not be dereferenced");
|
|
||||||
return m_derefType;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TypeInfoPtr getDerefType() {
|
TypeInfoPtr getDerefType() {
|
||||||
@ -296,11 +294,21 @@ public:
|
|||||||
return m_derefType;
|
return m_derefType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool derefPossible() const {
|
||||||
|
return m_derefType;
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::string getDerefName() const {
|
||||||
|
if (m_derefName.empty())
|
||||||
|
throw TypeException("<ptr>", "this pointer can not be dereferenced");
|
||||||
|
return m_derefName;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
TypeInfoPtr m_derefType;
|
TypeInfoPtr m_derefType;
|
||||||
|
|
||||||
ULONG m_size;
|
ULONG m_size;
|
||||||
|
std::string m_derefName;
|
||||||
};
|
};
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -117,6 +117,8 @@ class TypeInfoTest( unittest.TestCase ):
|
|||||||
self.assertEqual( "listStruct1*[2]", target.module.type( "g_arrOfListStruct1" ).name())
|
self.assertEqual( "listStruct1*[2]", target.module.type( "g_arrOfListStruct1" ).name())
|
||||||
self.assertEqual( "Void*", target.module.type( "g_voidPtr" ).name() )
|
self.assertEqual( "Void*", target.module.type( "g_voidPtr" ).name() )
|
||||||
self.assertEqual( "Void*[3]", target.module.type( "g_arrOfVoidPtr" ).name())
|
self.assertEqual( "Void*[3]", target.module.type( "g_arrOfVoidPtr" ).name())
|
||||||
|
self.assertEqual( "<function>*", target.module.type( "g_ptrToFunction" ).name())
|
||||||
|
self.assertEqual( "<function>*[4]", target.module.type( "g_arrOfPtrToFunc" ).name())
|
||||||
|
|
||||||
def testUnion(self):
|
def testUnion(self):
|
||||||
ti = target.module.type("unionTest")
|
ti = target.module.type("unionTest")
|
||||||
|
@ -170,6 +170,12 @@ void *g_arrOfVoidPtr[] = {
|
|||||||
g_voidPtr, g_voidPtr, g_voidPtr
|
g_voidPtr, g_voidPtr, g_voidPtr
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// kd> x targetapp!g_arrOfPtrToFunc
|
||||||
|
// xxxxxxxx`xxxxxxxx targetapp!g_arrOfPtrToFunc = <function> *[4]
|
||||||
|
WNDPROC g_arrOfPtrToFunc[] = {
|
||||||
|
NULL, NULL, NULL, NULL
|
||||||
|
};
|
||||||
|
|
||||||
struct listStruct1 {
|
struct listStruct1 {
|
||||||
int num;
|
int num;
|
||||||
struct listStruct1 *next;
|
struct listStruct1 *next;
|
||||||
@ -310,6 +316,9 @@ void FuncWithName1(int a)
|
|||||||
std::cout << g_unNamedStruct.m_fieldOfUnNamed;
|
std::cout << g_unNamedStruct.m_fieldOfUnNamed;
|
||||||
std::cout << g_structWithNested.m_field;
|
std::cout << g_structWithNested.m_field;
|
||||||
std::cout << g_ptrToFunction;
|
std::cout << g_ptrToFunction;
|
||||||
|
|
||||||
|
std::cout << g_ptrToFunction;
|
||||||
|
std::cout << g_arrOfPtrToFunc[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
Loading…
Reference in New Issue
Block a user