dash/contrib/auto_gdb/common_helpers.py
gladcow 1c9ed7806a GDB automation with Python script to measure memory usage in dashd (#1609)
* standart STL containers and Masternode-related classes processing

* masternode-related classes

* fix st containers processing,  use reflection to process simple classes

* Content descrioption in README.md

* Increase python scripts performance

Use gdb objects instead strings and type info for creating Pyton wrappers

* fixed simple classes list

* addition to README

* fix nits

* missed `the`

Co-Authored-By: gladcow <sergey@dash.org>

* fix nits

Co-Authored-By: gladcow <sergey@dash.org>

* fixed grammatical issues

Co-Authored-By: gladcow <sergey@dash.org>

* fixed phrase construction

Co-Authored-By: gladcow <sergey@dash.org>

* missed point

Co-Authored-By: gladcow <sergey@dash.org>

* fixed grammatical issues

Co-Authored-By: gladcow <sergey@dash.org>

* remove double space

Co-Authored-By: gladcow <sergey@dash.org>

* fixed grammatical issues

Co-Authored-By: gladcow <sergey@dash.org>
2018-10-23 14:15:08 +03:00

58 lines
1.6 KiB
Python

#!/usr/bin/python
#
try:
import gdb
except ImportError as e:
raise ImportError("This script must be run in GDB: ", str(e))
import sys
import os
sys.path.append(os.getcwd())
import stl_containers
import simple_class_obj
SIZE_OF_INT = 4
SIZE_OF_BOOL = 1
SIZE_OF_INT64 = 8
SIZE_OF_UINT256 = 32
def get_special_type_obj(gobj):
obj_type = gobj.type.strip_typedefs()
if stl_containers.VectorObj.is_this_type(obj_type):
return stl_containers.VectorObj(gobj)
if stl_containers.ListObj.is_this_type(obj_type):
return stl_containers.ListObj(gobj)
if stl_containers.PairObj.is_this_type(obj_type):
return stl_containers.PairObj(gobj)
if stl_containers.MapObj.is_this_type(obj_type):
return stl_containers.MapObj(gobj)
if stl_containers.SetObj.is_this_type(obj_type):
return stl_containers.SetObj(gobj)
if simple_class_obj.SimpleClassObj.is_this_type(obj_type):
return simple_class_obj.SimpleClassObj(gobj)
return False
def is_special_type(obj_type):
if stl_containers.VectorObj.is_this_type(obj_type):
return True
if stl_containers.ListObj.is_this_type(obj_type):
return True
if stl_containers.PairObj.is_this_type(obj_type):
return True
if stl_containers.MapObj.is_this_type(obj_type):
return True
if stl_containers.SetObj.is_this_type(obj_type):
return True
if simple_class_obj.SimpleClassObj.is_this_type(obj_type):
return True
return False
def get_instance_size(gobj):
obj = get_special_type_obj(gobj)
if not obj:
return gobj.type.sizeof
return obj.get_used_size()