Skip to content
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

Fix reporting of non-statement rows in DWARF backtrace #8499

Merged
merged 2 commits into from Jan 7, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
42 changes: 24 additions & 18 deletions src/debug/dwarf/line_numbers.cr
Expand Up @@ -359,24 +359,30 @@ module Debug
@current_sequence_matrix : Array(Row)?

private def register_to_matrix(sequence, registers)
file = sequence.file_names[registers.file]
path = sequence.include_directories[file[1]]

row = Row.new(
registers.address,
registers.op_index,
path,
file[0],
registers.line.to_i,
registers.column.to_i,
registers.end_sequence
)

if rows = @current_sequence_matrix
rows << row
else
matrix << (rows = [row])
@current_sequence_matrix = rows
# checking is_stmt should be enough to avoid "non statement" operations
# some of which have confusing line number 0.
# but some operations within macros seem to be useful and marked as !is_stmt
# so attempt to include them also
if registers.is_stmt || (registers.line.to_i > 0 && registers.column.to_i > 0)
rdp marked this conversation as resolved.
Show resolved Hide resolved
file = sequence.file_names[registers.file]
path = sequence.include_directories[file[1]]

row = Row.new(
registers.address,
registers.op_index,
path,
file[0],
registers.line.to_i,
registers.column.to_i,
registers.end_sequence
)

if rows = @current_sequence_matrix
rows << row
else
matrix << (rows = [row])
@current_sequence_matrix = rows
end
end

if registers.end_sequence
Expand Down