mirror of
https://github.com/encounter/objdiff.git
synced 2025-06-07 15:13:47 +00:00
Add address to ReportItem, stabilize sections/functions ordering
This commit is contained in:
parent
0c9e5526d4
commit
34220a8e26
@ -228,6 +228,7 @@ fn report_object(
|
|||||||
demangled_name: None,
|
demangled_name: None,
|
||||||
virtual_address: section.virtual_address,
|
virtual_address: section.virtual_address,
|
||||||
}),
|
}),
|
||||||
|
address: None,
|
||||||
});
|
});
|
||||||
|
|
||||||
match section.kind {
|
match section.kind {
|
||||||
@ -273,6 +274,7 @@ fn report_object(
|
|||||||
demangled_name: symbol.demangled_name.clone(),
|
demangled_name: symbol.demangled_name.clone(),
|
||||||
virtual_address: symbol.virtual_address,
|
virtual_address: symbol.virtual_address,
|
||||||
}),
|
}),
|
||||||
|
address: symbol.address.checked_sub(section.address),
|
||||||
});
|
});
|
||||||
if match_percent == 100.0 {
|
if match_percent == 100.0 {
|
||||||
measures.matched_functions += 1;
|
measures.matched_functions += 1;
|
||||||
@ -280,6 +282,16 @@ fn report_object(
|
|||||||
measures.total_functions += 1;
|
measures.total_functions += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
sections.sort_by(|a, b| a.name.cmp(&b.name));
|
||||||
|
let reverse_fn_order = object.metadata.reverse_fn_order.unwrap_or(false);
|
||||||
|
functions.sort_by(|a, b| {
|
||||||
|
if reverse_fn_order {
|
||||||
|
b.address.unwrap_or(0).cmp(&a.address.unwrap_or(0))
|
||||||
|
} else {
|
||||||
|
a.address.unwrap_or(u64::MAX).cmp(&b.address.unwrap_or(u64::MAX))
|
||||||
|
}
|
||||||
|
.then_with(|| a.size.cmp(&b.size))
|
||||||
|
});
|
||||||
if metadata.complete.unwrap_or(false) {
|
if metadata.complete.unwrap_or(false) {
|
||||||
measures.complete_code = measures.total_code;
|
measures.complete_code = measures.total_code;
|
||||||
measures.complete_data = measures.total_data;
|
measures.complete_data = measures.total_data;
|
||||||
|
Binary file not shown.
@ -99,6 +99,8 @@ message ReportItem {
|
|||||||
float fuzzy_match_percent = 3;
|
float fuzzy_match_percent = 3;
|
||||||
// Extra metadata for this item
|
// Extra metadata for this item
|
||||||
optional ReportItemMetadata metadata = 4;
|
optional ReportItemMetadata metadata = 4;
|
||||||
|
// Address of the item (section-relative offset)
|
||||||
|
optional uint64 address = 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Extra metadata for an item
|
// Extra metadata for an item
|
||||||
|
@ -434,6 +434,7 @@ impl From<LegacyReportItem> for ReportItem {
|
|||||||
demangled_name: value.demangled_name,
|
demangled_name: value.demangled_name,
|
||||||
virtual_address: value.address,
|
virtual_address: value.address,
|
||||||
}),
|
}),
|
||||||
|
address: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -687,19 +687,20 @@ pub fn display_sections(
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
let section_diff = &diff.sections[section_idx];
|
let section_diff = &diff.sections[section_idx];
|
||||||
if section.kind == SectionKind::Code && reverse_fn_order {
|
let reverse_fn_order = section.kind == SectionKind::Code && reverse_fn_order;
|
||||||
symbols.sort_by(|a, b| {
|
symbols.sort_by(|a, b| {
|
||||||
let a_symbol = &obj.symbols[a.symbol];
|
let a = &obj.symbols[a.symbol];
|
||||||
let b_symbol = &obj.symbols[b.symbol];
|
let b = &obj.symbols[b.symbol];
|
||||||
symbol_sort_reverse(a_symbol, b_symbol)
|
section_symbol_sort(a, b)
|
||||||
});
|
.then_with(|| {
|
||||||
|
if reverse_fn_order {
|
||||||
|
b.address.cmp(&a.address)
|
||||||
} else {
|
} else {
|
||||||
symbols.sort_by(|a, b| {
|
a.address.cmp(&b.address)
|
||||||
let a_symbol = &obj.symbols[a.symbol];
|
|
||||||
let b_symbol = &obj.symbols[b.symbol];
|
|
||||||
symbol_sort(a_symbol, b_symbol)
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
.then_with(|| a.size.cmp(&b.size))
|
||||||
|
});
|
||||||
sections.push(SectionDisplay {
|
sections.push(SectionDisplay {
|
||||||
id: section.id.clone(),
|
id: section.id.clone(),
|
||||||
name: if section.flags.contains(SectionFlag::Combined) {
|
name: if section.flags.contains(SectionFlag::Combined) {
|
||||||
@ -737,14 +738,6 @@ fn section_symbol_sort(a: &Symbol, b: &Symbol) -> Ordering {
|
|||||||
Ordering::Equal
|
Ordering::Equal
|
||||||
}
|
}
|
||||||
|
|
||||||
fn symbol_sort(a: &Symbol, b: &Symbol) -> Ordering {
|
|
||||||
section_symbol_sort(a, b).then(a.address.cmp(&b.address)).then(a.size.cmp(&b.size))
|
|
||||||
}
|
|
||||||
|
|
||||||
fn symbol_sort_reverse(a: &Symbol, b: &Symbol) -> Ordering {
|
|
||||||
section_symbol_sort(a, b).then(b.address.cmp(&a.address)).then(b.size.cmp(&a.size))
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn display_ins_data_labels(obj: &Object, resolved: ResolvedInstructionRef) -> Vec<String> {
|
pub fn display_ins_data_labels(obj: &Object, resolved: ResolvedInstructionRef) -> Vec<String> {
|
||||||
let Some(reloc) = resolved.relocation else {
|
let Some(reloc) = resolved.relocation else {
|
||||||
return Vec::new();
|
return Vec::new();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user