Version 0.2.2

- Add application icon
- Fixes for objects containing multiple
  sections with the same name
This commit is contained in:
2022-12-10 10:34:03 -05:00
parent d1d6f1101b
commit 7219e72acf
12 changed files with 92 additions and 38 deletions

View File

@@ -5,7 +5,7 @@ use egui_extras::{Size, StripBuilder, TableBuilder};
use time::format_description;
use crate::{
app::{View, ViewConfig, ViewState},
app::{SymbolReference, View, ViewConfig, ViewState},
jobs::Job,
obj::{ObjDataDiff, ObjDataDiffKind, ObjInfo, ObjSection},
views::{write_text, COLOR_RED},
@@ -13,8 +13,8 @@ use crate::{
const BYTES_PER_ROW: usize = 16;
fn find_section<'a>(obj: &'a ObjInfo, section_name: &str) -> Option<&'a ObjSection> {
obj.sections.iter().find(|s| s.name == section_name)
fn find_section<'a>(obj: &'a ObjInfo, selected_symbol: &SymbolReference) -> Option<&'a ObjSection> {
obj.sections.get(selected_symbol.section_index)
}
fn data_row_ui(ui: &mut egui::Ui, address: usize, diffs: &[ObjDataDiff], config: &ViewConfig) {
@@ -132,11 +132,11 @@ fn data_table_ui(
table: TableBuilder<'_>,
left_obj: &ObjInfo,
right_obj: &ObjInfo,
section_name: &str,
selected_symbol: &SymbolReference,
config: &ViewConfig,
) -> Option<()> {
let left_section = find_section(left_obj, section_name)?;
let right_section = find_section(right_obj, section_name)?;
let left_section = find_section(left_obj, selected_symbol)?;
let right_section = find_section(right_obj, selected_symbol)?;
let total_bytes = left_section.data_diff.iter().fold(0usize, |accum, item| accum + item.len);
if total_bytes == 0 {
@@ -219,7 +219,7 @@ pub fn data_diff_ui(ui: &mut egui::Ui, view_state: &mut ViewState) -> bool {
ui.style_mut().override_text_style =
Some(egui::TextStyle::Monospace);
ui.style_mut().wrap = Some(false);
ui.colored_label(Color32::WHITE, selected_symbol);
ui.colored_label(Color32::WHITE, &selected_symbol.symbol_name);
ui.label("Diff target:");
ui.separator();
});

View File

@@ -7,7 +7,7 @@ use ppc750cl::Argument;
use time::format_description;
use crate::{
app::{View, ViewConfig, ViewState},
app::{SymbolReference, View, ViewConfig, ViewState},
jobs::Job,
obj::{
ObjInfo, ObjIns, ObjInsArg, ObjInsArgDiff, ObjInsDiff, ObjInsDiffKind, ObjReloc,
@@ -240,9 +240,9 @@ fn ins_context_menu(ui: &mut egui::Ui, ins: &ObjIns) {
});
}
fn find_symbol<'a>(obj: &'a ObjInfo, section_name: &str, name: &str) -> Option<&'a ObjSymbol> {
let section = obj.sections.iter().find(|s| s.name == section_name)?;
section.symbols.iter().find(|s| s.name == name)
fn find_symbol<'a>(obj: &'a ObjInfo, selected_symbol: &SymbolReference) -> Option<&'a ObjSymbol> {
let section = obj.sections.get(selected_symbol.section_index)?;
section.symbols.iter().find(|s| s.name == selected_symbol.symbol_name)
}
fn asm_row_ui(ui: &mut egui::Ui, ins_diff: &ObjInsDiff, symbol: &ObjSymbol, config: &ViewConfig) {
@@ -296,11 +296,11 @@ fn asm_table_ui(
table: TableBuilder<'_>,
left_obj: &ObjInfo,
right_obj: &ObjInfo,
fn_name: &str,
selected_symbol: &SymbolReference,
config: &ViewConfig,
) -> Option<()> {
let left_symbol = find_symbol(left_obj, ".text", fn_name);
let right_symbol = find_symbol(right_obj, ".text", fn_name);
let left_symbol = find_symbol(left_obj, selected_symbol);
let right_symbol = find_symbol(right_obj, selected_symbol);
let instructions_len = left_symbol.or(right_symbol).map(|s| s.instructions.len())?;
table.body(|body| {
body.rows(config.code_font.size, instructions_len, |row_index, mut row| {
@@ -372,7 +372,7 @@ pub fn function_diff_ui(ui: &mut egui::Ui, view_state: &mut ViewState) -> bool {
});
strip.strip(|builder| {
builder.sizes(Size::remainder(), 2).horizontal(|mut strip| {
let demangled = demangle(selected_symbol, &Default::default());
let demangled = demangle(&selected_symbol.symbol_name, &Default::default());
strip.cell(|ui| {
ui.scope(|ui| {
ui.style_mut().override_text_style =
@@ -380,7 +380,7 @@ pub fn function_diff_ui(ui: &mut egui::Ui, view_state: &mut ViewState) -> bool {
ui.style_mut().wrap = Some(false);
ui.colored_label(
Color32::WHITE,
demangled.as_ref().unwrap_or(selected_symbol),
demangled.as_ref().unwrap_or(&selected_symbol.symbol_name),
);
ui.label("Diff target:");
ui.separator();
@@ -394,7 +394,7 @@ pub fn function_diff_ui(ui: &mut egui::Ui, view_state: &mut ViewState) -> bool {
if let Some(match_percent) = result
.second_obj
.as_ref()
.and_then(|obj| find_symbol(obj, ".text", selected_symbol))
.and_then(|obj| find_symbol(obj, selected_symbol))
.and_then(|symbol| symbol.match_percent)
{
ui.colored_label(

View File

@@ -4,7 +4,7 @@ use egui::{
use egui_extras::{Size, StripBuilder};
use crate::{
app::{View, ViewConfig, ViewState},
app::{SymbolReference, View, ViewConfig, ViewState},
jobs::objdiff::BuildStatus,
obj::{ObjInfo, ObjSection, ObjSectionKind, ObjSymbol, ObjSymbolFlags},
views::write_text,
@@ -56,9 +56,9 @@ fn symbol_hover_ui(ui: &mut Ui, symbol: &ObjSymbol) {
fn symbol_ui(
ui: &mut Ui,
symbol: &ObjSymbol,
section: Option<&ObjSection>,
section: Option<(usize, &ObjSection)>,
highlighted_symbol: &mut Option<String>,
selected_symbol: &mut Option<String>,
selected_symbol: &mut Option<SymbolReference>,
current_view: &mut View,
config: &ViewConfig,
) {
@@ -97,12 +97,14 @@ fn symbol_ui(
.context_menu(|ui| symbol_context_menu_ui(ui, symbol))
.on_hover_ui_at_pointer(|ui| symbol_hover_ui(ui, symbol));
if response.clicked() {
if let Some(section) = section {
if let Some((section_index, section)) = section {
if section.kind == ObjSectionKind::Code {
*selected_symbol = Some(symbol.name.clone());
*selected_symbol =
Some(SymbolReference { symbol_name: symbol.name.clone(), section_index });
*current_view = View::FunctionDiff;
} else if section.kind == ObjSectionKind::Data {
*selected_symbol = Some(section.name.clone());
*selected_symbol =
Some(SymbolReference { symbol_name: section.name.clone(), section_index });
*current_view = View::DataDiff;
}
}
@@ -126,7 +128,7 @@ fn symbol_list_ui(
ui: &mut Ui,
obj: &ObjInfo,
highlighted_symbol: &mut Option<String>,
selected_symbol: &mut Option<String>,
selected_symbol: &mut Option<SymbolReference>,
current_view: &mut View,
reverse_function_order: bool,
search: &mut String,
@@ -156,7 +158,7 @@ fn symbol_list_ui(
});
}
for section in &obj.sections {
for (section_index, section) in obj.sections.iter().enumerate() {
CollapsingHeader::new(format!("{} ({:x})", section.name, section.size))
.default_open(true)
.show(ui, |ui| {
@@ -168,7 +170,7 @@ fn symbol_list_ui(
symbol_ui(
ui,
symbol,
Some(section),
Some((section_index, section)),
highlighted_symbol,
selected_symbol,
current_view,
@@ -183,7 +185,7 @@ fn symbol_list_ui(
symbol_ui(
ui,
symbol,
Some(section),
Some((section_index, section)),
highlighted_symbol,
selected_symbol,
current_view,