@@ -198,7 +198,7 @@ bool has_flag_attribute(const attribute_sequence& attributes, dw::at name) {
198
198
199
199
std::size_t die_hash (const die& d, const attribute_sequence& attributes) {
200
200
ZoneScoped;
201
-
201
+
202
202
// Ideally, tag would not be part of this hash and all symbols, regardless of tag, would be
203
203
// unique. However, that fails in at least one case:
204
204
//
@@ -221,11 +221,8 @@ std::size_t die_hash(const die& d, const attribute_sequence& attributes) {
221
221
auto tag = d._tag == dw::tag::structure_type ? dw::tag::class_type : d._tag ;
222
222
223
223
// clang-tidy off
224
- return orc::hash_combine (0 ,
225
- static_cast <std::size_t >(d._arch ),
226
- static_cast <std::size_t >(tag),
227
- has_flag_attribute (attributes, dw::at::declaration),
228
- d._path .hash ());
224
+ return orc::hash_combine (0 , static_cast <std::size_t >(d._arch ), static_cast <std::size_t >(tag),
225
+ has_flag_attribute (attributes, dw::at::declaration), d._path .hash ());
229
226
// clang-tidy on
230
227
};
231
228
@@ -575,15 +572,14 @@ pool_string dwarf::implementation::read_debug_str(std::size_t offset) {
575
572
576
573
++total_s;
577
574
578
- thread_local const char * plot_name_k = []{
579
- const char * result = orc::tracy::format_unique (" debug_str cache %s" , orc::tracy::unique_thread_name ());
575
+ thread_local const char * plot_name_k = [] {
576
+ const char * result =
577
+ orc::tracy::format_unique (" debug_str cache %s" , orc::tracy::unique_thread_name ());
580
578
TracyPlotConfig (result, tracy::PlotFormatType::Percentage, true , true , 0 );
581
579
return result;
582
580
}();
583
581
584
- const auto update_zone = [&]{
585
- tracy::Profiler::PlotData (plot_name_k, hit_s / total_s * 100 );
586
- };
582
+ const auto update_zone = [&] { tracy::Profiler::PlotData (plot_name_k, hit_s / total_s * 100 ); };
587
583
#endif // ORC_FEATURE(DEBUG_STR_CACHE)
588
584
589
585
// I tried an implementation that loaded the whole debug_str section into the string pool on
@@ -888,9 +884,7 @@ attribute_value dwarf::implementation::evaluate_exprloc(std::uint32_t expression
888
884
// Useful to see what the whole expression is that this routine is about to evaluate.
889
885
#if ORC_FEATURE(DEBUG) && 0
890
886
std::vector<char > expression (expression_size, 0 );
891
- temp_seek (_s, [&]{
892
- _s.read (&expression[0 ], expression_size);
893
- });
887
+ temp_seek (_s, [&] { _s.read (&expression[0 ], expression_size); });
894
888
#endif // ORC_FEATURE(DEBUG)
895
889
896
890
// clang-format off
@@ -1108,7 +1102,7 @@ attribute_value dwarf::implementation::process_form(const attribute& attr,
1108
1102
1109
1103
attribute_value result;
1110
1104
1111
- const auto handle_reference = [&](std::uint64_t offset){
1105
+ const auto handle_reference = [&](std::uint64_t offset) {
1112
1106
const auto debug_info_offset = _debug_info._offset ;
1113
1107
const auto cu_offset = _cu_address - debug_info_offset;
1114
1108
// REVISIT (fosterbrereton): Possible overflow
@@ -1190,7 +1184,8 @@ attribute_value dwarf::implementation::process_form(const attribute& attr,
1190
1184
}
1191
1185
};
1192
1186
default : {
1193
- // We have a problem if we are passing over an attribute that is needed to determine ODRVs.
1187
+ // We have a problem if we are passing over an attribute that is needed to determine
1188
+ // ODRVs.
1194
1189
assert (nonfatal_attribute (attr._name ));
1195
1190
result.passover ();
1196
1191
auto size = form_length (attr._form , _s);
@@ -1302,8 +1297,9 @@ bool dwarf::implementation::register_sections_done() {
1302
1297
// the name of the compilation unit unless we explicitly ask for it.
1303
1298
//
1304
1299
// DWARF Spec 6.2.4 talking about `directories` (sequence of directory names):
1305
- // The first entry in the sequence is the primary source file whose file name exactly matches
1306
- // that given in the DW_AT_name attribute in the compilation unit debugging information entry.
1300
+ // The first entry in the sequence is the primary source file whose file name exactly
1301
+ // matches that given in the DW_AT_name attribute in the compilation unit debugging
1302
+ // information entry.
1307
1303
_decl_files.push_back (object_file_ancestry (_ofd_index)._ancestors [0 ]);
1308
1304
1309
1305
// Once we've loaded all the necessary DWARF sections, now we start piecing the details
@@ -1430,10 +1426,8 @@ void dwarf::implementation::process_all_dies() {
1430
1426
1431
1427
// Useful for looking up symbols in dwarfdump output.
1432
1428
#if ORC_FEATURE(DEBUG) && 0
1433
- std::cerr << std::hex << " 0x" << (die._debug_info_offset ) << std::dec
1434
- << " : "
1435
- << to_string (die._tag )
1436
- << ' \n ' ;
1429
+ std::cerr << std::hex << " 0x" << (die._debug_info_offset ) << std::dec << " : "
1430
+ << to_string (die._tag ) << ' \n ' ;
1437
1431
#endif // ORC_FEATURE(DEBUG) && 0
1438
1432
1439
1433
// code 0 is reserved; it's a null entry, and signifies the end of siblings.
@@ -1522,6 +1516,21 @@ die_pair dwarf::implementation::fetch_one_die(std::size_t debug_info_offset) {
1522
1516
ZoneScoped;
1523
1517
1524
1518
if (!_ready && !register_sections_done ()) throw std::runtime_error (" dwarf setup failed" );
1519
+
1520
+ // This is a hack for https://github.com/adobe/orc/issues/72. The problem is the file
1521
+ // declaration list is contained in a specific `debug_lines` entry, which is driven by the
1522
+ // `stmt_list` attribute in the `compilation_unit` die that contains this die we are trying to
1523
+ // fetch. (We have observed there can be more than one compilation unit declaration, and thus
1524
+ // more than one `debug_lines` entry, per `debug_info`). However, the way ORC tracks die
1525
+ // information today, we do not cross reference from the compilation unit die to this one, or
1526
+ // give each die its own `debug_lines` offset (which would be the proper solution). The reasons
1527
+ // I am avoiding the latter are 1) it adds an extra 32 bits per die, and 2) in all observed
1528
+ // instances the `debug_lines` offset for user-defined symbols is 0. So, the hack here to save
1529
+ // 32 bits per die is to assume a `debug_lines` offset of 0, read the file list from the
1530
+ // `debug_lines` header, and assume it is the right one. If/when a real-world instance is found
1531
+ // that breaks this assumption, we can fall back on the more memory-expensive option.
1532
+ read_lines (0 );
1533
+
1525
1534
auto die_address = _debug_info._offset + debug_info_offset;
1526
1535
_s.seekg (die_address);
1527
1536
_cu_address = _debug_info._offset ; // not sure if this is correct in all cases
0 commit comments