in folly/experimental/symbolizer/DwarfLineNumberVM.cpp [59:178]
LineNumberAttribute readLineNumberAttribute(
bool is64Bit,
folly::StringPiece& format,
folly::StringPiece& entries,
folly::StringPiece debugStr,
folly::StringPiece debugLineStr) {
uint64_t contentTypeCode = readULEB(format);
uint64_t formCode = readULEB(format);
boost::variant<uint64_t, folly::StringPiece> attrValue;
switch (contentTypeCode) {
case DW_LNCT_path: {
switch (formCode) {
case DW_FORM_string:
attrValue = readNullTerminated(entries);
break;
case DW_FORM_line_strp: {
auto off = readOffset(entries, is64Bit);
attrValue = getStringFromStringSection(debugLineStr, off);
} break;
case DW_FORM_strp:
attrValue = getStringFromStringSection(
debugStr, readOffset(entries, is64Bit));
break;
case DW_FORM_strp_sup:
FOLLY_SAFE_CHECK(false, "Unexpected DW_FORM_strp_sup");
break;
default:
FOLLY_SAFE_CHECK(
false, "Unexpected form for DW_LNCT_path: ", formCode);
break;
}
} break;
case DW_LNCT_directory_index: {
switch (formCode) {
case DW_FORM_data1:
attrValue = read<uint8_t>(entries);
break;
case DW_FORM_data2:
attrValue = read<uint16_t>(entries);
break;
case DW_FORM_udata:
attrValue = readULEB(entries);
break;
default:
FOLLY_SAFE_CHECK(
false, "Unexpected form for DW_LNCT_directory_index: ", formCode);
break;
}
} break;
case DW_LNCT_timestamp: {
switch (formCode) {
case DW_FORM_udata:
attrValue = readULEB(entries);
break;
case DW_FORM_data4:
attrValue = read<uint32_t>(entries);
break;
case DW_FORM_data8:
attrValue = read<uint64_t>(entries);
break;
case DW_FORM_block:
attrValue = readBytes(entries, readULEB(entries));
break;
default:
FOLLY_SAFE_CHECK(
false, "Unexpected form for DW_LNCT_timestamp: ", formCode);
}
} break;
case DW_LNCT_size: {
switch (formCode) {
case DW_FORM_udata:
attrValue = readULEB(entries);
break;
case DW_FORM_data1:
attrValue = read<uint8_t>(entries);
break;
case DW_FORM_data2:
attrValue = read<uint16_t>(entries);
break;
case DW_FORM_data4:
attrValue = read<uint32_t>(entries);
break;
case DW_FORM_data8:
attrValue = read<uint64_t>(entries);
break;
default:
FOLLY_SAFE_CHECK(
false, "Unexpected form for DW_LNCT_size: ", formCode);
break;
}
} break;
case DW_LNCT_MD5: {
switch (formCode) {
case DW_FORM_data16:
attrValue = readBytes(entries, 16);
break;
default:
FOLLY_SAFE_CHECK(
false, "Unexpected form for DW_LNCT_MD5: ", formCode);
break;
}
} break;
default:
// TODO: skip over vendor data as specified by the form instead.
FOLLY_SAFE_CHECK(
false, "Unexpected vendor content type code: ", contentTypeCode);
break;
}
return {
.contentTypeCode = contentTypeCode,
.formCode = formCode,
.attrValue = attrValue,
};
}