comparison src/share/tools/hsdis/hsdis.c @ 23352:3848113e3e6b

Update hsdis binaries
author Tom Rodriguez <tom.rodriguez@oracle.com>
date Tue, 19 Apr 2016 23:28:22 -0700
parents 52b4284cb496
children
comparison
equal deleted inserted replaced
23351:1c62a8bac25a 23352:3848113e3e6b
68 68
69 char mach_option[64]; 69 char mach_option[64];
70 char insn_options[256]; 70 char insn_options[256];
71 }; 71 };
72 72
73 #if defined(LIBARCH_i386) || defined(LIBARCH_amd64)
74 #ifdef ATT_SYNTAX
75 #define PLATFORM_OPTIONS "att"
76 #else
77 #define PLATFORM_OPTIONS "intel"
78 #endif
79 #else
80 #define PLATFORM_OPTIONS ""
81 #endif
82 static const char* platform_options = PLATFORM_OPTIONS;
83
84 const char* hsdis_version_string = "built from " BINUTILS " with disassembler options \"" PLATFORM_OPTIONS "\" on " __DATE__ " at " __TIME__;
85
73 static void* decode(struct hsdis_app_data* app_data, const char* options); 86 static void* decode(struct hsdis_app_data* app_data, const char* options);
74 87
75 #define DECL_APP_DATA(dinfo) \ 88 #define DECL_APP_DATA(dinfo) \
76 struct hsdis_app_data* app_data = (struct hsdis_app_data*) (dinfo)->application_data 89 struct hsdis_app_data* app_data = (struct hsdis_app_data*) (dinfo)->application_data
77 90
123 #endif 136 #endif
124 decode_instructions(void* start_pv, void* end_pv, 137 decode_instructions(void* start_pv, void* end_pv,
125 event_callback_t event_callback_arg, void* event_stream_arg, 138 event_callback_t event_callback_arg, void* event_stream_arg,
126 printf_callback_t printf_callback_arg, void* printf_stream_arg, 139 printf_callback_t printf_callback_arg, void* printf_stream_arg,
127 const char* options) { 140 const char* options) {
128 decode_instructions_virtual((uintptr_t)start_pv, 141 return decode_instructions_virtual((uintptr_t)start_pv,
129 (uintptr_t)end_pv, 142 (uintptr_t)end_pv,
130 (unsigned char*)start_pv, 143 (unsigned char*)start_pv,
131 (uintptr_t)end_pv - (uintptr_t)start_pv, 144 (uintptr_t)end_pv - (uintptr_t)start_pv,
132 event_callback_arg, 145 event_callback_arg,
133 event_stream_arg, 146 event_stream_arg,
148 uintptr_t end = app_data->end_va; 161 uintptr_t end = app_data->end_va;
149 uintptr_t p = start; 162 uintptr_t p = start;
150 163
151 (*event_callback)(event_stream, "insns", (void*)start); 164 (*event_callback)(event_stream, "insns", (void*)start);
152 165
166 (*event_callback)(event_stream, "options='%s'",
167 (void*) app_data->insn_options);
153 (*event_callback)(event_stream, "mach name='%s'", 168 (*event_callback)(event_stream, "mach name='%s'",
154 (void*) app_data->arch_info->printable_name); 169 (void*) app_data->arch_info->printable_name);
155 if (app_data->dinfo.bytes_per_line != 0) { 170 if (app_data->dinfo.bytes_per_line != 0) {
156 (*event_callback)(event_stream, "format bytes-per-line='%p'/", 171 (*event_callback)(event_stream, "format bytes-per-line='%p'/",
157 (void*)(intptr_t) app_data->dinfo.bytes_per_line); 172 (void*)(intptr_t) app_data->dinfo.bytes_per_line);
203 || (strlen(close) + 3*20 > bufsize)) 218 || (strlen(close) + 3*20 > bufsize))
204 return close; 219 return close;
205 220
206 const char* type = "unknown"; 221 const char* type = "unknown";
207 switch (itype) { 222 switch (itype) {
223 case dis_noninsn:
208 case dis_nonbranch: type = NULL; break; 224 case dis_nonbranch: type = NULL; break;
209 case dis_branch: type = "branch"; break; 225 case dis_branch: type = "branch"; break;
210 case dis_condbranch: type = "condbranch"; break; 226 case dis_condbranch: type = "condbranch"; break;
211 case dis_jsr: type = "jsr"; break; 227 case dis_jsr: type = "jsr"; break;
212 case dis_condjsr: type = "condjsr"; break; 228 case dis_condjsr: type = "condjsr"; break;
283 A non-null stream for a null callback is assumed to be a FILE* for output. 299 A non-null stream for a null callback is assumed to be a FILE* for output.
284 Events are rendered as XML. 300 Events are rendered as XML.
285 */ 301 */
286 set_optional_callbacks(app_data); 302 set_optional_callbacks(app_data);
287 303
304 memset(app_data->insn_options, 0, sizeof(app_data->insn_options));
305 if (platform_options != NULL) {
306 parse_caller_options(app_data, platform_options);
307 }
288 /* Look into caller_options for anything interesting. */ 308 /* Look into caller_options for anything interesting. */
289 if (caller_options != NULL) 309 if (caller_options != NULL) {
290 parse_caller_options(app_data, caller_options); 310 parse_caller_options(app_data, caller_options);
311 }
291 312
292 /* Discover which architecture we are going to disassemble. */ 313 /* Discover which architecture we are going to disassemble. */
293 app_data->arch_name = &app_data->mach_option[0]; 314 app_data->arch_name = &app_data->mach_option[0];
294 if (app_data->arch_name[0] == '\0') 315 if (app_data->arch_name[0] == '\0')
295 app_data->arch_name = native_arch_name(); 316 app_data->arch_name = native_arch_name();
383 404
384 static void parse_caller_options(struct hsdis_app_data* app_data, const char* caller_options) { 405 static void parse_caller_options(struct hsdis_app_data* app_data, const char* caller_options) {
385 char* iop_base = app_data->insn_options; 406 char* iop_base = app_data->insn_options;
386 char* iop_limit = iop_base + sizeof(app_data->insn_options) - 1; 407 char* iop_limit = iop_base + sizeof(app_data->insn_options) - 1;
387 char* iop = iop_base; 408 char* iop = iop_base;
409
410 // Move to the end of any options already in the buffer
411 while (*iop != '\0' && iop < iop_limit) {
412 iop++;
413 }
388 const char* p; 414 const char* p;
389 for (p = caller_options; p != NULL; ) { 415 for (p = caller_options; p != NULL; ) {
390 const char* q = strchr(p, ','); 416 const char* q = strchr(p, ',');
391 size_t plen = (q == NULL) ? strlen(p) : ((q++) - p); 417 size_t plen = (q == NULL) ? strlen(p) : ((q++) - p);
392 if (plen == 4 && strncmp(p, "help", plen) == 0) { 418 if (plen == 4 && strncmp(p, "help", plen) == 0) {