mirror of
https://github.com/encounter/objdiff.git
synced 2025-06-28 09:23:30 +00:00
Migrate to Rust edition 2024
This commit is contained in:
parent
8eef37e8df
commit
799971d54e
@ -5,7 +5,7 @@ members = [
|
||||
"objdiff-gui",
|
||||
"objdiff-wasm",
|
||||
]
|
||||
resolver = "2"
|
||||
resolver = "3"
|
||||
|
||||
[profile.release-lto]
|
||||
inherits = "release"
|
||||
@ -16,7 +16,7 @@ codegen-units = 1
|
||||
[workspace.package]
|
||||
version = "3.0.0-beta.1"
|
||||
authors = ["Luke Street <luke@street.dev>"]
|
||||
edition = "2021"
|
||||
edition = "2024"
|
||||
license = "MIT OR Apache-2.0"
|
||||
repository = "https://github.com/encounter/objdiff"
|
||||
rust-version = "1.82"
|
||||
rust-version = "1.85"
|
||||
|
@ -4,7 +4,7 @@
|
||||
//! For now, this only adds a --version/-V option which causes early-exit.
|
||||
use std::ffi::OsStr;
|
||||
|
||||
use argp::{parser::ParseGlobalOptions, EarlyExit, FromArgs, TopLevelCommand};
|
||||
use argp::{EarlyExit, FromArgs, TopLevelCommand, parser::ParseGlobalOptions};
|
||||
|
||||
struct ArgsOrVersion<T>(T)
|
||||
where T: FromArgs;
|
||||
|
@ -3,40 +3,39 @@ use std::{
|
||||
mem,
|
||||
str::FromStr,
|
||||
sync::{
|
||||
atomic::{AtomicBool, Ordering},
|
||||
Arc,
|
||||
atomic::{AtomicBool, Ordering},
|
||||
},
|
||||
task::{Wake, Waker},
|
||||
time::Duration,
|
||||
};
|
||||
|
||||
use anyhow::{anyhow, bail, Context, Result};
|
||||
use anyhow::{Context, Result, anyhow, bail};
|
||||
use argp::FromArgs;
|
||||
use crossterm::{
|
||||
event,
|
||||
event::{DisableMouseCapture, EnableMouseCapture},
|
||||
terminal::{
|
||||
disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen, SetTitle,
|
||||
EnterAlternateScreen, LeaveAlternateScreen, SetTitle, disable_raw_mode, enable_raw_mode,
|
||||
},
|
||||
};
|
||||
use objdiff_core::{
|
||||
bindings::diff::DiffResult,
|
||||
build::{
|
||||
watcher::{create_watcher, Watcher},
|
||||
BuildConfig,
|
||||
watcher::{Watcher, create_watcher},
|
||||
},
|
||||
config::{
|
||||
build_globset,
|
||||
ProjectConfig, ProjectObject, ProjectObjectMetadata, build_globset,
|
||||
path::{check_path_buf, platform_path, platform_path_serde_option},
|
||||
ProjectConfig, ProjectObject, ProjectObjectMetadata,
|
||||
},
|
||||
diff::{
|
||||
self, ConfigEnum, ConfigPropertyId, ConfigPropertyKind, DiffObjConfig, MappingConfig,
|
||||
ObjectDiff,
|
||||
},
|
||||
jobs::{
|
||||
objdiff::{start_build, ObjDiffConfig},
|
||||
Job, JobQueue, JobResult,
|
||||
objdiff::{ObjDiffConfig, start_build},
|
||||
},
|
||||
obj::{self, Object},
|
||||
};
|
||||
@ -45,10 +44,10 @@ use typed_path::{Utf8PlatformPath, Utf8PlatformPathBuf};
|
||||
|
||||
use crate::{
|
||||
util::{
|
||||
output::{write_output, OutputFormat},
|
||||
output::{OutputFormat, write_output},
|
||||
term::crossterm_panic_handler,
|
||||
},
|
||||
views::{function_diff::FunctionDiffUi, EventControlFlow, EventResult, UiView},
|
||||
views::{EventControlFlow, EventResult, UiView, function_diff::FunctionDiffUi},
|
||||
};
|
||||
|
||||
#[derive(FromArgs, PartialEq, Debug)]
|
||||
@ -426,7 +425,8 @@ fn run_interactive(
|
||||
let mut result = EventResult { redraw: true, ..Default::default() };
|
||||
'outer: loop {
|
||||
if result.redraw {
|
||||
terminal.draw(|f| loop {
|
||||
terminal.draw(|f| {
|
||||
loop {
|
||||
result.redraw = false;
|
||||
view.draw(&state, f, &mut result);
|
||||
result.click_xy = None;
|
||||
@ -435,6 +435,7 @@ fn run_interactive(
|
||||
}
|
||||
// Clear buffer on redraw
|
||||
f.buffer_mut().reset();
|
||||
}
|
||||
})?;
|
||||
}
|
||||
loop {
|
||||
|
@ -1,12 +1,11 @@
|
||||
use std::{collections::HashSet, fs::File, io::Read, time::Instant};
|
||||
|
||||
use anyhow::{bail, Context, Result};
|
||||
use anyhow::{Context, Result, bail};
|
||||
use argp::FromArgs;
|
||||
use objdiff_core::{
|
||||
bindings::report::{
|
||||
ChangeItem, ChangeItemInfo, ChangeUnit, Changes, ChangesInput, Measures, Report,
|
||||
ReportCategory, ReportItem, ReportItemMetadata, ReportUnit, ReportUnitMetadata,
|
||||
REPORT_VERSION,
|
||||
ChangeItem, ChangeItemInfo, ChangeUnit, Changes, ChangesInput, Measures, REPORT_VERSION,
|
||||
Report, ReportCategory, ReportItem, ReportItemMetadata, ReportUnit, ReportUnitMetadata,
|
||||
},
|
||||
config::path::platform_path,
|
||||
diff, obj,
|
||||
@ -19,7 +18,7 @@ use typed_path::{Utf8PlatformPath, Utf8PlatformPathBuf};
|
||||
|
||||
use crate::{
|
||||
cmd::diff::ObjectConfig,
|
||||
util::output::{write_output, OutputFormat},
|
||||
util::output::{OutputFormat, write_output},
|
||||
};
|
||||
|
||||
#[derive(FromArgs, PartialEq, Debug)]
|
||||
@ -206,11 +205,7 @@ fn report_object(
|
||||
let section_match_percent = section_diff.match_percent.unwrap_or_else(|| {
|
||||
// Support cases where we don't have a target object,
|
||||
// assume complete means 100% match
|
||||
if object.complete.unwrap_or(false) {
|
||||
100.0
|
||||
} else {
|
||||
0.0
|
||||
}
|
||||
if object.complete.unwrap_or(false) { 100.0 } else { 0.0 }
|
||||
});
|
||||
sections.push(ReportItem {
|
||||
name: section.name.clone(),
|
||||
@ -251,11 +246,7 @@ fn report_object(
|
||||
let match_percent = symbol_diff.match_percent.unwrap_or_else(|| {
|
||||
// Support cases where we don't have a target object,
|
||||
// assume complete means 100% match
|
||||
if object.complete.unwrap_or(false) {
|
||||
100.0
|
||||
} else {
|
||||
0.0
|
||||
}
|
||||
if object.complete.unwrap_or(false) { 100.0 } else { 0.0 }
|
||||
});
|
||||
measures.fuzzy_match_percent += match_percent * symbol.size as f32;
|
||||
measures.total_code += symbol.size;
|
||||
|
@ -17,7 +17,7 @@ use anyhow::{Error, Result};
|
||||
use argp::{FromArgValue, FromArgs};
|
||||
use enable_ansi_support::enable_ansi_support;
|
||||
use supports_color::Stream;
|
||||
use tracing_subscriber::{filter::LevelFilter, EnvFilter};
|
||||
use tracing_subscriber::{EnvFilter, filter::LevelFilter};
|
||||
|
||||
#[derive(Debug, Eq, PartialEq, Copy, Clone)]
|
||||
enum LogLevel {
|
||||
|
@ -5,7 +5,7 @@ use std::{
|
||||
path::Path,
|
||||
};
|
||||
|
||||
use anyhow::{bail, Context, Result};
|
||||
use anyhow::{Context, Result, bail};
|
||||
use tracing::info;
|
||||
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, Default)]
|
||||
|
@ -3,7 +3,7 @@ use std::{io::stdout, panic};
|
||||
use crossterm::{
|
||||
cursor::Show,
|
||||
event::DisableMouseCapture,
|
||||
terminal::{disable_raw_mode, LeaveAlternateScreen},
|
||||
terminal::{LeaveAlternateScreen, disable_raw_mode},
|
||||
};
|
||||
|
||||
pub fn crossterm_panic_handler() {
|
||||
|
@ -1,18 +1,18 @@
|
||||
use core::cmp::Ordering;
|
||||
|
||||
use anyhow::{bail, Result};
|
||||
use anyhow::{Result, bail};
|
||||
use crossterm::event::{Event, KeyCode, KeyEventKind, KeyModifiers, MouseButton, MouseEventKind};
|
||||
use objdiff_core::{
|
||||
diff::{
|
||||
display::{display_row, DiffText, DiffTextColor, HighlightKind},
|
||||
DiffObjConfig, FunctionRelocDiffs, InstructionDiffKind, ObjectDiff, SymbolDiff,
|
||||
display::{DiffText, DiffTextColor, HighlightKind, display_row},
|
||||
},
|
||||
obj::Object,
|
||||
};
|
||||
use ratatui::{
|
||||
Frame,
|
||||
prelude::*,
|
||||
widgets::{Block, Borders, Clear, Paragraph, Scrollbar, ScrollbarOrientation, ScrollbarState},
|
||||
Frame,
|
||||
};
|
||||
|
||||
use super::{EventControlFlow, EventResult, UiView};
|
||||
|
@ -5,14 +5,14 @@ use alloc::{
|
||||
vec::Vec,
|
||||
};
|
||||
|
||||
use anyhow::{bail, Result};
|
||||
use arm_attr::{enums::CpuArch, tag::Tag, BuildAttrs};
|
||||
use object::{elf, Endian as _, Object as _, ObjectSection as _, ObjectSymbol as _};
|
||||
use anyhow::{Result, bail};
|
||||
use arm_attr::{BuildAttrs, enums::CpuArch, tag::Tag};
|
||||
use object::{Endian as _, Object as _, ObjectSection as _, ObjectSymbol as _, elf};
|
||||
use unarm::{args, arm, thumb};
|
||||
|
||||
use crate::{
|
||||
arch::Arch,
|
||||
diff::{display::InstructionPart, ArmArchVersion, ArmR9Usage, DiffObjConfig},
|
||||
diff::{ArmArchVersion, ArmR9Usage, DiffObjConfig, display::InstructionPart},
|
||||
obj::{
|
||||
InstructionRef, RelocationFlags, ResolvedInstructionRef, ResolvedRelocation,
|
||||
ScannedInstruction, SymbolFlag, SymbolFlagSet, SymbolKind,
|
||||
@ -58,11 +58,7 @@ impl ArchArm {
|
||||
}
|
||||
// Only checking first CpuArch tag. Others may exist, but that's very unlikely.
|
||||
let cpu_arch = subsection.into_public_tag_iter()?.find_map(|(_, tag)| {
|
||||
if let Tag::CpuArch(cpu_arch) = tag {
|
||||
Some(cpu_arch)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
if let Tag::CpuArch(cpu_arch) = tag { Some(cpu_arch) } else { None }
|
||||
});
|
||||
match cpu_arch {
|
||||
Some(CpuArch::V4T) => return Ok(Some(unarm::ArmVersion::V4T)),
|
||||
@ -358,11 +354,7 @@ impl Arch for ArchArm {
|
||||
}
|
||||
|
||||
fn symbol_address(&self, address: u64, kind: SymbolKind) -> u64 {
|
||||
if kind == SymbolKind::Function {
|
||||
address & !1
|
||||
} else {
|
||||
address
|
||||
}
|
||||
if kind == SymbolKind::Function { address & !1 } else { address }
|
||||
}
|
||||
|
||||
fn extra_symbol_flags(&self, symbol: &object::Symbol) -> SymbolFlagSet {
|
||||
|
@ -5,7 +5,7 @@ use alloc::{
|
||||
};
|
||||
use core::cmp::Ordering;
|
||||
|
||||
use anyhow::{bail, Result};
|
||||
use anyhow::{Result, bail};
|
||||
use object::elf;
|
||||
use yaxpeax_arch::{Arch as YaxpeaxArch, Decoder, Reader, U8Reader};
|
||||
use yaxpeax_arm::armv8::a64::{
|
||||
@ -15,7 +15,7 @@ use yaxpeax_arm::armv8::a64::{
|
||||
|
||||
use crate::{
|
||||
arch::Arch,
|
||||
diff::{display::InstructionPart, DiffObjConfig},
|
||||
diff::{DiffObjConfig, display::InstructionPart},
|
||||
obj::{
|
||||
InstructionRef, RelocationFlags, ResolvedInstructionRef, ResolvedRelocation,
|
||||
ScannedInstruction,
|
||||
@ -216,11 +216,7 @@ where Cb: FnMut(InstructionPart<'static>) {
|
||||
unreachable!("movn operand 1 is always ImmShift");
|
||||
};
|
||||
let imm = if let Operand::Register(size, _) = ins.operands[0] {
|
||||
if size == SizeCode::W {
|
||||
imm as u32 as u64
|
||||
} else {
|
||||
imm
|
||||
}
|
||||
if size == SizeCode::W { imm as u32 as u64 } else { imm }
|
||||
} else {
|
||||
unreachable!("movn operand 0 is always Register");
|
||||
};
|
||||
@ -237,11 +233,7 @@ where Cb: FnMut(InstructionPart<'static>) {
|
||||
unreachable!("movz operand is always ImmShift");
|
||||
};
|
||||
let imm = if let Operand::Register(size, _) = ins.operands[0] {
|
||||
if size == SizeCode::W {
|
||||
imm as u32 as u64
|
||||
} else {
|
||||
imm
|
||||
}
|
||||
if size == SizeCode::W { imm as u32 as u64 } else { imm }
|
||||
} else {
|
||||
unreachable!("movz operand 0 is always Register");
|
||||
};
|
||||
@ -574,11 +566,7 @@ where Cb: FnMut(InstructionPart<'static>) {
|
||||
{
|
||||
if immr < imms {
|
||||
let size = if let Operand::Register(size, _) = ins.operands[0] {
|
||||
if size == SizeCode::W {
|
||||
32
|
||||
} else {
|
||||
64
|
||||
}
|
||||
if size == SizeCode::W { 32 } else { 64 }
|
||||
} else {
|
||||
unreachable!("operand 0 is always a register");
|
||||
};
|
||||
|
@ -1,18 +1,18 @@
|
||||
use alloc::{collections::BTreeMap, string::ToString, vec::Vec};
|
||||
use core::ops::Range;
|
||||
|
||||
use anyhow::{bail, Result};
|
||||
use object::{elf, Endian as _, Object as _, ObjectSection as _, ObjectSymbol as _};
|
||||
use anyhow::{Result, bail};
|
||||
use object::{Endian as _, Object as _, ObjectSection as _, ObjectSymbol as _, elf};
|
||||
use rabbitizer::{
|
||||
abi::Abi,
|
||||
operands::{ValuedOperand, IU16},
|
||||
registers_meta::Register,
|
||||
IsaExtension, IsaVersion, Vram,
|
||||
abi::Abi,
|
||||
operands::{IU16, ValuedOperand},
|
||||
registers_meta::Register,
|
||||
};
|
||||
|
||||
use crate::{
|
||||
arch::Arch,
|
||||
diff::{display::InstructionPart, DiffObjConfig, MipsAbi, MipsInstrCategory},
|
||||
diff::{DiffObjConfig, MipsAbi, MipsInstrCategory, display::InstructionPart},
|
||||
obj::{
|
||||
InstructionArg, InstructionArgValue, InstructionRef, Relocation, RelocationFlags,
|
||||
ResolvedInstructionRef, ResolvedRelocation, ScannedInstruction,
|
||||
|
@ -1,13 +1,13 @@
|
||||
use alloc::{borrow::Cow, boxed::Box, format, string::String, vec::Vec};
|
||||
use core::{ffi::CStr, fmt, fmt::Debug};
|
||||
|
||||
use anyhow::{bail, Result};
|
||||
use anyhow::{Result, bail};
|
||||
use object::Endian as _;
|
||||
|
||||
use crate::{
|
||||
diff::{
|
||||
display::{ContextItem, HoverItem, InstructionPart},
|
||||
DiffObjConfig,
|
||||
display::{ContextItem, HoverItem, InstructionPart},
|
||||
},
|
||||
obj::{
|
||||
InstructionArg, Object, ParsedInstruction, Relocation, RelocationFlags,
|
||||
@ -66,7 +66,9 @@ impl DataType {
|
||||
pub fn display_literals(&self, endian: object::Endianness, bytes: &[u8]) -> Vec<String> {
|
||||
let mut strs = Vec::new();
|
||||
if self.required_len().is_some_and(|l| bytes.len() < l) {
|
||||
log::warn!("Failed to display a symbol value for a symbol whose size is too small for instruction referencing it.");
|
||||
log::warn!(
|
||||
"Failed to display a symbol value for a symbol whose size is too small for instruction referencing it."
|
||||
);
|
||||
return strs;
|
||||
}
|
||||
let mut bytes = bytes;
|
||||
|
@ -5,17 +5,17 @@ use alloc::{
|
||||
vec::Vec,
|
||||
};
|
||||
|
||||
use anyhow::{bail, ensure, Result};
|
||||
use cwextab::{decode_extab, ExceptionTableData};
|
||||
use anyhow::{Result, bail, ensure};
|
||||
use cwextab::{ExceptionTableData, decode_extab};
|
||||
use flagset::Flags;
|
||||
use object::{elf, Object as _, ObjectSection as _, ObjectSymbol as _};
|
||||
use object::{Object as _, ObjectSection as _, ObjectSymbol as _, elf};
|
||||
|
||||
use crate::{
|
||||
arch::{Arch, DataType},
|
||||
diff::{
|
||||
DiffObjConfig,
|
||||
data::resolve_relocation,
|
||||
display::{ContextItem, HoverItem, HoverItemColor, InstructionPart, SymbolNavigationKind},
|
||||
DiffObjConfig,
|
||||
},
|
||||
obj::{
|
||||
InstructionRef, Object, Relocation, RelocationFlags, ResolvedInstructionRef,
|
||||
@ -826,8 +826,8 @@ fn generate_fake_pool_relocations_for_function(
|
||||
for unseen_addr in unseen_addrs {
|
||||
let prev_bctr_gpr_state = gpr_state_at_bctr
|
||||
.iter()
|
||||
.filter(|(&addr, _)| addr < unseen_addr)
|
||||
.min_by_key(|(&addr, _)| addr)
|
||||
.filter(|&(&addr, _)| addr < unseen_addr)
|
||||
.min_by_key(|&(&addr, _)| addr)
|
||||
.map(|(_, gpr_state)| gpr_state);
|
||||
if let Some(gpr_pool_relocs) = prev_bctr_gpr_state {
|
||||
let dest_offset_into_func = unseen_addr - func_address as u32;
|
||||
|
@ -1,15 +1,15 @@
|
||||
use alloc::{boxed::Box, string::String, vec::Vec};
|
||||
|
||||
use anyhow::{anyhow, bail, Result};
|
||||
use anyhow::{Result, anyhow, bail};
|
||||
use iced_x86::{
|
||||
Decoder, DecoderOptions, DecoratorKind, FormatterOutput, FormatterTextKind, GasFormatter,
|
||||
Instruction, IntelFormatter, MasmFormatter, NasmFormatter, NumberKind, OpKind, Register,
|
||||
};
|
||||
use object::{pe, Endian as _, Object as _, ObjectSection as _};
|
||||
use object::{Endian as _, Object as _, ObjectSection as _, pe};
|
||||
|
||||
use crate::{
|
||||
arch::Arch,
|
||||
diff::{display::InstructionPart, DiffObjConfig, X86Formatter},
|
||||
diff::{DiffObjConfig, X86Formatter, display::InstructionPart},
|
||||
obj::{InstructionRef, RelocationFlags, ResolvedInstructionRef, ScannedInstruction},
|
||||
};
|
||||
|
||||
|
@ -7,7 +7,7 @@ use alloc::{
|
||||
};
|
||||
use core::ops::AddAssign;
|
||||
|
||||
use anyhow::{bail, Result};
|
||||
use anyhow::{Result, bail};
|
||||
use prost::Message;
|
||||
|
||||
// Protobuf report types
|
||||
@ -441,11 +441,7 @@ impl From<LegacyReportItem> for ReportItem {
|
||||
#[cfg(feature = "serde")]
|
||||
fn serialize_hex<S>(x: &Option<u64>, s: S) -> Result<S::Ok, S::Error>
|
||||
where S: serde::Serializer {
|
||||
if let Some(x) = x {
|
||||
s.serialize_str(&format!("{:#x}", x))
|
||||
} else {
|
||||
s.serialize_none()
|
||||
}
|
||||
if let Some(x) = x { s.serialize_str(&format!("{:#x}", x)) } else { s.serialize_none() }
|
||||
}
|
||||
|
||||
#[cfg(feature = "serde")]
|
||||
|
@ -2,8 +2,8 @@ use std::{
|
||||
fs,
|
||||
path::{Path, PathBuf},
|
||||
sync::{
|
||||
atomic::{AtomicBool, Ordering},
|
||||
Arc,
|
||||
atomic::{AtomicBool, Ordering},
|
||||
},
|
||||
task::Waker,
|
||||
time::Duration,
|
||||
@ -11,7 +11,7 @@ use std::{
|
||||
|
||||
use globset::GlobSet;
|
||||
use notify::RecursiveMode;
|
||||
use notify_debouncer_full::{new_debouncer_opt, DebounceEventResult};
|
||||
use notify_debouncer_full::{DebounceEventResult, new_debouncer_opt};
|
||||
|
||||
pub type Watcher = notify_debouncer_full::Debouncer<
|
||||
notify::RecommendedWatcher,
|
||||
|
@ -6,7 +6,7 @@ use alloc::{
|
||||
vec::Vec,
|
||||
};
|
||||
|
||||
use anyhow::{anyhow, Context, Result};
|
||||
use anyhow::{Context, Result, anyhow};
|
||||
use globset::{Glob, GlobSet, GlobSetBuilder};
|
||||
use path::unix_path_serde_option;
|
||||
use typed_path::Utf8UnixPathBuf;
|
||||
|
@ -31,11 +31,7 @@ pub mod unix_path_serde_option {
|
||||
|
||||
pub fn serialize<S>(path: &Option<Utf8UnixPathBuf>, s: S) -> Result<S::Ok, S::Error>
|
||||
where S: Serializer {
|
||||
if let Some(path) = path {
|
||||
s.serialize_some(path.as_str())
|
||||
} else {
|
||||
s.serialize_none()
|
||||
}
|
||||
if let Some(path) = path { s.serialize_some(path.as_str()) } else { s.serialize_none() }
|
||||
}
|
||||
|
||||
pub fn deserialize<'de, D>(deserializer: D) -> Result<Option<Utf8UnixPathBuf>, D::Error>
|
||||
@ -51,11 +47,7 @@ pub mod platform_path_serde_option {
|
||||
|
||||
pub fn serialize<S>(path: &Option<Utf8PlatformPathBuf>, s: S) -> Result<S::Ok, S::Error>
|
||||
where S: Serializer {
|
||||
if let Some(path) = path {
|
||||
s.serialize_some(path.as_str())
|
||||
} else {
|
||||
s.serialize_none()
|
||||
}
|
||||
if let Some(path) = path { s.serialize_some(path.as_str()) } else { s.serialize_none() }
|
||||
}
|
||||
|
||||
pub fn deserialize<'de, D>(deserializer: D) -> Result<Option<Utf8PlatformPathBuf>, D::Error>
|
||||
|
@ -1,16 +1,16 @@
|
||||
use alloc::{
|
||||
collections::{btree_map, BTreeMap},
|
||||
collections::{BTreeMap, btree_map},
|
||||
string::{String, ToString},
|
||||
vec,
|
||||
vec::Vec,
|
||||
};
|
||||
|
||||
use anyhow::{anyhow, ensure, Context, Result};
|
||||
use anyhow::{Context, Result, anyhow, ensure};
|
||||
|
||||
use super::{
|
||||
display::display_ins_data_literals, DiffObjConfig, FunctionRelocDiffs, InstructionArgDiffIndex,
|
||||
InstructionBranchFrom, InstructionBranchTo, InstructionDiffKind, InstructionDiffRow,
|
||||
SymbolDiff,
|
||||
DiffObjConfig, FunctionRelocDiffs, InstructionArgDiffIndex, InstructionBranchFrom,
|
||||
InstructionBranchTo, InstructionDiffKind, InstructionDiffRow, SymbolDiff,
|
||||
display::display_ins_data_literals,
|
||||
};
|
||||
use crate::obj::{
|
||||
InstructionArg, InstructionArgValue, InstructionRef, Object, ResolvedInstructionRef,
|
||||
|
@ -1,12 +1,12 @@
|
||||
use alloc::{vec, vec::Vec};
|
||||
use core::{cmp::Ordering, ops::Range};
|
||||
|
||||
use anyhow::{anyhow, Result};
|
||||
use similar::{capture_diff_slices, get_diff_ratio, Algorithm};
|
||||
use anyhow::{Result, anyhow};
|
||||
use similar::{Algorithm, capture_diff_slices, get_diff_ratio};
|
||||
|
||||
use super::{
|
||||
code::{address_eq, section_name_eq},
|
||||
DataDiff, DataDiffKind, DataRelocationDiff, ObjectDiff, SectionDiff, SymbolDiff,
|
||||
code::{address_eq, section_name_eq},
|
||||
};
|
||||
use crate::obj::{Object, Relocation, ResolvedRelocation, Symbol, SymbolFlag, SymbolKind};
|
||||
|
||||
@ -431,11 +431,7 @@ pub fn diff_generic_section(
|
||||
.fold((0.0, 0.0), |(matched, total), (s, d)| {
|
||||
(matched + d.match_percent.unwrap_or(0.0) * s.size as f32, total + s.size as f32)
|
||||
});
|
||||
if total == 0.0 {
|
||||
100.0
|
||||
} else {
|
||||
matched / total
|
||||
}
|
||||
if total == 0.0 { 100.0 } else { matched / total }
|
||||
};
|
||||
Ok((
|
||||
SectionDiff { match_percent: Some(match_percent), data_diff: vec![], reloc_diff: vec![] },
|
||||
|
@ -26,13 +26,7 @@ pub mod display;
|
||||
include!(concat!(env!("OUT_DIR"), "/config.gen.rs"));
|
||||
|
||||
impl DiffObjConfig {
|
||||
pub fn separator(&self) -> &'static str {
|
||||
if self.space_between_args {
|
||||
", "
|
||||
} else {
|
||||
","
|
||||
}
|
||||
}
|
||||
pub fn separator(&self) -> &'static str { if self.space_between_args { ", " } else { "," } }
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
|
@ -6,7 +6,7 @@ use self_update::{
|
||||
update::{Release, ReleaseUpdate},
|
||||
};
|
||||
|
||||
use crate::jobs::{start_job, update_status, Job, JobContext, JobResult, JobState};
|
||||
use crate::jobs::{Job, JobContext, JobResult, JobState, start_job, update_status};
|
||||
|
||||
pub struct CheckUpdateConfig {
|
||||
pub build_updater: fn() -> Result<Box<dyn ReleaseUpdate>>,
|
||||
|
@ -1,11 +1,11 @@
|
||||
use std::{fs, sync::mpsc::Receiver, task::Waker};
|
||||
|
||||
use anyhow::{anyhow, bail, Context, Result};
|
||||
use anyhow::{Context, Result, anyhow, bail};
|
||||
use typed_path::{Utf8PlatformPathBuf, Utf8UnixPathBuf};
|
||||
|
||||
use crate::{
|
||||
build::{run_make, BuildConfig, BuildStatus},
|
||||
jobs::{start_job, update_status, Job, JobContext, JobResult, JobState},
|
||||
build::{BuildConfig, BuildStatus, run_make},
|
||||
jobs::{Job, JobContext, JobResult, JobState, start_job, update_status},
|
||||
};
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
|
@ -1,8 +1,8 @@
|
||||
use std::{
|
||||
sync::{
|
||||
Arc, RwLock,
|
||||
atomic::{AtomicUsize, Ordering},
|
||||
mpsc::{Receiver, Sender, TryRecvError},
|
||||
Arc, RwLock,
|
||||
},
|
||||
task::Waker,
|
||||
thread::JoinHandle,
|
||||
|
@ -1,14 +1,14 @@
|
||||
use std::{sync::mpsc::Receiver, task::Waker};
|
||||
|
||||
use anyhow::{bail, Error, Result};
|
||||
use anyhow::{Error, Result, bail};
|
||||
use time::OffsetDateTime;
|
||||
use typed_path::Utf8PlatformPathBuf;
|
||||
|
||||
use crate::{
|
||||
build::{run_make, BuildConfig, BuildStatus},
|
||||
diff::{diff_objs, DiffObjConfig, MappingConfig, ObjectDiff},
|
||||
jobs::{start_job, update_status, Job, JobContext, JobResult, JobState},
|
||||
obj::{read, Object},
|
||||
build::{BuildConfig, BuildStatus, run_make},
|
||||
diff::{DiffObjConfig, MappingConfig, ObjectDiff, diff_objs},
|
||||
jobs::{Job, JobContext, JobResult, JobState, start_job, update_status},
|
||||
obj::{Object, read},
|
||||
};
|
||||
|
||||
pub struct ObjDiffConfig {
|
||||
|
@ -10,7 +10,7 @@ use anyhow::{Context, Result};
|
||||
pub use self_update; // Re-export self_update crate
|
||||
use self_update::update::ReleaseUpdate;
|
||||
|
||||
use crate::jobs::{start_job, update_status, Job, JobContext, JobResult, JobState};
|
||||
use crate::jobs::{Job, JobContext, JobResult, JobState, start_job, update_status};
|
||||
|
||||
pub struct UpdateConfig {
|
||||
pub build_updater: fn() -> Result<Box<dyn ReleaseUpdate>>,
|
||||
|
@ -11,7 +11,7 @@ use alloc::{
|
||||
};
|
||||
use core::{fmt, num::NonZeroU32};
|
||||
|
||||
use flagset::{flags, FlagSet};
|
||||
use flagset::{FlagSet, flags};
|
||||
|
||||
use crate::{
|
||||
arch::{Arch, ArchDummy},
|
||||
|
@ -6,16 +6,16 @@ use alloc::{
|
||||
};
|
||||
use core::cmp::Ordering;
|
||||
|
||||
use anyhow::{anyhow, bail, ensure, Context, Result};
|
||||
use anyhow::{Context, Result, anyhow, bail, ensure};
|
||||
use object::{Object as _, ObjectSection as _, ObjectSymbol as _};
|
||||
|
||||
use crate::{
|
||||
arch::{new_arch, Arch},
|
||||
arch::{Arch, new_arch},
|
||||
diff::DiffObjConfig,
|
||||
obj::{
|
||||
split_meta::{SplitMeta, SPLITMETA_SECTION},
|
||||
Object, Relocation, RelocationFlags, Section, SectionData, SectionFlag, SectionKind,
|
||||
Symbol, SymbolFlag, SymbolKind,
|
||||
split_meta::{SPLITMETA_SECTION, SplitMeta},
|
||||
},
|
||||
util::{read_u16, read_u32},
|
||||
};
|
||||
|
@ -1,7 +1,7 @@
|
||||
use alloc::{string::String, vec, vec::Vec};
|
||||
|
||||
use anyhow::{anyhow, Result};
|
||||
use object::{elf::SHT_NOTE, Endian, ObjectSection};
|
||||
use anyhow::{Result, anyhow};
|
||||
use object::{Endian, ObjectSection, elf::SHT_NOTE};
|
||||
|
||||
pub const SPLITMETA_SECTION: &str = ".note.split";
|
||||
pub const SHT_SPLITMETA: u32 = SHT_NOTE;
|
||||
|
@ -1,7 +1,7 @@
|
||||
use alloc::format;
|
||||
use core::fmt;
|
||||
|
||||
use anyhow::{ensure, Result};
|
||||
use anyhow::{Result, ensure};
|
||||
use num_traits::PrimInt;
|
||||
use object::{Endian, Object};
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
use objdiff_core::{
|
||||
diff::{display::DiffTextSegment, DiffObjConfig, SymbolDiff},
|
||||
diff::{DiffObjConfig, SymbolDiff, display::DiffTextSegment},
|
||||
obj::Object,
|
||||
};
|
||||
|
||||
|
@ -5,8 +5,8 @@ use std::{
|
||||
path::{Path, PathBuf},
|
||||
rc::Rc,
|
||||
sync::{
|
||||
atomic::{AtomicBool, Ordering},
|
||||
Arc, Mutex, RwLock,
|
||||
atomic::{AtomicBool, Ordering},
|
||||
},
|
||||
time::Instant,
|
||||
};
|
||||
@ -14,11 +14,11 @@ use std::{
|
||||
use filetime::FileTime;
|
||||
use globset::Glob;
|
||||
use objdiff_core::{
|
||||
build::watcher::{create_watcher, Watcher},
|
||||
build::watcher::{Watcher, create_watcher},
|
||||
config::{
|
||||
DEFAULT_WATCH_PATTERNS, ProjectConfig, ProjectConfigInfo, ProjectObject, ScratchConfig,
|
||||
build_globset, default_watch_patterns, path::platform_path_serde_option,
|
||||
save_project_config, ProjectConfig, ProjectConfigInfo, ProjectObject, ScratchConfig,
|
||||
DEFAULT_WATCH_PATTERNS,
|
||||
save_project_config,
|
||||
},
|
||||
diff::DiffObjConfig,
|
||||
jobs::{Job, JobQueue, JobResult},
|
||||
@ -27,22 +27,22 @@ use time::UtcOffset;
|
||||
use typed_path::{Utf8PlatformPath, Utf8PlatformPathBuf};
|
||||
|
||||
use crate::{
|
||||
app_config::{deserialize_config, AppConfigVersion},
|
||||
config::{load_project_config, ProjectObjectNode},
|
||||
app_config::{AppConfigVersion, deserialize_config},
|
||||
config::{ProjectObjectNode, load_project_config},
|
||||
jobs::{create_objdiff_config, egui_waker, start_build},
|
||||
views::{
|
||||
appearance::{appearance_window, Appearance},
|
||||
appearance::{Appearance, appearance_window},
|
||||
config::{
|
||||
arch_config_window, config_ui, general_config_ui, project_window, ConfigViewState,
|
||||
CONFIG_DISABLED_TEXT,
|
||||
CONFIG_DISABLED_TEXT, ConfigViewState, arch_config_window, config_ui,
|
||||
general_config_ui, project_window,
|
||||
},
|
||||
debug::debug_window,
|
||||
demangle::{demangle_window, DemangleViewState},
|
||||
demangle::{DemangleViewState, demangle_window},
|
||||
diff::diff_view_ui,
|
||||
frame_history::FrameHistory,
|
||||
graphics::{graphics_window, GraphicsConfig, GraphicsViewState},
|
||||
graphics::{GraphicsConfig, GraphicsViewState, graphics_window},
|
||||
jobs::{jobs_menu_ui, jobs_window},
|
||||
rlwinm::{rlwinm_decode_window, RlwinmDecodeViewState},
|
||||
rlwinm::{RlwinmDecodeViewState, rlwinm_decode_window},
|
||||
symbol_diff::{DiffViewAction, DiffViewState, ResolvedNavigation, View},
|
||||
},
|
||||
};
|
||||
|
@ -11,7 +11,7 @@ use objdiff_core::{
|
||||
};
|
||||
use typed_path::{Utf8PlatformPathBuf, Utf8UnixPathBuf};
|
||||
|
||||
use crate::app::{AppConfig, ObjectConfig, CONFIG_KEY};
|
||||
use crate::app::{AppConfig, CONFIG_KEY, ObjectConfig};
|
||||
|
||||
#[derive(Clone, serde::Deserialize, serde::Serialize)]
|
||||
pub struct AppConfigVersion {
|
||||
|
@ -1,6 +1,6 @@
|
||||
use anyhow::Result;
|
||||
use globset::Glob;
|
||||
use objdiff_core::config::{try_project_config, DEFAULT_WATCH_PATTERNS};
|
||||
use objdiff_core::config::{DEFAULT_WATCH_PATTERNS, try_project_config};
|
||||
use typed_path::{Utf8UnixComponent, Utf8UnixPath};
|
||||
|
||||
use crate::app::{AppState, ObjectConfig};
|
||||
|
@ -1,5 +1,5 @@
|
||||
use egui::{
|
||||
style::ScrollAnimation, vec2, Context, Key, KeyboardShortcut, Modifiers, PointerButton,
|
||||
Context, Key, KeyboardShortcut, Modifiers, PointerButton, style::ScrollAnimation, vec2,
|
||||
};
|
||||
|
||||
fn any_widget_focused(ctx: &Context) -> bool { ctx.memory(|mem| mem.focused().is_some()) }
|
||||
|
@ -3,18 +3,18 @@ use std::{
|
||||
task::{Wake, Waker},
|
||||
};
|
||||
|
||||
use anyhow::{bail, Result};
|
||||
use anyhow::{Result, bail};
|
||||
use jobs::create_scratch;
|
||||
use objdiff_core::{
|
||||
build::BuildConfig,
|
||||
diff::MappingConfig,
|
||||
jobs,
|
||||
jobs::{check_update::CheckUpdateConfig, objdiff, update::UpdateConfig, Job, JobQueue},
|
||||
jobs::{Job, JobQueue, check_update::CheckUpdateConfig, objdiff, update::UpdateConfig},
|
||||
};
|
||||
|
||||
use crate::{
|
||||
app::{AppConfig, AppState},
|
||||
update::{build_updater, BIN_NAME_NEW, BIN_NAME_OLD},
|
||||
update::{BIN_NAME_NEW, BIN_NAME_OLD, build_updater},
|
||||
};
|
||||
|
||||
struct EguiWaker(egui::Context);
|
||||
|
@ -17,12 +17,12 @@ use std::{
|
||||
sync::{Arc, Mutex},
|
||||
};
|
||||
|
||||
use anyhow::{ensure, Result};
|
||||
use anyhow::{Result, ensure};
|
||||
use cfg_if::cfg_if;
|
||||
use time::UtcOffset;
|
||||
use tracing_subscriber::EnvFilter;
|
||||
|
||||
use crate::views::graphics::{load_graphics_config, GraphicsBackend, GraphicsConfig};
|
||||
use crate::views::graphics::{GraphicsBackend, GraphicsConfig, load_graphics_config};
|
||||
|
||||
fn load_icon() -> Result<egui::IconData> {
|
||||
let decoder = png::Decoder::new(include_bytes!("../assets/icon_64.png").as_ref());
|
||||
@ -86,7 +86,7 @@ fn main() -> ExitCode {
|
||||
}
|
||||
#[cfg(feature = "wgpu")]
|
||||
{
|
||||
use eframe::egui_wgpu::{wgpu, WgpuSetup};
|
||||
use eframe::egui_wgpu::{WgpuSetup, wgpu};
|
||||
if graphics_config.desired_backend.is_supported() {
|
||||
native_options.wgpu_options.wgpu_setup = match native_options.wgpu_options.wgpu_setup {
|
||||
WgpuSetup::CreateNew(mut setup) => {
|
||||
|
@ -1,6 +1,6 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use egui::{text::LayoutJob, Color32, FontFamily, FontId, TextFormat, TextStyle, Widget};
|
||||
use egui::{Color32, FontFamily, FontId, TextFormat, TextStyle, Widget, text::LayoutJob};
|
||||
use time::UtcOffset;
|
||||
|
||||
use crate::fonts::load_font_if_needed;
|
||||
|
@ -5,17 +5,17 @@ use std::{mem::take, path::MAIN_SEPARATOR};
|
||||
#[cfg(all(windows, feature = "wsl"))]
|
||||
use anyhow::{Context, Result};
|
||||
use egui::{
|
||||
output::OpenUrl, text::LayoutJob, CollapsingHeader, FontFamily, FontId, RichText,
|
||||
SelectableLabel, TextFormat, Widget,
|
||||
CollapsingHeader, FontFamily, FontId, RichText, SelectableLabel, TextFormat, Widget,
|
||||
output::OpenUrl, text::LayoutJob,
|
||||
};
|
||||
use globset::Glob;
|
||||
use objdiff_core::{
|
||||
config::{path::check_path_buf, DEFAULT_WATCH_PATTERNS},
|
||||
config::{DEFAULT_WATCH_PATTERNS, path::check_path_buf},
|
||||
diff::{
|
||||
ConfigEnum, ConfigEnumVariantInfo, ConfigPropertyId, ConfigPropertyKind,
|
||||
ConfigPropertyValue, CONFIG_GROUPS,
|
||||
CONFIG_GROUPS, ConfigEnum, ConfigEnumVariantInfo, ConfigPropertyId, ConfigPropertyKind,
|
||||
ConfigPropertyValue,
|
||||
},
|
||||
jobs::{check_update::CheckUpdateResult, Job, JobQueue, JobResult},
|
||||
jobs::{Job, JobQueue, JobResult, check_update::CheckUpdateResult},
|
||||
};
|
||||
use typed_path::Utf8PlatformPathBuf;
|
||||
|
||||
@ -347,11 +347,7 @@ fn display_unit(
|
||||
let color = if selected {
|
||||
appearance.emphasized_text_color
|
||||
} else if let Some(complete) = object.complete {
|
||||
if complete {
|
||||
appearance.insert_color
|
||||
} else {
|
||||
appearance.delete_color
|
||||
}
|
||||
if complete { appearance.insert_color } else { appearance.delete_color }
|
||||
} else {
|
||||
appearance.text_color
|
||||
};
|
||||
|
@ -1,11 +1,11 @@
|
||||
use std::{cmp::min, default::Default, mem::take};
|
||||
|
||||
use egui::{text::LayoutJob, Label, Sense, Widget};
|
||||
use egui::{Label, Sense, Widget, text::LayoutJob};
|
||||
use objdiff_core::{
|
||||
diff::{
|
||||
data::resolve_relocation,
|
||||
display::{relocation_context, relocation_hover, ContextItem, HoverItem},
|
||||
DataDiff, DataDiffKind, DataRelocationDiff,
|
||||
data::resolve_relocation,
|
||||
display::{ContextItem, HoverItem, relocation_context, relocation_hover},
|
||||
},
|
||||
obj::Object,
|
||||
};
|
||||
|
@ -1,9 +1,9 @@
|
||||
use egui::{text::LayoutJob, Id, Layout, RichText, ScrollArea, TextEdit, Ui, Widget};
|
||||
use egui::{Id, Layout, RichText, ScrollArea, TextEdit, Ui, Widget, text::LayoutJob};
|
||||
use objdiff_core::{
|
||||
build::BuildStatus,
|
||||
diff::{
|
||||
display::{ContextItem, HoverItem, HoverItemColor, SymbolFilter, SymbolNavigationKind},
|
||||
DiffObjConfig, ObjectDiff, SectionDiff, SymbolDiff,
|
||||
display::{ContextItem, HoverItem, HoverItemColor, SymbolFilter, SymbolNavigationKind},
|
||||
},
|
||||
obj::{Object, Section, Symbol},
|
||||
};
|
||||
@ -14,13 +14,12 @@ use crate::{
|
||||
views::{
|
||||
appearance::Appearance,
|
||||
column_layout::{render_header, render_strips, render_table},
|
||||
data_diff::{data_row_ui, split_diffs, BYTES_PER_ROW},
|
||||
data_diff::{BYTES_PER_ROW, data_row_ui, split_diffs},
|
||||
extab_diff::extab_ui,
|
||||
function_diff::{asm_col_ui, FunctionDiffContext},
|
||||
function_diff::{FunctionDiffContext, asm_col_ui},
|
||||
symbol_diff::{
|
||||
match_color_for_symbol, symbol_context_menu_ui, symbol_hover_ui, symbol_list_ui,
|
||||
DiffViewAction, DiffViewNavigation, DiffViewState, SymbolDiffContext, SymbolRefByName,
|
||||
View,
|
||||
View, match_color_for_symbol, symbol_context_menu_ui, symbol_hover_ui, symbol_list_ui,
|
||||
},
|
||||
write_text,
|
||||
},
|
||||
|
@ -1,14 +1,14 @@
|
||||
use std::{cmp::Ordering, default::Default};
|
||||
|
||||
use egui::{text::LayoutJob, Label, Response, Sense, Widget};
|
||||
use egui::{Label, Response, Sense, Widget, text::LayoutJob};
|
||||
use egui_extras::TableRow;
|
||||
use objdiff_core::{
|
||||
diff::{
|
||||
display::{
|
||||
display_row, instruction_context, instruction_hover, DiffText, DiffTextColor,
|
||||
DiffTextSegment, HighlightKind,
|
||||
},
|
||||
DiffObjConfig, InstructionDiffKind, InstructionDiffRow, ObjectDiff,
|
||||
display::{
|
||||
DiffText, DiffTextColor, DiffTextSegment, HighlightKind, display_row,
|
||||
instruction_context, instruction_hover,
|
||||
},
|
||||
},
|
||||
obj::{InstructionArgValue, InstructionRef, Object},
|
||||
util::ReallySigned,
|
||||
|
@ -5,7 +5,7 @@ use std::{
|
||||
};
|
||||
|
||||
use anyhow::Result;
|
||||
use egui::{text::LayoutJob, Context, FontId, RichText, TextFormat, TextStyle, Window};
|
||||
use egui::{Context, FontId, RichText, TextFormat, TextStyle, Window, text::LayoutJob};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::views::{appearance::Appearance, frame_history::FrameHistory};
|
||||
|
@ -1,4 +1,4 @@
|
||||
use egui::{text::LayoutJob, Color32, FontId, TextFormat};
|
||||
use egui::{Color32, FontId, TextFormat, text::LayoutJob};
|
||||
|
||||
pub(crate) mod appearance;
|
||||
pub(crate) mod column_layout;
|
||||
|
@ -1,18 +1,18 @@
|
||||
use std::mem::take;
|
||||
|
||||
use egui::{
|
||||
style::ScrollAnimation, text::LayoutJob, CollapsingHeader, Color32, Id, OpenUrl, ScrollArea,
|
||||
SelectableLabel, Ui, Widget,
|
||||
CollapsingHeader, Color32, Id, OpenUrl, ScrollArea, SelectableLabel, Ui, Widget,
|
||||
style::ScrollAnimation, text::LayoutJob,
|
||||
};
|
||||
use objdiff_core::{
|
||||
diff::{
|
||||
display::{
|
||||
display_sections, symbol_context, symbol_hover, HighlightKind, SectionDisplay,
|
||||
SymbolFilter, SymbolNavigationKind,
|
||||
},
|
||||
ObjectDiff, SymbolDiff,
|
||||
display::{
|
||||
HighlightKind, SectionDisplay, SymbolFilter, SymbolNavigationKind, display_sections,
|
||||
symbol_context, symbol_hover,
|
||||
},
|
||||
jobs::{create_scratch::CreateScratchResult, objdiff::ObjDiffResult, Job, JobQueue, JobResult},
|
||||
},
|
||||
jobs::{Job, JobQueue, JobResult, create_scratch::CreateScratchResult, objdiff::ObjDiffResult},
|
||||
obj::{Object, Section, SectionKind, Symbol, SymbolFlag},
|
||||
};
|
||||
use regex::{Regex, RegexBuilder};
|
||||
|
@ -20,7 +20,7 @@
|
||||
//! this is defined as a "weak" symbol. This means that other definitions are
|
||||
//! allowed to overwrite it if they are present in a compilation.
|
||||
|
||||
use alloc::{alloc, Layout};
|
||||
use alloc::{Layout, alloc};
|
||||
use core::ptr;
|
||||
|
||||
#[used]
|
||||
|
Loading…
x
Reference in New Issue
Block a user