src/share/tools/hsdis/hsdis.c
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File sadis Cdiff src/share/tools/hsdis/hsdis.c

src/share/tools/hsdis/hsdis.c

Print this page

        

*** 26,41 **** This implements the plugin protocol required by the HotSpot PrintAssembly option. */ #include "hsdis.h" - - #include <sysdep.h> #include <libiberty.h> #include <bfd.h> #include <dis-asm.h> #include <inttypes.h> #ifndef bool #define bool int #define true 1 #define false 0 --- 26,41 ---- This implements the plugin protocol required by the HotSpot PrintAssembly option. */ #include "hsdis.h" #include <libiberty.h> #include <bfd.h> #include <dis-asm.h> #include <inttypes.h> + #include <string.h> + #include <errno.h> #ifndef bool #define bool int #define true 1 #define false 0
*** 45,54 **** --- 45,55 ---- typedef decode_instructions_event_callback_ftype event_callback_t; typedef decode_instructions_printf_callback_ftype printf_callback_t; /* disassemble_info.application_data object */ struct hsdis_app_data { + uintptr_t start_va, end_va; /* virtual address of data */ /* the arguments to decode_instructions */ uintptr_t start; uintptr_t end; event_callback_t event_callback; void* event_stream; printf_callback_t printf_callback; void* printf_stream; bool losing;
*** 87,104 **** void* #ifdef DLL_ENTRY DLL_ENTRY #endif ! decode_instructions(void* start_pv, void* end_pv, event_callback_t event_callback_arg, void* event_stream_arg, printf_callback_t printf_callback_arg, void* printf_stream_arg, const char* options) { struct hsdis_app_data app_data; memset(&app_data, 0, sizeof(app_data)); app_data.start = (uintptr_t) start_pv; app_data.end = (uintptr_t) end_pv; app_data.event_callback = event_callback_arg; app_data.event_stream = event_stream_arg; app_data.printf_callback = printf_callback_arg; app_data.printf_stream = printf_stream_arg; --- 88,108 ---- void* #ifdef DLL_ENTRY DLL_ENTRY #endif ! decode_instructions_virtual(void* start_va, ! void* start_pv, void* end_pv, event_callback_t event_callback_arg, void* event_stream_arg, printf_callback_t printf_callback_arg, void* printf_stream_arg, const char* options) { struct hsdis_app_data app_data; memset(&app_data, 0, sizeof(app_data)); app_data.start = (uintptr_t) start_pv; app_data.end = (uintptr_t) end_pv; + app_data.start_va = (uintptr_t) start_va; + app_data.end_va = app_data.start_va + app_data.end - app_data.start; app_data.event_callback = event_callback_arg; app_data.event_stream = event_stream_arg; app_data.printf_callback = printf_callback_arg; app_data.printf_stream = printf_stream_arg;
*** 107,118 **** { /* now reload everything from app_data: */ DECL_EVENT_CALLBACK(&app_data); DECL_PRINTF_CALLBACK(&app_data); ! uintptr_t start = app_data.start; ! uintptr_t end = app_data.end; uintptr_t p = start; (*event_callback)(event_stream, "insns", (void*)start); (*event_callback)(event_stream, "mach name='%s'", --- 111,122 ---- { /* now reload everything from app_data: */ DECL_EVENT_CALLBACK(&app_data); DECL_PRINTF_CALLBACK(&app_data); ! uintptr_t start = app_data.start_va; ! uintptr_t end = app_data.end_va; uintptr_t p = start; (*event_callback)(event_stream, "insns", (void*)start); (*event_callback)(event_stream, "mach name='%s'",
*** 147,156 **** --- 151,174 ---- (*event_callback)(event_stream, "/insns", (void*) p); return (void*) p; } } + void* + #ifdef DLL_ENTRY + DLL_ENTRY + #endif + decode_instructions(void* start_pv, void* end_pv, + event_callback_t event_callback_arg, void* event_stream_arg, + printf_callback_t printf_callback_arg, void* printf_stream_arg, + const char* options) { + return decode_instructions_virtual(start_pv, start_pv, end_pv, + event_callback_arg, event_stream_arg, + printf_callback_arg, printf_stream_arg, + options); + } + /* take the address of the function, for luck, and also test the typedef: */ const decode_instructions_ftype decode_instructions_address = &decode_instructions; static const char* format_insn_close(const char* close, disassemble_info* dinfo,
*** 187,198 **** static int hsdis_read_memory_func(bfd_vma memaddr, bfd_byte* myaddr, unsigned int length, struct disassemble_info* dinfo) { - uintptr_t memaddr_p = (uintptr_t) memaddr; DECL_APP_DATA(dinfo); if (memaddr_p + length > app_data->end) { /* read is out of bounds */ return EIO; } else { memcpy(myaddr, (bfd_byte*) memaddr_p, length); --- 205,217 ---- static int hsdis_read_memory_func(bfd_vma memaddr, bfd_byte* myaddr, unsigned int length, struct disassemble_info* dinfo) { DECL_APP_DATA(dinfo); + // convert the virtual address membar into an address within memory buffer + uintptr_t memaddr_p = ((uintptr_t) memaddr) - app_data->start_va + app_data->start; if (memaddr_p + length > app_data->end) { /* read is out of bounds */ return EIO; } else { memcpy(myaddr, (bfd_byte*) memaddr_p, length);
src/share/tools/hsdis/hsdis.c
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File