gdb/gdbserver/ax.h - gdb

Data types defined

Macros defined

Source code

  1. /* Data structures and functions associated with agent expressions in GDB.
  2.    Copyright (C) 2009-2015 Free Software Foundation, Inc.

  3.    This file is part of GDB.

  4.    This program is free software; you can redistribute it and/or modify
  5.    it under the terms of the GNU General Public License as published by
  6.    the Free Software Foundation; either version 3 of the License, or
  7.    (at your option) any later version.

  8.    This program is distributed in the hope that it will be useful,
  9.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  10.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  11.    GNU General Public License for more details.

  12.    You should have received a copy of the GNU General Public License
  13.    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */

  14. #if !defined (AX_H)
  15. #define AX_H 1

  16. #include "regcache.h"

  17. #ifdef IN_PROCESS_AGENT
  18. extern int debug_agent;
  19. #define debug_threads debug_agent
  20. #endif

  21. struct traceframe;

  22. /* Enumeration of the different kinds of things that can happen during
  23.    agent expression evaluation.  */

  24. enum eval_result_type
  25.   {
  26.     expr_eval_no_error,
  27.     expr_eval_empty_expression,
  28.     expr_eval_empty_stack,
  29.     expr_eval_stack_overflow,
  30.     expr_eval_stack_underflow,
  31.     expr_eval_unhandled_opcode,
  32.     expr_eval_unrecognized_opcode,
  33.     expr_eval_divide_by_zero,
  34.     expr_eval_invalid_goto
  35.   };

  36. struct agent_expr
  37. {
  38.   int length;

  39.   unsigned char *bytes;
  40. };

  41. #ifndef IN_PROCESS_AGENT

  42. /* The packet form of an agent expression consists of an 'X', number
  43.    of bytes in expression, a comma, and then the bytes.  */
  44. struct agent_expr *gdb_parse_agent_expr (char **actparm);

  45. /* Release an agent expression.  */
  46. void gdb_free_agent_expr (struct agent_expr *aexpr);

  47. /* Convert the bytes of an agent expression back into hex digits, so
  48.    they can be printed or uploaded.  This allocates the buffer,
  49.    callers should free when they are done with it.  */
  50. char *gdb_unparse_agent_expr (struct agent_expr *aexpr);
  51. void emit_prologue (void);
  52. void emit_epilogue (void);
  53. enum eval_result_type compile_bytecodes (struct agent_expr *aexpr);
  54. #endif

  55. /* The context when evaluating agent expression.  */

  56. struct eval_agent_expr_context
  57. {
  58.   /* The registers when evaluating agent expression.  */
  59.   struct regcache *regcache;
  60.   /* The traceframe, if any, when evaluating agent expression.  */
  61.   struct traceframe *tframe;
  62.   /* The tracepoint, if any, when evaluating agent expression.  */
  63.   struct tracepoint *tpoint;
  64. };

  65. enum eval_result_type
  66.   gdb_eval_agent_expr (struct eval_agent_expr_context *ctx,
  67.                        struct agent_expr *aexpr,
  68.                        ULONGEST *rslt);

  69. /* Bytecode compilation function vector.  */

  70. struct emit_ops
  71. {
  72.   void (*emit_prologue) (void);
  73.   void (*emit_epilogue) (void);
  74.   void (*emit_add) (void);
  75.   void (*emit_sub) (void);
  76.   void (*emit_mul) (void);
  77.   void (*emit_lsh) (void);
  78.   void (*emit_rsh_signed) (void);
  79.   void (*emit_rsh_unsigned) (void);
  80.   void (*emit_ext) (int arg);
  81.   void (*emit_log_not) (void);
  82.   void (*emit_bit_and) (void);
  83.   void (*emit_bit_or) (void);
  84.   void (*emit_bit_xor) (void);
  85.   void (*emit_bit_not) (void);
  86.   void (*emit_equal) (void);
  87.   void (*emit_less_signed) (void);
  88.   void (*emit_less_unsigned) (void);
  89.   void (*emit_ref) (int size);
  90.   void (*emit_if_goto) (int *offset_p, int *size_p);
  91.   void (*emit_goto) (int *offset_p, int *size_p);
  92.   void (*write_goto_address) (CORE_ADDR from, CORE_ADDR to, int size);
  93.   void (*emit_const) (LONGEST num);
  94.   void (*emit_call) (CORE_ADDR fn);
  95.   void (*emit_reg) (int reg);
  96.   void (*emit_pop) (void);
  97.   void (*emit_stack_flush) (void);
  98.   void (*emit_zero_ext) (int arg);
  99.   void (*emit_swap) (void);
  100.   void (*emit_stack_adjust) (int n);

  101.   /* Emit code for a generic function that takes one fixed integer
  102.      argument and returns a 64-bit int (for instance, tsv getter).  */
  103.   void (*emit_int_call_1) (CORE_ADDR fn, int arg1);

  104.   /* Emit code for a generic function that takes one fixed integer
  105.      argument and a 64-bit int from the top of the stack, and returns
  106.      nothing (for instance, tsv setter).  */
  107.   void (*emit_void_call_2) (CORE_ADDR fn, int arg1);

  108.   /* Emit code specialized for common combinations of compare followed
  109.      by a goto.  */
  110.   void (*emit_eq_goto) (int *offset_p, int *size_p);
  111.   void (*emit_ne_goto) (int *offset_p, int *size_p);
  112.   void (*emit_lt_goto) (int *offset_p, int *size_p);
  113.   void (*emit_le_goto) (int *offset_p, int *size_p);
  114.   void (*emit_gt_goto) (int *offset_p, int *size_p);
  115.   void (*emit_ge_goto) (int *offset_p, int *size_p);
  116. };

  117. extern CORE_ADDR current_insn_ptr;
  118. extern int emit_error;

  119. #endif /* AX_H */