1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/crashreporter/google-breakpad/src/third_party/libdisasm/x86_misc.c Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,71 @@ 1.4 +#include <stdio.h> 1.5 +#include <stdlib.h> 1.6 +#include <string.h> 1.7 + 1.8 +#include "libdis.h" 1.9 +#include "ia32_insn.h" 1.10 +#include "ia32_reg.h" /* for ia32_reg wrapper */ 1.11 +#include "ia32_settings.h" 1.12 +extern ia32_settings_t ia32_settings; 1.13 + 1.14 +#ifdef _MSC_VER 1.15 + #define snprintf _snprintf 1.16 + #define inline __inline 1.17 +#endif 1.18 + 1.19 + 1.20 +/* =========================================================== INIT/TERM */ 1.21 +static DISASM_REPORTER __x86_reporter_func = NULL; 1.22 +static void * __x86_reporter_arg = NULL; 1.23 + 1.24 +int x86_init( enum x86_options options, DISASM_REPORTER reporter, void * arg ) 1.25 +{ 1.26 + ia32_settings.options = options; 1.27 + __x86_reporter_func = reporter; 1.28 + __x86_reporter_arg = arg; 1.29 + 1.30 + return 1; 1.31 +} 1.32 + 1.33 +void x86_set_reporter( DISASM_REPORTER reporter, void * arg ) { 1.34 + __x86_reporter_func = reporter; 1.35 + __x86_reporter_arg = arg; 1.36 +} 1.37 + 1.38 +void x86_set_options( enum x86_options options ){ 1.39 + ia32_settings.options = options; 1.40 +} 1.41 + 1.42 +enum x86_options x86_get_options( void ) { 1.43 + return ia32_settings.options; 1.44 +} 1.45 + 1.46 +int x86_cleanup( void ) 1.47 +{ 1.48 + return 1; 1.49 +} 1.50 + 1.51 +/* =========================================================== ERRORS */ 1.52 +void x86_report_error( enum x86_report_codes code, void *data ) { 1.53 + if ( __x86_reporter_func ) { 1.54 + (*__x86_reporter_func)(code, data, __x86_reporter_arg); 1.55 + } 1.56 +} 1.57 + 1.58 + 1.59 +/* =========================================================== MISC */ 1.60 +unsigned int x86_endian(void) { return ia32_settings.endian; } 1.61 +unsigned int x86_addr_size(void) { return ia32_settings.sz_addr; } 1.62 +unsigned int x86_op_size(void) { return ia32_settings.sz_oper; } 1.63 +unsigned int x86_word_size(void) { return ia32_settings.sz_word; } 1.64 +unsigned int x86_max_insn_size(void) { return ia32_settings.max_insn; } 1.65 +unsigned int x86_sp_reg(void) { return ia32_settings.id_sp_reg; } 1.66 +unsigned int x86_fp_reg(void) { return ia32_settings.id_fp_reg; } 1.67 +unsigned int x86_ip_reg(void) { return ia32_settings.id_ip_reg; } 1.68 +unsigned int x86_flag_reg(void) { return ia32_settings.id_flag_reg; } 1.69 + 1.70 +/* wrapper function to hide the IA32 register fn */ 1.71 +void x86_reg_from_id( unsigned int id, x86_reg_t * reg ) { 1.72 + ia32_handle_register( reg, id ); 1.73 + return; 1.74 +}