in src/producer.rs [307:396]
fn gcno_gcda_producer(
tmp_dir: &Path,
gcno_stem_archives: &FxHashMap<GCNOStem, &Archive>,
gcda_stem_archives: &FxHashMap<String, Vec<&Archive>>,
sender: &JobSender,
ignore_orphan_gcno: bool,
) {
let send_job = |item, name| {
sender
.send(Some(WorkItem {
format: ItemFormat::Gcno,
item,
name,
}))
.unwrap()
};
for (gcno_stem, gcno_archive) in gcno_stem_archives {
let stem = &gcno_stem.stem;
if let Some(gcda_archives) = gcda_stem_archives.get(stem) {
let gcno_archive = *gcno_archive;
let gcno = format!("{}.gcno", stem).to_string();
let physical_gcno_path = tmp_dir.join(format!("{}_{}.gcno", stem, 1));
if gcno_stem.llvm {
let mut gcda_buffers: Vec<Vec<u8>> = Vec::with_capacity(gcda_archives.len());
if let Some(gcno_buffer) = gcno_archive.read(&gcno) {
for gcda_archive in gcda_archives {
let gcda = format!("{}.gcda", stem).to_string();
if let Some(gcda_buf) = gcda_archive.read(&gcda) {
gcda_buffers.push(gcda_buf);
}
}
send_job(
ItemType::Buffers(GcnoBuffers {
stem: stem.clone(),
gcno_buf: gcno_buffer,
gcda_buf: gcda_buffers,
}),
"".to_string(),
);
}
} else {
gcno_archive.extract(&gcno, &physical_gcno_path);
for (num, &gcda_archive) in gcda_archives.iter().enumerate() {
let gcno_path = tmp_dir.join(format!("{}_{}.gcno", stem, num + 1));
let gcda = format!("{}.gcda", stem).to_string();
// Create symlinks.
if num != 0 {
fs::hard_link(&physical_gcno_path, &gcno_path).unwrap_or_else(|_| {
panic!("Failed to create hardlink {:?}", gcno_path)
});
}
let gcda_path = tmp_dir.join(format!("{}_{}.gcda", stem, num + 1));
if gcda_archive.extract(&gcda, &gcda_path) || (num == 0 && !ignore_orphan_gcno)
{
send_job(
ItemType::Path((stem.clone(), gcno_path)),
gcda_archive.get_name().to_string(),
);
}
}
}
} else if !ignore_orphan_gcno {
let gcno_archive = *gcno_archive;
let gcno = format!("{}.gcno", stem).to_string();
if gcno_stem.llvm {
if let Some(gcno_buf) = gcno_archive.read(&gcno) {
send_job(
ItemType::Buffers(GcnoBuffers {
stem: stem.clone(),
gcno_buf,
gcda_buf: Vec::new(),
}),
gcno_archive.get_name().to_string(),
);
}
} else {
let physical_gcno_path = tmp_dir.join(format!("{}_{}.gcno", stem, 1));
if gcno_archive.extract(&gcno, &physical_gcno_path) {
send_job(
ItemType::Path((stem.clone(), physical_gcno_path)),
gcno_archive.get_name().to_string(),
);
}
}
}
}
}