GDBserver

Classes | Macros | Enumerations | Functions | Variables
ax.c File Reference
`#include "server.h"`
`#include "ax.h"`
`#include "format.h"`
`#include "tracepoint.h"`
`#include "rsp-low.h"`
`#include "ax.def"`

Go to the source code of this file.

## Classes
struct | bytecode_address

## Macros
#define | ax_debug_1(level, fmt, args...)
#define | ax_debug(FMT, args...) ax_debug_1 (1, FMT, ##args)
#define | DEFOP(NAME, SIZE, DATA_SIZE, CONSUMED, PRODUCED, VALUE) gdb_agent_op_ ## NAME = VALUE,
#define | DEFOP(NAME, SIZE, DATA_SIZE, CONSUMED, PRODUCED, VALUE) , # NAME
#define | DEFOP(NAME, SIZE, DATA_SIZE, CONSUMED, PRODUCED, VALUE) , SIZE
#define | UNHANDLED
#define | STACK_MAX 100

## Enumerations
enum | gdb_agent_op { gdb_agent_op_last }

## Functions
static void | ax_vdebug (const char *,...)
static const char * | gdb_agent_op_name (int op)
struct agent_expr * | gdb_parse_agent_expr (const char **actparm)
void | gdb_free_agent_expr (struct agent_expr *aexpr)
char * | gdb_unparse_agent_expr (struct agent_expr *aexpr)
void | emit_prologue (void)
void | emit_epilogue (void)
static void | emit_add (void)
static void | emit_sub (void)
static void | emit_mul (void)
static void | emit_lsh (void)
static void | emit_rsh_signed (void)
static void | emit_rsh_unsigned (void)
static void | emit_ext (int arg)
static void | emit_log_not (void)
static void | emit_bit_and (void)
static void | emit_bit_or (void)
static void | emit_bit_xor (void)
static void | emit_bit_not (void)
static void | emit_equal (void)
static void | emit_less_signed (void)
static void | emit_less_unsigned (void)
static void | emit_ref (int size)
static void | emit_if_goto (int *offset_p, int *size_p)
static void | emit_goto (int *offset_p, int *size_p)
static void | write_goto_address (CORE_ADDR from, CORE_ADDR to, int size)
static void | emit_const (LONGEST num)
static void | emit_reg (int reg)
static void | emit_pop (void)
static void | emit_stack_flush (void)
static void | emit_zero_ext (int arg)
static void | emit_swap (void)
static void | emit_stack_adjust (int n)
static void | emit_int_call_1 (CORE_ADDR fn, int arg1)
static void | emit_void_call_2 (CORE_ADDR fn, int arg1)
static void | emit_eq_goto (int *offset_p, int *size_p)
static void | emit_ne_goto (int *offset_p, int *size_p)
static void | emit_lt_goto (int *offset_p, int *size_p)
static void | emit_ge_goto (int *offset_p, int *size_p)
static void | emit_gt_goto (int *offset_p, int *size_p)
static void | emit_le_goto (int *offset_p, int *size_p)
static int | is_goto_target (struct agent_expr *aexpr, int pc)
enum eval_result_type | compile_bytecodes (struct agent_expr *aexpr)
static void | ax_printf (CORE_ADDR fn, CORE_ADDR chan, const char *format, int nargs, ULONGEST *args)
enum eval_result_type | gdb_eval_agent_expr (struct eval_agent_expr_context *ctx, struct agent_expr *aexpr, ULONGEST *rslt)

## Variables
static const char * | gdb_agent_op_names [gdb_agent_op_last]
static const unsigned char | gdb_agent_op_sizes [gdb_agent_op_last]
CORE_ADDR | current_insn_ptr
int | emit_error
struct bytecode_address * | bytecode_address_table

## Macro Definition Documentation

## ◆ ax_debug

#define ax_debug | ( |  | FMT,
|  |  | args...
| ) |  | ax_debug_1 (1, FMT, ##args)

Definition at line 49 of file ax.c.

Referenced by ax_printf(), compile_bytecodes(), and gdb_eval_agent_expr().

## ◆ ax_debug_1

#define ax_debug_1 | ( |  | level,
|  |  | fmt,
|  |  | args...
| ) |  |

Value:
do { \
if (level <= debug_threads) \
ax_vdebug ((fmt), ##args); \
} while (0)
debug_threads
int debug_threads
Definition: debug.c:24

Definition at line 43 of file ax.c.

## ◆ DEFOP [1/3]

#define DEFOP | ( |  | NAME,
|  |  | SIZE,
|  |  | DATA_SIZE,
|  |  | CONSUMED,
|  |  | PRODUCED,
|  |  | VALUE
| ) |  | gdb_agent_op_ ## NAME = VALUE,

Definition at line 57 of file ax.c.

## ◆ DEFOP [2/3]

#define DEFOP | ( |  | NAME,
|  |  | SIZE,
|  |  | DATA_SIZE,
|  |  | CONSUMED,
|  |  | PRODUCED,
|  |  | VALUE
| ) |  | , # NAME

Definition at line 57 of file ax.c.

## ◆ DEFOP [3/3]

#define DEFOP | ( |  | NAME,
|  |  | SIZE,
|  |  | DATA_SIZE,
|  |  | CONSUMED,
|  |  | PRODUCED,
|  |  | VALUE
| ) |  | , SIZE

Definition at line 57 of file ax.c.

## ◆ STACK_MAX

#define STACK_MAX 100

Referenced by gdb_eval_agent_expr().

## ◆ UNHANDLED

#define UNHANDLED

Value:
do \
{ \
ax_debug ("Cannot compile op 0x%x\n", op); \
return expr_eval_unhandled_opcode; \
} while (0)
expr_eval_unhandled_opcode
Definition: ax.h:41

Referenced by compile_bytecodes().

## Enumeration Type Documentation

## ◆ gdb_agent_op

enum gdb_agent_op

Enumerator
gdb_agent_op_last |

Definition at line 55 of file ax.c.

## Function Documentation

## ◆ ax_printf()

static void ax_printf | ( | CORE_ADDR | fn,
|  | CORE_ADDR | chan,
|  | const char * | format,
|  | int | nargs,
|  | ULONGEST * | args
| ) |  |
| static

Definition at line 815 of file ax.c.

References _, alloca(), ax_debug, error(), int_arg, literal_piece, long_arg, long_long_arg, read_inferior_memory(), and string_arg.

Referenced by gdb_eval_agent_expr().

## ◆ ax_vdebug()

static void ax_vdebug | ( | const char * | ,
|  |  | ...
| ) |  |
| static

Definition at line 25 of file ax.c.

References PROG.

## ◆ compile_bytecodes()

enum eval_result_type compile_bytecodes | ( | struct agent_expr * | aexpr | ) |

Definition at line 402 of file ax.c.

References bytecode_address::address, ax_debug, bytecode_address_table, agent_expr::bytes, current_insn_ptr, emit_add(), emit_bit_and(), emit_bit_not(), emit_bit_or(), emit_bit_xor(), emit_const(), emit_eq_goto(), emit_equal(), emit_error, emit_ext(), emit_ge_goto(), emit_goto(), emit_gt_goto(), emit_if_goto(), emit_int_call_1(), emit_le_goto(), emit_less_signed(), emit_less_unsigned(), emit_log_not(), emit_lsh(), emit_lt_goto(), emit_mul(), emit_ne_goto(), emit_pop(), emit_ref(), emit_reg(), emit_rsh_signed(), emit_rsh_unsigned(), emit_stack_adjust(), emit_stack_flush(), emit_sub(), emit_swap(), emit_void_call_2(), emit_zero_ext(), expr_eval_empty_expression, expr_eval_invalid_goto, expr_eval_no_error, expr_eval_unhandled_opcode, expr_eval_unrecognized_opcode, bytecode_address::from_offset, bytecode_address::from_size, gdb_agent_op_name(), get_get_tsv_func_addr(), get_set_tsv_func_addr(), bytecode_address::goto_pc, is_goto_target(), agent_expr::length, bytecode_address::next, paddress(), bytecode_address::pc, target_emit_ops, UNHANDLED, write_goto_address(), and XNEW.

Referenced by compile_tracepoint_condition().

## ◆ emit_add()

static void emit_add | ( | void |  | ) |
| static

Definition at line 168 of file ax.c.

References target_emit_ops.

Referenced by compile_bytecodes().

## ◆ emit_bit_and()

static void emit_bit_and | ( | void |  | ) |
| static

Definition at line 216 of file ax.c.

References target_emit_ops.

Referenced by compile_bytecodes().

## ◆ emit_bit_not()

static void emit_bit_not | ( | void |  | ) |
| static

Definition at line 234 of file ax.c.

References target_emit_ops.

Referenced by compile_bytecodes().

## ◆ emit_bit_or()

static void emit_bit_or | ( | void |  | ) |
| static

Definition at line 222 of file ax.c.

References target_emit_ops.

Referenced by compile_bytecodes().

## ◆ emit_bit_xor()

static void emit_bit_xor | ( | void |  | ) |
| static

Definition at line 228 of file ax.c.

References target_emit_ops.

Referenced by compile_bytecodes().

## ◆ emit_const()

static void emit_const | ( | LONGEST | num | ) |
| static

Definition at line 282 of file ax.c.

References target_emit_ops.

Referenced by compile_bytecodes().

## ◆ emit_epilogue()

void emit_epilogue | ( | void |  | ) |

Definition at line 162 of file ax.c.

References target_emit_ops.

Referenced by compile_tracepoint_condition().

## ◆ emit_eq_goto()

static void emit_eq_goto | ( | int * | offset_p,
|  | int * | size_p
| ) |  |
| static

Definition at line 340 of file ax.c.

References target_emit_ops.

Referenced by compile_bytecodes().

## ◆ emit_equal()

static void emit_equal | ( | void |  | ) |
| static

Definition at line 240 of file ax.c.

References target_emit_ops.

Referenced by compile_bytecodes().

## ◆ emit_ext()

static void emit_ext | ( | int | arg | ) |
| static

Definition at line 204 of file ax.c.

References target_emit_ops.

Referenced by compile_bytecodes().

## ◆ emit_ge_goto()

static void emit_ge_goto | ( | int * | offset_p,
|  | int * | size_p
| ) |  |
| static

Definition at line 358 of file ax.c.

References target_emit_ops.

Referenced by compile_bytecodes().

## ◆ emit_goto()

static void emit_goto | ( | int * | offset_p,
|  | int * | size_p
| ) |  |
| static

Definition at line 270 of file ax.c.

References target_emit_ops.

Referenced by compile_bytecodes().

## ◆ emit_gt_goto()

static void emit_gt_goto | ( | int * | offset_p,
|  | int * | size_p
| ) |  |
| static

Definition at line 364 of file ax.c.

References target_emit_ops.

Referenced by compile_bytecodes().

## ◆ emit_if_goto()

static void emit_if_goto | ( | int * | offset_p,
|  | int * | size_p
| ) |  |
| static

Definition at line 264 of file ax.c.

References target_emit_ops.

Referenced by compile_bytecodes().

## ◆ emit_int_call_1()

static void emit_int_call_1 | ( | CORE_ADDR | fn,
|  | int | arg1
| ) |  |
| static

Definition at line 326 of file ax.c.

References target_emit_ops.

Referenced by compile_bytecodes().

## ◆ emit_le_goto()

static void emit_le_goto | ( | int * | offset_p,
|  | int * | size_p
| ) |  |
| static

Definition at line 370 of file ax.c.

References target_emit_ops.

Referenced by compile_bytecodes().

## ◆ emit_less_signed()

static void emit_less_signed | ( | void |  | ) |
| static

Definition at line 246 of file ax.c.

References target_emit_ops.

Referenced by compile_bytecodes().

## ◆ emit_less_unsigned()

static void emit_less_unsigned | ( | void |  | ) |
| static

Definition at line 252 of file ax.c.

References target_emit_ops.

Referenced by compile_bytecodes().

## ◆ emit_log_not()

static void emit_log_not | ( | void |  | ) |
| static

Definition at line 210 of file ax.c.

References target_emit_ops.

Referenced by compile_bytecodes().

## ◆ emit_lsh()

static void emit_lsh | ( | void |  | ) |
| static

Definition at line 186 of file ax.c.

References target_emit_ops.

Referenced by compile_bytecodes().

## ◆ emit_lt_goto()

static void emit_lt_goto | ( | int * | offset_p,
|  | int * | size_p
| ) |  |
| static

Definition at line 352 of file ax.c.

References target_emit_ops.

Referenced by compile_bytecodes().

## ◆ emit_mul()

static void emit_mul | ( | void |  | ) |
| static

Definition at line 180 of file ax.c.

References target_emit_ops.

Referenced by compile_bytecodes().

## ◆ emit_ne_goto()

static void emit_ne_goto | ( | int * | offset_p,
|  | int * | size_p
| ) |  |
| static

Definition at line 346 of file ax.c.

References target_emit_ops.

Referenced by compile_bytecodes().

## ◆ emit_pop()

static void emit_pop | ( | void |  | ) |
| static

Definition at line 294 of file ax.c.

References target_emit_ops.

Referenced by compile_bytecodes().

## ◆ emit_prologue()

void emit_prologue | ( | void |  | ) |

Definition at line 156 of file ax.c.

References target_emit_ops.

Referenced by compile_tracepoint_condition().

## ◆ emit_ref()

static void emit_ref | ( | int | size | ) |
| static

Definition at line 258 of file ax.c.

References target_emit_ops.

Referenced by compile_bytecodes().

## ◆ emit_reg()

static void emit_reg | ( | int | reg | ) |
| static

Definition at line 288 of file ax.c.

References target_emit_ops.

Referenced by compile_bytecodes().

## ◆ emit_rsh_signed()

static void emit_rsh_signed | ( | void |  | ) |
| static

Definition at line 192 of file ax.c.

References target_emit_ops.

Referenced by compile_bytecodes().

## ◆ emit_rsh_unsigned()

static void emit_rsh_unsigned | ( | void |  | ) |
| static

Definition at line 198 of file ax.c.

References target_emit_ops.

Referenced by compile_bytecodes().

## ◆ emit_stack_adjust()

static void emit_stack_adjust | ( | int | n | ) |
| static

Definition at line 318 of file ax.c.

References target_emit_ops.

Referenced by compile_bytecodes().

## ◆ emit_stack_flush()

static void emit_stack_flush | ( | void |  | ) |
| static

Definition at line 300 of file ax.c.

References target_emit_ops.

Referenced by compile_bytecodes().

## ◆ emit_sub()

static void emit_sub | ( | void |  | ) |
| static

Definition at line 174 of file ax.c.

References target_emit_ops.

Referenced by compile_bytecodes().

## ◆ emit_swap()

static void emit_swap | ( | void |  | ) |
| static

Definition at line 312 of file ax.c.

References target_emit_ops.

Referenced by compile_bytecodes().

## ◆ emit_void_call_2()

static void emit_void_call_2 | ( | CORE_ADDR | fn,
|  | int | arg1
| ) |  |
| static

Definition at line 334 of file ax.c.

References target_emit_ops.

Referenced by compile_bytecodes().

## ◆ emit_zero_ext()

static void emit_zero_ext | ( | int | arg | ) |
| static

Definition at line 306 of file ax.c.

References target_emit_ops.

Referenced by compile_bytecodes().

## ◆ gdb_agent_op_name()

static const char* gdb_agent_op_name | ( | int | op | ) |
| static

Definition at line 85 of file ax.c.

References gdb_agent_op_last, and gdb_agent_op_names.

Referenced by compile_bytecodes(), and gdb_eval_agent_expr().

## ◆ gdb_eval_agent_expr()

enum eval_result_type gdb_eval_agent_expr | ( | struct eval_agent_expr_context * | ctx,
|  | struct agent_expr * | aexpr,
|  | ULONGEST * | rslt
| ) |  |

Definition at line 928 of file ax.c.

References _, agent_get_trace_state_variable_value(), agent_mem_read(), agent_mem_read_string(), agent_set_trace_state_variable_value(), agent_tsv_read(), ax_debug, ax_printf(), agent_expr::bytes, collect_register(), error(), expr_eval_divide_by_zero, expr_eval_empty_expression, expr_eval_empty_stack, expr_eval_no_error, expr_eval_stack_overflow, expr_eval_stack_underflow, expr_eval_unhandled_opcode, expr_eval_unrecognized_opcode, gdb_agent_op_name(), internal_error(), agent_expr::length, bytecode_address::pc, phex_nz(), pulongest(), eval_agent_expr_context::regcache, register_size(), sp, STACK_MAX, and regcache::tdesc.

Referenced by condition_true_at_tracepoint(), do_action_at_tracepoint(), gdb_condition_true_at_breakpoint_z_type(), and run_breakpoint_commands_z_type().

## ◆ gdb_free_agent_expr()

void gdb_free_agent_expr | ( | struct agent_expr * | aexpr | ) |

Definition at line 116 of file ax.c.

References agent_expr::bytes, and free().

Referenced by clear_breakpoint_commands(), and clear_breakpoint_conditions().

## ◆ gdb_parse_agent_expr()

struct agent_expr* gdb_parse_agent_expr | ( | const char ** | actparm | ) |

Definition at line 98 of file ax.c.

References agent_expr::bytes, hex2bin(), agent_expr::length, unpack_varlen_hex(), xmalloc(), and XNEW.

Referenced by add_breakpoint_commands(), add_breakpoint_condition(), add_tracepoint_action(), and cmd_qtdp().

## ◆ gdb_unparse_agent_expr()

char* gdb_unparse_agent_expr | ( | struct agent_expr * | aexpr | ) |

Definition at line 130 of file ax.c.

References bin2hex(), agent_expr::bytes, agent_expr::length, and xmalloc().

Referenced by response_tracepoint().

## ◆ is_goto_target()

static int is_goto_target | ( | struct agent_expr * | aexpr,
|  | int | pc
| ) |  |
| static

Definition at line 379 of file ax.c.

References agent_expr::bytes, gdb_agent_op_sizes, agent_expr::length, and bytecode_address::pc.

Referenced by compile_bytecodes().

## ◆ write_goto_address()

static void write_goto_address | ( | CORE_ADDR | from,
|  | CORE_ADDR | to,
|  | int | size
| ) |  |
| static

Definition at line 276 of file ax.c.

References target_emit_ops.

Referenced by compile_bytecodes().

## Variable Documentation

## ◆ bytecode_address_table

struct bytecode_address * bytecode_address_table

Referenced by compile_bytecodes().

## ◆ current_insn_ptr

CORE_ADDR current_insn_ptr

Definition at line 141 of file ax.c.

Referenced by add_insns(), compile_bytecodes(), compile_tracepoint_condition(), emit_insns(), emit_ops_insns(), i386_emit_call(), i386_emit_const(), i386_emit_int_call_1(), i386_emit_reg(), i386_emit_stack_adjust(), i386_emit_void_call_2(), and s390_emit_litpool().

## ◆ emit_error

int emit_error

Definition at line 143 of file ax.c.

Referenced by aarch64_emit_ref(), compile_bytecodes(), i386_emit_ext(), i386_emit_lsh(), i386_emit_mul(), i386_emit_rsh_signed(), i386_emit_rsh_unsigned(), i386_emit_zero_ext(), i386_write_goto_address(), ppc_emit_ext(), ppc_emit_stack_adjust(), ppc_emit_zero_ext(), ppc_write_goto_address(), s390_emit_mul(), s390_emit_ref(), and s390_write_goto_address().

## ◆ gdb_agent_op_names

const char* gdb_agent_op_names[gdb_agent_op_last]
| static

Definition at line 64 of file ax.c.

Referenced by gdb_agent_op_name().

## ◆ gdb_agent_op_sizes

const unsigned char gdb_agent_op_sizes[gdb_agent_op_last]
| static

Definition at line 73 of file ax.c.

Referenced by is_goto_target().