mirror of
https://github.com/encounter/objdiff.git
synced 2025-12-08 21:17:59 +00:00
Implementation of basic data flow analysis for PowerPC (#212)
* WIP implementation * * Move flow analysis to dedicated file * Show string constants inline * Handle calls to MWCC "sled" helpers which otherwise disrupt flow analysis * Run cargo insta review * Apply clippy feedback * Update more tests. * Remove std use from ppc flow analysis * Try to make wasm build work again * More test changes * Probably last wasm fix * Formatting * Fix WASM * One more clippy thing * Fixed display of float constants in a LFS or LFD instruction in case where there is a branch to the subsequent instruction with a different register value. * On lines with a reloc, only hide Symbol type data flow values rather than all data flow values. * Formatting
This commit is contained in:
@@ -23,6 +23,8 @@ pub struct Appearance {
|
||||
#[serde(skip)]
|
||||
pub highlight_color: Color32, // WHITE
|
||||
#[serde(skip)]
|
||||
pub dataflow_color: Color32, //
|
||||
#[serde(skip)]
|
||||
pub replace_color: Color32, // LIGHT_BLUE
|
||||
#[serde(skip)]
|
||||
pub insert_color: Color32, // GREEN
|
||||
@@ -61,6 +63,7 @@ impl Default for Appearance {
|
||||
emphasized_text_color: Color32::LIGHT_GRAY,
|
||||
deemphasized_text_color: Color32::DARK_GRAY,
|
||||
highlight_color: Color32::WHITE,
|
||||
dataflow_color: Color32::from_rgb(0, 128, 128),
|
||||
replace_color: Color32::LIGHT_BLUE,
|
||||
insert_color: Color32::GREEN,
|
||||
delete_color: Color32::from_rgb(200, 40, 41),
|
||||
@@ -104,6 +107,7 @@ impl Appearance {
|
||||
self.emphasized_text_color = Color32::LIGHT_GRAY;
|
||||
self.deemphasized_text_color = Color32::DARK_GRAY;
|
||||
self.highlight_color = Color32::WHITE;
|
||||
self.dataflow_color = Color32::from_rgb(0, 128, 128);
|
||||
self.replace_color = Color32::LIGHT_BLUE;
|
||||
self.insert_color = Color32::GREEN;
|
||||
self.delete_color = Color32::from_rgb(200, 40, 41);
|
||||
@@ -114,6 +118,7 @@ impl Appearance {
|
||||
self.emphasized_text_color = Color32::DARK_GRAY;
|
||||
self.deemphasized_text_color = Color32::LIGHT_GRAY;
|
||||
self.highlight_color = Color32::BLACK;
|
||||
self.dataflow_color = Color32::from_rgb(0, 128, 128);
|
||||
self.replace_color = Color32::DARK_BLUE;
|
||||
self.insert_color = Color32::DARK_GREEN;
|
||||
self.delete_color = Color32::from_rgb(200, 40, 41);
|
||||
|
||||
@@ -281,6 +281,24 @@ pub fn diff_view_ui(
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
// Only need to check the first Object. Technically the first could not have a flow analysis
|
||||
// result while the second does but we don't want to waste space on two separate checkboxes.
|
||||
if state.current_view == View::FunctionDiff
|
||||
&& result
|
||||
.first_obj
|
||||
.as_ref()
|
||||
.is_some_and(|(first, _)| first.has_flow_analysis_result())
|
||||
{
|
||||
let mut value = diff_config.show_data_flow;
|
||||
if ui
|
||||
.checkbox(&mut value, "Show data flow")
|
||||
.on_hover_text("Show data flow analysis results in place of register names")
|
||||
.clicked()
|
||||
{
|
||||
ret = Some(DiffViewAction::SetShowDataFlow(value));
|
||||
}
|
||||
}
|
||||
} else if column == 1 {
|
||||
// Right column
|
||||
|
||||
|
||||
@@ -174,6 +174,7 @@ fn diff_text_ui(
|
||||
DiffTextColor::Normal => appearance.text_color,
|
||||
DiffTextColor::Dim => appearance.deemphasized_text_color,
|
||||
DiffTextColor::Bright => appearance.emphasized_text_color,
|
||||
DiffTextColor::DataFlow => appearance.dataflow_color,
|
||||
DiffTextColor::Replace => appearance.replace_color,
|
||||
DiffTextColor::Delete => appearance.delete_color,
|
||||
DiffTextColor::Insert => appearance.insert_color,
|
||||
|
||||
@@ -79,6 +79,8 @@ pub enum DiffViewAction {
|
||||
SetMapping(usize, usize),
|
||||
/// Set the show_mapped_symbols flag
|
||||
SetShowMappedSymbols(bool),
|
||||
/// Set the show_data_flow flag
|
||||
SetShowDataFlow(bool),
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Default, Eq, PartialEq)]
|
||||
@@ -350,6 +352,12 @@ impl DiffViewState {
|
||||
DiffViewAction::SetShowMappedSymbols(value) => {
|
||||
self.symbol_state.show_mapped_symbols = value;
|
||||
}
|
||||
DiffViewAction::SetShowDataFlow(value) => {
|
||||
let Ok(mut state) = state.write() else {
|
||||
return;
|
||||
};
|
||||
state.config.diff_obj_config.show_data_flow = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user