MCPcopy Create free account
hub / github.com/OpenDDS/OpenDDS / std_string_value

Function std_string_value

tools/scripts/gdbext.py:159–174  ·  view source on GitHub ↗
(value, enc='utf-8')

Source from the content-addressed store, hash-verified

157 return get_byte_slice(value, value.type.strip_typedefs().range()[1] + 1, tuple)
158
159def std_string_value(value, enc='utf-8'):
160 p = value['_M_dataplus']['_M_p']
161 t = value.type.strip_typedefs()
162 if t.name.find("::__cxx11::basic_string") != -1:
163 l = value['_M_string_length']
164 p = p.cast(p.type.strip_typedefs())
165 else:
166 if t.code == gdb.TYPE_CODE_REF:
167 t = t.target()
168 real = t.unqualified().strip_typedefs()
169 rep = gdb.lookup_type(str(real) + '::_Rep').pointer()
170 l = (ptr.cast(rep) - 1).dereference()['_M_length']
171 string = get_byte_slice(p, l, bytes)
172 if enc is not None:
173 string = string.decode(enc)
174 return string
175
176
177def _std_values(StdPrinter, value):

Callers 2

get_discoveriesFunction · 0.85
get_transportsFunction · 0.85

Calls 3

strFunction · 0.85
get_byte_sliceFunction · 0.85
findMethod · 0.45

Tested by

no test coverage detected