GDBserver
|
00001 /* Data structures and functions associated with agent expressions in GDB. 00002 Copyright (C) 2009-2013 Free Software Foundation, Inc. 00003 00004 This file is part of GDB. 00005 00006 This program is free software; you can redistribute it and/or modify 00007 it under the terms of the GNU General Public License as published by 00008 the Free Software Foundation; either version 3 of the License, or 00009 (at your option) any later version. 00010 00011 This program is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 GNU General Public License for more details. 00015 00016 You should have received a copy of the GNU General Public License 00017 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 00018 00019 #if !defined (AX_H) 00020 #define AX_H 1 00021 00022 #include "server.h" 00023 #include "regcache.h" 00024 00025 #ifdef IN_PROCESS_AGENT 00026 extern int debug_agent; 00027 #define debug_threads debug_agent 00028 #endif 00029 00030 struct traceframe; 00031 00032 /* Enumeration of the different kinds of things that can happen during 00033 agent expression evaluation. */ 00034 00035 enum eval_result_type 00036 { 00037 expr_eval_no_error, 00038 expr_eval_empty_expression, 00039 expr_eval_empty_stack, 00040 expr_eval_stack_overflow, 00041 expr_eval_stack_underflow, 00042 expr_eval_unhandled_opcode, 00043 expr_eval_unrecognized_opcode, 00044 expr_eval_divide_by_zero, 00045 expr_eval_invalid_goto 00046 }; 00047 00048 struct agent_expr 00049 { 00050 int length; 00051 00052 unsigned char *bytes; 00053 }; 00054 00055 #ifndef IN_PROCESS_AGENT 00056 00057 /* The packet form of an agent expression consists of an 'X', number 00058 of bytes in expression, a comma, and then the bytes. */ 00059 struct agent_expr *gdb_parse_agent_expr (char **actparm); 00060 00061 /* Convert the bytes of an agent expression back into hex digits, so 00062 they can be printed or uploaded. This allocates the buffer, 00063 callers should free when they are done with it. */ 00064 char *gdb_unparse_agent_expr (struct agent_expr *aexpr); 00065 void emit_prologue (void); 00066 void emit_epilogue (void); 00067 enum eval_result_type compile_bytecodes (struct agent_expr *aexpr); 00068 #endif 00069 00070 /* The context when evaluating agent expression. */ 00071 00072 struct eval_agent_expr_context 00073 { 00074 /* The registers when evaluating agent expression. */ 00075 struct regcache *regcache; 00076 /* The traceframe, if any, when evaluating agent expression. */ 00077 struct traceframe *tframe; 00078 /* The tracepoint, if any, when evaluating agent expression. */ 00079 struct tracepoint *tpoint; 00080 }; 00081 00082 enum eval_result_type 00083 gdb_eval_agent_expr (struct eval_agent_expr_context *ctx, 00084 struct agent_expr *aexpr, 00085 ULONGEST *rslt); 00086 00087 /* Bytecode compilation function vector. */ 00088 00089 struct emit_ops 00090 { 00091 void (*emit_prologue) (void); 00092 void (*emit_epilogue) (void); 00093 void (*emit_add) (void); 00094 void (*emit_sub) (void); 00095 void (*emit_mul) (void); 00096 void (*emit_lsh) (void); 00097 void (*emit_rsh_signed) (void); 00098 void (*emit_rsh_unsigned) (void); 00099 void (*emit_ext) (int arg); 00100 void (*emit_log_not) (void); 00101 void (*emit_bit_and) (void); 00102 void (*emit_bit_or) (void); 00103 void (*emit_bit_xor) (void); 00104 void (*emit_bit_not) (void); 00105 void (*emit_equal) (void); 00106 void (*emit_less_signed) (void); 00107 void (*emit_less_unsigned) (void); 00108 void (*emit_ref) (int size); 00109 void (*emit_if_goto) (int *offset_p, int *size_p); 00110 void (*emit_goto) (int *offset_p, int *size_p); 00111 void (*write_goto_address) (CORE_ADDR from, CORE_ADDR to, int size); 00112 void (*emit_const) (LONGEST num); 00113 void (*emit_call) (CORE_ADDR fn); 00114 void (*emit_reg) (int reg); 00115 void (*emit_pop) (void); 00116 void (*emit_stack_flush) (void); 00117 void (*emit_zero_ext) (int arg); 00118 void (*emit_swap) (void); 00119 void (*emit_stack_adjust) (int n); 00120 00121 /* Emit code for a generic function that takes one fixed integer 00122 argument and returns a 64-bit int (for instance, tsv getter). */ 00123 void (*emit_int_call_1) (CORE_ADDR fn, int arg1); 00124 00125 /* Emit code for a generic function that takes one fixed integer 00126 argument and a 64-bit int from the top of the stack, and returns 00127 nothing (for instance, tsv setter). */ 00128 void (*emit_void_call_2) (CORE_ADDR fn, int arg1); 00129 00130 /* Emit code specialized for common combinations of compare followed 00131 by a goto. */ 00132 void (*emit_eq_goto) (int *offset_p, int *size_p); 00133 void (*emit_ne_goto) (int *offset_p, int *size_p); 00134 void (*emit_lt_goto) (int *offset_p, int *size_p); 00135 void (*emit_le_goto) (int *offset_p, int *size_p); 00136 void (*emit_gt_goto) (int *offset_p, int *size_p); 00137 void (*emit_ge_goto) (int *offset_p, int *size_p); 00138 }; 00139 00140 extern CORE_ADDR current_insn_ptr; 00141 extern int emit_error; 00142 00143 #endif /* AX_H */