Skip to content

Commit

Permalink
Support un-tracing (revert interposes)
Browse files Browse the repository at this point in the history
  • Loading branch information
johnno1962 committed Nov 10, 2020
1 parent 7959224 commit d4d63c7
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 10 deletions.
1 change: 1 addition & 0 deletions InjectionBundle/InjectionClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ typedef NS_ENUM(int, InjectionCommand) {
InjectionCallOrder,
InjectionFileOrder,
InjectionFileReorder,
InjectionUninterpose,

InjectionInvalid = 1000,

Expand Down
7 changes: 6 additions & 1 deletion InjectionBundle/InjectionClient.mm
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Created by John Holdsworth on 06/11/2017.
// Copyright © 2017 John Holdsworth. All rights reserved.
//
// $Id: //depot/ResidentEval/InjectionBundle/InjectionClient.mm#139 $
// $Id: //depot/ResidentEval/InjectionBundle/InjectionClient.mm#141 $
//

#import "InjectionClient.h"
Expand Down Expand Up @@ -336,6 +336,11 @@ - (void)runInBackground {
componentsJoinedByString:CALLORDER_DELIMITER]];
[self needsTracing];
break;
case InjectionUninterpose:
[SwiftTrace swiftTraceRevertAllInterposes];
[SwiftTrace swiftTraceRemoveAllTraces];
printf("💉 Removed all traces (and injections).\n");
break;
case InjectionInvalid:
printf("💉 ⚠️ Connection rejected. Are you running the correct version of InjectionIII.app from /Applications? ⚠️\n");
break;
Expand Down
2 changes: 1 addition & 1 deletion InjectionIII.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@
BB1BA906251DC51900044608 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
BB1BA90A251DC54100044608 /* SwiftUISupport.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftUISupport.swift; sourceTree = "<group>"; };
BB1BA918251DD0CA00044608 /* SwiftUISupport-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "SwiftUISupport-Bridging-Header.h"; sourceTree = "<group>"; };
BB1C3245254BFAFC001EDFCC /* EasyPointer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = EasyPointer.swift; path = ../../SwiftTrace/SwiftTrace/EasyPointer.swift; sourceTree = "<group>"; };
BB1C3245254BFAFC001EDFCC /* EasyPointer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = EasyPointer.swift; path = SwiftTrace/EasyPointer.swift; sourceTree = "<group>"; };
BB1DEA9A1FD6A74800AF509F /* Xtrace.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Xtrace.h; path = XprobePlugin/Classes/Xtrace.h; sourceTree = "<group>"; };
BB1DEA9B1FD6A74900AF509F /* IvarAccess.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = IvarAccess.h; path = XprobePlugin/Classes/IvarAccess.h; sourceTree = "<group>"; };
BB1DEA9C1FD6A74900AF509F /* Xprobe.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Xprobe.h; path = XprobePlugin/Classes/Xprobe.h; sourceTree = "<group>"; };
Expand Down
6 changes: 5 additions & 1 deletion InjectionIII/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Created by John Holdsworth on 06/11/2017.
// Copyright © 2017 John Holdsworth. All rights reserved.
//
// $Id: //depot/ResidentEval/InjectionIII/AppDelegate.swift#93 $
// $Id: //depot/ResidentEval/InjectionIII/AppDelegate.swift#94 $
//

import Cocoa
Expand Down Expand Up @@ -299,6 +299,10 @@ class AppDelegate : NSObject, NSApplicationDelegate {
lastConnection?.sendCommand(.stats, with: nil)
}

@IBAction func remmoveTraces(_ sender: NSMenuItem?) {
lastConnection?.sendCommand(.uninterpose, with: nil)
}

@IBAction func showTraceFilters(_ sender: NSMenuItem?) {
NSApplication.shared.activate(ignoringOtherApps: true)
traceFilters.makeKeyAndOrderFront(sender)
Expand Down
7 changes: 7 additions & 0 deletions InjectionIII/Base.lproj/MainMenu.xib
Original file line number Diff line number Diff line change
Expand Up @@ -791,6 +791,13 @@
<action selector="traceSwiftUI:" target="Voe-Tx-rLC" id="0xk-LY-4Pv"/>
</connections>
</menuItem>
<menuItem title="Undo Traces" allowsKeyEquivalentWhenHidden="YES" toolTip="Log calls made to SwiftUI." id="0Nz-cB-dDv">
<modifierMask key="keyEquivalentModifierMask"/>
<accessibility description="Trace App"/>
<connections>
<action selector="remmoveTraces:" target="Voe-Tx-rLC" id="V0U-kh-UYB"/>
</connections>
</menuItem>
<menuItem title="Legacy Trace" hidden="YES" toolTip="Log app class messaging. Includes calls via Objective-C" id="u9J-81-lZJ">
<modifierMask key="keyEquivalentModifierMask"/>
<accessibility description="Trace App"/>
Expand Down
2 changes: 1 addition & 1 deletion InjectionIII/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<key>CFBundleShortVersionString</key>
<string>$(MARKETING_VERSION)</string>
<key>CFBundleVersion</key>
<string>4902</string>
<string>4927</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.developer-tools</string>
<key>LSMinimumSystemVersion</key>
Expand Down
5 changes: 3 additions & 2 deletions InjectionIII/InjectionServer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
// Created by John Holdsworth on 06/11/2017.
// Copyright © 2017 John Holdsworth. All rights reserved.
//
// $Id: //depot/ResidentEval/InjectionIII/InjectionServer.swift#60 $
// $Id: //depot/ResidentEval/InjectionIII/InjectionServer.swift#61 $
//

let commandQueue = DispatchQueue(label: "InjectionCommand")
let compileQueue = DispatchQueue(label: "InjectionCompile")

var projectInjected = [String: [String: TimeInterval]]()
let MIN_INJECTION_INTERVAL = 1.0
Expand Down Expand Up @@ -250,7 +251,7 @@ public class InjectionServer: SimpleSocket {
source.hasSuffix(".storyboard") || source.hasSuffix(".xib") {
sendCommand(.inject, with: source)
} else {
DispatchQueue.main.asyncAfter(deadline: .now()+0.01) {
compileQueue.async {
if let dylib = try? self.builder.rebuildClass(oldClass: nil,
classNameOrFile: source, extra: nil) {
self.sendCommand(.load, with: dylib)
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ has been built into a standalone app: `InjectionIII.app` which runs in the statu

### Getting Started

To use injection, download the app from the App Store and run it. Then, you must add `"-Xlinker -interposable"` to your project's `"Other Linker Flags"` for the Debug target (qualified by the simulator SDK to avoid complications with bitcode). Finally, add one of the following to your application delegate's `applicationDidFinishLaunching:`
To use injection, download the app from the App Store and run it. Then, you must add `"-Xlinker -interposable"` (without the double quotes) to your project's `"Other Linker Flags"` for the Debug target (qualified by the simulator SDK to avoid complications with bitcode). Finally, add one of the following to your application delegate's `applicationDidFinishLaunching:`

Xcode 10.2 and later (Swift 5+):

Expand Down Expand Up @@ -343,4 +343,4 @@ store edge paths so they can be coloured (line 66 and 303) in "canviz-0.1/canviz
It also includes [CodeMirror](http://codemirror.net/) JavaScript editor
for the code to be evaluated using injection under an MIT license.

$Date: 2020/10/19 $
$Date: 2020/11/10 $
2 changes: 1 addition & 1 deletion SwiftUISupport/SwiftUISupport-Bridging-Header.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
#ifndef SwiftUISupport_Bridging_Header_h
#define SwiftUISupport_Bridging_Header_h

#import "../SwiftTrace/SwiftTrace/SwiftTrace.h"
#import "../SwiftTrace/SwiftTraceGuts/include/SwiftTrace.h"

#endif /* SwiftUISupport_Bridging_Header_h */

0 comments on commit d4d63c7

Please sign in to comment.