Fix corner cases on Windows dump_syms

- don't do iter decrement when the map empty.
- add dummy file with id equals to 0 to represent unknown file.

Change-Id: I3fe55a459c9fa835bbe0c4272e4ac12b1150c034
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3425732
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
This commit is contained in:
Zequan Wu 2022-01-28 16:49:10 -08:00 committed by Joshua Peraza
parent d55a5f3dca
commit 08bd844599

View file

@ -343,8 +343,10 @@ void PDBSourceLineWriter::Lines::AddLine(const Line& line) {
do { do {
auto iter = line_map_.lower_bound(line.rva); auto iter = line_map_.lower_bound(line.rva);
if (iter == line_map_.end()) { if (iter == line_map_.end()) {
--iter; if (!line_map_.empty()) {
intercept(iter->second); --iter;
intercept(iter->second);
}
break; break;
} }
is_intercept = false; is_intercept = false;
@ -570,6 +572,10 @@ bool PDBSourceLineWriter::PrintSourceFiles() {
return false; return false;
} }
// Print a dummy file with id equals 0 to represent unknown file, because
// inline records might have unknown call site.
fwprintf(output_, L"FILE %d unknown file\n", 0);
CComPtr<IDiaSymbol> compiland; CComPtr<IDiaSymbol> compiland;
ULONG count; ULONG count;
while (SUCCEEDED(compilands->Next(1, &compiland, &count)) && count == 1) { while (SUCCEEDED(compilands->Next(1, &compiland, &count)) && count == 1) {