mirror of
https://github.com/encounter/objdiff.git
synced 2025-12-10 22:17:51 +00:00
Version 0.2.0
- Update checker & auto-updater - Configure font sizes and diff colors - Data diffing bug fixes & improvements - Bug fix for low match percent - Improvements to Jobs UI (cancel, dismiss errors) - "Demangle" tool Closes #6, #13, #17, #19
This commit is contained in:
@@ -4,10 +4,14 @@ use std::sync::{Arc, RwLock};
|
||||
|
||||
#[cfg(windows)]
|
||||
use anyhow::{Context, Result};
|
||||
use const_format::formatcp;
|
||||
use egui::{output::OpenUrl, Color32};
|
||||
use self_update::cargo_crate_version;
|
||||
|
||||
use crate::{
|
||||
app::{AppConfig, DiffKind, ViewState},
|
||||
jobs::{bindiff::queue_bindiff, objdiff::queue_build},
|
||||
jobs::{bindiff::queue_bindiff, objdiff::queue_build, update::queue_update},
|
||||
update::RELEASE_URL,
|
||||
};
|
||||
|
||||
#[cfg(windows)]
|
||||
@@ -57,8 +61,50 @@ pub fn config_ui(ui: &mut egui::Ui, config: &Arc<RwLock<AppConfig>>, view_state:
|
||||
left_obj,
|
||||
right_obj,
|
||||
project_dir_change,
|
||||
queue_update_check,
|
||||
auto_update_check,
|
||||
} = &mut *config_guard;
|
||||
|
||||
ui.heading("Updates");
|
||||
ui.checkbox(auto_update_check, "Check for updates on startup");
|
||||
if ui.button("Check now").clicked() {
|
||||
*queue_update_check = true;
|
||||
}
|
||||
ui.label(format!("Current version: {}", cargo_crate_version!())).on_hover_ui_at_pointer(|ui| {
|
||||
ui.label(formatcp!("Git branch: {}", env!("VERGEN_GIT_BRANCH")));
|
||||
ui.label(formatcp!("Git commit: {}", env!("VERGEN_GIT_SHA")));
|
||||
ui.label(formatcp!("Build target: {}", env!("VERGEN_CARGO_TARGET_TRIPLE")));
|
||||
ui.label(formatcp!("Build type: {}", env!("VERGEN_CARGO_PROFILE")));
|
||||
});
|
||||
if let Some(state) = &view_state.check_update {
|
||||
ui.label(format!("Latest version: {}", state.latest_release.version));
|
||||
if state.update_available {
|
||||
ui.colored_label(Color32::LIGHT_GREEN, "Update available");
|
||||
ui.horizontal(|ui| {
|
||||
if state.found_binary {
|
||||
if ui
|
||||
.button("Automatic")
|
||||
.on_hover_text_at_pointer(
|
||||
"Automatically download and replace the current build",
|
||||
)
|
||||
.clicked()
|
||||
{
|
||||
view_state.jobs.push(queue_update());
|
||||
}
|
||||
}
|
||||
if ui
|
||||
.button("Manual")
|
||||
.on_hover_text_at_pointer("Open a link to the latest release on GitHub")
|
||||
.clicked()
|
||||
{
|
||||
ui.output().open_url =
|
||||
Some(OpenUrl { url: RELEASE_URL.to_string(), new_tab: true });
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
ui.separator();
|
||||
|
||||
ui.heading("Build config");
|
||||
|
||||
#[cfg(windows)]
|
||||
@@ -82,7 +128,14 @@ pub fn config_ui(ui: &mut egui::Ui, config: &Arc<RwLock<AppConfig>>, view_state:
|
||||
}
|
||||
|
||||
ui.label("Custom make program:");
|
||||
ui.text_edit_singleline(custom_make);
|
||||
let mut custom_make_str = custom_make.clone().unwrap_or_default();
|
||||
if ui.text_edit_singleline(&mut custom_make_str).changed() {
|
||||
if custom_make_str.is_empty() {
|
||||
*custom_make = None;
|
||||
} else {
|
||||
*custom_make = Some(custom_make_str);
|
||||
}
|
||||
}
|
||||
|
||||
ui.separator();
|
||||
|
||||
|
||||
@@ -5,10 +5,10 @@ use egui_extras::{Size, StripBuilder, TableBuilder};
|
||||
use time::format_description;
|
||||
|
||||
use crate::{
|
||||
app::{View, ViewState},
|
||||
app::{View, ViewConfig, ViewState},
|
||||
jobs::Job,
|
||||
obj::{ObjDataDiff, ObjDataDiffKind, ObjInfo, ObjSection},
|
||||
views::{write_text, COLOR_RED, FONT_SIZE},
|
||||
views::{write_text, COLOR_RED},
|
||||
};
|
||||
|
||||
const BYTES_PER_ROW: usize = 16;
|
||||
@@ -17,12 +17,17 @@ fn find_section<'a>(obj: &'a ObjInfo, section_name: &str) -> Option<&'a ObjSecti
|
||||
obj.sections.iter().find(|s| s.name == section_name)
|
||||
}
|
||||
|
||||
fn data_row_ui(ui: &mut egui::Ui, address: usize, diffs: &[ObjDataDiff]) {
|
||||
fn data_row_ui(ui: &mut egui::Ui, address: usize, diffs: &[ObjDataDiff], config: &ViewConfig) {
|
||||
if diffs.iter().any(|d| d.kind != ObjDataDiffKind::None) {
|
||||
ui.painter().rect_filled(ui.available_rect_before_wrap(), 0.0, ui.visuals().faint_bg_color);
|
||||
}
|
||||
let mut job = LayoutJob::default();
|
||||
write_text(format!("{:08X}: ", address).as_str(), Color32::GRAY, &mut job);
|
||||
write_text(
|
||||
format!("{:08X}: ", address).as_str(),
|
||||
Color32::GRAY,
|
||||
&mut job,
|
||||
config.code_font.clone(),
|
||||
);
|
||||
let mut cur_addr = 0usize;
|
||||
for diff in diffs {
|
||||
let base_color = match diff.kind {
|
||||
@@ -34,7 +39,7 @@ fn data_row_ui(ui: &mut egui::Ui, address: usize, diffs: &[ObjDataDiff]) {
|
||||
if diff.data.is_empty() {
|
||||
let mut str = " ".repeat(diff.len);
|
||||
str.push_str(" ".repeat(diff.len / 8).as_str());
|
||||
write_text(str.as_str(), base_color, &mut job);
|
||||
write_text(str.as_str(), base_color, &mut job, config.code_font.clone());
|
||||
cur_addr += diff.len;
|
||||
} else {
|
||||
let mut text = String::new();
|
||||
@@ -45,7 +50,7 @@ fn data_row_ui(ui: &mut egui::Ui, address: usize, diffs: &[ObjDataDiff]) {
|
||||
text.push(' ');
|
||||
}
|
||||
}
|
||||
write_text(text.as_str(), base_color, &mut job);
|
||||
write_text(text.as_str(), base_color, &mut job, config.code_font.clone());
|
||||
}
|
||||
}
|
||||
if cur_addr < BYTES_PER_ROW {
|
||||
@@ -53,9 +58,9 @@ fn data_row_ui(ui: &mut egui::Ui, address: usize, diffs: &[ObjDataDiff]) {
|
||||
let mut str = " ".to_string();
|
||||
str.push_str(" ".repeat(n).as_str());
|
||||
str.push_str(" ".repeat(n / 8).as_str());
|
||||
write_text(str.as_str(), Color32::GRAY, &mut job);
|
||||
write_text(str.as_str(), Color32::GRAY, &mut job, config.code_font.clone());
|
||||
}
|
||||
write_text(" ", Color32::GRAY, &mut job);
|
||||
write_text(" ", Color32::GRAY, &mut job, config.code_font.clone());
|
||||
for diff in diffs {
|
||||
let base_color = match diff.kind {
|
||||
ObjDataDiffKind::None => Color32::GRAY,
|
||||
@@ -64,7 +69,12 @@ fn data_row_ui(ui: &mut egui::Ui, address: usize, diffs: &[ObjDataDiff]) {
|
||||
ObjDataDiffKind::Insert => Color32::GREEN,
|
||||
};
|
||||
if diff.data.is_empty() {
|
||||
write_text(" ".repeat(diff.len).as_str(), base_color, &mut job);
|
||||
write_text(
|
||||
" ".repeat(diff.len).as_str(),
|
||||
base_color,
|
||||
&mut job,
|
||||
config.code_font.clone(),
|
||||
);
|
||||
} else {
|
||||
let mut text = String::new();
|
||||
for byte in &diff.data {
|
||||
@@ -75,7 +85,7 @@ fn data_row_ui(ui: &mut egui::Ui, address: usize, diffs: &[ObjDataDiff]) {
|
||||
text.push('.');
|
||||
}
|
||||
}
|
||||
write_text(text.as_str(), base_color, &mut job);
|
||||
write_text(text.as_str(), base_color, &mut job, config.code_font.clone());
|
||||
}
|
||||
}
|
||||
ui.add(Label::new(job).sense(Sense::click()));
|
||||
@@ -101,6 +111,8 @@ fn split_diffs(diffs: &[ObjDataDiff]) -> Vec<Vec<ObjDataDiff>> {
|
||||
},
|
||||
kind: diff.kind,
|
||||
len,
|
||||
// TODO
|
||||
symbol: String::new(),
|
||||
});
|
||||
remaining_in_row -= len;
|
||||
cur_len += len;
|
||||
@@ -121,6 +133,7 @@ fn data_table_ui(
|
||||
left_obj: &ObjInfo,
|
||||
right_obj: &ObjInfo,
|
||||
section_name: &str,
|
||||
config: &ViewConfig,
|
||||
) -> Option<()> {
|
||||
let left_section = find_section(left_obj, section_name)?;
|
||||
let right_section = find_section(right_obj, section_name)?;
|
||||
@@ -135,13 +148,13 @@ fn data_table_ui(
|
||||
let right_diffs = split_diffs(&right_section.data_diff);
|
||||
|
||||
table.body(|body| {
|
||||
body.rows(FONT_SIZE, total_rows, |row_index, mut row| {
|
||||
body.rows(config.code_font.size, total_rows, |row_index, mut row| {
|
||||
let address = row_index * BYTES_PER_ROW;
|
||||
row.col(|ui| {
|
||||
data_row_ui(ui, address, &left_diffs[row_index]);
|
||||
data_row_ui(ui, address, &left_diffs[row_index], config);
|
||||
});
|
||||
row.col(|ui| {
|
||||
data_row_ui(ui, address, &right_diffs[row_index]);
|
||||
data_row_ui(ui, address, &right_diffs[row_index], config);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -233,7 +246,13 @@ pub fn data_diff_ui(ui: &mut egui::Ui, view_state: &mut ViewState) -> bool {
|
||||
.column(Size::relative(0.5))
|
||||
.column(Size::relative(0.5))
|
||||
.resizable(false);
|
||||
data_table_ui(table, left_obj, right_obj, selected_symbol);
|
||||
data_table_ui(
|
||||
table,
|
||||
left_obj,
|
||||
right_obj,
|
||||
selected_symbol,
|
||||
&view_state.view_config,
|
||||
);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,62 +1,62 @@
|
||||
use std::default::Default;
|
||||
|
||||
use cwdemangle::demangle;
|
||||
use egui::{text::LayoutJob, Color32, Label, Sense};
|
||||
use egui::{text::LayoutJob, Color32, FontId, Label, Sense};
|
||||
use egui_extras::{Size, StripBuilder, TableBuilder};
|
||||
use ppc750cl::Argument;
|
||||
use time::format_description;
|
||||
|
||||
use crate::{
|
||||
app::{View, ViewState},
|
||||
app::{View, ViewConfig, ViewState},
|
||||
jobs::Job,
|
||||
obj::{
|
||||
ObjInfo, ObjIns, ObjInsArg, ObjInsArgDiff, ObjInsDiff, ObjInsDiffKind, ObjReloc,
|
||||
ObjRelocKind, ObjSymbol,
|
||||
},
|
||||
views::{symbol_diff::match_color_for_symbol, write_text, COLOR_RED, FONT_SIZE},
|
||||
views::{symbol_diff::match_color_for_symbol, write_text, COLOR_RED},
|
||||
};
|
||||
|
||||
fn write_reloc_name(reloc: &ObjReloc, color: Color32, job: &mut LayoutJob) {
|
||||
fn write_reloc_name(reloc: &ObjReloc, color: Color32, job: &mut LayoutJob, font_id: FontId) {
|
||||
let name = reloc.target.demangled_name.as_ref().unwrap_or(&reloc.target.name);
|
||||
write_text(name, Color32::LIGHT_GRAY, job);
|
||||
write_text(name, Color32::LIGHT_GRAY, job, font_id.clone());
|
||||
if reloc.target.addend != 0 {
|
||||
write_text(&format!("+{:X}", reloc.target.addend), color, job);
|
||||
write_text(&format!("+{:X}", reloc.target.addend), color, job, font_id.clone());
|
||||
}
|
||||
}
|
||||
|
||||
fn write_reloc(reloc: &ObjReloc, color: Color32, job: &mut LayoutJob) {
|
||||
fn write_reloc(reloc: &ObjReloc, color: Color32, job: &mut LayoutJob, font_id: FontId) {
|
||||
match reloc.kind {
|
||||
ObjRelocKind::PpcAddr16Lo => {
|
||||
write_reloc_name(reloc, color, job);
|
||||
write_text("@l", color, job);
|
||||
write_reloc_name(reloc, color, job, font_id.clone());
|
||||
write_text("@l", color, job, font_id.clone());
|
||||
}
|
||||
ObjRelocKind::PpcAddr16Hi => {
|
||||
write_reloc_name(reloc, color, job);
|
||||
write_text("@h", color, job);
|
||||
write_reloc_name(reloc, color, job, font_id.clone());
|
||||
write_text("@h", color, job, font_id.clone());
|
||||
}
|
||||
ObjRelocKind::PpcAddr16Ha => {
|
||||
write_reloc_name(reloc, color, job);
|
||||
write_text("@ha", color, job);
|
||||
write_reloc_name(reloc, color, job, font_id.clone());
|
||||
write_text("@ha", color, job, font_id.clone());
|
||||
}
|
||||
ObjRelocKind::PpcEmbSda21 => {
|
||||
write_reloc_name(reloc, color, job);
|
||||
write_text("@sda21", color, job);
|
||||
write_reloc_name(reloc, color, job, font_id.clone());
|
||||
write_text("@sda21", color, job, font_id.clone());
|
||||
}
|
||||
ObjRelocKind::MipsHi16 => {
|
||||
write_text("%hi(", color, job);
|
||||
write_reloc_name(reloc, color, job);
|
||||
write_text(")", color, job);
|
||||
write_text("%hi(", color, job, font_id.clone());
|
||||
write_reloc_name(reloc, color, job, font_id.clone());
|
||||
write_text(")", color, job, font_id.clone());
|
||||
}
|
||||
ObjRelocKind::MipsLo16 => {
|
||||
write_text("%lo(", color, job);
|
||||
write_reloc_name(reloc, color, job);
|
||||
write_text(")", color, job);
|
||||
write_text("%lo(", color, job, font_id.clone());
|
||||
write_reloc_name(reloc, color, job, font_id.clone());
|
||||
write_text(")", color, job, font_id.clone());
|
||||
}
|
||||
ObjRelocKind::Absolute
|
||||
| ObjRelocKind::PpcRel24
|
||||
| ObjRelocKind::PpcRel14
|
||||
| ObjRelocKind::Mips26 => {
|
||||
write_reloc_name(reloc, color, job);
|
||||
write_reloc_name(reloc, color, job, font_id.clone());
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -67,6 +67,7 @@ fn write_ins(
|
||||
args: &[Option<ObjInsArgDiff>],
|
||||
base_addr: u32,
|
||||
job: &mut LayoutJob,
|
||||
config: &ViewConfig,
|
||||
) {
|
||||
let base_color = match diff_kind {
|
||||
ObjInsDiffKind::None | ObjInsDiffKind::OpMismatch | ObjInsDiffKind::ArgMismatch => {
|
||||
@@ -83,54 +84,60 @@ fn write_ins(
|
||||
_ => base_color,
|
||||
},
|
||||
job,
|
||||
config.code_font.clone(),
|
||||
);
|
||||
let mut writing_offset = false;
|
||||
for (i, arg) in ins.args.iter().enumerate() {
|
||||
if i == 0 {
|
||||
write_text(" ", base_color, job);
|
||||
write_text(" ", base_color, job, config.code_font.clone());
|
||||
}
|
||||
if i > 0 && !writing_offset {
|
||||
write_text(", ", base_color, job);
|
||||
write_text(", ", base_color, job, config.code_font.clone());
|
||||
}
|
||||
let color = if let Some(diff) = args.get(i).and_then(|a| a.as_ref()) {
|
||||
COLOR_ROTATION[diff.idx % COLOR_ROTATION.len()]
|
||||
config.diff_colors[diff.idx % config.diff_colors.len()]
|
||||
} else {
|
||||
base_color
|
||||
};
|
||||
match arg {
|
||||
ObjInsArg::PpcArg(arg) => match arg {
|
||||
Argument::Offset(val) => {
|
||||
write_text(&format!("{}", val), color, job);
|
||||
write_text("(", base_color, job);
|
||||
write_text(&format!("{}", val), color, job, config.code_font.clone());
|
||||
write_text("(", base_color, job, config.code_font.clone());
|
||||
writing_offset = true;
|
||||
continue;
|
||||
}
|
||||
Argument::Uimm(_) | Argument::Simm(_) => {
|
||||
write_text(&format!("{}", arg), color, job);
|
||||
write_text(&format!("{}", arg), color, job, config.code_font.clone());
|
||||
}
|
||||
_ => {
|
||||
write_text(&format!("{}", arg), color, job);
|
||||
write_text(&format!("{}", arg), color, job, config.code_font.clone());
|
||||
}
|
||||
},
|
||||
ObjInsArg::Reloc => {
|
||||
write_reloc(ins.reloc.as_ref().unwrap(), base_color, job);
|
||||
write_reloc(ins.reloc.as_ref().unwrap(), base_color, job, config.code_font.clone());
|
||||
}
|
||||
ObjInsArg::RelocWithBase => {
|
||||
write_reloc(ins.reloc.as_ref().unwrap(), base_color, job);
|
||||
write_text("(", base_color, job);
|
||||
write_reloc(ins.reloc.as_ref().unwrap(), base_color, job, config.code_font.clone());
|
||||
write_text("(", base_color, job, config.code_font.clone());
|
||||
writing_offset = true;
|
||||
continue;
|
||||
}
|
||||
ObjInsArg::MipsArg(str) => {
|
||||
write_text(str.strip_prefix('$').unwrap_or(str), color, job);
|
||||
write_text(
|
||||
str.strip_prefix('$').unwrap_or(str),
|
||||
color,
|
||||
job,
|
||||
config.code_font.clone(),
|
||||
);
|
||||
}
|
||||
ObjInsArg::BranchOffset(offset) => {
|
||||
let addr = offset + ins.address as i32 - base_addr as i32;
|
||||
write_text(&format!("{:x}", addr), color, job);
|
||||
write_text(&format!("{:x}", addr), color, job, config.code_font.clone());
|
||||
}
|
||||
}
|
||||
if writing_offset {
|
||||
write_text(")", base_color, job);
|
||||
write_text(")", base_color, job, config.code_font.clone());
|
||||
writing_offset = false;
|
||||
}
|
||||
}
|
||||
@@ -233,24 +240,12 @@ fn ins_context_menu(ui: &mut egui::Ui, ins: &ObjIns) {
|
||||
});
|
||||
}
|
||||
|
||||
const COLOR_ROTATION: [Color32; 9] = [
|
||||
Color32::from_rgb(255, 0, 255),
|
||||
Color32::from_rgb(0, 255, 255),
|
||||
Color32::from_rgb(0, 128, 0),
|
||||
Color32::from_rgb(255, 0, 0),
|
||||
Color32::from_rgb(255, 255, 0),
|
||||
Color32::from_rgb(255, 192, 203),
|
||||
Color32::from_rgb(0, 0, 255),
|
||||
Color32::from_rgb(0, 255, 0),
|
||||
Color32::from_rgb(128, 128, 128),
|
||||
];
|
||||
|
||||
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 asm_row_ui(ui: &mut egui::Ui, ins_diff: &ObjInsDiff, symbol: &ObjSymbol) {
|
||||
fn asm_row_ui(ui: &mut egui::Ui, ins_diff: &ObjInsDiff, symbol: &ObjSymbol, config: &ViewConfig) {
|
||||
if ins_diff.kind != ObjInsDiffKind::None {
|
||||
ui.painter().rect_filled(ui.available_rect_before_wrap(), 0.0, ui.visuals().faint_bg_color);
|
||||
}
|
||||
@@ -268,15 +263,26 @@ fn asm_row_ui(ui: &mut egui::Ui, ins_diff: &ObjInsDiff, symbol: &ObjSymbol) {
|
||||
&format!("{:<6}", format!("{:x}:", ins.address - symbol.address as u32)),
|
||||
base_color,
|
||||
&mut job,
|
||||
config.code_font.clone(),
|
||||
);
|
||||
if let Some(branch) = &ins_diff.branch_from {
|
||||
write_text("~> ", COLOR_ROTATION[branch.branch_idx % COLOR_ROTATION.len()], &mut job);
|
||||
write_text(
|
||||
"~> ",
|
||||
config.diff_colors[branch.branch_idx % config.diff_colors.len()],
|
||||
&mut job,
|
||||
config.code_font.clone(),
|
||||
);
|
||||
} else {
|
||||
write_text(" ", base_color, &mut job);
|
||||
write_text(" ", base_color, &mut job, config.code_font.clone());
|
||||
}
|
||||
write_ins(ins, &ins_diff.kind, &ins_diff.arg_diff, symbol.address as u32, &mut job);
|
||||
write_ins(ins, &ins_diff.kind, &ins_diff.arg_diff, symbol.address as u32, &mut job, config);
|
||||
if let Some(branch) = &ins_diff.branch_to {
|
||||
write_text(" ~>", COLOR_ROTATION[branch.branch_idx % COLOR_ROTATION.len()], &mut job);
|
||||
write_text(
|
||||
" ~>",
|
||||
config.diff_colors[branch.branch_idx % config.diff_colors.len()],
|
||||
&mut job,
|
||||
config.code_font.clone(),
|
||||
);
|
||||
}
|
||||
ui.add(Label::new(job).sense(Sense::click()))
|
||||
.on_hover_ui_at_pointer(|ui| ins_hover_ui(ui, ins))
|
||||
@@ -291,16 +297,22 @@ fn asm_table_ui(
|
||||
left_obj: &ObjInfo,
|
||||
right_obj: &ObjInfo,
|
||||
fn_name: &str,
|
||||
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, ".text", fn_name);
|
||||
let right_symbol = find_symbol(right_obj, ".text", fn_name);
|
||||
let instructions_len = left_symbol.or(right_symbol).map(|s| s.instructions.len())?;
|
||||
table.body(|body| {
|
||||
body.rows(FONT_SIZE, left_symbol.instructions.len(), |row_index, mut row| {
|
||||
body.rows(config.code_font.size, instructions_len, |row_index, mut row| {
|
||||
row.col(|ui| {
|
||||
asm_row_ui(ui, &left_symbol.instructions[row_index], left_symbol);
|
||||
if let Some(symbol) = left_symbol {
|
||||
asm_row_ui(ui, &symbol.instructions[row_index], symbol, config);
|
||||
}
|
||||
});
|
||||
row.col(|ui| {
|
||||
asm_row_ui(ui, &right_symbol.instructions[row_index], right_symbol);
|
||||
if let Some(symbol) = right_symbol {
|
||||
asm_row_ui(ui, &symbol.instructions[row_index], symbol, config);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -379,14 +391,16 @@ pub fn function_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);
|
||||
if let Some(obj) = &result.second_obj {
|
||||
if let Some(symbol) = find_symbol(obj, ".text", selected_symbol)
|
||||
{
|
||||
ui.colored_label(
|
||||
match_color_for_symbol(symbol),
|
||||
&format!("{:.0}%", symbol.match_percent),
|
||||
);
|
||||
}
|
||||
if let Some(match_percent) = result
|
||||
.second_obj
|
||||
.as_ref()
|
||||
.and_then(|obj| find_symbol(obj, ".text", selected_symbol))
|
||||
.and_then(|symbol| symbol.match_percent)
|
||||
{
|
||||
ui.colored_label(
|
||||
match_color_for_symbol(match_percent),
|
||||
&format!("{:.0}%", match_percent),
|
||||
);
|
||||
}
|
||||
ui.label("Diff base:");
|
||||
ui.separator();
|
||||
@@ -404,7 +418,13 @@ pub fn function_diff_ui(ui: &mut egui::Ui, view_state: &mut ViewState) -> bool {
|
||||
.column(Size::relative(0.5))
|
||||
.column(Size::relative(0.5))
|
||||
.resizable(false);
|
||||
asm_table_ui(table, left_obj, right_obj, selected_symbol);
|
||||
asm_table_ui(
|
||||
table,
|
||||
left_obj,
|
||||
right_obj,
|
||||
selected_symbol,
|
||||
&view_state.view_config,
|
||||
);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -2,13 +2,26 @@ use egui::{Color32, ProgressBar, Widget};
|
||||
|
||||
use crate::app::ViewState;
|
||||
|
||||
pub fn jobs_ui(ui: &mut egui::Ui, view_state: &ViewState) {
|
||||
pub fn jobs_ui(ui: &mut egui::Ui, view_state: &mut ViewState) {
|
||||
ui.label("Jobs");
|
||||
|
||||
for job in &view_state.jobs {
|
||||
let mut remove_job: Option<usize> = None;
|
||||
for (idx, job) in view_state.jobs.iter_mut().enumerate() {
|
||||
if let Ok(status) = job.status.read() {
|
||||
ui.group(|ui| {
|
||||
ui.label(&status.title);
|
||||
ui.horizontal(|ui| {
|
||||
ui.label(&status.title);
|
||||
if ui.small_button("✖").clicked() {
|
||||
if job.handle.is_some() {
|
||||
job.should_remove = true;
|
||||
if let Err(e) = job.cancel.send(()) {
|
||||
eprintln!("Failed to cancel job: {:?}", e);
|
||||
}
|
||||
} else {
|
||||
remove_job = Some(idx);
|
||||
}
|
||||
}
|
||||
});
|
||||
let mut bar = ProgressBar::new(status.progress_percent);
|
||||
if let Some(items) = &status.progress_items {
|
||||
bar = bar.text(format!("{} / {}", items[0], items[1]));
|
||||
@@ -35,4 +48,8 @@ pub fn jobs_ui(ui: &mut egui::Ui, view_state: &ViewState) {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(idx) = remove_job {
|
||||
view_state.jobs.remove(idx);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use egui::{text::LayoutJob, Color32, FontFamily, FontId, TextFormat};
|
||||
use egui::{text::LayoutJob, Color32, FontId, TextFormat};
|
||||
|
||||
pub(crate) mod config;
|
||||
pub(crate) mod data_diff;
|
||||
@@ -6,11 +6,8 @@ pub(crate) mod function_diff;
|
||||
pub(crate) mod jobs;
|
||||
pub(crate) mod symbol_diff;
|
||||
|
||||
const FONT_SIZE: f32 = 14.0;
|
||||
const FONT_ID: FontId = FontId::new(FONT_SIZE, FontFamily::Monospace);
|
||||
|
||||
const COLOR_RED: Color32 = Color32::from_rgb(200, 40, 41);
|
||||
|
||||
fn write_text(str: &str, color: Color32, job: &mut LayoutJob) {
|
||||
job.append(str, 0.0, TextFormat { font_id: FONT_ID, color, ..Default::default() });
|
||||
fn write_text(str: &str, color: Color32, job: &mut LayoutJob, font_id: FontId) {
|
||||
job.append(str, 0.0, TextFormat { font_id, color, ..Default::default() });
|
||||
}
|
||||
|
||||
@@ -4,16 +4,16 @@ use egui::{
|
||||
use egui_extras::{Size, StripBuilder};
|
||||
|
||||
use crate::{
|
||||
app::{View, ViewState},
|
||||
app::{View, ViewConfig, ViewState},
|
||||
jobs::objdiff::BuildStatus,
|
||||
obj::{ObjInfo, ObjSection, ObjSectionKind, ObjSymbol, ObjSymbolFlags},
|
||||
views::write_text,
|
||||
};
|
||||
|
||||
pub fn match_color_for_symbol(symbol: &ObjSymbol) -> Color32 {
|
||||
if symbol.match_percent == 100.0 {
|
||||
pub fn match_color_for_symbol(match_percent: f32) -> Color32 {
|
||||
if match_percent == 100.0 {
|
||||
Color32::GREEN
|
||||
} else if symbol.match_percent >= 50.0 {
|
||||
} else if match_percent >= 50.0 {
|
||||
Color32::LIGHT_BLUE
|
||||
} else {
|
||||
Color32::RED
|
||||
@@ -45,7 +45,11 @@ fn symbol_hover_ui(ui: &mut Ui, symbol: &ObjSymbol) {
|
||||
|
||||
ui.colored_label(Color32::WHITE, format!("Name: {}", symbol.name));
|
||||
ui.colored_label(Color32::WHITE, format!("Address: {:x}", symbol.address));
|
||||
ui.colored_label(Color32::WHITE, format!("Size: {:x}", symbol.size));
|
||||
if symbol.size_known {
|
||||
ui.colored_label(Color32::WHITE, format!("Size: {:x}", symbol.size));
|
||||
} else {
|
||||
ui.colored_label(Color32::WHITE, format!("Size: {:x} (assumed)", symbol.size));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -56,6 +60,7 @@ fn symbol_ui(
|
||||
highlighted_symbol: &mut Option<String>,
|
||||
selected_symbol: &mut Option<String>,
|
||||
current_view: &mut View,
|
||||
config: &ViewConfig,
|
||||
) {
|
||||
let mut job = LayoutJob::default();
|
||||
let name: &str =
|
||||
@@ -64,28 +69,29 @@ fn symbol_ui(
|
||||
if let Some(sym) = highlighted_symbol {
|
||||
selected = sym == &symbol.name;
|
||||
}
|
||||
write_text("[", Color32::GRAY, &mut job);
|
||||
write_text("[", Color32::GRAY, &mut job, config.code_font.clone());
|
||||
if symbol.flags.0.contains(ObjSymbolFlags::Common) {
|
||||
write_text("c", Color32::from_rgb(0, 255, 255), &mut job);
|
||||
write_text("c", Color32::from_rgb(0, 255, 255), &mut job, config.code_font.clone());
|
||||
} else if symbol.flags.0.contains(ObjSymbolFlags::Global) {
|
||||
write_text("g", Color32::GREEN, &mut job);
|
||||
write_text("g", Color32::GREEN, &mut job, config.code_font.clone());
|
||||
} else if symbol.flags.0.contains(ObjSymbolFlags::Local) {
|
||||
write_text("l", Color32::GRAY, &mut job);
|
||||
write_text("l", Color32::GRAY, &mut job, config.code_font.clone());
|
||||
}
|
||||
if symbol.flags.0.contains(ObjSymbolFlags::Weak) {
|
||||
write_text("w", Color32::GRAY, &mut job);
|
||||
write_text("w", Color32::GRAY, &mut job, config.code_font.clone());
|
||||
}
|
||||
write_text("] ", Color32::GRAY, &mut job);
|
||||
if symbol.match_percent > 0.0 {
|
||||
write_text("(", Color32::GRAY, &mut job);
|
||||
write_text("] ", Color32::GRAY, &mut job, config.code_font.clone());
|
||||
if let Some(match_percent) = symbol.match_percent {
|
||||
write_text("(", Color32::GRAY, &mut job, config.code_font.clone());
|
||||
write_text(
|
||||
&format!("{:.0}%", symbol.match_percent),
|
||||
match_color_for_symbol(symbol),
|
||||
&format!("{:.0}%", match_percent),
|
||||
match_color_for_symbol(match_percent),
|
||||
&mut job,
|
||||
config.code_font.clone(),
|
||||
);
|
||||
write_text(") ", Color32::GRAY, &mut job);
|
||||
write_text(") ", Color32::GRAY, &mut job, config.code_font.clone());
|
||||
}
|
||||
write_text(name, Color32::WHITE, &mut job);
|
||||
write_text(name, Color32::WHITE, &mut job, config.code_font.clone());
|
||||
let response = SelectableLabel::new(selected, job)
|
||||
.ui(ui)
|
||||
.context_menu(|ui| symbol_context_menu_ui(ui, symbol))
|
||||
@@ -123,6 +129,7 @@ fn symbol_list_ui(
|
||||
current_view: &mut View,
|
||||
reverse_function_order: bool,
|
||||
search: &mut String,
|
||||
config: &ViewConfig,
|
||||
) {
|
||||
ui.text_edit_singleline(search);
|
||||
let lower_search = search.to_ascii_lowercase();
|
||||
@@ -142,6 +149,7 @@ fn symbol_list_ui(
|
||||
highlighted_symbol,
|
||||
selected_symbol,
|
||||
current_view,
|
||||
config,
|
||||
);
|
||||
}
|
||||
});
|
||||
@@ -163,6 +171,7 @@ fn symbol_list_ui(
|
||||
highlighted_symbol,
|
||||
selected_symbol,
|
||||
current_view,
|
||||
config,
|
||||
);
|
||||
}
|
||||
} else {
|
||||
@@ -177,6 +186,7 @@ fn symbol_list_ui(
|
||||
highlighted_symbol,
|
||||
selected_symbol,
|
||||
current_view,
|
||||
config,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -255,6 +265,7 @@ pub fn symbol_diff_ui(ui: &mut Ui, view_state: &mut ViewState) {
|
||||
current_view,
|
||||
view_state.reverse_fn_order,
|
||||
search,
|
||||
&view_state.view_config,
|
||||
);
|
||||
});
|
||||
}
|
||||
@@ -274,6 +285,7 @@ pub fn symbol_diff_ui(ui: &mut Ui, view_state: &mut ViewState) {
|
||||
current_view,
|
||||
view_state.reverse_fn_order,
|
||||
search,
|
||||
&view_state.view_config,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user