97 #endif |
97 #endif |
98 decode_instructions_virtual(uintptr_t start_va, uintptr_t end_va, |
98 decode_instructions_virtual(uintptr_t start_va, uintptr_t end_va, |
99 unsigned char* buffer, uintptr_t length, |
99 unsigned char* buffer, uintptr_t length, |
100 event_callback_t event_callback_arg, void* event_stream_arg, |
100 event_callback_t event_callback_arg, void* event_stream_arg, |
101 printf_callback_t printf_callback_arg, void* printf_stream_arg, |
101 printf_callback_t printf_callback_arg, void* printf_stream_arg, |
102 const char* options) { |
102 const char* options, int newline) { |
103 struct hsdis_app_data app_data; |
103 struct hsdis_app_data app_data; |
104 memset(&app_data, 0, sizeof(app_data)); |
104 memset(&app_data, 0, sizeof(app_data)); |
105 app_data.start_va = start_va; |
105 app_data.start_va = start_va; |
106 app_data.end_va = end_va; |
106 app_data.end_va = end_va; |
107 app_data.buffer = buffer; |
107 app_data.buffer = buffer; |
108 app_data.length = length; |
108 app_data.length = length; |
109 app_data.event_callback = event_callback_arg; |
109 app_data.event_callback = event_callback_arg; |
110 app_data.event_stream = event_stream_arg; |
110 app_data.event_stream = event_stream_arg; |
111 app_data.printf_callback = printf_callback_arg; |
111 app_data.printf_callback = printf_callback_arg; |
112 app_data.printf_stream = printf_stream_arg; |
112 app_data.printf_stream = printf_stream_arg; |
113 app_data.do_newline = false; |
113 app_data.do_newline = newline == 0 ? false : true; |
114 |
114 |
115 return decode(&app_data, options); |
115 return decode(&app_data, options); |
116 } |
116 } |
117 |
117 |
118 /* This is the compatability interface for older version of hotspot */ |
118 /* This is the compatability interface for older version of hotspot */ |
171 else app_data->losing = true; |
171 else app_data->losing = true; |
172 |
172 |
173 if (!app_data->losing) { |
173 if (!app_data->losing) { |
174 const char* insn_close = format_insn_close("/insn", &app_data->dinfo, |
174 const char* insn_close = format_insn_close("/insn", &app_data->dinfo, |
175 buf, sizeof(buf)); |
175 buf, sizeof(buf)); |
176 (*event_callback)(event_stream, insn_close, (void*) p) != NULL; |
176 (*event_callback)(event_stream, insn_close, (void*) p); |
177 |
177 |
178 if (app_data->do_newline) { |
178 if (app_data->do_newline) { |
179 /* follow each complete insn by a nice newline */ |
179 /* follow each complete insn by a nice newline */ |
180 (*printf_callback)(printf_stream, "\n"); |
180 (*printf_callback)(printf_stream, "\n"); |
181 } |
181 } |
182 } |
182 } |
183 } |
183 } |
184 |
184 |
185 (*event_callback)(event_stream, "/insns", (void*) p); |
185 if (app_data->losing) (*event_callback)(event_stream, "/insns", (void*) p); |
186 return (void*) p; |
186 return (void*) p; |
187 } |
187 } |
188 } |
188 } |
189 |
189 |
190 /* take the address of the function, for luck, and also test the typedef: */ |
190 /* take the address of the function, for luck, and also test the typedef: */ |
191 const decode_instructions_ftype decode_instructions_address = &decode_instructions_virtual; |
191 const decode_func_vtype decode_func_virtual_address = &decode_instructions_virtual; |
|
192 const decode_func_stype decode_func_address = &decode_instructions; |
192 |
193 |
193 static const char* format_insn_close(const char* close, |
194 static const char* format_insn_close(const char* close, |
194 disassemble_info* dinfo, |
195 disassemble_info* dinfo, |
195 char* buf, size_t bufsize) { |
196 char* buf, size_t bufsize) { |
196 if (!dinfo->insn_info_valid) |
197 if (!dinfo->insn_info_valid) |