Skip to content

Commit 247d6da

Browse files
committed
Restore extab diff view
1 parent bd95faa commit 247d6da

File tree

2 files changed

+13
-15
lines changed

2 files changed

+13
-15
lines changed

objdiff-core/src/arch/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use alloc::{
66
vec::Vec,
77
};
88
use core::{
9+
any::Any,
910
ffi::CStr,
1011
fmt::{self, Debug},
1112
};
@@ -305,7 +306,7 @@ impl dyn Arch {
305306
}
306307
}
307308

308-
pub trait Arch: Send + Sync + Debug {
309+
pub trait Arch: Any + Debug + Send + Sync {
309310
/// Finishes arch-specific initialization that must be done after sections have been combined.
310311
fn post_init(&mut self, _sections: &[Section], _symbols: &[Symbol]) {}
311312

objdiff-gui/src/views/extab_diff.rs

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1+
use core::any::Any;
2+
13
use egui::ScrollArea;
2-
use objdiff_core::{
3-
arch::ppc::ExceptionInfo,
4-
obj::{Object, Symbol},
5-
};
4+
use objdiff_core::{arch::ppc::ExceptionInfo, obj::Object};
65

76
use crate::views::{appearance::Appearance, function_diff::FunctionDiffContext};
87

@@ -26,19 +25,19 @@ fn decode_extab(extab: &ExceptionInfo) -> String {
2625
text
2726
}
2827

29-
fn find_extab_entry<'a>(_obj: &'a Object, _symbol: &Symbol) -> Option<&'a ExceptionInfo> {
30-
// TODO
31-
// obj.arch.ppc().and_then(|ppc| ppc.extab_for_symbol(symbol))
32-
None
28+
fn find_extab_entry(obj: &Object, symbol_index: usize) -> Option<&ExceptionInfo> {
29+
(obj.arch.as_ref() as &dyn Any)
30+
.downcast_ref::<objdiff_core::arch::ppc::ArchPpc>()
31+
.and_then(|ppc| ppc.extab_for_symbol(symbol_index))
3332
}
3433

3534
fn extab_text_ui(
3635
ui: &mut egui::Ui,
3736
ctx: FunctionDiffContext<'_>,
38-
symbol: &Symbol,
37+
symbol_index: usize,
3938
appearance: &Appearance,
4039
) -> Option<()> {
41-
if let Some(extab_entry) = find_extab_entry(ctx.obj, symbol) {
40+
if let Some(extab_entry) = find_extab_entry(ctx.obj, symbol_index) {
4241
let text = decode_extab(extab_entry);
4342
ui.colored_label(appearance.replace_color, &text);
4443
return Some(());
@@ -58,10 +57,8 @@ pub(crate) fn extab_ui(
5857
ui.style_mut().override_text_style = Some(egui::TextStyle::Monospace);
5958
ui.style_mut().wrap_mode = Some(egui::TextWrapMode::Extend);
6059

61-
if let Some(symbol) =
62-
ctx.symbol_ref.and_then(|symbol_ref| ctx.obj.symbols.get(symbol_ref))
63-
{
64-
extab_text_ui(ui, ctx, symbol, appearance);
60+
if let Some(symbol_index) = ctx.symbol_ref {
61+
extab_text_ui(ui, ctx, symbol_index, appearance);
6562
}
6663
});
6764
});

0 commit comments

Comments
 (0)