Skip to content

Commit

Permalink
feat: add debug section kind
Browse files Browse the repository at this point in the history
Closes: #196

Signed-off-by: Zxilly <[email protected]>
  • Loading branch information
Zxilly committed Aug 28, 2024
1 parent d7bf302 commit 8cbd14b
Showing 1 changed file with 27 additions and 6 deletions.
33 changes: 27 additions & 6 deletions ui/src/tool/entry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,10 @@ export class UnknownImpl extends BaseImpl implements EntryLike<"unknown"> {
}
}

function isDebugSection(name: string): boolean {
return name.startsWith(".debug_") || name.startsWith(".zdebug_") || name.endsWith("__DWARF");
}

export class ResultImpl extends BaseImpl implements EntryLike<"result"> {
private readonly children: EntryChildren["result"];

Expand All @@ -312,19 +316,36 @@ export class ResultImpl extends BaseImpl implements EntryLike<"result"> {

const children: EntryChildren["result"] = [];

const sectionContainerChildren: EntryLike<"section">[] = [];
const uknSectChildren: EntryLike<"section">[] = [];
const debugSectChildren: EntryLike<"section">[] = [];

for (const section of data.sections) {
sectionContainerChildren.push(new SectionImpl(section));
const s = new SectionImpl(section);
if (isDebugSection(section.name)) {
debugSectChildren.push(s);
}
else {
uknSectChildren.push(s);
}
}
const sectionContainerSize = sectionContainerChildren.reduce((acc, child) => acc + child.getSize(), 0);
const uknSectContainerSize = uknSectChildren.reduce((acc, child) => acc + child.getSize(), 0);
const sectionContainer = new ContainerImpl(
"Unknown Sections Size",
"unk-sections",
sectionContainerSize,
sectionContainerChildren,
uknSectContainerSize,
uknSectChildren,
"The unknown size of the sections in the binary.",
);
children.push(sectionContainer);
const debugSectContainerSize = debugSectChildren.reduce((acc, child) => acc + child.getSize(), 0);
const debugSectionContainer = new ContainerImpl(
"Debug Sections Size",
"debug-sections",
debugSectContainerSize,
debugSectChildren,
"The size of the debug sections in the binary. Can be stripped.",
);

children.push(sectionContainer, debugSectionContainer);

const typedPackages: Record<string, Package[]> = {};
for (const pkg of Object.values(data.packages)) {
Expand Down

0 comments on commit 8cbd14b

Please sign in to comment.