| 273 | } |
| 274 | |
| 275 | void blink::pdb_reader::read_source_files(std::vector<std::vector<std::filesystem::path>> &source_files, source_file_map &file_map) |
| 276 | { |
| 277 | stream_reader stream(msf_reader::stream(3)); |
| 278 | |
| 279 | const pdb_dbi_header &header = stream.read<pdb_dbi_header>(); |
| 280 | if (header.signature != 0xFFFFFFFF) |
| 281 | return; |
| 282 | |
| 283 | // Find file information stream (https://llvm.org/docs/PDB/DbiStream.html#file-info-substream) |
| 284 | stream.skip(header.module_info_size + header.section_contribution_size + header.section_map_size); |
| 285 | |
| 286 | const uint16_t num_modules = stream.read<uint16_t>(); |
| 287 | stream.skip(2); // Skip old number of file names (see comment on counting the number below) |
| 288 | |
| 289 | // Ignoring since it is not useful: const uint16_t *const module_file_offsets = stream.data<uint16_t>(); |
| 290 | const uint16_t *const module_num_source_files = stream.data<uint16_t>(num_modules * sizeof(uint16_t)); |
| 291 | const uint32_t *const file_name_offsets = stream.data<uint32_t>(num_modules * sizeof(uint16_t) * 2); |
| 292 | |
| 293 | // Count number of source files instead of reading the value from the header, since there may be more source files that would fit into a 16-bit value |
| 294 | uint32_t num_source_files = 0; |
| 295 | for (uint16_t i = 0; i < num_modules; ++i) |
| 296 | num_source_files += module_num_source_files[i]; |
| 297 | |
| 298 | stream.skip(num_modules * sizeof(uint16_t) * 2 + num_source_files * sizeof(uint32_t)); |
| 299 | const auto offset = stream.tell(); |
| 300 | |
| 301 | // Append source files to array |
| 302 | size_t n = source_files.size(); |
| 303 | source_files.resize(n + num_modules); |
| 304 | |
| 305 | uint32_t file_name_offset_index = 0; |
| 306 | for (uint32_t k = 0; k < num_modules; ++k) |
| 307 | { |
| 308 | uint16_t num_files = module_num_source_files[k]; |
| 309 | source_files[n + k].resize(num_files); |
| 310 | |
| 311 | for (uint32_t i = 0; i < num_files; ++i) |
| 312 | { |
| 313 | stream.seek(offset + file_name_offsets[file_name_offset_index]); |
| 314 | source_file_indices indices; |
| 315 | indices.module = n + k; |
| 316 | indices.file = i; |
| 317 | source_files[indices.module][indices.file] = stream.read_string(); |
| 318 | file_map.insert(std::make_pair(source_files[indices.module][indices.file], indices)); |
| 319 | file_name_offset_index += 1; |
| 320 | } |
| 321 | } |
| 322 | } |
| 323 | |
| 324 | void blink::pdb_reader::read_link_info(std::filesystem::path &cwd, std::string &cmd) |
| 325 | { |
no test coverage detected