mirror of https://github.com/encounter/objdiff.git
Merge branch 'main' into pr/fix-ci
This commit is contained in:
commit
da9402e280
|
@ -43,6 +43,9 @@ pub struct Args {
|
||||||
#[argp(option, short = 'u')]
|
#[argp(option, short = 'u')]
|
||||||
/// Unit name within project
|
/// Unit name within project
|
||||||
unit: Option<String>,
|
unit: Option<String>,
|
||||||
|
#[argp(switch, short = 'x')]
|
||||||
|
/// Relax relocation diffs
|
||||||
|
relax_reloc_diffs: bool,
|
||||||
#[argp(positional)]
|
#[argp(positional)]
|
||||||
/// Function symbol to diff
|
/// Function symbol to diff
|
||||||
symbol: String,
|
symbol: String,
|
||||||
|
@ -144,6 +147,7 @@ pub fn run(args: Args) -> Result<()> {
|
||||||
.context("Failed to parse time format")?;
|
.context("Failed to parse time format")?;
|
||||||
let mut state = Box::new(FunctionDiffUi {
|
let mut state = Box::new(FunctionDiffUi {
|
||||||
redraw: true,
|
redraw: true,
|
||||||
|
relax_reloc_diffs: args.relax_reloc_diffs,
|
||||||
click_xy: None,
|
click_xy: None,
|
||||||
left_highlight: HighlightKind::None,
|
left_highlight: HighlightKind::None,
|
||||||
right_highlight: HighlightKind::None,
|
right_highlight: HighlightKind::None,
|
||||||
|
@ -216,6 +220,7 @@ fn find_function(obj: &ObjInfo, name: &str) -> Option<ObjSymbol> {
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
struct FunctionDiffUi {
|
struct FunctionDiffUi {
|
||||||
redraw: bool,
|
redraw: bool,
|
||||||
|
relax_reloc_diffs: bool,
|
||||||
click_xy: Option<(u16, u16)>,
|
click_xy: Option<(u16, u16)>,
|
||||||
left_highlight: HighlightKind,
|
left_highlight: HighlightKind,
|
||||||
right_highlight: HighlightKind,
|
right_highlight: HighlightKind,
|
||||||
|
@ -403,39 +408,28 @@ impl FunctionDiffUi {
|
||||||
// Quit
|
// Quit
|
||||||
KeyCode::Esc | KeyCode::Char('q') => return FunctionDiffResult::Break,
|
KeyCode::Esc | KeyCode::Char('q') => return FunctionDiffResult::Break,
|
||||||
// Page up
|
// Page up
|
||||||
KeyCode::PageUp => {
|
KeyCode::PageUp => self.page_up(false),
|
||||||
self.scroll_y = self.scroll_y.saturating_sub(self.per_page);
|
|
||||||
self.redraw = true;
|
|
||||||
}
|
|
||||||
// Page up (shift + space)
|
// Page up (shift + space)
|
||||||
KeyCode::Char(' ') if event.modifiers.contains(KeyModifiers::SHIFT) => {
|
KeyCode::Char(' ') if event.modifiers.contains(KeyModifiers::SHIFT) => {
|
||||||
self.scroll_y = self.scroll_y.saturating_sub(self.per_page);
|
self.page_up(false)
|
||||||
self.redraw = true;
|
|
||||||
}
|
}
|
||||||
// Page down
|
// Page down
|
||||||
KeyCode::Char(' ') | KeyCode::PageDown => {
|
KeyCode::Char(' ') | KeyCode::PageDown => self.page_down(false),
|
||||||
self.scroll_y += self.per_page;
|
|
||||||
self.redraw = true;
|
|
||||||
}
|
|
||||||
// Page down (ctrl + f)
|
// Page down (ctrl + f)
|
||||||
KeyCode::Char('f') if event.modifiers.contains(KeyModifiers::CONTROL) => {
|
KeyCode::Char('f') if event.modifiers.contains(KeyModifiers::CONTROL) => {
|
||||||
self.scroll_y += self.per_page;
|
self.page_down(false)
|
||||||
self.redraw = true;
|
|
||||||
}
|
}
|
||||||
// Page up (ctrl + b)
|
// Page up (ctrl + b)
|
||||||
KeyCode::Char('b') if event.modifiers.contains(KeyModifiers::CONTROL) => {
|
KeyCode::Char('b') if event.modifiers.contains(KeyModifiers::CONTROL) => {
|
||||||
self.scroll_y = self.scroll_y.saturating_sub(self.per_page);
|
self.page_up(false)
|
||||||
self.redraw = true;
|
|
||||||
}
|
}
|
||||||
// Half page down (ctrl + d)
|
// Half page down (ctrl + d)
|
||||||
KeyCode::Char('d') if event.modifiers.contains(KeyModifiers::CONTROL) => {
|
KeyCode::Char('d') if event.modifiers.contains(KeyModifiers::CONTROL) => {
|
||||||
self.scroll_y += self.per_page / 2;
|
self.page_down(true)
|
||||||
self.redraw = true;
|
|
||||||
}
|
}
|
||||||
// Half page up (ctrl + u)
|
// Half page up (ctrl + u)
|
||||||
KeyCode::Char('u') if event.modifiers.contains(KeyModifiers::CONTROL) => {
|
KeyCode::Char('u') if event.modifiers.contains(KeyModifiers::CONTROL) => {
|
||||||
self.scroll_y = self.scroll_y.saturating_sub(self.per_page / 2);
|
self.page_up(true)
|
||||||
self.redraw = true;
|
|
||||||
}
|
}
|
||||||
// Scroll down
|
// Scroll down
|
||||||
KeyCode::Down | KeyCode::Char('j') => {
|
KeyCode::Down | KeyCode::Char('j') => {
|
||||||
|
@ -472,6 +466,12 @@ impl FunctionDiffUi {
|
||||||
self.scroll_x = self.scroll_x.saturating_sub(1);
|
self.scroll_x = self.scroll_x.saturating_sub(1);
|
||||||
self.redraw = true;
|
self.redraw = true;
|
||||||
}
|
}
|
||||||
|
// Toggle relax relocation diffs
|
||||||
|
KeyCode::Char('x') => {
|
||||||
|
self.relax_reloc_diffs = !self.relax_reloc_diffs;
|
||||||
|
self.redraw = true;
|
||||||
|
return FunctionDiffResult::Reload;
|
||||||
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -506,6 +506,16 @@ impl FunctionDiffUi {
|
||||||
FunctionDiffResult::Continue
|
FunctionDiffResult::Continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn page_up(&mut self, half: bool) {
|
||||||
|
self.scroll_y = self.scroll_y.saturating_sub(self.per_page / if half { 2 } else { 1 });
|
||||||
|
self.redraw = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
fn page_down(&mut self, half: bool) {
|
||||||
|
self.scroll_y += self.per_page / if half { 2 } else { 1 };
|
||||||
|
self.redraw = true;
|
||||||
|
}
|
||||||
|
|
||||||
fn print_sym(
|
fn print_sym(
|
||||||
&self,
|
&self,
|
||||||
out: &mut Text,
|
out: &mut Text,
|
||||||
|
@ -630,7 +640,7 @@ impl FunctionDiffUi {
|
||||||
.as_deref()
|
.as_deref()
|
||||||
.map(|p| obj::elf::read(p).with_context(|| format!("Loading {}", p.display())))
|
.map(|p| obj::elf::read(p).with_context(|| format!("Loading {}", p.display())))
|
||||||
.transpose()?;
|
.transpose()?;
|
||||||
let config = diff::DiffObjConfig::default();
|
let config = diff::DiffObjConfig { relax_reloc_diffs: self.relax_reloc_diffs };
|
||||||
diff::diff_objs(&config, target.as_mut(), base.as_mut())?;
|
diff::diff_objs(&config, target.as_mut(), base.as_mut())?;
|
||||||
|
|
||||||
let left_sym = target.as_ref().and_then(|o| find_function(o, &self.symbol_name));
|
let left_sym = target.as_ref().and_then(|o| find_function(o, &self.symbol_name));
|
||||||
|
|
Loading…
Reference in New Issue