DerekSelander / LLDB

A collection of LLDB aliases/regexes and Python scripts to aid in your debugging sessions
GNU General Public License v2.0
1.77k stars 198 forks source link

Running sys echo "$(dclass -t swift)" outputs "command not found" #13

Closed rmaloney3 closed 5 years ago

rmaloney3 commented 5 years ago

I just started reading Advanced Apple Debugging & Reverse Engineering, and I am in chapter 1 where it says to execute:

(lldb) sys echo "$(dclass -t swift)" | grep -v _ | grep "\." | cut -d. -f1 | uniq | wc -l

When attached to Xcode 10.2, upon running this command, I receive over 1000 lines of output ending with this:

/bin/sh: line 1422: _TtGCs23_ContiguousArrayStorageGVs5RangeSi__$: command not found
/bin/sh: line 1423: _TtGCs23_ContiguousArrayStorageGSaGVs5RangeSi___$: command not found
/bin/sh: line 1424: _TtGCs23_ContiguousArrayStorageV12SourceEditor26SourceEditorLineIdentifier_$: command not found
/bin/sh: line 1425: _TtGCs23_ContiguousArrayStorageCSo18NSAttributedString_$: command not found
/bin/sh: line 1426: _TtGCs23_ContiguousArrayStorageCSo9NSTextTab_$: command not found
/bin/sh: line 1427: _TtGCs23_ContiguousArrayStorageTSSP___$: command not found
/bin/sh: line 1428: _TtGCs23_ContiguousArrayStorageGSqP12SourceEditor30SourceEditorDataSourceObserver___$: command not found
/bin/sh: line 1429: _TtGCs23_ContiguousArrayStorageTVs11AnyHashableP___$: command not found
/bin/sh: line 1430: _TtGCs23_ContiguousArrayStorageTaSo21NSAttributedStringKeyP___$: command not found
/bin/sh: line 1431: _TtGCs23_ContiguousArrayStorageP12SourceEditor29SourceEditorFeatureController__$: command not found
/bin/sh: line 1432: _TtGCs23_ContiguousArrayStorageVs9Character_$: command not found
/bin/sh: line 1433: _TtGCs23_ContiguousArrayStorageP12SourceEditor33EditAssistantPostProcessOperation__$: command not found
/bin/sh: line 1434: _TtGCs23_ContiguousArrayStorageP12SourceEditor32EditAssistantPreProcessOperation__$: command not found
/bin/sh: line 1435: _TtGCs23_ContiguousArrayStorageaSo16NSPasteboardType_$: command not found
/bin/sh: line 1436: _TtGCs23_ContiguousArrayStorageVSo21NSTrackingAreaOptions_$: command not found
/bin/sh: line 1437: _TtGCs23_ContiguousArrayStorageP12SourceEditor30LineLayerRangeOverrideProvider__$: command not found
/bin/sh: line 1438: _TtGCs23_ContiguousArrayStorageP12SourceEditor27ColumnShiftOverrideProvider__$: command not found
/bin/sh: line 1439: _TtGCs23_ContiguousArrayStorageGSaVC12SourceEditor25SourceEditorDelimiterDataP1020db24a09Delimiter__$: command not found
/bin/sh: line 1440: _TtGCs23_ContiguousArrayStorageP12SourceEditor35HiddenGutterContentOverrideProvider__$: command not found
/bin/sh: line 1441: _TtGCs23_ContiguousArrayStorageP12SourceEditor29LineHighlightOverrideProvider__$: command not found
/bin/sh: line 1442: _TtGCs23_ContiguousArrayStorageP12SourceEditor27SourceEditorMarginAccessory__$: command not found
/bin/sh: line 1443: _TtGCs23_ContiguousArrayStorageP12SourceEditor28LineNumberAttributesProvider__$: command not found
/bin/sh: line 1444: _TtGCs23_ContiguousArrayStorageP12SourceEditor29SourceEditorViewEventConsumer__$: command not found
/bin/sh: line 1445: _TtGCs23_ContiguousArrayStorageP12SourceEditor29TextAttributeOverrideProvider__$: command not found
/bin/sh: line 1446: _TtGCs23_ContiguousArrayStorageP12SourceEditor22LayoutOverrideProvider__$: command not found
/bin/sh: line 1447: _TtGCs23_ContiguousArrayStorageP12SourceEditor19LayoutVisualization__$: command not found
/bin/sh: line 1448: _TtGCs23_ContiguousArrayStorageCSo18NSLayoutConstraint_$: command not found
/bin/sh: line 1449: _TtGCs23_ContiguousArrayStorageV12SourceEditorP1020db875035SourceEditorDataSourceObserverToken_$: command not found
/bin/sh: line 1450: _TtGCs23_ContiguousArrayStorageVSo8_NSRange_$: command not found
/bin/sh: line 1451: _TtGCs23_ContiguousArrayStorageC12SourceEditor20SourceEditorLineData_$: command not found
/bin/sh: line 1452: _TtGCs23_ContiguousArrayStorageVSo26NSStringEnumerationOptions_$: command not found
/bin/sh: line 1453: _TtGCs23_ContiguousArrayStorageVSo18CAAutoresizingMask_$: command not found
/bin/sh: line 1454: _TtGCs23_ContiguousArrayStorageV12SourceEditor30SourceEditorFontRenderingStyle_$: command not found
/bin/sh: line 1455: _TtGCs23_ContiguousArrayStoragePMP12SourceEditor29SourceEditorFeatureController__$: command not found
/bin/sh: line 1456: _TtGCs23_ContiguousArrayStorageCSo13IDEAlertEvent_$: command not found
/bin/sh: line 1457: _TtGCs23_ContiguousArrayStorageSi_$: command not found
/bin/sh: line 1458: _TtGCs23_ContiguousArrayStorageVs5UInt8_$: command not found
/bin/sh: line 1459: _TtGCs23_ContiguousArrayStorageGSaVs5UInt8__$: command not found
/bin/sh: line 1460: _TtGCs23_ContiguousArrayStorageO21DNTDocumentationModel14SourceLanguage_$: command not found
/bin/sh: line 1461: _TtGCs23_ContiguousArrayStorageV21DNTDocumentationModel24AllCollectionsIdentifier_$: command not found
/bin/sh: line 1462: _TtGCs23_ContiguousArrayStoragePs9CodingKey__$: command not found
/bin/sh: line 1463: _TtGCs23_ContiguousArrayStorageP23DNTDocumentationSupport8SQLValue__$: command not found
/bin/sh: line 1464: _TtGCs23_ContiguousArrayStorageGVs10DictionarySSP23DNTDocumentationSupport8SQLValue___$: command not found
/bin/sh: line 1465: _TtGCs23_ContiguousArrayStorageCSo32DVTSourceControlRemoteRepository_$: command not found
/bin/sh: line 1466: _TtGCs23_ContiguousArrayStorageP__$: command not found
/bin/sh: line 1467: _TtGCs23_ContiguousArrayStorageCSo9NSControl_$: command not found
/bin/sh: line 1468: _TtGCs23_ContiguousArrayStorageGSqCSo9NSControl__$: command not found
/bin/sh: line 1469: _TtGCs23_ContiguousArrayStorageSS_$: command not found
/bin/sh: line 1470: _TtGCs23_ContiguousArrayStorageVs4Int8_$: command not found
/bin/sh: line 1471: Swift.__EmptyArrayStorage: command not found
Dumping classes
       0

I attempted to break it down to find the problem, but quickly realized that even if I use (lldb) sys echo "$(dclass -t swift)", I get the same output (minus the "0" at the end).

If I just run dclass -t swift, I get the desired output. If I just run sys echo "hello world". I also get the desired output.

I would like to be able to follow along with this part of the book, but I can not seem to get this command to work as desired. Any help would be appreciated.

DerekSelander commented 5 years ago

Forgot I referenced that command in the book. Revert a recent push. Verified working on Xcode 10.2 after a po @import AppKit

rmaloney3 commented 5 years ago

@DerekSelander thanks :)

MEnnabah commented 4 years ago

@DerekSelander now after I po @import AppKit, and execute dclass -t swift, it throws and error:

Error [IRForTarget]: Rewriting an Objective-C constant string requires CFStringCreateWithBytes
error: error: error: The expression could not be prepared to run in the target
DerekSelander commented 4 years ago

@MEnnabah Is this Xcode 11? Can you run a (lldb) version so I can see which version of Xcode I should download to test