MCPcopy Create free account
hub / github.com/crossuo/crossuo / resolve_string

Function resolve_string

external/tracy/libbacktrace/dwarf.cpp:1372–1420  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1370 offset. */
1371
1372static int
1373resolve_string (const struct dwarf_sections *dwarf_sections, int is_dwarf64,
1374 int is_bigendian, uint64_t str_offsets_base,
1375 const struct attr_val *val,
1376 backtrace_error_callback error_callback, void *data,
1377 const char **string)
1378{
1379 switch (val->encoding)
1380 {
1381 case ATTR_VAL_STRING:
1382 *string = val->u.string;
1383 return 1;
1384
1385 case ATTR_VAL_STRING_INDEX:
1386 {
1387 uint64_t offset;
1388 struct dwarf_buf offset_buf;
1389
1390 offset = val->u.uint * (is_dwarf64 ? 8 : 4) + str_offsets_base;
1391 if (offset + (is_dwarf64 ? 8 : 4)
1392 >= dwarf_sections->size[DEBUG_STR_OFFSETS])
1393 {
1394 error_callback (data, "DW_FORM_strx value out of range", 0);
1395 return 0;
1396 }
1397
1398 offset_buf.name = ".debug_str_offsets";
1399 offset_buf.start = dwarf_sections->data[DEBUG_STR_OFFSETS];
1400 offset_buf.buf = dwarf_sections->data[DEBUG_STR_OFFSETS] + offset;
1401 offset_buf.left = dwarf_sections->size[DEBUG_STR_OFFSETS] - offset;
1402 offset_buf.is_bigendian = is_bigendian;
1403 offset_buf.error_callback = error_callback;
1404 offset_buf.data = data;
1405 offset_buf.reported_underflow = 0;
1406
1407 offset = read_offset (&offset_buf, is_dwarf64);
1408 if (offset >= dwarf_sections->size[DEBUG_STR])
1409 {
1410 dwarf_buf_error (&offset_buf, "DW_FORM_strx offset out of range");
1411 return 0;
1412 }
1413 *string = (const char *) dwarf_sections->data[DEBUG_STR] + offset;
1414 return 1;
1415 }
1416
1417 default:
1418 return 1;
1419 }
1420}
1421
1422/* Set *ADDRESS to the real address for a ATTR_VAL_ADDRESS_INDEX.
1423 Return 1 on success, 0 on error. */

Callers 4

find_address_rangesFunction · 0.85
read_lnctFunction · 0.85
read_referenced_nameFunction · 0.85
read_function_entryFunction · 0.85

Calls 3

error_callbackFunction · 0.85
read_offsetFunction · 0.85
dwarf_buf_errorFunction · 0.85

Tested by

no test coverage detected