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')]
|
||||
/// Unit name within project
|
||||
unit: Option<String>,
|
||||
#[argp(switch, short = 'x')]
|
||||
/// Relax relocation diffs
|
||||
relax_reloc_diffs: bool,
|
||||
#[argp(positional)]
|
||||
/// Function symbol to diff
|
||||
symbol: String,
|
||||
|
@ -144,6 +147,7 @@ pub fn run(args: Args) -> Result<()> {
|
|||
.context("Failed to parse time format")?;
|
||||
let mut state = Box::new(FunctionDiffUi {
|
||||
redraw: true,
|
||||
relax_reloc_diffs: args.relax_reloc_diffs,
|
||||
click_xy: None,
|
||||
left_highlight: HighlightKind::None,
|
||||
right_highlight: HighlightKind::None,
|
||||
|
@ -216,6 +220,7 @@ fn find_function(obj: &ObjInfo, name: &str) -> Option<ObjSymbol> {
|
|||
#[allow(dead_code)]
|
||||
struct FunctionDiffUi {
|
||||
redraw: bool,
|
||||
relax_reloc_diffs: bool,
|
||||
click_xy: Option<(u16, u16)>,
|
||||
left_highlight: HighlightKind,
|
||||
right_highlight: HighlightKind,
|
||||
|
@ -403,39 +408,28 @@ impl FunctionDiffUi {
|
|||
// Quit
|
||||
KeyCode::Esc | KeyCode::Char('q') => return FunctionDiffResult::Break,
|
||||
// Page up
|
||||
KeyCode::PageUp => {
|
||||
self.scroll_y = self.scroll_y.saturating_sub(self.per_page);
|
||||
self.redraw = true;
|
||||
}
|
||||
KeyCode::PageUp => self.page_up(false),
|
||||
// Page up (shift + space)
|
||||
KeyCode::Char(' ') if event.modifiers.contains(KeyModifiers::SHIFT) => {
|
||||
self.scroll_y = self.scroll_y.saturating_sub(self.per_page);
|
||||
self.redraw = true;
|
||||
self.page_up(false)
|
||||
}
|
||||
// Page down
|
||||
KeyCode::Char(' ') | KeyCode::PageDown => {
|
||||
self.scroll_y += self.per_page;
|
||||
self.redraw = true;
|
||||
}
|
||||
KeyCode::Char(' ') | KeyCode::PageDown => self.page_down(false),
|
||||
// Page down (ctrl + f)
|
||||
KeyCode::Char('f') if event.modifiers.contains(KeyModifiers::CONTROL) => {
|
||||
self.scroll_y += self.per_page;
|
||||
self.redraw = true;
|
||||
self.page_down(false)
|
||||
}
|
||||
// Page up (ctrl + b)
|
||||
KeyCode::Char('b') if event.modifiers.contains(KeyModifiers::CONTROL) => {
|
||||
self.scroll_y = self.scroll_y.saturating_sub(self.per_page);
|
||||
self.redraw = true;
|
||||
self.page_up(false)
|
||||
}
|
||||
// Half page down (ctrl + d)
|
||||
KeyCode::Char('d') if event.modifiers.contains(KeyModifiers::CONTROL) => {
|
||||
self.scroll_y += self.per_page / 2;
|
||||
self.redraw = true;
|
||||
self.page_down(true)
|
||||
}
|
||||
// Half page up (ctrl + u)
|
||||
KeyCode::Char('u') if event.modifiers.contains(KeyModifiers::CONTROL) => {
|
||||
self.scroll_y = self.scroll_y.saturating_sub(self.per_page / 2);
|
||||
self.redraw = true;
|
||||
self.page_up(true)
|
||||
}
|
||||
// Scroll down
|
||||
KeyCode::Down | KeyCode::Char('j') => {
|
||||
|
@ -472,6 +466,12 @@ impl FunctionDiffUi {
|
|||
self.scroll_x = self.scroll_x.saturating_sub(1);
|
||||
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
|
||||
}
|
||||
|
||||
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(
|
||||
&self,
|
||||
out: &mut Text,
|
||||
|
@ -630,7 +640,7 @@ impl FunctionDiffUi {
|
|||
.as_deref()
|
||||
.map(|p| obj::elf::read(p).with_context(|| format!("Loading {}", p.display())))
|
||||
.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())?;
|
||||
|
||||
let left_sym = target.as_ref().and_then(|o| find_function(o, &self.symbol_name));
|
||||
|
|
Loading…
Reference in New Issue