Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Supported Dynamic Library #1

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
940 changes: 932 additions & 8 deletions SymbolicatorX/SymbolicatorX.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions SymbolicatorX/SymbolicatorX/Adaptor/Plist/PlistArray.swift
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,9 @@ public extension Plist {
return PlistArray(plist: self)
}
}

extension Array where Element : Hashable {
var unique: [Element] {
return Array(Set(self))
}
}
4 changes: 2 additions & 2 deletions SymbolicatorX/SymbolicatorX/Devicelib/libimobiledevice/afc.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
extern "C" {
#endif

#include <libimobiledevice/libimobiledevice.h>
#include <libimobiledevice/lockdown.h>
#include "libimobiledevice.h"
#include "lockdown.h"

#define AFC_SERVICE_NAME "com.apple.afc"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
extern "C" {
#endif

#include <libimobiledevice/libimobiledevice.h>
#include <libimobiledevice/lockdown.h>
#include "libimobiledevice.h"
#include "lockdown.h"

#define COMPANION_PROXY_SERVICE_NAME "com.apple.companion_proxy"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
extern "C" {
#endif

#include <libimobiledevice/libimobiledevice.h>
#include <libimobiledevice/lockdown.h>
#include <libmobiledevice/libimobiledevice.h>
#include <libmobiledevice/lockdown.h>

#define DEBUGSERVER_SERVICE_NAME "com.apple.debugserver"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
extern "C" {
#endif

#include <libimobiledevice/libimobiledevice.h>
#include <libimobiledevice/lockdown.h>
#include "libimobiledevice.h"
#include "lockdown.h"

#define DIAGNOSTICS_RELAY_SERVICE_NAME "com.apple.mobile.diagnostics_relay"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
extern "C" {
#endif

#include <libimobiledevice/libimobiledevice.h>
#include <libimobiledevice/lockdown.h>
#include "libimobiledevice.h"
#include "lockdown.h"

#define FILE_RELAY_SERVICE_NAME "com.apple.mobile.file_relay"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
extern "C" {
#endif

#include <libimobiledevice/libimobiledevice.h>
#include <libimobiledevice/lockdown.h>
#include "libimobiledevice.h"
#include "lockdown.h"

#define HEARTBEAT_SERVICE_NAME "com.apple.mobile.heartbeat"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
extern "C" {
#endif

#include <libimobiledevice/libimobiledevice.h>
#include <libimobiledevice/lockdown.h>
#include <libimobiledevice/afc.h>
#include "libimobiledevice.h"
#include "lockdown.h"
#include "afc.h"

#define HOUSE_ARREST_SERVICE_NAME "com.apple.mobile.house_arrest"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
extern "C" {
#endif

#include <libimobiledevice/libimobiledevice.h>
#include <libimobiledevice/lockdown.h>
#include "libimobiledevice.h"
#include "lockdown.h"

#define INSTPROXY_SERVICE_NAME "com.apple.mobile.installation_proxy"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ extern "C" {
#include <stdint.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <plist/plist.h>
#include <libplist/plist.h>

/** Error Codes */
typedef enum {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
extern "C" {
#endif

#include <libimobiledevice/libimobiledevice.h>
#include <libimobiledevice/lockdown.h>
#include <libmobiledevice/libimobiledevice.h>
#include <libmobiledevice/lockdown.h>

/** Error Codes */
typedef enum {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
extern "C" {
#endif

#include <libimobiledevice/libimobiledevice.h>
#include <libimobiledevice/lockdown.h>
#include "libimobiledevice.h"
#include "lockdown.h"

#define MISAGENT_SERVICE_NAME "com.apple.misagent"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
extern "C" {
#endif

#include <libimobiledevice/libimobiledevice.h>
#include <libimobiledevice/lockdown.h>
#include "libimobiledevice.h"
#include "lockdown.h"

#define MOBILE_IMAGE_MOUNTER_SERVICE_NAME "com.apple.mobile.mobile_image_mounter"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
extern "C" {
#endif

#include <libimobiledevice/libimobiledevice.h>
#include <libimobiledevice/lockdown.h>
#include "libimobiledevice.h"
#include "lockdown.h"

#define MOBILEACTIVATION_SERVICE_NAME "com.apple.mobileactivationd"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
extern "C" {
#endif

#include <libimobiledevice/libimobiledevice.h>
#include <libimobiledevice/lockdown.h>
#include "libimobiledevice.h"
#include "lockdown.h"

#define MOBILEBACKUP_SERVICE_NAME "com.apple.mobilebackup"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
extern "C" {
#endif

#include <libimobiledevice/libimobiledevice.h>
#include <libimobiledevice/lockdown.h>
#include "libimobiledevice.h"
#include "lockdown.h"

#define MOBILEBACKUP2_SERVICE_NAME "com.apple.mobilebackup2"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
extern "C" {
#endif

#include <libimobiledevice/libimobiledevice.h>
#include <libimobiledevice/lockdown.h>
#include "libimobiledevice.h"
#include "lockdown.h"

#define MOBILESYNC_SERVICE_NAME "com.apple.mobilesync"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
extern "C" {
#endif

#include <libimobiledevice/libimobiledevice.h>
#include <libimobiledevice/lockdown.h>
#include "libimobiledevice.h"
#include "lockdown.h"

#define NP_SERVICE_NAME "com.apple.mobile.notification_proxy"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
extern "C" {
#endif

#include <libimobiledevice/libimobiledevice.h>
#include <libimobiledevice/lockdown.h>
#include "libimobiledevice.h"
#include "lockdown.h"

#define PREBOARD_SERVICE_NAME "com.apple.preboardservice_v2"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
extern "C" {
#endif

#include <libimobiledevice/lockdown.h>
#include "lockdown.h"

/* Error Codes */
typedef enum {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
extern "C" {
#endif

#include <libimobiledevice/libimobiledevice.h>
#include "libimobiledevice.h"

/** Error Codes */
typedef enum {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
extern "C" {
#endif

#include <libimobiledevice/libimobiledevice.h>
#include <libimobiledevice/lockdown.h>
#include "libimobiledevice.h"
#include "lockdown.h"

#define SBSERVICES_SERVICE_NAME "com.apple.springboardservices"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
extern "C" {
#endif

#include <libimobiledevice/libimobiledevice.h>
#include <libimobiledevice/lockdown.h>
#include "libimobiledevice.h"
#include "lockdown.h"

#define SCREENSHOTR_SERVICE_NAME "com.apple.mobile.screenshotr"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
extern "C" {
#endif

#include <libimobiledevice/libimobiledevice.h>
#include <libimobiledevice/lockdown.h>
#include "libimobiledevice.h"
#include "lockdown.h"

/** Error Codes */
typedef enum {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
extern "C" {
#endif

#include <libimobiledevice/libimobiledevice.h>
#include <libimobiledevice/lockdown.h>
#include "libimobiledevice.h"
#include "lockdown.h"

#define SYSLOG_RELAY_SERVICE_NAME "com.apple.syslog_relay"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
extern "C" {
#endif

#include <libimobiledevice/libimobiledevice.h>
#include <libimobiledevice/lockdown.h>
#include "libimobiledevice.h"
#include "lockdown.h"

#define WEBINSPECTOR_SERVICE_NAME "com.apple.webinspector"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
// SymbolicatorX
//
// Created by 钟晓跃 on 2020/7/5.
// Copyright © 2020 钟晓跃. All rights reserved.
// Modify by 钟晓跃 on 2020/7/5.
// Copyright © 2020 lory. All rights reserved.
//

import Cocoa
import libSymbolicatorX

class MainViewController: BaseViewController {

Expand Down Expand Up @@ -62,7 +64,12 @@ extension MainViewController {

isSymbolicating = true

Symbolicator.symbolicate(crashFile: crashFile, dsymFile: dsymFile, errorHandler: { [weak self] (error) in
print(crashFile.path?.absoluteString)
print(dsymFile.path.absoluteString)

guard let cf = libSymbolicatorX.LibCrashFile(path: crashFile.path!) else { return }
let df = libSymbolicatorX.LibDSYMFile(path: dsymFile.path)
libSymbolicatorX.symbolicate(crashFile: cf, dsymFile: df, errorHandler: { [weak self] (error) in

DispatchQueue.main.async {
self?.view.window?.alert(message: error)
Expand All @@ -78,6 +85,23 @@ extension MainViewController {
self?.textWindowController.saveUrl = crashFile.symbolicatedContentSaveURL
}
}

// Symbolicator.symbolicate(crashFile: crashFile, dsymFile: dsymFile, errorHandler: { [weak self] (error) in
//
// DispatchQueue.main.async {
// self?.view.window?.alert(message: error)
// self?.isSymbolicating = false
// }
// }) { [weak self] (content) in
//
// DispatchQueue.main.async {
// self?.isSymbolicating = false
// self?.textWindowController.showWindow(nil)
// self?.textWindowController.fileName = crashFile.filename
// self?.textWindowController.text = content
// self?.textWindowController.saveUrl = crashFile.symbolicatedContentSaveURL
// }
// }
}
}

Expand Down
14 changes: 14 additions & 0 deletions SymbolicatorX/SymbolicatorX/Main/Model/CrashFile.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public struct CrashFile {
var architecture: Architecture?
var loadAddress: String?
var addresses: [String]?
var addressArray = [String:[String]]()
var version: String?
var buildVersion: String?
var uuid: BinaryUUID?
Expand Down Expand Up @@ -138,6 +139,19 @@ public struct CrashFile {

self.addresses = crashReportAddresses + sampleAddresses

let crashReportBinaries = content.scan(
pattern: "^\\d+\\s+(\("[a-zA-Z0-9_\\u4e00-\\u9fa5]*")).*?0x.*?\\s",
options: [.caseInsensitive, .anchorsMatchLines, .dotMatchesLineSeparators]
).compactMap { $0.last }

crashReportBinaries.unique.forEach { (binary) in
let crashReportAddresses = content.scan(
pattern: "^\\d+\\s+(\(binary)).*?(0x.*?)\\s",
options: [.caseInsensitive, .anchorsMatchLines, .dotMatchesLineSeparators]
).compactMap { $0.last }
self.addressArray[binary] = crashReportAddresses
}

self.responsible = content.scan(pattern: "^Responsible:\\s+(.+?)\\[").first?.first?.trimmed
self.version = content.scan(pattern: "^Version:\\s+(.+?)\\(").first?.first?.trimmed
self.buildVersion = content.scan(pattern: "^Version:.+\\((.*?)\\)").first?.first?.trimmed
Expand Down
11 changes: 11 additions & 0 deletions SymbolicatorX/SymbolicatorX/Main/Model/DSYMFile.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,17 @@ public struct DSYMFile {

return dwarfPath.appendingPathComponent(binary).path
}

var binaryName: String {

let dwarfPath = path.appendingPathComponent("Contents").appendingPathComponent("Resources").appendingPathComponent("DWARF")

guard let binary = (try? FileManager.default.contentsOfDirectory(atPath: dwarfPath.path))?.first else {
return filename.replacingOccurrences(of: ".dSYM", with: "")
}

return binary
}

public init(path: URL) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class Symbolicator {
return
}

guard let addresses = crashFile.addresses, addresses.count > 0 else {
guard let addresses = crashFile.addressArray[dsymFile.binaryName], addresses.count > 0 else {
completion(crashFile.content)
return
}
Expand Down
Loading