FOLLY_SAFE_CHECK(p, "invalid null-terminated string");
folly::StringPiece ret(sp.data(), p);
sp.assign(p + 1, sp.end());
FOLLY_SAFE_CHECK(p, "invalid null-terminated string");
folly::StringPiece ret(sp.data(), p);
sp.assign(p + 1, sp.end());
-Dwarf::Path::Path(folly::StringPiece baseDir, folly::StringPiece subDir,
- folly::StringPiece file)
- : baseDir_(baseDir),
- subDir_(subDir),
- file_(file) {
+Dwarf::Path::Path(
+ folly::StringPiece baseDir,
+ folly::StringPiece subDir,
+ folly::StringPiece file)
+ : baseDir_(baseDir), subDir_(subDir), file_(file) {
- case DW_FORM_addr:
- return read<uintptr_t>(sp);
- case DW_FORM_block1:
- return readBytes(sp, read<uint8_t>(sp));
- case DW_FORM_block2:
- return readBytes(sp, read<uint16_t>(sp));
- case DW_FORM_block4:
- return readBytes(sp, read<uint32_t>(sp));
- case DW_FORM_block: // fallthrough
- case DW_FORM_exprloc:
- return readBytes(sp, readULEB(sp));
- case DW_FORM_data1: // fallthrough
- case DW_FORM_ref1:
- return read<uint8_t>(sp);
- case DW_FORM_data2: // fallthrough
- case DW_FORM_ref2:
- return read<uint16_t>(sp);
- case DW_FORM_data4: // fallthrough
- case DW_FORM_ref4:
- return read<uint32_t>(sp);
- case DW_FORM_data8: // fallthrough
- case DW_FORM_ref8:
- return read<uint64_t>(sp);
- case DW_FORM_sdata:
- return readSLEB(sp);
- case DW_FORM_udata: // fallthrough
- case DW_FORM_ref_udata:
- return readULEB(sp);
- case DW_FORM_flag:
- return read<uint8_t>(sp);
- case DW_FORM_flag_present:
- return 1;
- case DW_FORM_sec_offset: // fallthrough
- case DW_FORM_ref_addr:
- return readOffset(sp, is64Bit);
- case DW_FORM_string:
- return readNullTerminated(sp);
- case DW_FORM_strp:
- return getStringFromStringSection(readOffset(sp, is64Bit));
- case DW_FORM_indirect: // form is explicitly specified
- return readAttributeValue(sp, readULEB(sp), is64Bit);
- default:
- FOLLY_SAFE_CHECK(false, "invalid attribute form");
+ case DW_FORM_addr:
+ return read<uintptr_t>(sp);
+ case DW_FORM_block1:
+ return readBytes(sp, read<uint8_t>(sp));
+ case DW_FORM_block2:
+ return readBytes(sp, read<uint16_t>(sp));
+ case DW_FORM_block4:
+ return readBytes(sp, read<uint32_t>(sp));
+ case DW_FORM_block: // fallthrough
+ case DW_FORM_exprloc:
+ return readBytes(sp, readULEB(sp));
+ case DW_FORM_data1: // fallthrough
+ case DW_FORM_ref1:
+ return read<uint8_t>(sp);
+ case DW_FORM_data2: // fallthrough
+ case DW_FORM_ref2:
+ return read<uint16_t>(sp);
+ case DW_FORM_data4: // fallthrough
+ case DW_FORM_ref4:
+ return read<uint32_t>(sp);
+ case DW_FORM_data8: // fallthrough
+ case DW_FORM_ref8:
+ return read<uint64_t>(sp);
+ case DW_FORM_sdata:
+ return readSLEB(sp);
+ case DW_FORM_udata: // fallthrough
+ case DW_FORM_ref_udata:
+ return readULEB(sp);
+ case DW_FORM_flag:
+ return read<uint8_t>(sp);
+ case DW_FORM_flag_present:
+ return 1;
+ case DW_FORM_sec_offset: // fallthrough
+ case DW_FORM_ref_addr:
+ return readOffset(sp, is64Bit);
+ case DW_FORM_string:
+ return readNullTerminated(sp);
+ case DW_FORM_strp:
+ return getStringFromStringSection(readOffset(sp, is64Bit));
+ case DW_FORM_indirect: // form is explicitly specified
+ return readAttributeValue(sp, readULEB(sp), is64Bit);
+ default:
+ FOLLY_SAFE_CHECK(false, "invalid attribute form");
- case DW_AT_stmt_list:
- // Offset in .debug_line for the line number VM program for this
- // compilation unit
- lineOffset = boost::get<uint64_t>(val);
- foundLineOffset = true;
- break;
- case DW_AT_comp_dir:
- // Compilation directory
- compilationDirectory = boost::get<folly::StringPiece>(val);
- break;
- case DW_AT_name:
- // File name of main file being compiled
- mainFileName = boost::get<folly::StringPiece>(val);
- break;
+ case DW_AT_stmt_list:
+ // Offset in .debug_line for the line number VM program for this
+ // compilation unit
+ lineOffset = boost::get<uint64_t>(val);
+ foundLineOffset = true;
+ break;
+ case DW_AT_comp_dir:
+ // Compilation directory
+ compilationDirectory = boost::get<folly::StringPiece>(val);
+ break;
+ case DW_AT_name:
+ // File name of main file being compiled
+ mainFileName = boost::get<folly::StringPiece>(val);
+ break;
- case DW_LNS_copy:
- basicBlock_ = false;
- prologueEnd_ = false;
- epilogueBegin_ = false;
- discriminator_ = 0;
- return COMMIT;
- case DW_LNS_advance_pc:
- address_ += minLength_ * readULEB(program);
- return CONTINUE;
- case DW_LNS_advance_line:
- line_ += readSLEB(program);
- return CONTINUE;
- case DW_LNS_set_file:
- file_ = readULEB(program);
- return CONTINUE;
- case DW_LNS_set_column:
- column_ = readULEB(program);
- return CONTINUE;
- case DW_LNS_negate_stmt:
- isStmt_ = !isStmt_;
- return CONTINUE;
- case DW_LNS_set_basic_block:
- basicBlock_ = true;
- return CONTINUE;
- case DW_LNS_const_add_pc:
- address_ += minLength_ * ((255 - opcodeBase_) / lineRange_);
- return CONTINUE;
- case DW_LNS_fixed_advance_pc:
- address_ += read<uint16_t>(program);
- return CONTINUE;
- case DW_LNS_set_prologue_end:
- if (version_ == 2) break; // not supported in version 2
- prologueEnd_ = true;
- return CONTINUE;
- case DW_LNS_set_epilogue_begin:
- if (version_ == 2) break; // not supported in version 2
- epilogueBegin_ = true;
- return CONTINUE;
- case DW_LNS_set_isa:
- if (version_ == 2) break; // not supported in version 2
- isa_ = readULEB(program);
- return CONTINUE;
+ case DW_LNS_copy:
+ basicBlock_ = false;
+ prologueEnd_ = false;
+ epilogueBegin_ = false;
+ discriminator_ = 0;
+ return COMMIT;
+ case DW_LNS_advance_pc:
+ address_ += minLength_ * readULEB(program);
+ return CONTINUE;
+ case DW_LNS_advance_line:
+ line_ += readSLEB(program);
+ return CONTINUE;
+ case DW_LNS_set_file:
+ file_ = readULEB(program);
+ return CONTINUE;
+ case DW_LNS_set_column:
+ column_ = readULEB(program);
+ return CONTINUE;
+ case DW_LNS_negate_stmt:
+ isStmt_ = !isStmt_;
+ return CONTINUE;
+ case DW_LNS_set_basic_block:
+ basicBlock_ = true;
+ return CONTINUE;
+ case DW_LNS_const_add_pc:
+ address_ += minLength_ * ((255 - opcodeBase_) / lineRange_);
+ return CONTINUE;
+ case DW_LNS_fixed_advance_pc:
+ address_ += read<uint16_t>(program);
+ return CONTINUE;
+ case DW_LNS_set_prologue_end:
+ if (version_ == 2) {
+ break; // not supported in version 2
+ }
+ prologueEnd_ = true;
+ return CONTINUE;
+ case DW_LNS_set_epilogue_begin:
+ if (version_ == 2) {
+ break; // not supported in version 2
+ }
+ epilogueBegin_ = true;
+ return CONTINUE;
+ case DW_LNS_set_isa:
+ if (version_ == 2) {
+ break; // not supported in version 2
+ }
+ isa_ = readULEB(program);
+ return CONTINUE;
- case DW_LNE_end_sequence:
- return END;
- case DW_LNE_set_address:
- address_ = read<uintptr_t>(program);
- return CONTINUE;
- case DW_LNE_define_file:
- // We can't process DW_LNE_define_file here, as it would require us to
- // use unbounded amounts of state (ie. use the heap). We'll do a second
- // pass (using nextDefineFile()) if necessary.
- break;
- case DW_LNE_set_discriminator:
- discriminator_ = readULEB(program);
- return CONTINUE;
+ case DW_LNE_end_sequence:
+ return END;
+ case DW_LNE_set_address:
+ address_ = read<uintptr_t>(program);
+ return CONTINUE;
+ case DW_LNE_define_file:
+ // We can't process DW_LNE_define_file here, as it would require us to
+ // use unbounded amounts of state (ie. use the heap). We'll do a second
+ // pass (using nextDefineFile()) if necessary.
+ break;
+ case DW_LNE_set_discriminator:
+ discriminator_ = readULEB(program);
+ return CONTINUE;