Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Open sidebar
pykd
pykd
Commits
7d9b0faf
Commit
7d9b0faf
authored
Sep 17, 2019
by
ussrhero
Browse files
added TypeInfo.isStaticField method ( return True if a field is a static field )
parent
0450a3ab
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
66 additions
and
6 deletions
+66
-6
kdlibcpp
kdlibcpp
+1
-1
pykd/pymod.cpp
pykd/pymod.cpp
+8
-0
pykd/pytypeinfo.cpp
pykd/pytypeinfo.cpp
+33
-4
pykd/pytypeinfo.h
pykd/pytypeinfo.h
+14
-1
test/scripts/typeinfo.py
test/scripts/typeinfo.py
+10
-0
No files found.
kdlibcpp
@
58bd6564
Compare
deda36a0
...
58bd6564
Subproject commit
deda36a086494be526a5d62bf1b104cb780d7a07
Subproject commit
58bd65641b0a351204b60f0697d4868241eae198
pykd/pymod.cpp
View file @
7d9b0faf
...
...
@@ -913,6 +913,10 @@ void pykd_init()
"Return offset of the nonstatic field"
)
.
def
(
"fieldOffset"
,
TypeInfoAdapter
::
getElementOffsetByIndex
,
"Return offset of the nonstatic field by index"
)
.
def
(
"isStaticField"
,
TypeInfoAdapter
::
isStaticField
,
"Return True if a field is a static field by field name"
)
.
def
(
"isStaticField"
,
TypeInfoAdapter
::
isStaticFieldByIndex
,
"Return True if a field is a static field by field name"
)
.
def
(
"bitOffset"
,
TypeInfoAdapter
::
getBitOffset
,
"Return bit field's offset"
)
.
def
(
"bitWidth"
,
TypeInfoAdapter
::
getBitWidth
,
...
...
@@ -929,6 +933,8 @@ void pykd_init()
"Return name of struct field by index"
)
.
def
(
"fields"
,
TypeInfoAdapter
::
getFields
,
"Return list of tuple ( filedName, fieldType )"
)
.
def
(
"members"
,
TypeInfoAdapter
::
getMembers
,
"Return list of tuple ( memberName, fieldType ). Only defined member, not inherited from base class"
)
.
def
(
"getNumberMethods"
,
TypeInfoAdapter
::
getMethodsCount
,
"Return number of methods"
)
.
def
(
"method"
,
TypeInfoAdapter
::
getMethodByName
,
...
...
@@ -1049,6 +1055,8 @@ void pykd_init()
"Check if a typedVar object has the specified field"
)
.
def
(
"fields"
,
TypedVarAdapter
::
getFields
,
"Return list of tuple ( filedName, fieldOffset, fieldValue )"
)
.
def
(
"members"
,
TypedVarAdapter
::
getMembers
,
"Return list of tuple ( filedName, fieldOffset, fieldValue )"
)
.
def
(
"fieldName"
,
TypedVarAdapter
::
getElementName
,
"Return name of struct field by index"
)
.
def
(
"method"
,
TypedVarAdapter
::
getMethodByName
,
(
python
::
arg
(
"name"
),
python
::
arg
(
"prototype"
)
=
""
),
...
...
pykd/pytypeinfo.cpp
View file @
7d9b0faf
...
...
@@ -75,7 +75,7 @@ python::tuple findSymbolAndDisp( ULONG64 offset )
///////////////////////////////////////////////////////////////////////////////
python
::
list
TypeInfoAdapter
::
getFields
(
kdlib
::
TypeInfo
&
typeInfo
)
python
::
list
TypeInfoAdapter
::
getFields
(
const
kdlib
::
TypeInfo
Ptr
&
typeInfo
)
{
typedef
boost
::
tuple
<
std
::
wstring
,
kdlib
::
TypeInfoPtr
>
FieldTuple
;
...
...
@@ -85,10 +85,10 @@ python::list TypeInfoAdapter::getFields( kdlib::TypeInfo &typeInfo )
AutoRestorePyState
pystate
;
for
(
size_t
i
=
0
;
i
<
typeInfo
.
getElementCount
();
++
i
)
for
(
size_t
i
=
0
;
i
<
typeInfo
->
getElementCount
();
++
i
)
{
std
::
wstring
name
=
typeInfo
.
getElementName
(
i
);
kdlib
::
TypeInfoPtr
val
=
typeInfo
.
getElement
(
i
);
std
::
wstring
name
=
typeInfo
->
getElementName
(
i
);
kdlib
::
TypeInfoPtr
val
=
typeInfo
->
getElement
(
i
);
lst
.
push_back
(
FieldTuple
(
name
,
val
)
);
}
...
...
@@ -103,6 +103,35 @@ python::list TypeInfoAdapter::getFields( kdlib::TypeInfo &typeInfo )
return
pylst
;
}
python
::
list
TypeInfoAdapter
::
getMembers
(
const
kdlib
::
TypeInfoPtr
&
typeInfo
)
{
typedef
boost
::
tuple
<
std
::
wstring
,
kdlib
::
TypeInfoPtr
>
FieldTuple
;
std
::
list
<
FieldTuple
>
lst
;
do
{
AutoRestorePyState
pystate
;
for
(
size_t
i
=
0
;
i
<
typeInfo
->
getElementCount
();
++
i
)
{
std
::
wstring
name
=
typeInfo
->
getElementName
(
i
);
kdlib
::
TypeInfoPtr
val
=
typeInfo
->
getElement
(
i
);
if
(
!
typeInfo
->
isInheritedMember
(
i
))
lst
.
push_back
(
FieldTuple
(
name
,
val
));
}
}
while
(
false
);
python
::
list
pylst
;
for
(
std
::
list
<
FieldTuple
>::
const_iterator
it
=
lst
.
begin
();
it
!=
lst
.
end
();
++
it
)
pylst
.
append
(
python
::
make_tuple
(
it
->
get
<
0
>
(),
it
->
get
<
1
>
()));
return
pylst
;
}
bool
TypeInfoAdapter
::
hasFieldOrMethod
(
kdlib
::
TypeInfoPtr
&
typeInfo
,
const
std
::
wstring
&
fieldName
)
{
AutoRestorePyState
pystate
;
...
...
pykd/pytypeinfo.h
View file @
7d9b0faf
...
...
@@ -143,6 +143,17 @@ struct TypeInfoAdapter : public kdlib::TypeInfo {
return
typeInfo
.
getElementVa
(
name
);
}
static
bool
isStaticField
(
const
kdlib
::
TypeInfoPtr
&
typeInfo
,
const
std
::
wstring
&
name
)
{
AutoRestorePyState
pystate
;
return
typeInfo
->
isStaticMember
(
name
);
}
static
bool
isStaticFieldByIndex
(
const
kdlib
::
TypeInfoPtr
&
typeInfo
,
size_t
index
)
{
AutoRestorePyState
pystate
;
return
typeInfo
->
isStaticMember
(
index
);
}
static
kdlib
::
TypeInfoPtr
getElementByName
(
kdlib
::
TypeInfo
&
typeInfo
,
const
std
::
wstring
&
name
)
{
...
...
@@ -332,7 +343,9 @@ struct TypeInfoAdapter : public kdlib::TypeInfo {
return
typeInfo
.
str
();
}
static
python
::
list
getFields
(
kdlib
::
TypeInfo
&
typeInfo
);
static
python
::
list
getFields
(
const
kdlib
::
TypeInfoPtr
&
typeInfo
);
static
python
::
list
getMembers
(
const
kdlib
::
TypeInfoPtr
&
typeInfo
);
static
python
::
list
getMethods
(
kdlib
::
TypeInfo
&
typeInfo
);
...
...
test/scripts/typeinfo.py
View file @
7d9b0faf
...
...
@@ -371,3 +371,13 @@ class TypeInfoTest( unittest.TestCase ):
self
.
assertTrue
(
ti
.
isTemplate
)
self
.
assertEqual
([
'int'
,
'TestClassTemplate<int>'
],
ti
.
getTemplateArgs
()
)
def
testMembers
(
self
):
self
.
assertEqual
(
[
'__VFN_table'
,
'__VFN_table'
,
'm_staticConst'
,
'm_staticField'
,
'm_childField'
,
'm_childField2'
,
'm_childField3'
,
'm_enumField'
],
[
member
[
0
]
for
member
in
pykd
.
typeInfo
(
"classChild"
).
members
()
])
def
testIsStaticField
(
self
):
ti
=
pykd
.
typeInfo
(
"classChild"
)
self
.
assertTrue
(
ti
.
isStaticField
(
"m_staticField"
))
self
.
assertFalse
(
ti
.
isStaticField
(
"m_baseField"
))
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment