|
5 | 5 | options = {}
|
6 | 6 |
|
7 | 7 | #Defaults
|
8 |
| -options[:exclusion_prefixes] = "NS|UI|CA" |
| 8 | +options[:exclusion_prefixes] = "NS|UI|CA|CG|CI" |
9 | 9 |
|
10 | 10 |
|
11 | 11 | parser = OptionParser.new do |o|
|
|
24 | 24 | options[:exclusion_prefixes] = exclusion_prefixes
|
25 | 25 | }
|
26 | 26 |
|
| 27 | + o.on("-d", "--use-dwarf-info", "Use DWARF Information also") { |v| |
| 28 | + options[:use_dwarf] = v |
| 29 | + } |
| 30 | + |
27 | 31 | o.separator "Common options:"
|
28 | 32 | o.on_tail('-h', "Prints this help") { puts o; exit }
|
29 | 33 | o.parse!
|
|
84 | 88 | [
|
85 | 89 | THEEND
|
86 | 90 |
|
| 91 | +links = {} |
87 | 92 |
|
88 | 93 | #Searching all the .o files and showing its information through nm call
|
89 | 94 | IO.popen("find \"#{options[:search_directory]}\" -name \"*.o\" -exec /usr/bin/nm -o {} \\;") { |f|
|
|
103 | 108 |
|
104 | 109 | source,dest = /[^\w]*([^\.\/]+)\.o.*_OBJC_CLASS_\$_(.*)/.match(line)[1,2]
|
105 | 110 | if source != dest
|
106 |
| - puts " { \"source\" : \"#{source}\", \"dest\" : \"#{dest}\" }," |
| 111 | + destinations = links[source] ? links[source] : (links[source] = {}) |
| 112 | + destinations[dest] = "set up" |
107 | 113 | end
|
108 | 114 | end
|
109 |
| - end |
110 |
| - end |
| 115 | + end |
| 116 | + end |
111 | 117 | }
|
112 | 118 |
|
| 119 | +if options[:use_dwarf] |
| 120 | + |
| 121 | + # Search files again |
| 122 | + IO.popen("find \"#{options[:search_directory]}\" -name \"*.o\"") { |f| |
| 123 | + f.each do |line| |
| 124 | + |
| 125 | + # puts "Running dwarfdump #{line} | grep -A1 TAG_pointer_type" |
| 126 | + source = /.*\/(.+)\.o/.match(line)[1] |
| 127 | + IO.popen("dwarfdump #{line.strip} | grep -A1 TAG_pointer_type") { |fd| |
| 128 | + fd.each do |line2| |
| 129 | + # Finding the name in types |
| 130 | + # AT_type( {0x00000456} ( objc_object ) ) |
| 131 | + name = /.*?AT_type\(\s\{.*?\}.*\(\s((function|const)\s)?([A-Z][^\)]+?)\*?\s\).*/.match(line2) |
| 132 | + if name != nil |
| 133 | + dest = name[3] |
| 134 | + if /^(#{options[:exclusion_prefixes]})/.match(dest) == nil |
| 135 | + if source != dest and dest != "BOOL" |
| 136 | + destinations = links[source] ? links[source] : (links[source] = {}) |
| 137 | + destinations[dest] = "set up" |
| 138 | + end |
| 139 | + end |
| 140 | + end |
| 141 | + end |
| 142 | + } |
| 143 | + end |
| 144 | + } |
| 145 | +end |
| 146 | + |
| 147 | +sources_count = links.length |
| 148 | +links_count = 0 |
| 149 | +links.each do |source, dest_hash| |
| 150 | + links_count = links_count + dest_hash.length |
| 151 | + dest_hash.each do |dest, _ | |
| 152 | + puts " { \"source\" : \"#{source}\", \"dest\" : \"#{dest}\" }," |
| 153 | + end |
| 154 | +end |
| 155 | + |
| 156 | + |
| 157 | + |
113 | 158 | puts <<-THEEND
|
114 |
| - ] |
| 159 | + ], |
| 160 | + "source_files_count":#{sources_count}, |
| 161 | + "links_count":#{links_count}, |
115 | 162 | }
|
116 | 163 | ;
|
117 | 164 | THEEND
|
|
0 commit comments