-
-
Notifications
You must be signed in to change notification settings - Fork 77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[debuginfo] No error in functions iterator on name errors #201
Merged
Merged
Changes from 2 commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -507,11 +507,11 @@ impl<'d, 'a> DwarfUnit<'d, 'a> { | |
} | ||
|
||
/// Resolves line records of a DIE's range list and puts them into the given buffer. | ||
fn resolve_lines(&self, ranges: &[Range]) -> Result<Vec<LineInfo<'d>>, DwarfError> { | ||
fn resolve_lines(&self, ranges: &[Range]) -> Vec<LineInfo<'d>> { | ||
// Early exit in case this unit did not declare a line program. | ||
let line_program = match self.line_program { | ||
Some(ref program) => program, | ||
None => return Ok(Vec::new()), | ||
None => return Vec::new(), | ||
}; | ||
|
||
let mut last = None; | ||
|
@@ -524,7 +524,11 @@ impl<'d, 'a> DwarfUnit<'d, 'a> { | |
lines.reserve(rows.len()); | ||
|
||
for row in rows { | ||
let file = self.resolve_file(row.file_index)?.unwrap(); | ||
let file = self | ||
.resolve_file(row.file_index) | ||
.ok() | ||
.flatten() | ||
.unwrap_or_default(); | ||
let line = row.line.unwrap_or(0); | ||
|
||
if let Some((last_file, last_line)) = last { | ||
|
@@ -543,7 +547,7 @@ impl<'d, 'a> DwarfUnit<'d, 'a> { | |
} | ||
} | ||
|
||
Ok(lines) | ||
lines | ||
} | ||
|
||
/// Resolves file information from a line program. | ||
|
@@ -643,18 +647,21 @@ impl<'d, 'a> DwarfUnit<'d, 'a> { | |
|
||
let name = match symbol_name { | ||
Some(name) => Some(name), | ||
None => self.inner.resolve_function_name(entry)?, | ||
None => self.inner.resolve_function_name(entry).ok().flatten(), | ||
}; | ||
|
||
// Avoid constant allocations by collecting repeatedly into the same buffer and | ||
// draining the results out of it. This keeps the original buffer allocated and | ||
// allows for a single allocation per call to `resolve_lines`. | ||
let lines = self.resolve_lines(&range_buf)?; | ||
let lines = self.resolve_lines(&range_buf); | ||
|
||
let function = Function { | ||
address: function_address, | ||
size: function_size, | ||
name: Name::with_language(name.unwrap_or_default(), self.language), | ||
name: Name::with_language( | ||
name.unwrap_or_else(|| Cow::from("<name omitted>")), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you leave this an empty string and coerce in the caller? We rely on this being empty in Sentry since we show our own placeholders which have semantic meaning. |
||
self.language, | ||
), | ||
compilation_dir: self.compilation_dir(), | ||
lines, | ||
inlinees: Vec::new(), | ||
|
@@ -674,36 +681,39 @@ impl<'d, 'a> DwarfUnit<'d, 'a> { | |
// file for inlined subprograms. If this info is missing, the lookup might | ||
// return invalid line numbers. | ||
if let (Some(line), Some(file_id)) = (call_line, call_file) { | ||
if let Some(file) = self.resolve_file(file_id)? { | ||
match parent | ||
.lines | ||
.binary_search_by_key(&function_address, |line| line.address) | ||
{ | ||
Ok(idx) => { | ||
// We found a line record that points to this function. This happens | ||
// especially, if the function range overlaps exactly. Patch the | ||
// call info with the correct location. | ||
parent.lines[idx].file = file; | ||
parent.lines[idx].line = line; | ||
} | ||
Err(idx) => { | ||
let size = parent | ||
.lines | ||
.get(idx) | ||
.map(|next| next.address - function_address); | ||
|
||
// There is no line record pointing to this function, so add one to | ||
// the correct call location. Note that "base_dir" can be inherited | ||
// safely here. | ||
let line_info = LineInfo { | ||
address: function_address, | ||
size, | ||
file, | ||
line, | ||
}; | ||
|
||
parent.lines.insert(idx, line_info); | ||
} | ||
let file = self | ||
.resolve_file(file_id) | ||
.ok() | ||
.flatten() | ||
.unwrap_or_default(); | ||
match parent | ||
.lines | ||
.binary_search_by_key(&function_address, |line| line.address) | ||
{ | ||
Ok(idx) => { | ||
// We found a line record that points to this function. This happens | ||
// especially, if the function range overlaps exactly. Patch the | ||
// call info with the correct location. | ||
parent.lines[idx].file = file; | ||
parent.lines[idx].line = line; | ||
} | ||
Err(idx) => { | ||
let size = parent | ||
.lines | ||
.get(idx) | ||
.map(|next| next.address - function_address); | ||
|
||
// There is no line record pointing to this function, so add one to | ||
// the correct call location. Note that "base_dir" can be inherited | ||
// safely here. | ||
let line_info = LineInfo { | ||
address: function_address, | ||
size, | ||
file, | ||
line, | ||
}; | ||
|
||
parent.lines.insert(idx, line_info); | ||
} | ||
} | ||
} | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since both usages now only require an option, can you change the function signature to
Option<FileInfo>
?