From 06d0b22778c43bace677d2407128479e96a5371a Mon Sep 17 00:00:00 2001 From: Kyle Huey Date: Thu, 22 Aug 2024 07:11:20 -0700 Subject: [PATCH] Support more than one debug dir from the gdb script. --- src/SourcesCommand.cc | 46 +++++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 23 deletions(-) mode change 100644 => 100755 src/SourcesCommand.cc diff --git a/src/SourcesCommand.cc b/src/SourcesCommand.cc old mode 100644 new mode 100755 index 2c5aaecd0f4..f0d39fc3f65 --- a/src/SourcesCommand.cc +++ b/src/SourcesCommand.cc @@ -815,32 +815,32 @@ static bool try_debuglink_file(ElfFileReader& trace_file_reader, dd = debug_dirs->process_one_binary(original_file_name); } - const string* chosen_debug_dir = nullptr; - if (!dd.debug_file_directories.empty()) { - // XXXkhuey what do we do if there's more than one directory? - chosen_debug_dir = &dd.debug_file_directories.back(); - } - const string* chosen_src_dir = nullptr; - if (!dd.source_directories.empty()) { - chosen_src_dir = &dd.source_directories.back(); - } + for (auto chosen_debug_dir : dd.debug_file_directories) { + const string* chosen_src_dir = nullptr; + if (!dd.source_directories.empty()) { + chosen_src_dir = &dd.source_directories.back(); + } - bool has_source_files = process_auxiliary_file(trace_file_reader, *reader, altlink_reader.get(), + bool has_source_files = process_auxiliary_file(trace_file_reader, *reader, altlink_reader.get(), + trace_relative_name, original_file_name, + file_names, full_file_name, DEBUGLINK, + comp_dir_substitutions, output_comp_dir_substitutions, + &chosen_debug_dir, chosen_src_dir, + dwos, external_debug_info, false, dir_exists_cache); + + if (altlink_reader) { + has_source_files |= process_auxiliary_file(trace_file_reader, *altlink_reader, nullptr, trace_relative_name, original_file_name, - file_names, full_file_name, DEBUGLINK, + file_names, full_altfile_name, DEBUGALTLINK, comp_dir_substitutions, output_comp_dir_substitutions, - chosen_debug_dir, chosen_src_dir, - dwos, external_debug_info, false, dir_exists_cache); - - if (altlink_reader) { - has_source_files |= process_auxiliary_file(trace_file_reader, *altlink_reader, nullptr, - trace_relative_name, original_file_name, - file_names, full_altfile_name, DEBUGALTLINK, - comp_dir_substitutions, output_comp_dir_substitutions, - chosen_debug_dir, chosen_src_dir, - dwos, external_debug_info, has_source_files, dir_exists_cache); - } - return has_source_files; + &chosen_debug_dir, chosen_src_dir, + dwos, external_debug_info, has_source_files, dir_exists_cache); + } + if (has_source_files) { + return true; + } + } + return false; } struct Symlink {