mirror of
https://github.com/encounter/objdiff.git
synced 2026-03-30 11:32:16 -07:00
Implement click-to-highlight
Highlights registers, instructions, arguments, symbols or addresses on click. Resolves #7
This commit is contained in:
Generated
+1
-1
@@ -2457,7 +2457,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "objdiff"
|
||||
version = "0.4.4"
|
||||
version = "0.5.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"byteorder",
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "objdiff"
|
||||
version = "0.4.4"
|
||||
version = "0.5.0"
|
||||
edition = "2021"
|
||||
rust-version = "1.65"
|
||||
authors = ["Luke Street <luke@street.dev>"]
|
||||
|
||||
@@ -91,6 +91,7 @@ pub fn process_code(
|
||||
reloc: reloc.cloned(),
|
||||
branch_dest,
|
||||
line,
|
||||
orig: None,
|
||||
});
|
||||
cur_addr += 4;
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@ pub struct ObjSection {
|
||||
pub data_diff: Vec<ObjDataDiff>,
|
||||
pub match_percent: f32,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum ObjInsArg {
|
||||
PpcArg(ppc750cl::Argument),
|
||||
@@ -46,6 +47,40 @@ pub enum ObjInsArg {
|
||||
RelocWithBase,
|
||||
BranchOffset(i32),
|
||||
}
|
||||
|
||||
// TODO derive PartialEq on ppc750cl::Argument so this isn't necessary
|
||||
impl PartialEq for ObjInsArg {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
match (self, other) {
|
||||
(ObjInsArg::PpcArg(a), ObjInsArg::PpcArg(b)) => {
|
||||
use ppc750cl::Argument;
|
||||
match (a, b) {
|
||||
(Argument::GPR(a), Argument::GPR(b)) => a == b,
|
||||
(Argument::FPR(a), Argument::FPR(b)) => a == b,
|
||||
(Argument::SR(a), Argument::SR(b)) => a == b,
|
||||
(Argument::SPR(a), Argument::SPR(b)) => a == b,
|
||||
(Argument::CRField(a), Argument::CRField(b)) => a == b,
|
||||
(Argument::CRBit(a), Argument::CRBit(b)) => a == b,
|
||||
(Argument::GQR(a), Argument::GQR(b)) => a == b,
|
||||
(Argument::Uimm(a), Argument::Uimm(b)) => a == b,
|
||||
(Argument::Simm(a), Argument::Simm(b)) => a == b,
|
||||
(Argument::Offset(a), Argument::Offset(b)) => a == b,
|
||||
(Argument::BranchDest(a), Argument::BranchDest(b)) => a == b,
|
||||
(Argument::Bit(a), Argument::Bit(b)) => a == b,
|
||||
(Argument::OpaqueU(a), Argument::OpaqueU(b)) => a == b,
|
||||
(_, _) => false,
|
||||
}
|
||||
}
|
||||
(ObjInsArg::MipsArg(a), ObjInsArg::MipsArg(b)) => a == b,
|
||||
(ObjInsArg::MipsArgWithBase(a), ObjInsArg::MipsArgWithBase(b)) => a == b,
|
||||
(ObjInsArg::Reloc, ObjInsArg::Reloc) => true,
|
||||
(ObjInsArg::RelocWithBase, ObjInsArg::RelocWithBase) => true,
|
||||
(ObjInsArg::BranchOffset(a), ObjInsArg::BranchOffset(b)) => a == b,
|
||||
(_, _) => false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub struct ObjInsArgDiff {
|
||||
/// Incrementing index for coloring
|
||||
@@ -86,6 +121,8 @@ pub struct ObjIns {
|
||||
pub branch_dest: Option<u32>,
|
||||
/// Line info
|
||||
pub line: Option<u32>,
|
||||
/// Original (unsimplified) instruction
|
||||
pub orig: Option<String>,
|
||||
}
|
||||
#[derive(Debug, Clone, Default)]
|
||||
pub struct ObjInsDiff {
|
||||
|
||||
+14
-3
@@ -1,7 +1,7 @@
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
use anyhow::Result;
|
||||
use ppc750cl::{disasm_iter, Argument};
|
||||
use ppc750cl::{disasm_iter, Argument, Ins, SimplifiedIns};
|
||||
|
||||
use crate::obj::{ObjIns, ObjInsArg, ObjReloc, ObjRelocKind};
|
||||
|
||||
@@ -40,7 +40,7 @@ pub fn process_code(
|
||||
_ => ins.code,
|
||||
};
|
||||
}
|
||||
let simplified = ins.simplified();
|
||||
let simplified = ins.clone().simplified();
|
||||
let mut args: Vec<ObjInsArg> = simplified
|
||||
.args
|
||||
.iter()
|
||||
@@ -86,10 +86,21 @@ pub fn process_code(
|
||||
mnemonic: format!("{}{}", simplified.mnemonic, simplified.suffix),
|
||||
args,
|
||||
reloc: reloc.cloned(),
|
||||
op: 0,
|
||||
op: ins.op as u8,
|
||||
branch_dest: None,
|
||||
line,
|
||||
orig: Some(format!("{}", basic_form(ins))),
|
||||
});
|
||||
}
|
||||
Ok((ops, insts))
|
||||
}
|
||||
|
||||
// TODO make public in ppc750cl
|
||||
fn basic_form(ins: Ins) -> SimplifiedIns {
|
||||
SimplifiedIns {
|
||||
mnemonic: ins.op.mnemonic(),
|
||||
suffix: ins.suffix(),
|
||||
args: ins.fields().iter().flat_map(|field| field.argument()).collect(),
|
||||
ins,
|
||||
}
|
||||
}
|
||||
|
||||
+260
-107
File diff suppressed because it is too large
Load Diff
@@ -13,7 +13,7 @@ use crate::{
|
||||
Job, JobQueue, JobResult,
|
||||
},
|
||||
obj::{ObjInfo, ObjSection, ObjSectionKind, ObjSymbol, ObjSymbolFlags},
|
||||
views::{appearance::Appearance, write_text},
|
||||
views::{appearance::Appearance, function_diff::FunctionViewState, write_text},
|
||||
};
|
||||
|
||||
pub struct SymbolReference {
|
||||
@@ -35,6 +35,7 @@ pub struct DiffViewState {
|
||||
pub build: Option<Box<ObjDiffResult>>,
|
||||
pub current_view: View,
|
||||
pub symbol_state: SymbolViewState,
|
||||
pub function_state: FunctionViewState,
|
||||
pub search: String,
|
||||
pub queue_build: bool,
|
||||
pub build_running: bool,
|
||||
|
||||
Reference in New Issue
Block a user