Skip to content

Commit e2a32d0

Browse files
committed
Data diff view: Make rows show offset within the symbol, not within the section
1 parent 0306d93 commit e2a32d0

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

objdiff-gui/src/views/data_diff.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,8 @@ fn get_hover_item_color_for_diff_kind(diff_kind: DataDiffKind) -> HoverItemColor
115115
pub(crate) fn data_row_ui(
116116
ui: &mut egui::Ui,
117117
obj: Option<&Object>,
118-
address: usize,
118+
base_address: usize,
119+
row_address: usize,
119120
diffs: &[(DataDiff, Vec<DataRelocationDiff>)],
120121
appearance: &Appearance,
121122
column: usize,
@@ -127,15 +128,15 @@ pub(crate) fn data_row_ui(
127128
}
128129
let mut job = LayoutJob::default();
129130
write_text(
130-
format!("{address:08x}: ").as_str(),
131+
format!("{row_address:08x}: ").as_str(),
131132
appearance.text_color,
132133
&mut job,
133134
appearance.code_font.clone(),
134135
);
135136
// The offset shown on the side of the GUI, shifted by insertions/deletions.
136137
let mut cur_addr = 0usize;
137138
// The offset into the actual bytes of the section on this side, ignoring differences.
138-
let mut cur_addr_actual = address;
139+
let mut cur_addr_actual = base_address + row_address;
139140
for (diff, reloc_diffs) in diffs {
140141
let base_color = get_color_for_diff_kind(diff.kind, appearance);
141142
if diff.data.is_empty() {

objdiff-gui/src/views/diff.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -507,13 +507,14 @@ pub fn diff_view_ui(
507507
total_rows,
508508
|row, column| {
509509
let i = row.index();
510-
let address = i * BYTES_PER_ROW;
510+
let row_offset = i * BYTES_PER_ROW;
511511
row.col(|ui| {
512512
if column == 0 {
513513
data_row_ui(
514514
ui,
515515
Some(left_obj),
516-
address + left_symbol.address as usize,
516+
left_symbol.address as usize,
517+
row_offset,
517518
&left_diffs[i],
518519
appearance,
519520
column,
@@ -522,7 +523,8 @@ pub fn diff_view_ui(
522523
data_row_ui(
523524
ui,
524525
Some(right_obj),
525-
address + right_symbol.address as usize,
526+
right_symbol.address as usize,
527+
row_offset,
526528
&right_diffs[i],
527529
appearance,
528530
column,
@@ -642,12 +644,13 @@ fn diff_col_ui(
642644
total_rows,
643645
|row, _column| {
644646
let i = row.index();
645-
let address = i * BYTES_PER_ROW;
647+
let row_offset = i * BYTES_PER_ROW;
646648
row.col(|ui| {
647649
data_row_ui(
648650
ui,
649651
Some(obj),
650-
address + symbol.address as usize,
652+
symbol.address as usize,
653+
row_offset,
651654
&diffs[i],
652655
appearance,
653656
column,

0 commit comments

Comments
 (0)