Skip to content

Commit 7810717

Browse files
authored
show symbol size in symbol list (#268)
* show symbol size in symbol list * configs for show symbol size * move symbol size config to config-schema
1 parent 572afa8 commit 7810717

File tree

4 files changed

+47
-2
lines changed

4 files changed

+47
-2
lines changed

objdiff-core/config-schema.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,27 @@
8282
"name": "Space between args",
8383
"description": "Adds a space between arguments in the diff output."
8484
},
85+
{
86+
"id": "showSymbolSizes",
87+
"type": "choice",
88+
"default": "off",
89+
"name": "Show symbol sizes",
90+
"description": "Shows symbol sizes in the symbol view.",
91+
"items": [
92+
{
93+
"value": "off",
94+
"name": "Off"
95+
},
96+
{
97+
"value": "hex",
98+
"name": "Hex"
99+
},
100+
{
101+
"value": "decimal",
102+
"name": "Decimal"
103+
}
104+
]
105+
},
85106
{
86107
"id": "combineDataSections",
87108
"type": "boolean",
@@ -296,6 +317,7 @@
296317
"properties": [
297318
"functionRelocDiffs",
298319
"demangler",
320+
"showSymbolSizes",
299321
"spaceBetweenArgs",
300322
"combineDataSections",
301323
"combineTextSections"

objdiff-gui/src/app_config.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use objdiff_core::{
66
config::ScratchConfig,
77
diff::{
88
ArmArchVersion, ArmR9Usage, DiffObjConfig, FunctionRelocDiffs, MipsAbi, MipsInstrCategory,
9-
X86Formatter,
9+
ShowSymbolSizes, X86Formatter,
1010
},
1111
};
1212
use typed_path::{Utf8PlatformPathBuf, Utf8UnixPathBuf};
@@ -227,6 +227,7 @@ pub struct DiffObjConfigV1 {
227227
pub relax_reloc_diffs: bool,
228228
#[serde(default = "bool_true")]
229229
pub space_between_args: bool,
230+
pub show_symbol_sizes: ShowSymbolSizes,
230231
pub combine_data_sections: bool,
231232
// x86
232233
pub x86_formatter: X86Formatter,
@@ -248,6 +249,7 @@ impl Default for DiffObjConfigV1 {
248249
Self {
249250
relax_reloc_diffs: false,
250251
space_between_args: true,
252+
show_symbol_sizes: Default::default(),
251253
combine_data_sections: false,
252254
x86_formatter: Default::default(),
253255
mips_abi: Default::default(),
@@ -272,6 +274,7 @@ impl DiffObjConfigV1 {
272274
FunctionRelocDiffs::default()
273275
},
274276
space_between_args: self.space_between_args,
277+
show_symbol_sizes: self.show_symbol_sizes,
275278
combine_data_sections: self.combine_data_sections,
276279
x86_formatter: self.x86_formatter,
277280
mips_abi: self.mips_abi,

objdiff-gui/src/views/diff.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -665,6 +665,7 @@ fn diff_col_ui(
665665
appearance,
666666
column,
667667
open_sections,
668+
diff_config,
668669
) {
669670
match (column, action) {
670671
(
@@ -703,6 +704,7 @@ fn diff_col_ui(
703704
appearance,
704705
column,
705706
open_sections,
707+
diff_config,
706708
) {
707709
ret = Some(result);
708710
}

objdiff-gui/src/views/symbol_diff.rs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use egui::{
66
};
77
use objdiff_core::{
88
diff::{
9-
ObjectDiff, SymbolDiff,
9+
DiffObjConfig, ObjectDiff, ShowSymbolSizes, SymbolDiff,
1010
display::{
1111
HighlightKind, SectionDisplay, SymbolFilter, SymbolNavigationKind, display_sections,
1212
symbol_context, symbol_hover,
@@ -525,6 +525,7 @@ fn symbol_ui(
525525
state: &SymbolViewState,
526526
appearance: &Appearance,
527527
column: usize,
528+
diff_config: &DiffObjConfig,
528529
) -> Option<DiffViewAction> {
529530
let mut ret = None;
530531
let mut job = LayoutJob::default();
@@ -572,6 +573,21 @@ fn symbol_ui(
572573
write_text(") ", appearance.text_color, &mut job, appearance.code_font.clone());
573574
}
574575
write_text(name, appearance.highlight_color, &mut job, appearance.code_font.clone());
576+
if diff_config.show_symbol_sizes == ShowSymbolSizes::Decimal {
577+
write_text(
578+
&format!(" (size={})", symbol.size),
579+
appearance.deemphasized_text_color,
580+
&mut job,
581+
appearance.code_font.clone(),
582+
);
583+
} else if diff_config.show_symbol_sizes == ShowSymbolSizes::Hex {
584+
write_text(
585+
&format!(" (size={:x})", symbol.size),
586+
appearance.deemphasized_text_color,
587+
&mut job,
588+
appearance.code_font.clone(),
589+
);
590+
}
575591
let response = egui::Button::selectable(selected, job)
576592
.ui(ui)
577593
.on_hover_ui_at_pointer(|ui| symbol_hover_ui(ui, ctx, symbol_idx, appearance));
@@ -646,6 +662,7 @@ pub fn symbol_list_ui(
646662
appearance: &Appearance,
647663
column: usize,
648664
open_sections: Option<bool>,
665+
diff_config: &DiffObjConfig,
649666
) -> Option<DiffViewAction> {
650667
let mut ret = None;
651668
ScrollArea::both().auto_shrink([false, false]).show(ui, |ui| {
@@ -770,6 +787,7 @@ pub fn symbol_list_ui(
770787
state,
771788
appearance,
772789
column,
790+
diff_config,
773791
) {
774792
ret = Some(result);
775793
}

0 commit comments

Comments
 (0)