atosl 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: bcf2f819cf10ef934ef1c7c741af28d4eaafd907
4
+ data.tar.gz: 35db780cd14acb2383c4973fe35d5ea5a96b57be
5
+ SHA512:
6
+ metadata.gz: ee47e199ed2aa3fb9908730f31da057cd1876194089d3a91c003906c9fb1536c84526fb599303b04cfc15c5c0bffa8818f50bb48a5ef93e77fe2fdd48873f5ce
7
+ data.tar.gz: 2c722675ecf90dab8483006e802dfe0648095f01c51775cf0d4262ead079d65ad3bff8ee6577af855cbbccd47275cbe39009e75c26129b218e28ff183b5dbaa3
data/.gitignore ADDED
@@ -0,0 +1,23 @@
1
+ *.gem
2
+ *.rbc
3
+ lib/atosl/atosl.bundle
4
+ .bundle
5
+ .config
6
+ .yardoc
7
+ Gemfile.lock
8
+ InstalledFiles
9
+ _yardoc
10
+ coverage
11
+ doc/
12
+ lib/bundler/man
13
+ pkg
14
+ rdoc
15
+ spec/reports
16
+ test/tmp
17
+ test/version_tmp
18
+ tmp
19
+ ext/atosl/atosl.bundle
20
+ .DS_Store
21
+ */.DS_Store
22
+ ext/atosl/mkmf.log
23
+ ext/atosl/Makefile
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in atosl.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Reno Qiu
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,33 @@
1
+ # Atosl
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'atosl'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install atosl
18
+
19
+ ## Usage
20
+
21
+ Usage: atosl --arch architecture -o executable -a [address,address,...]
22
+
23
+ ## Reference
24
+
25
+ [Original](https://github.com/renoqiu/atosl "atosl").
26
+
27
+ ## Contributing
28
+
29
+ 1. Fork it
30
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
31
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
32
+ 4. Push to the branch (`git push origin my-new-feature`)
33
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,14 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rake/testtask'
3
+ require "rake/extensiontask"
4
+
5
+ Rake::TestTask.new do |t|
6
+ t.libs << 'test'
7
+ end
8
+
9
+ desc "Run tests"
10
+ task :default => :test
11
+
12
+ Rake::ExtensionTask.new "atosl" do |ext|
13
+ ext.lib_dir = "lib/atosl"
14
+ end
data/atosl.gemspec ADDED
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'atosl/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "atosl"
8
+ spec.version = Atosl::VERSION
9
+ spec.authors = ["Reno Qiu"]
10
+ spec.email = ["dechao.qiu@gmail.com"]
11
+ spec.summary = %q{atos for Linux.}
12
+ spec.description = %q{atosl is used for converting binary addresses within a macho file to symbols.}
13
+ spec.homepage = "https://github.com/renoqiu/atosl"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.extensions << "ext/atosl/extconf.rb"
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.4"
23
+ spec.add_development_dependency "rake"
24
+ spec.add_development_dependency "rake-compiler"
25
+ end
data/bin/atosl ADDED
@@ -0,0 +1,48 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'optparse'
4
+ require 'atosl'
5
+
6
+ options = {}
7
+
8
+ opts = OptionParser.new do |opts|
9
+ opts.banner = "atosl: atos on linux for converting binary addresses into symbols."
10
+ opts.define_head "Usage: atosl --arch architecture -o executable -a [address,address,...]"
11
+ opts.separator ""
12
+ opts.separator "Examples:"
13
+ opts.separator " atosl --arch ARMV7S -o ~/TEST -a 0X00001100 0X00001200"
14
+ opts.separator ""
15
+ opts.separator "Options:"
16
+
17
+ opts.on("--arch [architecture]") do |v|
18
+ @arch = v.to_s
19
+ options[:arch] = v.to_s
20
+ end
21
+
22
+ opts.on("-o macho_path", "Specifies target macho file path from command-line.") do |v|
23
+ @macho_path = v
24
+ options[:macho_path] = v
25
+ end
26
+
27
+ opts.on('-a address1,address2', '--address address1,address2', Array, 'List of addresses') do |value|
28
+ options[:addresses] = value
29
+ end
30
+
31
+ opts.on_tail("-?", "--help", "Show this message") do
32
+ puts opts
33
+ exit
34
+ end
35
+
36
+ opts.on_tail("-v", "--version", "Show version") do
37
+ puts Atosl::VERSION
38
+ exit
39
+ end
40
+ end
41
+ opts.parse!
42
+
43
+ if options[:arch].nil? or options[:macho_path].nil? or options[:addresses].nil?
44
+ puts opts
45
+ raise OptionParser::MissingArgument
46
+ end
47
+
48
+ Atosl.convert(options[:arch], options[:macho_path], options[:addresses])
data/ext/atosl/atosl.c ADDED
@@ -0,0 +1,153 @@
1
+ /*
2
+ * =====================================================================================
3
+ *
4
+ * Filename: atosl.c
5
+ *
6
+ * Description: Main Function
7
+ *
8
+ * Version: 1.0
9
+ * Created: 02/17/2013 19:00:22
10
+ * Revision: none
11
+ * Compiler: gcc
12
+ *
13
+ * Author: Reno Qiu
14
+ * Organization:
15
+ *
16
+ * =====================================================================================
17
+ */
18
+ #include <stdio.h>
19
+ #include "macho.h"
20
+ #include <ruby.h>
21
+
22
+ extern char *project_name;
23
+
24
+ static int lookup_by_address(struct thin_macho *thin_macho, CORE_ADDR integer_address){
25
+ int result = -1;
26
+ if(thin_macho->dwarf2_per_objfile != NULL){
27
+ result = lookup_by_address_in_dwarf(thin_macho, integer_address);
28
+ }
29
+ if(result == -1){
30
+ result = lookup_by_address_in_symtable(thin_macho, integer_address);
31
+ }
32
+ return result;
33
+ }
34
+
35
+ static void numeric_to_symbols(struct thin_macho *thin_macho, const char **addresses, int numofaddresses){
36
+ int i = 0;
37
+ const char *address = NULL;
38
+ CORE_ADDR integer_address = 0;
39
+
40
+ for (i = 0; i < numofaddresses; i++){
41
+ address = addresses[i];
42
+ if(address[0] == '0' && (address[1] == 'x' || address[1] == 'X')){
43
+ //address start with 0x
44
+ integer_address = strtoll(address, NULL, 0);
45
+ }else{
46
+ integer_address= strtoll(address, NULL, 16);
47
+ }
48
+
49
+ if (lookup_by_address(thin_macho, integer_address) != 0){
50
+ printf("%s\n", addresses[i]);
51
+ }
52
+ }
53
+ }
54
+
55
+ static void set_project_name(const char* full_filename){
56
+ char *filename = strrchr(full_filename, '/');
57
+ if(filename == NULL){
58
+ filename = (char *)full_filename;
59
+ }else{
60
+ filename = filename + 1;
61
+ }
62
+ project_name = filename;
63
+ }
64
+
65
+
66
+ int symbolicate(const char* arch, const char *executable, char *addresses[], int numofaddresses){
67
+ debug("in symbolicate arch: %s executable: %s\n", arch, executable);
68
+ set_project_name(executable);
69
+ debug("about to parse file.");
70
+ struct target_file *tf = parse_file(executable);
71
+ if (tf == NULL){
72
+ debug("parse target file error.");
73
+ return -1;
74
+ }
75
+ debug("parse file finished.");
76
+
77
+ struct thin_macho *thin_macho = NULL;
78
+ //TODO performance
79
+ int i = select_thin_macho_by_arch(tf, arch);
80
+ if(i == -1){
81
+ printf("atosl: Can not find macho for architecture: %s.\n", arch);
82
+ return -1;
83
+ }
84
+ thin_macho = tf->thin_machos[i];
85
+ //#ifdef DEBUG
86
+ // print_all_dwarf2_per_objfile(thin_macho->dwarf2_per_objfile);
87
+ //#endif
88
+
89
+ debug("thin_macho->dwarf2_per_objfile: %p.", thin_macho->dwarf2_per_objfile);
90
+ if(thin_macho->dwarf2_per_objfile != NULL){
91
+ debug("about to parse dwarf2 objfile.");
92
+ parse_dwarf2_per_objfile(thin_macho->dwarf2_per_objfile);
93
+ debug("parse dwarf2 objfile finished.");
94
+ }
95
+
96
+ #ifdef DEBUG
97
+ print_thin_macho_aranges(thin_macho);
98
+ #endif
99
+
100
+ debug("about to invoke numeric_to_symbols.");
101
+ numeric_to_symbols(thin_macho, (const char **)addresses, numofaddresses);
102
+ free_target_file(tf);
103
+ return 0;
104
+ }
105
+
106
+ // Initial setup function, takes no arguments and returns nothing. Some API
107
+ // notes:
108
+ //
109
+ // * rb_define_module() creates and returns a top-level module by name
110
+ //
111
+ // * rb_define_module_under() takes a module and a name, and creates a new
112
+ // module within the given one
113
+ //
114
+ // * rb_define_singleton_method() take a module, the method name, a reference to
115
+ // a C function, and the method's arity, and exposes the C function as a
116
+ // single method on the given module
117
+ VALUE Atosl;
118
+
119
+ VALUE symbolicate_wrapper(VALUE self, VALUE arch, VALUE executable, VALUE addresses){
120
+ int numofaddresses = RARRAY_LEN(addresses);
121
+ char *arch_str = RSTRING_PTR(StringValue(arch));
122
+ char *executable_str = RSTRING_PTR(StringValue(executable));
123
+ char **addresses_array = malloc(numofaddresses * sizeof(char *));
124
+ for (int i = 0; i < numofaddresses; i++){
125
+ VALUE ret = rb_ary_entry(addresses, i);
126
+ addresses_array[i] = RSTRING_PTR(StringValue(ret));
127
+ }
128
+ int result = symbolicate(arch_str, executable_str, addresses_array, numofaddresses);
129
+ free(addresses_array);
130
+ return INT2NUM(result);
131
+ }
132
+ void Init_atosl(){
133
+ Atosl = rb_define_module("Atosl");
134
+ rb_define_singleton_method(Atosl, "symbolicate", symbolicate_wrapper, 3);
135
+ }
136
+
137
+ int main(int argc, char *argv[]){
138
+ if (argc < 6){
139
+ printf("usage: atosl -arch architecture -o executable [address ...]\n");
140
+ exit(-1);
141
+ }
142
+ assert(strcmp(argv[1], "-arch") == 0);
143
+ char *arch = argv[2];
144
+ assert(strcmp(argv[3], "-o") == 0);
145
+
146
+ char *executable = argv[4];
147
+
148
+ int numofaddresses = argc - 5;
149
+ char **addresses = argv + 5;
150
+ int result = symbolicate(arch, executable, addresses, numofaddresses);
151
+ return result;
152
+ }
153
+
data/ext/atosl/atosl.h ADDED
@@ -0,0 +1,4 @@
1
+ #ifndef ATOSL_H
2
+ #define ATOSL_H
3
+ int symbolicate(const char* arch, const char *executable, char *addresses[], int numofaddresses);
4
+ #endif
@@ -0,0 +1,411 @@
1
+ /*
2
+ * =====================================================================================
3
+ *
4
+ * Filename: converter.c
5
+ *
6
+ * Description: Convert code to string or enum type
7
+ *
8
+ * Version: 1.0
9
+ * Created: 21/02/13 08:54:55
10
+ * Revision: none
11
+ * Compiler: gcc
12
+ *
13
+ * Author: Reno Qiu
14
+ * Organization:
15
+ *
16
+ * =====================================================================================
17
+ */
18
+
19
+ #include "converter.h"
20
+ /* Convert a DWARF attribute code into its string name. */
21
+
22
+ const char* dwarf_attr_name (unsigned int attr)
23
+ {
24
+ switch (attr)
25
+ {
26
+ case DW_AT_sibling:
27
+ return "DW_AT_sibling";
28
+ case DW_AT_location:
29
+ return "DW_AT_location";
30
+ case DW_AT_name:
31
+ return "DW_AT_name";
32
+ case DW_AT_ordering:
33
+ return "DW_AT_ordering";
34
+ case DW_AT_subscr_data:
35
+ return "DW_AT_subscr_data";
36
+ case DW_AT_byte_size:
37
+ return "DW_AT_byte_size";
38
+ case DW_AT_bit_offset:
39
+ return "DW_AT_bit_offset";
40
+ case DW_AT_bit_size:
41
+ return "DW_AT_bit_size";
42
+ case DW_AT_element_list:
43
+ return "DW_AT_element_list";
44
+ case DW_AT_stmt_list:
45
+ return "DW_AT_stmt_list";
46
+ case DW_AT_low_pc:
47
+ return "DW_AT_low_pc";
48
+ case DW_AT_high_pc:
49
+ return "DW_AT_high_pc";
50
+ case DW_AT_language:
51
+ return "DW_AT_language";
52
+ case DW_AT_member:
53
+ return "DW_AT_member";
54
+ case DW_AT_discr:
55
+ return "DW_AT_discr";
56
+ case DW_AT_discr_value:
57
+ return "DW_AT_discr_value";
58
+ case DW_AT_visibility:
59
+ return "DW_AT_visibility";
60
+ case DW_AT_import:
61
+ return "DW_AT_import";
62
+ case DW_AT_string_length:
63
+ return "DW_AT_string_length";
64
+ case DW_AT_common_reference:
65
+ return "DW_AT_common_reference";
66
+ case DW_AT_comp_dir:
67
+ return "DW_AT_comp_dir";
68
+ case DW_AT_const_value:
69
+ return "DW_AT_const_value";
70
+ case DW_AT_containing_type:
71
+ return "DW_AT_containing_type";
72
+ case DW_AT_default_value:
73
+ return "DW_AT_default_value";
74
+ case DW_AT_inline:
75
+ return "DW_AT_inline";
76
+ case DW_AT_is_optional:
77
+ return "DW_AT_is_optional";
78
+ case DW_AT_lower_bound:
79
+ return "DW_AT_lower_bound";
80
+ case DW_AT_producer:
81
+ return "DW_AT_producer";
82
+ case DW_AT_prototyped:
83
+ return "DW_AT_prototyped";
84
+ case DW_AT_return_addr:
85
+ return "DW_AT_return_addr";
86
+ case DW_AT_start_scope:
87
+ return "DW_AT_start_scope";
88
+ case DW_AT_stride_size:
89
+ return "DW_AT_stride_size";
90
+ case DW_AT_upper_bound:
91
+ return "DW_AT_upper_bound";
92
+ case DW_AT_abstract_origin:
93
+ return "DW_AT_abstract_origin";
94
+ case DW_AT_accessibility:
95
+ return "DW_AT_accessibility";
96
+ case DW_AT_address_class:
97
+ return "DW_AT_address_class";
98
+ case DW_AT_artificial:
99
+ return "DW_AT_artificial";
100
+ case DW_AT_base_types:
101
+ return "DW_AT_base_types";
102
+ case DW_AT_calling_convention:
103
+ return "DW_AT_calling_convention";
104
+ case DW_AT_count:
105
+ return "DW_AT_count";
106
+ case DW_AT_data_member_location:
107
+ return "DW_AT_data_member_location";
108
+ case DW_AT_decl_column:
109
+ return "DW_AT_decl_column";
110
+ case DW_AT_decl_file:
111
+ return "DW_AT_decl_file";
112
+ case DW_AT_decl_line:
113
+ return "DW_AT_decl_line";
114
+ case DW_AT_declaration:
115
+ return "DW_AT_declaration";
116
+ case DW_AT_discr_list:
117
+ return "DW_AT_discr_list";
118
+ case DW_AT_encoding:
119
+ return "DW_AT_encoding";
120
+ case DW_AT_external:
121
+ return "DW_AT_external";
122
+ case DW_AT_frame_base:
123
+ return "DW_AT_frame_base";
124
+ case DW_AT_friend:
125
+ return "DW_AT_friend";
126
+ case DW_AT_identifier_case:
127
+ return "DW_AT_identifier_case";
128
+ case DW_AT_macro_info:
129
+ return "DW_AT_macro_info";
130
+ case DW_AT_namelist_items:
131
+ return "DW_AT_namelist_items";
132
+ case DW_AT_priority:
133
+ return "DW_AT_priority";
134
+ case DW_AT_segment:
135
+ return "DW_AT_segment";
136
+ case DW_AT_specification:
137
+ return "DW_AT_specification";
138
+ case DW_AT_static_link:
139
+ return "DW_AT_static_link";
140
+ case DW_AT_type:
141
+ return "DW_AT_type";
142
+ case DW_AT_use_location:
143
+ return "DW_AT_use_location";
144
+ case DW_AT_variable_parameter:
145
+ return "DW_AT_variable_parameter";
146
+ case DW_AT_virtuality:
147
+ return "DW_AT_virtuality";
148
+ case DW_AT_vtable_elem_location:
149
+ return "DW_AT_vtable_elem_location";
150
+ case DW_AT_allocated:
151
+ return "DW_AT_allocated";
152
+ case DW_AT_associated:
153
+ return "DW_AT_associated";
154
+ case DW_AT_data_location:
155
+ return "DW_AT_data_location";
156
+ case DW_AT_stride:
157
+ return "DW_AT_stride";
158
+ case DW_AT_entry_pc:
159
+ return "DW_AT_entry_pc";
160
+ case DW_AT_use_UTF8:
161
+ return "DW_AT_use_UTF8";
162
+ case DW_AT_extension:
163
+ return "DW_AT_extension";
164
+ case DW_AT_ranges:
165
+ return "DW_AT_ranges";
166
+ case DW_AT_trampoline:
167
+ return "DW_AT_trampoline";
168
+ case DW_AT_call_column:
169
+ return "DW_AT_call_column";
170
+ case DW_AT_call_file:
171
+ return "DW_AT_call_file";
172
+ case DW_AT_call_line:
173
+ return "DW_AT_call_line";
174
+ //#ifdef MIPS
175
+ // case DW_AT_MIPS_fde:
176
+ // return "DW_AT_MIPS_fde";
177
+ // case DW_AT_MIPS_loop_begin:
178
+ // return "DW_AT_MIPS_loop_begin";
179
+ // case DW_AT_MIPS_tail_loop_begin:
180
+ // return "DW_AT_MIPS_tail_loop_begin";
181
+ // case DW_AT_MIPS_epilog_begin:
182
+ // return "DW_AT_MIPS_epilog_begin";
183
+ // case DW_AT_MIPS_loop_unroll_factor:
184
+ // return "DW_AT_MIPS_loop_unroll_factor";
185
+ // case DW_AT_MIPS_software_pipeline_depth:
186
+ // return "DW_AT_MIPS_software_pipeline_depth";
187
+ //#endif
188
+ case DW_AT_MIPS_linkage_name:
189
+ return "DW_AT_MIPS_linkage_name";
190
+
191
+ case DW_AT_sf_names:
192
+ return "DW_AT_sf_names";
193
+ case DW_AT_src_info:
194
+ return "DW_AT_src_info";
195
+ case DW_AT_mac_info:
196
+ return "DW_AT_mac_info";
197
+ case DW_AT_src_coords:
198
+ return "DW_AT_src_coords";
199
+ case DW_AT_body_begin:
200
+ return "DW_AT_body_begin";
201
+ case DW_AT_body_end:
202
+ return "DW_AT_body_end";
203
+ case DW_AT_GNU_vector:
204
+ return "DW_AT_GNU_vector";
205
+ // /* APPLE LOCAL begin dwarf repository */
206
+ // case DW_AT_APPLE_repository_file:
207
+ // return "DW_AT_APPLE_repository_file";
208
+ // case DW_AT_APPLE_repository_type:
209
+ // return "DW_AT_APPLE_repository_type";
210
+ // case DW_AT_APPLE_repository_name:
211
+ // return "DW_AT_APPLE_repository_name";
212
+ // case DW_AT_APPLE_repository_specification:
213
+ // return "DW_AT_APPLE_repository_specification";
214
+ // case DW_AT_APPLE_repository_import:
215
+ // return "DW_AT_APPLE_repository_import";
216
+ // case DW_AT_APPLE_repository_abstract_origin:
217
+ // return "DW_AT_APPLE_repository_abstract_origin";
218
+ /* APPLE LOCAL end dwarf repository */
219
+ default:
220
+ return "DW_AT_<unknown>";
221
+ }
222
+ }
223
+
224
+
225
+
226
+ /* Convert a DWARF value form code into its string name. */
227
+
228
+ const char * dwarf_form_name (unsigned form)
229
+ {
230
+ switch (form)
231
+ {
232
+ case DW_FORM_addr:
233
+ return "DW_FORM_addr";
234
+ case DW_FORM_block2:
235
+ return "DW_FORM_block2";
236
+ case DW_FORM_block4:
237
+ return "DW_FORM_block4";
238
+ case DW_FORM_data2:
239
+ return "DW_FORM_data2";
240
+ case DW_FORM_data4:
241
+ return "DW_FORM_data4";
242
+ case DW_FORM_data8:
243
+ return "DW_FORM_data8";
244
+ case DW_FORM_string:
245
+ return "DW_FORM_string";
246
+ case DW_FORM_block:
247
+ return "DW_FORM_block";
248
+ case DW_FORM_block1:
249
+ return "DW_FORM_block1";
250
+ case DW_FORM_data1:
251
+ return "DW_FORM_data1";
252
+ case DW_FORM_flag:
253
+ return "DW_FORM_flag";
254
+ case DW_FORM_sdata:
255
+ return "DW_FORM_sdata";
256
+ case DW_FORM_strp:
257
+ return "DW_FORM_strp";
258
+ case DW_FORM_udata:
259
+ return "DW_FORM_udata";
260
+ case DW_FORM_ref_addr:
261
+ return "DW_FORM_ref_addr";
262
+ case DW_FORM_ref1:
263
+ return "DW_FORM_ref1";
264
+ case DW_FORM_ref2:
265
+ return "DW_FORM_ref2";
266
+ case DW_FORM_ref4:
267
+ return "DW_FORM_ref4";
268
+ case DW_FORM_ref8:
269
+ return "DW_FORM_ref8";
270
+ case DW_FORM_ref_udata:
271
+ return "DW_FORM_ref_udata";
272
+ case DW_FORM_indirect:
273
+ return "DW_FORM_indirect";
274
+ //case DW_FORM_APPLE_db_str:
275
+ // return "DW_FORM_APPLE_db_str";
276
+ default:
277
+ return "DW_FORM_<unknown>";
278
+ }
279
+ }
280
+
281
+ /* Convert a DIE tag into its string name. */
282
+
283
+ const char * dwarf_tag_name (unsigned tag)
284
+ {
285
+ switch (tag)
286
+ {
287
+ case DW_TAG_padding:
288
+ return "DW_TAG_padding";
289
+ case DW_TAG_array_type:
290
+ return "DW_TAG_array_type";
291
+ case DW_TAG_class_type:
292
+ return "DW_TAG_class_type";
293
+ case DW_TAG_entry_point:
294
+ return "DW_TAG_entry_point";
295
+ case DW_TAG_enumeration_type:
296
+ return "DW_TAG_enumeration_type";
297
+ case DW_TAG_formal_parameter:
298
+ return "DW_TAG_formal_parameter";
299
+ case DW_TAG_imported_declaration:
300
+ return "DW_TAG_imported_declaration";
301
+ case DW_TAG_label:
302
+ return "DW_TAG_label";
303
+ case DW_TAG_lexical_block:
304
+ return "DW_TAG_lexical_block";
305
+ case DW_TAG_member:
306
+ return "DW_TAG_member";
307
+ case DW_TAG_pointer_type:
308
+ return "DW_TAG_pointer_type";
309
+ case DW_TAG_reference_type:
310
+ return "DW_TAG_reference_type";
311
+ case DW_TAG_compile_unit:
312
+ return "DW_TAG_compile_unit";
313
+ case DW_TAG_string_type:
314
+ return "DW_TAG_string_type";
315
+ case DW_TAG_structure_type:
316
+ return "DW_TAG_structure_type";
317
+ case DW_TAG_subroutine_type:
318
+ return "DW_TAG_subroutine_type";
319
+ case DW_TAG_typedef:
320
+ return "DW_TAG_typedef";
321
+ case DW_TAG_union_type:
322
+ return "DW_TAG_union_type";
323
+ case DW_TAG_unspecified_parameters:
324
+ return "DW_TAG_unspecified_parameters";
325
+ case DW_TAG_variant:
326
+ return "DW_TAG_variant";
327
+ case DW_TAG_common_block:
328
+ return "DW_TAG_common_block";
329
+ case DW_TAG_common_inclusion:
330
+ return "DW_TAG_common_inclusion";
331
+ case DW_TAG_inheritance:
332
+ return "DW_TAG_inheritance";
333
+ case DW_TAG_inlined_subroutine:
334
+ return "DW_TAG_inlined_subroutine";
335
+ case DW_TAG_module:
336
+ return "DW_TAG_module";
337
+ case DW_TAG_ptr_to_member_type:
338
+ return "DW_TAG_ptr_to_member_type";
339
+ case DW_TAG_set_type:
340
+ return "DW_TAG_set_type";
341
+ case DW_TAG_subrange_type:
342
+ return "DW_TAG_subrange_type";
343
+ case DW_TAG_with_stmt:
344
+ return "DW_TAG_with_stmt";
345
+ case DW_TAG_access_declaration:
346
+ return "DW_TAG_access_declaration";
347
+ case DW_TAG_base_type:
348
+ return "DW_TAG_base_type";
349
+ case DW_TAG_catch_block:
350
+ return "DW_TAG_catch_block";
351
+ case DW_TAG_const_type:
352
+ return "DW_TAG_const_type";
353
+ case DW_TAG_constant:
354
+ return "DW_TAG_constant";
355
+ case DW_TAG_enumerator:
356
+ return "DW_TAG_enumerator";
357
+ case DW_TAG_file_type:
358
+ return "DW_TAG_file_type";
359
+ case DW_TAG_friend:
360
+ return "DW_TAG_friend";
361
+ case DW_TAG_namelist:
362
+ return "DW_TAG_namelist";
363
+ case DW_TAG_namelist_item:
364
+ return "DW_TAG_namelist_item";
365
+ case DW_TAG_packed_type:
366
+ return "DW_TAG_packed_type";
367
+ case DW_TAG_subprogram:
368
+ return "DW_TAG_subprogram";
369
+ case DW_TAG_template_type_param:
370
+ return "DW_TAG_template_type_param";
371
+ case DW_TAG_template_value_param:
372
+ return "DW_TAG_template_value_param";
373
+ case DW_TAG_thrown_type:
374
+ return "DW_TAG_thrown_type";
375
+ case DW_TAG_try_block:
376
+ return "DW_TAG_try_block";
377
+ case DW_TAG_variant_part:
378
+ return "DW_TAG_variant_part";
379
+ case DW_TAG_variable:
380
+ return "DW_TAG_variable";
381
+ case DW_TAG_volatile_type:
382
+ return "DW_TAG_volatile_type";
383
+ case DW_TAG_dwarf_procedure:
384
+ return "DW_TAG_dwarf_procedure";
385
+ case DW_TAG_restrict_type:
386
+ return "DW_TAG_restrict_type";
387
+ case DW_TAG_interface_type:
388
+ return "DW_TAG_interface_type";
389
+ case DW_TAG_namespace:
390
+ return "DW_TAG_namespace";
391
+ case DW_TAG_imported_module:
392
+ return "DW_TAG_imported_module";
393
+ case DW_TAG_unspecified_type:
394
+ return "DW_TAG_unspecified_type";
395
+ case DW_TAG_partial_unit:
396
+ return "DW_TAG_partial_unit";
397
+ case DW_TAG_imported_unit:
398
+ return "DW_TAG_imported_unit";
399
+ case DW_TAG_MIPS_loop:
400
+ return "DW_TAG_MIPS_loop";
401
+ case DW_TAG_format_label:
402
+ return "DW_TAG_format_label";
403
+ case DW_TAG_function_template:
404
+ return "DW_TAG_function_template";
405
+ case DW_TAG_class_template:
406
+ return "DW_TAG_class_template";
407
+ default:
408
+ return "DW_TAG_<unknown>";
409
+ }
410
+ }
411
+