Gdb pretty printer for vwr::Vec.
This commit is contained in:
parent
490009df47
commit
f556bd396f
5 changed files with 49 additions and 0 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -2,3 +2,5 @@ tags
|
||||||
cscope.out
|
cscope.out
|
||||||
cscope.in.out
|
cscope.in.out
|
||||||
cscope.po.out
|
cscope.po.out
|
||||||
|
*.idea/
|
||||||
|
*.pyc
|
||||||
|
|
|
@ -26,6 +26,8 @@ target_include_directories(${PROJECT_NAME}
|
||||||
INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/lib/vectorwrapper/include
|
INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/lib/vectorwrapper/include
|
||||||
)
|
)
|
||||||
|
|
||||||
|
set(gdb_scripts_path "${CMAKE_CURRENT_SOURCE_DIR}/tools/gdb")
|
||||||
|
|
||||||
#add_subdirectory(lib/sprout)
|
#add_subdirectory(lib/sprout)
|
||||||
add_subdirectory(src)
|
add_subdirectory(src)
|
||||||
add_subdirectory(test)
|
add_subdirectory(test)
|
||||||
|
|
|
@ -25,3 +25,5 @@ target_link_libraries(${PROJECT_NAME}
|
||||||
${SDL2_LIBRARIES}
|
${SDL2_LIBRARIES}
|
||||||
${SDL2IMAGE_LIBRARIES}
|
${SDL2IMAGE_LIBRARIES}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
configure_file(${gdb_scripts_path}/libdoorkeeper-gdb.py ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-gdb.py)
|
||||||
|
|
6
tools/gdb/libdoorkeeper-gdb.py
Normal file
6
tools/gdb/libdoorkeeper-gdb.py
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
import sys;
|
||||||
|
sys.path.append("@gdb_scripts_path@");
|
||||||
|
|
||||||
|
import libdoorkeeper;
|
||||||
|
|
||||||
|
libdoorkeeper.register_printers(gdb.current_objfile());
|
37
tools/gdb/libdoorkeeper.py
Normal file
37
tools/gdb/libdoorkeeper.py
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
import gdb;
|
||||||
|
import re;
|
||||||
|
|
||||||
|
class VectorWrapperPrinter:
|
||||||
|
def __init__(self, parVal):
|
||||||
|
self.val = parVal
|
||||||
|
|
||||||
|
def to_string(self):
|
||||||
|
sz = int(self.val["m_wrapped"].type.template_argument(1));
|
||||||
|
arr_vals = ", ".join(str(self.val["m_wrapped"]["_M_elems"][z]) for z in range(0, sz));
|
||||||
|
return "<{0}>".format(arr_vals);
|
||||||
|
|
||||||
|
def vector_wrapper_match(parVal):
|
||||||
|
tag_value = str(parVal.type.strip_typedefs().tag);
|
||||||
|
if tag_value == None:
|
||||||
|
return None;
|
||||||
|
|
||||||
|
reg_vecbase = re.compile("^vwr::implem::VecBase<.*>$");
|
||||||
|
reg_vec = re.compile("^vwr::Vec<.*>$");
|
||||||
|
if reg_vecbase.match(tag_value) or reg_vec.match(tag_value):
|
||||||
|
return VectorWrapperPrinter(parVal);
|
||||||
|
else:
|
||||||
|
return None;
|
||||||
|
|
||||||
|
def display_hint(self):
|
||||||
|
return "array";
|
||||||
|
|
||||||
|
def register_printers(parObjfile):
|
||||||
|
parObjfile.pretty_printers.append(vector_wrapper_match);
|
||||||
|
|
||||||
|
# (gdb) p parFrom
|
||||||
|
# $1 = (const dk::Viewport<2u>::coords &) @0x7fffffffb810: {<vwr::implem::VecBase<std::array<int, 2ul> >> = {m_wrapped = {_M_elems = {0,
|
||||||
|
# 0}}}, <vwr::implem::VecAccessors<std::array<int, 2ul>, 2u>> = {<vwr::implem::Vec2Promotion<std::array<int, 2ul>, true>> = {<No data fields>}, <No data fields>}, static unit_x = <optimized out>, static unit_y = <optimized out>}
|
||||||
|
|
||||||
|
# (gdb) p parFrom
|
||||||
|
# $1 = (const dk::Viewport<2u>::coords &) @0x7fffffffb810: {<vwr::implem::VecBase<std::array<int, 2ul> >> =
|
||||||
|
# {0, 0}, <vwr::implem::VecAccessors<std::array<int, 2ul>, 2u>> = {<vwr::implem::Vec2Promotion<std::array<int, 2ul>, true>> = {<No data fields>}, <No data fields>}, static unit_x = <optimized out>, static unit_y = <optimized out>}
|
Loading…
Reference in a new issue