Skip to content

Commit 52bb1c8

Browse files
committed
printer.rs refactors
1 parent bce1909 commit 52bb1c8

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

src/printer.rs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use prettytable::{row, Table};
22

33
use crate::constants::*;
4-
use crate::header::{MachHeader, MachHeader32, MachHeader64};
5-
use crate::load_commands::{BuildVersionCommand, DyldInfoCommand, DylibCommand, DynSymtabCommand, EncryptionInfoCommand, EncryptionInfoCommand32, EncryptionInfoCommand64, EntryPointCommand, LcStr, LinkeditDataCommand, LinkerOptionCommand, LoadCommand, NoteCommand, PrebindCksumCommand, PreboundDylibCommand, RoutinesCommand, RoutinesCommand32, RoutinesCommand64, Section, Section32, Section64, SegmentCommand, SegmentCommand32, SegmentCommand64, SourceVersionCommand, SymsegCommand, SymtabCommand, ThreadCommand, TwoLevelHintsCommand, UuidCommand, VersionMinCommand};
4+
use crate::header::*;
5+
use crate::load_commands::*;
66

77
pub fn print_header(header: &MachHeader) {
88
let mut table = Table::new();
@@ -320,12 +320,23 @@ fn print_common_lcstr(cmd: u32, cmdsize: u32, lc_str_name: &str, lc_str: String,
320320

321321
fn print_prebound_dylib_command(command: &PreboundDylibCommand, table: &mut Table) {
322322
print_lc_cmd_and_cmdsize(command.cmd, command.cmdsize, table);
323+
table.add_row(row![ Fcc->"nmodules", Fyc->format!("0x{:x}", command.nmodules), c->"-"]);
324+
323325
// TODO: this is problematic because this command has 2 lc_str in its LcStr struct (2 in one Vec<u8>) printing should be different.
324326
}
325327

326328
fn print_thread_command(command: &ThreadCommand, table: &mut Table) {
327329
print_lc_cmd_and_cmdsize(command.cmd, command.cmdsize, table);
328-
// TODO: implement this after we manage to make it work in parser.rs as well.
330+
for (index, thread_state) in command.thread_states.iter().enumerate() {
331+
table.add_row(row![Fgbc->format!("Thread State #{}", index), c->"-", c->"-"]);
332+
print_thread_state(thread_state, table);
333+
}
334+
}
335+
336+
fn print_thread_state(thread_state: &ThreadState, table: &mut Table) {
337+
table.add_row(row![Fcc->"flavor", Fyc->format!("0x{:x}", thread_state.flavor), c->"-"]);
338+
table.add_row(row![Fcc->"count", Fyc->format!("0x{:x}", thread_state.count), c->"-"]);
339+
print_bytes_array("state", &thread_state.state, table);
329340
}
330341

331342
fn print_routines_command_32(command: &RoutinesCommand32, table: &mut Table) {

0 commit comments

Comments
 (0)