MCPcopy Create free account
hub / github.com/aclements/libelfin / to_string

Function to_string

dwarf/value.cc:286–334  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

284}
285
286string
287to_string(const value &v)
288{
289 switch (v.get_type()) {
290 case value::type::invalid:
291 return "<invalid value type>";
292 case value::type::address:
293 return "0x" + to_hex(v.as_address());
294 case value::type::block: {
295 size_t size;
296 const char *b = (const char*)v.as_block(&size);
297 string res = ::to_string(size) + " byte block:";
298 for (size_t pos = 0; pos < size; ++pos) {
299 res += ' ';
300 res += to_hex(b[pos]);
301 }
302 return res;
303 }
304 case value::type::constant:
305 return "0x" + to_hex(v.as_uconstant());
306 case value::type::uconstant:
307 return ::to_string(v.as_uconstant());
308 case value::type::sconstant:
309 return ::to_string(v.as_sconstant());
310 case value::type::exprloc:
311 // XXX
312 return "<exprloc>";
313 case value::type::flag:
314 return v.as_flag() ? "true" : "false";
315 case value::type::line:
316 return "<line 0x" + to_hex(v.as_sec_offset()) + ">";
317 case value::type::loclist:
318 return "<loclist 0x" + to_hex(v.as_sec_offset()) + ">";
319 case value::type::mac:
320 return "<mac 0x" + to_hex(v.as_sec_offset()) + ">";
321 case value::type::rangelist:
322 return "<rangelist 0x" + to_hex(v.as_sec_offset()) + ">";
323 case value::type::reference: {
324 die d = v.as_reference();
325 auto tu = dynamic_cast<const type_unit*>(&d.get_unit());
326 if (tu)
327 return "<.debug_types+0x" + to_hex(d.get_section_offset()) + ">";
328 return "<0x" + to_hex(d.get_section_offset()) + ">";
329 }
330 case value::type::string:
331 return v.as_string();
332 }
333 return "<unexpected value type " + to_string(v.get_type()) + ">";
334}
335
336DWARFPP_END_NAMESPACE

Callers 15

as_addressMethod · 0.85
as_blockMethod · 0.85
as_uconstantMethod · 0.85
as_sconstantMethod · 0.85
as_exprlocMethod · 0.85
as_flagMethod · 0.85
as_referenceMethod · 0.85
as_cstrMethod · 0.85
as_sec_offsetMethod · 0.85
_at_udynamicFunction · 0.85
at_high_pcFunction · 0.85
at_data_member_locationFunction · 0.85

Calls 11

to_hexFunction · 0.85
get_typeMethod · 0.80
as_addressMethod · 0.80
as_blockMethod · 0.80
as_uconstantMethod · 0.80
as_sconstantMethod · 0.80
as_flagMethod · 0.80
as_sec_offsetMethod · 0.80
as_referenceMethod · 0.80
as_stringMethod · 0.80
get_section_offsetMethod · 0.45

Tested by

no test coverage detected