File tree Expand file tree Collapse file tree 2 files changed +22
-25
lines changed Expand file tree Collapse file tree 2 files changed +22
-25
lines changed Original file line number Diff line number Diff line change @@ -458,29 +458,26 @@ extension MachOFilePrintTests {
458
458
}
459
459
460
460
func testThreadCommand( ) {
461
- let path = " /usr/local/bin/texindex " // has thread command
461
+ let path = " /cores/core.2627 " // has thread command
462
462
let url = URL ( fileURLWithPath: path)
463
463
guard let machO = try ? MachOFile ( url: url) else { return }
464
464
465
465
let commands = Array ( machO. loadCommands. infos ( of: LoadCommand . thread) )
466
466
+ Array( machO. loadCommands. infos ( of: LoadCommand . unixthread) )
467
467
468
+ let cpuType = machO. header. cpuType!
469
+
468
470
for command in commands {
471
+ let flavor = command. flavor (
472
+ in: machO,
473
+ cpuType: cpuType
474
+ )
469
475
print ( " Flavor: " ,
470
- command. flavor (
471
- in: machO,
472
- cpuType: machO. header. cpuType!
473
- ) ? . description ?? " unknown "
476
+ flavor? . description ?? " unknown "
474
477
)
475
478
print ( " Count: " , command. count ( in: machO) ?? 0 )
476
- if let state = command. stateData ( in: machO) {
477
- print (
478
- " State: " ,
479
- state. withUnsafeBytes {
480
- [ UInt64] ( $0. bindMemory ( to: UInt64 . self) )
481
- } . map { " 0x " + String( $0, radix: 16 ) }
482
- . joined ( separator: " , " )
483
- )
479
+ if let state = command. state ( in: machO, cpuType: cpuType) {
480
+ print ( " State: " , state)
484
481
}
485
482
}
486
483
}
Original file line number Diff line number Diff line change @@ -392,22 +392,22 @@ extension MachOPrintTests {
392
392
let commands = Array ( machO. loadCommands. infos ( of: LoadCommand . thread) )
393
393
+ Array( machO. loadCommands. infos ( of: LoadCommand . unixthread) )
394
394
395
+ let cpuType = machO. header. cpuType!
396
+
395
397
for command in commands {
398
+ let flavor = command. flavor (
399
+ cmdsStart: machO. cmdsStartPtr,
400
+ cpuType: cpuType
401
+ )
396
402
print ( " Flavor: " ,
397
- command. flavor (
398
- cmdsStart: machO. cmdsStartPtr,
399
- cpuType: machO. header. cpuType!
400
- ) ? . description ?? " unknown "
403
+ flavor? . description ?? " unknown "
401
404
)
402
405
print ( " Count: " , command. count ( cmdsStart: machO. cmdsStartPtr) ?? 0 )
403
- if let state = command. stateData ( cmdsStart: machO. cmdsStartPtr) {
404
- print (
405
- " State: " ,
406
- state. withUnsafeBytes {
407
- [ UInt64] ( $0. bindMemory ( to: UInt64 . self) )
408
- } . map { " 0x " + String( $0, radix: 16 ) }
409
- . joined ( separator: " , " )
410
- )
406
+ if let state = command. state (
407
+ cmdsStart: machO. cmdsStartPtr,
408
+ cpuType: cpuType
409
+ ) {
410
+ print ( " State: " , state)
411
411
}
412
412
}
413
413
}
You can’t perform that action at this time.
0 commit comments