analyze: show begin/end

This commit is contained in:
Motiejus Jakštys 2022-07-06 11:16:20 +03:00
parent 09de309b6e
commit 9f69a972ee

View File

@ -126,19 +126,18 @@ fn execute(
};
const template =
\\File: {[fname]s}
\\Size: {[size_file]s} ({[bytes_file]d} bytes)
\\Version: {[version]d}
\\Endian: {[endian]s}
\\Pointer size: {[ptr_size]}d
\\Buffer size in bytes for getgr: {[getgr_bufsize]d}
\\Buffer size in bytes for getpw: {[getpw_bufsize]d}
\\
\\Users: {[users]d}
\\Groups: {[groups]d}
\\Shells: {[shells]d}
\\File: {[fname]s}
\\Size: {[size_file]s} ({[bytes_file]d} bytes)
\\Version: {[version]d}
\\Endian: {[endian]s}
\\Pointer size: {[ptr_size]} bytes
\\getgr buffer size: {[getgr_bufsize]d}B
\\getpw buffer size: {[getpw_bufsize]d}B
\\Users: {[users]d}
\\Groups: {[groups]d}
\\Shells: {[shells]d}
\\Sections:
\\ Name Blocks Size Offset
\\ Name Begin End Size
\\
;
stdout.print(template, info) catch {};
@ -148,16 +147,17 @@ fn execute(
inline for (meta.fields(DB.DBNumbers)) |field| {
const length = @field(lengths, field.name);
const size = fmt.bufPrint(scratch[0..], "{:.2}", .{
const size = fmt.bufPrint(scratch[0..], "{:.0}", .{
fmt.fmtIntSizeBin(@intCast(u64, length << section_length_bits)),
}) catch unreachable;
const offset = @field(offsets, field.name);
stdout.print(" {s:<19}{:8} {s:<12} {:8}\n", .{
const start = @field(offsets, field.name);
const end = start + @field(lengths, field.name);
stdout.print("{s:>21} {x:0>8} {x:0>8} {s:>10}\n", .{
field.name,
length,
start << section_length_bits,
end << section_length_bits,
size,
offset,
}) catch {};
}