subclass_lldb 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/lib/rubygems_plugin.rb +89 -0
- data/lib/setup +87 -0
- metadata +45 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 9f5787cc00945c9ef73e0aebd615fe9b4e5b823b4e7ee0c9eef92b37b6dd815d
|
4
|
+
data.tar.gz: 73e4e28f2beb0119421e655afac6d510d025bf20e9d8bfda8a5c64b9e023b7a2
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c50f7b3bc0b6540ac9604b53c21d4f4576e1e19c91d26fe78361a48cfd5037fc64e3ccd404fc2a4af85c765e6b359e8ae4c580aee64a8f2ac0b8e8434b81bc98
|
7
|
+
data.tar.gz: 1ff6f8f77285027e6940f48b29f6c95db4ede5f87c699b56286e98ea4592b2d8b3a1f7fe1239b589f315f869cd1afbe996ec766e9084c382db4762bb5cf2d80b
|
@@ -0,0 +1,89 @@
|
|
1
|
+
|
2
|
+
require 'pathname'
|
3
|
+
|
4
|
+
Lldb_init_path = File.expand_path('~')+'/.lldbinit'
|
5
|
+
Lldb_init_path_temp = File.expand_path('~')+'/.lldbinit_temp'
|
6
|
+
Lldb_source_path = File.expand_path('~')+'/.isource_lldb'
|
7
|
+
Lldb_file_path = File.expand_path('~')+'/.isource_lldb/isource_lldb.py'
|
8
|
+
Commond_str = 'command script import '+Lldb_file_path
|
9
|
+
|
10
|
+
Gem.post_install do
|
11
|
+
|
12
|
+
# 配置 .lldbinit
|
13
|
+
if File.exist?(Lldb_init_path)
|
14
|
+
f=File.new(Lldb_init_path,"a+")
|
15
|
+
data = f.readlines
|
16
|
+
isExist = false
|
17
|
+
data.each do |d|
|
18
|
+
if d.chomp.include?Commond_str
|
19
|
+
isExist = true
|
20
|
+
end
|
21
|
+
end
|
22
|
+
if isExist == false
|
23
|
+
f.puts ''
|
24
|
+
f.puts Commond_str
|
25
|
+
f.close
|
26
|
+
end
|
27
|
+
else
|
28
|
+
f=File.new(Lldb_init_path,"w+")
|
29
|
+
f.puts ''
|
30
|
+
f.puts Commond_str
|
31
|
+
f.close
|
32
|
+
end
|
33
|
+
File.chmod(0664,Lldb_init_path)
|
34
|
+
|
35
|
+
# 配置执行脚本
|
36
|
+
if !File.exist?(Lldb_source_path)
|
37
|
+
Dir.mkdir(Lldb_source_path)
|
38
|
+
end
|
39
|
+
File.chmod(0775,Lldb_source_path)
|
40
|
+
scriptPath = File.dirname(Pathname.new(__FILE__).realpath)
|
41
|
+
File.rename scriptPath+'/setup', Lldb_file_path
|
42
|
+
File.chmod(0775,Lldb_file_path)
|
43
|
+
|
44
|
+
puts "Please use the isource command in your Xcode LLDB."
|
45
|
+
end
|
46
|
+
|
47
|
+
def remove_dir(path)
|
48
|
+
if File.directory?(path)
|
49
|
+
Dir.foreach(path) do |file|
|
50
|
+
if ((file.to_s != ".") and (file.to_s != ".."))
|
51
|
+
remove_dir("#{path}/#{file}")
|
52
|
+
end
|
53
|
+
end
|
54
|
+
Dir.delete(path)
|
55
|
+
else
|
56
|
+
File.delete(path)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def remove_file()
|
61
|
+
f_temp = File.new(Lldb_init_path_temp,"w")
|
62
|
+
f = File.new(Lldb_init_path, 'r')
|
63
|
+
f.each do |line|
|
64
|
+
if !line.chomp.include?Commond_str
|
65
|
+
f_temp.puts line
|
66
|
+
end
|
67
|
+
end
|
68
|
+
f.close
|
69
|
+
f_temp.close
|
70
|
+
|
71
|
+
File.delete(Lldb_init_path)
|
72
|
+
File.rename Lldb_init_path_temp, Lldb_init_path
|
73
|
+
File.chmod(0664,Lldb_init_path)
|
74
|
+
|
75
|
+
end
|
76
|
+
|
77
|
+
Gem.post_uninstall do
|
78
|
+
if File.exist?(Lldb_source_path)
|
79
|
+
remove_dir(Lldb_source_path)
|
80
|
+
end
|
81
|
+
|
82
|
+
if File.exist?(Lldb_init_path)
|
83
|
+
remove_file()
|
84
|
+
end
|
85
|
+
|
86
|
+
puts "Thank you for using subclass."
|
87
|
+
|
88
|
+
end
|
89
|
+
|
data/lib/setup
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
# !/usr/bin/env python3
|
2
|
+
import lldb #line:5
|
3
|
+
import re #line:6
|
4
|
+
def help ():#line:8
|
5
|
+
print ("Usage:")#line:9
|
6
|
+
print (" isource superclass eg:isource NSObject")#line:10
|
7
|
+
pass #line:11
|
8
|
+
def process (OO000O00OOO000O00 ):#line:13
|
9
|
+
OO00OO0OO00OOO0OO =r'''
|
10
|
+
@import <dlfcn.h>;
|
11
|
+
@import <objc/runtime.h>;
|
12
|
+
@import Foundation;
|
13
|
+
unsigned int count;
|
14
|
+
const char **classes;
|
15
|
+
Dl_info info;
|
16
|
+
|
17
|
+
void *_mh_execute_header = __builtin_return_address(0);
|
18
|
+
dladdr(_mh_execute_header, &info);
|
19
|
+
classes = (const char **)objc_copyClassNamesForImage(info.dli_fname, &count);
|
20
|
+
|
21
|
+
NSInteger level = 0;//继承层级
|
22
|
+
NSMutableDictionary * visited_class = [[NSMutableDictionary alloc]init];
|
23
|
+
NSMutableArray * class_stack = [[NSMutableArray alloc] init];
|
24
|
+
[class_stack addObject:@"'''+OO000O00OOO000O00 +'''"];
|
25
|
+
BOOL isPrint = NO;
|
26
|
+
printf("\\n");
|
27
|
+
while (true) {
|
28
|
+
|
29
|
+
NSString * current_class = [class_stack firstObject];
|
30
|
+
|
31
|
+
if (current_class) {
|
32
|
+
if((BOOL)[[visited_class objectForKey:current_class] boolValue] == YES ) {
|
33
|
+
|
34
|
+
BOOL hasNewClass = NO;
|
35
|
+
for (int i = 0; i < count; i++) {
|
36
|
+
|
37
|
+
NSString *className = [NSString stringWithCString:classes[i] encoding:NSUTF8StringEncoding];
|
38
|
+
NSString *superName = (NSString*)NSStringFromClass((Class)class_getSuperclass(NSClassFromString(className)));
|
39
|
+
|
40
|
+
if ([superName isEqualToString:current_class] && (BOOL)[[visited_class objectForKey:className] boolValue] == NO) {
|
41
|
+
[class_stack insertObject:className atIndex:0];
|
42
|
+
hasNewClass = YES;
|
43
|
+
break;
|
44
|
+
}
|
45
|
+
}
|
46
|
+
if (hasNewClass == YES) {
|
47
|
+
level += 1;
|
48
|
+
} else {
|
49
|
+
[class_stack removeObjectAtIndex:0];
|
50
|
+
level -= 1;
|
51
|
+
}
|
52
|
+
|
53
|
+
} else {
|
54
|
+
NSMutableString * separation = [[NSMutableString alloc]init];
|
55
|
+
for (int i = 0; i < level; ++i) {
|
56
|
+
[separation appendString:@"----"];
|
57
|
+
}
|
58
|
+
if (isPrint == YES) {
|
59
|
+
printf("|\\n");
|
60
|
+
}
|
61
|
+
NSString * temp = (NSString*)NSStringFromClass((Class)class_getSuperclass(NSClassFromString(current_class)));
|
62
|
+
if (temp.length > 0) {
|
63
|
+
printf("|--%s%s : %s (L%s) \\n",(char *)[[separation copy] UTF8String],(char *)[current_class UTF8String],(char *)[temp UTF8String],(char *)[[NSString stringWithFormat:@"%ld",(long)level] UTF8String]);
|
64
|
+
} else {
|
65
|
+
printf("|--%s%s (L%s) \\n",(char *)[[separation copy] UTF8String],(char *)[current_class UTF8String],(char *)[[NSString stringWithFormat:@"%ld",(long)level] UTF8String]);
|
66
|
+
}
|
67
|
+
isPrint = YES;
|
68
|
+
[visited_class setObject:@1 forKey:current_class];
|
69
|
+
}
|
70
|
+
} else {
|
71
|
+
break;
|
72
|
+
}
|
73
|
+
}
|
74
|
+
'''#line:79
|
75
|
+
O0OO0O000O000O00O =lldb .debugger .GetCommandInterpreter ()#line:81
|
76
|
+
OO000O0O0O0O0O0O0 =lldb .SBCommandReturnObject ()#line:82
|
77
|
+
O0OO0O000O000O00O .HandleCommand ('expression -lobjc -O -- '+OO00OO0OO00OOO0OO ,OO000O0O0O0O0O0O0 )#line:84
|
78
|
+
OOO00OOO0000O00O0 =OO000O0O0O0O0O0O0 .GetOutput ()#line:85
|
79
|
+
OOO00000O0OOO00OO =re .search ('error',OOO00OOO0000O00O0 )#line:86
|
80
|
+
print (OO000O0O0O0O0O0O0 .GetError ())#line:87
|
81
|
+
def helloworld (OOOOO0O0OO0OOO00O ,OOOOO00OO00O000OO ,O0000OOO0O0OOOOO0 ,O00O0O00O00OOOO00 ):#line:90
|
82
|
+
if OOOOO00OO00O000OO ==None or OOOOO00OO00O000OO =='-h':#line:92
|
83
|
+
help ()#line:93
|
84
|
+
else :#line:94
|
85
|
+
process (OOOOO00OO00O000OO )#line:95
|
86
|
+
def __OOO00OOO00O00O00O (OO000OOO0O000O0OO ,OOOOO0OOOOOOOOO00 ):#line:98
|
87
|
+
OO000OOO0O000O0OO .HandleCommand ("command script add -f subclass_lldb.helloworld subclass")#line:99
|
metadata
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: subclass_lldb
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- ningyuan
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-06-15 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: An plugin of LLDB.
|
14
|
+
email:
|
15
|
+
- m13811217138@gmail.com
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- lib/rubygems_plugin.rb
|
21
|
+
- lib/setup
|
22
|
+
homepage: https://github.com/Jeremi-LZ/subclass_lldb
|
23
|
+
licenses:
|
24
|
+
- MIT
|
25
|
+
metadata: {}
|
26
|
+
post_install_message:
|
27
|
+
rdoc_options: []
|
28
|
+
require_paths:
|
29
|
+
- lib
|
30
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: 2.3.0
|
35
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
requirements: []
|
41
|
+
rubygems_version: 3.0.3
|
42
|
+
signing_key:
|
43
|
+
specification_version: 4
|
44
|
+
summary: An plugin of LLDB.
|
45
|
+
test_files: []
|