gdb_printers.hpp 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345
  1. //
  2. // Copyright (c) 2024 Dmitry Arkhipov (grisumbras@yandex.ru)
  3. //
  4. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  5. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. //
  7. // Official repository: https://github.com/boostorg/json
  8. //
  9. // Autogenerated from boost_json_gdb_printers.py by boost-pretty-printers
  10. #ifndef BOOST_JSON_DETAIL_GDB_PRINTERS_HPP
  11. #define BOOST_JSON_DETAIL_GDB_PRINTERS_HPP
  12. #if defined(__ELF__)
  13. #if defined(__clang__)
  14. # pragma clang diagnostic push
  15. # pragma clang diagnostic ignored "-Woverlength-strings"
  16. #elif defined(__GNUC__)
  17. # pragma GCC diagnostic push
  18. # pragma GCC diagnostic ignored "-Woverlength-strings"
  19. #endif
  20. __asm__(
  21. ".pushsection \".debug_gdb_scripts\", \"MS\",%progbits,1\n"
  22. ".ascii \"\\4gdb.inlined-script.BOOST_JSON_DETAIL_GDB_PRINTERS_HPP\\n\"\n"
  23. ".ascii \"import gdb\\n\"\n"
  24. ".ascii \"import gdb.printing\\n\"\n"
  25. ".ascii \"class PrettyPrinterBuilder():\\n\"\n"
  26. ".ascii \" '''decorator that accumulates pretty printers for types'''\\n\"\n"
  27. ".ascii \" def __init__(self, name=None):\\n\"\n"
  28. ".ascii \" self.result = gdb.printing.RegexpCollectionPrettyPrinter(\\n\"\n"
  29. ".ascii \" name or 'Boost.JSON')\\n\"\n"
  30. ".ascii \" def __call__(self, pp=None, ns=None, template=False):\\n\"\n"
  31. ".ascii \" if pp is None:\\n\"\n"
  32. ".ascii \" def decorator(pp):\\n\"\n"
  33. ".ascii \" return self(pp, ns=ns, template=template)\\n\"\n"
  34. ".ascii \" return decorator\\n\"\n"
  35. ".ascii \" typename = getattr(pp, '__name__')\\n\"\n"
  36. ".ascii \" ns = ns or 'boost::json'\\n\"\n"
  37. ".ascii \" self.result.add_printer(\\n\"\n"
  38. ".ascii \" typename,\\n\"\n"
  39. ".ascii \" '^{ns}::{typename}{marker}'.format(\\n\"\n"
  40. ".ascii \" ns=ns,\\n\"\n"
  41. ".ascii \" typename=typename,\\n\"\n"
  42. ".ascii \" marker='<'if template else '$'),\\n\"\n"
  43. ".ascii \" pp)\\n\"\n"
  44. ".ascii \" return pp\\n\"\n"
  45. ".ascii \"pretty_printer = PrettyPrinterBuilder()\\n\"\n"
  46. ".ascii \"class static_property:\\n\"\n"
  47. ".ascii \" '''decorator for lazy evaluation of static members'''\\n\"\n"
  48. ".ascii \" def __init__(self, wrapped):\\n\"\n"
  49. ".ascii \" self.wrapped = wrapped\\n\"\n"
  50. ".ascii \" self.__name__ = wrapped.__name__\\n\"\n"
  51. ".ascii \" self.__doc__ = wrapped.__doc__\\n\"\n"
  52. ".ascii \" def __get__(self, inst, objtype=None):\\n\"\n"
  53. ".ascii \" val = self.wrapped()\\n\"\n"
  54. ".ascii \" if objtype is not None:\\n\"\n"
  55. ".ascii \" setattr(objtype, self.wrapped.__name__, val)\\n\"\n"
  56. ".ascii \" return val\\n\"\n"
  57. ".ascii \"@pretty_printer\\n\"\n"
  58. ".ascii \"class storage_ptr:\\n\"\n"
  59. ".ascii \" '''boost::json::storage_ptr pretty printer'''\\n\"\n"
  60. ".ascii \" @static_property\\n\"\n"
  61. ".ascii \" def _size_t():\\n\"\n"
  62. ".ascii \" return gdb.lookup_type('std::size_t')\\n\"\n"
  63. ".ascii \" @static_property\\n\"\n"
  64. ".ascii \" def _shared_resource_ptr():\\n\"\n"
  65. ".ascii \" return gdb.lookup_type(\\n\"\n"
  66. ".ascii \" 'boost::json::detail::shared_resource').pointer()\\n\"\n"
  67. ".ascii \" @static_property\\n\"\n"
  68. ".ascii \" def _memory_resource_ptr():\\n\"\n"
  69. ".ascii \" return gdb.lookup_type(\\n\"\n"
  70. ".ascii \" 'boost::container::pmr::memory_resource').pointer()\\n\"\n"
  71. ".ascii \" def __init__(self, val):\\n\"\n"
  72. ".ascii \" self.val = val['i_']\\n\"\n"
  73. ".ascii \" def to_string(self):\\n\"\n"
  74. ".ascii \" items = []\\n\"\n"
  75. ".ascii \" if bool(self.val & 2):\\n\"\n"
  76. ".ascii \" items.append('trivial')\\n\"\n"
  77. ".ascii \" shared = bool(self.val & 1)\\n\"\n"
  78. ".ascii \" if shared:\\n\"\n"
  79. ".ascii \" items.append('shared')\\n\"\n"
  80. ".ascii \" pointer = self.val & ~3\\n\"\n"
  81. ".ascii \" if not pointer:\\n\"\n"
  82. ".ascii \" items.append('resource=default')\\n\"\n"
  83. ".ascii \" else:\\n\"\n"
  84. ".ascii \" if shared:\\n\"\n"
  85. ".ascii \" resource = pointer.cast(\\n\"\n"
  86. ".ascii \" self._shared_resource_ptr).dereference()\\n\"\n"
  87. ".ascii \" impl_t = resource.dynamic_type\\n\"\n"
  88. ".ascii \" impl_ptr = impl_t.pointer()\\n\"\n"
  89. ".ascii \" resource = resource.address.cast(impl_ptr).dereference()\\n\"\n"
  90. ".ascii \" items.append(\\n\"\n"
  91. ".ascii \" 'refs=%s' % resource['refs'].cast(self._size_t))\\n\"\n"
  92. ".ascii \" resource = resource['t']\\n\"\n"
  93. ".ascii \" else:\\n\"\n"
  94. ".ascii \" resource = pointer.cast(\\n\"\n"
  95. ".ascii \" self._memory_resource_ptr).dereference()\\n\"\n"
  96. ".ascii \" derived_t = resource.dynamic_type\\n\"\n"
  97. ".ascii \" derived_ptr = derived_t.pointer()\\n\"\n"
  98. ".ascii \" resource = resource.address.cast(derived_ptr).dereference()\\n\"\n"
  99. ".ascii \" items.append('resource=%s' % resource)\\n\"\n"
  100. ".ascii \" return 'storage_ptr [' + ', '.join(items) + ']'\\n\"\n"
  101. ".ascii \"@pretty_printer\\n\"\n"
  102. ".ascii \"class monotonic_resource:\\n\"\n"
  103. ".ascii \" '''boost::json::monotonic_resource pretty printer'''\\n\"\n"
  104. ".ascii \" def __init__(self, val):\\n\"\n"
  105. ".ascii \" self.val = val\\n\"\n"
  106. ".ascii \" def to_string(self):\\n\"\n"
  107. ".ascii \" buffer = self.val['buffer_']\\n\"\n"
  108. ".ascii \" buffer = buffer['p'] - ( int(buffer['size']) - int(buffer['avail']) )\\n\"\n"
  109. ".ascii \" head = self.val['head_'].dereference()\\n\"\n"
  110. ".ascii \" block = head['p'] - ( int(head['size']) - int(head['avail']) )\\n\"\n"
  111. ".ascii \" upstream = self.val['upstream_']\\n\"\n"
  112. ".ascii \" items = []\\n\"\n"
  113. ".ascii \" items.append('buffer=%s' % buffer)\\n\"\n"
  114. ".ascii \" items.append('block=%s' % block)\\n\"\n"
  115. ".ascii \" items.append('head=%s' % head['p'])\\n\"\n"
  116. ".ascii \" items.append('free=%s' % head['avail'])\\n\"\n"
  117. ".ascii \" if upstream['i_'] != 0:\\n\"\n"
  118. ".ascii \" items.append('upstream=%s' % upstream)\\n\"\n"
  119. ".ascii \" return 'monotonic_resource [%s]' % ', '.join(items)\\n\"\n"
  120. ".ascii \"@pretty_printer\\n\"\n"
  121. ".ascii \"class static_resource:\\n\"\n"
  122. ".ascii \" '''boost::json::static_resource pretty printer'''\\n\"\n"
  123. ".ascii \" def __init__(self, val):\\n\"\n"
  124. ".ascii \" self.val = val\\n\"\n"
  125. ".ascii \" def to_string(self):\\n\"\n"
  126. ".ascii \" buf = self.val['p_'] - ( int(self.val['size_']) - int(self.val['n_']) )\\n\"\n"
  127. ".ascii \" return 'static_resource [buffer=%s, head=%s, free=%s]' % (\\n\"\n"
  128. ".ascii \" buf, self.val['p_'], self.val['n_'])\\n\"\n"
  129. ".ascii \"@pretty_printer\\n\"\n"
  130. ".ascii \"class string:\\n\"\n"
  131. ".ascii \" '''boost::json::string pretty printer'''\\n\"\n"
  132. ".ascii \" @static_property\\n\"\n"
  133. ".ascii \" def _char_const_ptr():\\n\"\n"
  134. ".ascii \" return gdb.lookup_type('char').const().pointer()\\n\"\n"
  135. ".ascii \" def __init__(self, val):\\n\"\n"
  136. ".ascii \" self.impl = val['impl_']\\n\"\n"
  137. ".ascii \" def display_hint(self):\\n\"\n"
  138. ".ascii \" return 'string'\\n\"\n"
  139. ".ascii \" def to_string(self):\\n\"\n"
  140. ".ascii \" kind = self.impl['s_']['k']\\n\"\n"
  141. ".ascii \" if kind == self.impl['short_string_']:\\n\"\n"
  142. ".ascii \" sbo_size = self.impl['sbo_chars_']\\n\"\n"
  143. ".ascii \" size = sbo_size - self.impl['s_']['buf'][sbo_size]\\n\"\n"
  144. ".ascii \" pointer = self.impl['s_']['buf']\\n\"\n"
  145. ".ascii \" elif kind == self.impl['key_string_']:\\n\"\n"
  146. ".ascii \" size = self.impl['k_']['n']\\n\"\n"
  147. ".ascii \" pointer = self.impl['k_']['s']\\n\"\n"
  148. ".ascii \" else:\\n\"\n"
  149. ".ascii \" size = self.impl['p_']['t'].dereference()['size']\\n\"\n"
  150. ".ascii \" pointer = self.impl['p_']['t']\\n\"\n"
  151. ".ascii \" pointer += 1\\n\"\n"
  152. ".ascii \" pointer = pointer.cast(self._char_const_ptr)\\n\"\n"
  153. ".ascii \" return pointer.lazy_string(length=size)\\n\"\n"
  154. ".ascii \"@pretty_printer\\n\"\n"
  155. ".ascii \"class array:\\n\"\n"
  156. ".ascii \" '''boost::json::array pretty printer'''\\n\"\n"
  157. ".ascii \" @static_property\\n\"\n"
  158. ".ascii \" def _value_ptr():\\n\"\n"
  159. ".ascii \" return gdb.lookup_type('boost::json::value').pointer()\\n\"\n"
  160. ".ascii \" def __init__(self, val):\\n\"\n"
  161. ".ascii \" self.val = val\\n\"\n"
  162. ".ascii \" def display_hint(self):\\n\"\n"
  163. ".ascii \" return 'array'\\n\"\n"
  164. ".ascii \" def to_string(self):\\n\"\n"
  165. ".ascii \" capacity = int(self.val['t_'].dereference()['capacity'])\\n\"\n"
  166. ".ascii \" return 'array [size={0}, capacity={1}]'.format(\\n\"\n"
  167. ".ascii \" self.num_children(), capacity)\\n\"\n"
  168. ".ascii \" def num_children(self):\\n\"\n"
  169. ".ascii \" return int(self.val['t_'].dereference()['size'])\\n\"\n"
  170. ".ascii \" def children(self):\\n\"\n"
  171. ".ascii \" for i in range(0, self.num_children()):\\n\"\n"
  172. ".ascii \" yield self.child(i)\\n\"\n"
  173. ".ascii \" def child(self, n):\\n\"\n"
  174. ".ascii \" table = (self.val['t_'] + 1).cast(self._value_ptr)\\n\"\n"
  175. ".ascii \" return str(n), table[n]\\n\"\n"
  176. ".ascii \"@pretty_printer\\n\"\n"
  177. ".ascii \"class key_value_pair:\\n\"\n"
  178. ".ascii \" '''boost::json::key_value_pair pretty printer'''\\n\"\n"
  179. ".ascii \" @staticmethod\\n\"\n"
  180. ".ascii \" def _pair(kv):\\n\"\n"
  181. ".ascii \" return kv['key_'].lazy_string(length=kv['len_']), kv['value_']\\n\"\n"
  182. ".ascii \" def __init__(self, val):\\n\"\n"
  183. ".ascii \" self.val = val\\n\"\n"
  184. ".ascii \" def to_string(self):\\n\"\n"
  185. ".ascii \" k, v = self._pair(self.val)\\n\"\n"
  186. ".ascii \" return '[%s] = %s' % (k.value(), v)\\n\"\n"
  187. ".ascii \"@pretty_printer\\n\"\n"
  188. ".ascii \"class object:\\n\"\n"
  189. ".ascii \" '''boost::json::object pretty printer'''\\n\"\n"
  190. ".ascii \" def __init__(self, val):\\n\"\n"
  191. ".ascii \" self.val = val\\n\"\n"
  192. ".ascii \" self.kv_ptr = gdb.lookup_type('boost::json::key_value_pair').pointer()\\n\"\n"
  193. ".ascii \" def display_hint(self):\\n\"\n"
  194. ".ascii \" return 'map'\\n\"\n"
  195. ".ascii \" def to_string(self):\\n\"\n"
  196. ".ascii \" capacity = int(self.val['t_'].dereference()['capacity'])\\n\"\n"
  197. ".ascii \" return 'object [size={}, capacity={}]'.format(\\n\"\n"
  198. ".ascii \" self.num_children(), capacity)\\n\"\n"
  199. ".ascii \" def num_children(self):\\n\"\n"
  200. ".ascii \" return int(self.val['t_'].dereference()['size'])\\n\"\n"
  201. ".ascii \" def children(self):\\n\"\n"
  202. ".ascii \" table = (self.val['t_'] + 1).cast(self.kv_ptr)\\n\"\n"
  203. ".ascii \" for i in range(0, self.num_children()):\\n\"\n"
  204. ".ascii \" k, v = key_value_pair._pair(table[i])\\n\"\n"
  205. ".ascii \" yield str(2 * i), k\\n\"\n"
  206. ".ascii \" yield str(2 * i + 1), v\\n\"\n"
  207. ".ascii \"@pretty_printer\\n\"\n"
  208. ".ascii \"class value:\\n\"\n"
  209. ".ascii \" '''boost::json::value pretty printer'''\\n\"\n"
  210. ".ascii \" @static_property\\n\"\n"
  211. ".ascii \" def _kind_t():\\n\"\n"
  212. ".ascii \" result = gdb.lookup_type('boost::json::kind')\\n\"\n"
  213. ".ascii \" return dict(result.items())\\n\"\n"
  214. ".ascii \" def __init__(self, val):\\n\"\n"
  215. ".ascii \" self.val = val\\n\"\n"
  216. ".ascii \" def to_string(self):\\n\"\n"
  217. ".ascii \" kind = self.val['sca_']['k']\\n\"\n"
  218. ".ascii \" if self._compare_kind(kind, 'null'):\\n\"\n"
  219. ".ascii \" return 'null'\\n\"\n"
  220. ".ascii \" elif self._compare_kind(kind, 'bool_'):\\n\"\n"
  221. ".ascii \" return self.val['sca_']['b']\\n\"\n"
  222. ".ascii \" elif self._compare_kind(kind, 'int64'):\\n\"\n"
  223. ".ascii \" return self.val['sca_']['i']\\n\"\n"
  224. ".ascii \" elif self._compare_kind(kind, 'uint64'):\\n\"\n"
  225. ".ascii \" return self.val['sca_']['u']\\n\"\n"
  226. ".ascii \" elif self._compare_kind(kind, 'double_'):\\n\"\n"
  227. ".ascii \" return self.val['sca_']['d']\\n\"\n"
  228. ".ascii \" elif self._compare_kind(kind, 'array'):\\n\"\n"
  229. ".ascii \" return self.val['arr_']\\n\"\n"
  230. ".ascii \" elif self._compare_kind(kind, 'object'):\\n\"\n"
  231. ".ascii \" return self.val['obj_']\\n\"\n"
  232. ".ascii \" else:\\n\"\n"
  233. ".ascii \" return self.val['str_']\\n\"\n"
  234. ".ascii \" def _compare_kind(self, kind, name):\\n\"\n"
  235. ".ascii \" return kind == self._kind_t['boost::json::kind::' + name].enumval\\n\"\n"
  236. ".ascii \"def register(obj_file):\\n\"\n"
  237. ".ascii \" mod = obj_file or gdb\\n\"\n"
  238. ".ascii \" for printer in getattr(mod, 'pretty_printers', []):\\n\"\n"
  239. ".ascii \" if getattr(printer, 'name') == pretty_printer.result.name:\\n\"\n"
  240. ".ascii \" return\\n\"\n"
  241. ".ascii \" gdb.printing.register_pretty_printer(\\n\"\n"
  242. ".ascii \" obj_file,\\n\"\n"
  243. ".ascii \" pretty_printer.result)\\n\"\n"
  244. ".ascii \"if __name__ == '__main__':\\n\"\n"
  245. ".ascii \" register(gdb.current_objfile())\\n\"\n"
  246. ".byte 0\n"
  247. ".popsection\n");
  248. #if defined(__clang__)
  249. # pragma clang diagnostic pop
  250. #elif defined(__GNUC__)
  251. # pragma GCC diagnostic pop
  252. #endif
  253. #endif // defined(__ELF__)
  254. #endif // BOOST_JSON_DETAIL_GDB_PRINTERS_HPP