Skip to content

Commit 613e84e

Browse files
committed
Version 0.2.3
- Fix regression when diffing symbols across mismatched section indexes
1 parent 7219e72 commit 613e84e

File tree

4 files changed

+21
-14
lines changed

4 files changed

+21
-14
lines changed

src/app.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ impl Default for ViewConfig {
8181

8282
pub struct SymbolReference {
8383
pub symbol_name: String,
84-
pub section_index: usize,
84+
pub section_name: String,
8585
}
8686

8787
#[derive(serde::Deserialize, serde::Serialize)]

src/views/data_diff.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ use crate::{
1414
const BYTES_PER_ROW: usize = 16;
1515

1616
fn find_section<'a>(obj: &'a ObjInfo, selected_symbol: &SymbolReference) -> Option<&'a ObjSection> {
17-
obj.sections.get(selected_symbol.section_index)
17+
obj.sections.iter().find(|section| {
18+
section.symbols.iter().any(|symbol| symbol.name == selected_symbol.symbol_name)
19+
})
1820
}
1921

2022
fn data_row_ui(ui: &mut egui::Ui, address: usize, diffs: &[ObjDataDiff], config: &ViewConfig) {

src/views/function_diff.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,9 @@ fn ins_context_menu(ui: &mut egui::Ui, ins: &ObjIns) {
241241
}
242242

243243
fn find_symbol<'a>(obj: &'a ObjInfo, selected_symbol: &SymbolReference) -> Option<&'a ObjSymbol> {
244-
let section = obj.sections.get(selected_symbol.section_index)?;
245-
section.symbols.iter().find(|s| s.name == selected_symbol.symbol_name)
244+
obj.sections.iter().find_map(|section| {
245+
section.symbols.iter().find(|symbol| symbol.name == selected_symbol.symbol_name)
246+
})
246247
}
247248

248249
fn asm_row_ui(ui: &mut egui::Ui, ins_diff: &ObjInsDiff, symbol: &ObjSymbol, config: &ViewConfig) {

src/views/symbol_diff.rs

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ fn symbol_hover_ui(ui: &mut Ui, symbol: &ObjSymbol) {
5656
fn symbol_ui(
5757
ui: &mut Ui,
5858
symbol: &ObjSymbol,
59-
section: Option<(usize, &ObjSection)>,
59+
section: Option<&ObjSection>,
6060
highlighted_symbol: &mut Option<String>,
6161
selected_symbol: &mut Option<SymbolReference>,
6262
current_view: &mut View,
@@ -97,14 +97,18 @@ fn symbol_ui(
9797
.context_menu(|ui| symbol_context_menu_ui(ui, symbol))
9898
.on_hover_ui_at_pointer(|ui| symbol_hover_ui(ui, symbol));
9999
if response.clicked() {
100-
if let Some((section_index, section)) = section {
100+
if let Some(section) = section {
101101
if section.kind == ObjSectionKind::Code {
102-
*selected_symbol =
103-
Some(SymbolReference { symbol_name: symbol.name.clone(), section_index });
102+
*selected_symbol = Some(SymbolReference {
103+
symbol_name: symbol.name.clone(),
104+
section_name: section.name.clone(),
105+
});
104106
*current_view = View::FunctionDiff;
105107
} else if section.kind == ObjSectionKind::Data {
106-
*selected_symbol =
107-
Some(SymbolReference { symbol_name: section.name.clone(), section_index });
108+
*selected_symbol = Some(SymbolReference {
109+
symbol_name: section.name.clone(),
110+
section_name: section.name.clone(),
111+
});
108112
*current_view = View::DataDiff;
109113
}
110114
}
@@ -158,19 +162,19 @@ fn symbol_list_ui(
158162
});
159163
}
160164

161-
for (section_index, section) in obj.sections.iter().enumerate() {
165+
for section in &obj.sections {
162166
CollapsingHeader::new(format!("{} ({:x})", section.name, section.size))
163167
.default_open(true)
164168
.show(ui, |ui| {
165-
if section.name == ".text" && reverse_function_order {
169+
if section.kind == ObjSectionKind::Code && reverse_function_order {
166170
for symbol in section.symbols.iter().rev() {
167171
if !symbol_matches_search(symbol, &lower_search) {
168172
continue;
169173
}
170174
symbol_ui(
171175
ui,
172176
symbol,
173-
Some((section_index, section)),
177+
Some(section),
174178
highlighted_symbol,
175179
selected_symbol,
176180
current_view,
@@ -185,7 +189,7 @@ fn symbol_list_ui(
185189
symbol_ui(
186190
ui,
187191
symbol,
188-
Some((section_index, section)),
192+
Some(section),
189193
highlighted_symbol,
190194
selected_symbol,
191195
current_view,

0 commit comments

Comments
 (0)