aboutsummaryrefslogtreecommitdiff
path: root/gdbserver
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@polymtl.ca>2023-02-08 15:36:23 -0500
committerSimon Marchi <simon.marchi@polymtl.ca>2023-02-08 15:46:02 -0500
commitc583a2520616c2736cffc389c89a48b159366e6c (patch)
treeb4925f26506fcee96c16119431c01760f05db95d /gdbserver
parentca7f92c2f15b86b09c4a8ad14806bef666308d31 (diff)
downloadgdb-users/simark/clang-format.zip
gdb-users/simark/clang-format.tar.gz
gdb-users/simark/clang-format.tar.bz2
Run clang-format.shusers/simark/clang-format
Change-Id: Ia948cc26d534b0dd02702244d52434b1a2093968
Diffstat (limited to 'gdbserver')
-rw-r--r--gdbserver/ax.cc1591
-rw-r--r--gdbserver/ax.h29
-rw-r--r--gdbserver/debug.cc16
-rw-r--r--gdbserver/debug.h8
-rw-r--r--gdbserver/dll.cc25
-rw-r--r--gdbserver/dll.h10
-rw-r--r--gdbserver/fork-child.cc7
-rw-r--r--gdbserver/gdbreplay.cc198
-rw-r--r--gdbserver/gdbthread.h42
-rw-r--r--gdbserver/hostio.cc119
-rw-r--r--gdbserver/i387-fp.cc647
-rw-r--r--gdbserver/inferiors.cc26
-rw-r--r--gdbserver/inferiors.h10
-rw-r--r--gdbserver/linux-aarch32-low.cc92
-rw-r--r--gdbserver/linux-aarch32-low.h4
-rw-r--r--gdbserver/linux-aarch32-tdesc.h2
-rw-r--r--gdbserver/linux-aarch64-ipa.cc128
-rw-r--r--gdbserver/linux-aarch64-low.cc671
-rw-r--r--gdbserver/linux-aarch64-tdesc.cc12
-rw-r--r--gdbserver/linux-aarch64-tdesc.h2
-rw-r--r--gdbserver/linux-amd64-ipa.cc114
-rw-r--r--gdbserver/linux-arc-low.cc58
-rw-r--r--gdbserver/linux-arm-low.cc348
-rw-r--r--gdbserver/linux-arm-tdesc.cc2
-rw-r--r--gdbserver/linux-arm-tdesc.h2
-rw-r--r--gdbserver/linux-csky-low.cc95
-rw-r--r--gdbserver/linux-i386-ipa.cc155
-rw-r--r--gdbserver/linux-ia64-low.cc741
-rw-r--r--gdbserver/linux-loongarch-low.cc68
-rw-r--r--gdbserver/linux-low.cc3611
-rw-r--r--gdbserver/linux-low.h127
-rw-r--r--gdbserver/linux-m68k-low.cc82
-rw-r--r--gdbserver/linux-mips-low.cc369
-rw-r--r--gdbserver/linux-nios2-low.cc66
-rw-r--r--gdbserver/linux-or1k-low.cc58
-rw-r--r--gdbserver/linux-ppc-ipa.cc74
-rw-r--r--gdbserver/linux-ppc-low.cc1615
-rw-r--r--gdbserver/linux-ppc-tdesc-init.h5
-rw-r--r--gdbserver/linux-riscv-low.cc94
-rw-r--r--gdbserver/linux-s390-ipa.cc691
-rw-r--r--gdbserver/linux-s390-low.cc1730
-rw-r--r--gdbserver/linux-s390-tdesc.h3
-rw-r--r--gdbserver/linux-sh-low.cc95
-rw-r--r--gdbserver/linux-sparc-low.cc132
-rw-r--r--gdbserver/linux-tic6x-low.cc157
-rw-r--r--gdbserver/linux-x86-low.cc1607
-rw-r--r--gdbserver/linux-x86-tdesc.cc33
-rw-r--r--gdbserver/linux-x86-tdesc.h5
-rw-r--r--gdbserver/linux-xtensa-low.cc162
-rw-r--r--gdbserver/mem-break.cc744
-rw-r--r--gdbserver/mem-break.h46
-rw-r--r--gdbserver/netbsd-aarch64-low.cc30
-rw-r--r--gdbserver/netbsd-amd64-low.cc89
-rw-r--r--gdbserver/netbsd-i386-low.cc61
-rw-r--r--gdbserver/netbsd-low.cc509
-rw-r--r--gdbserver/netbsd-low.h28
-rw-r--r--gdbserver/notif.cc16
-rw-r--r--gdbserver/notif.h7
-rw-r--r--gdbserver/proc-service.cc17
-rw-r--r--gdbserver/regcache.cc84
-rw-r--r--gdbserver/regcache.h18
-rw-r--r--gdbserver/remote-utils.cc711
-rw-r--r--gdbserver/remote-utils.h31
-rw-r--r--gdbserver/server.cc2920
-rw-r--r--gdbserver/server.h18
-rw-r--r--gdbserver/symbol.cc2
-rw-r--r--gdbserver/target.cc147
-rw-r--r--gdbserver/target.h221
-rw-r--r--gdbserver/tdesc.cc45
-rw-r--r--gdbserver/tdesc.h11
-rw-r--r--gdbserver/thread-db.cc186
-rw-r--r--gdbserver/tracepoint.cc3213
-rw-r--r--gdbserver/tracepoint.h70
-rw-r--r--gdbserver/utils.cc22
-rw-r--r--gdbserver/win32-i386-low.cc364
-rw-r--r--gdbserver/win32-low.cc532
-rw-r--r--gdbserver/win32-low.h50
-rw-r--r--gdbserver/x86-low.cc10
-rw-r--r--gdbserver/x86-tdesc.h4
-rw-r--r--gdbserver/xtensa-xtregs.cc32
80 files changed, 12924 insertions, 13252 deletions
diff --git a/gdbserver/ax.cc b/gdbserver/ax.cc
index 38ebfbb..76f2fa1 100644
--- a/gdbserver/ax.cc
+++ b/gdbserver/ax.cc
@@ -44,40 +44,38 @@ ax_vdebug (const char *fmt, ...)
va_end (ap);
}
-#define ax_debug(fmt, args...) \
- do { \
- if (debug_threads) \
- ax_vdebug ((fmt), ##args); \
- } while (0)
+#define ax_debug(fmt, args...) \
+ do \
+ { \
+ if (debug_threads) \
+ ax_vdebug ((fmt), ##args); \
+ } \
+ while (0)
/* This enum must exactly match what is documented in
gdb/doc/agentexpr.texi, including all the numerical values. */
enum gdb_agent_op
- {
-#define DEFOP(NAME, SIZE, DATA_SIZE, CONSUMED, PRODUCED, VALUE) \
- gdb_agent_op_ ## NAME = VALUE,
+{
+#define DEFOP(NAME, SIZE, DATA_SIZE, CONSUMED, PRODUCED, VALUE) \
+ gdb_agent_op_##NAME = VALUE,
#include "gdbsupport/ax.def"
#undef DEFOP
- gdb_agent_op_last
- };
+ gdb_agent_op_last
+};
-static const char * const gdb_agent_op_names [gdb_agent_op_last] =
- {
- "?undef?"
-#define DEFOP(NAME, SIZE, DATA_SIZE, CONSUMED, PRODUCED, VALUE) , # NAME
+static const char *const gdb_agent_op_names[gdb_agent_op_last] = { "?undef?"
+#define DEFOP(NAME, SIZE, DATA_SIZE, CONSUMED, PRODUCED, VALUE) , #NAME
#include "gdbsupport/ax.def"
#undef DEFOP
- };
+};
#ifndef IN_PROCESS_AGENT
-static const unsigned char gdb_agent_op_sizes [gdb_agent_op_last] =
- {
- 0
-#define DEFOP(NAME, SIZE, DATA_SIZE, CONSUMED, PRODUCED, VALUE) , SIZE
+static const unsigned char gdb_agent_op_sizes[gdb_agent_op_last] = { 0
+#define DEFOP(NAME, SIZE, DATA_SIZE, CONSUMED, PRODUCED, VALUE) , SIZE
#include "gdbsupport/ax.def"
#undef DEFOP
- };
+};
#endif
/* A wrapper for gdb_agent_op_names that does some bounds-checking. */
@@ -102,9 +100,9 @@ gdb_parse_agent_expr (const char **actparm)
ULONGEST xlen;
struct agent_expr *aexpr;
- ++act; /* skip the X */
+ ++act; /* skip the X */
act = unpack_varlen_hex (act, &xlen);
- ++act; /* skip a comma */
+ ++act; /* skip a comma */
aexpr = XNEW (struct agent_expr);
aexpr->length = xlen;
aexpr->bytes = (unsigned char *) xmalloc (xlen);
@@ -387,11 +385,11 @@ is_goto_target (struct agent_expr *aexpr, int pc)
op = aexpr->bytes[i];
if (op == gdb_agent_op_goto || op == gdb_agent_op_if_goto)
- {
- int target = (aexpr->bytes[i + 1] << 8) + aexpr->bytes[i + 2];
- if (target == pc)
- return 1;
- }
+ {
+ int target = (aexpr->bytes[i + 1] << 8) + aexpr->bytes[i + 2];
+ if (target == pc)
+ return 1;
+ }
}
return 0;
@@ -410,12 +408,13 @@ compile_bytecodes (struct agent_expr *aexpr)
ULONGEST top;
struct bytecode_address *aentry, *aentry2;
-#define UNHANDLED \
- do \
- { \
- ax_debug ("Cannot compile op 0x%x\n", op); \
- return expr_eval_unhandled_opcode; \
- } while (0)
+#define UNHANDLED \
+ do \
+ { \
+ ax_debug ("Cannot compile op 0x%x\n", op); \
+ return expr_eval_unhandled_opcode; \
+ } \
+ while (0)
if (aexpr->length == 0)
{
@@ -446,322 +445,318 @@ compile_bytecodes (struct agent_expr *aexpr)
emit_error = 0;
switch (op)
- {
- case gdb_agent_op_add:
- emit_add ();
- break;
-
- case gdb_agent_op_sub:
- emit_sub ();
- break;
-
- case gdb_agent_op_mul:
- emit_mul ();
- break;
-
- case gdb_agent_op_div_signed:
- UNHANDLED;
- break;
-
- case gdb_agent_op_div_unsigned:
- UNHANDLED;
- break;
-
- case gdb_agent_op_rem_signed:
- UNHANDLED;
- break;
-
- case gdb_agent_op_rem_unsigned:
- UNHANDLED;
- break;
-
- case gdb_agent_op_lsh:
- emit_lsh ();
- break;
-
- case gdb_agent_op_rsh_signed:
- emit_rsh_signed ();
- break;
-
- case gdb_agent_op_rsh_unsigned:
- emit_rsh_unsigned ();
- break;
-
- case gdb_agent_op_trace:
- UNHANDLED;
- break;
-
- case gdb_agent_op_trace_quick:
- UNHANDLED;
- break;
-
- case gdb_agent_op_log_not:
- emit_log_not ();
- break;
-
- case gdb_agent_op_bit_and:
- emit_bit_and ();
- break;
-
- case gdb_agent_op_bit_or:
- emit_bit_or ();
- break;
-
- case gdb_agent_op_bit_xor:
- emit_bit_xor ();
- break;
-
- case gdb_agent_op_bit_not:
- emit_bit_not ();
- break;
-
- case gdb_agent_op_equal:
- next_op = aexpr->bytes[pc];
- if (next_op == gdb_agent_op_if_goto
- && !is_goto_target (aexpr, pc)
- && target_emit_ops ()->emit_eq_goto)
- {
- ax_debug ("Combining equal & if_goto");
- pc += 1;
- aentry->pc = pc;
- arg = aexpr->bytes[pc++];
- arg = (arg << 8) + aexpr->bytes[pc++];
- aentry->goto_pc = arg;
- emit_eq_goto (&(aentry->from_offset), &(aentry->from_size));
- }
- else if (next_op == gdb_agent_op_log_not
- && (aexpr->bytes[pc + 1] == gdb_agent_op_if_goto)
- && !is_goto_target (aexpr, pc + 1)
- && target_emit_ops ()->emit_ne_goto)
- {
- ax_debug ("Combining equal & log_not & if_goto");
- pc += 2;
- aentry->pc = pc;
- arg = aexpr->bytes[pc++];
- arg = (arg << 8) + aexpr->bytes[pc++];
- aentry->goto_pc = arg;
- emit_ne_goto (&(aentry->from_offset), &(aentry->from_size));
- }
- else
- emit_equal ();
- break;
-
- case gdb_agent_op_less_signed:
- next_op = aexpr->bytes[pc];
- if (next_op == gdb_agent_op_if_goto
- && !is_goto_target (aexpr, pc))
- {
- ax_debug ("Combining less_signed & if_goto");
- pc += 1;
- aentry->pc = pc;
- arg = aexpr->bytes[pc++];
- arg = (arg << 8) + aexpr->bytes[pc++];
- aentry->goto_pc = arg;
- emit_lt_goto (&(aentry->from_offset), &(aentry->from_size));
- }
- else if (next_op == gdb_agent_op_log_not
- && !is_goto_target (aexpr, pc)
- && (aexpr->bytes[pc + 1] == gdb_agent_op_if_goto)
- && !is_goto_target (aexpr, pc + 1))
- {
- ax_debug ("Combining less_signed & log_not & if_goto");
- pc += 2;
- aentry->pc = pc;
- arg = aexpr->bytes[pc++];
- arg = (arg << 8) + aexpr->bytes[pc++];
- aentry->goto_pc = arg;
- emit_ge_goto (&(aentry->from_offset), &(aentry->from_size));
- }
- else
- emit_less_signed ();
- break;
-
- case gdb_agent_op_less_unsigned:
- emit_less_unsigned ();
- break;
-
- case gdb_agent_op_ext:
- arg = aexpr->bytes[pc++];
- if (arg < (sizeof (LONGEST) * 8))
- emit_ext (arg);
- break;
-
- case gdb_agent_op_ref8:
- emit_ref (1);
- break;
-
- case gdb_agent_op_ref16:
- emit_ref (2);
- break;
-
- case gdb_agent_op_ref32:
- emit_ref (4);
- break;
-
- case gdb_agent_op_ref64:
- emit_ref (8);
- break;
-
- case gdb_agent_op_if_goto:
- arg = aexpr->bytes[pc++];
- arg = (arg << 8) + aexpr->bytes[pc++];
- aentry->goto_pc = arg;
- emit_if_goto (&(aentry->from_offset), &(aentry->from_size));
- break;
-
- case gdb_agent_op_goto:
- arg = aexpr->bytes[pc++];
- arg = (arg << 8) + aexpr->bytes[pc++];
- aentry->goto_pc = arg;
- emit_goto (&(aentry->from_offset), &(aentry->from_size));
- break;
-
- case gdb_agent_op_const8:
- emit_stack_flush ();
- top = aexpr->bytes[pc++];
- emit_const (top);
- break;
-
- case gdb_agent_op_const16:
- emit_stack_flush ();
- top = aexpr->bytes[pc++];
- top = (top << 8) + aexpr->bytes[pc++];
- emit_const (top);
- break;
-
- case gdb_agent_op_const32:
- emit_stack_flush ();
- top = aexpr->bytes[pc++];
- top = (top << 8) + aexpr->bytes[pc++];
- top = (top << 8) + aexpr->bytes[pc++];
- top = (top << 8) + aexpr->bytes[pc++];
- emit_const (top);
- break;
-
- case gdb_agent_op_const64:
- emit_stack_flush ();
- top = aexpr->bytes[pc++];
- top = (top << 8) + aexpr->bytes[pc++];
- top = (top << 8) + aexpr->bytes[pc++];
- top = (top << 8) + aexpr->bytes[pc++];
- top = (top << 8) + aexpr->bytes[pc++];
- top = (top << 8) + aexpr->bytes[pc++];
- top = (top << 8) + aexpr->bytes[pc++];
- top = (top << 8) + aexpr->bytes[pc++];
- emit_const (top);
- break;
-
- case gdb_agent_op_reg:
- emit_stack_flush ();
- arg = aexpr->bytes[pc++];
- arg = (arg << 8) + aexpr->bytes[pc++];
- emit_reg (arg);
- break;
-
- case gdb_agent_op_end:
- ax_debug ("At end of expression\n");
-
- /* Assume there is one stack element left, and that it is
+ {
+ case gdb_agent_op_add:
+ emit_add ();
+ break;
+
+ case gdb_agent_op_sub:
+ emit_sub ();
+ break;
+
+ case gdb_agent_op_mul:
+ emit_mul ();
+ break;
+
+ case gdb_agent_op_div_signed:
+ UNHANDLED;
+ break;
+
+ case gdb_agent_op_div_unsigned:
+ UNHANDLED;
+ break;
+
+ case gdb_agent_op_rem_signed:
+ UNHANDLED;
+ break;
+
+ case gdb_agent_op_rem_unsigned:
+ UNHANDLED;
+ break;
+
+ case gdb_agent_op_lsh:
+ emit_lsh ();
+ break;
+
+ case gdb_agent_op_rsh_signed:
+ emit_rsh_signed ();
+ break;
+
+ case gdb_agent_op_rsh_unsigned:
+ emit_rsh_unsigned ();
+ break;
+
+ case gdb_agent_op_trace:
+ UNHANDLED;
+ break;
+
+ case gdb_agent_op_trace_quick:
+ UNHANDLED;
+ break;
+
+ case gdb_agent_op_log_not:
+ emit_log_not ();
+ break;
+
+ case gdb_agent_op_bit_and:
+ emit_bit_and ();
+ break;
+
+ case gdb_agent_op_bit_or:
+ emit_bit_or ();
+ break;
+
+ case gdb_agent_op_bit_xor:
+ emit_bit_xor ();
+ break;
+
+ case gdb_agent_op_bit_not:
+ emit_bit_not ();
+ break;
+
+ case gdb_agent_op_equal:
+ next_op = aexpr->bytes[pc];
+ if (next_op == gdb_agent_op_if_goto && !is_goto_target (aexpr, pc)
+ && target_emit_ops ()->emit_eq_goto)
+ {
+ ax_debug ("Combining equal & if_goto");
+ pc += 1;
+ aentry->pc = pc;
+ arg = aexpr->bytes[pc++];
+ arg = (arg << 8) + aexpr->bytes[pc++];
+ aentry->goto_pc = arg;
+ emit_eq_goto (&(aentry->from_offset), &(aentry->from_size));
+ }
+ else if (next_op == gdb_agent_op_log_not
+ && (aexpr->bytes[pc + 1] == gdb_agent_op_if_goto)
+ && !is_goto_target (aexpr, pc + 1)
+ && target_emit_ops ()->emit_ne_goto)
+ {
+ ax_debug ("Combining equal & log_not & if_goto");
+ pc += 2;
+ aentry->pc = pc;
+ arg = aexpr->bytes[pc++];
+ arg = (arg << 8) + aexpr->bytes[pc++];
+ aentry->goto_pc = arg;
+ emit_ne_goto (&(aentry->from_offset), &(aentry->from_size));
+ }
+ else
+ emit_equal ();
+ break;
+
+ case gdb_agent_op_less_signed:
+ next_op = aexpr->bytes[pc];
+ if (next_op == gdb_agent_op_if_goto && !is_goto_target (aexpr, pc))
+ {
+ ax_debug ("Combining less_signed & if_goto");
+ pc += 1;
+ aentry->pc = pc;
+ arg = aexpr->bytes[pc++];
+ arg = (arg << 8) + aexpr->bytes[pc++];
+ aentry->goto_pc = arg;
+ emit_lt_goto (&(aentry->from_offset), &(aentry->from_size));
+ }
+ else if (next_op == gdb_agent_op_log_not
+ && !is_goto_target (aexpr, pc)
+ && (aexpr->bytes[pc + 1] == gdb_agent_op_if_goto)
+ && !is_goto_target (aexpr, pc + 1))
+ {
+ ax_debug ("Combining less_signed & log_not & if_goto");
+ pc += 2;
+ aentry->pc = pc;
+ arg = aexpr->bytes[pc++];
+ arg = (arg << 8) + aexpr->bytes[pc++];
+ aentry->goto_pc = arg;
+ emit_ge_goto (&(aentry->from_offset), &(aentry->from_size));
+ }
+ else
+ emit_less_signed ();
+ break;
+
+ case gdb_agent_op_less_unsigned:
+ emit_less_unsigned ();
+ break;
+
+ case gdb_agent_op_ext:
+ arg = aexpr->bytes[pc++];
+ if (arg < (sizeof (LONGEST) * 8))
+ emit_ext (arg);
+ break;
+
+ case gdb_agent_op_ref8:
+ emit_ref (1);
+ break;
+
+ case gdb_agent_op_ref16:
+ emit_ref (2);
+ break;
+
+ case gdb_agent_op_ref32:
+ emit_ref (4);
+ break;
+
+ case gdb_agent_op_ref64:
+ emit_ref (8);
+ break;
+
+ case gdb_agent_op_if_goto:
+ arg = aexpr->bytes[pc++];
+ arg = (arg << 8) + aexpr->bytes[pc++];
+ aentry->goto_pc = arg;
+ emit_if_goto (&(aentry->from_offset), &(aentry->from_size));
+ break;
+
+ case gdb_agent_op_goto:
+ arg = aexpr->bytes[pc++];
+ arg = (arg << 8) + aexpr->bytes[pc++];
+ aentry->goto_pc = arg;
+ emit_goto (&(aentry->from_offset), &(aentry->from_size));
+ break;
+
+ case gdb_agent_op_const8:
+ emit_stack_flush ();
+ top = aexpr->bytes[pc++];
+ emit_const (top);
+ break;
+
+ case gdb_agent_op_const16:
+ emit_stack_flush ();
+ top = aexpr->bytes[pc++];
+ top = (top << 8) + aexpr->bytes[pc++];
+ emit_const (top);
+ break;
+
+ case gdb_agent_op_const32:
+ emit_stack_flush ();
+ top = aexpr->bytes[pc++];
+ top = (top << 8) + aexpr->bytes[pc++];
+ top = (top << 8) + aexpr->bytes[pc++];
+ top = (top << 8) + aexpr->bytes[pc++];
+ emit_const (top);
+ break;
+
+ case gdb_agent_op_const64:
+ emit_stack_flush ();
+ top = aexpr->bytes[pc++];
+ top = (top << 8) + aexpr->bytes[pc++];
+ top = (top << 8) + aexpr->bytes[pc++];
+ top = (top << 8) + aexpr->bytes[pc++];
+ top = (top << 8) + aexpr->bytes[pc++];
+ top = (top << 8) + aexpr->bytes[pc++];
+ top = (top << 8) + aexpr->bytes[pc++];
+ top = (top << 8) + aexpr->bytes[pc++];
+ emit_const (top);
+ break;
+
+ case gdb_agent_op_reg:
+ emit_stack_flush ();
+ arg = aexpr->bytes[pc++];
+ arg = (arg << 8) + aexpr->bytes[pc++];
+ emit_reg (arg);
+ break;
+
+ case gdb_agent_op_end:
+ ax_debug ("At end of expression\n");
+
+ /* Assume there is one stack element left, and that it is
cached in "top" where emit_epilogue can get to it. */
- emit_stack_adjust (1);
-
- done = 1;
- break;
-
- case gdb_agent_op_dup:
- /* In our design, dup is equivalent to stack flushing. */
- emit_stack_flush ();
- break;
-
- case gdb_agent_op_pop:
- emit_pop ();
- break;
-
- case gdb_agent_op_zero_ext:
- arg = aexpr->bytes[pc++];
- if (arg < (sizeof (LONGEST) * 8))
- emit_zero_ext (arg);
- break;
-
- case gdb_agent_op_swap:
- next_op = aexpr->bytes[pc];
- /* Detect greater-than comparison sequences. */
- if (next_op == gdb_agent_op_less_signed
- && !is_goto_target (aexpr, pc)
- && (aexpr->bytes[pc + 1] == gdb_agent_op_if_goto)
- && !is_goto_target (aexpr, pc + 1))
- {
- ax_debug ("Combining swap & less_signed & if_goto");
- pc += 2;
- aentry->pc = pc;
- arg = aexpr->bytes[pc++];
- arg = (arg << 8) + aexpr->bytes[pc++];
- aentry->goto_pc = arg;
- emit_gt_goto (&(aentry->from_offset), &(aentry->from_size));
- }
- else if (next_op == gdb_agent_op_less_signed
- && !is_goto_target (aexpr, pc)
- && (aexpr->bytes[pc + 1] == gdb_agent_op_log_not)
- && !is_goto_target (aexpr, pc + 1)
- && (aexpr->bytes[pc + 2] == gdb_agent_op_if_goto)
- && !is_goto_target (aexpr, pc + 2))
- {
- ax_debug ("Combining swap & less_signed & log_not & if_goto");
- pc += 3;
- aentry->pc = pc;
- arg = aexpr->bytes[pc++];
- arg = (arg << 8) + aexpr->bytes[pc++];
- aentry->goto_pc = arg;
- emit_le_goto (&(aentry->from_offset), &(aentry->from_size));
- }
- else
- emit_swap ();
- break;
-
- case gdb_agent_op_getv:
- emit_stack_flush ();
- arg = aexpr->bytes[pc++];
- arg = (arg << 8) + aexpr->bytes[pc++];
- emit_int_call_1 (get_get_tsv_func_addr (),
- arg);
- break;
-
- case gdb_agent_op_setv:
- arg = aexpr->bytes[pc++];
- arg = (arg << 8) + aexpr->bytes[pc++];
- emit_void_call_2 (get_set_tsv_func_addr (),
- arg);
- break;
-
- case gdb_agent_op_tracev:
- UNHANDLED;
- break;
-
- /* GDB never (currently) generates any of these ops. */
- case gdb_agent_op_float:
- case gdb_agent_op_ref_float:
- case gdb_agent_op_ref_double:
- case gdb_agent_op_ref_long_double:
- case gdb_agent_op_l_to_d:
- case gdb_agent_op_d_to_l:
- case gdb_agent_op_trace16:
- UNHANDLED;
- break;
-
- default:
- ax_debug ("Agent expression op 0x%x not recognized\n", op);
- /* Don't struggle on, things will just get worse. */
- return expr_eval_unrecognized_opcode;
- }
+ emit_stack_adjust (1);
+
+ done = 1;
+ break;
+
+ case gdb_agent_op_dup:
+ /* In our design, dup is equivalent to stack flushing. */
+ emit_stack_flush ();
+ break;
+
+ case gdb_agent_op_pop:
+ emit_pop ();
+ break;
+
+ case gdb_agent_op_zero_ext:
+ arg = aexpr->bytes[pc++];
+ if (arg < (sizeof (LONGEST) * 8))
+ emit_zero_ext (arg);
+ break;
+
+ case gdb_agent_op_swap:
+ next_op = aexpr->bytes[pc];
+ /* Detect greater-than comparison sequences. */
+ if (next_op == gdb_agent_op_less_signed
+ && !is_goto_target (aexpr, pc)
+ && (aexpr->bytes[pc + 1] == gdb_agent_op_if_goto)
+ && !is_goto_target (aexpr, pc + 1))
+ {
+ ax_debug ("Combining swap & less_signed & if_goto");
+ pc += 2;
+ aentry->pc = pc;
+ arg = aexpr->bytes[pc++];
+ arg = (arg << 8) + aexpr->bytes[pc++];
+ aentry->goto_pc = arg;
+ emit_gt_goto (&(aentry->from_offset), &(aentry->from_size));
+ }
+ else if (next_op == gdb_agent_op_less_signed
+ && !is_goto_target (aexpr, pc)
+ && (aexpr->bytes[pc + 1] == gdb_agent_op_log_not)
+ && !is_goto_target (aexpr, pc + 1)
+ && (aexpr->bytes[pc + 2] == gdb_agent_op_if_goto)
+ && !is_goto_target (aexpr, pc + 2))
+ {
+ ax_debug ("Combining swap & less_signed & log_not & if_goto");
+ pc += 3;
+ aentry->pc = pc;
+ arg = aexpr->bytes[pc++];
+ arg = (arg << 8) + aexpr->bytes[pc++];
+ aentry->goto_pc = arg;
+ emit_le_goto (&(aentry->from_offset), &(aentry->from_size));
+ }
+ else
+ emit_swap ();
+ break;
+
+ case gdb_agent_op_getv:
+ emit_stack_flush ();
+ arg = aexpr->bytes[pc++];
+ arg = (arg << 8) + aexpr->bytes[pc++];
+ emit_int_call_1 (get_get_tsv_func_addr (), arg);
+ break;
+
+ case gdb_agent_op_setv:
+ arg = aexpr->bytes[pc++];
+ arg = (arg << 8) + aexpr->bytes[pc++];
+ emit_void_call_2 (get_set_tsv_func_addr (), arg);
+ break;
+
+ case gdb_agent_op_tracev:
+ UNHANDLED;
+ break;
+
+ /* GDB never (currently) generates any of these ops. */
+ case gdb_agent_op_float:
+ case gdb_agent_op_ref_float:
+ case gdb_agent_op_ref_double:
+ case gdb_agent_op_ref_long_double:
+ case gdb_agent_op_l_to_d:
+ case gdb_agent_op_d_to_l:
+ case gdb_agent_op_trace16:
+ UNHANDLED;
+ break;
+
+ default:
+ ax_debug ("Agent expression op 0x%x not recognized\n", op);
+ /* Don't struggle on, things will just get worse. */
+ return expr_eval_unrecognized_opcode;
+ }
/* This catches errors that occur in target-specific code
emission. */
if (emit_error)
- {
- ax_debug ("Error %d while emitting code for %s\n",
- emit_error, gdb_agent_op_name (op));
- return expr_eval_unhandled_opcode;
- }
+ {
+ ax_debug ("Error %d while emitting code for %s\n", emit_error,
+ gdb_agent_op_name (op));
+ return expr_eval_unhandled_opcode;
+ }
ax_debug ("Op %s compiled\n", gdb_agent_op_name (op));
}
@@ -772,32 +767,31 @@ compile_bytecodes (struct agent_expr *aexpr)
int written = 0;
if (aentry->goto_pc < 0)
- continue;
+ continue;
/* Find the location that we are going to, and call back into
target-specific code to write the actual address or
displacement. */
for (aentry2 = bytecode_address_table; aentry2; aentry2 = aentry2->next)
- {
- if (aentry2->pc == aentry->goto_pc)
- {
- ax_debug ("Want to jump from %s to %s\n",
- paddress (aentry->address),
- paddress (aentry2->address));
- write_goto_address (aentry->address + aentry->from_offset,
- aentry2->address, aentry->from_size);
- written = 1;
- break;
- }
- }
+ {
+ if (aentry2->pc == aentry->goto_pc)
+ {
+ ax_debug ("Want to jump from %s to %s\n",
+ paddress (aentry->address),
+ paddress (aentry2->address));
+ write_goto_address (aentry->address + aentry->from_offset,
+ aentry2->address, aentry->from_size);
+ written = 1;
+ break;
+ }
+ }
/* Error out if we didn't find a destination. */
if (!written)
- {
- ax_debug ("Destination of goto %d not found\n",
- aentry->goto_pc);
- return expr_eval_invalid_goto;
- }
+ {
+ ax_debug ("Destination of goto %d not found\n", aentry->goto_pc);
+ return expr_eval_invalid_goto;
+ }
}
return expr_eval_no_error;
@@ -813,8 +807,8 @@ compile_bytecodes (struct agent_expr *aexpr)
in. */
static void
-ax_printf (CORE_ADDR fn, CORE_ADDR chan, const char *format,
- int nargs, ULONGEST *args)
+ax_printf (CORE_ADDR fn, CORE_ADDR chan, const char *format, int nargs,
+ ULONGEST *args)
{
const char *f = format;
int i;
@@ -831,86 +825,86 @@ ax_printf (CORE_ADDR fn, CORE_ADDR chan, const char *format,
++nargs_wanted;
if (nargs != nargs_wanted)
- error (_("Wrong number of arguments for specified format-string"));
+ error (_ ("Wrong number of arguments for specified format-string"));
i = 0;
for (auto &&piece : fpieces)
{
current_substring = piece.string;
- ax_debug ("current substring is '%s', class is %d",
- current_substring, piece.argclass);
+ ax_debug ("current substring is '%s', class is %d", current_substring,
+ piece.argclass);
switch (piece.argclass)
- {
- case string_arg:
- {
- gdb_byte *str;
- CORE_ADDR tem;
- int j;
-
- tem = args[i];
- if (tem == 0)
- {
- printf (current_substring, "(null)");
- break;
- }
-
- /* This is a %s argument. Find the length of the string. */
- for (j = 0;; j++)
- {
- gdb_byte c;
-
- read_inferior_memory (tem + j, &c, 1);
- if (c == 0)
- break;
- }
-
- /* Copy the string contents into a string inside GDB. */
- str = (gdb_byte *) alloca (j + 1);
- if (j != 0)
- read_inferior_memory (tem, str, j);
- str[j] = 0;
-
- printf (current_substring, (char *) str);
- }
- break;
-
- case long_long_arg:
-#if defined (PRINTF_HAS_LONG_LONG)
- {
- long long val = args[i];
-
- printf (current_substring, val);
- break;
- }
+ {
+ case string_arg:
+ {
+ gdb_byte *str;
+ CORE_ADDR tem;
+ int j;
+
+ tem = args[i];
+ if (tem == 0)
+ {
+ printf (current_substring, "(null)");
+ break;
+ }
+
+ /* This is a %s argument. Find the length of the string. */
+ for (j = 0;; j++)
+ {
+ gdb_byte c;
+
+ read_inferior_memory (tem + j, &c, 1);
+ if (c == 0)
+ break;
+ }
+
+ /* Copy the string contents into a string inside GDB. */
+ str = (gdb_byte *) alloca (j + 1);
+ if (j != 0)
+ read_inferior_memory (tem, str, j);
+ str[j] = 0;
+
+ printf (current_substring, (char *) str);
+ }
+ break;
+
+ case long_long_arg:
+#if defined(PRINTF_HAS_LONG_LONG)
+ {
+ long long val = args[i];
+
+ printf (current_substring, val);
+ break;
+ }
#else
- error (_("long long not supported in agent printf"));
+ error (_ ("long long not supported in agent printf"));
#endif
- case int_arg:
- {
- int val = args[i];
+ case int_arg:
+ {
+ int val = args[i];
- printf (current_substring, val);
- break;
- }
+ printf (current_substring, val);
+ break;
+ }
- case long_arg:
- {
- long val = args[i];
+ case long_arg:
+ {
+ long val = args[i];
- printf (current_substring, val);
- break;
- }
+ printf (current_substring, val);
+ break;
+ }
- case size_t_arg:
- {
- size_t val = args[i];
+ case size_t_arg:
+ {
+ size_t val = args[i];
- printf (current_substring, val);
- break;
- }
+ printf (current_substring, val);
+ break;
+ }
- case literal_piece:
- /* Print a portion of the format string that has no
+ case literal_piece:
+ /* Print a portion of the format string that has no
directives. Note that this will not include any
ordinary %-specs, but it might include "%%". That is
why we use printf_filtered and not puts_filtered here.
@@ -918,17 +912,17 @@ ax_printf (CORE_ADDR fn, CORE_ADDR chan, const char *format,
have modified GCC to include -Wformat-security by
default, which will warn here if there is no
argument. */
- printf (current_substring, 0);
- break;
+ printf (current_substring, 0);
+ break;
- default:
- error (_("Format directive in '%s' not supported in agent printf"),
- current_substring);
- }
+ default:
+ error (_ ("Format directive in '%s' not supported in agent printf"),
+ current_substring);
+ }
/* Maybe advance to the next argument. */
if (piece.argclass != literal_piece)
- ++i;
+ ++i;
}
fflush (stdout);
@@ -940,8 +934,7 @@ ax_printf (CORE_ADDR fn, CORE_ADDR chan, const char *format,
enum eval_result_type
gdb_eval_agent_expr (struct eval_agent_expr_context *ctx,
- struct agent_expr *aexpr,
- ULONGEST *rslt)
+ struct agent_expr *aexpr, ULONGEST *rslt)
{
int pc = 0;
#define STACK_MAX 100
@@ -996,377 +989,375 @@ gdb_eval_agent_expr (struct eval_agent_expr_context *ctx,
ax_debug ("About to interpret byte 0x%x", op);
switch (op)
- {
- case gdb_agent_op_add:
- top += stack[--sp];
- break;
-
- case gdb_agent_op_sub:
- top = stack[--sp] - top;
- break;
-
- case gdb_agent_op_mul:
- top *= stack[--sp];
- break;
-
- case gdb_agent_op_div_signed:
- if (top == 0)
- {
- ax_debug ("Attempted to divide by zero");
- return expr_eval_divide_by_zero;
- }
- top = ((LONGEST) stack[--sp]) / ((LONGEST) top);
- break;
-
- case gdb_agent_op_div_unsigned:
- if (top == 0)
- {
- ax_debug ("Attempted to divide by zero");
- return expr_eval_divide_by_zero;
- }
- top = stack[--sp] / top;
- break;
-
- case gdb_agent_op_rem_signed:
- if (top == 0)
- {
- ax_debug ("Attempted to divide by zero");
- return expr_eval_divide_by_zero;
- }
- top = ((LONGEST) stack[--sp]) % ((LONGEST) top);
- break;
-
- case gdb_agent_op_rem_unsigned:
- if (top == 0)
- {
- ax_debug ("Attempted to divide by zero");
- return expr_eval_divide_by_zero;
- }
- top = stack[--sp] % top;
- break;
-
- case gdb_agent_op_lsh:
- top = stack[--sp] << top;
- break;
-
- case gdb_agent_op_rsh_signed:
- top = ((LONGEST) stack[--sp]) >> top;
- break;
-
- case gdb_agent_op_rsh_unsigned:
- top = stack[--sp] >> top;
- break;
-
- case gdb_agent_op_trace:
- agent_mem_read (ctx, NULL, (CORE_ADDR) stack[--sp],
- (ULONGEST) top);
- if (--sp >= 0)
- top = stack[sp];
- break;
-
- case gdb_agent_op_trace_quick:
- arg = aexpr->bytes[pc++];
- agent_mem_read (ctx, NULL, (CORE_ADDR) top, (ULONGEST) arg);
- break;
-
- case gdb_agent_op_log_not:
- top = !top;
- break;
-
- case gdb_agent_op_bit_and:
- top &= stack[--sp];
- break;
-
- case gdb_agent_op_bit_or:
- top |= stack[--sp];
- break;
-
- case gdb_agent_op_bit_xor:
- top ^= stack[--sp];
- break;
-
- case gdb_agent_op_bit_not:
- top = ~top;
- break;
-
- case gdb_agent_op_equal:
- top = (stack[--sp] == top);
- break;
-
- case gdb_agent_op_less_signed:
- top = (((LONGEST) stack[--sp]) < ((LONGEST) top));
- break;
-
- case gdb_agent_op_less_unsigned:
- top = (stack[--sp] < top);
- break;
-
- case gdb_agent_op_ext:
- arg = aexpr->bytes[pc++];
- if (arg < (sizeof (LONGEST) * 8))
- {
- LONGEST mask = 1 << (arg - 1);
- top &= ((LONGEST) 1 << arg) - 1;
- top = (top ^ mask) - mask;
- }
- break;
-
- case gdb_agent_op_ref8:
- agent_mem_read (ctx, cnv.u8.bytes, (CORE_ADDR) top, 1);
- top = cnv.u8.val;
- break;
-
- case gdb_agent_op_ref16:
- agent_mem_read (ctx, cnv.u16.bytes, (CORE_ADDR) top, 2);
- top = cnv.u16.val;
- break;
-
- case gdb_agent_op_ref32:
- agent_mem_read (ctx, cnv.u32.bytes, (CORE_ADDR) top, 4);
- top = cnv.u32.val;
- break;
-
- case gdb_agent_op_ref64:
- agent_mem_read (ctx, cnv.u64.bytes, (CORE_ADDR) top, 8);
- top = cnv.u64.val;
- break;
-
- case gdb_agent_op_if_goto:
- if (top)
- pc = (aexpr->bytes[pc] << 8) + (aexpr->bytes[pc + 1]);
- else
- pc += 2;
- if (--sp >= 0)
- top = stack[sp];
- break;
-
- case gdb_agent_op_goto:
- pc = (aexpr->bytes[pc] << 8) + (aexpr->bytes[pc + 1]);
- break;
-
- case gdb_agent_op_const8:
- /* Flush the cached stack top. */
- stack[sp++] = top;
- top = aexpr->bytes[pc++];
- break;
-
- case gdb_agent_op_const16:
- /* Flush the cached stack top. */
- stack[sp++] = top;
- top = aexpr->bytes[pc++];
- top = (top << 8) + aexpr->bytes[pc++];
- break;
-
- case gdb_agent_op_const32:
- /* Flush the cached stack top. */
- stack[sp++] = top;
- top = aexpr->bytes[pc++];
- top = (top << 8) + aexpr->bytes[pc++];
- top = (top << 8) + aexpr->bytes[pc++];
- top = (top << 8) + aexpr->bytes[pc++];
- break;
-
- case gdb_agent_op_const64:
- /* Flush the cached stack top. */
- stack[sp++] = top;
- top = aexpr->bytes[pc++];
- top = (top << 8) + aexpr->bytes[pc++];
- top = (top << 8) + aexpr->bytes[pc++];
- top = (top << 8) + aexpr->bytes[pc++];
- top = (top << 8) + aexpr->bytes[pc++];
- top = (top << 8) + aexpr->bytes[pc++];
- top = (top << 8) + aexpr->bytes[pc++];
- top = (top << 8) + aexpr->bytes[pc++];
- break;
-
- case gdb_agent_op_reg:
- /* Flush the cached stack top. */
- stack[sp++] = top;
- arg = aexpr->bytes[pc++];
- arg = (arg << 8) + aexpr->bytes[pc++];
- {
- int regnum = arg;
- struct regcache *regcache = ctx->regcache;
-
- switch (register_size (regcache->tdesc, regnum))
- {
- case 8:
- collect_register (regcache, regnum, cnv.u64.bytes);
- top = cnv.u64.val;
- break;
- case 4:
- collect_register (regcache, regnum, cnv.u32.bytes);
- top = cnv.u32.val;
- break;
- case 2:
- collect_register (regcache, regnum, cnv.u16.bytes);
- top = cnv.u16.val;
- break;
- case 1:
- collect_register (regcache, regnum, cnv.u8.bytes);
- top = cnv.u8.val;
- break;
- default:
- internal_error ("unhandled register size");
- }
- }
- break;
-
- case gdb_agent_op_end:
- ax_debug ("At end of expression, sp=%d, stack top cache=0x%s",
- sp, pulongest (top));
- if (rslt)
- {
- if (sp <= 0)
- {
- /* This should be an error */
- ax_debug ("Stack is empty, nothing to return");
- return expr_eval_empty_stack;
- }
- *rslt = top;
- }
- return expr_eval_no_error;
-
- case gdb_agent_op_dup:
- stack[sp++] = top;
- break;
-
- case gdb_agent_op_pop:
- if (--sp >= 0)
- top = stack[sp];
- break;
-
- case gdb_agent_op_pick:
- arg = aexpr->bytes[pc++];
- stack[sp] = top;
- top = stack[sp - arg];
- ++sp;
- break;
-
- case gdb_agent_op_rot:
- {
- ULONGEST tem = stack[sp - 1];
-
- stack[sp - 1] = stack[sp - 2];
- stack[sp - 2] = top;
- top = tem;
- }
- break;
-
- case gdb_agent_op_zero_ext:
- arg = aexpr->bytes[pc++];
- if (arg < (sizeof (LONGEST) * 8))
- top &= ((LONGEST) 1 << arg) - 1;
- break;
-
- case gdb_agent_op_swap:
- /* Interchange top two stack elements, making sure top gets
+ {
+ case gdb_agent_op_add:
+ top += stack[--sp];
+ break;
+
+ case gdb_agent_op_sub:
+ top = stack[--sp] - top;
+ break;
+
+ case gdb_agent_op_mul:
+ top *= stack[--sp];
+ break;
+
+ case gdb_agent_op_div_signed:
+ if (top == 0)
+ {
+ ax_debug ("Attempted to divide by zero");
+ return expr_eval_divide_by_zero;
+ }
+ top = ((LONGEST) stack[--sp]) / ((LONGEST) top);
+ break;
+
+ case gdb_agent_op_div_unsigned:
+ if (top == 0)
+ {
+ ax_debug ("Attempted to divide by zero");
+ return expr_eval_divide_by_zero;
+ }
+ top = stack[--sp] / top;
+ break;
+
+ case gdb_agent_op_rem_signed:
+ if (top == 0)
+ {
+ ax_debug ("Attempted to divide by zero");
+ return expr_eval_divide_by_zero;
+ }
+ top = ((LONGEST) stack[--sp]) % ((LONGEST) top);
+ break;
+
+ case gdb_agent_op_rem_unsigned:
+ if (top == 0)
+ {
+ ax_debug ("Attempted to divide by zero");
+ return expr_eval_divide_by_zero;
+ }
+ top = stack[--sp] % top;
+ break;
+
+ case gdb_agent_op_lsh:
+ top = stack[--sp] << top;
+ break;
+
+ case gdb_agent_op_rsh_signed:
+ top = ((LONGEST) stack[--sp]) >> top;
+ break;
+
+ case gdb_agent_op_rsh_unsigned:
+ top = stack[--sp] >> top;
+ break;
+
+ case gdb_agent_op_trace:
+ agent_mem_read (ctx, NULL, (CORE_ADDR) stack[--sp], (ULONGEST) top);
+ if (--sp >= 0)
+ top = stack[sp];
+ break;
+
+ case gdb_agent_op_trace_quick:
+ arg = aexpr->bytes[pc++];
+ agent_mem_read (ctx, NULL, (CORE_ADDR) top, (ULONGEST) arg);
+ break;
+
+ case gdb_agent_op_log_not:
+ top = !top;
+ break;
+
+ case gdb_agent_op_bit_and:
+ top &= stack[--sp];
+ break;
+
+ case gdb_agent_op_bit_or:
+ top |= stack[--sp];
+ break;
+
+ case gdb_agent_op_bit_xor:
+ top ^= stack[--sp];
+ break;
+
+ case gdb_agent_op_bit_not:
+ top = ~top;
+ break;
+
+ case gdb_agent_op_equal:
+ top = (stack[--sp] == top);
+ break;
+
+ case gdb_agent_op_less_signed:
+ top = (((LONGEST) stack[--sp]) < ((LONGEST) top));
+ break;
+
+ case gdb_agent_op_less_unsigned:
+ top = (stack[--sp] < top);
+ break;
+
+ case gdb_agent_op_ext:
+ arg = aexpr->bytes[pc++];
+ if (arg < (sizeof (LONGEST) * 8))
+ {
+ LONGEST mask = 1 << (arg - 1);
+ top &= ((LONGEST) 1 << arg) - 1;
+ top = (top ^ mask) - mask;
+ }
+ break;
+
+ case gdb_agent_op_ref8:
+ agent_mem_read (ctx, cnv.u8.bytes, (CORE_ADDR) top, 1);
+ top = cnv.u8.val;
+ break;
+
+ case gdb_agent_op_ref16:
+ agent_mem_read (ctx, cnv.u16.bytes, (CORE_ADDR) top, 2);
+ top = cnv.u16.val;
+ break;
+
+ case gdb_agent_op_ref32:
+ agent_mem_read (ctx, cnv.u32.bytes, (CORE_ADDR) top, 4);
+ top = cnv.u32.val;
+ break;
+
+ case gdb_agent_op_ref64:
+ agent_mem_read (ctx, cnv.u64.bytes, (CORE_ADDR) top, 8);
+ top = cnv.u64.val;
+ break;
+
+ case gdb_agent_op_if_goto:
+ if (top)
+ pc = (aexpr->bytes[pc] << 8) + (aexpr->bytes[pc + 1]);
+ else
+ pc += 2;
+ if (--sp >= 0)
+ top = stack[sp];
+ break;
+
+ case gdb_agent_op_goto:
+ pc = (aexpr->bytes[pc] << 8) + (aexpr->bytes[pc + 1]);
+ break;
+
+ case gdb_agent_op_const8:
+ /* Flush the cached stack top. */
+ stack[sp++] = top;
+ top = aexpr->bytes[pc++];
+ break;
+
+ case gdb_agent_op_const16:
+ /* Flush the cached stack top. */
+ stack[sp++] = top;
+ top = aexpr->bytes[pc++];
+ top = (top << 8) + aexpr->bytes[pc++];
+ break;
+
+ case gdb_agent_op_const32:
+ /* Flush the cached stack top. */
+ stack[sp++] = top;
+ top = aexpr->bytes[pc++];
+ top = (top << 8) + aexpr->bytes[pc++];
+ top = (top << 8) + aexpr->bytes[pc++];
+ top = (top << 8) + aexpr->bytes[pc++];
+ break;
+
+ case gdb_agent_op_const64:
+ /* Flush the cached stack top. */
+ stack[sp++] = top;
+ top = aexpr->bytes[pc++];
+ top = (top << 8) + aexpr->bytes[pc++];
+ top = (top << 8) + aexpr->bytes[pc++];
+ top = (top << 8) + aexpr->bytes[pc++];
+ top = (top << 8) + aexpr->bytes[pc++];
+ top = (top << 8) + aexpr->bytes[pc++];
+ top = (top << 8) + aexpr->bytes[pc++];
+ top = (top << 8) + aexpr->bytes[pc++];
+ break;
+
+ case gdb_agent_op_reg:
+ /* Flush the cached stack top. */
+ stack[sp++] = top;
+ arg = aexpr->bytes[pc++];
+ arg = (arg << 8) + aexpr->bytes[pc++];
+ {
+ int regnum = arg;
+ struct regcache *regcache = ctx->regcache;
+
+ switch (register_size (regcache->tdesc, regnum))
+ {
+ case 8:
+ collect_register (regcache, regnum, cnv.u64.bytes);
+ top = cnv.u64.val;
+ break;
+ case 4:
+ collect_register (regcache, regnum, cnv.u32.bytes);
+ top = cnv.u32.val;
+ break;
+ case 2:
+ collect_register (regcache, regnum, cnv.u16.bytes);
+ top = cnv.u16.val;
+ break;
+ case 1:
+ collect_register (regcache, regnum, cnv.u8.bytes);
+ top = cnv.u8.val;
+ break;
+ default:
+ internal_error ("unhandled register size");
+ }
+ }
+ break;
+
+ case gdb_agent_op_end:
+ ax_debug ("At end of expression, sp=%d, stack top cache=0x%s", sp,
+ pulongest (top));
+ if (rslt)
+ {
+ if (sp <= 0)
+ {
+ /* This should be an error */
+ ax_debug ("Stack is empty, nothing to return");
+ return expr_eval_empty_stack;
+ }
+ *rslt = top;
+ }
+ return expr_eval_no_error;
+
+ case gdb_agent_op_dup:
+ stack[sp++] = top;
+ break;
+
+ case gdb_agent_op_pop:
+ if (--sp >= 0)
+ top = stack[sp];
+ break;
+
+ case gdb_agent_op_pick:
+ arg = aexpr->bytes[pc++];
+ stack[sp] = top;
+ top = stack[sp - arg];
+ ++sp;
+ break;
+
+ case gdb_agent_op_rot:
+ {
+ ULONGEST tem = stack[sp - 1];
+
+ stack[sp - 1] = stack[sp - 2];
+ stack[sp - 2] = top;
+ top = tem;
+ }
+ break;
+
+ case gdb_agent_op_zero_ext:
+ arg = aexpr->bytes[pc++];
+ if (arg < (sizeof (LONGEST) * 8))
+ top &= ((LONGEST) 1 << arg) - 1;
+ break;
+
+ case gdb_agent_op_swap:
+ /* Interchange top two stack elements, making sure top gets
copied back onto stack. */
- stack[sp] = top;
- top = stack[sp - 1];
- stack[sp - 1] = stack[sp];
- break;
-
- case gdb_agent_op_getv:
- /* Flush the cached stack top. */
- stack[sp++] = top;
- arg = aexpr->bytes[pc++];
- arg = (arg << 8) + aexpr->bytes[pc++];
- top = agent_get_trace_state_variable_value (arg);
- break;
-
- case gdb_agent_op_setv:
- arg = aexpr->bytes[pc++];
- arg = (arg << 8) + aexpr->bytes[pc++];
- agent_set_trace_state_variable_value (arg, top);
- /* Note that we leave the value on the stack, for the
+ stack[sp] = top;
+ top = stack[sp - 1];
+ stack[sp - 1] = stack[sp];
+ break;
+
+ case gdb_agent_op_getv:
+ /* Flush the cached stack top. */
+ stack[sp++] = top;
+ arg = aexpr->bytes[pc++];
+ arg = (arg << 8) + aexpr->bytes[pc++];
+ top = agent_get_trace_state_variable_value (arg);
+ break;
+
+ case gdb_agent_op_setv:
+ arg = aexpr->bytes[pc++];
+ arg = (arg << 8) + aexpr->bytes[pc++];
+ agent_set_trace_state_variable_value (arg, top);
+ /* Note that we leave the value on the stack, for the
benefit of later/enclosing expressions. */
- break;
-
- case gdb_agent_op_tracev:
- arg = aexpr->bytes[pc++];
- arg = (arg << 8) + aexpr->bytes[pc++];
- agent_tsv_read (ctx, arg);
- break;
-
- case gdb_agent_op_tracenz:
- agent_mem_read_string (ctx, NULL, (CORE_ADDR) stack[--sp],
- (ULONGEST) top);
- if (--sp >= 0)
- top = stack[sp];
- break;
-
- case gdb_agent_op_printf:
- {
- int nargs, slen, i;
- CORE_ADDR fn = 0, chan = 0;
- /* Can't have more args than the entire size of the stack. */
- ULONGEST args[STACK_MAX];
- char *format;
-
- nargs = aexpr->bytes[pc++];
- slen = aexpr->bytes[pc++];
- slen = (slen << 8) + aexpr->bytes[pc++];
- format = (char *) &(aexpr->bytes[pc]);
- pc += slen;
- /* Pop function and channel. */
- fn = top;
- if (--sp >= 0)
- top = stack[sp];
- chan = top;
- if (--sp >= 0)
- top = stack[sp];
- /* Pop arguments into a dedicated array. */
- for (i = 0; i < nargs; ++i)
- {
- args[i] = top;
- if (--sp >= 0)
- top = stack[sp];
- }
-
- /* A bad format string means something is very wrong; give
+ break;
+
+ case gdb_agent_op_tracev:
+ arg = aexpr->bytes[pc++];
+ arg = (arg << 8) + aexpr->bytes[pc++];
+ agent_tsv_read (ctx, arg);
+ break;
+
+ case gdb_agent_op_tracenz:
+ agent_mem_read_string (ctx, NULL, (CORE_ADDR) stack[--sp],
+ (ULONGEST) top);
+ if (--sp >= 0)
+ top = stack[sp];
+ break;
+
+ case gdb_agent_op_printf:
+ {
+ int nargs, slen, i;
+ CORE_ADDR fn = 0, chan = 0;
+ /* Can't have more args than the entire size of the stack. */
+ ULONGEST args[STACK_MAX];
+ char *format;
+
+ nargs = aexpr->bytes[pc++];
+ slen = aexpr->bytes[pc++];
+ slen = (slen << 8) + aexpr->bytes[pc++];
+ format = (char *) &(aexpr->bytes[pc]);
+ pc += slen;
+ /* Pop function and channel. */
+ fn = top;
+ if (--sp >= 0)
+ top = stack[sp];
+ chan = top;
+ if (--sp >= 0)
+ top = stack[sp];
+ /* Pop arguments into a dedicated array. */
+ for (i = 0; i < nargs; ++i)
+ {
+ args[i] = top;
+ if (--sp >= 0)
+ top = stack[sp];
+ }
+
+ /* A bad format string means something is very wrong; give
up immediately. */
- if (format[slen - 1] != '\0')
- error (_("Unterminated format string in printf bytecode"));
-
- ax_printf (fn, chan, format, nargs, args);
- }
- break;
-
- /* GDB never (currently) generates any of these ops. */
- case gdb_agent_op_float:
- case gdb_agent_op_ref_float:
- case gdb_agent_op_ref_double:
- case gdb_agent_op_ref_long_double:
- case gdb_agent_op_l_to_d:
- case gdb_agent_op_d_to_l:
- case gdb_agent_op_trace16:
- ax_debug ("Agent expression op 0x%x valid, but not handled",
- op);
- /* If ever GDB generates any of these, we don't have the
+ if (format[slen - 1] != '\0')
+ error (_ ("Unterminated format string in printf bytecode"));
+
+ ax_printf (fn, chan, format, nargs, args);
+ }
+ break;
+
+ /* GDB never (currently) generates any of these ops. */
+ case gdb_agent_op_float:
+ case gdb_agent_op_ref_float:
+ case gdb_agent_op_ref_double:
+ case gdb_agent_op_ref_long_double:
+ case gdb_agent_op_l_to_d:
+ case gdb_agent_op_d_to_l:
+ case gdb_agent_op_trace16:
+ ax_debug ("Agent expression op 0x%x valid, but not handled", op);
+ /* If ever GDB generates any of these, we don't have the
option of ignoring. */
- return expr_eval_unhandled_opcode;
+ return expr_eval_unhandled_opcode;
- default:
- ax_debug ("Agent expression op 0x%x not recognized", op);
- /* Don't struggle on, things will just get worse. */
- return expr_eval_unrecognized_opcode;
- }
+ default:
+ ax_debug ("Agent expression op 0x%x not recognized", op);
+ /* Don't struggle on, things will just get worse. */
+ return expr_eval_unrecognized_opcode;
+ }
/* Check for stack badness. */
if (sp >= (STACK_MAX - 1))
- {
- ax_debug ("Expression stack overflow");
- return expr_eval_stack_overflow;
- }
+ {
+ ax_debug ("Expression stack overflow");
+ return expr_eval_stack_overflow;
+ }
if (sp < 0)
- {
- ax_debug ("Expression stack underflow");
- return expr_eval_stack_underflow;
- }
+ {
+ ax_debug ("Expression stack underflow");
+ return expr_eval_stack_underflow;
+ }
- ax_debug ("Op %s -> sp=%d, top=0x%s",
- gdb_agent_op_name (op), sp, phex_nz (top, 0));
+ ax_debug ("Op %s -> sp=%d, top=0x%s", gdb_agent_op_name (op), sp,
+ phex_nz (top, 0));
}
}
diff --git a/gdbserver/ax.h b/gdbserver/ax.h
index 8e64a7a..0fb09b2 100644
--- a/gdbserver/ax.h
+++ b/gdbserver/ax.h
@@ -32,17 +32,17 @@ struct traceframe;
agent expression evaluation. */
enum eval_result_type
- {
- expr_eval_no_error,
- expr_eval_empty_expression,
- expr_eval_empty_stack,
- expr_eval_stack_overflow,
- expr_eval_stack_underflow,
- expr_eval_unhandled_opcode,
- expr_eval_unrecognized_opcode,
- expr_eval_divide_by_zero,
- expr_eval_invalid_goto
- };
+{
+ expr_eval_no_error,
+ expr_eval_empty_expression,
+ expr_eval_empty_stack,
+ expr_eval_stack_overflow,
+ expr_eval_stack_underflow,
+ expr_eval_unhandled_opcode,
+ expr_eval_unrecognized_opcode,
+ expr_eval_divide_by_zero,
+ expr_eval_invalid_goto
+};
struct agent_expr
{
@@ -81,10 +81,9 @@ struct eval_agent_expr_context
struct tracepoint *tpoint;
};
-enum eval_result_type
- gdb_eval_agent_expr (struct eval_agent_expr_context *ctx,
- struct agent_expr *aexpr,
- ULONGEST *rslt);
+enum eval_result_type gdb_eval_agent_expr (struct eval_agent_expr_context *ctx,
+ struct agent_expr *aexpr,
+ ULONGEST *rslt);
/* Bytecode compilation function vector. */
diff --git a/gdbserver/debug.cc b/gdbserver/debug.cc
index 2426c91..28cdb78 100644
--- a/gdbserver/debug.cc
+++ b/gdbserver/debug.cc
@@ -19,7 +19,7 @@
#include "server.h"
#include <chrono>
-#if !defined (IN_PROCESS_AGENT)
+#if !defined(IN_PROCESS_AGENT)
bool remote_debug = false;
#endif
@@ -32,7 +32,7 @@ bool debug_threads;
/* Include timestamps in debugging output. */
int debug_timestamp;
-#if !defined (IN_PROCESS_AGENT)
+#if !defined(IN_PROCESS_AGENT)
/* See debug.h. */
@@ -55,7 +55,7 @@ debug_set_output (const char *new_debug_file)
if (fptr == nullptr)
{
debug_printf ("Cannot open %s for writing. %s. Switching to stderr.\n",
- new_debug_file, safe_strerror (errno));
+ new_debug_file, safe_strerror (errno));
return;
}
@@ -76,7 +76,7 @@ int debug_print_depth = 0;
void
debug_vprintf (const char *format, va_list ap)
{
-#if !defined (IN_PROCESS_AGENT)
+#if !defined(IN_PROCESS_AGENT)
/* N.B. Not thread safe, and can't be used, as is, with IPA. */
static int new_line = 1;
@@ -86,15 +86,17 @@ debug_vprintf (const char *format, va_list ap)
steady_clock::time_point now = steady_clock::now ();
seconds s = duration_cast<seconds> (now.time_since_epoch ());
- microseconds us = duration_cast<microseconds> (now.time_since_epoch ()) - s;
+ microseconds us
+ = duration_cast<microseconds> (now.time_since_epoch ()) - s;
- fprintf (debug_file, "%ld.%06ld ", (long) s.count (), (long) us.count ());
+ fprintf (debug_file, "%ld.%06ld ", (long) s.count (),
+ (long) us.count ());
}
#endif
vfprintf (debug_file, format, ap);
-#if !defined (IN_PROCESS_AGENT)
+#if !defined(IN_PROCESS_AGENT)
if (*format)
new_line = format[strlen (format) - 1] == '\n';
#endif
diff --git a/gdbserver/debug.h b/gdbserver/debug.h
index 6b733ef..8925052 100644
--- a/gdbserver/debug.h
+++ b/gdbserver/debug.h
@@ -19,14 +19,13 @@
#ifndef GDBSERVER_DEBUG_H
#define GDBSERVER_DEBUG_H
-#if !defined (IN_PROCESS_AGENT)
+#if !defined(IN_PROCESS_AGENT)
extern bool remote_debug;
/* Print a "remote" debug statement. */
#define remote_debug_printf(fmt, ...) \
- debug_prefixed_printf_cond (remote_debug, \
- "remote", fmt, ##__VA_ARGS__)
+ debug_prefixed_printf_cond (remote_debug, "remote", fmt, ##__VA_ARGS__)
/* Switch all debug output to DEBUG_FILE. If DEBUG_FILE is nullptr or an
empty string, or if the file cannot be opened, then debug output is sent to
@@ -44,8 +43,7 @@ extern bool debug_threads;
/* Print a "threads" debug statement. */
#define threads_debug_printf(fmt, ...) \
- debug_prefixed_printf_cond (debug_threads, \
- "threads", fmt, ##__VA_ARGS__)
+ debug_prefixed_printf_cond (debug_threads, "threads", fmt, ##__VA_ARGS__)
/* Print "threads" enter/exit debug statements. */
diff --git a/gdbserver/dll.cc b/gdbserver/dll.cc
index 15d0c5d..205baca 100644
--- a/gdbserver/dll.cc
+++ b/gdbserver/dll.cc
@@ -57,20 +57,18 @@ void
unloaded_dll (process_info *proc, const char *name, CORE_ADDR base_addr)
{
gdb_assert (proc != nullptr);
- auto pred = [&] (const dll_info &dll)
- {
- if (base_addr != UNSPECIFIED_CORE_ADDR
- && base_addr == dll.base_addr)
- return true;
+ auto pred = [&] (const dll_info &dll) {
+ if (base_addr != UNSPECIFIED_CORE_ADDR && base_addr == dll.base_addr)
+ return true;
- if (name != NULL && dll.name == name)
- return true;
+ if (name != NULL && dll.name == name)
+ return true;
- return false;
- };
+ return false;
+ };
- auto iter = std::find_if (proc->all_dlls.begin (), proc->all_dlls.end (),
- pred);
+ auto iter
+ = std::find_if (proc->all_dlls.begin (), proc->all_dlls.end (), pred);
if (iter == proc->all_dlls.end ())
/* For some inferiors we might get unloaded_dll events without having
@@ -94,8 +92,5 @@ unloaded_dll (process_info *proc, const char *name, CORE_ADDR base_addr)
void
clear_dlls (void)
{
- for_each_process ([] (process_info *proc)
- {
- proc->all_dlls.clear ();
- });
+ for_each_process ([] (process_info *proc) { proc->all_dlls.clear (); });
}
diff --git a/gdbserver/dll.h b/gdbserver/dll.h
index a5bb2a0..df9610f 100644
--- a/gdbserver/dll.h
+++ b/gdbserver/dll.h
@@ -25,8 +25,10 @@ struct process_info;
struct dll_info
{
dll_info (const std::string &name_, CORE_ADDR base_addr_)
- : name (name_), base_addr (base_addr_)
- {}
+ : name (name_),
+ base_addr (base_addr_)
+ {
+ }
std::string name;
CORE_ADDR base_addr;
@@ -35,9 +37,9 @@ struct dll_info
extern void clear_dlls (void);
extern void loaded_dll (const char *name, CORE_ADDR base_addr);
extern void loaded_dll (process_info *proc, const char *name,
- CORE_ADDR base_addr);
+ CORE_ADDR base_addr);
extern void unloaded_dll (const char *name, CORE_ADDR base_addr);
extern void unloaded_dll (process_info *proc, const char *name,
- CORE_ADDR base_addr);
+ CORE_ADDR base_addr);
#endif /* GDBSERVER_DLL_H */
diff --git a/gdbserver/fork-child.cc b/gdbserver/fork-child.cc
index e791a8d..ef4c16d 100644
--- a/gdbserver/fork-child.cc
+++ b/gdbserver/fork-child.cc
@@ -77,7 +77,7 @@ postfork_child_hook ()
debug_setpgrp = gdb_setpgid ();
if (debug_setpgrp == -1)
- perror (_("setpgrp failed in child"));
+ perror (_ ("setpgrp failed in child"));
}
/* See nat/fork-inferior.h. */
@@ -113,9 +113,8 @@ post_fork_inferior (int pid, const char *program)
scoped_restore. */
proc->starting_up = true;
- startup_inferior (the_target, pid,
- START_INFERIOR_TRAPS_EXPECTED,
- &cs.last_status, &cs.last_ptid);
+ startup_inferior (the_target, pid, START_INFERIOR_TRAPS_EXPECTED,
+ &cs.last_status, &cs.last_ptid);
/* If we get here, the process was successfully started. */
proc->starting_up = false;
diff --git a/gdbserver/gdbreplay.cc b/gdbserver/gdbreplay.cc
index 42a512a..cf6af57 100644
--- a/gdbserver/gdbreplay.cc
+++ b/gdbserver/gdbreplay.cc
@@ -74,7 +74,7 @@ sync_error (FILE *fp, const char *desc, int expect, int got)
{
fprintf (stderr, "\n%s\n", desc);
fprintf (stderr, "At logfile offset %ld, expected '0x%x' got '0x%x'\n",
- ftell (fp), expect, got);
+ ftell (fp), expect, got);
fflush (stderr);
exit (1);
}
@@ -142,7 +142,7 @@ remote_open (const char *name)
parsed_connection_spec parsed = parse_connection_spec (name, &hint);
if (parsed.port_str.empty ())
- error (_("Missing port on hostname '%s'"), name);
+ error (_ ("Missing port on hostname '%s'"), name);
#ifdef USE_WIN32API
if (!winsock_initialized)
@@ -155,13 +155,13 @@ remote_open (const char *name)
#endif
int r = getaddrinfo (parsed.host_str.c_str (), parsed.port_str.c_str (),
- &hint, &ainfo);
+ &hint, &ainfo);
if (r != 0)
{
fprintf (stderr, "%s:%s: cannot resolve name: %s\n",
- parsed.host_str.c_str (), parsed.port_str.c_str (),
- gai_strerror (r));
+ parsed.host_str.c_str (), parsed.port_str.c_str (),
+ gai_strerror (r));
fflush (stderr);
exit (1);
}
@@ -175,7 +175,7 @@ remote_open (const char *name)
tmp_desc = socket (p->ai_family, p->ai_socktype, p->ai_protocol);
if (tmp_desc >= 0)
- break;
+ break;
}
if (p == NULL)
@@ -183,8 +183,7 @@ remote_open (const char *name)
/* Allow rapid reuse of this port. */
tmp = 1;
- setsockopt (tmp_desc, SOL_SOCKET, SO_REUSEADDR, (char *) &tmp,
- sizeof (tmp));
+ setsockopt (tmp_desc, SOL_SOCKET, SO_REUSEADDR, (char *) &tmp, sizeof (tmp));
switch (p->ai_family)
{
@@ -211,47 +210,47 @@ remote_open (const char *name)
char orig_host[GDB_NI_MAX_ADDR], orig_port[GDB_NI_MAX_PORT];
if (listen (tmp_desc, 1) != 0)
- perror_with_name ("Can't listen on socket");
+ perror_with_name ("Can't listen on socket");
- remote_desc_in = accept (tmp_desc, (struct sockaddr *) &sockaddr,
- &sockaddrsize);
+ remote_desc_in
+ = accept (tmp_desc, (struct sockaddr *) &sockaddr, &sockaddrsize);
if (remote_desc_in == -1)
- perror_with_name ("Accept failed");
+ perror_with_name ("Accept failed");
/* Enable TCP keep alive process. */
tmp = 1;
- setsockopt (tmp_desc, SOL_SOCKET, SO_KEEPALIVE,
- (char *) &tmp, sizeof (tmp));
+ setsockopt (tmp_desc, SOL_SOCKET, SO_KEEPALIVE, (char *) &tmp,
+ sizeof (tmp));
/* Tell TCP not to delay small packets. This greatly speeds up
interactive response. */
tmp = 1;
- setsockopt (remote_desc_in, IPPROTO_TCP, TCP_NODELAY,
- (char *) &tmp, sizeof (tmp));
-
- if (getnameinfo ((struct sockaddr *) &sockaddr, sockaddrsize,
- orig_host, sizeof (orig_host),
- orig_port, sizeof (orig_port),
- NI_NUMERICHOST | NI_NUMERICSERV) == 0)
- {
- fprintf (stderr, "Remote debugging from host %s, port %s\n",
- orig_host, orig_port);
- fflush (stderr);
- }
+ setsockopt (remote_desc_in, IPPROTO_TCP, TCP_NODELAY, (char *) &tmp,
+ sizeof (tmp));
+
+ if (getnameinfo ((struct sockaddr *) &sockaddr, sockaddrsize, orig_host,
+ sizeof (orig_host), orig_port, sizeof (orig_port),
+ NI_NUMERICHOST | NI_NUMERICSERV)
+ == 0)
+ {
+ fprintf (stderr, "Remote debugging from host %s, port %s\n",
+ orig_host, orig_port);
+ fflush (stderr);
+ }
#ifndef USE_WIN32API
- close (tmp_desc); /* No longer need this */
+ close (tmp_desc); /* No longer need this */
- signal (SIGPIPE, SIG_IGN); /* If we don't do this, then
+ signal (SIGPIPE, SIG_IGN); /* If we don't do this, then
gdbreplay simply exits when
the remote side dies. */
#else
- closesocket (tmp_desc); /* No longer need this */
+ closesocket (tmp_desc); /* No longer need this */
#endif
}
-#if defined(F_SETFL) && defined (FASYNC)
+#if defined(F_SETFL) && defined(FASYNC)
fcntl (remote_desc_in, F_SETFL, FASYNC);
#endif
remote_desc_out = remote_desc_in;
@@ -278,12 +277,12 @@ logchar (FILE *fp)
case '\r':
ch = fgetc (fp);
if (ch == '\n')
- ch = EOL;
+ ch = EOL;
else
- {
- ungetc (ch, fp);
- ch = '\r';
- }
+ {
+ ungetc (ch, fp);
+ ch = '\r';
+ }
fputc (ch == EOL ? '\n' : '\r', stderr);
fflush (stderr);
break;
@@ -295,41 +294,41 @@ logchar (FILE *fp)
fputc (ch, stderr);
fflush (stderr);
switch (ch)
- {
- case '\\':
- break;
- case 'b':
- ch = '\b';
- break;
- case 'f':
- ch = '\f';
- break;
- case 'n':
- ch = '\n';
- break;
- case 'r':
- ch = '\r';
- break;
- case 't':
- ch = '\t';
- break;
- case 'v':
- ch = '\v';
- break;
- case 'x':
- ch2 = fgetc (fp);
- fputc (ch2, stderr);
- fflush (stderr);
- ch = fromhex (ch2) << 4;
- ch2 = fgetc (fp);
- fputc (ch2, stderr);
- fflush (stderr);
- ch |= fromhex (ch2);
- break;
- default:
- /* Treat any other char as just itself */
- break;
- }
+ {
+ case '\\':
+ break;
+ case 'b':
+ ch = '\b';
+ break;
+ case 'f':
+ ch = '\f';
+ break;
+ case 'n':
+ ch = '\n';
+ break;
+ case 'r':
+ ch = '\r';
+ break;
+ case 't':
+ ch = '\t';
+ break;
+ case 'v':
+ ch = '\v';
+ break;
+ case 'x':
+ ch2 = fgetc (fp);
+ fputc (ch2, stderr);
+ fflush (stderr);
+ ch = fromhex (ch2) << 4;
+ ch2 = fgetc (fp);
+ fputc (ch2, stderr);
+ fflush (stderr);
+ ch |= fromhex (ch2);
+ break;
+ default:
+ /* Treat any other char as just itself */
+ break;
+ }
default:
break;
}
@@ -359,23 +358,23 @@ expect (FILE *fp)
if ((fromlog = logchar (fp)) != ' ')
{
sync_error (fp, "Sync error during gdb read of leading blank", ' ',
- fromlog);
+ fromlog);
}
do
{
fromlog = logchar (fp);
if (fromlog == EOL)
- break;
+ break;
fromgdb = gdbchar (remote_desc_in);
if (fromgdb < 0)
- remote_error ("Error during read from gdb");
+ remote_error ("Error during read from gdb");
}
while (fromlog == fromgdb);
if (fromlog != EOL)
{
sync_error (fp, "Sync error during read of gdb packet from log", fromlog,
- fromgdb);
+ fromgdb);
}
}
@@ -391,13 +390,13 @@ play (FILE *fp)
if ((fromlog = logchar (fp)) != ' ')
{
sync_error (fp, "Sync error skipping blank during write to gdb", ' ',
- fromlog);
+ fromlog);
}
while ((fromlog = logchar (fp)) != EOL)
{
ch = fromlog;
if (write (remote_desc_out, &ch, 1) != 1)
- remote_error ("Error during write to gdb");
+ remote_error ("Error during write to gdb");
}
}
@@ -405,11 +404,11 @@ static void
gdbreplay_version (void)
{
printf ("GNU gdbreplay %s%s\n"
- "Copyright (C) 2023 Free Software Foundation, Inc.\n"
- "gdbreplay is free software, covered by "
- "the GNU General Public License.\n"
- "This gdbreplay was configured as \"%s\"\n",
- PKGVERSION, version, host_name);
+ "Copyright (C) 2023 Free Software Foundation, Inc.\n"
+ "gdbreplay is free software, covered by "
+ "the GNU General Public License.\n"
+ "This gdbreplay was configured as \"%s\"\n",
+ PKGVERSION, version, host_name);
}
static void
@@ -454,20 +453,21 @@ captured_main (int argc, char *argv[])
while ((ch = logchar (fp)) != EOF)
{
switch (ch)
- {
- case 'w':
- /* data sent from gdb to gdbreplay, accept and match it */
- expect (fp);
- break;
- case 'r':
- /* data sent from gdbreplay to gdb, play it */
- play (fp);
- break;
- case 'c':
- /* Command executed by gdb */
- while ((ch = logchar (fp)) != EOL);
- break;
- }
+ {
+ case 'w':
+ /* data sent from gdb to gdbreplay, accept and match it */
+ expect (fp);
+ break;
+ case 'r':
+ /* data sent from gdbreplay to gdb, play it */
+ play (fp);
+ break;
+ case 'c':
+ /* Command executed by gdb */
+ while ((ch = logchar (fp)) != EOL)
+ ;
+ break;
+ }
}
remote_close ();
exit (0);
@@ -483,10 +483,10 @@ main (int argc, char *argv[])
catch (const gdb_exception &exception)
{
if (exception.reason == RETURN_ERROR)
- {
- fflush (stdout);
- fprintf (stderr, "%s\n", exception.what ());
- }
+ {
+ fflush (stdout);
+ fprintf (stderr, "%s\n", exception.what ());
+ }
exit (1);
}
diff --git a/gdbserver/gdbthread.h b/gdbserver/gdbthread.h
index 493e1db..4d8b200 100644
--- a/gdbserver/gdbthread.h
+++ b/gdbserver/gdbthread.h
@@ -30,14 +30,13 @@ struct regcache;
struct thread_info
{
thread_info (ptid_t id, void *target_data)
- : id (id), target_data (target_data)
- {}
-
- ~thread_info ()
+ : id (id),
+ target_data (target_data)
{
- free_register_cache (this->regcache_data);
}
+ ~thread_info () { free_register_cache (this->regcache_data); }
+
/* The id of this thread. */
ptid_t id;
@@ -100,7 +99,7 @@ struct thread_info *find_any_thread_of_pid (int pid);
/* Find the first thread for which FUNC returns true. Return NULL if no thread
satisfying FUNC is found. */
-template <typename Func>
+template<typename Func>
static thread_info *
find_thread (Func func)
{
@@ -112,7 +111,7 @@ find_thread (Func func)
next++;
if (func (*cur))
- return *cur;
+ return *cur;
cur = next;
}
@@ -122,20 +121,19 @@ find_thread (Func func)
/* Like the above, but only consider threads with pid PID. */
-template <typename Func>
+template<typename Func>
static thread_info *
find_thread (int pid, Func func)
{
- return find_thread ([&] (thread_info *thread)
- {
- return thread->id.pid () == pid && func (thread);
- });
+ return find_thread ([&] (thread_info *thread) {
+ return thread->id.pid () == pid && func (thread);
+ });
}
/* Find the first thread that matches FILTER for which FUNC returns true.
Return NULL if no thread satisfying these conditions is found. */
-template <typename Func>
+template<typename Func>
static thread_info *
find_thread (ptid_t filter, Func func)
{
@@ -146,7 +144,7 @@ find_thread (ptid_t filter, Func func)
/* Invoke FUNC for each thread. */
-template <typename Func>
+template<typename Func>
static void
for_each_thread (Func func)
{
@@ -163,21 +161,20 @@ for_each_thread (Func func)
/* Like the above, but only consider threads with pid PID. */
-template <typename Func>
+template<typename Func>
static void
for_each_thread (int pid, Func func)
{
- for_each_thread ([&] (thread_info *thread)
- {
- if (pid == thread->id.pid ())
- func (thread);
- });
+ for_each_thread ([&] (thread_info *thread) {
+ if (pid == thread->id.pid ())
+ func (thread);
+ });
}
/* Find the a random thread for which FUNC (THREAD) returns true. If
no entry is found then return NULL. */
-template <typename Func>
+template<typename Func>
static thread_info *
find_thread_in_random (Func func)
{
@@ -194,8 +191,7 @@ find_thread_in_random (Func func)
return NULL;
/* Now randomly pick an entry out of those. */
- random_selector = (int)
- ((count * (double) rand ()) / (RAND_MAX + 1.0));
+ random_selector = (int) ((count * (double) rand ()) / (RAND_MAX + 1.0));
thread_info *thread = find_thread ([&] (thread_info *thr_arg) {
return func (thr_arg) && (random_selector-- == 0);
diff --git a/gdbserver/hostio.cc b/gdbserver/hostio.cc
index ea70c26..50aa185 100644
--- a/gdbserver/hostio.cc
+++ b/gdbserver/hostio.cc
@@ -54,10 +54,10 @@ safe_fromhex (char a, int *nibble)
/* Filenames are hex encoded, so the maximum we can handle is half the
packet buffer size. Cap to PATH_MAX, if it is shorter. */
-#if !defined (PATH_MAX) || (PATH_MAX > (PBUFSIZ / 2 + 1))
-# define HOSTIO_PATH_MAX (PBUFSIZ / 2 + 1)
+#if !defined(PATH_MAX) || (PATH_MAX > (PBUFSIZ / 2 + 1))
+#define HOSTIO_PATH_MAX (PBUFSIZ / 2 + 1)
#else
-# define HOSTIO_PATH_MAX PATH_MAX
+#define HOSTIO_PATH_MAX PATH_MAX
#endif
static int
@@ -75,11 +75,10 @@ require_filename (char **pp, char *filename)
/* Don't allow overflow. */
if (count >= HOSTIO_PATH_MAX - 1)
- return -1;
+ return -1;
- if (safe_fromhex (p[0], &nib1)
- || safe_fromhex (p[1], &nib2))
- return -1;
+ if (safe_fromhex (p[0], &nib1) || safe_fromhex (p[1], &nib2))
+ return -1;
filename[count++] = nib1 * 16 + nib2;
p += 2;
@@ -106,14 +105,14 @@ require_int (char **pp, int *value)
int nib;
if (safe_fromhex (p[0], &nib))
- return -1;
+ return -1;
if (firstdigit == -1)
- firstdigit = nib;
+ firstdigit = nib;
/* Don't allow overflow. */
if (count >= 8 || (count == 7 && firstdigit >= 0x8))
- return -1;
+ return -1;
*value = *value * 16 + nib;
p++;
@@ -138,14 +137,14 @@ require_data (char *p, int p_len, char **data, int *data_len)
char b = p[input_index];
if (escaped)
- {
- (*data)[output_index++] = b ^ 0x20;
- escaped = 0;
- }
+ {
+ (*data)[output_index++] = b ^ 0x20;
+ escaped = 0;
+ }
else if (b == '}')
- escaped = 1;
+ escaped = 1;
else
- (*data)[output_index++] = b;
+ (*data)[output_index++] = b;
}
if (escaped)
@@ -215,7 +214,7 @@ hostio_reply (char *own_buf, int result)
static int
hostio_reply_with_data (char *own_buf, char *buffer, int len,
- int *new_packet_len)
+ int *new_packet_len)
{
int input_index, output_index, out_maxlen;
@@ -229,19 +228,19 @@ hostio_reply_with_data (char *own_buf, char *buffer, int len,
char b = buffer[input_index];
if (b == '$' || b == '#' || b == '}' || b == '*')
- {
- /* These must be escaped. */
- if (output_index + 2 > out_maxlen)
- break;
- own_buf[output_index++] = '}';
- own_buf[output_index++] = b ^ 0x20;
- }
+ {
+ /* These must be escaped. */
+ if (output_index + 2 > out_maxlen)
+ break;
+ own_buf[output_index++] = '}';
+ own_buf[output_index++] = b ^ 0x20;
+ }
else
- {
- if (output_index + 1 > out_maxlen)
- break;
- own_buf[output_index++] = b;
- }
+ {
+ if (output_index + 1 > out_maxlen)
+ break;
+ own_buf[output_index++] = b;
+ }
}
*new_packet_len = output_index;
@@ -282,9 +281,7 @@ handle_setfs (char *own_buf)
p = own_buf + strlen ("vFile:setfs:");
- if (require_int (&p, &pid)
- || pid < 0
- || require_end (p))
+ if (require_int (&p, &pid) || pid < 0 || require_end (p))
{
hostio_packet_error (own_buf);
return;
@@ -306,12 +303,9 @@ handle_open (char *own_buf)
p = own_buf + strlen ("vFile:open:");
- if (require_filename (&p, filename)
- || require_comma (&p)
- || require_int (&p, &fileio_flags)
- || require_comma (&p)
- || require_int (&p, &fileio_mode)
- || require_end (p)
+ if (require_filename (&p, filename) || require_comma (&p)
+ || require_int (&p, &fileio_flags) || require_comma (&p)
+ || require_int (&p, &fileio_mode) || require_end (p)
|| fileio_to_host_openflags (fileio_flags, &flags)
|| fileio_to_host_mode (fileio_mode, &mode))
{
@@ -350,13 +344,9 @@ handle_pread (char *own_buf, int *new_packet_len)
p = own_buf + strlen ("vFile:pread:");
- if (require_int (&p, &fd)
- || require_comma (&p)
- || require_valid_fd (fd)
- || require_int (&p, &len)
- || require_comma (&p)
- || require_int (&p, &offset)
- || require_end (p))
+ if (require_int (&p, &fd) || require_comma (&p) || require_valid_fd (fd)
+ || require_int (&p, &len) || require_comma (&p)
+ || require_int (&p, &offset) || require_end (p))
{
hostio_packet_error (own_buf);
return;
@@ -384,7 +374,7 @@ handle_pread (char *own_buf, int *new_packet_len)
{
ret = lseek (fd, offset, SEEK_SET);
if (ret != -1)
- ret = read (fd, data, len);
+ ret = read (fd, data, len);
}
if (ret == -1)
@@ -402,8 +392,8 @@ handle_pread (char *own_buf, int *new_packet_len)
packet might be wrong, so we must fix it. This time it will
definitely fit. */
if (bytes_sent < ret)
- bytes_sent = hostio_reply_with_data (own_buf, data, bytes_sent,
- new_packet_len);
+ bytes_sent
+ = hostio_reply_with_data (own_buf, data, bytes_sent, new_packet_len);
free (data);
}
@@ -416,11 +406,8 @@ handle_pwrite (char *own_buf, int packet_len)
p = own_buf + strlen ("vFile:pwrite:");
- if (require_int (&p, &fd)
- || require_comma (&p)
- || require_valid_fd (fd)
- || require_int (&p, &offset)
- || require_comma (&p)
+ if (require_int (&p, &fd) || require_comma (&p) || require_valid_fd (fd)
+ || require_int (&p, &offset) || require_comma (&p)
|| require_data (p, packet_len - (p - own_buf), &data, &len))
{
hostio_packet_error (own_buf);
@@ -437,7 +424,7 @@ handle_pwrite (char *own_buf, int packet_len)
{
ret = lseek (fd, offset, SEEK_SET);
if (ret != -1)
- ret = write (fd, data, len);
+ ret = write (fd, data, len);
}
if (ret == -1)
@@ -461,9 +448,7 @@ handle_fstat (char *own_buf, int *new_packet_len)
p = own_buf + strlen ("vFile:fstat:");
- if (require_int (&p, &fd)
- || require_valid_fd (fd)
- || require_end (p))
+ if (require_int (&p, &fd) || require_valid_fd (fd) || require_end (p))
{
hostio_packet_error (own_buf);
return;
@@ -477,9 +462,8 @@ handle_fstat (char *own_buf, int *new_packet_len)
host_to_fileio_stat (&st, &fst);
- bytes_sent = hostio_reply_with_data (own_buf,
- (char *) &fst, sizeof (fst),
- new_packet_len);
+ bytes_sent = hostio_reply_with_data (own_buf, (char *) &fst, sizeof (fst),
+ new_packet_len);
/* If the response does not fit into a single packet, do not attempt
to return a partial response, but simply fail. */
@@ -496,9 +480,7 @@ handle_close (char *own_buf)
p = own_buf + strlen ("vFile:close:");
- if (require_int (&p, &fd)
- || require_valid_fd (fd)
- || require_end (p))
+ if (require_int (&p, &fd) || require_valid_fd (fd) || require_end (p))
{
hostio_packet_error (own_buf);
return;
@@ -533,8 +515,7 @@ handle_unlink (char *own_buf)
p = own_buf + strlen ("vFile:unlink:");
- if (require_filename (&p, filename)
- || require_end (p))
+ if (require_filename (&p, filename) || require_end (p))
{
hostio_packet_error (own_buf);
return;
@@ -563,17 +544,15 @@ handle_readlink (char *own_buf, int *new_packet_len)
p = own_buf + strlen ("vFile:readlink:");
- if (require_filename (&p, filename)
- || require_end (p))
+ if (require_filename (&p, filename) || require_end (p))
{
hostio_packet_error (own_buf);
return;
}
if (hostio_fs_pid != 0)
- ret = the_target->multifs_readlink (hostio_fs_pid, filename,
- linkname,
- sizeof (linkname) - 1);
+ ret = the_target->multifs_readlink (hostio_fs_pid, filename, linkname,
+ sizeof (linkname) - 1);
else
ret = readlink (filename, linkname, sizeof (linkname) - 1);
diff --git a/gdbserver/i387-fp.cc b/gdbserver/i387-fp.cc
index 12cb614..c578f324 100644
--- a/gdbserver/i387-fp.cc
+++ b/gdbserver/i387-fp.cc
@@ -31,7 +31,8 @@ static const int num_pkeys_registers = 1;
/* These structs should have the proper sizes and alignment on both
i386 and x86-64 machines. */
-struct i387_fsave {
+struct i387_fsave
+{
/* All these are only sixteen bits, plus padding, except for fop (which
is only eleven bits), and fooff / fioff (which are 32 bits each). */
unsigned short fctrl;
@@ -51,7 +52,8 @@ struct i387_fsave {
unsigned char st_space[80];
};
-struct i387_fxsave {
+struct i387_fxsave
+{
/* All these are only sixteen bits, plus padding, except for fop (which
is only eleven bits), and fooff / fioff (which are 32 bits each). */
unsigned short fctrl;
@@ -75,7 +77,8 @@ struct i387_fxsave {
unsigned char xmm_space[256];
};
-struct i387_xsave {
+struct i387_xsave
+{
/* All these are only sixteen bits, plus padding, except for fop (which
is only eleven bits), and fooff / fioff (which are 32 bits each). */
unsigned short fctrl;
@@ -149,7 +152,7 @@ i387_cache_to_fsave (struct regcache *regcache, void *buf)
for (i = 0; i < 8; i++)
collect_register (regcache, i + st0_regnum,
- ((char *) &fp->st_space[0]) + i * 10);
+ ((char *) &fp->st_space[0]) + i * 10);
fp->fioff = regcache_raw_get_unsigned_by_name (regcache, "fioff");
fp->fooff = regcache_raw_get_unsigned_by_name (regcache, "fooff");
@@ -176,7 +179,7 @@ i387_fsave_to_cache (struct regcache *regcache, const void *buf)
for (i = 0; i < 8; i++)
supply_register (regcache, i + st0_regnum,
- ((char *) &fp->st_space[0]) + i * 10);
+ ((char *) &fp->st_space[0]) + i * 10);
supply_register_by_name (regcache, "fioff", &fp->fioff);
supply_register_by_name (regcache, "fooff", &fp->fooff);
@@ -215,10 +218,10 @@ i387_cache_to_fxsave (struct regcache *regcache, void *buf)
for (i = 0; i < 8; i++)
collect_register (regcache, i + st0_regnum,
- ((char *) &fp->st_space[0]) + i * 16);
+ ((char *) &fp->st_space[0]) + i * 16);
for (i = 0; i < num_xmm_registers; i++)
collect_register (regcache, i + xmm0_regnum,
- ((char *) &fp->xmm_space[0]) + i * 16);
+ ((char *) &fp->xmm_space[0]) + i * 16);
fp->fioff = regcache_raw_get_unsigned_by_name (regcache, "fioff");
fp->fooff = regcache_raw_get_unsigned_by_name (regcache, "fooff");
@@ -240,7 +243,7 @@ i387_cache_to_fxsave (struct regcache *regcache, void *buf)
int tag = (val >> (i * 2)) & 3;
if (tag != 3)
- val2 |= (1 << i);
+ val2 |= (1 << i);
}
fp->ftag = val2;
@@ -278,60 +281,60 @@ i387_cache_to_xsave (struct regcache *regcache, void *buf)
if (clear_bv)
{
if ((clear_bv & X86_XSTATE_X87))
- {
- for (i = 0; i < 8; i++)
- memset (((char *) &fp->st_space[0]) + i * 16, 0, 10);
-
- fp->fioff = 0;
- fp->fooff = 0;
- fp->fctrl = I387_FCTRL_INIT_VAL;
- fp->fstat = 0;
- fp->ftag = 0;
- fp->fiseg = 0;
- fp->foseg = 0;
- fp->fop = 0;
- }
+ {
+ for (i = 0; i < 8; i++)
+ memset (((char *) &fp->st_space[0]) + i * 16, 0, 10);
+
+ fp->fioff = 0;
+ fp->fooff = 0;
+ fp->fctrl = I387_FCTRL_INIT_VAL;
+ fp->fstat = 0;
+ fp->ftag = 0;
+ fp->fiseg = 0;
+ fp->foseg = 0;
+ fp->fop = 0;
+ }
if ((clear_bv & X86_XSTATE_SSE))
- for (i = 0; i < num_xmm_registers; i++)
- memset (((char *) &fp->xmm_space[0]) + i * 16, 0, 16);
+ for (i = 0; i < num_xmm_registers; i++)
+ memset (((char *) &fp->xmm_space[0]) + i * 16, 0, 16);
if ((clear_bv & X86_XSTATE_AVX))
- for (i = 0; i < num_xmm_registers; i++)
- memset (((char *) &fp->ymmh_space[0]) + i * 16, 0, 16);
+ for (i = 0; i < num_xmm_registers; i++)
+ memset (((char *) &fp->ymmh_space[0]) + i * 16, 0, 16);
if ((clear_bv & X86_XSTATE_SSE) && (clear_bv & X86_XSTATE_AVX))
- memset (((char *) &fp->mxcsr), 0, 4);
+ memset (((char *) &fp->mxcsr), 0, 4);
if ((clear_bv & X86_XSTATE_BNDREGS))
- for (i = 0; i < num_mpx_bnd_registers; i++)
- memset (((char *) &fp->mpx_bnd_space[0]) + i * 16, 0, 16);
+ for (i = 0; i < num_mpx_bnd_registers; i++)
+ memset (((char *) &fp->mpx_bnd_space[0]) + i * 16, 0, 16);
if ((clear_bv & X86_XSTATE_BNDCFG))
- for (i = 0; i < num_mpx_cfg_registers; i++)
- memset (((char *) &fp->mpx_cfg_space[0]) + i * 8, 0, 8);
+ for (i = 0; i < num_mpx_cfg_registers; i++)
+ memset (((char *) &fp->mpx_cfg_space[0]) + i * 8, 0, 8);
if ((clear_bv & X86_XSTATE_K))
- for (i = 0; i < num_avx512_k_registers; i++)
- memset (((char *) &fp->k_space[0]) + i * 8, 0, 8);
+ for (i = 0; i < num_avx512_k_registers; i++)
+ memset (((char *) &fp->k_space[0]) + i * 8, 0, 8);
if ((clear_bv & X86_XSTATE_ZMM_H))
- for (i = 0; i < num_avx512_zmmh_low_registers; i++)
- memset (((char *) &fp->zmmh_low_space[0]) + i * 32, 0, 32);
+ for (i = 0; i < num_avx512_zmmh_low_registers; i++)
+ memset (((char *) &fp->zmmh_low_space[0]) + i * 32, 0, 32);
if ((clear_bv & X86_XSTATE_ZMM))
- {
- for (i = 0; i < num_avx512_zmmh_high_registers; i++)
- memset (((char *) &fp->zmmh_low_space[0]) + 32 + i * 64, 0, 32);
- for (i = 0; i < num_avx512_xmm_registers; i++)
- memset (((char *) &fp->zmmh_high_space[0]) + i * 64, 0, 16);
- for (i = 0; i < num_avx512_ymmh_registers; i++)
- memset (((char *) &fp->zmmh_high_space[0]) + 16 + i * 64, 0, 16);
- }
+ {
+ for (i = 0; i < num_avx512_zmmh_high_registers; i++)
+ memset (((char *) &fp->zmmh_low_space[0]) + 32 + i * 64, 0, 32);
+ for (i = 0; i < num_avx512_xmm_registers; i++)
+ memset (((char *) &fp->zmmh_high_space[0]) + i * 64, 0, 16);
+ for (i = 0; i < num_avx512_ymmh_registers; i++)
+ memset (((char *) &fp->zmmh_high_space[0]) + 16 + i * 64, 0, 16);
+ }
if ((clear_bv & X86_XSTATE_PKRU))
- for (i = 0; i < num_pkeys_registers; i++)
- memset (((char *) &fp->pkru_space[0]) + i * 4, 0, 4);
+ for (i = 0; i < num_pkeys_registers; i++)
+ memset (((char *) &fp->pkru_space[0]) + i * 4, 0, 4);
}
/* Check if any x87 registers are changed. */
@@ -340,15 +343,15 @@ i387_cache_to_xsave (struct regcache *regcache, void *buf)
int st0_regnum = find_regno (regcache->tdesc, "st0");
for (i = 0; i < 8; i++)
- {
- collect_register (regcache, i + st0_regnum, raw);
- p = ((char *) &fp->st_space[0]) + i * 16;
- if (memcmp (raw, p, 10))
- {
- xstate_bv |= X86_XSTATE_X87;
- memcpy (p, raw, 10);
- }
- }
+ {
+ collect_register (regcache, i + st0_regnum, raw);
+ p = ((char *) &fp->st_space[0]) + i * 16;
+ if (memcmp (raw, p, 10))
+ {
+ xstate_bv |= X86_XSTATE_X87;
+ memcpy (p, raw, 10);
+ }
+ }
}
/* Check if any SSE registers are changed. */
@@ -356,16 +359,16 @@ i387_cache_to_xsave (struct regcache *regcache, void *buf)
{
int xmm0_regnum = find_regno (regcache->tdesc, "xmm0");
- for (i = 0; i < num_xmm_registers; i++)
- {
- collect_register (regcache, i + xmm0_regnum, raw);
- p = ((char *) &fp->xmm_space[0]) + i * 16;
- if (memcmp (raw, p, 16))
- {
- xstate_bv |= X86_XSTATE_SSE;
- memcpy (p, raw, 16);
- }
- }
+ for (i = 0; i < num_xmm_registers; i++)
+ {
+ collect_register (regcache, i + xmm0_regnum, raw);
+ p = ((char *) &fp->xmm_space[0]) + i * 16;
+ if (memcmp (raw, p, 16))
+ {
+ xstate_bv |= X86_XSTATE_SSE;
+ memcpy (p, raw, 16);
+ }
+ }
}
/* Check if any AVX registers are changed. */
@@ -373,33 +376,33 @@ i387_cache_to_xsave (struct regcache *regcache, void *buf)
{
int ymm0h_regnum = find_regno (regcache->tdesc, "ymm0h");
- for (i = 0; i < num_xmm_registers; i++)
- {
- collect_register (regcache, i + ymm0h_regnum, raw);
- p = ((char *) &fp->ymmh_space[0]) + i * 16;
- if (memcmp (raw, p, 16))
- {
- xstate_bv |= X86_XSTATE_AVX;
- memcpy (p, raw, 16);
- }
- }
+ for (i = 0; i < num_xmm_registers; i++)
+ {
+ collect_register (regcache, i + ymm0h_regnum, raw);
+ p = ((char *) &fp->ymmh_space[0]) + i * 16;
+ if (memcmp (raw, p, 16))
+ {
+ xstate_bv |= X86_XSTATE_AVX;
+ memcpy (p, raw, 16);
+ }
+ }
}
/* Check if any bound register has changed. */
if ((x86_xcr0 & X86_XSTATE_BNDREGS))
{
- int bnd0r_regnum = find_regno (regcache->tdesc, "bnd0raw");
+ int bnd0r_regnum = find_regno (regcache->tdesc, "bnd0raw");
for (i = 0; i < num_mpx_bnd_registers; i++)
- {
- collect_register (regcache, i + bnd0r_regnum, raw);
- p = ((char *) &fp->mpx_bnd_space[0]) + i * 16;
- if (memcmp (raw, p, 16))
- {
- xstate_bv |= X86_XSTATE_BNDREGS;
- memcpy (p, raw, 16);
- }
- }
+ {
+ collect_register (regcache, i + bnd0r_regnum, raw);
+ p = ((char *) &fp->mpx_bnd_space[0]) + i * 16;
+ if (memcmp (raw, p, 16))
+ {
+ xstate_bv |= X86_XSTATE_BNDREGS;
+ memcpy (p, raw, 16);
+ }
+ }
}
/* Check if any status register has changed. */
@@ -408,15 +411,15 @@ i387_cache_to_xsave (struct regcache *regcache, void *buf)
int bndcfg_regnum = find_regno (regcache->tdesc, "bndcfgu");
for (i = 0; i < num_mpx_cfg_registers; i++)
- {
- collect_register (regcache, i + bndcfg_regnum, raw);
- p = ((char *) &fp->mpx_cfg_space[0]) + i * 8;
- if (memcmp (raw, p, 8))
- {
- xstate_bv |= X86_XSTATE_BNDCFG;
- memcpy (p, raw, 8);
- }
- }
+ {
+ collect_register (regcache, i + bndcfg_regnum, raw);
+ p = ((char *) &fp->mpx_cfg_space[0]) + i * 8;
+ if (memcmp (raw, p, 8))
+ {
+ xstate_bv |= X86_XSTATE_BNDCFG;
+ memcpy (p, raw, 8);
+ }
+ }
}
/* Check if any K registers are changed. */
@@ -425,15 +428,15 @@ i387_cache_to_xsave (struct regcache *regcache, void *buf)
int k0_regnum = find_regno (regcache->tdesc, "k0");
for (i = 0; i < num_avx512_k_registers; i++)
- {
- collect_register (regcache, i + k0_regnum, raw);
- p = ((char *) &fp->k_space[0]) + i * 8;
- if (memcmp (raw, p, 8) != 0)
- {
- xstate_bv |= X86_XSTATE_K;
- memcpy (p, raw, 8);
- }
- }
+ {
+ collect_register (regcache, i + k0_regnum, raw);
+ p = ((char *) &fp->k_space[0]) + i * 8;
+ if (memcmp (raw, p, 8) != 0)
+ {
+ xstate_bv |= X86_XSTATE_K;
+ memcpy (p, raw, 8);
+ }
+ }
}
/* Check if any of ZMM0H-ZMM15H registers are changed. */
@@ -442,72 +445,72 @@ i387_cache_to_xsave (struct regcache *regcache, void *buf)
int zmm0h_regnum = find_regno (regcache->tdesc, "zmm0h");
for (i = 0; i < num_avx512_zmmh_low_registers; i++)
- {
- collect_register (regcache, i + zmm0h_regnum, raw);
- p = ((char *) &fp->zmmh_low_space[0]) + i * 32;
- if (memcmp (raw, p, 32) != 0)
- {
- xstate_bv |= X86_XSTATE_ZMM_H;
- memcpy (p, raw, 32);
- }
- }
+ {
+ collect_register (regcache, i + zmm0h_regnum, raw);
+ p = ((char *) &fp->zmmh_low_space[0]) + i * 32;
+ if (memcmp (raw, p, 32) != 0)
+ {
+ xstate_bv |= X86_XSTATE_ZMM_H;
+ memcpy (p, raw, 32);
+ }
+ }
}
/* Check if any of ZMM16H-ZMM31H registers are changed. */
if ((x86_xcr0 & X86_XSTATE_ZMM))
{
int zmm16h_regnum = (num_avx512_zmmh_high_registers == 0
- ? -1
- : find_regno (regcache->tdesc, "zmm16h"));
+ ? -1
+ : find_regno (regcache->tdesc, "zmm16h"));
for (i = 0; i < num_avx512_zmmh_high_registers; i++)
- {
- collect_register (regcache, i + zmm16h_regnum, raw);
- p = ((char *) &fp->zmmh_high_space[0]) + 32 + i * 64;
- if (memcmp (raw, p, 32) != 0)
- {
- xstate_bv |= X86_XSTATE_ZMM;
- memcpy (p, raw, 32);
- }
- }
+ {
+ collect_register (regcache, i + zmm16h_regnum, raw);
+ p = ((char *) &fp->zmmh_high_space[0]) + 32 + i * 64;
+ if (memcmp (raw, p, 32) != 0)
+ {
+ xstate_bv |= X86_XSTATE_ZMM;
+ memcpy (p, raw, 32);
+ }
+ }
}
/* Check if any XMM_AVX512 registers are changed. */
if ((x86_xcr0 & X86_XSTATE_ZMM))
{
int xmm_avx512_regnum = (num_avx512_xmm_registers == 0
- ? -1
- : find_regno (regcache->tdesc, "xmm16"));
+ ? -1
+ : find_regno (regcache->tdesc, "xmm16"));
for (i = 0; i < num_avx512_xmm_registers; i++)
- {
- collect_register (regcache, i + xmm_avx512_regnum, raw);
- p = ((char *) &fp->zmmh_high_space[0]) + i * 64;
- if (memcmp (raw, p, 16) != 0)
- {
- xstate_bv |= X86_XSTATE_ZMM;
- memcpy (p, raw, 16);
- }
- }
+ {
+ collect_register (regcache, i + xmm_avx512_regnum, raw);
+ p = ((char *) &fp->zmmh_high_space[0]) + i * 64;
+ if (memcmp (raw, p, 16) != 0)
+ {
+ xstate_bv |= X86_XSTATE_ZMM;
+ memcpy (p, raw, 16);
+ }
+ }
}
/* Check if any YMMH_AVX512 registers are changed. */
if ((x86_xcr0 & X86_XSTATE_ZMM))
{
int ymmh_avx512_regnum = (num_avx512_ymmh_registers == 0
- ? -1
- : find_regno (regcache->tdesc, "ymm16h"));
+ ? -1
+ : find_regno (regcache->tdesc, "ymm16h"));
for (i = 0; i < num_avx512_ymmh_registers; i++)
- {
- collect_register (regcache, i + ymmh_avx512_regnum, raw);
- p = ((char *) &fp->zmmh_high_space[0]) + 16 + i * 64;
- if (memcmp (raw, p, 16) != 0)
- {
- xstate_bv |= X86_XSTATE_ZMM;
- memcpy (p, raw, 16);
- }
- }
+ {
+ collect_register (regcache, i + ymmh_avx512_regnum, raw);
+ p = ((char *) &fp->zmmh_high_space[0]) + 16 + i * 64;
+ if (memcmp (raw, p, 16) != 0)
+ {
+ xstate_bv |= X86_XSTATE_ZMM;
+ memcpy (p, raw, 16);
+ }
+ }
}
/* Check if any PKEYS registers are changed. */
@@ -516,98 +519,98 @@ i387_cache_to_xsave (struct regcache *regcache, void *buf)
int pkru_regnum = find_regno (regcache->tdesc, "pkru");
for (i = 0; i < num_pkeys_registers; i++)
- {
- collect_register (regcache, i + pkru_regnum, raw);
- p = ((char *) &fp->pkru_space[0]) + i * 4;
- if (memcmp (raw, p, 4) != 0)
- {
- xstate_bv |= X86_XSTATE_PKRU;
- memcpy (p, raw, 4);
- }
- }
+ {
+ collect_register (regcache, i + pkru_regnum, raw);
+ p = ((char *) &fp->pkru_space[0]) + i * 4;
+ if (memcmp (raw, p, 4) != 0)
+ {
+ xstate_bv |= X86_XSTATE_PKRU;
+ memcpy (p, raw, 4);
+ }
+ }
}
if ((x86_xcr0 & X86_XSTATE_SSE) || (x86_xcr0 & X86_XSTATE_AVX))
{
collect_register_by_name (regcache, "mxcsr", raw);
if (memcmp (raw, &fp->mxcsr, 4) != 0)
- {
- if (((fp->xstate_bv | xstate_bv)
- & (X86_XSTATE_SSE | X86_XSTATE_AVX)) == 0)
- xstate_bv |= X86_XSTATE_SSE;
- memcpy (&fp->mxcsr, raw, 4);
- }
+ {
+ if (((fp->xstate_bv | xstate_bv) & (X86_XSTATE_SSE | X86_XSTATE_AVX))
+ == 0)
+ xstate_bv |= X86_XSTATE_SSE;
+ memcpy (&fp->mxcsr, raw, 4);
+ }
}
if (x86_xcr0 & X86_XSTATE_X87)
{
collect_register_by_name (regcache, "fioff", raw);
if (memcmp (raw, &fp->fioff, 4) != 0)
- {
- xstate_bv |= X86_XSTATE_X87;
- memcpy (&fp->fioff, raw, 4);
- }
+ {
+ xstate_bv |= X86_XSTATE_X87;
+ memcpy (&fp->fioff, raw, 4);
+ }
collect_register_by_name (regcache, "fooff", raw);
if (memcmp (raw, &fp->fooff, 4) != 0)
- {
- xstate_bv |= X86_XSTATE_X87;
- memcpy (&fp->fooff, raw, 4);
- }
+ {
+ xstate_bv |= X86_XSTATE_X87;
+ memcpy (&fp->fooff, raw, 4);
+ }
/* This one's 11 bits... */
val2 = regcache_raw_get_unsigned_by_name (regcache, "fop");
val2 = (val2 & 0x7FF) | (fp->fop & 0xF800);
if (fp->fop != val2)
- {
- xstate_bv |= X86_XSTATE_X87;
- fp->fop = val2;
- }
+ {
+ xstate_bv |= X86_XSTATE_X87;
+ fp->fop = val2;
+ }
/* Some registers are 16-bit. */
val = regcache_raw_get_unsigned_by_name (regcache, "fctrl");
if (fp->fctrl != val)
- {
- xstate_bv |= X86_XSTATE_X87;
- fp->fctrl = val;
- }
+ {
+ xstate_bv |= X86_XSTATE_X87;
+ fp->fctrl = val;
+ }
val = regcache_raw_get_unsigned_by_name (regcache, "fstat");
if (fp->fstat != val)
- {
- xstate_bv |= X86_XSTATE_X87;
- fp->fstat = val;
- }
+ {
+ xstate_bv |= X86_XSTATE_X87;
+ fp->fstat = val;
+ }
/* Convert to the simplifed tag form stored in fxsave data. */
val = regcache_raw_get_unsigned_by_name (regcache, "ftag");
val2 = 0;
for (i = 7; i >= 0; i--)
- {
- int tag = (val >> (i * 2)) & 3;
+ {
+ int tag = (val >> (i * 2)) & 3;
- if (tag != 3)
- val2 |= (1 << i);
- }
+ if (tag != 3)
+ val2 |= (1 << i);
+ }
if (fp->ftag != val2)
- {
- xstate_bv |= X86_XSTATE_X87;
- fp->ftag = val2;
- }
+ {
+ xstate_bv |= X86_XSTATE_X87;
+ fp->ftag = val2;
+ }
val = regcache_raw_get_unsigned_by_name (regcache, "fiseg");
if (fp->fiseg != val)
- {
- xstate_bv |= X86_XSTATE_X87;
- fp->fiseg = val;
- }
+ {
+ xstate_bv |= X86_XSTATE_X87;
+ fp->fiseg = val;
+ }
val = regcache_raw_get_unsigned_by_name (regcache, "foseg");
if (fp->foseg != val)
- {
- xstate_bv |= X86_XSTATE_X87;
- fp->foseg = val;
- }
+ {
+ xstate_bv |= X86_XSTATE_X87;
+ fp->foseg = val;
+ }
}
/* Update the corresponding bits in xstate_bv if any SSE/AVX
@@ -626,8 +629,8 @@ i387_ftag (struct i387_fxsave *fp, int regno)
integer = raw[7] & 0x80;
exponent = (((raw[9] & 0x7f) << 8) | raw[8]);
fraction[0] = ((raw[3] << 24) | (raw[2] << 16) | (raw[1] << 8) | raw[0]);
- fraction[1] = (((raw[7] & 0x7f) << 24) | (raw[6] << 16)
- | (raw[5] << 8) | raw[4]);
+ fraction[1]
+ = (((raw[7] & 0x7f) << 24) | (raw[6] << 16) | (raw[5] << 8) | raw[4]);
if (exponent == 0x7fff)
{
@@ -637,28 +640,28 @@ i387_ftag (struct i387_fxsave *fp, int regno)
else if (exponent == 0x0000)
{
if (fraction[0] == 0x0000 && fraction[1] == 0x0000 && !integer)
- {
- /* Zero. */
- return (1);
- }
+ {
+ /* Zero. */
+ return (1);
+ }
else
- {
- /* Special. */
- return (2);
- }
+ {
+ /* Special. */
+ return (2);
+ }
}
else
{
if (integer)
- {
- /* Valid. */
- return (0);
- }
+ {
+ /* Valid. */
+ return (0);
+ }
else
- {
- /* Special. */
- return (2);
- }
+ {
+ /* Special. */
+ return (2);
+ }
}
}
@@ -675,10 +678,10 @@ i387_fxsave_to_cache (struct regcache *regcache, const void *buf)
for (i = 0; i < 8; i++)
supply_register (regcache, i + st0_regnum,
- ((char *) &fp->st_space[0]) + i * 16);
+ ((char *) &fp->st_space[0]) + i * 16);
for (i = 0; i < num_xmm_registers; i++)
supply_register (regcache, i + xmm0_regnum,
- ((char *) &fp->xmm_space[0]) + i * 16);
+ ((char *) &fp->xmm_space[0]) + i * 16);
supply_register_by_name (regcache, "fioff", &fp->fioff);
supply_register_by_name (regcache, "fooff", &fp->fooff);
@@ -698,9 +701,9 @@ i387_fxsave_to_cache (struct regcache *regcache, const void *buf)
{
int tag;
if (fp->ftag & (1 << i))
- tag = i387_ftag (fp, (i + 8 - top) % 8);
+ tag = i387_ftag (fp, (i + 8 - top) % 8);
else
- tag = 3;
+ tag = 3;
val |= tag << (2 * i);
}
supply_register_by_name (regcache, "ftag", &val);
@@ -726,7 +729,7 @@ i387_xsave_to_cache (struct regcache *regcache, const void *buf)
unsigned long long clear_bv;
gdb_byte *p;
- /* Amd64 has 16 xmm regs; I386 has 8 xmm regs. */
+ /* Amd64 has 16 xmm regs; I386 has 8 xmm regs. */
int num_xmm_registers = amd64 ? 16 : 8;
/* AVX512 extends the existing xmm/ymm registers to a wider mode: zmm. */
int num_avx512_zmmh_low_registers = num_xmm_registers;
@@ -745,16 +748,16 @@ i387_xsave_to_cache (struct regcache *regcache, const void *buf)
int st0_regnum = find_regno (regcache->tdesc, "st0");
if ((clear_bv & X86_XSTATE_X87) != 0)
- {
- for (i = 0; i < 8; i++)
- supply_register_zeroed (regcache, i + st0_regnum);
- }
+ {
+ for (i = 0; i < 8; i++)
+ supply_register_zeroed (regcache, i + st0_regnum);
+ }
else
- {
- p = (gdb_byte *) &fp->st_space[0];
- for (i = 0; i < 8; i++)
- supply_register (regcache, i + st0_regnum, p + i * 16);
- }
+ {
+ p = (gdb_byte *) &fp->st_space[0];
+ for (i = 0; i < 8; i++)
+ supply_register (regcache, i + st0_regnum, p + i * 16);
+ }
}
if ((x86_xcr0 & X86_XSTATE_SSE) != 0)
@@ -762,16 +765,16 @@ i387_xsave_to_cache (struct regcache *regcache, const void *buf)
int xmm0_regnum = find_regno (regcache->tdesc, "xmm0");
if ((clear_bv & X86_XSTATE_SSE))
- {
- for (i = 0; i < num_xmm_registers; i++)
- supply_register_zeroed (regcache, i + xmm0_regnum);
- }
+ {
+ for (i = 0; i < num_xmm_registers; i++)
+ supply_register_zeroed (regcache, i + xmm0_regnum);
+ }
else
- {
- p = (gdb_byte *) &fp->xmm_space[0];
- for (i = 0; i < num_xmm_registers; i++)
- supply_register (regcache, i + xmm0_regnum, p + i * 16);
- }
+ {
+ p = (gdb_byte *) &fp->xmm_space[0];
+ for (i = 0; i < num_xmm_registers; i++)
+ supply_register (regcache, i + xmm0_regnum, p + i * 16);
+ }
}
if ((x86_xcr0 & X86_XSTATE_AVX) != 0)
@@ -779,35 +782,33 @@ i387_xsave_to_cache (struct regcache *regcache, const void *buf)
int ymm0h_regnum = find_regno (regcache->tdesc, "ymm0h");
if ((clear_bv & X86_XSTATE_AVX) != 0)
- {
- for (i = 0; i < num_xmm_registers; i++)
- supply_register_zeroed (regcache, i + ymm0h_regnum);
- }
+ {
+ for (i = 0; i < num_xmm_registers; i++)
+ supply_register_zeroed (regcache, i + ymm0h_regnum);
+ }
else
- {
- p = (gdb_byte *) &fp->ymmh_space[0];
- for (i = 0; i < num_xmm_registers; i++)
- supply_register (regcache, i + ymm0h_regnum, p + i * 16);
- }
+ {
+ p = (gdb_byte *) &fp->ymmh_space[0];
+ for (i = 0; i < num_xmm_registers; i++)
+ supply_register (regcache, i + ymm0h_regnum, p + i * 16);
+ }
}
if ((x86_xcr0 & X86_XSTATE_BNDREGS))
{
int bnd0r_regnum = find_regno (regcache->tdesc, "bnd0raw");
-
if ((clear_bv & X86_XSTATE_BNDREGS) != 0)
- {
- for (i = 0; i < num_mpx_bnd_registers; i++)
- supply_register_zeroed (regcache, i + bnd0r_regnum);
- }
+ {
+ for (i = 0; i < num_mpx_bnd_registers; i++)
+ supply_register_zeroed (regcache, i + bnd0r_regnum);
+ }
else
- {
- p = (gdb_byte *) &fp->mpx_bnd_space[0];
- for (i = 0; i < num_mpx_bnd_registers; i++)
- supply_register (regcache, i + bnd0r_regnum, p + i * 16);
- }
-
+ {
+ p = (gdb_byte *) &fp->mpx_bnd_space[0];
+ for (i = 0; i < num_mpx_bnd_registers; i++)
+ supply_register (regcache, i + bnd0r_regnum, p + i * 16);
+ }
}
if ((x86_xcr0 & X86_XSTATE_BNDCFG))
@@ -815,16 +816,16 @@ i387_xsave_to_cache (struct regcache *regcache, const void *buf)
int bndcfg_regnum = find_regno (regcache->tdesc, "bndcfgu");
if ((clear_bv & X86_XSTATE_BNDCFG) != 0)
- {
- for (i = 0; i < num_mpx_cfg_registers; i++)
- supply_register_zeroed (regcache, i + bndcfg_regnum);
- }
+ {
+ for (i = 0; i < num_mpx_cfg_registers; i++)
+ supply_register_zeroed (regcache, i + bndcfg_regnum);
+ }
else
- {
- p = (gdb_byte *) &fp->mpx_cfg_space[0];
- for (i = 0; i < num_mpx_cfg_registers; i++)
- supply_register (regcache, i + bndcfg_regnum, p + i * 8);
- }
+ {
+ p = (gdb_byte *) &fp->mpx_cfg_space[0];
+ for (i = 0; i < num_mpx_cfg_registers; i++)
+ supply_register (regcache, i + bndcfg_regnum, p + i * 8);
+ }
}
if ((x86_xcr0 & X86_XSTATE_K) != 0)
@@ -832,16 +833,16 @@ i387_xsave_to_cache (struct regcache *regcache, const void *buf)
int k0_regnum = find_regno (regcache->tdesc, "k0");
if ((clear_bv & X86_XSTATE_K) != 0)
- {
- for (i = 0; i < num_avx512_k_registers; i++)
- supply_register_zeroed (regcache, i + k0_regnum);
- }
+ {
+ for (i = 0; i < num_avx512_k_registers; i++)
+ supply_register_zeroed (regcache, i + k0_regnum);
+ }
else
- {
- p = (gdb_byte *) &fp->k_space[0];
- for (i = 0; i < num_avx512_k_registers; i++)
- supply_register (regcache, i + k0_regnum, p + i * 8);
- }
+ {
+ p = (gdb_byte *) &fp->k_space[0];
+ for (i = 0; i < num_avx512_k_registers; i++)
+ supply_register (regcache, i + k0_regnum, p + i * 8);
+ }
}
if ((x86_xcr0 & X86_XSTATE_ZMM_H) != 0)
@@ -849,49 +850,49 @@ i387_xsave_to_cache (struct regcache *regcache, const void *buf)
int zmm0h_regnum = find_regno (regcache->tdesc, "zmm0h");
if ((clear_bv & X86_XSTATE_ZMM_H) != 0)
- {
- for (i = 0; i < num_avx512_zmmh_low_registers; i++)
- supply_register_zeroed (regcache, i + zmm0h_regnum);
- }
+ {
+ for (i = 0; i < num_avx512_zmmh_low_registers; i++)
+ supply_register_zeroed (regcache, i + zmm0h_regnum);
+ }
else
- {
- p = (gdb_byte *) &fp->zmmh_low_space[0];
- for (i = 0; i < num_avx512_zmmh_low_registers; i++)
- supply_register (regcache, i + zmm0h_regnum, p + i * 32);
- }
+ {
+ p = (gdb_byte *) &fp->zmmh_low_space[0];
+ for (i = 0; i < num_avx512_zmmh_low_registers; i++)
+ supply_register (regcache, i + zmm0h_regnum, p + i * 32);
+ }
}
if ((x86_xcr0 & X86_XSTATE_ZMM) != 0)
{
int zmm16h_regnum = (num_avx512_zmmh_high_registers == 0
- ? -1
- : find_regno (regcache->tdesc, "zmm16h"));
+ ? -1
+ : find_regno (regcache->tdesc, "zmm16h"));
int ymm16h_regnum = (num_avx512_ymmh_registers == 0
- ? -1
- : find_regno (regcache->tdesc, "ymm16h"));
+ ? -1
+ : find_regno (regcache->tdesc, "ymm16h"));
int xmm16_regnum = (num_avx512_xmm_registers == 0
- ? -1
- : find_regno (regcache->tdesc, "xmm16"));
+ ? -1
+ : find_regno (regcache->tdesc, "xmm16"));
if ((clear_bv & X86_XSTATE_ZMM) != 0)
- {
- for (i = 0; i < num_avx512_zmmh_high_registers; i++)
- supply_register_zeroed (regcache, i + zmm16h_regnum);
- for (i = 0; i < num_avx512_ymmh_registers; i++)
- supply_register_zeroed (regcache, i + ymm16h_regnum);
- for (i = 0; i < num_avx512_xmm_registers; i++)
- supply_register_zeroed (regcache, i + xmm16_regnum);
- }
+ {
+ for (i = 0; i < num_avx512_zmmh_high_registers; i++)
+ supply_register_zeroed (regcache, i + zmm16h_regnum);
+ for (i = 0; i < num_avx512_ymmh_registers; i++)
+ supply_register_zeroed (regcache, i + ymm16h_regnum);
+ for (i = 0; i < num_avx512_xmm_registers; i++)
+ supply_register_zeroed (regcache, i + xmm16_regnum);
+ }
else
- {
- p = (gdb_byte *) &fp->zmmh_high_space[0];
- for (i = 0; i < num_avx512_zmmh_high_registers; i++)
- supply_register (regcache, i + zmm16h_regnum, p + 32 + i * 64);
- for (i = 0; i < num_avx512_ymmh_registers; i++)
- supply_register (regcache, i + ymm16h_regnum, p + 16 + i * 64);
- for (i = 0; i < num_avx512_xmm_registers; i++)
- supply_register (regcache, i + xmm16_regnum, p + i * 64);
- }
+ {
+ p = (gdb_byte *) &fp->zmmh_high_space[0];
+ for (i = 0; i < num_avx512_zmmh_high_registers; i++)
+ supply_register (regcache, i + zmm16h_regnum, p + 32 + i * 64);
+ for (i = 0; i < num_avx512_ymmh_registers; i++)
+ supply_register (regcache, i + ymm16h_regnum, p + 16 + i * 64);
+ for (i = 0; i < num_avx512_xmm_registers; i++)
+ supply_register (regcache, i + xmm16_regnum, p + i * 64);
+ }
}
if ((x86_xcr0 & X86_XSTATE_PKRU) != 0)
@@ -899,16 +900,16 @@ i387_xsave_to_cache (struct regcache *regcache, const void *buf)
int pkru_regnum = find_regno (regcache->tdesc, "pkru");
if ((clear_bv & X86_XSTATE_PKRU) != 0)
- {
- for (i = 0; i < num_pkeys_registers; i++)
- supply_register_zeroed (regcache, i + pkru_regnum);
- }
+ {
+ for (i = 0; i < num_pkeys_registers; i++)
+ supply_register_zeroed (regcache, i + pkru_regnum);
+ }
else
- {
- p = (gdb_byte *) &fp->pkru_space[0];
- for (i = 0; i < num_pkeys_registers; i++)
- supply_register (regcache, i + pkru_regnum, p + i * 4);
- }
+ {
+ p = (gdb_byte *) &fp->pkru_space[0];
+ for (i = 0; i < num_pkeys_registers; i++)
+ supply_register (regcache, i + pkru_regnum, p + i * 4);
+ }
}
if ((clear_bv & (X86_XSTATE_SSE | X86_XSTATE_AVX))
@@ -953,14 +954,14 @@ i387_xsave_to_cache (struct regcache *regcache, const void *buf)
top = (fp->fstat >> 11) & 0x7;
val = 0;
for (i = 7; i >= 0; i--)
- {
- int tag;
- if (fp->ftag & (1 << i))
- tag = i387_ftag (fxp, (i + 8 - top) % 8);
- else
- tag = 3;
- val |= tag << (2 * i);
- }
+ {
+ int tag;
+ if (fp->ftag & (1 << i))
+ tag = i387_ftag (fxp, (i + 8 - top) % 8);
+ else
+ tag = 3;
+ val |= tag << (2 * i);
+ }
supply_register_by_name (regcache, "ftag", &val);
val = fp->fiseg & 0xFFFF;
diff --git a/gdbserver/inferiors.cc b/gdbserver/inferiors.cc
index cbf4677..a35165d 100644
--- a/gdbserver/inferiors.cc
+++ b/gdbserver/inferiors.cc
@@ -65,9 +65,8 @@ get_first_thread (void)
struct thread_info *
find_thread_ptid (ptid_t ptid)
{
- return find_thread ([&] (thread_info *thread) {
- return thread->id == ptid;
- });
+ return find_thread (
+ [&] (thread_info *thread) { return thread->id == ptid; });
}
/* Find a thread associated with the given PROCESS, or NULL if no
@@ -84,9 +83,7 @@ find_thread_process (const struct process_info *const process)
struct thread_info *
find_any_thread_of_pid (int pid)
{
- return find_thread (pid, [] (thread_info *thread) {
- return true;
- });
+ return find_thread (pid, [] (thread_info *thread) { return true; });
}
static void
@@ -167,9 +164,8 @@ remove_process (struct process_info *process)
process_info *
find_process_pid (int pid)
{
- return find_process ([&] (process_info *process) {
- return process->pid == pid;
- });
+ return find_process (
+ [&] (process_info *process) { return process->pid == pid; });
}
/* Get the first process in the process list, or NULL if the list is empty. */
@@ -189,9 +185,9 @@ get_first_process (void)
int
have_started_inferiors_p (void)
{
- return find_process ([] (process_info *process) {
- return !process->attached;
- }) != NULL;
+ return find_process (
+ [] (process_info *process) { return !process->attached; })
+ != NULL;
}
/* Return non-zero if there are any inferiors that we have attached to. */
@@ -199,9 +195,9 @@ have_started_inferiors_p (void)
int
have_attached_inferiors_p (void)
{
- return find_process ([] (process_info *process) {
- return process->attached;
- }) != NULL;
+ return find_process (
+ [] (process_info *process) { return process->attached; })
+ != NULL;
}
struct process_info *
diff --git a/gdbserver/inferiors.h b/gdbserver/inferiors.h
index a0ba990..a7b9c82 100644
--- a/gdbserver/inferiors.h
+++ b/gdbserver/inferiors.h
@@ -34,9 +34,7 @@ struct process_info_private;
struct process_info
{
- process_info (int pid_, int attached_)
- : pid (pid_), attached (attached_)
- {}
+ process_info (int pid_, int attached_) : pid (pid_), attached (attached_) {}
/* This process' pid. */
int pid;
@@ -103,7 +101,7 @@ extern std::list<process_info *> all_processes;
/* Invoke FUNC for each process. */
-template <typename Func>
+template<typename Func>
static void
for_each_process (Func func)
{
@@ -121,7 +119,7 @@ for_each_process (Func func)
/* Find the first process for which FUNC returns true. Return NULL if no
process satisfying FUNC is found. */
-template <typename Func>
+template<typename Func>
static process_info *
find_process (Func func)
{
@@ -133,7 +131,7 @@ find_process (Func func)
next++;
if (func (*cur))
- return *cur;
+ return *cur;
cur = next;
}
diff --git a/gdbserver/linux-aarch32-low.cc b/gdbserver/linux-aarch32-low.cc
index 990a352..f079e52 100644
--- a/gdbserver/linux-aarch32-low.cc
+++ b/gdbserver/linux-aarch32-low.cc
@@ -69,8 +69,8 @@ arm_fill_gregset (struct regcache *regcache, void *buf)
collect_register (regcache, ARM_PS_REGNUM, &regs[ARM_CPSR_GREGNUM]);
/* Keep reserved bits bit 20 to bit 23. */
- regs[ARM_CPSR_GREGNUM] = ((regs[ARM_CPSR_GREGNUM] & 0xff0fffff)
- | (cpsr & 0x00f00000));
+ regs[ARM_CPSR_GREGNUM]
+ = ((regs[ARM_CPSR_GREGNUM] & 0xff0fffff) | (cpsr & 0x00f00000));
}
/* Supply GP registers contents, stored in BUF, to REGCACHE. */
@@ -142,29 +142,23 @@ arm_store_vfpregset (struct regcache *regcache, const void *buf)
/* Register sets with using PTRACE_GETREGSET. */
-static struct regset_info aarch32_regsets[] = {
- { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_PRSTATUS,
- ARM_CORE_REGS_SIZE + ARM_INT_REGISTER_SIZE, GENERAL_REGS,
- arm_fill_gregset, arm_store_gregset },
- { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_ARM_VFP, ARM_VFP3_REGS_SIZE,
- EXTENDED_REGS,
- arm_fill_vfpregset, arm_store_vfpregset },
- NULL_REGSET
+static struct regset_info aarch32_regsets[]
+ = { { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_PRSTATUS,
+ ARM_CORE_REGS_SIZE + ARM_INT_REGISTER_SIZE, GENERAL_REGS,
+ arm_fill_gregset, arm_store_gregset },
+ { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_ARM_VFP, ARM_VFP3_REGS_SIZE,
+ EXTENDED_REGS, arm_fill_vfpregset, arm_store_vfpregset },
+ NULL_REGSET };
+
+static struct regsets_info aarch32_regsets_info = {
+ aarch32_regsets, /* regsets */
+ 0, /* num_regsets */
+ NULL, /* disabled_regsets */
};
-static struct regsets_info aarch32_regsets_info =
- {
- aarch32_regsets, /* regsets */
- 0, /* num_regsets */
- NULL, /* disabled_regsets */
- };
-
-struct regs_info regs_info_aarch32 =
- {
- NULL, /* regset_bitmap */
- NULL, /* usrregs */
- &aarch32_regsets_info
- };
+struct regs_info regs_info_aarch32 = { NULL, /* regset_bitmap */
+ NULL, /* usrregs */
+ &aarch32_regsets_info };
/* Returns 1 if the current instruction set is thumb, 0 otherwise. */
@@ -194,14 +188,14 @@ arm_breakpoint_at (CORE_ADDR where)
the_target->read_memory (where, (unsigned char *) &insn, 2);
if (insn == thumb_breakpoint)
- return 1;
+ return 1;
if (insn == thumb2_breakpoint[0])
- {
- the_target->read_memory (where + 2, (unsigned char *) &insn, 2);
- if (insn == thumb2_breakpoint[1])
- return 1;
- }
+ {
+ the_target->read_memory (where + 2, (unsigned char *) &insn, 2);
+ if (insn == thumb2_breakpoint[1])
+ return 1;
+ }
}
else
{
@@ -210,10 +204,10 @@ arm_breakpoint_at (CORE_ADDR where)
the_target->read_memory (where, (unsigned char *) &insn, 4);
if (insn == arm_abi_breakpoint)
- return 1;
+ return 1;
if (insn == arm_eabi_breakpoint)
- return 1;
+ return 1;
}
return 0;
@@ -238,13 +232,13 @@ arm_breakpoint_kind_from_pc (CORE_ADDR *pcptr)
/* Check whether we are replacing a thumb2 32-bit instruction. */
if (target_read_memory (*pcptr, buf, 2) == 0)
- {
- unsigned short inst1 = 0;
+ {
+ unsigned short inst1 = 0;
- target_read_memory (*pcptr, (gdb_byte *) &inst1, 2);
- if (thumb_insn_size (inst1) == 4)
- return ARM_BP_KIND_THUMB2;
- }
+ target_read_memory (*pcptr, (gdb_byte *) &inst1, 2);
+ if (thumb_insn_size (inst1) == 4)
+ return ARM_BP_KIND_THUMB2;
+ }
return ARM_BP_KIND_THUMB;
}
else
@@ -254,7 +248,7 @@ arm_breakpoint_kind_from_pc (CORE_ADDR *pcptr)
/* Implementation of the linux_target_ops method "sw_breakpoint_from_kind". */
const gdb_byte *
-arm_sw_breakpoint_from_kind (int kind , int *size)
+arm_sw_breakpoint_from_kind (int kind, int *size)
{
*size = arm_breakpoint_len;
/* Define an ARM-mode breakpoint; we only set breakpoints in the C
@@ -264,17 +258,17 @@ arm_sw_breakpoint_from_kind (int kind , int *size)
application. */
switch (kind)
{
- case ARM_BP_KIND_THUMB:
- *size = thumb_breakpoint_len;
- return (gdb_byte *) &thumb_breakpoint;
- case ARM_BP_KIND_THUMB2:
- *size = thumb2_breakpoint_len;
- return (gdb_byte *) &thumb2_breakpoint;
- case ARM_BP_KIND_ARM:
- *size = arm_breakpoint_len;
- return (const gdb_byte *) &arm_breakpoint;
- default:
- return NULL;
+ case ARM_BP_KIND_THUMB:
+ *size = thumb_breakpoint_len;
+ return (gdb_byte *) &thumb_breakpoint;
+ case ARM_BP_KIND_THUMB2:
+ *size = thumb2_breakpoint_len;
+ return (gdb_byte *) &thumb2_breakpoint;
+ case ARM_BP_KIND_ARM:
+ *size = arm_breakpoint_len;
+ return (const gdb_byte *) &arm_breakpoint;
+ default:
+ return NULL;
}
return NULL;
}
diff --git a/gdbserver/linux-aarch32-low.h b/gdbserver/linux-aarch32-low.h
index 18edcbd..48cc263 100644
--- a/gdbserver/linux-aarch32-low.h
+++ b/gdbserver/linux-aarch32-low.h
@@ -24,10 +24,10 @@ void arm_fill_gregset (struct regcache *regcache, void *buf);
void arm_store_gregset (struct regcache *regcache, const void *buf);
void arm_fill_vfpregset_num (struct regcache *regcache, void *buf, int num);
void arm_store_vfpregset_num (struct regcache *regcache, const void *buf,
- int num);
+ int num);
int arm_breakpoint_kind_from_pc (CORE_ADDR *pcptr);
-const gdb_byte *arm_sw_breakpoint_from_kind (int kind , int *size);
+const gdb_byte *arm_sw_breakpoint_from_kind (int kind, int *size);
int arm_breakpoint_kind_from_current_state (CORE_ADDR *pcptr);
int arm_breakpoint_at (CORE_ADDR where);
diff --git a/gdbserver/linux-aarch32-tdesc.h b/gdbserver/linux-aarch32-tdesc.h
index 0f23ccc..ed14012 100644
--- a/gdbserver/linux-aarch32-tdesc.h
+++ b/gdbserver/linux-aarch32-tdesc.h
@@ -20,7 +20,7 @@
/* Return the AArch32 target description. */
-const target_desc * aarch32_linux_read_description ();
+const target_desc *aarch32_linux_read_description ();
/* Return true if TDESC is the AArch32 target description. */
diff --git a/gdbserver/linux-aarch64-ipa.cc b/gdbserver/linux-aarch64-ipa.cc
index e37bed0..074474b 100644
--- a/gdbserver/linux-aarch64-ipa.cc
+++ b/gdbserver/linux-aarch64-ipa.cc
@@ -30,14 +30,14 @@
/* Each register saved by the jump pad is in a 16 byte cell. */
#define FT_CR_SIZE 16
-#define FT_CR_FPCR 0
-#define FT_CR_FPSR 1
-#define FT_CR_CPSR 2
-#define FT_CR_PC 3
-#define FT_CR_SP 4
-#define FT_CR_X0 5
-#define FT_CR_GPR(n) (FT_CR_X0 + (n))
-#define FT_CR_FPR(n) (FT_CR_GPR (31) + (n))
+#define FT_CR_FPCR 0
+#define FT_CR_FPSR 1
+#define FT_CR_CPSR 2
+#define FT_CR_PC 3
+#define FT_CR_SP 4
+#define FT_CR_X0 5
+#define FT_CR_GPR(n) (FT_CR_X0 + (n))
+#define FT_CR_FPR(n) (FT_CR_GPR (31) + (n))
/* Mapping between registers collected by the jump pad and GDB's register
array layout used by regcache.
@@ -45,94 +45,43 @@
See linux-aarch64-low.c (aarch64_install_fast_tracepoint_jump_pad) for
more details. */
-static const int aarch64_ft_collect_regmap[] = {
- FT_CR_GPR (0),
- FT_CR_GPR (1),
- FT_CR_GPR (2),
- FT_CR_GPR (3),
- FT_CR_GPR (4),
- FT_CR_GPR (5),
- FT_CR_GPR (6),
- FT_CR_GPR (7),
- FT_CR_GPR (8),
- FT_CR_GPR (9),
- FT_CR_GPR (10),
- FT_CR_GPR (11),
- FT_CR_GPR (12),
- FT_CR_GPR (13),
- FT_CR_GPR (14),
- FT_CR_GPR (15),
- FT_CR_GPR (16),
- FT_CR_GPR (17),
- FT_CR_GPR (18),
- FT_CR_GPR (19),
- FT_CR_GPR (20),
- FT_CR_GPR (21),
- FT_CR_GPR (22),
- FT_CR_GPR (23),
- FT_CR_GPR (24),
- FT_CR_GPR (25),
- FT_CR_GPR (26),
- FT_CR_GPR (27),
- FT_CR_GPR (28),
- /* FP */
- FT_CR_GPR (29),
- /* LR */
- FT_CR_GPR (30),
- FT_CR_SP,
- FT_CR_PC,
- FT_CR_CPSR,
- FT_CR_FPR (0),
- FT_CR_FPR (1),
- FT_CR_FPR (2),
- FT_CR_FPR (3),
- FT_CR_FPR (4),
- FT_CR_FPR (5),
- FT_CR_FPR (6),
- FT_CR_FPR (7),
- FT_CR_FPR (8),
- FT_CR_FPR (9),
- FT_CR_FPR (10),
- FT_CR_FPR (11),
- FT_CR_FPR (12),
- FT_CR_FPR (13),
- FT_CR_FPR (14),
- FT_CR_FPR (15),
- FT_CR_FPR (16),
- FT_CR_FPR (17),
- FT_CR_FPR (18),
- FT_CR_FPR (19),
- FT_CR_FPR (20),
- FT_CR_FPR (21),
- FT_CR_FPR (22),
- FT_CR_FPR (23),
- FT_CR_FPR (24),
- FT_CR_FPR (25),
- FT_CR_FPR (26),
- FT_CR_FPR (27),
- FT_CR_FPR (28),
- FT_CR_FPR (29),
- FT_CR_FPR (30),
- FT_CR_FPR (31),
- FT_CR_FPSR,
- FT_CR_FPCR
-};
+static const int aarch64_ft_collect_regmap[]
+ = { FT_CR_GPR (0), FT_CR_GPR (1), FT_CR_GPR (2), FT_CR_GPR (3),
+ FT_CR_GPR (4), FT_CR_GPR (5), FT_CR_GPR (6), FT_CR_GPR (7),
+ FT_CR_GPR (8), FT_CR_GPR (9), FT_CR_GPR (10), FT_CR_GPR (11),
+ FT_CR_GPR (12), FT_CR_GPR (13), FT_CR_GPR (14), FT_CR_GPR (15),
+ FT_CR_GPR (16), FT_CR_GPR (17), FT_CR_GPR (18), FT_CR_GPR (19),
+ FT_CR_GPR (20), FT_CR_GPR (21), FT_CR_GPR (22), FT_CR_GPR (23),
+ FT_CR_GPR (24), FT_CR_GPR (25), FT_CR_GPR (26), FT_CR_GPR (27),
+ FT_CR_GPR (28),
+ /* FP */
+ FT_CR_GPR (29),
+ /* LR */
+ FT_CR_GPR (30), FT_CR_SP, FT_CR_PC, FT_CR_CPSR, FT_CR_FPR (0),
+ FT_CR_FPR (1), FT_CR_FPR (2), FT_CR_FPR (3), FT_CR_FPR (4),
+ FT_CR_FPR (5), FT_CR_FPR (6), FT_CR_FPR (7), FT_CR_FPR (8),
+ FT_CR_FPR (9), FT_CR_FPR (10), FT_CR_FPR (11), FT_CR_FPR (12),
+ FT_CR_FPR (13), FT_CR_FPR (14), FT_CR_FPR (15), FT_CR_FPR (16),
+ FT_CR_FPR (17), FT_CR_FPR (18), FT_CR_FPR (19), FT_CR_FPR (20),
+ FT_CR_FPR (21), FT_CR_FPR (22), FT_CR_FPR (23), FT_CR_FPR (24),
+ FT_CR_FPR (25), FT_CR_FPR (26), FT_CR_FPR (27), FT_CR_FPR (28),
+ FT_CR_FPR (29), FT_CR_FPR (30), FT_CR_FPR (31), FT_CR_FPSR, FT_CR_FPCR };
#define AARCH64_NUM_FT_COLLECT_GREGS \
- (sizeof (aarch64_ft_collect_regmap) / sizeof(aarch64_ft_collect_regmap[0]))
+ (sizeof (aarch64_ft_collect_regmap) / sizeof (aarch64_ft_collect_regmap[0]))
/* Fill in REGCACHE with registers saved by the jump pad in BUF. */
void
supply_fast_tracepoint_registers (struct regcache *regcache,
- const unsigned char *buf)
+ const unsigned char *buf)
{
int i;
for (i = 0; i < AARCH64_NUM_FT_COLLECT_GREGS; i++)
supply_register (regcache, i,
- ((char *) buf)
- + (aarch64_ft_collect_regmap[i] * FT_CR_SIZE));
+ ((char *) buf)
+ + (aarch64_ft_collect_regmap[i] * FT_CR_SIZE));
}
ULONGEST
@@ -142,7 +91,7 @@ get_raw_reg (const unsigned char *raw_regs, int regnum)
return 0;
return *(ULONGEST *) (raw_regs
- + aarch64_ft_collect_regmap[regnum] * FT_CR_SIZE);
+ + aarch64_ft_collect_regmap[regnum] * FT_CR_SIZE);
}
/* Return target_desc to use for IPA, given the tdesc index passed by
@@ -185,17 +134,16 @@ alloc_jump_pad_buffer (size_t size)
for (; addr; addr -= pagesize)
{
/* No MAP_FIXED - we don't want to zap someone's mapping. */
- res = mmap ((void *) addr, size,
- PROT_READ | PROT_WRITE | PROT_EXEC,
- MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+ res = mmap ((void *) addr, size, PROT_READ | PROT_WRITE | PROT_EXEC,
+ MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
/* If we got what we wanted, return. */
if ((uintptr_t) res == addr)
- return res;
+ return res;
/* If we got a mapping, but at a wrong address, undo it. */
if (res != MAP_FAILED)
- munmap (res, size);
+ munmap (res, size);
}
return NULL;
diff --git a/gdbserver/linux-aarch64-low.cc b/gdbserver/linux-aarch64-low.cc
index 2ed6e95..c248147 100644
--- a/gdbserver/linux-aarch64-low.cc
+++ b/gdbserver/linux-aarch64-low.cc
@@ -60,7 +60,6 @@
class aarch64_target : public linux_process_target
{
public:
-
const regs_info *get_regs_info () override;
int breakpoint_kind_from_pc (CORE_ADDR *pcptr) override;
@@ -75,13 +74,13 @@ public:
bool supports_fast_tracepoints () override;
- int install_fast_tracepoint_jump_pad
- (CORE_ADDR tpoint, CORE_ADDR tpaddr, CORE_ADDR collector,
- CORE_ADDR lockaddr, ULONGEST orig_size, CORE_ADDR *jump_entry,
- CORE_ADDR *trampoline, ULONGEST *trampoline_size,
- unsigned char *jjump_pad_insn, ULONGEST *jjump_pad_insn_size,
- CORE_ADDR *adjusted_insn_addr, CORE_ADDR *adjusted_insn_addr_end,
- char *err) override;
+ int install_fast_tracepoint_jump_pad (
+ CORE_ADDR tpoint, CORE_ADDR tpaddr, CORE_ADDR collector,
+ CORE_ADDR lockaddr, ULONGEST orig_size, CORE_ADDR *jump_entry,
+ CORE_ADDR *trampoline, ULONGEST *trampoline_size,
+ unsigned char *jjump_pad_insn, ULONGEST *jjump_pad_insn_size,
+ CORE_ADDR *adjusted_insn_addr, CORE_ADDR *adjusted_insn_addr_end,
+ char *err) override;
int get_min_fast_tracepoint_insn_len () override;
@@ -89,14 +88,13 @@ public:
bool supports_memory_tagging () override;
- bool fetch_memtags (CORE_ADDR address, size_t len,
- gdb::byte_vector &tags, int type) override;
+ bool fetch_memtags (CORE_ADDR address, size_t len, gdb::byte_vector &tags,
+ int type) override;
bool store_memtags (CORE_ADDR address, size_t len,
- const gdb::byte_vector &tags, int type) override;
+ const gdb::byte_vector &tags, int type) override;
protected:
-
void low_arch_setup () override;
bool low_cannot_fetch_register (int regno) override;
@@ -111,18 +109,18 @@ protected:
bool low_breakpoint_at (CORE_ADDR pc) override;
- int low_insert_point (raw_bkpt_type type, CORE_ADDR addr,
- int size, raw_breakpoint *bp) override;
+ int low_insert_point (raw_bkpt_type type, CORE_ADDR addr, int size,
+ raw_breakpoint *bp) override;
- int low_remove_point (raw_bkpt_type type, CORE_ADDR addr,
- int size, raw_breakpoint *bp) override;
+ int low_remove_point (raw_bkpt_type type, CORE_ADDR addr, int size,
+ raw_breakpoint *bp) override;
bool low_stopped_by_watchpoint () override;
CORE_ADDR low_stopped_data_address () override;
bool low_siginfo_fixup (siginfo_t *native, gdb_byte *inf,
- int direction) override;
+ int direction) override;
arch_process_info *low_new_process () override;
@@ -153,14 +151,14 @@ bool
aarch64_target::low_cannot_fetch_register (int regno)
{
gdb_assert_not_reached ("linux target op low_cannot_fetch_register "
- "is not implemented by the target");
+ "is not implemented by the target");
}
bool
aarch64_target::low_cannot_store_register (int regno)
{
gdb_assert_not_reached ("linux target op low_cannot_store_register "
- "is not implemented by the target");
+ "is not implemented by the target");
}
void
@@ -259,9 +257,9 @@ aarch64_store_pauthregset (struct regcache *regcache, const void *buf)
return;
supply_register (regcache, AARCH64_PAUTH_DMASK_REGNUM (pauth_base),
- &pauth_regset[0]);
+ &pauth_regset[0]);
supply_register (regcache, AARCH64_PAUTH_CMASK_REGNUM (pauth_base),
- &pauth_regset[1]);
+ &pauth_regset[1]);
}
/* Fill BUF with the MTE registers from the regcache. */
@@ -293,7 +291,7 @@ static void
aarch64_fill_tlsregset (struct regcache *regcache, void *buf)
{
gdb_byte *tls_buf = (gdb_byte *) buf;
- int tls_regnum = find_regno (regcache->tdesc, "tpidr");
+ int tls_regnum = find_regno (regcache->tdesc, "tpidr");
collect_register (regcache, tls_regnum, tls_buf);
@@ -310,7 +308,7 @@ static void
aarch64_store_tlsregset (struct regcache *regcache, const void *buf)
{
gdb_byte *tls_buf = (gdb_byte *) buf;
- int tls_regnum = find_regno (regcache->tdesc, "tpidr");
+ int tls_regnum = find_regno (regcache->tdesc, "tpidr");
supply_register (regcache, tls_regnum, tls_buf);
@@ -354,7 +352,7 @@ aarch64_target::low_set_pc (regcache *regcache, CORE_ADDR pc)
/* AArch64 BRK software debug mode instruction.
This instruction needs to match gdb/aarch64-tdep.c
(aarch64_default_breakpoint). */
-static const gdb_byte aarch64_breakpoint[] = {0x00, 0x00, 0x20, 0xd4};
+static const gdb_byte aarch64_breakpoint[] = { 0x00, 0x00, 0x20, 0xd4 };
/* Implementation of linux target ops method "low_breakpoint_at". */
@@ -367,7 +365,7 @@ aarch64_target::low_breakpoint_at (CORE_ADDR where)
read_memory (where, (unsigned char *) &insn, aarch64_breakpoint_len);
if (memcmp (insn, aarch64_breakpoint, aarch64_breakpoint_len) == 0)
- return true;
+ return true;
return false;
}
@@ -430,8 +428,8 @@ aarch64_target::supports_z_point_type (char z_type)
the actual insertion will happen when threads are resumed. */
int
-aarch64_target::low_insert_point (raw_bkpt_type type, CORE_ADDR addr,
- int len, raw_breakpoint *bp)
+aarch64_target::low_insert_point (raw_bkpt_type type, CORE_ADDR addr, int len,
+ raw_breakpoint *bp)
{
int ret;
enum target_hw_bp_type targ_type;
@@ -440,7 +438,7 @@ aarch64_target::low_insert_point (raw_bkpt_type type, CORE_ADDR addr,
if (show_debug_regs)
fprintf (stderr, "insert_point on entry (addr=0x%08lx, len=%d)\n",
- (unsigned long) addr, len);
+ (unsigned long) addr, len);
/* Determine the type from the raw breakpoint type. */
targ_type = raw_bkpt_type_to_target_hw_bp_type (type);
@@ -448,29 +446,27 @@ aarch64_target::low_insert_point (raw_bkpt_type type, CORE_ADDR addr,
if (targ_type != hw_execute)
{
if (aarch64_region_ok_for_watchpoint (addr, len))
- ret = aarch64_handle_watchpoint (targ_type, addr, len,
- 1 /* is_insert */,
- current_lwp_ptid (), state);
+ ret
+ = aarch64_handle_watchpoint (targ_type, addr, len, 1 /* is_insert */,
+ current_lwp_ptid (), state);
else
- ret = -1;
+ ret = -1;
}
else
{
if (len == 3)
- {
- /* LEN is 3 means the breakpoint is set on a 32-bit thumb
+ {
+ /* LEN is 3 means the breakpoint is set on a 32-bit thumb
instruction. Set it to 2 to correctly encode length bit
mask in hardware/watchpoint control register. */
- len = 2;
- }
- ret = aarch64_handle_breakpoint (targ_type, addr, len,
- 1 /* is_insert */, current_lwp_ptid (),
- state);
+ len = 2;
+ }
+ ret = aarch64_handle_breakpoint (targ_type, addr, len, 1 /* is_insert */,
+ current_lwp_ptid (), state);
}
if (show_debug_regs)
- aarch64_show_debug_reg_state (state, "insert_point", addr, len,
- targ_type);
+ aarch64_show_debug_reg_state (state, "insert_point", addr, len, targ_type);
return ret;
}
@@ -481,8 +477,8 @@ aarch64_target::low_insert_point (raw_bkpt_type type, CORE_ADDR addr,
the actual removal will be done when threads are resumed. */
int
-aarch64_target::low_remove_point (raw_bkpt_type type, CORE_ADDR addr,
- int len, raw_breakpoint *bp)
+aarch64_target::low_remove_point (raw_bkpt_type type, CORE_ADDR addr, int len,
+ raw_breakpoint *bp)
{
int ret;
enum target_hw_bp_type targ_type;
@@ -491,33 +487,30 @@ aarch64_target::low_remove_point (raw_bkpt_type type, CORE_ADDR addr,
if (show_debug_regs)
fprintf (stderr, "remove_point on entry (addr=0x%08lx, len=%d)\n",
- (unsigned long) addr, len);
+ (unsigned long) addr, len);
/* Determine the type from the raw breakpoint type. */
targ_type = raw_bkpt_type_to_target_hw_bp_type (type);
/* Set up state pointers. */
if (targ_type != hw_execute)
- ret =
- aarch64_handle_watchpoint (targ_type, addr, len, 0 /* is_insert */,
- current_lwp_ptid (), state);
+ ret = aarch64_handle_watchpoint (targ_type, addr, len, 0 /* is_insert */,
+ current_lwp_ptid (), state);
else
{
if (len == 3)
- {
- /* LEN is 3 means the breakpoint is set on a 32-bit thumb
+ {
+ /* LEN is 3 means the breakpoint is set on a 32-bit thumb
instruction. Set it to 2 to correctly encode length bit
mask in hardware/watchpoint control register. */
- len = 2;
- }
- ret = aarch64_handle_breakpoint (targ_type, addr, len,
- 0 /* is_insert */, current_lwp_ptid (),
- state);
+ len = 2;
+ }
+ ret = aarch64_handle_breakpoint (targ_type, addr, len, 0 /* is_insert */,
+ current_lwp_ptid (), state);
}
if (show_debug_regs)
- aarch64_show_debug_reg_state (state, "remove_point", addr, len,
- targ_type);
+ aarch64_show_debug_reg_state (state, "remove_point", addr, len, targ_type);
return ret;
}
@@ -531,7 +524,7 @@ aarch64_remove_non_address_bits (CORE_ADDR pointer)
/* Check if PAC is available for this target. */
if (tdesc_contains_feature (current_process ()->tdesc,
- "org.gnu.gdb.aarch64.pauth"))
+ "org.gnu.gdb.aarch64.pauth"))
{
/* Fetch the PAC masks. These masks are per-process, so we can just
fetch data from whatever thread we have at the moment.
@@ -540,8 +533,10 @@ aarch64_remove_non_address_bits (CORE_ADDR pointer)
same, but this may change in the future. */
struct regcache *regs = get_thread_regcache (current_thread, 1);
- CORE_ADDR dmask = regcache_raw_get_unsigned_by_name (regs, "pauth_dmask");
- CORE_ADDR cmask = regcache_raw_get_unsigned_by_name (regs, "pauth_cmask");
+ CORE_ADDR dmask
+ = regcache_raw_get_unsigned_by_name (regs, "pauth_dmask");
+ CORE_ADDR cmask
+ = regcache_raw_get_unsigned_by_name (regs, "pauth_cmask");
mask |= aarch64_mask_from_pac_registers (cmask, dmask);
}
@@ -579,18 +574,19 @@ aarch64_target::low_stopped_data_address ()
for (i = aarch64_num_wp_regs - 1; i >= 0; --i)
{
const unsigned int offset
- = aarch64_watchpoint_offset (state->dr_ctrl_wp[i]);
- const unsigned int len = aarch64_watchpoint_length (state->dr_ctrl_wp[i]);
+ = aarch64_watchpoint_offset (state->dr_ctrl_wp[i]);
+ const unsigned int len
+ = aarch64_watchpoint_length (state->dr_ctrl_wp[i]);
const CORE_ADDR addr_watch = state->dr_addr_wp[i] + offset;
- const CORE_ADDR addr_watch_aligned = align_down (state->dr_addr_wp[i], 8);
+ const CORE_ADDR addr_watch_aligned
+ = align_down (state->dr_addr_wp[i], 8);
const CORE_ADDR addr_orig = state->dr_addr_orig_wp[i];
if (state->dr_ref_count_wp[i]
- && DR_CONTROL_ENABLED (state->dr_ctrl_wp[i])
- && addr_trap >= addr_watch_aligned
- && addr_trap < addr_watch + len)
- {
- /* ADDR_TRAP reports the first address of the memory range
+ && DR_CONTROL_ENABLED (state->dr_ctrl_wp[i])
+ && addr_trap >= addr_watch_aligned && addr_trap < addr_watch + len)
+ {
+ /* ADDR_TRAP reports the first address of the memory range
accessed by the CPU, regardless of what was the memory
range watched. Thus, a large CPU access that straddles
the ADDR_WATCH..ADDR_WATCH+LEN range may result in an
@@ -608,8 +604,8 @@ aarch64_target::low_stopped_data_address ()
range. ADDR_WATCH <= ADDR_TRAP < ADDR_ORIG is a false
positive on kernels older than 4.10. See PR
external/20207. */
- return addr_orig;
- }
+ return addr_orig;
+ }
}
return (CORE_ADDR) 0;
@@ -626,28 +622,27 @@ aarch64_target::low_stopped_by_watchpoint ()
/* Fetch the thread-local storage pointer for libthread_db. */
ps_err_e
-ps_get_thread_area (struct ps_prochandle *ph,
- lwpid_t lwpid, int idx, void **base)
+ps_get_thread_area (struct ps_prochandle *ph, lwpid_t lwpid, int idx,
+ void **base)
{
- return aarch64_ps_get_thread_area (ph, lwpid, idx, base,
- is_64bit_tdesc ());
+ return aarch64_ps_get_thread_area (ph, lwpid, idx, base, is_64bit_tdesc ());
}
/* Implementation of linux target ops method "low_siginfo_fixup". */
bool
aarch64_target::low_siginfo_fixup (siginfo_t *native, gdb_byte *inf,
- int direction)
+ int direction)
{
/* Is the inferior 32-bit? If so, then fixup the siginfo object. */
if (!is_64bit_tdesc ())
{
if (direction == 0)
- aarch64_compat_siginfo_from_siginfo ((struct compat_siginfo *) inf,
- native);
+ aarch64_compat_siginfo_from_siginfo ((struct compat_siginfo *) inf,
+ native);
else
- aarch64_siginfo_from_compat_siginfo (native,
- (struct compat_siginfo *) inf);
+ aarch64_siginfo_from_compat_siginfo (native,
+ (struct compat_siginfo *) inf);
return true;
}
@@ -690,14 +685,11 @@ aarch64_target::low_delete_thread (arch_lwp_info *arch_lwp)
/* Implementation of linux target ops method "low_new_fork". */
void
-aarch64_target::low_new_fork (process_info *parent,
- process_info *child)
+aarch64_target::low_new_fork (process_info *parent, process_info *child)
{
/* These are allocated by linux_add_process. */
- gdb_assert (parent->priv != NULL
- && parent->priv->arch_private != NULL);
- gdb_assert (child->priv != NULL
- && child->priv->arch_private != NULL);
+ gdb_assert (parent->priv != NULL && parent->priv->arch_private != NULL);
+ gdb_assert (child->priv != NULL && child->priv->arch_private != NULL);
/* Linux kernel before 2.6.33 commit
72f674d203cd230426437cdcf7dd6f681dad8b0d
@@ -738,50 +730,39 @@ aarch64_sve_regs_copy_from_regcache (struct regcache *regcache, void *buf)
Their sizes are set to 0 here, but they will be adjusted later depending
on whether each register set is available or not. */
-static struct regset_info aarch64_regsets[] =
-{
+static struct regset_info aarch64_regsets[] = {
/* GPR registers. */
- { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_PRSTATUS,
- 0, GENERAL_REGS,
+ { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_PRSTATUS, 0, GENERAL_REGS,
aarch64_fill_gregset, aarch64_store_gregset },
/* Floating Point (FPU) registers. */
- { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_FPREGSET,
- 0, FP_REGS,
- aarch64_fill_fpregset, aarch64_store_fpregset
- },
+ { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_FPREGSET, 0, FP_REGS,
+ aarch64_fill_fpregset, aarch64_store_fpregset },
/* Scalable Vector Extension (SVE) registers. */
- { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_ARM_SVE,
- 0, EXTENDED_REGS,
- aarch64_sve_regs_copy_from_regcache, aarch64_sve_regs_copy_to_regcache
- },
+ { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_ARM_SVE, 0, EXTENDED_REGS,
+ aarch64_sve_regs_copy_from_regcache, aarch64_sve_regs_copy_to_regcache },
/* PAC registers. */
- { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_ARM_PAC_MASK,
- 0, OPTIONAL_REGS,
+ { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_ARM_PAC_MASK, 0, OPTIONAL_REGS,
nullptr, aarch64_store_pauthregset },
/* Tagged address control / MTE registers. */
- { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_ARM_TAGGED_ADDR_CTRL,
- 0, OPTIONAL_REGS,
- aarch64_fill_mteregset, aarch64_store_mteregset },
+ { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_ARM_TAGGED_ADDR_CTRL, 0,
+ OPTIONAL_REGS, aarch64_fill_mteregset, aarch64_store_mteregset },
/* TLS register. */
- { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_ARM_TLS,
- 0, OPTIONAL_REGS,
+ { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_ARM_TLS, 0, OPTIONAL_REGS,
aarch64_fill_tlsregset, aarch64_store_tlsregset },
NULL_REGSET
};
-static struct regsets_info aarch64_regsets_info =
- {
- aarch64_regsets, /* regsets */
- 0, /* num_regsets */
- nullptr, /* disabled_regsets */
- };
+static struct regsets_info aarch64_regsets_info = {
+ aarch64_regsets, /* regsets */
+ 0, /* num_regsets */
+ nullptr, /* disabled_regsets */
+};
-static struct regs_info regs_info_aarch64 =
- {
- nullptr, /* regset_bitmap */
- nullptr, /* usrregs */
- &aarch64_regsets_info,
- };
+static struct regs_info regs_info_aarch64 = {
+ nullptr, /* regset_bitmap */
+ nullptr, /* usrregs */
+ &aarch64_regsets_info,
+};
/* Given FEATURES, adjust the available register sets by setting their
sizes. A size of 0 means the register set is disabled and won't be
@@ -795,35 +776,35 @@ aarch64_adjust_register_sets (const struct aarch64_features &features)
for (regset = aarch64_regsets; regset->size >= 0; regset++)
{
switch (regset->nt_type)
- {
- case NT_PRSTATUS:
- /* General purpose registers are always present. */
- regset->size = sizeof (struct user_pt_regs);
- break;
- case NT_FPREGSET:
- /* This is unavailable when SVE is present. */
- if (features.vq == 0)
- regset->size = sizeof (struct user_fpsimd_state);
- break;
- case NT_ARM_SVE:
- if (features.vq > 0)
- regset->size = SVE_PT_SIZE (AARCH64_MAX_SVE_VQ, SVE_PT_REGS_SVE);
- break;
- case NT_ARM_PAC_MASK:
- if (features.pauth)
- regset->size = AARCH64_PAUTH_REGS_SIZE;
- break;
- case NT_ARM_TAGGED_ADDR_CTRL:
- if (features.mte)
- regset->size = AARCH64_LINUX_SIZEOF_MTE;
- break;
- case NT_ARM_TLS:
- if (features.tls > 0)
- regset->size = AARCH64_TLS_REGISTER_SIZE * features.tls;
- break;
- default:
- gdb_assert_not_reached ("Unknown register set found.");
- }
+ {
+ case NT_PRSTATUS:
+ /* General purpose registers are always present. */
+ regset->size = sizeof (struct user_pt_regs);
+ break;
+ case NT_FPREGSET:
+ /* This is unavailable when SVE is present. */
+ if (features.vq == 0)
+ regset->size = sizeof (struct user_fpsimd_state);
+ break;
+ case NT_ARM_SVE:
+ if (features.vq > 0)
+ regset->size = SVE_PT_SIZE (AARCH64_MAX_SVE_VQ, SVE_PT_REGS_SVE);
+ break;
+ case NT_ARM_PAC_MASK:
+ if (features.pauth)
+ regset->size = AARCH64_PAUTH_REGS_SIZE;
+ break;
+ case NT_ARM_TAGGED_ADDR_CTRL:
+ if (features.mte)
+ regset->size = AARCH64_LINUX_SIZEOF_MTE;
+ break;
+ case NT_ARM_TLS:
+ if (features.tls > 0)
+ regset->size = AARCH64_TLS_REGISTER_SIZE * features.tls;
+ break;
+ default:
+ gdb_assert_not_reached ("Unknown register set found.");
+ }
}
}
@@ -965,10 +946,10 @@ struct aarch64_operand
/* Value of the operand according to the type. */
union
- {
- uint32_t imm;
- struct aarch64_register reg;
- };
+ {
+ uint32_t imm;
+ struct aarch64_register reg;
+ };
};
/* List of registers that we are currently using, we can add more here as
@@ -1083,9 +1064,9 @@ postindex_memory_operand (int32_t index)
enum aarch64_system_control_registers
{
/* op0 op1 crn crm op2 */
- NZCV = (0x1 << 14) | (0x3 << 11) | (0x4 << 7) | (0x2 << 3) | 0x0,
- FPSR = (0x1 << 14) | (0x3 << 11) | (0x4 << 7) | (0x4 << 3) | 0x1,
- FPCR = (0x1 << 14) | (0x3 << 11) | (0x4 << 7) | (0x4 << 3) | 0x0,
+ NZCV = (0x1 << 14) | (0x3 << 11) | (0x4 << 7) | (0x2 << 3) | 0x0,
+ FPSR = (0x1 << 14) | (0x3 << 11) | (0x4 << 7) | (0x4 << 3) | 0x1,
+ FPCR = (0x1 << 14) | (0x3 << 11) | (0x4 << 7) | (0x4 << 3) | 0x0,
TPIDR_EL0 = (0x1 << 14) | (0x3 << 11) | (0xd << 7) | (0x0 << 3) | 0x2
};
@@ -1115,10 +1096,9 @@ emit_ret (uint32_t *buf, struct aarch64_register rn)
static int
emit_load_store_pair (uint32_t *buf, enum aarch64_opcodes opcode,
- struct aarch64_register rt,
- struct aarch64_register rt2,
- struct aarch64_register rn,
- struct aarch64_memory_operand operand)
+ struct aarch64_register rt, struct aarch64_register rt2,
+ struct aarch64_register rn,
+ struct aarch64_memory_operand operand)
{
uint32_t opc;
uint32_t pre_index;
@@ -1133,30 +1113,31 @@ emit_load_store_pair (uint32_t *buf, enum aarch64_opcodes opcode,
{
case MEMORY_OPERAND_OFFSET:
{
- pre_index = ENCODE (1, 1, 24);
- write_back = ENCODE (0, 1, 23);
- break;
+ pre_index = ENCODE (1, 1, 24);
+ write_back = ENCODE (0, 1, 23);
+ break;
}
case MEMORY_OPERAND_POSTINDEX:
{
- pre_index = ENCODE (0, 1, 24);
- write_back = ENCODE (1, 1, 23);
- break;
+ pre_index = ENCODE (0, 1, 24);
+ write_back = ENCODE (1, 1, 23);
+ break;
}
case MEMORY_OPERAND_PREINDEX:
{
- pre_index = ENCODE (1, 1, 24);
- write_back = ENCODE (1, 1, 23);
- break;
+ pre_index = ENCODE (1, 1, 24);
+ write_back = ENCODE (1, 1, 23);
+ break;
}
default:
return 0;
}
return aarch64_emit_insn (buf, opcode | opc | pre_index | write_back
- | ENCODE (operand.index >> 3, 7, 15)
- | ENCODE (rt2.num, 5, 10)
- | ENCODE (rn.num, 5, 5) | ENCODE (rt.num, 5, 0));
+ | ENCODE (operand.index >> 3, 7, 15)
+ | ENCODE (rt2.num, 5, 10)
+ | ENCODE (rn.num, 5, 5)
+ | ENCODE (rt.num, 5, 0));
}
/* Write a STP instruction into *BUF.
@@ -1172,8 +1153,8 @@ emit_load_store_pair (uint32_t *buf, enum aarch64_opcodes opcode,
static int
emit_stp (uint32_t *buf, struct aarch64_register rt,
- struct aarch64_register rt2, struct aarch64_register rn,
- struct aarch64_memory_operand operand)
+ struct aarch64_register rt2, struct aarch64_register rn,
+ struct aarch64_memory_operand operand)
{
return emit_load_store_pair (buf, STP, rt, rt2, rn, operand);
}
@@ -1191,8 +1172,8 @@ emit_stp (uint32_t *buf, struct aarch64_register rt,
static int
emit_ldp (uint32_t *buf, struct aarch64_register rt,
- struct aarch64_register rt2, struct aarch64_register rn,
- struct aarch64_memory_operand operand)
+ struct aarch64_register rt2, struct aarch64_register rn,
+ struct aarch64_memory_operand operand)
{
return emit_load_store_pair (buf, LDP, rt, rt2, rn, operand);
}
@@ -1208,15 +1189,16 @@ emit_ldp (uint32_t *buf, struct aarch64_register rt,
static int
emit_ldp_q_offset (uint32_t *buf, unsigned rt, unsigned rt2,
- struct aarch64_register rn, int32_t offset)
+ struct aarch64_register rn, int32_t offset)
{
uint32_t opc = ENCODE (2, 2, 30);
uint32_t pre_index = ENCODE (1, 1, 24);
return aarch64_emit_insn (buf, LDP_SIMD_VFP | opc | pre_index
- | ENCODE (offset >> 4, 7, 15)
- | ENCODE (rt2, 5, 10)
- | ENCODE (rn.num, 5, 5) | ENCODE (rt, 5, 0));
+ | ENCODE (offset >> 4, 7, 15)
+ | ENCODE (rt2, 5, 10)
+ | ENCODE (rn.num, 5, 5)
+ | ENCODE (rt, 5, 0));
}
/* Write a STP (SIMD&VFP) instruction using Q registers into *BUF.
@@ -1230,15 +1212,16 @@ emit_ldp_q_offset (uint32_t *buf, unsigned rt, unsigned rt2,
static int
emit_stp_q_offset (uint32_t *buf, unsigned rt, unsigned rt2,
- struct aarch64_register rn, int32_t offset)
+ struct aarch64_register rn, int32_t offset)
{
uint32_t opc = ENCODE (2, 2, 30);
uint32_t pre_index = ENCODE (1, 1, 24);
return aarch64_emit_insn (buf, STP_SIMD_VFP | opc | pre_index
- | ENCODE (offset >> 4, 7, 15)
- | ENCODE (rt2, 5, 10)
- | ENCODE (rn.num, 5, 5) | ENCODE (rt, 5, 0));
+ | ENCODE (offset >> 4, 7, 15)
+ | ENCODE (rt2, 5, 10)
+ | ENCODE (rn.num, 5, 5)
+ | ENCODE (rt, 5, 0));
}
/* Write a LDRH instruction into *BUF.
@@ -1254,8 +1237,7 @@ emit_stp_q_offset (uint32_t *buf, unsigned rt, unsigned rt2,
static int
emit_ldrh (uint32_t *buf, struct aarch64_register rt,
- struct aarch64_register rn,
- struct aarch64_memory_operand operand)
+ struct aarch64_register rn, struct aarch64_memory_operand operand)
{
return aarch64_emit_load_store (buf, 1, LDR, rt, rn, operand);
}
@@ -1273,14 +1255,11 @@ emit_ldrh (uint32_t *buf, struct aarch64_register rt,
static int
emit_ldrb (uint32_t *buf, struct aarch64_register rt,
- struct aarch64_register rn,
- struct aarch64_memory_operand operand)
+ struct aarch64_register rn, struct aarch64_memory_operand operand)
{
return aarch64_emit_load_store (buf, 0, LDR, rt, rn, operand);
}
-
-
/* Write a STR instruction into *BUF.
STR rt, [rn, #offset]
@@ -1294,8 +1273,7 @@ emit_ldrb (uint32_t *buf, struct aarch64_register rt,
static int
emit_str (uint32_t *buf, struct aarch64_register rt,
- struct aarch64_register rn,
- struct aarch64_memory_operand operand)
+ struct aarch64_register rn, struct aarch64_memory_operand operand)
{
return aarch64_emit_load_store (buf, rt.is64 ? 3 : 2, STR, rt, rn, operand);
}
@@ -1304,15 +1282,17 @@ emit_str (uint32_t *buf, struct aarch64_register rt,
static int
emit_load_store_exclusive (uint32_t *buf, uint32_t size,
- enum aarch64_opcodes opcode,
- struct aarch64_register rs,
- struct aarch64_register rt,
- struct aarch64_register rt2,
- struct aarch64_register rn)
+ enum aarch64_opcodes opcode,
+ struct aarch64_register rs,
+ struct aarch64_register rt,
+ struct aarch64_register rt2,
+ struct aarch64_register rn)
{
return aarch64_emit_insn (buf, opcode | ENCODE (size, 2, 30)
- | ENCODE (rs.num, 5, 16) | ENCODE (rt2.num, 5, 10)
- | ENCODE (rn.num, 5, 5) | ENCODE (rt.num, 5, 0));
+ | ENCODE (rs.num, 5, 16)
+ | ENCODE (rt2.num, 5, 10)
+ | ENCODE (rn.num, 5, 5)
+ | ENCODE (rt.num, 5, 0));
}
/* Write a LAXR instruction into *BUF.
@@ -1324,10 +1304,10 @@ emit_load_store_exclusive (uint32_t *buf, uint32_t size,
static int
emit_ldaxr (uint32_t *buf, struct aarch64_register rt,
- struct aarch64_register rn)
+ struct aarch64_register rn)
{
- return emit_load_store_exclusive (buf, rt.is64 ? 3 : 2, LDAXR, xzr, rt,
- xzr, rn);
+ return emit_load_store_exclusive (buf, rt.is64 ? 3 : 2, LDAXR, xzr, rt, xzr,
+ rn);
}
/* Write a STXR instruction into *BUF.
@@ -1340,10 +1320,10 @@ emit_ldaxr (uint32_t *buf, struct aarch64_register rt,
static int
emit_stxr (uint32_t *buf, struct aarch64_register rs,
- struct aarch64_register rt, struct aarch64_register rn)
+ struct aarch64_register rt, struct aarch64_register rn)
{
- return emit_load_store_exclusive (buf, rt.is64 ? 3 : 2, STXR, rs, rt,
- xzr, rn);
+ return emit_load_store_exclusive (buf, rt.is64 ? 3 : 2, STXR, rs, rt, xzr,
+ rn);
}
/* Write a STLR instruction into *BUF.
@@ -1355,24 +1335,25 @@ emit_stxr (uint32_t *buf, struct aarch64_register rs,
static int
emit_stlr (uint32_t *buf, struct aarch64_register rt,
- struct aarch64_register rn)
+ struct aarch64_register rn)
{
- return emit_load_store_exclusive (buf, rt.is64 ? 3 : 2, STLR, xzr, rt,
- xzr, rn);
+ return emit_load_store_exclusive (buf, rt.is64 ? 3 : 2, STLR, xzr, rt, xzr,
+ rn);
}
/* Helper function for data processing instructions with register sources. */
static int
emit_data_processing_reg (uint32_t *buf, uint32_t opcode,
- struct aarch64_register rd,
- struct aarch64_register rn,
- struct aarch64_register rm)
+ struct aarch64_register rd,
+ struct aarch64_register rn,
+ struct aarch64_register rm)
{
uint32_t size = ENCODE (rd.is64, 1, 31);
return aarch64_emit_insn (buf, opcode | size | ENCODE (rm.num, 5, 16)
- | ENCODE (rn.num, 5, 5) | ENCODE (rd.num, 5, 0));
+ | ENCODE (rn.num, 5, 5)
+ | ENCODE (rd.num, 5, 0));
}
/* Helper function for data processing instructions taking either a register
@@ -1380,9 +1361,8 @@ emit_data_processing_reg (uint32_t *buf, uint32_t opcode,
static int
emit_data_processing (uint32_t *buf, enum aarch64_opcodes opcode,
- struct aarch64_register rd,
- struct aarch64_register rn,
- struct aarch64_operand operand)
+ struct aarch64_register rd, struct aarch64_register rn,
+ struct aarch64_operand operand)
{
uint32_t size = ENCODE (rd.is64, 1, 31);
/* The opcode is different for register and immediate source operands. */
@@ -1394,17 +1374,17 @@ emit_data_processing (uint32_t *buf, enum aarch64_opcodes opcode,
operand_opcode = ENCODE (8, 4, 25);
return aarch64_emit_insn (buf, opcode | operand_opcode | size
- | ENCODE (operand.imm, 12, 10)
- | ENCODE (rn.num, 5, 5)
- | ENCODE (rd.num, 5, 0));
+ | ENCODE (operand.imm, 12, 10)
+ | ENCODE (rn.num, 5, 5)
+ | ENCODE (rd.num, 5, 0));
}
else
{
/* xxx0 101x xxxx xxxx xxxx xxxx xxxx xxxx */
operand_opcode = ENCODE (5, 4, 25);
- return emit_data_processing_reg (buf, opcode | operand_opcode, rd,
- rn, operand.reg);
+ return emit_data_processing_reg (buf, opcode | operand_opcode, rd, rn,
+ operand.reg);
}
}
@@ -1422,7 +1402,7 @@ emit_data_processing (uint32_t *buf, enum aarch64_opcodes opcode,
static int
emit_add (uint32_t *buf, struct aarch64_register rd,
- struct aarch64_register rn, struct aarch64_operand operand)
+ struct aarch64_register rn, struct aarch64_operand operand)
{
return emit_data_processing (buf, ADD, rd, rn, operand);
}
@@ -1440,7 +1420,7 @@ emit_add (uint32_t *buf, struct aarch64_register rd,
static int
emit_sub (uint32_t *buf, struct aarch64_register rd,
- struct aarch64_register rn, struct aarch64_operand operand)
+ struct aarch64_register rn, struct aarch64_operand operand)
{
return emit_data_processing (buf, SUB, rd, rn, operand);
}
@@ -1461,7 +1441,7 @@ emit_sub (uint32_t *buf, struct aarch64_register rd,
static int
emit_mov (uint32_t *buf, struct aarch64_register rd,
- struct aarch64_operand operand)
+ struct aarch64_operand operand)
{
if (operand.type == OPERAND_IMMEDIATE)
{
@@ -1470,8 +1450,8 @@ emit_mov (uint32_t *buf, struct aarch64_register rd,
uint32_t shift = ENCODE (0, 2, 21);
return aarch64_emit_insn (buf, MOV | size | shift
- | ENCODE (operand.imm, 16, 5)
- | ENCODE (rd.num, 5, 0));
+ | ENCODE (operand.imm, 16, 5)
+ | ENCODE (rd.num, 5, 0));
}
else
return emit_add (buf, rd, operand.reg, immediate_operand (0));
@@ -1487,12 +1467,13 @@ emit_mov (uint32_t *buf, struct aarch64_register rd,
static int
emit_movk (uint32_t *buf, struct aarch64_register rd, uint32_t imm,
- unsigned shift)
+ unsigned shift)
{
uint32_t size = ENCODE (rd.is64, 1, 31);
- return aarch64_emit_insn (buf, MOVK | size | ENCODE (shift, 2, 21) |
- ENCODE (imm, 16, 5) | ENCODE (rd.num, 5, 0));
+ return aarch64_emit_insn (buf, MOVK | size | ENCODE (shift, 2, 21)
+ | ENCODE (imm, 16, 5)
+ | ENCODE (rd.num, 5, 0));
}
/* Write instructions into *BUF in order to move ADDR into a register.
@@ -1541,7 +1522,7 @@ emit_mov_addr (uint32_t *buf, struct aarch64_register rd, CORE_ADDR addr)
static int
emit_subs (uint32_t *buf, struct aarch64_register rd,
- struct aarch64_register rn, struct aarch64_operand operand)
+ struct aarch64_register rn, struct aarch64_operand operand)
{
return emit_data_processing (buf, SUBS, rd, rn, operand);
}
@@ -1556,7 +1537,7 @@ emit_subs (uint32_t *buf, struct aarch64_register rd,
static int
emit_cmp (uint32_t *buf, struct aarch64_register rn,
- struct aarch64_operand operand)
+ struct aarch64_operand operand)
{
return emit_subs (buf, xzr, rn, operand);
}
@@ -1570,7 +1551,7 @@ emit_cmp (uint32_t *buf, struct aarch64_register rn,
static int
emit_and (uint32_t *buf, struct aarch64_register rd,
- struct aarch64_register rn, struct aarch64_register rm)
+ struct aarch64_register rn, struct aarch64_register rm)
{
return emit_data_processing_reg (buf, AND, rd, rn, rm);
}
@@ -1584,7 +1565,7 @@ emit_and (uint32_t *buf, struct aarch64_register rd,
static int
emit_orr (uint32_t *buf, struct aarch64_register rd,
- struct aarch64_register rn, struct aarch64_register rm)
+ struct aarch64_register rn, struct aarch64_register rm)
{
return emit_data_processing_reg (buf, ORR, rd, rn, rm);
}
@@ -1598,7 +1579,7 @@ emit_orr (uint32_t *buf, struct aarch64_register rd,
static int
emit_orn (uint32_t *buf, struct aarch64_register rd,
- struct aarch64_register rn, struct aarch64_register rm)
+ struct aarch64_register rn, struct aarch64_register rm)
{
return emit_data_processing_reg (buf, ORN, rd, rn, rm);
}
@@ -1612,7 +1593,7 @@ emit_orn (uint32_t *buf, struct aarch64_register rd,
static int
emit_eor (uint32_t *buf, struct aarch64_register rd,
- struct aarch64_register rn, struct aarch64_register rm)
+ struct aarch64_register rn, struct aarch64_register rm)
{
return emit_data_processing_reg (buf, EOR, rd, rn, rm);
}
@@ -1628,7 +1609,7 @@ emit_eor (uint32_t *buf, struct aarch64_register rd,
static int
emit_mvn (uint32_t *buf, struct aarch64_register rd,
- struct aarch64_register rm)
+ struct aarch64_register rm)
{
return emit_orn (buf, rd, xzr, rm);
}
@@ -1642,7 +1623,7 @@ emit_mvn (uint32_t *buf, struct aarch64_register rd,
static int
emit_lslv (uint32_t *buf, struct aarch64_register rd,
- struct aarch64_register rn, struct aarch64_register rm)
+ struct aarch64_register rn, struct aarch64_register rm)
{
return emit_data_processing_reg (buf, LSLV, rd, rn, rm);
}
@@ -1656,7 +1637,7 @@ emit_lslv (uint32_t *buf, struct aarch64_register rd,
static int
emit_lsrv (uint32_t *buf, struct aarch64_register rd,
- struct aarch64_register rn, struct aarch64_register rm)
+ struct aarch64_register rn, struct aarch64_register rm)
{
return emit_data_processing_reg (buf, LSRV, rd, rn, rm);
}
@@ -1670,7 +1651,7 @@ emit_lsrv (uint32_t *buf, struct aarch64_register rd,
static int
emit_asrv (uint32_t *buf, struct aarch64_register rd,
- struct aarch64_register rn, struct aarch64_register rm)
+ struct aarch64_register rn, struct aarch64_register rm)
{
return emit_data_processing_reg (buf, ASRV, rd, rn, rm);
}
@@ -1684,7 +1665,7 @@ emit_asrv (uint32_t *buf, struct aarch64_register rd,
static int
emit_mul (uint32_t *buf, struct aarch64_register rd,
- struct aarch64_register rn, struct aarch64_register rm)
+ struct aarch64_register rn, struct aarch64_register rm)
{
return emit_data_processing_reg (buf, MUL, rd, rn, rm);
}
@@ -1698,10 +1679,10 @@ emit_mul (uint32_t *buf, struct aarch64_register rd,
static int
emit_mrs (uint32_t *buf, struct aarch64_register rt,
- enum aarch64_system_control_registers system_reg)
+ enum aarch64_system_control_registers system_reg)
{
return aarch64_emit_insn (buf, MRS | ENCODE (system_reg, 15, 5)
- | ENCODE (rt.num, 5, 0));
+ | ENCODE (rt.num, 5, 0));
}
/* Write a MSR instruction into *BUF. The register size is 64-bit.
@@ -1713,10 +1694,10 @@ emit_mrs (uint32_t *buf, struct aarch64_register rt,
static int
emit_msr (uint32_t *buf, enum aarch64_system_control_registers system_reg,
- struct aarch64_register rt)
+ struct aarch64_register rt)
{
return aarch64_emit_insn (buf, MSR | ENCODE (system_reg, 15, 5)
- | ENCODE (rt.num, 5, 0));
+ | ENCODE (rt.num, 5, 0));
}
/* Write a SEVL instruction into *BUF.
@@ -1753,14 +1734,15 @@ emit_wfe (uint32_t *buf)
static int
emit_sbfm (uint32_t *buf, struct aarch64_register rd,
- struct aarch64_register rn, uint32_t immr, uint32_t imms)
+ struct aarch64_register rn, uint32_t immr, uint32_t imms)
{
uint32_t size = ENCODE (rd.is64, 1, 31);
uint32_t n = ENCODE (rd.is64, 1, 22);
return aarch64_emit_insn (buf, SBFM | size | n | ENCODE (immr, 6, 16)
- | ENCODE (imms, 6, 10) | ENCODE (rn.num, 5, 5)
- | ENCODE (rd.num, 5, 0));
+ | ENCODE (imms, 6, 10)
+ | ENCODE (rn.num, 5, 5)
+ | ENCODE (rd.num, 5, 0));
}
/* Write a SBFX instruction into *BUF.
@@ -1779,7 +1761,7 @@ emit_sbfm (uint32_t *buf, struct aarch64_register rd,
static int
emit_sbfx (uint32_t *buf, struct aarch64_register rd,
- struct aarch64_register rn, uint32_t lsb, uint32_t width)
+ struct aarch64_register rn, uint32_t lsb, uint32_t width)
{
return emit_sbfm (buf, rd, rn, lsb, lsb + width - 1);
}
@@ -1798,14 +1780,15 @@ emit_sbfx (uint32_t *buf, struct aarch64_register rd,
static int
emit_ubfm (uint32_t *buf, struct aarch64_register rd,
- struct aarch64_register rn, uint32_t immr, uint32_t imms)
+ struct aarch64_register rn, uint32_t immr, uint32_t imms)
{
uint32_t size = ENCODE (rd.is64, 1, 31);
uint32_t n = ENCODE (rd.is64, 1, 22);
return aarch64_emit_insn (buf, UBFM | size | n | ENCODE (immr, 6, 16)
- | ENCODE (imms, 6, 10) | ENCODE (rn.num, 5, 5)
- | ENCODE (rd.num, 5, 0));
+ | ENCODE (imms, 6, 10)
+ | ENCODE (rn.num, 5, 5)
+ | ENCODE (rd.num, 5, 0));
}
/* Write a UBFX instruction into *BUF.
@@ -1824,7 +1807,7 @@ emit_ubfm (uint32_t *buf, struct aarch64_register rd,
static int
emit_ubfx (uint32_t *buf, struct aarch64_register rd,
- struct aarch64_register rn, uint32_t lsb, uint32_t width)
+ struct aarch64_register rn, uint32_t lsb, uint32_t width)
{
return emit_ubfm (buf, rd, rn, lsb, lsb + width - 1);
}
@@ -1842,14 +1825,15 @@ emit_ubfx (uint32_t *buf, struct aarch64_register rd,
static int
emit_csinc (uint32_t *buf, struct aarch64_register rd,
- struct aarch64_register rn, struct aarch64_register rm,
- unsigned cond)
+ struct aarch64_register rn, struct aarch64_register rm,
+ unsigned cond)
{
uint32_t size = ENCODE (rd.is64, 1, 31);
return aarch64_emit_insn (buf, CSINC | size | ENCODE (rm.num, 5, 16)
- | ENCODE (cond, 4, 12) | ENCODE (rn.num, 5, 5)
- | ENCODE (rd.num, 5, 0));
+ | ENCODE (cond, 4, 12)
+ | ENCODE (rn.num, 5, 5)
+ | ENCODE (rd.num, 5, 0));
}
/* Write a CSET instruction into *BUF.
@@ -1919,7 +1903,7 @@ struct aarch64_insn_relocation_data
static void
aarch64_ftrace_insn_reloc_b (const int is_bl, const int32_t offset,
- struct aarch64_insn_data *data)
+ struct aarch64_insn_data *data)
{
struct aarch64_insn_relocation_data *insn_reloc
= (struct aarch64_insn_relocation_data *) data;
@@ -1934,7 +1918,7 @@ aarch64_ftrace_insn_reloc_b (const int is_bl, const int32_t offset,
static void
aarch64_ftrace_insn_reloc_b_cond (const unsigned cond, const int32_t offset,
- struct aarch64_insn_data *data)
+ struct aarch64_insn_data *data)
{
struct aarch64_insn_relocation_data *insn_reloc
= (struct aarch64_insn_relocation_data *) data;
@@ -1943,8 +1927,8 @@ aarch64_ftrace_insn_reloc_b_cond (const unsigned cond, const int32_t offset,
if (can_encode_int32 (new_offset, 21))
{
- insn_reloc->insn_ptr += emit_bcond (insn_reloc->insn_ptr, cond,
- new_offset);
+ insn_reloc->insn_ptr
+ += emit_bcond (insn_reloc->insn_ptr, cond, new_offset);
}
else if (can_encode_int32 (new_offset, 28))
{
@@ -1970,8 +1954,8 @@ aarch64_ftrace_insn_reloc_b_cond (const unsigned cond, const int32_t offset,
static void
aarch64_ftrace_insn_reloc_cb (const int32_t offset, const int is_cbnz,
- const unsigned rn, int is64,
- struct aarch64_insn_data *data)
+ const unsigned rn, int is64,
+ struct aarch64_insn_data *data)
{
struct aarch64_insn_relocation_data *insn_reloc
= (struct aarch64_insn_relocation_data *) data;
@@ -1980,8 +1964,9 @@ aarch64_ftrace_insn_reloc_cb (const int32_t offset, const int is_cbnz,
if (can_encode_int32 (new_offset, 21))
{
- insn_reloc->insn_ptr += emit_cb (insn_reloc->insn_ptr, is_cbnz,
- aarch64_register (rn, is64), new_offset);
+ insn_reloc->insn_ptr
+ += emit_cb (insn_reloc->insn_ptr, is_cbnz, aarch64_register (rn, is64),
+ new_offset);
}
else if (can_encode_int32 (new_offset, 28))
{
@@ -1997,7 +1982,7 @@ aarch64_ftrace_insn_reloc_cb (const int32_t offset, const int is_cbnz,
*/
insn_reloc->insn_ptr += emit_cb (insn_reloc->insn_ptr, is_cbnz,
- aarch64_register (rn, is64), 8);
+ aarch64_register (rn, is64), 8);
insn_reloc->insn_ptr += emit_b (insn_reloc->insn_ptr, 0, 8);
insn_reloc->insn_ptr += emit_b (insn_reloc->insn_ptr, 0, new_offset - 8);
}
@@ -2007,8 +1992,8 @@ aarch64_ftrace_insn_reloc_cb (const int32_t offset, const int is_cbnz,
static void
aarch64_ftrace_insn_reloc_tb (const int32_t offset, int is_tbnz,
- const unsigned rt, unsigned bit,
- struct aarch64_insn_data *data)
+ const unsigned rt, unsigned bit,
+ struct aarch64_insn_data *data)
{
struct aarch64_insn_relocation_data *insn_reloc
= (struct aarch64_insn_relocation_data *) data;
@@ -2018,7 +2003,7 @@ aarch64_ftrace_insn_reloc_tb (const int32_t offset, int is_tbnz,
if (can_encode_int32 (new_offset, 16))
{
insn_reloc->insn_ptr += emit_tb (insn_reloc->insn_ptr, is_tbnz, bit,
- aarch64_register (rt, 1), new_offset);
+ aarch64_register (rt, 1), new_offset);
}
else if (can_encode_int32 (new_offset, 28))
{
@@ -2034,10 +2019,9 @@ aarch64_ftrace_insn_reloc_tb (const int32_t offset, int is_tbnz,
*/
insn_reloc->insn_ptr += emit_tb (insn_reloc->insn_ptr, is_tbnz, bit,
- aarch64_register (rt, 1), 8);
+ aarch64_register (rt, 1), 8);
insn_reloc->insn_ptr += emit_b (insn_reloc->insn_ptr, 0, 8);
- insn_reloc->insn_ptr += emit_b (insn_reloc->insn_ptr, 0,
- new_offset - 8);
+ insn_reloc->insn_ptr += emit_b (insn_reloc->insn_ptr, 0, new_offset - 8);
}
}
@@ -2045,8 +2029,8 @@ aarch64_ftrace_insn_reloc_tb (const int32_t offset, int is_tbnz,
static void
aarch64_ftrace_insn_reloc_adr (const int32_t offset, const unsigned rd,
- const int is_adrp,
- struct aarch64_insn_data *data)
+ const int is_adrp,
+ struct aarch64_insn_data *data)
{
struct aarch64_insn_relocation_data *insn_reloc
= (struct aarch64_insn_relocation_data *) data;
@@ -2057,28 +2041,28 @@ aarch64_ftrace_insn_reloc_adr (const int32_t offset, const unsigned rd,
if (is_adrp)
{
/* Clear the lower 12 bits of the offset to get the 4K page. */
- insn_reloc->insn_ptr += emit_mov_addr (insn_reloc->insn_ptr,
- aarch64_register (rd, 1),
- address & ~0xfff);
+ insn_reloc->insn_ptr
+ += emit_mov_addr (insn_reloc->insn_ptr, aarch64_register (rd, 1),
+ address & ~0xfff);
}
else
insn_reloc->insn_ptr += emit_mov_addr (insn_reloc->insn_ptr,
- aarch64_register (rd, 1), address);
+ aarch64_register (rd, 1), address);
}
/* Implementation of aarch64_insn_visitor method "ldr_literal". */
static void
aarch64_ftrace_insn_reloc_ldr_literal (const int32_t offset, const int is_sw,
- const unsigned rt, const int is64,
- struct aarch64_insn_data *data)
+ const unsigned rt, const int is64,
+ struct aarch64_insn_data *data)
{
struct aarch64_insn_relocation_data *insn_reloc
= (struct aarch64_insn_relocation_data *) data;
CORE_ADDR address = data->insn_addr + offset;
- insn_reloc->insn_ptr += emit_mov_addr (insn_reloc->insn_ptr,
- aarch64_register (rt, 1), address);
+ insn_reloc->insn_ptr
+ += emit_mov_addr (insn_reloc->insn_ptr, aarch64_register (rt, 1), address);
/* We know exactly what address to load from, and what register we
can use:
@@ -2092,22 +2076,20 @@ aarch64_ftrace_insn_reloc_ldr_literal (const int32_t offset, const int is_sw,
*/
if (is_sw)
- insn_reloc->insn_ptr += emit_ldrsw (insn_reloc->insn_ptr,
- aarch64_register (rt, 1),
- aarch64_register (rt, 1),
- offset_memory_operand (0));
+ insn_reloc->insn_ptr
+ += emit_ldrsw (insn_reloc->insn_ptr, aarch64_register (rt, 1),
+ aarch64_register (rt, 1), offset_memory_operand (0));
else
- insn_reloc->insn_ptr += emit_ldr (insn_reloc->insn_ptr,
- aarch64_register (rt, is64),
- aarch64_register (rt, 1),
- offset_memory_operand (0));
+ insn_reloc->insn_ptr
+ += emit_ldr (insn_reloc->insn_ptr, aarch64_register (rt, is64),
+ aarch64_register (rt, 1), offset_memory_operand (0));
}
/* Implementation of aarch64_insn_visitor method "others". */
static void
aarch64_ftrace_insn_reloc_others (const uint32_t insn,
- struct aarch64_insn_data *data)
+ struct aarch64_insn_data *data)
{
struct aarch64_insn_relocation_data *insn_reloc
= (struct aarch64_insn_relocation_data *) data;
@@ -2117,14 +2099,10 @@ aarch64_ftrace_insn_reloc_others (const uint32_t insn,
insn_reloc->insn_ptr += aarch64_emit_insn (insn_reloc->insn_ptr, insn);
}
-static const struct aarch64_insn_visitor visitor =
-{
- aarch64_ftrace_insn_reloc_b,
- aarch64_ftrace_insn_reloc_b_cond,
- aarch64_ftrace_insn_reloc_cb,
- aarch64_ftrace_insn_reloc_tb,
- aarch64_ftrace_insn_reloc_adr,
- aarch64_ftrace_insn_reloc_ldr_literal,
+static const struct aarch64_insn_visitor visitor = {
+ aarch64_ftrace_insn_reloc_b, aarch64_ftrace_insn_reloc_b_cond,
+ aarch64_ftrace_insn_reloc_cb, aarch64_ftrace_insn_reloc_tb,
+ aarch64_ftrace_insn_reloc_adr, aarch64_ftrace_insn_reloc_ldr_literal,
aarch64_ftrace_insn_reloc_others,
};
@@ -2138,13 +2116,12 @@ aarch64_target::supports_fast_tracepoints ()
"install_fast_tracepoint_jump_pad". */
int
-aarch64_target::install_fast_tracepoint_jump_pad
- (CORE_ADDR tpoint, CORE_ADDR tpaddr, CORE_ADDR collector,
- CORE_ADDR lockaddr, ULONGEST orig_size, CORE_ADDR *jump_entry,
- CORE_ADDR *trampoline, ULONGEST *trampoline_size,
- unsigned char *jjump_pad_insn, ULONGEST *jjump_pad_insn_size,
- CORE_ADDR *adjusted_insn_addr, CORE_ADDR *adjusted_insn_addr_end,
- char *err)
+aarch64_target::install_fast_tracepoint_jump_pad (
+ CORE_ADDR tpoint, CORE_ADDR tpaddr, CORE_ADDR collector, CORE_ADDR lockaddr,
+ ULONGEST orig_size, CORE_ADDR *jump_entry, CORE_ADDR *trampoline,
+ ULONGEST *trampoline_size, unsigned char *jjump_pad_insn,
+ ULONGEST *jjump_pad_insn_size, CORE_ADDR *adjusted_insn_addr,
+ CORE_ADDR *adjusted_insn_addr_end, char *err)
{
uint32_t buf[256];
uint32_t *p = buf;
@@ -2229,7 +2206,7 @@ aarch64_target::install_fast_tracepoint_jump_pad
p += emit_sub (p, sp, sp, immediate_operand (31 * 16));
for (i = 30; i >= 0; i -= 1)
p += emit_str (p, aarch64_register (i, 1), sp,
- offset_memory_operand (i * 16));
+ offset_memory_operand (i * 16));
/* Make space for 5 more cells.
@@ -2238,7 +2215,6 @@ aarch64_target::install_fast_tracepoint_jump_pad
*/
p += emit_sub (p, sp, sp, immediate_operand (5 * 16));
-
/* Save SP:
ADD x4, sp, #((32 + 31 + 5) * 16)
@@ -2433,7 +2409,7 @@ aarch64_target::install_fast_tracepoint_jump_pad
*/
for (i = 0; i <= 30; i += 1)
p += emit_ldr (p, aarch64_register (i, 1), sp,
- offset_memory_operand (i * 16));
+ offset_memory_operand (i * 16));
p += emit_add (p, sp, sp, immediate_operand (31 * 16));
/* Pop SIMD&FP registers:
@@ -2461,15 +2437,14 @@ aarch64_target::install_fast_tracepoint_jump_pad
insn_data.insn_ptr = buf;
aarch64_relocate_instruction (insn, &visitor,
- (struct aarch64_insn_data *) &insn_data);
+ (struct aarch64_insn_data *) &insn_data);
/* We may not have been able to relocate the instruction. */
if (insn_data.insn_ptr == buf)
{
- sprintf (err,
- "E.Could not relocate instruction from %s to %s.",
- core_addr_to_string_nz (tpaddr),
- core_addr_to_string_nz (buildaddr));
+ sprintf (err, "E.Could not relocate instruction from %s to %s.",
+ core_addr_to_string_nz (tpaddr),
+ core_addr_to_string_nz (buildaddr));
return 1;
}
else
@@ -2484,9 +2459,9 @@ aarch64_target::install_fast_tracepoint_jump_pad
if (!can_encode_int32 (offset, 28))
{
sprintf (err,
- "E.Jump back from jump pad too far from tracepoint "
- "(offset 0x%" PRIx64 " cannot be encoded in 28 bits).",
- offset);
+ "E.Jump back from jump pad too far from tracepoint "
+ "(offset 0x%" PRIx64 " cannot be encoded in 28 bits).",
+ offset);
return 1;
}
@@ -2498,9 +2473,9 @@ aarch64_target::install_fast_tracepoint_jump_pad
if (!can_encode_int32 (offset, 28))
{
sprintf (err,
- "E.Jump pad too far from tracepoint "
- "(offset 0x%" PRIx64 " cannot be encoded in 28 bits).",
- offset);
+ "E.Jump pad too far from tracepoint "
+ "(offset 0x%" PRIx64 " cannot be encoded in 28 bits).",
+ offset);
return 1;
}
@@ -2521,8 +2496,8 @@ emit_ops_insns (const uint32_t *start, int len)
{
CORE_ADDR buildaddr = current_insn_ptr;
- threads_debug_printf ("Adding %d instrucions at %s",
- len, paddress (buildaddr));
+ threads_debug_printf ("Adding %d instrucions at %s", len,
+ paddress (buildaddr));
append_insns (&buildaddr, len, start);
current_insn_ptr = buildaddr;
@@ -2586,7 +2561,6 @@ aarch64_emit_prologue (void)
p += emit_add (p, fp, sp, immediate_operand (2 * 8));
-
emit_ops_insns (buf, p - buf);
}
@@ -3203,44 +3177,25 @@ aarch64_emit_ge_got (int *offset_p, int *size_p)
emit_ops_insns (buf, p - buf);
}
-static struct emit_ops aarch64_emit_ops_impl =
-{
- aarch64_emit_prologue,
- aarch64_emit_epilogue,
- aarch64_emit_add,
- aarch64_emit_sub,
- aarch64_emit_mul,
- aarch64_emit_lsh,
- aarch64_emit_rsh_signed,
- aarch64_emit_rsh_unsigned,
- aarch64_emit_ext,
- aarch64_emit_log_not,
- aarch64_emit_bit_and,
- aarch64_emit_bit_or,
- aarch64_emit_bit_xor,
- aarch64_emit_bit_not,
- aarch64_emit_equal,
- aarch64_emit_less_signed,
- aarch64_emit_less_unsigned,
- aarch64_emit_ref,
- aarch64_emit_if_goto,
- aarch64_emit_goto,
- aarch64_write_goto_address,
- aarch64_emit_const,
- aarch64_emit_call,
- aarch64_emit_reg,
- aarch64_emit_pop,
- aarch64_emit_stack_flush,
- aarch64_emit_zero_ext,
- aarch64_emit_swap,
- aarch64_emit_stack_adjust,
- aarch64_emit_int_call_1,
- aarch64_emit_void_call_2,
- aarch64_emit_eq_goto,
- aarch64_emit_ne_goto,
- aarch64_emit_lt_goto,
- aarch64_emit_le_goto,
- aarch64_emit_gt_goto,
+static struct emit_ops aarch64_emit_ops_impl = {
+ aarch64_emit_prologue, aarch64_emit_epilogue,
+ aarch64_emit_add, aarch64_emit_sub,
+ aarch64_emit_mul, aarch64_emit_lsh,
+ aarch64_emit_rsh_signed, aarch64_emit_rsh_unsigned,
+ aarch64_emit_ext, aarch64_emit_log_not,
+ aarch64_emit_bit_and, aarch64_emit_bit_or,
+ aarch64_emit_bit_xor, aarch64_emit_bit_not,
+ aarch64_emit_equal, aarch64_emit_less_signed,
+ aarch64_emit_less_unsigned, aarch64_emit_ref,
+ aarch64_emit_if_goto, aarch64_emit_goto,
+ aarch64_write_goto_address, aarch64_emit_const,
+ aarch64_emit_call, aarch64_emit_reg,
+ aarch64_emit_pop, aarch64_emit_stack_flush,
+ aarch64_emit_zero_ext, aarch64_emit_swap,
+ aarch64_emit_stack_adjust, aarch64_emit_int_call_1,
+ aarch64_emit_void_call_2, aarch64_emit_eq_goto,
+ aarch64_emit_ne_goto, aarch64_emit_lt_goto,
+ aarch64_emit_le_goto, aarch64_emit_gt_goto,
aarch64_emit_ge_got,
};
@@ -3328,13 +3283,13 @@ aarch64_target::supports_memory_tagging ()
bool
aarch64_target::fetch_memtags (CORE_ADDR address, size_t len,
- gdb::byte_vector &tags, int type)
+ gdb::byte_vector &tags, int type)
{
/* Allocation tags are per-process, so any tid is fine. */
int tid = lwpid_of (current_thread);
/* Allocation tag? */
- if (type == static_cast <int> (aarch64_memtag_type::mte_allocation))
+ if (type == static_cast<int> (aarch64_memtag_type::mte_allocation))
return aarch64_mte_fetch_memtags (tid, address, len, tags);
return false;
@@ -3342,13 +3297,13 @@ aarch64_target::fetch_memtags (CORE_ADDR address, size_t len,
bool
aarch64_target::store_memtags (CORE_ADDR address, size_t len,
- const gdb::byte_vector &tags, int type)
+ const gdb::byte_vector &tags, int type)
{
/* Allocation tags are per-process, so any tid is fine. */
int tid = lwpid_of (current_thread);
/* Allocation tag? */
- if (type == static_cast <int> (aarch64_memtag_type::mte_allocation))
+ if (type == static_cast<int> (aarch64_memtag_type::mte_allocation))
return aarch64_mte_store_memtags (tid, address, len, tags);
return false;
diff --git a/gdbserver/linux-aarch64-tdesc.cc b/gdbserver/linux-aarch64-tdesc.cc
index 6331349..8e926e8 100644
--- a/gdbserver/linux-aarch64-tdesc.cc
+++ b/gdbserver/linux-aarch64-tdesc.cc
@@ -36,8 +36,8 @@ const target_desc *
aarch64_linux_read_description (const aarch64_features &features)
{
if (features.vq > AARCH64_MAX_SVE_VQ)
- error (_("VQ is %" PRIu64 ", maximum supported value is %d"), features.vq,
- AARCH64_MAX_SVE_VQ);
+ error (_ ("VQ is %" PRIu64 ", maximum supported value is %d"), features.vq,
+ AARCH64_MAX_SVE_VQ);
struct target_desc *tdesc = tdesc_aarch64_map[features];
@@ -46,13 +46,13 @@ aarch64_linux_read_description (const aarch64_features &features)
tdesc = aarch64_create_target_description (features);
static const char *expedite_regs_aarch64[] = { "x29", "sp", "pc", NULL };
- static const char *expedite_regs_aarch64_sve[] = { "x29", "sp", "pc",
- "vg", NULL };
+ static const char *expedite_regs_aarch64_sve[]
+ = { "x29", "sp", "pc", "vg", NULL };
if (features.vq == 0)
- init_target_desc (tdesc, expedite_regs_aarch64);
+ init_target_desc (tdesc, expedite_regs_aarch64);
else
- init_target_desc (tdesc, expedite_regs_aarch64_sve);
+ init_target_desc (tdesc, expedite_regs_aarch64_sve);
tdesc_aarch64_map[features] = tdesc;
}
diff --git a/gdbserver/linux-aarch64-tdesc.h b/gdbserver/linux-aarch64-tdesc.h
index 9650479..005890d 100644
--- a/gdbserver/linux-aarch64-tdesc.h
+++ b/gdbserver/linux-aarch64-tdesc.h
@@ -23,6 +23,6 @@
#include "arch/aarch64.h"
const target_desc *
- aarch64_linux_read_description (const aarch64_features &features);
+aarch64_linux_read_description (const aarch64_features &features);
#endif /* GDBSERVER_LINUX_AARCH64_TDESC_H */
diff --git a/gdbserver/linux-amd64-ipa.cc b/gdbserver/linux-amd64-ipa.cc
index ae2bd15..2e8cd12 100644
--- a/gdbserver/linux-amd64-ipa.cc
+++ b/gdbserver/linux-amd64-ipa.cc
@@ -49,26 +49,25 @@ extern const struct target_desc *tdesc_amd64_linux;
#define FT_CR_RBP 16
#define FT_CR_RSP 17
-static const int x86_64_ft_collect_regmap[] = {
- FT_CR_RAX * 8, FT_CR_RBX * 8, FT_CR_RCX * 8, FT_CR_RDX * 8,
- FT_CR_RSI * 8, FT_CR_RDI * 8, FT_CR_RBP * 8, FT_CR_RSP * 8,
- FT_CR_R8 * 8, FT_CR_R9 * 8, FT_CR_R10 * 8, FT_CR_R11 * 8,
- FT_CR_R12 * 8, FT_CR_R13 * 8, FT_CR_R14 * 8, FT_CR_R15 * 8,
- FT_CR_RIP * 8, FT_CR_EFLAGS * 8
-};
+static const int x86_64_ft_collect_regmap[]
+ = { FT_CR_RAX * 8, FT_CR_RBX * 8, FT_CR_RCX * 8, FT_CR_RDX * 8,
+ FT_CR_RSI * 8, FT_CR_RDI * 8, FT_CR_RBP * 8, FT_CR_RSP * 8,
+ FT_CR_R8 * 8, FT_CR_R9 * 8, FT_CR_R10 * 8, FT_CR_R11 * 8,
+ FT_CR_R12 * 8, FT_CR_R13 * 8, FT_CR_R14 * 8, FT_CR_R15 * 8,
+ FT_CR_RIP * 8, FT_CR_EFLAGS * 8 };
#define X86_64_NUM_FT_COLLECT_GREGS \
- (sizeof (x86_64_ft_collect_regmap) / sizeof(x86_64_ft_collect_regmap[0]))
+ (sizeof (x86_64_ft_collect_regmap) / sizeof (x86_64_ft_collect_regmap[0]))
void
supply_fast_tracepoint_registers (struct regcache *regcache,
- const unsigned char *buf)
+ const unsigned char *buf)
{
int i;
for (i = 0; i < X86_64_NUM_FT_COLLECT_GREGS; i++)
supply_register (regcache, i,
- ((char *) buf) + x86_64_ft_collect_regmap[i]);
+ ((char *) buf) + x86_64_ft_collect_regmap[i]);
}
ULONGEST
@@ -89,39 +88,25 @@ get_raw_reg (const unsigned char *raw_regs, int regnum)
contain RIP, but we know what it must have been (the marker
address). */
-#define ST_REGENTRY(REG) \
- { \
- offsetof (struct registers, REG), \
- sizeof (((struct registers *) NULL)->REG) \
+#define ST_REGENTRY(REG) \
+ { \
+ offsetof (struct registers, REG), \
+ sizeof (((struct registers *) NULL)->REG) \
}
static struct
{
int offset;
int size;
-} x86_64_st_collect_regmap[] =
- {
- ST_REGENTRY(rax),
- ST_REGENTRY(rbx),
- ST_REGENTRY(rcx),
- ST_REGENTRY(rdx),
- ST_REGENTRY(rsi),
- ST_REGENTRY(rdi),
- ST_REGENTRY(rbp),
- ST_REGENTRY(rsp),
- ST_REGENTRY(r8),
- ST_REGENTRY(r9),
- ST_REGENTRY(r10),
- ST_REGENTRY(r11),
- ST_REGENTRY(r12),
- ST_REGENTRY(r13),
- ST_REGENTRY(r14),
- ST_REGENTRY(r15),
- { -1, 0 },
- ST_REGENTRY(rflags),
- ST_REGENTRY(cs),
- ST_REGENTRY(ss),
- };
+} x86_64_st_collect_regmap[] = {
+ ST_REGENTRY (rax), ST_REGENTRY (rbx), ST_REGENTRY (rcx),
+ ST_REGENTRY (rdx), ST_REGENTRY (rsi), ST_REGENTRY (rdi),
+ ST_REGENTRY (rbp), ST_REGENTRY (rsp), ST_REGENTRY (r8),
+ ST_REGENTRY (r9), ST_REGENTRY (r10), ST_REGENTRY (r11),
+ ST_REGENTRY (r12), ST_REGENTRY (r13), ST_REGENTRY (r14),
+ ST_REGENTRY (r15), { -1, 0 }, ST_REGENTRY (rflags),
+ ST_REGENTRY (cs), ST_REGENTRY (ss),
+};
#define X86_64_NUM_ST_COLLECT_GREGS \
(sizeof (x86_64_st_collect_regmap) / sizeof (x86_64_st_collect_regmap[0]))
@@ -131,8 +116,7 @@ static struct
void
supply_static_tracepoint_registers (struct regcache *regcache,
- const unsigned char *buf,
- CORE_ADDR pc)
+ const unsigned char *buf, CORE_ADDR pc)
{
int i;
unsigned long newpc = pc;
@@ -142,27 +126,26 @@ supply_static_tracepoint_registers (struct regcache *regcache,
for (i = 0; i < X86_64_NUM_ST_COLLECT_GREGS; i++)
if (x86_64_st_collect_regmap[i].offset != -1)
{
- switch (x86_64_st_collect_regmap[i].size)
- {
- case 8:
- supply_register (regcache, i,
- ((char *) buf)
- + x86_64_st_collect_regmap[i].offset);
- break;
- case 2:
- {
- unsigned long reg
- = * (short *) (((char *) buf)
- + x86_64_st_collect_regmap[i].offset);
- reg &= 0xffff;
- supply_register (regcache, i, &reg);
- }
- break;
- default:
- internal_error ("unhandled register size: %d",
- x86_64_st_collect_regmap[i].size);
- break;
- }
+ switch (x86_64_st_collect_regmap[i].size)
+ {
+ case 8:
+ supply_register (regcache, i,
+ ((char *) buf)
+ + x86_64_st_collect_regmap[i].offset);
+ break;
+ case 2:
+ {
+ unsigned long reg = *(
+ short *) (((char *) buf) + x86_64_st_collect_regmap[i].offset);
+ reg &= 0xffff;
+ supply_register (regcache, i, &reg);
+ }
+ break;
+ default:
+ internal_error ("unhandled register size: %d",
+ x86_64_st_collect_regmap[i].size);
+ break;
+ }
}
}
@@ -247,23 +230,22 @@ alloc_jump_pad_buffer (size_t size)
void *res;
/* No MAP_FIXED - we don't want to zap someone's mapping. */
- res = mmap ((void *) addr, size,
- PROT_READ | PROT_WRITE | PROT_EXEC,
- MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+ res = mmap ((void *) addr, size, PROT_READ | PROT_WRITE | PROT_EXEC,
+ MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
/* If we got what we wanted, return. */
if ((uintptr_t) res == addr)
- return res;
+ return res;
/* If we got a mapping, but at a wrong address, undo it. */
if (res != MAP_FAILED)
- munmap (res, size);
+ munmap (res, size);
}
return NULL;
#else
void *res = mmap (NULL, size, PROT_READ | PROT_WRITE | PROT_EXEC,
- MAP_PRIVATE | MAP_ANONYMOUS | MAP_32BIT, -1, 0);
+ MAP_PRIVATE | MAP_ANONYMOUS | MAP_32BIT, -1, 0);
if (res == MAP_FAILED)
return NULL;
diff --git a/gdbserver/linux-arc-low.cc b/gdbserver/linux-arc-low.cc
index f028847..bd4f884 100644
--- a/gdbserver/linux-arc-low.cc
+++ b/gdbserver/linux-arc-low.cc
@@ -33,8 +33,8 @@
#endif
/* The encoding of the instruction "TRAP_S 1" (endianness agnostic). */
-#define TRAP_S_1_OPCODE 0x783e
-#define TRAP_S_1_SIZE 2
+#define TRAP_S_1_OPCODE 0x783e
+#define TRAP_S_1_SIZE 2
/* Using a mere "uint16_t arc_linux_traps_s = TRAP_S_1_OPCODE" would
work as well, because the endianness will end up correctly when
@@ -45,11 +45,11 @@
#if defined(__BIG_ENDIAN__)
/* 0x78, 0x3e. */
static gdb_byte arc_linux_trap_s[TRAP_S_1_SIZE]
- = {TRAP_S_1_OPCODE >> 8, TRAP_S_1_OPCODE & 0xFF};
+ = { TRAP_S_1_OPCODE >> 8, TRAP_S_1_OPCODE & 0xFF };
#else
/* 0x3e, 0x78. */
static gdb_byte arc_linux_trap_s[TRAP_S_1_SIZE]
- = {TRAP_S_1_OPCODE && 0xFF, TRAP_S_1_OPCODE >> 8};
+ = { TRAP_S_1_OPCODE && 0xFF, TRAP_S_1_OPCODE >> 8 };
#endif
/* Linux target op definitions for the ARC architecture.
@@ -60,13 +60,11 @@ static gdb_byte arc_linux_trap_s[TRAP_S_1_SIZE]
class arc_target : public linux_process_target
{
public:
-
const regs_info *get_regs_info () override;
const gdb_byte *sw_breakpoint_from_kind (int kind, int *size) override;
protected:
-
void low_arch_setup () override;
bool low_cannot_fetch_register (int regno) override;
@@ -233,7 +231,8 @@ arc_fill_gregset (struct regcache *regcache, void *buf)
static void
arc_store_gregset (struct regcache *regcache, const void *buf)
{
- const struct user_regs_struct *regbuf = (const struct user_regs_struct *) buf;
+ const struct user_regs_struct *regbuf
+ = (const struct user_regs_struct *) buf;
/* Core registers. */
supply_register_by_name (regcache, "r0", &(regbuf->scratch.r0));
@@ -296,8 +295,7 @@ arc_store_gregset (struct regcache *regcache, const void *buf)
If found, return true; false, otherwise. */
static bool
-is_reg_name_available_p (const struct target_desc *tdesc,
- const char *name)
+is_reg_name_available_p (const struct target_desc *tdesc, const char *name)
{
for (const gdb::reg &reg : tdesc->reg_defs)
if (strcmp (name, reg.name) == 0)
@@ -348,8 +346,8 @@ arc_store_v2_regset (struct regcache *regcache, const void *buf)
linux-arm-low.c. */
ps_err_e
-ps_get_thread_area (struct ps_prochandle *ph, lwpid_t lwpid,
- int idx, void **base)
+ps_get_thread_area (struct ps_prochandle *ph, lwpid_t lwpid, int idx,
+ void **base)
{
if (ptrace (PTRACE_GET_THREAD_AREA, lwpid, nullptr, base) != 0)
return PS_ERR;
@@ -362,34 +360,26 @@ ps_get_thread_area (struct ps_prochandle *ph, lwpid_t lwpid,
return PS_OK;
}
-static struct regset_info arc_regsets[] =
-{
- { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_PRSTATUS,
- sizeof (struct user_regs_struct), GENERAL_REGS,
- arc_fill_gregset, arc_store_gregset
- },
+static struct regset_info arc_regsets[]
+ = { { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_PRSTATUS,
+ sizeof (struct user_regs_struct), GENERAL_REGS, arc_fill_gregset,
+ arc_store_gregset },
#ifdef ARC_HAS_V2_REGSET
- { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_ARC_V2,
- sizeof (struct user_regs_arcv2), GENERAL_REGS,
- arc_fill_v2_regset, arc_store_v2_regset
- },
+ { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_ARC_V2,
+ sizeof (struct user_regs_arcv2), GENERAL_REGS, arc_fill_v2_regset,
+ arc_store_v2_regset },
#endif
- NULL_REGSET
-};
+ NULL_REGSET };
-static struct regsets_info arc_regsets_info =
-{
- arc_regsets, /* regsets */
- 0, /* num_regsets */
- nullptr, /* disabled regsets */
+static struct regsets_info arc_regsets_info = {
+ arc_regsets, /* regsets */
+ 0, /* num_regsets */
+ nullptr, /* disabled regsets */
};
-static struct regs_info arc_regs_info =
-{
- nullptr, /* regset_bitmap */
- nullptr, /* usrregs */
- &arc_regsets_info
-};
+static struct regs_info arc_regs_info = { nullptr, /* regset_bitmap */
+ nullptr, /* usrregs */
+ &arc_regsets_info };
const regs_info *
arc_target::get_regs_info ()
diff --git a/gdbserver/linux-arm-low.cc b/gdbserver/linux-arm-low.cc
index 5975b44..92538d5 100644
--- a/gdbserver/linux-arm-low.cc
+++ b/gdbserver/linux-arm-low.cc
@@ -40,13 +40,13 @@
#endif
#ifndef PTRACE_GETWMMXREGS
-# define PTRACE_GETWMMXREGS 18
-# define PTRACE_SETWMMXREGS 19
+#define PTRACE_GETWMMXREGS 18
+#define PTRACE_SETWMMXREGS 19
#endif
#ifndef PTRACE_GETVFPREGS
-# define PTRACE_GETVFPREGS 27
-# define PTRACE_SETVFPREGS 28
+#define PTRACE_GETVFPREGS 27
+#define PTRACE_SETVFPREGS 28
#endif
#ifndef PTRACE_GETHBPREGS
@@ -59,7 +59,6 @@
class arm_target : public linux_process_target
{
public:
-
const regs_info *get_regs_info () override;
int breakpoint_kind_from_pc (CORE_ADDR *pcptr) override;
@@ -75,7 +74,6 @@ public:
bool supports_hardware_single_step () override;
protected:
-
void low_arch_setup () override;
bool low_cannot_fetch_register (int regno) override;
@@ -92,11 +90,11 @@ protected:
bool low_breakpoint_at (CORE_ADDR pc) override;
- int low_insert_point (raw_bkpt_type type, CORE_ADDR addr,
- int size, raw_breakpoint *bp) override;
+ int low_insert_point (raw_bkpt_type type, CORE_ADDR addr, int size,
+ raw_breakpoint *bp) override;
- int low_remove_point (raw_bkpt_type type, CORE_ADDR addr,
- int size, raw_breakpoint *bp) override;
+ int low_remove_point (raw_bkpt_type type, CORE_ADDR addr, int size,
+ raw_breakpoint *bp) override;
bool low_stopped_by_watchpoint () override;
@@ -220,11 +218,11 @@ struct arch_lwp_info
};
/* These are in <asm/elf.h> in current kernels. */
-#define HWCAP_VFP 64
-#define HWCAP_IWMMXT 512
-#define HWCAP_NEON 4096
-#define HWCAP_VFPv3 8192
-#define HWCAP_VFPv3D16 16384
+#define HWCAP_VFP 64
+#define HWCAP_IWMMXT 512
+#define HWCAP_NEON 4096
+#define HWCAP_VFPv3 8192
+#define HWCAP_VFPv3D16 16384
#ifdef HAVE_SYS_REG_H
#include <sys/reg.h>
@@ -232,20 +230,17 @@ struct arch_lwp_info
#define arm_num_regs 26
-static int arm_regmap[] = {
- 0, 4, 8, 12, 16, 20, 24, 28,
- 32, 36, 40, 44, 48, 52, 56, 60,
- -1, -1, -1, -1, -1, -1, -1, -1, -1,
- 64
-};
+static int arm_regmap[]
+ = { 0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48,
+ 52, 56, 60, -1, -1, -1, -1, -1, -1, -1, -1, -1, 64 };
/* Forward declarations needed for get_next_pcs ops. */
static ULONGEST get_next_pcs_read_memory_unsigned_integer (CORE_ADDR memaddr,
- int len,
- int byte_order);
+ int len,
+ int byte_order);
static CORE_ADDR get_next_pcs_addr_bits_remove (struct arm_get_next_pcs *self,
- CORE_ADDR val);
+ CORE_ADDR val);
static CORE_ADDR get_next_pcs_syscall_next_pc (struct arm_get_next_pcs *self);
@@ -284,7 +279,7 @@ arm_fill_wmmxregset (struct regcache *regcache, void *buf)
/* We only have access to wcssf, wcasf, and wcgr0-wcgr3. */
for (int i = 0; i < 6; i++)
collect_register (regcache, arm_num_regs + i + 16,
- (char *) buf + 16 * 8 + i * 4);
+ (char *) buf + 16 * 8 + i * 4);
}
static void
@@ -299,7 +294,7 @@ arm_store_wmmxregset (struct regcache *regcache, const void *buf)
/* We only have access to wcssf, wcasf, and wcgr0-wcgr3. */
for (int i = 0; i < 6; i++)
supply_register (regcache, arm_num_regs + i + 16,
- (char *) buf + 16 * 8 + i * 4);
+ (char *) buf + 16 * 8 + i * 4);
}
static void
@@ -314,11 +309,11 @@ arm_fill_vfpregset (struct regcache *regcache, void *buf)
arm_fp_type fp_type = arm_linux_get_tdesc_fp_type (regcache->tdesc);
if (fp_type == ARM_FP_TYPE_VFPV3)
- num = 32;
+ num = 32;
else if (fp_type == ARM_FP_TYPE_VFPV2)
- num = 16;
+ num = 16;
else
- return;
+ return;
}
arm_fill_vfpregset_num (regcache, buf, num);
@@ -343,11 +338,11 @@ arm_store_vfpregset (struct regcache *regcache, const void *buf)
arm_fp_type fp_type = arm_linux_get_tdesc_fp_type (regcache->tdesc);
if (fp_type == ARM_FP_TYPE_VFPV3)
- num = 32;
+ num = 32;
else if (fp_type == ARM_FP_TYPE_VFPV2)
- num = 16;
+ num = 16;
else
- return;
+ return;
}
arm_store_vfpregset_num (regcache, buf, num);
@@ -364,9 +359,8 @@ get_next_pcs_is_thumb (struct arm_get_next_pcs *self)
BYTE_ORDER is ignored and there to keep compatiblity with GDB's
read_memory_unsigned_integer. */
static ULONGEST
-get_next_pcs_read_memory_unsigned_integer (CORE_ADDR memaddr,
- int len,
- int byte_order)
+get_next_pcs_read_memory_unsigned_integer (CORE_ADDR memaddr, int len,
+ int byte_order)
{
ULONGEST res;
@@ -379,8 +373,8 @@ get_next_pcs_read_memory_unsigned_integer (CORE_ADDR memaddr,
/* Fetch the thread-local storage pointer for libthread_db. */
ps_err_e
-ps_get_thread_area (struct ps_prochandle *ph,
- lwpid_t lwpid, int idx, void **base)
+ps_get_thread_area (struct ps_prochandle *ph, lwpid_t lwpid, int idx,
+ void **base)
{
if (ptrace (PTRACE_GET_THREAD_AREA, lwpid, NULL, base) != 0)
return PS_ERR;
@@ -388,12 +382,11 @@ ps_get_thread_area (struct ps_prochandle *ph,
/* IDX is the bias from the thread pointer to the beginning of the
thread descriptor. It has to be subtracted due to implementation
quirks in libthread_db. */
- *base = (void *) ((char *)*base - idx);
+ *base = (void *) ((char *) *base - idx);
return PS_OK;
}
-
/* Query Hardware Breakpoint information for the target we are attached to
(using PID as ptrace argument) and set up arm_linux_hwbp_cap. */
static void
@@ -404,13 +397,13 @@ arm_linux_init_hwbp_cap (int pid)
if (ptrace (PTRACE_GETHBPREGS, pid, 0, &val) < 0)
return;
- arm_linux_hwbp_cap.arch = (unsigned char)((val >> 24) & 0xff);
+ arm_linux_hwbp_cap.arch = (unsigned char) ((val >> 24) & 0xff);
if (arm_linux_hwbp_cap.arch == 0)
return;
- arm_linux_hwbp_cap.max_wp_length = (unsigned char)((val >> 16) & 0xff);
- arm_linux_hwbp_cap.wp_count = (unsigned char)((val >> 8) & 0xff);
- arm_linux_hwbp_cap.bp_count = (unsigned char)(val & 0xff);
+ arm_linux_hwbp_cap.max_wp_length = (unsigned char) ((val >> 16) & 0xff);
+ arm_linux_hwbp_cap.wp_count = (unsigned char) ((val >> 8) & 0xff);
+ arm_linux_hwbp_cap.bp_count = (unsigned char) (val & 0xff);
if (arm_linux_hwbp_cap.wp_count > MAX_WPTS)
internal_error ("Unsupported number of watchpoints");
@@ -445,12 +438,11 @@ arm_linux_get_hw_watchpoint_max_length (void)
*/
static arm_hwbp_control_t
arm_hwbp_control_initialize (unsigned byte_address_select,
- arm_hwbp_type hwbp_type,
- int enable)
+ arm_hwbp_type hwbp_type, int enable)
{
gdb_assert ((byte_address_select & ~0xffU) == 0);
gdb_assert (hwbp_type != arm_hwbp_break
- || ((byte_address_select & 0xfU) != 0));
+ || ((byte_address_select & 0xfU) != 0));
return (byte_address_select << 5) | (hwbp_type << 3) | (3 << 1) | enable;
}
@@ -479,7 +471,7 @@ arm_hwbp_control_disable (arm_hwbp_control_t control)
/* Are two break-/watch-points equal? */
static int
arm_linux_hw_breakpoint_equal (const struct arm_linux_hw_breakpoint *p1,
- const struct arm_linux_hw_breakpoint *p2)
+ const struct arm_linux_hw_breakpoint *p2)
{
return p1->address == p2->address && p1->control == p2->control;
}
@@ -511,7 +503,7 @@ raw_bkpt_type_to_arm_hwbp_type (enum raw_bkpt_type raw_type)
represents a breakpoint and 1 if type represents a watchpoint. */
static int
arm_linux_hw_point_initialize (enum raw_bkpt_type raw_type, CORE_ADDR addr,
- int len, struct arm_linux_hw_breakpoint *p)
+ int len, struct arm_linux_hw_breakpoint *p)
{
arm_hwbp_type hwbp_type;
unsigned mask;
@@ -522,20 +514,20 @@ arm_linux_hw_point_initialize (enum raw_bkpt_type raw_type, CORE_ADDR addr,
{
/* For breakpoints, the length field encodes the mode. */
switch (len)
- {
- case 2: /* 16-bit Thumb mode breakpoint */
- case 3: /* 32-bit Thumb mode breakpoint */
- mask = 0x3;
- addr &= ~1;
- break;
- case 4: /* 32-bit ARM mode breakpoint */
- mask = 0xf;
- addr &= ~3;
- break;
- default:
- /* Unsupported. */
- return -2;
- }
+ {
+ case 2: /* 16-bit Thumb mode breakpoint */
+ case 3: /* 32-bit Thumb mode breakpoint */
+ mask = 0x3;
+ addr &= ~1;
+ break;
+ case 4: /* 32-bit ARM mode breakpoint */
+ mask = 0xf;
+ addr &= ~3;
+ break;
+ default:
+ /* Unsupported. */
+ return -2;
+ }
}
else
{
@@ -544,17 +536,17 @@ arm_linux_hw_point_initialize (enum raw_bkpt_type raw_type, CORE_ADDR addr,
/* Can not set watchpoints for zero or negative lengths. */
if (len <= 0)
- return -2;
+ return -2;
/* The current ptrace interface can only handle watchpoints that are a
power of 2. */
if ((len & (len - 1)) != 0)
- return -2;
+ return -2;
/* Test that the range [ADDR, ADDR + LEN) fits into the largest address
range covered by a watchpoint. */
aligned_addr = addr & ~(max_wp_length - 1);
if (aligned_addr + max_wp_length < addr + len)
- return -2;
+ return -2;
mask = (1 << len) - 1;
}
@@ -605,8 +597,8 @@ arm_target::supports_z_point_type (char z_type)
/* Insert hardware break-/watchpoint. */
int
-arm_target::low_insert_point (raw_bkpt_type type, CORE_ADDR addr,
- int len, raw_breakpoint *bp)
+arm_target::low_insert_point (raw_bkpt_type type, CORE_ADDR addr, int len,
+ raw_breakpoint *bp)
{
struct process_info *proc = current_process ();
struct arm_linux_hw_breakpoint p, *pts;
@@ -633,15 +625,14 @@ arm_target::low_insert_point (raw_bkpt_type type, CORE_ADDR addr,
for (i = 0; i < count; i++)
if (!arm_hwbp_control_is_enabled (pts[i].control))
{
- pts[i] = p;
+ pts[i] = p;
- /* Only update the threads of the current process. */
- for_each_thread (current_thread->id.pid (), [&] (thread_info *thread)
- {
- update_registers_callback (thread, watch, i);
- });
+ /* Only update the threads of the current process. */
+ for_each_thread (current_thread->id.pid (), [&] (thread_info *thread) {
+ update_registers_callback (thread, watch, i);
+ });
- return 0;
+ return 0;
}
/* We're out of watchpoints. */
@@ -650,8 +641,8 @@ arm_target::low_insert_point (raw_bkpt_type type, CORE_ADDR addr,
/* Remove hardware break-/watchpoint. */
int
-arm_target::low_remove_point (raw_bkpt_type type, CORE_ADDR addr,
- int len, raw_breakpoint *bp)
+arm_target::low_remove_point (raw_bkpt_type type, CORE_ADDR addr, int len,
+ raw_breakpoint *bp)
{
struct process_info *proc = current_process ();
struct arm_linux_hw_breakpoint p, *pts;
@@ -678,15 +669,14 @@ arm_target::low_remove_point (raw_bkpt_type type, CORE_ADDR addr,
for (i = 0; i < count; i++)
if (arm_linux_hw_breakpoint_equal (&p, pts + i))
{
- pts[i].control = arm_hwbp_control_disable (pts[i].control);
+ pts[i].control = arm_hwbp_control_disable (pts[i].control);
- /* Only update the threads of the current process. */
- for_each_thread (current_thread->id.pid (), [&] (thread_info *thread)
- {
- update_registers_callback (thread, watch, i);
- });
+ /* Only update the threads of the current process. */
+ for_each_thread (current_thread->id.pid (), [&] (thread_info *thread) {
+ update_registers_callback (thread, watch, i);
+ });
- return 0;
+ return 0;
}
/* No watchpoint matched. */
@@ -785,10 +775,8 @@ arm_target::low_new_fork (process_info *parent, process_info *child)
int i;
/* These are allocated by linux_add_process. */
- gdb_assert (parent->priv != NULL
- && parent->priv->arch_private != NULL);
- gdb_assert (child->priv != NULL
- && child->priv->arch_private != NULL);
+ gdb_assert (parent->priv != NULL && parent->priv->arch_private != NULL);
+ gdb_assert (child->priv != NULL && child->priv->arch_private != NULL);
parent_proc_info = parent->priv->arch_private;
child_proc_info = child->priv->arch_private;
@@ -834,41 +822,45 @@ arm_target::low_prepare_to_resume (lwp_info *lwp)
for (i = 0; i < arm_linux_get_hw_breakpoint_count (); i++)
if (lwp_info->bpts_changed[i])
{
- errno = 0;
-
- if (arm_hwbp_control_is_enabled (proc_info->bpts[i].control))
- if (ptrace (PTRACE_SETHBPREGS, pid,
- (PTRACE_TYPE_ARG3) ((i << 1) + 1),
- &proc_info->bpts[i].address) < 0)
- perror_with_name ("Unexpected error setting breakpoint address");
-
- if (arm_hwbp_control_is_initialized (proc_info->bpts[i].control))
- if (ptrace (PTRACE_SETHBPREGS, pid,
- (PTRACE_TYPE_ARG3) ((i << 1) + 2),
- &proc_info->bpts[i].control) < 0)
- perror_with_name ("Unexpected error setting breakpoint");
-
- lwp_info->bpts_changed[i] = 0;
+ errno = 0;
+
+ if (arm_hwbp_control_is_enabled (proc_info->bpts[i].control))
+ if (ptrace (PTRACE_SETHBPREGS, pid,
+ (PTRACE_TYPE_ARG3) ((i << 1) + 1),
+ &proc_info->bpts[i].address)
+ < 0)
+ perror_with_name ("Unexpected error setting breakpoint address");
+
+ if (arm_hwbp_control_is_initialized (proc_info->bpts[i].control))
+ if (ptrace (PTRACE_SETHBPREGS, pid,
+ (PTRACE_TYPE_ARG3) ((i << 1) + 2),
+ &proc_info->bpts[i].control)
+ < 0)
+ perror_with_name ("Unexpected error setting breakpoint");
+
+ lwp_info->bpts_changed[i] = 0;
}
for (i = 0; i < arm_linux_get_hw_watchpoint_count (); i++)
if (lwp_info->wpts_changed[i])
{
- errno = 0;
-
- if (arm_hwbp_control_is_enabled (proc_info->wpts[i].control))
- if (ptrace (PTRACE_SETHBPREGS, pid,
- (PTRACE_TYPE_ARG3) -((i << 1) + 1),
- &proc_info->wpts[i].address) < 0)
- perror_with_name ("Unexpected error setting watchpoint address");
-
- if (arm_hwbp_control_is_initialized (proc_info->wpts[i].control))
- if (ptrace (PTRACE_SETHBPREGS, pid,
- (PTRACE_TYPE_ARG3) -((i << 1) + 2),
- &proc_info->wpts[i].control) < 0)
- perror_with_name ("Unexpected error setting watchpoint");
-
- lwp_info->wpts_changed[i] = 0;
+ errno = 0;
+
+ if (arm_hwbp_control_is_enabled (proc_info->wpts[i].control))
+ if (ptrace (PTRACE_SETHBPREGS, pid,
+ (PTRACE_TYPE_ARG3) - ((i << 1) + 1),
+ &proc_info->wpts[i].address)
+ < 0)
+ perror_with_name ("Unexpected error setting watchpoint address");
+
+ if (arm_hwbp_control_is_initialized (proc_info->wpts[i].control))
+ if (ptrace (PTRACE_SETHBPREGS, pid,
+ (PTRACE_TYPE_ARG3) - ((i << 1) + 2),
+ &proc_info->wpts[i].control)
+ < 0)
+ perror_with_name ("Unexpected error setting watchpoint");
+
+ lwp_info->wpts_changed[i] = 0;
}
}
@@ -878,7 +870,7 @@ arm_target::low_prepare_to_resume (lwp_info *lwp)
See arm-linux.h for stack layout details. */
static CORE_ADDR
arm_sigreturn_next_pc (struct regcache *regcache, int svc_number,
- int *is_thumb)
+ int *is_thumb)
{
unsigned long sp;
unsigned long sp_data;
@@ -892,8 +884,10 @@ arm_sigreturn_next_pc (struct regcache *regcache, int svc_number,
collect_register_by_name (regcache, "sp", &sp);
the_target->read_memory (sp, (unsigned char *) &sp_data, 4);
- pc_offset = arm_linux_sigreturn_next_pc_offset
- (sp, sp_data, svc_number, __NR_sigreturn == svc_number ? 1 : 0);
+ pc_offset
+ = arm_linux_sigreturn_next_pc_offset (sp, sp_data, svc_number,
+ __NR_sigreturn == svc_number ? 1
+ : 0);
the_target->read_memory (sp + pc_offset, (unsigned char *) &next_pc, 4);
@@ -928,14 +922,14 @@ get_next_pcs_syscall_next_pc (struct arm_get_next_pcs *self)
target_read_memory (pc, (unsigned char *) &this_instr, 4);
svc_operand = (0x00ffffff & this_instr);
- if (svc_operand) /* OABI. */
- {
- svc_number = svc_operand - 0x900000;
- }
+ if (svc_operand) /* OABI. */
+ {
+ svc_number = svc_operand - 0x900000;
+ }
else /* EABI. */
- {
- collect_register (regcache, 7, &svc_number);
- }
+ {
+ collect_register (regcache, 7, &svc_number);
+ }
next_pc = pc + 4;
}
@@ -971,16 +965,16 @@ arm_read_description (void)
errno = 0;
char *buf = (char *) alloca (ARM_VFP3_REGS_SIZE);
if (ptrace (PTRACE_GETVFPREGS, pid, 0, buf) < 0 && errno == EIO)
- return arm_linux_read_description (ARM_FP_TYPE_NONE);
+ return arm_linux_read_description (ARM_FP_TYPE_NONE);
/* NEON implies either no VFP, or VFPv3-D32. We only support
it with VFP. */
if (arm_hwcap & HWCAP_NEON)
- return aarch32_linux_read_description ();
+ return aarch32_linux_read_description ();
else if ((arm_hwcap & (HWCAP_VFPv3 | HWCAP_VFPv3D16)) == HWCAP_VFPv3)
- return arm_linux_read_description (ARM_FP_TYPE_VFPV3);
+ return arm_linux_read_description (ARM_FP_TYPE_VFPV3);
else
- return arm_linux_read_description (ARM_FP_TYPE_VFPV2);
+ return arm_linux_read_description (ARM_FP_TYPE_VFPV2);
}
/* The default configuration uses legacy FPA registers, probably
@@ -1023,13 +1017,9 @@ arm_target::low_get_next_pcs (regcache *regcache)
{
struct arm_get_next_pcs next_pcs_ctx;
- arm_get_next_pcs_ctor (&next_pcs_ctx,
- &get_next_pcs_ops,
- /* Byte order is ignored assumed as host. */
- 0,
- 0,
- 1,
- regcache);
+ arm_get_next_pcs_ctor (&next_pcs_ctx, &get_next_pcs_ops,
+ /* Byte order is ignored assumed as host. */
+ 0, 0, 1, regcache);
return arm_get_next_pcs (&next_pcs_ctx);
}
@@ -1063,57 +1053,51 @@ arm_target::low_get_syscall_trapinfo (regcache *regcache, int *sysno)
collect_register_by_name (regcache, "pc", &pc);
if (read_memory (pc - 4, (unsigned char *) &insn, 4))
- *sysno = UNKNOWN_SYSCALL;
+ *sysno = UNKNOWN_SYSCALL;
else
- {
- unsigned long svc_operand = (0x00ffffff & insn);
-
- if (svc_operand)
- {
- /* OABI */
- *sysno = svc_operand - 0x900000;
- }
- else
- {
- /* EABI */
- collect_register_by_name (regcache, "r7", sysno);
- }
- }
+ {
+ unsigned long svc_operand = (0x00ffffff & insn);
+
+ if (svc_operand)
+ {
+ /* OABI */
+ *sysno = svc_operand - 0x900000;
+ }
+ else
+ {
+ /* EABI */
+ collect_register_by_name (regcache, "r7", sysno);
+ }
+ }
}
}
/* Register sets without using PTRACE_GETREGSET. */
-static struct regset_info arm_regsets[] = {
- { PTRACE_GETREGS, PTRACE_SETREGS, 0,
- ARM_CORE_REGS_SIZE + ARM_INT_REGISTER_SIZE, GENERAL_REGS,
- arm_fill_gregset, arm_store_gregset },
- { PTRACE_GETWMMXREGS, PTRACE_SETWMMXREGS, 0, IWMMXT_REGS_SIZE, EXTENDED_REGS,
- arm_fill_wmmxregset, arm_store_wmmxregset },
- { PTRACE_GETVFPREGS, PTRACE_SETVFPREGS, 0, ARM_VFP3_REGS_SIZE, EXTENDED_REGS,
- arm_fill_vfpregset, arm_store_vfpregset },
- NULL_REGSET
+static struct regset_info arm_regsets[]
+ = { { PTRACE_GETREGS, PTRACE_SETREGS, 0,
+ ARM_CORE_REGS_SIZE + ARM_INT_REGISTER_SIZE, GENERAL_REGS,
+ arm_fill_gregset, arm_store_gregset },
+ { PTRACE_GETWMMXREGS, PTRACE_SETWMMXREGS, 0, IWMMXT_REGS_SIZE,
+ EXTENDED_REGS, arm_fill_wmmxregset, arm_store_wmmxregset },
+ { PTRACE_GETVFPREGS, PTRACE_SETVFPREGS, 0, ARM_VFP3_REGS_SIZE,
+ EXTENDED_REGS, arm_fill_vfpregset, arm_store_vfpregset },
+ NULL_REGSET };
+
+static struct regsets_info arm_regsets_info = {
+ arm_regsets, /* regsets */
+ 0, /* num_regsets */
+ NULL, /* disabled_regsets */
+};
+
+static struct usrregs_info arm_usrregs_info = {
+ arm_num_regs,
+ arm_regmap,
};
-static struct regsets_info arm_regsets_info =
- {
- arm_regsets, /* regsets */
- 0, /* num_regsets */
- NULL, /* disabled_regsets */
- };
-
-static struct usrregs_info arm_usrregs_info =
- {
- arm_num_regs,
- arm_regmap,
- };
-
-static struct regs_info regs_info_arm =
- {
- NULL, /* regset_bitmap */
- &arm_usrregs_info,
- &arm_regsets_info
- };
+static struct regs_info regs_info_arm
+ = { NULL, /* regset_bitmap */
+ &arm_usrregs_info, &arm_regsets_info };
const regs_info *
arm_target::get_regs_info ()
@@ -1122,7 +1106,7 @@ arm_target::get_regs_info ()
if (have_ptrace_getregset == 1
&& (is_aarch32_linux_description (tdesc)
- || arm_linux_get_tdesc_fp_type (tdesc) == ARM_FP_TYPE_VFPV3))
+ || arm_linux_get_tdesc_fp_type (tdesc) == ARM_FP_TYPE_VFPV3))
return &regs_info_aarch32;
return &regs_info_arm;
diff --git a/gdbserver/linux-arm-tdesc.cc b/gdbserver/linux-arm-tdesc.cc
index 5f84ccb..33e7d46 100644
--- a/gdbserver/linux-arm-tdesc.cc
+++ b/gdbserver/linux-arm-tdesc.cc
@@ -58,7 +58,7 @@ arm_linux_get_tdesc_fp_type (const target_desc *tdesc)
for (int i = ARM_FP_TYPE_NONE; i < ARM_FP_TYPE_INVALID; i++)
{
if (tdesc == tdesc_arm_list[i])
- return (arm_fp_type) i;
+ return (arm_fp_type) i;
}
return ARM_FP_TYPE_INVALID;
diff --git a/gdbserver/linux-arm-tdesc.h b/gdbserver/linux-arm-tdesc.h
index 857eb81..76a7b09 100644
--- a/gdbserver/linux-arm-tdesc.h
+++ b/gdbserver/linux-arm-tdesc.h
@@ -22,7 +22,7 @@
/* Return the Arm target description with fp registers FP_TYPE. */
-const target_desc * arm_linux_read_description (arm_fp_type fp_type);
+const target_desc *arm_linux_read_description (arm_fp_type fp_type);
/* For a target description TDESC, return its fp type. */
diff --git a/gdbserver/linux-csky-low.cc b/gdbserver/linux-csky-low.cc
index 809a4ed..b48e425 100644
--- a/gdbserver/linux-csky-low.cc
+++ b/gdbserver/linux-csky-low.cc
@@ -30,7 +30,6 @@
class csky_target : public linux_process_target
{
public:
-
const regs_info *get_regs_info () override;
const gdb_byte *sw_breakpoint_from_kind (int kind, int *size) override;
@@ -40,7 +39,6 @@ public:
bool supports_hardware_single_step () override;
protected:
-
void low_arch_setup () override;
bool low_cannot_fetch_register (int regno) override;
@@ -60,23 +58,27 @@ static csky_target the_csky_target;
/* Return the ptrace "address" of register REGNO. */
static int csky_regmap[] = {
- 0*4, 1*4, 2*4, 3*4, 4*4, 5*4, 6*4, 7*4,
- 8*4, 9*4, 10*4, 11*4, 12*4, 13*4, 14*4, 15*4,
- 16*4, 17*4, 18*4, 19*4, 20*4, 21*4, 22*4, 23*4,
- 24*4, 25*4, 26*4, 27*4, 28*4, 29*4, 30*4, 31*4,
- -1, -1, -1, -1, 34*4, 35*4, -1, -1,
- 40*4, 42*4, 44*4, 46*4, 48*4, 50*4, 52*4, 54*4, /* fr0 ~ fr15, 64bit */
- 56*4, 58*4, 60*4, 62*4, 64*4, 66*4, 68*4, 70*4,
- 72*4, 76*4, 80*4, 84*4, 88*4, 92*4, 96*4,100*4, /* vr0 ~ vr15, 128bit */
- 104*4,108*4,112*4,116*4,120*4,124*4,128*4,132*4,
- 33*4, /* pc */
- -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1,
- 32*4, -1, -1, -1, -1, -1, -1, -1, /* psr */
- -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1,
- 73*4, 72*4, 74*4, -1, -1, -1, 14*4, /* fcr, fid, fesr, usp */
+ 0 * 4, 1 * 4, 2 * 4, 3 * 4, 4 * 4, 5 * 4, 6 * 4,
+ 7 * 4, 8 * 4, 9 * 4, 10 * 4, 11 * 4, 12 * 4, 13 * 4,
+ 14 * 4, 15 * 4, 16 * 4, 17 * 4, 18 * 4, 19 * 4, 20 * 4,
+ 21 * 4, 22 * 4, 23 * 4, 24 * 4, 25 * 4, 26 * 4, 27 * 4,
+ 28 * 4, 29 * 4, 30 * 4, 31 * 4, -1, -1, -1,
+ -1, 34 * 4, 35 * 4, -1, -1, 40 * 4, 42 * 4,
+ 44 * 4, 46 * 4, 48 * 4, 50 * 4, 52 * 4, 54 * 4, /* fr0 ~ fr15, 64bit */
+ 56 * 4, 58 * 4, 60 * 4, 62 * 4, 64 * 4, 66 * 4, 68 * 4,
+ 70 * 4, 72 * 4, 76 * 4, 80 * 4, 84 * 4, 88 * 4, 92 * 4,
+ 96 * 4, 100 * 4, /* vr0 ~ vr15, 128bit */
+ 104 * 4, 108 * 4, 112 * 4, 116 * 4, 120 * 4, 124 * 4, 128 * 4,
+ 132 * 4, 33 * 4, /* pc */
+ -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, 32 * 4, -1, -1, -1, -1,
+ -1, -1, -1, /* psr */
+ -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, 73 * 4, 72 * 4, 74 * 4, -1,
+ -1, -1, 14 * 4, /* fcr, fid, fesr, usp */
};
/* CSKY software breakpoint instruction code. */
@@ -125,7 +127,6 @@ csky_target::low_set_pc (struct regcache *regcache, CORE_ADDR pc)
supply_register_by_name (regcache, "pc", &new_pc);
}
-
void
csky_target::low_arch_setup ()
{
@@ -143,12 +144,13 @@ csky_target::low_arch_setup ()
/* Fetch the thread-local storage pointer for libthread_db. */
ps_err_e
-ps_get_thread_area (struct ps_prochandle *ph,
- lwpid_t lwpid, int idx, void **base)
+ps_get_thread_area (struct ps_prochandle *ph, lwpid_t lwpid, int idx,
+ void **base)
{
struct pt_regs regset;
- if (ptrace (PTRACE_GETREGSET, lwpid,
- (PTRACE_TYPE_ARG3) (long) NT_PRSTATUS, &regset) != 0)
+ if (ptrace (PTRACE_GETREGSET, lwpid, (PTRACE_TYPE_ARG3) (long) NT_PRSTATUS,
+ &regset)
+ != 0)
return PS_ERR;
*base = (void *) regset.tls;
@@ -156,7 +158,7 @@ ps_get_thread_area (struct ps_prochandle *ph,
/* IDX is the bias from the thread pointer to the beginning of the
thread descriptor. It has to be subtracted due to implementation
quirks in libthread_db. */
- *base = (void *) ((char *)*base - idx);
+ *base = (void *) ((char *) *base - idx);
return PS_OK;
}
@@ -167,9 +169,9 @@ static void
csky_fill_pt_gregset (struct regcache *regcache, void *buf)
{
int i, base;
- struct pt_regs *regset = (struct pt_regs *)buf;
+ struct pt_regs *regset = (struct pt_regs *) buf;
- collect_register_by_name (regcache, "r15", &regset->lr);
+ collect_register_by_name (regcache, "r15", &regset->lr);
collect_register_by_name (regcache, "pc", &regset->pc);
collect_register_by_name (regcache, "psr", &regset->sr);
collect_register_by_name (regcache, "r14", &regset->usp);
@@ -182,11 +184,11 @@ csky_fill_pt_gregset (struct regcache *regcache, void *buf)
base = find_regno (regcache->tdesc, "r4");
for (i = 0; i < 10; i++)
- collect_register (regcache, base + i, &regset->regs[i]);
+ collect_register (regcache, base + i, &regset->regs[i]);
base = find_regno (regcache->tdesc, "r16");
for (i = 0; i < 16; i++)
- collect_register (regcache, base + i, &regset->exregs[i]);
+ collect_register (regcache, base + i, &regset->exregs[i]);
collect_register_by_name (regcache, "hi", &regset->rhi);
collect_register_by_name (regcache, "lo", &regset->rlo);
@@ -198,7 +200,7 @@ csky_store_pt_gregset (struct regcache *regcache, const void *buf)
int i, base;
const struct pt_regs *regset = (const struct pt_regs *) buf;
- supply_register_by_name (regcache, "r15", &regset->lr);
+ supply_register_by_name (regcache, "r15", &regset->lr);
supply_register_by_name (regcache, "pc", &regset->pc);
supply_register_by_name (regcache, "psr", &regset->sr);
supply_register_by_name (regcache, "r14", &regset->usp);
@@ -211,11 +213,11 @@ csky_store_pt_gregset (struct regcache *regcache, const void *buf)
base = find_regno (regcache->tdesc, "r4");
for (i = 0; i < 10; i++)
- supply_register (regcache, base + i, &regset->regs[i]);
+ supply_register (regcache, base + i, &regset->regs[i]);
base = find_regno (regcache->tdesc, "r16");
for (i = 0; i < 16; i++)
- supply_register (regcache, base + i, &regset->exregs[i]);
+ supply_register (regcache, base + i, &regset->exregs[i]);
supply_register_by_name (regcache, "hi", &regset->rhi);
supply_register_by_name (regcache, "lo", &regset->rlo);
@@ -225,7 +227,7 @@ static void
csky_fill_pt_vrregset (struct regcache *regcache, void *buf)
{
int i, base;
- struct user_fp *regset = (struct user_fp *)buf;
+ struct user_fp *regset = (struct user_fp *) buf;
base = find_regno (regcache->tdesc, "vr0");
@@ -236,12 +238,11 @@ csky_fill_pt_vrregset (struct regcache *regcache, void *buf)
collect_register_by_name (regcache, "fid", &regset->fid);
}
-
static void
csky_store_pt_vrregset (struct regcache *regcache, const void *buf)
{
int i, base;
- const struct user_fp *regset = (const struct user_fp *)buf;
+ const struct user_fp *regset = (const struct user_fp *) buf;
base = find_regno (regcache->tdesc, "vr0");
@@ -258,30 +259,24 @@ csky_store_pt_vrregset (struct regcache *regcache, const void *buf)
}
struct regset_info csky_regsets[] = {
- { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_PRSTATUS, sizeof(struct pt_regs),
- GENERAL_REGS, csky_fill_pt_gregset, csky_store_pt_gregset},
+ { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_PRSTATUS, sizeof (struct pt_regs),
+ GENERAL_REGS, csky_fill_pt_gregset, csky_store_pt_gregset },
- { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_FPREGSET, sizeof(struct user_fp),
- FP_REGS, csky_fill_pt_vrregset, csky_store_pt_vrregset},
+ { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_FPREGSET, sizeof (struct user_fp),
+ FP_REGS, csky_fill_pt_vrregset, csky_store_pt_vrregset },
NULL_REGSET
};
-
-static struct regsets_info csky_regsets_info =
-{
+static struct regsets_info csky_regsets_info = {
csky_regsets, /* Regsets */
0, /* Num_regsets */
NULL, /* Disabled_regsets */
};
-
-static struct regs_info csky_regs_info =
-{
- NULL, /* FIXME: what's this */
- NULL, /* PEEKUSER/PORKUSR isn't supported by kernel > 4.x */
- &csky_regsets_info
-};
-
+static struct regs_info csky_regs_info
+ = { NULL, /* FIXME: what's this */
+ NULL, /* PEEKUSER/PORKUSR isn't supported by kernel > 4.x */
+ &csky_regsets_info };
const regs_info *
csky_target::get_regs_info ()
diff --git a/gdbserver/linux-i386-ipa.cc b/gdbserver/linux-i386-ipa.cc
index 21e690e..b441dff 100644
--- a/gdbserver/linux-i386-ipa.cc
+++ b/gdbserver/linux-i386-ipa.cc
@@ -28,23 +28,23 @@
enum i386_gdb_regnum
{
- I386_EAX_REGNUM, /* %eax */
- I386_ECX_REGNUM, /* %ecx */
- I386_EDX_REGNUM, /* %edx */
- I386_EBX_REGNUM, /* %ebx */
- I386_ESP_REGNUM, /* %esp */
- I386_EBP_REGNUM, /* %ebp */
- I386_ESI_REGNUM, /* %esi */
- I386_EDI_REGNUM, /* %edi */
- I386_EIP_REGNUM, /* %eip */
- I386_EFLAGS_REGNUM, /* %eflags */
- I386_CS_REGNUM, /* %cs */
- I386_SS_REGNUM, /* %ss */
- I386_DS_REGNUM, /* %ds */
- I386_ES_REGNUM, /* %es */
- I386_FS_REGNUM, /* %fs */
- I386_GS_REGNUM, /* %gs */
- I386_ST0_REGNUM /* %st(0) */
+ I386_EAX_REGNUM, /* %eax */
+ I386_ECX_REGNUM, /* %ecx */
+ I386_EDX_REGNUM, /* %edx */
+ I386_EBX_REGNUM, /* %ebx */
+ I386_ESP_REGNUM, /* %esp */
+ I386_EBP_REGNUM, /* %ebp */
+ I386_ESI_REGNUM, /* %esi */
+ I386_EDI_REGNUM, /* %edi */
+ I386_EIP_REGNUM, /* %eip */
+ I386_EFLAGS_REGNUM, /* %eflags */
+ I386_CS_REGNUM, /* %cs */
+ I386_SS_REGNUM, /* %ss */
+ I386_DS_REGNUM, /* %ds */
+ I386_ES_REGNUM, /* %es */
+ I386_FS_REGNUM, /* %fs */
+ I386_GS_REGNUM, /* %gs */
+ I386_ST0_REGNUM /* %st(0) */
};
#define i386_num_regs 16
@@ -69,17 +69,15 @@ enum i386_gdb_regnum
/* Mapping between the general-purpose registers in jump tracepoint
format and GDB's register array layout. */
-static const int i386_ft_collect_regmap[] =
-{
- FT_CR_EAX * 4, FT_CR_ECX * 4, FT_CR_EDX * 4, FT_CR_EBX * 4,
- FT_CR_UESP * 4, FT_CR_EBP * 4, FT_CR_ESI * 4, FT_CR_EDI * 4,
- FT_CR_EIP * 4, FT_CR_EFL * 4, FT_CR_CS * 4, FT_CR_SS * 4,
- FT_CR_DS * 4, FT_CR_ES * 4, FT_CR_FS * 4, FT_CR_GS * 4
-};
+static const int i386_ft_collect_regmap[]
+ = { FT_CR_EAX * 4, FT_CR_ECX * 4, FT_CR_EDX * 4, FT_CR_EBX * 4,
+ FT_CR_UESP * 4, FT_CR_EBP * 4, FT_CR_ESI * 4, FT_CR_EDI * 4,
+ FT_CR_EIP * 4, FT_CR_EFL * 4, FT_CR_CS * 4, FT_CR_SS * 4,
+ FT_CR_DS * 4, FT_CR_ES * 4, FT_CR_FS * 4, FT_CR_GS * 4 };
void
supply_fast_tracepoint_registers (struct regcache *regcache,
- const unsigned char *buf)
+ const unsigned char *buf)
{
int i;
@@ -88,9 +86,9 @@ supply_fast_tracepoint_registers (struct regcache *regcache,
int regval;
if (i >= I386_CS_REGNUM && i <= I386_GS_REGNUM)
- regval = *(short *) (((char *) buf) + i386_ft_collect_regmap[i]);
+ regval = *(short *) (((char *) buf) + i386_ft_collect_regmap[i]);
else
- regval = *(int *) (((char *) buf) + i386_ft_collect_regmap[i]);
+ regval = *(int *) (((char *) buf) + i386_ft_collect_regmap[i]);
supply_register (regcache, i, &regval);
}
@@ -120,39 +118,29 @@ get_raw_reg (const unsigned char *raw_regs, int regnum)
contain EIP, but we know what it must have been (the marker
address). */
-#define ST_REGENTRY(REG) \
- { \
- offsetof (struct registers, REG), \
- sizeof (((struct registers *) NULL)->REG) \
+#define ST_REGENTRY(REG) \
+ { \
+ offsetof (struct registers, REG), \
+ sizeof (((struct registers *) NULL)->REG) \
}
static struct
{
int offset;
int size;
-} i386_st_collect_regmap[] =
- {
- ST_REGENTRY(eax),
- ST_REGENTRY(ecx),
- ST_REGENTRY(edx),
- ST_REGENTRY(ebx),
- ST_REGENTRY(esp),
- ST_REGENTRY(ebp),
- ST_REGENTRY(esi),
- ST_REGENTRY(edi),
- { -1, 0 }, /* eip */
- ST_REGENTRY(eflags),
- ST_REGENTRY(cs),
- ST_REGENTRY(ss),
- };
+} i386_st_collect_regmap[] = {
+ ST_REGENTRY (eax), ST_REGENTRY (ecx), ST_REGENTRY (edx),
+ ST_REGENTRY (ebx), ST_REGENTRY (esp), ST_REGENTRY (ebp),
+ ST_REGENTRY (esi), ST_REGENTRY (edi), { -1, 0 }, /* eip */
+ ST_REGENTRY (eflags), ST_REGENTRY (cs), ST_REGENTRY (ss),
+};
#define i386_NUM_ST_COLLECT_GREGS \
(sizeof (i386_st_collect_regmap) / sizeof (i386_st_collect_regmap[0]))
void
supply_static_tracepoint_registers (struct regcache *regcache,
- const unsigned char *buf,
- CORE_ADDR pc)
+ const unsigned char *buf, CORE_ADDR pc)
{
int i;
unsigned int newpc = pc;
@@ -162,32 +150,30 @@ supply_static_tracepoint_registers (struct regcache *regcache,
for (i = 0; i < i386_NUM_ST_COLLECT_GREGS; i++)
if (i386_st_collect_regmap[i].offset != -1)
{
- switch (i386_st_collect_regmap[i].size)
- {
- case 4:
- supply_register (regcache, i,
- ((char *) buf)
- + i386_st_collect_regmap[i].offset);
- break;
- case 2:
- {
- unsigned long reg
- = * (short *) (((char *) buf)
- + i386_st_collect_regmap[i].offset);
- reg &= 0xffff;
- supply_register (regcache, i, &reg);
- }
- break;
- default:
- internal_error ("unhandled register size: %d",
- i386_st_collect_regmap[i].size);
- }
+ switch (i386_st_collect_regmap[i].size)
+ {
+ case 4:
+ supply_register (regcache, i,
+ ((char *) buf)
+ + i386_st_collect_regmap[i].offset);
+ break;
+ case 2:
+ {
+ unsigned long reg = *(
+ short *) (((char *) buf) + i386_st_collect_regmap[i].offset);
+ reg &= 0xffff;
+ supply_register (regcache, i, &reg);
+ }
+ break;
+ default:
+ internal_error ("unhandled register size: %d",
+ i386_st_collect_regmap[i].size);
+ }
}
}
#endif /* HAVE_UST */
-
/* This is only needed because reg-i386-linux-lib.o references it. We
may use it proper at some point. */
const char *gdbserver_xmltarget;
@@ -208,39 +194,38 @@ initialize_fast_tracepoint_trampoline_buffer (void)
FILE *f = fopen ("/proc/sys/vm/mmap_min_addr", "r");
if (!f)
- {
+ {
snprintf (buf, sizeof (buf), "mmap_min_addr open failed: %s",
- safe_strerror (errno));
+ safe_strerror (errno));
set_trampoline_buffer_space (0, 0, buf);
return;
}
if (fgets (buf, IPA_BUFSIZ, f))
sscanf (buf, "%llu", &mmap_min_addr);
-
+
fclose (f);
-
+
buffer_size = buffer_end - mmap_min_addr;
if (buffer_size >= min_buffer_size)
{
if (mmap ((void *) (uintptr_t) mmap_min_addr, buffer_size,
- PROT_READ | PROT_EXEC | PROT_WRITE,
- MAP_FIXED | MAP_PRIVATE | MAP_ANONYMOUS,
- -1, 0)
- != MAP_FAILED)
- set_trampoline_buffer_space (mmap_min_addr, buffer_end, NULL);
+ PROT_READ | PROT_EXEC | PROT_WRITE,
+ MAP_FIXED | MAP_PRIVATE | MAP_ANONYMOUS, -1, 0)
+ != MAP_FAILED)
+ set_trampoline_buffer_space (mmap_min_addr, buffer_end, NULL);
else
- {
- snprintf (buf, IPA_BUFSIZ, "low-64K-buffer mmap() failed: %s",
- safe_strerror (errno));
- set_trampoline_buffer_space (0, 0, buf);
- }
+ {
+ snprintf (buf, IPA_BUFSIZ, "low-64K-buffer mmap() failed: %s",
+ safe_strerror (errno));
+ set_trampoline_buffer_space (0, 0, buf);
+ }
}
else
{
snprintf (buf, IPA_BUFSIZ, "mmap_min_addr is %d, must be %d or less",
- (int) mmap_min_addr, (int) buffer_end - min_buffer_size);
+ (int) mmap_min_addr, (int) buffer_end - min_buffer_size);
set_trampoline_buffer_space (0, 0, buf);
}
}
@@ -276,7 +261,7 @@ void *
alloc_jump_pad_buffer (size_t size)
{
void *res = mmap (NULL, size, PROT_READ | PROT_WRITE | PROT_EXEC,
- MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+ MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
if (res == MAP_FAILED)
return NULL;
diff --git a/gdbserver/linux-ia64-low.cc b/gdbserver/linux-ia64-low.cc
index 2586e57..e9a8e6c 100644
--- a/gdbserver/linux-ia64-low.cc
+++ b/gdbserver/linux-ia64-low.cc
@@ -28,13 +28,11 @@
class ia64_target : public linux_process_target
{
public:
-
const regs_info *get_regs_info () override;
const gdb_byte *sw_breakpoint_from_kind (int kind, int *size) override;
protected:
-
void low_arch_setup () override;
bool low_cannot_fetch_register (int regno) override;
@@ -54,14 +52,14 @@ const gdb_byte *
ia64_target::sw_breakpoint_from_kind (int kind, int *size)
{
gdb_assert_not_reached ("target op sw_breakpoint_from_kind is not "
- "implemented by this target");
+ "implemented by this target");
}
bool
ia64_target::low_breakpoint_at (CORE_ADDR pc)
{
gdb_assert_not_reached ("linux target op low_breakpoint_at is not "
- "implemented by this target");
+ "implemented by this target");
}
/* Defined in auto-generated file reg-ia64.c. */
@@ -72,240 +70,479 @@ extern const struct target_desc *tdesc_ia64;
#include <asm/ptrace_offsets.h>
-static int ia64_regmap[] =
- {
- /* general registers */
- -1, /* gr0 not available; i.e, it's always zero */
- PT_R1,
- PT_R2,
- PT_R3,
- PT_R4,
- PT_R5,
- PT_R6,
- PT_R7,
- PT_R8,
- PT_R9,
- PT_R10,
- PT_R11,
- PT_R12,
- PT_R13,
- PT_R14,
- PT_R15,
- PT_R16,
- PT_R17,
- PT_R18,
- PT_R19,
- PT_R20,
- PT_R21,
- PT_R22,
- PT_R23,
- PT_R24,
- PT_R25,
- PT_R26,
- PT_R27,
- PT_R28,
- PT_R29,
- PT_R30,
- PT_R31,
- /* gr32 through gr127 not directly available via the ptrace interface */
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- /* Floating point registers */
- -1, -1, /* f0 and f1 not available (f0 is +0.0 and f1 is +1.0) */
- PT_F2,
- PT_F3,
- PT_F4,
- PT_F5,
- PT_F6,
- PT_F7,
- PT_F8,
- PT_F9,
- PT_F10,
- PT_F11,
- PT_F12,
- PT_F13,
- PT_F14,
- PT_F15,
- PT_F16,
- PT_F17,
- PT_F18,
- PT_F19,
- PT_F20,
- PT_F21,
- PT_F22,
- PT_F23,
- PT_F24,
- PT_F25,
- PT_F26,
- PT_F27,
- PT_F28,
- PT_F29,
- PT_F30,
- PT_F31,
- PT_F32,
- PT_F33,
- PT_F34,
- PT_F35,
- PT_F36,
- PT_F37,
- PT_F38,
- PT_F39,
- PT_F40,
- PT_F41,
- PT_F42,
- PT_F43,
- PT_F44,
- PT_F45,
- PT_F46,
- PT_F47,
- PT_F48,
- PT_F49,
- PT_F50,
- PT_F51,
- PT_F52,
- PT_F53,
- PT_F54,
- PT_F55,
- PT_F56,
- PT_F57,
- PT_F58,
- PT_F59,
- PT_F60,
- PT_F61,
- PT_F62,
- PT_F63,
- PT_F64,
- PT_F65,
- PT_F66,
- PT_F67,
- PT_F68,
- PT_F69,
- PT_F70,
- PT_F71,
- PT_F72,
- PT_F73,
- PT_F74,
- PT_F75,
- PT_F76,
- PT_F77,
- PT_F78,
- PT_F79,
- PT_F80,
- PT_F81,
- PT_F82,
- PT_F83,
- PT_F84,
- PT_F85,
- PT_F86,
- PT_F87,
- PT_F88,
- PT_F89,
- PT_F90,
- PT_F91,
- PT_F92,
- PT_F93,
- PT_F94,
- PT_F95,
- PT_F96,
- PT_F97,
- PT_F98,
- PT_F99,
- PT_F100,
- PT_F101,
- PT_F102,
- PT_F103,
- PT_F104,
- PT_F105,
- PT_F106,
- PT_F107,
- PT_F108,
- PT_F109,
- PT_F110,
- PT_F111,
- PT_F112,
- PT_F113,
- PT_F114,
- PT_F115,
- PT_F116,
- PT_F117,
- PT_F118,
- PT_F119,
- PT_F120,
- PT_F121,
- PT_F122,
- PT_F123,
- PT_F124,
- PT_F125,
- PT_F126,
- PT_F127,
- /* predicate registers - we don't fetch these individually */
- -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1,
- /* branch registers */
- PT_B0,
- PT_B1,
- PT_B2,
- PT_B3,
- PT_B4,
- PT_B5,
- PT_B6,
- PT_B7,
- /* virtual frame pointer and virtual return address pointer */
- -1, -1,
- /* other registers */
- PT_PR,
- PT_CR_IIP, /* ip */
- PT_CR_IPSR, /* psr */
- PT_CFM, /* cfm */
- /* kernel registers not visible via ptrace interface (?) */
- -1, -1, -1, -1, -1, -1, -1, -1,
- /* hole */
- -1, -1, -1, -1, -1, -1, -1, -1,
- PT_AR_RSC,
- PT_AR_BSP,
- PT_AR_BSPSTORE,
- PT_AR_RNAT,
- -1,
- -1, /* Not available: FCR, IA32 floating control register */
- -1, -1,
- -1, /* Not available: EFLAG */
- -1, /* Not available: CSD */
- -1, /* Not available: SSD */
- -1, /* Not available: CFLG */
- -1, /* Not available: FSR */
- -1, /* Not available: FIR */
- -1, /* Not available: FDR */
- -1,
- PT_AR_CCV,
- -1, -1, -1,
- PT_AR_UNAT,
- -1, -1, -1,
- PT_AR_FPSR,
- -1, -1, -1,
- -1, /* Not available: ITC */
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1,
- PT_AR_PFS,
- PT_AR_LC,
- PT_AR_EC,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1,
- };
+static int ia64_regmap[] = {
+ /* general registers */
+ -1, /* gr0 not available; i.e, it's always zero */
+ PT_R1,
+ PT_R2,
+ PT_R3,
+ PT_R4,
+ PT_R5,
+ PT_R6,
+ PT_R7,
+ PT_R8,
+ PT_R9,
+ PT_R10,
+ PT_R11,
+ PT_R12,
+ PT_R13,
+ PT_R14,
+ PT_R15,
+ PT_R16,
+ PT_R17,
+ PT_R18,
+ PT_R19,
+ PT_R20,
+ PT_R21,
+ PT_R22,
+ PT_R23,
+ PT_R24,
+ PT_R25,
+ PT_R26,
+ PT_R27,
+ PT_R28,
+ PT_R29,
+ PT_R30,
+ PT_R31,
+ /* gr32 through gr127 not directly available via the ptrace interface */
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ /* Floating point registers */
+ -1,
+ -1, /* f0 and f1 not available (f0 is +0.0 and f1 is +1.0) */
+ PT_F2,
+ PT_F3,
+ PT_F4,
+ PT_F5,
+ PT_F6,
+ PT_F7,
+ PT_F8,
+ PT_F9,
+ PT_F10,
+ PT_F11,
+ PT_F12,
+ PT_F13,
+ PT_F14,
+ PT_F15,
+ PT_F16,
+ PT_F17,
+ PT_F18,
+ PT_F19,
+ PT_F20,
+ PT_F21,
+ PT_F22,
+ PT_F23,
+ PT_F24,
+ PT_F25,
+ PT_F26,
+ PT_F27,
+ PT_F28,
+ PT_F29,
+ PT_F30,
+ PT_F31,
+ PT_F32,
+ PT_F33,
+ PT_F34,
+ PT_F35,
+ PT_F36,
+ PT_F37,
+ PT_F38,
+ PT_F39,
+ PT_F40,
+ PT_F41,
+ PT_F42,
+ PT_F43,
+ PT_F44,
+ PT_F45,
+ PT_F46,
+ PT_F47,
+ PT_F48,
+ PT_F49,
+ PT_F50,
+ PT_F51,
+ PT_F52,
+ PT_F53,
+ PT_F54,
+ PT_F55,
+ PT_F56,
+ PT_F57,
+ PT_F58,
+ PT_F59,
+ PT_F60,
+ PT_F61,
+ PT_F62,
+ PT_F63,
+ PT_F64,
+ PT_F65,
+ PT_F66,
+ PT_F67,
+ PT_F68,
+ PT_F69,
+ PT_F70,
+ PT_F71,
+ PT_F72,
+ PT_F73,
+ PT_F74,
+ PT_F75,
+ PT_F76,
+ PT_F77,
+ PT_F78,
+ PT_F79,
+ PT_F80,
+ PT_F81,
+ PT_F82,
+ PT_F83,
+ PT_F84,
+ PT_F85,
+ PT_F86,
+ PT_F87,
+ PT_F88,
+ PT_F89,
+ PT_F90,
+ PT_F91,
+ PT_F92,
+ PT_F93,
+ PT_F94,
+ PT_F95,
+ PT_F96,
+ PT_F97,
+ PT_F98,
+ PT_F99,
+ PT_F100,
+ PT_F101,
+ PT_F102,
+ PT_F103,
+ PT_F104,
+ PT_F105,
+ PT_F106,
+ PT_F107,
+ PT_F108,
+ PT_F109,
+ PT_F110,
+ PT_F111,
+ PT_F112,
+ PT_F113,
+ PT_F114,
+ PT_F115,
+ PT_F116,
+ PT_F117,
+ PT_F118,
+ PT_F119,
+ PT_F120,
+ PT_F121,
+ PT_F122,
+ PT_F123,
+ PT_F124,
+ PT_F125,
+ PT_F126,
+ PT_F127,
+ /* predicate registers - we don't fetch these individually */
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ /* branch registers */
+ PT_B0,
+ PT_B1,
+ PT_B2,
+ PT_B3,
+ PT_B4,
+ PT_B5,
+ PT_B6,
+ PT_B7,
+ /* virtual frame pointer and virtual return address pointer */
+ -1,
+ -1,
+ /* other registers */
+ PT_PR,
+ PT_CR_IIP, /* ip */
+ PT_CR_IPSR, /* psr */
+ PT_CFM, /* cfm */
+ /* kernel registers not visible via ptrace interface (?) */
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ /* hole */
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ PT_AR_RSC,
+ PT_AR_BSP,
+ PT_AR_BSPSTORE,
+ PT_AR_RNAT,
+ -1,
+ -1, /* Not available: FCR, IA32 floating control register */
+ -1,
+ -1,
+ -1, /* Not available: EFLAG */
+ -1, /* Not available: CSD */
+ -1, /* Not available: SSD */
+ -1, /* Not available: CFLG */
+ -1, /* Not available: FSR */
+ -1, /* Not available: FIR */
+ -1, /* Not available: FDR */
+ -1,
+ PT_AR_CCV,
+ -1,
+ -1,
+ -1,
+ PT_AR_UNAT,
+ -1,
+ -1,
+ -1,
+ PT_AR_FPSR,
+ -1,
+ -1,
+ -1,
+ -1, /* Not available: ITC */
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ PT_AR_PFS,
+ PT_AR_LC,
+ PT_AR_EC,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+};
bool
ia64_target::low_cannot_store_register (int regno)
@@ -320,9 +557,9 @@ ia64_target::low_cannot_fetch_register (int regno)
}
/* GDB register numbers. */
-#define IA64_GR0_REGNUM 0
-#define IA64_FR0_REGNUM 128
-#define IA64_FR1_REGNUM 129
+#define IA64_GR0_REGNUM 0
+#define IA64_FR0_REGNUM 128
+#define IA64_FR1_REGNUM 129
bool
ia64_target::low_fetch_register (regcache *regcache, int regnum)
@@ -350,8 +587,8 @@ ia64_target::low_fetch_register (regcache *regcache, int regnum)
/* fr1 cannot be fetched but is always one (1.0). */
if (regnum == IA64_FR1_REGNUM)
{
- const gdb_byte f_one[16] =
- { 0, 0, 0, 0, 0, 0, 0, 0x80, 0xff, 0xff, 0, 0, 0, 0, 0, 0 };
+ const gdb_byte f_one[16]
+ = { 0, 0, 0, 0, 0, 0, 0, 0x80, 0xff, 0xff, 0, 0, 0, 0, 0, 0 };
gdb_assert (sizeof (f_one) == register_size (regcache->tdesc, regnum));
supply_register (regcache, regnum, f_one);
@@ -361,17 +598,13 @@ ia64_target::low_fetch_register (regcache *regcache, int regnum)
return false;
}
-static struct usrregs_info ia64_usrregs_info =
- {
- ia64_num_regs,
- ia64_regmap,
- };
-
-static struct regs_info myregs_info =
- {
- NULL, /* regset_bitmap */
- &ia64_usrregs_info
- };
+static struct usrregs_info ia64_usrregs_info = {
+ ia64_num_regs,
+ ia64_regmap,
+};
+
+static struct regs_info myregs_info = { NULL, /* regset_bitmap */
+ &ia64_usrregs_info };
const regs_info *
ia64_target::get_regs_info ()
diff --git a/gdbserver/linux-loongarch-low.cc b/gdbserver/linux-loongarch-low.cc
index ead2e76..c2c59bc 100644
--- a/gdbserver/linux-loongarch-low.cc
+++ b/gdbserver/linux-loongarch-low.cc
@@ -28,7 +28,6 @@
class loongarch_target : public linux_process_target
{
public:
-
const regs_info *get_regs_info () override;
int breakpoint_kind_from_pc (CORE_ADDR *pcptr) override;
@@ -36,7 +35,6 @@ public:
const gdb_byte *sw_breakpoint_from_kind (int kind, int *size) override;
protected:
-
void low_arch_setup () override;
bool low_cannot_fetch_register (int regno) override;
@@ -62,14 +60,14 @@ bool
loongarch_target::low_cannot_fetch_register (int regno)
{
gdb_assert_not_reached ("linux target op low_cannot_fetch_register "
- "is not implemented by the target");
+ "is not implemented by the target");
}
bool
loongarch_target::low_cannot_store_register (int regno)
{
gdb_assert_not_reached ("linux target op low_cannot_store_register "
- "is not implemented by the target");
+ "is not implemented by the target");
}
/* Implementation of linux target ops method "low_arch_setup". */
@@ -99,9 +97,12 @@ loongarch_fill_gregset (struct regcache *regcache, void *buf)
for (i = 1; i < 32; i++)
collect_register (regcache, i, *regset + i);
- collect_register (regcache, LOONGARCH_ORIG_A0_REGNUM, *regset + LOONGARCH_ORIG_A0_REGNUM);
- collect_register (regcache, LOONGARCH_PC_REGNUM, *regset + LOONGARCH_PC_REGNUM);
- collect_register (regcache, LOONGARCH_BADV_REGNUM, *regset + LOONGARCH_BADV_REGNUM);
+ collect_register (regcache, LOONGARCH_ORIG_A0_REGNUM,
+ *regset + LOONGARCH_ORIG_A0_REGNUM);
+ collect_register (regcache, LOONGARCH_PC_REGNUM,
+ *regset + LOONGARCH_PC_REGNUM);
+ collect_register (regcache, LOONGARCH_BADV_REGNUM,
+ *regset + LOONGARCH_BADV_REGNUM);
}
/* Supply GPRs from BUF into REGCACHE. */
@@ -115,9 +116,12 @@ loongarch_store_gregset (struct regcache *regcache, const void *buf)
supply_register_zeroed (regcache, 0);
for (i = 1; i < 32; i++)
supply_register (regcache, i, *regset + i);
- supply_register (regcache, LOONGARCH_ORIG_A0_REGNUM, *regset + LOONGARCH_ORIG_A0_REGNUM);
- supply_register (regcache, LOONGARCH_PC_REGNUM, *regset + LOONGARCH_PC_REGNUM);
- supply_register (regcache, LOONGARCH_BADV_REGNUM, *regset + LOONGARCH_BADV_REGNUM);
+ supply_register (regcache, LOONGARCH_ORIG_A0_REGNUM,
+ *regset + LOONGARCH_ORIG_A0_REGNUM);
+ supply_register (regcache, LOONGARCH_PC_REGNUM,
+ *regset + LOONGARCH_PC_REGNUM);
+ supply_register (regcache, LOONGARCH_BADV_REGNUM,
+ *regset + LOONGARCH_BADV_REGNUM);
}
/* Collect FPRs from REGCACHE into BUF. */
@@ -131,19 +135,19 @@ loongarch_fill_fpregset (struct regcache *regcache, void *buf)
for (int i = 0; i < LOONGARCH_LINUX_NUM_FPREGSET; i++)
{
- regbuf = (gdb_byte *)buf + fprsize * i;
+ regbuf = (gdb_byte *) buf + fprsize * i;
collect_register (regcache, LOONGARCH_FIRST_FP_REGNUM + i, regbuf);
}
for (int i = 0; i < LOONGARCH_LINUX_NUM_FCC; i++)
{
- regbuf = (gdb_byte *)buf + fprsize * LOONGARCH_LINUX_NUM_FPREGSET +
- fccsize * i;
+ regbuf = (gdb_byte *) buf + fprsize * LOONGARCH_LINUX_NUM_FPREGSET
+ + fccsize * i;
collect_register (regcache, LOONGARCH_FIRST_FCC_REGNUM + i, regbuf);
}
- regbuf = (gdb_byte *)buf + fprsize * LOONGARCH_LINUX_NUM_FPREGSET +
- fccsize * LOONGARCH_LINUX_NUM_FCC;
+ regbuf = (gdb_byte *) buf + fprsize * LOONGARCH_LINUX_NUM_FPREGSET
+ + fccsize * LOONGARCH_LINUX_NUM_FCC;
collect_register (regcache, LOONGARCH_FCSR_REGNUM, regbuf);
}
@@ -158,19 +162,19 @@ loongarch_store_fpregset (struct regcache *regcache, const void *buf)
for (int i = 0; i < LOONGARCH_LINUX_NUM_FPREGSET; i++)
{
- regbuf = (const gdb_byte *)buf + fprsize * i;
+ regbuf = (const gdb_byte *) buf + fprsize * i;
supply_register (regcache, LOONGARCH_FIRST_FP_REGNUM + i, regbuf);
}
for (int i = 0; i < LOONGARCH_LINUX_NUM_FCC; i++)
{
- regbuf = (const gdb_byte *)buf + fprsize * LOONGARCH_LINUX_NUM_FPREGSET +
- fccsize * i;
+ regbuf = (const gdb_byte *) buf + fprsize * LOONGARCH_LINUX_NUM_FPREGSET
+ + fccsize * i;
supply_register (regcache, LOONGARCH_FIRST_FCC_REGNUM + i, regbuf);
}
- regbuf = (const gdb_byte *)buf + fprsize * LOONGARCH_LINUX_NUM_FPREGSET +
- fccsize * LOONGARCH_LINUX_NUM_FCC;
+ regbuf = (const gdb_byte *) buf + fprsize * LOONGARCH_LINUX_NUM_FPREGSET
+ + fccsize * LOONGARCH_LINUX_NUM_FCC;
supply_register (regcache, LOONGARCH_FCSR_REGNUM, regbuf);
}
@@ -184,20 +188,18 @@ static struct regset_info loongarch_regsets[] = {
};
/* LoongArch/Linux regset information. */
-static struct regsets_info loongarch_regsets_info =
- {
- loongarch_regsets, /* regsets */
- 0, /* num_regsets */
- NULL, /* disabled_regsets */
- };
+static struct regsets_info loongarch_regsets_info = {
+ loongarch_regsets, /* regsets */
+ 0, /* num_regsets */
+ NULL, /* disabled_regsets */
+};
/* Definition of linux_target_ops data member "regs_info". */
-static struct regs_info loongarch_regs =
- {
- NULL, /* regset_bitmap */
- NULL, /* usrregs */
- &loongarch_regsets_info,
- };
+static struct regs_info loongarch_regs = {
+ NULL, /* regset_bitmap */
+ NULL, /* usrregs */
+ &loongarch_regsets_info,
+};
/* Implementation of linux target ops method "get_regs_info". */
@@ -251,7 +253,7 @@ loongarch_target::low_set_pc (regcache *regcache, CORE_ADDR newpc)
/* LoongArch BRK software debug mode instruction.
This instruction needs to match gdb/loongarch-tdep.c
(loongarch_default_breakpoint). */
-static const gdb_byte loongarch_breakpoint[] = {0x05, 0x00, 0x2a, 0x00};
+static const gdb_byte loongarch_breakpoint[] = { 0x05, 0x00, 0x2a, 0x00 };
/* Implementation of target ops method "breakpoint_kind_from_pc". */
diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc
index 5cd2282..55788bb 100644
--- a/gdbserver/linux-low.cc
+++ b/gdbserver/linux-low.cc
@@ -73,47 +73,43 @@
/* Some targets did not define these ptrace constants from the start,
so gdbserver defines them locally here. In the future, these may
be removed after they are added to asm/ptrace.h. */
-#if !(defined(PT_TEXT_ADDR) \
- || defined(PT_DATA_ADDR) \
+#if !(defined(PT_TEXT_ADDR) || defined(PT_DATA_ADDR) \
|| defined(PT_TEXT_END_ADDR))
#if defined(__mcoldfire__)
/* These are still undefined in 3.10 kernels. */
-#define PT_TEXT_ADDR 49*4
-#define PT_DATA_ADDR 50*4
-#define PT_TEXT_END_ADDR 51*4
+#define PT_TEXT_ADDR 49 * 4
+#define PT_DATA_ADDR 50 * 4
+#define PT_TEXT_END_ADDR 51 * 4
/* These are still undefined in 3.10 kernels. */
#elif defined(__TMS320C6X__)
-#define PT_TEXT_ADDR (0x10000*4)
-#define PT_DATA_ADDR (0x10004*4)
-#define PT_TEXT_END_ADDR (0x10008*4)
+#define PT_TEXT_ADDR (0x10000 * 4)
+#define PT_DATA_ADDR (0x10004 * 4)
+#define PT_TEXT_END_ADDR (0x10008 * 4)
#endif
#endif
-#if (defined(__UCLIBC__) \
- && defined(HAS_NOMMU) \
- && defined(PT_TEXT_ADDR) \
- && defined(PT_DATA_ADDR) \
- && defined(PT_TEXT_END_ADDR))
+#if (defined(__UCLIBC__) && defined(HAS_NOMMU) && defined(PT_TEXT_ADDR) \
+ && defined(PT_DATA_ADDR) && defined(PT_TEXT_END_ADDR))
#define SUPPORTS_READ_OFFSETS
#endif
#ifdef HAVE_LINUX_BTRACE
-# include "nat/linux-btrace.h"
-# include "gdbsupport/btrace-common.h"
+#include "nat/linux-btrace.h"
+#include "gdbsupport/btrace-common.h"
#endif
#ifndef HAVE_ELF32_AUXV_T
/* Copied from glibc's elf.h. */
typedef struct
{
- uint32_t a_type; /* Entry type */
+ uint32_t a_type; /* Entry type */
union
- {
- uint32_t a_val; /* Integer value */
- /* We use to have pointer elements added here. We cannot do that,
+ {
+ uint32_t a_val; /* Integer value */
+ /* We use to have pointer elements added here. We cannot do that,
though, since it does not work when using 32-bit definitions
on 64-bit platforms and vice versa. */
- } a_un;
+ } a_un;
} Elf32_auxv_t;
#endif
@@ -121,14 +117,14 @@ typedef struct
/* Copied from glibc's elf.h. */
typedef struct
{
- uint64_t a_type; /* Entry type */
+ uint64_t a_type; /* Entry type */
union
- {
- uint64_t a_val; /* Integer value */
- /* We use to have pointer elements added here. We cannot do that,
+ {
+ uint64_t a_val; /* Integer value */
+ /* We use to have pointer elements added here. We cannot do that,
though, since it does not work when using 32-bit definitions
on 64-bit platforms and vice versa. */
- } a_un;
+ } a_un;
} Elf64_auxv_t;
#endif
@@ -157,8 +153,7 @@ ptid_of_lwp (struct lwp_info *lwp)
/* See nat/linux-nat.h. */
void
-lwp_set_arch_private_info (struct lwp_info *lwp,
- struct arch_lwp_info *info)
+lwp_set_arch_private_info (struct lwp_info *lwp, struct arch_lwp_info *info)
{
lwp->arch_private = info;
}
@@ -234,27 +229,27 @@ pull_pid_from_list (struct simple_pid_list **listp, int pid, int *statusp)
for (p = listp; *p != NULL; p = &(*p)->next)
if ((*p)->pid == pid)
{
- struct simple_pid_list *next = (*p)->next;
+ struct simple_pid_list *next = (*p)->next;
- *statusp = (*p)->status;
- xfree (*p);
- *p = next;
- return 1;
+ *statusp = (*p)->status;
+ xfree (*p);
+ *p = next;
+ return 1;
}
return 0;
}
enum stopping_threads_kind
- {
- /* Not stopping threads presently. */
- NOT_STOPPING_THREADS,
+{
+ /* Not stopping threads presently. */
+ NOT_STOPPING_THREADS,
- /* Stopping threads. */
- STOPPING_THREADS,
+ /* Stopping threads. */
+ STOPPING_THREADS,
- /* Stopping and suspending threads. */
- STOPPING_AND_SUSPENDING_THREADS
- };
+ /* Stopping and suspending threads. */
+ STOPPING_AND_SUSPENDING_THREADS
+};
/* This is set while stop_all_lwps is in effect. */
static stopping_threads_kind stopping_threads = NOT_STOPPING_THREADS;
@@ -270,7 +265,8 @@ static void unsuspend_all_lwps (struct lwp_info *except);
static void mark_lwp_dead (struct lwp_info *lwp, int wstat);
static int lwp_is_marked_dead (struct lwp_info *lwp);
static int kill_lwp (unsigned long lwpid, int signo);
-static void enqueue_pending_signal (struct lwp_info *lwp, int signal, siginfo_t *info);
+static void enqueue_pending_signal (struct lwp_info *lwp, int signal,
+ siginfo_t *info);
static int linux_low_ptrace_options (int attached);
static int check_ptrace_stopped_lwp_gone (struct lwp_info *lp);
@@ -300,7 +296,7 @@ std::vector<CORE_ADDR>
linux_process_target::low_get_next_pcs (regcache *regcache)
{
gdb_assert_not_reached ("linux target op low_get_next_pcs is not "
- "implemented");
+ "implemented");
}
int
@@ -339,7 +335,6 @@ elf_64_header_p (const Elf64_Ehdr *header, unsigned int *machine)
{
*machine = header->e_machine;
return header->e_ident[EI_CLASS] == ELFCLASS64;
-
}
*machine = EM_NONE;
return -1;
@@ -431,7 +426,6 @@ linux_process_target::add_linux_process_no_mem_file (int pid, int attached)
return proc;
}
-
process_info *
linux_process_target::add_linux_process (int pid, int attached)
{
@@ -485,7 +479,7 @@ linux_process_target::arch_setup_thread (thread_info *thread)
int
linux_process_target::handle_extended_wait (lwp_info **orig_event_lwp,
- int wstat)
+ int wstat)
{
client_state &cs = get_client_state ();
struct lwp_info *event_lwp = *orig_event_lwp;
@@ -509,129 +503,126 @@ linux_process_target::handle_extended_wait (lwp_info **orig_event_lwp,
/* Get the pid of the new lwp. */
ptrace (PTRACE_GETEVENTMSG, lwpid_of (event_thr), (PTRACE_TYPE_ARG3) 0,
- &new_pid);
+ &new_pid);
/* If we haven't already seen the new PID stop, wait for it now. */
if (!pull_pid_from_list (&stopped_pids, new_pid, &status))
- {
- /* The new child has a pending SIGSTOP. We can't affect it until it
+ {
+ /* The new child has a pending SIGSTOP. We can't affect it until it
hits the SIGSTOP, but we're already attached. */
- ret = my_waitpid (new_pid, &status, __WALL);
+ ret = my_waitpid (new_pid, &status, __WALL);
- if (ret == -1)
- perror_with_name ("waiting for new child");
- else if (ret != new_pid)
- warning ("wait returned unexpected PID %d", ret);
- else if (!WIFSTOPPED (status))
- warning ("wait returned unexpected status 0x%x", status);
- }
+ if (ret == -1)
+ perror_with_name ("waiting for new child");
+ else if (ret != new_pid)
+ warning ("wait returned unexpected PID %d", ret);
+ else if (!WIFSTOPPED (status))
+ warning ("wait returned unexpected status 0x%x", status);
+ }
if (event == PTRACE_EVENT_FORK || event == PTRACE_EVENT_VFORK)
- {
- struct process_info *parent_proc;
- struct process_info *child_proc;
- struct lwp_info *child_lwp;
- struct thread_info *child_thr;
+ {
+ struct process_info *parent_proc;
+ struct process_info *child_proc;
+ struct lwp_info *child_lwp;
+ struct thread_info *child_thr;
- ptid = ptid_t (new_pid, new_pid);
+ ptid = ptid_t (new_pid, new_pid);
- threads_debug_printf ("Got fork event from LWP %ld, "
- "new child is %d",
- ptid_of (event_thr).lwp (),
- ptid.pid ());
+ threads_debug_printf ("Got fork event from LWP %ld, "
+ "new child is %d",
+ ptid_of (event_thr).lwp (), ptid.pid ());
- /* Add the new process to the tables and clone the breakpoint
+ /* Add the new process to the tables and clone the breakpoint
lists of the parent. We need to do this even if the new process
will be detached, since we will need the process object and the
breakpoints to remove any breakpoints from memory when we
detach, and the client side will access registers. */
- child_proc = add_linux_process (new_pid, 0);
- gdb_assert (child_proc != NULL);
- child_lwp = add_lwp (ptid);
- gdb_assert (child_lwp != NULL);
- child_lwp->stopped = 1;
- child_lwp->must_set_ptrace_flags = 1;
- child_lwp->status_pending_p = 0;
- child_thr = get_lwp_thread (child_lwp);
- child_thr->last_resume_kind = resume_stop;
- child_thr->last_status.set_stopped (GDB_SIGNAL_0);
-
- /* If we're suspending all threads, leave this one suspended
+ child_proc = add_linux_process (new_pid, 0);
+ gdb_assert (child_proc != NULL);
+ child_lwp = add_lwp (ptid);
+ gdb_assert (child_lwp != NULL);
+ child_lwp->stopped = 1;
+ child_lwp->must_set_ptrace_flags = 1;
+ child_lwp->status_pending_p = 0;
+ child_thr = get_lwp_thread (child_lwp);
+ child_thr->last_resume_kind = resume_stop;
+ child_thr->last_status.set_stopped (GDB_SIGNAL_0);
+
+ /* If we're suspending all threads, leave this one suspended
too. If the fork/clone parent is stepping over a breakpoint,
all other threads have been suspended already. Leave the
child suspended too. */
- if (stopping_threads == STOPPING_AND_SUSPENDING_THREADS
- || event_lwp->bp_reinsert != 0)
- {
- threads_debug_printf ("leaving child suspended");
- child_lwp->suspended = 1;
- }
-
- parent_proc = get_thread_process (event_thr);
- child_proc->attached = parent_proc->attached;
-
- if (event_lwp->bp_reinsert != 0
- && supports_software_single_step ()
- && event == PTRACE_EVENT_VFORK)
- {
- /* If we leave single-step breakpoints there, child will
+ if (stopping_threads == STOPPING_AND_SUSPENDING_THREADS
+ || event_lwp->bp_reinsert != 0)
+ {
+ threads_debug_printf ("leaving child suspended");
+ child_lwp->suspended = 1;
+ }
+
+ parent_proc = get_thread_process (event_thr);
+ child_proc->attached = parent_proc->attached;
+
+ if (event_lwp->bp_reinsert != 0 && supports_software_single_step ()
+ && event == PTRACE_EVENT_VFORK)
+ {
+ /* If we leave single-step breakpoints there, child will
hit it, so uninsert single-step breakpoints from parent
(and child). Once vfork child is done, reinsert
them back to parent. */
- uninsert_single_step_breakpoints (event_thr);
- }
+ uninsert_single_step_breakpoints (event_thr);
+ }
- clone_all_breakpoints (child_thr, event_thr);
+ clone_all_breakpoints (child_thr, event_thr);
- target_desc_up tdesc = allocate_target_description ();
- copy_target_description (tdesc.get (), parent_proc->tdesc);
- child_proc->tdesc = tdesc.release ();
+ target_desc_up tdesc = allocate_target_description ();
+ copy_target_description (tdesc.get (), parent_proc->tdesc);
+ child_proc->tdesc = tdesc.release ();
- /* Clone arch-specific process data. */
- low_new_fork (parent_proc, child_proc);
+ /* Clone arch-specific process data. */
+ low_new_fork (parent_proc, child_proc);
- /* Save fork info in the parent thread. */
- if (event == PTRACE_EVENT_FORK)
- event_lwp->waitstatus.set_forked (ptid);
- else if (event == PTRACE_EVENT_VFORK)
- event_lwp->waitstatus.set_vforked (ptid);
+ /* Save fork info in the parent thread. */
+ if (event == PTRACE_EVENT_FORK)
+ event_lwp->waitstatus.set_forked (ptid);
+ else if (event == PTRACE_EVENT_VFORK)
+ event_lwp->waitstatus.set_vforked (ptid);
- /* The status_pending field contains bits denoting the
+ /* The status_pending field contains bits denoting the
extended event, so when the pending event is handled,
the handler will look at lwp->waitstatus. */
- event_lwp->status_pending_p = 1;
- event_lwp->status_pending = wstat;
+ event_lwp->status_pending_p = 1;
+ event_lwp->status_pending = wstat;
- /* Link the threads until the parent event is passed on to
+ /* Link the threads until the parent event is passed on to
higher layers. */
- event_lwp->fork_relative = child_lwp;
- child_lwp->fork_relative = event_lwp;
+ event_lwp->fork_relative = child_lwp;
+ child_lwp->fork_relative = event_lwp;
- /* If the parent thread is doing step-over with single-step
+ /* If the parent thread is doing step-over with single-step
breakpoints, the list of single-step breakpoints are cloned
from the parent's. Remove them from the child process.
In case of vfork, we'll reinsert them back once vforked
child is done. */
- if (event_lwp->bp_reinsert != 0
- && supports_software_single_step ())
- {
- /* The child process is forked and stopped, so it is safe
+ if (event_lwp->bp_reinsert != 0 && supports_software_single_step ())
+ {
+ /* The child process is forked and stopped, so it is safe
to access its memory without stopping all other threads
from other processes. */
- delete_single_step_breakpoints (child_thr);
+ delete_single_step_breakpoints (child_thr);
- gdb_assert (has_single_step_breakpoints (event_thr));
- gdb_assert (!has_single_step_breakpoints (child_thr));
- }
+ gdb_assert (has_single_step_breakpoints (event_thr));
+ gdb_assert (!has_single_step_breakpoints (child_thr));
+ }
- /* Report the event. */
- return 0;
- }
+ /* Report the event. */
+ return 0;
+ }
- threads_debug_printf
- ("Got clone event from LWP %ld, new child is LWP %ld",
- lwpid_of (event_thr), new_pid);
+ threads_debug_printf (
+ "Got clone event from LWP %ld, new child is LWP %ld",
+ lwpid_of (event_thr), new_pid);
ptid = ptid_t (pid_of (event_thr), new_pid);
new_lwp = add_lwp (ptid);
@@ -647,24 +638,24 @@ linux_process_target::handle_extended_wait (lwp_info **orig_event_lwp,
all other threads have been suspended already. Leave the
child suspended too. */
if (stopping_threads == STOPPING_AND_SUSPENDING_THREADS
- || event_lwp->bp_reinsert != 0)
- new_lwp->suspended = 1;
+ || event_lwp->bp_reinsert != 0)
+ new_lwp->suspended = 1;
/* Normally we will get the pending SIGSTOP. But in some cases
we might get another signal delivered to the group first.
If we do get another signal, be sure not to lose it. */
if (WSTOPSIG (status) != SIGSTOP)
- {
- new_lwp->stop_expected = 1;
- new_lwp->status_pending_p = 1;
- new_lwp->status_pending = status;
- }
+ {
+ new_lwp->stop_expected = 1;
+ new_lwp->status_pending_p = 1;
+ new_lwp->status_pending = status;
+ }
else if (cs.report_thread_events)
- {
- new_lwp->waitstatus.set_thread_created ();
- new_lwp->status_pending_p = 1;
- new_lwp->status_pending = status;
- }
+ {
+ new_lwp->waitstatus.set_thread_created ();
+ new_lwp->status_pending_p = 1;
+ new_lwp->status_pending = status;
+ }
#ifdef USE_THREAD_DB
thread_db_notice_clone (event_thr, ptid);
@@ -678,11 +669,11 @@ linux_process_target::handle_extended_wait (lwp_info **orig_event_lwp,
event_lwp->waitstatus.set_vfork_done ();
if (event_lwp->bp_reinsert != 0 && supports_software_single_step ())
- {
- reinsert_single_step_breakpoints (event_thr);
+ {
+ reinsert_single_step_breakpoints (event_thr);
- gdb_assert (has_single_step_breakpoints (event_thr));
- }
+ gdb_assert (has_single_step_breakpoints (event_thr));
+ }
/* Report the event. */
return 0;
@@ -695,7 +686,7 @@ linux_process_target::handle_extended_wait (lwp_info **orig_event_lwp,
pid_t event_pid;
threads_debug_printf ("Got exec event from LWP %ld",
- lwpid_of (event_thr));
+ lwpid_of (event_thr));
/* Get the event ptid. */
event_ptid = ptid_of (event_thr);
@@ -717,9 +708,8 @@ linux_process_target::handle_extended_wait (lwp_info **orig_event_lwp,
arch_setup_thread (event_thr);
/* Set the event status. */
- event_lwp->waitstatus.set_execd
- (make_unique_xstrdup
- (linux_proc_pid_to_exec_file (lwpid_of (event_thr))));
+ event_lwp->waitstatus.set_execd (make_unique_xstrdup (
+ linux_proc_pid_to_exec_file (lwpid_of (event_thr))));
/* Mark the exec status as pending. */
event_lwp->stopped = 1;
@@ -741,7 +731,7 @@ linux_process_target::handle_extended_wait (lwp_info **orig_event_lwp,
return 0;
}
- internal_error (_("unknown ptrace event %d"), event);
+ internal_error (_ ("unknown ptrace event %d"), event);
}
CORE_ADDR
@@ -814,45 +804,46 @@ linux_process_target::save_stop_reason (lwp_info *lwp)
#if USE_SIGTRAP_SIGINFO
if (ptrace (PTRACE_GETSIGINFO, lwpid_of (current_thread),
- (PTRACE_TYPE_ARG3) 0, &siginfo) == 0)
+ (PTRACE_TYPE_ARG3) 0, &siginfo)
+ == 0)
{
if (siginfo.si_signo == SIGTRAP)
- {
- if (GDB_ARCH_IS_TRAP_BRKPT (siginfo.si_code)
- && GDB_ARCH_IS_TRAP_HWBKPT (siginfo.si_code))
- {
- /* The si_code is ambiguous on this arch -- check debug
+ {
+ if (GDB_ARCH_IS_TRAP_BRKPT (siginfo.si_code)
+ && GDB_ARCH_IS_TRAP_HWBKPT (siginfo.si_code))
+ {
+ /* The si_code is ambiguous on this arch -- check debug
registers. */
- if (!check_stopped_by_watchpoint (lwp))
- lwp->stop_reason = TARGET_STOPPED_BY_SW_BREAKPOINT;
- }
- else if (GDB_ARCH_IS_TRAP_BRKPT (siginfo.si_code))
- {
- /* If we determine the LWP stopped for a SW breakpoint,
+ if (!check_stopped_by_watchpoint (lwp))
+ lwp->stop_reason = TARGET_STOPPED_BY_SW_BREAKPOINT;
+ }
+ else if (GDB_ARCH_IS_TRAP_BRKPT (siginfo.si_code))
+ {
+ /* If we determine the LWP stopped for a SW breakpoint,
trust it. Particularly don't check watchpoint
registers, because at least on s390, we'd find
stopped-by-watchpoint as long as there's a watchpoint
set. */
- lwp->stop_reason = TARGET_STOPPED_BY_SW_BREAKPOINT;
- }
- else if (GDB_ARCH_IS_TRAP_HWBKPT (siginfo.si_code))
- {
- /* This can indicate either a hardware breakpoint or
+ lwp->stop_reason = TARGET_STOPPED_BY_SW_BREAKPOINT;
+ }
+ else if (GDB_ARCH_IS_TRAP_HWBKPT (siginfo.si_code))
+ {
+ /* This can indicate either a hardware breakpoint or
hardware watchpoint. Check debug registers. */
- if (!check_stopped_by_watchpoint (lwp))
- lwp->stop_reason = TARGET_STOPPED_BY_HW_BREAKPOINT;
- }
- else if (siginfo.si_code == TRAP_TRACE)
- {
- /* We may have single stepped an instruction that
+ if (!check_stopped_by_watchpoint (lwp))
+ lwp->stop_reason = TARGET_STOPPED_BY_HW_BREAKPOINT;
+ }
+ else if (siginfo.si_code == TRAP_TRACE)
+ {
+ /* We may have single stepped an instruction that
triggered a watchpoint. In that case, on some
architectures (such as x86), instead of TRAP_HWBKPT,
si_code indicates TRAP_TRACE, and we need to check
the debug registers separately. */
- if (!check_stopped_by_watchpoint (lwp))
- lwp->stop_reason = TARGET_STOPPED_BY_SINGLE_STEP;
- }
- }
+ if (!check_stopped_by_watchpoint (lwp))
+ lwp->stop_reason = TARGET_STOPPED_BY_SINGLE_STEP;
+ }
+ }
}
#else
/* We may have just stepped a breakpoint instruction. E.g., in
@@ -872,33 +863,32 @@ linux_process_target::save_stop_reason (lwp_info *lwp)
if (lwp->stop_reason == TARGET_STOPPED_BY_SW_BREAKPOINT)
{
- threads_debug_printf
- ("%s stopped by software breakpoint",
- target_pid_to_str (ptid_of (get_lwp_thread (lwp))).c_str ());
+ threads_debug_printf ("%s stopped by software breakpoint",
+ target_pid_to_str (ptid_of (get_lwp_thread (lwp)))
+ .c_str ());
/* Back up the PC if necessary. */
if (pc != sw_breakpoint_pc)
- {
- struct regcache *regcache
- = get_thread_regcache (current_thread, 1);
- low_set_pc (regcache, sw_breakpoint_pc);
- }
+ {
+ struct regcache *regcache = get_thread_regcache (current_thread, 1);
+ low_set_pc (regcache, sw_breakpoint_pc);
+ }
/* Update this so we record the correct stop PC below. */
pc = sw_breakpoint_pc;
}
else if (lwp->stop_reason == TARGET_STOPPED_BY_HW_BREAKPOINT)
- threads_debug_printf
- ("%s stopped by hardware breakpoint",
- target_pid_to_str (ptid_of (get_lwp_thread (lwp))).c_str ());
+ threads_debug_printf ("%s stopped by hardware breakpoint",
+ target_pid_to_str (ptid_of (get_lwp_thread (lwp)))
+ .c_str ());
else if (lwp->stop_reason == TARGET_STOPPED_BY_WATCHPOINT)
- threads_debug_printf
- ("%s stopped by hardware watchpoint",
- target_pid_to_str (ptid_of (get_lwp_thread (lwp))).c_str ());
+ threads_debug_printf ("%s stopped by hardware watchpoint",
+ target_pid_to_str (ptid_of (get_lwp_thread (lwp)))
+ .c_str ());
else if (lwp->stop_reason == TARGET_STOPPED_BY_SINGLE_STEP)
- threads_debug_printf
- ("%s stopped by trace",
- target_pid_to_str (ptid_of (get_lwp_thread (lwp))).c_str ());
+ threads_debug_printf ("%s stopped by trace",
+ target_pid_to_str (ptid_of (get_lwp_thread (lwp)))
+ .c_str ());
lwp->stop_pc = pc;
return true;
@@ -928,8 +918,8 @@ linux_process_target::low_new_thread (lwp_info *info)
static void
linux_ptrace_fun ()
{
- if (ptrace (PTRACE_TRACEME, 0, (PTRACE_TYPE_ARG3) 0,
- (PTRACE_TYPE_ARG4) 0) < 0)
+ if (ptrace (PTRACE_TRACEME, 0, (PTRACE_TYPE_ARG3) 0, (PTRACE_TYPE_ARG4) 0)
+ < 0)
trace_start_error_with_name ("ptrace");
if (setpgid (0, 0) < 0)
@@ -941,16 +931,17 @@ linux_ptrace_fun ()
if (remote_connection_is_stdio ())
{
if (close (0) < 0)
- trace_start_error_with_name ("close");
+ trace_start_error_with_name ("close");
if (open ("/dev/null", O_RDONLY) < 0)
- trace_start_error_with_name ("open");
+ trace_start_error_with_name ("open");
if (dup2 (2, 1) < 0)
- trace_start_error_with_name ("dup2");
+ trace_start_error_with_name ("dup2");
if (write (2, "stdin/stdout redirected\n",
- sizeof ("stdin/stdout redirected\n") - 1) < 0)
- {
- /* Errors ignored. */;
- }
+ sizeof ("stdin/stdout redirected\n") - 1)
+ < 0)
+ {
+ /* Errors ignored. */;
+ }
}
}
@@ -960,7 +951,7 @@ linux_ptrace_fun ()
int
linux_process_target::create_inferior (const char *program,
- const std::vector<char *> &program_args)
+ const std::vector<char *> &program_args)
{
client_state &cs = get_client_state ();
struct lwp_info *new_lwp;
@@ -968,14 +959,13 @@ linux_process_target::create_inferior (const char *program,
ptid_t ptid;
{
- maybe_disable_address_space_randomization restore_personality
- (cs.disable_randomization);
+ maybe_disable_address_space_randomization restore_personality (
+ cs.disable_randomization);
std::string str_program_args = construct_inferior_arguments (program_args);
- pid = fork_inferior (program,
- str_program_args.c_str (),
- get_environ ()->envp (), linux_ptrace_fun,
- NULL, NULL, NULL, NULL);
+ pid = fork_inferior (program, str_program_args.c_str (),
+ get_environ ()->envp (), linux_ptrace_fun, NULL, NULL,
+ NULL, NULL);
}
/* When spawning a new process, we can't open the mem file yet. We
@@ -1118,18 +1108,17 @@ attach_proc_task_lwp_callback (ptid_t ptid)
is returned if the thread's task still exists, and is marked
as exited or zombie, as well as other conditions, so in that
case, confirm the status in /proc/PID/status. */
- if (err == ESRCH
- || (err == EPERM && linux_proc_pid_is_gone (lwpid)))
- threads_debug_printf
- ("Cannot attach to lwp %d: thread is gone (%d: %s)",
- lwpid, err, safe_strerror (err));
+ if (err == ESRCH || (err == EPERM && linux_proc_pid_is_gone (lwpid)))
+ threads_debug_printf (
+ "Cannot attach to lwp %d: thread is gone (%d: %s)", lwpid, err,
+ safe_strerror (err));
else if (err != 0)
- {
- std::string reason
- = linux_ptrace_attach_fail_reason_string (ptid, err);
+ {
+ std::string reason
+ = linux_ptrace_attach_fail_reason_string (ptid, err);
- warning (_("Cannot attach to lwp %d: %s"), lwpid, reason.c_str ());
- }
+ warning (_ ("Cannot attach to lwp %d: %s"), lwpid, reason.c_str ());
+ }
return 1;
}
@@ -1200,10 +1189,10 @@ linux_process_target::attach (unsigned long pid)
lwp = find_lwp_pid (ptid_t (lwpid));
if (!WIFSTOPPED (wstat) || WSTOPSIG (wstat) != SIGSTOP)
- {
- lwp->status_pending_p = 1;
- lwp->status_pending = wstat;
- }
+ {
+ lwp->status_pending_p = 1;
+ lwp->status_pending = wstat;
+ }
initial_thread->last_resume_kind = resume_continue;
@@ -1220,20 +1209,19 @@ last_thread_of_process_p (int pid)
{
bool seen_one = false;
- thread_info *thread = find_thread (pid, [&] (thread_info *thr_arg)
- {
- if (!seen_one)
- {
- /* This is the first thread of this process we see. */
- seen_one = true;
- return false;
- }
- else
- {
- /* This is the second thread of this process we see. */
- return true;
- }
- });
+ thread_info *thread = find_thread (pid, [&] (thread_info *thr_arg) {
+ if (!seen_one)
+ {
+ /* This is the first thread of this process we see. */
+ seen_one = true;
+ return false;
+ }
+ else
+ {
+ /* This is the second thread of this process we see. */
+ return true;
+ }
+ });
return thread == NULL;
}
@@ -1266,8 +1254,8 @@ linux_kill_one_lwp (struct lwp_info *lwp)
int save_errno = errno;
threads_debug_printf ("kill_lwp (SIGKILL) %s, 0, 0 (%s)",
- target_pid_to_str (ptid_of (thr)).c_str (),
- save_errno ? safe_strerror (save_errno) : "OK");
+ target_pid_to_str (ptid_of (thr)).c_str (),
+ save_errno ? safe_strerror (save_errno) : "OK");
}
errno = 0;
@@ -1277,8 +1265,8 @@ linux_kill_one_lwp (struct lwp_info *lwp)
int save_errno = errno;
threads_debug_printf ("PTRACE_KILL %s, 0, 0 (%s)",
- target_pid_to_str (ptid_of (thr)).c_str (),
- save_errno ? safe_strerror (save_errno) : "OK");
+ target_pid_to_str (ptid_of (thr)).c_str (),
+ save_errno ? safe_strerror (save_errno) : "OK");
}
}
@@ -1315,8 +1303,9 @@ kill_wait_lwp (struct lwp_info *lwp)
*/
res = my_waitpid (lwpid, &wstat, 0);
if (res == -1 && errno == ECHILD)
- res = my_waitpid (lwpid, &wstat, __WCLONE);
- } while (res > 0 && WIFSTOPPED (wstat));
+ res = my_waitpid (lwpid, &wstat, __WCLONE);
+ }
+ while (res > 0 && WIFSTOPPED (wstat));
/* Even if it was stopped, the child may have already disappeared.
E.g., if it was killed by SIGKILL. */
@@ -1340,7 +1329,7 @@ kill_one_lwp_callback (thread_info *thread, int pid)
if (lwpid_of (thread) == pid)
{
threads_debug_printf ("is last of process %s",
- target_pid_to_str (thread->id).c_str ());
+ target_pid_to_str (thread->id).c_str ());
return;
}
@@ -1356,10 +1345,9 @@ linux_process_target::kill (process_info *process)
first, as PTRACE_KILL will not work otherwise. */
stop_all_lwps (0, NULL);
- for_each_thread (pid, [&] (thread_info *thread)
- {
- kill_one_lwp_callback (thread, pid);
- });
+ for_each_thread (pid, [&] (thread_info *thread) {
+ kill_one_lwp_callback (thread, pid);
+ });
/* See the comment in linux_kill_one_lwp. We did not kill the first
thread in the list, so do so now. */
@@ -1398,8 +1386,8 @@ get_detach_signal (struct thread_info *thread)
cleanly, then it'll have stopped with SIGSTOP. But we don't
want to deliver that SIGSTOP. */
if (thread->last_status.kind () != TARGET_WAITKIND_STOPPED
- || thread->last_status.sig () == GDB_SIGNAL_0)
- return 0;
+ || thread->last_status.sig () == GDB_SIGNAL_0)
+ return 0;
/* Otherwise, we may need to deliver the signal we
intercepted. */
@@ -1409,7 +1397,7 @@ get_detach_signal (struct thread_info *thread)
if (!WIFSTOPPED (status))
{
threads_debug_printf ("lwp %s hasn't stopped: no pending signal",
- target_pid_to_str (ptid_of (thread)).c_str ());
+ target_pid_to_str (ptid_of (thread)).c_str ());
return 0;
}
@@ -1417,8 +1405,8 @@ get_detach_signal (struct thread_info *thread)
if (WSTOPSIG (status) == SIGTRAP && linux_is_extended_waitstatus (status))
{
threads_debug_printf ("lwp %s had stopped with extended "
- "status: no pending signal",
- target_pid_to_str (ptid_of (thread)).c_str ());
+ "status: no pending signal",
+ target_pid_to_str (ptid_of (thread)).c_str ());
return 0;
}
@@ -1427,28 +1415,28 @@ get_detach_signal (struct thread_info *thread)
if (cs.program_signals_p && !cs.program_signals[signo])
{
threads_debug_printf ("lwp %s had signal %s, but it is in nopass state",
- target_pid_to_str (ptid_of (thread)).c_str (),
- gdb_signal_to_string (signo));
+ target_pid_to_str (ptid_of (thread)).c_str (),
+ gdb_signal_to_string (signo));
return 0;
}
else if (!cs.program_signals_p
- /* If we have no way to know which signals GDB does not
+ /* If we have no way to know which signals GDB does not
want to have passed to the program, assume
SIGTRAP/SIGINT, which is GDB's default. */
- && (signo == GDB_SIGNAL_TRAP || signo == GDB_SIGNAL_INT))
+ && (signo == GDB_SIGNAL_TRAP || signo == GDB_SIGNAL_INT))
{
threads_debug_printf ("lwp %s had signal %s, "
- "but we don't know if we should pass it. "
- "Default to not.",
- target_pid_to_str (ptid_of (thread)).c_str (),
- gdb_signal_to_string (signo));
+ "but we don't know if we should pass it. "
+ "Default to not.",
+ target_pid_to_str (ptid_of (thread)).c_str (),
+ gdb_signal_to_string (signo));
return 0;
}
else
{
threads_debug_printf ("lwp %s has pending signal %s: delivering it",
- target_pid_to_str (ptid_of (thread)).c_str (),
- gdb_signal_to_string (signo));
+ target_pid_to_str (ptid_of (thread)).c_str (),
+ gdb_signal_to_string (signo));
return WSTOPSIG (status);
}
@@ -1465,7 +1453,7 @@ linux_process_target::detach_one_lwp (lwp_info *lwp)
if (lwp->stop_expected)
{
threads_debug_printf ("Sending SIGCONT to %s",
- target_pid_to_str (ptid_of (thread)).c_str ());
+ target_pid_to_str (ptid_of (thread)).c_str ());
kill_lwp (lwpid_of (thread), SIGCONT);
lwp->stop_expected = 0;
@@ -1488,12 +1476,13 @@ linux_process_target::detach_one_lwp (lwp_info *lwp)
catch (const gdb_exception_error &ex)
{
if (!check_ptrace_stopped_lwp_gone (lwp))
- throw;
+ throw;
}
lwpid = lwpid_of (thread);
if (ptrace (PTRACE_DETACH, lwpid, (PTRACE_TYPE_ARG3) 0,
- (PTRACE_TYPE_ARG4) (long) sig) < 0)
+ (PTRACE_TYPE_ARG4) (long) sig)
+ < 0)
{
int save_errno = errno;
@@ -1502,33 +1491,33 @@ linux_process_target::detach_one_lwp (lwp_info *lwp)
threads exits the whole thread group. In that case we're
still attached, and must reap the lwp. */
if (save_errno == ESRCH)
- {
- int ret, status;
-
- ret = my_waitpid (lwpid, &status, __WALL);
- if (ret == -1)
- {
- warning (_("Couldn't reap LWP %d while detaching: %s"),
- lwpid, safe_strerror (errno));
- }
- else if (!WIFEXITED (status) && !WIFSIGNALED (status))
- {
- warning (_("Reaping LWP %d while detaching "
- "returned unexpected status 0x%x"),
- lwpid, status);
- }
- }
+ {
+ int ret, status;
+
+ ret = my_waitpid (lwpid, &status, __WALL);
+ if (ret == -1)
+ {
+ warning (_ ("Couldn't reap LWP %d while detaching: %s"), lwpid,
+ safe_strerror (errno));
+ }
+ else if (!WIFEXITED (status) && !WIFSIGNALED (status))
+ {
+ warning (_ ("Reaping LWP %d while detaching "
+ "returned unexpected status 0x%x"),
+ lwpid, status);
+ }
+ }
else
- {
- error (_("Can't detach %s: %s"),
- target_pid_to_str (ptid_of (thread)).c_str (),
- safe_strerror (save_errno));
- }
+ {
+ error (_ ("Can't detach %s: %s"),
+ target_pid_to_str (ptid_of (thread)).c_str (),
+ safe_strerror (save_errno));
+ }
}
else
threads_debug_printf ("PTRACE_DETACH (%s, %s, 0) (OK)",
- target_pid_to_str (ptid_of (thread)).c_str (),
- strsignal (sig));
+ target_pid_to_str (ptid_of (thread)).c_str (),
+ strsignal (sig));
delete_lwp (lwp);
}
@@ -1559,17 +1548,16 @@ linux_process_target::detach (process_info *process)
/* Detach from the clone lwps first. If the thread group exits just
while we're detaching, we must reap the clone lwps before we're
able to reap the leader. */
- for_each_thread (process->pid, [this] (thread_info *thread)
- {
- /* We don't actually detach from the thread group leader just yet.
+ for_each_thread (process->pid, [this] (thread_info *thread) {
+ /* We don't actually detach from the thread group leader just yet.
If the thread group exits, we must reap the zombie clone lwps
before we're able to reap the leader. */
- if (thread->id.pid () == thread->id.lwp ())
- return;
+ if (thread->id.pid () == thread->id.lwp ())
+ return;
- lwp_info *lwp = get_thread_lwp (thread);
- detach_one_lwp (lwp);
- });
+ lwp_info *lwp = get_thread_lwp (thread);
+ detach_one_lwp (lwp);
+ });
main_lwp = find_lwp_pid (ptid_t (process->pid));
detach_one_lwp (main_lwp);
@@ -1591,10 +1579,9 @@ linux_process_target::mourn (process_info *process)
thread_db_mourn (process);
#endif
- for_each_thread (process->pid, [this] (thread_info *thread)
- {
- delete_lwp (get_thread_lwp (thread));
- });
+ for_each_thread (process->pid, [this] (thread_info *thread) {
+ delete_lwp (get_thread_lwp (thread));
+ });
this->remove_linux_process (process);
}
@@ -1604,11 +1591,13 @@ linux_process_target::join (int pid)
{
int status, ret;
- do {
- ret = my_waitpid (pid, &status, 0);
- if (WIFEXITED (status) || WIFSIGNALED (status))
- break;
- } while (ret != -1 || errno != ECHILD);
+ do
+ {
+ ret = my_waitpid (pid, &status, 0);
+ if (WIFEXITED (status) || WIFSIGNALED (status))
+ break;
+ }
+ while (ret != -1 || errno != ECHILD);
}
/* Return true if the given thread is still alive. */
@@ -1637,7 +1626,7 @@ linux_process_target::thread_still_has_status_pending (thread_info *thread)
if (thread->last_resume_kind != resume_stop
&& (lp->stop_reason == TARGET_STOPPED_BY_SW_BREAKPOINT
- || lp->stop_reason == TARGET_STOPPED_BY_HW_BREAKPOINT))
+ || lp->stop_reason == TARGET_STOPPED_BY_HW_BREAKPOINT))
{
CORE_ADDR pc;
int discard = 0;
@@ -1650,35 +1639,34 @@ linux_process_target::thread_still_has_status_pending (thread_info *thread)
switch_to_thread (thread);
if (pc != lp->stop_pc)
- {
- threads_debug_printf ("PC of %ld changed",
- lwpid_of (thread));
- discard = 1;
- }
+ {
+ threads_debug_printf ("PC of %ld changed", lwpid_of (thread));
+ discard = 1;
+ }
#if !USE_SIGTRAP_SIGINFO
else if (lp->stop_reason == TARGET_STOPPED_BY_SW_BREAKPOINT
- && !low_breakpoint_at (pc))
- {
- threads_debug_printf ("previous SW breakpoint of %ld gone",
- lwpid_of (thread));
- discard = 1;
- }
+ && !low_breakpoint_at (pc))
+ {
+ threads_debug_printf ("previous SW breakpoint of %ld gone",
+ lwpid_of (thread));
+ discard = 1;
+ }
else if (lp->stop_reason == TARGET_STOPPED_BY_HW_BREAKPOINT
- && !hardware_breakpoint_inserted_here (pc))
- {
- threads_debug_printf ("previous HW breakpoint of %ld gone",
- lwpid_of (thread));
- discard = 1;
- }
+ && !hardware_breakpoint_inserted_here (pc))
+ {
+ threads_debug_printf ("previous HW breakpoint of %ld gone",
+ lwpid_of (thread));
+ discard = 1;
+ }
#endif
if (discard)
- {
- threads_debug_printf ("discarding pending breakpoint status");
- lp->status_pending_p = 0;
- return 0;
- }
+ {
+ threads_debug_printf ("discarding pending breakpoint status");
+ lp->status_pending_p = 0;
+ return 0;
+ }
}
return 1;
@@ -1706,7 +1694,7 @@ lwp_resumed (struct lwp_info *lwp)
bool
linux_process_target::status_pending_p_callback (thread_info *thread,
- ptid_t ptid)
+ ptid_t ptid)
{
struct lwp_info *lp = get_thread_lwp (thread);
@@ -1718,8 +1706,7 @@ linux_process_target::status_pending_p_callback (thread_info *thread,
if (!lwp_resumed (lp))
return 0;
- if (lp->status_pending_p
- && !thread_still_has_status_pending (thread))
+ if (lp->status_pending_p && !thread_still_has_status_pending (thread))
{
resume_one_lwp (lp, lp->stepping, GDB_SIGNAL_0, NULL);
return 0;
@@ -1732,10 +1719,8 @@ struct lwp_info *
find_lwp_pid (ptid_t ptid)
{
long lwp = ptid.lwp () != 0 ? ptid.lwp () : ptid.pid ();
- thread_info *thread = find_thread ([lwp] (thread_info *thr_arg)
- {
- return thr_arg->id.lwp () == lwp;
- });
+ thread_info *thread = find_thread (
+ [lwp] (thread_info *thr_arg) { return thr_arg->id.lwp () == lwp; });
if (thread == NULL)
return NULL;
@@ -1750,10 +1735,7 @@ num_lwps (int pid)
{
int count = 0;
- for_each_thread (pid, [&] (thread_info *thread)
- {
- count++;
- });
+ for_each_thread (pid, [&] (thread_info *thread) { count++; });
return count;
}
@@ -1762,14 +1744,13 @@ num_lwps (int pid)
struct lwp_info *
iterate_over_lwps (ptid_t filter,
- gdb::function_view<iterate_over_lwps_ftype> callback)
+ gdb::function_view<iterate_over_lwps_ftype> callback)
{
- thread_info *thread = find_thread (filter, [&] (thread_info *thr_arg)
- {
- lwp_info *lwp = get_thread_lwp (thr_arg);
+ thread_info *thread = find_thread (filter, [&] (thread_info *thr_arg) {
+ lwp_info *lwp = get_thread_lwp (thr_arg);
- return callback (lwp);
- });
+ return callback (lwp);
+ });
if (thread == NULL)
return NULL;
@@ -1780,27 +1761,27 @@ iterate_over_lwps (ptid_t filter,
void
linux_process_target::check_zombie_leaders ()
{
- for_each_process ([this] (process_info *proc)
- {
- pid_t leader_pid = pid_of (proc);
- lwp_info *leader_lp = find_lwp_pid (ptid_t (leader_pid));
+ for_each_process ([this] (process_info *proc) {
+ pid_t leader_pid = pid_of (proc);
+ lwp_info *leader_lp = find_lwp_pid (ptid_t (leader_pid));
- threads_debug_printf ("leader_pid=%d, leader_lp!=NULL=%d, "
- "num_lwps=%d, zombie=%d",
- leader_pid, leader_lp!= NULL, num_lwps (leader_pid),
- linux_proc_pid_is_zombie (leader_pid));
+ threads_debug_printf ("leader_pid=%d, leader_lp!=NULL=%d, "
+ "num_lwps=%d, zombie=%d",
+ leader_pid, leader_lp != NULL, num_lwps (leader_pid),
+ linux_proc_pid_is_zombie (leader_pid));
- if (leader_lp != NULL && !leader_lp->stopped
- /* Check if there are other threads in the group, as we may
+ if (leader_lp != NULL
+ && !leader_lp->stopped
+ /* Check if there are other threads in the group, as we may
have raced with the inferior simply exiting. Note this
isn't a watertight check. If the inferior is
multi-threaded and is exiting, it may be we see the
leader as zombie before we reap all the non-leader
threads. See comments below. */
- && !last_thread_of_process_p (leader_pid)
- && linux_proc_pid_is_zombie (leader_pid))
- {
- /* A zombie leader in a multi-threaded program can mean one
+ && !last_thread_of_process_p (leader_pid)
+ && linux_proc_pid_is_zombie (leader_pid))
+ {
+ /* A zombie leader in a multi-threaded program can mean one
of three things:
#1 - Only the leader exited, not the whole program, e.g.,
@@ -1845,13 +1826,13 @@ linux_process_target::check_zombie_leaders ()
exit when we see the leader exiting, as opposed to when
the last LWP in the LWP list exits, which can be a
non-leader if we deleted the leader here. */
- threads_debug_printf ("Thread group leader %d zombie "
- "(it exited, or another thread execd), "
- "deleting it.",
- leader_pid);
- delete_lwp (leader_lp);
- }
- });
+ threads_debug_printf ("Thread group leader %d zombie "
+ "(it exited, or another thread execd), "
+ "deleting it.",
+ leader_pid);
+ delete_lwp (leader_lp);
+ }
+ });
}
/* Callback for `find_thread'. Returns the first LWP that is not
@@ -1876,9 +1857,9 @@ lwp_suspended_inc (struct lwp_info *lwp)
lwp->suspended++;
if (lwp->suspended > 4)
- threads_debug_printf
- ("LWP %ld has a suspiciously high suspend count, suspended=%d",
- lwpid_of (get_lwp_thread (lwp)), lwp->suspended);
+ threads_debug_printf (
+ "LWP %ld has a suspiciously high suspend count, suspended=%d",
+ lwpid_of (get_lwp_thread (lwp)), lwp->suspended);
}
/* Decrement LWP's suspend count. */
@@ -1893,7 +1874,7 @@ lwp_suspended_decr (struct lwp_info *lwp)
struct thread_info *thread = get_lwp_thread (lwp);
internal_error ("unsuspend LWP %ld, suspended=%d\n", lwpid_of (thread),
- lwp->suspended);
+ lwp->suspended);
}
}
@@ -1934,8 +1915,8 @@ handle_tracepoints (struct lwp_info *lwp)
gdb_assert (lwp->suspended == 0);
gdb_assert (!stabilizing_threads
- || (lwp->collecting_fast_tracepoint
- != fast_tpoint_collect_result::not_collecting));
+ || (lwp->collecting_fast_tracepoint
+ != fast_tpoint_collect_result::not_collecting));
if (tpoint_related_event)
{
@@ -1947,8 +1928,8 @@ handle_tracepoints (struct lwp_info *lwp)
}
fast_tpoint_collect_result
-linux_process_target::linux_fast_tracepoint_collecting
- (lwp_info *lwp, fast_tpoint_collect_status *status)
+linux_process_target::linux_fast_tracepoint_collecting (
+ lwp_info *lwp, fast_tpoint_collect_status *status)
{
CORE_ADDR thread_area;
struct thread_info *thread = get_lwp_thread (lwp);
@@ -1975,113 +1956,110 @@ linux_process_target::maybe_move_out_of_jump_pad (lwp_info *lwp, int *wstat)
scoped_restore_current_thread restore_thread;
switch_to_thread (get_lwp_thread (lwp));
- if ((wstat == NULL
- || (WIFSTOPPED (*wstat) && WSTOPSIG (*wstat) != SIGTRAP))
- && supports_fast_tracepoints ()
- && agent_loaded_p ())
+ if ((wstat == NULL || (WIFSTOPPED (*wstat) && WSTOPSIG (*wstat) != SIGTRAP))
+ && supports_fast_tracepoints () && agent_loaded_p ())
{
struct fast_tpoint_collect_status status;
- threads_debug_printf
- ("Checking whether LWP %ld needs to move out of the jump pad.",
- lwpid_of (current_thread));
+ threads_debug_printf (
+ "Checking whether LWP %ld needs to move out of the jump pad.",
+ lwpid_of (current_thread));
fast_tpoint_collect_result r
- = linux_fast_tracepoint_collecting (lwp, &status);
+ = linux_fast_tracepoint_collecting (lwp, &status);
if (wstat == NULL
- || (WSTOPSIG (*wstat) != SIGILL
- && WSTOPSIG (*wstat) != SIGFPE
- && WSTOPSIG (*wstat) != SIGSEGV
- && WSTOPSIG (*wstat) != SIGBUS))
- {
- lwp->collecting_fast_tracepoint = r;
-
- if (r != fast_tpoint_collect_result::not_collecting)
- {
- if (r == fast_tpoint_collect_result::before_insn
- && lwp->exit_jump_pad_bkpt == NULL)
- {
- /* Haven't executed the original instruction yet.
+ || (WSTOPSIG (*wstat) != SIGILL && WSTOPSIG (*wstat) != SIGFPE
+ && WSTOPSIG (*wstat) != SIGSEGV && WSTOPSIG (*wstat) != SIGBUS))
+ {
+ lwp->collecting_fast_tracepoint = r;
+
+ if (r != fast_tpoint_collect_result::not_collecting)
+ {
+ if (r == fast_tpoint_collect_result::before_insn
+ && lwp->exit_jump_pad_bkpt == NULL)
+ {
+ /* Haven't executed the original instruction yet.
Set breakpoint there, and wait till it's hit,
then single-step until exiting the jump pad. */
- lwp->exit_jump_pad_bkpt
- = set_breakpoint_at (status.adjusted_insn_addr, NULL);
- }
-
- threads_debug_printf
- ("Checking whether LWP %ld needs to move out of the jump pad..."
- " it does", lwpid_of (current_thread));
-
- return true;
- }
- }
+ lwp->exit_jump_pad_bkpt
+ = set_breakpoint_at (status.adjusted_insn_addr, NULL);
+ }
+
+ threads_debug_printf (
+ "Checking whether LWP %ld needs to move out of the jump pad..."
+ " it does",
+ lwpid_of (current_thread));
+
+ return true;
+ }
+ }
else
- {
- /* If we get a synchronous signal while collecting, *and*
+ {
+ /* If we get a synchronous signal while collecting, *and*
while executing the (relocated) original instruction,
reset the PC to point at the tpoint address, before
reporting to GDB. Otherwise, it's an IPA lib bug: just
report the signal to GDB, and pray for the best. */
- lwp->collecting_fast_tracepoint
- = fast_tpoint_collect_result::not_collecting;
+ lwp->collecting_fast_tracepoint
+ = fast_tpoint_collect_result::not_collecting;
- if (r != fast_tpoint_collect_result::not_collecting
- && (status.adjusted_insn_addr <= lwp->stop_pc
- && lwp->stop_pc < status.adjusted_insn_addr_end))
- {
- siginfo_t info;
- struct regcache *regcache;
+ if (r != fast_tpoint_collect_result::not_collecting
+ && (status.adjusted_insn_addr <= lwp->stop_pc
+ && lwp->stop_pc < status.adjusted_insn_addr_end))
+ {
+ siginfo_t info;
+ struct regcache *regcache;
- /* The si_addr on a few signals references the address
+ /* The si_addr on a few signals references the address
of the faulting instruction. Adjust that as
well. */
- if ((WSTOPSIG (*wstat) == SIGILL
- || WSTOPSIG (*wstat) == SIGFPE
- || WSTOPSIG (*wstat) == SIGBUS
- || WSTOPSIG (*wstat) == SIGSEGV)
- && ptrace (PTRACE_GETSIGINFO, lwpid_of (current_thread),
- (PTRACE_TYPE_ARG3) 0, &info) == 0
- /* Final check just to make sure we don't clobber
+ if ((WSTOPSIG (*wstat) == SIGILL || WSTOPSIG (*wstat) == SIGFPE
+ || WSTOPSIG (*wstat) == SIGBUS
+ || WSTOPSIG (*wstat) == SIGSEGV)
+ && ptrace (PTRACE_GETSIGINFO, lwpid_of (current_thread),
+ (PTRACE_TYPE_ARG3) 0, &info)
+ == 0
+ /* Final check just to make sure we don't clobber
the siginfo of non-kernel-sent signals. */
- && (uintptr_t) info.si_addr == lwp->stop_pc)
- {
- info.si_addr = (void *) (uintptr_t) status.tpoint_addr;
- ptrace (PTRACE_SETSIGINFO, lwpid_of (current_thread),
- (PTRACE_TYPE_ARG3) 0, &info);
- }
-
- regcache = get_thread_regcache (current_thread, 1);
- low_set_pc (regcache, status.tpoint_addr);
- lwp->stop_pc = status.tpoint_addr;
-
- /* Cancel any fast tracepoint lock this thread was
+ && (uintptr_t) info.si_addr == lwp->stop_pc)
+ {
+ info.si_addr = (void *) (uintptr_t) status.tpoint_addr;
+ ptrace (PTRACE_SETSIGINFO, lwpid_of (current_thread),
+ (PTRACE_TYPE_ARG3) 0, &info);
+ }
+
+ regcache = get_thread_regcache (current_thread, 1);
+ low_set_pc (regcache, status.tpoint_addr);
+ lwp->stop_pc = status.tpoint_addr;
+
+ /* Cancel any fast tracepoint lock this thread was
holding. */
- force_unlock_trace_buffer ();
- }
+ force_unlock_trace_buffer ();
+ }
- if (lwp->exit_jump_pad_bkpt != NULL)
- {
- threads_debug_printf
- ("Cancelling fast exit-jump-pad: removing bkpt."
- "stopping all threads momentarily.");
+ if (lwp->exit_jump_pad_bkpt != NULL)
+ {
+ threads_debug_printf (
+ "Cancelling fast exit-jump-pad: removing bkpt."
+ "stopping all threads momentarily.");
- stop_all_lwps (1, lwp);
+ stop_all_lwps (1, lwp);
- delete_breakpoint (lwp->exit_jump_pad_bkpt);
- lwp->exit_jump_pad_bkpt = NULL;
+ delete_breakpoint (lwp->exit_jump_pad_bkpt);
+ lwp->exit_jump_pad_bkpt = NULL;
- unstop_all_lwps (1, lwp);
+ unstop_all_lwps (1, lwp);
- gdb_assert (lwp->suspended >= 0);
- }
- }
+ gdb_assert (lwp->suspended >= 0);
+ }
+ }
}
- threads_debug_printf
- ("Checking whether LWP %ld needs to move out of the jump pad... no",
- lwpid_of (current_thread));
+ threads_debug_printf (
+ "Checking whether LWP %ld needs to move out of the jump pad... no",
+ lwpid_of (current_thread));
return false;
}
@@ -2094,13 +2072,13 @@ enqueue_one_deferred_signal (struct lwp_info *lwp, int *wstat)
{
struct thread_info *thread = get_lwp_thread (lwp);
- threads_debug_printf ("Deferring signal %d for LWP %ld.",
- WSTOPSIG (*wstat), lwpid_of (thread));
+ threads_debug_printf ("Deferring signal %d for LWP %ld.", WSTOPSIG (*wstat),
+ lwpid_of (thread));
if (debug_threads)
{
for (const auto &sig : lwp->pending_signals_to_report)
- threads_debug_printf (" Already queued %d", sig.signal);
+ threads_debug_printf (" Already queued %d", sig.signal);
threads_debug_printf (" (no more currently queued signals)");
}
@@ -2111,21 +2089,21 @@ enqueue_one_deferred_signal (struct lwp_info *lwp, int *wstat)
if (WSTOPSIG (*wstat) < __SIGRTMIN)
{
for (const auto &sig : lwp->pending_signals_to_report)
- {
- if (sig.signal == WSTOPSIG (*wstat))
- {
- threads_debug_printf
- ("Not requeuing already queued non-RT signal %d for LWP %ld",
- sig.signal, lwpid_of (thread));
- return;
- }
- }
+ {
+ if (sig.signal == WSTOPSIG (*wstat))
+ {
+ threads_debug_printf (
+ "Not requeuing already queued non-RT signal %d for LWP %ld",
+ sig.signal, lwpid_of (thread));
+ return;
+ }
+ }
}
lwp->pending_signals_to_report.emplace_back (WSTOPSIG (*wstat));
ptrace (PTRACE_GETSIGINFO, lwpid_of (thread), (PTRACE_TYPE_ARG3) 0,
- &lwp->pending_signals_to_report.back ().info);
+ &lwp->pending_signals_to_report.back ().info);
}
/* Dequeue one signal from the "signals to report later when out of
@@ -2142,21 +2120,21 @@ dequeue_one_deferred_signal (struct lwp_info *lwp, int *wstat)
*wstat = W_STOPCODE (p_sig.signal);
if (p_sig.info.si_signo != 0)
- ptrace (PTRACE_SETSIGINFO, lwpid_of (thread), (PTRACE_TYPE_ARG3) 0,
- &p_sig.info);
+ ptrace (PTRACE_SETSIGINFO, lwpid_of (thread), (PTRACE_TYPE_ARG3) 0,
+ &p_sig.info);
lwp->pending_signals_to_report.pop_front ();
threads_debug_printf ("Reporting deferred signal %d for LWP %ld.",
- WSTOPSIG (*wstat), lwpid_of (thread));
+ WSTOPSIG (*wstat), lwpid_of (thread));
if (debug_threads)
- {
- for (const auto &sig : lwp->pending_signals_to_report)
- threads_debug_printf (" Still queued %d", sig.signal);
+ {
+ for (const auto &sig : lwp->pending_signals_to_report)
+ threads_debug_printf (" Still queued %d", sig.signal);
- threads_debug_printf (" (no more queued signals)");
- }
+ threads_debug_printf (" (no more queued signals)");
+ }
return 1;
}
@@ -2230,60 +2208,57 @@ linux_process_target::filter_event (int lwpid, int wstat)
if (child == nullptr)
{
if (WIFSTOPPED (wstat))
- {
- if (WSTOPSIG (wstat) == SIGTRAP
- && linux_ptrace_get_extended_event (wstat) == PTRACE_EVENT_EXEC)
- {
- /* A non-leader thread exec'ed after we've seen the
+ {
+ if (WSTOPSIG (wstat) == SIGTRAP
+ && linux_ptrace_get_extended_event (wstat) == PTRACE_EVENT_EXEC)
+ {
+ /* A non-leader thread exec'ed after we've seen the
leader zombie, and removed it from our lists (in
check_zombie_leaders). The non-leader thread changes
its tid to the tgid. */
- threads_debug_printf
- ("Re-adding thread group leader LWP %d after exec.",
- lwpid);
-
- child = add_lwp (ptid_t (lwpid, lwpid));
- child->stopped = 1;
- switch_to_thread (child->thread);
- }
- else
- {
- /* A process we are controlling has forked and the new
+ threads_debug_printf (
+ "Re-adding thread group leader LWP %d after exec.", lwpid);
+
+ child = add_lwp (ptid_t (lwpid, lwpid));
+ child->stopped = 1;
+ switch_to_thread (child->thread);
+ }
+ else
+ {
+ /* A process we are controlling has forked and the new
child's stop was reported to us by the kernel. Save
its PID and go back to waiting for the fork event to
be reported - the stopped process might be returned
from waitpid before or after the fork event is. */
- threads_debug_printf
- ("Saving LWP %d status %s in stopped_pids list",
- lwpid, status_to_str (wstat).c_str ());
- add_to_pid_list (&stopped_pids, lwpid, wstat);
- }
- }
+ threads_debug_printf (
+ "Saving LWP %d status %s in stopped_pids list", lwpid,
+ status_to_str (wstat).c_str ());
+ add_to_pid_list (&stopped_pids, lwpid, wstat);
+ }
+ }
else
- {
- /* Don't report an event for the exit of an LWP not in our
+ {
+ /* Don't report an event for the exit of an LWP not in our
list, i.e. not part of any inferior we're debugging.
This can happen if we detach from a program we originally
forked and then it exits. However, note that we may have
earlier deleted a leader of an inferior we're debugging,
in check_zombie_leaders. Re-add it back here if so. */
- find_process ([&] (process_info *proc)
- {
- if (proc->pid == lwpid)
- {
- threads_debug_printf
- ("Re-adding thread group leader LWP %d after exit.",
- lwpid);
-
- child = add_lwp (ptid_t (lwpid, lwpid));
- return true;
- }
- return false;
- });
- }
+ find_process ([&] (process_info *proc) {
+ if (proc->pid == lwpid)
+ {
+ threads_debug_printf (
+ "Re-adding thread group leader LWP %d after exit.", lwpid);
+
+ child = add_lwp (ptid_t (lwpid, lwpid));
+ return true;
+ }
+ return false;
+ });
+ }
if (child == nullptr)
- return;
+ return;
}
thread = get_lwp_thread (child);
@@ -2298,27 +2273,27 @@ linux_process_target::filter_event (int lwpid, int wstat)
threads_debug_printf ("%d exited", lwpid);
if (finish_step_over (child))
- {
- /* Unsuspend all other LWPs, and set them back running again. */
- unsuspend_all_lwps (child);
- }
+ {
+ /* Unsuspend all other LWPs, and set them back running again. */
+ unsuspend_all_lwps (child);
+ }
/* If this is not the leader LWP, then the exit signal was not
the end of the debugged application and should be ignored,
unless GDB wants to hear about thread exits. */
if (cs.report_thread_events || is_leader (thread))
- {
- /* Since events are serialized to GDB core, and we can't
+ {
+ /* Since events are serialized to GDB core, and we can't
report this one right now. Leave the status pending for
the next time we're able to report it. */
- mark_lwp_dead (child, wstat);
- return;
- }
+ mark_lwp_dead (child, wstat);
+ return;
+ }
else
- {
- delete_lwp (child);
- return;
- }
+ {
+ delete_lwp (child);
+ return;
+ }
}
gdb_assert (WIFSTOPPED (wstat));
@@ -2330,24 +2305,24 @@ linux_process_target::filter_event (int lwpid, int wstat)
/* Architecture-specific setup after inferior is running. */
proc = find_process_pid (pid_of (thread));
if (proc->tdesc == NULL)
- {
- if (proc->attached)
- {
- /* This needs to happen after we have attached to the
+ {
+ if (proc->attached)
+ {
+ /* This needs to happen after we have attached to the
inferior and it is stopped for the first time, but
before we access any inferior registers. */
- arch_setup_thread (thread);
- }
- else
- {
- /* The process is started, but GDBserver will do
+ arch_setup_thread (thread);
+ }
+ else
+ {
+ /* The process is started, but GDBserver will do
architecture-specific setup after the program stops at
the first instruction. */
- child->status_pending_p = 1;
- child->status_pending = wstat;
- return;
- }
- }
+ child->status_pending_p = 1;
+ child->status_pending = wstat;
+ return;
+ }
+ }
}
if (WIFSTOPPED (wstat) && child->must_set_ptrace_flags)
@@ -2363,9 +2338,9 @@ linux_process_target::filter_event (int lwpid, int wstat)
if (WIFSTOPPED (wstat) && WSTOPSIG (wstat) == SYSCALL_SIGTRAP)
{
child->syscall_state
- = (child->syscall_state == TARGET_WAITKIND_SYSCALL_ENTRY
- ? TARGET_WAITKIND_SYSCALL_RETURN
- : TARGET_WAITKIND_SYSCALL_ENTRY);
+ = (child->syscall_state == TARGET_WAITKIND_SYSCALL_ENTRY
+ ? TARGET_WAITKIND_SYSCALL_RETURN
+ : TARGET_WAITKIND_SYSCALL_ENTRY);
}
else
{
@@ -2381,17 +2356,17 @@ linux_process_target::filter_event (int lwpid, int wstat)
{
child->stop_pc = get_pc (child);
if (handle_extended_wait (&child, wstat))
- {
- /* The event has been handled, so just return without
+ {
+ /* The event has been handled, so just return without
reporting it. */
- return;
- }
+ return;
+ }
}
if (linux_wstatus_maybe_breakpoint (wstat))
{
if (save_stop_reason (child))
- have_stop_pc = 1;
+ have_stop_pc = 1;
}
if (!have_stop_pc)
@@ -2405,30 +2380,31 @@ linux_process_target::filter_event (int lwpid, int wstat)
child->stop_expected = 0;
if (thread->last_resume_kind == resume_stop)
- {
- /* We want to report the stop to the core. Treat the
+ {
+ /* We want to report the stop to the core. Treat the
SIGSTOP as a normal event. */
- threads_debug_printf ("resume_stop SIGSTOP caught for %s.",
- target_pid_to_str (ptid_of (thread)).c_str ());
- }
+ threads_debug_printf ("resume_stop SIGSTOP caught for %s.",
+ target_pid_to_str (ptid_of (thread)).c_str ());
+ }
else if (stopping_threads != NOT_STOPPING_THREADS)
- {
- /* Stopping threads. We don't want this SIGSTOP to end up
+ {
+ /* Stopping threads. We don't want this SIGSTOP to end up
pending. */
- threads_debug_printf ("SIGSTOP caught for %s while stopping threads.",
- target_pid_to_str (ptid_of (thread)).c_str ());
- return;
- }
+ threads_debug_printf (
+ "SIGSTOP caught for %s while stopping threads.",
+ target_pid_to_str (ptid_of (thread)).c_str ());
+ return;
+ }
else
- {
- /* This is a delayed SIGSTOP. Filter out the event. */
- threads_debug_printf ("%s %s, 0, 0 (discard delayed SIGSTOP)",
- child->stepping ? "step" : "continue",
- target_pid_to_str (ptid_of (thread)).c_str ());
+ {
+ /* This is a delayed SIGSTOP. Filter out the event. */
+ threads_debug_printf ("%s %s, 0, 0 (discard delayed SIGSTOP)",
+ child->stepping ? "step" : "continue",
+ target_pid_to_str (ptid_of (thread)).c_str ());
- resume_one_lwp (child, child->stepping, 0, NULL);
- return;
- }
+ resume_one_lwp (child, child->stepping, 0, NULL);
+ return;
+ }
}
child->status_pending_p = 1;
@@ -2455,19 +2431,17 @@ linux_process_target::resume_stopped_resumed_lwps (thread_info *thread)
{
struct lwp_info *lp = get_thread_lwp (thread);
- if (lp->stopped
- && !lp->suspended
- && !lp->status_pending_p
+ if (lp->stopped && !lp->suspended && !lp->status_pending_p
&& thread->last_status.kind () == TARGET_WAITKIND_IGNORE)
{
int step = 0;
if (thread->last_resume_kind == resume_step)
- step = maybe_hw_step (thread);
+ step = maybe_hw_step (thread);
threads_debug_printf ("resuming stopped-resumed LWP %s at %s: step=%d",
- target_pid_to_str (ptid_of (thread)).c_str (),
- paddress (lp->stop_pc), step);
+ target_pid_to_str (ptid_of (thread)).c_str (),
+ paddress (lp->stop_pc), step);
resume_one_lwp (lp, step, GDB_SIGNAL_0, NULL);
}
@@ -2475,14 +2449,14 @@ linux_process_target::resume_stopped_resumed_lwps (thread_info *thread)
int
linux_process_target::wait_for_event_filtered (ptid_t wait_ptid,
- ptid_t filter_ptid,
- int *wstatp, int options)
+ ptid_t filter_ptid, int *wstatp,
+ int options)
{
struct thread_info *event_thread;
struct lwp_info *event_child, *requested_child;
sigset_t block_mask, prev_mask;
- retry:
+retry:
/* N.B. event_thread points to the thread_info struct that contains
event_child. Keep them in sync. */
event_thread = NULL;
@@ -2493,52 +2467,51 @@ linux_process_target::wait_for_event_filtered (ptid_t wait_ptid,
if (filter_ptid == minus_one_ptid || filter_ptid.is_pid ())
{
- event_thread = find_thread_in_random ([&] (thread_info *thread)
- {
- return status_pending_p_callback (thread, filter_ptid);
- });
+ event_thread = find_thread_in_random ([&] (thread_info *thread) {
+ return status_pending_p_callback (thread, filter_ptid);
+ });
if (event_thread != NULL)
- {
- event_child = get_thread_lwp (event_thread);
- threads_debug_printf ("Got a pending child %ld", lwpid_of (event_thread));
- }
+ {
+ event_child = get_thread_lwp (event_thread);
+ threads_debug_printf ("Got a pending child %ld",
+ lwpid_of (event_thread));
+ }
}
else if (filter_ptid != null_ptid)
{
requested_child = find_lwp_pid (filter_ptid);
if (stopping_threads == NOT_STOPPING_THREADS
- && requested_child->status_pending_p
- && (requested_child->collecting_fast_tracepoint
- != fast_tpoint_collect_result::not_collecting))
- {
- enqueue_one_deferred_signal (requested_child,
- &requested_child->status_pending);
- requested_child->status_pending_p = 0;
- requested_child->status_pending = 0;
- resume_one_lwp (requested_child, 0, 0, NULL);
- }
-
- if (requested_child->suspended
- && requested_child->status_pending_p)
- {
- internal_error ("requesting an event out of a"
- " suspended child?");
- }
+ && requested_child->status_pending_p
+ && (requested_child->collecting_fast_tracepoint
+ != fast_tpoint_collect_result::not_collecting))
+ {
+ enqueue_one_deferred_signal (requested_child,
+ &requested_child->status_pending);
+ requested_child->status_pending_p = 0;
+ requested_child->status_pending = 0;
+ resume_one_lwp (requested_child, 0, 0, NULL);
+ }
+
+ if (requested_child->suspended && requested_child->status_pending_p)
+ {
+ internal_error ("requesting an event out of a"
+ " suspended child?");
+ }
if (requested_child->status_pending_p)
- {
- event_child = requested_child;
- event_thread = get_lwp_thread (event_child);
- }
+ {
+ event_child = requested_child;
+ event_thread = get_lwp_thread (event_child);
+ }
}
if (event_child != NULL)
{
threads_debug_printf ("Got an event from pending child %ld (%04x)",
- lwpid_of (event_thread),
- event_child->status_pending);
+ lwpid_of (event_thread),
+ event_child->status_pending);
*wstatp = event_child->status_pending;
event_child->status_pending_p = 0;
@@ -2581,55 +2554,52 @@ linux_process_target::wait_for_event_filtered (ptid_t wait_ptid,
errno = 0;
ret = my_waitpid (-1, wstatp, options | WNOHANG);
- threads_debug_printf ("waitpid(-1, ...) returned %d, %s",
- ret, errno ? safe_strerror (errno) : "ERRNO-OK");
+ threads_debug_printf ("waitpid(-1, ...) returned %d, %s", ret,
+ errno ? safe_strerror (errno) : "ERRNO-OK");
if (ret > 0)
- {
- threads_debug_printf ("waitpid %ld received %s",
- (long) ret, status_to_str (*wstatp).c_str ());
+ {
+ threads_debug_printf ("waitpid %ld received %s", (long) ret,
+ status_to_str (*wstatp).c_str ());
- /* Filter all events. IOW, leave all events pending. We'll
+ /* Filter all events. IOW, leave all events pending. We'll
randomly select an event LWP out of all that have events
below. */
- filter_event (ret, *wstatp);
- /* Retry until nothing comes out of waitpid. A single
+ filter_event (ret, *wstatp);
+ /* Retry until nothing comes out of waitpid. A single
SIGCHLD can indicate more than one child stopped. */
- continue;
- }
+ continue;
+ }
/* Now that we've pulled all events out of the kernel, resume
LWPs that don't have an interesting event to report. */
if (stopping_threads == NOT_STOPPING_THREADS)
- for_each_thread ([this] (thread_info *thread)
- {
- resume_stopped_resumed_lwps (thread);
- });
+ for_each_thread ([this] (thread_info *thread) {
+ resume_stopped_resumed_lwps (thread);
+ });
/* ... and find an LWP with a status to report to the core, if
any. */
- event_thread = find_thread_in_random ([&] (thread_info *thread)
- {
- return status_pending_p_callback (thread, filter_ptid);
- });
+ event_thread = find_thread_in_random ([&] (thread_info *thread) {
+ return status_pending_p_callback (thread, filter_ptid);
+ });
if (event_thread != NULL)
- {
- event_child = get_thread_lwp (event_thread);
- *wstatp = event_child->status_pending;
- event_child->status_pending_p = 0;
- event_child->status_pending = 0;
- break;
- }
+ {
+ event_child = get_thread_lwp (event_thread);
+ *wstatp = event_child->status_pending;
+ event_child->status_pending_p = 0;
+ event_child->status_pending = 0;
+ break;
+ }
/* Check for zombie thread group leaders. Those can't be reaped
until all other threads in the thread group are. */
check_zombie_leaders ();
- auto not_stopped = [&] (thread_info *thread)
- {
- return not_stopped_callback (thread, wait_ptid);
- };
+ auto not_stopped = [&] (thread_info *thread) {
+ return not_stopped_callback (thread, wait_ptid);
+ };
/* If there are no resumed children left in the set of LWPs we
want to wait for, bail. We can't just block in
@@ -2639,21 +2609,21 @@ linux_process_target::wait_for_event_filtered (ptid_t wait_ptid,
them). Even if WNOHANG is set, this return code is preferred
over 0 (below), as it is more detailed. */
if (find_thread (not_stopped) == NULL)
- {
- threads_debug_printf ("exit (no unwaited-for LWP)");
+ {
+ threads_debug_printf ("exit (no unwaited-for LWP)");
- gdb_sigmask (SIG_SETMASK, &prev_mask, NULL);
- return -1;
- }
+ gdb_sigmask (SIG_SETMASK, &prev_mask, NULL);
+ return -1;
+ }
/* No interesting event to report to the caller. */
if ((options & WNOHANG))
- {
- threads_debug_printf ("WNOHANG set, no event found");
+ {
+ threads_debug_printf ("WNOHANG set, no event found");
- gdb_sigmask (SIG_SETMASK, &prev_mask, NULL);
- return 0;
- }
+ gdb_sigmask (SIG_SETMASK, &prev_mask, NULL);
+ return 0;
+ }
/* Block until we get an event reported with SIGCHLD. */
threads_debug_printf ("sigsuspend'ing");
@@ -2693,33 +2663,31 @@ select_event_lwp (struct lwp_info **orig_lp)
would report it to the user as a random signal. */
if (!non_stop)
{
- event_thread = find_thread ([] (thread_info *thread)
- {
- lwp_info *lp = get_thread_lwp (thread);
+ event_thread = find_thread ([] (thread_info *thread) {
+ lwp_info *lp = get_thread_lwp (thread);
- return (thread->last_status.kind () == TARGET_WAITKIND_IGNORE
- && thread->last_resume_kind == resume_step
- && lp->status_pending_p);
- });
+ return (thread->last_status.kind () == TARGET_WAITKIND_IGNORE
+ && thread->last_resume_kind == resume_step
+ && lp->status_pending_p);
+ });
if (event_thread != NULL)
- threads_debug_printf
- ("Select single-step %s",
- target_pid_to_str (ptid_of (event_thread)).c_str ());
+ threads_debug_printf ("Select single-step %s",
+ target_pid_to_str (ptid_of (event_thread))
+ .c_str ());
}
if (event_thread == NULL)
{
/* No single-stepping LWP. Select one at random, out of those
which have had events. */
- event_thread = find_thread_in_random ([&] (thread_info *thread)
- {
- lwp_info *lp = get_thread_lwp (thread);
+ event_thread = find_thread_in_random ([&] (thread_info *thread) {
+ lwp_info *lp = get_thread_lwp (thread);
- /* Only resumed LWPs that have an event pending. */
- return (thread->last_status.kind () == TARGET_WAITKIND_IGNORE
- && lp->status_pending_p);
- });
+ /* Only resumed LWPs that have an event pending. */
+ return (thread->last_status.kind () == TARGET_WAITKIND_IGNORE
+ && lp->status_pending_p);
+ });
}
if (event_thread != NULL)
@@ -2737,13 +2705,12 @@ select_event_lwp (struct lwp_info **orig_lp)
static void
unsuspend_all_lwps (struct lwp_info *except)
{
- for_each_thread ([&] (thread_info *thread)
- {
- lwp_info *lwp = get_thread_lwp (thread);
+ for_each_thread ([&] (thread_info *thread) {
+ lwp_info *lwp = get_thread_lwp (thread);
- if (lwp != except)
- lwp_suspended_decr (lwp);
- });
+ if (lwp != except)
+ lwp_suspended_decr (lwp);
+ });
}
static bool lwp_running (thread_info *thread);
@@ -2781,15 +2748,13 @@ static bool lwp_running (thread_info *thread);
void
linux_process_target::stabilize_threads ()
{
- thread_info *thread_stuck = find_thread ([this] (thread_info *thread)
- {
- return stuck_in_jump_pad (thread);
- });
+ thread_info *thread_stuck = find_thread (
+ [this] (thread_info *thread) { return stuck_in_jump_pad (thread); });
if (thread_stuck != NULL)
{
threads_debug_printf ("can't stabilize, LWP %ld is stuck in jump pad",
- lwpid_of (thread_stuck));
+ lwpid_of (thread_stuck));
return;
}
@@ -2798,10 +2763,8 @@ linux_process_target::stabilize_threads ()
stabilizing_threads = 1;
/* Kick 'em all. */
- for_each_thread ([this] (thread_info *thread)
- {
- move_out_of_jump_pad (thread);
- });
+ for_each_thread (
+ [this] (thread_info *thread) { move_out_of_jump_pad (thread); });
/* Loop until all are stopped out of the jump pads. */
while (find_thread (lwp_running) != NULL)
@@ -2816,19 +2779,19 @@ linux_process_target::stabilize_threads ()
wait_1 (minus_one_ptid, &ourstatus, 0);
if (ourstatus.kind () == TARGET_WAITKIND_STOPPED)
- {
- lwp = get_thread_lwp (current_thread);
+ {
+ lwp = get_thread_lwp (current_thread);
- /* Lock it. */
- lwp_suspended_inc (lwp);
+ /* Lock it. */
+ lwp_suspended_inc (lwp);
- if (ourstatus.sig () != GDB_SIGNAL_0
- || current_thread->last_resume_kind == resume_stop)
- {
- wstat = W_STOPCODE (gdb_signal_to_host (ourstatus.sig ()));
- enqueue_one_deferred_signal (lwp, &wstat);
- }
- }
+ if (ourstatus.sig () != GDB_SIGNAL_0
+ || current_thread->last_resume_kind == resume_stop)
+ {
+ wstat = W_STOPCODE (gdb_signal_to_host (ourstatus.sig ()));
+ enqueue_one_deferred_signal (lwp, &wstat);
+ }
+ }
}
unsuspend_all_lwps (NULL);
@@ -2837,15 +2800,13 @@ linux_process_target::stabilize_threads ()
if (debug_threads)
{
- thread_stuck = find_thread ([this] (thread_info *thread)
- {
- return stuck_in_jump_pad (thread);
- });
+ thread_stuck = find_thread (
+ [this] (thread_info *thread) { return stuck_in_jump_pad (thread); });
if (thread_stuck != NULL)
- threads_debug_printf
- ("couldn't stabilize, LWP %ld got stuck in jump pad",
- lwpid_of (thread_stuck));
+ threads_debug_printf (
+ "couldn't stabilize, LWP %ld got stuck in jump pad",
+ lwpid_of (thread_stuck));
}
}
@@ -2866,7 +2827,7 @@ ignore_event (struct target_waitstatus *ourstatus)
ptid_t
linux_process_target::filter_exit_event (lwp_info *event_child,
- target_waitstatus *ourstatus)
+ target_waitstatus *ourstatus)
{
client_state &cs = get_client_state ();
struct thread_info *thread = get_lwp_thread (event_child);
@@ -2875,9 +2836,9 @@ linux_process_target::filter_exit_event (lwp_info *event_child,
if (!is_leader (thread))
{
if (cs.report_thread_events)
- ourstatus->set_thread_exited (0);
+ ourstatus->set_thread_exited (0);
else
- ourstatus->set_ignore ();
+ ourstatus->set_ignore ();
delete_lwp (event_child);
}
@@ -2919,7 +2880,7 @@ linux_process_target::gdb_catch_this_syscall (lwp_info *event_child)
ptid_t
linux_process_target::wait_1 (ptid_t ptid, target_waitstatus *ourstatus,
- target_wait_flags target_options)
+ target_wait_flags target_options)
{
THREADS_SCOPED_DEBUG_ENTER_EXIT;
@@ -2948,15 +2909,13 @@ linux_process_target::wait_1 (ptid_t ptid, target_waitstatus *ourstatus,
in_step_range = 0;
ourstatus->set_ignore ();
- auto status_pending_p_any = [&] (thread_info *thread)
- {
- return status_pending_p_callback (thread, minus_one_ptid);
- };
+ auto status_pending_p_any = [&] (thread_info *thread) {
+ return status_pending_p_callback (thread, minus_one_ptid);
+ };
- auto not_stopped = [&] (thread_info *thread)
- {
- return not_stopped_callback (thread, minus_one_ptid);
- };
+ auto not_stopped = [&] (thread_info *thread) {
+ return not_stopped_callback (thread, minus_one_ptid);
+ };
/* Find a resumed LWP, if any. */
if (find_thread (status_pending_p_any) != NULL)
@@ -2971,7 +2930,7 @@ linux_process_target::wait_1 (ptid_t ptid, target_waitstatus *ourstatus,
else
{
threads_debug_printf ("step_over_bkpt set [%s], doing a blocking wait",
- target_pid_to_str (step_over_bkpt).c_str ());
+ target_pid_to_str (step_over_bkpt).c_str ());
pid = wait_for_event (step_over_bkpt, &w, options & ~WNOHANG);
}
@@ -2999,26 +2958,26 @@ linux_process_target::wait_1 (ptid_t ptid, target_waitstatus *ourstatus,
if (WIFEXITED (w) || WIFSIGNALED (w))
{
if (WIFEXITED (w))
- {
- ourstatus->set_exited (WEXITSTATUS (w));
-
- threads_debug_printf
- ("ret = %s, exited with retcode %d",
- target_pid_to_str (ptid_of (current_thread)).c_str (),
- WEXITSTATUS (w));
- }
+ {
+ ourstatus->set_exited (WEXITSTATUS (w));
+
+ threads_debug_printf ("ret = %s, exited with retcode %d",
+ target_pid_to_str (ptid_of (current_thread))
+ .c_str (),
+ WEXITSTATUS (w));
+ }
else
- {
- ourstatus->set_signalled (gdb_signal_from_host (WTERMSIG (w)));
+ {
+ ourstatus->set_signalled (gdb_signal_from_host (WTERMSIG (w)));
- threads_debug_printf
- ("ret = %s, terminated with signal %d",
- target_pid_to_str (ptid_of (current_thread)).c_str (),
- WTERMSIG (w));
- }
+ threads_debug_printf ("ret = %s, terminated with signal %d",
+ target_pid_to_str (ptid_of (current_thread))
+ .c_str (),
+ WTERMSIG (w));
+ }
if (ourstatus->kind () == TARGET_WAITKIND_EXITED)
- return filter_exit_event (event_child, ourstatus);
+ return filter_exit_event (event_child, ourstatus);
return ptid_of (current_thread);
}
@@ -3037,7 +2996,7 @@ linux_process_target::wait_1 (ptid_t ptid, target_waitstatus *ourstatus,
if (step_over_bkpt != null_ptid
&& event_child->stop_reason == TARGET_STOPPED_BY_SW_BREAKPOINT
&& (event_child->stepping
- || !single_step_breakpoint_inserted_here (event_child->stop_pc)))
+ || !single_step_breakpoint_inserted_here (event_child->stop_pc)))
{
int increment_pc = 0;
int breakpoint_kind = 0;
@@ -3046,21 +3005,20 @@ linux_process_target::wait_1 (ptid_t ptid, target_waitstatus *ourstatus,
breakpoint_kind = breakpoint_kind_from_current_state (&stop_pc);
sw_breakpoint_from_kind (breakpoint_kind, &increment_pc);
- threads_debug_printf
- ("step-over for %s executed software breakpoint",
- target_pid_to_str (ptid_of (current_thread)).c_str ());
+ threads_debug_printf ("step-over for %s executed software breakpoint",
+ target_pid_to_str (ptid_of (current_thread))
+ .c_str ());
if (increment_pc != 0)
- {
- struct regcache *regcache
- = get_thread_regcache (current_thread, 1);
+ {
+ struct regcache *regcache = get_thread_regcache (current_thread, 1);
- event_child->stop_pc += increment_pc;
- low_set_pc (regcache, event_child->stop_pc);
+ event_child->stop_pc += increment_pc;
+ low_set_pc (regcache, event_child->stop_pc);
- if (!low_breakpoint_at (event_child->stop_pc))
- event_child->stop_reason = TARGET_STOPPED_BY_NO_REASON;
- }
+ if (!low_breakpoint_at (event_child->stop_pc))
+ event_child->stop_reason = TARGET_STOPPED_BY_NO_REASON;
+ }
}
/* If this event was not handled before, and is not a SIGTRAP, we
@@ -3071,9 +3029,8 @@ linux_process_target::wait_1 (ptid_t ptid, target_waitstatus *ourstatus,
maybe_internal_trap
= (low_supports_breakpoints ()
&& (WSTOPSIG (w) == SIGTRAP
- || ((WSTOPSIG (w) == SIGILL
- || WSTOPSIG (w) == SIGSEGV)
- && low_breakpoint_at (event_child->stop_pc))));
+ || ((WSTOPSIG (w) == SIGILL || WSTOPSIG (w) == SIGSEGV)
+ && low_breakpoint_at (event_child->stop_pc))));
if (maybe_internal_trap)
{
@@ -3101,7 +3058,7 @@ linux_process_target::wait_1 (ptid_t ptid, target_waitstatus *ourstatus,
trace_event = handle_tracepoints (event_child);
if (bp_explains_trap)
- threads_debug_printf ("Hit a gdbserver breakpoint.");
+ threads_debug_printf ("Hit a gdbserver breakpoint.");
}
else
{
@@ -3117,108 +3074,105 @@ linux_process_target::wait_1 (ptid_t ptid, target_waitstatus *ourstatus,
move out of the jump pad before delivering a signal. See
linux_stabilize_threads. */
- if (WIFSTOPPED (w)
- && WSTOPSIG (w) != SIGTRAP
- && supports_fast_tracepoints ()
+ if (WIFSTOPPED (w) && WSTOPSIG (w) != SIGTRAP && supports_fast_tracepoints ()
&& agent_loaded_p ())
{
threads_debug_printf ("Got signal %d for LWP %ld. Check if we need "
- "to defer or adjust it.",
- WSTOPSIG (w), lwpid_of (current_thread));
+ "to defer or adjust it.",
+ WSTOPSIG (w), lwpid_of (current_thread));
/* Allow debugging the jump pad itself. */
if (current_thread->last_resume_kind != resume_step
- && maybe_move_out_of_jump_pad (event_child, &w))
- {
- enqueue_one_deferred_signal (event_child, &w);
+ && maybe_move_out_of_jump_pad (event_child, &w))
+ {
+ enqueue_one_deferred_signal (event_child, &w);
- threads_debug_printf ("Signal %d for LWP %ld deferred (in jump pad)",
- WSTOPSIG (w), lwpid_of (current_thread));
+ threads_debug_printf ("Signal %d for LWP %ld deferred (in jump pad)",
+ WSTOPSIG (w), lwpid_of (current_thread));
- resume_one_lwp (event_child, 0, 0, NULL);
+ resume_one_lwp (event_child, 0, 0, NULL);
- return ignore_event (ourstatus);
- }
+ return ignore_event (ourstatus);
+ }
}
if (event_child->collecting_fast_tracepoint
!= fast_tpoint_collect_result::not_collecting)
{
- threads_debug_printf
- ("LWP %ld was trying to move out of the jump pad (%d). "
- "Check if we're already there.",
- lwpid_of (current_thread),
- (int) event_child->collecting_fast_tracepoint);
+ threads_debug_printf (
+ "LWP %ld was trying to move out of the jump pad (%d). "
+ "Check if we're already there.",
+ lwpid_of (current_thread),
+ (int) event_child->collecting_fast_tracepoint);
trace_event = 1;
event_child->collecting_fast_tracepoint
- = linux_fast_tracepoint_collecting (event_child, NULL);
+ = linux_fast_tracepoint_collecting (event_child, NULL);
if (event_child->collecting_fast_tracepoint
- != fast_tpoint_collect_result::before_insn)
- {
- /* No longer need this breakpoint. */
- if (event_child->exit_jump_pad_bkpt != NULL)
- {
- threads_debug_printf
- ("No longer need exit-jump-pad bkpt; removing it."
- "stopping all threads momentarily.");
-
- /* Other running threads could hit this breakpoint.
+ != fast_tpoint_collect_result::before_insn)
+ {
+ /* No longer need this breakpoint. */
+ if (event_child->exit_jump_pad_bkpt != NULL)
+ {
+ threads_debug_printf (
+ "No longer need exit-jump-pad bkpt; removing it."
+ "stopping all threads momentarily.");
+
+ /* Other running threads could hit this breakpoint.
We don't handle moribund locations like GDB does,
instead we always pause all threads when removing
breakpoints, so that any step-over or
decr_pc_after_break adjustment is always taken
care of while the breakpoint is still
inserted. */
- stop_all_lwps (1, event_child);
+ stop_all_lwps (1, event_child);
- delete_breakpoint (event_child->exit_jump_pad_bkpt);
- event_child->exit_jump_pad_bkpt = NULL;
+ delete_breakpoint (event_child->exit_jump_pad_bkpt);
+ event_child->exit_jump_pad_bkpt = NULL;
- unstop_all_lwps (1, event_child);
+ unstop_all_lwps (1, event_child);
- gdb_assert (event_child->suspended >= 0);
- }
- }
+ gdb_assert (event_child->suspended >= 0);
+ }
+ }
if (event_child->collecting_fast_tracepoint
- == fast_tpoint_collect_result::not_collecting)
- {
- threads_debug_printf
- ("fast tracepoint finished collecting successfully.");
+ == fast_tpoint_collect_result::not_collecting)
+ {
+ threads_debug_printf (
+ "fast tracepoint finished collecting successfully.");
- /* We may have a deferred signal to report. */
- if (dequeue_one_deferred_signal (event_child, &w))
- threads_debug_printf ("dequeued one signal.");
- else
- {
- threads_debug_printf ("no deferred signals.");
+ /* We may have a deferred signal to report. */
+ if (dequeue_one_deferred_signal (event_child, &w))
+ threads_debug_printf ("dequeued one signal.");
+ else
+ {
+ threads_debug_printf ("no deferred signals.");
- if (stabilizing_threads)
- {
- ourstatus->set_stopped (GDB_SIGNAL_0);
+ if (stabilizing_threads)
+ {
+ ourstatus->set_stopped (GDB_SIGNAL_0);
- threads_debug_printf
- ("ret = %s, stopped while stabilizing threads",
- target_pid_to_str (ptid_of (current_thread)).c_str ());
+ threads_debug_printf (
+ "ret = %s, stopped while stabilizing threads",
+ target_pid_to_str (ptid_of (current_thread)).c_str ());
- return ptid_of (current_thread);
- }
- }
- }
+ return ptid_of (current_thread);
+ }
+ }
+ }
}
/* Check whether GDB would be interested in this event. */
/* Check if GDB is interested in this syscall. */
- if (WIFSTOPPED (w)
- && WSTOPSIG (w) == SYSCALL_SIGTRAP
+ if (WIFSTOPPED (w) && WSTOPSIG (w) == SYSCALL_SIGTRAP
&& !gdb_catch_this_syscall (event_child))
{
threads_debug_printf ("Ignored syscall for LWP %ld.",
- lwpid_of (current_thread));
+ lwpid_of (current_thread));
resume_one_lwp (event_child, event_child->stepping, 0, NULL);
@@ -3233,49 +3187,48 @@ linux_process_target::wait_1 (ptid_t ptid, target_waitstatus *ourstatus,
stepping - they may require special handling to skip the signal
handler. Also never ignore signals that could be caused by a
breakpoint. */
- if (WIFSTOPPED (w)
- && current_thread->last_resume_kind != resume_step
+ if (WIFSTOPPED (w) && current_thread->last_resume_kind != resume_step
&& (
-#if defined (USE_THREAD_DB) && !defined (__ANDROID__)
- (current_process ()->priv->thread_db != NULL
- && (WSTOPSIG (w) == __SIGRTMIN
- || WSTOPSIG (w) == __SIGRTMIN + 1))
- ||
+#if defined(USE_THREAD_DB) && !defined(__ANDROID__)
+ (current_process ()->priv->thread_db != NULL
+ && (WSTOPSIG (w) == __SIGRTMIN || WSTOPSIG (w) == __SIGRTMIN + 1))
+ ||
#endif
- (cs.pass_signals[gdb_signal_from_host (WSTOPSIG (w))]
- && !(WSTOPSIG (w) == SIGSTOP
- && current_thread->last_resume_kind == resume_stop)
- && !linux_wstatus_maybe_breakpoint (w))))
+ (cs.pass_signals[gdb_signal_from_host (WSTOPSIG (w))]
+ && !(WSTOPSIG (w) == SIGSTOP
+ && current_thread->last_resume_kind == resume_stop)
+ && !linux_wstatus_maybe_breakpoint (w))))
{
siginfo_t info, *info_p;
- threads_debug_printf ("Ignored signal %d for LWP %ld.",
- WSTOPSIG (w), lwpid_of (current_thread));
+ threads_debug_printf ("Ignored signal %d for LWP %ld.", WSTOPSIG (w),
+ lwpid_of (current_thread));
if (ptrace (PTRACE_GETSIGINFO, lwpid_of (current_thread),
- (PTRACE_TYPE_ARG3) 0, &info) == 0)
- info_p = &info;
+ (PTRACE_TYPE_ARG3) 0, &info)
+ == 0)
+ info_p = &info;
else
- info_p = NULL;
+ info_p = NULL;
if (step_over_finished)
- {
- /* We cancelled this thread's step-over above. We still
+ {
+ /* We cancelled this thread's step-over above. We still
need to unsuspend all other LWPs, and set them back
running again while the signal handler runs. */
- unsuspend_all_lwps (event_child);
+ unsuspend_all_lwps (event_child);
- /* Enqueue the pending signal info so that proceed_all_lwps
+ /* Enqueue the pending signal info so that proceed_all_lwps
doesn't lose it. */
- enqueue_pending_signal (event_child, WSTOPSIG (w), info_p);
+ enqueue_pending_signal (event_child, WSTOPSIG (w), info_p);
- proceed_all_lwps ();
- }
+ proceed_all_lwps ();
+ }
else
- {
- resume_one_lwp (event_child, event_child->stepping,
- WSTOPSIG (w), info_p);
- }
+ {
+ resume_one_lwp (event_child, event_child->stepping, WSTOPSIG (w),
+ info_p);
+ }
return ignore_event (ourstatus);
}
@@ -3297,20 +3250,18 @@ linux_process_target::wait_1 (ptid_t ptid, target_waitstatus *ourstatus,
That indicates that we had previously finished a single-step but
left the single-step pending -- see
complete_ongoing_step_over. */
- report_to_gdb = (!maybe_internal_trap
- || (current_thread->last_resume_kind == resume_step
- && !in_step_range)
- || event_child->stop_reason == TARGET_STOPPED_BY_WATCHPOINT
- || (!in_step_range
- && !bp_explains_trap
- && !trace_event
- && !step_over_finished
- && !(current_thread->last_resume_kind == resume_continue
- && event_child->stop_reason == TARGET_STOPPED_BY_SINGLE_STEP))
- || (gdb_breakpoint_here (event_child->stop_pc)
- && gdb_condition_true_at_breakpoint (event_child->stop_pc)
- && gdb_no_commands_at_breakpoint (event_child->stop_pc))
- || event_child->waitstatus.kind () != TARGET_WAITKIND_IGNORE);
+ report_to_gdb
+ = (!maybe_internal_trap
+ || (current_thread->last_resume_kind == resume_step && !in_step_range)
+ || event_child->stop_reason == TARGET_STOPPED_BY_WATCHPOINT
+ || (!in_step_range && !bp_explains_trap && !trace_event
+ && !step_over_finished
+ && !(current_thread->last_resume_kind == resume_continue
+ && event_child->stop_reason == TARGET_STOPPED_BY_SINGLE_STEP))
+ || (gdb_breakpoint_here (event_child->stop_pc)
+ && gdb_condition_true_at_breakpoint (event_child->stop_pc)
+ && gdb_no_commands_at_breakpoint (event_child->stop_pc))
+ || event_child->waitstatus.kind () != TARGET_WAITKIND_IGNORE);
run_breakpoint_commands (event_child->stop_pc);
@@ -3320,53 +3271,52 @@ linux_process_target::wait_1 (ptid_t ptid, target_waitstatus *ourstatus,
if (!report_to_gdb)
{
if (bp_explains_trap)
- threads_debug_printf ("Hit a gdbserver breakpoint.");
+ threads_debug_printf ("Hit a gdbserver breakpoint.");
if (step_over_finished)
- threads_debug_printf ("Step-over finished.");
+ threads_debug_printf ("Step-over finished.");
if (trace_event)
- threads_debug_printf ("Tracepoint event.");
+ threads_debug_printf ("Tracepoint event.");
if (lwp_in_step_range (event_child))
- threads_debug_printf ("Range stepping pc 0x%s [0x%s, 0x%s).",
- paddress (event_child->stop_pc),
- paddress (event_child->step_range_start),
- paddress (event_child->step_range_end));
+ threads_debug_printf ("Range stepping pc 0x%s [0x%s, 0x%s).",
+ paddress (event_child->stop_pc),
+ paddress (event_child->step_range_start),
+ paddress (event_child->step_range_end));
/* We're not reporting this breakpoint to GDB, so apply the
decr_pc_after_break adjustment to the inferior's regcache
ourselves. */
if (low_supports_breakpoints ())
- {
- struct regcache *regcache
- = get_thread_regcache (current_thread, 1);
- low_set_pc (regcache, event_child->stop_pc);
- }
+ {
+ struct regcache *regcache = get_thread_regcache (current_thread, 1);
+ low_set_pc (regcache, event_child->stop_pc);
+ }
if (step_over_finished)
- {
- /* If we have finished stepping over a breakpoint, we've
+ {
+ /* If we have finished stepping over a breakpoint, we've
stopped and suspended all LWPs momentarily except the
stepping one. This is where we resume them all again.
We're going to keep waiting, so use proceed, which
handles stepping over the next breakpoint. */
- unsuspend_all_lwps (event_child);
- }
+ unsuspend_all_lwps (event_child);
+ }
else
- {
- /* Remove the single-step breakpoints if any. Note that
+ {
+ /* Remove the single-step breakpoints if any. Note that
there isn't single-step breakpoint if we finished stepping
over. */
- if (supports_software_single_step ()
- && has_single_step_breakpoints (current_thread))
- {
- stop_all_lwps (0, event_child);
- delete_single_step_breakpoints (current_thread);
- unstop_all_lwps (0, event_child);
- }
- }
+ if (supports_software_single_step ()
+ && has_single_step_breakpoints (current_thread))
+ {
+ stop_all_lwps (0, event_child);
+ delete_single_step_breakpoints (current_thread);
+ unstop_all_lwps (0, event_child);
+ }
+ }
threads_debug_printf ("proceeding all threads.");
@@ -3375,29 +3325,29 @@ linux_process_target::wait_1 (ptid_t ptid, target_waitstatus *ourstatus,
return ignore_event (ourstatus);
}
- if (debug_threads)
- {
- if (event_child->waitstatus.kind () != TARGET_WAITKIND_IGNORE)
- threads_debug_printf ("LWP %ld: extended event with waitstatus %s",
- lwpid_of (get_lwp_thread (event_child)),
- event_child->waitstatus.to_string ().c_str ());
-
- if (current_thread->last_resume_kind == resume_step)
- {
- if (event_child->step_range_start == event_child->step_range_end)
- threads_debug_printf
- ("GDB wanted to single-step, reporting event.");
- else if (!lwp_in_step_range (event_child))
- threads_debug_printf ("Out of step range, reporting event.");
- }
-
- if (event_child->stop_reason == TARGET_STOPPED_BY_WATCHPOINT)
- threads_debug_printf ("Stopped by watchpoint.");
- else if (gdb_breakpoint_here (event_child->stop_pc))
- threads_debug_printf ("Stopped by GDB breakpoint.");
- }
+ if (debug_threads)
+ {
+ if (event_child->waitstatus.kind () != TARGET_WAITKIND_IGNORE)
+ threads_debug_printf ("LWP %ld: extended event with waitstatus %s",
+ lwpid_of (get_lwp_thread (event_child)),
+ event_child->waitstatus.to_string ().c_str ());
+
+ if (current_thread->last_resume_kind == resume_step)
+ {
+ if (event_child->step_range_start == event_child->step_range_end)
+ threads_debug_printf (
+ "GDB wanted to single-step, reporting event.");
+ else if (!lwp_in_step_range (event_child))
+ threads_debug_printf ("Out of step range, reporting event.");
+ }
+
+ if (event_child->stop_reason == TARGET_STOPPED_BY_WATCHPOINT)
+ threads_debug_printf ("Stopped by watchpoint.");
+ else if (gdb_breakpoint_here (event_child->stop_pc))
+ threads_debug_printf ("Stopped by GDB breakpoint.");
+ }
- threads_debug_printf ("Hit a non-gdbserver trap event.");
+ threads_debug_printf ("Hit a non-gdbserver trap event.");
/* Alright, we're going to report a stop. */
@@ -3410,102 +3360,101 @@ linux_process_target::wait_1 (ptid_t ptid, target_waitstatus *ourstatus,
int remove_single_step_breakpoints_p = 0;
if (non_stop)
- {
- remove_single_step_breakpoints_p
- = has_single_step_breakpoints (current_thread);
- }
+ {
+ remove_single_step_breakpoints_p
+ = has_single_step_breakpoints (current_thread);
+ }
else
- {
- /* In all-stop, a stop reply cancels all previous resume
+ {
+ /* In all-stop, a stop reply cancels all previous resume
requests. Delete all single-step breakpoints. */
- find_thread ([&] (thread_info *thread) {
- if (has_single_step_breakpoints (thread))
- {
- remove_single_step_breakpoints_p = 1;
- return true;
- }
+ find_thread ([&] (thread_info *thread) {
+ if (has_single_step_breakpoints (thread))
+ {
+ remove_single_step_breakpoints_p = 1;
+ return true;
+ }
- return false;
- });
- }
+ return false;
+ });
+ }
if (remove_single_step_breakpoints_p)
- {
- /* If we remove single-step breakpoints from memory, stop all lwps,
+ {
+ /* If we remove single-step breakpoints from memory, stop all lwps,
so that other threads won't hit the breakpoint in the staled
memory. */
- stop_all_lwps (0, event_child);
+ stop_all_lwps (0, event_child);
- if (non_stop)
- {
- gdb_assert (has_single_step_breakpoints (current_thread));
- delete_single_step_breakpoints (current_thread);
- }
- else
- {
- for_each_thread ([] (thread_info *thread){
- if (has_single_step_breakpoints (thread))
- delete_single_step_breakpoints (thread);
- });
- }
+ if (non_stop)
+ {
+ gdb_assert (has_single_step_breakpoints (current_thread));
+ delete_single_step_breakpoints (current_thread);
+ }
+ else
+ {
+ for_each_thread ([] (thread_info *thread) {
+ if (has_single_step_breakpoints (thread))
+ delete_single_step_breakpoints (thread);
+ });
+ }
- unstop_all_lwps (0, event_child);
- }
+ unstop_all_lwps (0, event_child);
+ }
}
if (!stabilizing_threads)
{
/* In all-stop, stop all threads. */
if (!non_stop)
- stop_all_lwps (0, NULL);
+ stop_all_lwps (0, NULL);
if (step_over_finished)
- {
- if (!non_stop)
- {
- /* If we were doing a step-over, all other threads but
+ {
+ if (!non_stop)
+ {
+ /* If we were doing a step-over, all other threads but
the stepping one had been paused in start_step_over,
with their suspend counts incremented. We don't want
to do a full unstop/unpause, because we're in
all-stop mode (so we want threads stopped), but we
still need to unsuspend the other threads, to
decrement their `suspended' count back. */
- unsuspend_all_lwps (event_child);
- }
- else
- {
- /* If we just finished a step-over, then all threads had
+ unsuspend_all_lwps (event_child);
+ }
+ else
+ {
+ /* If we just finished a step-over, then all threads had
been momentarily paused. In all-stop, that's fine,
we want threads stopped by now anyway. In non-stop,
we need to re-resume threads that GDB wanted to be
running. */
- unstop_all_lwps (1, event_child);
- }
- }
+ unstop_all_lwps (1, event_child);
+ }
+ }
/* If we're not waiting for a specific LWP, choose an event LWP
from among those that have had events. Giving equal priority
to all LWPs that have had events helps prevent
starvation. */
if (ptid == minus_one_ptid)
- {
- event_child->status_pending_p = 1;
- event_child->status_pending = w;
+ {
+ event_child->status_pending_p = 1;
+ event_child->status_pending = w;
- select_event_lwp (&event_child);
+ select_event_lwp (&event_child);
- /* current_thread and event_child must stay in sync. */
- switch_to_thread (get_lwp_thread (event_child));
-
- event_child->status_pending_p = 0;
- w = event_child->status_pending;
- }
+ /* current_thread and event_child must stay in sync. */
+ switch_to_thread (get_lwp_thread (event_child));
+ event_child->status_pending_p = 0;
+ w = event_child->status_pending;
+ }
/* Stabilize threads (move out of jump pads). */
if (!non_stop)
- target_stabilize_threads ();
+ target_stabilize_threads ();
}
else
{
@@ -3514,7 +3463,7 @@ linux_process_target::wait_1 (ptid_t ptid, target_waitstatus *ourstatus,
threads stopped by now anyway. In non-stop, we need to
re-resume threads that GDB wanted to be running. */
if (step_over_finished)
- unstop_all_lwps (1, event_child);
+ unstop_all_lwps (1, event_child);
}
/* At this point, we haven't set OURSTATUS. This is where we do it. */
@@ -3527,11 +3476,11 @@ linux_process_target::wait_1 (ptid_t ptid, target_waitstatus *ourstatus,
/* Break the unreported fork relationship chain. */
if (event_child->waitstatus.kind () == TARGET_WAITKIND_FORKED
- || event_child->waitstatus.kind () == TARGET_WAITKIND_VFORKED)
- {
- event_child->fork_relative->fork_relative = NULL;
- event_child->fork_relative = NULL;
- }
+ || event_child->waitstatus.kind () == TARGET_WAITKIND_VFORKED)
+ {
+ event_child->fork_relative->fork_relative = NULL;
+ event_child->fork_relative = NULL;
+ }
*ourstatus = event_child->waitstatus;
/* Clear the event lwp's waitstatus since we handled it already. */
@@ -3543,27 +3492,28 @@ linux_process_target::wait_1 (ptid_t ptid, target_waitstatus *ourstatus,
event_chid->waitstatus wasn't filled in with the details, so look at
the wait status W. */
if (WSTOPSIG (w) == SYSCALL_SIGTRAP)
- {
- int syscall_number;
-
- get_syscall_trapinfo (event_child, &syscall_number);
- if (event_child->syscall_state == TARGET_WAITKIND_SYSCALL_ENTRY)
- ourstatus->set_syscall_entry (syscall_number);
- else if (event_child->syscall_state == TARGET_WAITKIND_SYSCALL_RETURN)
- ourstatus->set_syscall_return (syscall_number);
- else
- gdb_assert_not_reached ("unexpected syscall state");
- }
+ {
+ int syscall_number;
+
+ get_syscall_trapinfo (event_child, &syscall_number);
+ if (event_child->syscall_state == TARGET_WAITKIND_SYSCALL_ENTRY)
+ ourstatus->set_syscall_entry (syscall_number);
+ else if (event_child->syscall_state
+ == TARGET_WAITKIND_SYSCALL_RETURN)
+ ourstatus->set_syscall_return (syscall_number);
+ else
+ gdb_assert_not_reached ("unexpected syscall state");
+ }
else if (current_thread->last_resume_kind == resume_stop
- && WSTOPSIG (w) == SIGSTOP)
- {
- /* A thread that has been requested to stop by GDB with vCont;t,
+ && WSTOPSIG (w) == SIGSTOP)
+ {
+ /* A thread that has been requested to stop by GDB with vCont;t,
and it stopped cleanly, so report as SIG0. The use of
SIGSTOP is an implementation detail. */
- ourstatus->set_stopped (GDB_SIGNAL_0);
- }
+ ourstatus->set_stopped (GDB_SIGNAL_0);
+ }
else
- ourstatus->set_stopped (gdb_signal_from_host (WSTOPSIG (w)));
+ ourstatus->set_stopped (gdb_signal_from_host (WSTOPSIG (w)));
}
/* Now that we've selected our final event LWP, un-adjust its PC if
@@ -3575,18 +3525,17 @@ linux_process_target::wait_1 (ptid_t ptid, target_waitstatus *ourstatus,
int decr_pc = low_decr_pc_after_break ();
if (decr_pc != 0)
- {
- struct regcache *regcache
- = get_thread_regcache (current_thread, 1);
- low_set_pc (regcache, event_child->stop_pc + decr_pc);
- }
+ {
+ struct regcache *regcache = get_thread_regcache (current_thread, 1);
+ low_set_pc (regcache, event_child->stop_pc + decr_pc);
+ }
}
gdb_assert (step_over_bkpt == null_ptid);
threads_debug_printf ("ret = %s, %s",
- target_pid_to_str (ptid_of (current_thread)).c_str (),
- ourstatus->to_string ().c_str ());
+ target_pid_to_str (ptid_of (current_thread)).c_str (),
+ ourstatus->to_string ().c_str ());
if (ourstatus->kind () == TARGET_WAITKIND_EXITED)
return filter_exit_event (event_child, ourstatus);
@@ -3609,9 +3558,8 @@ async_file_mark (void)
}
ptid_t
-linux_process_target::wait (ptid_t ptid,
- target_waitstatus *ourstatus,
- target_wait_flags target_options)
+linux_process_target::wait (ptid_t ptid, target_waitstatus *ourstatus,
+ target_wait_flags target_options)
{
ptid_t event_ptid;
@@ -3623,14 +3571,12 @@ linux_process_target::wait (ptid_t ptid,
{
event_ptid = wait_1 (ptid, ourstatus, target_options);
}
- while ((target_options & TARGET_WNOHANG) == 0
- && event_ptid == null_ptid
- && ourstatus->kind () == TARGET_WAITKIND_IGNORE);
+ while ((target_options & TARGET_WNOHANG) == 0 && event_ptid == null_ptid
+ && ourstatus->kind () == TARGET_WAITKIND_IGNORE);
/* If at least one stop was reported, there may be more. A single
SIGCHLD can signal more than one child stop. */
- if (target_is_async_p ()
- && (target_options & TARGET_WNOHANG) != 0
+ if (target_is_async_p () && (target_options & TARGET_WNOHANG) != 0
&& event_ptid != null_ptid)
async_file_mark ();
@@ -3741,9 +3687,9 @@ mark_lwp_dead (struct lwp_info *lwp, int wstat)
static int
lwp_is_marked_dead (struct lwp_info *lwp)
{
- return (lwp->status_pending_p
- && (WIFEXITED (lwp->status_pending)
- || WIFSIGNALED (lwp->status_pending)));
+ return (
+ lwp->status_pending_p
+ && (WIFEXITED (lwp->status_pending) || WIFSIGNALED (lwp->status_pending)));
}
void
@@ -3792,18 +3738,17 @@ linux_process_target::stuck_in_jump_pad (thread_info *thread)
if (lwp->suspended != 0)
{
internal_error ("LWP %ld is suspended, suspended=%d\n",
- lwpid_of (thread), lwp->suspended);
+ lwpid_of (thread), lwp->suspended);
}
gdb_assert (lwp->stopped);
/* Allow debugging the jump pad, gdb_collect, etc.. */
- return (supports_fast_tracepoints ()
- && agent_loaded_p ()
- && (gdb_breakpoint_here (lwp->stop_pc)
- || lwp->stop_reason == TARGET_STOPPED_BY_WATCHPOINT
- || thread->last_resume_kind == resume_step)
- && (linux_fast_tracepoint_collecting (lwp, NULL)
- != fast_tpoint_collect_result::not_collecting));
+ return (supports_fast_tracepoints () && agent_loaded_p ()
+ && (gdb_breakpoint_here (lwp->stop_pc)
+ || lwp->stop_reason == TARGET_STOPPED_BY_WATCHPOINT
+ || thread->last_resume_kind == resume_step)
+ && (linux_fast_tracepoint_collecting (lwp, NULL)
+ != fast_tpoint_collect_result::not_collecting));
}
void
@@ -3815,7 +3760,7 @@ linux_process_target::move_out_of_jump_pad (thread_info *thread)
if (lwp->suspended != 0)
{
internal_error ("LWP %ld is suspended, suspended=%d\n",
- lwpid_of (thread), lwp->suspended);
+ lwpid_of (thread), lwp->suspended);
}
gdb_assert (lwp->stopped);
@@ -3832,16 +3777,16 @@ linux_process_target::move_out_of_jump_pad (thread_info *thread)
&& maybe_move_out_of_jump_pad (lwp, wstat))
{
threads_debug_printf ("LWP %ld needs stabilizing (in jump pad)",
- lwpid_of (thread));
+ lwpid_of (thread));
if (wstat)
- {
- lwp->status_pending_p = 0;
- enqueue_one_deferred_signal (lwp, wstat);
+ {
+ lwp->status_pending_p = 0;
+ enqueue_one_deferred_signal (lwp, wstat);
- threads_debug_printf ("Signal %d for LWP %ld deferred (in jump pad",
- WSTOPSIG (*wstat), lwpid_of (thread));
- }
+ threads_debug_printf ("Signal %d for LWP %ld deferred (in jump pad",
+ WSTOPSIG (*wstat), lwpid_of (thread));
+ }
resume_one_lwp (lwp, 0, 0, NULL);
}
@@ -3868,26 +3813,22 @@ linux_process_target::stop_all_lwps (int suspend, lwp_info *except)
THREADS_SCOPED_DEBUG_ENTER_EXIT;
- threads_debug_printf
- ("%s, except=%s", suspend ? "stop-and-suspend" : "stop",
- (except != NULL
- ? target_pid_to_str (ptid_of (get_lwp_thread (except))).c_str ()
- : "none"));
+ threads_debug_printf (
+ "%s, except=%s", suspend ? "stop-and-suspend" : "stop",
+ (except != NULL
+ ? target_pid_to_str (ptid_of (get_lwp_thread (except))).c_str ()
+ : "none"));
- stopping_threads = (suspend
- ? STOPPING_AND_SUSPENDING_THREADS
- : STOPPING_THREADS);
+ stopping_threads
+ = (suspend ? STOPPING_AND_SUSPENDING_THREADS : STOPPING_THREADS);
if (suspend)
- for_each_thread ([&] (thread_info *thread)
- {
- suspend_and_send_sigstop (thread, except);
- });
+ for_each_thread ([&] (thread_info *thread) {
+ suspend_and_send_sigstop (thread, except);
+ });
else
- for_each_thread ([&] (thread_info *thread)
- {
- send_sigstop (thread, except);
- });
+ for_each_thread (
+ [&] (thread_info *thread) { send_sigstop (thread, except); });
wait_for_sigstop ();
stopping_threads = NOT_STOPPING_THREADS;
@@ -3924,7 +3865,7 @@ linux_process_target::install_software_single_step_breakpoints (lwp_info *lwp)
}
int
-linux_process_target::single_step (lwp_info* lwp)
+linux_process_target::single_step (lwp_info *lwp)
{
int step = 0;
@@ -3953,12 +3894,12 @@ static int
lwp_signal_can_be_delivered (struct lwp_info *lwp)
{
return (lwp->collecting_fast_tracepoint
- == fast_tpoint_collect_result::not_collecting);
+ == fast_tpoint_collect_result::not_collecting);
}
void
linux_process_target::resume_one_lwp_throw (lwp_info *lwp, int step,
- int signal, siginfo_t *info)
+ int signal, siginfo_t *info)
{
struct thread_info *thread = get_lwp_thread (lwp);
int ptrace_request;
@@ -3979,9 +3920,9 @@ linux_process_target::resume_one_lwp_throw (lwp_info *lwp, int step,
fast_tpoint_collect_result fast_tp_collecting
= lwp->collecting_fast_tracepoint;
- gdb_assert (!stabilizing_threads
- || (fast_tp_collecting
- != fast_tpoint_collect_result::not_collecting));
+ gdb_assert (
+ !stabilizing_threads
+ || (fast_tp_collecting != fast_tpoint_collect_result::not_collecting));
/* Cancel actions that rely on GDB not changing the PC (e.g., the
user used the "jump" command, or "set $pc = foo"). */
@@ -3996,9 +3937,8 @@ linux_process_target::resume_one_lwp_throw (lwp_info *lwp, int step,
signal. Also enqueue the signal if it can't be delivered to the
inferior right now. */
if (signal != 0
- && (lwp->status_pending_p
- || !lwp->pending_signals.empty ()
- || !lwp_signal_can_be_delivered (lwp)))
+ && (lwp->status_pending_p || !lwp->pending_signals.empty ()
+ || !lwp_signal_can_be_delivered (lwp)))
{
enqueue_pending_signal (lwp, signal, info);
@@ -4008,10 +3948,10 @@ linux_process_target::resume_one_lwp_throw (lwp_info *lwp, int step,
if (lwp->status_pending_p)
{
- threads_debug_printf
- ("Not resuming lwp %ld (%s, stop %s); has pending status",
- lwpid_of (thread), step ? "step" : "continue",
- lwp->stop_expected ? "expected" : "not expected");
+ threads_debug_printf (
+ "Not resuming lwp %ld (%s, stop %s); has pending status",
+ lwpid_of (thread), step ? "step" : "continue",
+ lwp->stop_expected ? "expected" : "not expected");
return;
}
@@ -4031,41 +3971,42 @@ linux_process_target::resume_one_lwp_throw (lwp_info *lwp, int step,
if (lwp->bp_reinsert != 0)
{
threads_debug_printf (" pending reinsert at 0x%s",
- paddress (lwp->bp_reinsert));
+ paddress (lwp->bp_reinsert));
if (supports_hardware_single_step ())
- {
- if (fast_tp_collecting == fast_tpoint_collect_result::not_collecting)
- {
- if (step == 0)
- warning ("BAD - reinserting but not stepping.");
- if (lwp->suspended)
- warning ("BAD - reinserting and suspended(%d).",
- lwp->suspended);
- }
- }
+ {
+ if (fast_tp_collecting == fast_tpoint_collect_result::not_collecting)
+ {
+ if (step == 0)
+ warning ("BAD - reinserting but not stepping.");
+ if (lwp->suspended)
+ warning ("BAD - reinserting and suspended(%d).",
+ lwp->suspended);
+ }
+ }
step = maybe_hw_step (thread);
}
if (fast_tp_collecting == fast_tpoint_collect_result::before_insn)
- threads_debug_printf
- ("lwp %ld wants to get out of fast tracepoint jump pad "
- "(exit-jump-pad-bkpt)", lwpid_of (thread));
+ threads_debug_printf (
+ "lwp %ld wants to get out of fast tracepoint jump pad "
+ "(exit-jump-pad-bkpt)",
+ lwpid_of (thread));
else if (fast_tp_collecting == fast_tpoint_collect_result::at_insn)
{
- threads_debug_printf
- ("lwp %ld wants to get out of fast tracepoint jump pad single-stepping",
- lwpid_of (thread));
+ threads_debug_printf (
+ "lwp %ld wants to get out of fast tracepoint jump pad single-stepping",
+ lwpid_of (thread));
if (supports_hardware_single_step ())
- step = 1;
+ step = 1;
else
- {
- internal_error ("moving out of jump pad single-stepping"
- " not implemented on this target");
- }
+ {
+ internal_error ("moving out of jump pad single-stepping"
+ " not implemented on this target");
+ }
}
/* If we have while-stepping actions in this thread set it stepping.
@@ -4078,9 +4019,9 @@ linux_process_target::resume_one_lwp_throw (lwp_info *lwp, int step,
enhancement. */
if (thread->while_stepping != NULL)
{
- threads_debug_printf
- ("lwp %ld has a while-stepping action -> forcing step.",
- lwpid_of (thread));
+ threads_debug_printf (
+ "lwp %ld has a while-stepping action -> forcing step.",
+ lwpid_of (thread));
step = single_step (lwp);
}
@@ -4092,7 +4033,7 @@ linux_process_target::resume_one_lwp_throw (lwp_info *lwp, int step,
lwp->stop_pc = low_get_pc (regcache);
threads_debug_printf (" %s from pc 0x%lx", step ? "step" : "continue",
- (long) lwp->stop_pc);
+ (long) lwp->stop_pc);
}
/* If we have pending signals, consume one if it can be delivered to
@@ -4103,15 +4044,15 @@ linux_process_target::resume_one_lwp_throw (lwp_info *lwp, int step,
signal = p_sig.signal;
if (p_sig.info.si_signo != 0)
- ptrace (PTRACE_SETSIGINFO, lwpid_of (thread), (PTRACE_TYPE_ARG3) 0,
- &p_sig.info);
+ ptrace (PTRACE_SETSIGINFO, lwpid_of (thread), (PTRACE_TYPE_ARG3) 0,
+ &p_sig.info);
lwp->pending_signals.pop_front ();
}
threads_debug_printf ("Resuming lwp %ld (%s, signal %d, stop %s)",
- lwpid_of (thread), step ? "step" : "continue", signal,
- lwp->stop_expected ? "expected" : "not expected");
+ lwpid_of (thread), step ? "step" : "continue", signal,
+ lwp->stop_expected ? "expected" : "not expected");
low_prepare_to_resume (lwp);
@@ -4124,19 +4065,17 @@ linux_process_target::resume_one_lwp_throw (lwp_info *lwp, int step,
ptrace_request = PTRACE_SYSCALL;
else
ptrace_request = PTRACE_CONT;
- ptrace (ptrace_request,
- lwpid_of (thread),
- (PTRACE_TYPE_ARG3) 0,
- /* Coerce to a uintptr_t first to avoid potential gcc warning
+ ptrace (ptrace_request, lwpid_of (thread), (PTRACE_TYPE_ARG3) 0,
+ /* Coerce to a uintptr_t first to avoid potential gcc warning
of coercing an 8 byte integer to a 4 byte pointer. */
- (PTRACE_TYPE_ARG4) (uintptr_t) signal);
+ (PTRACE_TYPE_ARG4) (uintptr_t) signal);
if (errno)
{
int saved_errno = errno;
- threads_debug_printf ("ptrace errno = %d (%s)",
- saved_errno, strerror (saved_errno));
+ threads_debug_printf ("ptrace errno = %d (%s)", saved_errno,
+ strerror (saved_errno));
errno = saved_errno;
perror_with_name ("resuming thread");
@@ -4193,7 +4132,7 @@ check_ptrace_stopped_lwp_gone (struct lwp_info *lp)
void
linux_process_target::resume_one_lwp (lwp_info *lwp, int step, int signal,
- siginfo_t *info)
+ siginfo_t *info)
{
try
{
@@ -4202,15 +4141,15 @@ linux_process_target::resume_one_lwp (lwp_info *lwp, int step, int signal,
catch (const gdb_exception_error &ex)
{
if (check_ptrace_stopped_lwp_gone (lwp))
- {
- /* This could because we tried to resume an LWP after its leader
+ {
+ /* This could because we tried to resume an LWP after its leader
exited. Mark it as resumed, so we can collect an exit event
from it. */
- lwp->stopped = 0;
- lwp->stop_reason = TARGET_STOPPED_BY_NO_REASON;
- }
+ lwp->stopped = 0;
+ lwp->stop_reason = TARGET_STOPPED_BY_NO_REASON;
+ }
else
- throw;
+ throw;
}
}
@@ -4231,91 +4170,89 @@ linux_set_resume_request (thread_info *thread, thread_resume *resume, size_t n)
{
ptid_t ptid = resume[ndx].thread;
if (ptid == minus_one_ptid
- || ptid == thread->id
- /* Handle both 'pPID' and 'pPID.-1' as meaning 'all threads
+ || ptid == thread->id
+ /* Handle both 'pPID' and 'pPID.-1' as meaning 'all threads
of PID'. */
- || (ptid.pid () == pid_of (thread)
- && (ptid.is_pid ()
- || ptid.lwp () == -1)))
- {
- if (resume[ndx].kind == resume_stop
- && thread->last_resume_kind == resume_stop)
- {
- threads_debug_printf
- ("already %s LWP %ld at GDB's request",
- (thread->last_status.kind () == TARGET_WAITKIND_STOPPED
- ? "stopped" : "stopping"),
- lwpid_of (thread));
-
- continue;
- }
-
- /* Ignore (wildcard) resume requests for already-resumed
+ || (ptid.pid () == pid_of (thread)
+ && (ptid.is_pid () || ptid.lwp () == -1)))
+ {
+ if (resume[ndx].kind == resume_stop
+ && thread->last_resume_kind == resume_stop)
+ {
+ threads_debug_printf ("already %s LWP %ld at GDB's request",
+ (thread->last_status.kind ()
+ == TARGET_WAITKIND_STOPPED
+ ? "stopped"
+ : "stopping"),
+ lwpid_of (thread));
+
+ continue;
+ }
+
+ /* Ignore (wildcard) resume requests for already-resumed
threads. */
- if (resume[ndx].kind != resume_stop
- && thread->last_resume_kind != resume_stop)
- {
- threads_debug_printf
- ("already %s LWP %ld at GDB's request",
- (thread->last_resume_kind == resume_step
- ? "stepping" : "continuing"),
- lwpid_of (thread));
- continue;
- }
-
- /* Don't let wildcard resumes resume fork children that GDB
+ if (resume[ndx].kind != resume_stop
+ && thread->last_resume_kind != resume_stop)
+ {
+ threads_debug_printf ("already %s LWP %ld at GDB's request",
+ (thread->last_resume_kind == resume_step
+ ? "stepping"
+ : "continuing"),
+ lwpid_of (thread));
+ continue;
+ }
+
+ /* Don't let wildcard resumes resume fork children that GDB
does not yet know are new fork children. */
- if (lwp->fork_relative != NULL)
- {
- struct lwp_info *rel = lwp->fork_relative;
-
- if (rel->status_pending_p
- && (rel->waitstatus.kind () == TARGET_WAITKIND_FORKED
- || rel->waitstatus.kind () == TARGET_WAITKIND_VFORKED))
- {
- threads_debug_printf
- ("not resuming LWP %ld: has queued stop reply",
- lwpid_of (thread));
- continue;
- }
- }
-
- /* If the thread has a pending event that has already been
+ if (lwp->fork_relative != NULL)
+ {
+ struct lwp_info *rel = lwp->fork_relative;
+
+ if (rel->status_pending_p
+ && (rel->waitstatus.kind () == TARGET_WAITKIND_FORKED
+ || rel->waitstatus.kind () == TARGET_WAITKIND_VFORKED))
+ {
+ threads_debug_printf (
+ "not resuming LWP %ld: has queued stop reply",
+ lwpid_of (thread));
+ continue;
+ }
+ }
+
+ /* If the thread has a pending event that has already been
reported to GDBserver core, but GDB has not pulled the
event out of the vStopped queue yet, likewise, ignore the
(wildcard) resume request. */
- if (in_queued_stop_replies (thread->id))
- {
- threads_debug_printf
- ("not resuming LWP %ld: has queued stop reply",
- lwpid_of (thread));
- continue;
- }
+ if (in_queued_stop_replies (thread->id))
+ {
+ threads_debug_printf (
+ "not resuming LWP %ld: has queued stop reply",
+ lwpid_of (thread));
+ continue;
+ }
- lwp->resume = &resume[ndx];
- thread->last_resume_kind = lwp->resume->kind;
+ lwp->resume = &resume[ndx];
+ thread->last_resume_kind = lwp->resume->kind;
- lwp->step_range_start = lwp->resume->step_range_start;
- lwp->step_range_end = lwp->resume->step_range_end;
+ lwp->step_range_start = lwp->resume->step_range_start;
+ lwp->step_range_end = lwp->resume->step_range_end;
- /* If we had a deferred signal to report, dequeue one now.
+ /* If we had a deferred signal to report, dequeue one now.
This can happen if LWP gets more than one signal while
trying to get out of a jump pad. */
- if (lwp->stopped
- && !lwp->status_pending_p
- && dequeue_one_deferred_signal (lwp, &lwp->status_pending))
- {
- lwp->status_pending_p = 1;
+ if (lwp->stopped && !lwp->status_pending_p
+ && dequeue_one_deferred_signal (lwp, &lwp->status_pending))
+ {
+ lwp->status_pending_p = 1;
- threads_debug_printf
- ("Dequeueing deferred signal %d for LWP %ld, "
- "leaving status pending.",
- WSTOPSIG (lwp->status_pending),
- lwpid_of (thread));
- }
+ threads_debug_printf (
+ "Dequeueing deferred signal %d for LWP %ld, "
+ "leaving status pending.",
+ WSTOPSIG (lwp->status_pending), lwpid_of (thread));
+ }
- return;
- }
+ return;
+ }
}
/* No resume action for this thread. */
@@ -4353,15 +4290,15 @@ linux_process_target::thread_needs_step_over (thread_info *thread)
if (!lwp->stopped)
{
threads_debug_printf ("Need step over [LWP %ld]? Ignoring, not stopped",
- lwpid_of (thread));
+ lwpid_of (thread));
return false;
}
if (thread->last_resume_kind == resume_stop)
{
- threads_debug_printf
- ("Need step over [LWP %ld]? Ignoring, should remain stopped",
- lwpid_of (thread));
+ threads_debug_printf (
+ "Need step over [LWP %ld]? Ignoring, should remain stopped",
+ lwpid_of (thread));
return false;
}
@@ -4370,15 +4307,15 @@ linux_process_target::thread_needs_step_over (thread_info *thread)
if (lwp->suspended)
{
threads_debug_printf ("Need step over [LWP %ld]? Ignoring, suspended",
- lwpid_of (thread));
+ lwpid_of (thread));
return false;
}
if (lwp->status_pending_p)
{
- threads_debug_printf
- ("Need step over [LWP %ld]? Ignoring, has pending status.",
- lwpid_of (thread));
+ threads_debug_printf (
+ "Need step over [LWP %ld]? Ignoring, has pending status.",
+ lwpid_of (thread));
return false;
}
@@ -4393,22 +4330,21 @@ linux_process_target::thread_needs_step_over (thread_info *thread)
command, or poked thread's registers herself. */
if (pc != lwp->stop_pc)
{
- threads_debug_printf
- ("Need step over [LWP %ld]? Cancelling, PC was changed. "
- "Old stop_pc was 0x%s, PC is now 0x%s", lwpid_of (thread),
- paddress (lwp->stop_pc), paddress (pc));
+ threads_debug_printf (
+ "Need step over [LWP %ld]? Cancelling, PC was changed. "
+ "Old stop_pc was 0x%s, PC is now 0x%s",
+ lwpid_of (thread), paddress (lwp->stop_pc), paddress (pc));
return false;
}
/* On software single step target, resume the inferior with signal
rather than stepping over. */
- if (supports_software_single_step ()
- && !lwp->pending_signals.empty ()
+ if (supports_software_single_step () && !lwp->pending_signals.empty ()
&& lwp_signal_can_be_delivered (lwp))
{
- threads_debug_printf
- ("Need step over [LWP %ld]? Ignoring, has pending signals.",
- lwpid_of (thread));
+ threads_debug_printf (
+ "Need step over [LWP %ld]? Ignoring, has pending signals.",
+ lwpid_of (thread));
return false;
}
@@ -4422,31 +4358,30 @@ linux_process_target::thread_needs_step_over (thread_info *thread)
/* Don't step over a breakpoint that GDB expects to hit
though. If the condition is being evaluated on the target's side
and it evaluate to false, step over this breakpoint as well. */
- if (gdb_breakpoint_here (pc)
- && gdb_condition_true_at_breakpoint (pc)
- && gdb_no_commands_at_breakpoint (pc))
- {
- threads_debug_printf ("Need step over [LWP %ld]? yes, but found"
- " GDB breakpoint at 0x%s; skipping step over",
- lwpid_of (thread), paddress (pc));
-
- return false;
- }
+ if (gdb_breakpoint_here (pc) && gdb_condition_true_at_breakpoint (pc)
+ && gdb_no_commands_at_breakpoint (pc))
+ {
+ threads_debug_printf ("Need step over [LWP %ld]? yes, but found"
+ " GDB breakpoint at 0x%s; skipping step over",
+ lwpid_of (thread), paddress (pc));
+
+ return false;
+ }
else
- {
- threads_debug_printf ("Need step over [LWP %ld]? yes, "
- "found breakpoint at 0x%s",
- lwpid_of (thread), paddress (pc));
+ {
+ threads_debug_printf ("Need step over [LWP %ld]? yes, "
+ "found breakpoint at 0x%s",
+ lwpid_of (thread), paddress (pc));
- /* We've found an lwp that needs stepping over --- return 1 so
+ /* We've found an lwp that needs stepping over --- return 1 so
that find_thread stops looking. */
- return true;
- }
+ return true;
+ }
}
- threads_debug_printf
- ("Need step over [LWP %ld]? No, no breakpoint found at 0x%s",
- lwpid_of (thread), paddress (pc));
+ threads_debug_printf (
+ "Need step over [LWP %ld]? No, no breakpoint found at 0x%s",
+ lwpid_of (thread), paddress (pc));
return false;
}
@@ -4458,14 +4393,14 @@ linux_process_target::start_step_over (lwp_info *lwp)
CORE_ADDR pc;
threads_debug_printf ("Starting step-over on LWP %ld. Stopping all threads",
- lwpid_of (thread));
+ lwpid_of (thread));
stop_all_lwps (1, lwp);
if (lwp->suspended != 0)
{
internal_error ("LWP %ld suspended=%d\n", lwpid_of (thread),
- lwp->suspended);
+ lwp->suspended);
}
threads_debug_printf ("Done stopping all threads for step-over.");
@@ -4518,10 +4453,10 @@ linux_process_target::finish_step_over (lwp_info *lwp)
stepping over a breakpoint, and we hold all threads but
LWP stopped while doing that. */
if (!supports_hardware_single_step ())
- {
- gdb_assert (has_single_step_breakpoints (current_thread));
- delete_single_step_breakpoints (current_thread);
- }
+ {
+ gdb_assert (has_single_step_breakpoints (current_thread));
+ delete_single_step_breakpoints (current_thread);
+ }
step_over_bkpt = null_ptid;
return true;
@@ -4544,36 +4479,36 @@ linux_process_target::complete_ongoing_step_over ()
/* Passing NULL_PTID as filter indicates we want all events to
be left pending. Eventually this returns when there are no
unwaited-for children left. */
- ret = wait_for_event_filtered (minus_one_ptid, null_ptid, &wstat,
- __WALL);
+ ret
+ = wait_for_event_filtered (minus_one_ptid, null_ptid, &wstat, __WALL);
gdb_assert (ret == -1);
lwp = find_lwp_pid (step_over_bkpt);
if (lwp != NULL)
- {
- finish_step_over (lwp);
+ {
+ finish_step_over (lwp);
- /* If we got our step SIGTRAP, don't leave it pending,
+ /* If we got our step SIGTRAP, don't leave it pending,
otherwise we would report it to GDB as a spurious
SIGTRAP. */
- gdb_assert (lwp->status_pending_p);
- if (WIFSTOPPED (lwp->status_pending)
- && WSTOPSIG (lwp->status_pending) == SIGTRAP)
- {
- thread_info *thread = get_lwp_thread (lwp);
- if (thread->last_resume_kind != resume_step)
- {
- threads_debug_printf ("detach: discard step-over SIGTRAP");
-
- lwp->status_pending_p = 0;
- lwp->status_pending = 0;
- resume_one_lwp (lwp, lwp->stepping, 0, NULL);
- }
- else
- threads_debug_printf
- ("detach: resume_step, not discarding step-over SIGTRAP");
- }
- }
+ gdb_assert (lwp->status_pending_p);
+ if (WIFSTOPPED (lwp->status_pending)
+ && WSTOPSIG (lwp->status_pending) == SIGTRAP)
+ {
+ thread_info *thread = get_lwp_thread (lwp);
+ if (thread->last_resume_kind != resume_step)
+ {
+ threads_debug_printf ("detach: discard step-over SIGTRAP");
+
+ lwp->status_pending_p = 0;
+ lwp->status_pending = 0;
+ resume_one_lwp (lwp, lwp->stepping, 0, NULL);
+ }
+ else
+ threads_debug_printf (
+ "detach: resume_step, not discarding step-over SIGTRAP");
+ }
+ }
step_over_bkpt = null_ptid;
unsuspend_all_lwps (lwp);
}
@@ -4581,7 +4516,7 @@ linux_process_target::complete_ongoing_step_over ()
void
linux_process_target::resume_one_thread (thread_info *thread,
- bool leave_all_stopped)
+ bool leave_all_stopped)
{
struct lwp_info *lwp = get_thread_lwp (thread);
int leave_pending;
@@ -4592,26 +4527,26 @@ linux_process_target::resume_one_thread (thread_info *thread,
if (lwp->resume->kind == resume_stop)
{
threads_debug_printf ("resume_stop request for LWP %ld",
- lwpid_of (thread));
+ lwpid_of (thread));
if (!lwp->stopped)
- {
- threads_debug_printf ("stopping LWP %ld", lwpid_of (thread));
+ {
+ threads_debug_printf ("stopping LWP %ld", lwpid_of (thread));
- /* Stop the thread, and wait for the event asynchronously,
+ /* Stop the thread, and wait for the event asynchronously,
through the event loop. */
- send_sigstop (lwp);
- }
+ send_sigstop (lwp);
+ }
else
- {
- threads_debug_printf ("already stopped LWP %ld", lwpid_of (thread));
+ {
+ threads_debug_printf ("already stopped LWP %ld", lwpid_of (thread));
- /* The LWP may have been stopped in an internal event that
+ /* The LWP may have been stopped in an internal event that
was not meant to be notified back to GDB (e.g., gdbserver
breakpoint), so we should be reporting a stop event in
this case too. */
- /* If the thread already has a pending SIGSTOP, this is a
+ /* If the thread already has a pending SIGSTOP, this is a
no-op. Otherwise, something later will presumably resume
the thread and this will cause it to cancel any pending
operation, due to last_resume_kind == resume_stop. If
@@ -4619,14 +4554,14 @@ linux_process_target::resume_one_thread (thread_info *thread,
will still report it the next time we wait - see
status_pending_p_callback. */
- /* If we already have a pending signal to report, then
+ /* If we already have a pending signal to report, then
there's no need to queue a SIGSTOP, as this means we're
midway through moving the LWP out of the jumppad, and we
will report the pending signal as soon as that is
finished. */
- if (lwp->pending_signals_to_report.empty ())
- send_sigstop (lwp);
- }
+ if (lwp->pending_signals_to_report.empty ())
+ send_sigstop (lwp);
+ }
/* For stop requests, we're done. */
lwp->resume = NULL;
@@ -4642,9 +4577,8 @@ linux_process_target::resume_one_thread (thread_info *thread,
based on if *any* thread has a pending status. If there's a
thread that needs the step-over-breakpoint dance, then don't
resume any other thread but that particular one. */
- leave_pending = (lwp->suspended
- || lwp->status_pending_p
- || leave_all_stopped);
+ leave_pending
+ = (lwp->suspended || lwp->status_pending_p || leave_all_stopped);
/* If we have a new signal, enqueue the signal. */
if (lwp->resume->sig != 0)
@@ -4654,12 +4588,13 @@ linux_process_target::resume_one_thread (thread_info *thread,
/* If this is the same signal we were previously stopped by,
make sure to queue its siginfo. */
if (WIFSTOPPED (lwp->last_status)
- && WSTOPSIG (lwp->last_status) == lwp->resume->sig
- && ptrace (PTRACE_GETSIGINFO, lwpid_of (thread),
- (PTRACE_TYPE_ARG3) 0, &info) == 0)
- info_p = &info;
+ && WSTOPSIG (lwp->last_status) == lwp->resume->sig
+ && ptrace (PTRACE_GETSIGINFO, lwpid_of (thread),
+ (PTRACE_TYPE_ARG3) 0, &info)
+ == 0)
+ info_p = &info;
else
- info_p = NULL;
+ info_p = NULL;
enqueue_pending_signal (lwp, lwp->resume->sig, info_p);
}
@@ -4682,12 +4617,11 @@ linux_process_target::resume (thread_resume *resume_info, size_t n)
{
struct thread_info *need_step_over = NULL;
- THREADS_SCOPED_DEBUG_ENTER_EXIT;
+ THREADS_SCOPED_DEBUG_ENTER_EXIT;
- for_each_thread ([&] (thread_info *thread)
- {
- linux_set_resume_request (thread, resume_info, n);
- });
+ for_each_thread ([&] (thread_info *thread) {
+ linux_set_resume_request (thread, resume_info, n);
+ });
/* If there is a thread which would otherwise be resumed, which has
a pending status, then don't resume any threads - we can just
@@ -4697,10 +4631,10 @@ linux_process_target::resume (thread_resume *resume_info, size_t n)
before considering to start a step-over (in all-stop). */
bool any_pending = false;
if (!non_stop)
- any_pending = find_thread ([this] (thread_info *thread)
- {
- return resume_status_pending (thread);
- }) != nullptr;
+ any_pending = find_thread ([this] (thread_info *thread) {
+ return resume_status_pending (thread);
+ })
+ != nullptr;
/* If there is a thread which would otherwise be resumed, which is
stopped at a breakpoint that needs stepping over, then don't
@@ -4709,10 +4643,9 @@ linux_process_target::resume (thread_resume *resume_info, size_t n)
to queue any signals that would otherwise be delivered or
queued. */
if (!any_pending && low_supports_breakpoints ())
- need_step_over = find_thread ([this] (thread_info *thread)
- {
- return thread_needs_step_over (thread);
- });
+ need_step_over = find_thread ([this] (thread_info *thread) {
+ return thread_needs_step_over (thread);
+ });
bool leave_all_stopped = (need_step_over != NULL || any_pending);
@@ -4720,16 +4653,15 @@ linux_process_target::resume (thread_resume *resume_info, size_t n)
threads_debug_printf ("Not resuming all, need step over");
else if (any_pending)
threads_debug_printf ("Not resuming, all-stop and found "
- "an LWP with pending status");
+ "an LWP with pending status");
else
threads_debug_printf ("Resuming, no pending status or step over needed");
/* Even if we're leaving threads stopped, queue all signals we'd
otherwise deliver. */
- for_each_thread ([&] (thread_info *thread)
- {
- resume_one_thread (thread, leave_all_stopped);
- });
+ for_each_thread ([&] (thread_info *thread) {
+ resume_one_thread (thread, leave_all_stopped);
+ });
if (need_step_over)
start_step_over (get_thread_lwp (need_step_over));
@@ -4761,14 +4693,14 @@ linux_process_target::proceed_one_lwp (thread_info *thread, lwp_info *except)
&& thread->last_status.kind () != TARGET_WAITKIND_IGNORE)
{
threads_debug_printf (" client wants LWP to remain %ld stopped",
- lwpid_of (thread));
+ lwpid_of (thread));
return;
}
if (lwp->status_pending_p)
{
threads_debug_printf (" LWP %ld has pending status, leaving stopped",
- lwpid_of (thread));
+ lwpid_of (thread));
return;
}
@@ -4783,7 +4715,7 @@ linux_process_target::proceed_one_lwp (thread_info *thread, lwp_info *except)
if (thread->last_resume_kind == resume_stop
&& lwp->pending_signals_to_report.empty ()
&& (lwp->collecting_fast_tracepoint
- == fast_tpoint_collect_result::not_collecting))
+ == fast_tpoint_collect_result::not_collecting))
{
/* We haven't reported this LWP as stopped yet (otherwise, the
last_status.kind check above would catch it, and we wouldn't
@@ -4795,9 +4727,9 @@ linux_process_target::proceed_one_lwp (thread_info *thread, lwp_info *except)
another one here. Note that if the LWP already has a SIGSTOP
pending, this is a no-op. */
- threads_debug_printf
- ("Client wants LWP %ld to stop. Making sure it has a SIGSTOP pending",
- lwpid_of (thread));
+ threads_debug_printf (
+ "Client wants LWP %ld to stop. Making sure it has a SIGSTOP pending",
+ lwpid_of (thread));
send_sigstop (lwp);
}
@@ -4805,21 +4737,21 @@ linux_process_target::proceed_one_lwp (thread_info *thread, lwp_info *except)
if (thread->last_resume_kind == resume_step)
{
threads_debug_printf (" stepping LWP %ld, client wants it stepping",
- lwpid_of (thread));
+ lwpid_of (thread));
/* If resume_step is requested by GDB, install single-step
breakpoints when the thread is about to be actually resumed if
the single-step breakpoints weren't removed. */
if (supports_software_single_step ()
- && !has_single_step_breakpoints (thread))
- install_software_single_step_breakpoints (lwp);
+ && !has_single_step_breakpoints (thread))
+ install_software_single_step_breakpoints (lwp);
step = maybe_hw_step (thread);
}
else if (lwp->bp_reinsert != 0)
{
threads_debug_printf (" stepping LWP %ld, reinsert set",
- lwpid_of (thread));
+ lwpid_of (thread));
step = maybe_hw_step (thread);
}
@@ -4831,7 +4763,7 @@ linux_process_target::proceed_one_lwp (thread_info *thread, lwp_info *except)
void
linux_process_target::unsuspend_and_proceed_one_lwp (thread_info *thread,
- lwp_info *except)
+ lwp_info *except)
{
struct lwp_info *lwp = get_thread_lwp (thread);
@@ -4855,27 +4787,24 @@ linux_process_target::proceed_all_lwps ()
if (low_supports_breakpoints ())
{
- need_step_over = find_thread ([this] (thread_info *thread)
- {
- return thread_needs_step_over (thread);
- });
+ need_step_over = find_thread ([this] (thread_info *thread) {
+ return thread_needs_step_over (thread);
+ });
if (need_step_over != NULL)
- {
- threads_debug_printf ("found thread %ld needing a step-over",
- lwpid_of (need_step_over));
+ {
+ threads_debug_printf ("found thread %ld needing a step-over",
+ lwpid_of (need_step_over));
- start_step_over (get_thread_lwp (need_step_over));
- return;
- }
+ start_step_over (get_thread_lwp (need_step_over));
+ return;
+ }
}
threads_debug_printf ("Proceeding, no step-over needed");
- for_each_thread ([this] (thread_info *thread)
- {
- proceed_one_lwp (thread, NULL);
- });
+ for_each_thread (
+ [this] (thread_info *thread) { proceed_one_lwp (thread, NULL); });
}
void
@@ -4885,23 +4814,19 @@ linux_process_target::unstop_all_lwps (int unsuspend, lwp_info *except)
if (except)
threads_debug_printf ("except=(LWP %ld)",
- lwpid_of (get_lwp_thread (except)));
+ lwpid_of (get_lwp_thread (except)));
else
threads_debug_printf ("except=nullptr");
if (unsuspend)
- for_each_thread ([&] (thread_info *thread)
- {
- unsuspend_and_proceed_one_lwp (thread, except);
- });
+ for_each_thread ([&] (thread_info *thread) {
+ unsuspend_and_proceed_one_lwp (thread, except);
+ });
else
- for_each_thread ([&] (thread_info *thread)
- {
- proceed_one_lwp (thread, except);
- });
+ for_each_thread (
+ [&] (thread_info *thread) { proceed_one_lwp (thread, except); });
}
-
#ifdef HAVE_LINUX_REGSETS
#define use_linux_regsets 1
@@ -4912,7 +4837,7 @@ static int
regset_disabled (struct regsets_info *info, struct regset_info *regset)
{
return (info->disabled_regsets != NULL
- && info->disabled_regsets[regset - info->regsets]);
+ && info->disabled_regsets[regset - info->regsets]);
}
/* Disable REGSET. */
@@ -4930,7 +4855,7 @@ disable_regset (struct regsets_info *info, struct regset_info *regset)
static int
regsets_fetch_inferior_registers (struct regsets_info *regsets_info,
- struct regcache *regcache)
+ struct regcache *regcache)
{
struct regset_info *regset;
int saw_general_regs = 0;
@@ -4944,61 +4869,61 @@ regsets_fetch_inferior_registers (struct regsets_info *regsets_info,
int nt_type, res;
if (regset->size == 0 || regset_disabled (regsets_info, regset))
- continue;
+ continue;
buf = xmalloc (regset->size);
nt_type = regset->nt_type;
if (nt_type)
- {
- iov.iov_base = buf;
- iov.iov_len = regset->size;
- data = (void *) &iov;
- }
+ {
+ iov.iov_base = buf;
+ iov.iov_len = regset->size;
+ data = (void *) &iov;
+ }
else
- data = buf;
+ data = buf;
#ifndef __sparc__
res = ptrace (regset->get_request, pid,
- (PTRACE_TYPE_ARG3) (long) nt_type, data);
+ (PTRACE_TYPE_ARG3) (long) nt_type, data);
#else
res = ptrace (regset->get_request, pid, data, nt_type);
#endif
if (res < 0)
- {
- if (errno == EIO
- || (errno == EINVAL && regset->type == OPTIONAL_REGS))
- {
- /* If we get EIO on a regset, or an EINVAL and the regset is
+ {
+ if (errno == EIO
+ || (errno == EINVAL && regset->type == OPTIONAL_REGS))
+ {
+ /* If we get EIO on a regset, or an EINVAL and the regset is
optional, do not try it again for this process mode. */
- disable_regset (regsets_info, regset);
- }
- else if (errno == ENODATA)
- {
- /* ENODATA may be returned if the regset is currently
+ disable_regset (regsets_info, regset);
+ }
+ else if (errno == ENODATA)
+ {
+ /* ENODATA may be returned if the regset is currently
not "active". This can happen in normal operation,
so suppress the warning in this case. */
- }
- else if (errno == ESRCH)
- {
- /* At this point, ESRCH should mean the process is
+ }
+ else if (errno == ESRCH)
+ {
+ /* At this point, ESRCH should mean the process is
already gone, in which case we simply ignore attempts
to read its registers. */
- }
- else
- {
- char s[256];
- sprintf (s, "ptrace(regsets_fetch_inferior_registers) PID=%d",
- pid);
- perror (s);
- }
- }
+ }
+ else
+ {
+ char s[256];
+ sprintf (s, "ptrace(regsets_fetch_inferior_registers) PID=%d",
+ pid);
+ perror (s);
+ }
+ }
else
- {
- if (regset->type == GENERAL_REGS)
- saw_general_regs = 1;
- regset->store_function (regcache, buf);
- }
+ {
+ if (regset->type == GENERAL_REGS)
+ saw_general_regs = 1;
+ regset->store_function (regcache, buf);
+ }
free (buf);
}
if (saw_general_regs)
@@ -5009,7 +4934,7 @@ regsets_fetch_inferior_registers (struct regsets_info *regsets_info,
static int
regsets_store_inferior_registers (struct regsets_info *regsets_info,
- struct regcache *regcache)
+ struct regcache *regcache)
{
struct regset_info *regset;
int saw_general_regs = 0;
@@ -5023,8 +4948,8 @@ regsets_store_inferior_registers (struct regsets_info *regsets_info,
int nt_type, res;
if (regset->size == 0 || regset_disabled (regsets_info, regset)
- || regset->fill_function == NULL)
- continue;
+ || regset->fill_function == NULL)
+ continue;
buf = xmalloc (regset->size);
@@ -5034,60 +4959,60 @@ regsets_store_inferior_registers (struct regsets_info *regsets_info,
nt_type = regset->nt_type;
if (nt_type)
- {
- iov.iov_base = buf;
- iov.iov_len = regset->size;
- data = (void *) &iov;
- }
+ {
+ iov.iov_base = buf;
+ iov.iov_len = regset->size;
+ data = (void *) &iov;
+ }
else
- data = buf;
+ data = buf;
#ifndef __sparc__
res = ptrace (regset->get_request, pid,
- (PTRACE_TYPE_ARG3) (long) nt_type, data);
+ (PTRACE_TYPE_ARG3) (long) nt_type, data);
#else
res = ptrace (regset->get_request, pid, data, nt_type);
#endif
if (res == 0)
- {
- /* Then overlay our cached registers on that. */
- regset->fill_function (regcache, buf);
+ {
+ /* Then overlay our cached registers on that. */
+ regset->fill_function (regcache, buf);
- /* Only now do we write the register set. */
+ /* Only now do we write the register set. */
#ifndef __sparc__
- res = ptrace (regset->set_request, pid,
- (PTRACE_TYPE_ARG3) (long) nt_type, data);
+ res = ptrace (regset->set_request, pid,
+ (PTRACE_TYPE_ARG3) (long) nt_type, data);
#else
- res = ptrace (regset->set_request, pid, data, nt_type);
+ res = ptrace (regset->set_request, pid, data, nt_type);
#endif
- }
+ }
if (res < 0)
- {
- if (errno == EIO
- || (errno == EINVAL && regset->type == OPTIONAL_REGS))
- {
- /* If we get EIO on a regset, or an EINVAL and the regset is
+ {
+ if (errno == EIO
+ || (errno == EINVAL && regset->type == OPTIONAL_REGS))
+ {
+ /* If we get EIO on a regset, or an EINVAL and the regset is
optional, do not try it again for this process mode. */
- disable_regset (regsets_info, regset);
- }
- else if (errno == ESRCH)
- {
- /* At this point, ESRCH should mean the process is
+ disable_regset (regsets_info, regset);
+ }
+ else if (errno == ESRCH)
+ {
+ /* At this point, ESRCH should mean the process is
already gone, in which case we simply ignore attempts
to change its registers. See also the related
comment in resume_one_lwp. */
- free (buf);
- return 0;
- }
- else
- {
- perror ("Warning: ptrace(regsets_store_inferior_registers)");
- }
- }
+ free (buf);
+ return 0;
+ }
+ else
+ {
+ perror ("Warning: ptrace(regsets_store_inferior_registers)");
+ }
+ }
else if (regset->type == GENERAL_REGS)
- saw_general_regs = 1;
+ saw_general_regs = 1;
free (buf);
}
if (saw_general_regs)
@@ -5114,8 +5039,8 @@ linux_register_in_regsets (const struct regs_info *regs_info, int regno)
size_t index = regno / 8;
return (use_linux_regsets
- && (regs_info->regset_bitmap == NULL
- || (regs_info->regset_bitmap[index] & mask) != 0));
+ && (regs_info->regset_bitmap == NULL
+ || (regs_info->regset_bitmap[index] & mask) != 0));
}
#ifdef HAVE_LINUX_USRREGS
@@ -5133,10 +5058,9 @@ register_addr (const struct usrregs_info *usrregs, int regnum)
return addr;
}
-
void
linux_process_target::fetch_register (const usrregs_info *usrregs,
- regcache *regcache, int regno)
+ regcache *regcache, int regno)
{
CORE_ADDR regaddr;
int i, size;
@@ -5152,27 +5076,28 @@ linux_process_target::fetch_register (const usrregs_info *usrregs,
if (regaddr == -1)
return;
- size = ((register_size (regcache->tdesc, regno)
- + sizeof (PTRACE_XFER_TYPE) - 1)
- & -sizeof (PTRACE_XFER_TYPE));
+ size
+ = ((register_size (regcache->tdesc, regno) + sizeof (PTRACE_XFER_TYPE) - 1)
+ & -sizeof (PTRACE_XFER_TYPE));
buf = (char *) alloca (size);
pid = lwpid_of (current_thread);
for (i = 0; i < size; i += sizeof (PTRACE_XFER_TYPE))
{
errno = 0;
- *(PTRACE_XFER_TYPE *) (buf + i) =
- ptrace (PTRACE_PEEKUSER, pid,
- /* Coerce to a uintptr_t first to avoid potential gcc warning
+ *(PTRACE_XFER_TYPE *) (buf + i)
+ = ptrace (PTRACE_PEEKUSER, pid,
+ /* Coerce to a uintptr_t first to avoid potential gcc warning
of coercing an 8 byte integer to a 4 byte pointer. */
- (PTRACE_TYPE_ARG3) (uintptr_t) regaddr, (PTRACE_TYPE_ARG4) 0);
+ (PTRACE_TYPE_ARG3) (uintptr_t) regaddr,
+ (PTRACE_TYPE_ARG4) 0);
regaddr += sizeof (PTRACE_XFER_TYPE);
if (errno != 0)
- {
- /* Mark register REGNO unavailable. */
- supply_register (regcache, regno, NULL);
- return;
- }
+ {
+ /* Mark register REGNO unavailable. */
+ supply_register (regcache, regno, NULL);
+ return;
+ }
}
low_supply_ptrace_register (regcache, regno, buf);
@@ -5180,7 +5105,7 @@ linux_process_target::fetch_register (const usrregs_info *usrregs,
void
linux_process_target::store_register (const usrregs_info *usrregs,
- regcache *regcache, int regno)
+ regcache *regcache, int regno)
{
CORE_ADDR regaddr;
int i, size;
@@ -5196,9 +5121,9 @@ linux_process_target::store_register (const usrregs_info *usrregs,
if (regaddr == -1)
return;
- size = ((register_size (regcache->tdesc, regno)
- + sizeof (PTRACE_XFER_TYPE) - 1)
- & -sizeof (PTRACE_XFER_TYPE));
+ size
+ = ((register_size (regcache->tdesc, regno) + sizeof (PTRACE_XFER_TYPE) - 1)
+ & -sizeof (PTRACE_XFER_TYPE));
buf = (char *) alloca (size);
memset (buf, 0, size);
@@ -5209,23 +5134,22 @@ linux_process_target::store_register (const usrregs_info *usrregs,
{
errno = 0;
ptrace (PTRACE_POKEUSER, pid,
- /* Coerce to a uintptr_t first to avoid potential gcc warning
+ /* Coerce to a uintptr_t first to avoid potential gcc warning
about coercing an 8 byte integer to a 4 byte pointer. */
- (PTRACE_TYPE_ARG3) (uintptr_t) regaddr,
- (PTRACE_TYPE_ARG4) *(PTRACE_XFER_TYPE *) (buf + i));
+ (PTRACE_TYPE_ARG3) (uintptr_t) regaddr,
+ (PTRACE_TYPE_ARG4) * (PTRACE_XFER_TYPE *) (buf + i));
if (errno != 0)
- {
- /* At this point, ESRCH should mean the process is
+ {
+ /* At this point, ESRCH should mean the process is
already gone, in which case we simply ignore attempts
to change its registers. See also the related
comment in resume_one_lwp. */
- if (errno == ESRCH)
- return;
-
+ if (errno == ESRCH)
+ return;
- if (!low_cannot_store_register (regno))
- error ("writing register %d: %s", regno, safe_strerror (errno));
- }
+ if (!low_cannot_store_register (regno))
+ error ("writing register %d: %s", regno, safe_strerror (errno));
+ }
regaddr += sizeof (PTRACE_XFER_TYPE);
}
}
@@ -5233,22 +5157,22 @@ linux_process_target::store_register (const usrregs_info *usrregs,
void
linux_process_target::low_collect_ptrace_register (regcache *regcache,
- int regno, char *buf)
+ int regno, char *buf)
{
collect_register (regcache, regno, buf);
}
void
linux_process_target::low_supply_ptrace_register (regcache *regcache,
- int regno, const char *buf)
+ int regno, const char *buf)
{
supply_register (regcache, regno, buf);
}
void
linux_process_target::usr_fetch_inferior_registers (const regs_info *regs_info,
- regcache *regcache,
- int regno, int all)
+ regcache *regcache,
+ int regno, int all)
{
#ifdef HAVE_LINUX_USRREGS
struct usrregs_info *usr = regs_info->usrregs;
@@ -5256,8 +5180,8 @@ linux_process_target::usr_fetch_inferior_registers (const regs_info *regs_info,
if (regno == -1)
{
for (regno = 0; regno < usr->num_regs; regno++)
- if (all || !linux_register_in_regsets (regs_info, regno))
- fetch_register (usr, regcache, regno);
+ if (all || !linux_register_in_regsets (regs_info, regno))
+ fetch_register (usr, regcache, regno);
}
else
fetch_register (usr, regcache, regno);
@@ -5266,8 +5190,8 @@ linux_process_target::usr_fetch_inferior_registers (const regs_info *regs_info,
void
linux_process_target::usr_store_inferior_registers (const regs_info *regs_info,
- regcache *regcache,
- int regno, int all)
+ regcache *regcache,
+ int regno, int all)
{
#ifdef HAVE_LINUX_USRREGS
struct usrregs_info *usr = regs_info->usrregs;
@@ -5275,8 +5199,8 @@ linux_process_target::usr_store_inferior_registers (const regs_info *regs_info,
if (regno == -1)
{
for (regno = 0; regno < usr->num_regs; regno++)
- if (all || !linux_register_in_regsets (regs_info, regno))
- store_register (usr, regcache, regno);
+ if (all || !linux_register_in_regsets (regs_info, regno))
+ store_register (usr, regcache, regno);
}
else
store_register (usr, regcache, regno);
@@ -5293,24 +5217,25 @@ linux_process_target::fetch_registers (regcache *regcache, int regno)
if (regno == -1)
{
if (regs_info->usrregs != NULL)
- for (regno = 0; regno < regs_info->usrregs->num_regs; regno++)
- low_fetch_register (regcache, regno);
+ for (regno = 0; regno < regs_info->usrregs->num_regs; regno++)
+ low_fetch_register (regcache, regno);
- all = regsets_fetch_inferior_registers (regs_info->regsets_info, regcache);
+ all
+ = regsets_fetch_inferior_registers (regs_info->regsets_info, regcache);
if (regs_info->usrregs != NULL)
- usr_fetch_inferior_registers (regs_info, regcache, -1, all);
+ usr_fetch_inferior_registers (regs_info, regcache, -1, all);
}
else
{
if (low_fetch_register (regcache, regno))
- return;
+ return;
use_regsets = linux_register_in_regsets (regs_info, regno);
if (use_regsets)
- all = regsets_fetch_inferior_registers (regs_info->regsets_info,
- regcache);
+ all = regsets_fetch_inferior_registers (regs_info->regsets_info,
+ regcache);
if ((!use_regsets || all) && regs_info->usrregs != NULL)
- usr_fetch_inferior_registers (regs_info, regcache, regno, 1);
+ usr_fetch_inferior_registers (regs_info, regcache, regno, 1);
}
}
@@ -5323,19 +5248,19 @@ linux_process_target::store_registers (regcache *regcache, int regno)
if (regno == -1)
{
- all = regsets_store_inferior_registers (regs_info->regsets_info,
- regcache);
+ all
+ = regsets_store_inferior_registers (regs_info->regsets_info, regcache);
if (regs_info->usrregs != NULL)
- usr_store_inferior_registers (regs_info, regcache, regno, all);
+ usr_store_inferior_registers (regs_info, regcache, regno, all);
}
else
{
use_regsets = linux_register_in_regsets (regs_info, regno);
if (use_regsets)
- all = regsets_store_inferior_registers (regs_info->regsets_info,
- regcache);
+ all = regsets_store_inferior_registers (regs_info->regsets_info,
+ regcache);
if ((!use_regsets || all) && regs_info->usrregs != NULL)
- usr_store_inferior_registers (regs_info, regcache, regno, 1);
+ usr_store_inferior_registers (regs_info, regcache, regno, 1);
}
}
@@ -5353,7 +5278,6 @@ linux_read_memory (CORE_ADDR memaddr, unsigned char *myaddr, int len)
return the_target->read_memory (memaddr, myaddr, len);
}
-
/* Helper for read_memory/write_memory using /proc/PID/mem. Because
we can use a single read/write call, this can be much more
efficient than banging away at PTRACE_PEEKTEXT. Also, unlike
@@ -5363,7 +5287,7 @@ linux_read_memory (CORE_ADDR memaddr, unsigned char *myaddr, int len)
static int
proc_xfer_memory (CORE_ADDR memaddr, unsigned char *readbuf,
- const gdb_byte *writebuf, int len)
+ const gdb_byte *writebuf, int len)
{
gdb_assert ((readbuf == nullptr) != (writebuf == nullptr));
@@ -5382,31 +5306,30 @@ proc_xfer_memory (CORE_ADDR memaddr, unsigned char *readbuf,
32-bit platforms (for instance, SPARC debugging a SPARC64
application). */
#ifdef HAVE_PREAD64
- bytes = (readbuf != nullptr
- ? pread64 (fd, readbuf, len, memaddr)
- : pwrite64 (fd, writebuf, len, memaddr));
+ bytes = (readbuf != nullptr ? pread64 (fd, readbuf, len, memaddr)
+ : pwrite64 (fd, writebuf, len, memaddr));
#else
bytes = -1;
if (lseek (fd, memaddr, SEEK_SET) != -1)
- bytes = (readbuf != nullptr
+ bytes = (readbuf != nullptr
? read (fd, readbuf, len)
? write (fd, writebuf, len));
#endif
if (bytes < 0)
- return errno;
+ return errno;
else if (bytes == 0)
- {
- /* EOF means the address space is gone, the whole process
+ {
+ /* EOF means the address space is gone, the whole process
exited or execed. */
- return EIO;
- }
+ return EIO;
+ }
memaddr += bytes;
if (readbuf != nullptr)
- readbuf += bytes;
+ readbuf += bytes;
else
- writebuf += bytes;
+ writebuf += bytes;
len -= bytes;
}
@@ -5414,8 +5337,8 @@ proc_xfer_memory (CORE_ADDR memaddr, unsigned char *readbuf,
}
int
-linux_process_target::read_memory (CORE_ADDR memaddr,
- unsigned char *myaddr, int len)
+linux_process_target::read_memory (CORE_ADDR memaddr, unsigned char *myaddr,
+ int len)
{
return proc_xfer_memory (memaddr, myaddr, nullptr, len);
}
@@ -5426,7 +5349,7 @@ linux_process_target::read_memory (CORE_ADDR memaddr,
int
linux_process_target::write_memory (CORE_ADDR memaddr,
- const unsigned char *myaddr, int len)
+ const unsigned char *myaddr, int len)
{
if (debug_threads)
{
@@ -5436,14 +5359,14 @@ linux_process_target::write_memory (CORE_ADDR memaddr,
int dump = len < 4 ? len : 4;
for (int i = 0; i < dump; i++)
- {
- sprintf (p, "%02x", myaddr[i]);
- p += 2;
- }
+ {
+ sprintf (p, "%02x", myaddr[i]);
+ p += 2;
+ }
*p = '\0';
- threads_debug_printf ("Writing %s to 0x%08lx in process %d",
- str, (long) memaddr, current_process ()->pid);
+ threads_debug_printf ("Writing %s to 0x%08lx in process %d", str,
+ (long) memaddr, current_process ()->pid);
}
return proc_xfer_memory (memaddr, nullptr, myaddr, len);
@@ -5469,8 +5392,8 @@ linux_process_target::request_interrupt ()
typed a ^C on the controlling terminal. */
int res = ::kill (-signal_pid, SIGINT);
if (res == -1)
- warning (_("Sending SIGINT to process group of pid %ld failed: %s"),
- signal_pid, safe_strerror (errno));
+ warning (_ ("Sending SIGINT to process group of pid %ld failed: %s"),
+ signal_pid, safe_strerror (errno));
}
bool
@@ -5484,7 +5407,7 @@ linux_process_target::supports_read_auxv ()
int
linux_process_target::read_auxv (int pid, CORE_ADDR offset,
- unsigned char *myaddr, unsigned int len)
+ unsigned char *myaddr, unsigned int len)
{
char filename[PATH_MAX];
int fd, n;
@@ -5508,7 +5431,7 @@ linux_process_target::read_auxv (int pid, CORE_ADDR offset,
int
linux_process_target::insert_point (enum raw_bkpt_type type, CORE_ADDR addr,
- int size, raw_breakpoint *bp)
+ int size, raw_breakpoint *bp)
{
if (type == raw_bkpt_type_sw)
return insert_memory_breakpoint (bp);
@@ -5518,7 +5441,7 @@ linux_process_target::insert_point (enum raw_bkpt_type type, CORE_ADDR addr,
int
linux_process_target::low_insert_point (raw_bkpt_type type, CORE_ADDR addr,
- int size, raw_breakpoint *bp)
+ int size, raw_breakpoint *bp)
{
/* Unsupported (see target.h). */
return 1;
@@ -5526,7 +5449,7 @@ linux_process_target::low_insert_point (raw_bkpt_type type, CORE_ADDR addr,
int
linux_process_target::remove_point (enum raw_bkpt_type type, CORE_ADDR addr,
- int size, raw_breakpoint *bp)
+ int size, raw_breakpoint *bp)
{
if (type == raw_bkpt_type_sw)
return remove_memory_breakpoint (bp);
@@ -5536,7 +5459,7 @@ linux_process_target::remove_point (enum raw_bkpt_type type, CORE_ADDR addr,
int
linux_process_target::low_remove_point (raw_bkpt_type type, CORE_ADDR addr,
- int size, raw_breakpoint *bp)
+ int size, raw_breakpoint *bp)
{
/* Unsupported (see target.h). */
return 1;
@@ -5634,11 +5557,11 @@ linux_process_target::read_offsets (CORE_ADDR *text_p, CORE_ADDR *data_p)
errno = 0;
text = ptrace (PTRACE_PEEKUSER, pid, (PTRACE_TYPE_ARG3) PT_TEXT_ADDR,
- (PTRACE_TYPE_ARG4) 0);
+ (PTRACE_TYPE_ARG4) 0);
text_end = ptrace (PTRACE_PEEKUSER, pid, (PTRACE_TYPE_ARG3) PT_TEXT_END_ADDR,
- (PTRACE_TYPE_ARG4) 0);
+ (PTRACE_TYPE_ARG4) 0);
data = ptrace (PTRACE_PEEKUSER, pid, (PTRACE_TYPE_ARG3) PT_DATA_ADDR,
- (PTRACE_TYPE_ARG4) 0);
+ (PTRACE_TYPE_ARG4) 0);
if (errno == 0)
{
@@ -5673,10 +5596,9 @@ linux_process_target::supports_get_tls_address ()
}
int
-linux_process_target::get_tls_address (thread_info *thread,
- CORE_ADDR offset,
- CORE_ADDR load_module,
- CORE_ADDR *address)
+linux_process_target::get_tls_address (thread_info *thread, CORE_ADDR offset,
+ CORE_ADDR load_module,
+ CORE_ADDR *address)
{
#ifdef USE_THREAD_DB
return thread_db_get_tls_address (thread, offset, load_module, address);
@@ -5692,17 +5614,16 @@ linux_process_target::supports_qxfer_osdata ()
}
int
-linux_process_target::qxfer_osdata (const char *annex,
- unsigned char *readbuf,
- unsigned const char *writebuf,
- CORE_ADDR offset, int len)
+linux_process_target::qxfer_osdata (const char *annex, unsigned char *readbuf,
+ unsigned const char *writebuf,
+ CORE_ADDR offset, int len)
{
return linux_common_xfer_osdata (annex, readbuf, offset, len);
}
void
-linux_process_target::siginfo_fixup (siginfo_t *siginfo,
- gdb_byte *inf_siginfo, int direction)
+linux_process_target::siginfo_fixup (siginfo_t *siginfo, gdb_byte *inf_siginfo,
+ int direction)
{
bool done = low_siginfo_fixup (siginfo, inf_siginfo, direction);
@@ -5711,15 +5632,15 @@ linux_process_target::siginfo_fixup (siginfo_t *siginfo,
if (!done)
{
if (direction == 1)
- memcpy (siginfo, inf_siginfo, sizeof (siginfo_t));
+ memcpy (siginfo, inf_siginfo, sizeof (siginfo_t));
else
- memcpy (inf_siginfo, siginfo, sizeof (siginfo_t));
+ memcpy (inf_siginfo, siginfo, sizeof (siginfo_t));
}
}
bool
linux_process_target::low_siginfo_fixup (siginfo_t *native, gdb_byte *inf,
- int direction)
+ int direction)
{
return false;
}
@@ -5731,10 +5652,9 @@ linux_process_target::supports_qxfer_siginfo ()
}
int
-linux_process_target::qxfer_siginfo (const char *annex,
- unsigned char *readbuf,
- unsigned const char *writebuf,
- CORE_ADDR offset, int len)
+linux_process_target::qxfer_siginfo (const char *annex, unsigned char *readbuf,
+ unsigned const char *writebuf,
+ CORE_ADDR offset, int len)
{
int pid;
siginfo_t siginfo;
@@ -5746,8 +5666,7 @@ linux_process_target::qxfer_siginfo (const char *annex,
pid = lwpid_of (current_thread);
threads_debug_printf ("%s siginfo for lwp %d.",
- readbuf != NULL ? "Reading" : "Writing",
- pid);
+ readbuf != NULL ? "Reading" : "Writing", pid);
if (offset >= sizeof (siginfo))
return -1;
@@ -5774,7 +5693,7 @@ linux_process_target::qxfer_siginfo (const char *annex,
siginfo_fixup (&siginfo, inf_siginfo, 1);
if (ptrace (PTRACE_SETSIGINFO, pid, (PTRACE_TYPE_ARG3) 0, &siginfo) != 0)
- return -1;
+ return -1;
}
return len;
@@ -5792,12 +5711,14 @@ sigchld_handler (int signo)
if (debug_threads)
{
do
- {
- /* Use the async signal safe debug function. */
- if (debug_write ("sigchld_handler\n",
- sizeof ("sigchld_handler\n") - 1) < 0)
- break; /* just ignore */
- } while (0);
+ {
+ /* Use the async signal safe debug function. */
+ if (debug_write ("sigchld_handler\n",
+ sizeof ("sigchld_handler\n") - 1)
+ < 0)
+ break; /* just ignore */
+ }
+ while (0);
}
if (target_is_async_p ())
@@ -5817,8 +5738,7 @@ linux_process_target::async (bool enable)
{
bool previous = target_is_async_p ();
- threads_debug_printf ("async (%d), previous=%d",
- enable, previous);
+ threads_debug_printf ("async (%d), previous=%d", enable, previous);
if (previous != enable)
{
@@ -5829,29 +5749,28 @@ linux_process_target::async (bool enable)
gdb_sigmask (SIG_BLOCK, &mask, NULL);
if (enable)
- {
- if (!linux_event_pipe.open_pipe ())
- {
- gdb_sigmask (SIG_UNBLOCK, &mask, NULL);
-
- warning ("creating event pipe failed.");
- return previous;
- }
-
- /* Register the event loop handler. */
- add_file_handler (linux_event_pipe.event_fd (),
- handle_target_event, NULL,
- "linux-low");
-
- /* Always trigger a linux_wait. */
- async_file_mark ();
- }
+ {
+ if (!linux_event_pipe.open_pipe ())
+ {
+ gdb_sigmask (SIG_UNBLOCK, &mask, NULL);
+
+ warning ("creating event pipe failed.");
+ return previous;
+ }
+
+ /* Register the event loop handler. */
+ add_file_handler (linux_event_pipe.event_fd (), handle_target_event,
+ NULL, "linux-low");
+
+ /* Always trigger a linux_wait. */
+ async_file_mark ();
+ }
else
- {
- delete_file_handler (linux_event_pipe.event_fd ());
+ {
+ delete_file_handler (linux_event_pipe.event_fd ());
- linux_event_pipe.close_pipe ();
- }
+ linux_event_pipe.close_pipe ();
+ }
gdb_sigmask (SIG_UNBLOCK, &mask, NULL);
}
@@ -5909,26 +5828,25 @@ void
linux_process_target::handle_new_gdb_connection ()
{
/* Request that all the lwps reset their ptrace options. */
- for_each_thread ([] (thread_info *thread)
- {
- struct lwp_info *lwp = get_thread_lwp (thread);
+ for_each_thread ([] (thread_info *thread) {
+ struct lwp_info *lwp = get_thread_lwp (thread);
- if (!lwp->stopped)
- {
- /* Stop the lwp so we can modify its ptrace options. */
- lwp->must_set_ptrace_flags = 1;
- linux_stop_lwp (lwp);
- }
- else
- {
- /* Already stopped; go ahead and set the ptrace options. */
- struct process_info *proc = find_process_pid (pid_of (thread));
- int options = linux_low_ptrace_options (proc->attached);
-
- linux_enable_event_reporting (lwpid_of (thread), options);
- lwp->must_set_ptrace_flags = 0;
- }
- });
+ if (!lwp->stopped)
+ {
+ /* Stop the lwp so we can modify its ptrace options. */
+ lwp->must_set_ptrace_flags = 1;
+ linux_stop_lwp (lwp);
+ }
+ else
+ {
+ /* Already stopped; go ahead and set the ptrace options. */
+ struct process_info *proc = find_process_pid (pid_of (thread));
+ int options = linux_low_ptrace_options (proc->attached);
+
+ linux_enable_event_reporting (lwpid_of (thread), options);
+ lwp->must_set_ptrace_flags = 0;
+ }
+ });
}
int
@@ -5993,8 +5911,8 @@ linux_process_target::supports_multifs ()
}
int
-linux_process_target::multifs_open (int pid, const char *filename,
- int flags, mode_t mode)
+linux_process_target::multifs_open (int pid, const char *filename, int flags,
+ mode_t mode)
{
return linux_mntns_open_cloexec (pid, filename, flags, mode);
}
@@ -6007,7 +5925,7 @@ linux_process_target::multifs_unlink (int pid, const char *filename)
ssize_t
linux_process_target::multifs_readlink (int pid, const char *filename,
- char *buf, size_t bufsiz)
+ char *buf, size_t bufsiz)
{
return linux_mntns_readlink (pid, filename, buf, bufsiz);
}
@@ -6023,7 +5941,7 @@ struct target_loadseg
Elf32_Word p_memsz;
};
-# if defined PT_GETDSBT
+#if defined PT_GETDSBT
struct target_loadmap
{
/* Protocol version number, must be zero. */
@@ -6036,10 +5954,10 @@ struct target_loadmap
/* The actual memory map. */
struct target_loadseg segs[/*nsegs*/];
};
-# define LINUX_LOADMAP PT_GETDSBT
-# define LINUX_LOADMAP_EXEC PTRACE_GETDSBT_EXEC
-# define LINUX_LOADMAP_INTERP PTRACE_GETDSBT_INTERP
-# else
+#define LINUX_LOADMAP PT_GETDSBT
+#define LINUX_LOADMAP_EXEC PTRACE_GETDSBT_EXEC
+#define LINUX_LOADMAP_INTERP PTRACE_GETDSBT_INTERP
+#else
struct target_loadmap
{
/* Protocol version number, must be zero. */
@@ -6049,10 +5967,10 @@ struct target_loadmap
/* The actual memory map. */
struct target_loadseg segs[/*nsegs*/];
};
-# define LINUX_LOADMAP PTRACE_GETFDPIC
-# define LINUX_LOADMAP_EXEC PTRACE_GETFDPIC_EXEC
-# define LINUX_LOADMAP_INTERP PTRACE_GETFDPIC_INTERP
-# endif
+#define LINUX_LOADMAP PTRACE_GETFDPIC
+#define LINUX_LOADMAP_EXEC PTRACE_GETFDPIC_EXEC
+#define LINUX_LOADMAP_INTERP PTRACE_GETFDPIC_INTERP
+#endif
bool
linux_process_target::supports_read_loadmap ()
@@ -6062,7 +5980,7 @@ linux_process_target::supports_read_loadmap ()
int
linux_process_target::read_loadmap (const char *annex, CORE_ADDR offset,
- unsigned char *myaddr, unsigned int len)
+ unsigned char *myaddr, unsigned int len)
{
int pid = lwpid_of (current_thread);
int addr = -1;
@@ -6083,7 +6001,7 @@ linux_process_target::read_loadmap (const char *annex, CORE_ADDR offset,
return -1;
actual_length = sizeof (struct target_loadmap)
- + sizeof (struct target_loadseg) * data->nsegs;
+ + sizeof (struct target_loadseg) * data->nsegs;
if (offset < 0 || offset > actual_length)
return -1;
@@ -6156,13 +6074,13 @@ linux_process_target::unpause_all (bool unfreeze)
static int
get_phdr_phnum_from_proc_auxv (const int pid, const int is_elf64,
- CORE_ADDR *phdr_memaddr, int *num_phdr)
+ CORE_ADDR *phdr_memaddr, int *num_phdr)
{
char filename[PATH_MAX];
int fd;
- const int auxv_size = is_elf64
- ? sizeof (Elf64_auxv_t) : sizeof (Elf32_auxv_t);
- char buf[sizeof (Elf64_auxv_t)]; /* The larger of the two. */
+ const int auxv_size
+ = is_elf64 ? sizeof (Elf64_auxv_t) : sizeof (Elf32_auxv_t);
+ char buf[sizeof (Elf64_auxv_t)]; /* The larger of the two. */
xsnprintf (filename, sizeof filename, "/proc/%d/auxv", pid);
@@ -6173,36 +6091,36 @@ get_phdr_phnum_from_proc_auxv (const int pid, const int is_elf64,
*phdr_memaddr = 0;
*num_phdr = 0;
while (read (fd, buf, auxv_size) == auxv_size
- && (*phdr_memaddr == 0 || *num_phdr == 0))
+ && (*phdr_memaddr == 0 || *num_phdr == 0))
{
if (is_elf64)
- {
- Elf64_auxv_t *const aux = (Elf64_auxv_t *) buf;
-
- switch (aux->a_type)
- {
- case AT_PHDR:
- *phdr_memaddr = aux->a_un.a_val;
- break;
- case AT_PHNUM:
- *num_phdr = aux->a_un.a_val;
- break;
- }
- }
+ {
+ Elf64_auxv_t *const aux = (Elf64_auxv_t *) buf;
+
+ switch (aux->a_type)
+ {
+ case AT_PHDR:
+ *phdr_memaddr = aux->a_un.a_val;
+ break;
+ case AT_PHNUM:
+ *num_phdr = aux->a_un.a_val;
+ break;
+ }
+ }
else
- {
- Elf32_auxv_t *const aux = (Elf32_auxv_t *) buf;
+ {
+ Elf32_auxv_t *const aux = (Elf32_auxv_t *) buf;
- switch (aux->a_type)
- {
- case AT_PHDR:
- *phdr_memaddr = aux->a_un.a_val;
- break;
- case AT_PHNUM:
- *num_phdr = aux->a_un.a_val;
- break;
- }
- }
+ switch (aux->a_type)
+ {
+ case AT_PHDR:
+ *phdr_memaddr = aux->a_un.a_val;
+ break;
+ case AT_PHNUM:
+ *num_phdr = aux->a_un.a_val;
+ break;
+ }
+ }
}
close (fd);
@@ -6210,8 +6128,8 @@ get_phdr_phnum_from_proc_auxv (const int pid, const int is_elf64,
if (*phdr_memaddr == 0 || *num_phdr == 0)
{
warning ("Unexpected missing AT_PHDR and/or AT_PHNUM: "
- "phdr_memaddr = %ld, phdr_num = %d",
- (long) *phdr_memaddr, *num_phdr);
+ "phdr_memaddr = %ld, phdr_num = %d",
+ (long) *phdr_memaddr, *num_phdr);
return 2;
}
@@ -6231,7 +6149,7 @@ get_dynamic (const int pid, const int is_elf64)
if (get_phdr_phnum_from_proc_auxv (pid, is_elf64, &phdr_memaddr, &num_phdr))
return 0;
- gdb_assert (num_phdr < 100); /* Basic sanity check. */
+ gdb_assert (num_phdr < 100); /* Basic sanity check. */
phdr_buf = (unsigned char *) alloca (num_phdr * phdr_size);
if (linux_read_memory (phdr_memaddr, phdr_buf, num_phdr * phdr_size))
@@ -6243,17 +6161,17 @@ get_dynamic (const int pid, const int is_elf64)
for (i = 0; relocation == -1 && i < num_phdr; i++)
if (is_elf64)
{
- Elf64_Phdr *const p = (Elf64_Phdr *) (phdr_buf + i * phdr_size);
+ Elf64_Phdr *const p = (Elf64_Phdr *) (phdr_buf + i * phdr_size);
- if (p->p_type == PT_PHDR)
- relocation = phdr_memaddr - p->p_vaddr;
+ if (p->p_type == PT_PHDR)
+ relocation = phdr_memaddr - p->p_vaddr;
}
else
{
- Elf32_Phdr *const p = (Elf32_Phdr *) (phdr_buf + i * phdr_size);
+ Elf32_Phdr *const p = (Elf32_Phdr *) (phdr_buf + i * phdr_size);
- if (p->p_type == PT_PHDR)
- relocation = phdr_memaddr - p->p_vaddr;
+ if (p->p_type == PT_PHDR)
+ relocation = phdr_memaddr - p->p_vaddr;
}
if (relocation == -1)
@@ -6274,19 +6192,19 @@ get_dynamic (const int pid, const int is_elf64)
for (i = 0; i < num_phdr; i++)
{
if (is_elf64)
- {
- Elf64_Phdr *const p = (Elf64_Phdr *) (phdr_buf + i * phdr_size);
+ {
+ Elf64_Phdr *const p = (Elf64_Phdr *) (phdr_buf + i * phdr_size);
- if (p->p_type == PT_DYNAMIC)
- return p->p_vaddr + relocation;
- }
+ if (p->p_type == PT_DYNAMIC)
+ return p->p_vaddr + relocation;
+ }
else
- {
- Elf32_Phdr *const p = (Elf32_Phdr *) (phdr_buf + i * phdr_size);
+ {
+ Elf32_Phdr *const p = (Elf32_Phdr *) (phdr_buf + i * phdr_size);
- if (p->p_type == PT_DYNAMIC)
- return p->p_vaddr + relocation;
- }
+ if (p->p_type == PT_DYNAMIC)
+ return p->p_vaddr + relocation;
+ }
}
return 0;
@@ -6302,7 +6220,7 @@ get_r_debug (const int pid, const int is_elf64)
{
CORE_ADDR dynamic_memaddr;
const int dyn_size = is_elf64 ? sizeof (Elf64_Dyn) : sizeof (Elf32_Dyn);
- unsigned char buf[sizeof (Elf64_Dyn)]; /* The larger of the two. */
+ unsigned char buf[sizeof (Elf64_Dyn)]; /* The larger of the two. */
CORE_ADDR map = -1;
dynamic_memaddr = get_dynamic (pid, is_elf64);
@@ -6312,81 +6230,83 @@ get_r_debug (const int pid, const int is_elf64)
while (linux_read_memory (dynamic_memaddr, buf, dyn_size) == 0)
{
if (is_elf64)
- {
- Elf64_Dyn *const dyn = (Elf64_Dyn *) buf;
+ {
+ Elf64_Dyn *const dyn = (Elf64_Dyn *) buf;
#if defined DT_MIPS_RLD_MAP || defined DT_MIPS_RLD_MAP_REL
- union
- {
- Elf64_Xword map;
- unsigned char buf[sizeof (Elf64_Xword)];
- }
- rld_map;
+ union
+ {
+ Elf64_Xword map;
+ unsigned char buf[sizeof (Elf64_Xword)];
+ } rld_map;
#endif
#ifdef DT_MIPS_RLD_MAP
- if (dyn->d_tag == DT_MIPS_RLD_MAP)
- {
- if (linux_read_memory (dyn->d_un.d_val,
- rld_map.buf, sizeof (rld_map.buf)) == 0)
- return rld_map.map;
- else
- break;
- }
-#endif /* DT_MIPS_RLD_MAP */
+ if (dyn->d_tag == DT_MIPS_RLD_MAP)
+ {
+ if (linux_read_memory (dyn->d_un.d_val, rld_map.buf,
+ sizeof (rld_map.buf))
+ == 0)
+ return rld_map.map;
+ else
+ break;
+ }
+#endif /* DT_MIPS_RLD_MAP */
#ifdef DT_MIPS_RLD_MAP_REL
- if (dyn->d_tag == DT_MIPS_RLD_MAP_REL)
- {
- if (linux_read_memory (dyn->d_un.d_val + dynamic_memaddr,
- rld_map.buf, sizeof (rld_map.buf)) == 0)
- return rld_map.map;
- else
- break;
- }
-#endif /* DT_MIPS_RLD_MAP_REL */
-
- if (dyn->d_tag == DT_DEBUG && map == -1)
- map = dyn->d_un.d_val;
-
- if (dyn->d_tag == DT_NULL)
- break;
- }
+ if (dyn->d_tag == DT_MIPS_RLD_MAP_REL)
+ {
+ if (linux_read_memory (dyn->d_un.d_val + dynamic_memaddr,
+ rld_map.buf, sizeof (rld_map.buf))
+ == 0)
+ return rld_map.map;
+ else
+ break;
+ }
+#endif /* DT_MIPS_RLD_MAP_REL */
+
+ if (dyn->d_tag == DT_DEBUG && map == -1)
+ map = dyn->d_un.d_val;
+
+ if (dyn->d_tag == DT_NULL)
+ break;
+ }
else
- {
- Elf32_Dyn *const dyn = (Elf32_Dyn *) buf;
+ {
+ Elf32_Dyn *const dyn = (Elf32_Dyn *) buf;
#if defined DT_MIPS_RLD_MAP || defined DT_MIPS_RLD_MAP_REL
- union
- {
- Elf32_Word map;
- unsigned char buf[sizeof (Elf32_Word)];
- }
- rld_map;
+ union
+ {
+ Elf32_Word map;
+ unsigned char buf[sizeof (Elf32_Word)];
+ } rld_map;
#endif
#ifdef DT_MIPS_RLD_MAP
- if (dyn->d_tag == DT_MIPS_RLD_MAP)
- {
- if (linux_read_memory (dyn->d_un.d_val,
- rld_map.buf, sizeof (rld_map.buf)) == 0)
- return rld_map.map;
- else
- break;
- }
-#endif /* DT_MIPS_RLD_MAP */
+ if (dyn->d_tag == DT_MIPS_RLD_MAP)
+ {
+ if (linux_read_memory (dyn->d_un.d_val, rld_map.buf,
+ sizeof (rld_map.buf))
+ == 0)
+ return rld_map.map;
+ else
+ break;
+ }
+#endif /* DT_MIPS_RLD_MAP */
#ifdef DT_MIPS_RLD_MAP_REL
- if (dyn->d_tag == DT_MIPS_RLD_MAP_REL)
- {
- if (linux_read_memory (dyn->d_un.d_val + dynamic_memaddr,
- rld_map.buf, sizeof (rld_map.buf)) == 0)
- return rld_map.map;
- else
- break;
- }
-#endif /* DT_MIPS_RLD_MAP_REL */
-
- if (dyn->d_tag == DT_DEBUG && map == -1)
- map = dyn->d_un.d_val;
-
- if (dyn->d_tag == DT_NULL)
- break;
- }
+ if (dyn->d_tag == DT_MIPS_RLD_MAP_REL)
+ {
+ if (linux_read_memory (dyn->d_un.d_val + dynamic_memaddr,
+ rld_map.buf, sizeof (rld_map.buf))
+ == 0)
+ return rld_map.map;
+ else
+ break;
+ }
+#endif /* DT_MIPS_RLD_MAP_REL */
+
+ if (dyn->d_tag == DT_DEBUG && map == -1)
+ map = dyn->d_un.d_val;
+
+ if (dyn->d_tag == DT_NULL)
+ break;
+ }
dynamic_memaddr += dyn_size;
}
@@ -6416,11 +6336,11 @@ read_one_ptr (CORE_ADDR memaddr, CORE_ADDR *ptr, int ptr_size)
if (ret == 0)
{
if (ptr_size == sizeof (CORE_ADDR))
- *ptr = addr.core_addr;
+ *ptr = addr.core_addr;
else if (ptr_size == sizeof (unsigned int))
- *ptr = addr.ui;
+ *ptr = addr.ui;
else
- gdb_assert_not_reached ("unhandled pointer size");
+ gdb_assert_not_reached ("unhandled pointer size");
}
return ret;
}
@@ -6432,84 +6352,78 @@ linux_process_target::supports_qxfer_libraries_svr4 ()
}
struct link_map_offsets
- {
- /* Offset and size of r_debug.r_version. */
- int r_version_offset;
+{
+ /* Offset and size of r_debug.r_version. */
+ int r_version_offset;
- /* Offset and size of r_debug.r_map. */
- int r_map_offset;
+ /* Offset and size of r_debug.r_map. */
+ int r_map_offset;
- /* Offset of r_debug_extended.r_next. */
- int r_next_offset;
+ /* Offset of r_debug_extended.r_next. */
+ int r_next_offset;
- /* Offset to l_addr field in struct link_map. */
- int l_addr_offset;
+ /* Offset to l_addr field in struct link_map. */
+ int l_addr_offset;
- /* Offset to l_name field in struct link_map. */
- int l_name_offset;
+ /* Offset to l_name field in struct link_map. */
+ int l_name_offset;
- /* Offset to l_ld field in struct link_map. */
- int l_ld_offset;
+ /* Offset to l_ld field in struct link_map. */
+ int l_ld_offset;
- /* Offset to l_next field in struct link_map. */
- int l_next_offset;
+ /* Offset to l_next field in struct link_map. */
+ int l_next_offset;
- /* Offset to l_prev field in struct link_map. */
- int l_prev_offset;
- };
+ /* Offset to l_prev field in struct link_map. */
+ int l_prev_offset;
+};
-static const link_map_offsets lmo_32bit_offsets =
- {
- 0, /* r_version offset. */
- 4, /* r_debug.r_map offset. */
- 20, /* r_debug_extended.r_next. */
- 0, /* l_addr offset in link_map. */
- 4, /* l_name offset in link_map. */
- 8, /* l_ld offset in link_map. */
- 12, /* l_next offset in link_map. */
- 16 /* l_prev offset in link_map. */
- };
+static const link_map_offsets lmo_32bit_offsets = {
+ 0, /* r_version offset. */
+ 4, /* r_debug.r_map offset. */
+ 20, /* r_debug_extended.r_next. */
+ 0, /* l_addr offset in link_map. */
+ 4, /* l_name offset in link_map. */
+ 8, /* l_ld offset in link_map. */
+ 12, /* l_next offset in link_map. */
+ 16 /* l_prev offset in link_map. */
+};
-static const link_map_offsets lmo_64bit_offsets =
- {
- 0, /* r_version offset. */
- 8, /* r_debug.r_map offset. */
- 40, /* r_debug_extended.r_next. */
- 0, /* l_addr offset in link_map. */
- 8, /* l_name offset in link_map. */
- 16, /* l_ld offset in link_map. */
- 24, /* l_next offset in link_map. */
- 32 /* l_prev offset in link_map. */
- };
+static const link_map_offsets lmo_64bit_offsets = {
+ 0, /* r_version offset. */
+ 8, /* r_debug.r_map offset. */
+ 40, /* r_debug_extended.r_next. */
+ 0, /* l_addr offset in link_map. */
+ 8, /* l_name offset in link_map. */
+ 16, /* l_ld offset in link_map. */
+ 24, /* l_next offset in link_map. */
+ 32 /* l_prev offset in link_map. */
+};
/* Get the loaded shared libraries from one namespace. */
static void
read_link_map (std::string &document, CORE_ADDR lmid, CORE_ADDR lm_addr,
- CORE_ADDR lm_prev, int ptr_size, const link_map_offsets *lmo)
+ CORE_ADDR lm_prev, int ptr_size, const link_map_offsets *lmo)
{
CORE_ADDR l_name, l_addr, l_ld, l_next, l_prev;
while (lm_addr
- && read_one_ptr (lm_addr + lmo->l_name_offset,
- &l_name, ptr_size) == 0
- && read_one_ptr (lm_addr + lmo->l_addr_offset,
- &l_addr, ptr_size) == 0
- && read_one_ptr (lm_addr + lmo->l_ld_offset,
- &l_ld, ptr_size) == 0
- && read_one_ptr (lm_addr + lmo->l_prev_offset,
- &l_prev, ptr_size) == 0
- && read_one_ptr (lm_addr + lmo->l_next_offset,
- &l_next, ptr_size) == 0)
+ && read_one_ptr (lm_addr + lmo->l_name_offset, &l_name, ptr_size) == 0
+ && read_one_ptr (lm_addr + lmo->l_addr_offset, &l_addr, ptr_size) == 0
+ && read_one_ptr (lm_addr + lmo->l_ld_offset, &l_ld, ptr_size) == 0
+ && read_one_ptr (lm_addr + lmo->l_prev_offset, &l_prev, ptr_size) == 0
+ && read_one_ptr (lm_addr + lmo->l_next_offset, &l_next, ptr_size)
+ == 0)
{
unsigned char libname[PATH_MAX];
if (lm_prev != l_prev)
- {
- warning ("Corrupted shared library list: 0x%s != 0x%s",
- paddress (lm_prev), paddress (l_prev));
- break;
- }
+ {
+ warning ("Corrupted shared library list: 0x%s != 0x%s",
+ paddress (lm_prev), paddress (l_prev));
+ break;
+ }
/* Not checking for error because reading may stop before we've got
PATH_MAX worth of characters. */
@@ -6517,14 +6431,15 @@ read_link_map (std::string &document, CORE_ADDR lmid, CORE_ADDR lm_addr,
linux_read_memory (l_name, libname, sizeof (libname) - 1);
libname[sizeof (libname) - 1] = '\0';
if (libname[0] != '\0')
- {
- string_appendf (document, "<library name=\"");
- xml_escape_text_append (document, (char *) libname);
- string_appendf (document, "\" lm=\"0x%s\" l_addr=\"0x%s\" "
- "l_ld=\"0x%s\" lmid=\"0x%s\"/>",
- paddress (lm_addr), paddress (l_addr),
- paddress (l_ld), paddress (lmid));
- }
+ {
+ string_appendf (document, "<library name=\"");
+ xml_escape_text_append (document, (char *) libname);
+ string_appendf (document,
+ "\" lm=\"0x%s\" l_addr=\"0x%s\" "
+ "l_ld=\"0x%s\" lmid=\"0x%s\"/>",
+ paddress (lm_addr), paddress (l_addr),
+ paddress (l_ld), paddress (lmid));
+ }
lm_prev = lm_addr;
lm_addr = l_next;
@@ -6535,9 +6450,9 @@ read_link_map (std::string &document, CORE_ADDR lmid, CORE_ADDR lm_addr,
int
linux_process_target::qxfer_libraries_svr4 (const char *annex,
- unsigned char *readbuf,
- unsigned const char *writebuf,
- CORE_ADDR offset, int len)
+ unsigned char *readbuf,
+ unsigned const char *writebuf,
+ CORE_ADDR offset, int len)
{
struct process_info_private *const priv = current_process ()->priv;
char filename[PATH_MAX];
@@ -6574,23 +6489,23 @@ linux_process_target::qxfer_libraries_svr4 (const char *annex,
sep = strchr (annex, '=');
if (sep == NULL)
- break;
+ break;
name_len = sep - annex;
if (name_len == 4 && startswith (annex, "lmid"))
- addrp = &lmid;
+ addrp = &lmid;
else if (name_len == 5 && startswith (annex, "start"))
- addrp = &lm_addr;
+ addrp = &lm_addr;
else if (name_len == 4 && startswith (annex, "prev"))
- addrp = &lm_prev;
+ addrp = &lm_prev;
else
- {
- annex = strchr (sep, ';');
- if (annex == NULL)
- break;
- annex++;
- continue;
- }
+ {
+ annex = strchr (sep, ';');
+ if (annex == NULL)
+ break;
+ annex++;
+ continue;
+ }
annex = decode_address_to_semicolon (addrp, sep + 1);
}
@@ -6609,92 +6524,94 @@ linux_process_target::qxfer_libraries_svr4 (const char *annex,
else
{
if (lm_prev != 0)
- warning ("ignoring prev=0x%s without start", paddress (lm_prev));
+ warning ("ignoring prev=0x%s without start", paddress (lm_prev));
/* We could interpret LMID as 'provide only the libraries for this
namespace' but GDB is currently only providing lmid, start, and
prev, or nothing. */
if (lmid != 0)
- warning ("ignoring lmid=0x%s without start", paddress (lmid));
+ warning ("ignoring lmid=0x%s without start", paddress (lmid));
CORE_ADDR r_debug = priv->r_debug;
if (r_debug == 0)
- r_debug = priv->r_debug = get_r_debug (pid, is_elf64);
+ r_debug = priv->r_debug = get_r_debug (pid, is_elf64);
/* We failed to find DT_DEBUG. Such situation will not change
for this inferior - do not retry it. Report it to GDB as
E01, see for the reasons at the GDB solib-svr4.c side. */
if (r_debug == (CORE_ADDR) -1)
- return -1;
+ return -1;
/* Terminate the header if we end up with an empty list. */
if (r_debug == 0)
- document += ">";
+ document += ">";
while (r_debug != 0)
- {
- int r_version = 0;
- if (linux_read_memory (r_debug + lmo->r_version_offset,
- (unsigned char *) &r_version,
- sizeof (r_version)) != 0)
- {
- warning ("unable to read r_version from 0x%s",
- paddress (r_debug + lmo->r_version_offset));
- break;
- }
-
- if (r_version < 1)
- {
- warning ("unexpected r_debug version %d", r_version);
- break;
- }
-
- if (read_one_ptr (r_debug + lmo->r_map_offset, &lm_addr,
- ptr_size) != 0)
- {
- warning ("unable to read r_map from 0x%s",
- paddress (r_debug + lmo->r_map_offset));
- break;
- }
-
- /* We read the entire namespace. */
- lm_prev = 0;
-
- /* The first entry corresponds to the main executable unless the
+ {
+ int r_version = 0;
+ if (linux_read_memory (r_debug + lmo->r_version_offset,
+ (unsigned char *) &r_version,
+ sizeof (r_version))
+ != 0)
+ {
+ warning ("unable to read r_version from 0x%s",
+ paddress (r_debug + lmo->r_version_offset));
+ break;
+ }
+
+ if (r_version < 1)
+ {
+ warning ("unexpected r_debug version %d", r_version);
+ break;
+ }
+
+ if (read_one_ptr (r_debug + lmo->r_map_offset, &lm_addr, ptr_size)
+ != 0)
+ {
+ warning ("unable to read r_map from 0x%s",
+ paddress (r_debug + lmo->r_map_offset));
+ break;
+ }
+
+ /* We read the entire namespace. */
+ lm_prev = 0;
+
+ /* The first entry corresponds to the main executable unless the
dynamic loader was loaded late by a static executable. But
in such case the main executable does not have PT_DYNAMIC
present and we would not have gotten here. */
- if (r_debug == priv->r_debug)
- {
- if (lm_addr != 0)
- string_appendf (document, " main-lm=\"0x%s\">",
- paddress (lm_addr));
- else
- document += ">";
-
- lm_prev = lm_addr;
- if (read_one_ptr (lm_addr + lmo->l_next_offset,
- &lm_addr, ptr_size) != 0)
- {
- warning ("unable to read l_next from 0x%s",
- paddress (lm_addr + lmo->l_next_offset));
- break;
- }
- }
-
- read_link_map (document, r_debug, lm_addr, lm_prev, ptr_size, lmo);
-
- if (r_version < 2)
- break;
-
- if (read_one_ptr (r_debug + lmo->r_next_offset, &r_debug,
- ptr_size) != 0)
- {
- warning ("unable to read r_next from 0x%s",
- paddress (r_debug + lmo->r_next_offset));
- break;
- }
- }
+ if (r_debug == priv->r_debug)
+ {
+ if (lm_addr != 0)
+ string_appendf (document, " main-lm=\"0x%s\">",
+ paddress (lm_addr));
+ else
+ document += ">";
+
+ lm_prev = lm_addr;
+ if (read_one_ptr (lm_addr + lmo->l_next_offset, &lm_addr,
+ ptr_size)
+ != 0)
+ {
+ warning ("unable to read l_next from 0x%s",
+ paddress (lm_addr + lmo->l_next_offset));
+ break;
+ }
+ }
+
+ read_link_map (document, r_debug, lm_addr, lm_prev, ptr_size, lmo);
+
+ if (r_version < 2)
+ break;
+
+ if (read_one_ptr (r_debug + lmo->r_next_offset, &r_debug, ptr_size)
+ != 0)
+ {
+ warning ("unable to read r_next from 0x%s",
+ paddress (r_debug + lmo->r_next_offset));
+ break;
+ }
+ }
}
document += "</library-list-svr4>";
@@ -6722,7 +6639,7 @@ linux_process_target::supports_btrace ()
btrace_target_info *
linux_process_target::enable_btrace (thread_info *tp,
- const btrace_config *conf)
+ const btrace_config *conf)
{
return linux_enable_btrace (tp->id, conf);
}
@@ -6742,17 +6659,18 @@ linux_process_target::disable_btrace (btrace_target_info *tinfo)
static void
linux_low_encode_pt_config (struct buffer *buffer,
- const struct btrace_data_pt_config *config)
+ const struct btrace_data_pt_config *config)
{
buffer_grow_str (buffer, "<pt-config>\n");
switch (config->cpu.vendor)
{
case CV_INTEL:
- buffer_xml_printf (buffer, "<cpu vendor=\"GenuineIntel\" family=\"%u\" "
- "model=\"%u\" stepping=\"%u\"/>\n",
- config->cpu.family, config->cpu.model,
- config->cpu.stepping);
+ buffer_xml_printf (buffer,
+ "<cpu vendor=\"GenuineIntel\" family=\"%u\" "
+ "model=\"%u\" stepping=\"%u\"/>\n",
+ config->cpu.family, config->cpu.model,
+ config->cpu.stepping);
break;
default:
@@ -6766,7 +6684,7 @@ linux_low_encode_pt_config (struct buffer *buffer,
static void
linux_low_encode_raw (struct buffer *buffer, const gdb_byte *data,
- unsigned int size)
+ unsigned int size)
{
if (size == 0)
return;
@@ -6790,9 +6708,8 @@ linux_low_encode_raw (struct buffer *buffer, const gdb_byte *data,
/* See to_read_btrace target method. */
int
-linux_process_target::read_btrace (btrace_target_info *tinfo,
- buffer *buffer,
- enum btrace_read_type type)
+linux_process_target::read_btrace (btrace_target_info *tinfo, buffer *buffer,
+ enum btrace_read_type type)
{
struct btrace_data btrace;
enum btrace_error err;
@@ -6801,9 +6718,9 @@ linux_process_target::read_btrace (btrace_target_info *tinfo,
if (err != BTRACE_ERR_NONE)
{
if (err == BTRACE_ERR_OVERFLOW)
- buffer_grow_str0 (buffer, "E.Overflow.");
+ buffer_grow_str0 (buffer, "E.Overflow.");
else
- buffer_grow_str0 (buffer, "E.Generic Error.");
+ buffer_grow_str0 (buffer, "E.Generic Error.");
return -1;
}
@@ -6819,8 +6736,8 @@ linux_process_target::read_btrace (btrace_target_info *tinfo,
buffer_grow_str (buffer, "<btrace version=\"1.0\">\n");
for (const btrace_block &block : *btrace.variant.bts.blocks)
- buffer_xml_printf (buffer, "<block begin=\"0x%s\" end=\"0x%s\"/>\n",
- paddress (block.begin), paddress (block.end));
+ buffer_xml_printf (buffer, "<block begin=\"0x%s\" end=\"0x%s\"/>\n",
+ paddress (block.begin), paddress (block.end));
buffer_grow_str0 (buffer, "</btrace>\n");
break;
@@ -6833,7 +6750,7 @@ linux_process_target::read_btrace (btrace_target_info *tinfo,
linux_low_encode_pt_config (buffer, &btrace.variant.pt.config);
linux_low_encode_raw (buffer, btrace.variant.pt.data,
- btrace.variant.pt.size);
+ btrace.variant.pt.size);
buffer_grow_str (buffer, "</pt>\n");
buffer_grow_str0 (buffer, "</btrace>\n");
@@ -6851,33 +6768,34 @@ linux_process_target::read_btrace (btrace_target_info *tinfo,
int
linux_process_target::read_btrace_conf (const btrace_target_info *tinfo,
- buffer *buffer)
+ buffer *buffer)
{
const struct btrace_config *conf;
- buffer_grow_str (buffer, "<!DOCTYPE btrace-conf SYSTEM \"btrace-conf.dtd\">\n");
+ buffer_grow_str (buffer,
+ "<!DOCTYPE btrace-conf SYSTEM \"btrace-conf.dtd\">\n");
buffer_grow_str (buffer, "<btrace-conf version=\"1.0\">\n");
conf = linux_btrace_conf (tinfo);
if (conf != NULL)
{
switch (conf->format)
- {
- case BTRACE_FORMAT_NONE:
- break;
+ {
+ case BTRACE_FORMAT_NONE:
+ break;
- case BTRACE_FORMAT_BTS:
- buffer_xml_printf (buffer, "<bts");
- buffer_xml_printf (buffer, " size=\"0x%x\"", conf->bts.size);
- buffer_xml_printf (buffer, " />\n");
- break;
+ case BTRACE_FORMAT_BTS:
+ buffer_xml_printf (buffer, "<bts");
+ buffer_xml_printf (buffer, " size=\"0x%x\"", conf->bts.size);
+ buffer_xml_printf (buffer, " />\n");
+ break;
- case BTRACE_FORMAT_PT:
- buffer_xml_printf (buffer, "<pt");
- buffer_xml_printf (buffer, " size=\"0x%x\"", conf->pt.size);
- buffer_xml_printf (buffer, "/>\n");
- break;
- }
+ case BTRACE_FORMAT_PT:
+ buffer_xml_printf (buffer, "<pt");
+ buffer_xml_printf (buffer, " size=\"0x%x\"", conf->pt.size);
+ buffer_xml_printf (buffer, "/>\n");
+ break;
+ }
}
buffer_grow_str0 (buffer, "</btrace-conf>\n");
@@ -6902,7 +6820,7 @@ linux_process_target::thread_name (ptid_t thread)
#if USE_THREAD_DB
bool
linux_process_target::thread_handle (ptid_t ptid, gdb_byte **handle,
- int *handle_len)
+ int *handle_len)
{
return thread_db_thread_handle (ptid, handle, handle_len);
}
@@ -6989,26 +6907,26 @@ linux_get_auxv (int pid, int wordsize, CORE_ADDR match, CORE_ADDR *valp)
gdb_assert (wordsize == 4 || wordsize == 8);
while (the_target->read_auxv (pid, offset, data, 2 * wordsize)
- == 2 * wordsize)
+ == 2 * wordsize)
{
if (wordsize == 4)
- {
- uint32_t *data_p = (uint32_t *) data;
- if (data_p[0] == match)
- {
- *valp = data_p[1];
- return 1;
- }
- }
+ {
+ uint32_t *data_p = (uint32_t *) data;
+ if (data_p[0] == match)
+ {
+ *valp = data_p[1];
+ return 1;
+ }
+ }
else
- {
- uint64_t *data_p = (uint64_t *) data;
- if (data_p[0] == match)
- {
- *valp = data_p[1];
- return 1;
- }
- }
+ {
+ uint64_t *data_p = (uint64_t *) data;
+ if (data_p[0] == match)
+ {
+ *valp = data_p[1];
+ return 1;
+ }
+ }
offset += 2 * wordsize;
}
@@ -7040,8 +6958,7 @@ linux_get_hwcap2 (int pid, int wordsize)
void
initialize_regsets_info (struct regsets_info *info)
{
- for (info->num_regsets = 0;
- info->regsets[info->num_regsets].size >= 0;
+ for (info->num_regsets = 0; info->regsets[info->num_regsets].size >= 0;
info->num_regsets++)
;
}
diff --git a/gdbserver/linux-low.h b/gdbserver/linux-low.h
index e672855..a23f186 100644
--- a/gdbserver/linux-low.h
+++ b/gdbserver/linux-low.h
@@ -38,7 +38,8 @@
#ifdef HAVE_LINUX_REGSETS
typedef void (*regset_fill_func) (struct regcache *, void *);
typedef void (*regset_store_func) (struct regcache *, const void *);
-enum regset_type {
+enum regset_type
+{
GENERAL_REGS,
FP_REGS,
EXTENDED_REGS,
@@ -47,8 +48,10 @@ enum regset_type {
/* The arch's regsets array initializer must be terminated with a NULL
regset. */
-#define NULL_REGSET \
- { 0, 0, 0, -1, (enum regset_type) -1, NULL, NULL }
+#define NULL_REGSET \
+ { \
+ 0, 0, 0, -1, (enum regset_type) - 1, NULL, NULL \
+ }
struct regset_info
{
@@ -139,9 +142,8 @@ struct lwp_info;
class linux_process_target : public process_stratum_target
{
public:
-
int create_inferior (const char *program,
- const std::vector<char *> &program_args) override;
+ const std::vector<char *> &program_args) override;
void post_create_inferior () override;
@@ -160,17 +162,16 @@ public:
void resume (thread_resume *resume_info, size_t n) override;
ptid_t wait (ptid_t ptid, target_waitstatus *status,
- target_wait_flags options) override;
+ target_wait_flags options) override;
void fetch_registers (regcache *regcache, int regno) override;
void store_registers (regcache *regcache, int regno) override;
- int read_memory (CORE_ADDR memaddr, unsigned char *myaddr,
- int len) override;
+ int read_memory (CORE_ADDR memaddr, unsigned char *myaddr, int len) override;
int write_memory (CORE_ADDR memaddr, const unsigned char *myaddr,
- int len) override;
+ int len) override;
void look_up_symbols () override;
@@ -179,13 +180,13 @@ public:
bool supports_read_auxv () override;
int read_auxv (int pid, CORE_ADDR offset, unsigned char *myaddr,
- unsigned int len) override;
+ unsigned int len) override;
- int insert_point (enum raw_bkpt_type type, CORE_ADDR addr,
- int size, raw_breakpoint *bp) override;
+ int insert_point (enum raw_bkpt_type type, CORE_ADDR addr, int size,
+ raw_breakpoint *bp) override;
- int remove_point (enum raw_bkpt_type type, CORE_ADDR addr,
- int size, raw_breakpoint *bp) override;
+ int remove_point (enum raw_bkpt_type type, CORE_ADDR addr, int size,
+ raw_breakpoint *bp) override;
bool stopped_by_sw_breakpoint () override;
@@ -208,19 +209,19 @@ public:
bool supports_get_tls_address () override;
int get_tls_address (thread_info *thread, CORE_ADDR offset,
- CORE_ADDR load_module, CORE_ADDR *address) override;
+ CORE_ADDR load_module, CORE_ADDR *address) override;
bool supports_qxfer_osdata () override;
int qxfer_osdata (const char *annex, unsigned char *readbuf,
- unsigned const char *writebuf,
- CORE_ADDR offset, int len) override;
+ unsigned const char *writebuf, CORE_ADDR offset,
+ int len) override;
bool supports_qxfer_siginfo () override;
int qxfer_siginfo (const char *annex, unsigned char *readbuf,
- unsigned const char *writebuf,
- CORE_ADDR offset, int len) override;
+ unsigned const char *writebuf, CORE_ADDR offset,
+ int len) override;
bool supports_non_stop () override;
@@ -245,8 +246,8 @@ public:
#if defined PT_GETDSBT || defined PTRACE_GETFDPIC
bool supports_read_loadmap () override;
- int read_loadmap (const char *annex, CORE_ADDR offset,
- unsigned char *myaddr, unsigned int len) override;
+ int read_loadmap (const char *annex, CORE_ADDR offset, unsigned char *myaddr,
+ unsigned int len) override;
#endif
CORE_ADDR read_pc (regcache *regcache) override;
@@ -267,10 +268,9 @@ public:
bool supports_qxfer_libraries_svr4 () override;
- int qxfer_libraries_svr4 (const char *annex,
- unsigned char *readbuf,
- unsigned const char *writebuf,
- CORE_ADDR offset, int len) override;
+ int qxfer_libraries_svr4 (const char *annex, unsigned char *readbuf,
+ unsigned const char *writebuf, CORE_ADDR offset,
+ int len) override;
bool supports_agent () override;
@@ -278,15 +278,14 @@ public:
bool supports_btrace () override;
btrace_target_info *enable_btrace (thread_info *tp,
- const btrace_config *conf) override;
+ const btrace_config *conf) override;
int disable_btrace (btrace_target_info *tinfo) override;
int read_btrace (btrace_target_info *tinfo, buffer *buf,
- enum btrace_read_type type) override;
+ enum btrace_read_type type) override;
- int read_btrace_conf (const btrace_target_info *tinfo,
- buffer *buf) override;
+ int read_btrace_conf (const btrace_target_info *tinfo, buffer *buf) override;
#endif
bool supports_range_stepping () override;
@@ -298,18 +297,18 @@ public:
bool supports_multifs () override;
int multifs_open (int pid, const char *filename, int flags,
- mode_t mode) override;
+ mode_t mode) override;
int multifs_unlink (int pid, const char *filename) override;
ssize_t multifs_readlink (int pid, const char *filename, char *buf,
- size_t bufsiz) override;
+ size_t bufsiz) override;
const char *thread_name (ptid_t thread) override;
#if USE_THREAD_DB
bool thread_handle (ptid_t ptid, gdb_byte **handle,
- int *handle_len) override;
+ int *handle_len) override;
#endif
thread_info *thread_pending_parent (thread_info *thread) override;
@@ -322,7 +321,6 @@ public:
virtual const regs_info *get_regs_info () = 0;
private:
-
/* Handle a GNU/Linux extended wait response. If we see a clone,
fork, or vfork event, we need to add the new LWP to our list
(and return 0 so as not to report the trap to higher layers).
@@ -344,7 +342,7 @@ private:
OPTIONS contains WNOHANG. Return -1 if no unwaited-for children
was found. Return the PID of the stopped child otherwise. */
int wait_for_event_filtered (ptid_t wait_ptid, ptid_t filter_ptid,
- int *wstatp, int options);
+ int *wstatp, int options);
/* Wait for an event from child(ren) PTID. PTIDs can be:
minus_one_ptid, to specify any child; a pid PTID, specifying all
@@ -360,7 +358,7 @@ private:
/* Wait for process, returns status. */
ptid_t wait_1 (ptid_t ptid, target_waitstatus *ourstatus,
- target_wait_flags target_options);
+ target_wait_flags target_options);
/* Stop all lwps that aren't stopped yet, except EXCEPT, if not NULL.
If SUSPEND, then also increase the suspend count of every LWP,
@@ -416,11 +414,11 @@ private:
#ifdef HAVE_LINUX_USRREGS
/* Fetch one register. */
void fetch_register (const usrregs_info *usrregs, regcache *regcache,
- int regno);
+ int regno);
/* Store one register. */
void store_register (const usrregs_info *usrregs, regcache *regcache,
- int regno);
+ int regno);
#endif
/* Fetch all registers, or just one, from the child process.
@@ -429,7 +427,7 @@ private:
unless ALL is non-zero.
Otherwise, REGNO specifies which register (so we can save time). */
void usr_fetch_inferior_registers (const regs_info *regs_info,
- regcache *regcache, int regno, int all);
+ regcache *regcache, int regno, int all);
/* Store our register values back into the inferior.
If REGNO is -1, do this for all registers, skipping any that are
@@ -437,7 +435,7 @@ private:
unless ALL is non-zero.
Otherwise, REGNO specifies which register (so we can save time). */
void usr_store_inferior_registers (const regs_info *regs_info,
- regcache *regcache, int regno, int all);
+ regcache *regcache, int regno, int all);
/* Return the PC as read from the regcache of LWP, without any
adjustment. */
@@ -453,7 +451,7 @@ private:
/* Resume execution of LWP. If STEP is nonzero, single-step it. If
SIGNAL is nonzero, give it that signal. */
void resume_one_lwp_throw (lwp_info *lwp, int step, int signal,
- siginfo_t *info);
+ siginfo_t *info);
/* Like resume_one_lwp_throw, but no error is thrown if the LWP
disappears while we try to resume it. */
@@ -512,7 +510,7 @@ private:
/* Single step via hardware or software single step.
Return 1 if hardware single stepping, 0 if software single stepping
or can't single step. */
- int single_step (lwp_info* lwp);
+ int single_step (lwp_info *lwp);
/* Return true if THREAD is doing hardware single step. */
bool maybe_hw_step (thread_info *thread);
@@ -539,7 +537,7 @@ private:
/* Convert a native/host siginfo object, into/from the siginfo in the
layout of the inferiors' architecture. */
void siginfo_fixup (siginfo_t *siginfo, gdb_byte *inf_siginfo,
- int direction);
+ int direction);
/* Add a process to the common process list, and set its private
data. */
@@ -550,7 +548,7 @@ private:
process_info *add_linux_process_no_mem_file (int pid, int attached);
/* Free resources associated to PROC and remove it. */
- void remove_linux_process (process_info *proc);
+ void remove_linux_process (process_info *proc);
/* Add a new thread. */
lwp_info *add_lwp (ptid_t ptid);
@@ -577,7 +575,7 @@ private: /* Back to private. */
process exit event, a thread exit event, or to suppress the
event. */
ptid_t filter_exit_event (lwp_info *event_child,
- target_waitstatus *ourstatus);
+ target_waitstatus *ourstatus);
/* Returns true if THREAD is stopped in a jump pad, and we can't
move it out, because we need to report the stop event to GDB. For
@@ -587,8 +585,9 @@ private: /* Back to private. */
/* Convenience wrapper. Returns information about LWP's fast tracepoint
collection status. */
- fast_tpoint_collect_result linux_fast_tracepoint_collecting
- (lwp_info *lwp, fast_tpoint_collect_status *status);
+ fast_tpoint_collect_result
+ linux_fast_tracepoint_collecting (lwp_info *lwp,
+ fast_tpoint_collect_status *status);
/* This function should only be called if LWP got a SYSCALL_SIGTRAP.
Fill *SYSNO with the syscall nr trapped. */
@@ -635,11 +634,11 @@ protected:
/* Breakpoint and watchpoint related functions. See target.h for
comments. */
- virtual int low_insert_point (raw_bkpt_type type, CORE_ADDR addr,
- int size, raw_breakpoint *bp);
+ virtual int low_insert_point (raw_bkpt_type type, CORE_ADDR addr, int size,
+ raw_breakpoint *bp);
- virtual int low_remove_point (raw_bkpt_type type, CORE_ADDR addr,
- int size, raw_breakpoint *bp);
+ virtual int low_remove_point (raw_bkpt_type type, CORE_ADDR addr, int size,
+ raw_breakpoint *bp);
virtual bool low_stopped_by_watchpoint ();
@@ -648,17 +647,17 @@ protected:
/* Hooks to reformat register data for PEEKUSR/POKEUSR (in particular
for registers smaller than an xfer unit). */
virtual void low_collect_ptrace_register (regcache *regcache, int regno,
- char *buf);
+ char *buf);
virtual void low_supply_ptrace_register (regcache *regcache, int regno,
- const char *buf);
+ const char *buf);
/* Hook to convert from target format to ptrace format and back.
Returns true if any conversion was done; false otherwise.
If DIRECTION is 1, then copy from INF to NATIVE.
If DIRECTION is 0, copy from NATIVE to INF. */
virtual bool low_siginfo_fixup (siginfo_t *native, gdb_byte *inf,
- int direction);
+ int direction);
/* Hook to call when a new process is created or attached to.
If extra per-process architecture-specific data is needed,
@@ -712,9 +711,7 @@ extern linux_process_target *the_linux_target;
struct pending_signal
{
- pending_signal (int signal)
- : signal {signal}
- {};
+ pending_signal (int signal) : signal { signal } {};
int signal;
siginfo_t info;
@@ -746,15 +743,14 @@ struct lwp_info
at most. So we can recognize who is the parent based on which one has
a pending status. */
gdb_assert (!!this->status_pending_p
- != !!this->fork_relative->status_pending_p);
+ != !!this->fork_relative->status_pending_p);
if (!this->fork_relative->status_pending_p)
return nullptr;
- const target_waitstatus &ws
- = this->fork_relative->waitstatus;
+ const target_waitstatus &ws = this->fork_relative->waitstatus;
gdb_assert (ws.kind () == TARGET_WAITKIND_FORKED
- || ws.kind () == TARGET_WAITKIND_VFORKED);
+ || ws.kind () == TARGET_WAITKIND_VFORKED);
return this->fork_relative;
}
@@ -773,14 +769,14 @@ struct lwp_info
at most. So we can recognize who is the parent based on which one has
a pending status. */
gdb_assert (!!this->status_pending_p
- != !!this->fork_relative->status_pending_p);
+ != !!this->fork_relative->status_pending_p);
if (!this->status_pending_p)
return nullptr;
const target_waitstatus &ws = this->waitstatus;
gdb_assert (ws.kind () == TARGET_WAITKIND_FORKED
- || ws.kind () == TARGET_WAITKIND_VFORKED);
+ || ws.kind () == TARGET_WAITKIND_VFORKED);
return this->fork_relative;
}
@@ -858,7 +854,7 @@ struct lwp_info
passed along the last resume request. See 'struct
thread_resume'. */
CORE_ADDR step_range_start = 0; /* Inclusive */
- CORE_ADDR step_range_end = 0; /* Exclusive */
+ CORE_ADDR step_range_end = 0; /* Exclusive */
/* If this flag is set, we need to set the event request flags the
next time we see this LWP stop. */
@@ -928,14 +924,15 @@ void thread_db_detach (struct process_info *);
void thread_db_mourn (struct process_info *);
int thread_db_handle_monitor_command (char *);
int thread_db_get_tls_address (struct thread_info *thread, CORE_ADDR offset,
- CORE_ADDR load_module, CORE_ADDR *address);
+ CORE_ADDR load_module, CORE_ADDR *address);
int thread_db_look_up_one_symbol (const char *name, CORE_ADDR *addrp);
/* Called from linux-low.c when a clone event is detected. Upon entry,
both the clone and the parent should be stopped. This function does
whatever is required have the clone under thread_db's control. */
-void thread_db_notice_clone (struct thread_info *parent_thr, ptid_t child_ptid);
+void thread_db_notice_clone (struct thread_info *parent_thr,
+ ptid_t child_ptid);
bool thread_db_thread_handle (ptid_t ptid, gdb_byte **handle, int *handle_len);
diff --git a/gdbserver/linux-m68k-low.cc b/gdbserver/linux-m68k-low.cc
index 6094fd9..e336e1d 100644
--- a/gdbserver/linux-m68k-low.cc
+++ b/gdbserver/linux-m68k-low.cc
@@ -24,13 +24,11 @@
class m68k_target : public linux_process_target
{
public:
-
const regs_info *get_regs_info () override;
const gdb_byte *sw_breakpoint_from_kind (int kind, int *size) override;
protected:
-
void low_arch_setup () override;
bool low_cannot_fetch_register (int regno) override;
@@ -88,26 +86,21 @@ extern const struct target_desc *tdesc_m68k;
#define m68k_num_gregs 18
/* This table must line up with REGISTER_NAMES in tm-m68k.h */
-static int m68k_regmap[] =
-{
+static int m68k_regmap[] = {
#ifdef PT_D0
- PT_D0 * 4, PT_D1 * 4, PT_D2 * 4, PT_D3 * 4,
- PT_D4 * 4, PT_D5 * 4, PT_D6 * 4, PT_D7 * 4,
- PT_A0 * 4, PT_A1 * 4, PT_A2 * 4, PT_A3 * 4,
- PT_A4 * 4, PT_A5 * 4, PT_A6 * 4, PT_USP * 4,
- PT_SR * 4, PT_PC * 4,
+ PT_D0 * 4, PT_D1 * 4, PT_D2 * 4, PT_D3 * 4, PT_D4 * 4, PT_D5 * 4,
+ PT_D6 * 4, PT_D7 * 4, PT_A0 * 4, PT_A1 * 4, PT_A2 * 4, PT_A3 * 4,
+ PT_A4 * 4, PT_A5 * 4, PT_A6 * 4, PT_USP * 4, PT_SR * 4, PT_PC * 4,
#else
- 14 * 4, 0 * 4, 1 * 4, 2 * 4, 3 * 4, 4 * 4, 5 * 4, 6 * 4,
- 7 * 4, 8 * 4, 9 * 4, 10 * 4, 11 * 4, 12 * 4, 13 * 4, 15 * 4,
- 17 * 4, 18 * 4,
+ 14 * 4, 0 * 4, 1 * 4, 2 * 4, 3 * 4, 4 * 4, 5 * 4, 6 * 4, 7 * 4,
+ 8 * 4, 9 * 4, 10 * 4, 11 * 4, 12 * 4, 13 * 4, 15 * 4, 17 * 4, 18 * 4,
#endif
#ifdef PT_FP0
- PT_FP0 * 4, PT_FP1 * 4, PT_FP2 * 4, PT_FP3 * 4,
- PT_FP4 * 4, PT_FP5 * 4, PT_FP6 * 4, PT_FP7 * 4,
- PT_FPCR * 4, PT_FPSR * 4, PT_FPIAR * 4
+ PT_FP0 * 4, PT_FP1 * 4, PT_FP2 * 4, PT_FP3 * 4, PT_FP4 * 4, PT_FP5 * 4,
+ PT_FP6 * 4, PT_FP7 * 4, PT_FPCR * 4, PT_FPSR * 4, PT_FPIAR * 4
#else
- 21 * 4, 24 * 4, 27 * 4, 30 * 4, 33 * 4, 36 * 4,
- 39 * 4, 42 * 4, 45 * 4, 46 * 4, 47 * 4
+ 21 * 4, 24 * 4, 27 * 4, 30 * 4, 33 * 4, 36 * 4, 39 * 4, 42 * 4, 45 * 4,
+ 46 * 4, 47 * 4
#endif
};
@@ -151,8 +144,9 @@ m68k_fill_fpregset (struct regcache *regcache, void *buf)
int i;
for (i = m68k_num_gregs; i < m68k_num_regs; i++)
- collect_register (regcache, i, ((char *) buf
- + (m68k_regmap[i] - m68k_regmap[m68k_num_gregs])));
+ collect_register (regcache, i,
+ ((char *) buf
+ + (m68k_regmap[i] - m68k_regmap[m68k_num_gregs])));
}
static void
@@ -161,19 +155,18 @@ m68k_store_fpregset (struct regcache *regcache, const void *buf)
int i;
for (i = m68k_num_gregs; i < m68k_num_regs; i++)
- supply_register (regcache, i, ((const char *) buf
- + (m68k_regmap[i] - m68k_regmap[m68k_num_gregs])));
+ supply_register (regcache, i,
+ ((const char *) buf
+ + (m68k_regmap[i] - m68k_regmap[m68k_num_gregs])));
}
#endif /* HAVE_PTRACE_GETREGS */
static struct regset_info m68k_regsets[] = {
#ifdef HAVE_PTRACE_GETREGS
- { PTRACE_GETREGS, PTRACE_SETREGS, 0, sizeof (elf_gregset_t),
- GENERAL_REGS,
+ { PTRACE_GETREGS, PTRACE_SETREGS, 0, sizeof (elf_gregset_t), GENERAL_REGS,
m68k_fill_gregset, m68k_store_gregset },
- { PTRACE_GETFPREGS, PTRACE_SETFPREGS, 0, sizeof (elf_fpregset_t),
- FP_REGS,
+ { PTRACE_GETFPREGS, PTRACE_SETFPREGS, 0, sizeof (elf_fpregset_t), FP_REGS,
m68k_fill_fpregset, m68k_store_fpregset },
#endif /* HAVE_PTRACE_GETREGS */
NULL_REGSET
@@ -209,8 +202,8 @@ m68k_target::low_breakpoint_at (CORE_ADDR pc)
/* Fetch the thread-local storage pointer for libthread_db. */
ps_err_e
-ps_get_thread_area (struct ps_prochandle *ph,
- lwpid_t lwpid, int idx, void **base)
+ps_get_thread_area (struct ps_prochandle *ph, lwpid_t lwpid, int idx,
+ void **base)
{
if (ptrace (PTRACE_GET_THREAD_AREA, lwpid, NULL, base) != 0)
return PS_ERR;
@@ -218,31 +211,26 @@ ps_get_thread_area (struct ps_prochandle *ph,
/* IDX is the bias from the thread pointer to the beginning of the
thread descriptor. It has to be subtracted due to implementation
quirks in libthread_db. */
- *base = (void *) ((char *)*base - idx);
+ *base = (void *) ((char *) *base - idx);
return PS_OK;
}
#endif /* PTRACE_GET_THREAD_AREA */
-static struct regsets_info m68k_regsets_info =
- {
- m68k_regsets, /* regsets */
- 0, /* num_regsets */
- NULL, /* disabled_regsets */
- };
-
-static struct usrregs_info m68k_usrregs_info =
- {
- m68k_num_regs,
- m68k_regmap,
- };
-
-static struct regs_info myregs_info =
- {
- NULL, /* regset_bitmap */
- &m68k_usrregs_info,
- &m68k_regsets_info
- };
+static struct regsets_info m68k_regsets_info = {
+ m68k_regsets, /* regsets */
+ 0, /* num_regsets */
+ NULL, /* disabled_regsets */
+};
+
+static struct usrregs_info m68k_usrregs_info = {
+ m68k_num_regs,
+ m68k_regmap,
+};
+
+static struct regs_info myregs_info
+ = { NULL, /* regset_bitmap */
+ &m68k_usrregs_info, &m68k_regsets_info };
const regs_info *
m68k_target::get_regs_info ()
diff --git a/gdbserver/linux-mips-low.cc b/gdbserver/linux-mips-low.cc
index 2cbe522..35a83b7 100644
--- a/gdbserver/linux-mips-low.cc
+++ b/gdbserver/linux-mips-low.cc
@@ -30,7 +30,6 @@
class mips_target : public linux_process_target
{
public:
-
const regs_info *get_regs_info () override;
const gdb_byte *sw_breakpoint_from_kind (int kind, int *size) override;
@@ -38,7 +37,6 @@ public:
bool supports_z_point_type (char z_type) override;
protected:
-
void low_arch_setup () override;
bool low_cannot_fetch_register (int regno) override;
@@ -55,21 +53,21 @@ protected:
bool low_breakpoint_at (CORE_ADDR pc) override;
- int low_insert_point (raw_bkpt_type type, CORE_ADDR addr,
- int size, raw_breakpoint *bp) override;
+ int low_insert_point (raw_bkpt_type type, CORE_ADDR addr, int size,
+ raw_breakpoint *bp) override;
- int low_remove_point (raw_bkpt_type type, CORE_ADDR addr,
- int size, raw_breakpoint *bp) override;
+ int low_remove_point (raw_bkpt_type type, CORE_ADDR addr, int size,
+ raw_breakpoint *bp) override;
bool low_stopped_by_watchpoint () override;
CORE_ADDR low_stopped_data_address () override;
void low_collect_ptrace_register (regcache *regcache, int regno,
- char *buf) override;
+ char *buf) override;
void low_supply_ptrace_register (regcache *regcache, int regno,
- const char *buf) override;
+ const char *buf) override;
arch_process_info *low_new_process () override;
@@ -138,46 +136,35 @@ union mips_register
/* Return the ptrace ``address'' of register REGNO. */
-#define mips_base_regs \
- -1, 1, 2, 3, 4, 5, 6, 7, \
- 8, 9, 10, 11, 12, 13, 14, 15, \
- 16, 17, 18, 19, 20, 21, 22, 23, \
- 24, 25, 26, 27, 28, 29, 30, 31, \
- \
- -1, MMLO, MMHI, BADVADDR, CAUSE, PC, \
- \
- FPR_BASE, FPR_BASE + 1, FPR_BASE + 2, FPR_BASE + 3, \
- FPR_BASE + 4, FPR_BASE + 5, FPR_BASE + 6, FPR_BASE + 7, \
- FPR_BASE + 8, FPR_BASE + 9, FPR_BASE + 10, FPR_BASE + 11, \
- FPR_BASE + 12, FPR_BASE + 13, FPR_BASE + 14, FPR_BASE + 15, \
- FPR_BASE + 16, FPR_BASE + 17, FPR_BASE + 18, FPR_BASE + 19, \
- FPR_BASE + 20, FPR_BASE + 21, FPR_BASE + 22, FPR_BASE + 23, \
- FPR_BASE + 24, FPR_BASE + 25, FPR_BASE + 26, FPR_BASE + 27, \
- FPR_BASE + 28, FPR_BASE + 29, FPR_BASE + 30, FPR_BASE + 31, \
- FPC_CSR, FPC_EIR
-
-#define mips_dsp_regs \
- DSP_BASE, DSP_BASE + 1, DSP_BASE + 2, DSP_BASE + 3, \
- DSP_BASE + 4, DSP_BASE + 5, \
- DSP_CONTROL
-
-static int mips_regmap[mips_num_regs] = {
- mips_base_regs,
- 0
-};
-
-static int mips_dsp_regmap[mips_dsp_num_regs] = {
- mips_base_regs,
- mips_dsp_regs,
- 0
-};
+#define mips_base_regs \
+ -1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, \
+ 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, \
+ \
+ -1, MMLO, MMHI, BADVADDR, CAUSE, PC, \
+ \
+ FPR_BASE, FPR_BASE + 1, FPR_BASE + 2, FPR_BASE + 3, FPR_BASE + 4, \
+ FPR_BASE + 5, FPR_BASE + 6, FPR_BASE + 7, FPR_BASE + 8, FPR_BASE + 9, \
+ FPR_BASE + 10, FPR_BASE + 11, FPR_BASE + 12, FPR_BASE + 13, \
+ FPR_BASE + 14, FPR_BASE + 15, FPR_BASE + 16, FPR_BASE + 17, \
+ FPR_BASE + 18, FPR_BASE + 19, FPR_BASE + 20, FPR_BASE + 21, \
+ FPR_BASE + 22, FPR_BASE + 23, FPR_BASE + 24, FPR_BASE + 25, \
+ FPR_BASE + 26, FPR_BASE + 27, FPR_BASE + 28, FPR_BASE + 29, \
+ FPR_BASE + 30, FPR_BASE + 31, FPC_CSR, FPC_EIR
+
+#define mips_dsp_regs \
+ DSP_BASE, DSP_BASE + 1, DSP_BASE + 2, DSP_BASE + 3, DSP_BASE + 4, \
+ DSP_BASE + 5, DSP_CONTROL
+
+static int mips_regmap[mips_num_regs] = { mips_base_regs, 0 };
+
+static int mips_dsp_regmap[mips_dsp_num_regs]
+ = { mips_base_regs, mips_dsp_regs, 0 };
/* DSP registers are not in any regset and can only be accessed
individually. */
-static unsigned char mips_dsp_regset_bitmap[(mips_dsp_num_regs + 7) / 8] = {
- 0xfe, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x80
-};
+static unsigned char mips_dsp_regset_bitmap[(mips_dsp_num_regs + 7) / 8]
+ = { 0xfe, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x80 };
static int have_dsp = -1;
@@ -194,17 +181,17 @@ mips_read_description (void)
errno = 0;
ptrace (PTRACE_PEEKUSER, pid, DSP_CONTROL, 0);
switch (errno)
- {
- case 0:
- have_dsp = 1;
- break;
- case EIO:
- have_dsp = 0;
- break;
- default:
- perror_with_name ("ptrace");
- break;
- }
+ {
+ case 0:
+ have_dsp = 1;
+ break;
+ case EIO:
+ have_dsp = 0;
+ break;
+ default:
+ perror_with_name ("ptrace");
+ break;
+ }
}
return have_dsp ? tdesc_mips_dsp_linux : tdesc_mips_linux;
@@ -435,7 +422,7 @@ mips_target::low_delete_thread (arch_lwp_info *arch_lwp)
static void
mips_add_watchpoint (struct arch_process_info *priv, CORE_ADDR addr, int len,
- enum target_hw_bp_type watch_type)
+ enum target_hw_bp_type watch_type)
{
struct mips_watchpoint *new_watch;
struct mips_watchpoint **pw;
@@ -455,18 +442,15 @@ mips_add_watchpoint (struct arch_process_info *priv, CORE_ADDR addr, int len,
/* Hook to call when a new fork is attached. */
void
-mips_target::low_new_fork (process_info *parent,
- process_info *child)
+mips_target::low_new_fork (process_info *parent, process_info *child)
{
struct arch_process_info *parent_private;
struct arch_process_info *child_private;
struct mips_watchpoint *wp;
/* These are allocated by linux_add_process. */
- gdb_assert (parent->priv != NULL
- && parent->priv->arch_private != NULL);
- gdb_assert (child->priv != NULL
- && child->priv->arch_private != NULL);
+ gdb_assert (parent->priv != NULL && parent->priv->arch_private != NULL);
+ gdb_assert (child->priv != NULL && child->priv->arch_private != NULL);
/* Linux kernel before 2.6.33 commit
72f674d203cd230426437cdcf7dd6f681dad8b0d
@@ -509,14 +493,15 @@ mips_target::low_prepare_to_resume (lwp_info *lwp)
/* Only update the watch registers if we have set or unset a
watchpoint already. */
if (mips_linux_watch_get_num_valid (&priv->watch_mirror) > 0)
- {
- /* Write the mirrored watch register values. */
- int tid = ptid.lwp ();
+ {
+ /* Write the mirrored watch register values. */
+ int tid = ptid.lwp ();
- if (-1 == ptrace (PTRACE_SET_WATCH_REGS, tid,
- &priv->watch_mirror, NULL))
- perror_with_name ("Couldn't write watch register");
- }
+ if (-1
+ == ptrace (PTRACE_SET_WATCH_REGS, tid, &priv->watch_mirror,
+ NULL))
+ perror_with_name ("Couldn't write watch register");
+ }
lwp->arch_private->watch_registers_changed = 0;
}
@@ -540,8 +525,8 @@ mips_target::supports_z_point_type (char z_type)
low_insert_point. */
int
-mips_target::low_insert_point (raw_bkpt_type type, CORE_ADDR addr,
- int len, raw_breakpoint *bp)
+mips_target::low_insert_point (raw_bkpt_type type, CORE_ADDR addr, int len,
+ raw_breakpoint *bp)
{
struct process_info *proc = current_process ();
struct arch_process_info *priv = proc->priv->arch_private;
@@ -551,10 +536,8 @@ mips_target::low_insert_point (raw_bkpt_type type, CORE_ADDR addr,
uint32_t irw;
lwpid = lwpid_of (current_thread);
- if (!mips_linux_read_watch_registers (lwpid,
- &priv->watch_readback,
- &priv->watch_readback_valid,
- 0))
+ if (!mips_linux_read_watch_registers (lwpid, &priv->watch_readback,
+ &priv->watch_readback_valid, 0))
return -1;
if (len <= 0)
@@ -585,8 +568,8 @@ mips_target::low_insert_point (raw_bkpt_type type, CORE_ADDR addr,
low_remove_point. */
int
-mips_target::low_remove_point (raw_bkpt_type type, CORE_ADDR addr,
- int len, raw_breakpoint *bp)
+mips_target::low_remove_point (raw_bkpt_type type, CORE_ADDR addr, int len,
+ raw_breakpoint *bp)
{
struct process_info *proc = current_process ();
struct arch_process_info *priv = proc->priv->arch_private;
@@ -604,25 +587,24 @@ mips_target::low_remove_point (raw_bkpt_type type, CORE_ADDR addr,
while ((w = *pw))
{
if (w->addr == addr && w->len == len && w->type == watch_type)
- {
- *pw = w->next;
- free (w);
- deleted_one = 1;
- break;
- }
+ {
+ *pw = w->next;
+ free (w);
+ deleted_one = 1;
+ break;
+ }
pw = &(w->next);
}
if (!deleted_one)
- return -1; /* We don't know about it, fail doing nothing. */
+ return -1; /* We don't know about it, fail doing nothing. */
/* At this point watch_readback is known to be valid because we
could not have added the watch without reading it. */
gdb_assert (priv->watch_readback_valid == 1);
priv->watch_mirror = priv->watch_readback;
- mips_linux_watch_populate_regs (priv->current_watches,
- &priv->watch_mirror);
+ mips_linux_watch_populate_regs (priv->current_watches, &priv->watch_mirror);
/* Only update the threads of this process. */
for_each_thread (proc->pid, update_watch_registers_callback);
@@ -643,17 +625,15 @@ mips_target::low_stopped_by_watchpoint ()
int num_valid;
long lwpid = lwpid_of (current_thread);
- if (!mips_linux_read_watch_registers (lwpid,
- &priv->watch_readback,
- &priv->watch_readback_valid,
- 1))
+ if (!mips_linux_read_watch_registers (lwpid, &priv->watch_readback,
+ &priv->watch_readback_valid, 1))
return 0;
num_valid = mips_linux_watch_get_num_valid (&priv->watch_readback);
for (n = 0; n < MAX_DEBUG_REGISTER && n < num_valid; n++)
if (mips_linux_watch_get_watchhi (&priv->watch_readback, n)
- & (R_MASK | W_MASK))
+ & (R_MASK | W_MASK))
return true;
return false;
@@ -677,44 +657,40 @@ mips_target::low_stopped_data_address ()
address of a watchpoint request which overlaps the one that
triggered. */
- if (!mips_linux_read_watch_registers (lwpid,
- &priv->watch_readback,
- &priv->watch_readback_valid,
- 0))
+ if (!mips_linux_read_watch_registers (lwpid, &priv->watch_readback,
+ &priv->watch_readback_valid, 0))
return 0;
num_valid = mips_linux_watch_get_num_valid (&priv->watch_readback);
for (n = 0; n < MAX_DEBUG_REGISTER && n < num_valid; n++)
if (mips_linux_watch_get_watchhi (&priv->watch_readback, n)
- & (R_MASK | W_MASK))
+ & (R_MASK | W_MASK))
{
- CORE_ADDR t_low, t_hi;
- int t_irw;
- struct mips_watchpoint *watch;
-
- t_low = mips_linux_watch_get_watchlo (&priv->watch_readback, n);
- t_irw = t_low & IRW_MASK;
- t_hi = (mips_linux_watch_get_watchhi (&priv->watch_readback, n)
- | IRW_MASK);
- t_low &= ~(CORE_ADDR)t_hi;
-
- for (watch = priv->current_watches;
- watch != NULL;
- watch = watch->next)
- {
- CORE_ADDR addr = watch->addr;
- CORE_ADDR last_byte = addr + watch->len - 1;
-
- if ((t_irw & mips_linux_watch_type_to_irw (watch->type)) == 0)
- {
- /* Different type. */
- continue;
- }
- /* Check for overlap of even a single byte. */
- if (last_byte >= t_low && addr <= t_low + t_hi)
- return addr;
- }
+ CORE_ADDR t_low, t_hi;
+ int t_irw;
+ struct mips_watchpoint *watch;
+
+ t_low = mips_linux_watch_get_watchlo (&priv->watch_readback, n);
+ t_irw = t_low & IRW_MASK;
+ t_hi = (mips_linux_watch_get_watchhi (&priv->watch_readback, n)
+ | IRW_MASK);
+ t_low &= ~(CORE_ADDR) t_hi;
+
+ for (watch = priv->current_watches; watch != NULL; watch = watch->next)
+ {
+ CORE_ADDR addr = watch->addr;
+ CORE_ADDR last_byte = addr + watch->len - 1;
+
+ if ((t_irw & mips_linux_watch_type_to_irw (watch->type)) == 0)
+ {
+ /* Different type. */
+ continue;
+ }
+ /* Check for overlap of even a single byte. */
+ if (last_byte >= t_low && addr <= t_low + t_hi)
+ return addr;
+ }
}
/* Shouldn't happen. */
@@ -724,8 +700,8 @@ mips_target::low_stopped_data_address ()
/* Fetch the thread-local storage pointer for libthread_db. */
ps_err_e
-ps_get_thread_area (struct ps_prochandle *ph,
- lwpid_t lwpid, int idx, void **base)
+ps_get_thread_area (struct ps_prochandle *ph, lwpid_t lwpid, int idx,
+ void **base)
{
if (ptrace (PTRACE_GET_THREAD_AREA, lwpid, NULL, base) != 0)
return PS_ERR;
@@ -733,14 +709,14 @@ ps_get_thread_area (struct ps_prochandle *ph,
/* IDX is the bias from the thread pointer to the beginning of the
thread descriptor. It has to be subtracted due to implementation
quirks in libthread_db. */
- *base = (void *) ((char *)*base - idx);
+ *base = (void *) ((char *) *base - idx);
return PS_OK;
}
static void
-mips_collect_register (struct regcache *regcache,
- int use_64bit, int regno, union mips_register *reg)
+mips_collect_register (struct regcache *regcache, int use_64bit, int regno,
+ union mips_register *reg)
{
union mips_register tmp_reg;
@@ -757,8 +733,8 @@ mips_collect_register (struct regcache *regcache,
}
static void
-mips_supply_register (struct regcache *regcache,
- int use_64bit, int regno, const union mips_register *reg)
+mips_supply_register (struct regcache *regcache, int use_64bit, int regno,
+ const union mips_register *reg)
{
int offset = 0;
@@ -773,8 +749,8 @@ mips_supply_register (struct regcache *regcache,
#ifdef HAVE_PTRACE_GETREGS
static void
-mips_collect_register_32bit (struct regcache *regcache,
- int use_64bit, int regno, unsigned char *buf)
+mips_collect_register_32bit (struct regcache *regcache, int use_64bit,
+ int regno, unsigned char *buf)
{
union mips_register tmp_reg;
int reg32;
@@ -785,8 +761,8 @@ mips_collect_register_32bit (struct regcache *regcache,
}
static void
-mips_supply_register_32bit (struct regcache *regcache,
- int use_64bit, int regno, const unsigned char *buf)
+mips_supply_register_32bit (struct regcache *regcache, int use_64bit,
+ int regno, const unsigned char *buf)
{
union mips_register tmp_reg;
int reg32;
@@ -808,21 +784,21 @@ mips_fill_gregset (struct regcache *regcache, void *buf)
for (i = 1; i < 32; i++)
mips_collect_register (regcache, use_64bit, i, regset + i);
- mips_collect_register (regcache, use_64bit,
- find_regno (tdesc, "lo"), regset + 32);
- mips_collect_register (regcache, use_64bit,
- find_regno (tdesc, "hi"), regset + 33);
- mips_collect_register (regcache, use_64bit,
- find_regno (tdesc, "pc"), regset + 34);
- mips_collect_register (regcache, use_64bit,
- find_regno (tdesc, "badvaddr"), regset + 35);
- mips_collect_register (regcache, use_64bit,
- find_regno (tdesc, "status"), regset + 36);
- mips_collect_register (regcache, use_64bit,
- find_regno (tdesc, "cause"), regset + 37);
+ mips_collect_register (regcache, use_64bit, find_regno (tdesc, "lo"),
+ regset + 32);
+ mips_collect_register (regcache, use_64bit, find_regno (tdesc, "hi"),
+ regset + 33);
+ mips_collect_register (regcache, use_64bit, find_regno (tdesc, "pc"),
+ regset + 34);
+ mips_collect_register (regcache, use_64bit, find_regno (tdesc, "badvaddr"),
+ regset + 35);
+ mips_collect_register (regcache, use_64bit, find_regno (tdesc, "status"),
+ regset + 36);
+ mips_collect_register (regcache, use_64bit, find_regno (tdesc, "cause"),
+ regset + 37);
- mips_collect_register (regcache, use_64bit,
- find_regno (tdesc, "restart"), regset + 0);
+ mips_collect_register (regcache, use_64bit, find_regno (tdesc, "restart"),
+ regset + 0);
}
static void
@@ -839,20 +815,20 @@ mips_store_gregset (struct regcache *regcache, const void *buf)
mips_supply_register (regcache, use_64bit, i, regset + i);
mips_supply_register (regcache, use_64bit,
- find_regno (regcache->tdesc, "lo"), regset + 32);
+ find_regno (regcache->tdesc, "lo"), regset + 32);
mips_supply_register (regcache, use_64bit,
- find_regno (regcache->tdesc, "hi"), regset + 33);
+ find_regno (regcache->tdesc, "hi"), regset + 33);
mips_supply_register (regcache, use_64bit,
- find_regno (regcache->tdesc, "pc"), regset + 34);
+ find_regno (regcache->tdesc, "pc"), regset + 34);
mips_supply_register (regcache, use_64bit,
- find_regno (regcache->tdesc, "badvaddr"), regset + 35);
+ find_regno (regcache->tdesc, "badvaddr"), regset + 35);
mips_supply_register (regcache, use_64bit,
- find_regno (regcache->tdesc, "status"), regset + 36);
+ find_regno (regcache->tdesc, "status"), regset + 36);
mips_supply_register (regcache, use_64bit,
- find_regno (regcache->tdesc, "cause"), regset + 37);
+ find_regno (regcache->tdesc, "cause"), regset + 37);
mips_supply_register (regcache, use_64bit,
- find_regno (regcache->tdesc, "restart"), regset + 0);
+ find_regno (regcache->tdesc, "restart"), regset + 0);
}
static void
@@ -871,13 +847,14 @@ mips_fill_fpregset (struct regcache *regcache, void *buf)
collect_register (regcache, first_fp + i, regset[i].buf);
else
collect_register (regcache, first_fp + i,
- regset[i & ~1].buf + 4 * (big_endian != (i & 1)));
+ regset[i & ~1].buf + 4 * (big_endian != (i & 1)));
mips_collect_register_32bit (regcache, use_64bit,
- find_regno (regcache->tdesc, "fcsr"), regset[32].buf);
+ find_regno (regcache->tdesc, "fcsr"),
+ regset[32].buf);
mips_collect_register_32bit (regcache, use_64bit,
- find_regno (regcache->tdesc, "fir"),
- regset[32].buf + 4);
+ find_regno (regcache->tdesc, "fir"),
+ regset[32].buf + 4);
}
static void
@@ -896,14 +873,14 @@ mips_store_fpregset (struct regcache *regcache, const void *buf)
supply_register (regcache, first_fp + i, regset[i].buf);
else
supply_register (regcache, first_fp + i,
- regset[i & ~1].buf + 4 * (big_endian != (i & 1)));
+ regset[i & ~1].buf + 4 * (big_endian != (i & 1)));
mips_supply_register_32bit (regcache, use_64bit,
- find_regno (regcache->tdesc, "fcsr"),
- regset[32].buf);
+ find_regno (regcache->tdesc, "fcsr"),
+ regset[32].buf);
mips_supply_register_32bit (regcache, use_64bit,
- find_regno (regcache->tdesc, "fir"),
- regset[32].buf + 4);
+ find_regno (regcache->tdesc, "fir"),
+ regset[32].buf + 4);
}
#endif /* HAVE_PTRACE_GETREGS */
@@ -911,7 +888,7 @@ mips_store_fpregset (struct regcache *regcache, const void *buf)
void
mips_target::low_collect_ptrace_register (regcache *regcache, int regno,
- char *buf)
+ char *buf)
{
int use_64bit = sizeof (PTRACE_XFER_TYPE) == 8;
@@ -930,7 +907,7 @@ mips_target::low_collect_ptrace_register (regcache *regcache, int regno,
void
mips_target::low_supply_ptrace_register (regcache *regcache, int regno,
- const char *buf)
+ const char *buf)
{
int use_64bit = sizeof (PTRACE_XFER_TYPE) == 8;
@@ -947,46 +924,36 @@ mips_target::low_supply_ptrace_register (regcache *regcache, int regno,
static struct regset_info mips_regsets[] = {
#ifdef HAVE_PTRACE_GETREGS
- { PTRACE_GETREGS, PTRACE_SETREGS, 0, 38 * 8, GENERAL_REGS,
- mips_fill_gregset, mips_store_gregset },
- { PTRACE_GETFPREGS, PTRACE_SETFPREGS, 0, 33 * 8, FP_REGS,
- mips_fill_fpregset, mips_store_fpregset },
+ { PTRACE_GETREGS, PTRACE_SETREGS, 0, 38 * 8, GENERAL_REGS, mips_fill_gregset,
+ mips_store_gregset },
+ { PTRACE_GETFPREGS, PTRACE_SETFPREGS, 0, 33 * 8, FP_REGS, mips_fill_fpregset,
+ mips_store_fpregset },
#endif /* HAVE_PTRACE_GETREGS */
NULL_REGSET
};
-static struct regsets_info mips_regsets_info =
- {
- mips_regsets, /* regsets */
- 0, /* num_regsets */
- NULL, /* disabled_regsets */
- };
-
-static struct usrregs_info mips_dsp_usrregs_info =
- {
- mips_dsp_num_regs,
- mips_dsp_regmap,
- };
-
-static struct usrregs_info mips_usrregs_info =
- {
- mips_num_regs,
- mips_regmap,
- };
-
-static struct regs_info dsp_regs_info =
- {
- mips_dsp_regset_bitmap,
- &mips_dsp_usrregs_info,
- &mips_regsets_info
- };
-
-static struct regs_info myregs_info =
- {
- NULL, /* regset_bitmap */
- &mips_usrregs_info,
- &mips_regsets_info
- };
+static struct regsets_info mips_regsets_info = {
+ mips_regsets, /* regsets */
+ 0, /* num_regsets */
+ NULL, /* disabled_regsets */
+};
+
+static struct usrregs_info mips_dsp_usrregs_info = {
+ mips_dsp_num_regs,
+ mips_dsp_regmap,
+};
+
+static struct usrregs_info mips_usrregs_info = {
+ mips_num_regs,
+ mips_regmap,
+};
+
+static struct regs_info dsp_regs_info
+ = { mips_dsp_regset_bitmap, &mips_dsp_usrregs_info, &mips_regsets_info };
+
+static struct regs_info myregs_info
+ = { NULL, /* regset_bitmap */
+ &mips_usrregs_info, &mips_regsets_info };
const regs_info *
mips_target::get_regs_info ()
diff --git a/gdbserver/linux-nios2-low.cc b/gdbserver/linux-nios2-low.cc
index 448a2ef..4ebe447 100644
--- a/gdbserver/linux-nios2-low.cc
+++ b/gdbserver/linux-nios2-low.cc
@@ -36,13 +36,11 @@
class nios2_target : public linux_process_target
{
public:
-
const regs_info *get_regs_info () override;
const gdb_byte *sw_breakpoint_from_kind (int kind, int *size) override;
protected:
-
void low_arch_setup () override;
bool low_cannot_fetch_register (int regno) override;
@@ -103,16 +101,10 @@ union nios2_register
/* Return the ptrace ``address'' of register REGNO. */
-static int nios2_regmap[] = {
- -1, 1, 2, 3, 4, 5, 6, 7,
- 8, 9, 10, 11, 12, 13, 14, 15,
- 16, 17, 18, 19, 20, 21, 22, 23,
- 24, 25, 26, 27, 28, 29, 30, 31,
- 32, 33, 34, 35, 36, 37, 38, 39,
- 40, 41, 42, 43, 44, 45, 46, 47,
- 48,
- 0
-};
+static int nios2_regmap[]
+ = { -1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
+ 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
+ 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 0 };
/* Implement the low_arch_setup linux target ops method. */
@@ -188,8 +180,8 @@ nios2_target::low_breakpoint_at (CORE_ADDR where)
/* Fetch the thread-local storage pointer for libthread_db. */
ps_err_e
-ps_get_thread_area (struct ps_prochandle *ph,
- lwpid_t lwpid, int idx, void **base)
+ps_get_thread_area (struct ps_prochandle *ph, lwpid_t lwpid, int idx,
+ void **base)
{
if (ptrace (PTRACE_GET_THREAD_AREA, lwpid, NULL, base) != 0)
return PS_ERR;
@@ -206,7 +198,7 @@ ps_get_thread_area (struct ps_prochandle *ph,
static void
nios2_collect_register (struct regcache *regcache, int regno,
- union nios2_register *reg)
+ union nios2_register *reg)
{
union nios2_register tmp_reg;
@@ -216,7 +208,7 @@ nios2_collect_register (struct regcache *regcache, int regno,
static void
nios2_supply_register (struct regcache *regcache, int regno,
- const union nios2_register *reg)
+ const union nios2_register *reg)
{
supply_register (regcache, regno, reg->buf);
}
@@ -243,33 +235,25 @@ nios2_store_gregset (struct regcache *regcache, const void *buf)
nios2_supply_register (regcache, i, regset + i);
}
-static struct regset_info nios2_regsets[] =
-{
- { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_PRSTATUS,
- nios2_num_regs * 4, GENERAL_REGS,
- nios2_fill_gregset, nios2_store_gregset },
- NULL_REGSET
+static struct regset_info nios2_regsets[]
+ = { { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_PRSTATUS, nios2_num_regs * 4,
+ GENERAL_REGS, nios2_fill_gregset, nios2_store_gregset },
+ NULL_REGSET };
+
+static struct regsets_info nios2_regsets_info = {
+ nios2_regsets, /* regsets */
+ 0, /* num_regsets */
+ NULL, /* disabled_regsets */
+};
+
+static struct usrregs_info nios2_usrregs_info = {
+ nios2_num_regs,
+ nios2_regmap,
};
-static struct regsets_info nios2_regsets_info =
- {
- nios2_regsets, /* regsets */
- 0, /* num_regsets */
- NULL, /* disabled_regsets */
- };
-
-static struct usrregs_info nios2_usrregs_info =
- {
- nios2_num_regs,
- nios2_regmap,
- };
-
-static struct regs_info myregs_info =
- {
- NULL, /* regset_bitmap */
- &nios2_usrregs_info,
- &nios2_regsets_info
- };
+static struct regs_info myregs_info
+ = { NULL, /* regset_bitmap */
+ &nios2_usrregs_info, &nios2_regsets_info };
const regs_info *
nios2_target::get_regs_info ()
diff --git a/gdbserver/linux-or1k-low.cc b/gdbserver/linux-or1k-low.cc
index 498955a..2916f11 100644
--- a/gdbserver/linux-or1k-low.cc
+++ b/gdbserver/linux-or1k-low.cc
@@ -33,13 +33,11 @@
class or1k_target : public linux_process_target
{
public:
-
const regs_info *get_regs_info () override;
const gdb_byte *sw_breakpoint_from_kind (int kind, int *size) override;
protected:
-
void low_arch_setup () override;
bool low_cannot_fetch_register (int regno) override;
@@ -101,11 +99,8 @@ union or1k_register
/* Return the ptrace ``address'' of register REGNO. */
static int or1k_regmap[] = {
- -1, 1, 2, 3, 4, 5, 6, 7,
- 8, 9, 10, 11, 12, 13, 14, 15,
- 16, 17, 18, 19, 20, 21, 22, 23,
- 24, 25, 26, 27, 28, 29, 30, 31,
- -1, /* PC */
+ -1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
+ 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, -1, /* PC */
-1, /* ORIGINAL R11 */
-1 /* SYSCALL NO */
};
@@ -164,8 +159,8 @@ or1k_target::low_breakpoint_at (CORE_ADDR where)
/* Fetch the thread-local storage pointer for libthread_db. */
ps_err_e
-ps_get_thread_area (struct ps_prochandle *ph,
- lwpid_t lwpid, int idx, void **base)
+ps_get_thread_area (struct ps_prochandle *ph, lwpid_t lwpid, int idx,
+ void **base)
{
if (ptrace (PTRACE_GET_THREAD_AREA, lwpid, NULL, base) != 0)
return PS_ERR;
@@ -182,7 +177,7 @@ ps_get_thread_area (struct ps_prochandle *ph,
static void
or1k_collect_register (struct regcache *regcache, int regno,
- union or1k_register *reg)
+ union or1k_register *reg)
{
union or1k_register tmp_reg;
@@ -192,7 +187,7 @@ or1k_collect_register (struct regcache *regcache, int regno,
static void
or1k_supply_register (struct regcache *regcache, int regno,
- const union or1k_register *reg)
+ const union or1k_register *reg)
{
supply_register (regcache, regno, reg->buf);
}
@@ -219,33 +214,24 @@ or1k_store_gregset (struct regcache *regcache, const void *buf)
or1k_supply_register (regcache, i, regset + i);
}
-static struct regset_info or1k_regsets[] =
-{
- { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_PRSTATUS,
- or1k_num_regs * 4, GENERAL_REGS,
- or1k_fill_gregset, or1k_store_gregset },
- NULL_REGSET
+static struct regset_info or1k_regsets[]
+ = { { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_PRSTATUS, or1k_num_regs * 4,
+ GENERAL_REGS, or1k_fill_gregset, or1k_store_gregset },
+ NULL_REGSET };
+
+static struct regsets_info or1k_regsets_info = {
+ or1k_regsets, /* regsets */
+ 0, /* num_regsets */
+ NULL, /* disabled_regsets */
+};
+
+static struct usrregs_info or1k_usrregs_info = {
+ or1k_num_regs,
+ or1k_regmap,
};
-static struct regsets_info or1k_regsets_info =
- {
- or1k_regsets, /* regsets */
- 0, /* num_regsets */
- NULL, /* disabled_regsets */
- };
-
-static struct usrregs_info or1k_usrregs_info =
- {
- or1k_num_regs,
- or1k_regmap,
- };
-
-static struct regs_info or1k_regs =
- {
- NULL, /* regset_bitmap */
- &or1k_usrregs_info,
- &or1k_regsets_info
- };
+static struct regs_info or1k_regs = { NULL, /* regset_bitmap */
+ &or1k_usrregs_info, &or1k_regsets_info };
const regs_info *
or1k_target::get_regs_info ()
diff --git a/gdbserver/linux-ppc-ipa.cc b/gdbserver/linux-ppc-ipa.cc
index ab89e44..f079c12 100644
--- a/gdbserver/linux-ppc-ipa.cc
+++ b/gdbserver/linux-ppc-ipa.cc
@@ -30,60 +30,54 @@
/* These macros define the position of registers in the buffer collected
by the fast tracepoint jump pad. */
-#define FT_CR_R0 0
-#define FT_CR_CR 32
-#define FT_CR_XER 33
-#define FT_CR_LR 34
-#define FT_CR_CTR 35
-#define FT_CR_PC 36
-#define FT_CR_GPR(n) (FT_CR_R0 + (n))
+#define FT_CR_R0 0
+#define FT_CR_CR 32
+#define FT_CR_XER 33
+#define FT_CR_LR 34
+#define FT_CR_CTR 35
+#define FT_CR_PC 36
+#define FT_CR_GPR(n) (FT_CR_R0 + (n))
static const int ppc_ft_collect_regmap[] = {
/* GPRs */
- FT_CR_GPR (0), FT_CR_GPR (1), FT_CR_GPR (2),
- FT_CR_GPR (3), FT_CR_GPR (4), FT_CR_GPR (5),
- FT_CR_GPR (6), FT_CR_GPR (7), FT_CR_GPR (8),
- FT_CR_GPR (9), FT_CR_GPR (10), FT_CR_GPR (11),
- FT_CR_GPR (12), FT_CR_GPR (13), FT_CR_GPR (14),
- FT_CR_GPR (15), FT_CR_GPR (16), FT_CR_GPR (17),
- FT_CR_GPR (18), FT_CR_GPR (19), FT_CR_GPR (20),
- FT_CR_GPR (21), FT_CR_GPR (22), FT_CR_GPR (23),
- FT_CR_GPR (24), FT_CR_GPR (25), FT_CR_GPR (26),
- FT_CR_GPR (27), FT_CR_GPR (28), FT_CR_GPR (29),
+ FT_CR_GPR (0), FT_CR_GPR (1), FT_CR_GPR (2), FT_CR_GPR (3), FT_CR_GPR (4),
+ FT_CR_GPR (5), FT_CR_GPR (6), FT_CR_GPR (7), FT_CR_GPR (8), FT_CR_GPR (9),
+ FT_CR_GPR (10), FT_CR_GPR (11), FT_CR_GPR (12), FT_CR_GPR (13),
+ FT_CR_GPR (14), FT_CR_GPR (15), FT_CR_GPR (16), FT_CR_GPR (17),
+ FT_CR_GPR (18), FT_CR_GPR (19), FT_CR_GPR (20), FT_CR_GPR (21),
+ FT_CR_GPR (22), FT_CR_GPR (23), FT_CR_GPR (24), FT_CR_GPR (25),
+ FT_CR_GPR (26), FT_CR_GPR (27), FT_CR_GPR (28), FT_CR_GPR (29),
FT_CR_GPR (30), FT_CR_GPR (31),
/* FPRs - not collected. */
- -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1,
- FT_CR_PC, /* PC */
- -1, /* MSR */
- FT_CR_CR, /* CR */
- FT_CR_LR, /* LR */
- FT_CR_CTR, /* CTR */
- FT_CR_XER, /* XER */
- -1, /* FPSCR */
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, FT_CR_PC, /* PC */
+ -1, /* MSR */
+ FT_CR_CR, /* CR */
+ FT_CR_LR, /* LR */
+ FT_CR_CTR, /* CTR */
+ FT_CR_XER, /* XER */
+ -1, /* FPSCR */
};
#define PPC_NUM_FT_COLLECT_GREGS \
- (sizeof (ppc_ft_collect_regmap) / sizeof(ppc_ft_collect_regmap[0]))
+ (sizeof (ppc_ft_collect_regmap) / sizeof (ppc_ft_collect_regmap[0]))
/* Supply registers collected by the fast tracepoint jump pad.
BUF is the second argument we pass to gdb_collect in jump pad. */
void
supply_fast_tracepoint_registers (struct regcache *regcache,
- const unsigned char *buf)
+ const unsigned char *buf)
{
int i;
for (i = 0; i < PPC_NUM_FT_COLLECT_GREGS; i++)
{
if (ppc_ft_collect_regmap[i] == -1)
- continue;
+ continue;
supply_register (regcache, i,
- ((char *) buf)
- + ppc_ft_collect_regmap[i] * sizeof (long));
+ ((char *) buf)
+ + ppc_ft_collect_regmap[i] * sizeof (long));
}
}
@@ -99,7 +93,7 @@ get_raw_reg (const unsigned char *raw_regs, int regnum)
return 0;
return *(unsigned long *) (raw_regs
- + ppc_ft_collect_regmap[regnum] * sizeof (long));
+ + ppc_ft_collect_regmap[regnum] * sizeof (long));
}
/* Allocate buffer for the jump pads. The branch instruction has a reach
@@ -139,24 +133,23 @@ alloc_jump_pad_buffer (size_t size)
for (; addr; addr -= pagesize)
{
/* No MAP_FIXED - we don't want to zap someone's mapping. */
- res = mmap ((void *) addr, size,
- PROT_READ | PROT_WRITE | PROT_EXEC,
- MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+ res = mmap ((void *) addr, size, PROT_READ | PROT_WRITE | PROT_EXEC,
+ MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
/* If we got what we wanted, return. */
if ((uintptr_t) res == addr)
- return res;
+ return res;
/* If we got a mapping, but at a wrong address, undo it. */
if (res != MAP_FAILED)
- munmap (res, size);
+ munmap (res, size);
}
return NULL;
#else
void *target = sbrk (0);
void *res = mmap (target, size, PROT_READ | PROT_WRITE | PROT_EXEC,
- MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+ MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
if (res == target)
return res;
@@ -227,7 +220,6 @@ get_ipa_tdesc (int idx)
}
}
-
/* Initialize ipa_tdesc and others. */
void
diff --git a/gdbserver/linux-ppc-low.cc b/gdbserver/linux-ppc-low.cc
index f8dd770..148f49e 100644
--- a/gdbserver/linux-ppc-low.cc
+++ b/gdbserver/linux-ppc-low.cc
@@ -34,46 +34,44 @@
#include "tracepoint.h"
#define PPC_FIELD(value, from, len) \
- (((value) >> (32 - (from) - (len))) & ((1 << (len)) - 1))
-#define PPC_SEXT(v, bs) \
- ((((CORE_ADDR) (v) & (((CORE_ADDR) 1 << (bs)) - 1)) \
- ^ ((CORE_ADDR) 1 << ((bs) - 1))) \
- - ((CORE_ADDR) 1 << ((bs) - 1)))
-#define PPC_OP6(insn) PPC_FIELD (insn, 0, 6)
-#define PPC_BO(insn) PPC_FIELD (insn, 6, 5)
-#define PPC_LI(insn) (PPC_SEXT (PPC_FIELD (insn, 6, 24), 24) << 2)
-#define PPC_BD(insn) (PPC_SEXT (PPC_FIELD (insn, 16, 14), 14) << 2)
+ (((value) >> (32 - (from) - (len))) & ((1 << (len)) - 1))
+#define PPC_SEXT(v, bs) \
+ ((((CORE_ADDR) (v) & (((CORE_ADDR) 1 << (bs)) - 1)) \
+ ^ ((CORE_ADDR) 1 << ((bs) -1))) \
+ - ((CORE_ADDR) 1 << ((bs) -1)))
+#define PPC_OP6(insn) PPC_FIELD (insn, 0, 6)
+#define PPC_BO(insn) PPC_FIELD (insn, 6, 5)
+#define PPC_LI(insn) (PPC_SEXT (PPC_FIELD (insn, 6, 24), 24) << 2)
+#define PPC_BD(insn) (PPC_SEXT (PPC_FIELD (insn, 16, 14), 14) << 2)
/* Linux target op definitions for the PowerPC architecture. */
class ppc_target : public linux_process_target
{
public:
-
const regs_info *get_regs_info () override;
const gdb_byte *sw_breakpoint_from_kind (int kind, int *size) override;
bool supports_z_point_type (char z_type) override;
-
void low_collect_ptrace_register (regcache *regcache, int regno,
- char *buf) override;
+ char *buf) override;
void low_supply_ptrace_register (regcache *regcache, int regno,
- const char *buf) override;
+ const char *buf) override;
bool supports_tracepoints () override;
bool supports_fast_tracepoints () override;
- int install_fast_tracepoint_jump_pad
- (CORE_ADDR tpoint, CORE_ADDR tpaddr, CORE_ADDR collector,
- CORE_ADDR lockaddr, ULONGEST orig_size, CORE_ADDR *jump_entry,
- CORE_ADDR *trampoline, ULONGEST *trampoline_size,
- unsigned char *jjump_pad_insn, ULONGEST *jjump_pad_insn_size,
- CORE_ADDR *adjusted_insn_addr, CORE_ADDR *adjusted_insn_addr_end,
- char *err) override;
+ int install_fast_tracepoint_jump_pad (
+ CORE_ADDR tpoint, CORE_ADDR tpaddr, CORE_ADDR collector,
+ CORE_ADDR lockaddr, ULONGEST orig_size, CORE_ADDR *jump_entry,
+ CORE_ADDR *trampoline, ULONGEST *trampoline_size,
+ unsigned char *jjump_pad_insn, ULONGEST *jjump_pad_insn_size,
+ CORE_ADDR *adjusted_insn_addr, CORE_ADDR *adjusted_insn_addr_end,
+ char *err) override;
int get_min_fast_tracepoint_insn_len () override;
@@ -82,7 +80,6 @@ public:
int get_ipa_tdesc_idx () override;
protected:
-
void low_arch_setup () override;
bool low_cannot_fetch_register (int regno) override;
@@ -97,11 +94,11 @@ protected:
bool low_breakpoint_at (CORE_ADDR pc) override;
- int low_insert_point (raw_bkpt_type type, CORE_ADDR addr,
- int size, raw_breakpoint *bp) override;
+ int low_insert_point (raw_bkpt_type type, CORE_ADDR addr, int size,
+ raw_breakpoint *bp) override;
- int low_remove_point (raw_bkpt_type type, CORE_ADDR addr,
- int size, raw_breakpoint *bp) override;
+ int low_remove_point (raw_bkpt_type type, CORE_ADDR addr, int size,
+ raw_breakpoint *bp) override;
int low_get_thread_area (int lwpid, CORE_ADDR *addrp) override;
};
@@ -118,77 +115,71 @@ static unsigned long ppc_hwcap;
static unsigned long ppc_hwcap2;
-
#define ppc_num_regs 73
#ifdef __powerpc64__
/* We use a constant for FPSCR instead of PT_FPSCR, because
many shipped PPC64 kernels had the wrong value in ptrace.h. */
-static int ppc_regmap[] =
- {PT_R0 * 8, PT_R1 * 8, PT_R2 * 8, PT_R3 * 8,
- PT_R4 * 8, PT_R5 * 8, PT_R6 * 8, PT_R7 * 8,
- PT_R8 * 8, PT_R9 * 8, PT_R10 * 8, PT_R11 * 8,
- PT_R12 * 8, PT_R13 * 8, PT_R14 * 8, PT_R15 * 8,
- PT_R16 * 8, PT_R17 * 8, PT_R18 * 8, PT_R19 * 8,
- PT_R20 * 8, PT_R21 * 8, PT_R22 * 8, PT_R23 * 8,
- PT_R24 * 8, PT_R25 * 8, PT_R26 * 8, PT_R27 * 8,
- PT_R28 * 8, PT_R29 * 8, PT_R30 * 8, PT_R31 * 8,
- PT_FPR0*8, PT_FPR0*8 + 8, PT_FPR0*8+16, PT_FPR0*8+24,
- PT_FPR0*8+32, PT_FPR0*8+40, PT_FPR0*8+48, PT_FPR0*8+56,
- PT_FPR0*8+64, PT_FPR0*8+72, PT_FPR0*8+80, PT_FPR0*8+88,
- PT_FPR0*8+96, PT_FPR0*8+104, PT_FPR0*8+112, PT_FPR0*8+120,
- PT_FPR0*8+128, PT_FPR0*8+136, PT_FPR0*8+144, PT_FPR0*8+152,
- PT_FPR0*8+160, PT_FPR0*8+168, PT_FPR0*8+176, PT_FPR0*8+184,
- PT_FPR0*8+192, PT_FPR0*8+200, PT_FPR0*8+208, PT_FPR0*8+216,
- PT_FPR0*8+224, PT_FPR0*8+232, PT_FPR0*8+240, PT_FPR0*8+248,
- PT_NIP * 8, PT_MSR * 8, PT_CCR * 8, PT_LNK * 8,
- PT_CTR * 8, PT_XER * 8, PT_FPR0*8 + 256,
- PT_ORIG_R3 * 8, PT_TRAP * 8 };
+static int ppc_regmap[] = {
+ PT_R0 * 8, PT_R1 * 8, PT_R2 * 8, PT_R3 * 8,
+ PT_R4 * 8, PT_R5 * 8, PT_R6 * 8, PT_R7 * 8,
+ PT_R8 * 8, PT_R9 * 8, PT_R10 * 8, PT_R11 * 8,
+ PT_R12 * 8, PT_R13 * 8, PT_R14 * 8, PT_R15 * 8,
+ PT_R16 * 8, PT_R17 * 8, PT_R18 * 8, PT_R19 * 8,
+ PT_R20 * 8, PT_R21 * 8, PT_R22 * 8, PT_R23 * 8,
+ PT_R24 * 8, PT_R25 * 8, PT_R26 * 8, PT_R27 * 8,
+ PT_R28 * 8, PT_R29 * 8, PT_R30 * 8, PT_R31 * 8,
+ PT_FPR0 * 8, PT_FPR0 * 8 + 8, PT_FPR0 * 8 + 16, PT_FPR0 * 8 + 24,
+ PT_FPR0 * 8 + 32, PT_FPR0 * 8 + 40, PT_FPR0 * 8 + 48, PT_FPR0 * 8 + 56,
+ PT_FPR0 * 8 + 64, PT_FPR0 * 8 + 72, PT_FPR0 * 8 + 80, PT_FPR0 * 8 + 88,
+ PT_FPR0 * 8 + 96, PT_FPR0 * 8 + 104, PT_FPR0 * 8 + 112, PT_FPR0 * 8 + 120,
+ PT_FPR0 * 8 + 128, PT_FPR0 * 8 + 136, PT_FPR0 * 8 + 144, PT_FPR0 * 8 + 152,
+ PT_FPR0 * 8 + 160, PT_FPR0 * 8 + 168, PT_FPR0 * 8 + 176, PT_FPR0 * 8 + 184,
+ PT_FPR0 * 8 + 192, PT_FPR0 * 8 + 200, PT_FPR0 * 8 + 208, PT_FPR0 * 8 + 216,
+ PT_FPR0 * 8 + 224, PT_FPR0 * 8 + 232, PT_FPR0 * 8 + 240, PT_FPR0 * 8 + 248,
+ PT_NIP * 8, PT_MSR * 8, PT_CCR * 8, PT_LNK * 8,
+ PT_CTR * 8, PT_XER * 8, PT_FPR0 * 8 + 256, PT_ORIG_R3 * 8,
+ PT_TRAP * 8
+};
#else
/* Currently, don't check/send MQ. */
-static int ppc_regmap[] =
- {PT_R0 * 4, PT_R1 * 4, PT_R2 * 4, PT_R3 * 4,
- PT_R4 * 4, PT_R5 * 4, PT_R6 * 4, PT_R7 * 4,
- PT_R8 * 4, PT_R9 * 4, PT_R10 * 4, PT_R11 * 4,
- PT_R12 * 4, PT_R13 * 4, PT_R14 * 4, PT_R15 * 4,
- PT_R16 * 4, PT_R17 * 4, PT_R18 * 4, PT_R19 * 4,
- PT_R20 * 4, PT_R21 * 4, PT_R22 * 4, PT_R23 * 4,
- PT_R24 * 4, PT_R25 * 4, PT_R26 * 4, PT_R27 * 4,
- PT_R28 * 4, PT_R29 * 4, PT_R30 * 4, PT_R31 * 4,
- PT_FPR0*4, PT_FPR0*4 + 8, PT_FPR0*4+16, PT_FPR0*4+24,
- PT_FPR0*4+32, PT_FPR0*4+40, PT_FPR0*4+48, PT_FPR0*4+56,
- PT_FPR0*4+64, PT_FPR0*4+72, PT_FPR0*4+80, PT_FPR0*4+88,
- PT_FPR0*4+96, PT_FPR0*4+104, PT_FPR0*4+112, PT_FPR0*4+120,
- PT_FPR0*4+128, PT_FPR0*4+136, PT_FPR0*4+144, PT_FPR0*4+152,
- PT_FPR0*4+160, PT_FPR0*4+168, PT_FPR0*4+176, PT_FPR0*4+184,
- PT_FPR0*4+192, PT_FPR0*4+200, PT_FPR0*4+208, PT_FPR0*4+216,
- PT_FPR0*4+224, PT_FPR0*4+232, PT_FPR0*4+240, PT_FPR0*4+248,
- PT_NIP * 4, PT_MSR * 4, PT_CCR * 4, PT_LNK * 4,
- PT_CTR * 4, PT_XER * 4, PT_FPSCR * 4,
- PT_ORIG_R3 * 4, PT_TRAP * 4
- };
-
-static int ppc_regmap_e500[] =
- {PT_R0 * 4, PT_R1 * 4, PT_R2 * 4, PT_R3 * 4,
- PT_R4 * 4, PT_R5 * 4, PT_R6 * 4, PT_R7 * 4,
- PT_R8 * 4, PT_R9 * 4, PT_R10 * 4, PT_R11 * 4,
- PT_R12 * 4, PT_R13 * 4, PT_R14 * 4, PT_R15 * 4,
- PT_R16 * 4, PT_R17 * 4, PT_R18 * 4, PT_R19 * 4,
- PT_R20 * 4, PT_R21 * 4, PT_R22 * 4, PT_R23 * 4,
- PT_R24 * 4, PT_R25 * 4, PT_R26 * 4, PT_R27 * 4,
- PT_R28 * 4, PT_R29 * 4, PT_R30 * 4, PT_R31 * 4,
- -1, -1, -1, -1,
- -1, -1, -1, -1,
- -1, -1, -1, -1,
- -1, -1, -1, -1,
- -1, -1, -1, -1,
- -1, -1, -1, -1,
- -1, -1, -1, -1,
- -1, -1, -1, -1,
- PT_NIP * 4, PT_MSR * 4, PT_CCR * 4, PT_LNK * 4,
- PT_CTR * 4, PT_XER * 4, -1,
- PT_ORIG_R3 * 4, PT_TRAP * 4
- };
+static int ppc_regmap[] = {
+ PT_R0 * 4, PT_R1 * 4, PT_R2 * 4, PT_R3 * 4,
+ PT_R4 * 4, PT_R5 * 4, PT_R6 * 4, PT_R7 * 4,
+ PT_R8 * 4, PT_R9 * 4, PT_R10 * 4, PT_R11 * 4,
+ PT_R12 * 4, PT_R13 * 4, PT_R14 * 4, PT_R15 * 4,
+ PT_R16 * 4, PT_R17 * 4, PT_R18 * 4, PT_R19 * 4,
+ PT_R20 * 4, PT_R21 * 4, PT_R22 * 4, PT_R23 * 4,
+ PT_R24 * 4, PT_R25 * 4, PT_R26 * 4, PT_R27 * 4,
+ PT_R28 * 4, PT_R29 * 4, PT_R30 * 4, PT_R31 * 4,
+ PT_FPR0 * 4, PT_FPR0 * 4 + 8, PT_FPR0 * 4 + 16, PT_FPR0 * 4 + 24,
+ PT_FPR0 * 4 + 32, PT_FPR0 * 4 + 40, PT_FPR0 * 4 + 48, PT_FPR0 * 4 + 56,
+ PT_FPR0 * 4 + 64, PT_FPR0 * 4 + 72, PT_FPR0 * 4 + 80, PT_FPR0 * 4 + 88,
+ PT_FPR0 * 4 + 96, PT_FPR0 * 4 + 104, PT_FPR0 * 4 + 112, PT_FPR0 * 4 + 120,
+ PT_FPR0 * 4 + 128, PT_FPR0 * 4 + 136, PT_FPR0 * 4 + 144, PT_FPR0 * 4 + 152,
+ PT_FPR0 * 4 + 160, PT_FPR0 * 4 + 168, PT_FPR0 * 4 + 176, PT_FPR0 * 4 + 184,
+ PT_FPR0 * 4 + 192, PT_FPR0 * 4 + 200, PT_FPR0 * 4 + 208, PT_FPR0 * 4 + 216,
+ PT_FPR0 * 4 + 224, PT_FPR0 * 4 + 232, PT_FPR0 * 4 + 240, PT_FPR0 * 4 + 248,
+ PT_NIP * 4, PT_MSR * 4, PT_CCR * 4, PT_LNK * 4,
+ PT_CTR * 4, PT_XER * 4, PT_FPSCR * 4, PT_ORIG_R3 * 4,
+ PT_TRAP * 4
+};
+
+static int ppc_regmap_e500[] = {
+ PT_R0 * 4, PT_R1 * 4, PT_R2 * 4, PT_R3 * 4, PT_R4 * 4, PT_R5 * 4,
+ PT_R6 * 4, PT_R7 * 4, PT_R8 * 4, PT_R9 * 4, PT_R10 * 4, PT_R11 * 4,
+ PT_R12 * 4, PT_R13 * 4, PT_R14 * 4, PT_R15 * 4, PT_R16 * 4, PT_R17 * 4,
+ PT_R18 * 4, PT_R19 * 4, PT_R20 * 4, PT_R21 * 4, PT_R22 * 4, PT_R23 * 4,
+ PT_R24 * 4, PT_R25 * 4, PT_R26 * 4, PT_R27 * 4, PT_R28 * 4, PT_R29 * 4,
+ PT_R30 * 4, PT_R31 * 4, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, PT_NIP * 4, PT_MSR * 4,
+ PT_CCR * 4, PT_LNK * 4, PT_CTR * 4, PT_XER * 4, -1, PT_ORIG_R3 * 4,
+ PT_TRAP * 4
+};
#endif
/* Check whether the kernel provides a register set with number
@@ -203,8 +194,7 @@ ppc_check_regset (int tid, int regset_id, int regsetsize)
iov.iov_base = buf;
iov.iov_len = regsetsize;
- if (ptrace (PTRACE_GETREGSET, tid, regset_id, &iov) >= 0
- || errno == ENODATA)
+ if (ptrace (PTRACE_GETREGSET, tid, regset_id, &iov) >= 0 || errno == ENODATA)
return 1;
return 0;
}
@@ -237,7 +227,7 @@ ppc_target::low_cannot_fetch_register (int regno)
void
ppc_target::low_collect_ptrace_register (regcache *regcache, int regno,
- char *buf)
+ char *buf)
{
memset (buf, 0, sizeof (long));
@@ -254,9 +244,9 @@ ppc_target::low_collect_ptrace_register (regcache *regcache, int regno,
int size = register_size (regcache->tdesc, regno);
if (size < sizeof (long))
- collect_register (regcache, regno, buf + sizeof (long) - size);
+ collect_register (regcache, regno, buf + sizeof (long) - size);
else
- collect_register (regcache, regno, buf);
+ collect_register (regcache, regno, buf);
}
else
perror_with_name ("Unexpected byte order");
@@ -264,7 +254,7 @@ ppc_target::low_collect_ptrace_register (regcache *regcache, int regno,
void
ppc_target::low_supply_ptrace_register (regcache *regcache, int regno,
- const char *buf)
+ const char *buf)
{
if (__BYTE_ORDER == __LITTLE_ENDIAN)
{
@@ -279,9 +269,9 @@ ppc_target::low_supply_ptrace_register (regcache *regcache, int regno,
int size = register_size (regcache->tdesc, regno);
if (size < sizeof (long))
- supply_register (regcache, regno, buf + sizeof (long) - size);
+ supply_register (regcache, regno, buf + sizeof (long) - size);
else
- supply_register (regcache, regno, buf);
+ supply_register (regcache, regno, buf);
}
else
perror_with_name ("Unexpected byte order");
@@ -329,7 +319,6 @@ ppc_target::low_set_pc (regcache *regcache, CORE_ADDR pc)
static int ppc_regmap_adjusted;
#endif
-
/* Correct in either endianness.
This instruction is "twge r2, r2", which GDB uses as a software
breakpoint. */
@@ -384,8 +373,8 @@ ppc_target::supports_z_point_type (char z_type)
Returns 0 on success, -1 on failure and 1 on unsupported. */
int
-ppc_target::low_insert_point (raw_bkpt_type type, CORE_ADDR addr,
- int size, raw_breakpoint *bp)
+ppc_target::low_insert_point (raw_bkpt_type type, CORE_ADDR addr, int size,
+ raw_breakpoint *bp)
{
switch (type)
{
@@ -405,8 +394,8 @@ ppc_target::low_insert_point (raw_bkpt_type type, CORE_ADDR addr,
Returns 0 on success, -1 on failure and 1 on unsupported. */
int
-ppc_target::low_remove_point (raw_bkpt_type type, CORE_ADDR addr,
- int size, raw_breakpoint *bp)
+ppc_target::low_remove_point (raw_bkpt_type type, CORE_ADDR addr, int size,
+ raw_breakpoint *bp)
{
switch (type)
{
@@ -425,7 +414,8 @@ ppc_target::low_remove_point (raw_bkpt_type type, CORE_ADDR addr,
/* Provide only a fill function for the general register set. ps_lgetregs
will use this for NPTL support. */
-static void ppc_fill_gregset (struct regcache *regcache, void *buf)
+static void
+ppc_fill_gregset (struct regcache *regcache, void *buf)
{
int i;
@@ -433,15 +423,15 @@ static void ppc_fill_gregset (struct regcache *regcache, void *buf)
for (i = 0; i < 32; i++)
my_ppc_target->low_collect_ptrace_register (regcache, i,
- (char *) buf + ppc_regmap[i]);
+ (char *) buf + ppc_regmap[i]);
for (i = 64; i < 70; i++)
my_ppc_target->low_collect_ptrace_register (regcache, i,
- (char *) buf + ppc_regmap[i]);
+ (char *) buf + ppc_regmap[i]);
for (i = 71; i < 73; i++)
my_ppc_target->low_collect_ptrace_register (regcache, i,
- (char *) buf + ppc_regmap[i]);
+ (char *) buf + ppc_regmap[i]);
}
/* Program Priority Register regset fill function. */
@@ -614,10 +604,10 @@ ppc_store_tm_cgprregset (struct regcache *regcache, const void *buf)
endian_offset = 4;
supply_register_by_name (regcache, "ccr",
- &regset[PT_CCR * size + endian_offset]);
+ &regset[PT_CCR * size + endian_offset]);
supply_register_by_name (regcache, "cxer",
- &regset[PT_XER * size + endian_offset]);
+ &regset[PT_XER * size + endian_offset]);
supply_register_by_name (regcache, "clr", &regset[PT_LNK * size]);
supply_register_by_name (regcache, "cctr", &regset[PT_CTR * size]);
@@ -658,8 +648,7 @@ ppc_store_tm_cvrregset (struct regcache *regcache, const void *buf)
if (__BYTE_ORDER == __BIG_ENDIAN)
vscr_offset = 12;
- supply_register_by_name (regcache, "cvscr",
- &regset[32 * 16 + vscr_offset]);
+ supply_register_by_name (regcache, "cvscr", &regset[32 * 16 + vscr_offset]);
supply_register_by_name (regcache, "cvrsave", &regset[33 * 16]);
}
@@ -747,8 +736,7 @@ ppc_fill_vrregset (struct regcache *regcache, void *buf)
if (__BYTE_ORDER == __BIG_ENDIAN)
vscr_offset = 12;
- collect_register_by_name (regcache, "vscr",
- &regset[32 * 16 + vscr_offset]);
+ collect_register_by_name (regcache, "vscr", &regset[32 * 16 + vscr_offset]);
collect_register_by_name (regcache, "vrsave", &regset[33 * 16]);
}
@@ -767,8 +755,7 @@ ppc_store_vrregset (struct regcache *regcache, const void *buf)
if (__BYTE_ORDER == __BIG_ENDIAN)
vscr_offset = 12;
- supply_register_by_name (regcache, "vscr",
- &regset[32 * 16 + vscr_offset]);
+ supply_register_by_name (regcache, "vscr", &regset[32 * 16 + vscr_offset]);
supply_register_by_name (regcache, "vrsave", &regset[33 * 16]);
}
@@ -812,24 +799,24 @@ static struct regset_info ppc_regsets[] = {
fetch them every time, but still fall back to PTRACE_PEEKUSER for the
general registers. Some kernels support these, but not the newer
PPC_PTRACE_GETREGS. */
- { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_PPC_TM_CTAR, 0, EXTENDED_REGS,
- NULL, ppc_store_tm_ctarregset },
+ { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_PPC_TM_CTAR, 0, EXTENDED_REGS, NULL,
+ ppc_store_tm_ctarregset },
{ PTRACE_GETREGSET, PTRACE_SETREGSET, NT_PPC_TM_CDSCR, 0, EXTENDED_REGS,
NULL, ppc_store_tm_cdscrregset },
- { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_PPC_TM_CPPR, 0, EXTENDED_REGS,
- NULL, ppc_store_tm_cpprregset },
- { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_PPC_TM_CVSX, 0, EXTENDED_REGS,
- NULL, ppc_store_tm_cvsxregset },
- { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_PPC_TM_CVMX, 0, EXTENDED_REGS,
- NULL, ppc_store_tm_cvrregset },
- { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_PPC_TM_CFPR, 0, EXTENDED_REGS,
- NULL, ppc_store_tm_cfprregset },
- { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_PPC_TM_CGPR, 0, EXTENDED_REGS,
- NULL, ppc_store_tm_cgprregset },
+ { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_PPC_TM_CPPR, 0, EXTENDED_REGS, NULL,
+ ppc_store_tm_cpprregset },
+ { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_PPC_TM_CVSX, 0, EXTENDED_REGS, NULL,
+ ppc_store_tm_cvsxregset },
+ { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_PPC_TM_CVMX, 0, EXTENDED_REGS, NULL,
+ ppc_store_tm_cvrregset },
+ { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_PPC_TM_CFPR, 0, EXTENDED_REGS, NULL,
+ ppc_store_tm_cfprregset },
+ { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_PPC_TM_CGPR, 0, EXTENDED_REGS, NULL,
+ ppc_store_tm_cgprregset },
{ PTRACE_GETREGSET, PTRACE_SETREGSET, NT_PPC_TM_SPR, 0, EXTENDED_REGS,
ppc_fill_tm_sprregset, ppc_store_tm_sprregset },
- { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_PPC_EBB, 0, EXTENDED_REGS,
- NULL, ppc_store_ebbregset },
+ { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_PPC_EBB, 0, EXTENDED_REGS, NULL,
+ ppc_store_ebbregset },
{ PTRACE_GETREGSET, PTRACE_SETREGSET, NT_PPC_PMU, 0, EXTENDED_REGS,
ppc_fill_pmuregset, ppc_store_pmuregset },
{ PTRACE_GETREGSET, PTRACE_SETREGSET, NT_PPC_TAR, 0, EXTENDED_REGS,
@@ -839,34 +826,28 @@ static struct regset_info ppc_regsets[] = {
{ PTRACE_GETREGSET, PTRACE_SETREGSET, NT_PPC_DSCR, 0, EXTENDED_REGS,
ppc_fill_dscrregset, ppc_store_dscrregset },
{ PTRACE_GETVSXREGS, PTRACE_SETVSXREGS, 0, 0, EXTENDED_REGS,
- ppc_fill_vsxregset, ppc_store_vsxregset },
- { PTRACE_GETVRREGS, PTRACE_SETVRREGS, 0, 0, EXTENDED_REGS,
- ppc_fill_vrregset, ppc_store_vrregset },
+ ppc_fill_vsxregset, ppc_store_vsxregset },
+ { PTRACE_GETVRREGS, PTRACE_SETVRREGS, 0, 0, EXTENDED_REGS, ppc_fill_vrregset,
+ ppc_store_vrregset },
{ PTRACE_GETEVRREGS, PTRACE_SETEVRREGS, 0, 0, EXTENDED_REGS,
ppc_fill_evrregset, ppc_store_evrregset },
{ 0, 0, 0, 0, GENERAL_REGS, ppc_fill_gregset, NULL },
NULL_REGSET
};
-static struct usrregs_info ppc_usrregs_info =
- {
- ppc_num_regs,
- ppc_regmap,
- };
-
-static struct regsets_info ppc_regsets_info =
- {
- ppc_regsets, /* regsets */
- 0, /* num_regsets */
- NULL, /* disabled_regsets */
- };
-
-static struct regs_info myregs_info =
- {
- NULL, /* regset_bitmap */
- &ppc_usrregs_info,
- &ppc_regsets_info
- };
+static struct usrregs_info ppc_usrregs_info = {
+ ppc_num_regs,
+ ppc_regmap,
+};
+
+static struct regsets_info ppc_regsets_info = {
+ ppc_regsets, /* regsets */
+ 0, /* num_regsets */
+ NULL, /* disabled_regsets */
+};
+
+static struct regs_info myregs_info = { NULL, /* regset_bitmap */
+ &ppc_usrregs_info, &ppc_regsets_info };
const regs_info *
ppc_target::get_regs_info ()
@@ -886,9 +867,9 @@ ppc_target::low_arch_setup ()
features.wordsize = ppc_linux_target_wordsize (tid);
if (features.wordsize == 4)
- tdesc = tdesc_powerpc_32l;
+ tdesc = tdesc_powerpc_32l;
else
- tdesc = tdesc_powerpc_64l;
+ tdesc = tdesc_powerpc_64l;
current_process ()->tdesc = tdesc;
@@ -911,21 +892,17 @@ ppc_target::low_arch_setup ()
{
features.ppr_dscr = true;
if ((ppc_hwcap2 & PPC_FEATURE2_ARCH_2_07)
- && (ppc_hwcap2 & PPC_FEATURE2_TAR)
- && (ppc_hwcap2 & PPC_FEATURE2_EBB)
- && ppc_check_regset (tid, NT_PPC_TAR,
- PPC_LINUX_SIZEOF_TARREGSET)
- && ppc_check_regset (tid, NT_PPC_EBB,
- PPC_LINUX_SIZEOF_EBBREGSET)
- && ppc_check_regset (tid, NT_PPC_PMU,
- PPC_LINUX_SIZEOF_PMUREGSET))
- {
- features.isa207 = true;
- if ((ppc_hwcap2 & PPC_FEATURE2_HTM)
- && ppc_check_regset (tid, NT_PPC_TM_SPR,
- PPC_LINUX_SIZEOF_TM_SPRREGSET))
- features.htm = true;
- }
+ && (ppc_hwcap2 & PPC_FEATURE2_TAR) && (ppc_hwcap2 & PPC_FEATURE2_EBB)
+ && ppc_check_regset (tid, NT_PPC_TAR, PPC_LINUX_SIZEOF_TARREGSET)
+ && ppc_check_regset (tid, NT_PPC_EBB, PPC_LINUX_SIZEOF_EBBREGSET)
+ && ppc_check_regset (tid, NT_PPC_PMU, PPC_LINUX_SIZEOF_PMUREGSET))
+ {
+ features.isa207 = true;
+ if ((ppc_hwcap2 & PPC_FEATURE2_HTM)
+ && ppc_check_regset (tid, NT_PPC_TM_SPR,
+ PPC_LINUX_SIZEOF_TM_SPRREGSET))
+ features.htm = true;
+ }
}
tdesc = ppc_linux_match_description (features);
@@ -939,17 +916,17 @@ ppc_target::low_arch_setup ()
if (!ppc_regmap_adjusted)
{
if (ppc_hwcap & PPC_FEATURE_HAS_SPE)
- ppc_usrregs_info.regmap = ppc_regmap_e500;
+ ppc_usrregs_info.regmap = ppc_regmap_e500;
/* If the FPSCR is 64-bit wide, we need to fetch the whole
64-bit slot and not just its second word. The PT_FPSCR
supplied in a 32-bit GDB compilation doesn't reflect
this. */
if (register_size (tdesc, 70) == 8)
- ppc_regmap[70] = (48 + 2*32) * sizeof (long);
+ ppc_regmap[70] = (48 + 2 * 32) * sizeof (long);
ppc_regmap_adjusted = 1;
- }
+ }
#endif
current_process ()->tdesc = tdesc;
@@ -958,82 +935,72 @@ ppc_target::low_arch_setup ()
switch (regset->get_request)
{
case PTRACE_GETVRREGS:
- regset->size = features.altivec ? PPC_LINUX_SIZEOF_VRREGSET : 0;
- break;
+ regset->size = features.altivec ? PPC_LINUX_SIZEOF_VRREGSET : 0;
+ break;
case PTRACE_GETVSXREGS:
- regset->size = features.vsx ? PPC_LINUX_SIZEOF_VSXREGSET : 0;
- break;
+ regset->size = features.vsx ? PPC_LINUX_SIZEOF_VSXREGSET : 0;
+ break;
case PTRACE_GETEVRREGS:
- if (ppc_hwcap & PPC_FEATURE_HAS_SPE)
- regset->size = 32 * 4 + 8 + 4;
- else
- regset->size = 0;
- break;
+ if (ppc_hwcap & PPC_FEATURE_HAS_SPE)
+ regset->size = 32 * 4 + 8 + 4;
+ else
+ regset->size = 0;
+ break;
case PTRACE_GETREGSET:
- switch (regset->nt_type)
- {
- case NT_PPC_PPR:
- regset->size = (features.ppr_dscr ?
- PPC_LINUX_SIZEOF_PPRREGSET : 0);
- break;
- case NT_PPC_DSCR:
- regset->size = (features.ppr_dscr ?
- PPC_LINUX_SIZEOF_DSCRREGSET : 0);
- break;
- case NT_PPC_TAR:
- regset->size = (features.isa207 ?
- PPC_LINUX_SIZEOF_TARREGSET : 0);
- break;
- case NT_PPC_EBB:
- regset->size = (features.isa207 ?
- PPC_LINUX_SIZEOF_EBBREGSET : 0);
- break;
- case NT_PPC_PMU:
- regset->size = (features.isa207 ?
- PPC_LINUX_SIZEOF_PMUREGSET : 0);
- break;
- case NT_PPC_TM_SPR:
- regset->size = (features.htm ?
- PPC_LINUX_SIZEOF_TM_SPRREGSET : 0);
- break;
- case NT_PPC_TM_CGPR:
- if (features.wordsize == 4)
- regset->size = (features.htm ?
- PPC32_LINUX_SIZEOF_CGPRREGSET : 0);
- else
- regset->size = (features.htm ?
- PPC64_LINUX_SIZEOF_CGPRREGSET : 0);
- break;
- case NT_PPC_TM_CFPR:
- regset->size = (features.htm ?
- PPC_LINUX_SIZEOF_CFPRREGSET : 0);
- break;
- case NT_PPC_TM_CVMX:
- regset->size = (features.htm ?
- PPC_LINUX_SIZEOF_CVMXREGSET : 0);
- break;
- case NT_PPC_TM_CVSX:
- regset->size = (features.htm ?
- PPC_LINUX_SIZEOF_CVSXREGSET : 0);
- break;
- case NT_PPC_TM_CPPR:
- regset->size = (features.htm ?
- PPC_LINUX_SIZEOF_CPPRREGSET : 0);
- break;
- case NT_PPC_TM_CDSCR:
- regset->size = (features.htm ?
- PPC_LINUX_SIZEOF_CDSCRREGSET : 0);
- break;
- case NT_PPC_TM_CTAR:
- regset->size = (features.htm ?
- PPC_LINUX_SIZEOF_CTARREGSET : 0);
- break;
- default:
- break;
- }
- break;
+ switch (regset->nt_type)
+ {
+ case NT_PPC_PPR:
+ regset->size
+ = (features.ppr_dscr ? PPC_LINUX_SIZEOF_PPRREGSET : 0);
+ break;
+ case NT_PPC_DSCR:
+ regset->size
+ = (features.ppr_dscr ? PPC_LINUX_SIZEOF_DSCRREGSET : 0);
+ break;
+ case NT_PPC_TAR:
+ regset->size = (features.isa207 ? PPC_LINUX_SIZEOF_TARREGSET : 0);
+ break;
+ case NT_PPC_EBB:
+ regset->size = (features.isa207 ? PPC_LINUX_SIZEOF_EBBREGSET : 0);
+ break;
+ case NT_PPC_PMU:
+ regset->size = (features.isa207 ? PPC_LINUX_SIZEOF_PMUREGSET : 0);
+ break;
+ case NT_PPC_TM_SPR:
+ regset->size = (features.htm ? PPC_LINUX_SIZEOF_TM_SPRREGSET : 0);
+ break;
+ case NT_PPC_TM_CGPR:
+ if (features.wordsize == 4)
+ regset->size
+ = (features.htm ? PPC32_LINUX_SIZEOF_CGPRREGSET : 0);
+ else
+ regset->size
+ = (features.htm ? PPC64_LINUX_SIZEOF_CGPRREGSET : 0);
+ break;
+ case NT_PPC_TM_CFPR:
+ regset->size = (features.htm ? PPC_LINUX_SIZEOF_CFPRREGSET : 0);
+ break;
+ case NT_PPC_TM_CVMX:
+ regset->size = (features.htm ? PPC_LINUX_SIZEOF_CVMXREGSET : 0);
+ break;
+ case NT_PPC_TM_CVSX:
+ regset->size = (features.htm ? PPC_LINUX_SIZEOF_CVSXREGSET : 0);
+ break;
+ case NT_PPC_TM_CPPR:
+ regset->size = (features.htm ? PPC_LINUX_SIZEOF_CPPRREGSET : 0);
+ break;
+ case NT_PPC_TM_CDSCR:
+ regset->size = (features.htm ? PPC_LINUX_SIZEOF_CDSCRREGSET : 0);
+ break;
+ case NT_PPC_TM_CTAR:
+ regset->size = (features.htm ? PPC_LINUX_SIZEOF_CTARREGSET : 0);
+ break;
+ default:
+ break;
+ }
+ break;
default:
- break;
+ break;
}
}
@@ -1104,7 +1071,7 @@ is_elfv2_inferior (void)
are located. If it doesn't look like one, bail. */
read_inferior_memory (phdr & ~0xfff, (unsigned char *) &ehdr, sizeof ehdr);
- if (memcmp(ehdr.e_ident, ELFMAG, SELFMAG))
+ if (memcmp (ehdr.e_ident, ELFMAG, SELFMAG))
return def_res;
return (ehdr.e_flags & EF_PPC64_ABI) == 2;
@@ -1117,7 +1084,7 @@ is_elfv2_inferior (void)
0 6 11 16 30 32
| OPCD | RST | RA | DS |XO| */
-__attribute__((unused)) /* Maybe unused due to conditional compilation. */
+__attribute__ ((unused)) /* Maybe unused due to conditional compilation. */
static int
gen_ds_form (uint32_t *buf, int opcd, int rst, int ra, int ds, int xo)
{
@@ -1135,10 +1102,10 @@ gen_ds_form (uint32_t *buf, int opcd, int rst, int ra, int ds, int xo)
/* Followings are frequently used ds-form instructions. */
-#define GEN_STD(buf, rs, ra, offset) gen_ds_form (buf, 62, rs, ra, offset, 0)
-#define GEN_STDU(buf, rs, ra, offset) gen_ds_form (buf, 62, rs, ra, offset, 1)
-#define GEN_LD(buf, rt, ra, offset) gen_ds_form (buf, 58, rt, ra, offset, 0)
-#define GEN_LDU(buf, rt, ra, offset) gen_ds_form (buf, 58, rt, ra, offset, 1)
+#define GEN_STD(buf, rs, ra, offset) gen_ds_form (buf, 62, rs, ra, offset, 0)
+#define GEN_STDU(buf, rs, ra, offset) gen_ds_form (buf, 62, rs, ra, offset, 1)
+#define GEN_LD(buf, rt, ra, offset) gen_ds_form (buf, 58, rt, ra, offset, 0)
+#define GEN_LDU(buf, rt, ra, offset) gen_ds_form (buf, 58, rt, ra, offset, 1)
/* Generate a d-form instruction in BUF.
@@ -1161,15 +1128,15 @@ gen_d_form (uint32_t *buf, int opcd, int rst, int ra, int si)
/* Followings are frequently used d-form instructions. */
-#define GEN_ADDI(buf, rt, ra, si) gen_d_form (buf, 14, rt, ra, si)
-#define GEN_ADDIS(buf, rt, ra, si) gen_d_form (buf, 15, rt, ra, si)
-#define GEN_LI(buf, rt, si) GEN_ADDI (buf, rt, 0, si)
-#define GEN_LIS(buf, rt, si) GEN_ADDIS (buf, rt, 0, si)
-#define GEN_ORI(buf, rt, ra, si) gen_d_form (buf, 24, rt, ra, si)
-#define GEN_ORIS(buf, rt, ra, si) gen_d_form (buf, 25, rt, ra, si)
-#define GEN_LWZ(buf, rt, ra, si) gen_d_form (buf, 32, rt, ra, si)
-#define GEN_STW(buf, rt, ra, si) gen_d_form (buf, 36, rt, ra, si)
-#define GEN_STWU(buf, rt, ra, si) gen_d_form (buf, 37, rt, ra, si)
+#define GEN_ADDI(buf, rt, ra, si) gen_d_form (buf, 14, rt, ra, si)
+#define GEN_ADDIS(buf, rt, ra, si) gen_d_form (buf, 15, rt, ra, si)
+#define GEN_LI(buf, rt, si) GEN_ADDI (buf, rt, 0, si)
+#define GEN_LIS(buf, rt, si) GEN_ADDIS (buf, rt, 0, si)
+#define GEN_ORI(buf, rt, ra, si) gen_d_form (buf, 24, rt, ra, si)
+#define GEN_ORIS(buf, rt, ra, si) gen_d_form (buf, 25, rt, ra, si)
+#define GEN_LWZ(buf, rt, ra, si) gen_d_form (buf, 32, rt, ra, si)
+#define GEN_STW(buf, rt, ra, si) gen_d_form (buf, 36, rt, ra, si)
+#define GEN_STWU(buf, rt, ra, si) gen_d_form (buf, 37, rt, ra, si)
/* Generate a xfx-form instruction in BUF and return the number of bytes
written.
@@ -1194,14 +1161,12 @@ gen_xfx_form (uint32_t *buf, int opcd, int rst, int ri, int xo)
/* Followings are frequently used xfx-form instructions. */
-#define GEN_MFSPR(buf, rt, spr) gen_xfx_form (buf, 31, rt, spr, 339)
-#define GEN_MTSPR(buf, rt, spr) gen_xfx_form (buf, 31, rt, spr, 467)
-#define GEN_MFCR(buf, rt) gen_xfx_form (buf, 31, rt, 0, 19)
-#define GEN_MTCR(buf, rt) gen_xfx_form (buf, 31, rt, 0x3cf, 144)
-#define GEN_SYNC(buf, L, E) gen_xfx_form (buf, 31, L & 0x3, \
- E & 0xf, 598)
-#define GEN_LWSYNC(buf) GEN_SYNC (buf, 1, 0)
-
+#define GEN_MFSPR(buf, rt, spr) gen_xfx_form (buf, 31, rt, spr, 339)
+#define GEN_MTSPR(buf, rt, spr) gen_xfx_form (buf, 31, rt, spr, 467)
+#define GEN_MFCR(buf, rt) gen_xfx_form (buf, 31, rt, 0, 19)
+#define GEN_MTCR(buf, rt) gen_xfx_form (buf, 31, rt, 0x3cf, 144)
+#define GEN_SYNC(buf, L, E) gen_xfx_form (buf, 31, L & 0x3, E & 0xf, 598)
+#define GEN_LWSYNC(buf) GEN_SYNC (buf, 1, 0)
/* Generate a x-form instruction in BUF and return the number of bytes written.
@@ -1227,13 +1192,12 @@ gen_x_form (uint32_t *buf, int opcd, int rst, int ra, int rb, int xo, int rc)
/* Followings are frequently used x-form instructions. */
-#define GEN_OR(buf, ra, rs, rb) gen_x_form (buf, 31, rs, ra, rb, 444, 0)
-#define GEN_MR(buf, ra, rs) GEN_OR (buf, ra, rs, rs)
-#define GEN_LWARX(buf, rt, ra, rb) gen_x_form (buf, 31, rt, ra, rb, 20, 0)
-#define GEN_STWCX(buf, rs, ra, rb) gen_x_form (buf, 31, rs, ra, rb, 150, 1)
+#define GEN_OR(buf, ra, rs, rb) gen_x_form (buf, 31, rs, ra, rb, 444, 0)
+#define GEN_MR(buf, ra, rs) GEN_OR (buf, ra, rs, rs)
+#define GEN_LWARX(buf, rt, ra, rb) gen_x_form (buf, 31, rt, ra, rb, 20, 0)
+#define GEN_STWCX(buf, rs, ra, rb) gen_x_form (buf, 31, rs, ra, rb, 150, 1)
/* Assume bf = cr7. */
-#define GEN_CMPW(buf, ra, rb) gen_x_form (buf, 31, 28, ra, rb, 0, 0)
-
+#define GEN_CMPW(buf, ra, rb) gen_x_form (buf, 31, 28, ra, rb, 0, 0)
/* Generate a md-form instruction in BUF and return the number of bytes written.
@@ -1241,8 +1205,8 @@ gen_x_form (uint32_t *buf, int opcd, int rst, int ra, int rb, int xo, int rc)
| OPCD | RS | RA | sh | mb | XO |sh|Rc| */
static int
-gen_md_form (uint32_t *buf, int opcd, int rs, int ra, int sh, int mb,
- int xo, int rc)
+gen_md_form (uint32_t *buf, int opcd, int rs, int ra, int sh, int mb, int xo,
+ int rc)
{
uint32_t insn;
unsigned int n = ((mb & 0x1f) << 1) | ((mb >> 5) & 0x1);
@@ -1257,18 +1221,18 @@ gen_md_form (uint32_t *buf, int opcd, int rs, int ra, int sh, int mb,
gdb_assert ((xo & ~0x7) == 0);
gdb_assert ((rc & ~0x1) == 0);
- insn = (rs << 21) | (ra << 16) | (sh0_4 << 11) | (n << 5)
- | (sh5 << 1) | (xo << 2) | (rc & 1);
+ insn = (rs << 21) | (ra << 16) | (sh0_4 << 11) | (n << 5) | (sh5 << 1)
+ | (xo << 2) | (rc & 1);
*buf = (opcd << 26) | insn;
return 1;
}
/* The following are frequently used md-form instructions. */
-#define GEN_RLDICL(buf, ra, rs ,sh, mb) \
- gen_md_form (buf, 30, rs, ra, sh, mb, 0, 0)
-#define GEN_RLDICR(buf, ra, rs ,sh, mb) \
- gen_md_form (buf, 30, rs, ra, sh, mb, 1, 0)
+#define GEN_RLDICL(buf, ra, rs, sh, mb) \
+ gen_md_form (buf, 30, rs, ra, sh, mb, 0, 0)
+#define GEN_RLDICR(buf, ra, rs, sh, mb) \
+ gen_md_form (buf, 30, rs, ra, sh, mb, 1, 0)
/* Generate a i-form instruction in BUF and return the number of bytes written.
@@ -1289,8 +1253,8 @@ gen_i_form (uint32_t *buf, int opcd, int li, int aa, int lk)
/* The following are frequently used i-form instructions. */
-#define GEN_B(buf, li) gen_i_form (buf, 18, li, 0, 0)
-#define GEN_BL(buf, li) gen_i_form (buf, 18, li, 0, 1)
+#define GEN_B(buf, li) gen_i_form (buf, 18, li, 0, 0)
+#define GEN_BL(buf, li) gen_i_form (buf, 18, li, 0, 1)
/* Generate a b-form instruction in BUF and return the number of bytes written.
@@ -1298,8 +1262,7 @@ gen_i_form (uint32_t *buf, int opcd, int li, int aa, int lk)
| OPCD | BO | BI | BD |AA|LK| */
static int
-gen_b_form (uint32_t *buf, int opcd, int bo, int bi, int bd,
- int aa, int lk)
+gen_b_form (uint32_t *buf, int opcd, int bo, int bi, int bd, int aa, int lk)
{
uint32_t insn;
@@ -1314,22 +1277,20 @@ gen_b_form (uint32_t *buf, int opcd, int bo, int bi, int bd,
/* The following are frequently used b-form instructions. */
/* Assume bi = cr7. */
-#define GEN_BNE(buf, bd) gen_b_form (buf, 16, 0x4, (7 << 2) | 2, bd, 0 ,0)
+#define GEN_BNE(buf, bd) gen_b_form (buf, 16, 0x4, (7 << 2) | 2, bd, 0, 0)
/* GEN_LOAD and GEN_STORE generate 64- or 32-bit load/store for ppc64 or ppc32
respectively. They are primary used for save/restore GPRs in jump-pad,
not used for bytecode compiling. */
#ifdef __powerpc64__
-#define GEN_LOAD(buf, rt, ra, si, is_64) (is_64 ? \
- GEN_LD (buf, rt, ra, si) : \
- GEN_LWZ (buf, rt, ra, si))
-#define GEN_STORE(buf, rt, ra, si, is_64) (is_64 ? \
- GEN_STD (buf, rt, ra, si) : \
- GEN_STW (buf, rt, ra, si))
+#define GEN_LOAD(buf, rt, ra, si, is_64) \
+ (is_64 ? GEN_LD (buf, rt, ra, si) : GEN_LWZ (buf, rt, ra, si))
+#define GEN_STORE(buf, rt, ra, si, is_64) \
+ (is_64 ? GEN_STD (buf, rt, ra, si) : GEN_STW (buf, rt, ra, si))
#else
-#define GEN_LOAD(buf, rt, ra, si, is_64) GEN_LWZ (buf, rt, ra, si)
-#define GEN_STORE(buf, rt, ra, si, is_64) GEN_STW (buf, rt, ra, si)
+#define GEN_LOAD(buf, rt, ra, si, is_64) GEN_LWZ (buf, rt, ra, si)
+#define GEN_STORE(buf, rt, ra, si, is_64) GEN_STW (buf, rt, ra, si)
#endif
/* Generate a sequence of instructions to load IMM in the register REG.
@@ -1352,10 +1313,10 @@ gen_limm (uint32_t *buf, int reg, uint64_t imm, int is_64)
rldicl reg, reg, 0, 32 */
p += GEN_LIS (p, reg, (imm >> 16) & 0xffff);
if ((imm & 0xffff) != 0)
- p += GEN_ORI (p, reg, reg, imm & 0xffff);
+ p += GEN_ORI (p, reg, reg, imm & 0xffff);
/* Clear upper 32-bit if sign-bit is set. */
if (imm & (1u << 31) && is_64)
- p += GEN_RLDICL (p, reg, reg, 0, 32);
+ p += GEN_RLDICL (p, reg, reg, 0, 32);
}
else
{
@@ -1367,12 +1328,12 @@ gen_limm (uint32_t *buf, int reg, uint64_t imm, int is_64)
ori reg, reg, <imm[15:0]> */
p += GEN_LIS (p, reg, ((imm >> 48) & 0xffff));
if (((imm >> 32) & 0xffff) != 0)
- p += GEN_ORI (p, reg, reg, ((imm >> 32) & 0xffff));
+ p += GEN_ORI (p, reg, reg, ((imm >> 32) & 0xffff));
p += GEN_RLDICR (p, reg, reg, 32, 31);
if (((imm >> 16) & 0xffff) != 0)
- p += GEN_ORIS (p, reg, reg, ((imm >> 16) & 0xffff));
+ p += GEN_ORIS (p, reg, reg, ((imm >> 16) & 0xffff));
if ((imm & 0xffff) != 0)
- p += GEN_ORI (p, reg, reg, (imm & 0xffff));
+ p += GEN_ORI (p, reg, reg, (imm & 0xffff));
}
return p - buf;
@@ -1385,7 +1346,7 @@ gen_limm (uint32_t *buf, int reg, uint64_t imm, int is_64)
static int
gen_atomic_xchg (uint32_t *buf, CORE_ADDR lock, int old_value, int r_new,
- int is_64)
+ int is_64)
{
const int r_lock = 6;
const int r_old = 7;
@@ -1427,8 +1388,8 @@ gen_call (uint32_t *buf, CORE_ADDR fn, int is_64, int is_opd)
p += GEN_LOAD (p, 2, 12, 8, is_64);
p += GEN_LOAD (p, 12, 12, 0, is_64);
}
- p += GEN_MTSPR (p, 12, 9); /* mtctr r12 */
- *p++ = 0x4e800421; /* bctrl */
+ p += GEN_MTSPR (p, 12, 9); /* mtctr r12 */
+ *p++ = 0x4e800421; /* bctrl */
return p - buf;
}
@@ -1454,7 +1415,7 @@ ppc_relocate_instruction (CORE_ADDR *to, CORE_ADDR oldloc)
/* Out of range. Cannot relocate instruction. */
if (newrel >= (1 << 25) || newrel < -(1 << 25))
- return;
+ return;
insn = (insn & ~0x3fffffc) | (newrel & 0x3fffffc);
}
@@ -1503,75 +1464,75 @@ ppc_relocate_instruction (CORE_ADDR *to, CORE_ADDR oldloc)
newrel = (oldloc - *to) + rel;
if (newrel < (1 << 15) && newrel >= -(1 << 15))
- insn = (insn & ~0xfffc) | (newrel & 0xfffc);
+ insn = (insn & ~0xfffc) | (newrel & 0xfffc);
else if ((PPC_BO (insn) & 0x14) == 0x4 || (PPC_BO (insn) & 0x14) == 0x10)
- {
- newrel -= 4;
-
- /* Out of range. Cannot relocate instruction. */
- if (newrel >= (1 << 25) || newrel < -(1 << 25))
- return;
-
- if ((PPC_BO (insn) & 0x14) == 0x4)
- insn ^= (1 << 24);
- else if ((PPC_BO (insn) & 0x14) == 0x10)
- insn ^= (1 << 22);
-
- /* Jump over the unconditional branch. */
- insn = (insn & ~0xfffc) | 0x8;
- target_write_memory (*to, (unsigned char *) &insn, 4);
- *to += 4;
-
- /* Build a unconditional branch and copy LK bit. */
- insn = (18 << 26) | (0x3fffffc & newrel) | (insn & 0x3);
- target_write_memory (*to, (unsigned char *) &insn, 4);
- *to += 4;
-
- return;
- }
+ {
+ newrel -= 4;
+
+ /* Out of range. Cannot relocate instruction. */
+ if (newrel >= (1 << 25) || newrel < -(1 << 25))
+ return;
+
+ if ((PPC_BO (insn) & 0x14) == 0x4)
+ insn ^= (1 << 24);
+ else if ((PPC_BO (insn) & 0x14) == 0x10)
+ insn ^= (1 << 22);
+
+ /* Jump over the unconditional branch. */
+ insn = (insn & ~0xfffc) | 0x8;
+ target_write_memory (*to, (unsigned char *) &insn, 4);
+ *to += 4;
+
+ /* Build a unconditional branch and copy LK bit. */
+ insn = (18 << 26) | (0x3fffffc & newrel) | (insn & 0x3);
+ target_write_memory (*to, (unsigned char *) &insn, 4);
+ *to += 4;
+
+ return;
+ }
else if ((PPC_BO (insn) & 0x14) == 0)
- {
- uint32_t bdnz_insn = (16 << 26) | (0x10 << 21) | 12;
- uint32_t bf_insn = (16 << 26) | (0x4 << 21) | 8;
+ {
+ uint32_t bdnz_insn = (16 << 26) | (0x10 << 21) | 12;
+ uint32_t bf_insn = (16 << 26) | (0x4 << 21) | 8;
- newrel -= 8;
+ newrel -= 8;
- /* Out of range. Cannot relocate instruction. */
- if (newrel >= (1 << 25) || newrel < -(1 << 25))
- return;
+ /* Out of range. Cannot relocate instruction. */
+ if (newrel >= (1 << 25) || newrel < -(1 << 25))
+ return;
- /* Copy BI field. */
- bf_insn |= (insn & 0x1f0000);
+ /* Copy BI field. */
+ bf_insn |= (insn & 0x1f0000);
- /* Invert condition. */
- bdnz_insn |= (insn ^ (1 << 22)) & (1 << 22);
- bf_insn |= (insn ^ (1 << 24)) & (1 << 24);
+ /* Invert condition. */
+ bdnz_insn |= (insn ^ (1 << 22)) & (1 << 22);
+ bf_insn |= (insn ^ (1 << 24)) & (1 << 24);
- target_write_memory (*to, (unsigned char *) &bdnz_insn, 4);
- *to += 4;
- target_write_memory (*to, (unsigned char *) &bf_insn, 4);
- *to += 4;
+ target_write_memory (*to, (unsigned char *) &bdnz_insn, 4);
+ *to += 4;
+ target_write_memory (*to, (unsigned char *) &bf_insn, 4);
+ *to += 4;
- /* Build a unconditional branch and copy LK bit. */
- insn = (18 << 26) | (0x3fffffc & newrel) | (insn & 0x3);
- target_write_memory (*to, (unsigned char *) &insn, 4);
- *to += 4;
+ /* Build a unconditional branch and copy LK bit. */
+ insn = (18 << 26) | (0x3fffffc & newrel) | (insn & 0x3);
+ target_write_memory (*to, (unsigned char *) &insn, 4);
+ *to += 4;
- return;
- }
+ return;
+ }
else /* (BO & 0x14) == 0x14, branch always. */
- {
- /* Out of range. Cannot relocate instruction. */
- if (newrel >= (1 << 25) || newrel < -(1 << 25))
- return;
-
- /* Build a unconditional branch and copy LK bit. */
- insn = (18 << 26) | (0x3fffffc & newrel) | (insn & 0x3);
- target_write_memory (*to, (unsigned char *) &insn, 4);
- *to += 4;
-
- return;
- }
+ {
+ /* Out of range. Cannot relocate instruction. */
+ if (newrel >= (1 << 25) || newrel < -(1 << 25))
+ return;
+
+ /* Build a unconditional branch and copy LK bit. */
+ insn = (18 << 26) | (0x3fffffc & newrel) | (insn & 0x3);
+ target_write_memory (*to, (unsigned char *) &insn, 4);
+ *to += 4;
+
+ return;
+ }
}
target_write_memory (*to, (unsigned char *) &insn, 4);
@@ -1588,19 +1549,12 @@ ppc_target::supports_fast_tracepoints ()
See target.h for details. */
int
-ppc_target::install_fast_tracepoint_jump_pad (CORE_ADDR tpoint,
- CORE_ADDR tpaddr,
- CORE_ADDR collector,
- CORE_ADDR lockaddr,
- ULONGEST orig_size,
- CORE_ADDR *jump_entry,
- CORE_ADDR *trampoline,
- ULONGEST *trampoline_size,
- unsigned char *jjump_pad_insn,
- ULONGEST *jjump_pad_insn_size,
- CORE_ADDR *adjusted_insn_addr,
- CORE_ADDR *adjusted_insn_addr_end,
- char *err)
+ppc_target::install_fast_tracepoint_jump_pad (
+ CORE_ADDR tpoint, CORE_ADDR tpaddr, CORE_ADDR collector, CORE_ADDR lockaddr,
+ ULONGEST orig_size, CORE_ADDR *jump_entry, CORE_ADDR *trampoline,
+ ULONGEST *trampoline_size, unsigned char *jjump_pad_insn,
+ ULONGEST *jjump_pad_insn_size, CORE_ADDR *adjusted_insn_addr,
+ CORE_ADDR *adjusted_insn_addr_end, char *err)
{
uint32_t buf[256];
uint32_t *p = buf;
@@ -1669,9 +1623,9 @@ ppc_target::install_fast_tracepoint_jump_pad (CORE_ADDR tpoint,
/* Adjust stack pointer. */
if (is_64)
- p += GEN_STDU (p, 1, 1, -frame_size); /* stdu r1,-frame_size(r1) */
+ p += GEN_STDU (p, 1, 1, -frame_size); /* stdu r1,-frame_size(r1) */
else
- p += GEN_STWU (p, 1, 1, -frame_size); /* stwu r1,-frame_size(r1) */
+ p += GEN_STWU (p, 1, 1, -frame_size); /* stwu r1,-frame_size(r1) */
/* Store GPRs. Save R1 later, because it had just been modified, but
we want the original value. */
@@ -1684,20 +1638,23 @@ ppc_target::install_fast_tracepoint_jump_pad (CORE_ADDR tpoint,
p += GEN_STORE (p, 0, 1, min_frame + 1 * rsz, is_64);
/* Save CR, XER, LR, and CTR. */
- p += GEN_MFCR (p, 3); /* mfcr r3 */
- p += GEN_MFSPR (p, 4, 1); /* mfxer r4 */
- p += GEN_MFSPR (p, 5, 8); /* mflr r5 */
- p += GEN_MFSPR (p, 6, 9); /* mfctr r6 */
- p += GEN_STORE (p, 3, 1, min_frame + 32 * rsz, is_64);/* std r3, 32(r1) */
- p += GEN_STORE (p, 4, 1, min_frame + 33 * rsz, is_64);/* std r4, 33(r1) */
- p += GEN_STORE (p, 5, 1, min_frame + 34 * rsz, is_64);/* std r5, 34(r1) */
- p += GEN_STORE (p, 6, 1, min_frame + 35 * rsz, is_64);/* std r6, 35(r1) */
+ p += GEN_MFCR (p, 3); /* mfcr r3 */
+ p += GEN_MFSPR (p, 4, 1); /* mfxer r4 */
+ p += GEN_MFSPR (p, 5, 8); /* mflr r5 */
+ p += GEN_MFSPR (p, 6, 9); /* mfctr r6 */
+ p += GEN_STORE (p, 3, 1, min_frame + 32 * rsz,
+ is_64); /* std r3, 32(r1) */
+ p += GEN_STORE (p, 4, 1, min_frame + 33 * rsz,
+ is_64); /* std r4, 33(r1) */
+ p += GEN_STORE (p, 5, 1, min_frame + 34 * rsz,
+ is_64); /* std r5, 34(r1) */
+ p += GEN_STORE (p, 6, 1, min_frame + 35 * rsz,
+ is_64); /* std r6, 35(r1) */
/* Save PC<tpaddr> */
p += gen_limm (p, 3, tpaddr, is_64);
p += GEN_STORE (p, 3, 1, min_frame + 36 * rsz, is_64);
-
/* Setup arguments to collector. */
/* Set r4 to collected registers. */
p += GEN_ADDI (p, 4, 1, min_frame);
@@ -1724,14 +1681,14 @@ ppc_target::install_fast_tracepoint_jump_pad (CORE_ADDR tpoint,
p += GEN_STORE (p, 4, 3, 0, is_64);
/* Restore stack and registers. */
- p += GEN_LOAD (p, 3, 1, min_frame + 32 * rsz, is_64); /* ld r3, 32(r1) */
- p += GEN_LOAD (p, 4, 1, min_frame + 33 * rsz, is_64); /* ld r4, 33(r1) */
- p += GEN_LOAD (p, 5, 1, min_frame + 34 * rsz, is_64); /* ld r5, 34(r1) */
- p += GEN_LOAD (p, 6, 1, min_frame + 35 * rsz, is_64); /* ld r6, 35(r1) */
- p += GEN_MTCR (p, 3); /* mtcr r3 */
- p += GEN_MTSPR (p, 4, 1); /* mtxer r4 */
- p += GEN_MTSPR (p, 5, 8); /* mtlr r5 */
- p += GEN_MTSPR (p, 6, 9); /* mtctr r6 */
+ p += GEN_LOAD (p, 3, 1, min_frame + 32 * rsz, is_64); /* ld r3, 32(r1) */
+ p += GEN_LOAD (p, 4, 1, min_frame + 33 * rsz, is_64); /* ld r4, 33(r1) */
+ p += GEN_LOAD (p, 5, 1, min_frame + 34 * rsz, is_64); /* ld r5, 34(r1) */
+ p += GEN_LOAD (p, 6, 1, min_frame + 35 * rsz, is_64); /* ld r6, 35(r1) */
+ p += GEN_MTCR (p, 3); /* mtcr r3 */
+ p += GEN_MTSPR (p, 4, 1); /* mtxer r4 */
+ p += GEN_MTSPR (p, 5, 8); /* mtlr r5 */
+ p += GEN_MTSPR (p, 6, 9); /* mtctr r6 */
/* Restore GPRs. */
for (j = 2; j < 32; j++)
@@ -1753,9 +1710,10 @@ ppc_target::install_fast_tracepoint_jump_pad (CORE_ADDR tpoint,
if ((*adjusted_insn_addr_end - *adjusted_insn_addr == 0)
|| (*adjusted_insn_addr_end - *adjusted_insn_addr > 12))
{
- sprintf (err, "E.Unexpected instruction length = %d"
- "when relocate instruction.",
- (int) (*adjusted_insn_addr_end - *adjusted_insn_addr));
+ sprintf (err,
+ "E.Unexpected instruction length = %d"
+ "when relocate instruction.",
+ (int) (*adjusted_insn_addr_end - *adjusted_insn_addr));
return 1;
}
@@ -1765,8 +1723,10 @@ ppc_target::install_fast_tracepoint_jump_pad (CORE_ADDR tpoint,
offset = (tpaddr + 4) - buildaddr;
if (offset >= (1 << 25) || offset < -(1 << 25))
{
- sprintf (err, "E.Jump back from jump pad too far from tracepoint "
- "(offset 0x%x > 26-bit).", offset);
+ sprintf (err,
+ "E.Jump back from jump pad too far from tracepoint "
+ "(offset 0x%x > 26-bit).",
+ offset);
return 1;
}
/* b <tpaddr+4> */
@@ -1781,8 +1741,10 @@ ppc_target::install_fast_tracepoint_jump_pad (CORE_ADDR tpoint,
offset = entryaddr - tpaddr;
if (offset >= (1 << 25) || offset < -(1 << 25))
{
- sprintf (err, "E.Jump back from jump pad too far from tracepoint "
- "(offset 0x%x > 26-bit).", offset);
+ sprintf (err,
+ "E.Jump back from jump pad too far from tracepoint "
+ "(offset 0x%x > 26-bit).",
+ offset);
return 1;
}
/* b <jentry> */
@@ -1811,22 +1773,21 @@ emit_insns (uint32_t *buf, int n)
current_insn_ptr += n;
}
-#define __EMIT_ASM(NAME, INSNS) \
- do \
- { \
- extern uint32_t start_bcax_ ## NAME []; \
- extern uint32_t end_bcax_ ## NAME []; \
- emit_insns (start_bcax_ ## NAME, \
- end_bcax_ ## NAME - start_bcax_ ## NAME); \
- __asm__ (".section .text.__ppcbcax\n\t" \
- "start_bcax_" #NAME ":\n\t" \
- INSNS "\n\t" \
- "end_bcax_" #NAME ":\n\t" \
- ".previous\n\t"); \
- } while (0)
+#define __EMIT_ASM(NAME, INSNS) \
+ do \
+ { \
+ extern uint32_t start_bcax_##NAME[]; \
+ extern uint32_t end_bcax_##NAME[]; \
+ emit_insns (start_bcax_##NAME, end_bcax_##NAME - start_bcax_##NAME); \
+ __asm__ (".section .text.__ppcbcax\n\t" \
+ "start_bcax_" #NAME ":\n\t" INSNS "\n\t" \
+ "end_bcax_" #NAME ":\n\t" \
+ ".previous\n\t"); \
+ } \
+ while (0)
-#define _EMIT_ASM(NAME, INSNS) __EMIT_ASM (NAME, INSNS)
-#define EMIT_ASM(INSNS) _EMIT_ASM (__LINE__, INSNS)
+#define _EMIT_ASM(NAME, INSNS) __EMIT_ASM (NAME, INSNS)
+#define EMIT_ASM(INSNS) _EMIT_ASM (__LINE__, INSNS)
/*
@@ -1875,15 +1836,15 @@ emit_insns (uint32_t *buf, int n)
Likewise, to simplify code, have a similiar define for 5:6. */
#if __BYTE_ORDER == __LITTLE_ENDIAN
-#define TOP_FIRST "4"
-#define TOP_SECOND "3"
-#define TMP_FIRST "6"
-#define TMP_SECOND "5"
+#define TOP_FIRST "4"
+#define TOP_SECOND "3"
+#define TMP_FIRST "6"
+#define TMP_SECOND "5"
#else
-#define TOP_FIRST "3"
-#define TOP_SECOND "4"
-#define TMP_FIRST "5"
-#define TMP_SECOND "6"
+#define TOP_FIRST "3"
+#define TOP_SECOND "4"
+#define TMP_FIRST "5"
+#define TMP_SECOND "6"
#endif
/* Emit prologue in inferior memory. See above comments. */
@@ -1892,22 +1853,22 @@ static void
ppc_emit_prologue (void)
{
EMIT_ASM (/* Save return address. */
- "mflr 0 \n"
- "stw 0, 4(1) \n"
- /* Adjust SP. 96 is the initial frame size. */
- "stwu 1, -96(1) \n"
- /* Save r30 and incoming arguments. */
- "stw 31, 96-4(1) \n"
- "stw 30, 96-8(1) \n"
- "stw 4, 96-12(1) \n"
- "stw 3, 96-16(1) \n"
- /* Point r31 to original r1 for access arguments. */
- "addi 31, 1, 96 \n"
- /* Set r30 to pointing stack-top. */
- "addi 30, 1, 64 \n"
- /* Initial r3/TOP to 0. */
- "li 3, 0 \n"
- "li 4, 0 \n");
+ "mflr 0 \n"
+ "stw 0, 4(1) \n"
+ /* Adjust SP. 96 is the initial frame size. */
+ "stwu 1, -96(1) \n"
+ /* Save r30 and incoming arguments. */
+ "stw 31, 96-4(1) \n"
+ "stw 30, 96-8(1) \n"
+ "stw 4, 96-12(1) \n"
+ "stw 3, 96-16(1) \n"
+ /* Point r31 to original r1 for access arguments. */
+ "addi 31, 1, 96 \n"
+ /* Set r30 to pointing stack-top. */
+ "addi 30, 1, 64 \n"
+ /* Initial r3/TOP to 0. */
+ "li 3, 0 \n"
+ "li 4, 0 \n");
}
/* Emit epilogue in inferior memory. See above comments. */
@@ -1916,20 +1877,20 @@ static void
ppc_emit_epilogue (void)
{
EMIT_ASM (/* *result = TOP */
- "lwz 5, -12(31) \n"
- "stw " TOP_FIRST ", 0(5) \n"
- "stw " TOP_SECOND ", 4(5) \n"
- /* Restore registers. */
- "lwz 31, -4(31) \n"
- "lwz 30, -8(31) \n"
- /* Restore SP. */
- "lwz 1, 0(1) \n"
- /* Restore LR. */
- "lwz 0, 4(1) \n"
- /* Return 0 for no-error. */
- "li 3, 0 \n"
- "mtlr 0 \n"
- "blr \n");
+ "lwz 5, -12(31) \n"
+ "stw " TOP_FIRST ", 0(5) \n"
+ "stw " TOP_SECOND ", 4(5) \n"
+ /* Restore registers. */
+ "lwz 31, -4(31) \n"
+ "lwz 30, -8(31) \n"
+ /* Restore SP. */
+ "lwz 1, 0(1) \n"
+ /* Restore LR. */
+ "lwz 0, 4(1) \n"
+ /* Return 0 for no-error. */
+ "li 3, 0 \n"
+ "mtlr 0 \n"
+ "blr \n");
}
/* TOP = stack[--sp] + TOP */
@@ -1938,9 +1899,9 @@ static void
ppc_emit_add (void)
{
EMIT_ASM ("lwzu " TMP_FIRST ", 8(30) \n"
- "lwz " TMP_SECOND ", 4(30)\n"
- "addc 4, 6, 4 \n"
- "adde 3, 5, 3 \n");
+ "lwz " TMP_SECOND ", 4(30)\n"
+ "addc 4, 6, 4 \n"
+ "adde 3, 5, 3 \n");
}
/* TOP = stack[--sp] - TOP */
@@ -1949,9 +1910,9 @@ static void
ppc_emit_sub (void)
{
EMIT_ASM ("lwzu " TMP_FIRST ", 8(30) \n"
- "lwz " TMP_SECOND ", 4(30) \n"
- "subfc 4, 4, 6 \n"
- "subfe 3, 3, 5 \n");
+ "lwz " TMP_SECOND ", 4(30) \n"
+ "subfc 4, 4, 6 \n"
+ "subfe 3, 3, 5 \n");
}
/* TOP = stack[--sp] * TOP */
@@ -1960,13 +1921,13 @@ static void
ppc_emit_mul (void)
{
EMIT_ASM ("lwzu " TMP_FIRST ", 8(30) \n"
- "lwz " TMP_SECOND ", 4(30) \n"
- "mulhwu 7, 6, 4 \n"
- "mullw 3, 6, 3 \n"
- "mullw 5, 4, 5 \n"
- "mullw 4, 6, 4 \n"
- "add 3, 5, 3 \n"
- "add 3, 7, 3 \n");
+ "lwz " TMP_SECOND ", 4(30) \n"
+ "mulhwu 7, 6, 4 \n"
+ "mullw 3, 6, 3 \n"
+ "mullw 5, 4, 5 \n"
+ "mullw 4, 6, 4 \n"
+ "add 3, 5, 3 \n"
+ "add 3, 7, 3 \n");
}
/* TOP = stack[--sp] << TOP */
@@ -1975,15 +1936,15 @@ static void
ppc_emit_lsh (void)
{
EMIT_ASM ("lwzu " TMP_FIRST ", 8(30) \n"
- "lwz " TMP_SECOND ", 4(30) \n"
- "subfic 3, 4, 32\n" /* r3 = 32 - TOP */
- "addi 7, 4, -32\n" /* r7 = TOP - 32 */
- "slw 5, 5, 4\n" /* Shift high part left */
- "slw 4, 6, 4\n" /* Shift low part left */
- "srw 3, 6, 3\n" /* Shift low to high if shift < 32 */
- "slw 7, 6, 7\n" /* Shift low to high if shift >= 32 */
- "or 3, 5, 3\n"
- "or 3, 7, 3\n"); /* Assemble high part */
+ "lwz " TMP_SECOND ", 4(30) \n"
+ "subfic 3, 4, 32\n" /* r3 = 32 - TOP */
+ "addi 7, 4, -32\n" /* r7 = TOP - 32 */
+ "slw 5, 5, 4\n" /* Shift high part left */
+ "slw 4, 6, 4\n" /* Shift low part left */
+ "srw 3, 6, 3\n" /* Shift low to high if shift < 32 */
+ "slw 7, 6, 7\n" /* Shift low to high if shift >= 32 */
+ "or 3, 5, 3\n"
+ "or 3, 7, 3\n"); /* Assemble high part */
}
/* Top = stack[--sp] >> TOP
@@ -1993,19 +1954,19 @@ static void
ppc_emit_rsh_signed (void)
{
EMIT_ASM ("lwzu " TMP_FIRST ", 8(30) \n"
- "lwz " TMP_SECOND ", 4(30) \n"
- "addi 7, 4, -32\n" /* r7 = TOP - 32 */
- "sraw 3, 5, 4\n" /* Shift high part right */
- "cmpwi 7, 1\n"
- "blt 0, 1f\n" /* If shift <= 32, goto 1: */
- "sraw 4, 5, 7\n" /* Shift high to low */
- "b 2f\n"
- "1:\n"
- "subfic 7, 4, 32\n" /* r7 = 32 - TOP */
- "srw 4, 6, 4\n" /* Shift low part right */
- "slw 5, 5, 7\n" /* Shift high to low */
- "or 4, 4, 5\n" /* Assemble low part */
- "2:\n");
+ "lwz " TMP_SECOND ", 4(30) \n"
+ "addi 7, 4, -32\n" /* r7 = TOP - 32 */
+ "sraw 3, 5, 4\n" /* Shift high part right */
+ "cmpwi 7, 1\n"
+ "blt 0, 1f\n" /* If shift <= 32, goto 1: */
+ "sraw 4, 5, 7\n" /* Shift high to low */
+ "b 2f\n"
+ "1:\n"
+ "subfic 7, 4, 32\n" /* r7 = 32 - TOP */
+ "srw 4, 6, 4\n" /* Shift low part right */
+ "slw 5, 5, 7\n" /* Shift high to low */
+ "or 4, 4, 5\n" /* Assemble low part */
+ "2:\n");
}
/* Top = stack[--sp] >> TOP
@@ -2015,15 +1976,15 @@ static void
ppc_emit_rsh_unsigned (void)
{
EMIT_ASM ("lwzu " TMP_FIRST ", 8(30) \n"
- "lwz " TMP_SECOND ", 4(30) \n"
- "subfic 3, 4, 32\n" /* r3 = 32 - TOP */
- "addi 7, 4, -32\n" /* r7 = TOP - 32 */
- "srw 6, 6, 4\n" /* Shift low part right */
- "slw 3, 5, 3\n" /* Shift high to low if shift < 32 */
- "srw 7, 5, 7\n" /* Shift high to low if shift >= 32 */
- "or 6, 6, 3\n"
- "srw 3, 5, 4\n" /* Shift high part right */
- "or 4, 6, 7\n"); /* Assemble low part */
+ "lwz " TMP_SECOND ", 4(30) \n"
+ "subfic 3, 4, 32\n" /* r3 = 32 - TOP */
+ "addi 7, 4, -32\n" /* r7 = TOP - 32 */
+ "srw 6, 6, 4\n" /* Shift low part right */
+ "slw 3, 5, 3\n" /* Shift high to low if shift < 32 */
+ "srw 7, 5, 7\n" /* Shift high to low if shift >= 32 */
+ "or 6, 6, 3\n"
+ "srw 3, 5, 4\n" /* Shift high part right */
+ "or 4, 6, 7\n"); /* Assemble low part */
}
/* Emit code for signed-extension specified by ARG. */
@@ -2035,11 +1996,11 @@ ppc_emit_ext (int arg)
{
case 8:
EMIT_ASM ("extsb 4, 4\n"
- "srawi 3, 4, 31");
+ "srawi 3, 4, 31");
break;
case 16:
EMIT_ASM ("extsh 4, 4\n"
- "srawi 3, 4, 31");
+ "srawi 3, 4, 31");
break;
case 32:
EMIT_ASM ("srawi 3, 4, 31");
@@ -2058,11 +2019,11 @@ ppc_emit_zero_ext (int arg)
{
case 8:
EMIT_ASM ("clrlwi 4,4,24\n"
- "li 3, 0\n");
+ "li 3, 0\n");
break;
case 16:
EMIT_ASM ("clrlwi 4,4,16\n"
- "li 3, 0\n");
+ "li 3, 0\n");
break;
case 32:
EMIT_ASM ("li 3, 0");
@@ -2079,9 +2040,9 @@ static void
ppc_emit_log_not (void)
{
EMIT_ASM ("or 4, 3, 4 \n"
- "cntlzw 4, 4 \n"
- "srwi 4, 4, 5 \n"
- "li 3, 0 \n");
+ "cntlzw 4, 4 \n"
+ "srwi 4, 4, 5 \n"
+ "li 3, 0 \n");
}
/* TOP = stack[--sp] & TOP */
@@ -2090,9 +2051,9 @@ static void
ppc_emit_bit_and (void)
{
EMIT_ASM ("lwzu " TMP_FIRST ", 8(30) \n"
- "lwz " TMP_SECOND ", 4(30) \n"
- "and 4, 6, 4 \n"
- "and 3, 5, 3 \n");
+ "lwz " TMP_SECOND ", 4(30) \n"
+ "and 4, 6, 4 \n"
+ "and 3, 5, 3 \n");
}
/* TOP = stack[--sp] | TOP */
@@ -2101,9 +2062,9 @@ static void
ppc_emit_bit_or (void)
{
EMIT_ASM ("lwzu " TMP_FIRST ", 8(30) \n"
- "lwz " TMP_SECOND ", 4(30) \n"
- "or 4, 6, 4 \n"
- "or 3, 5, 3 \n");
+ "lwz " TMP_SECOND ", 4(30) \n"
+ "or 4, 6, 4 \n"
+ "or 3, 5, 3 \n");
}
/* TOP = stack[--sp] ^ TOP */
@@ -2112,9 +2073,9 @@ static void
ppc_emit_bit_xor (void)
{
EMIT_ASM ("lwzu " TMP_FIRST ", 8(30) \n"
- "lwz " TMP_SECOND ", 4(30) \n"
- "xor 4, 6, 4 \n"
- "xor 3, 5, 3 \n");
+ "lwz " TMP_SECOND ", 4(30) \n"
+ "xor 4, 6, 4 \n"
+ "xor 3, 5, 3 \n");
}
/* TOP = ~TOP
@@ -2124,7 +2085,7 @@ static void
ppc_emit_bit_not (void)
{
EMIT_ASM ("nor 3, 3, 3 \n"
- "nor 4, 4, 4 \n");
+ "nor 4, 4, 4 \n");
}
/* TOP = stack[--sp] == TOP */
@@ -2133,13 +2094,13 @@ static void
ppc_emit_equal (void)
{
EMIT_ASM ("lwzu " TMP_FIRST ", 8(30) \n"
- "lwz " TMP_SECOND ", 4(30) \n"
- "xor 4, 6, 4 \n"
- "xor 3, 5, 3 \n"
- "or 4, 3, 4 \n"
- "cntlzw 4, 4 \n"
- "srwi 4, 4, 5 \n"
- "li 3, 0 \n");
+ "lwz " TMP_SECOND ", 4(30) \n"
+ "xor 4, 6, 4 \n"
+ "xor 3, 5, 3 \n"
+ "or 4, 3, 4 \n"
+ "cntlzw 4, 4 \n"
+ "srwi 4, 4, 5 \n"
+ "li 3, 0 \n");
}
/* TOP = stack[--sp] < TOP
@@ -2149,16 +2110,16 @@ static void
ppc_emit_less_signed (void)
{
EMIT_ASM ("lwzu " TMP_FIRST ", 8(30) \n"
- "lwz " TMP_SECOND ", 4(30) \n"
- "cmplw 6, 6, 4 \n"
- "cmpw 7, 5, 3 \n"
- /* CR6 bit 0 = low less and high equal */
- "crand 6*4+0, 6*4+0, 7*4+2\n"
- /* CR7 bit 0 = (low less and high equal) or high less */
- "cror 7*4+0, 7*4+0, 6*4+0\n"
- "mfcr 4 \n"
- "rlwinm 4, 4, 29, 31, 31 \n"
- "li 3, 0 \n");
+ "lwz " TMP_SECOND ", 4(30) \n"
+ "cmplw 6, 6, 4 \n"
+ "cmpw 7, 5, 3 \n"
+ /* CR6 bit 0 = low less and high equal */
+ "crand 6*4+0, 6*4+0, 7*4+2\n"
+ /* CR7 bit 0 = (low less and high equal) or high less */
+ "cror 7*4+0, 7*4+0, 6*4+0\n"
+ "mfcr 4 \n"
+ "rlwinm 4, 4, 29, 31, 31 \n"
+ "li 3, 0 \n");
}
/* TOP = stack[--sp] < TOP
@@ -2168,16 +2129,16 @@ static void
ppc_emit_less_unsigned (void)
{
EMIT_ASM ("lwzu " TMP_FIRST ", 8(30) \n"
- "lwz " TMP_SECOND ", 4(30) \n"
- "cmplw 6, 6, 4 \n"
- "cmplw 7, 5, 3 \n"
- /* CR6 bit 0 = low less and high equal */
- "crand 6*4+0, 6*4+0, 7*4+2\n"
- /* CR7 bit 0 = (low less and high equal) or high less */
- "cror 7*4+0, 7*4+0, 6*4+0\n"
- "mfcr 4 \n"
- "rlwinm 4, 4, 29, 31, 31 \n"
- "li 3, 0 \n");
+ "lwz " TMP_SECOND ", 4(30) \n"
+ "cmplw 6, 6, 4 \n"
+ "cmplw 7, 5, 3 \n"
+ /* CR6 bit 0 = low less and high equal */
+ "crand 6*4+0, 6*4+0, 7*4+2\n"
+ /* CR7 bit 0 = (low less and high equal) or high less */
+ "cror 7*4+0, 7*4+0, 6*4+0\n"
+ "mfcr 4 \n"
+ "rlwinm 4, 4, 29, 31, 31 \n"
+ "li 3, 0 \n");
}
/* Access the memory address in TOP in size of SIZE.
@@ -2190,23 +2151,23 @@ ppc_emit_ref (int size)
{
case 1:
EMIT_ASM ("lbz 4, 0(4)\n"
- "li 3, 0");
+ "li 3, 0");
break;
case 2:
EMIT_ASM ("lhz 4, 0(4)\n"
- "li 3, 0");
+ "li 3, 0");
break;
case 4:
EMIT_ASM ("lwz 4, 0(4)\n"
- "li 3, 0");
+ "li 3, 0");
break;
case 8:
if (__BYTE_ORDER == __LITTLE_ENDIAN)
- EMIT_ASM ("lwz 3, 4(4)\n"
- "lwz 4, 0(4)");
+ EMIT_ASM ("lwz 3, 4(4)\n"
+ "lwz 4, 0(4)");
else
- EMIT_ASM ("lwz 3, 0(4)\n"
- "lwz 4, 4(4)");
+ EMIT_ASM ("lwz 3, 0(4)\n"
+ "lwz 4, 4(4)");
break;
}
}
@@ -2237,7 +2198,7 @@ ppc_emit_reg (int reg)
/* fctx->regs is passed in r3 and then saved in -16(31). */
p += GEN_LWZ (p, 3, 31, -16);
- p += GEN_LI (p, 4, reg); /* li r4, reg */
+ p += GEN_LI (p, 4, reg); /* li r4, reg */
p += gen_call (p, get_raw_reg_func_addr (), 0, 0);
emit_insns (buf, p - buf);
@@ -2246,8 +2207,8 @@ ppc_emit_reg (int reg)
if (__BYTE_ORDER == __LITTLE_ENDIAN)
{
EMIT_ASM ("mr 5, 4\n"
- "mr 4, 3\n"
- "mr 3, 5\n");
+ "mr 4, 3\n"
+ "mr 3, 5\n");
}
}
@@ -2257,7 +2218,7 @@ static void
ppc_emit_pop (void)
{
EMIT_ASM ("lwzu " TOP_FIRST ", 8(30) \n"
- "lwz " TOP_SECOND ", 4(30) \n");
+ "lwz " TOP_SECOND ", 4(30) \n");
}
/* stack[sp++] = TOP
@@ -2272,12 +2233,12 @@ ppc_emit_stack_flush (void)
Otherwise, expand 64-byte more. */
EMIT_ASM (" stw " TOP_FIRST ", 0(30) \n"
- " stw " TOP_SECOND ", 4(30)\n"
- " addi 5, 30, -(8 + 8) \n"
- " cmpw 7, 5, 1 \n"
- " bgt 7, 1f \n"
- " stwu 31, -64(1) \n"
- "1:addi 30, 30, -8 \n");
+ " stw " TOP_SECOND ", 4(30)\n"
+ " addi 5, 30, -(8 + 8) \n"
+ " cmpw 7, 5, 1 \n"
+ " bgt 7, 1f \n"
+ " stwu 31, -64(1) \n"
+ "1:addi 30, 30, -8 \n");
}
/* Swap TOP and stack[sp-1] */
@@ -2286,11 +2247,11 @@ static void
ppc_emit_swap (void)
{
EMIT_ASM ("lwz " TMP_FIRST ", 8(30) \n"
- "lwz " TMP_SECOND ", 12(30) \n"
- "stw " TOP_FIRST ", 8(30) \n"
- "stw " TOP_SECOND ", 12(30) \n"
- "mr 3, 5 \n"
- "mr 4, 6 \n");
+ "lwz " TMP_SECOND ", 12(30) \n"
+ "stw " TOP_FIRST ", 8(30) \n"
+ "stw " TOP_SECOND ", 12(30) \n"
+ "mr 3, 5 \n"
+ "mr 4, 6 \n");
}
/* Discard N elements in the stack. Also used for ppc64. */
@@ -2348,8 +2309,8 @@ ppc_emit_int_call_1 (CORE_ADDR fn, int arg1)
if (__BYTE_ORDER == __LITTLE_ENDIAN)
{
EMIT_ASM ("mr 5, 4\n"
- "mr 4, 3\n"
- "mr 3, 5\n");
+ "mr 4, 3\n"
+ "mr 3, 5\n");
}
}
@@ -2371,13 +2332,13 @@ ppc_emit_void_call_2 (CORE_ADDR fn, int arg1)
/* Setup argument. arg1 is a 16-bit value. */
if (__BYTE_ORDER == __LITTLE_ENDIAN)
{
- p += GEN_MR (p, 5, 4);
- p += GEN_MR (p, 6, 3);
+ p += GEN_MR (p, 5, 4);
+ p += GEN_MR (p, 6, 3);
}
else
{
- p += GEN_MR (p, 5, 3);
- p += GEN_MR (p, 6, 4);
+ p += GEN_MR (p, 5, 3);
+ p += GEN_MR (p, 6, 4);
}
p += gen_limm (p, 3, (uint32_t) arg1, 0);
p += gen_call (p, fn, 0, 0);
@@ -2405,9 +2366,9 @@ static void
ppc_emit_if_goto (int *offset_p, int *size_p)
{
EMIT_ASM ("or. 3, 3, 4 \n"
- "lwzu " TOP_FIRST ", 8(30) \n"
- "lwz " TOP_SECOND ", 4(30) \n"
- "1:bne 0, 1b \n");
+ "lwzu " TOP_FIRST ", 8(30) \n"
+ "lwz " TOP_SECOND ", 4(30) \n"
+ "1:bne 0, 1b \n");
if (offset_p)
*offset_p = 12;
@@ -2434,13 +2395,13 @@ static void
ppc_emit_eq_goto (int *offset_p, int *size_p)
{
EMIT_ASM ("lwzu " TMP_FIRST ", 8(30) \n"
- "lwz " TMP_SECOND ", 4(30) \n"
- "xor 4, 6, 4 \n"
- "xor 3, 5, 3 \n"
- "or. 3, 3, 4 \n"
- "lwzu " TOP_FIRST ", 8(30) \n"
- "lwz " TOP_SECOND ", 4(30) \n"
- "1:beq 0, 1b \n");
+ "lwz " TMP_SECOND ", 4(30) \n"
+ "xor 4, 6, 4 \n"
+ "xor 3, 5, 3 \n"
+ "or. 3, 3, 4 \n"
+ "lwzu " TOP_FIRST ", 8(30) \n"
+ "lwz " TOP_SECOND ", 4(30) \n"
+ "1:beq 0, 1b \n");
if (offset_p)
*offset_p = 28;
@@ -2454,13 +2415,13 @@ static void
ppc_emit_ne_goto (int *offset_p, int *size_p)
{
EMIT_ASM ("lwzu " TMP_FIRST ", 8(30) \n"
- "lwz " TMP_SECOND ", 4(30) \n"
- "xor 4, 6, 4 \n"
- "xor 3, 5, 3 \n"
- "or. 3, 3, 4 \n"
- "lwzu " TOP_FIRST ", 8(30) \n"
- "lwz " TOP_SECOND ", 4(30) \n"
- "1:bne 0, 1b \n");
+ "lwz " TMP_SECOND ", 4(30) \n"
+ "xor 4, 6, 4 \n"
+ "xor 3, 5, 3 \n"
+ "or. 3, 3, 4 \n"
+ "lwzu " TOP_FIRST ", 8(30) \n"
+ "lwz " TOP_SECOND ", 4(30) \n"
+ "1:bne 0, 1b \n");
if (offset_p)
*offset_p = 28;
@@ -2474,16 +2435,16 @@ static void
ppc_emit_lt_goto (int *offset_p, int *size_p)
{
EMIT_ASM ("lwzu " TMP_FIRST ", 8(30) \n"
- "lwz " TMP_SECOND ", 4(30) \n"
- "cmplw 6, 6, 4 \n"
- "cmpw 7, 5, 3 \n"
- /* CR6 bit 0 = low less and high equal */
- "crand 6*4+0, 6*4+0, 7*4+2\n"
- /* CR7 bit 0 = (low less and high equal) or high less */
- "cror 7*4+0, 7*4+0, 6*4+0\n"
- "lwzu " TOP_FIRST ", 8(30) \n"
- "lwz " TOP_SECOND ", 4(30)\n"
- "1:blt 7, 1b \n");
+ "lwz " TMP_SECOND ", 4(30) \n"
+ "cmplw 6, 6, 4 \n"
+ "cmpw 7, 5, 3 \n"
+ /* CR6 bit 0 = low less and high equal */
+ "crand 6*4+0, 6*4+0, 7*4+2\n"
+ /* CR7 bit 0 = (low less and high equal) or high less */
+ "cror 7*4+0, 7*4+0, 6*4+0\n"
+ "lwzu " TOP_FIRST ", 8(30) \n"
+ "lwz " TOP_SECOND ", 4(30)\n"
+ "1:blt 7, 1b \n");
if (offset_p)
*offset_p = 32;
@@ -2497,16 +2458,16 @@ static void
ppc_emit_le_goto (int *offset_p, int *size_p)
{
EMIT_ASM ("lwzu " TMP_FIRST ", 8(30) \n"
- "lwz " TMP_SECOND ", 4(30) \n"
- "cmplw 6, 6, 4 \n"
- "cmpw 7, 5, 3 \n"
- /* CR6 bit 0 = low less/equal and high equal */
- "crandc 6*4+0, 7*4+2, 6*4+1\n"
- /* CR7 bit 0 = (low less/eq and high equal) or high less */
- "cror 7*4+0, 7*4+0, 6*4+0\n"
- "lwzu " TOP_FIRST ", 8(30) \n"
- "lwz " TOP_SECOND ", 4(30)\n"
- "1:blt 7, 1b \n");
+ "lwz " TMP_SECOND ", 4(30) \n"
+ "cmplw 6, 6, 4 \n"
+ "cmpw 7, 5, 3 \n"
+ /* CR6 bit 0 = low less/equal and high equal */
+ "crandc 6*4+0, 7*4+2, 6*4+1\n"
+ /* CR7 bit 0 = (low less/eq and high equal) or high less */
+ "cror 7*4+0, 7*4+0, 6*4+0\n"
+ "lwzu " TOP_FIRST ", 8(30) \n"
+ "lwz " TOP_SECOND ", 4(30)\n"
+ "1:blt 7, 1b \n");
if (offset_p)
*offset_p = 32;
@@ -2520,16 +2481,16 @@ static void
ppc_emit_gt_goto (int *offset_p, int *size_p)
{
EMIT_ASM ("lwzu " TMP_FIRST ", 8(30) \n"
- "lwz " TMP_SECOND ", 4(30) \n"
- "cmplw 6, 6, 4 \n"
- "cmpw 7, 5, 3 \n"
- /* CR6 bit 0 = low greater and high equal */
- "crand 6*4+0, 6*4+1, 7*4+2\n"
- /* CR7 bit 0 = (low greater and high equal) or high greater */
- "cror 7*4+0, 7*4+1, 6*4+0\n"
- "lwzu " TOP_FIRST ", 8(30) \n"
- "lwz " TOP_SECOND ", 4(30)\n"
- "1:blt 7, 1b \n");
+ "lwz " TMP_SECOND ", 4(30) \n"
+ "cmplw 6, 6, 4 \n"
+ "cmpw 7, 5, 3 \n"
+ /* CR6 bit 0 = low greater and high equal */
+ "crand 6*4+0, 6*4+1, 7*4+2\n"
+ /* CR7 bit 0 = (low greater and high equal) or high greater */
+ "cror 7*4+0, 7*4+1, 6*4+0\n"
+ "lwzu " TOP_FIRST ", 8(30) \n"
+ "lwz " TOP_SECOND ", 4(30)\n"
+ "1:blt 7, 1b \n");
if (offset_p)
*offset_p = 32;
@@ -2543,16 +2504,16 @@ static void
ppc_emit_ge_goto (int *offset_p, int *size_p)
{
EMIT_ASM ("lwzu " TMP_FIRST ", 8(30) \n"
- "lwz " TMP_SECOND ", 4(30) \n"
- "cmplw 6, 6, 4 \n"
- "cmpw 7, 5, 3 \n"
- /* CR6 bit 0 = low ge and high equal */
- "crandc 6*4+0, 7*4+2, 6*4+0\n"
- /* CR7 bit 0 = (low ge and high equal) or high greater */
- "cror 7*4+0, 7*4+1, 6*4+0\n"
- "lwzu " TOP_FIRST ", 8(30)\n"
- "lwz " TOP_SECOND ", 4(30)\n"
- "1:blt 7, 1b \n");
+ "lwz " TMP_SECOND ", 4(30) \n"
+ "cmplw 6, 6, 4 \n"
+ "cmpw 7, 5, 3 \n"
+ /* CR6 bit 0 = low ge and high equal */
+ "crandc 6*4+0, 7*4+2, 6*4+0\n"
+ /* CR7 bit 0 = (low ge and high equal) or high greater */
+ "cror 7*4+0, 7*4+1, 6*4+0\n"
+ "lwzu " TOP_FIRST ", 8(30)\n"
+ "lwz " TOP_SECOND ", 4(30)\n"
+ "1:blt 7, 1b \n");
if (offset_p)
*offset_p = 32;
@@ -2579,15 +2540,13 @@ ppc_write_goto_address (CORE_ADDR from, CORE_ADDR to, int size)
switch (size)
{
case 14:
- if (opcd != 16
- || (rel >= (1 << 15) || rel < -(1 << 15)))
- emit_error = 1;
+ if (opcd != 16 || (rel >= (1 << 15) || rel < -(1 << 15)))
+ emit_error = 1;
insn = (insn & ~0xfffc) | (rel & 0xfffc);
break;
case 24:
- if (opcd != 18
- || (rel >= (1 << 25) || rel < -(1 << 25)))
- emit_error = 1;
+ if (opcd != 18 || (rel >= (1 << 25) || rel < -(1 << 25)))
+ emit_error = 1;
insn = (insn & ~0x3fffffc) | (rel & 0x3fffffc);
break;
default:
@@ -2600,46 +2559,20 @@ ppc_write_goto_address (CORE_ADDR from, CORE_ADDR to, int size)
/* Table of emit ops for 32-bit. */
-static struct emit_ops ppc_emit_ops_impl =
-{
- ppc_emit_prologue,
- ppc_emit_epilogue,
- ppc_emit_add,
- ppc_emit_sub,
- ppc_emit_mul,
- ppc_emit_lsh,
- ppc_emit_rsh_signed,
- ppc_emit_rsh_unsigned,
- ppc_emit_ext,
- ppc_emit_log_not,
- ppc_emit_bit_and,
- ppc_emit_bit_or,
- ppc_emit_bit_xor,
- ppc_emit_bit_not,
- ppc_emit_equal,
- ppc_emit_less_signed,
- ppc_emit_less_unsigned,
- ppc_emit_ref,
- ppc_emit_if_goto,
- ppc_emit_goto,
- ppc_write_goto_address,
- ppc_emit_const,
- ppc_emit_call,
- ppc_emit_reg,
- ppc_emit_pop,
- ppc_emit_stack_flush,
- ppc_emit_zero_ext,
- ppc_emit_swap,
- ppc_emit_stack_adjust,
- ppc_emit_int_call_1,
- ppc_emit_void_call_2,
- ppc_emit_eq_goto,
- ppc_emit_ne_goto,
- ppc_emit_lt_goto,
- ppc_emit_le_goto,
- ppc_emit_gt_goto,
- ppc_emit_ge_goto
-};
+static struct emit_ops ppc_emit_ops_impl
+ = { ppc_emit_prologue, ppc_emit_epilogue, ppc_emit_add,
+ ppc_emit_sub, ppc_emit_mul, ppc_emit_lsh,
+ ppc_emit_rsh_signed, ppc_emit_rsh_unsigned, ppc_emit_ext,
+ ppc_emit_log_not, ppc_emit_bit_and, ppc_emit_bit_or,
+ ppc_emit_bit_xor, ppc_emit_bit_not, ppc_emit_equal,
+ ppc_emit_less_signed, ppc_emit_less_unsigned, ppc_emit_ref,
+ ppc_emit_if_goto, ppc_emit_goto, ppc_write_goto_address,
+ ppc_emit_const, ppc_emit_call, ppc_emit_reg,
+ ppc_emit_pop, ppc_emit_stack_flush, ppc_emit_zero_ext,
+ ppc_emit_swap, ppc_emit_stack_adjust, ppc_emit_int_call_1,
+ ppc_emit_void_call_2, ppc_emit_eq_goto, ppc_emit_ne_goto,
+ ppc_emit_lt_goto, ppc_emit_le_goto, ppc_emit_gt_goto,
+ ppc_emit_ge_goto };
#ifdef __powerpc64__
@@ -2698,23 +2631,23 @@ ppc64v1_emit_prologue (void)
/* Mind the strict aliasing rules. */
memcpy (buf, &opd, sizeof buf);
- emit_insns(buf, 2);
+ emit_insns (buf, 2);
EMIT_ASM (/* Save return address. */
- "mflr 0 \n"
- "std 0, 16(1) \n"
- /* Save r30 and incoming arguments. */
- "std 31, -8(1) \n"
- "std 30, -16(1) \n"
- "std 4, -24(1) \n"
- "std 3, -32(1) \n"
- /* Point r31 to current r1 for access arguments. */
- "mr 31, 1 \n"
- /* Adjust SP. 208 is the initial frame size. */
- "stdu 1, -208(1) \n"
- /* Set r30 to pointing stack-top. */
- "addi 30, 1, 168 \n"
- /* Initial r3/TOP to 0. */
- "li 3, 0 \n");
+ "mflr 0 \n"
+ "std 0, 16(1) \n"
+ /* Save r30 and incoming arguments. */
+ "std 31, -8(1) \n"
+ "std 30, -16(1) \n"
+ "std 4, -24(1) \n"
+ "std 3, -32(1) \n"
+ /* Point r31 to current r1 for access arguments. */
+ "mr 31, 1 \n"
+ /* Adjust SP. 208 is the initial frame size. */
+ "stdu 1, -208(1) \n"
+ /* Set r30 to pointing stack-top. */
+ "addi 30, 1, 168 \n"
+ /* Initial r3/TOP to 0. */
+ "li 3, 0 \n");
}
/* Emit prologue in inferior memory. See above comments. */
@@ -2723,21 +2656,21 @@ static void
ppc64v2_emit_prologue (void)
{
EMIT_ASM (/* Save return address. */
- "mflr 0 \n"
- "std 0, 16(1) \n"
- /* Save r30 and incoming arguments. */
- "std 31, -8(1) \n"
- "std 30, -16(1) \n"
- "std 4, -24(1) \n"
- "std 3, -32(1) \n"
- /* Point r31 to current r1 for access arguments. */
- "mr 31, 1 \n"
- /* Adjust SP. 208 is the initial frame size. */
- "stdu 1, -208(1) \n"
- /* Set r30 to pointing stack-top. */
- "addi 30, 1, 168 \n"
- /* Initial r3/TOP to 0. */
- "li 3, 0 \n");
+ "mflr 0 \n"
+ "std 0, 16(1) \n"
+ /* Save r30 and incoming arguments. */
+ "std 31, -8(1) \n"
+ "std 30, -16(1) \n"
+ "std 4, -24(1) \n"
+ "std 3, -32(1) \n"
+ /* Point r31 to current r1 for access arguments. */
+ "mr 31, 1 \n"
+ /* Adjust SP. 208 is the initial frame size. */
+ "stdu 1, -208(1) \n"
+ /* Set r30 to pointing stack-top. */
+ "addi 30, 1, 168 \n"
+ /* Initial r3/TOP to 0. */
+ "li 3, 0 \n");
}
/* Emit epilogue in inferior memory. See above comments. */
@@ -2746,19 +2679,19 @@ static void
ppc64_emit_epilogue (void)
{
EMIT_ASM (/* Restore SP. */
- "ld 1, 0(1) \n"
- /* *result = TOP */
- "ld 4, -24(1) \n"
- "std 3, 0(4) \n"
- /* Restore registers. */
- "ld 31, -8(1) \n"
- "ld 30, -16(1) \n"
- /* Restore LR. */
- "ld 0, 16(1) \n"
- /* Return 0 for no-error. */
- "li 3, 0 \n"
- "mtlr 0 \n"
- "blr \n");
+ "ld 1, 0(1) \n"
+ /* *result = TOP */
+ "ld 4, -24(1) \n"
+ "std 3, 0(4) \n"
+ /* Restore registers. */
+ "ld 31, -8(1) \n"
+ "ld 30, -16(1) \n"
+ /* Restore LR. */
+ "ld 0, 16(1) \n"
+ /* Return 0 for no-error. */
+ "li 3, 0 \n"
+ "mtlr 0 \n"
+ "blr \n");
}
/* TOP = stack[--sp] + TOP */
@@ -2767,7 +2700,7 @@ static void
ppc64_emit_add (void)
{
EMIT_ASM ("ldu 4, 8(30) \n"
- "add 3, 4, 3 \n");
+ "add 3, 4, 3 \n");
}
/* TOP = stack[--sp] - TOP */
@@ -2776,7 +2709,7 @@ static void
ppc64_emit_sub (void)
{
EMIT_ASM ("ldu 4, 8(30) \n"
- "sub 3, 4, 3 \n");
+ "sub 3, 4, 3 \n");
}
/* TOP = stack[--sp] * TOP */
@@ -2785,7 +2718,7 @@ static void
ppc64_emit_mul (void)
{
EMIT_ASM ("ldu 4, 8(30) \n"
- "mulld 3, 4, 3 \n");
+ "mulld 3, 4, 3 \n");
}
/* TOP = stack[--sp] << TOP */
@@ -2794,7 +2727,7 @@ static void
ppc64_emit_lsh (void)
{
EMIT_ASM ("ldu 4, 8(30) \n"
- "sld 3, 4, 3 \n");
+ "sld 3, 4, 3 \n");
}
/* Top = stack[--sp] >> TOP
@@ -2804,7 +2737,7 @@ static void
ppc64_emit_rsh_signed (void)
{
EMIT_ASM ("ldu 4, 8(30) \n"
- "srad 3, 4, 3 \n");
+ "srad 3, 4, 3 \n");
}
/* Top = stack[--sp] >> TOP
@@ -2814,7 +2747,7 @@ static void
ppc64_emit_rsh_unsigned (void)
{
EMIT_ASM ("ldu 4, 8(30) \n"
- "srd 3, 4, 3 \n");
+ "srd 3, 4, 3 \n");
}
/* Emit code for signed-extension specified by ARG. */
@@ -2866,7 +2799,7 @@ static void
ppc64_emit_log_not (void)
{
EMIT_ASM ("cntlzd 3, 3 \n"
- "srdi 3, 3, 6 \n");
+ "srdi 3, 3, 6 \n");
}
/* TOP = stack[--sp] & TOP */
@@ -2875,7 +2808,7 @@ static void
ppc64_emit_bit_and (void)
{
EMIT_ASM ("ldu 4, 8(30) \n"
- "and 3, 4, 3 \n");
+ "and 3, 4, 3 \n");
}
/* TOP = stack[--sp] | TOP */
@@ -2884,7 +2817,7 @@ static void
ppc64_emit_bit_or (void)
{
EMIT_ASM ("ldu 4, 8(30) \n"
- "or 3, 4, 3 \n");
+ "or 3, 4, 3 \n");
}
/* TOP = stack[--sp] ^ TOP */
@@ -2893,7 +2826,7 @@ static void
ppc64_emit_bit_xor (void)
{
EMIT_ASM ("ldu 4, 8(30) \n"
- "xor 3, 4, 3 \n");
+ "xor 3, 4, 3 \n");
}
/* TOP = ~TOP
@@ -2911,9 +2844,9 @@ static void
ppc64_emit_equal (void)
{
EMIT_ASM ("ldu 4, 8(30) \n"
- "xor 3, 3, 4 \n"
- "cntlzd 3, 3 \n"
- "srdi 3, 3, 6 \n");
+ "xor 3, 3, 4 \n"
+ "cntlzd 3, 3 \n"
+ "srdi 3, 3, 6 \n");
}
/* TOP = stack[--sp] < TOP
@@ -2923,9 +2856,9 @@ static void
ppc64_emit_less_signed (void)
{
EMIT_ASM ("ldu 4, 8(30) \n"
- "cmpd 7, 4, 3 \n"
- "mfcr 3 \n"
- "rlwinm 3, 3, 29, 31, 31 \n");
+ "cmpd 7, 4, 3 \n"
+ "mfcr 3 \n"
+ "rlwinm 3, 3, 29, 31, 31 \n");
}
/* TOP = stack[--sp] < TOP
@@ -2935,9 +2868,9 @@ static void
ppc64_emit_less_unsigned (void)
{
EMIT_ASM ("ldu 4, 8(30) \n"
- "cmpld 7, 4, 3 \n"
- "mfcr 3 \n"
- "rlwinm 3, 3, 29, 31, 31 \n");
+ "cmpld 7, 4, 3 \n"
+ "mfcr 3 \n"
+ "rlwinm 3, 3, 29, 31, 31 \n");
}
/* Access the memory address in TOP in size of SIZE.
@@ -2989,9 +2922,9 @@ ppc64v1_emit_reg (int reg)
/* fctx->regs is passed in r3 and then saved in 176(1). */
p += GEN_LD (p, 3, 31, -32);
p += GEN_LI (p, 4, reg);
- p += GEN_STD (p, 2, 1, 40); /* Save TOC. */
+ p += GEN_STD (p, 2, 1, 40); /* Save TOC. */
p += gen_call (p, get_raw_reg_func_addr (), 1, 1);
- p += GEN_LD (p, 2, 1, 40); /* Restore TOC. */
+ p += GEN_LD (p, 2, 1, 40); /* Restore TOC. */
emit_insns (buf, p - buf);
gdb_assert ((p - buf) <= (sizeof (buf) / sizeof (*buf)));
@@ -3008,9 +2941,9 @@ ppc64v2_emit_reg (int reg)
/* fctx->regs is passed in r3 and then saved in 176(1). */
p += GEN_LD (p, 3, 31, -32);
p += GEN_LI (p, 4, reg);
- p += GEN_STD (p, 2, 1, 24); /* Save TOC. */
+ p += GEN_STD (p, 2, 1, 24); /* Save TOC. */
p += gen_call (p, get_raw_reg_func_addr (), 1, 0);
- p += GEN_LD (p, 2, 1, 24); /* Restore TOC. */
+ p += GEN_LD (p, 2, 1, 24); /* Restore TOC. */
emit_insns (buf, p - buf);
gdb_assert ((p - buf) <= (sizeof (buf) / sizeof (*buf)));
@@ -3036,11 +2969,11 @@ ppc64_emit_stack_flush (void)
Otherwise, expand 64-byte more. */
EMIT_ASM (" std 3, 0(30) \n"
- " addi 4, 30, -(112 + 8) \n"
- " cmpd 7, 4, 1 \n"
- " bgt 7, 1f \n"
- " stdu 31, -64(1) \n"
- "1:addi 30, 30, -8 \n");
+ " addi 4, 30, -(112 + 8) \n"
+ " cmpd 7, 4, 1 \n"
+ " bgt 7, 1f \n"
+ " stdu 31, -64(1) \n"
+ "1:addi 30, 30, -8 \n");
}
/* Swap TOP and stack[sp-1] */
@@ -3049,8 +2982,8 @@ static void
ppc64_emit_swap (void)
{
EMIT_ASM ("ld 4, 8(30) \n"
- "std 3, 8(30) \n"
- "mr 3, 4 \n");
+ "std 3, 8(30) \n"
+ "mr 3, 4 \n");
}
/* Call function FN - ELFv1. */
@@ -3061,9 +2994,9 @@ ppc64v1_emit_call (CORE_ADDR fn)
uint32_t buf[13];
uint32_t *p = buf;
- p += GEN_STD (p, 2, 1, 40); /* Save TOC. */
+ p += GEN_STD (p, 2, 1, 40); /* Save TOC. */
p += gen_call (p, fn, 1, 1);
- p += GEN_LD (p, 2, 1, 40); /* Restore TOC. */
+ p += GEN_LD (p, 2, 1, 40); /* Restore TOC. */
emit_insns (buf, p - buf);
gdb_assert ((p - buf) <= (sizeof (buf) / sizeof (*buf)));
@@ -3077,9 +3010,9 @@ ppc64v2_emit_call (CORE_ADDR fn)
uint32_t buf[10];
uint32_t *p = buf;
- p += GEN_STD (p, 2, 1, 24); /* Save TOC. */
+ p += GEN_STD (p, 2, 1, 24); /* Save TOC. */
p += gen_call (p, fn, 1, 0);
- p += GEN_LD (p, 2, 1, 24); /* Restore TOC. */
+ p += GEN_LD (p, 2, 1, 24); /* Restore TOC. */
emit_insns (buf, p - buf);
gdb_assert ((p - buf) <= (sizeof (buf) / sizeof (*buf)));
@@ -3097,9 +3030,9 @@ ppc64v1_emit_int_call_1 (CORE_ADDR fn, int arg1)
/* Setup argument. arg1 is a 16-bit value. */
p += gen_limm (p, 3, arg1, 1);
- p += GEN_STD (p, 2, 1, 40); /* Save TOC. */
+ p += GEN_STD (p, 2, 1, 40); /* Save TOC. */
p += gen_call (p, fn, 1, 1);
- p += GEN_LD (p, 2, 1, 40); /* Restore TOC. */
+ p += GEN_LD (p, 2, 1, 40); /* Restore TOC. */
emit_insns (buf, p - buf);
gdb_assert ((p - buf) <= (sizeof (buf) / sizeof (*buf)));
@@ -3115,9 +3048,9 @@ ppc64v2_emit_int_call_1 (CORE_ADDR fn, int arg1)
/* Setup argument. arg1 is a 16-bit value. */
p += gen_limm (p, 3, arg1, 1);
- p += GEN_STD (p, 2, 1, 24); /* Save TOC. */
+ p += GEN_STD (p, 2, 1, 24); /* Save TOC. */
p += gen_call (p, fn, 1, 0);
- p += GEN_LD (p, 2, 1, 24); /* Restore TOC. */
+ p += GEN_LD (p, 2, 1, 24); /* Restore TOC. */
emit_insns (buf, p - buf);
gdb_assert ((p - buf) <= (sizeof (buf) / sizeof (*buf)));
@@ -3138,11 +3071,11 @@ ppc64v1_emit_void_call_2 (CORE_ADDR fn, int arg1)
p += GEN_STD (p, 3, 30, 0);
/* Setup argument. arg1 is a 16-bit value. */
- p += GEN_MR (p, 4, 3); /* mr r4, r3 */
+ p += GEN_MR (p, 4, 3); /* mr r4, r3 */
p += gen_limm (p, 3, arg1, 1);
- p += GEN_STD (p, 2, 1, 40); /* Save TOC. */
+ p += GEN_STD (p, 2, 1, 40); /* Save TOC. */
p += gen_call (p, fn, 1, 1);
- p += GEN_LD (p, 2, 1, 40); /* Restore TOC. */
+ p += GEN_LD (p, 2, 1, 40); /* Restore TOC. */
/* Restore TOP */
p += GEN_LD (p, 3, 30, 0);
@@ -3163,11 +3096,11 @@ ppc64v2_emit_void_call_2 (CORE_ADDR fn, int arg1)
p += GEN_STD (p, 3, 30, 0);
/* Setup argument. arg1 is a 16-bit value. */
- p += GEN_MR (p, 4, 3); /* mr r4, r3 */
+ p += GEN_MR (p, 4, 3); /* mr r4, r3 */
p += gen_limm (p, 3, arg1, 1);
- p += GEN_STD (p, 2, 1, 24); /* Save TOC. */
+ p += GEN_STD (p, 2, 1, 24); /* Save TOC. */
p += gen_call (p, fn, 1, 0);
- p += GEN_LD (p, 2, 1, 24); /* Restore TOC. */
+ p += GEN_LD (p, 2, 1, 24); /* Restore TOC. */
/* Restore TOP */
p += GEN_LD (p, 3, 30, 0);
@@ -3182,8 +3115,8 @@ static void
ppc64_emit_if_goto (int *offset_p, int *size_p)
{
EMIT_ASM ("cmpdi 7, 3, 0 \n"
- "ldu 3, 8(30) \n"
- "1:bne 7, 1b \n");
+ "ldu 3, 8(30) \n"
+ "1:bne 7, 1b \n");
if (offset_p)
*offset_p = 8;
@@ -3197,9 +3130,9 @@ static void
ppc64_emit_eq_goto (int *offset_p, int *size_p)
{
EMIT_ASM ("ldu 4, 8(30) \n"
- "cmpd 7, 4, 3 \n"
- "ldu 3, 8(30) \n"
- "1:beq 7, 1b \n");
+ "cmpd 7, 4, 3 \n"
+ "ldu 3, 8(30) \n"
+ "1:beq 7, 1b \n");
if (offset_p)
*offset_p = 12;
@@ -3213,9 +3146,9 @@ static void
ppc64_emit_ne_goto (int *offset_p, int *size_p)
{
EMIT_ASM ("ldu 4, 8(30) \n"
- "cmpd 7, 4, 3 \n"
- "ldu 3, 8(30) \n"
- "1:bne 7, 1b \n");
+ "cmpd 7, 4, 3 \n"
+ "ldu 3, 8(30) \n"
+ "1:bne 7, 1b \n");
if (offset_p)
*offset_p = 12;
@@ -3229,9 +3162,9 @@ static void
ppc64_emit_lt_goto (int *offset_p, int *size_p)
{
EMIT_ASM ("ldu 4, 8(30) \n"
- "cmpd 7, 4, 3 \n"
- "ldu 3, 8(30) \n"
- "1:blt 7, 1b \n");
+ "cmpd 7, 4, 3 \n"
+ "ldu 3, 8(30) \n"
+ "1:blt 7, 1b \n");
if (offset_p)
*offset_p = 12;
@@ -3245,9 +3178,9 @@ static void
ppc64_emit_le_goto (int *offset_p, int *size_p)
{
EMIT_ASM ("ldu 4, 8(30) \n"
- "cmpd 7, 4, 3 \n"
- "ldu 3, 8(30) \n"
- "1:ble 7, 1b \n");
+ "cmpd 7, 4, 3 \n"
+ "ldu 3, 8(30) \n"
+ "1:ble 7, 1b \n");
if (offset_p)
*offset_p = 12;
@@ -3261,9 +3194,9 @@ static void
ppc64_emit_gt_goto (int *offset_p, int *size_p)
{
EMIT_ASM ("ldu 4, 8(30) \n"
- "cmpd 7, 4, 3 \n"
- "ldu 3, 8(30) \n"
- "1:bgt 7, 1b \n");
+ "cmpd 7, 4, 3 \n"
+ "ldu 3, 8(30) \n"
+ "1:bgt 7, 1b \n");
if (offset_p)
*offset_p = 12;
@@ -3277,9 +3210,9 @@ static void
ppc64_emit_ge_goto (int *offset_p, int *size_p)
{
EMIT_ASM ("ldu 4, 8(30) \n"
- "cmpd 7, 4, 3 \n"
- "ldu 3, 8(30) \n"
- "1:bge 7, 1b \n");
+ "cmpd 7, 4, 3 \n"
+ "ldu 3, 8(30) \n"
+ "1:bge 7, 1b \n");
if (offset_p)
*offset_p = 12;
@@ -3289,89 +3222,49 @@ ppc64_emit_ge_goto (int *offset_p, int *size_p)
/* Table of emit ops for 64-bit ELFv1. */
-static struct emit_ops ppc64v1_emit_ops_impl =
-{
- ppc64v1_emit_prologue,
- ppc64_emit_epilogue,
- ppc64_emit_add,
- ppc64_emit_sub,
- ppc64_emit_mul,
- ppc64_emit_lsh,
- ppc64_emit_rsh_signed,
- ppc64_emit_rsh_unsigned,
- ppc64_emit_ext,
- ppc64_emit_log_not,
- ppc64_emit_bit_and,
- ppc64_emit_bit_or,
- ppc64_emit_bit_xor,
- ppc64_emit_bit_not,
- ppc64_emit_equal,
- ppc64_emit_less_signed,
- ppc64_emit_less_unsigned,
- ppc64_emit_ref,
- ppc64_emit_if_goto,
- ppc_emit_goto,
- ppc_write_goto_address,
- ppc64_emit_const,
- ppc64v1_emit_call,
- ppc64v1_emit_reg,
- ppc64_emit_pop,
- ppc64_emit_stack_flush,
- ppc64_emit_zero_ext,
- ppc64_emit_swap,
- ppc_emit_stack_adjust,
- ppc64v1_emit_int_call_1,
- ppc64v1_emit_void_call_2,
- ppc64_emit_eq_goto,
- ppc64_emit_ne_goto,
- ppc64_emit_lt_goto,
- ppc64_emit_le_goto,
- ppc64_emit_gt_goto,
- ppc64_emit_ge_goto
-};
+static struct emit_ops ppc64v1_emit_ops_impl
+ = { ppc64v1_emit_prologue, ppc64_emit_epilogue,
+ ppc64_emit_add, ppc64_emit_sub,
+ ppc64_emit_mul, ppc64_emit_lsh,
+ ppc64_emit_rsh_signed, ppc64_emit_rsh_unsigned,
+ ppc64_emit_ext, ppc64_emit_log_not,
+ ppc64_emit_bit_and, ppc64_emit_bit_or,
+ ppc64_emit_bit_xor, ppc64_emit_bit_not,
+ ppc64_emit_equal, ppc64_emit_less_signed,
+ ppc64_emit_less_unsigned, ppc64_emit_ref,
+ ppc64_emit_if_goto, ppc_emit_goto,
+ ppc_write_goto_address, ppc64_emit_const,
+ ppc64v1_emit_call, ppc64v1_emit_reg,
+ ppc64_emit_pop, ppc64_emit_stack_flush,
+ ppc64_emit_zero_ext, ppc64_emit_swap,
+ ppc_emit_stack_adjust, ppc64v1_emit_int_call_1,
+ ppc64v1_emit_void_call_2, ppc64_emit_eq_goto,
+ ppc64_emit_ne_goto, ppc64_emit_lt_goto,
+ ppc64_emit_le_goto, ppc64_emit_gt_goto,
+ ppc64_emit_ge_goto };
/* Table of emit ops for 64-bit ELFv2. */
-static struct emit_ops ppc64v2_emit_ops_impl =
-{
- ppc64v2_emit_prologue,
- ppc64_emit_epilogue,
- ppc64_emit_add,
- ppc64_emit_sub,
- ppc64_emit_mul,
- ppc64_emit_lsh,
- ppc64_emit_rsh_signed,
- ppc64_emit_rsh_unsigned,
- ppc64_emit_ext,
- ppc64_emit_log_not,
- ppc64_emit_bit_and,
- ppc64_emit_bit_or,
- ppc64_emit_bit_xor,
- ppc64_emit_bit_not,
- ppc64_emit_equal,
- ppc64_emit_less_signed,
- ppc64_emit_less_unsigned,
- ppc64_emit_ref,
- ppc64_emit_if_goto,
- ppc_emit_goto,
- ppc_write_goto_address,
- ppc64_emit_const,
- ppc64v2_emit_call,
- ppc64v2_emit_reg,
- ppc64_emit_pop,
- ppc64_emit_stack_flush,
- ppc64_emit_zero_ext,
- ppc64_emit_swap,
- ppc_emit_stack_adjust,
- ppc64v2_emit_int_call_1,
- ppc64v2_emit_void_call_2,
- ppc64_emit_eq_goto,
- ppc64_emit_ne_goto,
- ppc64_emit_lt_goto,
- ppc64_emit_le_goto,
- ppc64_emit_gt_goto,
- ppc64_emit_ge_goto
-};
+static struct emit_ops ppc64v2_emit_ops_impl
+ = { ppc64v2_emit_prologue, ppc64_emit_epilogue,
+ ppc64_emit_add, ppc64_emit_sub,
+ ppc64_emit_mul, ppc64_emit_lsh,
+ ppc64_emit_rsh_signed, ppc64_emit_rsh_unsigned,
+ ppc64_emit_ext, ppc64_emit_log_not,
+ ppc64_emit_bit_and, ppc64_emit_bit_or,
+ ppc64_emit_bit_xor, ppc64_emit_bit_not,
+ ppc64_emit_equal, ppc64_emit_less_signed,
+ ppc64_emit_less_unsigned, ppc64_emit_ref,
+ ppc64_emit_if_goto, ppc_emit_goto,
+ ppc_write_goto_address, ppc64_emit_const,
+ ppc64v2_emit_call, ppc64v2_emit_reg,
+ ppc64_emit_pop, ppc64_emit_stack_flush,
+ ppc64_emit_zero_ext, ppc64_emit_swap,
+ ppc_emit_stack_adjust, ppc64v2_emit_int_call_1,
+ ppc64v2_emit_void_call_2, ppc64_emit_eq_goto,
+ ppc64_emit_ne_goto, ppc64_emit_lt_goto,
+ ppc64_emit_le_goto, ppc64_emit_gt_goto,
+ ppc64_emit_ge_goto };
#endif
@@ -3386,9 +3279,9 @@ ppc_target::emit_ops ()
if (register_size (regcache->tdesc, 0) == 8)
{
if (is_elfv2_inferior ())
- return &ppc64v2_emit_ops_impl;
+ return &ppc64v2_emit_ops_impl;
else
- return &ppc64v1_emit_ops_impl;
+ return &ppc64v1_emit_ops_impl;
}
#endif
return &ppc_emit_ops_impl;
diff --git a/gdbserver/linux-ppc-tdesc-init.h b/gdbserver/linux-ppc-tdesc-init.h
index b9cc1b1..e824b07 100644
--- a/gdbserver/linux-ppc-tdesc-init.h
+++ b/gdbserver/linux-ppc-tdesc-init.h
@@ -24,10 +24,11 @@
it's sufficient to pass only the register set here. This, together with
the ABI known at IPA compile time, maps to a tdesc. */
-enum ppc_linux_tdesc {
+enum ppc_linux_tdesc
+{
PPC_TDESC_BASE,
PPC_TDESC_ALTIVEC,
- PPC_TDESC_CELL, /* No longer used, but kept to avoid ABI changes. */
+ PPC_TDESC_CELL, /* No longer used, but kept to avoid ABI changes. */
PPC_TDESC_VSX,
PPC_TDESC_ISA205,
PPC_TDESC_ISA205_ALTIVEC,
diff --git a/gdbserver/linux-riscv-low.cc b/gdbserver/linux-riscv-low.cc
index 129bc3b..aa4f42c 100644
--- a/gdbserver/linux-riscv-low.cc
+++ b/gdbserver/linux-riscv-low.cc
@@ -27,7 +27,7 @@
/* Work around glibc header breakage causing ELF_NFPREG not to be usable. */
#ifndef NFPREG
-# define NFPREG 33
+#define NFPREG 33
#endif
/* Linux target op definitions for the RISC-V architecture. */
@@ -35,7 +35,6 @@
class riscv_target : public linux_process_target
{
public:
-
const regs_info *get_regs_info () override;
int breakpoint_kind_from_pc (CORE_ADDR *pcptr) override;
@@ -43,7 +42,6 @@ public:
const gdb_byte *sw_breakpoint_from_kind (int kind, int *size) override;
protected:
-
void low_arch_setup () override;
bool low_cannot_fetch_register (int regno) override;
@@ -69,14 +67,14 @@ bool
riscv_target::low_cannot_fetch_register (int regno)
{
gdb_assert_not_reached ("linux target op low_cannot_fetch_register "
- "is not implemented by the target");
+ "is not implemented by the target");
}
bool
riscv_target::low_cannot_store_register (int regno)
{
gdb_assert_not_reached ("linux target op low_cannot_store_register "
- "is not implemented by the target");
+ "is not implemented by the target");
}
/* Implementation of linux target ops method "low_arch_setup". */
@@ -162,37 +160,34 @@ riscv_store_fpregset (struct regcache *regcache, const void *buf)
so define multiple regsets for them marking them all as OPTIONAL_REGS
rather than FP_REGS, so that "regsets_fetch_inferior_registers" picks
the right one according to size. */
-static struct regset_info riscv_regsets[] = {
- { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_PRSTATUS,
- sizeof (elf_gregset_t), GENERAL_REGS,
- riscv_fill_gregset, riscv_store_gregset },
- { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_FPREGSET,
- sizeof (struct __riscv_mc_q_ext_state), OPTIONAL_REGS,
- riscv_fill_fpregset, riscv_store_fpregset },
- { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_FPREGSET,
- sizeof (struct __riscv_mc_d_ext_state), OPTIONAL_REGS,
- riscv_fill_fpregset, riscv_store_fpregset },
- { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_FPREGSET,
- sizeof (struct __riscv_mc_f_ext_state), OPTIONAL_REGS,
- riscv_fill_fpregset, riscv_store_fpregset },
- NULL_REGSET
-};
+static struct regset_info riscv_regsets[]
+ = { { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_PRSTATUS,
+ sizeof (elf_gregset_t), GENERAL_REGS, riscv_fill_gregset,
+ riscv_store_gregset },
+ { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_FPREGSET,
+ sizeof (struct __riscv_mc_q_ext_state), OPTIONAL_REGS,
+ riscv_fill_fpregset, riscv_store_fpregset },
+ { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_FPREGSET,
+ sizeof (struct __riscv_mc_d_ext_state), OPTIONAL_REGS,
+ riscv_fill_fpregset, riscv_store_fpregset },
+ { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_FPREGSET,
+ sizeof (struct __riscv_mc_f_ext_state), OPTIONAL_REGS,
+ riscv_fill_fpregset, riscv_store_fpregset },
+ NULL_REGSET };
/* RISC-V/Linux regset information. */
-static struct regsets_info riscv_regsets_info =
- {
- riscv_regsets, /* regsets */
- 0, /* num_regsets */
- NULL, /* disabled_regsets */
- };
+static struct regsets_info riscv_regsets_info = {
+ riscv_regsets, /* regsets */
+ 0, /* num_regsets */
+ NULL, /* disabled_regsets */
+};
/* Definition of linux_target_ops data member "regs_info". */
-static struct regs_info riscv_regs =
- {
- NULL, /* regset_bitmap */
- NULL, /* usrregs */
- &riscv_regsets_info,
- };
+static struct regs_info riscv_regs = {
+ NULL, /* regset_bitmap */
+ NULL, /* usrregs */
+ &riscv_regsets_info,
+};
/* Implementation of linux target ops method "get_regs_info". */
@@ -257,11 +252,10 @@ int
riscv_target::breakpoint_kind_from_pc (CORE_ADDR *pcptr)
{
union
- {
- gdb_byte bytes[2];
- uint16_t insn;
- }
- buf;
+ {
+ gdb_byte bytes[2];
+ uint16_t insn;
+ } buf;
if (target_read_memory (*pcptr, buf.bytes, sizeof (buf.insn)) == 0
&& riscv_insn_length (buf.insn == sizeof (riscv_ibreakpoint)))
@@ -278,10 +272,10 @@ riscv_target::sw_breakpoint_from_kind (int kind, int *size)
*size = kind;
switch (kind)
{
- case sizeof (riscv_ibreakpoint):
- return (const gdb_byte *) &riscv_ibreakpoint;
- default:
- return (const gdb_byte *) &riscv_cbreakpoint;
+ case sizeof (riscv_ibreakpoint):
+ return (const gdb_byte *) &riscv_ibreakpoint;
+ default:
+ return (const gdb_byte *) &riscv_cbreakpoint;
}
}
@@ -291,18 +285,18 @@ bool
riscv_target::low_breakpoint_at (CORE_ADDR pc)
{
union
- {
- gdb_byte bytes[2];
- uint16_t insn;
- }
- buf;
+ {
+ gdb_byte bytes[2];
+ uint16_t insn;
+ } buf;
if (target_read_memory (pc, buf.bytes, sizeof (buf.insn)) == 0
&& (buf.insn == riscv_cbreakpoint
- || (buf.insn == riscv_ibreakpoint[0]
- && target_read_memory (pc + sizeof (buf.insn), buf.bytes,
- sizeof (buf.insn)) == 0
- && buf.insn == riscv_ibreakpoint[1])))
+ || (buf.insn == riscv_ibreakpoint[0]
+ && target_read_memory (pc + sizeof (buf.insn), buf.bytes,
+ sizeof (buf.insn))
+ == 0
+ && buf.insn == riscv_ibreakpoint[1])))
return true;
else
return false;
diff --git a/gdbserver/linux-s390-ipa.cc b/gdbserver/linux-s390-ipa.cc
index b8e1af9..0078822 100644
--- a/gdbserver/linux-s390-ipa.cc
+++ b/gdbserver/linux-s390-ipa.cc
@@ -27,14 +27,14 @@
#include <sys/auxv.h>
#endif
-#define FT_FPR(x) (0x000 + (x) * 0x10)
-#define FT_VR(x) (0x000 + (x) * 0x10)
-#define FT_VR_L(x) (0x008 + (x) * 0x10)
-#define FT_GPR(x) (0x200 + (x) * 8)
-#define FT_GPR_U(x) (0x200 + (x) * 8)
-#define FT_GPR_L(x) (0x204 + (x) * 8)
-#define FT_GPR(x) (0x200 + (x) * 8)
-#define FT_ACR(x) (0x280 + (x) * 4)
+#define FT_FPR(x) (0x000 + (x) *0x10)
+#define FT_VR(x) (0x000 + (x) *0x10)
+#define FT_VR_L(x) (0x008 + (x) *0x10)
+#define FT_GPR(x) (0x200 + (x) *8)
+#define FT_GPR_U(x) (0x200 + (x) *8)
+#define FT_GPR_L(x) (0x204 + (x) *8)
+#define FT_GPR(x) (0x200 + (x) *8)
+#define FT_ACR(x) (0x280 + (x) *4)
#define FT_PSWM 0x2c0
#define FT_PSWM_U 0x2c0
#define FT_PSWA 0x2c8
@@ -53,122 +53,310 @@
static const int s390_linux32_ft_collect_regmap[] = {
/* 32-bit PSWA and PSWM. */
- FT_PSWM_U, FT_PSWA_L,
+ FT_PSWM_U,
+ FT_PSWA_L,
/* 32-bit GPRs (mapped to lower halves of 64-bit slots). */
- FT_GPR_L (0), FT_GPR_L (1), FT_GPR_L (2), FT_GPR_L (3),
- FT_GPR_L (4), FT_GPR_L (5), FT_GPR_L (6), FT_GPR_L (7),
- FT_GPR_L (8), FT_GPR_L (9), FT_GPR_L (10), FT_GPR_L (11),
- FT_GPR_L (12), FT_GPR_L (13), FT_GPR_L (14), FT_GPR_L (15),
+ FT_GPR_L (0),
+ FT_GPR_L (1),
+ FT_GPR_L (2),
+ FT_GPR_L (3),
+ FT_GPR_L (4),
+ FT_GPR_L (5),
+ FT_GPR_L (6),
+ FT_GPR_L (7),
+ FT_GPR_L (8),
+ FT_GPR_L (9),
+ FT_GPR_L (10),
+ FT_GPR_L (11),
+ FT_GPR_L (12),
+ FT_GPR_L (13),
+ FT_GPR_L (14),
+ FT_GPR_L (15),
/* ACRs */
- FT_ACR (0), FT_ACR (1), FT_ACR (2), FT_ACR (3),
- FT_ACR (4), FT_ACR (5), FT_ACR (6), FT_ACR (7),
- FT_ACR (8), FT_ACR (9), FT_ACR (10), FT_ACR (11),
- FT_ACR (12), FT_ACR (13), FT_ACR (14), FT_ACR (15),
+ FT_ACR (0),
+ FT_ACR (1),
+ FT_ACR (2),
+ FT_ACR (3),
+ FT_ACR (4),
+ FT_ACR (5),
+ FT_ACR (6),
+ FT_ACR (7),
+ FT_ACR (8),
+ FT_ACR (9),
+ FT_ACR (10),
+ FT_ACR (11),
+ FT_ACR (12),
+ FT_ACR (13),
+ FT_ACR (14),
+ FT_ACR (15),
/* FPRs (mapped to upper halves of 128-bit VR slots). */
- FT_FPR (0), FT_FPR (1), FT_FPR (2), FT_FPR (3),
- FT_FPR (4), FT_FPR (5), FT_FPR (6), FT_FPR (7),
- FT_FPR (8), FT_FPR (9), FT_FPR (10), FT_FPR (11),
- FT_FPR (12), FT_FPR (13), FT_FPR (14), FT_FPR (15),
+ FT_FPR (0),
+ FT_FPR (1),
+ FT_FPR (2),
+ FT_FPR (3),
+ FT_FPR (4),
+ FT_FPR (5),
+ FT_FPR (6),
+ FT_FPR (7),
+ FT_FPR (8),
+ FT_FPR (9),
+ FT_FPR (10),
+ FT_FPR (11),
+ FT_FPR (12),
+ FT_FPR (13),
+ FT_FPR (14),
+ FT_FPR (15),
/* orig_r2, last_break, system_call */
- -1, -1, -1,
+ -1,
+ -1,
+ -1,
};
/* Used for s390-linux64, s390-linux64v1, s390-linux64v2, s390-vx-linux64. */
static const int s390_linux64_ft_collect_regmap[] = {
/* 32-bit PSWA and PSWM. */
- FT_PSWM_U, FT_PSWA_L,
+ FT_PSWM_U,
+ FT_PSWA_L,
/* 32-bit halves of 64-bit GPRs. */
- FT_GPR_U (0), FT_GPR_L (0),
- FT_GPR_U (1), FT_GPR_L (1),
- FT_GPR_U (2), FT_GPR_L (2),
- FT_GPR_U (3), FT_GPR_L (3),
- FT_GPR_U (4), FT_GPR_L (4),
- FT_GPR_U (5), FT_GPR_L (5),
- FT_GPR_U (6), FT_GPR_L (6),
- FT_GPR_U (7), FT_GPR_L (7),
- FT_GPR_U (8), FT_GPR_L (8),
- FT_GPR_U (9), FT_GPR_L (9),
- FT_GPR_U (10), FT_GPR_L (10),
- FT_GPR_U (11), FT_GPR_L (11),
- FT_GPR_U (12), FT_GPR_L (12),
- FT_GPR_U (13), FT_GPR_L (13),
- FT_GPR_U (14), FT_GPR_L (14),
- FT_GPR_U (15), FT_GPR_L (15),
+ FT_GPR_U (0),
+ FT_GPR_L (0),
+ FT_GPR_U (1),
+ FT_GPR_L (1),
+ FT_GPR_U (2),
+ FT_GPR_L (2),
+ FT_GPR_U (3),
+ FT_GPR_L (3),
+ FT_GPR_U (4),
+ FT_GPR_L (4),
+ FT_GPR_U (5),
+ FT_GPR_L (5),
+ FT_GPR_U (6),
+ FT_GPR_L (6),
+ FT_GPR_U (7),
+ FT_GPR_L (7),
+ FT_GPR_U (8),
+ FT_GPR_L (8),
+ FT_GPR_U (9),
+ FT_GPR_L (9),
+ FT_GPR_U (10),
+ FT_GPR_L (10),
+ FT_GPR_U (11),
+ FT_GPR_L (11),
+ FT_GPR_U (12),
+ FT_GPR_L (12),
+ FT_GPR_U (13),
+ FT_GPR_L (13),
+ FT_GPR_U (14),
+ FT_GPR_L (14),
+ FT_GPR_U (15),
+ FT_GPR_L (15),
/* ACRs */
- FT_ACR (0), FT_ACR (1), FT_ACR (2), FT_ACR (3),
- FT_ACR (4), FT_ACR (5), FT_ACR (6), FT_ACR (7),
- FT_ACR (8), FT_ACR (9), FT_ACR (10), FT_ACR (11),
- FT_ACR (12), FT_ACR (13), FT_ACR (14), FT_ACR (15),
+ FT_ACR (0),
+ FT_ACR (1),
+ FT_ACR (2),
+ FT_ACR (3),
+ FT_ACR (4),
+ FT_ACR (5),
+ FT_ACR (6),
+ FT_ACR (7),
+ FT_ACR (8),
+ FT_ACR (9),
+ FT_ACR (10),
+ FT_ACR (11),
+ FT_ACR (12),
+ FT_ACR (13),
+ FT_ACR (14),
+ FT_ACR (15),
/* FPRs (mapped to upper halves of 128-bit VR slots). */
- FT_FPR (0), FT_FPR (1), FT_FPR (2), FT_FPR (3),
- FT_FPR (4), FT_FPR (5), FT_FPR (6), FT_FPR (7),
- FT_FPR (8), FT_FPR (9), FT_FPR (10), FT_FPR (11),
- FT_FPR (12), FT_FPR (13), FT_FPR (14), FT_FPR (15),
+ FT_FPR (0),
+ FT_FPR (1),
+ FT_FPR (2),
+ FT_FPR (3),
+ FT_FPR (4),
+ FT_FPR (5),
+ FT_FPR (6),
+ FT_FPR (7),
+ FT_FPR (8),
+ FT_FPR (9),
+ FT_FPR (10),
+ FT_FPR (11),
+ FT_FPR (12),
+ FT_FPR (13),
+ FT_FPR (14),
+ FT_FPR (15),
/* orig_r2, last_break, system_call */
- -1, -1, -1,
+ -1,
+ -1,
+ -1,
/* Lower halves of 128-bit VRs. */
- FT_VR_L (0), FT_VR_L (1), FT_VR_L (2), FT_VR_L (3),
- FT_VR_L (4), FT_VR_L (5), FT_VR_L (6), FT_VR_L (7),
- FT_VR_L (8), FT_VR_L (9), FT_VR_L (10), FT_VR_L (11),
- FT_VR_L (12), FT_VR_L (13), FT_VR_L (14), FT_VR_L (15),
+ FT_VR_L (0),
+ FT_VR_L (1),
+ FT_VR_L (2),
+ FT_VR_L (3),
+ FT_VR_L (4),
+ FT_VR_L (5),
+ FT_VR_L (6),
+ FT_VR_L (7),
+ FT_VR_L (8),
+ FT_VR_L (9),
+ FT_VR_L (10),
+ FT_VR_L (11),
+ FT_VR_L (12),
+ FT_VR_L (13),
+ FT_VR_L (14),
+ FT_VR_L (15),
/* And the next 16 VRs. */
- FT_VR (16), FT_VR (17), FT_VR (18), FT_VR (19),
- FT_VR (20), FT_VR (21), FT_VR (22), FT_VR (23),
- FT_VR (24), FT_VR (25), FT_VR (26), FT_VR (27),
- FT_VR (28), FT_VR (29), FT_VR (30), FT_VR (31),
+ FT_VR (16),
+ FT_VR (17),
+ FT_VR (18),
+ FT_VR (19),
+ FT_VR (20),
+ FT_VR (21),
+ FT_VR (22),
+ FT_VR (23),
+ FT_VR (24),
+ FT_VR (25),
+ FT_VR (26),
+ FT_VR (27),
+ FT_VR (28),
+ FT_VR (29),
+ FT_VR (30),
+ FT_VR (31),
};
/* Used for s390-te-linux64, s390-tevx-linux64, and s390-gs-linux64. */
static const int s390_te_linux64_ft_collect_regmap[] = {
/* 32-bit PSWA and PSWM. */
- FT_PSWM_U, FT_PSWA_L,
+ FT_PSWM_U,
+ FT_PSWA_L,
/* 32-bit halves of 64-bit GPRs. */
- FT_GPR_U (0), FT_GPR_L (0),
- FT_GPR_U (1), FT_GPR_L (1),
- FT_GPR_U (2), FT_GPR_L (2),
- FT_GPR_U (3), FT_GPR_L (3),
- FT_GPR_U (4), FT_GPR_L (4),
- FT_GPR_U (5), FT_GPR_L (5),
- FT_GPR_U (6), FT_GPR_L (6),
- FT_GPR_U (7), FT_GPR_L (7),
- FT_GPR_U (8), FT_GPR_L (8),
- FT_GPR_U (9), FT_GPR_L (9),
- FT_GPR_U (10), FT_GPR_L (10),
- FT_GPR_U (11), FT_GPR_L (11),
- FT_GPR_U (12), FT_GPR_L (12),
- FT_GPR_U (13), FT_GPR_L (13),
- FT_GPR_U (14), FT_GPR_L (14),
- FT_GPR_U (15), FT_GPR_L (15),
+ FT_GPR_U (0),
+ FT_GPR_L (0),
+ FT_GPR_U (1),
+ FT_GPR_L (1),
+ FT_GPR_U (2),
+ FT_GPR_L (2),
+ FT_GPR_U (3),
+ FT_GPR_L (3),
+ FT_GPR_U (4),
+ FT_GPR_L (4),
+ FT_GPR_U (5),
+ FT_GPR_L (5),
+ FT_GPR_U (6),
+ FT_GPR_L (6),
+ FT_GPR_U (7),
+ FT_GPR_L (7),
+ FT_GPR_U (8),
+ FT_GPR_L (8),
+ FT_GPR_U (9),
+ FT_GPR_L (9),
+ FT_GPR_U (10),
+ FT_GPR_L (10),
+ FT_GPR_U (11),
+ FT_GPR_L (11),
+ FT_GPR_U (12),
+ FT_GPR_L (12),
+ FT_GPR_U (13),
+ FT_GPR_L (13),
+ FT_GPR_U (14),
+ FT_GPR_L (14),
+ FT_GPR_U (15),
+ FT_GPR_L (15),
/* ACRs */
- FT_ACR (0), FT_ACR (1), FT_ACR (2), FT_ACR (3),
- FT_ACR (4), FT_ACR (5), FT_ACR (6), FT_ACR (7),
- FT_ACR (8), FT_ACR (9), FT_ACR (10), FT_ACR (11),
- FT_ACR (12), FT_ACR (13), FT_ACR (14), FT_ACR (15),
+ FT_ACR (0),
+ FT_ACR (1),
+ FT_ACR (2),
+ FT_ACR (3),
+ FT_ACR (4),
+ FT_ACR (5),
+ FT_ACR (6),
+ FT_ACR (7),
+ FT_ACR (8),
+ FT_ACR (9),
+ FT_ACR (10),
+ FT_ACR (11),
+ FT_ACR (12),
+ FT_ACR (13),
+ FT_ACR (14),
+ FT_ACR (15),
/* FPRs (mapped to upper halves of 128-bit VR slots). */
- FT_FPR (0), FT_FPR (1), FT_FPR (2), FT_FPR (3),
- FT_FPR (4), FT_FPR (5), FT_FPR (6), FT_FPR (7),
- FT_FPR (8), FT_FPR (9), FT_FPR (10), FT_FPR (11),
- FT_FPR (12), FT_FPR (13), FT_FPR (14), FT_FPR (15),
+ FT_FPR (0),
+ FT_FPR (1),
+ FT_FPR (2),
+ FT_FPR (3),
+ FT_FPR (4),
+ FT_FPR (5),
+ FT_FPR (6),
+ FT_FPR (7),
+ FT_FPR (8),
+ FT_FPR (9),
+ FT_FPR (10),
+ FT_FPR (11),
+ FT_FPR (12),
+ FT_FPR (13),
+ FT_FPR (14),
+ FT_FPR (15),
/* orig_r2, last_break, system_call */
- -1, -1, -1,
+ -1,
+ -1,
+ -1,
/* TDB */
- -1, -1, -1, -1,
- -1, -1, -1, -1,
- -1, -1, -1, -1,
- -1, -1, -1, -1,
- -1, -1, -1, -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
/* Lower halves of 128-bit VRs. */
- FT_VR_L (0), FT_VR_L (1), FT_VR_L (2), FT_VR_L (3),
- FT_VR_L (4), FT_VR_L (5), FT_VR_L (6), FT_VR_L (7),
- FT_VR_L (8), FT_VR_L (9), FT_VR_L (10), FT_VR_L (11),
- FT_VR_L (12), FT_VR_L (13), FT_VR_L (14), FT_VR_L (15),
+ FT_VR_L (0),
+ FT_VR_L (1),
+ FT_VR_L (2),
+ FT_VR_L (3),
+ FT_VR_L (4),
+ FT_VR_L (5),
+ FT_VR_L (6),
+ FT_VR_L (7),
+ FT_VR_L (8),
+ FT_VR_L (9),
+ FT_VR_L (10),
+ FT_VR_L (11),
+ FT_VR_L (12),
+ FT_VR_L (13),
+ FT_VR_L (14),
+ FT_VR_L (15),
/* And the next 16 VRs. */
- FT_VR (16), FT_VR (17), FT_VR (18), FT_VR (19),
- FT_VR (20), FT_VR (21), FT_VR (22), FT_VR (23),
- FT_VR (24), FT_VR (25), FT_VR (26), FT_VR (27),
- FT_VR (28), FT_VR (29), FT_VR (30), FT_VR (31),
+ FT_VR (16),
+ FT_VR (17),
+ FT_VR (18),
+ FT_VR (19),
+ FT_VR (20),
+ FT_VR (21),
+ FT_VR (22),
+ FT_VR (23),
+ FT_VR (24),
+ FT_VR (25),
+ FT_VR (26),
+ FT_VR (27),
+ FT_VR (28),
+ FT_VR (29),
+ FT_VR (30),
+ FT_VR (31),
};
#else /* __s390x__ */
@@ -177,34 +365,97 @@ static const int s390_te_linux64_ft_collect_regmap[] = {
static const int s390x_ft_collect_regmap[] = {
/* 64-bit PSWA and PSWM. */
- FT_PSWM, FT_PSWA,
+ FT_PSWM,
+ FT_PSWA,
/* 64-bit GPRs. */
- FT_GPR (0), FT_GPR (1), FT_GPR (2), FT_GPR (3),
- FT_GPR (4), FT_GPR (5), FT_GPR (6), FT_GPR (7),
- FT_GPR (8), FT_GPR (9), FT_GPR (10), FT_GPR (11),
- FT_GPR (12), FT_GPR (13), FT_GPR (14), FT_GPR (15),
+ FT_GPR (0),
+ FT_GPR (1),
+ FT_GPR (2),
+ FT_GPR (3),
+ FT_GPR (4),
+ FT_GPR (5),
+ FT_GPR (6),
+ FT_GPR (7),
+ FT_GPR (8),
+ FT_GPR (9),
+ FT_GPR (10),
+ FT_GPR (11),
+ FT_GPR (12),
+ FT_GPR (13),
+ FT_GPR (14),
+ FT_GPR (15),
/* ACRs */
- FT_ACR (0), FT_ACR (1), FT_ACR (2), FT_ACR (3),
- FT_ACR (4), FT_ACR (5), FT_ACR (6), FT_ACR (7),
- FT_ACR (8), FT_ACR (9), FT_ACR (10), FT_ACR (11),
- FT_ACR (12), FT_ACR (13), FT_ACR (14), FT_ACR (15),
+ FT_ACR (0),
+ FT_ACR (1),
+ FT_ACR (2),
+ FT_ACR (3),
+ FT_ACR (4),
+ FT_ACR (5),
+ FT_ACR (6),
+ FT_ACR (7),
+ FT_ACR (8),
+ FT_ACR (9),
+ FT_ACR (10),
+ FT_ACR (11),
+ FT_ACR (12),
+ FT_ACR (13),
+ FT_ACR (14),
+ FT_ACR (15),
/* FPRs (mapped to upper halves of 128-bit VR slots). */
- FT_FPR (0), FT_FPR (1), FT_FPR (2), FT_FPR (3),
- FT_FPR (4), FT_FPR (5), FT_FPR (6), FT_FPR (7),
- FT_FPR (8), FT_FPR (9), FT_FPR (10), FT_FPR (11),
- FT_FPR (12), FT_FPR (13), FT_FPR (14), FT_FPR (15),
+ FT_FPR (0),
+ FT_FPR (1),
+ FT_FPR (2),
+ FT_FPR (3),
+ FT_FPR (4),
+ FT_FPR (5),
+ FT_FPR (6),
+ FT_FPR (7),
+ FT_FPR (8),
+ FT_FPR (9),
+ FT_FPR (10),
+ FT_FPR (11),
+ FT_FPR (12),
+ FT_FPR (13),
+ FT_FPR (14),
+ FT_FPR (15),
/* orig_r2, last_break, system_call */
- -1, -1, -1,
+ -1,
+ -1,
+ -1,
/* Lower halves of 128-bit VRs. */
- FT_VR_L (0), FT_VR_L (1), FT_VR_L (2), FT_VR_L (3),
- FT_VR_L (4), FT_VR_L (5), FT_VR_L (6), FT_VR_L (7),
- FT_VR_L (8), FT_VR_L (9), FT_VR_L (10), FT_VR_L (11),
- FT_VR_L (12), FT_VR_L (13), FT_VR_L (14), FT_VR_L (15),
+ FT_VR_L (0),
+ FT_VR_L (1),
+ FT_VR_L (2),
+ FT_VR_L (3),
+ FT_VR_L (4),
+ FT_VR_L (5),
+ FT_VR_L (6),
+ FT_VR_L (7),
+ FT_VR_L (8),
+ FT_VR_L (9),
+ FT_VR_L (10),
+ FT_VR_L (11),
+ FT_VR_L (12),
+ FT_VR_L (13),
+ FT_VR_L (14),
+ FT_VR_L (15),
/* And the next 16 VRs. */
- FT_VR (16), FT_VR (17), FT_VR (18), FT_VR (19),
- FT_VR (20), FT_VR (21), FT_VR (22), FT_VR (23),
- FT_VR (24), FT_VR (25), FT_VR (26), FT_VR (27),
- FT_VR (28), FT_VR (29), FT_VR (30), FT_VR (31),
+ FT_VR (16),
+ FT_VR (17),
+ FT_VR (18),
+ FT_VR (19),
+ FT_VR (20),
+ FT_VR (21),
+ FT_VR (22),
+ FT_VR (23),
+ FT_VR (24),
+ FT_VR (25),
+ FT_VR (26),
+ FT_VR (27),
+ FT_VR (28),
+ FT_VR (29),
+ FT_VR (30),
+ FT_VR (31),
};
/* Used for s390x-te-linux64, s390x-tevx-linux64, and
@@ -212,40 +463,118 @@ static const int s390x_ft_collect_regmap[] = {
static const int s390x_te_ft_collect_regmap[] = {
/* 64-bit PSWA and PSWM. */
- FT_PSWM, FT_PSWA,
+ FT_PSWM,
+ FT_PSWA,
/* 64-bit GPRs. */
- FT_GPR (0), FT_GPR (1), FT_GPR (2), FT_GPR (3),
- FT_GPR (4), FT_GPR (5), FT_GPR (6), FT_GPR (7),
- FT_GPR (8), FT_GPR (9), FT_GPR (10), FT_GPR (11),
- FT_GPR (12), FT_GPR (13), FT_GPR (14), FT_GPR (15),
+ FT_GPR (0),
+ FT_GPR (1),
+ FT_GPR (2),
+ FT_GPR (3),
+ FT_GPR (4),
+ FT_GPR (5),
+ FT_GPR (6),
+ FT_GPR (7),
+ FT_GPR (8),
+ FT_GPR (9),
+ FT_GPR (10),
+ FT_GPR (11),
+ FT_GPR (12),
+ FT_GPR (13),
+ FT_GPR (14),
+ FT_GPR (15),
/* ACRs */
- FT_ACR (0), FT_ACR (1), FT_ACR (2), FT_ACR (3),
- FT_ACR (4), FT_ACR (5), FT_ACR (6), FT_ACR (7),
- FT_ACR (8), FT_ACR (9), FT_ACR (10), FT_ACR (11),
- FT_ACR (12), FT_ACR (13), FT_ACR (14), FT_ACR (15),
+ FT_ACR (0),
+ FT_ACR (1),
+ FT_ACR (2),
+ FT_ACR (3),
+ FT_ACR (4),
+ FT_ACR (5),
+ FT_ACR (6),
+ FT_ACR (7),
+ FT_ACR (8),
+ FT_ACR (9),
+ FT_ACR (10),
+ FT_ACR (11),
+ FT_ACR (12),
+ FT_ACR (13),
+ FT_ACR (14),
+ FT_ACR (15),
/* FPRs (mapped to upper halves of 128-bit VR slots). */
- FT_FPR (0), FT_FPR (1), FT_FPR (2), FT_FPR (3),
- FT_FPR (4), FT_FPR (5), FT_FPR (6), FT_FPR (7),
- FT_FPR (8), FT_FPR (9), FT_FPR (10), FT_FPR (11),
- FT_FPR (12), FT_FPR (13), FT_FPR (14), FT_FPR (15),
+ FT_FPR (0),
+ FT_FPR (1),
+ FT_FPR (2),
+ FT_FPR (3),
+ FT_FPR (4),
+ FT_FPR (5),
+ FT_FPR (6),
+ FT_FPR (7),
+ FT_FPR (8),
+ FT_FPR (9),
+ FT_FPR (10),
+ FT_FPR (11),
+ FT_FPR (12),
+ FT_FPR (13),
+ FT_FPR (14),
+ FT_FPR (15),
/* orig_r2, last_break, system_call */
- -1, -1, -1,
+ -1,
+ -1,
+ -1,
/* TDB */
- -1, -1, -1, -1,
- -1, -1, -1, -1,
- -1, -1, -1, -1,
- -1, -1, -1, -1,
- -1, -1, -1, -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
/* Lower halves of 128-bit VRs. */
- FT_VR_L (0), FT_VR_L (1), FT_VR_L (2), FT_VR_L (3),
- FT_VR_L (4), FT_VR_L (5), FT_VR_L (6), FT_VR_L (7),
- FT_VR_L (8), FT_VR_L (9), FT_VR_L (10), FT_VR_L (11),
- FT_VR_L (12), FT_VR_L (13), FT_VR_L (14), FT_VR_L (15),
+ FT_VR_L (0),
+ FT_VR_L (1),
+ FT_VR_L (2),
+ FT_VR_L (3),
+ FT_VR_L (4),
+ FT_VR_L (5),
+ FT_VR_L (6),
+ FT_VR_L (7),
+ FT_VR_L (8),
+ FT_VR_L (9),
+ FT_VR_L (10),
+ FT_VR_L (11),
+ FT_VR_L (12),
+ FT_VR_L (13),
+ FT_VR_L (14),
+ FT_VR_L (15),
/* And the next 16 VRs. */
- FT_VR (16), FT_VR (17), FT_VR (18), FT_VR (19),
- FT_VR (20), FT_VR (21), FT_VR (22), FT_VR (23),
- FT_VR (24), FT_VR (25), FT_VR (26), FT_VR (27),
- FT_VR (28), FT_VR (29), FT_VR (30), FT_VR (31),
+ FT_VR (16),
+ FT_VR (17),
+ FT_VR (18),
+ FT_VR (19),
+ FT_VR (20),
+ FT_VR (21),
+ FT_VR (22),
+ FT_VR (23),
+ FT_VR (24),
+ FT_VR (25),
+ FT_VR (26),
+ FT_VR (27),
+ FT_VR (28),
+ FT_VR (29),
+ FT_VR (30),
+ FT_VR (31),
};
#endif
@@ -259,7 +588,7 @@ static int s390_regnum;
void
supply_fast_tracepoint_registers (struct regcache *regcache,
- const unsigned char *buf)
+ const unsigned char *buf)
{
int i;
for (i = 0; i < s390_regnum; i++)
@@ -280,23 +609,20 @@ get_raw_reg (const unsigned char *raw_regs, int regnum)
/* The regnums are variable, better to figure out size by FT offset. */
/* 64-bit ones. */
- if (offset < FT_VR(16)
+ if (offset < FT_VR (16)
#ifdef __s390x__
- || (offset >= FT_GPR(0) && offset < FT_ACR(0))
- || offset == FT_PSWM
+ || (offset >= FT_GPR (0) && offset < FT_ACR (0)) || offset == FT_PSWM
|| offset == FT_PSWA
#endif
- )
+ )
return *(uint64_t *) (raw_regs + offset);
- if (offset >= FT_ACR(0 && offset < FT_PSWM)
- || offset == FT_FPC
+ if (offset >= FT_ACR (0 && offset < FT_PSWM) || offset == FT_FPC
#ifndef __s390x__
- || (offset >= FT_GPR(0) && offset < FT_ACR(0))
- || offset == FT_PSWM_U
+ || (offset >= FT_GPR (0) && offset < FT_ACR (0)) || offset == FT_PSWM_U
|| offset == FT_PSWA_L
#endif
- )
+ )
return *(uint32_t *) (raw_regs + offset);
/* This leaves 128-bit VX. No way to return them. */
@@ -309,66 +635,68 @@ get_raw_reg (const unsigned char *raw_regs, int regnum)
const struct target_desc *
get_ipa_tdesc (int idx)
{
-#define SET_REGMAP(regmap, skip_last) \
- do { \
- s390_regmap = regmap; \
- s390_regnum = (sizeof regmap / sizeof regmap[0]) - skip_last; \
- } while(0)
+#define SET_REGMAP(regmap, skip_last) \
+ do \
+ { \
+ s390_regmap = regmap; \
+ s390_regnum = (sizeof regmap / sizeof regmap[0]) - skip_last; \
+ } \
+ while (0)
switch (idx)
{
#ifdef __s390x__
case S390_TDESC_64:
/* Subtract number of VX regs. */
- SET_REGMAP(s390x_ft_collect_regmap, 32);
+ SET_REGMAP (s390x_ft_collect_regmap, 32);
return tdesc_s390x_linux64;
case S390_TDESC_64V1:
- SET_REGMAP(s390x_ft_collect_regmap, 32);
+ SET_REGMAP (s390x_ft_collect_regmap, 32);
return tdesc_s390x_linux64v1;
case S390_TDESC_64V2:
- SET_REGMAP(s390x_ft_collect_regmap, 32);
+ SET_REGMAP (s390x_ft_collect_regmap, 32);
return tdesc_s390x_linux64v2;
case S390_TDESC_TE:
- SET_REGMAP(s390x_te_ft_collect_regmap, 32);
+ SET_REGMAP (s390x_te_ft_collect_regmap, 32);
return tdesc_s390x_te_linux64;
case S390_TDESC_VX:
- SET_REGMAP(s390x_ft_collect_regmap, 0);
+ SET_REGMAP (s390x_ft_collect_regmap, 0);
return tdesc_s390x_vx_linux64;
case S390_TDESC_TEVX:
- SET_REGMAP(s390x_te_ft_collect_regmap, 0);
+ SET_REGMAP (s390x_te_ft_collect_regmap, 0);
return tdesc_s390x_tevx_linux64;
case S390_TDESC_GS:
- SET_REGMAP(s390x_te_ft_collect_regmap, 0);
+ SET_REGMAP (s390x_te_ft_collect_regmap, 0);
return tdesc_s390x_gs_linux64;
#else
case S390_TDESC_32:
- SET_REGMAP(s390_linux32_ft_collect_regmap, 0);
+ SET_REGMAP (s390_linux32_ft_collect_regmap, 0);
return tdesc_s390_linux32;
case S390_TDESC_32V1:
- SET_REGMAP(s390_linux32_ft_collect_regmap, 0);
+ SET_REGMAP (s390_linux32_ft_collect_regmap, 0);
return tdesc_s390_linux32v1;
case S390_TDESC_32V2:
- SET_REGMAP(s390_linux32_ft_collect_regmap, 0);
+ SET_REGMAP (s390_linux32_ft_collect_regmap, 0);
return tdesc_s390_linux32v2;
case S390_TDESC_64:
- SET_REGMAP(s390_linux64_ft_collect_regmap, 32);
+ SET_REGMAP (s390_linux64_ft_collect_regmap, 32);
return tdesc_s390_linux64;
case S390_TDESC_64V1:
- SET_REGMAP(s390_linux64_ft_collect_regmap, 32);
+ SET_REGMAP (s390_linux64_ft_collect_regmap, 32);
return tdesc_s390_linux64v1;
case S390_TDESC_64V2:
- SET_REGMAP(s390_linux64_ft_collect_regmap, 32);
+ SET_REGMAP (s390_linux64_ft_collect_regmap, 32);
return tdesc_s390_linux64v2;
case S390_TDESC_TE:
- SET_REGMAP(s390_te_linux64_ft_collect_regmap, 32);
+ SET_REGMAP (s390_te_linux64_ft_collect_regmap, 32);
return tdesc_s390_te_linux64;
case S390_TDESC_VX:
- SET_REGMAP(s390_linux64_ft_collect_regmap, 0);
+ SET_REGMAP (s390_linux64_ft_collect_regmap, 0);
return tdesc_s390_vx_linux64;
case S390_TDESC_TEVX:
- SET_REGMAP(s390_te_linux64_ft_collect_regmap, 0);
+ SET_REGMAP (s390_te_linux64_ft_collect_regmap, 0);
return tdesc_s390_tevx_linux64;
case S390_TDESC_GS:
- SET_REGMAP(s390_te_linux64_ft_collect_regmap, 0);
+ SET_REGMAP (s390_te_linux64_ft_collect_regmap, 0);
return tdesc_s390_gs_linux64;
#endif
default:
@@ -411,23 +739,22 @@ alloc_jump_pad_buffer (size_t size)
for (; addr; addr -= pagesize)
{
/* No MAP_FIXED - we don't want to zap someone's mapping. */
- res = mmap ((void *) addr, size,
- PROT_READ | PROT_WRITE | PROT_EXEC,
- MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+ res = mmap ((void *) addr, size, PROT_READ | PROT_WRITE | PROT_EXEC,
+ MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
/* If we got what we wanted, return. */
if ((uintptr_t) res == addr)
- return res;
+ return res;
/* If we got a mapping, but at a wrong address, undo it. */
if (res != MAP_FAILED)
- munmap (res, size);
+ munmap (res, size);
}
return NULL;
#else
void *res = mmap (NULL, size, PROT_READ | PROT_WRITE | PROT_EXEC,
- MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+ MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
if (res == MAP_FAILED)
return NULL;
diff --git a/gdbserver/linux-s390-low.cc b/gdbserver/linux-s390-low.cc
index 48f64ef..afa45d5 100644
--- a/gdbserver/linux-s390-low.cc
+++ b/gdbserver/linux-s390-low.cc
@@ -56,7 +56,6 @@
class s390_target : public linux_process_target
{
public:
-
const regs_info *get_regs_info () override;
const gdb_byte *sw_breakpoint_from_kind (int kind, int *size) override;
@@ -67,28 +66,27 @@ public:
bool supports_fast_tracepoints () override;
- int install_fast_tracepoint_jump_pad
- (CORE_ADDR tpoint, CORE_ADDR tpaddr, CORE_ADDR collector,
- CORE_ADDR lockaddr, ULONGEST orig_size, CORE_ADDR *jump_entry,
- CORE_ADDR *trampoline, ULONGEST *trampoline_size,
- unsigned char *jjump_pad_insn, ULONGEST *jjump_pad_insn_size,
- CORE_ADDR *adjusted_insn_addr, CORE_ADDR *adjusted_insn_addr_end,
- char *err) override;
+ int install_fast_tracepoint_jump_pad (
+ CORE_ADDR tpoint, CORE_ADDR tpaddr, CORE_ADDR collector,
+ CORE_ADDR lockaddr, ULONGEST orig_size, CORE_ADDR *jump_entry,
+ CORE_ADDR *trampoline, ULONGEST *trampoline_size,
+ unsigned char *jjump_pad_insn, ULONGEST *jjump_pad_insn_size,
+ CORE_ADDR *adjusted_insn_addr, CORE_ADDR *adjusted_insn_addr_end,
+ char *err) override;
int get_min_fast_tracepoint_insn_len () override;
void low_collect_ptrace_register (regcache *regcache, int regno,
- char *buf) override;
+ char *buf) override;
void low_supply_ptrace_register (regcache *regcache, int regno,
- const char *buf) override;
+ const char *buf) override;
struct emit_ops *emit_ops () override;
int get_ipa_tdesc_idx () override;
protected:
-
void low_arch_setup () override;
bool low_cannot_fetch_register (int regno) override;
@@ -113,30 +111,26 @@ protected:
static s390_target the_s390_target;
static int s390_regmap[] = {
- PT_PSWMASK, PT_PSWADDR,
+ PT_PSWMASK, PT_PSWADDR,
- PT_GPR0, PT_GPR1, PT_GPR2, PT_GPR3,
- PT_GPR4, PT_GPR5, PT_GPR6, PT_GPR7,
- PT_GPR8, PT_GPR9, PT_GPR10, PT_GPR11,
- PT_GPR12, PT_GPR13, PT_GPR14, PT_GPR15,
+ PT_GPR0, PT_GPR1, PT_GPR2, PT_GPR3, PT_GPR4, PT_GPR5,
+ PT_GPR6, PT_GPR7, PT_GPR8, PT_GPR9, PT_GPR10, PT_GPR11,
+ PT_GPR12, PT_GPR13, PT_GPR14, PT_GPR15,
- PT_ACR0, PT_ACR1, PT_ACR2, PT_ACR3,
- PT_ACR4, PT_ACR5, PT_ACR6, PT_ACR7,
- PT_ACR8, PT_ACR9, PT_ACR10, PT_ACR11,
- PT_ACR12, PT_ACR13, PT_ACR14, PT_ACR15,
+ PT_ACR0, PT_ACR1, PT_ACR2, PT_ACR3, PT_ACR4, PT_ACR5,
+ PT_ACR6, PT_ACR7, PT_ACR8, PT_ACR9, PT_ACR10, PT_ACR11,
+ PT_ACR12, PT_ACR13, PT_ACR14, PT_ACR15,
PT_FPC,
#ifndef __s390x__
- PT_FPR0_HI, PT_FPR1_HI, PT_FPR2_HI, PT_FPR3_HI,
- PT_FPR4_HI, PT_FPR5_HI, PT_FPR6_HI, PT_FPR7_HI,
- PT_FPR8_HI, PT_FPR9_HI, PT_FPR10_HI, PT_FPR11_HI,
+ PT_FPR0_HI, PT_FPR1_HI, PT_FPR2_HI, PT_FPR3_HI, PT_FPR4_HI, PT_FPR5_HI,
+ PT_FPR6_HI, PT_FPR7_HI, PT_FPR8_HI, PT_FPR9_HI, PT_FPR10_HI, PT_FPR11_HI,
PT_FPR12_HI, PT_FPR13_HI, PT_FPR14_HI, PT_FPR15_HI,
#else
- PT_FPR0, PT_FPR1, PT_FPR2, PT_FPR3,
- PT_FPR4, PT_FPR5, PT_FPR6, PT_FPR7,
- PT_FPR8, PT_FPR9, PT_FPR10, PT_FPR11,
- PT_FPR12, PT_FPR13, PT_FPR14, PT_FPR15,
+ PT_FPR0, PT_FPR1, PT_FPR2, PT_FPR3, PT_FPR4, PT_FPR5,
+ PT_FPR6, PT_FPR7, PT_FPR8, PT_FPR9, PT_FPR10, PT_FPR11,
+ PT_FPR12, PT_FPR13, PT_FPR14, PT_FPR15,
#endif
PT_ORIGGPR2,
@@ -146,61 +140,51 @@ static int s390_regmap[] = {
#ifdef __s390x__
static int s390_regmap_3264[] = {
- PT_PSWMASK, PT_PSWADDR,
-
- PT_GPR0, PT_GPR0, PT_GPR1, PT_GPR1,
- PT_GPR2, PT_GPR2, PT_GPR3, PT_GPR3,
- PT_GPR4, PT_GPR4, PT_GPR5, PT_GPR5,
- PT_GPR6, PT_GPR6, PT_GPR7, PT_GPR7,
- PT_GPR8, PT_GPR8, PT_GPR9, PT_GPR9,
- PT_GPR10, PT_GPR10, PT_GPR11, PT_GPR11,
- PT_GPR12, PT_GPR12, PT_GPR13, PT_GPR13,
- PT_GPR14, PT_GPR14, PT_GPR15, PT_GPR15,
-
- PT_ACR0, PT_ACR1, PT_ACR2, PT_ACR3,
- PT_ACR4, PT_ACR5, PT_ACR6, PT_ACR7,
- PT_ACR8, PT_ACR9, PT_ACR10, PT_ACR11,
- PT_ACR12, PT_ACR13, PT_ACR14, PT_ACR15,
+ PT_PSWMASK, PT_PSWADDR,
+
+ PT_GPR0, PT_GPR0, PT_GPR1, PT_GPR1, PT_GPR2, PT_GPR2, PT_GPR3,
+ PT_GPR3, PT_GPR4, PT_GPR4, PT_GPR5, PT_GPR5, PT_GPR6, PT_GPR6,
+ PT_GPR7, PT_GPR7, PT_GPR8, PT_GPR8, PT_GPR9, PT_GPR9, PT_GPR10,
+ PT_GPR10, PT_GPR11, PT_GPR11, PT_GPR12, PT_GPR12, PT_GPR13, PT_GPR13,
+ PT_GPR14, PT_GPR14, PT_GPR15, PT_GPR15,
+
+ PT_ACR0, PT_ACR1, PT_ACR2, PT_ACR3, PT_ACR4, PT_ACR5, PT_ACR6,
+ PT_ACR7, PT_ACR8, PT_ACR9, PT_ACR10, PT_ACR11, PT_ACR12, PT_ACR13,
+ PT_ACR14, PT_ACR15,
PT_FPC,
- PT_FPR0, PT_FPR1, PT_FPR2, PT_FPR3,
- PT_FPR4, PT_FPR5, PT_FPR6, PT_FPR7,
- PT_FPR8, PT_FPR9, PT_FPR10, PT_FPR11,
- PT_FPR12, PT_FPR13, PT_FPR14, PT_FPR15,
+ PT_FPR0, PT_FPR1, PT_FPR2, PT_FPR3, PT_FPR4, PT_FPR5, PT_FPR6,
+ PT_FPR7, PT_FPR8, PT_FPR9, PT_FPR10, PT_FPR11, PT_FPR12, PT_FPR13,
+ PT_FPR14, PT_FPR15,
PT_ORIGGPR2,
};
#else
static int s390_regmap_3264[] = {
- PT_PSWMASK, PT_PSWADDR,
-
- -1, PT_GPR0, -1, PT_GPR1,
- -1, PT_GPR2, -1, PT_GPR3,
- -1, PT_GPR4, -1, PT_GPR5,
- -1, PT_GPR6, -1, PT_GPR7,
- -1, PT_GPR8, -1, PT_GPR9,
- -1, PT_GPR10, -1, PT_GPR11,
- -1, PT_GPR12, -1, PT_GPR13,
- -1, PT_GPR14, -1, PT_GPR15,
-
- PT_ACR0, PT_ACR1, PT_ACR2, PT_ACR3,
- PT_ACR4, PT_ACR5, PT_ACR6, PT_ACR7,
- PT_ACR8, PT_ACR9, PT_ACR10, PT_ACR11,
- PT_ACR12, PT_ACR13, PT_ACR14, PT_ACR15,
+ PT_PSWMASK, PT_PSWADDR,
+
+ -1, PT_GPR0, -1, PT_GPR1, -1, PT_GPR2,
+ -1, PT_GPR3, -1, PT_GPR4, -1, PT_GPR5,
+ -1, PT_GPR6, -1, PT_GPR7, -1, PT_GPR8,
+ -1, PT_GPR9, -1, PT_GPR10, -1, PT_GPR11,
+ -1, PT_GPR12, -1, PT_GPR13, -1, PT_GPR14,
+ -1, PT_GPR15,
+
+ PT_ACR0, PT_ACR1, PT_ACR2, PT_ACR3, PT_ACR4, PT_ACR5,
+ PT_ACR6, PT_ACR7, PT_ACR8, PT_ACR9, PT_ACR10, PT_ACR11,
+ PT_ACR12, PT_ACR13, PT_ACR14, PT_ACR15,
PT_FPC,
- PT_FPR0_HI, PT_FPR1_HI, PT_FPR2_HI, PT_FPR3_HI,
- PT_FPR4_HI, PT_FPR5_HI, PT_FPR6_HI, PT_FPR7_HI,
- PT_FPR8_HI, PT_FPR9_HI, PT_FPR10_HI, PT_FPR11_HI,
+ PT_FPR0_HI, PT_FPR1_HI, PT_FPR2_HI, PT_FPR3_HI, PT_FPR4_HI, PT_FPR5_HI,
+ PT_FPR6_HI, PT_FPR7_HI, PT_FPR8_HI, PT_FPR9_HI, PT_FPR10_HI, PT_FPR11_HI,
PT_FPR12_HI, PT_FPR13_HI, PT_FPR14_HI, PT_FPR15_HI,
PT_ORIGGPR2,
};
#endif
-
bool
s390_target::low_cannot_fetch_register (int regno)
{
@@ -215,7 +199,7 @@ s390_target::low_cannot_store_register (int regno)
void
s390_target::low_collect_ptrace_register (regcache *regcache, int regno,
- char *buf)
+ char *buf)
{
int size = register_size (regcache->tdesc, regno);
const struct regs_info *regs_info = get_regs_info ();
@@ -226,35 +210,35 @@ s390_target::low_collect_ptrace_register (regcache *regcache, int regno,
{
memset (buf, 0, sizeof (long));
- if ((regno ^ 1) < usr->num_regs
- && usr->regmap[regno ^ 1] == regaddr)
- {
- collect_register (regcache, regno & ~1, buf);
- collect_register (regcache, (regno & ~1) + 1,
- buf + sizeof (long) - size);
- }
+ if ((regno ^ 1) < usr->num_regs && usr->regmap[regno ^ 1] == regaddr)
+ {
+ collect_register (regcache, regno & ~1, buf);
+ collect_register (regcache, (regno & ~1) + 1,
+ buf + sizeof (long) - size);
+ }
else if (regaddr == PT_PSWMASK)
- {
- /* Convert 4-byte PSW mask to 8 bytes by clearing bit 12 and copying
+ {
+ /* Convert 4-byte PSW mask to 8 bytes by clearing bit 12 and copying
the basic addressing mode bit from the PSW address. */
- gdb_byte *addr = (gdb_byte *) alloca (register_size (regcache->tdesc, regno ^ 1));
- collect_register (regcache, regno, buf);
- collect_register (regcache, regno ^ 1, addr);
- buf[1] &= ~0x8;
- buf[size] |= (addr[0] & 0x80);
- }
+ gdb_byte *addr
+ = (gdb_byte *) alloca (register_size (regcache->tdesc, regno ^ 1));
+ collect_register (regcache, regno, buf);
+ collect_register (regcache, regno ^ 1, addr);
+ buf[1] &= ~0x8;
+ buf[size] |= (addr[0] & 0x80);
+ }
else if (regaddr == PT_PSWADDR)
- {
- /* Convert 4-byte PSW address to 8 bytes by clearing the addressing
+ {
+ /* Convert 4-byte PSW address to 8 bytes by clearing the addressing
mode bit (which gets copied to the PSW mask instead). */
- collect_register (regcache, regno, buf + sizeof (long) - size);
- buf[sizeof (long) - size] &= ~0x80;
- }
+ collect_register (regcache, regno, buf + sizeof (long) - size);
+ buf[sizeof (long) - size] &= ~0x80;
+ }
else if ((regaddr >= PT_GPR0 && regaddr <= PT_GPR15)
- || regaddr == PT_ORIGGPR2)
- collect_register (regcache, regno, buf + sizeof (long) - size);
+ || regaddr == PT_ORIGGPR2)
+ collect_register (regcache, regno, buf + sizeof (long) - size);
else
- collect_register (regcache, regno, buf);
+ collect_register (regcache, regno, buf);
}
else if (regaddr != -1)
collect_register (regcache, regno, buf);
@@ -262,7 +246,7 @@ s390_target::low_collect_ptrace_register (regcache *regcache, int regno,
void
s390_target::low_supply_ptrace_register (regcache *regcache, int regno,
- const char *buf)
+ const char *buf)
{
int size = register_size (regcache->tdesc, regno);
const struct regs_info *regs_info = get_regs_info ();
@@ -271,46 +255,46 @@ s390_target::low_supply_ptrace_register (regcache *regcache, int regno,
if (size < sizeof (long))
{
- if ((regno ^ 1) < usr->num_regs
- && usr->regmap[regno ^ 1] == regaddr)
- {
- supply_register (regcache, regno & ~1, buf);
- supply_register (regcache, (regno & ~1) + 1,
- buf + sizeof (long) - size);
- }
+ if ((regno ^ 1) < usr->num_regs && usr->regmap[regno ^ 1] == regaddr)
+ {
+ supply_register (regcache, regno & ~1, buf);
+ supply_register (regcache, (regno & ~1) + 1,
+ buf + sizeof (long) - size);
+ }
else if (regaddr == PT_PSWMASK)
- {
- /* Convert 8-byte PSW mask to 4 bytes by setting bit 12 and copying
+ {
+ /* Convert 8-byte PSW mask to 4 bytes by setting bit 12 and copying
the basic addressing mode into the PSW address. */
- gdb_byte *mask = (gdb_byte *) alloca (size);
- gdb_byte *addr = (gdb_byte *) alloca (register_size (regcache->tdesc, regno ^ 1));
- memcpy (mask, buf, size);
- mask[1] |= 0x8;
- supply_register (regcache, regno, mask);
-
- collect_register (regcache, regno ^ 1, addr);
- addr[0] &= ~0x80;
- addr[0] |= (buf[size] & 0x80);
- supply_register (regcache, regno ^ 1, addr);
- }
+ gdb_byte *mask = (gdb_byte *) alloca (size);
+ gdb_byte *addr
+ = (gdb_byte *) alloca (register_size (regcache->tdesc, regno ^ 1));
+ memcpy (mask, buf, size);
+ mask[1] |= 0x8;
+ supply_register (regcache, regno, mask);
+
+ collect_register (regcache, regno ^ 1, addr);
+ addr[0] &= ~0x80;
+ addr[0] |= (buf[size] & 0x80);
+ supply_register (regcache, regno ^ 1, addr);
+ }
else if (regaddr == PT_PSWADDR)
- {
- /* Convert 8-byte PSW address to 4 bytes by truncating, but
+ {
+ /* Convert 8-byte PSW address to 4 bytes by truncating, but
keeping the addressing mode bit (which was set from the mask). */
- gdb_byte *addr = (gdb_byte *) alloca (size);
- char amode;
- collect_register (regcache, regno, addr);
- amode = addr[0] & 0x80;
- memcpy (addr, buf + sizeof (long) - size, size);
- addr[0] &= ~0x80;
- addr[0] |= amode;
- supply_register (regcache, regno, addr);
- }
+ gdb_byte *addr = (gdb_byte *) alloca (size);
+ char amode;
+ collect_register (regcache, regno, addr);
+ amode = addr[0] & 0x80;
+ memcpy (addr, buf + sizeof (long) - size, size);
+ addr[0] &= ~0x80;
+ addr[0] |= amode;
+ supply_register (regcache, regno, addr);
+ }
else if ((regaddr >= PT_GPR0 && regaddr <= PT_GPR15)
- || regaddr == PT_ORIGGPR2)
- supply_register (regcache, regno, buf + sizeof (long) - size);
+ || regaddr == PT_ORIGGPR2)
+ supply_register (regcache, regno, buf + sizeof (long) - size);
else
- supply_register (regcache, regno, buf);
+ supply_register (regcache, regno, buf);
}
else if (regaddr != -1)
supply_register (regcache, regno, buf);
@@ -328,12 +312,12 @@ s390_fill_gregset (struct regcache *regcache, void *buf)
for (i = 0; i < usr->num_regs; i++)
{
- if (usr->regmap[i] < PT_PSWMASK
- || usr->regmap[i] > PT_ACR15)
- continue;
+ if (usr->regmap[i] < PT_PSWMASK || usr->regmap[i] > PT_ACR15)
+ continue;
- ((s390_target *) the_linux_target)->low_collect_ptrace_register
- (regcache, i, (char *) buf + usr->regmap[i]);
+ ((s390_target *) the_linux_target)
+ ->low_collect_ptrace_register (regcache, i,
+ (char *) buf + usr->regmap[i]);
}
}
@@ -456,32 +440,30 @@ s390_store_gsbc (struct regcache *regcache, const void *buf)
supply_register (regcache, bc_gsd + i, (const char *) buf + 8 * (i + 1));
}
-static struct regset_info s390_regsets[] = {
- { 0, 0, 0, 0, GENERAL_REGS, s390_fill_gregset, NULL },
+static struct regset_info s390_regsets[]
+ = { { 0, 0, 0, 0, GENERAL_REGS, s390_fill_gregset, NULL },
#ifndef __s390x__
- { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_S390_HIGH_GPRS, 0,
- EXTENDED_REGS, s390_fill_gprs_high, s390_store_gprs_high },
+ { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_S390_HIGH_GPRS, 0,
+ EXTENDED_REGS, s390_fill_gprs_high, s390_store_gprs_high },
#endif
- /* Last break address is read-only; no fill function. */
- { PTRACE_GETREGSET, -1, NT_S390_LAST_BREAK, 0, EXTENDED_REGS,
- NULL, s390_store_last_break },
- { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_S390_SYSTEM_CALL, 0,
- EXTENDED_REGS, s390_fill_system_call, s390_store_system_call },
- /* TDB is read-only. */
- { PTRACE_GETREGSET, -1, NT_S390_TDB, 0, EXTENDED_REGS,
- NULL, s390_store_tdb },
- { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_S390_VXRS_LOW, 0,
- EXTENDED_REGS, s390_fill_vxrs_low, s390_store_vxrs_low },
- { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_S390_VXRS_HIGH, 0,
- EXTENDED_REGS, s390_fill_vxrs_high, s390_store_vxrs_high },
- /* Guarded storage registers are read-only. */
- { PTRACE_GETREGSET, -1, NT_S390_GS_CB, 0, EXTENDED_REGS,
- NULL, s390_store_gs },
- { PTRACE_GETREGSET, -1, NT_S390_GS_BC, 0, EXTENDED_REGS,
- NULL, s390_store_gsbc },
- NULL_REGSET
-};
-
+ /* Last break address is read-only; no fill function. */
+ { PTRACE_GETREGSET, -1, NT_S390_LAST_BREAK, 0, EXTENDED_REGS, NULL,
+ s390_store_last_break },
+ { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_S390_SYSTEM_CALL, 0,
+ EXTENDED_REGS, s390_fill_system_call, s390_store_system_call },
+ /* TDB is read-only. */
+ { PTRACE_GETREGSET, -1, NT_S390_TDB, 0, EXTENDED_REGS, NULL,
+ s390_store_tdb },
+ { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_S390_VXRS_LOW, 0, EXTENDED_REGS,
+ s390_fill_vxrs_low, s390_store_vxrs_low },
+ { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_S390_VXRS_HIGH, 0,
+ EXTENDED_REGS, s390_fill_vxrs_high, s390_store_vxrs_high },
+ /* Guarded storage registers are read-only. */
+ { PTRACE_GETREGSET, -1, NT_S390_GS_CB, 0, EXTENDED_REGS, NULL,
+ s390_store_gs },
+ { PTRACE_GETREGSET, -1, NT_S390_GS_BC, 0, EXTENDED_REGS, NULL,
+ s390_store_gsbc },
+ NULL_REGSET };
static const gdb_byte s390_breakpoint[] = { 0, 1 };
#define s390_breakpoint_len 2
@@ -548,12 +530,11 @@ static int
s390_get_wordsize (int pid)
{
errno = 0;
- PTRACE_XFER_TYPE pswm = ptrace (PTRACE_PEEKUSER, pid,
- (PTRACE_TYPE_ARG3) 0,
- (PTRACE_TYPE_ARG4) 0);
+ PTRACE_XFER_TYPE pswm = ptrace (PTRACE_PEEKUSER, pid, (PTRACE_TYPE_ARG3) 0,
+ (PTRACE_TYPE_ARG4) 0);
if (errno != 0)
{
- warning (_("Couldn't determine word size, assuming 64-bit."));
+ warning (_ ("Couldn't determine word size, assuming 64-bit."));
return 8;
}
/* Derive word size from extended addressing mode (PSW bit 31). */
@@ -595,71 +576,67 @@ s390_target::low_arch_setup ()
unsigned long hwcap = linux_get_hwcap (pid, wordsize);
/* Check whether the kernel supports extra register sets. */
- int have_regset_last_break
- = s390_check_regset (pid, NT_S390_LAST_BREAK, 8);
+ int have_regset_last_break = s390_check_regset (pid, NT_S390_LAST_BREAK, 8);
int have_regset_system_call
= s390_check_regset (pid, NT_S390_SYSTEM_CALL, 4);
- int have_regset_tdb
- = (s390_check_regset (pid, NT_S390_TDB, 256)
- && (hwcap & HWCAP_S390_TE) != 0);
- int have_regset_vxrs
- = (s390_check_regset (pid, NT_S390_VXRS_LOW, 128)
- && s390_check_regset (pid, NT_S390_VXRS_HIGH, 256)
- && (hwcap & HWCAP_S390_VX) != 0);
- int have_regset_gs
- = (s390_check_regset (pid, NT_S390_GS_CB, 32)
- && s390_check_regset (pid, NT_S390_GS_BC, 32)
- && (hwcap & HWCAP_S390_GS) != 0);
+ int have_regset_tdb = (s390_check_regset (pid, NT_S390_TDB, 256)
+ && (hwcap & HWCAP_S390_TE) != 0);
+ int have_regset_vxrs = (s390_check_regset (pid, NT_S390_VXRS_LOW, 128)
+ && s390_check_regset (pid, NT_S390_VXRS_HIGH, 256)
+ && (hwcap & HWCAP_S390_VX) != 0);
+ int have_regset_gs = (s390_check_regset (pid, NT_S390_GS_CB, 32)
+ && s390_check_regset (pid, NT_S390_GS_BC, 32)
+ && (hwcap & HWCAP_S390_GS) != 0);
{
#ifdef __s390x__
if (wordsize == 8)
{
- if (have_regset_gs)
- tdesc = tdesc_s390x_gs_linux64;
- else if (have_regset_vxrs)
- tdesc = (have_regset_tdb ? tdesc_s390x_tevx_linux64 :
- tdesc_s390x_vx_linux64);
- else if (have_regset_tdb)
- tdesc = tdesc_s390x_te_linux64;
- else if (have_regset_system_call)
- tdesc = tdesc_s390x_linux64v2;
- else if (have_regset_last_break)
- tdesc = tdesc_s390x_linux64v1;
- else
- tdesc = tdesc_s390x_linux64;
+ if (have_regset_gs)
+ tdesc = tdesc_s390x_gs_linux64;
+ else if (have_regset_vxrs)
+ tdesc = (have_regset_tdb ? tdesc_s390x_tevx_linux64
+ : tdesc_s390x_vx_linux64);
+ else if (have_regset_tdb)
+ tdesc = tdesc_s390x_te_linux64;
+ else if (have_regset_system_call)
+ tdesc = tdesc_s390x_linux64v2;
+ else if (have_regset_last_break)
+ tdesc = tdesc_s390x_linux64v1;
+ else
+ tdesc = tdesc_s390x_linux64;
}
/* For a 31-bit inferior, check whether the kernel supports
using the full 64-bit GPRs. */
else
#endif
- if (hwcap & HWCAP_S390_HIGH_GPRS)
+ if (hwcap & HWCAP_S390_HIGH_GPRS)
{
- have_hwcap_s390_high_gprs = 1;
- if (have_regset_gs)
- tdesc = tdesc_s390_gs_linux64;
- else if (have_regset_vxrs)
- tdesc = (have_regset_tdb ? tdesc_s390_tevx_linux64 :
- tdesc_s390_vx_linux64);
- else if (have_regset_tdb)
- tdesc = tdesc_s390_te_linux64;
- else if (have_regset_system_call)
- tdesc = tdesc_s390_linux64v2;
- else if (have_regset_last_break)
- tdesc = tdesc_s390_linux64v1;
- else
- tdesc = tdesc_s390_linux64;
+ have_hwcap_s390_high_gprs = 1;
+ if (have_regset_gs)
+ tdesc = tdesc_s390_gs_linux64;
+ else if (have_regset_vxrs)
+ tdesc = (have_regset_tdb ? tdesc_s390_tevx_linux64
+ : tdesc_s390_vx_linux64);
+ else if (have_regset_tdb)
+ tdesc = tdesc_s390_te_linux64;
+ else if (have_regset_system_call)
+ tdesc = tdesc_s390_linux64v2;
+ else if (have_regset_last_break)
+ tdesc = tdesc_s390_linux64v1;
+ else
+ tdesc = tdesc_s390_linux64;
}
else
{
- /* Assume 31-bit inferior process. */
- if (have_regset_system_call)
- tdesc = tdesc_s390_linux32v2;
- else if (have_regset_last_break)
- tdesc = tdesc_s390_linux32v1;
- else
- tdesc = tdesc_s390_linux32;
+ /* Assume 31-bit inferior process. */
+ if (have_regset_system_call)
+ tdesc = tdesc_s390_linux32v2;
+ else if (have_regset_last_break)
+ tdesc = tdesc_s390_linux32v1;
+ else
+ tdesc = tdesc_s390_linux32;
}
have_hwcap_s390_vx = have_regset_vxrs;
@@ -669,38 +646,37 @@ s390_target::low_arch_setup ()
for (regset = s390_regsets; regset->size >= 0; regset++)
if (regset->get_request == PTRACE_GETREGSET)
switch (regset->nt_type)
- {
+ {
#ifndef __s390x__
- case NT_S390_HIGH_GPRS:
- regset->size = have_hwcap_s390_high_gprs ? 64 : 0;
- break;
+ case NT_S390_HIGH_GPRS:
+ regset->size = have_hwcap_s390_high_gprs ? 64 : 0;
+ break;
#endif
- case NT_S390_LAST_BREAK:
- regset->size = have_regset_last_break ? 8 : 0;
- break;
- case NT_S390_SYSTEM_CALL:
- regset->size = have_regset_system_call ? 4 : 0;
- break;
- case NT_S390_TDB:
- regset->size = have_regset_tdb ? 256 : 0;
- break;
- case NT_S390_VXRS_LOW:
- regset->size = have_regset_vxrs ? 128 : 0;
- break;
- case NT_S390_VXRS_HIGH:
- regset->size = have_regset_vxrs ? 256 : 0;
- break;
- case NT_S390_GS_CB:
- case NT_S390_GS_BC:
- regset->size = have_regset_gs ? 32 : 0;
- default:
- break;
- }
+ case NT_S390_LAST_BREAK:
+ regset->size = have_regset_last_break ? 8 : 0;
+ break;
+ case NT_S390_SYSTEM_CALL:
+ regset->size = have_regset_system_call ? 4 : 0;
+ break;
+ case NT_S390_TDB:
+ regset->size = have_regset_tdb ? 256 : 0;
+ break;
+ case NT_S390_VXRS_LOW:
+ regset->size = have_regset_vxrs ? 128 : 0;
+ break;
+ case NT_S390_VXRS_HIGH:
+ regset->size = have_regset_vxrs ? 256 : 0;
+ break;
+ case NT_S390_GS_CB:
+ case NT_S390_GS_BC:
+ regset->size = have_regset_gs ? 32 : 0;
+ default:
+ break;
+ }
current_process ()->tdesc = tdesc;
}
-
bool
s390_target::low_breakpoint_at (CORE_ADDR pc)
{
@@ -725,45 +701,33 @@ s390_target::supports_z_point_type (char z_type)
}
}
-static struct usrregs_info s390_usrregs_info =
- {
- s390_num_regs,
- s390_regmap,
- };
+static struct usrregs_info s390_usrregs_info = {
+ s390_num_regs,
+ s390_regmap,
+};
-static struct regsets_info s390_regsets_info =
- {
- s390_regsets, /* regsets */
- 0, /* num_regsets */
- NULL, /* disabled_regsets */
- };
+static struct regsets_info s390_regsets_info = {
+ s390_regsets, /* regsets */
+ 0, /* num_regsets */
+ NULL, /* disabled_regsets */
+};
-static struct regs_info myregs_info =
- {
- NULL, /* regset_bitmap */
- &s390_usrregs_info,
- &s390_regsets_info
- };
+static struct regs_info myregs_info
+ = { NULL, /* regset_bitmap */
+ &s390_usrregs_info, &s390_regsets_info };
-static struct usrregs_info s390_usrregs_info_3264 =
- {
- s390_num_regs_3264,
- s390_regmap_3264
- };
+static struct usrregs_info s390_usrregs_info_3264
+ = { s390_num_regs_3264, s390_regmap_3264 };
-static struct regsets_info s390_regsets_info_3264 =
- {
- s390_regsets, /* regsets */
- 0, /* num_regsets */
- NULL, /* disabled_regsets */
- };
+static struct regsets_info s390_regsets_info_3264 = {
+ s390_regsets, /* regsets */
+ 0, /* num_regsets */
+ NULL, /* disabled_regsets */
+};
-static struct regs_info regs_info_3264 =
- {
- NULL, /* regset_bitmap */
- &s390_usrregs_info_3264,
- &s390_regsets_info_3264
- };
+static struct regs_info regs_info_3264
+ = { NULL, /* regset_bitmap */
+ &s390_usrregs_info_3264, &s390_regsets_info_3264 };
const regs_info *
s390_target::get_regs_info ()
@@ -774,7 +738,7 @@ s390_target::get_regs_info ()
const struct target_desc *tdesc = current_process ()->tdesc;
if (register_size (tdesc, 0) == 4)
- return &regs_info_3264;
+ return &regs_info_3264;
#else
return &regs_info_3264;
#endif
@@ -806,7 +770,6 @@ s390_target::low_get_thread_area (int lwpid, CORE_ADDR *addrp)
return 0;
}
-
/* Fast tracepoint support.
The register save area on stack is identical for all targets:
@@ -832,51 +795,51 @@ s390_target::low_get_thread_area (int lwpid, CORE_ADDR *addrp)
then branch to common path. */
static const unsigned char s390_ft_entry_gpr_esa[] = {
- 0xa7, 0x14, 0x00, 0x1e, /* jo .Lcc3 */
- 0xa7, 0x24, 0x00, 0x14, /* jh .Lcc2 */
- 0xa7, 0x44, 0x00, 0x0a, /* jl .Lcc1 */
+ 0xa7, 0x14, 0x00, 0x1e, /* jo .Lcc3 */
+ 0xa7, 0x24, 0x00, 0x14, /* jh .Lcc2 */
+ 0xa7, 0x44, 0x00, 0x0a, /* jl .Lcc1 */
/* CC = 0 */
- 0xa7, 0xfa, 0xfd, 0x00, /* ahi %r15, -0x300 */
- 0x50, 0x00, 0xf2, 0x04, /* st %r0, 0x204(%r15) */
- 0xa7, 0x08, 0x00, 0x00, /* lhi %r0, 0 */
- 0xa7, 0xf4, 0x00, 0x18, /* j .Lccdone */
+ 0xa7, 0xfa, 0xfd, 0x00, /* ahi %r15, -0x300 */
+ 0x50, 0x00, 0xf2, 0x04, /* st %r0, 0x204(%r15) */
+ 0xa7, 0x08, 0x00, 0x00, /* lhi %r0, 0 */
+ 0xa7, 0xf4, 0x00, 0x18, /* j .Lccdone */
/* .Lcc1: */
- 0xa7, 0xfa, 0xfd, 0x00, /* ahi %r15, -0x300 */
- 0x50, 0x00, 0xf2, 0x04, /* st %r0, 0x204(%r15) */
- 0xa7, 0x08, 0x10, 0x00, /* lhi %r0, 0x1000 */
- 0xa7, 0xf4, 0x00, 0x10, /* j .Lccdone */
+ 0xa7, 0xfa, 0xfd, 0x00, /* ahi %r15, -0x300 */
+ 0x50, 0x00, 0xf2, 0x04, /* st %r0, 0x204(%r15) */
+ 0xa7, 0x08, 0x10, 0x00, /* lhi %r0, 0x1000 */
+ 0xa7, 0xf4, 0x00, 0x10, /* j .Lccdone */
/* .Lcc2: */
- 0xa7, 0xfa, 0xfd, 0x00, /* ahi %r15, -0x300 */
- 0x50, 0x00, 0xf2, 0x04, /* st %r0, 0x204(%r15) */
- 0xa7, 0x08, 0x20, 0x00, /* lhi %r0, 0x2000 */
- 0xa7, 0xf4, 0x00, 0x08, /* j .Lccdone */
+ 0xa7, 0xfa, 0xfd, 0x00, /* ahi %r15, -0x300 */
+ 0x50, 0x00, 0xf2, 0x04, /* st %r0, 0x204(%r15) */
+ 0xa7, 0x08, 0x20, 0x00, /* lhi %r0, 0x2000 */
+ 0xa7, 0xf4, 0x00, 0x08, /* j .Lccdone */
/* .Lcc3: */
- 0xa7, 0xfa, 0xfd, 0x00, /* ahi %r15, -0x300 */
- 0x50, 0x00, 0xf2, 0x04, /* st %r0, 0x204(%r15) */
- 0xa7, 0x08, 0x30, 0x00, /* lhi %r0, 0x3000 */
+ 0xa7, 0xfa, 0xfd, 0x00, /* ahi %r15, -0x300 */
+ 0x50, 0x00, 0xf2, 0x04, /* st %r0, 0x204(%r15) */
+ 0xa7, 0x08, 0x30, 0x00, /* lhi %r0, 0x3000 */
/* .Lccdone: */
- 0x50, 0x10, 0xf2, 0x0c, /* st %r1, 0x20c(%r15) */
- 0x50, 0x20, 0xf2, 0x14, /* st %r2, 0x214(%r15) */
- 0x50, 0x30, 0xf2, 0x1c, /* st %r3, 0x21c(%r15) */
- 0x50, 0x40, 0xf2, 0x24, /* st %r4, 0x224(%r15) */
- 0x50, 0x50, 0xf2, 0x2c, /* st %r5, 0x22c(%r15) */
- 0x50, 0x60, 0xf2, 0x34, /* st %r6, 0x234(%r15) */
- 0x50, 0x70, 0xf2, 0x3c, /* st %r7, 0x23c(%r15) */
- 0x50, 0x80, 0xf2, 0x44, /* st %r8, 0x244(%r15) */
- 0x50, 0x90, 0xf2, 0x4c, /* st %r9, 0x24c(%r15) */
- 0x50, 0xa0, 0xf2, 0x54, /* st %r10, 0x254(%r15) */
- 0x50, 0xb0, 0xf2, 0x5c, /* st %r11, 0x25c(%r15) */
- 0x50, 0xc0, 0xf2, 0x64, /* st %r12, 0x264(%r15) */
- 0x50, 0xd0, 0xf2, 0x6c, /* st %r13, 0x26c(%r15) */
- 0x50, 0xe0, 0xf2, 0x74, /* st %r14, 0x274(%r15) */
+ 0x50, 0x10, 0xf2, 0x0c, /* st %r1, 0x20c(%r15) */
+ 0x50, 0x20, 0xf2, 0x14, /* st %r2, 0x214(%r15) */
+ 0x50, 0x30, 0xf2, 0x1c, /* st %r3, 0x21c(%r15) */
+ 0x50, 0x40, 0xf2, 0x24, /* st %r4, 0x224(%r15) */
+ 0x50, 0x50, 0xf2, 0x2c, /* st %r5, 0x22c(%r15) */
+ 0x50, 0x60, 0xf2, 0x34, /* st %r6, 0x234(%r15) */
+ 0x50, 0x70, 0xf2, 0x3c, /* st %r7, 0x23c(%r15) */
+ 0x50, 0x80, 0xf2, 0x44, /* st %r8, 0x244(%r15) */
+ 0x50, 0x90, 0xf2, 0x4c, /* st %r9, 0x24c(%r15) */
+ 0x50, 0xa0, 0xf2, 0x54, /* st %r10, 0x254(%r15) */
+ 0x50, 0xb0, 0xf2, 0x5c, /* st %r11, 0x25c(%r15) */
+ 0x50, 0xc0, 0xf2, 0x64, /* st %r12, 0x264(%r15) */
+ 0x50, 0xd0, 0xf2, 0x6c, /* st %r13, 0x26c(%r15) */
+ 0x50, 0xe0, 0xf2, 0x74, /* st %r14, 0x274(%r15) */
/* Compute original value of %r15 and store it. We use ahi instead
of la to preserve the whole value, and not just the low 31 bits.
This is not particularly important here, but essential in the
zarch case where someone might be using the high word of %r15
as an extra register. */
- 0x18, 0x1f, /* lr %r1, %r15 */
- 0xa7, 0x1a, 0x03, 0x00, /* ahi %r1, 0x300 */
- 0x50, 0x10, 0xf2, 0x7c, /* st %r1, 0x27c(%r15) */
+ 0x18, 0x1f, /* lr %r1, %r15 */
+ 0xa7, 0x1a, 0x03, 0x00, /* ahi %r1, 0x300 */
+ 0x50, 0x10, 0xf2, 0x7c, /* st %r1, 0x27c(%r15) */
};
/* Code sequence saving GPRs for 31-bit target with high GPRs and for 64-bit
@@ -884,74 +847,74 @@ static const unsigned char s390_ft_entry_gpr_esa[] = {
since the 64-bit regs are tightly packed. */
static const unsigned char s390_ft_entry_gpr_zarch[] = {
- 0xa7, 0x14, 0x00, 0x21, /* jo .Lcc3 */
- 0xa7, 0x24, 0x00, 0x16, /* jh .Lcc2 */
- 0xa7, 0x44, 0x00, 0x0b, /* jl .Lcc1 */
+ 0xa7, 0x14, 0x00, 0x21, /* jo .Lcc3 */
+ 0xa7, 0x24, 0x00, 0x16, /* jh .Lcc2 */
+ 0xa7, 0x44, 0x00, 0x0b, /* jl .Lcc1 */
/* CC = 0 */
- 0xa7, 0xfb, 0xfd, 0x00, /* aghi %r15, -0x300 */
- 0xeb, 0x0e, 0xf2, 0x00, 0x00, 0x24, /* stmg %r0, %r14, 0x200(%r15) */
- 0xa7, 0x08, 0x00, 0x00, /* lhi %r0, 0 */
- 0xa7, 0xf4, 0x00, 0x1b, /* j .Lccdone */
+ 0xa7, 0xfb, 0xfd, 0x00, /* aghi %r15, -0x300 */
+ 0xeb, 0x0e, 0xf2, 0x00, 0x00, 0x24, /* stmg %r0, %r14, 0x200(%r15) */
+ 0xa7, 0x08, 0x00, 0x00, /* lhi %r0, 0 */
+ 0xa7, 0xf4, 0x00, 0x1b, /* j .Lccdone */
/* .Lcc1: */
- 0xa7, 0xfb, 0xfd, 0x00, /* aghi %r15, -0x300 */
- 0xeb, 0x0e, 0xf2, 0x00, 0x00, 0x24, /* stmg %r0, %r14, 0x200(%r15) */
- 0xa7, 0x08, 0x10, 0x00, /* lhi %r0, 0x1000 */
- 0xa7, 0xf4, 0x00, 0x12, /* j .Lccdone */
+ 0xa7, 0xfb, 0xfd, 0x00, /* aghi %r15, -0x300 */
+ 0xeb, 0x0e, 0xf2, 0x00, 0x00, 0x24, /* stmg %r0, %r14, 0x200(%r15) */
+ 0xa7, 0x08, 0x10, 0x00, /* lhi %r0, 0x1000 */
+ 0xa7, 0xf4, 0x00, 0x12, /* j .Lccdone */
/* .Lcc2: */
- 0xa7, 0xfb, 0xfd, 0x00, /* aghi %r15, -0x300 */
- 0xeb, 0x0e, 0xf2, 0x00, 0x00, 0x24, /* stmg %r0, %r14, 0x200(%r15) */
- 0xa7, 0x08, 0x20, 0x00, /* lhi %r0, 0x2000 */
- 0xa7, 0xf4, 0x00, 0x09, /* j .Lccdone */
+ 0xa7, 0xfb, 0xfd, 0x00, /* aghi %r15, -0x300 */
+ 0xeb, 0x0e, 0xf2, 0x00, 0x00, 0x24, /* stmg %r0, %r14, 0x200(%r15) */
+ 0xa7, 0x08, 0x20, 0x00, /* lhi %r0, 0x2000 */
+ 0xa7, 0xf4, 0x00, 0x09, /* j .Lccdone */
/* .Lcc3: */
- 0xa7, 0xfb, 0xfd, 0x00, /* aghi %r15, -0x300 */
- 0xeb, 0x0e, 0xf2, 0x00, 0x00, 0x24, /* stmg %r0, %r14, 0x200(%r15) */
- 0xa7, 0x08, 0x30, 0x00, /* lhi %r0, 0x3000 */
+ 0xa7, 0xfb, 0xfd, 0x00, /* aghi %r15, -0x300 */
+ 0xeb, 0x0e, 0xf2, 0x00, 0x00, 0x24, /* stmg %r0, %r14, 0x200(%r15) */
+ 0xa7, 0x08, 0x30, 0x00, /* lhi %r0, 0x3000 */
/* .Lccdone: */
- 0xb9, 0x04, 0x00, 0x1f, /* lgr %r1, %r15 */
- 0xa7, 0x1b, 0x03, 0x00, /* aghi %r1, 0x300 */
- 0xe3, 0x10, 0xf2, 0x78, 0x00, 0x24, /* stg %r1, 0x278(%r15) */
+ 0xb9, 0x04, 0x00, 0x1f, /* lgr %r1, %r15 */
+ 0xa7, 0x1b, 0x03, 0x00, /* aghi %r1, 0x300 */
+ 0xe3, 0x10, 0xf2, 0x78, 0x00, 0x24, /* stg %r1, 0x278(%r15) */
};
/* Code sequence saving ARs, PSWM and FPC. PSWM has to be assembled from
current PSWM (read by epsw) and CC from entry (in %r0). */
static const unsigned char s390_ft_entry_misc[] = {
- 0x9b, 0x0f, 0xf2, 0x80, /* stam %a0, %a15, 0x20(%%r15) */
- 0xb9, 0x8d, 0x00, 0x23, /* epsw %r2, %r3 */
- 0xa7, 0x18, 0xcf, 0xff, /* lhi %r1, ~0x3000 */
- 0x14, 0x21, /* nr %r2, %r1 */
- 0x16, 0x20, /* or %r2, %r0 */
- 0x50, 0x20, 0xf2, 0xc0, /* st %r2, 0x2c0(%r15) */
- 0x50, 0x30, 0xf2, 0xc4, /* st %r3, 0x2c4(%r15) */
- 0xb2, 0x9c, 0xf2, 0xd0, /* stfpc 0x2d0(%r15) */
+ 0x9b, 0x0f, 0xf2, 0x80, /* stam %a0, %a15, 0x20(%%r15) */
+ 0xb9, 0x8d, 0x00, 0x23, /* epsw %r2, %r3 */
+ 0xa7, 0x18, 0xcf, 0xff, /* lhi %r1, ~0x3000 */
+ 0x14, 0x21, /* nr %r2, %r1 */
+ 0x16, 0x20, /* or %r2, %r0 */
+ 0x50, 0x20, 0xf2, 0xc0, /* st %r2, 0x2c0(%r15) */
+ 0x50, 0x30, 0xf2, 0xc4, /* st %r3, 0x2c4(%r15) */
+ 0xb2, 0x9c, 0xf2, 0xd0, /* stfpc 0x2d0(%r15) */
};
/* Code sequence saving FRs, used if VX not supported. */
static const unsigned char s390_ft_entry_fr[] = {
- 0x60, 0x00, 0xf0, 0x00, /* std %f0, 0x000(%r15) */
- 0x60, 0x10, 0xf0, 0x10, /* std %f1, 0x010(%r15) */
- 0x60, 0x20, 0xf0, 0x20, /* std %f2, 0x020(%r15) */
- 0x60, 0x30, 0xf0, 0x30, /* std %f3, 0x030(%r15) */
- 0x60, 0x40, 0xf0, 0x40, /* std %f4, 0x040(%r15) */
- 0x60, 0x50, 0xf0, 0x50, /* std %f5, 0x050(%r15) */
- 0x60, 0x60, 0xf0, 0x60, /* std %f6, 0x060(%r15) */
- 0x60, 0x70, 0xf0, 0x70, /* std %f7, 0x070(%r15) */
- 0x60, 0x80, 0xf0, 0x80, /* std %f8, 0x080(%r15) */
- 0x60, 0x90, 0xf0, 0x90, /* std %f9, 0x090(%r15) */
- 0x60, 0xa0, 0xf0, 0xa0, /* std %f10, 0x0a0(%r15) */
- 0x60, 0xb0, 0xf0, 0xb0, /* std %f11, 0x0b0(%r15) */
- 0x60, 0xc0, 0xf0, 0xc0, /* std %f12, 0x0c0(%r15) */
- 0x60, 0xd0, 0xf0, 0xd0, /* std %f13, 0x0d0(%r15) */
- 0x60, 0xe0, 0xf0, 0xe0, /* std %f14, 0x0e0(%r15) */
- 0x60, 0xf0, 0xf0, 0xf0, /* std %f15, 0x0f0(%r15) */
+ 0x60, 0x00, 0xf0, 0x00, /* std %f0, 0x000(%r15) */
+ 0x60, 0x10, 0xf0, 0x10, /* std %f1, 0x010(%r15) */
+ 0x60, 0x20, 0xf0, 0x20, /* std %f2, 0x020(%r15) */
+ 0x60, 0x30, 0xf0, 0x30, /* std %f3, 0x030(%r15) */
+ 0x60, 0x40, 0xf0, 0x40, /* std %f4, 0x040(%r15) */
+ 0x60, 0x50, 0xf0, 0x50, /* std %f5, 0x050(%r15) */
+ 0x60, 0x60, 0xf0, 0x60, /* std %f6, 0x060(%r15) */
+ 0x60, 0x70, 0xf0, 0x70, /* std %f7, 0x070(%r15) */
+ 0x60, 0x80, 0xf0, 0x80, /* std %f8, 0x080(%r15) */
+ 0x60, 0x90, 0xf0, 0x90, /* std %f9, 0x090(%r15) */
+ 0x60, 0xa0, 0xf0, 0xa0, /* std %f10, 0x0a0(%r15) */
+ 0x60, 0xb0, 0xf0, 0xb0, /* std %f11, 0x0b0(%r15) */
+ 0x60, 0xc0, 0xf0, 0xc0, /* std %f12, 0x0c0(%r15) */
+ 0x60, 0xd0, 0xf0, 0xd0, /* std %f13, 0x0d0(%r15) */
+ 0x60, 0xe0, 0xf0, 0xe0, /* std %f14, 0x0e0(%r15) */
+ 0x60, 0xf0, 0xf0, 0xf0, /* std %f15, 0x0f0(%r15) */
};
/* Code sequence saving VRs, used if VX not supported. */
static const unsigned char s390_ft_entry_vr[] = {
- 0xe7, 0x0f, 0xf0, 0x00, 0x00, 0x3e, /* vstm %v0, %v15, 0x000(%r15) */
- 0xe7, 0x0f, 0xf1, 0x00, 0x0c, 0x3e, /* vstm %v16, %v31, 0x100(%r15) */
+ 0xe7, 0x0f, 0xf0, 0x00, 0x00, 0x3e, /* vstm %v0, %v15, 0x000(%r15) */
+ 0xe7, 0x0f, 0xf1, 0x00, 0x0c, 0x3e, /* vstm %v16, %v31, 0x100(%r15) */
};
/* Code sequence doing the collection call for 31-bit target. %r1 contains
@@ -959,34 +922,34 @@ static const unsigned char s390_ft_entry_vr[] = {
static const unsigned char s390_ft_main_31[] = {
/* Load the literals into registers. */
- 0x58, 0x50, 0x10, 0x00, /* l %r5, 0x0(%r1) */
- 0x58, 0x20, 0x10, 0x04, /* l %r2, 0x4(%r1) */
- 0x58, 0x40, 0x10, 0x08, /* l %r4, 0x8(%r1) */
- 0x58, 0x60, 0x10, 0x0c, /* l %r6, 0xc(%r1) */
+ 0x58, 0x50, 0x10, 0x00, /* l %r5, 0x0(%r1) */
+ 0x58, 0x20, 0x10, 0x04, /* l %r2, 0x4(%r1) */
+ 0x58, 0x40, 0x10, 0x08, /* l %r4, 0x8(%r1) */
+ 0x58, 0x60, 0x10, 0x0c, /* l %r6, 0xc(%r1) */
/* Save original PSWA (tracepoint address | 0x80000000). */
- 0x50, 0x50, 0xf2, 0xcc, /* st %r5, 0x2cc(%r15) */
+ 0x50, 0x50, 0xf2, 0xcc, /* st %r5, 0x2cc(%r15) */
/* Construct a collecting_t object at %r15+0x2e0. */
- 0x50, 0x20, 0xf2, 0xe0, /* st %r2, 0x2e0(%r15) */
- 0x9b, 0x00, 0xf2, 0xe4, /* stam %a0, %a0, 0x2e4(%r15) */
+ 0x50, 0x20, 0xf2, 0xe0, /* st %r2, 0x2e0(%r15) */
+ 0x9b, 0x00, 0xf2, 0xe4, /* stam %a0, %a0, 0x2e4(%r15) */
/* Move its address to %r0. */
- 0x41, 0x00, 0xf2, 0xe0, /* la %r0, 0x2e0(%r15) */
+ 0x41, 0x00, 0xf2, 0xe0, /* la %r0, 0x2e0(%r15) */
/* Take the lock. */
/* .Lloop: */
- 0xa7, 0x18, 0x00, 0x00, /* lhi %r1, 0 */
- 0xba, 0x10, 0x60, 0x00, /* cs %r1, %r0, 0(%r6) */
- 0xa7, 0x74, 0xff, 0xfc, /* jne .Lloop */
+ 0xa7, 0x18, 0x00, 0x00, /* lhi %r1, 0 */
+ 0xba, 0x10, 0x60, 0x00, /* cs %r1, %r0, 0(%r6) */
+ 0xa7, 0x74, 0xff, 0xfc, /* jne .Lloop */
/* Address of the register save block to %r3. */
- 0x18, 0x3f, /* lr %r3, %r15 */
+ 0x18, 0x3f, /* lr %r3, %r15 */
/* Make a stack frame, so that we can call the collector. */
- 0xa7, 0xfa, 0xff, 0xa0, /* ahi %r15, -0x60 */
+ 0xa7, 0xfa, 0xff, 0xa0, /* ahi %r15, -0x60 */
/* Call it. */
- 0x0d, 0xe4, /* basr %r14, %r4 */
+ 0x0d, 0xe4, /* basr %r14, %r4 */
/* And get rid of the stack frame again. */
- 0x41, 0xf0, 0xf0, 0x60, /* la %r15, 0x60(%r15) */
+ 0x41, 0xf0, 0xf0, 0x60, /* la %r15, 0x60(%r15) */
/* Leave the lock. */
- 0x07, 0xf0, /* br %r0 */
- 0xa7, 0x18, 0x00, 0x00, /* lhi %r1, 0 */
- 0x50, 0x10, 0x60, 0x00, /* st %t1, 0(%r6) */
+ 0x07, 0xf0, /* br %r0 */
+ 0xa7, 0x18, 0x00, 0x00, /* lhi %r1, 0 */
+ 0x50, 0x10, 0x60, 0x00, /* st %t1, 0(%r6) */
};
/* Code sequence doing the collection call for 64-bit target. %r1 contains
@@ -994,62 +957,62 @@ static const unsigned char s390_ft_main_31[] = {
static const unsigned char s390_ft_main_64[] = {
/* Load the literals into registers. */
- 0xe3, 0x50, 0x10, 0x00, 0x00, 0x04, /* lg %r5, 0x00(%r1) */
- 0xe3, 0x20, 0x10, 0x08, 0x00, 0x04, /* lg %r2, 0x08(%r1) */
- 0xe3, 0x40, 0x10, 0x10, 0x00, 0x04, /* lg %r4, 0x10(%r1) */
- 0xe3, 0x60, 0x10, 0x18, 0x00, 0x04, /* lg %r6, 0x18(%r1) */
+ 0xe3, 0x50, 0x10, 0x00, 0x00, 0x04, /* lg %r5, 0x00(%r1) */
+ 0xe3, 0x20, 0x10, 0x08, 0x00, 0x04, /* lg %r2, 0x08(%r1) */
+ 0xe3, 0x40, 0x10, 0x10, 0x00, 0x04, /* lg %r4, 0x10(%r1) */
+ 0xe3, 0x60, 0x10, 0x18, 0x00, 0x04, /* lg %r6, 0x18(%r1) */
/* Save original PSWA (tracepoint address). */
- 0xe3, 0x50, 0xf2, 0xc8, 0x00, 0x24, /* stg %r5, 0x2c8(%r15) */
+ 0xe3, 0x50, 0xf2, 0xc8, 0x00, 0x24, /* stg %r5, 0x2c8(%r15) */
/* Construct a collecting_t object at %r15+0x2e0. */
- 0xe3, 0x20, 0xf2, 0xe0, 0x00, 0x24, /* stg %r2, 0x2e0(%r15) */
- 0x9b, 0x01, 0xf2, 0xe8, /* stam %a0, %a1, 0x2e8(%r15) */
+ 0xe3, 0x20, 0xf2, 0xe0, 0x00, 0x24, /* stg %r2, 0x2e0(%r15) */
+ 0x9b, 0x01, 0xf2, 0xe8, /* stam %a0, %a1, 0x2e8(%r15) */
/* Move its address to %r0. */
- 0x41, 0x00, 0xf2, 0xe0, /* la %r0, 0x2e0(%r15) */
+ 0x41, 0x00, 0xf2, 0xe0, /* la %r0, 0x2e0(%r15) */
/* Take the lock. */
/* .Lloop: */
- 0xa7, 0x19, 0x00, 0x00, /* lghi %r1, 0 */
- 0xeb, 0x10, 0x60, 0x00, 0x00, 0x30, /* csg %r1, %r0, 0(%r6) */
- 0xa7, 0x74, 0xff, 0xfb, /* jne .Lloop */
+ 0xa7, 0x19, 0x00, 0x00, /* lghi %r1, 0 */
+ 0xeb, 0x10, 0x60, 0x00, 0x00, 0x30, /* csg %r1, %r0, 0(%r6) */
+ 0xa7, 0x74, 0xff, 0xfb, /* jne .Lloop */
/* Address of the register save block to %r3. */
- 0xb9, 0x04, 0x00, 0x3f, /* lgr %r3, %r15 */
+ 0xb9, 0x04, 0x00, 0x3f, /* lgr %r3, %r15 */
/* Make a stack frame, so that we can call the collector. */
- 0xa7, 0xfb, 0xff, 0x60, /* aghi %r15, -0xa0 */
+ 0xa7, 0xfb, 0xff, 0x60, /* aghi %r15, -0xa0 */
/* Call it. */
- 0x0d, 0xe4, /* basr %r14, %r4 */
+ 0x0d, 0xe4, /* basr %r14, %r4 */
/* And get rid of the stack frame again. */
- 0x41, 0xf0, 0xf0, 0xa0, /* la %r15, 0xa0(%r15) */
+ 0x41, 0xf0, 0xf0, 0xa0, /* la %r15, 0xa0(%r15) */
/* Leave the lock. */
- 0x07, 0xf0, /* br %r0 */
- 0xa7, 0x19, 0x00, 0x00, /* lghi %r1, 0 */
- 0xe3, 0x10, 0x60, 0x00, 0x00, 0x24, /* stg %t1, 0(%r6) */
+ 0x07, 0xf0, /* br %r0 */
+ 0xa7, 0x19, 0x00, 0x00, /* lghi %r1, 0 */
+ 0xe3, 0x10, 0x60, 0x00, 0x00, 0x24, /* stg %t1, 0(%r6) */
};
/* Code sequence restoring FRs, for targets with no VX support. */
static const unsigned char s390_ft_exit_fr[] = {
- 0x68, 0x00, 0xf0, 0x00, /* ld %f0, 0x000(%r15) */
- 0x68, 0x10, 0xf0, 0x10, /* ld %f1, 0x010(%r15) */
- 0x68, 0x20, 0xf0, 0x20, /* ld %f2, 0x020(%r15) */
- 0x68, 0x30, 0xf0, 0x30, /* ld %f3, 0x030(%r15) */
- 0x68, 0x40, 0xf0, 0x40, /* ld %f4, 0x040(%r15) */
- 0x68, 0x50, 0xf0, 0x50, /* ld %f5, 0x050(%r15) */
- 0x68, 0x60, 0xf0, 0x60, /* ld %f6, 0x060(%r15) */
- 0x68, 0x70, 0xf0, 0x70, /* ld %f7, 0x070(%r15) */
- 0x68, 0x80, 0xf0, 0x80, /* ld %f8, 0x080(%r15) */
- 0x68, 0x90, 0xf0, 0x90, /* ld %f9, 0x090(%r15) */
- 0x68, 0xa0, 0xf0, 0xa0, /* ld %f10, 0x0a0(%r15) */
- 0x68, 0xb0, 0xf0, 0xb0, /* ld %f11, 0x0b0(%r15) */
- 0x68, 0xc0, 0xf0, 0xc0, /* ld %f12, 0x0c0(%r15) */
- 0x68, 0xd0, 0xf0, 0xd0, /* ld %f13, 0x0d0(%r15) */
- 0x68, 0xe0, 0xf0, 0xe0, /* ld %f14, 0x0e0(%r15) */
- 0x68, 0xf0, 0xf0, 0xf0, /* ld %f15, 0x0f0(%r15) */
+ 0x68, 0x00, 0xf0, 0x00, /* ld %f0, 0x000(%r15) */
+ 0x68, 0x10, 0xf0, 0x10, /* ld %f1, 0x010(%r15) */
+ 0x68, 0x20, 0xf0, 0x20, /* ld %f2, 0x020(%r15) */
+ 0x68, 0x30, 0xf0, 0x30, /* ld %f3, 0x030(%r15) */
+ 0x68, 0x40, 0xf0, 0x40, /* ld %f4, 0x040(%r15) */
+ 0x68, 0x50, 0xf0, 0x50, /* ld %f5, 0x050(%r15) */
+ 0x68, 0x60, 0xf0, 0x60, /* ld %f6, 0x060(%r15) */
+ 0x68, 0x70, 0xf0, 0x70, /* ld %f7, 0x070(%r15) */
+ 0x68, 0x80, 0xf0, 0x80, /* ld %f8, 0x080(%r15) */
+ 0x68, 0x90, 0xf0, 0x90, /* ld %f9, 0x090(%r15) */
+ 0x68, 0xa0, 0xf0, 0xa0, /* ld %f10, 0x0a0(%r15) */
+ 0x68, 0xb0, 0xf0, 0xb0, /* ld %f11, 0x0b0(%r15) */
+ 0x68, 0xc0, 0xf0, 0xc0, /* ld %f12, 0x0c0(%r15) */
+ 0x68, 0xd0, 0xf0, 0xd0, /* ld %f13, 0x0d0(%r15) */
+ 0x68, 0xe0, 0xf0, 0xe0, /* ld %f14, 0x0e0(%r15) */
+ 0x68, 0xf0, 0xf0, 0xf0, /* ld %f15, 0x0f0(%r15) */
};
/* Code sequence restoring VRs. */
static const unsigned char s390_ft_exit_vr[] = {
- 0xe7, 0x0f, 0xf0, 0x00, 0x00, 0x36, /* vlm %v0, %v15, 0x000(%r15) */
- 0xe7, 0x0f, 0xf1, 0x00, 0x0c, 0x36, /* vlm %v16, %v31, 0x100(%r15) */
+ 0xe7, 0x0f, 0xf0, 0x00, 0x00, 0x36, /* vlm %v0, %v15, 0x000(%r15) */
+ 0xe7, 0x0f, 0xf1, 0x00, 0x0c, 0x36, /* vlm %v16, %v31, 0x100(%r15) */
};
/* Code sequence restoring misc registers. As for PSWM, only CC should be
@@ -1057,44 +1020,44 @@ static const unsigned char s390_ft_exit_vr[] = {
manufacturing an operand that'll result in the original flags. */
static const unsigned char s390_ft_exit_misc[] = {
- 0xb2, 0x9d, 0xf2, 0xd0, /* lfpc 0x2d0(%r15) */
- 0x58, 0x00, 0xf2, 0xc0, /* l %r0, 0x2c0(%r15) */
+ 0xb2, 0x9d, 0xf2, 0xd0, /* lfpc 0x2d0(%r15) */
+ 0x58, 0x00, 0xf2, 0xc0, /* l %r0, 0x2c0(%r15) */
/* Extract CC to high 2 bits of %r0. */
- 0x88, 0x00, 0x00, 0x0c, /* srl %r0, 12 */
- 0x89, 0x00, 0x00, 0x1e, /* sll %r0, 30 */
+ 0x88, 0x00, 0x00, 0x0c, /* srl %r0, 12 */
+ 0x89, 0x00, 0x00, 0x1e, /* sll %r0, 30 */
/* Add %r0 to itself. Result will be nonzero iff CC bit 0 is set, and
will have carry iff CC bit 1 is set - resulting in the same flags
as the original. */
- 0x1e, 0x00, /* alr %r0, %r0 */
- 0x9a, 0x0f, 0xf2, 0x80, /* lam %a0, %a15, 0x280(%r15) */
+ 0x1e, 0x00, /* alr %r0, %r0 */
+ 0x9a, 0x0f, 0xf2, 0x80, /* lam %a0, %a15, 0x280(%r15) */
};
/* Code sequence restoring GPRs, for 31-bit targets with no high GPRs. */
static const unsigned char s390_ft_exit_gpr_esa[] = {
- 0x58, 0x00, 0xf2, 0x04, /* l %r0, 0x204(%r15) */
- 0x58, 0x10, 0xf2, 0x0c, /* l %r1, 0x20c(%r15) */
- 0x58, 0x20, 0xf2, 0x14, /* l %r2, 0x214(%r15) */
- 0x58, 0x30, 0xf2, 0x1c, /* l %r3, 0x21c(%r15) */
- 0x58, 0x40, 0xf2, 0x24, /* l %r4, 0x224(%r15) */
- 0x58, 0x50, 0xf2, 0x2c, /* l %r5, 0x22c(%r15) */
- 0x58, 0x60, 0xf2, 0x34, /* l %r6, 0x234(%r15) */
- 0x58, 0x70, 0xf2, 0x3c, /* l %r7, 0x23c(%r15) */
- 0x58, 0x80, 0xf2, 0x44, /* l %r8, 0x244(%r15) */
- 0x58, 0x90, 0xf2, 0x4c, /* l %r9, 0x24c(%r15) */
- 0x58, 0xa0, 0xf2, 0x54, /* l %r10, 0x254(%r15) */
- 0x58, 0xb0, 0xf2, 0x5c, /* l %r11, 0x25c(%r15) */
- 0x58, 0xc0, 0xf2, 0x64, /* l %r12, 0x264(%r15) */
- 0x58, 0xd0, 0xf2, 0x6c, /* l %r13, 0x26c(%r15) */
- 0x58, 0xe0, 0xf2, 0x74, /* l %r14, 0x274(%r15) */
- 0x58, 0xf0, 0xf2, 0x7c, /* l %r15, 0x27c(%r15) */
+ 0x58, 0x00, 0xf2, 0x04, /* l %r0, 0x204(%r15) */
+ 0x58, 0x10, 0xf2, 0x0c, /* l %r1, 0x20c(%r15) */
+ 0x58, 0x20, 0xf2, 0x14, /* l %r2, 0x214(%r15) */
+ 0x58, 0x30, 0xf2, 0x1c, /* l %r3, 0x21c(%r15) */
+ 0x58, 0x40, 0xf2, 0x24, /* l %r4, 0x224(%r15) */
+ 0x58, 0x50, 0xf2, 0x2c, /* l %r5, 0x22c(%r15) */
+ 0x58, 0x60, 0xf2, 0x34, /* l %r6, 0x234(%r15) */
+ 0x58, 0x70, 0xf2, 0x3c, /* l %r7, 0x23c(%r15) */
+ 0x58, 0x80, 0xf2, 0x44, /* l %r8, 0x244(%r15) */
+ 0x58, 0x90, 0xf2, 0x4c, /* l %r9, 0x24c(%r15) */
+ 0x58, 0xa0, 0xf2, 0x54, /* l %r10, 0x254(%r15) */
+ 0x58, 0xb0, 0xf2, 0x5c, /* l %r11, 0x25c(%r15) */
+ 0x58, 0xc0, 0xf2, 0x64, /* l %r12, 0x264(%r15) */
+ 0x58, 0xd0, 0xf2, 0x6c, /* l %r13, 0x26c(%r15) */
+ 0x58, 0xe0, 0xf2, 0x74, /* l %r14, 0x274(%r15) */
+ 0x58, 0xf0, 0xf2, 0x7c, /* l %r15, 0x27c(%r15) */
};
/* Code sequence restoring GPRs, for 64-bit targets and 31-bit targets
with high GPRs. */
static const unsigned char s390_ft_exit_gpr_zarch[] = {
- 0xeb, 0x0f, 0xf2, 0x00, 0x00, 0x04, /* lmg %r0, %r15, 0x200(%r15) */
+ 0xeb, 0x0f, 0xf2, 0x00, 0x00, 0x04, /* lmg %r0, %r15, 0x200(%r15) */
};
/* Writes instructions to target, updating the to pointer. */
@@ -1142,19 +1105,19 @@ s390_relocate_instruction (CORE_ADDR *to, CORE_ADDR oldloc, int is_64)
op2 = buf[1] & 0xf;
/* BRC, BRAS, BRCT, BRCTG */
if (op2 >= 4 && op2 <= 7)
- mode = 1;
+ mode = 1;
/* BRAS */
if (op2 == 5)
- is_bras = 1;
+ is_bras = 1;
break;
case 0xc0:
op2 = buf[1] & 0xf;
/* LARL, BRCL, BRASL */
if (op2 == 0 || op2 == 4 || op2 == 5)
- mode = 2;
+ mode = 2;
/* BRASL */
if (op2 == 5)
- is_bras = 1;
+ is_bras = 1;
break;
case 0xc4:
case 0xc6:
@@ -1169,21 +1132,21 @@ s390_relocate_instruction (CORE_ADDR *to, CORE_ADDR oldloc, int is_64)
op2 = buf[1] & 0xf;
/* BRCTH */
if (op2 == 6)
- mode = 2;
+ mode = 2;
break;
case 0xec:
op2 = buf[5];
switch (op2)
- {
- case 0x44: /* BRXHG */
- case 0x45: /* BRXLG */
- case 0x64: /* CGRJ */
- case 0x65: /* CLGRJ */
- case 0x76: /* CRJ */
- case 0x77: /* CLRJ */
- mode = 1;
- break;
- }
+ {
+ case 0x44: /* BRXHG */
+ case 0x45: /* BRXLG */
+ case 0x64: /* CGRJ */
+ case 0x65: /* CLGRJ */
+ case 0x76: /* CRJ */
+ case 0x77: /* CLRJ */
+ mode = 1;
+ break;
+ }
break;
}
@@ -1194,70 +1157,70 @@ s390_relocate_instruction (CORE_ADDR *to, CORE_ADDR oldloc, int is_64)
int64_t loffset = 0;
CORE_ADDR target;
if (mode == 1)
- {
- int16_t soffset = 0;
- memcpy (&soffset, buf + 2, 2);
- loffset = soffset;
- }
+ {
+ int16_t soffset = 0;
+ memcpy (&soffset, buf + 2, 2);
+ loffset = soffset;
+ }
else if (mode == 2)
- {
- int32_t soffset = 0;
- memcpy (&soffset, buf + 2, 4);
- loffset = soffset;
- }
+ {
+ int32_t soffset = 0;
+ memcpy (&soffset, buf + 2, 4);
+ loffset = soffset;
+ }
target = oldloc + loffset * 2;
if (!is_64)
- target &= 0x7fffffff;
+ target &= 0x7fffffff;
if (is_bras)
- {
- /* BRAS or BRASL was used. We cannot just relocate those, since
+ {
+ /* BRAS or BRASL was used. We cannot just relocate those, since
they save the return address in a register. We can, however,
replace them with a LARL+JG sequence. */
- /* Make the LARL. */
- int32_t soffset;
- buf[0] = 0xc0;
- buf[1] &= 0xf0;
- loffset = oldloc + ilen - *to;
- loffset >>= 1;
- soffset = loffset;
- if (soffset != loffset && is_64)
- return 1;
- memcpy (buf + 2, &soffset, 4);
- append_insns (to, 6, buf);
-
- /* Note: this is not fully correct. In 31-bit mode, LARL will write
+ /* Make the LARL. */
+ int32_t soffset;
+ buf[0] = 0xc0;
+ buf[1] &= 0xf0;
+ loffset = oldloc + ilen - *to;
+ loffset >>= 1;
+ soffset = loffset;
+ if (soffset != loffset && is_64)
+ return 1;
+ memcpy (buf + 2, &soffset, 4);
+ append_insns (to, 6, buf);
+
+ /* Note: this is not fully correct. In 31-bit mode, LARL will write
an address with the top bit 0, while BRAS/BRASL will write it
with top bit 1. It should not matter much, since linux compilers
use BR and not BSM to return from functions, but it could confuse
some poor stack unwinder. */
- /* We'll now be writing a JG. */
- mode = 2;
- buf[0] = 0xc0;
- buf[1] = 0xf4;
- ilen = 6;
- }
+ /* We'll now be writing a JG. */
+ mode = 2;
+ buf[0] = 0xc0;
+ buf[1] = 0xf4;
+ ilen = 6;
+ }
/* Compute the new offset and write it to the buffer. */
loffset = target - *to;
loffset >>= 1;
if (mode == 1)
- {
- int16_t soffset = loffset;
- if (soffset != loffset)
- return 1;
- memcpy (buf + 2, &soffset, 2);
- }
+ {
+ int16_t soffset = loffset;
+ if (soffset != loffset)
+ return 1;
+ memcpy (buf + 2, &soffset, 2);
+ }
else if (mode == 2)
- {
- int32_t soffset = loffset;
- if (soffset != loffset && is_64)
- return 1;
- memcpy (buf + 2, &soffset, 4);
- }
+ {
+ int32_t soffset = loffset;
+ if (soffset != loffset && is_64)
+ return 1;
+ memcpy (buf + 2, &soffset, 4);
+ }
}
append_insns (to, ilen, buf);
return 0;
@@ -1273,18 +1236,17 @@ s390_target::supports_fast_tracepoints ()
"install_fast_tracepoint_jump_pad". */
int
-s390_target::install_fast_tracepoint_jump_pad
- (CORE_ADDR tpoint, CORE_ADDR tpaddr, CORE_ADDR collector,
- CORE_ADDR lockaddr, ULONGEST orig_size, CORE_ADDR *jump_entry,
- CORE_ADDR *trampoline, ULONGEST *trampoline_size,
- unsigned char *jjump_pad_insn, ULONGEST *jjump_pad_insn_size,
- CORE_ADDR *adjusted_insn_addr, CORE_ADDR *adjusted_insn_addr_end,
- char *err)
+s390_target::install_fast_tracepoint_jump_pad (
+ CORE_ADDR tpoint, CORE_ADDR tpaddr, CORE_ADDR collector, CORE_ADDR lockaddr,
+ ULONGEST orig_size, CORE_ADDR *jump_entry, CORE_ADDR *trampoline,
+ ULONGEST *trampoline_size, unsigned char *jjump_pad_insn,
+ ULONGEST *jjump_pad_insn_size, CORE_ADDR *adjusted_insn_addr,
+ CORE_ADDR *adjusted_insn_addr_end, char *err)
{
int i;
int64_t loffset;
int32_t offset;
- unsigned char jbuf[6] = { 0xc0, 0xf4, 0, 0, 0, 0 }; /* jg ... */
+ unsigned char jbuf[6] = { 0xc0, 0xf4, 0, 0, 0, 0 }; /* jg ... */
CORE_ADDR buildaddr = *jump_entry;
#ifdef __s390x__
struct regcache *regcache = get_thread_regcache (current_thread, 0);
@@ -1304,10 +1266,10 @@ s390_target::install_fast_tracepoint_jump_pad
/* First, store the GPRs. */
if (is_zarch)
append_insns (&buildaddr, sizeof s390_ft_entry_gpr_zarch,
- s390_ft_entry_gpr_zarch);
+ s390_ft_entry_gpr_zarch);
else
append_insns (&buildaddr, sizeof s390_ft_entry_gpr_esa,
- s390_ft_entry_gpr_esa);
+ s390_ft_entry_gpr_esa);
/* Second, misc registers (ARs, PSWM, FPC). PSWA will be stored below. */
append_insns (&buildaddr, sizeof s390_ft_entry_misc, s390_ft_entry_misc);
@@ -1320,52 +1282,57 @@ s390_target::install_fast_tracepoint_jump_pad
/* Now, the main part of code - store PSWA, take lock, call collector,
leave lock. First, we'll need to fetch 4 literals. */
- if (is_64) {
- unsigned char buf[] = {
- 0x07, 0x07, /* nopr %r7 */
- 0x07, 0x07, /* nopr %r7 */
- 0x07, 0x07, /* nopr %r7 */
- 0xa7, 0x15, 0x00, 0x12, /* bras %r1, .Lend */
- 0, 0, 0, 0, 0, 0, 0, 0, /* tpaddr */
- 0, 0, 0, 0, 0, 0, 0, 0, /* tpoint */
- 0, 0, 0, 0, 0, 0, 0, 0, /* collector */
- 0, 0, 0, 0, 0, 0, 0, 0, /* lockaddr */
- /* .Lend: */
- };
- /* Find the proper start place in buf, so that literals will be
+ if (is_64)
+ {
+ unsigned char buf[] = {
+ 0x07, 0x07, /* nopr %r7 */
+ 0x07, 0x07, /* nopr %r7 */
+ 0x07, 0x07, /* nopr %r7 */
+ 0xa7, 0x15, 0x00, 0x12, /* bras %r1, .Lend */
+ 0, 0, 0, 0, 0, 0, 0, 0, /* tpaddr */
+ 0, 0, 0, 0, 0, 0, 0, 0, /* tpoint */
+ 0, 0, 0, 0, 0, 0, 0, 0, /* collector */
+ 0, 0, 0, 0, 0, 0, 0, 0, /* lockaddr */
+ /* .Lend: */
+ };
+ /* Find the proper start place in buf, so that literals will be
aligned. */
- int bufpos = (buildaddr + 2) & 7;
- /* Stuff the literals into the buffer. */
- for (i = 0; i < 4; i++) {
- uint64_t lit = literals[i];
- memcpy (&buf[sizeof buf - 32 + i * 8], &lit, 8);
+ int bufpos = (buildaddr + 2) & 7;
+ /* Stuff the literals into the buffer. */
+ for (i = 0; i < 4; i++)
+ {
+ uint64_t lit = literals[i];
+ memcpy (&buf[sizeof buf - 32 + i * 8], &lit, 8);
+ }
+ append_insns (&buildaddr, sizeof buf - bufpos, buf + bufpos);
+ append_insns (&buildaddr, sizeof s390_ft_main_64, s390_ft_main_64);
}
- append_insns (&buildaddr, sizeof buf - bufpos, buf + bufpos);
- append_insns (&buildaddr, sizeof s390_ft_main_64, s390_ft_main_64);
- } else {
- unsigned char buf[] = {
- 0x07, 0x07, /* nopr %r7 */
- 0xa7, 0x15, 0x00, 0x0a, /* bras %r1, .Lend */
- 0, 0, 0, 0, /* tpaddr */
- 0, 0, 0, 0, /* tpoint */
- 0, 0, 0, 0, /* collector */
- 0, 0, 0, 0, /* lockaddr */
- /* .Lend: */
- };
- /* Find the proper start place in buf, so that literals will be
+ else
+ {
+ unsigned char buf[] = {
+ 0x07, 0x07, /* nopr %r7 */
+ 0xa7, 0x15, 0x00, 0x0a, /* bras %r1, .Lend */
+ 0, 0, 0, 0, /* tpaddr */
+ 0, 0, 0, 0, /* tpoint */
+ 0, 0, 0, 0, /* collector */
+ 0, 0, 0, 0, /* lockaddr */
+ /* .Lend: */
+ };
+ /* Find the proper start place in buf, so that literals will be
aligned. */
- int bufpos = (buildaddr + 2) & 3;
- /* First literal will be saved as the PSWA, make sure it has the high bit
+ int bufpos = (buildaddr + 2) & 3;
+ /* First literal will be saved as the PSWA, make sure it has the high bit
set. */
- literals[0] |= 0x80000000;
- /* Stuff the literals into the buffer. */
- for (i = 0; i < 4; i++) {
- uint32_t lit = literals[i];
- memcpy (&buf[sizeof buf - 16 + i * 4], &lit, 4);
+ literals[0] |= 0x80000000;
+ /* Stuff the literals into the buffer. */
+ for (i = 0; i < 4; i++)
+ {
+ uint32_t lit = literals[i];
+ memcpy (&buf[sizeof buf - 16 + i * 4], &lit, 4);
+ }
+ append_insns (&buildaddr, sizeof buf - bufpos, buf + bufpos);
+ append_insns (&buildaddr, sizeof s390_ft_main_31, s390_ft_main_31);
}
- append_insns (&buildaddr, sizeof buf - bufpos, buf + bufpos);
- append_insns (&buildaddr, sizeof s390_ft_main_31, s390_ft_main_31);
- }
/* Restore FRs or VRs. */
if (has_vx)
@@ -1379,10 +1346,10 @@ s390_target::install_fast_tracepoint_jump_pad
/* Restore the GPRs. */
if (is_zarch)
append_insns (&buildaddr, sizeof s390_ft_exit_gpr_zarch,
- s390_ft_exit_gpr_zarch);
+ s390_ft_exit_gpr_zarch);
else
append_insns (&buildaddr, sizeof s390_ft_exit_gpr_esa,
- s390_ft_exit_gpr_esa);
+ s390_ft_exit_gpr_esa);
/* Now, adjust the original instruction to execute in the jump
pad. */
@@ -1402,8 +1369,9 @@ s390_target::install_fast_tracepoint_jump_pad
if (is_64 && offset != loffset)
{
sprintf (err,
- "E.Jump back from jump pad too far from tracepoint "
- "(offset 0x%" PRIx64 " > int33).", loffset);
+ "E.Jump back from jump pad too far from tracepoint "
+ "(offset 0x%" PRIx64 " > int33).",
+ loffset);
return 1;
}
memcpy (jbuf + 2, &offset, 4);
@@ -1419,8 +1387,9 @@ s390_target::install_fast_tracepoint_jump_pad
if (is_64 && offset != loffset)
{
sprintf (err,
- "E.Jump back from jump pad too far from tracepoint "
- "(offset 0x%" PRIx64 " > int33).", loffset);
+ "E.Jump back from jump pad too far from tracepoint "
+ "(offset 0x%" PRIx64 " > int33).",
+ loffset);
return 1;
}
memcpy (jbuf + 2, &offset, 4);
@@ -1503,8 +1472,8 @@ add_insns (const unsigned char *start, int len)
{
CORE_ADDR buildaddr = current_insn_ptr;
- threads_debug_printf ("Adding %d bytes of insn at %s",
- len, paddress (buildaddr));
+ threads_debug_printf ("Adding %d bytes of insn at %s", len,
+ paddress (buildaddr));
append_insns (&buildaddr, len, start);
current_insn_ptr = buildaddr;
@@ -1533,10 +1502,10 @@ static void
s390_emit_prologue (void)
{
static const unsigned char buf[] = {
- 0x90, 0x9f, 0xf0, 0x24, /* stm %r9, %r15, 0x24(%r15) */
- 0x18, 0x92, /* lr %r9, %r2 */
- 0x18, 0xa3, /* lr %r10, %r3 */
- 0x18, 0xbf, /* lr %r11, %r15 */
+ 0x90, 0x9f, 0xf0, 0x24, /* stm %r9, %r15, 0x24(%r15) */
+ 0x18, 0x92, /* lr %r9, %r2 */
+ 0x18, 0xa3, /* lr %r10, %r3 */
+ 0x18, 0xbf, /* lr %r11, %r15 */
};
add_insns (buf, sizeof buf);
}
@@ -1547,10 +1516,10 @@ static void
s390_emit_epilogue (void)
{
static const unsigned char buf[] = {
- 0x90, 0x23, 0xa0, 0x00, /* stm %r2, %r3, 0(%r10) */
- 0xa7, 0x28, 0x00, 0x00, /* lhi %r2, 0 */
- 0x98, 0x9f, 0xb0, 0x24, /* lm %r9, %r15, 0x24(%r11) */
- 0x07, 0xfe, /* br %r14 */
+ 0x90, 0x23, 0xa0, 0x00, /* stm %r2, %r3, 0(%r10) */
+ 0xa7, 0x28, 0x00, 0x00, /* lhi %r2, 0 */
+ 0x98, 0x9f, 0xb0, 0x24, /* lm %r9, %r15, 0x24(%r11) */
+ 0x07, 0xfe, /* br %r14 */
};
add_insns (buf, sizeof buf);
}
@@ -1561,9 +1530,9 @@ static void
s390_emit_add (void)
{
static const unsigned char buf[] = {
- 0x5e, 0x30, 0xf0, 0x04, /* al %r3, 4(%r15) */
- 0xe3, 0x20, 0xf0, 0x00, 0x00, 0x98, /* al %r2, 0(%r15) */
- 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
+ 0x5e, 0x30, 0xf0, 0x04, /* al %r3, 4(%r15) */
+ 0xe3, 0x20, 0xf0, 0x00, 0x00, 0x98, /* al %r2, 0(%r15) */
+ 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
};
add_insns (buf, sizeof buf);
}
@@ -1574,12 +1543,12 @@ static void
s390_emit_sub (void)
{
static const unsigned char buf[] = {
- 0x98, 0x45, 0xf0, 0x00, /* lm %r4, %r5, 0(%r15) */
- 0x1f, 0x53, /* slr %r5, %r3 */
- 0xb9, 0x99, 0x00, 0x42, /* slbr %r4, %r2 */
- 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
- 0x18, 0x35, /* lr %r3, %r5 */
- 0x18, 0x24, /* lr %r2, %r4 */
+ 0x98, 0x45, 0xf0, 0x00, /* lm %r4, %r5, 0(%r15) */
+ 0x1f, 0x53, /* slr %r5, %r3 */
+ 0xb9, 0x99, 0x00, 0x42, /* slbr %r4, %r2 */
+ 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
+ 0x18, 0x35, /* lr %r3, %r5 */
+ 0x18, 0x24, /* lr %r2, %r4 */
};
add_insns (buf, sizeof buf);
}
@@ -1598,10 +1567,10 @@ static void
s390_emit_lsh (void)
{
static const unsigned char buf[] = {
- 0x18, 0x43, /* lr %r4, %r3 */
- 0x98, 0x23, 0xf0, 0x00, /* lm %r2, %r3, 0(%r15) */
- 0x8d, 0x20, 0x40, 0x00, /* sldl %r2, 0(%r4) */
- 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
+ 0x18, 0x43, /* lr %r4, %r3 */
+ 0x98, 0x23, 0xf0, 0x00, /* lm %r2, %r3, 0(%r15) */
+ 0x8d, 0x20, 0x40, 0x00, /* sldl %r2, 0(%r4) */
+ 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
};
add_insns (buf, sizeof buf);
}
@@ -1612,10 +1581,10 @@ static void
s390_emit_rsh_signed (void)
{
static const unsigned char buf[] = {
- 0x18, 0x43, /* lr %r4, %r3 */
- 0x98, 0x23, 0xf0, 0x00, /* lm %r2, %r3, 0(%r15) */
- 0x8e, 0x20, 0x40, 0x00, /* srda %r2, 0(%r4) */
- 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
+ 0x18, 0x43, /* lr %r4, %r3 */
+ 0x98, 0x23, 0xf0, 0x00, /* lm %r2, %r3, 0(%r15) */
+ 0x8e, 0x20, 0x40, 0x00, /* srda %r2, 0(%r4) */
+ 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
};
add_insns (buf, sizeof buf);
}
@@ -1626,10 +1595,10 @@ static void
s390_emit_rsh_unsigned (void)
{
static const unsigned char buf[] = {
- 0x18, 0x43, /* lr %r4, %r3 */
- 0x98, 0x23, 0xf0, 0x00, /* lm %r2, %r3, 0(%r15) */
- 0x8c, 0x20, 0x40, 0x00, /* srdl %r2, 0(%r4) */
- 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
+ 0x18, 0x43, /* lr %r4, %r3 */
+ 0x98, 0x23, 0xf0, 0x00, /* lm %r2, %r3, 0(%r15) */
+ 0x8c, 0x20, 0x40, 0x00, /* srdl %r2, 0(%r4) */
+ 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
};
add_insns (buf, sizeof buf);
}
@@ -1652,11 +1621,11 @@ static void
s390_emit_log_not (void)
{
static const unsigned char buf[] = {
- 0x16, 0x23, /* or %r2, %r3 */
- 0xa7, 0x28, 0x00, 0x00, /* lhi %r2, 0 */
- 0xa7, 0x38, 0x00, 0x00, /* lhi %r3, 0 */
- 0xa7, 0x74, 0x00, 0x04, /* jne .Lskip */
- 0xa7, 0x38, 0x00, 0x01, /* lhi %r3, 1 */
+ 0x16, 0x23, /* or %r2, %r3 */
+ 0xa7, 0x28, 0x00, 0x00, /* lhi %r2, 0 */
+ 0xa7, 0x38, 0x00, 0x00, /* lhi %r3, 0 */
+ 0xa7, 0x74, 0x00, 0x04, /* jne .Lskip */
+ 0xa7, 0x38, 0x00, 0x01, /* lhi %r3, 1 */
/* .Lskip: */
};
add_insns (buf, sizeof buf);
@@ -1668,9 +1637,9 @@ static void
s390_emit_bit_and (void)
{
static const unsigned char buf[] = {
- 0x54, 0x20, 0xf0, 0x00, /* n %r2, 0(%r15) */
- 0x54, 0x30, 0xf0, 0x04, /* n %r3, 4(%r15) */
- 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
+ 0x54, 0x20, 0xf0, 0x00, /* n %r2, 0(%r15) */
+ 0x54, 0x30, 0xf0, 0x04, /* n %r3, 4(%r15) */
+ 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
};
add_insns (buf, sizeof buf);
}
@@ -1681,9 +1650,9 @@ static void
s390_emit_bit_or (void)
{
static const unsigned char buf[] = {
- 0x56, 0x20, 0xf0, 0x00, /* o %r2, 0(%r15) */
- 0x56, 0x30, 0xf0, 0x04, /* o %r3, 4(%r15) */
- 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
+ 0x56, 0x20, 0xf0, 0x00, /* o %r2, 0(%r15) */
+ 0x56, 0x30, 0xf0, 0x04, /* o %r3, 4(%r15) */
+ 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
};
add_insns (buf, sizeof buf);
}
@@ -1694,9 +1663,9 @@ static void
s390_emit_bit_xor (void)
{
static const unsigned char buf[] = {
- 0x57, 0x20, 0xf0, 0x00, /* x %r2, 0(%r15) */
- 0x57, 0x30, 0xf0, 0x04, /* x %r3, 4(%r15) */
- 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
+ 0x57, 0x20, 0xf0, 0x00, /* x %r2, 0(%r15) */
+ 0x57, 0x30, 0xf0, 0x04, /* x %r3, 4(%r15) */
+ 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
};
add_insns (buf, sizeof buf);
}
@@ -1707,9 +1676,9 @@ static void
s390_emit_bit_not (void)
{
static const unsigned char buf[] = {
- 0xa7, 0x48, 0xff, 0xff, /* lhi %r4, -1 */
- 0x17, 0x24, /* xr %r2, %r4 */
- 0x17, 0x34, /* xr %r3, %r4 */
+ 0xa7, 0x48, 0xff, 0xff, /* lhi %r4, -1 */
+ 0x17, 0x24, /* xr %r2, %r4 */
+ 0x17, 0x34, /* xr %r3, %r4 */
};
add_insns (buf, sizeof buf);
}
@@ -1729,19 +1698,19 @@ static void
s390_emit_less_signed (void)
{
static const unsigned char buf[] = {
- 0x59, 0x20, 0xf0, 0x00, /* c %r2, 0(%r15) */
- 0xa7, 0x24, 0x00, 0x0c, /* jh .Lless */
- 0xa7, 0x44, 0x00, 0x06, /* jl .Lhigh */
- 0x55, 0x30, 0xf0, 0x04, /* cl %r3, 4(%r15) */
- 0xa7, 0x24, 0x00, 0x06, /* jh .Lless */
+ 0x59, 0x20, 0xf0, 0x00, /* c %r2, 0(%r15) */
+ 0xa7, 0x24, 0x00, 0x0c, /* jh .Lless */
+ 0xa7, 0x44, 0x00, 0x06, /* jl .Lhigh */
+ 0x55, 0x30, 0xf0, 0x04, /* cl %r3, 4(%r15) */
+ 0xa7, 0x24, 0x00, 0x06, /* jh .Lless */
/* .Lhigh: */
- 0xa7, 0x38, 0x00, 0x00, /* lhi %r3, 0 */
- 0xa7, 0xf4, 0x00, 0x04, /* j .Lend */
+ 0xa7, 0x38, 0x00, 0x00, /* lhi %r3, 0 */
+ 0xa7, 0xf4, 0x00, 0x04, /* j .Lend */
/* .Lless: */
- 0xa7, 0x38, 0x00, 0x01, /* lhi %r3, 1 */
+ 0xa7, 0x38, 0x00, 0x01, /* lhi %r3, 1 */
/* .Lend: */
- 0xa7, 0x28, 0x00, 0x00, /* lhi %r2, 0 */
- 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
+ 0xa7, 0x28, 0x00, 0x00, /* lhi %r2, 0 */
+ 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
};
add_insns (buf, sizeof buf);
}
@@ -1752,19 +1721,19 @@ static void
s390_emit_less_unsigned (void)
{
static const unsigned char buf[] = {
- 0x55, 0x20, 0xf0, 0x00, /* cl %r2, 0(%r15) */
- 0xa7, 0x24, 0x00, 0x0c, /* jh .Lless */
- 0xa7, 0x44, 0x00, 0x06, /* jl .Lhigh */
- 0x55, 0x30, 0xf0, 0x04, /* cl %r3, 4(%r15) */
- 0xa7, 0x24, 0x00, 0x06, /* jh .Lless */
+ 0x55, 0x20, 0xf0, 0x00, /* cl %r2, 0(%r15) */
+ 0xa7, 0x24, 0x00, 0x0c, /* jh .Lless */
+ 0xa7, 0x44, 0x00, 0x06, /* jl .Lhigh */
+ 0x55, 0x30, 0xf0, 0x04, /* cl %r3, 4(%r15) */
+ 0xa7, 0x24, 0x00, 0x06, /* jh .Lless */
/* .Lhigh: */
- 0xa7, 0x38, 0x00, 0x00, /* lhi %r3, 0 */
- 0xa7, 0xf4, 0x00, 0x04, /* j .Lend */
+ 0xa7, 0x38, 0x00, 0x00, /* lhi %r3, 0 */
+ 0xa7, 0xf4, 0x00, 0x04, /* j .Lend */
/* .Lless: */
- 0xa7, 0x38, 0x00, 0x01, /* lhi %r3, 1 */
+ 0xa7, 0x38, 0x00, 0x01, /* lhi %r3, 1 */
/* .Lend: */
- 0xa7, 0x28, 0x00, 0x00, /* lhi %r2, 0 */
- 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
+ 0xa7, 0x28, 0x00, 0x00, /* lhi %r2, 0 */
+ 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
};
add_insns (buf, sizeof buf);
}
@@ -1775,19 +1744,19 @@ static void
s390_emit_ref (int size)
{
static const unsigned char buf1[] = {
- 0xa7, 0x28, 0x00, 0x00, /* lhi %r2, 0 */
- 0x43, 0x30, 0x30, 0x00, /* ic %r3, 0(%r3) */
+ 0xa7, 0x28, 0x00, 0x00, /* lhi %r2, 0 */
+ 0x43, 0x30, 0x30, 0x00, /* ic %r3, 0(%r3) */
};
static const unsigned char buf2[] = {
- 0xa7, 0x28, 0x00, 0x00, /* lhi %r2, 0 */
- 0x48, 0x30, 0x30, 0x00, /* lh %r3, 0(%r3) */
+ 0xa7, 0x28, 0x00, 0x00, /* lhi %r2, 0 */
+ 0x48, 0x30, 0x30, 0x00, /* lh %r3, 0(%r3) */
};
static const unsigned char buf4[] = {
- 0xa7, 0x28, 0x00, 0x00, /* lhi %r2, 0 */
- 0x58, 0x30, 0x30, 0x00, /* l %r3, 0(%r3) */
+ 0xa7, 0x28, 0x00, 0x00, /* lhi %r2, 0 */
+ 0x58, 0x30, 0x30, 0x00, /* l %r3, 0(%r3) */
};
static const unsigned char buf8[] = {
- 0x98, 0x23, 0x30, 0x00, /* lm %r2, %r3, 0(%r3) */
+ 0x98, 0x23, 0x30, 0x00, /* lm %r2, %r3, 0(%r3) */
};
switch (size)
{
@@ -1814,10 +1783,10 @@ static void
s390_emit_if_goto (int *offset_p, int *size_p)
{
static const unsigned char buf[] = {
- 0x16, 0x23, /* or %r2, %r3 */
- 0x98, 0x23, 0xf0, 0x00, /* lm %r2, %r3, 0(%r15) */
- 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
- 0xc0, 0x74, 0x00, 0x00, 0x00, 0x00 /* jgne <fillme> */
+ 0x16, 0x23, /* or %r2, %r3 */
+ 0x98, 0x23, 0xf0, 0x00, /* lm %r2, %r3, 0(%r15) */
+ 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
+ 0xc0, 0x74, 0x00, 0x00, 0x00, 0x00 /* jgne <fillme> */
};
add_insns (buf, sizeof buf);
if (offset_p)
@@ -1832,7 +1801,7 @@ static void
s390_emit_goto (int *offset_p, int *size_p)
{
static const unsigned char buf[] = {
- 0xc0, 0xf4, 0x00, 0x00, 0x00, 0x00, /* jg <fillme> */
+ 0xc0, 0xf4, 0x00, 0x00, 0x00, 0x00, /* jg <fillme> */
};
add_insns (buf, sizeof buf);
if (offset_p)
@@ -1869,23 +1838,24 @@ static void
s390_emit_litpool (int size)
{
static const unsigned char nop[] = {
- 0x07, 0x07,
+ 0x07,
+ 0x07,
};
unsigned char buf[] = {
0xa7, 0x15, 0x00,
- (unsigned char) ((size + 4) / 2), /* bras %r1, .Lend+size */
+ (unsigned char) ((size + 4) / 2), /* bras %r1, .Lend+size */
/* .Lend: */
};
if (size == 4)
{
/* buf needs to start at even halfword for litpool to be aligned */
if (current_insn_ptr & 2)
- add_insns (nop, sizeof nop);
+ add_insns (nop, sizeof nop);
}
else
{
while ((current_insn_ptr & 6) != 4)
- add_insns (nop, sizeof nop);
+ add_insns (nop, sizeof nop);
}
add_insns (buf, sizeof buf);
}
@@ -1898,13 +1868,16 @@ s390_emit_const (LONGEST num)
unsigned long long n = num;
unsigned char buf_s[] = {
/* lhi %r3, <num> */
- 0xa7, 0x38,
- (unsigned char) (num >> 8), (unsigned char) num,
+ 0xa7,
+ 0x38,
+ (unsigned char) (num >> 8),
+ (unsigned char) num,
/* xr %r2, %r2 */
- 0x17, 0x22,
+ 0x17,
+ 0x22,
};
static const unsigned char buf_l[] = {
- 0x98, 0x23, 0x10, 0x00, /* lm %r2, %r3, 0(%r1) */
+ 0x98, 0x23, 0x10, 0x00, /* lm %r2, %r3, 0(%r1) */
};
if (num < 0x8000 && num >= 0)
add_insns (buf_s, sizeof buf_s);
@@ -1923,10 +1896,10 @@ s390_emit_call (CORE_ADDR fn)
{
unsigned int n = fn;
static const unsigned char buf[] = {
- 0x58, 0x10, 0x10, 0x00, /* l %r1, 0(%r1) */
- 0xa7, 0xfa, 0xff, 0xa0, /* ahi %r15, -0x60 */
- 0x0d, 0xe1, /* basr %r14, %r1 */
- 0xa7, 0xfa, 0x00, 0x60, /* ahi %r15, 0x60 */
+ 0x58, 0x10, 0x10, 0x00, /* l %r1, 0(%r1) */
+ 0xa7, 0xfa, 0xff, 0xa0, /* ahi %r15, -0x60 */
+ 0x0d, 0xe1, /* basr %r14, %r1 */
+ 0xa7, 0xfa, 0x00, 0x60, /* ahi %r15, 0x60 */
};
s390_emit_litpool (4);
add_insns ((unsigned char *) &n, sizeof n);
@@ -1940,9 +1913,13 @@ s390_emit_reg (int reg)
{
unsigned char bufpre[] = {
/* lr %r2, %r9 */
- 0x18, 0x29,
+ 0x18,
+ 0x29,
/* lhi %r3, <reg> */
- 0xa7, 0x38, (unsigned char) (reg >> 8), (unsigned char) reg,
+ 0xa7,
+ 0x38,
+ (unsigned char) (reg >> 8),
+ (unsigned char) reg,
};
add_insns (bufpre, sizeof bufpre);
s390_emit_call (get_raw_reg_func_addr ());
@@ -1954,8 +1931,8 @@ static void
s390_emit_pop (void)
{
static const unsigned char buf[] = {
- 0x98, 0x23, 0xf0, 0x00, /* lm %r2, %r3, 0(%r15) */
- 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
+ 0x98, 0x23, 0xf0, 0x00, /* lm %r2, %r3, 0(%r15) */
+ 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
};
add_insns (buf, sizeof buf);
}
@@ -1966,8 +1943,8 @@ static void
s390_emit_stack_flush (void)
{
static const unsigned char buf[] = {
- 0xa7, 0xfa, 0xff, 0xf8, /* ahi %r15, -8 */
- 0x90, 0x23, 0xf0, 0x00, /* stm %r2, %r3, 0(%r15) */
+ 0xa7, 0xfa, 0xff, 0xf8, /* ahi %r15, -8 */
+ 0x90, 0x23, 0xf0, 0x00, /* stm %r2, %r3, 0(%r15) */
};
add_insns (buf, sizeof buf);
}
@@ -1990,10 +1967,10 @@ static void
s390_emit_swap (void)
{
static const unsigned char buf[] = {
- 0x98, 0x45, 0xf0, 0x00, /* lm %r4, %r5, 0(%r15) */
- 0x90, 0x23, 0xf0, 0x00, /* stm %r2, %r3, 0(%r15) */
- 0x18, 0x24, /* lr %r2, %r4 */
- 0x18, 0x35, /* lr %r3, %r5 */
+ 0x98, 0x45, 0xf0, 0x00, /* lm %r4, %r5, 0(%r15) */
+ 0x90, 0x23, 0xf0, 0x00, /* stm %r2, %r3, 0(%r15) */
+ 0x18, 0x24, /* lr %r2, %r4 */
+ 0x18, 0x35, /* lr %r3, %r5 */
};
add_insns (buf, sizeof buf);
}
@@ -2005,8 +1982,10 @@ s390_emit_stack_adjust (int n)
{
unsigned char buf[] = {
/* ahi %r15, 8*n */
- 0xa7, 0xfa,
- (unsigned char ) (n * 8 >> 8), (unsigned char) (n * 8),
+ 0xa7,
+ 0xfa,
+ (unsigned char) (n * 8 >> 8),
+ (unsigned char) (n * 8),
};
add_insns (buf, sizeof buf);
}
@@ -2018,10 +1997,13 @@ s390_emit_set_r2 (int arg1)
{
unsigned char buf_s[] = {
/* lhi %r2, <arg1> */
- 0xa7, 0x28, (unsigned char) (arg1 >> 8), (unsigned char) arg1,
+ 0xa7,
+ 0x28,
+ (unsigned char) (arg1 >> 8),
+ (unsigned char) arg1,
};
static const unsigned char buf_l[] = {
- 0x58, 0x20, 0x10, 0x00, /* l %r2, 0(%r1) */
+ 0x58, 0x20, 0x10, 0x00, /* l %r2, 0(%r1) */
};
if (arg1 < 0x8000 && arg1 >= -0x8000)
add_insns (buf_s, sizeof buf_s);
@@ -2050,14 +2032,14 @@ s390_emit_void_call_2 (CORE_ADDR fn, int arg1)
{
/* FN's prototype is `void(*fn)(int,LONGEST)'. */
static const unsigned char buf[] = {
- 0x18, 0xc2, /* lr %r12, %r2 */
- 0x18, 0xd3, /* lr %r13, %r3 */
- 0x18, 0x43, /* lr %r4, %r3 */
- 0x18, 0x32, /* lr %r3, %r2 */
+ 0x18, 0xc2, /* lr %r12, %r2 */
+ 0x18, 0xd3, /* lr %r13, %r3 */
+ 0x18, 0x43, /* lr %r4, %r3 */
+ 0x18, 0x32, /* lr %r3, %r2 */
};
static const unsigned char buf2[] = {
- 0x18, 0x2c, /* lr %r2, %r12 */
- 0x18, 0x3d, /* lr %r3, %r13 */
+ 0x18, 0x2c, /* lr %r2, %r12 */
+ 0x18, 0x3d, /* lr %r3, %r13 */
};
add_insns (buf, sizeof buf);
s390_emit_set_r2 (arg1);
@@ -2071,12 +2053,12 @@ static void
s390_emit_eq_goto (int *offset_p, int *size_p)
{
static const unsigned char buf[] = {
- 0x57, 0x20, 0xf0, 0x00, /* x %r2, 0(%r15) */
- 0x57, 0x30, 0xf0, 0x04, /* x %r3, 4(%r15) */
- 0x16, 0x23, /* or %r2, %r3 */
- 0x98, 0x23, 0xf0, 0x08, /* lm %r2, %r3, 8(%r15) */
- 0x41, 0xf0, 0xf0, 0x10, /* la %r15, 16(%r15) */
- 0xc0, 0x84, 0x00, 0x00, 0x00, 0x00, /* jge <fillme> */
+ 0x57, 0x20, 0xf0, 0x00, /* x %r2, 0(%r15) */
+ 0x57, 0x30, 0xf0, 0x04, /* x %r3, 4(%r15) */
+ 0x16, 0x23, /* or %r2, %r3 */
+ 0x98, 0x23, 0xf0, 0x08, /* lm %r2, %r3, 8(%r15) */
+ 0x41, 0xf0, 0xf0, 0x10, /* la %r15, 16(%r15) */
+ 0xc0, 0x84, 0x00, 0x00, 0x00, 0x00, /* jge <fillme> */
};
add_insns (buf, sizeof buf);
if (offset_p)
@@ -2091,12 +2073,12 @@ static void
s390_emit_ne_goto (int *offset_p, int *size_p)
{
static const unsigned char buf[] = {
- 0x57, 0x20, 0xf0, 0x00, /* x %r2, 0(%r15) */
- 0x57, 0x30, 0xf0, 0x04, /* x %r3, 4(%r15) */
- 0x16, 0x23, /* or %r2, %r3 */
- 0x98, 0x23, 0xf0, 0x08, /* lm %r2, %r3, 8(%r15) */
- 0x41, 0xf0, 0xf0, 0x10, /* la %r15, 16(%r15) */
- 0xc0, 0x74, 0x00, 0x00, 0x00, 0x00, /* jgne <fillme> */
+ 0x57, 0x20, 0xf0, 0x00, /* x %r2, 0(%r15) */
+ 0x57, 0x30, 0xf0, 0x04, /* x %r3, 4(%r15) */
+ 0x16, 0x23, /* or %r2, %r3 */
+ 0x98, 0x23, 0xf0, 0x08, /* lm %r2, %r3, 8(%r15) */
+ 0x41, 0xf0, 0xf0, 0x10, /* la %r15, 16(%r15) */
+ 0xc0, 0x74, 0x00, 0x00, 0x00, 0x00, /* jgne <fillme> */
};
add_insns (buf, sizeof buf);
if (offset_p)
@@ -2111,19 +2093,19 @@ static void
s390_emit_lt_goto (int *offset_p, int *size_p)
{
static const unsigned char buf[] = {
- 0x59, 0x20, 0xf0, 0x00, /* c %r2, 0(%r15) */
- 0xa7, 0x24, 0x00, 0x0e, /* jh .Ltrue */
- 0xa7, 0x44, 0x00, 0x06, /* jl .Lfalse */
- 0x55, 0x30, 0xf0, 0x04, /* cl %r3, 4(%r15) */
- 0xa7, 0x24, 0x00, 0x08, /* jh .Ltrue */
+ 0x59, 0x20, 0xf0, 0x00, /* c %r2, 0(%r15) */
+ 0xa7, 0x24, 0x00, 0x0e, /* jh .Ltrue */
+ 0xa7, 0x44, 0x00, 0x06, /* jl .Lfalse */
+ 0x55, 0x30, 0xf0, 0x04, /* cl %r3, 4(%r15) */
+ 0xa7, 0x24, 0x00, 0x08, /* jh .Ltrue */
/* .Lfalse: */
- 0x98, 0x23, 0xf0, 0x08, /* lm %r2, %r3, 8(%r15) */
- 0x41, 0xf0, 0xf0, 0x10, /* la %r15, 16(%r15) */
- 0xa7, 0xf4, 0x00, 0x09, /* j .Lend */
+ 0x98, 0x23, 0xf0, 0x08, /* lm %r2, %r3, 8(%r15) */
+ 0x41, 0xf0, 0xf0, 0x10, /* la %r15, 16(%r15) */
+ 0xa7, 0xf4, 0x00, 0x09, /* j .Lend */
/* .Ltrue: */
- 0x98, 0x23, 0xf0, 0x08, /* lm %r2, %r3, 8(%r15) */
- 0x41, 0xf0, 0xf0, 0x10, /* la %r15, 16(%r15) */
- 0xc0, 0xf4, 0x00, 0x00, 0x00, 0x00, /* jg <fillme> */
+ 0x98, 0x23, 0xf0, 0x08, /* lm %r2, %r3, 8(%r15) */
+ 0x41, 0xf0, 0xf0, 0x10, /* la %r15, 16(%r15) */
+ 0xc0, 0xf4, 0x00, 0x00, 0x00, 0x00, /* jg <fillme> */
/* .Lend: */
};
add_insns (buf, sizeof buf);
@@ -2139,19 +2121,19 @@ static void
s390_emit_le_goto (int *offset_p, int *size_p)
{
static const unsigned char buf[] = {
- 0x59, 0x20, 0xf0, 0x00, /* c %r2, 0(%r15) */
- 0xa7, 0x24, 0x00, 0x0e, /* jh .Ltrue */
- 0xa7, 0x44, 0x00, 0x06, /* jl .Lfalse */
- 0x55, 0x30, 0xf0, 0x04, /* cl %r3, 4(%r15) */
- 0xa7, 0xa4, 0x00, 0x08, /* jhe .Ltrue */
+ 0x59, 0x20, 0xf0, 0x00, /* c %r2, 0(%r15) */
+ 0xa7, 0x24, 0x00, 0x0e, /* jh .Ltrue */
+ 0xa7, 0x44, 0x00, 0x06, /* jl .Lfalse */
+ 0x55, 0x30, 0xf0, 0x04, /* cl %r3, 4(%r15) */
+ 0xa7, 0xa4, 0x00, 0x08, /* jhe .Ltrue */
/* .Lfalse: */
- 0x98, 0x23, 0xf0, 0x08, /* lm %r2, %r3, 8(%r15) */
- 0x41, 0xf0, 0xf0, 0x10, /* la %r15, 16(%r15) */
- 0xa7, 0xf4, 0x00, 0x09, /* j .Lend */
+ 0x98, 0x23, 0xf0, 0x08, /* lm %r2, %r3, 8(%r15) */
+ 0x41, 0xf0, 0xf0, 0x10, /* la %r15, 16(%r15) */
+ 0xa7, 0xf4, 0x00, 0x09, /* j .Lend */
/* .Ltrue: */
- 0x98, 0x23, 0xf0, 0x08, /* lm %r2, %r3, 8(%r15) */
- 0x41, 0xf0, 0xf0, 0x10, /* la %r15, 16(%r15) */
- 0xc0, 0xf4, 0x00, 0x00, 0x00, 0x00, /* jg <fillme> */
+ 0x98, 0x23, 0xf0, 0x08, /* lm %r2, %r3, 8(%r15) */
+ 0x41, 0xf0, 0xf0, 0x10, /* la %r15, 16(%r15) */
+ 0xc0, 0xf4, 0x00, 0x00, 0x00, 0x00, /* jg <fillme> */
/* .Lend: */
};
add_insns (buf, sizeof buf);
@@ -2167,19 +2149,19 @@ static void
s390_emit_gt_goto (int *offset_p, int *size_p)
{
static const unsigned char buf[] = {
- 0x59, 0x20, 0xf0, 0x00, /* c %r2, 0(%r15) */
- 0xa7, 0x44, 0x00, 0x0e, /* jl .Ltrue */
- 0xa7, 0x24, 0x00, 0x06, /* jh .Lfalse */
- 0x55, 0x30, 0xf0, 0x04, /* cl %r3, 4(%r15) */
- 0xa7, 0x44, 0x00, 0x08, /* jl .Ltrue */
+ 0x59, 0x20, 0xf0, 0x00, /* c %r2, 0(%r15) */
+ 0xa7, 0x44, 0x00, 0x0e, /* jl .Ltrue */
+ 0xa7, 0x24, 0x00, 0x06, /* jh .Lfalse */
+ 0x55, 0x30, 0xf0, 0x04, /* cl %r3, 4(%r15) */
+ 0xa7, 0x44, 0x00, 0x08, /* jl .Ltrue */
/* .Lfalse: */
- 0x98, 0x23, 0xf0, 0x08, /* lm %r2, %r3, 8(%r15) */
- 0x41, 0xf0, 0xf0, 0x10, /* la %r15, 16(%r15) */
- 0xa7, 0xf4, 0x00, 0x09, /* j .Lend */
+ 0x98, 0x23, 0xf0, 0x08, /* lm %r2, %r3, 8(%r15) */
+ 0x41, 0xf0, 0xf0, 0x10, /* la %r15, 16(%r15) */
+ 0xa7, 0xf4, 0x00, 0x09, /* j .Lend */
/* .Ltrue: */
- 0x98, 0x23, 0xf0, 0x08, /* lm %r2, %r3, 8(%r15) */
- 0x41, 0xf0, 0xf0, 0x10, /* la %r15, 16(%r15) */
- 0xc0, 0xf4, 0x00, 0x00, 0x00, 0x00, /* jg <fillme> */
+ 0x98, 0x23, 0xf0, 0x08, /* lm %r2, %r3, 8(%r15) */
+ 0x41, 0xf0, 0xf0, 0x10, /* la %r15, 16(%r15) */
+ 0xc0, 0xf4, 0x00, 0x00, 0x00, 0x00, /* jg <fillme> */
/* .Lend: */
};
add_insns (buf, sizeof buf);
@@ -2195,19 +2177,19 @@ static void
s390_emit_ge_goto (int *offset_p, int *size_p)
{
static const unsigned char buf[] = {
- 0x59, 0x20, 0xf0, 0x00, /* c %r2, 0(%r15) */
- 0xa7, 0x44, 0x00, 0x0e, /* jl .Ltrue */
- 0xa7, 0x24, 0x00, 0x06, /* jh .Lfalse */
- 0x55, 0x30, 0xf0, 0x04, /* cl %r3, 4(%r15) */
- 0xa7, 0xc4, 0x00, 0x08, /* jle .Ltrue */
+ 0x59, 0x20, 0xf0, 0x00, /* c %r2, 0(%r15) */
+ 0xa7, 0x44, 0x00, 0x0e, /* jl .Ltrue */
+ 0xa7, 0x24, 0x00, 0x06, /* jh .Lfalse */
+ 0x55, 0x30, 0xf0, 0x04, /* cl %r3, 4(%r15) */
+ 0xa7, 0xc4, 0x00, 0x08, /* jle .Ltrue */
/* .Lfalse: */
- 0x98, 0x23, 0xf0, 0x08, /* lm %r2, %r3, 8(%r15) */
- 0x41, 0xf0, 0xf0, 0x10, /* la %r15, 16(%r15) */
- 0xa7, 0xf4, 0x00, 0x09, /* j .Lend */
+ 0x98, 0x23, 0xf0, 0x08, /* lm %r2, %r3, 8(%r15) */
+ 0x41, 0xf0, 0xf0, 0x10, /* la %r15, 16(%r15) */
+ 0xa7, 0xf4, 0x00, 0x09, /* j .Lend */
/* .Ltrue: */
- 0x98, 0x23, 0xf0, 0x08, /* lm %r2, %r3, 8(%r15) */
- 0x41, 0xf0, 0xf0, 0x10, /* la %r15, 16(%r15) */
- 0xc0, 0xf4, 0x00, 0x00, 0x00, 0x00, /* jg <fillme> */
+ 0x98, 0x23, 0xf0, 0x08, /* lm %r2, %r3, 8(%r15) */
+ 0x41, 0xf0, 0xf0, 0x10, /* la %r15, 16(%r15) */
+ 0xc0, 0xf4, 0x00, 0x00, 0x00, 0x00, /* jg <fillme> */
/* .Lend: */
};
add_insns (buf, sizeof buf);
@@ -2220,46 +2202,20 @@ s390_emit_ge_goto (int *offset_p, int *size_p)
/* The "emit_ops" structure for s390. Named _impl to avoid name
collision with s390_emit_ops function. */
-static struct emit_ops s390_emit_ops_impl =
- {
- s390_emit_prologue,
- s390_emit_epilogue,
- s390_emit_add,
- s390_emit_sub,
- s390_emit_mul,
- s390_emit_lsh,
- s390_emit_rsh_signed,
- s390_emit_rsh_unsigned,
- s390_emit_ext,
- s390_emit_log_not,
- s390_emit_bit_and,
- s390_emit_bit_or,
- s390_emit_bit_xor,
- s390_emit_bit_not,
- s390_emit_equal,
- s390_emit_less_signed,
- s390_emit_less_unsigned,
- s390_emit_ref,
- s390_emit_if_goto,
- s390_emit_goto,
- s390_write_goto_address,
- s390_emit_const,
- s390_emit_call,
- s390_emit_reg,
- s390_emit_pop,
- s390_emit_stack_flush,
- s390_emit_zero_ext,
- s390_emit_swap,
- s390_emit_stack_adjust,
- s390_emit_int_call_1,
- s390_emit_void_call_2,
- s390_emit_eq_goto,
- s390_emit_ne_goto,
- s390_emit_lt_goto,
- s390_emit_le_goto,
- s390_emit_gt_goto,
- s390_emit_ge_goto
- };
+static struct emit_ops s390_emit_ops_impl
+ = { s390_emit_prologue, s390_emit_epilogue, s390_emit_add,
+ s390_emit_sub, s390_emit_mul, s390_emit_lsh,
+ s390_emit_rsh_signed, s390_emit_rsh_unsigned, s390_emit_ext,
+ s390_emit_log_not, s390_emit_bit_and, s390_emit_bit_or,
+ s390_emit_bit_xor, s390_emit_bit_not, s390_emit_equal,
+ s390_emit_less_signed, s390_emit_less_unsigned, s390_emit_ref,
+ s390_emit_if_goto, s390_emit_goto, s390_write_goto_address,
+ s390_emit_const, s390_emit_call, s390_emit_reg,
+ s390_emit_pop, s390_emit_stack_flush, s390_emit_zero_ext,
+ s390_emit_swap, s390_emit_stack_adjust, s390_emit_int_call_1,
+ s390_emit_void_call_2, s390_emit_eq_goto, s390_emit_ne_goto,
+ s390_emit_lt_goto, s390_emit_le_goto, s390_emit_gt_goto,
+ s390_emit_ge_goto };
#ifdef __s390x__
@@ -2269,10 +2225,10 @@ static void
s390x_emit_prologue (void)
{
static const unsigned char buf[] = {
- 0xeb, 0x9f, 0xf0, 0x48, 0x00, 0x24, /* stmg %r9, %r15, 0x48(%r15) */
- 0xb9, 0x04, 0x00, 0x92, /* lgr %r9, %r2 */
- 0xb9, 0x04, 0x00, 0xa3, /* lgr %r10, %r3 */
- 0xb9, 0x04, 0x00, 0xbf, /* lgr %r11, %r15 */
+ 0xeb, 0x9f, 0xf0, 0x48, 0x00, 0x24, /* stmg %r9, %r15, 0x48(%r15) */
+ 0xb9, 0x04, 0x00, 0x92, /* lgr %r9, %r2 */
+ 0xb9, 0x04, 0x00, 0xa3, /* lgr %r10, %r3 */
+ 0xb9, 0x04, 0x00, 0xbf, /* lgr %r11, %r15 */
};
add_insns (buf, sizeof buf);
}
@@ -2283,10 +2239,10 @@ static void
s390x_emit_epilogue (void)
{
static const unsigned char buf[] = {
- 0xe3, 0x20, 0xa0, 0x00, 0x00, 0x24, /* stg %r2, 0(%r10) */
- 0xa7, 0x29, 0x00, 0x00, /* lghi %r2, 0 */
- 0xeb, 0x9f, 0xf0, 0x48, 0x00, 0x04, /* lmg %r9, %r15, 0x48(%r15) */
- 0x07, 0xfe, /* br %r14 */
+ 0xe3, 0x20, 0xa0, 0x00, 0x00, 0x24, /* stg %r2, 0(%r10) */
+ 0xa7, 0x29, 0x00, 0x00, /* lghi %r2, 0 */
+ 0xeb, 0x9f, 0xf0, 0x48, 0x00, 0x04, /* lmg %r9, %r15, 0x48(%r15) */
+ 0x07, 0xfe, /* br %r14 */
};
add_insns (buf, sizeof buf);
}
@@ -2297,8 +2253,8 @@ static void
s390x_emit_add (void)
{
static const unsigned char buf[] = {
- 0xe3, 0x20, 0xf0, 0x00, 0x00, 0x0a, /* alg %r2, 0(%r15) */
- 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
+ 0xe3, 0x20, 0xf0, 0x00, 0x00, 0x0a, /* alg %r2, 0(%r15) */
+ 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
};
add_insns (buf, sizeof buf);
}
@@ -2309,10 +2265,10 @@ static void
s390x_emit_sub (void)
{
static const unsigned char buf[] = {
- 0xe3, 0x30, 0xf0, 0x00, 0x00, 0x04, /* lg %r3, 0(%r15) */
- 0xb9, 0x0b, 0x00, 0x32, /* slgr %r3, %r2 */
- 0xb9, 0x04, 0x00, 0x23, /* lgr %r2, %r3 */
- 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
+ 0xe3, 0x30, 0xf0, 0x00, 0x00, 0x04, /* lg %r3, 0(%r15) */
+ 0xb9, 0x0b, 0x00, 0x32, /* slgr %r3, %r2 */
+ 0xb9, 0x04, 0x00, 0x23, /* lgr %r2, %r3 */
+ 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
};
add_insns (buf, sizeof buf);
}
@@ -2331,9 +2287,9 @@ static void
s390x_emit_lsh (void)
{
static const unsigned char buf[] = {
- 0xe3, 0x30, 0xf0, 0x00, 0x00, 0x04, /* lg %r3, 0(%r15) */
- 0xeb, 0x23, 0x20, 0x00, 0x00, 0x0d, /* sllg %r2, %r3, 0(%r2) */
- 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
+ 0xe3, 0x30, 0xf0, 0x00, 0x00, 0x04, /* lg %r3, 0(%r15) */
+ 0xeb, 0x23, 0x20, 0x00, 0x00, 0x0d, /* sllg %r2, %r3, 0(%r2) */
+ 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
};
add_insns (buf, sizeof buf);
}
@@ -2344,9 +2300,9 @@ static void
s390x_emit_rsh_signed (void)
{
static const unsigned char buf[] = {
- 0xe3, 0x30, 0xf0, 0x00, 0x00, 0x04, /* lg %r3, 0(%r15) */
- 0xeb, 0x23, 0x20, 0x00, 0x00, 0x0a, /* srag %r2, %r3, 0(%r2) */
- 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
+ 0xe3, 0x30, 0xf0, 0x00, 0x00, 0x04, /* lg %r3, 0(%r15) */
+ 0xeb, 0x23, 0x20, 0x00, 0x00, 0x0a, /* srag %r2, %r3, 0(%r2) */
+ 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
};
add_insns (buf, sizeof buf);
}
@@ -2357,9 +2313,9 @@ static void
s390x_emit_rsh_unsigned (void)
{
static const unsigned char buf[] = {
- 0xe3, 0x30, 0xf0, 0x00, 0x00, 0x04, /* lg %r3, 0(%r15) */
- 0xeb, 0x23, 0x20, 0x00, 0x00, 0x0c, /* srlg %r2, %r3, 0(%r2) */
- 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
+ 0xe3, 0x30, 0xf0, 0x00, 0x00, 0x04, /* lg %r3, 0(%r15) */
+ 0xeb, 0x23, 0x20, 0x00, 0x00, 0x0c, /* srlg %r2, %r3, 0(%r2) */
+ 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
};
add_insns (buf, sizeof buf);
}
@@ -2371,9 +2327,19 @@ s390x_emit_ext (int arg)
{
unsigned char buf[] = {
/* sllg %r2, %r2, <64-arg> */
- 0xeb, 0x22, 0x00, (unsigned char) (64 - arg), 0x00, 0x0d,
+ 0xeb,
+ 0x22,
+ 0x00,
+ (unsigned char) (64 - arg),
+ 0x00,
+ 0x0d,
/* srag %r2, %r2, <64-arg> */
- 0xeb, 0x22, 0x00, (unsigned char) (64 - arg), 0x00, 0x0a,
+ 0xeb,
+ 0x22,
+ 0x00,
+ (unsigned char) (64 - arg),
+ 0x00,
+ 0x0a,
};
add_insns (buf, sizeof buf);
}
@@ -2384,9 +2350,9 @@ static void
s390x_emit_log_not (void)
{
static const unsigned char buf[] = {
- 0xb9, 0x00, 0x00, 0x22, /* lpgr %r2, %r2 */
- 0xa7, 0x2b, 0xff, 0xff, /* aghi %r2, -1 */
- 0xeb, 0x22, 0x00, 0x3f, 0x00, 0x0c, /* srlg %r2, %r2, 63 */
+ 0xb9, 0x00, 0x00, 0x22, /* lpgr %r2, %r2 */
+ 0xa7, 0x2b, 0xff, 0xff, /* aghi %r2, -1 */
+ 0xeb, 0x22, 0x00, 0x3f, 0x00, 0x0c, /* srlg %r2, %r2, 63 */
};
add_insns (buf, sizeof buf);
}
@@ -2397,8 +2363,8 @@ static void
s390x_emit_bit_and (void)
{
static const unsigned char buf[] = {
- 0xe3, 0x20, 0xf0, 0x00, 0x00, 0x80, /* ng %r2, 0(%r15) */
- 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
+ 0xe3, 0x20, 0xf0, 0x00, 0x00, 0x80, /* ng %r2, 0(%r15) */
+ 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
};
add_insns (buf, sizeof buf);
}
@@ -2409,8 +2375,8 @@ static void
s390x_emit_bit_or (void)
{
static const unsigned char buf[] = {
- 0xe3, 0x20, 0xf0, 0x00, 0x00, 0x81, /* og %r2, 0(%r15) */
- 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
+ 0xe3, 0x20, 0xf0, 0x00, 0x00, 0x81, /* og %r2, 0(%r15) */
+ 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
};
add_insns (buf, sizeof buf);
}
@@ -2421,8 +2387,8 @@ static void
s390x_emit_bit_xor (void)
{
static const unsigned char buf[] = {
- 0xe3, 0x20, 0xf0, 0x00, 0x00, 0x82, /* xg %r2, 0(%r15) */
- 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
+ 0xe3, 0x20, 0xf0, 0x00, 0x00, 0x82, /* xg %r2, 0(%r15) */
+ 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
};
add_insns (buf, sizeof buf);
}
@@ -2433,8 +2399,8 @@ static void
s390x_emit_bit_not (void)
{
static const unsigned char buf[] = {
- 0xa7, 0x39, 0xff, 0xff, /* lghi %r3, -1 */
- 0xb9, 0x82, 0x00, 0x23, /* xgr %r2, %r3 */
+ 0xa7, 0x39, 0xff, 0xff, /* lghi %r3, -1 */
+ 0xb9, 0x82, 0x00, 0x23, /* xgr %r2, %r3 */
};
add_insns (buf, sizeof buf);
}
@@ -2454,12 +2420,12 @@ static void
s390x_emit_less_signed (void)
{
static const unsigned char buf[] = {
- 0xe3, 0x20, 0xf0, 0x00, 0x00, 0x20, /* cg %r2, 0(%r15) */
- 0xa7, 0x29, 0x00, 0x01, /* lghi %r2, 1 */
- 0xa7, 0x24, 0x00, 0x04, /* jh .Lend */
- 0xa7, 0x29, 0x00, 0x00, /* lghi %r2, 0 */
+ 0xe3, 0x20, 0xf0, 0x00, 0x00, 0x20, /* cg %r2, 0(%r15) */
+ 0xa7, 0x29, 0x00, 0x01, /* lghi %r2, 1 */
+ 0xa7, 0x24, 0x00, 0x04, /* jh .Lend */
+ 0xa7, 0x29, 0x00, 0x00, /* lghi %r2, 0 */
/* .Lend: */
- 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
+ 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
};
add_insns (buf, sizeof buf);
}
@@ -2470,12 +2436,12 @@ static void
s390x_emit_less_unsigned (void)
{
static const unsigned char buf[] = {
- 0xe3, 0x20, 0xf0, 0x00, 0x00, 0x21, /* clg %r2, 0(%r15) */
- 0xa7, 0x29, 0x00, 0x01, /* lghi %r2, 1 */
- 0xa7, 0x24, 0x00, 0x04, /* jh .Lend */
- 0xa7, 0x29, 0x00, 0x00, /* lghi %r2, 0 */
+ 0xe3, 0x20, 0xf0, 0x00, 0x00, 0x21, /* clg %r2, 0(%r15) */
+ 0xa7, 0x29, 0x00, 0x01, /* lghi %r2, 1 */
+ 0xa7, 0x24, 0x00, 0x04, /* jh .Lend */
+ 0xa7, 0x29, 0x00, 0x00, /* lghi %r2, 0 */
/* .Lend: */
- 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
+ 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
};
add_insns (buf, sizeof buf);
}
@@ -2486,16 +2452,16 @@ static void
s390x_emit_ref (int size)
{
static const unsigned char buf1[] = {
- 0xe3, 0x20, 0x20, 0x00, 0x00, 0x90, /* llgc %r2, 0(%r2) */
+ 0xe3, 0x20, 0x20, 0x00, 0x00, 0x90, /* llgc %r2, 0(%r2) */
};
static const unsigned char buf2[] = {
- 0xe3, 0x20, 0x20, 0x00, 0x00, 0x91 /* llgh %r2, 0(%r2) */
+ 0xe3, 0x20, 0x20, 0x00, 0x00, 0x91 /* llgh %r2, 0(%r2) */
};
static const unsigned char buf4[] = {
- 0xe3, 0x20, 0x20, 0x00, 0x00, 0x16, /* llgf %r2, 0(%r2) */
+ 0xe3, 0x20, 0x20, 0x00, 0x00, 0x16, /* llgf %r2, 0(%r2) */
};
static const unsigned char buf8[] = {
- 0xe3, 0x20, 0x20, 0x00, 0x00, 0x04, /* lg %r2, 0(%r2) */
+ 0xe3, 0x20, 0x20, 0x00, 0x00, 0x04, /* lg %r2, 0(%r2) */
};
switch (size)
{
@@ -2522,10 +2488,10 @@ static void
s390x_emit_if_goto (int *offset_p, int *size_p)
{
static const unsigned char buf[] = {
- 0xb9, 0x02, 0x00, 0x22, /* ltgr %r2, %r2 */
- 0xe3, 0x20, 0xf0, 0x00, 0x00, 0x04, /* lg %r2, 0(%r15) */
- 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
- 0xc0, 0x74, 0x00, 0x00, 0x00, 0x00, /* jgne <fillme> */
+ 0xb9, 0x02, 0x00, 0x22, /* ltgr %r2, %r2 */
+ 0xe3, 0x20, 0xf0, 0x00, 0x00, 0x04, /* lg %r2, 0(%r15) */
+ 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
+ 0xc0, 0x74, 0x00, 0x00, 0x00, 0x00, /* jgne <fillme> */
};
add_insns (buf, sizeof buf);
if (offset_p)
@@ -2542,10 +2508,13 @@ s390x_emit_const (LONGEST num)
unsigned long long n = num;
unsigned char buf_s[] = {
/* lghi %r2, <num> */
- 0xa7, 0x29, (unsigned char) (num >> 8), (unsigned char) num,
+ 0xa7,
+ 0x29,
+ (unsigned char) (num >> 8),
+ (unsigned char) num,
};
static const unsigned char buf_l[] = {
- 0xe3, 0x20, 0x10, 0x00, 0x00, 0x04, /* lg %r2, 0(%r1) */
+ 0xe3, 0x20, 0x10, 0x00, 0x00, 0x04, /* lg %r2, 0(%r1) */
};
if (num < 0x8000 && num >= -0x8000)
add_insns (buf_s, sizeof buf_s);
@@ -2564,10 +2533,10 @@ s390x_emit_call (CORE_ADDR fn)
{
unsigned long n = fn;
static const unsigned char buf[] = {
- 0xe3, 0x10, 0x10, 0x00, 0x00, 0x04, /* lg %r1, 0(%r1) */
- 0xa7, 0xfb, 0xff, 0x60, /* aghi %r15, -0xa0 */
- 0x0d, 0xe1, /* basr %r14, %r1 */
- 0xa7, 0xfb, 0x00, 0xa0, /* aghi %r15, 0xa0 */
+ 0xe3, 0x10, 0x10, 0x00, 0x00, 0x04, /* lg %r1, 0(%r1) */
+ 0xa7, 0xfb, 0xff, 0x60, /* aghi %r15, -0xa0 */
+ 0x0d, 0xe1, /* basr %r14, %r1 */
+ 0xa7, 0xfb, 0x00, 0xa0, /* aghi %r15, 0xa0 */
};
s390_emit_litpool (8);
add_insns ((unsigned char *) &n, sizeof n);
@@ -2581,9 +2550,15 @@ s390x_emit_reg (int reg)
{
unsigned char buf[] = {
/* lgr %r2, %r9 */
- 0xb9, 0x04, 0x00, 0x29,
+ 0xb9,
+ 0x04,
+ 0x00,
+ 0x29,
/* lghi %r3, <reg> */
- 0xa7, 0x39, (unsigned char) (reg >> 8), (unsigned char) reg,
+ 0xa7,
+ 0x39,
+ (unsigned char) (reg >> 8),
+ (unsigned char) reg,
};
add_insns (buf, sizeof buf);
s390x_emit_call (get_raw_reg_func_addr ());
@@ -2595,8 +2570,8 @@ static void
s390x_emit_pop (void)
{
static const unsigned char buf[] = {
- 0xe3, 0x20, 0xf0, 0x00, 0x00, 0x04, /* lg %r2, 0(%r15) */
- 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
+ 0xe3, 0x20, 0xf0, 0x00, 0x00, 0x04, /* lg %r2, 0(%r15) */
+ 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
};
add_insns (buf, sizeof buf);
}
@@ -2607,8 +2582,8 @@ static void
s390x_emit_stack_flush (void)
{
static const unsigned char buf[] = {
- 0xa7, 0xfb, 0xff, 0xf8, /* aghi %r15, -8 */
- 0xe3, 0x20, 0xf0, 0x00, 0x00, 0x24, /* stg %r2, 0(%r15) */
+ 0xa7, 0xfb, 0xff, 0xf8, /* aghi %r15, -8 */
+ 0xe3, 0x20, 0xf0, 0x00, 0x00, 0x24, /* stg %r2, 0(%r15) */
};
add_insns (buf, sizeof buf);
}
@@ -2620,9 +2595,19 @@ s390x_emit_zero_ext (int arg)
{
unsigned char buf[] = {
/* sllg %r2, %r2, <64-arg> */
- 0xeb, 0x22, 0x00, (unsigned char) (64 - arg), 0x00, 0x0d,
+ 0xeb,
+ 0x22,
+ 0x00,
+ (unsigned char) (64 - arg),
+ 0x00,
+ 0x0d,
/* srlg %r2, %r2, <64-arg> */
- 0xeb, 0x22, 0x00, (unsigned char) (64 - arg), 0x00, 0x0c,
+ 0xeb,
+ 0x22,
+ 0x00,
+ (unsigned char) (64 - arg),
+ 0x00,
+ 0x0c,
};
add_insns (buf, sizeof buf);
}
@@ -2633,9 +2618,9 @@ static void
s390x_emit_swap (void)
{
static const unsigned char buf[] = {
- 0xe3, 0x30, 0xf0, 0x00, 0x00, 0x04, /* lg %r3, 0(%r15) */
- 0xe3, 0x20, 0xf0, 0x00, 0x00, 0x24, /* stg %r2, 0(%r15) */
- 0xb9, 0x04, 0x00, 0x23, /* lgr %r2, %r3 */
+ 0xe3, 0x30, 0xf0, 0x00, 0x00, 0x04, /* lg %r3, 0(%r15) */
+ 0xe3, 0x20, 0xf0, 0x00, 0x00, 0x24, /* stg %r2, 0(%r15) */
+ 0xb9, 0x04, 0x00, 0x23, /* lgr %r2, %r3 */
};
add_insns (buf, sizeof buf);
}
@@ -2647,8 +2632,10 @@ s390x_emit_stack_adjust (int n)
{
unsigned char buf[] = {
/* aghi %r15, 8*n */
- 0xa7, 0xfb,
- (unsigned char) (n * 8 >> 8), (unsigned char) (n * 8),
+ 0xa7,
+ 0xfb,
+ (unsigned char) (n * 8 >> 8),
+ (unsigned char) (n * 8),
};
add_insns (buf, sizeof buf);
}
@@ -2670,11 +2657,11 @@ s390x_emit_void_call_2 (CORE_ADDR fn, int arg1)
{
/* FN's prototype is `void(*fn)(int,LONGEST)'. */
static const unsigned char buf[] = {
- 0xb9, 0x04, 0x00, 0x32, /* lgr %r3, %r2 */
- 0xb9, 0x04, 0x00, 0xc2, /* lgr %r12, %r2 */
+ 0xb9, 0x04, 0x00, 0x32, /* lgr %r3, %r2 */
+ 0xb9, 0x04, 0x00, 0xc2, /* lgr %r12, %r2 */
};
static const unsigned char buf2[] = {
- 0xb9, 0x04, 0x00, 0x2c, /* lgr %r2, %r12 */
+ 0xb9, 0x04, 0x00, 0x2c, /* lgr %r2, %r12 */
};
add_insns (buf, sizeof buf);
s390x_emit_const (arg1);
@@ -2688,10 +2675,10 @@ static void
s390x_emit_eq_goto (int *offset_p, int *size_p)
{
static const unsigned char buf[] = {
- 0xe3, 0x20, 0xf0, 0x00, 0x00, 0x20, /* cg %r2, 0(%r15) */
+ 0xe3, 0x20, 0xf0, 0x00, 0x00, 0x20, /* cg %r2, 0(%r15) */
0xe3, 0x20, 0xf0, 0x08, 0x00, 0x04, /* lg %r2, 8(%r15) */
- 0x41, 0xf0, 0xf0, 0x10, /* la %r15, 16(%r15) */
- 0xc0, 0x84, 0x00, 0x00, 0x00, 0x00, /* jge <fillme> */
+ 0x41, 0xf0, 0xf0, 0x10, /* la %r15, 16(%r15) */
+ 0xc0, 0x84, 0x00, 0x00, 0x00, 0x00, /* jge <fillme> */
};
add_insns (buf, sizeof buf);
if (offset_p)
@@ -2706,10 +2693,10 @@ static void
s390x_emit_ne_goto (int *offset_p, int *size_p)
{
static const unsigned char buf[] = {
- 0xe3, 0x20, 0xf0, 0x00, 0x00, 0x20, /* cg %r2, 0(%r15) */
+ 0xe3, 0x20, 0xf0, 0x00, 0x00, 0x20, /* cg %r2, 0(%r15) */
0xe3, 0x20, 0xf0, 0x08, 0x00, 0x04, /* lg %r2, 8(%r15) */
- 0x41, 0xf0, 0xf0, 0x10, /* la %r15, 16(%r15) */
- 0xc0, 0x74, 0x00, 0x00, 0x00, 0x00, /* jgne <fillme> */
+ 0x41, 0xf0, 0xf0, 0x10, /* la %r15, 16(%r15) */
+ 0xc0, 0x74, 0x00, 0x00, 0x00, 0x00, /* jgne <fillme> */
};
add_insns (buf, sizeof buf);
if (offset_p)
@@ -2724,10 +2711,10 @@ static void
s390x_emit_lt_goto (int *offset_p, int *size_p)
{
static const unsigned char buf[] = {
- 0xe3, 0x20, 0xf0, 0x00, 0x00, 0x20, /* cg %r2, 0(%r15) */
+ 0xe3, 0x20, 0xf0, 0x00, 0x00, 0x20, /* cg %r2, 0(%r15) */
0xe3, 0x20, 0xf0, 0x08, 0x00, 0x04, /* lg %r2, 8(%r15) */
- 0x41, 0xf0, 0xf0, 0x10, /* la %r15, 16(%r15) */
- 0xc0, 0x24, 0x00, 0x00, 0x00, 0x00, /* jgh <fillme> */
+ 0x41, 0xf0, 0xf0, 0x10, /* la %r15, 16(%r15) */
+ 0xc0, 0x24, 0x00, 0x00, 0x00, 0x00, /* jgh <fillme> */
};
add_insns (buf, sizeof buf);
if (offset_p)
@@ -2742,10 +2729,10 @@ static void
s390x_emit_le_goto (int *offset_p, int *size_p)
{
static const unsigned char buf[] = {
- 0xe3, 0x20, 0xf0, 0x00, 0x00, 0x20, /* cg %r2, 0(%r15) */
+ 0xe3, 0x20, 0xf0, 0x00, 0x00, 0x20, /* cg %r2, 0(%r15) */
0xe3, 0x20, 0xf0, 0x08, 0x00, 0x04, /* lg %r2, 8(%r15) */
- 0x41, 0xf0, 0xf0, 0x10, /* la %r15, 16(%r15) */
- 0xc0, 0xa4, 0x00, 0x00, 0x00, 0x00, /* jghe <fillme> */
+ 0x41, 0xf0, 0xf0, 0x10, /* la %r15, 16(%r15) */
+ 0xc0, 0xa4, 0x00, 0x00, 0x00, 0x00, /* jghe <fillme> */
};
add_insns (buf, sizeof buf);
if (offset_p)
@@ -2760,10 +2747,10 @@ static void
s390x_emit_gt_goto (int *offset_p, int *size_p)
{
static const unsigned char buf[] = {
- 0xe3, 0x20, 0xf0, 0x00, 0x00, 0x20, /* cg %r2, 0(%r15) */
+ 0xe3, 0x20, 0xf0, 0x00, 0x00, 0x20, /* cg %r2, 0(%r15) */
0xe3, 0x20, 0xf0, 0x08, 0x00, 0x04, /* lg %r2, 8(%r15) */
- 0x41, 0xf0, 0xf0, 0x10, /* la %r15, 16(%r15) */
- 0xc0, 0x44, 0x00, 0x00, 0x00, 0x00, /* jgl <fillme> */
+ 0x41, 0xf0, 0xf0, 0x10, /* la %r15, 16(%r15) */
+ 0xc0, 0x44, 0x00, 0x00, 0x00, 0x00, /* jgl <fillme> */
};
add_insns (buf, sizeof buf);
if (offset_p)
@@ -2778,10 +2765,10 @@ static void
s390x_emit_ge_goto (int *offset_p, int *size_p)
{
static const unsigned char buf[] = {
- 0xe3, 0x20, 0xf0, 0x00, 0x00, 0x20, /* cg %r2, 0(%r15) */
+ 0xe3, 0x20, 0xf0, 0x00, 0x00, 0x20, /* cg %r2, 0(%r15) */
0xe3, 0x20, 0xf0, 0x08, 0x00, 0x04, /* lg %r2, 8(%r15) */
- 0x41, 0xf0, 0xf0, 0x10, /* la %r15, 16(%r15) */
- 0xc0, 0xc4, 0x00, 0x00, 0x00, 0x00, /* jgle <fillme> */
+ 0x41, 0xf0, 0xf0, 0x10, /* la %r15, 16(%r15) */
+ 0xc0, 0xc4, 0x00, 0x00, 0x00, 0x00, /* jgle <fillme> */
};
add_insns (buf, sizeof buf);
if (offset_p)
@@ -2792,46 +2779,21 @@ s390x_emit_ge_goto (int *offset_p, int *size_p)
/* The "emit_ops" structure for s390x. */
-static struct emit_ops s390x_emit_ops =
- {
- s390x_emit_prologue,
- s390x_emit_epilogue,
- s390x_emit_add,
- s390x_emit_sub,
- s390x_emit_mul,
- s390x_emit_lsh,
- s390x_emit_rsh_signed,
- s390x_emit_rsh_unsigned,
- s390x_emit_ext,
- s390x_emit_log_not,
- s390x_emit_bit_and,
- s390x_emit_bit_or,
- s390x_emit_bit_xor,
- s390x_emit_bit_not,
- s390x_emit_equal,
- s390x_emit_less_signed,
- s390x_emit_less_unsigned,
- s390x_emit_ref,
- s390x_emit_if_goto,
- s390_emit_goto,
- s390_write_goto_address,
- s390x_emit_const,
- s390x_emit_call,
- s390x_emit_reg,
- s390x_emit_pop,
- s390x_emit_stack_flush,
- s390x_emit_zero_ext,
- s390x_emit_swap,
- s390x_emit_stack_adjust,
- s390x_emit_int_call_1,
- s390x_emit_void_call_2,
- s390x_emit_eq_goto,
- s390x_emit_ne_goto,
- s390x_emit_lt_goto,
- s390x_emit_le_goto,
- s390x_emit_gt_goto,
- s390x_emit_ge_goto
- };
+static struct emit_ops s390x_emit_ops = {
+ s390x_emit_prologue, s390x_emit_epilogue, s390x_emit_add,
+ s390x_emit_sub, s390x_emit_mul, s390x_emit_lsh,
+ s390x_emit_rsh_signed, s390x_emit_rsh_unsigned, s390x_emit_ext,
+ s390x_emit_log_not, s390x_emit_bit_and, s390x_emit_bit_or,
+ s390x_emit_bit_xor, s390x_emit_bit_not, s390x_emit_equal,
+ s390x_emit_less_signed, s390x_emit_less_unsigned, s390x_emit_ref,
+ s390x_emit_if_goto, s390_emit_goto, s390_write_goto_address,
+ s390x_emit_const, s390x_emit_call, s390x_emit_reg,
+ s390x_emit_pop, s390x_emit_stack_flush, s390x_emit_zero_ext,
+ s390x_emit_swap, s390x_emit_stack_adjust, s390x_emit_int_call_1,
+ s390x_emit_void_call_2, s390x_emit_eq_goto, s390x_emit_ne_goto,
+ s390x_emit_lt_goto, s390x_emit_le_goto, s390x_emit_gt_goto,
+ s390x_emit_ge_goto
+};
#endif
/* The "emit_ops" target ops method. */
diff --git a/gdbserver/linux-s390-tdesc.h b/gdbserver/linux-s390-tdesc.h
index 71ed366..3d4497b 100644
--- a/gdbserver/linux-s390-tdesc.h
+++ b/gdbserver/linux-s390-tdesc.h
@@ -24,7 +24,8 @@
it's sufficient to pass only the register set here. This, together with
the ABI known at IPA compile time, maps to a tdesc. */
-enum s390_linux_tdesc {
+enum s390_linux_tdesc
+{
S390_TDESC_32,
S390_TDESC_32V1,
S390_TDESC_32V2,
diff --git a/gdbserver/linux-sh-low.cc b/gdbserver/linux-sh-low.cc
index 782b829..dba9d5b 100644
--- a/gdbserver/linux-sh-low.cc
+++ b/gdbserver/linux-sh-low.cc
@@ -24,13 +24,11 @@
class sh_target : public linux_process_target
{
public:
-
const regs_info *get_regs_info () override;
const gdb_byte *sw_breakpoint_from_kind (int kind, int *size) override;
protected:
-
void low_arch_setup () override;
bool low_cannot_fetch_register (int regno) override;
@@ -82,17 +80,49 @@ extern const struct target_desc *tdesc_sh;
/* Currently, don't check/send MQ. */
static int sh_regmap[] = {
- 0, 4, 8, 12, 16, 20, 24, 28,
- 32, 36, 40, 44, 48, 52, 56, 60,
-
- REG_PC*4, REG_PR*4, REG_GBR*4, -1,
- REG_MACH*4, REG_MACL*4, REG_SR*4,
- REG_FPUL*4, REG_FPSCR*4,
-
- REG_FPREG0*4+0, REG_FPREG0*4+4, REG_FPREG0*4+8, REG_FPREG0*4+12,
- REG_FPREG0*4+16, REG_FPREG0*4+20, REG_FPREG0*4+24, REG_FPREG0*4+28,
- REG_FPREG0*4+32, REG_FPREG0*4+36, REG_FPREG0*4+40, REG_FPREG0*4+44,
- REG_FPREG0*4+48, REG_FPREG0*4+52, REG_FPREG0*4+56, REG_FPREG0*4+60,
+ 0,
+ 4,
+ 8,
+ 12,
+ 16,
+ 20,
+ 24,
+ 28,
+ 32,
+ 36,
+ 40,
+ 44,
+ 48,
+ 52,
+ 56,
+ 60,
+
+ REG_PC * 4,
+ REG_PR * 4,
+ REG_GBR * 4,
+ -1,
+ REG_MACH * 4,
+ REG_MACL * 4,
+ REG_SR * 4,
+ REG_FPUL * 4,
+ REG_FPSCR * 4,
+
+ REG_FPREG0 * 4 + 0,
+ REG_FPREG0 * 4 + 4,
+ REG_FPREG0 * 4 + 8,
+ REG_FPREG0 * 4 + 12,
+ REG_FPREG0 * 4 + 16,
+ REG_FPREG0 * 4 + 20,
+ REG_FPREG0 * 4 + 24,
+ REG_FPREG0 * 4 + 28,
+ REG_FPREG0 * 4 + 32,
+ REG_FPREG0 * 4 + 36,
+ REG_FPREG0 * 4 + 40,
+ REG_FPREG0 * 4 + 44,
+ REG_FPREG0 * 4 + 48,
+ REG_FPREG0 * 4 + 52,
+ REG_FPREG0 * 4 + 56,
+ REG_FPREG0 * 4 + 60,
};
bool
@@ -137,7 +167,8 @@ sh_target::low_breakpoint_at (CORE_ADDR where)
/* Provide only a fill function for the general register set. ps_lgetregs
will use this for NPTL support. */
-static void sh_fill_gregset (struct regcache *regcache, void *buf)
+static void
+sh_fill_gregset (struct regcache *regcache, void *buf)
{
int i;
@@ -146,30 +177,22 @@ static void sh_fill_gregset (struct regcache *regcache, void *buf)
collect_register (regcache, i, (char *) buf + sh_regmap[i]);
}
-static struct regset_info sh_regsets[] = {
- { 0, 0, 0, 0, GENERAL_REGS, sh_fill_gregset, NULL },
- NULL_REGSET
+static struct regset_info sh_regsets[]
+ = { { 0, 0, 0, 0, GENERAL_REGS, sh_fill_gregset, NULL }, NULL_REGSET };
+
+static struct regsets_info sh_regsets_info = {
+ sh_regsets, /* regsets */
+ 0, /* num_regsets */
+ NULL, /* disabled_regsets */
+};
+
+static struct usrregs_info sh_usrregs_info = {
+ sh_num_regs,
+ sh_regmap,
};
-static struct regsets_info sh_regsets_info =
- {
- sh_regsets, /* regsets */
- 0, /* num_regsets */
- NULL, /* disabled_regsets */
- };
-
-static struct usrregs_info sh_usrregs_info =
- {
- sh_num_regs,
- sh_regmap,
- };
-
-static struct regs_info myregs_info =
- {
- NULL, /* regset_bitmap */
- &sh_usrregs_info,
- &sh_regsets_info
- };
+static struct regs_info myregs_info = { NULL, /* regset_bitmap */
+ &sh_usrregs_info, &sh_regsets_info };
const regs_info *
sh_target::get_regs_info ()
diff --git a/gdbserver/linux-sparc-low.cc b/gdbserver/linux-sparc-low.cc
index 660e832..7991d79 100644
--- a/gdbserver/linux-sparc-low.cc
+++ b/gdbserver/linux-sparc-low.cc
@@ -47,13 +47,11 @@
class sparc_target : public linux_process_target
{
public:
-
const regs_info *get_regs_info () override;
const gdb_byte *sw_breakpoint_from_kind (int kind, int *size) override;
protected:
-
void low_arch_setup () override;
bool low_cannot_fetch_register (int regno) override;
@@ -92,34 +90,39 @@ sparc_target::low_get_pc (regcache *regcache)
static int sparc_regmap[] = {
/* These offsets correspond to GET/SETREGSET. */
- -1, 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, /* g0 .. g7 */
- 7*8, 8*8, 9*8, 10*8, 11*8, 12*8, 13*8, 14*8, /* o0 .. o5, sp, o7 */
- -1, -1, -1, -1, -1, -1, -1, -1, /* l0 .. l7 */
- -1, -1, -1, -1, -1, -1, -1, -1, /* i0 .. i5, fp, i7 */
+ -1, 0 * 8, 1 * 8, 2 * 8, 3 * 8, 4 * 8, 5 * 8, 6 * 8, /* g0 .. g7 */
+ 7 * 8, 8 * 8, 9 * 8, 10 * 8, 11 * 8, 12 * 8, 13 * 8,
+ 14 * 8, /* o0 .. o5, sp, o7 */
+ -1, -1, -1, -1, -1, -1, -1, -1, /* l0 .. l7 */
+ -1, -1, -1, -1, -1, -1, -1, -1, /* i0 .. i5, fp, i7 */
/* Floating point registers offsets correspond to GET/SETFPREGSET. */
- 0*4, 1*4, 2*4, 3*4, 4*4, 5*4, 6*4, 7*4, /* f0 .. f7 */
- 8*4, 9*4, 10*4, 11*4, 12*4, 13*4, 14*4, 15*4, /* f8 .. f15 */
- 16*4, 17*4, 18*4, 19*4, 20*4, 21*4, 22*4, 23*4, /* f16 .. f23 */
- 24*4, 25*4, 26*4, 27*4, 28*4, 29*4, 30*4, 31*4, /* f24 .. f31 */
+ 0 * 4, 1 * 4, 2 * 4, 3 * 4, 4 * 4, 5 * 4, 6 * 4, 7 * 4, /* f0 .. f7 */
+ 8 * 4, 9 * 4, 10 * 4, 11 * 4, 12 * 4, 13 * 4, 14 * 4,
+ 15 * 4, /* f8 .. f15 */
+ 16 * 4, 17 * 4, 18 * 4, 19 * 4, 20 * 4, 21 * 4, 22 * 4,
+ 23 * 4, /* f16 .. f23 */
+ 24 * 4, 25 * 4, 26 * 4, 27 * 4, 28 * 4, 29 * 4, 30 * 4,
+ 31 * 4, /* f24 .. f31 */
/* F32 offset starts next to f31: 31*4+4 = 16 * 8. */
- 16*8, 17*8, 18*8, 19*8, 20*8, 21*8, 22*8, 23*8, /* f32 .. f46 */
- 24*8, 25*8, 26*8, 27*8, 28*8, 29*8, 30*8, 31*8, /* f48 .. f62 */
-
- 17 *8, /* pc */
- 18 *8, /* npc */
- 16 *8, /* state */
- /* FSR offset also corresponds to GET/SETFPREGSET, ans is placed
+ 16 * 8, 17 * 8, 18 * 8, 19 * 8, 20 * 8, 21 * 8, 22 * 8,
+ 23 * 8, /* f32 .. f46 */
+ 24 * 8, 25 * 8, 26 * 8, 27 * 8, 28 * 8, 29 * 8, 30 * 8,
+ 31 * 8, /* f48 .. f62 */
+
+ 17 * 8, /* pc */
+ 18 * 8, /* npc */
+ 16 * 8, /* state */
+ /* FSR offset also corresponds to GET/SETFPREGSET, ans is placed
next to f62. */
- 32 *8, /* fsr */
- -1, /* fprs */
- /* Y register is 32-bits length, but gdb takes care of that. */
- 19 *8, /* y */
+ 32 * 8, /* fsr */
+ -1, /* fprs */
+ /* Y register is 32-bits length, but gdb takes care of that. */
+ 19 * 8, /* y */
};
-
struct regs_range_t
{
int regno_start;
@@ -127,16 +130,16 @@ struct regs_range_t
};
static const struct regs_range_t gregs_ranges[] = {
- { 0, 31 }, /* g0 .. i7 */
- { 80, 82 }, /* pc .. state */
- { 84, 85 } /* fprs .. y */
+ { 0, 31 }, /* g0 .. i7 */
+ { 80, 82 }, /* pc .. state */
+ { 84, 85 } /* fprs .. y */
};
#define N_GREGS_RANGES (sizeof (gregs_ranges) / sizeof (struct regs_range_t))
static const struct regs_range_t fpregs_ranges[] = {
- { 32, 79 }, /* f0 .. f62 */
- { 83, 83 } /* fsr */
+ { 32, 79 }, /* f0 .. f62 */
+ { 83, 83 } /* fsr */
};
#define N_FPREGS_RANGES (sizeof (fpregs_ranges) / sizeof (struct regs_range_t))
@@ -168,8 +171,8 @@ sparc_fill_gregset_to_stack (struct regcache *regcache, const void *buf)
/* These registers have to be stored in the stack. */
memcpy (&addr,
- ((char *) buf) + sparc_regmap[find_regno (regcache->tdesc, "sp")],
- sizeof (addr));
+ ((char *) buf) + sparc_regmap[find_regno (regcache->tdesc, "sp")],
+ sizeof (addr));
addr += BIAS;
@@ -189,9 +192,9 @@ sparc_fill_gregset (struct regcache *regcache, void *buf)
for (range = 0; range < N_GREGS_RANGES; range++)
for (i = gregs_ranges[range].regno_start;
- i <= gregs_ranges[range].regno_end; i++)
+ i <= gregs_ranges[range].regno_end; i++)
if (sparc_regmap[i] != -1)
- collect_register (regcache, i, ((char *) buf) + sparc_regmap[i]);
+ collect_register (regcache, i, ((char *) buf) + sparc_regmap[i]);
sparc_fill_gregset_to_stack (regcache, buf);
}
@@ -204,9 +207,8 @@ sparc_fill_fpregset (struct regcache *regcache, void *buf)
for (range = 0; range < N_FPREGS_RANGES; range++)
for (i = fpregs_ranges[range].regno_start;
- i <= fpregs_ranges[range].regno_end; i++)
+ i <= fpregs_ranges[range].regno_end; i++)
collect_register (regcache, i, ((char *) buf) + sparc_regmap[i]);
-
}
static void
@@ -220,8 +222,8 @@ sparc_store_gregset_from_stack (struct regcache *regcache, const void *buf)
/* These registers have to be obtained from the stack. */
memcpy (&addr,
- ((char *) buf) + sparc_regmap[find_regno (regcache->tdesc, "sp")],
- sizeof (addr));
+ ((char *) buf) + sparc_regmap[find_regno (regcache->tdesc, "sp")],
+ sizeof (addr));
addr += BIAS;
@@ -244,11 +246,11 @@ sparc_store_gregset (struct regcache *regcache, const void *buf)
for (range = 0; range < N_GREGS_RANGES; range++)
for (i = gregs_ranges[range].regno_start;
- i <= gregs_ranges[range].regno_end; i++)
+ i <= gregs_ranges[range].regno_end; i++)
if (sparc_regmap[i] != -1)
- supply_register (regcache, i, ((char *) buf) + sparc_regmap[i]);
+ supply_register (regcache, i, ((char *) buf) + sparc_regmap[i]);
else
- supply_register (regcache, i, zerobuf);
+ supply_register (regcache, i, zerobuf);
sparc_store_gregset_from_stack (regcache, buf);
}
@@ -261,14 +263,11 @@ sparc_store_fpregset (struct regcache *regcache, const void *buf)
for (range = 0; range < N_FPREGS_RANGES; range++)
for (i = fpregs_ranges[range].regno_start;
- i <= fpregs_ranges[range].regno_end;
- i++)
+ i <= fpregs_ranges[range].regno_end; i++)
supply_register (regcache, i, ((char *) buf) + sparc_regmap[i]);
}
-static const gdb_byte sparc_breakpoint[INSN_SIZE] = {
- 0x91, 0xd0, 0x20, 0x01
-};
+static const gdb_byte sparc_breakpoint[INSN_SIZE] = { 0x91, 0xd0, 0x20, 0x01 };
#define sparc_breakpoint_len INSN_SIZE
/* Implementation of target ops method "sw_breakpoint_from_kind". */
@@ -302,37 +301,28 @@ sparc_target::low_arch_setup ()
current_process ()->tdesc = tdesc_sparc64;
}
-static struct regset_info sparc_regsets[] = {
- { PTRACE_GETREGS, PTRACE_SETREGS, 0, sizeof (elf_gregset_t),
- GENERAL_REGS,
- sparc_fill_gregset, sparc_store_gregset },
- { PTRACE_GETFPREGS, PTRACE_SETFPREGS, 0, sizeof (fpregset_t),
- FP_REGS,
- sparc_fill_fpregset, sparc_store_fpregset },
- NULL_REGSET
+static struct regset_info sparc_regsets[]
+ = { { PTRACE_GETREGS, PTRACE_SETREGS, 0, sizeof (elf_gregset_t),
+ GENERAL_REGS, sparc_fill_gregset, sparc_store_gregset },
+ { PTRACE_GETFPREGS, PTRACE_SETFPREGS, 0, sizeof (fpregset_t), FP_REGS,
+ sparc_fill_fpregset, sparc_store_fpregset },
+ NULL_REGSET };
+
+static struct regsets_info sparc_regsets_info = {
+ sparc_regsets, /* regsets */
+ 0, /* num_regsets */
+ NULL, /* disabled_regsets */
};
-static struct regsets_info sparc_regsets_info =
- {
- sparc_regsets, /* regsets */
- 0, /* num_regsets */
- NULL, /* disabled_regsets */
- };
-
-static struct usrregs_info sparc_usrregs_info =
- {
- sparc_num_regs,
- /* No regmap needs to be provided since this impl. doesn't use
+static struct usrregs_info sparc_usrregs_info
+ = { sparc_num_regs,
+ /* No regmap needs to be provided since this impl. doesn't use
USRREGS. */
- NULL
- };
-
-static struct regs_info myregs_info =
- {
- NULL, /* regset_bitmap */
- &sparc_usrregs_info,
- &sparc_regsets_info
- };
+ NULL };
+
+static struct regs_info myregs_info
+ = { NULL, /* regset_bitmap */
+ &sparc_usrregs_info, &sparc_regsets_info };
const regs_info *
sparc_target::get_regs_info ()
diff --git a/gdbserver/linux-tic6x-low.cc b/gdbserver/linux-tic6x-low.cc
index 9f4682d..8a1ff3c 100644
--- a/gdbserver/linux-tic6x-low.cc
+++ b/gdbserver/linux-tic6x-low.cc
@@ -43,13 +43,11 @@
class tic6x_target : public linux_process_target
{
public:
-
const regs_info *get_regs_info () override;
const gdb_byte *sw_breakpoint_from_kind (int kind, int *size) override;
protected:
-
void low_arch_setup () override;
bool low_cannot_fetch_register (int regno) override;
@@ -93,109 +91,79 @@ union tic6x_register
#if __BYTE_ORDER == __BIG_ENDIAN
static int tic6x_regmap_c64xp[] = {
/* A0 - A15 */
- 53, 52, 55, 54, 57, 56, 59, 58,
- 61, 60, 63, 62, 65, 64, 67, 66,
+ 53, 52, 55, 54, 57, 56, 59, 58, 61, 60, 63, 62, 65, 64, 67, 66,
/* B0 - B15 */
- 23, 22, 25, 24, 27, 26, 29, 28,
- 31, 30, 33, 32, 35, 34, 69, 68,
+ 23, 22, 25, 24, 27, 26, 29, 28, 31, 30, 33, 32, 35, 34, 69, 68,
/* CSR PC */
5, 4,
/* A16 - A31 */
- 37, 36, 39, 38, 41, 40, 43, 42,
- 45, 44, 47, 46, 49, 48, 51, 50,
+ 37, 36, 39, 38, 41, 40, 43, 42, 45, 44, 47, 46, 49, 48, 51, 50,
/* B16 - B31 */
- 7, 6, 9, 8, 11, 10, 13, 12,
- 15, 14, 17, 16, 19, 18, 21, 20,
+ 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18, 21, 20,
/* TSR, ILC, RILC */
- 1, 2, 3
+ 1, 2, 3
};
static int tic6x_regmap_c64x[] = {
/* A0 - A15 */
- 51, 50, 53, 52, 55, 54, 57, 56,
- 59, 58, 61, 60, 63, 62, 65, 64,
+ 51, 50, 53, 52, 55, 54, 57, 56, 59, 58, 61, 60, 63, 62, 65, 64,
/* B0 - B15 */
- 21, 20, 23, 22, 25, 24, 27, 26,
- 29, 28, 31, 30, 33, 32, 67, 66,
+ 21, 20, 23, 22, 25, 24, 27, 26, 29, 28, 31, 30, 33, 32, 67, 66,
/* CSR PC */
- 3, 2,
+ 3, 2,
/* A16 - A31 */
- 35, 34, 37, 36, 39, 38, 41, 40,
- 43, 42, 45, 44, 47, 46, 49, 48,
+ 35, 34, 37, 36, 39, 38, 41, 40, 43, 42, 45, 44, 47, 46, 49, 48,
/* B16 - B31 */
- 5, 4, 7, 6, 9, 8, 11, 10,
- 13, 12, 15, 14, 17, 16, 19, 18,
- -1, -1, -1
+ 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18, -1, -1, -1
};
static int tic6x_regmap_c62x[] = {
/* A0 - A15 */
- 19, 18, 21, 20, 23, 22, 25, 24,
- 27, 26, 29, 28, 31, 30, 33, 32,
+ 19, 18, 21, 20, 23, 22, 25, 24, 27, 26, 29, 28, 31, 30, 33, 32,
/* B0 - B15 */
- 5, 4, 7, 6, 9, 8, 11, 10,
- 13, 12, 15, 14, 17, 16, 35, 34,
+ 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 35, 34,
/* CSR, PC */
- 3, 2,
- -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1
+ 3, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
};
#else
static int tic6x_regmap_c64xp[] = {
/* A0 - A15 */
- 52, 53, 54, 55, 56, 57, 58, 59,
- 60, 61, 62, 63, 64, 65, 66, 67,
+ 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67,
/* B0 - B15 */
- 22, 23, 24, 25, 26, 27, 28, 29,
- 30, 31, 32, 33, 34, 35, 68, 69,
+ 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 68, 69,
/* CSR PC */
- 4, 5,
+ 4, 5,
/* A16 - A31 */
- 36, 37, 38, 39, 40, 41, 42, 43,
- 44, 45, 46, 47, 48, 49, 50, 51,
+ 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51,
/* B16 -B31 */
- 6, 7, 8, 9, 10, 11, 12, 13,
- 14, 15, 16, 17, 18, 19, 20, 31,
+ 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 31,
/* TSR, ILC, RILC */
- 0, 3, 2
+ 0, 3, 2
};
static int tic6x_regmap_c64x[] = {
/* A0 - A15 */
- 50, 51, 52, 53, 54, 55, 56, 57,
- 58, 59, 60, 61, 62, 63, 64, 65,
+ 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65,
/* B0 - B15 */
- 20, 21, 22, 23, 24, 25, 26, 27,
- 28, 29, 30, 31, 32, 33, 66, 67,
+ 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 66, 67,
/* CSR PC */
- 2, 3,
+ 2, 3,
/* A16 - A31 */
- 34, 35, 36, 37, 38, 39, 40, 41,
- 42, 43, 44, 45, 46, 47, 48, 49,
+ 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49,
/* B16 - B31 */
- 4, 5, 6, 7, 8, 9, 10, 11,
- 12, 13, 14, 15, 16, 17, 18, 19,
- -1, -1, -1
+ 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, -1, -1, -1
};
static int tic6x_regmap_c62x[] = {
/* A0 - A15 */
- 18, 19, 20, 21, 22, 23, 24, 25,
- 26, 27, 28, 29, 30, 31, 32, 33,
+ 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
/* B0 - B15 */
- 4, 5, 6, 7, 8, 9, 10, 11,
- 12, 13, 14, 15, 16, 17, 34, 35,
+ 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 34, 35,
/* CSR PC */
- 2, 3,
- -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1
+ 2, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
};
#endif
@@ -213,16 +181,14 @@ tic6x_target::sw_breakpoint_from_kind (int kind, int *size)
return (const gdb_byte *) &tic6x_breakpoint;
}
-static struct usrregs_info tic6x_usrregs_info =
- {
- TIC6X_NUM_REGS,
- NULL, /* Set in tic6x_read_description. */
- };
+static struct usrregs_info tic6x_usrregs_info = {
+ TIC6X_NUM_REGS, NULL, /* Set in tic6x_read_description. */
+};
static const struct target_desc *
tic6x_read_description (enum c6x_feature feature)
{
- static target_desc *tdescs[C6X_LAST] = { };
+ static target_desc *tdescs[C6X_LAST] = {};
struct target_desc **tdesc = &tdescs[feature];
if (*tdesc == NULL)
@@ -288,8 +254,8 @@ tic6x_target::low_breakpoint_at (CORE_ADDR where)
/* Fetch the thread-local storage pointer for libthread_db. */
ps_err_e
-ps_get_thread_area (struct ps_prochandle *ph,
- lwpid_t lwpid, int idx, void **base)
+ps_get_thread_area (struct ps_prochandle *ph, lwpid_t lwpid, int idx,
+ void **base)
{
if (ptrace (PTRACE_GET_THREAD_AREA, lwpid, NULL, base) != 0)
return PS_ERR;
@@ -304,7 +270,7 @@ ps_get_thread_area (struct ps_prochandle *ph,
static void
tic6x_collect_register (struct regcache *regcache, int regno,
- union tic6x_register *reg)
+ union tic6x_register *reg)
{
union tic6x_register tmp_reg;
@@ -314,7 +280,7 @@ tic6x_collect_register (struct regcache *regcache, int regno,
static void
tic6x_supply_register (struct regcache *regcache, int regno,
- const union tic6x_register *reg)
+ const union tic6x_register *reg)
{
int offset = 0;
@@ -343,11 +309,10 @@ tic6x_store_gregset (struct regcache *regcache, const void *buf)
tic6x_supply_register (regcache, i, regset + tic6x_regmap[i]);
}
-static struct regset_info tic6x_regsets[] = {
- { PTRACE_GETREGS, PTRACE_SETREGS, 0, TIC6X_NUM_REGS * 4, GENERAL_REGS,
- tic6x_fill_gregset, tic6x_store_gregset },
- NULL_REGSET
-};
+static struct regset_info tic6x_regsets[]
+ = { { PTRACE_GETREGS, PTRACE_SETREGS, 0, TIC6X_NUM_REGS * 4, GENERAL_REGS,
+ tic6x_fill_gregset, tic6x_store_gregset },
+ NULL_REGSET };
void
tic6x_target::low_arch_setup ()
@@ -357,31 +322,31 @@ tic6x_target::low_arch_setup ()
enum c6x_feature feature = C6X_CORE;
/* Determine the CPU we're running on to find the register order. */
- __asm__ ("MVC .S2 CSR,%0" : "=r" (csr) :);
+ __asm__ ("MVC .S2 CSR,%0" : "=r"(csr) :);
cpuid = csr >> 24;
switch (cpuid)
{
case 0x00: /* C62x */
case 0x02: /* C67x */
tic6x_regmap = tic6x_regmap_c62x;
- tic6x_breakpoint = 0x0000a122; /* BNOP .S2 0,5 */
+ tic6x_breakpoint = 0x0000a122; /* BNOP .S2 0,5 */
feature = C6X_CORE;
break;
case 0x03: /* C67x+ */
tic6x_regmap = tic6x_regmap_c64x;
- tic6x_breakpoint = 0x0000a122; /* BNOP .S2 0,5 */
+ tic6x_breakpoint = 0x0000a122; /* BNOP .S2 0,5 */
feature = C6X_GP;
break;
case 0x0c: /* C64x */
tic6x_regmap = tic6x_regmap_c64x;
- tic6x_breakpoint = 0x0000a122; /* BNOP .S2 0,5 */
+ tic6x_breakpoint = 0x0000a122; /* BNOP .S2 0,5 */
feature = C6X_GP;
break;
case 0x10: /* C64x+ */
case 0x14: /* C674x */
case 0x15: /* C66x */
tic6x_regmap = tic6x_regmap_c64xp;
- tic6x_breakpoint = 0x56454314; /* illegal opcode */
+ tic6x_breakpoint = 0x56454314; /* illegal opcode */
feature = C6X_C6XP;
break;
default:
@@ -392,19 +357,15 @@ tic6x_target::low_arch_setup ()
current_process ()->tdesc = tic6x_read_description (feature);
}
-static struct regsets_info tic6x_regsets_info =
- {
- tic6x_regsets, /* regsets */
- 0, /* num_regsets */
- NULL, /* disabled_regsets */
- };
+static struct regsets_info tic6x_regsets_info = {
+ tic6x_regsets, /* regsets */
+ 0, /* num_regsets */
+ NULL, /* disabled_regsets */
+};
-static struct regs_info myregs_info =
- {
- NULL, /* regset_bitmap */
- &tic6x_usrregs_info,
- &tic6x_regsets_info
- };
+static struct regs_info myregs_info
+ = { NULL, /* regset_bitmap */
+ &tic6x_usrregs_info, &tic6x_regsets_info };
const regs_info *
tic6x_target::get_regs_info ()
@@ -415,8 +376,10 @@ tic6x_target::get_regs_info ()
#if GDB_SELF_TEST
#include "gdbsupport/selftest.h"
-namespace selftests {
-namespace tdesc {
+namespace selftests
+{
+namespace tdesc
+{
static void
tic6x_tdesc_test ()
{
@@ -424,8 +387,8 @@ tic6x_tdesc_test ()
SELF_CHECK (*tdesc_tic6x_c64x_linux == *tic6x_read_description (C6X_GP));
SELF_CHECK (*tdesc_tic6x_c64xp_linux == *tic6x_read_description (C6X_C6XP));
}
-}
-}
+} // namespace tdesc
+} // namespace selftests
#endif
/* The linux target ops object. */
diff --git a/gdbserver/linux-x86-low.cc b/gdbserver/linux-x86-low.cc
index 4a538b1..0732f9d 100644
--- a/gdbserver/linux-x86-low.cc
+++ b/gdbserver/linux-x86-low.cc
@@ -52,7 +52,6 @@ static target_desc_up tdesc_amd64_linux_no_xml;
#endif
static target_desc_up tdesc_i386_linux_no_xml;
-
static unsigned char jump_insn[] = { 0xe9, 0, 0, 0, 0 };
static unsigned char small_jump_insn[] = { 0x66, 0xe9, 0, 0 };
@@ -80,7 +79,7 @@ static const char xmltarget_amd64_linux_no_xml[] = "@<target>\
/* This definition comes from prctl.h, but some kernels may not have it. */
#ifndef PTRACE_ARCH_PRCTL
-#define PTRACE_ARCH_PRCTL 30
+#define PTRACE_ARCH_PRCTL 30
#endif
/* The following definitions come from prctl.h, but may be absent
@@ -99,26 +98,26 @@ static const char xmltarget_amd64_linux_no_xml[] = "@<target>\
class x86_target : public linux_process_target
{
public:
-
const regs_info *get_regs_info () override;
const gdb_byte *sw_breakpoint_from_kind (int kind, int *size) override;
bool supports_z_point_type (char z_type) override;
- void process_qsupported (gdb::array_view<const char * const> features) override;
+ void
+ process_qsupported (gdb::array_view<const char *const> features) override;
bool supports_tracepoints () override;
bool supports_fast_tracepoints () override;
- int install_fast_tracepoint_jump_pad
- (CORE_ADDR tpoint, CORE_ADDR tpaddr, CORE_ADDR collector,
- CORE_ADDR lockaddr, ULONGEST orig_size, CORE_ADDR *jump_entry,
- CORE_ADDR *trampoline, ULONGEST *trampoline_size,
- unsigned char *jjump_pad_insn, ULONGEST *jjump_pad_insn_size,
- CORE_ADDR *adjusted_insn_addr, CORE_ADDR *adjusted_insn_addr_end,
- char *err) override;
+ int install_fast_tracepoint_jump_pad (
+ CORE_ADDR tpoint, CORE_ADDR tpaddr, CORE_ADDR collector,
+ CORE_ADDR lockaddr, ULONGEST orig_size, CORE_ADDR *jump_entry,
+ CORE_ADDR *trampoline, ULONGEST *trampoline_size,
+ unsigned char *jjump_pad_insn, ULONGEST *jjump_pad_insn_size,
+ CORE_ADDR *adjusted_insn_addr, CORE_ADDR *adjusted_insn_addr_end,
+ char *err) override;
int get_min_fast_tracepoint_insn_len () override;
@@ -127,7 +126,6 @@ public:
int get_ipa_tdesc_idx () override;
protected:
-
void low_arch_setup () override;
bool low_cannot_fetch_register (int regno) override;
@@ -144,11 +142,11 @@ protected:
bool low_breakpoint_at (CORE_ADDR pc) override;
- int low_insert_point (raw_bkpt_type type, CORE_ADDR addr,
- int size, raw_breakpoint *bp) override;
+ int low_insert_point (raw_bkpt_type type, CORE_ADDR addr, int size,
+ raw_breakpoint *bp) override;
- int low_remove_point (raw_bkpt_type type, CORE_ADDR addr,
- int size, raw_breakpoint *bp) override;
+ int low_remove_point (raw_bkpt_type type, CORE_ADDR addr, int size,
+ raw_breakpoint *bp) override;
bool low_stopped_by_watchpoint () override;
@@ -160,7 +158,7 @@ protected:
/* Need to fix up i386 siginfo if host is amd64. */
bool low_siginfo_fixup (siginfo_t *native, gdb_byte *inf,
- int direction) override;
+ int direction) override;
arch_process_info *low_new_process () override;
@@ -183,7 +181,6 @@ protected:
void low_get_syscall_trapinfo (regcache *regcache, int *sysno) override;
private:
-
/* Update all the target description of all processes; a new GDB
connected, and it may or not support xml target descriptions. */
void update_xmltarget ();
@@ -205,13 +202,10 @@ struct arch_process_info
/* Mapping between the general-purpose registers in `struct user'
format and GDB's register array layout.
Note that the transfer layout uses 64-bit regs. */
-static /*const*/ int i386_regmap[] =
-{
- RAX * 8, RCX * 8, RDX * 8, RBX * 8,
- RSP * 8, RBP * 8, RSI * 8, RDI * 8,
- RIP * 8, EFLAGS * 8, CS * 8, SS * 8,
- DS * 8, ES * 8, FS * 8, GS * 8
-};
+static /*const*/ int i386_regmap[]
+ = { RAX * 8, RCX * 8, RDX * 8, RBX * 8, RSP * 8, RBP * 8,
+ RSI * 8, RDI * 8, RIP * 8, EFLAGS * 8, CS * 8, SS * 8,
+ DS * 8, ES * 8, FS * 8, GS * 8 };
#define I386_NUM_REGS (sizeof (i386_regmap) / sizeof (i386_regmap[0]))
@@ -219,33 +213,32 @@ static /*const*/ int i386_regmap[] =
#define ORIG_EAX ORIG_RAX
#define REGSIZE 8
-static const int x86_64_regmap[] =
-{
- RAX * 8, RBX * 8, RCX * 8, RDX * 8,
- RSI * 8, RDI * 8, RBP * 8, RSP * 8,
- R8 * 8, R9 * 8, R10 * 8, R11 * 8,
- R12 * 8, R13 * 8, R14 * 8, R15 * 8,
- RIP * 8, EFLAGS * 8, CS * 8, SS * 8,
- DS * 8, ES * 8, FS * 8, GS * 8,
- -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1,
- -1,
- -1, -1, -1, -1, -1, -1, -1, -1,
- ORIG_RAX * 8,
- 21 * 8, 22 * 8,
- -1, -1, -1, -1, /* MPX registers BND0 ... BND3. */
- -1, -1, /* MPX registers BNDCFGU, BNDSTATUS. */
- -1, -1, -1, -1, -1, -1, -1, -1, /* xmm16 ... xmm31 (AVX512) */
- -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, /* ymm16 ... ymm31 (AVX512) */
- -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, /* k0 ... k7 (AVX512) */
- -1, -1, -1, -1, -1, -1, -1, -1, /* zmm0 ... zmm31 (AVX512) */
- -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1,
- -1 /* pkru */
+static const int x86_64_regmap[] = {
+ RAX * 8, RBX * 8, RCX * 8, RDX * 8, RSI * 8, RDI * 8, RBP * 8,
+ RSP * 8, R8 * 8, R9 * 8, R10 * 8, R11 * 8, R12 * 8, R13 * 8,
+ R14 * 8, R15 * 8, RIP * 8, EFLAGS * 8, CS * 8, SS * 8, DS * 8,
+ ES * 8, FS * 8, GS * 8, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1,
+ -1, ORIG_RAX * 8, 21 * 8, 22 * 8, -1, -1, -1,
+ -1, /* MPX registers BND0 ... BND3. */
+ -1, -1, /* MPX registers BNDCFGU, BNDSTATUS. */
+ -1, -1, -1, -1, -1, -1, -1,
+ -1, /* xmm16 ... xmm31 (AVX512) */
+ -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, /* ymm16 ... ymm31 (AVX512) */
+ -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, /* k0 ... k7 (AVX512) */
+ -1, -1, -1, -1, -1, -1, -1,
+ -1, /* zmm0 ... zmm31 (AVX512) */
+ -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1 /* pkru */
};
#define X86_64_NUM_REGS (sizeof (x86_64_regmap) / sizeof (x86_64_regmap[0]))
@@ -255,13 +248,9 @@ static const int x86_64_regmap[] =
/* Mapping between the general-purpose registers in `struct user'
format and GDB's register array layout. */
-static /*const*/ int i386_regmap[] =
-{
- EAX * 4, ECX * 4, EDX * 4, EBX * 4,
- UESP * 4, EBP * 4, ESI * 4, EDI * 4,
- EIP * 4, EFL * 4, CS * 4, SS * 4,
- DS * 4, ES * 4, FS * 4, GS * 4
-};
+static /*const*/ int i386_regmap[]
+ = { EAX * 4, ECX * 4, EDX * 4, EBX * 4, UESP * 4, EBP * 4, ESI * 4, EDI * 4,
+ EIP * 4, EFL * 4, CS * 4, SS * 4, DS * 4, ES * 4, FS * 4, GS * 4 };
#define I386_NUM_REGS (sizeof (i386_regmap) / sizeof (i386_regmap[0]))
@@ -283,12 +272,11 @@ is_64bit_tdesc (thread_info *thread)
#endif
-
/* Called by libthread_db. */
ps_err_e
-ps_get_thread_area (struct ps_prochandle *ph,
- lwpid_t lwpid, int idx, void **base)
+ps_get_thread_area (struct ps_prochandle *ph, lwpid_t lwpid, int idx,
+ void **base)
{
#ifdef __x86_64__
lwp_info *lwp = find_lwp_pid (ptid_t (lwpid));
@@ -298,18 +286,18 @@ ps_get_thread_area (struct ps_prochandle *ph,
if (use_64bit)
{
switch (idx)
- {
- case FS:
- if (ptrace (PTRACE_ARCH_PRCTL, lwpid, base, ARCH_GET_FS) == 0)
- return PS_OK;
- break;
- case GS:
- if (ptrace (PTRACE_ARCH_PRCTL, lwpid, base, ARCH_GET_GS) == 0)
- return PS_OK;
- break;
- default:
- return PS_BADADDR;
- }
+ {
+ case FS:
+ if (ptrace (PTRACE_ARCH_PRCTL, lwpid, base, ARCH_GET_FS) == 0)
+ return PS_OK;
+ break;
+ case GS:
+ if (ptrace (PTRACE_ARCH_PRCTL, lwpid, base, ARCH_GET_GS) == 0)
+ return PS_OK;
+ break;
+ default:
+ return PS_BADADDR;
+ }
return PS_ERR;
}
#endif
@@ -317,8 +305,9 @@ ps_get_thread_area (struct ps_prochandle *ph,
{
unsigned int desc[4];
- if (ptrace (PTRACE_GET_THREAD_AREA, lwpid,
- (void *) (intptr_t) idx, (unsigned long) &desc) < 0)
+ if (ptrace (PTRACE_GET_THREAD_AREA, lwpid, (void *) (intptr_t) idx,
+ (unsigned long) &desc)
+ < 0)
return PS_ERR;
/* Ensure we properly extend the value to 64-bits for x86_64. */
@@ -344,10 +333,10 @@ x86_target::low_get_thread_area (int lwpid, CORE_ADDR *addr)
{
void *base;
if (ptrace (PTRACE_ARCH_PRCTL, lwpid, &base, ARCH_GET_FS) == 0)
- {
- *addr = (CORE_ADDR) (uintptr_t) base;
- return 0;
- }
+ {
+ *addr = (CORE_ADDR) (uintptr_t) base;
+ return 0;
+ }
return -1;
}
@@ -365,9 +354,9 @@ x86_target::low_get_thread_area (int lwpid, CORE_ADDR *addr)
idx = gs >> reg_thread_area;
- if (ptrace (PTRACE_GET_THREAD_AREA,
- lwpid_of (thr),
- (void *) (long) idx, (unsigned long) &desc) < 0)
+ if (ptrace (PTRACE_GET_THREAD_AREA, lwpid_of (thr), (void *) (long) idx,
+ (unsigned long) &desc)
+ < 0)
return -1;
*addr = desc[1];
@@ -375,8 +364,6 @@ x86_target::low_get_thread_area (int lwpid, CORE_ADDR *addr)
}
}
-
-
bool
x86_target::low_cannot_store_register (int regno)
{
@@ -437,8 +424,8 @@ x86_fill_gregset (struct regcache *regcache, void *buf)
if (register_size (regcache->tdesc, 0) == 8)
{
for (i = 0; i < X86_64_NUM_REGS; i++)
- if (x86_64_regmap[i] != -1)
- collect_register (regcache, i, ((char *) buf) + x86_64_regmap[i]);
+ if (x86_64_regmap[i] != -1)
+ collect_register (regcache, i, ((char *) buf) + x86_64_regmap[i]);
return;
}
@@ -449,7 +436,7 @@ x86_fill_gregset (struct regcache *regcache, void *buf)
/* Handle ORIG_EAX, which is not in i386_regmap. */
collect_register_i386 (regcache, find_regno (regcache->tdesc, "orig_eax"),
- ((char *) buf) + ORIG_EAX * REGSIZE);
+ ((char *) buf) + ORIG_EAX * REGSIZE);
}
static void
@@ -461,8 +448,8 @@ x86_store_gregset (struct regcache *regcache, const void *buf)
if (register_size (regcache->tdesc, 0) == 8)
{
for (i = 0; i < X86_64_NUM_REGS; i++)
- if (x86_64_regmap[i] != -1)
- supply_register (regcache, i, ((char *) buf) + x86_64_regmap[i]);
+ if (x86_64_regmap[i] != -1)
+ supply_register (regcache, i, ((char *) buf) + x86_64_regmap[i]);
return;
}
@@ -472,7 +459,7 @@ x86_store_gregset (struct regcache *regcache, const void *buf)
supply_register (regcache, i, ((char *) buf) + i386_regmap[i]);
supply_register_by_name (regcache, "orig_eax",
- ((char *) buf) + ORIG_EAX * REGSIZE);
+ ((char *) buf) + ORIG_EAX * REGSIZE);
}
static void
@@ -530,23 +517,19 @@ x86_store_xstateregset (struct regcache *regcache, const void *buf)
does work. Maybe the arch_setup routine could check whether it works
and update the supported regsets accordingly. */
-static struct regset_info x86_regsets[] =
-{
+static struct regset_info x86_regsets[] = {
#ifdef HAVE_PTRACE_GETREGS
- { PTRACE_GETREGS, PTRACE_SETREGS, 0, sizeof (elf_gregset_t),
- GENERAL_REGS,
+ { PTRACE_GETREGS, PTRACE_SETREGS, 0, sizeof (elf_gregset_t), GENERAL_REGS,
x86_fill_gregset, x86_store_gregset },
- { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_X86_XSTATE, 0,
- EXTENDED_REGS, x86_fill_xstateregset, x86_store_xstateregset },
-# ifndef __x86_64__
-# ifdef HAVE_PTRACE_GETFPXREGS
+ { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_X86_XSTATE, 0, EXTENDED_REGS,
+ x86_fill_xstateregset, x86_store_xstateregset },
+#ifndef __x86_64__
+#ifdef HAVE_PTRACE_GETFPXREGS
{ PTRACE_GETFPXREGS, PTRACE_SETFPXREGS, 0, sizeof (elf_fpxregset_t),
- EXTENDED_REGS,
- x86_fill_fpxregset, x86_store_fpxregset },
-# endif
-# endif
- { PTRACE_GETFPREGS, PTRACE_SETFPREGS, 0, sizeof (elf_fpregset_t),
- FP_REGS,
+ EXTENDED_REGS, x86_fill_fpxregset, x86_store_fpxregset },
+#endif
+#endif
+ { PTRACE_GETFPREGS, PTRACE_SETFPREGS, 0, sizeof (elf_fpregset_t), FP_REGS,
x86_fill_fpregset, x86_store_fpregset },
#endif /* HAVE_PTRACE_GETREGS */
NULL_REGSET
@@ -604,7 +587,6 @@ x86_target::low_decr_pc_after_break ()
return 1;
}
-
static const gdb_byte x86_breakpoint[] = { 0xCC };
#define x86_breakpoint_len 1
@@ -619,18 +601,13 @@ x86_target::low_breakpoint_at (CORE_ADDR pc)
return false;
}
-
+
/* Low-level function vector. */
-struct x86_dr_low_type x86_dr_low =
- {
- x86_linux_dr_set_control,
- x86_linux_dr_set_addr,
- x86_linux_dr_get_addr,
- x86_linux_dr_get_status,
- x86_linux_dr_get_control,
- sizeof (void *),
- };
-
+struct x86_dr_low_type x86_dr_low = {
+ x86_linux_dr_set_control, x86_linux_dr_set_addr, x86_linux_dr_get_addr,
+ x86_linux_dr_get_status, x86_linux_dr_get_control, sizeof (void *),
+};
+
/* Breakpoint/Watchpoint support. */
bool
@@ -649,8 +626,8 @@ x86_target::supports_z_point_type (char z_type)
}
int
-x86_target::low_insert_point (raw_bkpt_type type, CORE_ADDR addr,
- int size, raw_breakpoint *bp)
+x86_target::low_insert_point (raw_bkpt_type type, CORE_ADDR addr, int size,
+ raw_breakpoint *bp)
{
struct process_info *proc = current_process ();
@@ -660,12 +637,12 @@ x86_target::low_insert_point (raw_bkpt_type type, CORE_ADDR addr,
case raw_bkpt_type_write_wp:
case raw_bkpt_type_access_wp:
{
- enum target_hw_bp_type hw_type
- = raw_bkpt_type_to_target_hw_bp_type (type);
- struct x86_debug_reg_state *state
- = &proc->priv->arch_private->debug_reg_state;
+ enum target_hw_bp_type hw_type
+ = raw_bkpt_type_to_target_hw_bp_type (type);
+ struct x86_debug_reg_state *state
+ = &proc->priv->arch_private->debug_reg_state;
- return x86_dr_insert_watchpoint (state, hw_type, addr, size);
+ return x86_dr_insert_watchpoint (state, hw_type, addr, size);
}
default:
@@ -675,8 +652,8 @@ x86_target::low_insert_point (raw_bkpt_type type, CORE_ADDR addr,
}
int
-x86_target::low_remove_point (raw_bkpt_type type, CORE_ADDR addr,
- int size, raw_breakpoint *bp)
+x86_target::low_remove_point (raw_bkpt_type type, CORE_ADDR addr, int size,
+ raw_breakpoint *bp)
{
struct process_info *proc = current_process ();
@@ -686,12 +663,12 @@ x86_target::low_remove_point (raw_bkpt_type type, CORE_ADDR addr,
case raw_bkpt_type_write_wp:
case raw_bkpt_type_access_wp:
{
- enum target_hw_bp_type hw_type
- = raw_bkpt_type_to_target_hw_bp_type (type);
- struct x86_debug_reg_state *state
- = &proc->priv->arch_private->debug_reg_state;
+ enum target_hw_bp_type hw_type
+ = raw_bkpt_type_to_target_hw_bp_type (type);
+ struct x86_debug_reg_state *state
+ = &proc->priv->arch_private->debug_reg_state;
- return x86_dr_remove_watchpoint (state, hw_type, addr, size);
+ return x86_dr_remove_watchpoint (state, hw_type, addr, size);
}
default:
/* Unsupported. */
@@ -703,7 +680,8 @@ bool
x86_target::low_stopped_by_watchpoint ()
{
struct process_info *proc = current_process ();
- return x86_dr_stopped_by_watchpoint (&proc->priv->arch_private->debug_reg_state);
+ return x86_dr_stopped_by_watchpoint (
+ &proc->priv->arch_private->debug_reg_state);
}
CORE_ADDR
@@ -712,11 +690,11 @@ x86_target::low_stopped_data_address ()
struct process_info *proc = current_process ();
CORE_ADDR addr;
if (x86_dr_stopped_data_address (&proc->priv->arch_private->debug_reg_state,
- &addr))
+ &addr))
return addr;
return 0;
}
-
+
/* Called when a new process is created. */
arch_process_info *
@@ -757,10 +735,8 @@ void
x86_target::low_new_fork (process_info *parent, process_info *child)
{
/* These are allocated by linux_add_process. */
- gdb_assert (parent->priv != NULL
- && parent->priv->arch_private != NULL);
- gdb_assert (child->priv != NULL
- && child->priv->arch_private != NULL);
+ gdb_assert (parent->priv != NULL && parent->priv->arch_private != NULL);
+ gdb_assert (child->priv != NULL && child->priv->arch_private != NULL);
/* Linux kernel before 2.6.33 commit
72f674d203cd230426437cdcf7dd6f681dad8b0d
@@ -795,7 +771,7 @@ x86_debug_reg_state (pid_t pid)
return &proc->priv->arch_private->debug_reg_state;
}
-
+
/* When GDBSERVER is built as a 64-bit application on linux, the
PTRACE_GETSIGINFO data is always presented in 64-bit layout. Since
debugging a 32-bit inferior with a 64-bit GDBSERVER should look the same
@@ -818,17 +794,16 @@ x86_target::low_siginfo_fixup (siginfo_t *ptrace, gdb_byte *inf, int direction)
/* Is the inferior 32-bit? If so, then fixup the siginfo object. */
if (!is_64bit_tdesc (current_thread))
- return amd64_linux_siginfo_fixup_common (ptrace, inf, direction,
- FIXUP_32);
+ return amd64_linux_siginfo_fixup_common (ptrace, inf, direction, FIXUP_32);
/* No fixup for native x32 GDB. */
else if (!is_elf64 && sizeof (void *) == 8)
return amd64_linux_siginfo_fixup_common (ptrace, inf, direction,
- FIXUP_X32);
+ FIXUP_X32);
#endif
return false;
}
-
+
static int use_xml;
/* Format of XSAVE extended state is:
@@ -861,7 +836,7 @@ int have_ptrace_getfpxregs =
#else
0
#endif
-;
+ ;
/* Get Linux/x86 target description from running target. */
@@ -882,10 +857,10 @@ x86_linux_read_description (void)
if (sizeof (void *) == 4)
{
if (is_elf64 > 0)
- error (_("Can't debug 64-bit process with 32-bit GDBserver"));
+ error (_ ("Can't debug 64-bit process with 32-bit GDBserver"));
#ifndef __x86_64__
else if (machine == EM_X86_64)
- error (_("Can't debug x86-64 process with 32-bit GDBserver"));
+ error (_ ("Can't debug x86-64 process with 32-bit GDBserver"));
#endif
}
@@ -895,13 +870,13 @@ x86_linux_read_description (void)
elf_fpxregset_t fpxregs;
if (ptrace (PTRACE_GETFPXREGS, tid, 0, (long) &fpxregs) < 0)
- {
- have_ptrace_getfpxregs = 0;
- have_ptrace_getregset = 0;
- return i386_linux_read_description (X86_XSTATE_X87);
- }
+ {
+ have_ptrace_getfpxregs = 0;
+ have_ptrace_getregset = 0;
+ return i386_linux_read_description (X86_XSTATE_X87);
+ }
else
- have_ptrace_getfpxregs = 1;
+ have_ptrace_getfpxregs = 1;
}
#endif
@@ -912,10 +887,10 @@ x86_linux_read_description (void)
/* Don't use XML. */
#ifdef __x86_64__
if (machine == EM_X86_64)
- return tdesc_amd64_linux_no_xml.get ();
+ return tdesc_amd64_linux_no_xml.get ();
else
#endif
- return tdesc_i386_linux_no_xml.get ();
+ return tdesc_i386_linux_no_xml.get ();
}
if (have_ptrace_getregset == -1)
@@ -927,30 +902,29 @@ x86_linux_read_description (void)
iov.iov_len = sizeof (xstateregs);
/* Check if PTRACE_GETREGSET works. */
- if (ptrace (PTRACE_GETREGSET, tid,
- (unsigned int) NT_X86_XSTATE, (long) &iov) < 0)
- have_ptrace_getregset = 0;
+ if (ptrace (PTRACE_GETREGSET, tid, (unsigned int) NT_X86_XSTATE,
+ (long) &iov)
+ < 0)
+ have_ptrace_getregset = 0;
else
- {
- have_ptrace_getregset = 1;
-
- /* Get XCR0 from XSAVE extended state. */
- xcr0 = xstateregs[(I386_LINUX_XSAVE_XCR0_OFFSET
- / sizeof (uint64_t))];
-
- /* Use PTRACE_GETREGSET if it is available. */
- for (regset = x86_regsets;
- regset->fill_function != NULL; regset++)
- if (regset->get_request == PTRACE_GETREGSET)
- regset->size = X86_XSTATE_SIZE (xcr0);
- else if (regset->type != GENERAL_REGS)
- regset->size = 0;
- }
+ {
+ have_ptrace_getregset = 1;
+
+ /* Get XCR0 from XSAVE extended state. */
+ xcr0
+ = xstateregs[(I386_LINUX_XSAVE_XCR0_OFFSET / sizeof (uint64_t))];
+
+ /* Use PTRACE_GETREGSET if it is available. */
+ for (regset = x86_regsets; regset->fill_function != NULL; regset++)
+ if (regset->get_request == PTRACE_GETREGSET)
+ regset->size = X86_XSTATE_SIZE (xcr0);
+ else if (regset->type != GENERAL_REGS)
+ regset->size = 0;
+ }
}
/* Check the native XCR0 only if PTRACE_GETREGSET is available. */
- xcr0_features = (have_ptrace_getregset
- && (xcr0 & X86_XSTATE_ALL_MASK));
+ xcr0_features = (have_ptrace_getregset && (xcr0 & X86_XSTATE_ALL_MASK));
if (xcr0_features)
x86_xcr0 = xcr0;
@@ -961,13 +935,13 @@ x86_linux_read_description (void)
const target_desc *tdesc = NULL;
if (xcr0_features)
- {
- tdesc = amd64_linux_read_description (xcr0 & X86_XSTATE_ALL_MASK,
- !is_elf64);
- }
+ {
+ tdesc = amd64_linux_read_description (xcr0 & X86_XSTATE_ALL_MASK,
+ !is_elf64);
+ }
if (tdesc == NULL)
- tdesc = amd64_linux_read_description (X86_XSTATE_SSE_MASK, !is_elf64);
+ tdesc = amd64_linux_read_description (X86_XSTATE_SSE_MASK, !is_elf64);
return tdesc;
#endif
}
@@ -976,10 +950,10 @@ x86_linux_read_description (void)
const target_desc *tdesc = NULL;
if (xcr0_features)
- tdesc = i386_linux_read_description (xcr0 & X86_XSTATE_ALL_MASK);
+ tdesc = i386_linux_read_description (xcr0 & X86_XSTATE_ALL_MASK);
if (tdesc == NULL)
- tdesc = i386_linux_read_description (X86_XSTATE_SSE);
+ tdesc = i386_linux_read_description (X86_XSTATE_SSE);
return tdesc;
}
@@ -1014,7 +988,7 @@ x86_target::update_xmltarget ()
PTRACE_GETREGSET. */
void
-x86_target::process_qsupported (gdb::array_view<const char * const> features)
+x86_target::process_qsupported (gdb::array_view<const char *const> features)
{
/* Return if gdb doesn't support XML. If gdb sends "xmlRegisters="
with "i386" in qSupported query, it supports x86 XML target
@@ -1024,23 +998,22 @@ x86_target::process_qsupported (gdb::array_view<const char * const> features)
for (const char *feature : features)
{
if (startswith (feature, "xmlRegisters="))
- {
- char *copy = xstrdup (feature + 13);
-
- char *saveptr;
- for (char *p = strtok_r (copy, ",", &saveptr);
- p != NULL;
- p = strtok_r (NULL, ",", &saveptr))
- {
- if (strcmp (p, "i386") == 0)
- {
- use_xml = 1;
- break;
- }
- }
-
- free (copy);
- }
+ {
+ char *copy = xstrdup (feature + 13);
+
+ char *saveptr;
+ for (char *p = strtok_r (copy, ",", &saveptr); p != NULL;
+ p = strtok_r (NULL, ",", &saveptr))
+ {
+ if (strcmp (p, "i386") == 0)
+ {
+ use_xml = 1;
+ break;
+ }
+ }
+
+ free (copy);
+ }
}
update_xmltarget ();
@@ -1048,33 +1021,25 @@ x86_target::process_qsupported (gdb::array_view<const char * const> features)
/* Common for x86/x86-64. */
-static struct regsets_info x86_regsets_info =
- {
- x86_regsets, /* regsets */
- 0, /* num_regsets */
- NULL, /* disabled_regsets */
- };
+static struct regsets_info x86_regsets_info = {
+ x86_regsets, /* regsets */
+ 0, /* num_regsets */
+ NULL, /* disabled_regsets */
+};
#ifdef __x86_64__
-static struct regs_info amd64_linux_regs_info =
- {
- NULL, /* regset_bitmap */
- NULL, /* usrregs_info */
- &x86_regsets_info
- };
+static struct regs_info amd64_linux_regs_info = { NULL, /* regset_bitmap */
+ NULL, /* usrregs_info */
+ &x86_regsets_info };
#endif
-static struct usrregs_info i386_linux_usrregs_info =
- {
- I386_NUM_REGS,
- i386_regmap,
- };
+static struct usrregs_info i386_linux_usrregs_info = {
+ I386_NUM_REGS,
+ i386_regmap,
+};
-static struct regs_info i386_linux_regs_info =
- {
- NULL, /* regset_bitmap */
- &i386_linux_usrregs_info,
- &x86_regsets_info
- };
+static struct regs_info i386_linux_regs_info
+ = { NULL, /* regset_bitmap */
+ &i386_linux_usrregs_info, &x86_regsets_info };
const regs_info *
x86_target::get_regs_info ()
@@ -1145,7 +1110,7 @@ push_opcode (unsigned char *buf, const char *op)
unsigned long ul = strtoul (op, &endptr, 16);
if (endptr == op)
- break;
+ break;
*buf++ = ul;
op = endptr;
@@ -1162,18 +1127,12 @@ push_opcode (unsigned char *buf, const char *op)
tracepoint address. */
static int
-amd64_install_fast_tracepoint_jump_pad (CORE_ADDR tpoint, CORE_ADDR tpaddr,
- CORE_ADDR collector,
- CORE_ADDR lockaddr,
- ULONGEST orig_size,
- CORE_ADDR *jump_entry,
- CORE_ADDR *trampoline,
- ULONGEST *trampoline_size,
- unsigned char *jjump_pad_insn,
- ULONGEST *jjump_pad_insn_size,
- CORE_ADDR *adjusted_insn_addr,
- CORE_ADDR *adjusted_insn_addr_end,
- char *err)
+amd64_install_fast_tracepoint_jump_pad (
+ CORE_ADDR tpoint, CORE_ADDR tpaddr, CORE_ADDR collector, CORE_ADDR lockaddr,
+ ULONGEST orig_size, CORE_ADDR *jump_entry, CORE_ADDR *trampoline,
+ ULONGEST *trampoline_size, unsigned char *jjump_pad_insn,
+ ULONGEST *jjump_pad_insn_size, CORE_ADDR *adjusted_insn_addr,
+ CORE_ADDR *adjusted_insn_addr_end, char *err)
{
unsigned char buf[40];
int i, offset;
@@ -1194,14 +1153,22 @@ amd64_install_fast_tracepoint_jump_pad (CORE_ADDR tpoint, CORE_ADDR tpaddr,
buf[i++] = 0x51; /* push %rcx */
buf[i++] = 0x53; /* push %rbx */
buf[i++] = 0x50; /* push %rax */
- buf[i++] = 0x41; buf[i++] = 0x57; /* push %r15 */
- buf[i++] = 0x41; buf[i++] = 0x56; /* push %r14 */
- buf[i++] = 0x41; buf[i++] = 0x55; /* push %r13 */
- buf[i++] = 0x41; buf[i++] = 0x54; /* push %r12 */
- buf[i++] = 0x41; buf[i++] = 0x53; /* push %r11 */
- buf[i++] = 0x41; buf[i++] = 0x52; /* push %r10 */
- buf[i++] = 0x41; buf[i++] = 0x51; /* push %r9 */
- buf[i++] = 0x41; buf[i++] = 0x50; /* push %r8 */
+ buf[i++] = 0x41;
+ buf[i++] = 0x57; /* push %r15 */
+ buf[i++] = 0x41;
+ buf[i++] = 0x56; /* push %r14 */
+ buf[i++] = 0x41;
+ buf[i++] = 0x55; /* push %r13 */
+ buf[i++] = 0x41;
+ buf[i++] = 0x54; /* push %r12 */
+ buf[i++] = 0x41;
+ buf[i++] = 0x53; /* push %r11 */
+ buf[i++] = 0x41;
+ buf[i++] = 0x52; /* push %r10 */
+ buf[i++] = 0x41;
+ buf[i++] = 0x51; /* push %r9 */
+ buf[i++] = 0x41;
+ buf[i++] = 0x50; /* push %r8 */
buf[i++] = 0x9c; /* pushfq */
buf[i++] = 0x48; /* movabs <addr>,%rdi */
buf[i++] = 0xbf;
@@ -1212,26 +1179,26 @@ amd64_install_fast_tracepoint_jump_pad (CORE_ADDR tpoint, CORE_ADDR tpaddr,
/* Stack space for the collecting_t object. */
i = 0;
- i += push_opcode (&buf[i], "48 83 ec 18"); /* sub $0x18,%rsp */
- i += push_opcode (&buf[i], "48 b8"); /* mov <tpoint>,%rax */
+ i += push_opcode (&buf[i], "48 83 ec 18"); /* sub $0x18,%rsp */
+ i += push_opcode (&buf[i], "48 b8"); /* mov <tpoint>,%rax */
memcpy (buf + i, &tpoint, 8);
i += 8;
- i += push_opcode (&buf[i], "48 89 04 24"); /* mov %rax,(%rsp) */
+ i += push_opcode (&buf[i], "48 89 04 24"); /* mov %rax,(%rsp) */
i += push_opcode (&buf[i],
- "64 48 8b 04 25 00 00 00 00"); /* mov %fs:0x0,%rax */
- i += push_opcode (&buf[i], "48 89 44 24 08"); /* mov %rax,0x8(%rsp) */
+ "64 48 8b 04 25 00 00 00 00"); /* mov %fs:0x0,%rax */
+ i += push_opcode (&buf[i], "48 89 44 24 08"); /* mov %rax,0x8(%rsp) */
append_insns (&buildaddr, i, buf);
/* spin-lock. */
i = 0;
- i += push_opcode (&buf[i], "48 be"); /* movl <lockaddr>,%rsi */
+ i += push_opcode (&buf[i], "48 be"); /* movl <lockaddr>,%rsi */
memcpy (&buf[i], (void *) &lockaddr, 8);
i += 8;
i += push_opcode (&buf[i], "48 89 e1"); /* mov %rsp,%rcx */
- i += push_opcode (&buf[i], "31 c0"); /* xor %eax,%eax */
+ i += push_opcode (&buf[i], "31 c0"); /* xor %eax,%eax */
i += push_opcode (&buf[i], "f0 48 0f b1 0e"); /* lock cmpxchg %rcx,(%rsi) */
- i += push_opcode (&buf[i], "48 85 c0"); /* test %rax,%rax */
- i += push_opcode (&buf[i], "75 f4"); /* jne <again> */
+ i += push_opcode (&buf[i], "48 85 c0"); /* test %rax,%rax */
+ i += push_opcode (&buf[i], "75 f4"); /* jne <again> */
append_insns (&buildaddr, i, buf);
/* Set up the gdb_collect call. */
@@ -1239,11 +1206,11 @@ amd64_install_fast_tracepoint_jump_pad (CORE_ADDR tpoint, CORE_ADDR tpaddr,
register block. */
i = 0;
- i += push_opcode (&buf[i], "48 89 e6"); /* mov %rsp,%rsi */
- i += push_opcode (&buf[i], "48 83 c6 18"); /* add $0x18,%rsi */
+ i += push_opcode (&buf[i], "48 89 e6"); /* mov %rsp,%rsi */
+ i += push_opcode (&buf[i], "48 83 c6 18"); /* add $0x18,%rsi */
/* tpoint address may be 64-bit wide. */
- i += push_opcode (&buf[i], "48 bf"); /* movl <addr>,%rdi */
+ i += push_opcode (&buf[i], "48 bf"); /* movl <addr>,%rdi */
memcpy (buf + i, &tpoint, 8);
i += 8;
append_insns (&buildaddr, i, buf);
@@ -1251,23 +1218,23 @@ amd64_install_fast_tracepoint_jump_pad (CORE_ADDR tpoint, CORE_ADDR tpaddr,
/* The collector function being in the shared library, may be
>31-bits away off the jump pad. */
i = 0;
- i += push_opcode (&buf[i], "48 b8"); /* mov $collector,%rax */
+ i += push_opcode (&buf[i], "48 b8"); /* mov $collector,%rax */
memcpy (buf + i, &collector, 8);
i += 8;
- i += push_opcode (&buf[i], "ff d0"); /* callq *%rax */
+ i += push_opcode (&buf[i], "ff d0"); /* callq *%rax */
append_insns (&buildaddr, i, buf);
/* Clear the spin-lock. */
i = 0;
- i += push_opcode (&buf[i], "31 c0"); /* xor %eax,%eax */
- i += push_opcode (&buf[i], "48 a3"); /* mov %rax, lockaddr */
+ i += push_opcode (&buf[i], "31 c0"); /* xor %eax,%eax */
+ i += push_opcode (&buf[i], "48 a3"); /* mov %rax, lockaddr */
memcpy (buf + i, &lockaddr, 8);
i += 8;
append_insns (&buildaddr, i, buf);
/* Remove stack that had been used for the collect_t object. */
i = 0;
- i += push_opcode (&buf[i], "48 83 c4 18"); /* add $0x18,%rsp */
+ i += push_opcode (&buf[i], "48 83 c4 18"); /* add $0x18,%rsp */
append_insns (&buildaddr, i, buf);
/* Restore register state. */
@@ -1277,14 +1244,22 @@ amd64_install_fast_tracepoint_jump_pad (CORE_ADDR tpoint, CORE_ADDR tpaddr,
buf[i++] = 0xc4;
buf[i++] = 0x08;
buf[i++] = 0x9d; /* popfq */
- buf[i++] = 0x41; buf[i++] = 0x58; /* pop %r8 */
- buf[i++] = 0x41; buf[i++] = 0x59; /* pop %r9 */
- buf[i++] = 0x41; buf[i++] = 0x5a; /* pop %r10 */
- buf[i++] = 0x41; buf[i++] = 0x5b; /* pop %r11 */
- buf[i++] = 0x41; buf[i++] = 0x5c; /* pop %r12 */
- buf[i++] = 0x41; buf[i++] = 0x5d; /* pop %r13 */
- buf[i++] = 0x41; buf[i++] = 0x5e; /* pop %r14 */
- buf[i++] = 0x41; buf[i++] = 0x5f; /* pop %r15 */
+ buf[i++] = 0x41;
+ buf[i++] = 0x58; /* pop %r8 */
+ buf[i++] = 0x41;
+ buf[i++] = 0x59; /* pop %r9 */
+ buf[i++] = 0x41;
+ buf[i++] = 0x5a; /* pop %r10 */
+ buf[i++] = 0x41;
+ buf[i++] = 0x5b; /* pop %r11 */
+ buf[i++] = 0x41;
+ buf[i++] = 0x5c; /* pop %r12 */
+ buf[i++] = 0x41;
+ buf[i++] = 0x5d; /* pop %r13 */
+ buf[i++] = 0x41;
+ buf[i++] = 0x5e; /* pop %r14 */
+ buf[i++] = 0x41;
+ buf[i++] = 0x5f; /* pop %r15 */
buf[i++] = 0x58; /* pop %rax */
buf[i++] = 0x5b; /* pop %rbx */
buf[i++] = 0x59; /* pop %rcx */
@@ -1307,8 +1282,9 @@ amd64_install_fast_tracepoint_jump_pad (CORE_ADDR tpoint, CORE_ADDR tpaddr,
if (loffset > INT_MAX || loffset < INT_MIN)
{
sprintf (err,
- "E.Jump back from jump pad too far from tracepoint "
- "(offset 0x%" PRIx64 " > int32).", loffset);
+ "E.Jump back from jump pad too far from tracepoint "
+ "(offset 0x%" PRIx64 " > int32).",
+ loffset);
return 1;
}
@@ -1325,8 +1301,9 @@ amd64_install_fast_tracepoint_jump_pad (CORE_ADDR tpoint, CORE_ADDR tpaddr,
if (loffset > INT_MAX || loffset < INT_MIN)
{
sprintf (err,
- "E.Jump pad too far from tracepoint "
- "(offset 0x%" PRIx64 " > int32).", loffset);
+ "E.Jump pad too far from tracepoint "
+ "(offset 0x%" PRIx64 " > int32).",
+ loffset);
return 1;
}
@@ -1351,18 +1328,12 @@ amd64_install_fast_tracepoint_jump_pad (CORE_ADDR tpoint, CORE_ADDR tpaddr,
tracepoint address. */
static int
-i386_install_fast_tracepoint_jump_pad (CORE_ADDR tpoint, CORE_ADDR tpaddr,
- CORE_ADDR collector,
- CORE_ADDR lockaddr,
- ULONGEST orig_size,
- CORE_ADDR *jump_entry,
- CORE_ADDR *trampoline,
- ULONGEST *trampoline_size,
- unsigned char *jjump_pad_insn,
- ULONGEST *jjump_pad_insn_size,
- CORE_ADDR *adjusted_insn_addr,
- CORE_ADDR *adjusted_insn_addr_end,
- char *err)
+i386_install_fast_tracepoint_jump_pad (
+ CORE_ADDR tpoint, CORE_ADDR tpaddr, CORE_ADDR collector, CORE_ADDR lockaddr,
+ ULONGEST orig_size, CORE_ADDR *jump_entry, CORE_ADDR *trampoline,
+ ULONGEST *trampoline_size, unsigned char *jjump_pad_insn,
+ ULONGEST *jjump_pad_insn_size, CORE_ADDR *adjusted_insn_addr,
+ CORE_ADDR *adjusted_insn_addr_end, char *err)
{
unsigned char buf[0x100];
int i, offset;
@@ -1374,7 +1345,7 @@ i386_install_fast_tracepoint_jump_pad (CORE_ADDR tpoint, CORE_ADDR tpaddr,
i = 0;
buf[i++] = 0x60; /* pushad */
buf[i++] = 0x68; /* push tpaddr aka $pc */
- *((int *)(buf + i)) = (int) tpaddr;
+ *((int *) (buf + i)) = (int) tpaddr;
i += 4;
buf[i++] = 0x9c; /* pushf */
buf[i++] = 0x1e; /* push %ds */
@@ -1389,45 +1360,44 @@ i386_install_fast_tracepoint_jump_pad (CORE_ADDR tpoint, CORE_ADDR tpaddr,
/* Stack space for the collecting_t object. */
i = 0;
- i += push_opcode (&buf[i], "83 ec 08"); /* sub $0x8,%esp */
+ i += push_opcode (&buf[i], "83 ec 08"); /* sub $0x8,%esp */
/* Build the object. */
- i += push_opcode (&buf[i], "b8"); /* mov <tpoint>,%eax */
+ i += push_opcode (&buf[i], "b8"); /* mov <tpoint>,%eax */
memcpy (buf + i, &tpoint, 4);
i += 4;
- i += push_opcode (&buf[i], "89 04 24"); /* mov %eax,(%esp) */
+ i += push_opcode (&buf[i], "89 04 24"); /* mov %eax,(%esp) */
i += push_opcode (&buf[i], "65 a1 00 00 00 00"); /* mov %gs:0x0,%eax */
- i += push_opcode (&buf[i], "89 44 24 04"); /* mov %eax,0x4(%esp) */
+ i += push_opcode (&buf[i], "89 44 24 04"); /* mov %eax,0x4(%esp) */
append_insns (&buildaddr, i, buf);
/* spin-lock. Note this is using cmpxchg, which leaves i386 behind.
If we cared for it, this could be using xchg alternatively. */
i = 0;
- i += push_opcode (&buf[i], "31 c0"); /* xor %eax,%eax */
- i += push_opcode (&buf[i], "f0 0f b1 25"); /* lock cmpxchg
+ i += push_opcode (&buf[i], "31 c0"); /* xor %eax,%eax */
+ i += push_opcode (&buf[i], "f0 0f b1 25"); /* lock cmpxchg
%esp,<lockaddr> */
memcpy (&buf[i], (void *) &lockaddr, 4);
i += 4;
- i += push_opcode (&buf[i], "85 c0"); /* test %eax,%eax */
- i += push_opcode (&buf[i], "75 f2"); /* jne <again> */
+ i += push_opcode (&buf[i], "85 c0"); /* test %eax,%eax */
+ i += push_opcode (&buf[i], "75 f2"); /* jne <again> */
append_insns (&buildaddr, i, buf);
-
/* Set up arguments to the gdb_collect call. */
i = 0;
- i += push_opcode (&buf[i], "89 e0"); /* mov %esp,%eax */
- i += push_opcode (&buf[i], "83 c0 08"); /* add $0x08,%eax */
- i += push_opcode (&buf[i], "89 44 24 fc"); /* mov %eax,-0x4(%esp) */
+ i += push_opcode (&buf[i], "89 e0"); /* mov %esp,%eax */
+ i += push_opcode (&buf[i], "83 c0 08"); /* add $0x08,%eax */
+ i += push_opcode (&buf[i], "89 44 24 fc"); /* mov %eax,-0x4(%esp) */
append_insns (&buildaddr, i, buf);
i = 0;
- i += push_opcode (&buf[i], "83 ec 08"); /* sub $0x8,%esp */
+ i += push_opcode (&buf[i], "83 ec 08"); /* sub $0x8,%esp */
append_insns (&buildaddr, i, buf);
i = 0;
- i += push_opcode (&buf[i], "c7 04 24"); /* movl <addr>,(%esp) */
+ i += push_opcode (&buf[i], "c7 04 24"); /* movl <addr>,(%esp) */
memcpy (&buf[i], (void *) &tpoint, 4);
i += 4;
append_insns (&buildaddr, i, buf);
@@ -1442,20 +1412,18 @@ i386_install_fast_tracepoint_jump_pad (CORE_ADDR tpoint, CORE_ADDR tpaddr,
buf[2] = 0x08;
append_insns (&buildaddr, 3, buf);
-
/* Clear the spin-lock. This would need the LOCK prefix on older
broken archs. */
i = 0;
- i += push_opcode (&buf[i], "31 c0"); /* xor %eax,%eax */
- i += push_opcode (&buf[i], "a3"); /* mov %eax, lockaddr */
+ i += push_opcode (&buf[i], "31 c0"); /* xor %eax,%eax */
+ i += push_opcode (&buf[i], "a3"); /* mov %eax, lockaddr */
memcpy (buf + i, &lockaddr, 4);
i += 4;
append_insns (&buildaddr, i, buf);
-
/* Remove stack that had been used for the collect_t object. */
i = 0;
- i += push_opcode (&buf[i], "83 c4 08"); /* add $0x08,%esp */
+ i += push_opcode (&buf[i], "83 c4 08"); /* add $0x08,%esp */
append_insns (&buildaddr, i, buf);
i = 0;
@@ -1497,13 +1465,12 @@ i386_install_fast_tracepoint_jump_pad (CORE_ADDR tpoint, CORE_ADDR tpaddr,
/* Create a trampoline. */
*trampoline_size = sizeof (jump_insn);
if (!claim_trampoline_space (*trampoline_size, trampoline))
- {
- /* No trampoline space available. */
- strcpy (err,
- "E.Cannot allocate trampoline space needed for fast "
- "tracepoints on 4-byte instructions.");
- return 1;
- }
+ {
+ /* No trampoline space available. */
+ strcpy (err, "E.Cannot allocate trampoline space needed for fast "
+ "tracepoints on 4-byte instructions.");
+ return 1;
+ }
offset = *jump_entry - (*trampoline + sizeof (jump_insn));
memcpy (buf, jump_insn, sizeof (jump_insn));
@@ -1540,42 +1507,34 @@ x86_target::supports_fast_tracepoints ()
}
int
-x86_target::install_fast_tracepoint_jump_pad (CORE_ADDR tpoint,
- CORE_ADDR tpaddr,
- CORE_ADDR collector,
- CORE_ADDR lockaddr,
- ULONGEST orig_size,
- CORE_ADDR *jump_entry,
- CORE_ADDR *trampoline,
- ULONGEST *trampoline_size,
- unsigned char *jjump_pad_insn,
- ULONGEST *jjump_pad_insn_size,
- CORE_ADDR *adjusted_insn_addr,
- CORE_ADDR *adjusted_insn_addr_end,
- char *err)
+x86_target::install_fast_tracepoint_jump_pad (
+ CORE_ADDR tpoint, CORE_ADDR tpaddr, CORE_ADDR collector, CORE_ADDR lockaddr,
+ ULONGEST orig_size, CORE_ADDR *jump_entry, CORE_ADDR *trampoline,
+ ULONGEST *trampoline_size, unsigned char *jjump_pad_insn,
+ ULONGEST *jjump_pad_insn_size, CORE_ADDR *adjusted_insn_addr,
+ CORE_ADDR *adjusted_insn_addr_end, char *err)
{
#ifdef __x86_64__
if (is_64bit_tdesc (current_thread))
- return amd64_install_fast_tracepoint_jump_pad (tpoint, tpaddr,
- collector, lockaddr,
- orig_size, jump_entry,
- trampoline, trampoline_size,
- jjump_pad_insn,
- jjump_pad_insn_size,
- adjusted_insn_addr,
- adjusted_insn_addr_end,
- err);
+ return amd64_install_fast_tracepoint_jump_pad (tpoint, tpaddr, collector,
+ lockaddr, orig_size,
+ jump_entry, trampoline,
+ trampoline_size,
+ jjump_pad_insn,
+ jjump_pad_insn_size,
+ adjusted_insn_addr,
+ adjusted_insn_addr_end,
+ err);
#endif
- return i386_install_fast_tracepoint_jump_pad (tpoint, tpaddr,
- collector, lockaddr,
- orig_size, jump_entry,
- trampoline, trampoline_size,
- jjump_pad_insn,
- jjump_pad_insn_size,
- adjusted_insn_addr,
- adjusted_insn_addr_end,
- err);
+ return i386_install_fast_tracepoint_jump_pad (tpoint, tpaddr, collector,
+ lockaddr, orig_size,
+ jump_entry, trampoline,
+ trampoline_size,
+ jjump_pad_insn,
+ jjump_pad_insn_size,
+ adjusted_insn_addr,
+ adjusted_insn_addr_end, err);
}
/* Return the minimum instruction length for fast tracepoints on x86/x86-64
@@ -1603,19 +1562,19 @@ x86_target::get_min_fast_tracepoint_insn_len ()
with a 2-byte offset may be used, otherwise 5-byte jump instructions
with a 4-byte offset are used instead. */
if (have_fast_tracepoint_trampoline_buffer (errbuf))
- return 4;
+ return 4;
else
- {
- /* GDB has no channel to explain to user why a shorter fast
+ {
+ /* GDB has no channel to explain to user why a shorter fast
tracepoint is not possible, but at least make GDBserver
mention that something has gone awry. */
- if (!warned_about_fast_tracepoints)
- {
- warning ("4-byte fast tracepoints not available; %s", errbuf);
- warned_about_fast_tracepoints = 1;
- }
- return 5;
- }
+ if (!warned_about_fast_tracepoints)
+ {
+ warning ("4-byte fast tracepoints not available; %s", errbuf);
+ warned_about_fast_tracepoints = 1;
+ }
+ return 5;
+ }
}
else
{
@@ -1630,8 +1589,8 @@ add_insns (unsigned char *start, int len)
{
CORE_ADDR buildaddr = current_insn_ptr;
- threads_debug_printf ("Adding %d bytes of insn at %s",
- len, paddress (buildaddr));
+ threads_debug_printf ("Adding %d bytes of insn at %s", len,
+ paddress (buildaddr));
append_insns (&buildaddr, len, start);
current_insn_ptr = buildaddr;
@@ -1643,35 +1602,42 @@ add_insns (unsigned char *start, int len)
we need to keep the compiler from discarding what looks like dead
code, plus suppress various warnings. */
-#define EMIT_ASM(NAME, INSNS) \
- do \
- { \
- extern unsigned char start_ ## NAME, end_ ## NAME; \
- add_insns (&start_ ## NAME, &end_ ## NAME - &start_ ## NAME); \
- __asm__ ("jmp end_" #NAME "\n" \
- "\t" "start_" #NAME ":" \
- "\t" INSNS "\n" \
- "\t" "end_" #NAME ":"); \
- } while (0)
+#define EMIT_ASM(NAME, INSNS) \
+ do \
+ { \
+ extern unsigned char start_##NAME, end_##NAME; \
+ add_insns (&start_##NAME, &end_##NAME - &start_##NAME); \
+ __asm__ ("jmp end_" #NAME "\n" \
+ "\t" \
+ "start_" #NAME ":" \
+ "\t" INSNS "\n" \
+ "\t" \
+ "end_" #NAME ":"); \
+ } \
+ while (0)
#ifdef __x86_64__
-#define EMIT_ASM32(NAME,INSNS) \
- do \
- { \
- extern unsigned char start_ ## NAME, end_ ## NAME; \
- add_insns (&start_ ## NAME, &end_ ## NAME - &start_ ## NAME); \
- __asm__ (".code32\n" \
- "\t" "jmp end_" #NAME "\n" \
- "\t" "start_" #NAME ":\n" \
- "\t" INSNS "\n" \
- "\t" "end_" #NAME ":\n" \
- ".code64\n"); \
- } while (0)
+#define EMIT_ASM32(NAME, INSNS) \
+ do \
+ { \
+ extern unsigned char start_##NAME, end_##NAME; \
+ add_insns (&start_##NAME, &end_##NAME - &start_##NAME); \
+ __asm__ (".code32\n" \
+ "\t" \
+ "jmp end_" #NAME "\n" \
+ "\t" \
+ "start_" #NAME ":\n" \
+ "\t" INSNS "\n" \
+ "\t" \
+ "end_" #NAME ":\n" \
+ ".code64\n"); \
+ } \
+ while (0)
#else
-#define EMIT_ASM32(NAME,INSNS) EMIT_ASM(NAME,INSNS)
+#define EMIT_ASM32(NAME, INSNS) EMIT_ASM (NAME, INSNS)
#endif
@@ -1680,40 +1646,35 @@ add_insns (unsigned char *start, int len)
static void
amd64_emit_prologue (void)
{
- EMIT_ASM (amd64_prologue,
- "pushq %rbp\n\t"
- "movq %rsp,%rbp\n\t"
- "sub $0x20,%rsp\n\t"
- "movq %rdi,-8(%rbp)\n\t"
- "movq %rsi,-16(%rbp)");
+ EMIT_ASM (amd64_prologue, "pushq %rbp\n\t"
+ "movq %rsp,%rbp\n\t"
+ "sub $0x20,%rsp\n\t"
+ "movq %rdi,-8(%rbp)\n\t"
+ "movq %rsi,-16(%rbp)");
}
-
static void
amd64_emit_epilogue (void)
{
- EMIT_ASM (amd64_epilogue,
- "movq -16(%rbp),%rdi\n\t"
- "movq %rax,(%rdi)\n\t"
- "xor %rax,%rax\n\t"
- "leave\n\t"
- "ret");
+ EMIT_ASM (amd64_epilogue, "movq -16(%rbp),%rdi\n\t"
+ "movq %rax,(%rdi)\n\t"
+ "xor %rax,%rax\n\t"
+ "leave\n\t"
+ "ret");
}
static void
amd64_emit_add (void)
{
- EMIT_ASM (amd64_add,
- "add (%rsp),%rax\n\t"
- "lea 0x8(%rsp),%rsp");
+ EMIT_ASM (amd64_add, "add (%rsp),%rax\n\t"
+ "lea 0x8(%rsp),%rsp");
}
static void
amd64_emit_sub (void)
{
- EMIT_ASM (amd64_sub,
- "sub %rax,(%rsp)\n\t"
- "pop %rax");
+ EMIT_ASM (amd64_sub, "sub %rax,(%rsp)\n\t"
+ "pop %rax");
}
static void
@@ -1746,19 +1707,16 @@ amd64_emit_ext (int arg)
switch (arg)
{
case 8:
- EMIT_ASM (amd64_ext_8,
- "cbtw\n\t"
- "cwtl\n\t"
- "cltq");
+ EMIT_ASM (amd64_ext_8, "cbtw\n\t"
+ "cwtl\n\t"
+ "cltq");
break;
case 16:
- EMIT_ASM (amd64_ext_16,
- "cwtl\n\t"
- "cltq");
+ EMIT_ASM (amd64_ext_16, "cwtl\n\t"
+ "cltq");
break;
case 32:
- EMIT_ASM (amd64_ext_32,
- "cltq");
+ EMIT_ASM (amd64_ext_32, "cltq");
break;
default:
emit_error = 1;
@@ -1768,83 +1726,75 @@ amd64_emit_ext (int arg)
static void
amd64_emit_log_not (void)
{
- EMIT_ASM (amd64_log_not,
- "test %rax,%rax\n\t"
- "sete %cl\n\t"
- "movzbq %cl,%rax");
+ EMIT_ASM (amd64_log_not, "test %rax,%rax\n\t"
+ "sete %cl\n\t"
+ "movzbq %cl,%rax");
}
static void
amd64_emit_bit_and (void)
{
- EMIT_ASM (amd64_and,
- "and (%rsp),%rax\n\t"
- "lea 0x8(%rsp),%rsp");
+ EMIT_ASM (amd64_and, "and (%rsp),%rax\n\t"
+ "lea 0x8(%rsp),%rsp");
}
static void
amd64_emit_bit_or (void)
{
- EMIT_ASM (amd64_or,
- "or (%rsp),%rax\n\t"
- "lea 0x8(%rsp),%rsp");
+ EMIT_ASM (amd64_or, "or (%rsp),%rax\n\t"
+ "lea 0x8(%rsp),%rsp");
}
static void
amd64_emit_bit_xor (void)
{
- EMIT_ASM (amd64_xor,
- "xor (%rsp),%rax\n\t"
- "lea 0x8(%rsp),%rsp");
+ EMIT_ASM (amd64_xor, "xor (%rsp),%rax\n\t"
+ "lea 0x8(%rsp),%rsp");
}
static void
amd64_emit_bit_not (void)
{
- EMIT_ASM (amd64_bit_not,
- "xorq $0xffffffffffffffff,%rax");
+ EMIT_ASM (amd64_bit_not, "xorq $0xffffffffffffffff,%rax");
}
static void
amd64_emit_equal (void)
{
- EMIT_ASM (amd64_equal,
- "cmp %rax,(%rsp)\n\t"
- "je .Lamd64_equal_true\n\t"
- "xor %rax,%rax\n\t"
- "jmp .Lamd64_equal_end\n\t"
- ".Lamd64_equal_true:\n\t"
- "mov $0x1,%rax\n\t"
- ".Lamd64_equal_end:\n\t"
- "lea 0x8(%rsp),%rsp");
+ EMIT_ASM (amd64_equal, "cmp %rax,(%rsp)\n\t"
+ "je .Lamd64_equal_true\n\t"
+ "xor %rax,%rax\n\t"
+ "jmp .Lamd64_equal_end\n\t"
+ ".Lamd64_equal_true:\n\t"
+ "mov $0x1,%rax\n\t"
+ ".Lamd64_equal_end:\n\t"
+ "lea 0x8(%rsp),%rsp");
}
static void
amd64_emit_less_signed (void)
{
- EMIT_ASM (amd64_less_signed,
- "cmp %rax,(%rsp)\n\t"
- "jl .Lamd64_less_signed_true\n\t"
- "xor %rax,%rax\n\t"
- "jmp .Lamd64_less_signed_end\n\t"
- ".Lamd64_less_signed_true:\n\t"
- "mov $1,%rax\n\t"
- ".Lamd64_less_signed_end:\n\t"
- "lea 0x8(%rsp),%rsp");
+ EMIT_ASM (amd64_less_signed, "cmp %rax,(%rsp)\n\t"
+ "jl .Lamd64_less_signed_true\n\t"
+ "xor %rax,%rax\n\t"
+ "jmp .Lamd64_less_signed_end\n\t"
+ ".Lamd64_less_signed_true:\n\t"
+ "mov $1,%rax\n\t"
+ ".Lamd64_less_signed_end:\n\t"
+ "lea 0x8(%rsp),%rsp");
}
static void
amd64_emit_less_unsigned (void)
{
- EMIT_ASM (amd64_less_unsigned,
- "cmp %rax,(%rsp)\n\t"
- "jb .Lamd64_less_unsigned_true\n\t"
- "xor %rax,%rax\n\t"
- "jmp .Lamd64_less_unsigned_end\n\t"
- ".Lamd64_less_unsigned_true:\n\t"
- "mov $1,%rax\n\t"
- ".Lamd64_less_unsigned_end:\n\t"
- "lea 0x8(%rsp),%rsp");
+ EMIT_ASM (amd64_less_unsigned, "cmp %rax,(%rsp)\n\t"
+ "jb .Lamd64_less_unsigned_true\n\t"
+ "xor %rax,%rax\n\t"
+ "jmp .Lamd64_less_unsigned_end\n\t"
+ ".Lamd64_less_unsigned_true:\n\t"
+ "mov $1,%rax\n\t"
+ ".Lamd64_less_unsigned_end:\n\t"
+ "lea 0x8(%rsp),%rsp");
}
static void
@@ -1853,20 +1803,16 @@ amd64_emit_ref (int size)
switch (size)
{
case 1:
- EMIT_ASM (amd64_ref1,
- "movb (%rax),%al");
+ EMIT_ASM (amd64_ref1, "movb (%rax),%al");
break;
case 2:
- EMIT_ASM (amd64_ref2,
- "movw (%rax),%ax");
+ EMIT_ASM (amd64_ref2, "movw (%rax),%ax");
break;
case 4:
- EMIT_ASM (amd64_ref4,
- "movl (%rax),%eax");
+ EMIT_ASM (amd64_ref4, "movl (%rax),%eax");
break;
case 8:
- EMIT_ASM (amd64_ref8,
- "movq (%rax),%rax");
+ EMIT_ASM (amd64_ref8, "movq (%rax),%rax");
break;
}
}
@@ -1874,11 +1820,10 @@ amd64_emit_ref (int size)
static void
amd64_emit_if_goto (int *offset_p, int *size_p)
{
- EMIT_ASM (amd64_if_goto,
- "mov %rax,%rcx\n\t"
- "pop %rax\n\t"
- "cmp $0,%rcx\n\t"
- ".byte 0x0f, 0x85, 0x0, 0x0, 0x0, 0x0");
+ EMIT_ASM (amd64_if_goto, "mov %rax,%rcx\n\t"
+ "pop %rax\n\t"
+ "cmp $0,%rcx\n\t"
+ ".byte 0x0f, 0x85, 0x0, 0x0, 0x0, 0x0");
if (offset_p)
*offset_p = 10;
if (size_p)
@@ -1888,8 +1833,7 @@ amd64_emit_if_goto (int *offset_p, int *size_p)
static void
amd64_emit_goto (int *offset_p, int *size_p)
{
- EMIT_ASM (amd64_goto,
- ".byte 0xe9, 0x0, 0x0, 0x0, 0x0");
+ EMIT_ASM (amd64_goto, ".byte 0xe9, 0x0, 0x0, 0x0, 0x0");
if (offset_p)
*offset_p = 1;
if (size_p)
@@ -1920,7 +1864,8 @@ amd64_emit_const (LONGEST num)
CORE_ADDR buildaddr = current_insn_ptr;
i = 0;
- buf[i++] = 0x48; buf[i++] = 0xb8; /* mov $<n>,%rax */
+ buf[i++] = 0x48;
+ buf[i++] = 0xb8; /* mov $<n>,%rax */
memcpy (&buf[i], &num, sizeof (num));
i += 8;
append_insns (&buildaddr, i, buf);
@@ -1990,15 +1935,13 @@ amd64_emit_reg (int reg)
static void
amd64_emit_pop (void)
{
- EMIT_ASM (amd64_pop,
- "pop %rax");
+ EMIT_ASM (amd64_pop, "pop %rax");
}
static void
amd64_emit_stack_flush (void)
{
- EMIT_ASM (amd64_stack_flush,
- "push %rax");
+ EMIT_ASM (amd64_stack_flush, "push %rax");
}
static void
@@ -2007,17 +1950,14 @@ amd64_emit_zero_ext (int arg)
switch (arg)
{
case 8:
- EMIT_ASM (amd64_zero_ext_8,
- "and $0xff,%rax");
+ EMIT_ASM (amd64_zero_ext_8, "and $0xff,%rax");
break;
case 16:
- EMIT_ASM (amd64_zero_ext_16,
- "and $0xffff,%rax");
+ EMIT_ASM (amd64_zero_ext_16, "and $0xffff,%rax");
break;
case 32:
- EMIT_ASM (amd64_zero_ext_32,
- "mov $0xffffffff,%rcx\n\t"
- "and %rcx,%rax");
+ EMIT_ASM (amd64_zero_ext_32, "mov $0xffffffff,%rcx\n\t"
+ "and %rcx,%rax");
break;
default:
emit_error = 1;
@@ -2027,10 +1967,9 @@ amd64_emit_zero_ext (int arg)
static void
amd64_emit_swap (void)
{
- EMIT_ASM (amd64_swap,
- "mov %rax,%rcx\n\t"
- "pop %rax\n\t"
- "push %rcx");
+ EMIT_ASM (amd64_swap, "mov %rax,%rcx\n\t"
+ "pop %rax\n\t"
+ "push %rcx");
}
static void
@@ -2087,29 +2026,29 @@ amd64_emit_void_call_2 (CORE_ADDR fn, int arg1)
append_insns (&buildaddr, i, buf);
current_insn_ptr = buildaddr;
EMIT_ASM (amd64_void_call_2_a,
- /* Save away a copy of the stack top. */
- "push %rax\n\t"
- /* Also pass top as the second argument. */
- "mov %rax,%rsi");
+ /* Save away a copy of the stack top. */
+ "push %rax\n\t"
+ /* Also pass top as the second argument. */
+ "mov %rax,%rsi");
amd64_emit_call (fn);
EMIT_ASM (amd64_void_call_2_b,
- /* Restore the stack top, %rax may have been trashed. */
- "pop %rax");
+ /* Restore the stack top, %rax may have been trashed. */
+ "pop %rax");
}
static void
amd64_emit_eq_goto (int *offset_p, int *size_p)
{
EMIT_ASM (amd64_eq,
- "cmp %rax,(%rsp)\n\t"
- "jne .Lamd64_eq_fallthru\n\t"
- "lea 0x8(%rsp),%rsp\n\t"
- "pop %rax\n\t"
- /* jmp, but don't trust the assembler to choose the right jump */
- ".byte 0xe9, 0x0, 0x0, 0x0, 0x0\n\t"
- ".Lamd64_eq_fallthru:\n\t"
- "lea 0x8(%rsp),%rsp\n\t"
- "pop %rax");
+ "cmp %rax,(%rsp)\n\t"
+ "jne .Lamd64_eq_fallthru\n\t"
+ "lea 0x8(%rsp),%rsp\n\t"
+ "pop %rax\n\t"
+ /* jmp, but don't trust the assembler to choose the right jump */
+ ".byte 0xe9, 0x0, 0x0, 0x0, 0x0\n\t"
+ ".Lamd64_eq_fallthru:\n\t"
+ "lea 0x8(%rsp),%rsp\n\t"
+ "pop %rax");
if (offset_p)
*offset_p = 13;
@@ -2121,15 +2060,15 @@ static void
amd64_emit_ne_goto (int *offset_p, int *size_p)
{
EMIT_ASM (amd64_ne,
- "cmp %rax,(%rsp)\n\t"
- "je .Lamd64_ne_fallthru\n\t"
- "lea 0x8(%rsp),%rsp\n\t"
- "pop %rax\n\t"
- /* jmp, but don't trust the assembler to choose the right jump */
- ".byte 0xe9, 0x0, 0x0, 0x0, 0x0\n\t"
- ".Lamd64_ne_fallthru:\n\t"
- "lea 0x8(%rsp),%rsp\n\t"
- "pop %rax");
+ "cmp %rax,(%rsp)\n\t"
+ "je .Lamd64_ne_fallthru\n\t"
+ "lea 0x8(%rsp),%rsp\n\t"
+ "pop %rax\n\t"
+ /* jmp, but don't trust the assembler to choose the right jump */
+ ".byte 0xe9, 0x0, 0x0, 0x0, 0x0\n\t"
+ ".Lamd64_ne_fallthru:\n\t"
+ "lea 0x8(%rsp),%rsp\n\t"
+ "pop %rax");
if (offset_p)
*offset_p = 13;
@@ -2141,15 +2080,15 @@ static void
amd64_emit_lt_goto (int *offset_p, int *size_p)
{
EMIT_ASM (amd64_lt,
- "cmp %rax,(%rsp)\n\t"
- "jnl .Lamd64_lt_fallthru\n\t"
- "lea 0x8(%rsp),%rsp\n\t"
- "pop %rax\n\t"
- /* jmp, but don't trust the assembler to choose the right jump */
- ".byte 0xe9, 0x0, 0x0, 0x0, 0x0\n\t"
- ".Lamd64_lt_fallthru:\n\t"
- "lea 0x8(%rsp),%rsp\n\t"
- "pop %rax");
+ "cmp %rax,(%rsp)\n\t"
+ "jnl .Lamd64_lt_fallthru\n\t"
+ "lea 0x8(%rsp),%rsp\n\t"
+ "pop %rax\n\t"
+ /* jmp, but don't trust the assembler to choose the right jump */
+ ".byte 0xe9, 0x0, 0x0, 0x0, 0x0\n\t"
+ ".Lamd64_lt_fallthru:\n\t"
+ "lea 0x8(%rsp),%rsp\n\t"
+ "pop %rax");
if (offset_p)
*offset_p = 13;
@@ -2161,15 +2100,15 @@ static void
amd64_emit_le_goto (int *offset_p, int *size_p)
{
EMIT_ASM (amd64_le,
- "cmp %rax,(%rsp)\n\t"
- "jnle .Lamd64_le_fallthru\n\t"
- "lea 0x8(%rsp),%rsp\n\t"
- "pop %rax\n\t"
- /* jmp, but don't trust the assembler to choose the right jump */
- ".byte 0xe9, 0x0, 0x0, 0x0, 0x0\n\t"
- ".Lamd64_le_fallthru:\n\t"
- "lea 0x8(%rsp),%rsp\n\t"
- "pop %rax");
+ "cmp %rax,(%rsp)\n\t"
+ "jnle .Lamd64_le_fallthru\n\t"
+ "lea 0x8(%rsp),%rsp\n\t"
+ "pop %rax\n\t"
+ /* jmp, but don't trust the assembler to choose the right jump */
+ ".byte 0xe9, 0x0, 0x0, 0x0, 0x0\n\t"
+ ".Lamd64_le_fallthru:\n\t"
+ "lea 0x8(%rsp),%rsp\n\t"
+ "pop %rax");
if (offset_p)
*offset_p = 13;
@@ -2181,15 +2120,15 @@ static void
amd64_emit_gt_goto (int *offset_p, int *size_p)
{
EMIT_ASM (amd64_gt,
- "cmp %rax,(%rsp)\n\t"
- "jng .Lamd64_gt_fallthru\n\t"
- "lea 0x8(%rsp),%rsp\n\t"
- "pop %rax\n\t"
- /* jmp, but don't trust the assembler to choose the right jump */
- ".byte 0xe9, 0x0, 0x0, 0x0, 0x0\n\t"
- ".Lamd64_gt_fallthru:\n\t"
- "lea 0x8(%rsp),%rsp\n\t"
- "pop %rax");
+ "cmp %rax,(%rsp)\n\t"
+ "jng .Lamd64_gt_fallthru\n\t"
+ "lea 0x8(%rsp),%rsp\n\t"
+ "pop %rax\n\t"
+ /* jmp, but don't trust the assembler to choose the right jump */
+ ".byte 0xe9, 0x0, 0x0, 0x0, 0x0\n\t"
+ ".Lamd64_gt_fallthru:\n\t"
+ "lea 0x8(%rsp),%rsp\n\t"
+ "pop %rax");
if (offset_p)
*offset_p = 13;
@@ -2201,16 +2140,16 @@ static void
amd64_emit_ge_goto (int *offset_p, int *size_p)
{
EMIT_ASM (amd64_ge,
- "cmp %rax,(%rsp)\n\t"
- "jnge .Lamd64_ge_fallthru\n\t"
- ".Lamd64_ge_jump:\n\t"
- "lea 0x8(%rsp),%rsp\n\t"
- "pop %rax\n\t"
- /* jmp, but don't trust the assembler to choose the right jump */
- ".byte 0xe9, 0x0, 0x0, 0x0, 0x0\n\t"
- ".Lamd64_ge_fallthru:\n\t"
- "lea 0x8(%rsp),%rsp\n\t"
- "pop %rax");
+ "cmp %rax,(%rsp)\n\t"
+ "jnge .Lamd64_ge_fallthru\n\t"
+ ".Lamd64_ge_jump:\n\t"
+ "lea 0x8(%rsp),%rsp\n\t"
+ "pop %rax\n\t"
+ /* jmp, but don't trust the assembler to choose the right jump */
+ ".byte 0xe9, 0x0, 0x0, 0x0, 0x0\n\t"
+ ".Lamd64_ge_fallthru:\n\t"
+ "lea 0x8(%rsp),%rsp\n\t"
+ "pop %rax");
if (offset_p)
*offset_p = 13;
@@ -2218,56 +2157,30 @@ amd64_emit_ge_goto (int *offset_p, int *size_p)
*size_p = 4;
}
-static emit_ops amd64_emit_ops =
- {
- amd64_emit_prologue,
- amd64_emit_epilogue,
- amd64_emit_add,
- amd64_emit_sub,
- amd64_emit_mul,
- amd64_emit_lsh,
- amd64_emit_rsh_signed,
- amd64_emit_rsh_unsigned,
- amd64_emit_ext,
- amd64_emit_log_not,
- amd64_emit_bit_and,
- amd64_emit_bit_or,
- amd64_emit_bit_xor,
- amd64_emit_bit_not,
- amd64_emit_equal,
- amd64_emit_less_signed,
- amd64_emit_less_unsigned,
- amd64_emit_ref,
- amd64_emit_if_goto,
- amd64_emit_goto,
- amd64_write_goto_address,
- amd64_emit_const,
- amd64_emit_call,
- amd64_emit_reg,
- amd64_emit_pop,
- amd64_emit_stack_flush,
- amd64_emit_zero_ext,
- amd64_emit_swap,
- amd64_emit_stack_adjust,
- amd64_emit_int_call_1,
- amd64_emit_void_call_2,
- amd64_emit_eq_goto,
- amd64_emit_ne_goto,
- amd64_emit_lt_goto,
- amd64_emit_le_goto,
- amd64_emit_gt_goto,
- amd64_emit_ge_goto
- };
+static emit_ops amd64_emit_ops = {
+ amd64_emit_prologue, amd64_emit_epilogue, amd64_emit_add,
+ amd64_emit_sub, amd64_emit_mul, amd64_emit_lsh,
+ amd64_emit_rsh_signed, amd64_emit_rsh_unsigned, amd64_emit_ext,
+ amd64_emit_log_not, amd64_emit_bit_and, amd64_emit_bit_or,
+ amd64_emit_bit_xor, amd64_emit_bit_not, amd64_emit_equal,
+ amd64_emit_less_signed, amd64_emit_less_unsigned, amd64_emit_ref,
+ amd64_emit_if_goto, amd64_emit_goto, amd64_write_goto_address,
+ amd64_emit_const, amd64_emit_call, amd64_emit_reg,
+ amd64_emit_pop, amd64_emit_stack_flush, amd64_emit_zero_ext,
+ amd64_emit_swap, amd64_emit_stack_adjust, amd64_emit_int_call_1,
+ amd64_emit_void_call_2, amd64_emit_eq_goto, amd64_emit_ne_goto,
+ amd64_emit_lt_goto, amd64_emit_le_goto, amd64_emit_gt_goto,
+ amd64_emit_ge_goto
+};
#endif /* __x86_64__ */
static void
i386_emit_prologue (void)
{
- EMIT_ASM32 (i386_prologue,
- "push %ebp\n\t"
- "mov %esp,%ebp\n\t"
- "push %ebx");
+ EMIT_ASM32 (i386_prologue, "push %ebp\n\t"
+ "mov %esp,%ebp\n\t"
+ "push %ebx");
/* At this point, the raw regs base address is at 8(%ebp), and the
value pointer is at 12(%ebp). */
}
@@ -2275,33 +2188,30 @@ i386_emit_prologue (void)
static void
i386_emit_epilogue (void)
{
- EMIT_ASM32 (i386_epilogue,
- "mov 12(%ebp),%ecx\n\t"
- "mov %eax,(%ecx)\n\t"
- "mov %ebx,0x4(%ecx)\n\t"
- "xor %eax,%eax\n\t"
- "pop %ebx\n\t"
- "pop %ebp\n\t"
- "ret");
+ EMIT_ASM32 (i386_epilogue, "mov 12(%ebp),%ecx\n\t"
+ "mov %eax,(%ecx)\n\t"
+ "mov %ebx,0x4(%ecx)\n\t"
+ "xor %eax,%eax\n\t"
+ "pop %ebx\n\t"
+ "pop %ebp\n\t"
+ "ret");
}
static void
i386_emit_add (void)
{
- EMIT_ASM32 (i386_add,
- "add (%esp),%eax\n\t"
- "adc 0x4(%esp),%ebx\n\t"
- "lea 0x8(%esp),%esp");
+ EMIT_ASM32 (i386_add, "add (%esp),%eax\n\t"
+ "adc 0x4(%esp),%ebx\n\t"
+ "lea 0x8(%esp),%esp");
}
static void
i386_emit_sub (void)
{
- EMIT_ASM32 (i386_sub,
- "subl %eax,(%esp)\n\t"
- "sbbl %ebx,4(%esp)\n\t"
- "pop %eax\n\t"
- "pop %ebx\n\t");
+ EMIT_ASM32 (i386_sub, "subl %eax,(%esp)\n\t"
+ "sbbl %ebx,4(%esp)\n\t"
+ "pop %eax\n\t"
+ "pop %ebx\n\t");
}
static void
@@ -2334,22 +2244,19 @@ i386_emit_ext (int arg)
switch (arg)
{
case 8:
- EMIT_ASM32 (i386_ext_8,
- "cbtw\n\t"
- "cwtl\n\t"
- "movl %eax,%ebx\n\t"
- "sarl $31,%ebx");
+ EMIT_ASM32 (i386_ext_8, "cbtw\n\t"
+ "cwtl\n\t"
+ "movl %eax,%ebx\n\t"
+ "sarl $31,%ebx");
break;
case 16:
- EMIT_ASM32 (i386_ext_16,
- "cwtl\n\t"
- "movl %eax,%ebx\n\t"
- "sarl $31,%ebx");
+ EMIT_ASM32 (i386_ext_16, "cwtl\n\t"
+ "movl %eax,%ebx\n\t"
+ "sarl $31,%ebx");
break;
case 32:
- EMIT_ASM32 (i386_ext_32,
- "movl %eax,%ebx\n\t"
- "sarl $31,%ebx");
+ EMIT_ASM32 (i386_ext_32, "movl %eax,%ebx\n\t"
+ "sarl $31,%ebx");
break;
default:
emit_error = 1;
@@ -2359,103 +2266,95 @@ i386_emit_ext (int arg)
static void
i386_emit_log_not (void)
{
- EMIT_ASM32 (i386_log_not,
- "or %ebx,%eax\n\t"
- "test %eax,%eax\n\t"
- "sete %cl\n\t"
- "xor %ebx,%ebx\n\t"
- "movzbl %cl,%eax");
+ EMIT_ASM32 (i386_log_not, "or %ebx,%eax\n\t"
+ "test %eax,%eax\n\t"
+ "sete %cl\n\t"
+ "xor %ebx,%ebx\n\t"
+ "movzbl %cl,%eax");
}
static void
i386_emit_bit_and (void)
{
- EMIT_ASM32 (i386_and,
- "and (%esp),%eax\n\t"
- "and 0x4(%esp),%ebx\n\t"
- "lea 0x8(%esp),%esp");
+ EMIT_ASM32 (i386_and, "and (%esp),%eax\n\t"
+ "and 0x4(%esp),%ebx\n\t"
+ "lea 0x8(%esp),%esp");
}
static void
i386_emit_bit_or (void)
{
- EMIT_ASM32 (i386_or,
- "or (%esp),%eax\n\t"
- "or 0x4(%esp),%ebx\n\t"
- "lea 0x8(%esp),%esp");
+ EMIT_ASM32 (i386_or, "or (%esp),%eax\n\t"
+ "or 0x4(%esp),%ebx\n\t"
+ "lea 0x8(%esp),%esp");
}
static void
i386_emit_bit_xor (void)
{
- EMIT_ASM32 (i386_xor,
- "xor (%esp),%eax\n\t"
- "xor 0x4(%esp),%ebx\n\t"
- "lea 0x8(%esp),%esp");
+ EMIT_ASM32 (i386_xor, "xor (%esp),%eax\n\t"
+ "xor 0x4(%esp),%ebx\n\t"
+ "lea 0x8(%esp),%esp");
}
static void
i386_emit_bit_not (void)
{
- EMIT_ASM32 (i386_bit_not,
- "xor $0xffffffff,%eax\n\t"
- "xor $0xffffffff,%ebx\n\t");
+ EMIT_ASM32 (i386_bit_not, "xor $0xffffffff,%eax\n\t"
+ "xor $0xffffffff,%ebx\n\t");
}
static void
i386_emit_equal (void)
{
- EMIT_ASM32 (i386_equal,
- "cmpl %ebx,4(%esp)\n\t"
- "jne .Li386_equal_false\n\t"
- "cmpl %eax,(%esp)\n\t"
- "je .Li386_equal_true\n\t"
- ".Li386_equal_false:\n\t"
- "xor %eax,%eax\n\t"
- "jmp .Li386_equal_end\n\t"
- ".Li386_equal_true:\n\t"
- "mov $1,%eax\n\t"
- ".Li386_equal_end:\n\t"
- "xor %ebx,%ebx\n\t"
- "lea 0x8(%esp),%esp");
+ EMIT_ASM32 (i386_equal, "cmpl %ebx,4(%esp)\n\t"
+ "jne .Li386_equal_false\n\t"
+ "cmpl %eax,(%esp)\n\t"
+ "je .Li386_equal_true\n\t"
+ ".Li386_equal_false:\n\t"
+ "xor %eax,%eax\n\t"
+ "jmp .Li386_equal_end\n\t"
+ ".Li386_equal_true:\n\t"
+ "mov $1,%eax\n\t"
+ ".Li386_equal_end:\n\t"
+ "xor %ebx,%ebx\n\t"
+ "lea 0x8(%esp),%esp");
}
static void
i386_emit_less_signed (void)
{
- EMIT_ASM32 (i386_less_signed,
- "cmpl %ebx,4(%esp)\n\t"
- "jl .Li386_less_signed_true\n\t"
- "jne .Li386_less_signed_false\n\t"
- "cmpl %eax,(%esp)\n\t"
- "jl .Li386_less_signed_true\n\t"
- ".Li386_less_signed_false:\n\t"
- "xor %eax,%eax\n\t"
- "jmp .Li386_less_signed_end\n\t"
- ".Li386_less_signed_true:\n\t"
- "mov $1,%eax\n\t"
- ".Li386_less_signed_end:\n\t"
- "xor %ebx,%ebx\n\t"
- "lea 0x8(%esp),%esp");
+ EMIT_ASM32 (i386_less_signed, "cmpl %ebx,4(%esp)\n\t"
+ "jl .Li386_less_signed_true\n\t"
+ "jne .Li386_less_signed_false\n\t"
+ "cmpl %eax,(%esp)\n\t"
+ "jl .Li386_less_signed_true\n\t"
+ ".Li386_less_signed_false:\n\t"
+ "xor %eax,%eax\n\t"
+ "jmp .Li386_less_signed_end\n\t"
+ ".Li386_less_signed_true:\n\t"
+ "mov $1,%eax\n\t"
+ ".Li386_less_signed_end:\n\t"
+ "xor %ebx,%ebx\n\t"
+ "lea 0x8(%esp),%esp");
}
static void
i386_emit_less_unsigned (void)
{
- EMIT_ASM32 (i386_less_unsigned,
- "cmpl %ebx,4(%esp)\n\t"
- "jb .Li386_less_unsigned_true\n\t"
- "jne .Li386_less_unsigned_false\n\t"
- "cmpl %eax,(%esp)\n\t"
- "jb .Li386_less_unsigned_true\n\t"
- ".Li386_less_unsigned_false:\n\t"
- "xor %eax,%eax\n\t"
- "jmp .Li386_less_unsigned_end\n\t"
- ".Li386_less_unsigned_true:\n\t"
- "mov $1,%eax\n\t"
- ".Li386_less_unsigned_end:\n\t"
- "xor %ebx,%ebx\n\t"
- "lea 0x8(%esp),%esp");
+ EMIT_ASM32 (i386_less_unsigned, "cmpl %ebx,4(%esp)\n\t"
+ "jb .Li386_less_unsigned_true\n\t"
+ "jne .Li386_less_unsigned_false\n\t"
+ "cmpl %eax,(%esp)\n\t"
+ "jb .Li386_less_unsigned_true\n\t"
+ ".Li386_less_unsigned_false:\n\t"
+ "xor %eax,%eax\n\t"
+ "jmp .Li386_less_unsigned_end\n\t"
+ ".Li386_less_unsigned_true:\n\t"
+ "mov $1,%eax\n\t"
+ ".Li386_less_unsigned_end:\n\t"
+ "xor %ebx,%ebx\n\t"
+ "lea 0x8(%esp),%esp");
}
static void
@@ -2464,21 +2363,17 @@ i386_emit_ref (int size)
switch (size)
{
case 1:
- EMIT_ASM32 (i386_ref1,
- "movb (%eax),%al");
+ EMIT_ASM32 (i386_ref1, "movb (%eax),%al");
break;
case 2:
- EMIT_ASM32 (i386_ref2,
- "movw (%eax),%ax");
+ EMIT_ASM32 (i386_ref2, "movw (%eax),%ax");
break;
case 4:
- EMIT_ASM32 (i386_ref4,
- "movl (%eax),%eax");
+ EMIT_ASM32 (i386_ref4, "movl (%eax),%eax");
break;
case 8:
- EMIT_ASM32 (i386_ref8,
- "movl 4(%eax),%ebx\n\t"
- "movl (%eax),%eax");
+ EMIT_ASM32 (i386_ref8, "movl 4(%eax),%ebx\n\t"
+ "movl (%eax),%eax");
break;
}
}
@@ -2487,13 +2382,13 @@ static void
i386_emit_if_goto (int *offset_p, int *size_p)
{
EMIT_ASM32 (i386_if_goto,
- "mov %eax,%ecx\n\t"
- "or %ebx,%ecx\n\t"
- "pop %eax\n\t"
- "pop %ebx\n\t"
- "cmpl $0,%ecx\n\t"
- /* Don't trust the assembler to choose the right jump */
- ".byte 0x0f, 0x85, 0x0, 0x0, 0x0, 0x0");
+ "mov %eax,%ecx\n\t"
+ "or %ebx,%ecx\n\t"
+ "pop %eax\n\t"
+ "pop %ebx\n\t"
+ "cmpl $0,%ecx\n\t"
+ /* Don't trust the assembler to choose the right jump */
+ ".byte 0x0f, 0x85, 0x0, 0x0, 0x0, 0x0");
if (offset_p)
*offset_p = 11; /* be sure that this matches the sequence above */
@@ -2505,8 +2400,8 @@ static void
i386_emit_goto (int *offset_p, int *size_p)
{
EMIT_ASM32 (i386_goto,
- /* Don't trust the assembler to choose the right jump */
- ".byte 0xe9, 0x0, 0x0, 0x0, 0x0");
+ /* Don't trust the assembler to choose the right jump */
+ ".byte 0xe9, 0x0, 0x0, 0x0, 0x0");
if (offset_p)
*offset_p = 1;
if (size_p)
@@ -2551,7 +2446,8 @@ i386_emit_const (LONGEST num)
}
else
{
- buf[i++] = 0x31; buf[i++] = 0xdb; /* xor %ebx,%ebx */
+ buf[i++] = 0x31;
+ buf[i++] = 0xdb; /* xor %ebx,%ebx */
}
append_insns (&buildaddr, i, buf);
current_insn_ptr = buildaddr;
@@ -2580,8 +2476,7 @@ i386_emit_reg (int reg)
int i;
CORE_ADDR buildaddr;
- EMIT_ASM32 (i386_reg_a,
- "sub $0x8,%esp");
+ EMIT_ASM32 (i386_reg_a, "sub $0x8,%esp");
buildaddr = current_insn_ptr;
i = 0;
buf[i++] = 0xb8; /* mov $<n>,%eax */
@@ -2589,30 +2484,26 @@ i386_emit_reg (int reg)
i += 4;
append_insns (&buildaddr, i, buf);
current_insn_ptr = buildaddr;
- EMIT_ASM32 (i386_reg_b,
- "mov %eax,4(%esp)\n\t"
- "mov 8(%ebp),%eax\n\t"
- "mov %eax,(%esp)");
+ EMIT_ASM32 (i386_reg_b, "mov %eax,4(%esp)\n\t"
+ "mov 8(%ebp),%eax\n\t"
+ "mov %eax,(%esp)");
i386_emit_call (get_raw_reg_func_addr ());
- EMIT_ASM32 (i386_reg_c,
- "xor %ebx,%ebx\n\t"
- "lea 0x8(%esp),%esp");
+ EMIT_ASM32 (i386_reg_c, "xor %ebx,%ebx\n\t"
+ "lea 0x8(%esp),%esp");
}
static void
i386_emit_pop (void)
{
- EMIT_ASM32 (i386_pop,
- "pop %eax\n\t"
- "pop %ebx");
+ EMIT_ASM32 (i386_pop, "pop %eax\n\t"
+ "pop %ebx");
}
static void
i386_emit_stack_flush (void)
{
- EMIT_ASM32 (i386_stack_flush,
- "push %ebx\n\t"
- "push %eax");
+ EMIT_ASM32 (i386_stack_flush, "push %ebx\n\t"
+ "push %eax");
}
static void
@@ -2621,18 +2512,15 @@ i386_emit_zero_ext (int arg)
switch (arg)
{
case 8:
- EMIT_ASM32 (i386_zero_ext_8,
- "and $0xff,%eax\n\t"
- "xor %ebx,%ebx");
+ EMIT_ASM32 (i386_zero_ext_8, "and $0xff,%eax\n\t"
+ "xor %ebx,%ebx");
break;
case 16:
- EMIT_ASM32 (i386_zero_ext_16,
- "and $0xffff,%eax\n\t"
- "xor %ebx,%ebx");
+ EMIT_ASM32 (i386_zero_ext_16, "and $0xffff,%eax\n\t"
+ "xor %ebx,%ebx");
break;
case 32:
- EMIT_ASM32 (i386_zero_ext_32,
- "xor %ebx,%ebx");
+ EMIT_ASM32 (i386_zero_ext_32, "xor %ebx,%ebx");
break;
default:
emit_error = 1;
@@ -2642,13 +2530,12 @@ i386_emit_zero_ext (int arg)
static void
i386_emit_swap (void)
{
- EMIT_ASM32 (i386_swap,
- "mov %eax,%ecx\n\t"
- "mov %ebx,%edx\n\t"
- "pop %eax\n\t"
- "pop %ebx\n\t"
- "push %edx\n\t"
- "push %ecx");
+ EMIT_ASM32 (i386_swap, "mov %eax,%ecx\n\t"
+ "mov %ebx,%edx\n\t"
+ "pop %eax\n\t"
+ "pop %ebx\n\t"
+ "push %edx\n\t"
+ "push %ecx");
}
static void
@@ -2677,12 +2564,12 @@ i386_emit_int_call_1 (CORE_ADDR fn, int arg1)
CORE_ADDR buildaddr;
EMIT_ASM32 (i386_int_call_1_a,
- /* Reserve a bit of stack space. */
- "sub $0x8,%esp");
+ /* Reserve a bit of stack space. */
+ "sub $0x8,%esp");
/* Put the one argument on the stack. */
buildaddr = current_insn_ptr;
i = 0;
- buf[i++] = 0xc7; /* movl $<arg1>,(%esp) */
+ buf[i++] = 0xc7; /* movl $<arg1>,(%esp) */
buf[i++] = 0x04;
buf[i++] = 0x24;
memcpy (&buf[i], &arg1, sizeof (arg1));
@@ -2690,9 +2577,8 @@ i386_emit_int_call_1 (CORE_ADDR fn, int arg1)
append_insns (&buildaddr, i, buf);
current_insn_ptr = buildaddr;
i386_emit_call (fn);
- EMIT_ASM32 (i386_int_call_1_c,
- "mov %edx,%ebx\n\t"
- "lea 0x8(%esp),%esp");
+ EMIT_ASM32 (i386_int_call_1_c, "mov %edx,%ebx\n\t"
+ "lea 0x8(%esp),%esp");
}
/* FN's prototype is `void(*fn)(int,LONGEST)'. */
@@ -2705,19 +2591,19 @@ i386_emit_void_call_2 (CORE_ADDR fn, int arg1)
CORE_ADDR buildaddr;
EMIT_ASM32 (i386_void_call_2_a,
- /* Preserve %eax only; we don't have to worry about %ebx. */
- "push %eax\n\t"
- /* Reserve a bit of stack space for arguments. */
- "sub $0x10,%esp\n\t"
- /* Copy "top" to the second argument position. (Note that
+ /* Preserve %eax only; we don't have to worry about %ebx. */
+ "push %eax\n\t"
+ /* Reserve a bit of stack space for arguments. */
+ "sub $0x10,%esp\n\t"
+ /* Copy "top" to the second argument position. (Note that
we can't assume function won't scribble on its
arguments, so don't try to restore from this.) */
- "mov %eax,4(%esp)\n\t"
- "mov %ebx,8(%esp)");
+ "mov %eax,4(%esp)\n\t"
+ "mov %ebx,8(%esp)");
/* Put the first argument on the stack. */
buildaddr = current_insn_ptr;
i = 0;
- buf[i++] = 0xc7; /* movl $<arg1>,(%esp) */
+ buf[i++] = 0xc7; /* movl $<arg1>,(%esp) */
buf[i++] = 0x04;
buf[i++] = 0x24;
memcpy (&buf[i], &arg1, sizeof (arg1));
@@ -2725,31 +2611,29 @@ i386_emit_void_call_2 (CORE_ADDR fn, int arg1)
append_insns (&buildaddr, i, buf);
current_insn_ptr = buildaddr;
i386_emit_call (fn);
- EMIT_ASM32 (i386_void_call_2_b,
- "lea 0x10(%esp),%esp\n\t"
- /* Restore original stack top. */
- "pop %eax");
+ EMIT_ASM32 (i386_void_call_2_b, "lea 0x10(%esp),%esp\n\t"
+ /* Restore original stack top. */
+ "pop %eax");
}
-
static void
i386_emit_eq_goto (int *offset_p, int *size_p)
{
EMIT_ASM32 (eq,
- /* Check low half first, more likely to be decider */
- "cmpl %eax,(%esp)\n\t"
- "jne .Leq_fallthru\n\t"
- "cmpl %ebx,4(%esp)\n\t"
- "jne .Leq_fallthru\n\t"
- "lea 0x8(%esp),%esp\n\t"
- "pop %eax\n\t"
- "pop %ebx\n\t"
- /* jmp, but don't trust the assembler to choose the right jump */
- ".byte 0xe9, 0x0, 0x0, 0x0, 0x0\n\t"
- ".Leq_fallthru:\n\t"
- "lea 0x8(%esp),%esp\n\t"
- "pop %eax\n\t"
- "pop %ebx");
+ /* Check low half first, more likely to be decider */
+ "cmpl %eax,(%esp)\n\t"
+ "jne .Leq_fallthru\n\t"
+ "cmpl %ebx,4(%esp)\n\t"
+ "jne .Leq_fallthru\n\t"
+ "lea 0x8(%esp),%esp\n\t"
+ "pop %eax\n\t"
+ "pop %ebx\n\t"
+ /* jmp, but don't trust the assembler to choose the right jump */
+ ".byte 0xe9, 0x0, 0x0, 0x0, 0x0\n\t"
+ ".Leq_fallthru:\n\t"
+ "lea 0x8(%esp),%esp\n\t"
+ "pop %eax\n\t"
+ "pop %ebx");
if (offset_p)
*offset_p = 18;
@@ -2761,21 +2645,21 @@ static void
i386_emit_ne_goto (int *offset_p, int *size_p)
{
EMIT_ASM32 (ne,
- /* Check low half first, more likely to be decider */
- "cmpl %eax,(%esp)\n\t"
- "jne .Lne_jump\n\t"
- "cmpl %ebx,4(%esp)\n\t"
- "je .Lne_fallthru\n\t"
- ".Lne_jump:\n\t"
- "lea 0x8(%esp),%esp\n\t"
- "pop %eax\n\t"
- "pop %ebx\n\t"
- /* jmp, but don't trust the assembler to choose the right jump */
- ".byte 0xe9, 0x0, 0x0, 0x0, 0x0\n\t"
- ".Lne_fallthru:\n\t"
- "lea 0x8(%esp),%esp\n\t"
- "pop %eax\n\t"
- "pop %ebx");
+ /* Check low half first, more likely to be decider */
+ "cmpl %eax,(%esp)\n\t"
+ "jne .Lne_jump\n\t"
+ "cmpl %ebx,4(%esp)\n\t"
+ "je .Lne_fallthru\n\t"
+ ".Lne_jump:\n\t"
+ "lea 0x8(%esp),%esp\n\t"
+ "pop %eax\n\t"
+ "pop %ebx\n\t"
+ /* jmp, but don't trust the assembler to choose the right jump */
+ ".byte 0xe9, 0x0, 0x0, 0x0, 0x0\n\t"
+ ".Lne_fallthru:\n\t"
+ "lea 0x8(%esp),%esp\n\t"
+ "pop %eax\n\t"
+ "pop %ebx");
if (offset_p)
*offset_p = 18;
@@ -2787,21 +2671,21 @@ static void
i386_emit_lt_goto (int *offset_p, int *size_p)
{
EMIT_ASM32 (lt,
- "cmpl %ebx,4(%esp)\n\t"
- "jl .Llt_jump\n\t"
- "jne .Llt_fallthru\n\t"
- "cmpl %eax,(%esp)\n\t"
- "jnl .Llt_fallthru\n\t"
- ".Llt_jump:\n\t"
- "lea 0x8(%esp),%esp\n\t"
- "pop %eax\n\t"
- "pop %ebx\n\t"
- /* jmp, but don't trust the assembler to choose the right jump */
- ".byte 0xe9, 0x0, 0x0, 0x0, 0x0\n\t"
- ".Llt_fallthru:\n\t"
- "lea 0x8(%esp),%esp\n\t"
- "pop %eax\n\t"
- "pop %ebx");
+ "cmpl %ebx,4(%esp)\n\t"
+ "jl .Llt_jump\n\t"
+ "jne .Llt_fallthru\n\t"
+ "cmpl %eax,(%esp)\n\t"
+ "jnl .Llt_fallthru\n\t"
+ ".Llt_jump:\n\t"
+ "lea 0x8(%esp),%esp\n\t"
+ "pop %eax\n\t"
+ "pop %ebx\n\t"
+ /* jmp, but don't trust the assembler to choose the right jump */
+ ".byte 0xe9, 0x0, 0x0, 0x0, 0x0\n\t"
+ ".Llt_fallthru:\n\t"
+ "lea 0x8(%esp),%esp\n\t"
+ "pop %eax\n\t"
+ "pop %ebx");
if (offset_p)
*offset_p = 20;
@@ -2813,21 +2697,21 @@ static void
i386_emit_le_goto (int *offset_p, int *size_p)
{
EMIT_ASM32 (le,
- "cmpl %ebx,4(%esp)\n\t"
- "jle .Lle_jump\n\t"
- "jne .Lle_fallthru\n\t"
- "cmpl %eax,(%esp)\n\t"
- "jnle .Lle_fallthru\n\t"
- ".Lle_jump:\n\t"
- "lea 0x8(%esp),%esp\n\t"
- "pop %eax\n\t"
- "pop %ebx\n\t"
- /* jmp, but don't trust the assembler to choose the right jump */
- ".byte 0xe9, 0x0, 0x0, 0x0, 0x0\n\t"
- ".Lle_fallthru:\n\t"
- "lea 0x8(%esp),%esp\n\t"
- "pop %eax\n\t"
- "pop %ebx");
+ "cmpl %ebx,4(%esp)\n\t"
+ "jle .Lle_jump\n\t"
+ "jne .Lle_fallthru\n\t"
+ "cmpl %eax,(%esp)\n\t"
+ "jnle .Lle_fallthru\n\t"
+ ".Lle_jump:\n\t"
+ "lea 0x8(%esp),%esp\n\t"
+ "pop %eax\n\t"
+ "pop %ebx\n\t"
+ /* jmp, but don't trust the assembler to choose the right jump */
+ ".byte 0xe9, 0x0, 0x0, 0x0, 0x0\n\t"
+ ".Lle_fallthru:\n\t"
+ "lea 0x8(%esp),%esp\n\t"
+ "pop %eax\n\t"
+ "pop %ebx");
if (offset_p)
*offset_p = 20;
@@ -2839,21 +2723,21 @@ static void
i386_emit_gt_goto (int *offset_p, int *size_p)
{
EMIT_ASM32 (gt,
- "cmpl %ebx,4(%esp)\n\t"
- "jg .Lgt_jump\n\t"
- "jne .Lgt_fallthru\n\t"
- "cmpl %eax,(%esp)\n\t"
- "jng .Lgt_fallthru\n\t"
- ".Lgt_jump:\n\t"
- "lea 0x8(%esp),%esp\n\t"
- "pop %eax\n\t"
- "pop %ebx\n\t"
- /* jmp, but don't trust the assembler to choose the right jump */
- ".byte 0xe9, 0x0, 0x0, 0x0, 0x0\n\t"
- ".Lgt_fallthru:\n\t"
- "lea 0x8(%esp),%esp\n\t"
- "pop %eax\n\t"
- "pop %ebx");
+ "cmpl %ebx,4(%esp)\n\t"
+ "jg .Lgt_jump\n\t"
+ "jne .Lgt_fallthru\n\t"
+ "cmpl %eax,(%esp)\n\t"
+ "jng .Lgt_fallthru\n\t"
+ ".Lgt_jump:\n\t"
+ "lea 0x8(%esp),%esp\n\t"
+ "pop %eax\n\t"
+ "pop %ebx\n\t"
+ /* jmp, but don't trust the assembler to choose the right jump */
+ ".byte 0xe9, 0x0, 0x0, 0x0, 0x0\n\t"
+ ".Lgt_fallthru:\n\t"
+ "lea 0x8(%esp),%esp\n\t"
+ "pop %eax\n\t"
+ "pop %ebx");
if (offset_p)
*offset_p = 20;
@@ -2865,21 +2749,21 @@ static void
i386_emit_ge_goto (int *offset_p, int *size_p)
{
EMIT_ASM32 (ge,
- "cmpl %ebx,4(%esp)\n\t"
- "jge .Lge_jump\n\t"
- "jne .Lge_fallthru\n\t"
- "cmpl %eax,(%esp)\n\t"
- "jnge .Lge_fallthru\n\t"
- ".Lge_jump:\n\t"
- "lea 0x8(%esp),%esp\n\t"
- "pop %eax\n\t"
- "pop %ebx\n\t"
- /* jmp, but don't trust the assembler to choose the right jump */
- ".byte 0xe9, 0x0, 0x0, 0x0, 0x0\n\t"
- ".Lge_fallthru:\n\t"
- "lea 0x8(%esp),%esp\n\t"
- "pop %eax\n\t"
- "pop %ebx");
+ "cmpl %ebx,4(%esp)\n\t"
+ "jge .Lge_jump\n\t"
+ "jne .Lge_fallthru\n\t"
+ "cmpl %eax,(%esp)\n\t"
+ "jnge .Lge_fallthru\n\t"
+ ".Lge_jump:\n\t"
+ "lea 0x8(%esp),%esp\n\t"
+ "pop %eax\n\t"
+ "pop %ebx\n\t"
+ /* jmp, but don't trust the assembler to choose the right jump */
+ ".byte 0xe9, 0x0, 0x0, 0x0, 0x0\n\t"
+ ".Lge_fallthru:\n\t"
+ "lea 0x8(%esp),%esp\n\t"
+ "pop %eax\n\t"
+ "pop %ebx");
if (offset_p)
*offset_p = 20;
@@ -2887,47 +2771,20 @@ i386_emit_ge_goto (int *offset_p, int *size_p)
*size_p = 4;
}
-static emit_ops i386_emit_ops =
- {
- i386_emit_prologue,
- i386_emit_epilogue,
- i386_emit_add,
- i386_emit_sub,
- i386_emit_mul,
- i386_emit_lsh,
- i386_emit_rsh_signed,
- i386_emit_rsh_unsigned,
- i386_emit_ext,
- i386_emit_log_not,
- i386_emit_bit_and,
- i386_emit_bit_or,
- i386_emit_bit_xor,
- i386_emit_bit_not,
- i386_emit_equal,
- i386_emit_less_signed,
- i386_emit_less_unsigned,
- i386_emit_ref,
- i386_emit_if_goto,
- i386_emit_goto,
- i386_write_goto_address,
- i386_emit_const,
- i386_emit_call,
- i386_emit_reg,
- i386_emit_pop,
- i386_emit_stack_flush,
- i386_emit_zero_ext,
- i386_emit_swap,
- i386_emit_stack_adjust,
- i386_emit_int_call_1,
- i386_emit_void_call_2,
- i386_emit_eq_goto,
- i386_emit_ne_goto,
- i386_emit_lt_goto,
- i386_emit_le_goto,
- i386_emit_gt_goto,
- i386_emit_ge_goto
- };
-
+static emit_ops i386_emit_ops
+ = { i386_emit_prologue, i386_emit_epilogue, i386_emit_add,
+ i386_emit_sub, i386_emit_mul, i386_emit_lsh,
+ i386_emit_rsh_signed, i386_emit_rsh_unsigned, i386_emit_ext,
+ i386_emit_log_not, i386_emit_bit_and, i386_emit_bit_or,
+ i386_emit_bit_xor, i386_emit_bit_not, i386_emit_equal,
+ i386_emit_less_signed, i386_emit_less_unsigned, i386_emit_ref,
+ i386_emit_if_goto, i386_emit_goto, i386_write_goto_address,
+ i386_emit_const, i386_emit_call, i386_emit_reg,
+ i386_emit_pop, i386_emit_stack_flush, i386_emit_zero_ext,
+ i386_emit_swap, i386_emit_stack_adjust, i386_emit_int_call_1,
+ i386_emit_void_call_2, i386_emit_eq_goto, i386_emit_ne_goto,
+ i386_emit_lt_goto, i386_emit_le_goto, i386_emit_gt_goto,
+ i386_emit_ge_goto };
emit_ops *
x86_target::emit_ops ()
@@ -2982,14 +2839,14 @@ initialize_low_arch (void)
#ifdef __x86_64__
tdesc_amd64_linux_no_xml = allocate_target_description ();
copy_target_description (tdesc_amd64_linux_no_xml.get (),
- amd64_linux_read_description (X86_XSTATE_SSE_MASK,
- false));
+ amd64_linux_read_description (X86_XSTATE_SSE_MASK,
+ false));
tdesc_amd64_linux_no_xml->xmltarget = xmltarget_amd64_linux_no_xml;
#endif
tdesc_i386_linux_no_xml = allocate_target_description ();
copy_target_description (tdesc_i386_linux_no_xml.get (),
- i386_linux_read_description (X86_XSTATE_SSE_MASK));
+ i386_linux_read_description (X86_XSTATE_SSE_MASK));
tdesc_i386_linux_no_xml->xmltarget = xmltarget_i386_linux_no_xml;
initialize_regsets_info (&x86_regsets_info);
diff --git a/gdbserver/linux-x86-tdesc.cc b/gdbserver/linux-x86-tdesc.cc
index ba81daa..026b56b 100644
--- a/gdbserver/linux-x86-tdesc.cc
+++ b/gdbserver/linux-x86-tdesc.cc
@@ -36,28 +36,28 @@ xcr0_to_tdesc_idx (uint64_t xcr0, bool is_x32)
if (xcr0 & X86_XSTATE_PKRU)
{
if (is_x32)
- {
- /* No x32 MPX and PKU, fall back to avx_avx512. */
- return X86_TDESC_AVX_AVX512;
- }
+ {
+ /* No x32 MPX and PKU, fall back to avx_avx512. */
+ return X86_TDESC_AVX_AVX512;
+ }
else
- return X86_TDESC_AVX_MPX_AVX512_PKU;
+ return X86_TDESC_AVX_MPX_AVX512_PKU;
}
else if (xcr0 & X86_XSTATE_AVX512)
return X86_TDESC_AVX_AVX512;
else if ((xcr0 & X86_XSTATE_AVX_MPX_MASK) == X86_XSTATE_AVX_MPX_MASK)
{
if (is_x32) /* No MPX on x32. */
- return X86_TDESC_AVX;
+ return X86_TDESC_AVX;
else
- return X86_TDESC_AVX_MPX;
+ return X86_TDESC_AVX_MPX;
}
else if (xcr0 & X86_XSTATE_MPX)
{
if (is_x32) /* No MPX on x32. */
- return X86_TDESC_AVX;
+ return X86_TDESC_AVX;
else
- return X86_TDESC_MPX;
+ return X86_TDESC_MPX;
}
else if (xcr0 & X86_XSTATE_AVX)
return X86_TDESC_AVX;
@@ -71,7 +71,7 @@ xcr0_to_tdesc_idx (uint64_t xcr0, bool is_x32)
#if defined __i386__ || !defined IN_PROCESS_AGENT
-static struct target_desc *i386_tdescs[X86_TDESC_LAST] = { };
+static struct target_desc *i386_tdescs[X86_TDESC_LAST] = {};
/* Return the target description according to XCR0. */
@@ -92,14 +92,15 @@ i386_linux_read_description (uint64_t xcr0)
init_target_desc (*tdesc, i386_expedite_regs);
}
- return *tdesc;;
+ return *tdesc;
+ ;
}
#endif
#ifdef __x86_64__
-static target_desc *amd64_tdescs[X86_TDESC_LAST] = { };
-static target_desc *x32_tdescs[X86_TDESC_LAST] = { };
+static target_desc *amd64_tdescs[X86_TDESC_LAST] = {};
+static target_desc *x32_tdescs[X86_TDESC_LAST] = {};
const struct target_desc *
amd64_linux_read_description (uint64_t xcr0, bool is_x32)
@@ -135,7 +136,7 @@ i386_get_ipa_tdesc_idx (const struct target_desc *tdesc)
for (int i = 0; i < X86_TDESC_LAST; i++)
{
if (tdesc == i386_tdescs[i])
- return i;
+ return i;
}
/* If none tdesc is found, return the one with minimum features. */
@@ -149,12 +150,12 @@ amd64_get_ipa_tdesc_idx (const struct target_desc *tdesc)
for (int i = 0; i < X86_TDESC_LAST; i++)
{
if (tdesc == amd64_tdescs[i])
- return i;
+ return i;
}
for (int i = 0; i < X86_TDESC_LAST; i++)
{
if (tdesc == x32_tdescs[i])
- return i;
+ return i;
}
return X86_TDESC_SSE;
diff --git a/gdbserver/linux-x86-tdesc.h b/gdbserver/linux-x86-tdesc.h
index a12d28d..fb890536 100644
--- a/gdbserver/linux-x86-tdesc.h
+++ b/gdbserver/linux-x86-tdesc.h
@@ -25,7 +25,8 @@
vs x32), it's sufficient to pass only the register set here. This,
together with the ABI known at IPA compile time, maps to a tdesc. */
-enum x86_linux_tdesc {
+enum x86_linux_tdesc
+{
X86_TDESC_MMX = 0,
X86_TDESC_SSE = 1,
X86_TDESC_AVX = 2,
@@ -48,7 +49,7 @@ const struct target_desc *i386_get_ipa_tdesc (int idx);
#ifdef __x86_64__
const struct target_desc *amd64_linux_read_description (uint64_t xcr0,
- bool is_x32);
+ bool is_x32);
#endif
const struct target_desc *i386_linux_read_description (uint64_t xcr0);
diff --git a/gdbserver/linux-xtensa-low.cc b/gdbserver/linux-xtensa-low.cc
index 9d213db..9ef4911 100644
--- a/gdbserver/linux-xtensa-low.cc
+++ b/gdbserver/linux-xtensa-low.cc
@@ -16,7 +16,6 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
-
#include "server.h"
#include "linux-low.h"
@@ -25,13 +24,11 @@
class xtensa_target : public linux_process_target
{
public:
-
const regs_info *get_regs_info () override;
const gdb_byte *sw_breakpoint_from_kind (int kind, int *size) override;
protected:
-
void low_arch_setup () override;
bool low_cannot_fetch_register (int regno) override;
@@ -55,14 +52,14 @@ bool
xtensa_target::low_cannot_fetch_register (int regno)
{
gdb_assert_not_reached ("linux target op low_cannot_fetch_register "
- "is not implemented by the target");
+ "is not implemented by the target");
}
bool
xtensa_target::low_cannot_store_register (int regno)
{
gdb_assert_not_reached ("linux target op low_cannot_store_register "
- "is not implemented by the target");
+ "is not implemented by the target");
}
bool
@@ -94,19 +91,24 @@ extern const struct target_desc *tdesc_xtensa;
#include "xtensa-xtregs.c"
-enum regnum {
- R_PC=0, R_PS,
- R_LBEG, R_LEND, R_LCOUNT,
- R_SAR,
- R_WS, R_WB,
- R_THREADPTR,
- R_A0 = 64
+enum regnum
+{
+ R_PC = 0,
+ R_PS,
+ R_LBEG,
+ R_LEND,
+ R_LCOUNT,
+ R_SAR,
+ R_WS,
+ R_WB,
+ R_THREADPTR,
+ R_A0 = 64
};
static void
xtensa_fill_gregset (struct regcache *regcache, void *buf)
{
- elf_greg_t* rset = (elf_greg_t*)buf;
+ elf_greg_t *rset = (elf_greg_t *) buf;
const struct target_desc *tdesc = regcache->tdesc;
int ar0_regnum;
char *ptr;
@@ -115,7 +117,7 @@ xtensa_fill_gregset (struct regcache *regcache, void *buf)
/* Take care of AR registers. */
ar0_regnum = find_regno (tdesc, "ar0");
- ptr = (char*)&rset[R_A0];
+ ptr = (char *) &rset[R_A0];
for (i = ar0_regnum; i < ar0_regnum + XCHAL_NUM_AREGS; i++)
{
@@ -129,38 +131,38 @@ xtensa_fill_gregset (struct regcache *regcache, void *buf)
ptr = (char *) &rset[R_A0 + 4 * rset[R_WB]];
for (i = a0_regnum; i < a0_regnum + C0_NREGS; i++)
- {
- if ((4 * rset[R_WB] + i - a0_regnum) == XCHAL_NUM_AREGS)
- ptr = (char *) &rset[R_A0];
- collect_register (regcache, i, ptr);
- ptr += register_size (tdesc, i);
- }
+ {
+ if ((4 * rset[R_WB] + i - a0_regnum) == XCHAL_NUM_AREGS)
+ ptr = (char *) &rset[R_A0];
+ collect_register (regcache, i, ptr);
+ ptr += register_size (tdesc, i);
+ }
}
- /* Loop registers, if hardware has it. */
+ /* Loop registers, if hardware has it. */
#if XCHAL_HAVE_LOOPS
- collect_register_by_name (regcache, "lbeg", (char*)&rset[R_LBEG]);
- collect_register_by_name (regcache, "lend", (char*)&rset[R_LEND]);
- collect_register_by_name (regcache, "lcount", (char*)&rset[R_LCOUNT]);
+ collect_register_by_name (regcache, "lbeg", (char *) &rset[R_LBEG]);
+ collect_register_by_name (regcache, "lend", (char *) &rset[R_LEND]);
+ collect_register_by_name (regcache, "lcount", (char *) &rset[R_LCOUNT]);
#endif
- collect_register_by_name (regcache, "sar", (char*)&rset[R_SAR]);
- collect_register_by_name (regcache, "pc", (char*)&rset[R_PC]);
- collect_register_by_name (regcache, "ps", (char*)&rset[R_PS]);
- collect_register_by_name (regcache, "windowbase", (char*)&rset[R_WB]);
- collect_register_by_name (regcache, "windowstart", (char*)&rset[R_WS]);
+ collect_register_by_name (regcache, "sar", (char *) &rset[R_SAR]);
+ collect_register_by_name (regcache, "pc", (char *) &rset[R_PC]);
+ collect_register_by_name (regcache, "ps", (char *) &rset[R_PS]);
+ collect_register_by_name (regcache, "windowbase", (char *) &rset[R_WB]);
+ collect_register_by_name (regcache, "windowstart", (char *) &rset[R_WS]);
#if XCHAL_HAVE_THREADPTR
collect_register_by_name (regcache, "threadptr",
- (char *) &rset[R_THREADPTR]);
+ (char *) &rset[R_THREADPTR]);
#endif
}
static void
xtensa_store_gregset (struct regcache *regcache, const void *buf)
{
- const elf_greg_t* rset = (const elf_greg_t*)buf;
+ const elf_greg_t *rset = (const elf_greg_t *) buf;
const struct target_desc *tdesc = regcache->tdesc;
int ar0_regnum;
char *ptr;
@@ -169,7 +171,7 @@ xtensa_store_gregset (struct regcache *regcache, const void *buf)
/* Take care of AR registers. */
ar0_regnum = find_regno (tdesc, "ar0");
- ptr = (char *)&rset[R_A0];
+ ptr = (char *) &rset[R_A0];
for (i = ar0_regnum; i < ar0_regnum + XCHAL_NUM_AREGS; i++)
{
@@ -183,31 +185,30 @@ xtensa_store_gregset (struct regcache *regcache, const void *buf)
ptr = (char *) &rset[R_A0 + (4 * rset[R_WB]) % XCHAL_NUM_AREGS];
for (i = a0_regnum; i < a0_regnum + C0_NREGS; i++)
- {
- if ((4 * rset[R_WB] + i - a0_regnum) == XCHAL_NUM_AREGS)
- ptr = (char *) &rset[R_A0];
- supply_register (regcache, i, ptr);
- ptr += register_size (tdesc, i);
- }
+ {
+ if ((4 * rset[R_WB] + i - a0_regnum) == XCHAL_NUM_AREGS)
+ ptr = (char *) &rset[R_A0];
+ supply_register (regcache, i, ptr);
+ ptr += register_size (tdesc, i);
+ }
}
- /* Loop registers, if hardware has it. */
+ /* Loop registers, if hardware has it. */
#if XCHAL_HAVE_LOOPS
- supply_register_by_name (regcache, "lbeg", (char*)&rset[R_LBEG]);
- supply_register_by_name (regcache, "lend", (char*)&rset[R_LEND]);
- supply_register_by_name (regcache, "lcount", (char*)&rset[R_LCOUNT]);
+ supply_register_by_name (regcache, "lbeg", (char *) &rset[R_LBEG]);
+ supply_register_by_name (regcache, "lend", (char *) &rset[R_LEND]);
+ supply_register_by_name (regcache, "lcount", (char *) &rset[R_LCOUNT]);
#endif
- supply_register_by_name (regcache, "sar", (char*)&rset[R_SAR]);
- supply_register_by_name (regcache, "pc", (char*)&rset[R_PC]);
- supply_register_by_name (regcache, "ps", (char*)&rset[R_PS]);
- supply_register_by_name (regcache, "windowbase", (char*)&rset[R_WB]);
- supply_register_by_name (regcache, "windowstart", (char*)&rset[R_WS]);
+ supply_register_by_name (regcache, "sar", (char *) &rset[R_SAR]);
+ supply_register_by_name (regcache, "pc", (char *) &rset[R_PC]);
+ supply_register_by_name (regcache, "ps", (char *) &rset[R_PS]);
+ supply_register_by_name (regcache, "windowbase", (char *) &rset[R_WB]);
+ supply_register_by_name (regcache, "windowstart", (char *) &rset[R_WS]);
#if XCHAL_HAVE_THREADPTR
- supply_register_by_name (regcache, "threadptr",
- (char *) &rset[R_THREADPTR]);
+ supply_register_by_name (regcache, "threadptr", (char *) &rset[R_THREADPTR]);
#endif
}
@@ -221,7 +222,7 @@ xtensa_fill_xtregset (struct regcache *regcache, void *buf)
for (ptr = xtensa_regmap_table; ptr->name; ptr++)
{
collect_register_by_name (regcache, ptr->name,
- (char*)buf + ptr->ptrace_offset);
+ (char *) buf + ptr->ptrace_offset);
}
}
@@ -233,24 +234,27 @@ xtensa_store_xtregset (struct regcache *regcache, const void *buf)
for (ptr = xtensa_regmap_table; ptr->name; ptr++)
{
supply_register_by_name (regcache, ptr->name,
- (char*)buf + ptr->ptrace_offset);
+ (char *) buf + ptr->ptrace_offset);
}
}
-static struct regset_info xtensa_regsets[] = {
- { PTRACE_GETREGS, PTRACE_SETREGS, 0, sizeof (elf_gregset_t),
- GENERAL_REGS,
- xtensa_fill_gregset, xtensa_store_gregset },
- { PTRACE_GETXTREGS, PTRACE_SETXTREGS, 0, XTENSA_ELF_XTREG_SIZE,
- EXTENDED_REGS,
- xtensa_fill_xtregset, xtensa_store_xtregset },
- NULL_REGSET
-};
+static struct regset_info xtensa_regsets[]
+ = { { PTRACE_GETREGS, PTRACE_SETREGS, 0, sizeof (elf_gregset_t),
+ GENERAL_REGS, xtensa_fill_gregset, xtensa_store_gregset },
+ { PTRACE_GETXTREGS, PTRACE_SETXTREGS, 0, XTENSA_ELF_XTREG_SIZE,
+ EXTENDED_REGS, xtensa_fill_xtregset, xtensa_store_xtregset },
+ NULL_REGSET };
#if XCHAL_HAVE_BE
-#define XTENSA_BREAKPOINT {0xd2,0x0f}
+#define XTENSA_BREAKPOINT \
+ { \
+ 0xd2, 0x0f \
+ }
#else
-#define XTENSA_BREAKPOINT {0x2d,0xf0}
+#define XTENSA_BREAKPOINT \
+ { \
+ 0x2d, 0xf0 \
+ }
#endif
static const gdb_byte xtensa_breakpoint[] = XTENSA_BREAKPOINT;
@@ -268,18 +272,18 @@ xtensa_target::sw_breakpoint_from_kind (int kind, int *size)
bool
xtensa_target::low_breakpoint_at (CORE_ADDR where)
{
- unsigned long insn;
+ unsigned long insn;
- read_memory (where, (unsigned char *) &insn, xtensa_breakpoint_len);
- return memcmp((char *) &insn,
- xtensa_breakpoint, xtensa_breakpoint_len) == 0;
+ read_memory (where, (unsigned char *) &insn, xtensa_breakpoint_len);
+ return memcmp ((char *) &insn, xtensa_breakpoint, xtensa_breakpoint_len)
+ == 0;
}
/* Called by libthread_db. */
ps_err_e
-ps_get_thread_area (struct ps_prochandle *ph,
- lwpid_t lwpid, int idx, void **base)
+ps_get_thread_area (struct ps_prochandle *ph, lwpid_t lwpid, int idx,
+ void **base)
{
xtensa_elf_gregset_t regs;
@@ -294,19 +298,15 @@ ps_get_thread_area (struct ps_prochandle *ph,
return PS_OK;
}
-static struct regsets_info xtensa_regsets_info =
- {
- xtensa_regsets, /* regsets */
- 0, /* num_regsets */
- NULL, /* disabled_regsets */
- };
-
-static struct regs_info myregs_info =
- {
- NULL, /* regset_bitmap */
- NULL, /* usrregs */
- &xtensa_regsets_info
- };
+static struct regsets_info xtensa_regsets_info = {
+ xtensa_regsets, /* regsets */
+ 0, /* num_regsets */
+ NULL, /* disabled_regsets */
+};
+
+static struct regs_info myregs_info = { NULL, /* regset_bitmap */
+ NULL, /* usrregs */
+ &xtensa_regsets_info };
void
xtensa_target::low_arch_setup ()
diff --git a/gdbserver/mem-break.cc b/gdbserver/mem-break.cc
index c669842..6e583b9 100644
--- a/gdbserver/mem-break.cc
+++ b/gdbserver/mem-break.cc
@@ -32,15 +32,15 @@
NULL. */
#define APPEND_TO_LIST(listpp, itemp, tailp) \
- do \
- { \
- if ((tailp) == NULL) \
- *(listpp) = (itemp); \
- else \
- (tailp)->next = (itemp); \
- (tailp) = (itemp); \
- } \
- while (0)
+ do \
+ { \
+ if ((tailp) == NULL) \
+ *(listpp) = (itemp); \
+ else \
+ (tailp)->next = (itemp); \
+ (tailp) = (itemp); \
+ } \
+ while (0)
/* GDB will never try to install multiple breakpoints at the same
address. However, we can see GDB requesting to insert a breakpoint
@@ -117,29 +117,29 @@ struct raw_breakpoint
/* The type of a breakpoint. */
enum bkpt_type
- {
- /* A GDB breakpoint, requested with a Z0 packet. */
- gdb_breakpoint_Z0,
+{
+ /* A GDB breakpoint, requested with a Z0 packet. */
+ gdb_breakpoint_Z0,
- /* A GDB hardware breakpoint, requested with a Z1 packet. */
- gdb_breakpoint_Z1,
+ /* A GDB hardware breakpoint, requested with a Z1 packet. */
+ gdb_breakpoint_Z1,
- /* A GDB write watchpoint, requested with a Z2 packet. */
- gdb_breakpoint_Z2,
+ /* A GDB write watchpoint, requested with a Z2 packet. */
+ gdb_breakpoint_Z2,
- /* A GDB read watchpoint, requested with a Z3 packet. */
- gdb_breakpoint_Z3,
+ /* A GDB read watchpoint, requested with a Z3 packet. */
+ gdb_breakpoint_Z3,
- /* A GDB access watchpoint, requested with a Z4 packet. */
- gdb_breakpoint_Z4,
+ /* A GDB access watchpoint, requested with a Z4 packet. */
+ gdb_breakpoint_Z4,
- /* A software single-step breakpoint. */
- single_step_breakpoint,
+ /* A software single-step breakpoint. */
+ single_step_breakpoint,
- /* Any other breakpoint type that doesn't require specific
+ /* Any other breakpoint type that doesn't require specific
treatment goes here. E.g., an event breakpoint. */
- other_breakpoint,
- };
+ other_breakpoint,
+};
struct point_cond_list
{
@@ -294,11 +294,9 @@ Z_packet_to_raw_bkpt_type (char z_type)
static int
is_gdb_breakpoint (enum bkpt_type type)
{
- return (type == gdb_breakpoint_Z0
- || type == gdb_breakpoint_Z1
- || type == gdb_breakpoint_Z2
- || type == gdb_breakpoint_Z3
- || type == gdb_breakpoint_Z4);
+ return (type == gdb_breakpoint_Z0 || type == gdb_breakpoint_Z1
+ || type == gdb_breakpoint_Z2 || type == gdb_breakpoint_Z3
+ || type == gdb_breakpoint_Z4);
}
bool
@@ -310,13 +308,13 @@ any_persistent_commands (process_info *proc)
for (bp = proc->breakpoints; bp != NULL; bp = bp->next)
{
if (is_gdb_breakpoint (bp->type))
- {
- struct gdb_breakpoint *gdb_bp = (struct gdb_breakpoint *) bp;
+ {
+ struct gdb_breakpoint *gdb_bp = (struct gdb_breakpoint *) bp;
- for (cl = gdb_bp->command_list; cl != NULL; cl = cl->next)
- if (cl->persistence)
- return true;
- }
+ for (cl = gdb_bp->command_list; cl != NULL; cl = cl->next)
+ if (cl->persistence)
+ return true;
+ }
}
return false;
@@ -332,9 +330,7 @@ find_enabled_raw_code_breakpoint_at (CORE_ADDR addr, enum raw_bkpt_type type)
struct raw_breakpoint *bp;
for (bp = proc->raw_breakpoints; bp != NULL; bp = bp->next)
- if (bp->pc == addr
- && bp->raw_type == type
- && bp->inserted >= 0)
+ if (bp->pc == addr && bp->raw_type == type && bp->inserted >= 0)
return bp;
return NULL;
@@ -371,18 +367,17 @@ insert_memory_breakpoint (struct raw_breakpoint *bp)
if (err != 0)
{
threads_debug_printf ("Failed to read shadow memory of"
- " breakpoint at 0x%s (%s).",
- paddress (bp->pc), safe_strerror (err));
+ " breakpoint at 0x%s (%s).",
+ paddress (bp->pc), safe_strerror (err));
}
else
{
memcpy (bp->old_data, buf, bp_size (bp));
- err = the_target->write_memory (bp->pc, bp_opcode (bp),
- bp_size (bp));
+ err = the_target->write_memory (bp->pc, bp_opcode (bp), bp_size (bp));
if (err != 0)
- threads_debug_printf ("Failed to insert breakpoint at 0x%s (%s).",
- paddress (bp->pc), safe_strerror (err));
+ threads_debug_printf ("Failed to insert breakpoint at 0x%s (%s).",
+ paddress (bp->pc), safe_strerror (err));
}
return err != 0 ? -1 : 0;
}
@@ -406,9 +401,9 @@ remove_memory_breakpoint (struct raw_breakpoint *bp)
memcpy (buf, bp->old_data, bp_size (bp));
err = target_write_memory (bp->pc, buf, bp_size (bp));
if (err != 0)
- threads_debug_printf ("Failed to uninsert raw breakpoint "
- "at 0x%s (%s) while deleting it.",
- paddress (bp->pc), safe_strerror (err));
+ threads_debug_printf ("Failed to uninsert raw breakpoint "
+ "at 0x%s (%s) while deleting it.",
+ paddress (bp->pc), safe_strerror (err));
return err != 0 ? -1 : 0;
}
@@ -419,7 +414,7 @@ remove_memory_breakpoint (struct raw_breakpoint *bp)
static struct raw_breakpoint *
set_raw_breakpoint_at (enum raw_bkpt_type type, CORE_ADDR where, int kind,
- int *err)
+ int *err)
{
struct process_info *proc = current_process ();
struct raw_breakpoint *bp;
@@ -428,15 +423,14 @@ set_raw_breakpoint_at (enum raw_bkpt_type type, CORE_ADDR where, int kind,
{
bp = find_enabled_raw_code_breakpoint_at (where, type);
if (bp != NULL && bp->kind != kind)
- {
- /* A different kind than previously seen. The previous
+ {
+ /* A different kind than previously seen. The previous
breakpoint must be gone then. */
- threads_debug_printf
- ("Inconsistent breakpoint kind? Was %d, now %d.",
- bp->kind, kind);
- bp->inserted = -1;
- bp = NULL;
- }
+ threads_debug_printf (
+ "Inconsistent breakpoint kind? Was %d, now %d.", bp->kind, kind);
+ bp->inserted = -1;
+ bp = NULL;
+ }
}
else
bp = find_raw_breakpoint_at (where, type, kind);
@@ -455,12 +449,12 @@ set_raw_breakpoint_at (enum raw_bkpt_type type, CORE_ADDR where, int kind,
{
*err = the_target->insert_point (bp->raw_type, bp->pc, bp->kind, bp);
if (*err != 0)
- {
- threads_debug_printf ("Failed to insert breakpoint at 0x%s (%d).",
- paddress (where), *err);
+ {
+ threads_debug_printf ("Failed to insert breakpoint at 0x%s (%d).",
+ paddress (where), *err);
- return NULL;
- }
+ return NULL;
+ }
bp->inserted = 1;
}
@@ -485,7 +479,6 @@ set_raw_breakpoint_at (enum raw_bkpt_type type, CORE_ADDR where, int kind,
"priority". In turn, this allows having fast and slow tracepoints
(and breakpoints) at the same address behave correctly. */
-
/* A fast tracepoint jump. */
struct fast_tracepoint_jump
@@ -516,13 +509,10 @@ struct fast_tracepoint_jump
};
/* Fast tracepoint FP's jump instruction to insert. */
-#define fast_tracepoint_jump_insn(fp) \
- ((fp)->insn_and_shadow + 0)
+#define fast_tracepoint_jump_insn(fp) ((fp)->insn_and_shadow + 0)
/* The shadow memory of fast tracepoint jump FP. */
-#define fast_tracepoint_jump_shadow(fp) \
- ((fp)->insn_and_shadow + (fp)->length)
-
+#define fast_tracepoint_jump_shadow(fp) ((fp)->insn_and_shadow + (fp)->length)
/* Return the fast tracepoint jump set at WHERE. */
@@ -560,16 +550,16 @@ delete_fast_tracepoint_jump (struct fast_tracepoint_jump *todel)
while (bp)
{
if (bp == todel)
- {
- if (--bp->refcount == 0)
- {
- struct fast_tracepoint_jump *prev_bp_link = *bp_link;
- unsigned char *buf;
+ {
+ if (--bp->refcount == 0)
+ {
+ struct fast_tracepoint_jump *prev_bp_link = *bp_link;
+ unsigned char *buf;
- /* Unlink it. */
- *bp_link = bp->next;
+ /* Unlink it. */
+ *bp_link = bp->next;
- /* Since there can be breakpoints inserted in the same
+ /* Since there can be breakpoints inserted in the same
address range, we use `target_write_memory', which
takes care of layering breakpoints on top of fast
tracepoints, and on top of the buffer we pass it.
@@ -578,31 +568,31 @@ delete_fast_tracepoint_jump (struct fast_tracepoint_jump *todel)
pass the current shadow contents, because
target_write_memory updates any shadow memory with
what we pass here, and we want that to be a nop. */
- buf = (unsigned char *) alloca (bp->length);
- memcpy (buf, fast_tracepoint_jump_shadow (bp), bp->length);
- ret = target_write_memory (bp->pc, buf, bp->length);
- if (ret != 0)
- {
- /* Something went wrong, relink the jump. */
- *bp_link = prev_bp_link;
-
- threads_debug_printf
- ("Failed to uninsert fast tracepoint jump "
- "at 0x%s (%s) while deleting it.",
- paddress (bp->pc), safe_strerror (ret));
- return ret;
- }
-
- free (bp);
- }
-
- return 0;
- }
+ buf = (unsigned char *) alloca (bp->length);
+ memcpy (buf, fast_tracepoint_jump_shadow (bp), bp->length);
+ ret = target_write_memory (bp->pc, buf, bp->length);
+ if (ret != 0)
+ {
+ /* Something went wrong, relink the jump. */
+ *bp_link = prev_bp_link;
+
+ threads_debug_printf (
+ "Failed to uninsert fast tracepoint jump "
+ "at 0x%s (%s) while deleting it.",
+ paddress (bp->pc), safe_strerror (ret));
+ return ret;
+ }
+
+ free (bp);
+ }
+
+ return 0;
+ }
else
- {
- bp_link = &bp->next;
- bp = *bp_link;
- }
+ {
+ bp_link = &bp->next;
+ bp = *bp_link;
+ }
}
warning ("Could not find fast tracepoint jump in list.");
@@ -616,8 +606,8 @@ inc_ref_fast_tracepoint_jump (struct fast_tracepoint_jump *jp)
}
struct fast_tracepoint_jump *
-set_fast_tracepoint_jump (CORE_ADDR where,
- unsigned char *insn, ULONGEST length)
+set_fast_tracepoint_jump (CORE_ADDR where, unsigned char *insn,
+ ULONGEST length)
{
struct process_info *proc = current_process ();
struct fast_tracepoint_jump *jp;
@@ -636,7 +626,8 @@ set_fast_tracepoint_jump (CORE_ADDR where,
/* We don't, so create a new object. Double the length, because the
flexible array member holds both the jump insn, and the
shadow. */
- jp = (struct fast_tracepoint_jump *) xcalloc (1, sizeof (*jp) + (length * 2));
+ jp
+ = (struct fast_tracepoint_jump *) xcalloc (1, sizeof (*jp) + (length * 2));
jp->pc = where;
jp->length = length;
memcpy (fast_tracepoint_jump_insn (jp), insn, length);
@@ -650,8 +641,8 @@ set_fast_tracepoint_jump (CORE_ADDR where,
if (err != 0)
{
threads_debug_printf ("Failed to read shadow memory of"
- " fast tracepoint at 0x%s (%s).",
- paddress (where), safe_strerror (err));
+ " fast tracepoint at 0x%s (%s).",
+ paddress (where), safe_strerror (err));
free (jp);
return NULL;
}
@@ -673,9 +664,9 @@ set_fast_tracepoint_jump (CORE_ADDR where,
err = target_write_memory (where, buf, length);
if (err != 0)
{
- threads_debug_printf
- ("Failed to insert fast tracepoint jump at 0x%s (%s).",
- paddress (where), safe_strerror (err));
+ threads_debug_printf (
+ "Failed to insert fast tracepoint jump at 0x%s (%s).",
+ paddress (where), safe_strerror (err));
/* Unlink it. */
proc->fast_tracepoint_jumps = jp->next;
@@ -699,8 +690,8 @@ uninsert_fast_tracepoint_jumps_at (CORE_ADDR pc)
/* This can happen when we remove all breakpoints while handling
a step-over. */
threads_debug_printf ("Could not find fast tracepoint jump at 0x%s "
- "in list (uninserting).",
- paddress (pc));
+ "in list (uninserting).",
+ paddress (pc));
return;
}
@@ -723,13 +714,13 @@ uninsert_fast_tracepoint_jumps_at (CORE_ADDR pc)
memcpy (buf, fast_tracepoint_jump_shadow (jp), jp->length);
err = target_write_memory (jp->pc, buf, jp->length);
if (err != 0)
- {
- jp->inserted = 1;
+ {
+ jp->inserted = 1;
- threads_debug_printf ("Failed to uninsert fast tracepoint jump at"
- " 0x%s (%s).",
- paddress (pc), safe_strerror (err));
- }
+ threads_debug_printf ("Failed to uninsert fast tracepoint jump at"
+ " 0x%s (%s).",
+ paddress (pc), safe_strerror (err));
+ }
}
}
@@ -746,8 +737,8 @@ reinsert_fast_tracepoint_jumps_at (CORE_ADDR where)
/* This can happen when we remove breakpoints when a tracepoint
hit causes a tracing stop, while handling a step-over. */
threads_debug_printf ("Could not find fast tracepoint jump at 0x%s "
- "in list (reinserting).",
- paddress (where));
+ "in list (reinserting).",
+ paddress (where));
return;
}
@@ -772,8 +763,8 @@ reinsert_fast_tracepoint_jumps_at (CORE_ADDR where)
jp->inserted = 0;
threads_debug_printf ("Failed to reinsert fast tracepoint jump at"
- " 0x%s (%s).",
- paddress (where), safe_strerror (err));
+ " 0x%s (%s).",
+ paddress (where), safe_strerror (err));
}
}
@@ -786,8 +777,8 @@ reinsert_fast_tracepoint_jumps_at (CORE_ADDR where)
static struct breakpoint *
set_breakpoint (enum bkpt_type type, enum raw_bkpt_type raw_type,
- CORE_ADDR where, int kind,
- int (*handler) (CORE_ADDR), int *err)
+ CORE_ADDR where, int kind, int (*handler) (CORE_ADDR),
+ int *err)
{
struct process_info *proc = current_process ();
struct breakpoint *bp;
@@ -818,7 +809,7 @@ set_breakpoint (enum bkpt_type type, enum raw_bkpt_type raw_type,
else if (type == single_step_breakpoint)
{
struct single_step_breakpoint *ss_bp
- = XCNEW (struct single_step_breakpoint);
+ = XCNEW (struct single_step_breakpoint);
bp = (struct breakpoint *) ss_bp;
}
@@ -838,15 +829,14 @@ set_breakpoint (enum bkpt_type type, enum raw_bkpt_type raw_type,
static struct breakpoint *
set_breakpoint_type_at (enum bkpt_type type, CORE_ADDR where,
- int (*handler) (CORE_ADDR))
+ int (*handler) (CORE_ADDR))
{
int err_ignored;
CORE_ADDR placed_address = where;
int breakpoint_kind = target_breakpoint_kind_from_pc (&placed_address);
- return set_breakpoint (type, raw_bkpt_type_sw,
- placed_address, breakpoint_kind, handler,
- &err_ignored);
+ return set_breakpoint (type, raw_bkpt_type_sw, placed_address,
+ breakpoint_kind, handler, &err_ignored);
}
/* See mem-break.h */
@@ -857,7 +847,6 @@ set_breakpoint_at (CORE_ADDR where, int (*handler) (CORE_ADDR))
return set_breakpoint_type_at (other_breakpoint, where, handler);
}
-
static int
delete_raw_breakpoint (struct process_info *proc, struct raw_breakpoint *todel)
{
@@ -870,37 +859,37 @@ delete_raw_breakpoint (struct process_info *proc, struct raw_breakpoint *todel)
while (bp)
{
if (bp == todel)
- {
- if (bp->inserted > 0)
- {
- struct raw_breakpoint *prev_bp_link = *bp_link;
-
- *bp_link = bp->next;
-
- ret = the_target->remove_point (bp->raw_type, bp->pc,
- bp->kind, bp);
- if (ret != 0)
- {
- /* Something went wrong, relink the breakpoint. */
- *bp_link = prev_bp_link;
-
- threads_debug_printf ("Failed to uninsert raw breakpoint "
- "at 0x%s while deleting it.",
- paddress (bp->pc));
- return ret;
- }
- }
- else
- *bp_link = bp->next;
-
- free (bp);
- return 0;
- }
+ {
+ if (bp->inserted > 0)
+ {
+ struct raw_breakpoint *prev_bp_link = *bp_link;
+
+ *bp_link = bp->next;
+
+ ret = the_target->remove_point (bp->raw_type, bp->pc, bp->kind,
+ bp);
+ if (ret != 0)
+ {
+ /* Something went wrong, relink the breakpoint. */
+ *bp_link = prev_bp_link;
+
+ threads_debug_printf ("Failed to uninsert raw breakpoint "
+ "at 0x%s while deleting it.",
+ paddress (bp->pc));
+ return ret;
+ }
+ }
+ else
+ *bp_link = bp->next;
+
+ free (bp);
+ return 0;
+ }
else
- {
- bp_link = &bp->next;
- bp = *bp_link;
- }
+ {
+ bp_link = &bp->next;
+ bp = *bp_link;
+ }
}
warning ("Could not find raw breakpoint in list.");
@@ -918,7 +907,7 @@ release_breakpoint (struct process_info *proc, struct breakpoint *bp)
{
ret = delete_raw_breakpoint (proc, bp->raw);
if (ret != 0)
- return ret;
+ return ret;
}
else
bp->raw->refcount = newrefcount;
@@ -940,21 +929,21 @@ delete_breakpoint_1 (struct process_info *proc, struct breakpoint *todel)
while (bp)
{
if (bp == todel)
- {
- *bp_link = bp->next;
+ {
+ *bp_link = bp->next;
- err = release_breakpoint (proc, bp);
- if (err != 0)
- return err;
+ err = release_breakpoint (proc, bp);
+ if (err != 0)
+ return err;
- bp = *bp_link;
- return 0;
- }
+ bp = *bp_link;
+ return 0;
+ }
else
- {
- bp_link = &bp->next;
- bp = *bp_link;
- }
+ {
+ bp_link = &bp->next;
+ bp = *bp_link;
+ }
}
warning ("Could not find breakpoint in list.");
@@ -981,7 +970,7 @@ find_gdb_breakpoint (char z_type, CORE_ADDR addr, int kind)
for (bp = proc->breakpoints; bp != NULL; bp = bp->next)
if (bp->type == type && bp->raw->pc == addr
- && (kind == -1 || bp->raw->kind == kind))
+ && (kind == -1 || bp->raw->kind == kind))
return (struct gdb_breakpoint *) bp;
return NULL;
@@ -991,7 +980,7 @@ static int
z_type_supported (char z_type)
{
return (z_type >= '0' && z_type <= '4'
- && the_target->supports_z_point_type (z_type));
+ && the_target->supports_z_point_type (z_type));
}
/* Create a new GDB breakpoint of type Z_TYPE at ADDR with kind KIND.
@@ -1027,33 +1016,32 @@ set_gdb_breakpoint (char z_type, CORE_ADDR addr, int kind, int *err)
Note this must be careful to not create a window where
breakpoints are removed from the target, for non-stop, in case
the target can poke at memory while the program is running. */
- if (z_type == Z_PACKET_SW_BP
- || z_type == Z_PACKET_HW_BP)
+ if (z_type == Z_PACKET_SW_BP || z_type == Z_PACKET_HW_BP)
{
bp = find_gdb_breakpoint (z_type, addr, -1);
if (bp != NULL)
- {
- if (bp->base.raw->kind != kind)
- {
- /* A different kind than previously seen. The previous
+ {
+ if (bp->base.raw->kind != kind)
+ {
+ /* A different kind than previously seen. The previous
breakpoint must be gone then. */
- bp->base.raw->inserted = -1;
- delete_breakpoint ((struct breakpoint *) bp);
- bp = NULL;
- }
- else if (z_type == Z_PACKET_SW_BP)
- {
- /* Check if the breakpoint is actually gone from the
+ bp->base.raw->inserted = -1;
+ delete_breakpoint ((struct breakpoint *) bp);
+ bp = NULL;
+ }
+ else if (z_type == Z_PACKET_SW_BP)
+ {
+ /* Check if the breakpoint is actually gone from the
target, due to an solib unload, for example. Might
as well validate _all_ breakpoints. */
- validate_breakpoints ();
+ validate_breakpoints ();
- /* Breakpoints that don't pass validation are
+ /* Breakpoints that don't pass validation are
deleted. */
- bp = find_gdb_breakpoint (z_type, addr, -1);
- }
- }
+ bp = find_gdb_breakpoint (z_type, addr, -1);
+ }
+ }
}
else
{
@@ -1075,8 +1063,8 @@ set_gdb_breakpoint (char z_type, CORE_ADDR addr, int kind, int *err)
raw_type = Z_packet_to_raw_bkpt_type (z_type);
type = Z_packet_to_bkpt_type (z_type);
- return (struct gdb_breakpoint *) set_breakpoint (type, raw_type, addr,
- kind, NULL, err);
+ return (struct gdb_breakpoint *) set_breakpoint (type, raw_type, addr, kind,
+ NULL, err);
}
/* Delete a GDB breakpoint of type Z_TYPE and kind KIND previously
@@ -1165,7 +1153,7 @@ clear_breakpoint_conditions_and_commands (struct gdb_breakpoint *bp)
static void
add_condition_to_breakpoint (struct gdb_breakpoint *bp,
- struct agent_expr *condition)
+ struct agent_expr *condition)
{
struct point_cond_list *new_cond;
@@ -1237,8 +1225,7 @@ gdb_condition_true_at_breakpoint_z_type (char z_type, CORE_ADDR addr)
If we failed to evaluate the expression, TRUE is returned. This
forces GDB to reevaluate the conditions. */
- for (cl = bp->cond_list;
- cl && !value && !err; cl = cl->next)
+ for (cl = bp->cond_list; cl && !value && !err; cl = cl->next)
{
/* Evaluate the condition. */
err = gdb_eval_agent_expr (&ctx, cl->cond, &value);
@@ -1255,14 +1242,14 @@ gdb_condition_true_at_breakpoint (CORE_ADDR where)
{
/* Only check code (software or hardware) breakpoints. */
return (gdb_condition_true_at_breakpoint_z_type (Z_PACKET_SW_BP, where)
- || gdb_condition_true_at_breakpoint_z_type (Z_PACKET_HW_BP, where));
+ || gdb_condition_true_at_breakpoint_z_type (Z_PACKET_HW_BP, where));
}
/* Add commands COMMANDS to GDBserver's breakpoint BP. */
static void
add_commands_to_breakpoint (struct gdb_breakpoint *bp,
- struct agent_expr *commands, int persist)
+ struct agent_expr *commands, int persist)
{
struct point_command_list *new_cmd;
@@ -1280,7 +1267,7 @@ add_commands_to_breakpoint (struct gdb_breakpoint *bp,
int
add_breakpoint_commands (struct gdb_breakpoint *bp, const char **command,
- int persist)
+ int persist)
{
const char *actparm = *command;
struct agent_expr *cmd;
@@ -1318,8 +1305,8 @@ gdb_no_commands_at_breakpoint_z_type (char z_type, CORE_ADDR addr)
return 1;
threads_debug_printf ("at 0x%s, type Z%c, bp command_list is 0x%s",
- paddress (addr), z_type,
- phex_nz ((uintptr_t) bp->command_list, 0));
+ paddress (addr), z_type,
+ phex_nz ((uintptr_t) bp->command_list, 0));
return (bp->command_list == NULL);
}
@@ -1331,7 +1318,7 @@ gdb_no_commands_at_breakpoint (CORE_ADDR where)
{
/* Only check code (software or hardware) breakpoints. */
return (gdb_no_commands_at_breakpoint_z_type (Z_PACKET_SW_BP, where)
- && gdb_no_commands_at_breakpoint_z_type (Z_PACKET_HW_BP, where));
+ && gdb_no_commands_at_breakpoint_z_type (Z_PACKET_HW_BP, where));
}
/* Run a breakpoint's commands. Returns 0 if there was a problem
@@ -1354,15 +1341,14 @@ run_breakpoint_commands_z_type (char z_type, CORE_ADDR addr)
ctx.tframe = NULL;
ctx.tpoint = NULL;
- for (cl = bp->command_list;
- cl && !value && !err; cl = cl->next)
+ for (cl = bp->command_list; cl && !value && !err; cl = cl->next)
{
/* Run the command. */
err = gdb_eval_agent_expr (&ctx, cl->cmd, &value);
/* If one command has a problem, stop digging the hole deeper. */
if (err)
- return 0;
+ return 0;
}
return 1;
@@ -1384,7 +1370,7 @@ gdb_breakpoint_here (CORE_ADDR where)
{
/* Only check code (software or hardware) breakpoints. */
return (find_gdb_breakpoint (Z_PACKET_SW_BP, where, -1) != NULL
- || find_gdb_breakpoint (Z_PACKET_HW_BP, where, -1) != NULL);
+ || find_gdb_breakpoint (Z_PACKET_HW_BP, where, -1) != NULL);
}
void
@@ -1394,8 +1380,8 @@ set_single_step_breakpoint (CORE_ADDR stop_at, ptid_t ptid)
gdb_assert (current_ptid.pid () == ptid.pid ());
- bp = (struct single_step_breakpoint *) set_breakpoint_type_at (single_step_breakpoint,
- stop_at, NULL);
+ bp = (struct single_step_breakpoint *)
+ set_breakpoint_type_at (single_step_breakpoint, stop_at, NULL);
bp->ptid = ptid;
}
@@ -1411,20 +1397,20 @@ delete_single_step_breakpoints (struct thread_info *thread)
while (bp)
{
if (bp->type == single_step_breakpoint
- && ((struct single_step_breakpoint *) bp)->ptid == ptid_of (thread))
- {
- scoped_restore_current_thread restore_thread;
-
- switch_to_thread (thread);
- *bp_link = bp->next;
- release_breakpoint (proc, bp);
- bp = *bp_link;
- }
+ && ((struct single_step_breakpoint *) bp)->ptid == ptid_of (thread))
+ {
+ scoped_restore_current_thread restore_thread;
+
+ switch_to_thread (thread);
+ *bp_link = bp->next;
+ release_breakpoint (proc, bp);
+ bp = *bp_link;
+ }
else
- {
- bp_link = &bp->next;
- bp = *bp_link;
- }
+ {
+ bp_link = &bp->next;
+ bp = *bp_link;
+ }
}
}
@@ -1434,7 +1420,7 @@ uninsert_raw_breakpoint (struct raw_breakpoint *bp)
if (bp->inserted < 0)
{
threads_debug_printf ("Breakpoint at %s is marked insert-disabled.",
- paddress (bp->pc));
+ paddress (bp->pc));
}
else if (bp->inserted > 0)
{
@@ -1444,12 +1430,12 @@ uninsert_raw_breakpoint (struct raw_breakpoint *bp)
err = the_target->remove_point (bp->raw_type, bp->pc, bp->kind, bp);
if (err != 0)
- {
- bp->inserted = 1;
+ {
+ bp->inserted = 1;
- threads_debug_printf ("Failed to uninsert raw breakpoint at 0x%s.",
- paddress (bp->pc));
- }
+ threads_debug_printf ("Failed to uninsert raw breakpoint at 0x%s.",
+ paddress (bp->pc));
+ }
}
}
@@ -1461,14 +1447,13 @@ uninsert_breakpoints_at (CORE_ADDR pc)
int found = 0;
for (bp = proc->raw_breakpoints; bp != NULL; bp = bp->next)
- if ((bp->raw_type == raw_bkpt_type_sw
- || bp->raw_type == raw_bkpt_type_hw)
- && bp->pc == pc)
+ if ((bp->raw_type == raw_bkpt_type_sw || bp->raw_type == raw_bkpt_type_hw)
+ && bp->pc == pc)
{
- found = 1;
+ found = 1;
- if (bp->inserted)
- uninsert_raw_breakpoint (bp);
+ if (bp->inserted)
+ uninsert_raw_breakpoint (bp);
}
if (!found)
@@ -1476,8 +1461,8 @@ uninsert_breakpoints_at (CORE_ADDR pc)
/* This can happen when we remove all breakpoints while handling
a step-over. */
threads_debug_printf ("Could not find breakpoint at 0x%s "
- "in list (uninserting).",
- paddress (pc));
+ "in list (uninserting).",
+ paddress (pc));
}
}
@@ -1488,9 +1473,8 @@ uninsert_all_breakpoints (void)
struct raw_breakpoint *bp;
for (bp = proc->raw_breakpoints; bp != NULL; bp = bp->next)
- if ((bp->raw_type == raw_bkpt_type_sw
- || bp->raw_type == raw_bkpt_type_hw)
- && bp->inserted)
+ if ((bp->raw_type == raw_bkpt_type_sw || bp->raw_type == raw_bkpt_type_hw)
+ && bp->inserted)
uninsert_raw_breakpoint (bp);
}
@@ -1502,21 +1486,21 @@ uninsert_single_step_breakpoints (struct thread_info *thread)
for (bp = proc->breakpoints; bp != NULL; bp = bp->next)
{
- if (bp->type == single_step_breakpoint
- && ((struct single_step_breakpoint *) bp)->ptid == ptid_of (thread))
- {
- gdb_assert (bp->raw->inserted > 0);
+ if (bp->type == single_step_breakpoint
+ && ((struct single_step_breakpoint *) bp)->ptid == ptid_of (thread))
+ {
+ gdb_assert (bp->raw->inserted > 0);
- /* Only uninsert the raw breakpoint if it only belongs to a
+ /* Only uninsert the raw breakpoint if it only belongs to a
reinsert breakpoint. */
- if (bp->raw->refcount == 1)
- {
- scoped_restore_current_thread restore_thread;
-
- switch_to_thread (thread);
- uninsert_raw_breakpoint (bp->raw);
- }
- }
+ if (bp->raw->refcount == 1)
+ {
+ scoped_restore_current_thread restore_thread;
+
+ switch_to_thread (thread);
+ uninsert_raw_breakpoint (bp->raw);
+ }
+ }
}
}
@@ -1533,7 +1517,7 @@ reinsert_raw_breakpoint (struct raw_breakpoint *bp)
bp->inserted = 1;
else
threads_debug_printf ("Failed to reinsert breakpoint at 0x%s (%d).",
- paddress (bp->pc), err);
+ paddress (bp->pc), err);
}
void
@@ -1544,13 +1528,12 @@ reinsert_breakpoints_at (CORE_ADDR pc)
int found = 0;
for (bp = proc->raw_breakpoints; bp != NULL; bp = bp->next)
- if ((bp->raw_type == raw_bkpt_type_sw
- || bp->raw_type == raw_bkpt_type_hw)
- && bp->pc == pc)
+ if ((bp->raw_type == raw_bkpt_type_sw || bp->raw_type == raw_bkpt_type_hw)
+ && bp->pc == pc)
{
- found = 1;
+ found = 1;
- reinsert_raw_breakpoint (bp);
+ reinsert_raw_breakpoint (bp);
}
if (!found)
@@ -1558,8 +1541,8 @@ reinsert_breakpoints_at (CORE_ADDR pc)
/* This can happen when we remove all breakpoints while handling
a step-over. */
threads_debug_printf ("Could not find raw breakpoint at 0x%s "
- "in list (reinserting).",
- paddress (pc));
+ "in list (reinserting).",
+ paddress (pc));
}
}
@@ -1575,13 +1558,13 @@ has_single_step_breakpoints (struct thread_info *thread)
while (bp)
{
if (bp->type == single_step_breakpoint
- && ((struct single_step_breakpoint *) bp)->ptid == ptid_of (thread))
- return 1;
+ && ((struct single_step_breakpoint *) bp)->ptid == ptid_of (thread))
+ return 1;
else
- {
- bp_link = &bp->next;
- bp = *bp_link;
- }
+ {
+ bp_link = &bp->next;
+ bp = *bp_link;
+ }
}
return 0;
@@ -1594,9 +1577,8 @@ reinsert_all_breakpoints (void)
struct raw_breakpoint *bp;
for (bp = proc->raw_breakpoints; bp != NULL; bp = bp->next)
- if ((bp->raw_type == raw_bkpt_type_sw
- || bp->raw_type == raw_bkpt_type_hw)
- && !bp->inserted)
+ if ((bp->raw_type == raw_bkpt_type_sw || bp->raw_type == raw_bkpt_type_hw)
+ && !bp->inserted)
reinsert_raw_breakpoint (bp);
}
@@ -1609,18 +1591,18 @@ reinsert_single_step_breakpoints (struct thread_info *thread)
for (bp = proc->breakpoints; bp != NULL; bp = bp->next)
{
if (bp->type == single_step_breakpoint
- && ((struct single_step_breakpoint *) bp)->ptid == ptid_of (thread))
- {
- gdb_assert (bp->raw->inserted > 0);
-
- if (bp->raw->refcount == 1)
- {
- scoped_restore_current_thread restore_thread;
-
- switch_to_thread (thread);
- reinsert_raw_breakpoint (bp->raw);
- }
- }
+ && ((struct single_step_breakpoint *) bp)->ptid == ptid_of (thread))
+ {
+ gdb_assert (bp->raw->inserted > 0);
+
+ if (bp->raw->refcount == 1)
+ {
+ scoped_restore_current_thread restore_thread;
+
+ switch_to_thread (thread);
+ reinsert_raw_breakpoint (bp->raw);
+ }
+ }
}
}
@@ -1638,31 +1620,31 @@ check_breakpoints (CORE_ADDR stop_pc)
struct raw_breakpoint *raw = bp->raw;
if ((raw->raw_type == raw_bkpt_type_sw
- || raw->raw_type == raw_bkpt_type_hw)
- && raw->pc == stop_pc)
- {
- if (!raw->inserted)
- {
- warning ("Hit a removed breakpoint?");
- return;
- }
-
- if (bp->type == other_breakpoint)
- {
- struct other_breakpoint *other_bp
- = (struct other_breakpoint *) bp;
-
- if (other_bp->handler != NULL && (*other_bp->handler) (stop_pc))
- {
- *bp_link = bp->next;
-
- release_breakpoint (proc, bp);
-
- bp = *bp_link;
- continue;
- }
- }
- }
+ || raw->raw_type == raw_bkpt_type_hw)
+ && raw->pc == stop_pc)
+ {
+ if (!raw->inserted)
+ {
+ warning ("Hit a removed breakpoint?");
+ return;
+ }
+
+ if (bp->type == other_breakpoint)
+ {
+ struct other_breakpoint *other_bp
+ = (struct other_breakpoint *) bp;
+
+ if (other_bp->handler != NULL && (*other_bp->handler) (stop_pc))
+ {
+ *bp_link = bp->next;
+
+ release_breakpoint (proc, bp);
+
+ bp = *bp_link;
+ continue;
+ }
+ }
+ }
bp_link = &bp->next;
bp = *bp_link;
@@ -1676,9 +1658,8 @@ breakpoint_here (CORE_ADDR addr)
struct raw_breakpoint *bp;
for (bp = proc->raw_breakpoints; bp != NULL; bp = bp->next)
- if ((bp->raw_type == raw_bkpt_type_sw
- || bp->raw_type == raw_bkpt_type_hw)
- && bp->pc == addr)
+ if ((bp->raw_type == raw_bkpt_type_sw || bp->raw_type == raw_bkpt_type_hw)
+ && bp->pc == addr)
return 1;
return 0;
@@ -1691,10 +1672,8 @@ breakpoint_inserted_here (CORE_ADDR addr)
struct raw_breakpoint *bp;
for (bp = proc->raw_breakpoints; bp != NULL; bp = bp->next)
- if ((bp->raw_type == raw_bkpt_type_sw
- || bp->raw_type == raw_bkpt_type_hw)
- && bp->pc == addr
- && bp->inserted)
+ if ((bp->raw_type == raw_bkpt_type_sw || bp->raw_type == raw_bkpt_type_hw)
+ && bp->pc == addr && bp->inserted)
return 1;
return 0;
@@ -1709,9 +1688,7 @@ software_breakpoint_inserted_here (CORE_ADDR addr)
struct raw_breakpoint *bp;
for (bp = proc->raw_breakpoints; bp != NULL; bp = bp->next)
- if (bp->raw_type == raw_bkpt_type_sw
- && bp->pc == addr
- && bp->inserted)
+ if (bp->raw_type == raw_bkpt_type_sw && bp->pc == addr && bp->inserted)
return 1;
return 0;
@@ -1726,9 +1703,7 @@ hardware_breakpoint_inserted_here (CORE_ADDR addr)
struct raw_breakpoint *bp;
for (bp = proc->raw_breakpoints; bp != NULL; bp = bp->next)
- if (bp->raw_type == raw_bkpt_type_hw
- && bp->pc == addr
- && bp->inserted)
+ if (bp->raw_type == raw_bkpt_type_hw && bp->pc == addr && bp->inserted)
return 1;
return 0;
@@ -1743,9 +1718,8 @@ single_step_breakpoint_inserted_here (CORE_ADDR addr)
struct breakpoint *bp;
for (bp = proc->breakpoints; bp != NULL; bp = bp->next)
- if (bp->type == single_step_breakpoint
- && bp->raw->pc == addr
- && bp->raw->inserted)
+ if (bp->type == single_step_breakpoint && bp->raw->pc == addr
+ && bp->raw->inserted)
return 1;
return 0;
@@ -1782,12 +1756,12 @@ delete_disabled_breakpoints (void)
{
next = bp->next;
if (bp->raw->inserted < 0)
- {
- /* If single_step_breakpoints become disabled, that means the
+ {
+ /* If single_step_breakpoints become disabled, that means the
manipulations (insertion and removal) of them are wrong. */
- gdb_assert (bp->type != single_step_breakpoint);
- delete_breakpoint_1 (proc, bp);
- }
+ gdb_assert (bp->type != single_step_breakpoint);
+ delete_breakpoint_1 (proc, bp);
+ }
}
}
@@ -1809,7 +1783,7 @@ validate_breakpoints (void)
struct raw_breakpoint *raw = bp->raw;
if (raw->raw_type == raw_bkpt_type_sw && raw->inserted > 0)
- validate_inserted_breakpoint (raw);
+ validate_inserted_breakpoint (raw);
}
delete_disabled_breakpoints ();
@@ -1831,29 +1805,28 @@ check_mem_read (CORE_ADDR mem_addr, unsigned char *buf, int mem_len)
int copy_offset, copy_len, buf_offset;
gdb_assert (fast_tracepoint_jump_shadow (jp) >= buf + mem_len
- || buf >= fast_tracepoint_jump_shadow (jp) + (jp)->length);
+ || buf >= fast_tracepoint_jump_shadow (jp) + (jp)->length);
if (mem_addr >= bp_end)
- continue;
+ continue;
if (jp->pc >= mem_end)
- continue;
+ continue;
start = jp->pc;
if (mem_addr > start)
- start = mem_addr;
+ start = mem_addr;
end = bp_end;
if (end > mem_end)
- end = mem_end;
+ end = mem_end;
copy_len = end - start;
copy_offset = start - jp->pc;
buf_offset = start - mem_addr;
if (jp->inserted)
- memcpy (buf + buf_offset,
- fast_tracepoint_jump_shadow (jp) + copy_offset,
- copy_len);
+ memcpy (buf + buf_offset,
+ fast_tracepoint_jump_shadow (jp) + copy_offset, copy_len);
}
for (; bp != NULL; bp = bp->next)
@@ -1863,35 +1836,35 @@ check_mem_read (CORE_ADDR mem_addr, unsigned char *buf, int mem_len)
int copy_offset, copy_len, buf_offset;
if (bp->raw_type != raw_bkpt_type_sw)
- continue;
+ continue;
gdb_assert (bp->old_data >= buf + mem_len
- || buf >= &bp->old_data[sizeof (bp->old_data)]);
+ || buf >= &bp->old_data[sizeof (bp->old_data)]);
if (mem_addr >= bp_end)
- continue;
+ continue;
if (bp->pc >= mem_end)
- continue;
+ continue;
start = bp->pc;
if (mem_addr > start)
- start = mem_addr;
+ start = mem_addr;
end = bp_end;
if (end > mem_end)
- end = mem_end;
+ end = mem_end;
copy_len = end - start;
copy_offset = start - bp->pc;
buf_offset = start - mem_addr;
if (bp->inserted > 0)
- {
- if (validate_inserted_breakpoint (bp))
- memcpy (buf + buf_offset, bp->old_data + copy_offset, copy_len);
- else
- disabled_one = 1;
- }
+ {
+ if (validate_inserted_breakpoint (bp))
+ memcpy (buf + buf_offset, bp->old_data + copy_offset, copy_len);
+ else
+ disabled_one = 1;
+ }
}
if (disabled_one)
@@ -1900,7 +1873,7 @@ check_mem_read (CORE_ADDR mem_addr, unsigned char *buf, int mem_len)
void
check_mem_write (CORE_ADDR mem_addr, unsigned char *buf,
- const unsigned char *myaddr, int mem_len)
+ const unsigned char *myaddr, int mem_len)
{
struct process_info *proc = current_process ();
struct raw_breakpoint *bp = proc->raw_breakpoints;
@@ -1917,32 +1890,33 @@ check_mem_write (CORE_ADDR mem_addr, unsigned char *buf,
int copy_offset, copy_len, buf_offset;
gdb_assert (fast_tracepoint_jump_shadow (jp) >= myaddr + mem_len
- || myaddr >= fast_tracepoint_jump_shadow (jp) + (jp)->length);
+ || myaddr
+ >= fast_tracepoint_jump_shadow (jp) + (jp)->length);
gdb_assert (fast_tracepoint_jump_insn (jp) >= buf + mem_len
- || buf >= fast_tracepoint_jump_insn (jp) + (jp)->length);
+ || buf >= fast_tracepoint_jump_insn (jp) + (jp)->length);
if (mem_addr >= jp_end)
- continue;
+ continue;
if (jp->pc >= mem_end)
- continue;
+ continue;
start = jp->pc;
if (mem_addr > start)
- start = mem_addr;
+ start = mem_addr;
end = jp_end;
if (end > mem_end)
- end = mem_end;
+ end = mem_end;
copy_len = end - start;
copy_offset = start - jp->pc;
buf_offset = start - mem_addr;
memcpy (fast_tracepoint_jump_shadow (jp) + copy_offset,
- myaddr + buf_offset, copy_len);
+ myaddr + buf_offset, copy_len);
if (jp->inserted)
- memcpy (buf + buf_offset,
- fast_tracepoint_jump_insn (jp) + copy_offset, copy_len);
+ memcpy (buf + buf_offset, fast_tracepoint_jump_insn (jp) + copy_offset,
+ copy_len);
}
for (; bp != NULL; bp = bp->next)
@@ -1952,23 +1926,23 @@ check_mem_write (CORE_ADDR mem_addr, unsigned char *buf,
int copy_offset, copy_len, buf_offset;
if (bp->raw_type != raw_bkpt_type_sw)
- continue;
+ continue;
gdb_assert (bp->old_data >= myaddr + mem_len
- || myaddr >= &bp->old_data[sizeof (bp->old_data)]);
+ || myaddr >= &bp->old_data[sizeof (bp->old_data)]);
if (mem_addr >= bp_end)
- continue;
+ continue;
if (bp->pc >= mem_end)
- continue;
+ continue;
start = bp->pc;
if (mem_addr > start)
- start = mem_addr;
+ start = mem_addr;
end = bp_end;
if (end > mem_end)
- end = mem_end;
+ end = mem_end;
copy_len = end - start;
copy_offset = start - bp->pc;
@@ -1976,12 +1950,12 @@ check_mem_write (CORE_ADDR mem_addr, unsigned char *buf,
memcpy (bp->old_data + copy_offset, myaddr + buf_offset, copy_len);
if (bp->inserted > 0)
- {
- if (validate_inserted_breakpoint (bp))
- memcpy (buf + buf_offset, bp_opcode (bp) + copy_offset, copy_len);
- else
- disabled_one = 1;
- }
+ {
+ if (validate_inserted_breakpoint (bp))
+ memcpy (buf + buf_offset, bp_opcode (bp) + copy_offset, copy_len);
+ else
+ disabled_one = 1;
+ }
}
if (disabled_one)
@@ -2070,24 +2044,22 @@ clone_one_breakpoint (const struct breakpoint *src, ptid_t ptid)
/* Clone the condition list. */
for (current_cond = ((struct gdb_breakpoint *) src)->cond_list;
- current_cond != NULL;
- current_cond = current_cond->next)
- {
- new_cond = XCNEW (struct point_cond_list);
- new_cond->cond = clone_agent_expr (current_cond->cond);
- APPEND_TO_LIST (&gdb_dest->cond_list, new_cond, cond_tail);
- }
+ current_cond != NULL; current_cond = current_cond->next)
+ {
+ new_cond = XCNEW (struct point_cond_list);
+ new_cond->cond = clone_agent_expr (current_cond->cond);
+ APPEND_TO_LIST (&gdb_dest->cond_list, new_cond, cond_tail);
+ }
/* Clone the command list. */
for (current_cmd = ((struct gdb_breakpoint *) src)->command_list;
- current_cmd != NULL;
- current_cmd = current_cmd->next)
- {
- new_cmd = XCNEW (struct point_command_list);
- new_cmd->cmd = clone_agent_expr (current_cmd->cmd);
- new_cmd->persistence = current_cmd->persistence;
- APPEND_TO_LIST (&gdb_dest->command_list, new_cmd, cmd_tail);
- }
+ current_cmd != NULL; current_cmd = current_cmd->next)
+ {
+ new_cmd = XCNEW (struct point_command_list);
+ new_cmd->cmd = clone_agent_expr (current_cmd->cmd);
+ new_cmd->persistence = current_cmd->persistence;
+ APPEND_TO_LIST (&gdb_dest->command_list, new_cmd, cmd_tail);
+ }
dest = (struct breakpoint *) gdb_dest;
}
@@ -2101,7 +2073,7 @@ clone_one_breakpoint (const struct breakpoint *src, ptid_t ptid)
else if (src->type == single_step_breakpoint)
{
struct single_step_breakpoint *ss_dest
- = XCNEW (struct single_step_breakpoint);
+ = XCNEW (struct single_step_breakpoint);
dest = (struct breakpoint *) ss_dest;
/* Since single-step breakpoint is thread specific, don't copy
@@ -2121,7 +2093,7 @@ clone_one_breakpoint (const struct breakpoint *src, ptid_t ptid)
void
clone_all_breakpoints (struct thread_info *child_thread,
- const struct thread_info *parent_thread)
+ const struct thread_info *parent_thread)
{
const struct breakpoint *bp;
struct breakpoint *new_bkpt;
diff --git a/gdbserver/mem-break.h b/gdbserver/mem-break.h
index 9bf7aa8..bfba2cf 100644
--- a/gdbserver/mem-break.h
+++ b/gdbserver/mem-break.h
@@ -39,22 +39,22 @@ struct process_info;
/* The low level breakpoint types. */
enum raw_bkpt_type
- {
- /* Software/memory breakpoint. */
- raw_bkpt_type_sw,
+{
+ /* Software/memory breakpoint. */
+ raw_bkpt_type_sw,
- /* Hardware-assisted breakpoint. */
- raw_bkpt_type_hw,
+ /* Hardware-assisted breakpoint. */
+ raw_bkpt_type_hw,
- /* Hardware-assisted write watchpoint. */
- raw_bkpt_type_write_wp,
+ /* Hardware-assisted write watchpoint. */
+ raw_bkpt_type_write_wp,
- /* Hardware-assisted read watchpoint. */
- raw_bkpt_type_read_wp,
+ /* Hardware-assisted read watchpoint. */
+ raw_bkpt_type_read_wp,
- /* Hardware-assisted access watchpoint. */
- raw_bkpt_type_access_wp
- };
+ /* Hardware-assisted access watchpoint. */
+ raw_bkpt_type_access_wp
+};
/* Map the protocol breakpoint/watchpoint type Z_TYPE to the internal
raw breakpoint type. */
@@ -63,8 +63,8 @@ enum raw_bkpt_type Z_packet_to_raw_bkpt_type (char z_type);
/* Map a raw breakpoint type to an enum target_hw_bp_type. */
-enum target_hw_bp_type raw_bkpt_type_to_target_hw_bp_type
- (enum raw_bkpt_type raw_type);
+enum target_hw_bp_type
+raw_bkpt_type_to_target_hw_bp_type (enum raw_bkpt_type raw_type);
/* Create a new GDB breakpoint of type Z_TYPE at ADDR with kind KIND.
Returns a pointer to the newly created breakpoint on success. On
@@ -72,7 +72,7 @@ enum target_hw_bp_type raw_bkpt_type_to_target_hw_bp_type
Z_TYPE breakpoints are not supported on this target. */
struct gdb_breakpoint *set_gdb_breakpoint (char z_type, CORE_ADDR addr,
- int kind, int *err);
+ int kind, int *err);
/* Delete a GDB breakpoint of type Z_TYPE and kind KIND previously
inserted at ADDR with set_gdb_breakpoint_at. Returns 0 on success,
@@ -115,7 +115,7 @@ void clear_breakpoint_conditions_and_commands (struct gdb_breakpoint *bp);
past the condition and returns true. */
int add_breakpoint_condition (struct gdb_breakpoint *bp,
- const char **condition);
+ const char **condition);
/* Set target-side commands COMMANDS to the breakpoint at ADDR.
Returns false on failure. On success, advances COMMANDS past the
@@ -123,7 +123,7 @@ int add_breakpoint_condition (struct gdb_breakpoint *bp,
even while GDB is disconnected. */
int add_breakpoint_commands (struct gdb_breakpoint *bp, const char **commands,
- int persist);
+ int persist);
/* Return true if PROC has any persistent command. */
bool any_persistent_commands (process_info *proc);
@@ -148,7 +148,7 @@ int gdb_breakpoint_here (CORE_ADDR where);
breakpoint is other_breakpoint. */
struct breakpoint *set_breakpoint_at (CORE_ADDR where,
- int (*handler) (CORE_ADDR));
+ int (*handler) (CORE_ADDR));
/* Delete a breakpoint. */
@@ -213,8 +213,8 @@ void check_mem_read (CORE_ADDR mem_addr, unsigned char *buf, int mem_len);
(in BUF, a copy of MYADDR on entry) if necessary, as well as the
original data for any breakpoints. */
-void check_mem_write (CORE_ADDR mem_addr,
- unsigned char *buf, const unsigned char *myaddr, int mem_len);
+void check_mem_write (CORE_ADDR mem_addr, unsigned char *buf,
+ const unsigned char *myaddr, int mem_len);
/* Delete all breakpoints. */
@@ -237,8 +237,8 @@ void validate_breakpoints (void);
LENGTH bytes. */
struct fast_tracepoint_jump *set_fast_tracepoint_jump (CORE_ADDR where,
- unsigned char *insn,
- ULONGEST length);
+ unsigned char *insn,
+ ULONGEST length);
/* Increment reference counter of JP. */
void inc_ref_fast_tracepoint_jump (struct fast_tracepoint_jump *jp);
@@ -274,6 +274,6 @@ int remove_memory_breakpoint (struct raw_breakpoint *bp);
copy of breakpoint list in PARENT_THREAD's process. */
void clone_all_breakpoints (struct thread_info *child_thread,
- const struct thread_info *parent_thread);
+ const struct thread_info *parent_thread);
#endif /* GDBSERVER_MEM_BREAK_H */
diff --git a/gdbserver/netbsd-aarch64-low.cc b/gdbserver/netbsd-aarch64-low.cc
index da572b2..dccd164 100644
--- a/gdbserver/netbsd-aarch64-low.cc
+++ b/gdbserver/netbsd-aarch64-low.cc
@@ -32,9 +32,12 @@ netbsd_aarch64_fill_gregset (struct regcache *regcache, char *buf)
{
struct reg *r = (struct reg *) buf;
-#define netbsd_aarch64_collect_gp(regnum, fld) do { \
- collect_register (regcache, regnum, &r->fld); \
- } while (0)
+#define netbsd_aarch64_collect_gp(regnum, fld) \
+ do \
+ { \
+ collect_register (regcache, regnum, &r->fld); \
+ } \
+ while (0)
for (size_t i = 0; i < ARRAY_SIZE (r->r_reg); i++)
netbsd_aarch64_collect_gp (AARCH64_X0_REGNUM + i, r_reg[i]);
@@ -50,9 +53,12 @@ netbsd_aarch64_store_gregset (struct regcache *regcache, const char *buf)
{
struct reg *r = (struct reg *) buf;
-#define netbsd_aarch64_supply_gp(regnum, fld) do { \
- supply_register (regcache, regnum, &r->fld); \
- } while(0)
+#define netbsd_aarch64_supply_gp(regnum, fld) \
+ do \
+ { \
+ supply_register (regcache, regnum, &r->fld); \
+ } \
+ while (0)
for (size_t i = 0; i < ARRAY_SIZE (r->r_reg); i++)
netbsd_aarch64_supply_gp (AARCH64_X0_REGNUM + i, r_reg[i]);
@@ -63,13 +69,12 @@ netbsd_aarch64_store_gregset (struct regcache *regcache, const char *buf)
/* Description of all the aarch64-netbsd register sets. */
-static const struct netbsd_regset_info netbsd_target_regsets[] =
-{
+static const struct netbsd_regset_info netbsd_target_regsets[] = {
/* General Purpose Registers. */
- {PT_GETREGS, PT_SETREGS, sizeof (struct reg),
- netbsd_aarch64_fill_gregset, netbsd_aarch64_store_gregset},
+ { PT_GETREGS, PT_SETREGS, sizeof (struct reg), netbsd_aarch64_fill_gregset,
+ netbsd_aarch64_store_gregset },
/* End of list marker. */
- {0, 0, -1, NULL, NULL }
+ { 0, 0, -1, NULL, NULL }
};
/* NetBSD target op definitions for the aarch64 architecture. */
@@ -95,8 +100,7 @@ netbsd_aarch64_target::get_regs_info ()
void
netbsd_aarch64_target::low_arch_setup ()
{
- target_desc *tdesc
- = aarch64_create_target_description ({});
+ target_desc *tdesc = aarch64_create_target_description ({});
static const char *expedite_regs_aarch64[] = { "x29", "sp", "pc", NULL };
init_target_desc (tdesc, expedite_regs_aarch64);
diff --git a/gdbserver/netbsd-amd64-low.cc b/gdbserver/netbsd-amd64-low.cc
index 490a090..63d57ea 100644
--- a/gdbserver/netbsd-amd64-low.cc
+++ b/gdbserver/netbsd-amd64-low.cc
@@ -30,39 +30,39 @@
enum netbsd_x86_64_gdb_regnum
{
- AMD64_RAX_REGNUM, /* %rax */
- AMD64_RBX_REGNUM, /* %rbx */
- AMD64_RCX_REGNUM, /* %rcx */
- AMD64_RDX_REGNUM, /* %rdx */
- AMD64_RSI_REGNUM, /* %rsi */
- AMD64_RDI_REGNUM, /* %rdi */
- AMD64_RBP_REGNUM, /* %rbp */
- AMD64_RSP_REGNUM, /* %rsp */
- AMD64_R8_REGNUM, /* %r8 */
- AMD64_R9_REGNUM, /* %r9 */
- AMD64_R10_REGNUM, /* %r10 */
- AMD64_R11_REGNUM, /* %r11 */
- AMD64_R12_REGNUM, /* %r12 */
- AMD64_R13_REGNUM, /* %r13 */
- AMD64_R14_REGNUM, /* %r14 */
- AMD64_R15_REGNUM, /* %r15 */
- AMD64_RIP_REGNUM, /* %rip */
- AMD64_EFLAGS_REGNUM, /* %eflags */
- AMD64_CS_REGNUM, /* %cs */
- AMD64_SS_REGNUM, /* %ss */
- AMD64_DS_REGNUM, /* %ds */
- AMD64_ES_REGNUM, /* %es */
- AMD64_FS_REGNUM, /* %fs */
- AMD64_GS_REGNUM, /* %gs */
- AMD64_ST0_REGNUM = 24, /* %st0 */
- AMD64_ST1_REGNUM, /* %st1 */
+ AMD64_RAX_REGNUM, /* %rax */
+ AMD64_RBX_REGNUM, /* %rbx */
+ AMD64_RCX_REGNUM, /* %rcx */
+ AMD64_RDX_REGNUM, /* %rdx */
+ AMD64_RSI_REGNUM, /* %rsi */
+ AMD64_RDI_REGNUM, /* %rdi */
+ AMD64_RBP_REGNUM, /* %rbp */
+ AMD64_RSP_REGNUM, /* %rsp */
+ AMD64_R8_REGNUM, /* %r8 */
+ AMD64_R9_REGNUM, /* %r9 */
+ AMD64_R10_REGNUM, /* %r10 */
+ AMD64_R11_REGNUM, /* %r11 */
+ AMD64_R12_REGNUM, /* %r12 */
+ AMD64_R13_REGNUM, /* %r13 */
+ AMD64_R14_REGNUM, /* %r14 */
+ AMD64_R15_REGNUM, /* %r15 */
+ AMD64_RIP_REGNUM, /* %rip */
+ AMD64_EFLAGS_REGNUM, /* %eflags */
+ AMD64_CS_REGNUM, /* %cs */
+ AMD64_SS_REGNUM, /* %ss */
+ AMD64_DS_REGNUM, /* %ds */
+ AMD64_ES_REGNUM, /* %es */
+ AMD64_FS_REGNUM, /* %fs */
+ AMD64_GS_REGNUM, /* %gs */
+ AMD64_ST0_REGNUM = 24, /* %st0 */
+ AMD64_ST1_REGNUM, /* %st1 */
AMD64_FCTRL_REGNUM = AMD64_ST0_REGNUM + 8,
AMD64_FSTAT_REGNUM = AMD64_ST0_REGNUM + 9,
AMD64_FTAG_REGNUM = AMD64_ST0_REGNUM + 10,
- AMD64_XMM0_REGNUM = 40, /* %xmm0 */
- AMD64_XMM1_REGNUM, /* %xmm1 */
+ AMD64_XMM0_REGNUM = 40, /* %xmm0 */
+ AMD64_XMM1_REGNUM, /* %xmm1 */
AMD64_MXCSR_REGNUM = AMD64_XMM0_REGNUM + 16,
- AMD64_YMM0H_REGNUM, /* %ymm0h */
+ AMD64_YMM0H_REGNUM, /* %ymm0h */
AMD64_YMM15H_REGNUM = AMD64_YMM0H_REGNUM + 15,
AMD64_BND0R_REGNUM = AMD64_YMM15H_REGNUM + 1,
AMD64_BND3R_REGNUM = AMD64_BND0R_REGNUM + 3,
@@ -88,9 +88,12 @@ netbsd_x86_64_fill_gregset (struct regcache *regcache, char *buf)
{
struct reg *r = (struct reg *) buf;
-#define netbsd_x86_64_collect_gp(regnum, fld) do { \
- collect_register (regcache, regnum, &r->regs[_REG_##fld]); \
- } while (0)
+#define netbsd_x86_64_collect_gp(regnum, fld) \
+ do \
+ { \
+ collect_register (regcache, regnum, &r->regs[_REG_##fld]); \
+ } \
+ while (0)
netbsd_x86_64_collect_gp (AMD64_RAX_REGNUM, RAX);
netbsd_x86_64_collect_gp (AMD64_RBX_REGNUM, RBX);
@@ -125,9 +128,12 @@ netbsd_x86_64_store_gregset (struct regcache *regcache, const char *buf)
{
struct reg *r = (struct reg *) buf;
-#define netbsd_x86_64_supply_gp(regnum, fld) do { \
- supply_register (regcache, regnum, &r->regs[_REG_##fld]); \
- } while(0)
+#define netbsd_x86_64_supply_gp(regnum, fld) \
+ do \
+ { \
+ supply_register (regcache, regnum, &r->regs[_REG_##fld]); \
+ } \
+ while (0)
netbsd_x86_64_supply_gp (AMD64_RAX_REGNUM, RAX);
netbsd_x86_64_supply_gp (AMD64_RBX_REGNUM, RBX);
@@ -157,13 +163,12 @@ netbsd_x86_64_store_gregset (struct regcache *regcache, const char *buf)
/* Description of all the x86-netbsd register sets. */
-static const struct netbsd_regset_info netbsd_target_regsets[] =
-{
+static const struct netbsd_regset_info netbsd_target_regsets[] = {
/* General Purpose Registers. */
- {PT_GETREGS, PT_SETREGS, sizeof (struct reg),
- netbsd_x86_64_fill_gregset, netbsd_x86_64_store_gregset},
+ { PT_GETREGS, PT_SETREGS, sizeof (struct reg), netbsd_x86_64_fill_gregset,
+ netbsd_x86_64_store_gregset },
/* End of list marker. */
- {0, 0, -1, NULL, NULL }
+ { 0, 0, -1, NULL, NULL }
};
/* NetBSD target op definitions for the amd64 architecture. */
@@ -189,8 +194,8 @@ netbsd_amd64_target::get_regs_info ()
void
netbsd_amd64_target::low_arch_setup ()
{
- target_desc *tdesc
- = amd64_create_target_description (X86_XSTATE_SSE_MASK, false, false, false);
+ target_desc *tdesc = amd64_create_target_description (X86_XSTATE_SSE_MASK,
+ false, false, false);
init_target_desc (tdesc, amd64_expedite_regs);
diff --git a/gdbserver/netbsd-i386-low.cc b/gdbserver/netbsd-i386-low.cc
index a482a34..9bf040a 100644
--- a/gdbserver/netbsd-i386-low.cc
+++ b/gdbserver/netbsd-i386-low.cc
@@ -30,23 +30,23 @@
enum netbsd_i386_gdb_regnum
{
- I386_EAX_REGNUM, /* %eax */
- I386_ECX_REGNUM, /* %ecx */
- I386_EDX_REGNUM, /* %edx */
- I386_EBX_REGNUM, /* %ebx */
- I386_ESP_REGNUM, /* %esp */
- I386_EBP_REGNUM, /* %ebp */
- I386_ESI_REGNUM, /* %esi */
- I386_EDI_REGNUM, /* %edi */
- I386_EIP_REGNUM, /* %eip */
- I386_EFLAGS_REGNUM, /* %eflags */
- I386_CS_REGNUM, /* %cs */
- I386_SS_REGNUM, /* %ss */
- I386_DS_REGNUM, /* %ds */
- I386_ES_REGNUM, /* %es */
- I386_FS_REGNUM, /* %fs */
- I386_GS_REGNUM, /* %gs */
- I386_ST0_REGNUM /* %st(0) */
+ I386_EAX_REGNUM, /* %eax */
+ I386_ECX_REGNUM, /* %ecx */
+ I386_EDX_REGNUM, /* %edx */
+ I386_EBX_REGNUM, /* %ebx */
+ I386_ESP_REGNUM, /* %esp */
+ I386_EBP_REGNUM, /* %ebp */
+ I386_ESI_REGNUM, /* %esi */
+ I386_EDI_REGNUM, /* %edi */
+ I386_EIP_REGNUM, /* %eip */
+ I386_EFLAGS_REGNUM, /* %eflags */
+ I386_CS_REGNUM, /* %cs */
+ I386_SS_REGNUM, /* %ss */
+ I386_DS_REGNUM, /* %ds */
+ I386_ES_REGNUM, /* %es */
+ I386_FS_REGNUM, /* %fs */
+ I386_GS_REGNUM, /* %gs */
+ I386_ST0_REGNUM /* %st(0) */
};
/* The fill_function for the general-purpose register set. */
@@ -56,9 +56,12 @@ netbsd_i386_fill_gregset (struct regcache *regcache, char *buf)
{
struct reg *r = (struct reg *) buf;
-#define netbsd_i386_collect_gp(regnum, fld) do { \
- collect_register (regcache, regnum, &r->r_##fld); \
- } while (0)
+#define netbsd_i386_collect_gp(regnum, fld) \
+ do \
+ { \
+ collect_register (regcache, regnum, &r->r_##fld); \
+ } \
+ while (0)
netbsd_i386_collect_gp (I386_EAX_REGNUM, eax);
netbsd_i386_collect_gp (I386_EBX_REGNUM, ebx);
@@ -85,9 +88,12 @@ netbsd_i386_store_gregset (struct regcache *regcache, const char *buf)
{
struct reg *r = (struct reg *) buf;
-#define netbsd_i386_supply_gp(regnum, fld) do { \
- supply_register (regcache, regnum, &r->r_##fld); \
- } while(0)
+#define netbsd_i386_supply_gp(regnum, fld) \
+ do \
+ { \
+ supply_register (regcache, regnum, &r->r_##fld); \
+ } \
+ while (0)
netbsd_i386_supply_gp (I386_EAX_REGNUM, eax);
netbsd_i386_supply_gp (I386_EBX_REGNUM, ebx);
@@ -109,13 +115,12 @@ netbsd_i386_store_gregset (struct regcache *regcache, const char *buf)
/* Description of all the x86-netbsd register sets. */
-static const struct netbsd_regset_info netbsd_target_regsets[] =
-{
+static const struct netbsd_regset_info netbsd_target_regsets[] = {
/* General Purpose Registers. */
- {PT_GETREGS, PT_SETREGS, sizeof (struct reg),
- netbsd_i386_fill_gregset, netbsd_i386_store_gregset},
+ { PT_GETREGS, PT_SETREGS, sizeof (struct reg), netbsd_i386_fill_gregset,
+ netbsd_i386_store_gregset },
/* End of list marker. */
- {0, 0, -1, NULL, NULL }
+ { 0, 0, -1, NULL, NULL }
};
/* NetBSD target op definitions for the amd64 architecture. */
diff --git a/gdbserver/netbsd-low.cc b/gdbserver/netbsd-low.cc
index 4defd79..4e10e4d 100644
--- a/gdbserver/netbsd-low.cc
+++ b/gdbserver/netbsd-low.cc
@@ -62,30 +62,31 @@ netbsd_ptrace_fun ()
if (remote_connection_is_stdio ())
{
if (close (0) < 0)
- trace_start_error_with_name (("close"));
+ trace_start_error_with_name (("close"));
if (open ("/dev/null", O_RDONLY) < 0)
- trace_start_error_with_name (("open"));
+ trace_start_error_with_name (("open"));
if (dup2 (2, 1) < 0)
- trace_start_error_with_name (("dup2"));
+ trace_start_error_with_name (("dup2"));
if (write (2, "stdin/stdout redirected\n",
- sizeof ("stdin/stdout redirected\n") - 1) < 0)
- {
- /* Errors ignored. */
- }
+ sizeof ("stdin/stdout redirected\n") - 1)
+ < 0)
+ {
+ /* Errors ignored. */
+ }
}
}
/* Implement the create_inferior method of the target_ops vector. */
int
-netbsd_process_target::create_inferior (const char *program,
- const std::vector<char *> &program_args)
+netbsd_process_target::create_inferior (
+ const char *program, const std::vector<char *> &program_args)
{
std::string str_program_args = construct_inferior_arguments (program_args);
pid_t pid = fork_inferior (program, str_program_args.c_str (),
- get_environ ()->envp (), netbsd_ptrace_fun,
- nullptr, nullptr, nullptr, nullptr);
+ get_environ ()->envp (), netbsd_ptrace_fun,
+ nullptr, nullptr, nullptr, nullptr);
add_process (pid, 0);
@@ -139,41 +140,39 @@ netbsd_process_target::resume (struct thread_resume *resume_info, size_t n)
const lwpid_t lwp = resume_ptid.lwp ();
regcache_invalidate_pid (pid);
- auto fn
- = [&] (ptid_t ptid)
+ auto fn = [&] (ptid_t ptid) {
+ if (step)
{
- if (step)
- {
- if (ptid.lwp () == lwp || n != 1)
- {
- if (ptrace (PT_SETSTEP, pid, NULL, ptid.lwp ()) == -1)
- perror_with_name (("ptrace"));
- if (ptrace (PT_RESUME, pid, NULL, ptid.lwp ()) == -1)
- perror_with_name (("ptrace"));
- }
- else
- {
- if (ptrace (PT_CLEARSTEP, pid, NULL, ptid.lwp ()) == -1)
- perror_with_name (("ptrace"));
- if (ptrace (PT_SUSPEND, pid, NULL, ptid.lwp ()) == -1)
- perror_with_name (("ptrace"));
- }
- }
- else
- {
- if (ptrace (PT_CLEARSTEP, pid, NULL, ptid.lwp ()) == -1)
- perror_with_name (("ptrace"));
- if (ptrace (PT_RESUME, pid, NULL, ptid.lwp ()) == -1)
- perror_with_name (("ptrace"));
- }
- };
+ if (ptid.lwp () == lwp || n != 1)
+ {
+ if (ptrace (PT_SETSTEP, pid, NULL, ptid.lwp ()) == -1)
+ perror_with_name (("ptrace"));
+ if (ptrace (PT_RESUME, pid, NULL, ptid.lwp ()) == -1)
+ perror_with_name (("ptrace"));
+ }
+ else
+ {
+ if (ptrace (PT_CLEARSTEP, pid, NULL, ptid.lwp ()) == -1)
+ perror_with_name (("ptrace"));
+ if (ptrace (PT_SUSPEND, pid, NULL, ptid.lwp ()) == -1)
+ perror_with_name (("ptrace"));
+ }
+ }
+ else
+ {
+ if (ptrace (PT_CLEARSTEP, pid, NULL, ptid.lwp ()) == -1)
+ perror_with_name (("ptrace"));
+ if (ptrace (PT_RESUME, pid, NULL, ptid.lwp ()) == -1)
+ perror_with_name (("ptrace"));
+ }
+ };
netbsd_nat::for_each_thread (pid, fn);
int request = gdb_catching_syscalls_p (pid) ? PT_CONTINUE : PT_SYSCALL;
errno = 0;
- ptrace (request, pid, (void *)1, signal);
+ ptrace (request, pid, (void *) 1, signal);
if (errno)
perror_with_name (("ptrace"));
}
@@ -217,22 +216,20 @@ netbsd_store_waitstatus (struct target_waitstatus *ourstatus, int hoststatus)
static pid_t
netbsd_waitpid (ptid_t ptid, struct target_waitstatus *ourstatus,
- target_wait_flags target_options)
+ target_wait_flags target_options)
{
int status;
int options = (target_options & TARGET_WNOHANG) ? WNOHANG : 0;
- pid_t pid
- = gdb::handle_eintr (-1, ::waitpid, ptid.pid (), &status, options);
+ pid_t pid = gdb::handle_eintr (-1, ::waitpid, ptid.pid (), &status, options);
if (pid == -1)
- perror_with_name (_("Child process unexpectedly missing"));
+ perror_with_name (_ ("Child process unexpectedly missing"));
netbsd_store_waitstatus (ourstatus, status);
return pid;
}
-
/* Implement the wait target_ops method.
Wait for the child specified by PTID to do something. Return the
@@ -241,7 +238,7 @@ netbsd_waitpid (ptid_t ptid, struct target_waitstatus *ourstatus,
static ptid_t
netbsd_wait (ptid_t ptid, struct target_waitstatus *ourstatus,
- target_wait_flags target_options)
+ target_wait_flags target_options)
{
pid_t pid = netbsd_waitpid (ptid, ourstatus, target_options);
ptid_t wptid = ptid_t (pid);
@@ -298,14 +295,14 @@ netbsd_wait (ptid_t ptid, struct target_waitstatus *ourstatus,
Ignore exited events for an unknown LWP. */
thread_info *thr = find_thread_ptid (wptid);
if (thr == nullptr)
- ourstatus->set_spurious ();
+ ourstatus->set_spurious ();
else
- {
- /* NetBSD does not store an LWP exit status. */
- ourstatus->set_thread_exited (0);
+ {
+ /* NetBSD does not store an LWP exit status. */
+ ourstatus->set_thread_exited (0);
- remove_thread (thr);
- }
+ remove_thread (thr);
+ }
return wptid;
}
@@ -319,40 +316,40 @@ netbsd_wait (ptid_t ptid, struct target_waitstatus *ourstatus,
not yet reported their PTRACE_LWP_CREATE event. Ignore
born events for an already-known LWP. */
if (find_thread_ptid (wptid))
- ourstatus->set_spurious ();
+ ourstatus->set_spurious ();
else
- {
- add_thread (wptid, NULL);
- ourstatus->set_thread_created ();
- }
+ {
+ add_thread (wptid, NULL);
+ ourstatus->set_thread_created ();
+ }
return wptid;
}
if (code == TRAP_EXEC)
{
- ourstatus->set_execd
- (make_unique_xstrdup (netbsd_nat::pid_to_exec_file (pid)));
+ ourstatus->set_execd (
+ make_unique_xstrdup (netbsd_nat::pid_to_exec_file (pid)));
return wptid;
}
if (code == TRAP_TRACE)
- return wptid;
+ return wptid;
if (code == TRAP_SCE || code == TRAP_SCX)
{
int sysnum = si->si_sysnum;
- if (!netbsd_catch_this_syscall(sysnum))
- {
- /* If the core isn't interested in this event, ignore it. */
- ourstatus->set_spurious ();
- return wptid;
- }
+ if (!netbsd_catch_this_syscall (sysnum))
+ {
+ /* If the core isn't interested in this event, ignore it. */
+ ourstatus->set_spurious ();
+ return wptid;
+ }
if (code == TRAP_SCE)
- ourstatus->set_syscall_entry (sysnum);
+ ourstatus->set_syscall_entry (sysnum);
else
- ourstatus->set_syscall_return (sysnum);
+ ourstatus->set_syscall_return (sysnum);
return wptid;
}
@@ -379,7 +376,7 @@ netbsd_wait (ptid_t ptid, struct target_waitstatus *ourstatus,
ptid_t
netbsd_process_target::wait (ptid_t ptid, struct target_waitstatus *ourstatus,
- target_wait_flags target_options)
+ target_wait_flags target_options)
{
while (true)
{
@@ -391,35 +388,35 @@ netbsd_process_target::wait (ptid_t ptid, struct target_waitstatus *ourstatus,
This may also happen on attach, when an event is registered on a thread
that was not fully initialized during the attach stage. */
if (wptid.lwp () != 0 && !find_thread_ptid (wptid)
- && ourstatus->kind () != TARGET_WAITKIND_THREAD_EXITED)
- add_thread (wptid, nullptr);
+ && ourstatus->kind () != TARGET_WAITKIND_THREAD_EXITED)
+ add_thread (wptid, nullptr);
switch (ourstatus->kind ())
- {
- case TARGET_WAITKIND_EXITED:
- case TARGET_WAITKIND_STOPPED:
- case TARGET_WAITKIND_SIGNALLED:
- case TARGET_WAITKIND_FORKED:
- case TARGET_WAITKIND_VFORKED:
- case TARGET_WAITKIND_EXECD:
- case TARGET_WAITKIND_VFORK_DONE:
- case TARGET_WAITKIND_SYSCALL_ENTRY:
- case TARGET_WAITKIND_SYSCALL_RETURN:
- /* Pass the result to the generic code. */
- return wptid;
- case TARGET_WAITKIND_THREAD_CREATED:
- case TARGET_WAITKIND_THREAD_EXITED:
- /* The core needlessly stops on these events. */
- /* FALLTHROUGH */
- case TARGET_WAITKIND_SPURIOUS:
- /* Spurious events are unhandled by the gdbserver core. */
- if (ptrace (PT_CONTINUE, current_process ()->pid, (void *) 1, 0)
- == -1)
- perror_with_name (("ptrace"));
- break;
- default:
- error (("Unknown stopped status"));
- }
+ {
+ case TARGET_WAITKIND_EXITED:
+ case TARGET_WAITKIND_STOPPED:
+ case TARGET_WAITKIND_SIGNALLED:
+ case TARGET_WAITKIND_FORKED:
+ case TARGET_WAITKIND_VFORKED:
+ case TARGET_WAITKIND_EXECD:
+ case TARGET_WAITKIND_VFORK_DONE:
+ case TARGET_WAITKIND_SYSCALL_ENTRY:
+ case TARGET_WAITKIND_SYSCALL_RETURN:
+ /* Pass the result to the generic code. */
+ return wptid;
+ case TARGET_WAITKIND_THREAD_CREATED:
+ case TARGET_WAITKIND_THREAD_EXITED:
+ /* The core needlessly stops on these events. */
+ /* FALLTHROUGH */
+ case TARGET_WAITKIND_SPURIOUS:
+ /* Spurious events are unhandled by the gdbserver core. */
+ if (ptrace (PT_CONTINUE, current_process ()->pid, (void *) 1, 0)
+ == -1)
+ perror_with_name (("ptrace"));
+ break;
+ default:
+ error (("Unknown stopped status"));
+ }
}
}
@@ -491,9 +488,9 @@ netbsd_process_target::fetch_registers (struct regcache *regcache, int regno)
std::vector<char> buf;
buf.resize (regset->size);
int res = ptrace (regset->get_request, inferior_ptid.pid (), buf.data (),
- inferior_ptid.lwp ());
+ inferior_ptid.lwp ());
if (res == -1)
- perror_with_name (("ptrace"));
+ perror_with_name (("ptrace"));
regset->store_function (regcache, buf.data ());
regset++;
}
@@ -512,17 +509,17 @@ netbsd_process_target::store_registers (struct regcache *regcache, int regno)
std::vector<char> buf;
buf.resize (regset->size);
int res = ptrace (regset->get_request, inferior_ptid.pid (), buf.data (),
- inferior_ptid.lwp ());
+ inferior_ptid.lwp ());
if (res == -1)
- perror_with_name (("ptrace"));
+ perror_with_name (("ptrace"));
/* Then overlay our cached registers on that. */
regset->fill_function (regcache, buf.data ());
/* Only now do we write the register set. */
- res = ptrace (regset->set_request, inferior_ptid.pid (), buf. data (),
- inferior_ptid.lwp ());
+ res = ptrace (regset->set_request, inferior_ptid.pid (), buf.data (),
+ inferior_ptid.lwp ());
if (res == -1)
- perror_with_name (("ptrace"));
+ perror_with_name (("ptrace"));
regset++;
}
}
@@ -531,7 +528,7 @@ netbsd_process_target::store_registers (struct regcache *regcache, int regno)
int
netbsd_process_target::read_memory (CORE_ADDR memaddr, unsigned char *myaddr,
- int size)
+ int size)
{
pid_t pid = current_process ()->pid;
return netbsd_nat::read_memory (pid, myaddr, memaddr, size, nullptr);
@@ -541,7 +538,7 @@ netbsd_process_target::read_memory (CORE_ADDR memaddr, unsigned char *myaddr,
int
netbsd_process_target::write_memory (CORE_ADDR memaddr,
- const unsigned char *myaddr, int size)
+ const unsigned char *myaddr, int size)
{
pid_t pid = current_process ()->pid;
return netbsd_nat::write_memory (pid, myaddr, memaddr, size, nullptr);
@@ -562,7 +559,7 @@ netbsd_process_target::request_interrupt ()
and output arguments. */
static size_t
-netbsd_read_auxv(pid_t pid, void *offs, void *addr, size_t len)
+netbsd_read_auxv (pid_t pid, void *offs, void *addr, size_t len)
{
struct ptrace_io_desc pio;
@@ -582,7 +579,7 @@ netbsd_read_auxv(pid_t pid, void *offs, void *addr, size_t len)
int
netbsd_process_target::read_auxv (int pid, CORE_ADDR offset,
- unsigned char *myaddr, unsigned int len)
+ unsigned char *myaddr, unsigned int len)
{
return netbsd_read_auxv (pid, (void *) (intptr_t) offset, myaddr, len);
}
@@ -607,7 +604,7 @@ netbsd_process_target::supports_z_point_type (char z_type)
int
netbsd_process_target::insert_point (enum raw_bkpt_type type, CORE_ADDR addr,
- int size, struct raw_breakpoint *bp)
+ int size, struct raw_breakpoint *bp)
{
switch (type)
{
@@ -626,7 +623,7 @@ netbsd_process_target::insert_point (enum raw_bkpt_type type, CORE_ADDR addr,
int
netbsd_process_target::remove_point (enum raw_bkpt_type type, CORE_ADDR addr,
- int size, struct raw_breakpoint *bp)
+ int size, struct raw_breakpoint *bp)
{
switch (type)
{
@@ -652,8 +649,8 @@ netbsd_process_target::stopped_by_sw_breakpoint ()
if (ptrace (PT_GET_SIGINFO, pid, &psi, sizeof (psi)) == -1)
perror_with_name (("ptrace"));
- return psi.psi_siginfo.si_signo == SIGTRAP &&
- psi.psi_siginfo.si_code == TRAP_BRKPT;
+ return psi.psi_siginfo.si_signo == SIGTRAP
+ && psi.psi_siginfo.si_code == TRAP_BRKPT;
}
/* Implement the supports_stopped_by_sw_breakpoint target_ops method. */
@@ -675,16 +672,18 @@ netbsd_process_target::supports_qxfer_siginfo ()
/* Implement the qxfer_siginfo target_ops method. */
int
-netbsd_process_target::qxfer_siginfo (const char *annex, unsigned char *readbuf,
- unsigned const char *writebuf,
- CORE_ADDR offset, int len)
+netbsd_process_target::qxfer_siginfo (const char *annex,
+ unsigned char *readbuf,
+ unsigned const char *writebuf,
+ CORE_ADDR offset, int len)
{
if (current_thread == nullptr)
return -1;
pid_t pid = current_process ()->pid;
- return netbsd_nat::qxfer_siginfo(pid, annex, readbuf, writebuf, offset, len);
+ return netbsd_nat::qxfer_siginfo (pid, annex, readbuf, writebuf, offset,
+ len);
}
/* Implement the supports_non_stop target_ops method. */
@@ -737,12 +736,13 @@ netbsd_process_target::supports_disable_randomization ()
/* Extract &phdr and num_phdr in the inferior. Return 0 on success. */
-template <typename T>
-int get_phdr_phnum_from_proc_auxv (const pid_t pid,
- CORE_ADDR *phdr_memaddr, int *num_phdr)
+template<typename T>
+int
+get_phdr_phnum_from_proc_auxv (const pid_t pid, CORE_ADDR *phdr_memaddr,
+ int *num_phdr)
{
- typedef typename std::conditional<sizeof(T) == sizeof(int64_t),
- Aux64Info, Aux32Info>::type auxv_type;
+ typedef typename std::conditional<sizeof (T) == sizeof (int64_t), Aux64Info,
+ Aux32Info>::type auxv_type;
const size_t auxv_size = sizeof (auxv_type);
const size_t auxv_buf_size = 128 * sizeof (auxv_type);
@@ -754,31 +754,30 @@ int get_phdr_phnum_from_proc_auxv (const pid_t pid,
*phdr_memaddr = 0;
*num_phdr = 0;
- for (char *buf = auxv_buf.data ();
- buf < (auxv_buf.data () + auxv_buf_size);
+ for (char *buf = auxv_buf.data (); buf < (auxv_buf.data () + auxv_buf_size);
buf += auxv_size)
{
auxv_type *const aux = (auxv_type *) buf;
switch (aux->a_type)
- {
- case AT_PHDR:
- *phdr_memaddr = aux->a_v;
- break;
- case AT_PHNUM:
- *num_phdr = aux->a_v;
- break;
- }
+ {
+ case AT_PHDR:
+ *phdr_memaddr = aux->a_v;
+ break;
+ case AT_PHNUM:
+ *num_phdr = aux->a_v;
+ break;
+ }
if (*phdr_memaddr != 0 && *num_phdr != 0)
- break;
+ break;
}
if (*phdr_memaddr == 0 || *num_phdr == 0)
{
warning ("Unexpected missing AT_PHDR and/or AT_PHNUM: "
- "phdr_memaddr = %s, phdr_num = %d",
- core_addr_to_string (*phdr_memaddr), *num_phdr);
+ "phdr_memaddr = %s, phdr_num = %d",
+ core_addr_to_string (*phdr_memaddr), *num_phdr);
return 2;
}
@@ -787,12 +786,12 @@ int get_phdr_phnum_from_proc_auxv (const pid_t pid,
/* Return &_DYNAMIC (via PT_DYNAMIC) in the inferior, or 0 if not present. */
-template <typename T>
+template<typename T>
static CORE_ADDR
get_dynamic (const pid_t pid)
{
- typedef typename std::conditional<sizeof(T) == sizeof(int64_t),
- Elf64_Phdr, Elf32_Phdr>::type phdr_type;
+ typedef typename std::conditional<sizeof (T) == sizeof (int64_t), Elf64_Phdr,
+ Elf32_Phdr>::type phdr_type;
const int phdr_size = sizeof (phdr_type);
CORE_ADDR phdr_memaddr;
@@ -804,7 +803,7 @@ get_dynamic (const pid_t pid)
phdr_buf.resize (num_phdr * phdr_size);
if (netbsd_nat::read_memory (pid, phdr_buf.data (), phdr_memaddr,
- phdr_buf.size (), nullptr))
+ phdr_buf.size (), nullptr))
return 0;
/* Compute relocation: it is expected to be 0 for "regular" executables,
@@ -815,7 +814,7 @@ get_dynamic (const pid_t pid)
phdr_type *const p = (phdr_type *) (phdr_buf.data () + i * phdr_size);
if (p->p_type == PT_PHDR)
- relocation = phdr_memaddr - p->p_vaddr;
+ relocation = phdr_memaddr - p->p_vaddr;
}
if (relocation == -1)
@@ -838,7 +837,7 @@ get_dynamic (const pid_t pid)
phdr_type *const p = (phdr_type *) (phdr_buf.data () + i * phdr_size);
if (p->p_type == PT_DYNAMIC)
- return p->p_vaddr + relocation;
+ return p->p_vaddr + relocation;
}
return 0;
@@ -849,14 +848,14 @@ get_dynamic (const pid_t pid)
We look for DT_MIPS_RLD_MAP first. MIPS executables use this instead of
DT_DEBUG, although they sometimes contain an unused DT_DEBUG entry too. */
-template <typename T>
+template<typename T>
static CORE_ADDR
get_r_debug (const pid_t pid)
{
- typedef typename std::conditional<sizeof(T) == sizeof(int64_t),
- Elf64_Dyn, Elf32_Dyn>::type dyn_type;
+ typedef typename std::conditional<sizeof (T) == sizeof (int64_t), Elf64_Dyn,
+ Elf32_Dyn>::type dyn_type;
const int dyn_size = sizeof (dyn_type);
- unsigned char buf[sizeof (dyn_type)]; /* The larger of the two. */
+ unsigned char buf[sizeof (dyn_type)]; /* The larger of the two. */
CORE_ADDR map = -1;
CORE_ADDR dynamic_memaddr = get_dynamic<T> (pid);
@@ -864,32 +863,32 @@ get_r_debug (const pid_t pid)
return map;
while (netbsd_nat::read_memory (pid, buf, dynamic_memaddr, dyn_size, nullptr)
- == 0)
+ == 0)
{
dyn_type *const dyn = (dyn_type *) buf;
#if defined DT_MIPS_RLD_MAP
union
{
- T map;
- unsigned char buf[sizeof (T)];
- }
- rld_map;
+ T map;
+ unsigned char buf[sizeof (T)];
+ } rld_map;
if (dyn->d_tag == DT_MIPS_RLD_MAP)
- {
- if (netbsd_nat::read_memory (pid, rld_map.buf, dyn->d_un.d_val,
- sizeof (rld_map.buf), nullptr) == 0)
- return rld_map.map;
- else
- break;
- }
-#endif /* DT_MIPS_RLD_MAP */
+ {
+ if (netbsd_nat::read_memory (pid, rld_map.buf, dyn->d_un.d_val,
+ sizeof (rld_map.buf), nullptr)
+ == 0)
+ return rld_map.map;
+ else
+ break;
+ }
+#endif /* DT_MIPS_RLD_MAP */
if (dyn->d_tag == DT_DEBUG && map == -1)
- map = dyn->d_un.d_val;
+ map = dyn->d_un.d_val;
if (dyn->d_tag == DT_NULL)
- break;
+ break;
dynamic_memaddr += dyn_size;
}
@@ -914,27 +913,28 @@ read_one_ptr (const pid_t pid, CORE_ADDR memaddr, CORE_ADDR *ptr, int ptr_size)
unsigned char uc;
} addr;
- int ret = netbsd_nat::read_memory (pid, &addr.uc, memaddr, ptr_size, nullptr);
+ int ret
+ = netbsd_nat::read_memory (pid, &addr.uc, memaddr, ptr_size, nullptr);
if (ret == 0)
{
if (ptr_size == sizeof (CORE_ADDR))
- *ptr = addr.core_addr;
+ *ptr = addr.core_addr;
else if (ptr_size == sizeof (unsigned int))
- *ptr = addr.ui;
+ *ptr = addr.ui;
else
- gdb_assert_not_reached ("unhandled pointer size");
+ gdb_assert_not_reached ("unhandled pointer size");
}
return ret;
}
/* Construct qXfer:libraries-svr4:read reply. */
-template <typename T>
+template<typename T>
int
netbsd_qxfer_libraries_svr4 (const pid_t pid, const char *annex,
- unsigned char *readbuf,
- unsigned const char *writebuf,
- CORE_ADDR offset, int len)
+ unsigned char *readbuf,
+ unsigned const char *writebuf, CORE_ADDR offset,
+ int len)
{
struct link_map_offsets
{
@@ -960,57 +960,55 @@ netbsd_qxfer_libraries_svr4 (const pid_t pid, const char *annex,
int l_prev_offset;
};
- static const struct link_map_offsets lmo_32bit_offsets =
- {
- 0, /* r_version offset. */
- 4, /* r_debug.r_map offset. */
- 0, /* l_addr offset in link_map. */
- 4, /* l_name offset in link_map. */
- 8, /* l_ld offset in link_map. */
- 12, /* l_next offset in link_map. */
- 16 /* l_prev offset in link_map. */
- };
-
- static const struct link_map_offsets lmo_64bit_offsets =
- {
- 0, /* r_version offset. */
- 8, /* r_debug.r_map offset. */
- 0, /* l_addr offset in link_map. */
- 8, /* l_name offset in link_map. */
- 16, /* l_ld offset in link_map. */
- 24, /* l_next offset in link_map. */
- 32 /* l_prev offset in link_map. */
- };
+ static const struct link_map_offsets lmo_32bit_offsets = {
+ 0, /* r_version offset. */
+ 4, /* r_debug.r_map offset. */
+ 0, /* l_addr offset in link_map. */
+ 4, /* l_name offset in link_map. */
+ 8, /* l_ld offset in link_map. */
+ 12, /* l_next offset in link_map. */
+ 16 /* l_prev offset in link_map. */
+ };
+
+ static const struct link_map_offsets lmo_64bit_offsets = {
+ 0, /* r_version offset. */
+ 8, /* r_debug.r_map offset. */
+ 0, /* l_addr offset in link_map. */
+ 8, /* l_name offset in link_map. */
+ 16, /* l_ld offset in link_map. */
+ 24, /* l_next offset in link_map. */
+ 32 /* l_prev offset in link_map. */
+ };
CORE_ADDR lm_addr = 0, lm_prev = 0;
CORE_ADDR l_name, l_addr, l_ld, l_next, l_prev;
int header_done = 0;
const struct link_map_offsets *lmo
- = ((sizeof (T) == sizeof (int64_t))
- ? &lmo_64bit_offsets : &lmo_32bit_offsets);
+ = ((sizeof (T) == sizeof (int64_t)) ? &lmo_64bit_offsets
+ : &lmo_32bit_offsets);
int ptr_size = sizeof (T);
while (annex[0] != '\0')
{
const char *sep = strchr (annex, '=');
if (sep == nullptr)
- break;
+ break;
int name_len = sep - annex;
CORE_ADDR *addrp;
if (name_len == 5 && startswith (annex, "start"))
- addrp = &lm_addr;
+ addrp = &lm_addr;
else if (name_len == 4 && startswith (annex, "prev"))
- addrp = &lm_prev;
+ addrp = &lm_prev;
else
- {
- annex = strchr (sep, ';');
- if (annex == nullptr)
- break;
- annex++;
- continue;
- }
+ {
+ annex = strchr (sep, ';');
+ if (annex == nullptr)
+ break;
+ annex++;
+ continue;
+ }
annex = decode_address_to_semicolon (addrp, sep + 1);
}
@@ -1023,37 +1021,34 @@ netbsd_qxfer_libraries_svr4 (const pid_t pid, const char *annex,
for this inferior - do not retry it. Report it to GDB as
E01, see for the reasons at the GDB solib-svr4.c side. */
if (r_debug == (CORE_ADDR) -1)
- return -1;
+ return -1;
if (r_debug != 0)
- {
- CORE_ADDR map_offset = r_debug + lmo->r_map_offset;
- if (read_one_ptr (pid, map_offset, &lm_addr, ptr_size) != 0)
- warning ("unable to read r_map from %s",
- core_addr_to_string (map_offset));
- }
+ {
+ CORE_ADDR map_offset = r_debug + lmo->r_map_offset;
+ if (read_one_ptr (pid, map_offset, &lm_addr, ptr_size) != 0)
+ warning ("unable to read r_map from %s",
+ core_addr_to_string (map_offset));
+ }
}
std::string document = "<library-list-svr4 version=\"1.0\"";
- while (lm_addr
- && read_one_ptr (pid, lm_addr + lmo->l_name_offset,
- &l_name, ptr_size) == 0
- && read_one_ptr (pid, lm_addr + lmo->l_addr_offset,
- &l_addr, ptr_size) == 0
- && read_one_ptr (pid, lm_addr + lmo->l_ld_offset,
- &l_ld, ptr_size) == 0
- && read_one_ptr (pid, lm_addr + lmo->l_prev_offset,
- &l_prev, ptr_size) == 0
- && read_one_ptr (pid, lm_addr + lmo->l_next_offset,
- &l_next, ptr_size) == 0)
+ while (
+ lm_addr
+ && read_one_ptr (pid, lm_addr + lmo->l_name_offset, &l_name, ptr_size) == 0
+ && read_one_ptr (pid, lm_addr + lmo->l_addr_offset, &l_addr, ptr_size) == 0
+ && read_one_ptr (pid, lm_addr + lmo->l_ld_offset, &l_ld, ptr_size) == 0
+ && read_one_ptr (pid, lm_addr + lmo->l_prev_offset, &l_prev, ptr_size) == 0
+ && read_one_ptr (pid, lm_addr + lmo->l_next_offset, &l_next, ptr_size)
+ == 0)
{
if (lm_prev != l_prev)
- {
- warning ("Corrupted shared library list: 0x%lx != 0x%lx",
- (long) lm_prev, (long) l_prev);
- break;
- }
+ {
+ warning ("Corrupted shared library list: 0x%lx != 0x%lx",
+ (long) lm_prev, (long) l_prev);
+ break;
+ }
/* Ignore the first entry even if it has valid name as the first entry
corresponds to the main executable. The first entry should not be
@@ -1062,35 +1057,36 @@ netbsd_qxfer_libraries_svr4 (const pid_t pid, const char *annex,
executable does not have PT_DYNAMIC present and this function already
exited above due to failed get_r_debug. */
if (lm_prev == 0)
- string_appendf (document, " main-lm=\"0x%lx\"",
- (unsigned long) lm_addr);
+ string_appendf (document, " main-lm=\"0x%lx\"",
+ (unsigned long) lm_addr);
else
- {
- unsigned char libname[PATH_MAX];
+ {
+ unsigned char libname[PATH_MAX];
- /* Not checking for error because reading may stop before
+ /* Not checking for error because reading may stop before
we've got PATH_MAX worth of characters. */
- libname[0] = '\0';
- netbsd_nat::read_memory (pid, libname, l_name, sizeof (libname) - 1,
- nullptr);
- libname[sizeof (libname) - 1] = '\0';
- if (libname[0] != '\0')
- {
- if (!header_done)
- {
- /* Terminate `<library-list-svr4'. */
- document += '>';
- header_done = 1;
- }
-
- string_appendf (document, "<library name=\"");
- xml_escape_text_append (document, (char *) libname);
- string_appendf (document, "\" lm=\"0x%lx\" "
- "l_addr=\"0x%lx\" l_ld=\"0x%lx\"/>",
- (unsigned long) lm_addr, (unsigned long) l_addr,
- (unsigned long) l_ld);
- }
- }
+ libname[0] = '\0';
+ netbsd_nat::read_memory (pid, libname, l_name, sizeof (libname) - 1,
+ nullptr);
+ libname[sizeof (libname) - 1] = '\0';
+ if (libname[0] != '\0')
+ {
+ if (!header_done)
+ {
+ /* Terminate `<library-list-svr4'. */
+ document += '>';
+ header_done = 1;
+ }
+
+ string_appendf (document, "<library name=\"");
+ xml_escape_text_append (document, (char *) libname);
+ string_appendf (document,
+ "\" lm=\"0x%lx\" "
+ "l_addr=\"0x%lx\" l_ld=\"0x%lx\"/>",
+ (unsigned long) lm_addr, (unsigned long) l_addr,
+ (unsigned long) l_ld);
+ }
+ }
lm_prev = lm_addr;
lm_addr = l_next;
@@ -1136,8 +1132,7 @@ elf_64_file_p (const char *file)
if (ret != sizeof (header))
error ("Cannot read ELF file header: %s", file);
- if (header.e_ident[EI_MAG0] != ELFMAG0
- || header.e_ident[EI_MAG1] != ELFMAG1
+ if (header.e_ident[EI_MAG0] != ELFMAG0 || header.e_ident[EI_MAG1] != ELFMAG1
|| header.e_ident[EI_MAG2] != ELFMAG2
|| header.e_ident[EI_MAG3] != ELFMAG3)
error ("Unrecognized ELF file header: %s", file);
@@ -1149,9 +1144,9 @@ elf_64_file_p (const char *file)
int
netbsd_process_target::qxfer_libraries_svr4 (const char *annex,
- unsigned char *readbuf,
- unsigned const char *writebuf,
- CORE_ADDR offset, int len)
+ unsigned char *readbuf,
+ unsigned const char *writebuf,
+ CORE_ADDR offset, int len)
{
if (writebuf != nullptr)
return -2;
@@ -1163,11 +1158,11 @@ netbsd_process_target::qxfer_libraries_svr4 (const char *annex,
bool is_elf64 = elf_64_file_p (netbsd_nat::pid_to_exec_file (pid));
if (is_elf64)
- return netbsd_qxfer_libraries_svr4<int64_t> (pid, annex, readbuf,
- writebuf, offset, len);
+ return netbsd_qxfer_libraries_svr4<int64_t> (pid, annex, readbuf, writebuf,
+ offset, len);
else
- return netbsd_qxfer_libraries_svr4<int32_t> (pid, annex, readbuf,
- writebuf, offset, len);
+ return netbsd_qxfer_libraries_svr4<int32_t> (pid, annex, readbuf, writebuf,
+ offset, len);
}
/* Implement the supports_qxfer_libraries_svr4 target_ops method. */
@@ -1207,7 +1202,7 @@ netbsd_process_target::supports_hardware_single_step ()
const gdb_byte *
netbsd_process_target::sw_breakpoint_from_kind (int kind, int *size)
{
- static gdb_byte brkpt[PTRACE_BREAKPOINT_SIZE] = {*PTRACE_BREAKPOINT};
+ static gdb_byte brkpt[PTRACE_BREAKPOINT_SIZE] = { *PTRACE_BREAKPOINT };
*size = PTRACE_BREAKPOINT_SIZE;
diff --git a/gdbserver/netbsd-low.h b/gdbserver/netbsd-low.h
index 050b43f..9303841 100644
--- a/gdbserver/netbsd-low.h
+++ b/gdbserver/netbsd-low.h
@@ -40,9 +40,8 @@ struct netbsd_regset_info
class netbsd_process_target : public process_stratum_target
{
public:
-
int create_inferior (const char *program,
- const std::vector<char *> &program_args) override;
+ const std::vector<char *> &program_args) override;
void post_create_inferior () override;
@@ -61,24 +60,23 @@ public:
void resume (thread_resume *resume_info, size_t n) override;
ptid_t wait (ptid_t ptid, target_waitstatus *status,
- target_wait_flags options) override;
+ target_wait_flags options) override;
void fetch_registers (regcache *regcache, int regno) override;
void store_registers (regcache *regcache, int regno) override;
- int read_memory (CORE_ADDR memaddr, unsigned char *myaddr,
- int len) override;
+ int read_memory (CORE_ADDR memaddr, unsigned char *myaddr, int len) override;
int write_memory (CORE_ADDR memaddr, const unsigned char *myaddr,
- int len) override;
+ int len) override;
void request_interrupt () override;
bool supports_read_auxv () override;
int read_auxv (int pid, CORE_ADDR offset, unsigned char *myaddr,
- unsigned int len) override;
+ unsigned int len) override;
bool supports_hardware_single_step () override;
@@ -86,19 +84,19 @@ public:
bool supports_z_point_type (char z_type) override;
- int insert_point (enum raw_bkpt_type type, CORE_ADDR addr,
- int size, struct raw_breakpoint *bp) override;
+ int insert_point (enum raw_bkpt_type type, CORE_ADDR addr, int size,
+ struct raw_breakpoint *bp) override;
- int remove_point (enum raw_bkpt_type type, CORE_ADDR addr,
- int size, struct raw_breakpoint *bp) override;
+ int remove_point (enum raw_bkpt_type type, CORE_ADDR addr, int size,
+ struct raw_breakpoint *bp) override;
bool stopped_by_sw_breakpoint () override;
bool supports_qxfer_siginfo () override;
int qxfer_siginfo (const char *annex, unsigned char *readbuf,
- unsigned const char *writebuf, CORE_ADDR offset,
- int len) override;
+ unsigned const char *writebuf, CORE_ADDR offset,
+ int len) override;
bool supports_stopped_by_sw_breakpoint () override;
@@ -116,8 +114,8 @@ public:
bool supports_qxfer_libraries_svr4 () override;
- int qxfer_libraries_svr4 (const char*, unsigned char*, const unsigned char*,
- CORE_ADDR, int) override;
+ int qxfer_libraries_svr4 (const char *, unsigned char *,
+ const unsigned char *, CORE_ADDR, int) override;
bool supports_pid_to_exec_file () override;
diff --git a/gdbserver/notif.cc b/gdbserver/notif.cc
index 9b323b4..5618f57 100644
--- a/gdbserver/notif.cc
+++ b/gdbserver/notif.cc
@@ -50,8 +50,7 @@
#include "server.h"
#include "notif.h"
-static struct notif_server *notifs[] =
-{
+static struct notif_server *notifs[] = {
&notif_stop,
};
@@ -85,9 +84,8 @@ handle_notif_ack (char *own_buf, int packet_len)
{
const char *ack_name = notifs[i]->ack_name;
- if (startswith (own_buf, ack_name)
- && packet_len == strlen (ack_name))
- break;
+ if (startswith (own_buf, ack_name) && packet_len == strlen (ack_name))
+ break;
}
if (i == ARRAY_SIZE (notifs))
@@ -103,7 +101,7 @@ handle_notif_ack (char *own_buf, int packet_len)
np->queue.pop_front ();
remote_debug_printf ("%s: acking %d", np->ack_name,
- (int) np->queue.size ());
+ (int) np->queue.size ());
delete head;
}
@@ -116,14 +114,12 @@ handle_notif_ack (char *own_buf, int packet_len)
/* Put EVENT to the queue of NOTIF. */
void
-notif_event_enque (struct notif_server *notif,
- struct notif_event *event)
+notif_event_enque (struct notif_server *notif, struct notif_event *event)
{
notif->queue.push_back (event);
remote_debug_printf ("pending events: %s %d", notif->notif_name,
- (int) notif->queue.size ());
-
+ (int) notif->queue.size ());
}
/* Push one event NEW_EVENT of notification NP into NP->queue. */
diff --git a/gdbserver/notif.h b/gdbserver/notif.h
index bb93619..044a125 100644
--- a/gdbserver/notif.h
+++ b/gdbserver/notif.h
@@ -28,9 +28,7 @@
struct notif_event
{
- virtual ~notif_event ()
- {
- }
+ virtual ~notif_event () {}
/* No payload needed. */
};
@@ -62,7 +60,6 @@ int handle_notif_ack (char *own_buf, int packet_len);
void notif_write_event (struct notif_server *notif, char *own_buf);
void notif_push (struct notif_server *np, struct notif_event *event);
-void notif_event_enque (struct notif_server *notif,
- struct notif_event *event);
+void notif_event_enque (struct notif_server *notif, struct notif_event *event);
#endif /* GDBSERVER_NOTIF_H */
diff --git a/gdbserver/proc-service.cc b/gdbserver/proc-service.cc
index 2d516a0..4750e52 100644
--- a/gdbserver/proc-service.cc
+++ b/gdbserver/proc-service.cc
@@ -48,7 +48,7 @@ gregset_info (void)
while (regsets_info->regsets[i].size != -1)
{
if (regsets_info->regsets[i].type == GENERAL_REGS)
- break;
+ break;
i++;
}
@@ -61,8 +61,8 @@ gregset_info (void)
symbol is stored in SYM_ADDR. */
ps_err_e
-ps_pglobal_lookup (gdb_ps_prochandle_t ph, const char *obj,
- const char *name, psaddr_t *sym_addr)
+ps_pglobal_lookup (gdb_ps_prochandle_t ph, const char *obj, const char *name,
+ psaddr_t *sym_addr)
{
CORE_ADDR addr;
@@ -77,8 +77,8 @@ ps_pglobal_lookup (gdb_ps_prochandle_t ph, const char *obj,
them into BUF. */
ps_err_e
-ps_pdread (gdb_ps_prochandle_t ph, psaddr_t addr,
- gdb_ps_read_buf_t buf, gdb_ps_size_t size)
+ps_pdread (gdb_ps_prochandle_t ph, psaddr_t addr, gdb_ps_read_buf_t buf,
+ gdb_ps_size_t size)
{
if (read_inferior_memory ((uintptr_t) addr, (gdb_byte *) buf, size) != 0)
return PS_ERR;
@@ -88,8 +88,8 @@ ps_pdread (gdb_ps_prochandle_t ph, psaddr_t addr,
/* Write SIZE bytes from BUF into the target process PH at address ADDR. */
ps_err_e
-ps_pdwrite (gdb_ps_prochandle_t ph, psaddr_t addr,
- gdb_ps_write_buf_t buf, gdb_ps_size_t size)
+ps_pdwrite (gdb_ps_prochandle_t ph, psaddr_t addr, gdb_ps_write_buf_t buf,
+ gdb_ps_size_t size)
{
if (target_write_memory ((uintptr_t) addr, (const gdb_byte *) buf, size)
!= 0)
@@ -146,7 +146,8 @@ ps_lgetfpregs (gdb_ps_prochandle_t ph, lwpid_t lwpid, prfpregset_t *fpregset)
process PH from FPREGSET. */
ps_err_e
-ps_lsetfpregs (gdb_ps_prochandle_t ph, lwpid_t lwpid, const prfpregset_t *fpregset)
+ps_lsetfpregs (gdb_ps_prochandle_t ph, lwpid_t lwpid,
+ const prfpregset_t *fpregset)
{
/* Unneeded. */
return PS_ERR;
diff --git a/gdbserver/regcache.cc b/gdbserver/regcache.cc
index 0b11416..c0df07f 100644
--- a/gdbserver/regcache.cc
+++ b/gdbserver/regcache.cc
@@ -54,7 +54,7 @@ get_thread_regcache (struct thread_info *thread, int fetch)
switch_to_thread (thread);
/* Invalidate all registers, to prevent stale left-overs. */
memset (regcache->register_status, REG_UNAVAILABLE,
- regcache->tdesc->reg_defs.size ());
+ regcache->tdesc->reg_defs.size ());
fetch_inferior_registers (regcache, -1);
regcache->registers_valid = 1;
}
@@ -115,8 +115,7 @@ regcache_invalidate (void)
struct regcache *
init_register_cache (struct regcache *regcache,
- const struct target_desc *tdesc,
- unsigned char *regbuf)
+ const struct target_desc *tdesc, unsigned char *regbuf)
{
if (regbuf == NULL)
{
@@ -127,12 +126,12 @@ init_register_cache (struct regcache *regcache,
garbage. */
regcache->tdesc = tdesc;
regcache->registers
- = (unsigned char *) xcalloc (1, tdesc->registers_size);
+ = (unsigned char *) xcalloc (1, tdesc->registers_size);
regcache->registers_owned = 1;
regcache->register_status
- = (unsigned char *) xmalloc (tdesc->reg_defs.size ());
+ = (unsigned char *) xmalloc (tdesc->reg_defs.size ());
memset ((void *) regcache->register_status, REG_UNAVAILABLE,
- tdesc->reg_defs.size ());
+ tdesc->reg_defs.size ());
#else
gdb_assert_not_reached ("can't allocate memory from the heap");
#endif
@@ -170,7 +169,7 @@ free_register_cache (struct regcache *regcache)
if (regcache)
{
if (regcache->registers_owned)
- free (regcache->registers);
+ free (regcache->registers);
free (regcache->register_status);
delete regcache;
}
@@ -189,7 +188,7 @@ regcache_cpy (struct regcache *dst, struct regcache *src)
#ifndef IN_PROCESS_AGENT
if (dst->register_status != NULL && src->register_status != NULL)
memcpy (dst->register_status, src->register_status,
- src->tdesc->reg_defs.size ());
+ src->tdesc->reg_defs.size ());
#endif
dst->registers_valid = src->registers_valid;
}
@@ -216,15 +215,15 @@ registers_to_string (struct regcache *regcache, char *buf)
for (int i = 0; i < tdesc->reg_defs.size (); ++i)
{
if (regcache->register_status[i] == REG_VALID)
- {
- bin2hex (registers, buf, register_size (tdesc, i));
- buf += register_size (tdesc, i) * 2;
- }
+ {
+ bin2hex (registers, buf, register_size (tdesc, i));
+ buf += register_size (tdesc, i) * 2;
+ }
else
- {
- memset (buf, 'x', register_size (tdesc, i) * 2);
- buf += register_size (tdesc, i) * 2;
- }
+ {
+ memset (buf, 'x', register_size (tdesc, i) * 2);
+ buf += register_size (tdesc, i) * 2;
+ }
registers += register_size (tdesc, i);
}
*buf = '\0';
@@ -240,9 +239,9 @@ registers_from_string (struct regcache *regcache, char *buf)
if (len != tdesc->registers_size * 2)
{
warning ("Wrong sized register packet (expected %d bytes, got %d)",
- 2 * tdesc->registers_size, len);
+ 2 * tdesc->registers_size, len);
if (len > tdesc->registers_size * 2)
- len = tdesc->registers_size * 2;
+ len = tdesc->registers_size * 2;
}
hex2bin (buf, registers, len / 2);
}
@@ -255,7 +254,7 @@ find_regno_no_throw (const struct target_desc *tdesc, const char *name)
for (int i = 0; i < tdesc->reg_defs.size (); ++i)
{
if (strcmp (name, find_register_by_number (tdesc, i).name) == 0)
- return i;
+ return i;
}
return {};
}
@@ -316,7 +315,7 @@ static unsigned char *
register_data (const struct regcache *regcache, int n)
{
return (regcache->registers
- + find_register_by_number (regcache->tdesc, n).offset / 8);
+ + find_register_by_number (regcache->tdesc, n).offset / 8);
}
void
@@ -335,7 +334,7 @@ regcache::raw_supply (int n, const void *buf)
memcpy (register_data (this, n), buf, register_size (tdesc, n));
#ifndef IN_PROCESS_AGENT
if (register_status != NULL)
- register_status[n] = REG_VALID;
+ register_status[n] = REG_VALID;
#endif
}
else
@@ -343,7 +342,7 @@ regcache::raw_supply (int n, const void *buf)
memset (register_data (this, n), 0, register_size (tdesc, n));
#ifndef IN_PROCESS_AGENT
if (register_status != NULL)
- register_status[n] = REG_UNAVAILABLE;
+ register_status[n] = REG_UNAVAILABLE;
#endif
}
}
@@ -353,8 +352,7 @@ regcache::raw_supply (int n, const void *buf)
void
supply_register_zeroed (struct regcache *regcache, int n)
{
- memset (register_data (regcache, n), 0,
- register_size (regcache->tdesc, n));
+ memset (register_data (regcache, n), 0, register_size (regcache->tdesc, n));
#ifndef IN_PROCESS_AGENT
if (regcache->register_status != NULL)
regcache->register_status[n] = REG_VALID;
@@ -366,8 +364,7 @@ supply_register_zeroed (struct regcache *regcache, int n)
/* Supply register called NAME with value zero to REGCACHE. */
void
-supply_register_by_name_zeroed (struct regcache *regcache,
- const char *name)
+supply_register_by_name_zeroed (struct regcache *regcache, const char *name)
{
supply_register_zeroed (regcache, find_regno (regcache->tdesc, name));
}
@@ -388,10 +385,10 @@ supply_regblock (struct regcache *regcache, const void *buf)
memcpy (regcache->registers, buf, tdesc->registers_size);
#ifndef IN_PROCESS_AGENT
{
- int i;
+ int i;
- for (i = 0; i < tdesc->reg_defs.size (); i++)
- regcache->register_status[i] = REG_VALID;
+ for (i = 0; i < tdesc->reg_defs.size (); i++)
+ regcache->register_status[i] = REG_VALID;
}
#endif
}
@@ -402,10 +399,10 @@ supply_regblock (struct regcache *regcache, const void *buf)
memset (regcache->registers, 0, tdesc->registers_size);
#ifndef IN_PROCESS_AGENT
{
- int i;
+ int i;
- for (i = 0; i < tdesc->reg_defs.size (); i++)
- regcache->register_status[i] = REG_UNAVAILABLE;
+ for (i = 0; i < tdesc->reg_defs.size (); i++)
+ regcache->register_status[i] = REG_UNAVAILABLE;
}
#endif
}
@@ -414,8 +411,8 @@ supply_regblock (struct regcache *regcache, const void *buf)
#ifndef IN_PROCESS_AGENT
void
-supply_register_by_name (struct regcache *regcache,
- const char *name, const void *buf)
+supply_register_by_name (struct regcache *regcache, const char *name,
+ const void *buf)
{
supply_register (regcache, find_regno (regcache->tdesc, name), buf);
}
@@ -438,7 +435,7 @@ regcache::raw_collect (int n, void *buf) const
enum register_status
regcache_raw_read_unsigned (struct regcache *regcache, int regnum,
- ULONGEST *val)
+ ULONGEST *val)
{
int size;
@@ -447,9 +444,9 @@ regcache_raw_read_unsigned (struct regcache *regcache, int regnum,
size = register_size (regcache->tdesc, regnum);
if (size > (int) sizeof (ULONGEST))
- error (_("That operation is not available on integers of more than"
- "%d bytes."),
- (int) sizeof (ULONGEST));
+ error (_ ("That operation is not available on integers of more than"
+ "%d bytes."),
+ (int) sizeof (ULONGEST));
*val = 0;
collect_register (regcache, regnum, val);
@@ -462,23 +459,22 @@ regcache_raw_read_unsigned (struct regcache *regcache, int regnum,
/* See regcache.h. */
ULONGEST
-regcache_raw_get_unsigned_by_name (struct regcache *regcache,
- const char *name)
+regcache_raw_get_unsigned_by_name (struct regcache *regcache, const char *name)
{
return regcache_raw_get_unsigned (regcache,
- find_regno (regcache->tdesc, name));
+ find_regno (regcache->tdesc, name));
}
void
collect_register_as_string (struct regcache *regcache, int n, char *buf)
{
bin2hex (register_data (regcache, n), buf,
- register_size (regcache->tdesc, n));
+ register_size (regcache->tdesc, n));
}
void
-collect_register_by_name (struct regcache *regcache,
- const char *name, void *buf)
+collect_register_by_name (struct regcache *regcache, const char *name,
+ void *buf)
{
collect_register (regcache, find_regno (regcache->tdesc, name), buf);
}
diff --git a/gdbserver/regcache.h b/gdbserver/regcache.h
index 7248bcf..2ffb912 100644
--- a/gdbserver/regcache.h
+++ b/gdbserver/regcache.h
@@ -60,8 +60,8 @@ struct regcache : public reg_buffer_common
};
struct regcache *init_register_cache (struct regcache *regcache,
- const struct target_desc *tdesc,
- unsigned char *regbuf);
+ const struct target_desc *tdesc,
+ unsigned char *regbuf);
void regcache_cpy (struct regcache *dst, struct regcache *src);
@@ -113,7 +113,7 @@ int register_size (const struct target_desc *tdesc, int n);
/* No throw version of find_regno. If NAME is not a known register, return
an empty value. */
gdb::optional<int> find_regno_no_throw (const struct target_desc *tdesc,
- const char *name);
+ const char *name);
int find_regno (const struct target_desc *tdesc, const char *name);
@@ -121,11 +121,11 @@ void supply_register (struct regcache *regcache, int n, const void *buf);
void supply_register_zeroed (struct regcache *regcache, int n);
-void supply_register_by_name (struct regcache *regcache,
- const char *name, const void *buf);
+void supply_register_by_name (struct regcache *regcache, const char *name,
+ const void *buf);
void supply_register_by_name_zeroed (struct regcache *regcache,
- const char *name);
+ const char *name);
void supply_regblock (struct regcache *regcache, const void *buf);
@@ -133,14 +133,14 @@ void collect_register (struct regcache *regcache, int n, void *buf);
void collect_register_as_string (struct regcache *regcache, int n, char *buf);
-void collect_register_by_name (struct regcache *regcache,
- const char *name, void *buf);
+void collect_register_by_name (struct regcache *regcache, const char *name,
+ void *buf);
/* Read a raw register as an unsigned integer. Convenience wrapper
around regcache_raw_get_unsigned that takes a register name instead
of a register number. */
ULONGEST regcache_raw_get_unsigned_by_name (struct regcache *regcache,
- const char *name);
+ const char *name);
#endif /* GDBSERVER_REGCACHE_H */
diff --git a/gdbserver/remote-utils.cc b/gdbserver/remote-utils.cc
index 80310bc..107a5b8 100644
--- a/gdbserver/remote-utils.cc
+++ b/gdbserver/remote-utils.cc
@@ -75,7 +75,8 @@ typedef int socklen_t;
#ifndef IN_PROCESS_AGENT
/* Extra value for readchar_callback. */
-enum {
+enum
+{
/* The callback is currently not scheduled. */
NOT_SCHEDULED = -1
};
@@ -103,11 +104,11 @@ static int listen_desc = -1;
#ifdef USE_WIN32API
/* gnulib wraps these as macros, undo them. */
-# undef read
-# undef write
+#undef read
+#undef write
-# define read(fd, buf, len) recv (fd, (char *) buf, len, 0)
-# define write(fd, buf, len) send (fd, (char *) buf, len, 0)
+#define read(fd, buf, len) recv (fd, (char *) buf, len, 0)
+#define write(fd, buf, len) send (fd, (char *) buf, len, 0)
#endif
int
@@ -127,12 +128,12 @@ remote_connection_is_stdio (void)
static void
enable_async_notification (int fd)
{
-#if defined(F_SETFL) && defined (FASYNC)
+#if defined(F_SETFL) && defined(FASYNC)
int save_fcntl_flags;
save_fcntl_flags = fcntl (fd, F_GETFL, 0);
fcntl (fd, F_SETFL, save_fcntl_flags | FASYNC);
-#if defined (F_SETOWN)
+#if defined(F_SETOWN)
fcntl (fd, F_SETOWN, getpid ());
#endif
#endif
@@ -152,26 +153,26 @@ handle_accept_event (int err, gdb_client_data client_data)
/* Enable TCP keep alive process. */
socklen_t tmp = 1;
- setsockopt (remote_desc, SOL_SOCKET, SO_KEEPALIVE,
- (char *) &tmp, sizeof (tmp));
+ setsockopt (remote_desc, SOL_SOCKET, SO_KEEPALIVE, (char *) &tmp,
+ sizeof (tmp));
/* Tell TCP not to delay small packets. This greatly speeds up
interactive response. */
tmp = 1;
- setsockopt (remote_desc, IPPROTO_TCP, TCP_NODELAY,
- (char *) &tmp, sizeof (tmp));
+ setsockopt (remote_desc, IPPROTO_TCP, TCP_NODELAY, (char *) &tmp,
+ sizeof (tmp));
#ifndef USE_WIN32API
- signal (SIGPIPE, SIG_IGN); /* If we don't do this, then gdbserver simply
+ signal (SIGPIPE, SIG_IGN); /* If we don't do this, then gdbserver simply
exits when the remote side dies. */
#endif
if (run_once)
{
#ifndef USE_WIN32API
- close (listen_desc); /* No longer need this */
+ close (listen_desc); /* No longer need this */
#else
- closesocket (listen_desc); /* No longer need this */
+ closesocket (listen_desc); /* No longer need this */
#endif
}
@@ -182,17 +183,16 @@ handle_accept_event (int err, gdb_client_data client_data)
/* Convert IP address to string. */
char orig_host[GDB_NI_MAX_ADDR], orig_port[GDB_NI_MAX_PORT];
- int r = getnameinfo ((struct sockaddr *) &sockaddr, len,
- orig_host, sizeof (orig_host),
- orig_port, sizeof (orig_port),
- NI_NUMERICHOST | NI_NUMERICSERV);
+ int r = getnameinfo ((struct sockaddr *) &sockaddr, len, orig_host,
+ sizeof (orig_host), orig_port, sizeof (orig_port),
+ NI_NUMERICHOST | NI_NUMERICSERV);
if (r != 0)
- fprintf (stderr, _("Could not obtain remote address: %s\n"),
- gai_strerror (r));
+ fprintf (stderr, _ ("Could not obtain remote address: %s\n"),
+ gai_strerror (r));
else
- fprintf (stderr, _("Remote debugging from host %s, port %s\n"),
- orig_host, orig_port);
+ fprintf (stderr, _ ("Remote debugging from host %s, port %s\n"), orig_host,
+ orig_port);
enable_async_notification (remote_desc);
@@ -261,10 +261,10 @@ remote_prepare (const char *name)
#endif
int r = getaddrinfo (parsed.host_str.c_str (), parsed.port_str.c_str (),
- &hint, &ainfo);
+ &hint, &ainfo);
if (r != 0)
- error (_("%s: cannot resolve name: %s"), name, gai_strerror (r));
+ error (_ ("%s: cannot resolve name: %s"), name, gai_strerror (r));
scoped_free_addrinfo freeaddrinfo (ainfo);
@@ -273,10 +273,10 @@ remote_prepare (const char *name)
for (iter = ainfo; iter != NULL; iter = iter->ai_next)
{
listen_desc = gdb_socket_cloexec (iter->ai_family, iter->ai_socktype,
- iter->ai_protocol);
+ iter->ai_protocol);
if (listen_desc >= 0)
- break;
+ break;
}
if (iter == NULL)
@@ -285,7 +285,7 @@ remote_prepare (const char *name)
/* Allow rapid reuse of this port. */
tmp = 1;
setsockopt (listen_desc, SOL_SOCKET, SO_REUSEADDR, (char *) &tmp,
- sizeof (tmp));
+ sizeof (tmp));
switch (iter->ai_family)
{
@@ -296,7 +296,7 @@ remote_prepare (const char *name)
((struct sockaddr_in6 *) iter->ai_addr)->sin6_addr = in6addr_any;
break;
default:
- internal_error (_("Invalid 'ai_family' %d\n"), iter->ai_family);
+ internal_error (_ ("Invalid 'ai_family' %d\n"), iter->ai_family);
}
if (bind (listen_desc, iter->ai_addr, iter->ai_addrlen) != 0)
@@ -333,7 +333,8 @@ remote_open (const char *name)
enable_async_notification (remote_desc);
/* Register the event loop handler. */
- add_file_handler (remote_desc, handle_serial_event, NULL, "remote-stdio");
+ add_file_handler (remote_desc, handle_serial_event, NULL,
+ "remote-stdio");
}
#ifndef USE_WIN32API
else if (port_str == NULL)
@@ -341,31 +342,31 @@ remote_open (const char *name)
struct stat statbuf;
if (stat (name, &statbuf) == 0
- && (S_ISCHR (statbuf.st_mode) || S_ISFIFO (statbuf.st_mode)))
- remote_desc = open (name, O_RDWR);
+ && (S_ISCHR (statbuf.st_mode) || S_ISFIFO (statbuf.st_mode)))
+ remote_desc = open (name, O_RDWR);
else
- {
- errno = EINVAL;
- remote_desc = -1;
- }
+ {
+ errno = EINVAL;
+ remote_desc = -1;
+ }
if (remote_desc < 0)
- perror_with_name ("Could not open remote device");
+ perror_with_name ("Could not open remote device");
#if HAVE_TERMIOS_H
{
- struct termios termios;
- tcgetattr (remote_desc, &termios);
-
- termios.c_iflag = 0;
- termios.c_oflag = 0;
- termios.c_lflag = 0;
- termios.c_cflag &= ~(CSIZE | PARENB);
- termios.c_cflag |= CLOCAL | CS8;
- termios.c_cc[VMIN] = 1;
- termios.c_cc[VTIME] = 0;
-
- tcsetattr (remote_desc, TCSANOW, &termios);
+ struct termios termios;
+ tcgetattr (remote_desc, &termios);
+
+ termios.c_iflag = 0;
+ termios.c_oflag = 0;
+ termios.c_lflag = 0;
+ termios.c_cflag &= ~(CSIZE | PARENB);
+ termios.c_cflag |= CLOCAL | CS8;
+ termios.c_cc[VMIN] = 1;
+ termios.c_cc[VTIME] = 0;
+
+ tcsetattr (remote_desc, TCSANOW, &termios);
}
#endif
@@ -375,7 +376,7 @@ remote_open (const char *name)
/* Register the event loop handler. */
add_file_handler (remote_desc, handle_serial_event, NULL,
- "remote-device");
+ "remote-device");
}
#endif /* USE_WIN32API */
else
@@ -385,24 +386,22 @@ remote_open (const char *name)
socklen_t len = sizeof (sockaddr);
if (getsockname (listen_desc, (struct sockaddr *) &sockaddr, &len) < 0)
- perror_with_name ("Can't determine port");
+ perror_with_name ("Can't determine port");
- int r = getnameinfo ((struct sockaddr *) &sockaddr, len,
- NULL, 0,
- listen_port, sizeof (listen_port),
- NI_NUMERICSERV);
+ int r = getnameinfo ((struct sockaddr *) &sockaddr, len, NULL, 0,
+ listen_port, sizeof (listen_port), NI_NUMERICSERV);
if (r != 0)
- fprintf (stderr, _("Can't obtain port where we are listening: %s"),
- gai_strerror (r));
+ fprintf (stderr, _ ("Can't obtain port where we are listening: %s"),
+ gai_strerror (r));
else
- fprintf (stderr, _("Listening on port %s\n"), listen_port);
+ fprintf (stderr, _ ("Listening on port %s\n"), listen_port);
fflush (stderr);
/* Register the event loop handler. */
add_file_handler (listen_desc, handle_accept_event, NULL,
- "remote-listen");
+ "remote-listen");
}
}
@@ -416,7 +415,7 @@ remote_close (void)
#ifdef USE_WIN32API
closesocket (remote_desc);
#else
- if (! remote_connection_is_stdio ())
+ if (!remote_connection_is_stdio ())
close (remote_desc);
#endif
remote_desc = -1;
@@ -525,9 +524,9 @@ write_ptid (char *buf, ptid_t ptid)
{
pid = ptid.pid ();
if (pid < 0)
- buf += sprintf (buf, "p-%x.", -pid);
+ buf += sprintf (buf, "p-%x.", -pid);
else
- buf += sprintf (buf, "p%x.", pid);
+ buf += sprintf (buf, "p%x.", pid);
}
tid = ptid.lwp ();
if (tid < 0)
@@ -571,14 +570,14 @@ read_ptid (const char *buf, const char **obuf)
/* Multi-process ptid. */
pp = unpack_varlen_hex (p + 1, &pid);
if (*pp != '.')
- error ("invalid remote ptid: %s\n", p);
+ error ("invalid remote ptid: %s\n", p);
p = pp + 1;
tid = hex_or_minus_one (p, &pp);
if (obuf)
- *obuf = pp;
+ *obuf = pp;
return ptid_t (pid, tid);
}
@@ -660,43 +659,43 @@ putpkt_binary_1 (char *buf, int cnt, int is_notif)
do
{
if (write_prim (buf2, p - buf2) != p - buf2)
- {
- perror ("putpkt(write)");
- free (buf2);
- return -1;
- }
+ {
+ perror ("putpkt(write)");
+ free (buf2);
+ return -1;
+ }
if (cs.noack_mode || is_notif)
- {
- /* Don't expect an ack then. */
- if (is_notif)
- remote_debug_printf ("putpkt (\"%s\"); [notif]", buf2);
- else
- remote_debug_printf ("putpkt (\"%s\"); [noack mode]", buf2);
+ {
+ /* Don't expect an ack then. */
+ if (is_notif)
+ remote_debug_printf ("putpkt (\"%s\"); [notif]", buf2);
+ else
+ remote_debug_printf ("putpkt (\"%s\"); [noack mode]", buf2);
- break;
- }
+ break;
+ }
remote_debug_printf ("putpkt (\"%s\"); [looking for ack]", buf2);
cc = readchar ();
if (cc < 0)
- {
- free (buf2);
- return -1;
- }
+ {
+ free (buf2);
+ return -1;
+ }
remote_debug_printf ("[received '%c' (0x%x)]", cc, cc);
/* Check for an input interrupt while we're here. */
if (cc == '\003' && current_thread != NULL)
- the_target->request_interrupt ();
+ the_target->request_interrupt ();
}
while (cc != '+');
free (buf2);
- return 1; /* Success! */
+ return 1; /* Success! */
}
int
@@ -746,19 +745,19 @@ input_interrupt (int unused)
cc = read_prim (&c, 1);
if (cc == 0)
- {
- fprintf (stderr, "client connection closed\n");
- return;
- }
+ {
+ fprintf (stderr, "client connection closed\n");
+ return;
+ }
else if (cc != 1 || c != '\003')
- {
- fprintf (stderr, "input_interrupt, count = %d c = %d ", cc, c);
- if (isprint (c))
- fprintf (stderr, "('%c')\n", c);
- else
- fprintf (stderr, "('\\x%02x')\n", c & 0xff);
- return;
- }
+ {
+ fprintf (stderr, "input_interrupt, count = %d c = %d ", cc, c);
+ if (isprint (c))
+ fprintf (stderr, "('%c')\n", c);
+ else
+ fprintf (stderr, "('\\x%02x')\n", c & 0xff);
+ return;
+ }
the_target->request_interrupt ();
}
@@ -853,16 +852,16 @@ readchar (void)
readchar_bufcnt = read_prim (readchar_buf, sizeof (readchar_buf));
if (readchar_bufcnt <= 0)
- {
- if (readchar_bufcnt == 0)
- {
- remote_debug_printf ("readchar: Got EOF");
- }
- else
- perror ("readchar");
+ {
+ if (readchar_bufcnt == 0)
+ {
+ remote_debug_printf ("readchar: Got EOF");
+ }
+ else
+ perror ("readchar");
- return -1;
- }
+ return -1;
+ }
readchar_bufp = readchar_buf;
}
@@ -924,59 +923,59 @@ getpkt (char *buf)
csum = 0;
while (1)
- {
- c = readchar ();
+ {
+ c = readchar ();
- /* The '\003' may appear before or after each packet, so
+ /* The '\003' may appear before or after each packet, so
check for an input interrupt. */
- if (c == '\003')
- {
- the_target->request_interrupt ();
- continue;
- }
+ if (c == '\003')
+ {
+ the_target->request_interrupt ();
+ continue;
+ }
- if (c == '$')
- break;
+ if (c == '$')
+ break;
- remote_debug_printf ("[getpkt: discarding char '%c']", c);
+ remote_debug_printf ("[getpkt: discarding char '%c']", c);
- if (c < 0)
- return -1;
- }
+ if (c < 0)
+ return -1;
+ }
bp = buf;
while (1)
- {
- c = readchar ();
- if (c < 0)
- return -1;
- if (c == '#')
- break;
- *bp++ = c;
- csum += c;
- }
+ {
+ c = readchar ();
+ if (c < 0)
+ return -1;
+ if (c == '#')
+ break;
+ *bp++ = c;
+ csum += c;
+ }
*bp = 0;
c1 = fromhex (readchar ());
c2 = fromhex (readchar ());
if (csum == (c1 << 4) + c2)
- break;
+ break;
if (cs.noack_mode)
- {
- fprintf (stderr,
- "Bad checksum, sentsum=0x%x, csum=0x%x, "
- "buf=%s [no-ack-mode, Bad medium?]\n",
- (c1 << 4) + c2, csum, buf);
- /* Not much we can do, GDB wasn't expecting an ack/nac. */
- break;
- }
+ {
+ fprintf (stderr,
+ "Bad checksum, sentsum=0x%x, csum=0x%x, "
+ "buf=%s [no-ack-mode, Bad medium?]\n",
+ (c1 << 4) + c2, csum, buf);
+ /* Not much we can do, GDB wasn't expecting an ack/nac. */
+ break;
+ }
fprintf (stderr, "Bad checksum, sentsum=0x%x, csum=0x%x, buf=%s\n",
- (c1 << 4) + c2, csum, buf);
+ (c1 << 4) + c2, csum, buf);
if (write_prim ("-", 1) != 1)
- return -1;
+ return -1;
}
if (!cs.noack_mode)
@@ -984,7 +983,7 @@ getpkt (char *buf)
remote_debug_printf ("getpkt (\"%s\"); [sending ack]", buf);
if (write_prim ("+", 1) != 1)
- return -1;
+ return -1;
remote_debug_printf ("[sent ack]");
}
@@ -1054,7 +1053,7 @@ prepare_resume_reply (char *buf, ptid_t ptid, const target_waitstatus &status)
{
client_state &cs = get_client_state ();
threads_debug_printf ("Writing resume reply for %s:%d",
- target_pid_to_str (ptid).c_str (), status.kind ());
+ target_pid_to_str (ptid).c_str (), status.kind ());
switch (status.kind ())
{
@@ -1067,70 +1066,72 @@ prepare_resume_reply (char *buf, ptid_t ptid, const target_waitstatus &status)
case TARGET_WAITKIND_SYSCALL_ENTRY:
case TARGET_WAITKIND_SYSCALL_RETURN:
{
- const char **regp;
- struct regcache *regcache;
- char *buf_start = buf;
-
- if ((status.kind () == TARGET_WAITKIND_FORKED && cs.report_fork_events)
- || (status.kind () == TARGET_WAITKIND_VFORKED
- && cs.report_vfork_events))
- {
- enum gdb_signal signal = GDB_SIGNAL_TRAP;
- const char *event = (status.kind () == TARGET_WAITKIND_FORKED
- ? "fork" : "vfork");
-
- sprintf (buf, "T%02x%s:", signal, event);
- buf += strlen (buf);
- buf = write_ptid (buf, status.child_ptid ());
- strcat (buf, ";");
- }
- else if (status.kind () == TARGET_WAITKIND_VFORK_DONE
- && cs.report_vfork_events)
- {
- enum gdb_signal signal = GDB_SIGNAL_TRAP;
-
- sprintf (buf, "T%02xvforkdone:;", signal);
- }
- else if (status.kind () == TARGET_WAITKIND_EXECD && cs.report_exec_events)
- {
- enum gdb_signal signal = GDB_SIGNAL_TRAP;
- const char *event = "exec";
- char hexified_pathname[PATH_MAX * 2];
-
- sprintf (buf, "T%02x%s:", signal, event);
- buf += strlen (buf);
-
- /* Encode pathname to hexified format. */
- bin2hex ((const gdb_byte *) status.execd_pathname (),
- hexified_pathname,
- strlen (status.execd_pathname ()));
-
- sprintf (buf, "%s;", hexified_pathname);
- buf += strlen (buf);
- }
- else if (status.kind () == TARGET_WAITKIND_THREAD_CREATED
- && cs.report_thread_events)
- {
- enum gdb_signal signal = GDB_SIGNAL_TRAP;
-
- sprintf (buf, "T%02xcreate:;", signal);
- }
- else if (status.kind () == TARGET_WAITKIND_SYSCALL_ENTRY
- || status.kind () == TARGET_WAITKIND_SYSCALL_RETURN)
- {
- enum gdb_signal signal = GDB_SIGNAL_TRAP;
- const char *event = (status.kind () == TARGET_WAITKIND_SYSCALL_ENTRY
- ? "syscall_entry" : "syscall_return");
-
- sprintf (buf, "T%02x%s:%x;", signal, event,
- status.syscall_number ());
- }
- else
- sprintf (buf, "T%02x", status.sig ());
-
- if (disable_packet_T)
- {
- /* This is a bit (OK, a lot) of a kludge, however, this isn't
+ const char **regp;
+ struct regcache *regcache;
+ char *buf_start = buf;
+
+ if ((status.kind () == TARGET_WAITKIND_FORKED && cs.report_fork_events)
+ || (status.kind () == TARGET_WAITKIND_VFORKED
+ && cs.report_vfork_events))
+ {
+ enum gdb_signal signal = GDB_SIGNAL_TRAP;
+ const char *event
+ = (status.kind () == TARGET_WAITKIND_FORKED ? "fork" : "vfork");
+
+ sprintf (buf, "T%02x%s:", signal, event);
+ buf += strlen (buf);
+ buf = write_ptid (buf, status.child_ptid ());
+ strcat (buf, ";");
+ }
+ else if (status.kind () == TARGET_WAITKIND_VFORK_DONE
+ && cs.report_vfork_events)
+ {
+ enum gdb_signal signal = GDB_SIGNAL_TRAP;
+
+ sprintf (buf, "T%02xvforkdone:;", signal);
+ }
+ else if (status.kind () == TARGET_WAITKIND_EXECD
+ && cs.report_exec_events)
+ {
+ enum gdb_signal signal = GDB_SIGNAL_TRAP;
+ const char *event = "exec";
+ char hexified_pathname[PATH_MAX * 2];
+
+ sprintf (buf, "T%02x%s:", signal, event);
+ buf += strlen (buf);
+
+ /* Encode pathname to hexified format. */
+ bin2hex ((const gdb_byte *) status.execd_pathname (),
+ hexified_pathname, strlen (status.execd_pathname ()));
+
+ sprintf (buf, "%s;", hexified_pathname);
+ buf += strlen (buf);
+ }
+ else if (status.kind () == TARGET_WAITKIND_THREAD_CREATED
+ && cs.report_thread_events)
+ {
+ enum gdb_signal signal = GDB_SIGNAL_TRAP;
+
+ sprintf (buf, "T%02xcreate:;", signal);
+ }
+ else if (status.kind () == TARGET_WAITKIND_SYSCALL_ENTRY
+ || status.kind () == TARGET_WAITKIND_SYSCALL_RETURN)
+ {
+ enum gdb_signal signal = GDB_SIGNAL_TRAP;
+ const char *event
+ = (status.kind () == TARGET_WAITKIND_SYSCALL_ENTRY
+ ? "syscall_entry"
+ : "syscall_return");
+
+ sprintf (buf, "T%02x%s:%x;", signal, event,
+ status.syscall_number ());
+ }
+ else
+ sprintf (buf, "T%02x", status.sig ());
+
+ if (disable_packet_T)
+ {
+ /* This is a bit (OK, a lot) of a kludge, however, this isn't
really a user feature, but exists only so GDB can use the
gdbserver to test handling of the 'S' stop reply packet, so
we would rather this code be as simple as possible.
@@ -1140,61 +1141,61 @@ prepare_resume_reply (char *buf, ptid_t ptid, const target_waitstatus &status)
An 'S' stop packet always looks like 'Sxx', so all we do
here is convert the buffer from a T packet to an S packet
and the avoid adding any extra content by breaking out. */
- gdb_assert (buf_start[0] == 'T');
- gdb_assert (isxdigit (buf_start[1]));
- gdb_assert (isxdigit (buf_start[2]));
- buf_start[0] = 'S';
- buf_start[3] = '\0';
- break;
- }
+ gdb_assert (buf_start[0] == 'T');
+ gdb_assert (isxdigit (buf_start[1]));
+ gdb_assert (isxdigit (buf_start[2]));
+ buf_start[0] = 'S';
+ buf_start[3] = '\0';
+ break;
+ }
- buf += strlen (buf);
+ buf += strlen (buf);
- scoped_restore_current_thread restore_thread;
+ scoped_restore_current_thread restore_thread;
- switch_to_thread (the_target, ptid);
+ switch_to_thread (the_target, ptid);
- regp = current_target_desc ()->expedite_regs;
+ regp = current_target_desc ()->expedite_regs;
- regcache = get_thread_regcache (current_thread, 1);
+ regcache = get_thread_regcache (current_thread, 1);
- if (the_target->stopped_by_watchpoint ())
- {
- CORE_ADDR addr;
- int i;
+ if (the_target->stopped_by_watchpoint ())
+ {
+ CORE_ADDR addr;
+ int i;
- memcpy (buf, "watch:", 6);
- buf += 6;
+ memcpy (buf, "watch:", 6);
+ buf += 6;
- addr = the_target->stopped_data_address ();
+ addr = the_target->stopped_data_address ();
- /* Convert each byte of the address into two hexadecimal
+ /* Convert each byte of the address into two hexadecimal
chars. Note that we take sizeof (void *) instead of
sizeof (addr); this is to avoid sending a 64-bit
address to a 32-bit GDB. */
- for (i = sizeof (void *) * 2; i > 0; i--)
- *buf++ = tohex ((addr >> (i - 1) * 4) & 0xf);
- *buf++ = ';';
- }
- else if (cs.swbreak_feature && target_stopped_by_sw_breakpoint ())
- {
- sprintf (buf, "swbreak:;");
- buf += strlen (buf);
- }
- else if (cs.hwbreak_feature && target_stopped_by_hw_breakpoint ())
- {
- sprintf (buf, "hwbreak:;");
- buf += strlen (buf);
- }
-
- while (*regp)
- {
- buf = outreg (regcache, find_regno (regcache->tdesc, *regp), buf);
- regp ++;
- }
- *buf = '\0';
-
- /* Formerly, if the debugger had not used any thread features
+ for (i = sizeof (void *) * 2; i > 0; i--)
+ *buf++ = tohex ((addr >> (i - 1) * 4) & 0xf);
+ *buf++ = ';';
+ }
+ else if (cs.swbreak_feature && target_stopped_by_sw_breakpoint ())
+ {
+ sprintf (buf, "swbreak:;");
+ buf += strlen (buf);
+ }
+ else if (cs.hwbreak_feature && target_stopped_by_hw_breakpoint ())
+ {
+ sprintf (buf, "hwbreak:;");
+ buf += strlen (buf);
+ }
+
+ while (*regp)
+ {
+ buf = outreg (regcache, find_regno (regcache->tdesc, *regp), buf);
+ regp++;
+ }
+ *buf = '\0';
+
+ /* Formerly, if the debugger had not used any thread features
we would not burden it with a thread status response. This
was for the benefit of GDB 4.13 and older. However, in
recent GDB versions the check (``if (cont_thread != 0)'')
@@ -1203,59 +1204,57 @@ prepare_resume_reply (char *buf, ptid_t ptid, const target_waitstatus &status)
thread. Since thread support relies on qSymbol support
anyway, assume GDB can handle threads. */
- if (using_threads && !disable_packet_Tthread)
- {
- /* This if (1) ought to be unnecessary. But remote_wait
+ if (using_threads && !disable_packet_Tthread)
+ {
+ /* This if (1) ought to be unnecessary. But remote_wait
in GDB will claim this event belongs to inferior_ptid
if we do not specify a thread, and there's no way for
gdbserver to know what inferior_ptid is. */
- if (1 || cs.general_thread != ptid)
- {
- int core = -1;
- /* In non-stop, don't change the general thread behind
+ if (1 || cs.general_thread != ptid)
+ {
+ int core = -1;
+ /* In non-stop, don't change the general thread behind
GDB's back. */
- if (!non_stop)
- cs.general_thread = ptid;
- sprintf (buf, "thread:");
- buf += strlen (buf);
- buf = write_ptid (buf, ptid);
- strcat (buf, ";");
- buf += strlen (buf);
-
- core = target_core_of_thread (ptid);
-
- if (core != -1)
- {
- sprintf (buf, "core:");
- buf += strlen (buf);
- sprintf (buf, "%x", core);
- strcat (buf, ";");
- buf += strlen (buf);
- }
- }
- }
-
- if (current_process ()->dlls_changed)
- {
- strcpy (buf, "library:;");
- buf += strlen (buf);
- current_process ()->dlls_changed = false;
- }
+ if (!non_stop)
+ cs.general_thread = ptid;
+ sprintf (buf, "thread:");
+ buf += strlen (buf);
+ buf = write_ptid (buf, ptid);
+ strcat (buf, ";");
+ buf += strlen (buf);
+
+ core = target_core_of_thread (ptid);
+
+ if (core != -1)
+ {
+ sprintf (buf, "core:");
+ buf += strlen (buf);
+ sprintf (buf, "%x", core);
+ strcat (buf, ";");
+ buf += strlen (buf);
+ }
+ }
+ }
+
+ if (current_process ()->dlls_changed)
+ {
+ strcpy (buf, "library:;");
+ buf += strlen (buf);
+ current_process ()->dlls_changed = false;
+ }
}
break;
case TARGET_WAITKIND_EXITED:
if (cs.multi_process)
- sprintf (buf, "W%x;process:%x",
- status.exit_status (), ptid.pid ());
+ sprintf (buf, "W%x;process:%x", status.exit_status (), ptid.pid ());
else
- sprintf (buf, "W%02x", status.exit_status ());
+ sprintf (buf, "W%02x", status.exit_status ());
break;
case TARGET_WAITKIND_SIGNALLED:
if (cs.multi_process)
- sprintf (buf, "X%x;process:%x",
- status.sig (), ptid.pid ());
+ sprintf (buf, "X%x;process:%x", status.sig (), ptid.pid ());
else
- sprintf (buf, "X%02x", status.sig ());
+ sprintf (buf, "X%02x", status.sig ());
break;
case TARGET_WAITKIND_THREAD_EXITED:
sprintf (buf, "w%x;", status.exit_status ());
@@ -1275,7 +1274,7 @@ prepare_resume_reply (char *buf, ptid_t ptid, const target_waitstatus &status)
const char *
decode_m_packet_params (const char *from, CORE_ADDR *mem_addr_ptr,
- unsigned int *len_ptr, const char end_marker)
+ unsigned int *len_ptr, const char end_marker)
{
int i = 0;
char ch;
@@ -1298,14 +1297,14 @@ decode_m_packet_params (const char *from, CORE_ADDR *mem_addr_ptr,
void
decode_m_packet (const char *from, CORE_ADDR *mem_addr_ptr,
- unsigned int *len_ptr)
+ unsigned int *len_ptr)
{
decode_m_packet_params (from, mem_addr_ptr, len_ptr, '\0');
}
void
decode_M_packet (const char *from, CORE_ADDR *mem_addr_ptr,
- unsigned int *len_ptr, unsigned char **to_p)
+ unsigned int *len_ptr, unsigned char **to_p)
{
from = decode_m_packet_params (from, mem_addr_ptr, len_ptr, ':');
@@ -1317,7 +1316,7 @@ decode_M_packet (const char *from, CORE_ADDR *mem_addr_ptr,
int
decode_X_packet (char *from, int packet_len, CORE_ADDR *mem_addr_ptr,
- unsigned int *len_ptr, unsigned char **to_p)
+ unsigned int *len_ptr, unsigned char **to_p)
{
int i = 0;
char ch;
@@ -1339,7 +1338,8 @@ decode_X_packet (char *from, int packet_len, CORE_ADDR *mem_addr_ptr,
*to_p = (unsigned char *) xmalloc (*len_ptr);
if (remote_unescape_input ((const gdb_byte *) &from[i], packet_len - i,
- *to_p, *len_ptr) != *len_ptr)
+ *to_p, *len_ptr)
+ != *len_ptr)
return -1;
return 0;
@@ -1349,7 +1349,7 @@ decode_X_packet (char *from, int packet_len, CORE_ADDR *mem_addr_ptr,
int
decode_xfer_write (char *buf, int packet_len, CORE_ADDR *offset,
- unsigned int *len, unsigned char *data)
+ unsigned int *len, unsigned char *data)
{
char ch;
char *b = buf;
@@ -1364,8 +1364,8 @@ decode_xfer_write (char *buf, int packet_len, CORE_ADDR *offset,
/* Get encoded data. */
packet_len -= buf - b;
- *len = remote_unescape_input ((const gdb_byte *) buf, packet_len,
- data, packet_len);
+ *len = remote_unescape_input ((const gdb_byte *) buf, packet_len, data,
+ packet_len);
return 0;
}
@@ -1373,9 +1373,9 @@ decode_xfer_write (char *buf, int packet_len, CORE_ADDR *offset,
int
decode_search_memory_packet (const char *buf, int packet_len,
- CORE_ADDR *start_addrp,
- CORE_ADDR *search_space_lenp,
- gdb_byte *pattern, unsigned int *pattern_lenp)
+ CORE_ADDR *start_addrp,
+ CORE_ADDR *search_space_lenp, gdb_byte *pattern,
+ unsigned int *pattern_lenp)
{
const char *p = buf;
@@ -1383,7 +1383,7 @@ decode_search_memory_packet (const char *buf, int packet_len,
p = decode_address_to_semicolon (search_space_lenp, p);
packet_len -= p - buf;
*pattern_lenp = remote_unescape_input ((const gdb_byte *) p, packet_len,
- pattern, packet_len);
+ pattern, packet_len);
return 0;
}
@@ -1431,8 +1431,8 @@ look_up_one_symbol (const char *name, CORE_ADDR *addrp, int may_ask_gdb)
for (sym = proc->symbol_cache; sym; sym = sym->next)
if (strcmp (name, sym->name) == 0)
{
- *addrp = sym->addr;
- return 1;
+ *addrp = sym->addr;
+ return 1;
}
/* It might not be an appropriate time to look up a symbol,
@@ -1443,7 +1443,7 @@ look_up_one_symbol (const char *name, CORE_ADDR *addrp, int may_ask_gdb)
/* Send the request. */
strcpy (cs.own_buf, "qSymbol:");
bin2hex ((const gdb_byte *) name, cs.own_buf + strlen ("qSymbol:"),
- strlen (name));
+ strlen (name));
if (putpkt (cs.own_buf) < 0)
return -1;
@@ -1460,35 +1460,35 @@ look_up_one_symbol (const char *name, CORE_ADDR *addrp, int may_ask_gdb)
while (1)
{
if (cs.own_buf[0] == 'm')
- {
- CORE_ADDR mem_addr;
- unsigned char *mem_buf;
- unsigned int mem_len;
-
- decode_m_packet (&cs.own_buf[1], &mem_addr, &mem_len);
- mem_buf = (unsigned char *) xmalloc (mem_len);
- if (read_inferior_memory (mem_addr, mem_buf, mem_len) == 0)
- bin2hex (mem_buf, cs.own_buf, mem_len);
- else
- write_enn (cs.own_buf);
- free (mem_buf);
- if (putpkt (cs.own_buf) < 0)
- return -1;
- }
+ {
+ CORE_ADDR mem_addr;
+ unsigned char *mem_buf;
+ unsigned int mem_len;
+
+ decode_m_packet (&cs.own_buf[1], &mem_addr, &mem_len);
+ mem_buf = (unsigned char *) xmalloc (mem_len);
+ if (read_inferior_memory (mem_addr, mem_buf, mem_len) == 0)
+ bin2hex (mem_buf, cs.own_buf, mem_len);
+ else
+ write_enn (cs.own_buf);
+ free (mem_buf);
+ if (putpkt (cs.own_buf) < 0)
+ return -1;
+ }
else if (cs.own_buf[0] == 'v')
- {
- int new_len = -1;
- handle_v_requests (cs.own_buf, len, &new_len);
- if (new_len != -1)
- putpkt_binary (cs.own_buf, new_len);
- else
- putpkt (cs.own_buf);
- }
+ {
+ int new_len = -1;
+ handle_v_requests (cs.own_buf, len, &new_len);
+ if (new_len != -1)
+ putpkt_binary (cs.own_buf, new_len);
+ else
+ putpkt (cs.own_buf);
+ }
else
- break;
+ break;
len = getpkt (cs.own_buf);
if (len < 0)
- return -1;
+ return -1;
}
if (!startswith (cs.own_buf, "qSymbol:"))
@@ -1538,8 +1538,7 @@ relocate_instruction (CORE_ADDR *to, CORE_ADDR oldloc)
ULONGEST written = 0;
/* Send the request. */
- sprintf (cs.own_buf, "qRelocInsn:%s;%s", paddress (oldloc),
- paddress (*to));
+ sprintf (cs.own_buf, "qRelocInsn:%s;%s", paddress (oldloc), paddress (*to));
if (putpkt (cs.own_buf) < 0)
return -1;
@@ -1559,50 +1558,50 @@ relocate_instruction (CORE_ADDR *to, CORE_ADDR oldloc)
unsigned int mem_len;
if (cs.own_buf[0] == 'm')
- {
- decode_m_packet (&cs.own_buf[1], &mem_addr, &mem_len);
- mem_buf = (unsigned char *) xmalloc (mem_len);
- if (read_inferior_memory (mem_addr, mem_buf, mem_len) == 0)
- bin2hex (mem_buf, cs.own_buf, mem_len);
- else
- write_enn (cs.own_buf);
- }
+ {
+ decode_m_packet (&cs.own_buf[1], &mem_addr, &mem_len);
+ mem_buf = (unsigned char *) xmalloc (mem_len);
+ if (read_inferior_memory (mem_addr, mem_buf, mem_len) == 0)
+ bin2hex (mem_buf, cs.own_buf, mem_len);
+ else
+ write_enn (cs.own_buf);
+ }
else if (cs.own_buf[0] == 'X')
- {
- if (decode_X_packet (&cs.own_buf[1], len - 1, &mem_addr,
- &mem_len, &mem_buf) < 0
- || target_write_memory (mem_addr, mem_buf, mem_len) != 0)
- write_enn (cs.own_buf);
- else
- write_ok (cs.own_buf);
- }
+ {
+ if (decode_X_packet (&cs.own_buf[1], len - 1, &mem_addr, &mem_len,
+ &mem_buf)
+ < 0
+ || target_write_memory (mem_addr, mem_buf, mem_len) != 0)
+ write_enn (cs.own_buf);
+ else
+ write_ok (cs.own_buf);
+ }
else
- {
- decode_M_packet (&cs.own_buf[1], &mem_addr, &mem_len, &mem_buf);
- if (target_write_memory (mem_addr, mem_buf, mem_len) == 0)
- write_ok (cs.own_buf);
- else
- write_enn (cs.own_buf);
- }
+ {
+ decode_M_packet (&cs.own_buf[1], &mem_addr, &mem_len, &mem_buf);
+ if (target_write_memory (mem_addr, mem_buf, mem_len) == 0)
+ write_ok (cs.own_buf);
+ else
+ write_enn (cs.own_buf);
+ }
free (mem_buf);
if (putpkt (cs.own_buf) < 0)
- return -1;
+ return -1;
len = getpkt (cs.own_buf);
if (len < 0)
- return -1;
+ return -1;
}
if (cs.own_buf[0] == 'E')
{
warning ("An error occurred while relocating an instruction: %s",
- cs.own_buf);
+ cs.own_buf);
return -1;
}
if (!startswith (cs.own_buf, "qRelocInsn:"))
{
- warning ("Malformed response to qRelocInsn, ignoring: %s",
- cs.own_buf);
+ warning ("Malformed response to qRelocInsn, ignoring: %s", cs.own_buf);
return -1;
}
diff --git a/gdbserver/remote-utils.h b/gdbserver/remote-utils.h
index cb2d6c3..7a115fe 100644
--- a/gdbserver/remote-utils.h
+++ b/gdbserver/remote-utils.h
@@ -41,7 +41,7 @@ void enable_async_io (void);
void disable_async_io (void);
void check_remote_input_interrupt_request (void);
void prepare_resume_reply (char *buf, ptid_t ptid,
- const target_waitstatus &status);
+ const target_waitstatus &status);
const char *decode_address_to_semicolon (CORE_ADDR *addrp, const char *start);
void decode_address (CORE_ADDR *addrp, const char *start, int len);
@@ -51,22 +51,21 @@ void decode_address (CORE_ADDR *addrp, const char *start, int len);
"<MEM_ADDR_PTR>,<LEN_PTR><END_MARKER>", with END_MARKER being an end marker
character. */
const char *decode_m_packet_params (const char *from, CORE_ADDR *mem_addr_ptr,
- unsigned int *len_ptr,
- const char end_marker);
-void decode_m_packet (const char *from, CORE_ADDR * mem_addr_ptr,
- unsigned int *len_ptr);
-void decode_M_packet (const char *from, CORE_ADDR * mem_addr_ptr,
- unsigned int *len_ptr, unsigned char **to_p);
-int decode_X_packet (char *from, int packet_len, CORE_ADDR * mem_addr_ptr,
- unsigned int *len_ptr, unsigned char **to_p);
-int decode_xfer_write (char *buf, int packet_len,
- CORE_ADDR *offset, unsigned int *len,
- unsigned char *data);
+ unsigned int *len_ptr,
+ const char end_marker);
+void decode_m_packet (const char *from, CORE_ADDR *mem_addr_ptr,
+ unsigned int *len_ptr);
+void decode_M_packet (const char *from, CORE_ADDR *mem_addr_ptr,
+ unsigned int *len_ptr, unsigned char **to_p);
+int decode_X_packet (char *from, int packet_len, CORE_ADDR *mem_addr_ptr,
+ unsigned int *len_ptr, unsigned char **to_p);
+int decode_xfer_write (char *buf, int packet_len, CORE_ADDR *offset,
+ unsigned int *len, unsigned char *data);
int decode_search_memory_packet (const char *buf, int packet_len,
- CORE_ADDR *start_addrp,
- CORE_ADDR *search_space_lenp,
- gdb_byte *pattern,
- unsigned int *pattern_lenp);
+ CORE_ADDR *start_addrp,
+ CORE_ADDR *search_space_lenp,
+ gdb_byte *pattern,
+ unsigned int *pattern_lenp);
void clear_symbol_cache (struct sym_cache **symcache_p);
int look_up_one_symbol (const char *name, CORE_ADDR *addrp, int may_ask_gdb);
diff --git a/gdbserver/server.cc b/gdbserver/server.cc
index 21fb51a..f9327ab 100644
--- a/gdbserver/server.cc
+++ b/gdbserver/server.cc
@@ -51,18 +51,18 @@
#include "gdbsupport/scoped_restore.h"
#include "gdbsupport/search.h"
-#define require_running_or_return(BUF) \
- if (!target_running ()) \
- { \
- write_enn (BUF); \
- return; \
+#define require_running_or_return(BUF) \
+ if (!target_running ()) \
+ { \
+ write_enn (BUF); \
+ return; \
}
-#define require_running_or_break(BUF) \
- if (!target_running ()) \
- { \
- write_enn (BUF); \
- break; \
+#define require_running_or_break(BUF) \
+ if (!target_running ()) \
+ { \
+ write_enn (BUF); \
+ break; \
}
/* The environment to pass to the inferior when creating it. */
@@ -87,7 +87,8 @@ static bool keep_processing_events = true;
bool non_stop;
-static struct {
+static struct
+{
/* Set the PROGRAM_PATH. Here we adjust the path of the provided
binary if needed. */
void set (const char *path)
@@ -98,19 +99,18 @@ static struct {
creating it. */
if (!contains_dir_separator (m_path.c_str ()))
{
- int reg_file_errno;
+ int reg_file_errno;
- /* Check if the file is in our CWD. If it is, then we prefix
+ /* Check if the file is in our CWD. If it is, then we prefix
its name with CURRENT_DIRECTORY. Otherwise, we leave the
name as-is because we'll try searching for it in $PATH. */
- if (is_regular_file (m_path.c_str (), &reg_file_errno))
- m_path = gdb_abspath (m_path.c_str ());
+ if (is_regular_file (m_path.c_str (), &reg_file_errno))
+ m_path = gdb_abspath (m_path.c_str ());
}
}
/* Return the PROGRAM_PATH. */
- const char *get ()
- { return m_path.empty () ? nullptr : m_path.c_str (); }
+ const char *get () { return m_path.empty () ? nullptr : m_path.c_str (); }
private:
/* The program name, adjusted if needed. */
@@ -165,7 +165,6 @@ get_client_state ()
return cs;
}
-
/* Put a stop reply to the stop reply queue. */
static void
@@ -200,19 +199,19 @@ discard_queued_stop_replies (ptid_t ptid)
++next;
if (iter == notif_stop.queue.begin ())
- {
- /* The head of the list contains the notification that was
+ {
+ /* The head of the list contains the notification that was
already sent to GDB. So we can't remove it, otherwise
when GDB sends the vStopped, it would ack the _next_
notification, which hadn't been sent yet! */
- continue;
- }
+ continue;
+ }
if (remove_all_on_match_ptid (*iter, ptid))
- {
- delete *iter;
- notif_stop.queue.erase (iter);
- }
+ {
+ delete *iter;
+ notif_stop.queue.erase (iter);
+ }
}
}
@@ -251,15 +250,17 @@ in_queued_stop_replies (ptid_t ptid)
for (notif_event *event : notif_stop.queue)
{
if (in_queued_stop_replies_ptid (event, ptid))
- return true;
+ return true;
}
return false;
}
-struct notif_server notif_stop =
-{
- "vStopped", "Stop", {}, vstop_notif_reply,
+struct notif_server notif_stop = {
+ "vStopped",
+ "Stop",
+ {},
+ vstop_notif_reply,
};
static int
@@ -282,7 +283,7 @@ const char *
get_exec_file (int err)
{
if (err && program_path.get () == NULL)
- error (_("No executable file specified."));
+ error (_ ("No executable file specified."));
return program_path.get ();
}
@@ -324,8 +325,8 @@ attach_inferior (int pid)
process using the "attach" command, but this is different; it's
just using "target remote". Pretend it's just starting up. */
if (cs.last_status.kind () == TARGET_WAITKIND_STOPPED
- && cs.last_status.sig () == GDB_SIGNAL_STOP)
- cs.last_status.set_stopped (GDB_SIGNAL_TRAP);
+ && cs.last_status.sig () == GDB_SIGNAL_STOP)
+ cs.last_status.set_stopped (GDB_SIGNAL_TRAP);
current_thread->last_resume_kind = resume_stop;
current_thread->last_status = cs.last_status;
@@ -393,7 +394,8 @@ write_qxfer_response (char *buf, const gdb_byte *data, int len, int is_more)
buf[0] = 'l';
return remote_escape_output (data, len, 1, (unsigned char *) buf + 1,
- &out_len, PBUFSIZ - 2) + 1;
+ &out_len, PBUFSIZ - 2)
+ + 1;
}
/* Handle btrace enabling in BTS format. */
@@ -402,7 +404,7 @@ static void
handle_btrace_enable_bts (struct thread_info *thread)
{
if (thread->btrace != NULL)
- error (_("Btrace already enabled."));
+ error (_ ("Btrace already enabled."));
current_btrace_conf.format = BTRACE_FORMAT_BTS;
thread->btrace = target_enable_btrace (thread, &current_btrace_conf);
@@ -414,7 +416,7 @@ static void
handle_btrace_enable_pt (struct thread_info *thread)
{
if (thread->btrace != NULL)
- error (_("Btrace already enabled."));
+ error (_ ("Btrace already enabled."));
current_btrace_conf.format = BTRACE_FORMAT_PT;
thread->btrace = target_enable_btrace (thread, &current_btrace_conf);
@@ -425,12 +427,11 @@ handle_btrace_enable_pt (struct thread_info *thread)
static void
handle_btrace_disable (struct thread_info *thread)
{
-
if (thread->btrace == NULL)
- error (_("Branch tracing not enabled."));
+ error (_ ("Branch tracing not enabled."));
if (target_disable_btrace (thread->btrace) != 0)
- error (_("Could not disable branch tracing."));
+ error (_ ("Could not disable branch tracing."));
thread->btrace = NULL;
}
@@ -449,8 +450,7 @@ handle_btrace_general_set (char *own_buf)
op = own_buf + strlen ("Qbtrace:");
- if (cs.general_thread == null_ptid
- || cs.general_thread == minus_one_ptid)
+ if (cs.general_thread == null_ptid || cs.general_thread == minus_one_ptid)
{
strcpy (own_buf, "E.Must select a single thread.");
return -1;
@@ -466,13 +466,13 @@ handle_btrace_general_set (char *own_buf)
try
{
if (strcmp (op, "bts") == 0)
- handle_btrace_enable_bts (thread);
+ handle_btrace_enable_bts (thread);
else if (strcmp (op, "pt") == 0)
- handle_btrace_enable_pt (thread);
+ handle_btrace_enable_pt (thread);
else if (strcmp (op, "off") == 0)
- handle_btrace_disable (thread);
+ handle_btrace_disable (thread);
else
- error (_("Bad Qbtrace operation. Use bts, pt, or off."));
+ error (_ ("Bad Qbtrace operation. Use bts, pt, or off."));
write_ok (own_buf);
}
@@ -498,8 +498,7 @@ handle_btrace_conf_general_set (char *own_buf)
op = own_buf + strlen ("Qbtrace-conf:");
- if (cs.general_thread == null_ptid
- || cs.general_thread == minus_one_ptid)
+ if (cs.general_thread == null_ptid || cs.general_thread == minus_one_ptid)
{
strcpy (own_buf, "E.Must select a single thread.");
return -1;
@@ -520,10 +519,10 @@ handle_btrace_conf_general_set (char *own_buf)
errno = 0;
size = strtoul (op + strlen ("bts:size="), &endp, 16);
if (endp == NULL || *endp != 0 || errno != 0 || size > UINT_MAX)
- {
- strcpy (own_buf, "E.Bad size value.");
- return -1;
- }
+ {
+ strcpy (own_buf, "E.Bad size value.");
+ return -1;
+ }
current_btrace_conf.bts.size = (unsigned int) size;
}
@@ -535,10 +534,10 @@ handle_btrace_conf_general_set (char *own_buf)
errno = 0;
size = strtoul (op + strlen ("pt:size="), &endp, 16);
if (endp == NULL || *endp != 0 || errno != 0 || size > UINT_MAX)
- {
- strcpy (own_buf, "E.Bad size value.");
- return -1;
- }
+ {
+ strcpy (own_buf, "E.Bad size value.");
+ return -1;
+ }
current_btrace_conf.pt.size = (unsigned int) size;
}
@@ -581,7 +580,7 @@ create_fetch_memtags_reply (char *reply, const gdb::byte_vector &tags)
static bool
parse_store_memtags_request (char *request, CORE_ADDR *addr, size_t *len,
- gdb::byte_vector &tags, int *type)
+ gdb::byte_vector &tags, int *type)
{
gdb_assert (startswith (request, "QMemTags:"));
@@ -624,19 +623,19 @@ handle_general_set (char *own_buf)
p = decode_address_to_semicolon (&cursig, p);
for (i = 0; i < numsigs; i++)
- {
- if (i == cursig)
- {
- cs.pass_signals[i] = 1;
- if (*p == '\0')
- /* Keep looping, to clear the remaining signals. */
- cursig = -1;
- else
- p = decode_address_to_semicolon (&cursig, p);
- }
- else
- cs.pass_signals[i] = 0;
- }
+ {
+ if (i == cursig)
+ {
+ cs.pass_signals[i] = 1;
+ if (*p == '\0')
+ /* Keep looping, to clear the remaining signals. */
+ cursig = -1;
+ else
+ p = decode_address_to_semicolon (&cursig, p);
+ }
+ else
+ cs.pass_signals[i] = 0;
+ }
strcpy (own_buf, "OK");
return;
}
@@ -651,19 +650,19 @@ handle_general_set (char *own_buf)
p = decode_address_to_semicolon (&cursig, p);
for (i = 0; i < numsigs; i++)
- {
- if (i == cursig)
- {
- cs.program_signals[i] = 1;
- if (*p == '\0')
- /* Keep looping, to clear the remaining signals. */
- cursig = -1;
- else
- p = decode_address_to_semicolon (&cursig, p);
- }
- else
- cs.program_signals[i] = 0;
- }
+ {
+ if (i == cursig)
+ {
+ cs.program_signals[i] = 1;
+ if (*p == '\0')
+ /* Keep looping, to clear the remaining signals. */
+ cursig = -1;
+ else
+ p = decode_address_to_semicolon (&cursig, p);
+ }
+ else
+ cs.program_signals[i] = 0;
+ }
strcpy (own_buf, "OK");
return;
}
@@ -676,41 +675,41 @@ handle_general_set (char *own_buf)
struct process_info *process;
if (!target_running () || !target_supports_catch_syscall ())
- {
- write_enn (own_buf);
- return;
- }
+ {
+ write_enn (own_buf);
+ return;
+ }
if (strcmp (p, "0") == 0)
- enabled = 0;
+ enabled = 0;
else if (p[0] == '1' && (p[1] == ';' || p[1] == '\0'))
- enabled = 1;
+ enabled = 1;
else
- {
- fprintf (stderr, "Unknown catch-syscalls mode requested: %s\n",
- own_buf);
- write_enn (own_buf);
- return;
- }
+ {
+ fprintf (stderr, "Unknown catch-syscalls mode requested: %s\n",
+ own_buf);
+ write_enn (own_buf);
+ return;
+ }
process = current_process ();
process->syscalls_to_catch.clear ();
if (enabled)
- {
- p += 1;
- if (*p == ';')
- {
- p += 1;
- while (*p != '\0')
- {
- p = decode_address_to_semicolon (&sysno, p);
- process->syscalls_to_catch.push_back (sysno);
- }
- }
- else
- process->syscalls_to_catch.push_back (ANY_SYSCALL);
- }
+ {
+ p += 1;
+ if (*p == ';')
+ {
+ p += 1;
+ while (*p != '\0')
+ {
+ p = decode_address_to_semicolon (&sysno, p);
+ process->syscalls_to_catch.push_back (sysno);
+ }
+ }
+ else
+ process->syscalls_to_catch.push_back (ANY_SYSCALL);
+ }
write_ok (own_buf);
return;
@@ -734,16 +733,16 @@ handle_general_set (char *own_buf)
remote_debug_printf ("[QEnvironmentHexEncoded received '%s']", p);
remote_debug_printf ("[Environment variable to be set: '%s']",
- final_var.c_str ());
+ final_var.c_str ());
size_t pos = final_var.find ('=');
if (pos == std::string::npos)
- {
- warning (_("Unexpected format for environment variable: '%s'"),
- final_var.c_str ());
- write_enn (own_buf);
- return;
- }
+ {
+ warning (_ ("Unexpected format for environment variable: '%s'"),
+ final_var.c_str ());
+ write_enn (own_buf);
+ return;
+ }
var_name = final_var.substr (0, pos);
var_value = final_var.substr (pos + 1, std::string::npos);
@@ -761,7 +760,7 @@ handle_general_set (char *own_buf)
remote_debug_printf ("[QEnvironmentUnset received '%s']", p);
remote_debug_printf ("[Environment variable to be unset: '%s']",
- varname.c_str ());
+ varname.c_str ());
our_environ.unset (varname.c_str ());
@@ -785,26 +784,25 @@ handle_general_set (char *own_buf)
const char *req_str;
if (strcmp (mode, "0") == 0)
- req = 0;
+ req = 0;
else if (strcmp (mode, "1") == 0)
- req = 1;
+ req = 1;
else
- {
- /* We don't know what this mode is, so complain to
+ {
+ /* We don't know what this mode is, so complain to
GDB. */
- fprintf (stderr, "Unknown non-stop mode requested: %s\n",
- own_buf);
- write_enn (own_buf);
- return;
- }
+ fprintf (stderr, "Unknown non-stop mode requested: %s\n", own_buf);
+ write_enn (own_buf);
+ return;
+ }
req_str = req ? "non-stop" : "all-stop";
if (the_target->start_non_stop (req == 1) != 0)
- {
- fprintf (stderr, "Setting %s mode failed\n", req_str);
- write_enn (own_buf);
- return;
- }
+ {
+ fprintf (stderr, "Setting %s mode failed\n", req_str);
+ write_enn (own_buf);
+ return;
+ }
non_stop = (req != 0);
@@ -823,8 +821,8 @@ handle_general_set (char *own_buf)
cs.disable_randomization = setting;
remote_debug_printf (cs.disable_randomization
- ? "[address space randomization disabled]"
- : "[address space randomization enabled]");
+ ? "[address space randomization disabled]"
+ : "[address space randomization enabled]");
write_ok (own_buf);
return;
@@ -840,15 +838,15 @@ handle_general_set (char *own_buf)
int req = 0;
if (strcmp (mode, "0") == 0)
- req = 0;
+ req = 0;
else if (strcmp (mode, "1") == 0)
- req = 1;
+ req = 1;
else
- {
- /* We don't know what this value is, so complain to GDB. */
- sprintf (own_buf, "E.Unknown QAgent value");
- return;
- }
+ {
+ /* We don't know what this value is, so complain to GDB. */
+ sprintf (own_buf, "E.Unknown QAgent value");
+ return;
+ }
/* Update the flag. */
use_agent = req;
@@ -869,23 +867,23 @@ handle_general_set (char *own_buf)
enum tribool req = TRIBOOL_UNKNOWN;
if (strcmp (mode, "0") == 0)
- req = TRIBOOL_FALSE;
+ req = TRIBOOL_FALSE;
else if (strcmp (mode, "1") == 0)
- req = TRIBOOL_TRUE;
+ req = TRIBOOL_TRUE;
else
- {
- /* We don't know what this mode is, so complain to GDB. */
- std::string err
- = string_printf ("E.Unknown thread-events mode requested: %s\n",
- mode);
- strcpy (own_buf, err.c_str ());
- return;
- }
+ {
+ /* We don't know what this mode is, so complain to GDB. */
+ std::string err
+ = string_printf ("E.Unknown thread-events mode requested: %s\n",
+ mode);
+ strcpy (own_buf, err.c_str ());
+ return;
+ }
cs.report_thread_events = (req == TRIBOOL_TRUE);
remote_debug_printf ("[thread events are now %s]\n",
- cs.report_thread_events ? "enabled" : "disabled");
+ cs.report_thread_events ? "enabled" : "disabled");
write_ok (own_buf);
return;
@@ -896,20 +894,20 @@ handle_general_set (char *own_buf)
const char *value = own_buf + strlen ("QStartupWithShell:");
if (strcmp (value, "1") == 0)
- startup_with_shell = true;
+ startup_with_shell = true;
else if (strcmp (value, "0") == 0)
- startup_with_shell = false;
+ startup_with_shell = false;
else
- {
- /* Unknown value. */
- fprintf (stderr, "Unknown value to startup-with-shell: %s\n",
- own_buf);
- write_enn (own_buf);
- return;
- }
+ {
+ /* Unknown value. */
+ fprintf (stderr, "Unknown value to startup-with-shell: %s\n",
+ own_buf);
+ write_enn (own_buf);
+ return;
+ }
remote_debug_printf ("[Inferior will %s started with shell]",
- startup_with_shell ? "be" : "not be");
+ startup_with_shell ? "be" : "not be");
write_ok (own_buf);
return;
@@ -920,32 +918,30 @@ handle_general_set (char *own_buf)
const char *p = own_buf + strlen ("QSetWorkingDir:");
if (*p != '\0')
- {
- std::string path = hex2str (p);
+ {
+ std::string path = hex2str (p);
- remote_debug_printf ("[Set the inferior's current directory to %s]",
- path.c_str ());
+ remote_debug_printf ("[Set the inferior's current directory to %s]",
+ path.c_str ());
- set_inferior_cwd (std::move (path));
- }
+ set_inferior_cwd (std::move (path));
+ }
else
- {
- /* An empty argument means that we should clear out any
+ {
+ /* An empty argument means that we should clear out any
previously set cwd for the inferior. */
- set_inferior_cwd ("");
+ set_inferior_cwd ("");
- remote_debug_printf ("[Unset the inferior's current directory; will "
- "use gdbserver's cwd]");
- }
+ remote_debug_printf ("[Unset the inferior's current directory; will "
+ "use gdbserver's cwd]");
+ }
write_ok (own_buf);
return;
}
-
/* Handle store memory tags packets. */
- if (startswith (own_buf, "QMemTags:")
- && target_supports_memory_tagging ())
+ if (startswith (own_buf, "QMemTags:") && target_supports_memory_tagging ())
{
gdb::byte_vector tags;
CORE_ADDR addr = 0;
@@ -954,16 +950,16 @@ handle_general_set (char *own_buf)
require_running_or_return (own_buf);
- bool ret = parse_store_memtags_request (own_buf, &addr, &len, tags,
- &type);
+ bool ret
+ = parse_store_memtags_request (own_buf, &addr, &len, tags, &type);
if (ret)
- ret = the_target->store_memtags (addr, len, tags, type);
+ ret = the_target->store_memtags (addr, len, tags, type);
if (!ret)
- write_enn (own_buf);
+ write_enn (own_buf);
else
- write_ok (own_buf);
+ write_ok (own_buf);
return;
}
@@ -991,9 +987,9 @@ get_features_xml (const char *annex)
const char *ret = tdesc_get_features_xml (desc);
if (*ret == '@')
- return ret + 1;
+ return ret + 1;
else
- annex = ret;
+ annex = ret;
}
#ifdef USE_XML
@@ -1003,7 +999,7 @@ get_features_xml (const char *annex)
/* Look for the annex. */
for (i = 0; xml_builtin[i][0] != NULL; i++)
if (strcmp (annex, xml_builtin[i][0]) == 0)
- break;
+ break;
if (xml_builtin[i][0] != NULL)
return xml_builtin[i][1];
@@ -1055,14 +1051,14 @@ gdb_read_memory (CORE_ADDR memaddr, unsigned char *myaddr, int len)
ULONGEST nbytes;
ULONGEST length = len;
- if (traceframe_read_mem (cs.current_traceframe,
- memaddr, myaddr, len, &nbytes))
- return -1;
+ if (traceframe_read_mem (cs.current_traceframe, memaddr, myaddr, len,
+ &nbytes))
+ return -1;
/* Data read from trace buffer, we're done. */
if (nbytes > 0)
- return nbytes;
+ return nbytes;
if (!in_readonly_region (memaddr, length))
- return -1;
+ return -1;
/* Otherwise we have a valid readonly case, fall through. */
/* (assume no half-trace half-real blocks for now) */
}
@@ -1089,9 +1085,9 @@ gdb_write_memory (CORE_ADDR memaddr, const unsigned char *myaddr, int len)
int ret;
if (set_desired_process ())
- ret = target_write_memory (memaddr, myaddr, len);
+ ret = target_write_memory (memaddr, myaddr, len);
else
- ret = EIO;
+ ret = EIO;
return ret;
}
}
@@ -1114,21 +1110,20 @@ handle_search_memory (char *own_buf, int packet_len)
error ("Unable to allocate memory to perform the search");
if (decode_search_memory_packet (own_buf + cmd_name_len,
- packet_len - cmd_name_len,
- &start_addr, &search_space_len,
- pattern, &pattern_len) < 0)
+ packet_len - cmd_name_len, &start_addr,
+ &search_space_len, pattern, &pattern_len)
+ < 0)
{
free (pattern);
error ("Error in parsing qSearch:memory packet");
}
- auto read_memory = [] (CORE_ADDR addr, gdb_byte *result, size_t len)
- {
- return gdb_read_memory (addr, result, len) == len;
- };
+ auto read_memory = [] (CORE_ADDR addr, gdb_byte *result, size_t len) {
+ return gdb_read_memory (addr, result, len) == len;
+ };
found = simple_search_memory (read_memory, start_addr, search_space_len,
- pattern, pattern_len, &found_addr);
+ pattern, pattern_len, &found_addr);
if (found > 0)
sprintf (own_buf, "1,%lx", (long) found_addr);
@@ -1158,9 +1153,9 @@ handle_detach (char *own_buf)
}
else
{
- process = (current_thread != nullptr
- ? get_thread_process (current_thread)
- : nullptr);
+ process
+ = (current_thread != nullptr ? get_thread_process (current_thread)
+ : nullptr);
}
if (process == NULL)
@@ -1172,14 +1167,12 @@ handle_detach (char *own_buf)
if ((tracing && disconnected_tracing) || any_persistent_commands (process))
{
if (tracing && disconnected_tracing)
- fprintf (stderr,
- "Disconnected tracing in effect, "
- "leaving gdbserver attached to the process\n");
+ fprintf (stderr, "Disconnected tracing in effect, "
+ "leaving gdbserver attached to the process\n");
if (any_persistent_commands (process))
- fprintf (stderr,
- "Persistent commands are present, "
- "leaving gdbserver attached to the process\n");
+ fprintf (stderr, "Persistent commands are present, "
+ "leaving gdbserver attached to the process\n");
/* Make sure we're in non-stop/async mode, so we we can both
wait for an async socket accept, and handle async target
@@ -1187,12 +1180,12 @@ handle_detach (char *own_buf)
having the target stop all threads, when we're going to
pass signals down without informing GDB. */
if (!non_stop)
- {
- threads_debug_printf ("Forcing non-stop mode");
+ {
+ threads_debug_printf ("Forcing non-stop mode");
- non_stop = true;
- the_target->start_non_stop (true);
- }
+ non_stop = true;
+ the_target->start_non_stop (true);
+ }
process->gdb_detached = 1;
@@ -1220,12 +1213,12 @@ handle_detach (char *own_buf)
{
/* Only threads that are of the process we are detaching. */
if (thread->id.pid () != pid)
- continue;
+ continue;
/* Only threads that have a pending fork event. */
thread_info *child = target_thread_pending_child (thread);
if (child == nullptr)
- continue;
+ continue;
process_info *fork_child_process = get_thread_process (child);
gdb_assert (fork_child_process != nullptr);
@@ -1233,9 +1226,9 @@ handle_detach (char *own_buf)
int fork_child_pid = fork_child_process->pid;
if (detach_inferior (fork_child_process) != 0)
- warning (_("Failed to detach fork child %s, child of %s"),
- target_pid_to_str (ptid_t (fork_child_pid)).c_str (),
- target_pid_to_str (thread->id).c_str ());
+ warning (_ ("Failed to detach fork child %s, child of %s"),
+ target_pid_to_str (ptid_t (fork_child_pid)).c_str (),
+ target_pid_to_str (thread->id).c_str ());
}
if (detach_inferior (process) != 0)
@@ -1246,26 +1239,26 @@ handle_detach (char *own_buf)
write_ok (own_buf);
if (extended_protocol || target_running ())
- {
- /* There is still at least one inferior remaining or
+ {
+ /* There is still at least one inferior remaining or
we are in extended mode, so don't terminate gdbserver,
and instead treat this like a normal program exit. */
- cs.last_status.set_exited (0);
- cs.last_ptid = ptid_t (pid);
+ cs.last_status.set_exited (0);
+ cs.last_ptid = ptid_t (pid);
- switch_to_thread (nullptr);
- }
+ switch_to_thread (nullptr);
+ }
else
- {
- putpkt (own_buf);
- remote_close ();
+ {
+ putpkt (own_buf);
+ remote_close ();
- /* If we are attached, then we can exit. Otherwise, we
+ /* If we are attached, then we can exit. Otherwise, we
need to hang around doing nothing, until the child is
gone. */
- join_inferior (pid);
- exit (0);
- }
+ join_inferior (pid);
+ exit (0);
+ }
}
}
@@ -1302,31 +1295,31 @@ parse_debug_format_options (const char *arg, int is_monitor)
for (const gdb::unique_xmalloc_ptr<char> &option : options)
{
if (strcmp (option.get (), "all") == 0)
- {
- debug_timestamp = 1;
- if (is_monitor)
- monitor_output ("All extra debug format options enabled.\n");
- }
+ {
+ debug_timestamp = 1;
+ if (is_monitor)
+ monitor_output ("All extra debug format options enabled.\n");
+ }
else if (strcmp (option.get (), "none") == 0)
- {
- debug_timestamp = 0;
- if (is_monitor)
- monitor_output ("All extra debug format options disabled.\n");
- }
+ {
+ debug_timestamp = 0;
+ if (is_monitor)
+ monitor_output ("All extra debug format options disabled.\n");
+ }
else if (strcmp (option.get (), "timestamp") == 0)
- {
- debug_timestamp = 1;
- if (is_monitor)
- monitor_output ("Timestamps will be added to debug output.\n");
- }
+ {
+ debug_timestamp = 1;
+ if (is_monitor)
+ monitor_output ("Timestamps will be added to debug output.\n");
+ }
else if (*option == '\0')
- {
- /* An empty option, e.g., "--debug-format=foo,,bar", is ignored. */
- continue;
- }
+ {
+ /* An empty option, e.g., "--debug-format=foo,,bar", is ignored. */
+ continue;
+ }
else
- return string_printf ("Unknown debug-format argument: \"%s\"\n",
- option.get ());
+ return string_printf ("Unknown debug-format argument: \"%s\"\n",
+ option.get ());
}
return std::string ();
@@ -1380,15 +1373,15 @@ handle_monitor_command (char *mon, char *own_buf)
else if (startswith (mon, "set debug-format "))
{
std::string error_msg
- = parse_debug_format_options (mon + sizeof ("set debug-format ") - 1,
- 1);
+ = parse_debug_format_options (mon + sizeof ("set debug-format ") - 1,
+ 1);
if (!error_msg.empty ())
- {
- monitor_output (error_msg.c_str ());
- monitor_show_help ();
- write_enn (own_buf);
- }
+ {
+ monitor_output (error_msg.c_str ());
+ monitor_show_help ();
+ write_enn (own_buf);
+ }
}
else if (strcmp (mon, "set debug-file") == 0)
debug_set_output (nullptr);
@@ -1425,17 +1418,15 @@ struct qxfer
not indicate the end of the object, only the end of the transfer.
One, and only one, of readbuf or writebuf must be non-NULL. */
- int (*xfer) (const char *annex,
- gdb_byte *readbuf, const gdb_byte *writebuf,
- ULONGEST offset, LONGEST len);
+ int (*xfer) (const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf,
+ ULONGEST offset, LONGEST len);
};
/* Handle qXfer:auxv:read. */
static int
-handle_qxfer_auxv (const char *annex,
- gdb_byte *readbuf, const gdb_byte *writebuf,
- ULONGEST offset, LONGEST len)
+handle_qxfer_auxv (const char *annex, gdb_byte *readbuf,
+ const gdb_byte *writebuf, ULONGEST offset, LONGEST len)
{
if (!the_target->supports_read_auxv () || writebuf != NULL)
return -2;
@@ -1444,15 +1435,14 @@ handle_qxfer_auxv (const char *annex,
return -1;
return the_target->read_auxv (current_thread->id.pid (), offset, readbuf,
- len);
+ len);
}
/* Handle qXfer:exec-file:read. */
static int
-handle_qxfer_exec_file (const char *annex,
- gdb_byte *readbuf, const gdb_byte *writebuf,
- ULONGEST offset, LONGEST len)
+handle_qxfer_exec_file (const char *annex, gdb_byte *readbuf,
+ const gdb_byte *writebuf, ULONGEST offset, LONGEST len)
{
ULONGEST pid;
int total_len;
@@ -1463,7 +1453,7 @@ handle_qxfer_exec_file (const char *annex,
if (annex[0] == '\0')
{
if (current_thread == NULL)
- return -1;
+ return -1;
pid = pid_of (current_thread);
}
@@ -1471,7 +1461,7 @@ handle_qxfer_exec_file (const char *annex,
{
annex = unpack_varlen_hex (annex, &pid);
if (annex[0] != '\0')
- return -1;
+ return -1;
}
if (pid <= 0)
@@ -1496,9 +1486,8 @@ handle_qxfer_exec_file (const char *annex,
/* Handle qXfer:features:read. */
static int
-handle_qxfer_features (const char *annex,
- gdb_byte *readbuf, const gdb_byte *writebuf,
- ULONGEST offset, LONGEST len)
+handle_qxfer_features (const char *annex, gdb_byte *readbuf,
+ const gdb_byte *writebuf, ULONGEST offset, LONGEST len)
{
const char *document;
size_t total_len;
@@ -1529,9 +1518,8 @@ handle_qxfer_features (const char *annex,
/* Handle qXfer:libraries:read. */
static int
-handle_qxfer_libraries (const char *annex,
- gdb_byte *readbuf, const gdb_byte *writebuf,
- ULONGEST offset, LONGEST len)
+handle_qxfer_libraries (const char *annex, gdb_byte *readbuf,
+ const gdb_byte *writebuf, ULONGEST offset, LONGEST len)
{
if (writebuf != NULL)
return -2;
@@ -1543,9 +1531,9 @@ handle_qxfer_libraries (const char *annex,
process_info *proc = current_process ();
for (const dll_info &dll : proc->all_dlls)
- document += string_printf
- (" <library name=\"%s\"><segment address=\"0x%s\"/></library>\n",
- dll.name.c_str (), paddress (dll.base_addr));
+ document += string_printf (
+ " <library name=\"%s\"><segment address=\"0x%s\"/></library>\n",
+ dll.name.c_str (), paddress (dll.base_addr));
document += "</library-list>\n";
@@ -1563,27 +1551,25 @@ handle_qxfer_libraries (const char *annex,
/* Handle qXfer:libraries-svr4:read. */
static int
-handle_qxfer_libraries_svr4 (const char *annex,
- gdb_byte *readbuf, const gdb_byte *writebuf,
- ULONGEST offset, LONGEST len)
+handle_qxfer_libraries_svr4 (const char *annex, gdb_byte *readbuf,
+ const gdb_byte *writebuf, ULONGEST offset,
+ LONGEST len)
{
if (writebuf != NULL)
return -2;
- if (current_thread == NULL
- || !the_target->supports_qxfer_libraries_svr4 ())
+ if (current_thread == NULL || !the_target->supports_qxfer_libraries_svr4 ())
return -1;
- return the_target->qxfer_libraries_svr4 (annex, readbuf, writebuf,
- offset, len);
+ return the_target->qxfer_libraries_svr4 (annex, readbuf, writebuf, offset,
+ len);
}
/* Handle qXfer:osadata:read. */
static int
-handle_qxfer_osdata (const char *annex,
- gdb_byte *readbuf, const gdb_byte *writebuf,
- ULONGEST offset, LONGEST len)
+handle_qxfer_osdata (const char *annex, gdb_byte *readbuf,
+ const gdb_byte *writebuf, ULONGEST offset, LONGEST len)
{
if (!the_target->supports_qxfer_osdata () || writebuf != NULL)
return -2;
@@ -1594,9 +1580,8 @@ handle_qxfer_osdata (const char *annex,
/* Handle qXfer:siginfo:read and qXfer:siginfo:write. */
static int
-handle_qxfer_siginfo (const char *annex,
- gdb_byte *readbuf, const gdb_byte *writebuf,
- ULONGEST offset, LONGEST len)
+handle_qxfer_siginfo (const char *annex, gdb_byte *readbuf,
+ const gdb_byte *writebuf, ULONGEST offset, LONGEST len)
{
if (!the_target->supports_qxfer_siginfo ())
return -2;
@@ -1610,9 +1595,9 @@ handle_qxfer_siginfo (const char *annex,
/* Handle qXfer:statictrace:read. */
static int
-handle_qxfer_statictrace (const char *annex,
- gdb_byte *readbuf, const gdb_byte *writebuf,
- ULONGEST offset, LONGEST len)
+handle_qxfer_statictrace (const char *annex, gdb_byte *readbuf,
+ const gdb_byte *writebuf, ULONGEST offset,
+ LONGEST len)
{
client_state &cs = get_client_state ();
ULONGEST nbytes;
@@ -1620,12 +1605,12 @@ handle_qxfer_statictrace (const char *annex,
if (writebuf != NULL)
return -2;
- if (annex[0] != '\0' || current_thread == NULL
+ if (annex[0] != '\0' || current_thread == NULL
|| cs.current_traceframe == -1)
return -1;
- if (traceframe_read_sdata (cs.current_traceframe, offset,
- readbuf, len, &nbytes))
+ if (traceframe_read_sdata (cs.current_traceframe, offset, readbuf, len,
+ &nbytes))
return -1;
return nbytes;
}
@@ -1692,10 +1677,9 @@ handle_qxfer_threads_proper (struct buffer *buffer)
if (non_stop)
target_pause_all (true);
- for_each_thread ([&] (thread_info *thread)
- {
- handle_qxfer_threads_worker (thread, buffer);
- });
+ for_each_thread ([&] (thread_info *thread) {
+ handle_qxfer_threads_worker (thread, buffer);
+ });
if (non_stop)
target_unpause_all (true);
@@ -1707,9 +1691,8 @@ handle_qxfer_threads_proper (struct buffer *buffer)
/* Handle qXfer:threads:read. */
static int
-handle_qxfer_threads (const char *annex,
- gdb_byte *readbuf, const gdb_byte *writebuf,
- ULONGEST offset, LONGEST len)
+handle_qxfer_threads (const char *annex, gdb_byte *readbuf,
+ const gdb_byte *writebuf, ULONGEST offset, LONGEST len)
{
static char *result = 0;
static unsigned int result_length = 0;
@@ -1726,7 +1709,7 @@ handle_qxfer_threads (const char *annex,
/* When asked for data at offset 0, generate everything and store into
'result'. Successive reads will be served off 'result'. */
if (result)
- free (result);
+ free (result);
buffer_init (&buffer);
@@ -1737,7 +1720,7 @@ handle_qxfer_threads (const char *annex,
buffer_free (&buffer);
if (!res)
- return -1;
+ return -1;
}
if (offset >= result_length)
@@ -1760,9 +1743,9 @@ handle_qxfer_threads (const char *annex,
/* Handle qXfer:traceframe-info:read. */
static int
-handle_qxfer_traceframe_info (const char *annex,
- gdb_byte *readbuf, const gdb_byte *writebuf,
- ULONGEST offset, LONGEST len)
+handle_qxfer_traceframe_info (const char *annex, gdb_byte *readbuf,
+ const gdb_byte *writebuf, ULONGEST offset,
+ LONGEST len)
{
client_state &cs = get_client_state ();
static char *result = 0;
@@ -1812,7 +1795,7 @@ handle_qxfer_traceframe_info (const char *annex,
static int
handle_qxfer_fdpic (const char *annex, gdb_byte *readbuf,
- const gdb_byte *writebuf, ULONGEST offset, LONGEST len)
+ const gdb_byte *writebuf, ULONGEST offset, LONGEST len)
{
if (!the_target->supports_read_loadmap ())
return -2;
@@ -1826,9 +1809,8 @@ handle_qxfer_fdpic (const char *annex, gdb_byte *readbuf,
/* Handle qXfer:btrace:read. */
static int
-handle_qxfer_btrace (const char *annex,
- gdb_byte *readbuf, const gdb_byte *writebuf,
- ULONGEST offset, LONGEST len)
+handle_qxfer_btrace (const char *annex, gdb_byte *readbuf,
+ const gdb_byte *writebuf, ULONGEST offset, LONGEST len)
{
client_state &cs = get_client_state ();
static struct buffer cache;
@@ -1839,8 +1821,7 @@ handle_qxfer_btrace (const char *annex,
if (writebuf != NULL)
return -2;
- if (cs.general_thread == null_ptid
- || cs.general_thread == minus_one_ptid)
+ if (cs.general_thread == null_ptid || cs.general_thread == minus_one_ptid)
{
strcpy (cs.own_buf, "E.Must select a single thread.");
return -3;
@@ -1876,19 +1857,19 @@ handle_qxfer_btrace (const char *annex,
buffer_free (&cache);
try
- {
- result = target_read_btrace (thread->btrace, &cache, type);
- if (result != 0)
- memcpy (cs.own_buf, cache.buffer, cache.used_size);
- }
+ {
+ result = target_read_btrace (thread->btrace, &cache, type);
+ if (result != 0)
+ memcpy (cs.own_buf, cache.buffer, cache.used_size);
+ }
catch (const gdb_exception_error &exception)
- {
- sprintf (cs.own_buf, "E.%s", exception.what ());
- result = -1;
- }
+ {
+ sprintf (cs.own_buf, "E.%s", exception.what ());
+ result = -1;
+ }
if (result != 0)
- return -3;
+ return -3;
}
else if (offset > cache.used_size)
{
@@ -1907,9 +1888,9 @@ handle_qxfer_btrace (const char *annex,
/* Handle qXfer:btrace-conf:read. */
static int
-handle_qxfer_btrace_conf (const char *annex,
- gdb_byte *readbuf, const gdb_byte *writebuf,
- ULONGEST offset, LONGEST len)
+handle_qxfer_btrace_conf (const char *annex, gdb_byte *readbuf,
+ const gdb_byte *writebuf, ULONGEST offset,
+ LONGEST len)
{
client_state &cs = get_client_state ();
static struct buffer cache;
@@ -1922,8 +1903,7 @@ handle_qxfer_btrace_conf (const char *annex,
if (annex[0] != '\0')
return -1;
- if (cs.general_thread == null_ptid
- || cs.general_thread == minus_one_ptid)
+ if (cs.general_thread == null_ptid || cs.general_thread == minus_one_ptid)
{
strcpy (cs.own_buf, "E.Must select a single thread.");
return -3;
@@ -1947,19 +1927,19 @@ handle_qxfer_btrace_conf (const char *annex,
buffer_free (&cache);
try
- {
- result = target_read_btrace_conf (thread->btrace, &cache);
- if (result != 0)
- memcpy (cs.own_buf, cache.buffer, cache.used_size);
- }
+ {
+ result = target_read_btrace_conf (thread->btrace, &cache);
+ if (result != 0)
+ memcpy (cs.own_buf, cache.buffer, cache.used_size);
+ }
catch (const gdb_exception_error &exception)
- {
- sprintf (cs.own_buf, "E.%s", exception.what ());
- result = -1;
- }
+ {
+ sprintf (cs.own_buf, "E.%s", exception.what ());
+ result = -1;
+ }
if (result != 0)
- return -3;
+ return -3;
}
else if (offset > cache.used_size)
{
@@ -1975,22 +1955,21 @@ handle_qxfer_btrace_conf (const char *annex,
return len;
}
-static const struct qxfer qxfer_packets[] =
- {
- { "auxv", handle_qxfer_auxv },
- { "btrace", handle_qxfer_btrace },
- { "btrace-conf", handle_qxfer_btrace_conf },
- { "exec-file", handle_qxfer_exec_file},
- { "fdpic", handle_qxfer_fdpic},
- { "features", handle_qxfer_features },
- { "libraries", handle_qxfer_libraries },
- { "libraries-svr4", handle_qxfer_libraries_svr4 },
- { "osdata", handle_qxfer_osdata },
- { "siginfo", handle_qxfer_siginfo },
- { "statictrace", handle_qxfer_statictrace },
- { "threads", handle_qxfer_threads },
- { "traceframe-info", handle_qxfer_traceframe_info },
- };
+static const struct qxfer qxfer_packets[] = {
+ { "auxv", handle_qxfer_auxv },
+ { "btrace", handle_qxfer_btrace },
+ { "btrace-conf", handle_qxfer_btrace_conf },
+ { "exec-file", handle_qxfer_exec_file },
+ { "fdpic", handle_qxfer_fdpic },
+ { "features", handle_qxfer_features },
+ { "libraries", handle_qxfer_libraries },
+ { "libraries-svr4", handle_qxfer_libraries_svr4 },
+ { "osdata", handle_qxfer_osdata },
+ { "siginfo", handle_qxfer_siginfo },
+ { "statictrace", handle_qxfer_statictrace },
+ { "threads", handle_qxfer_threads },
+ { "traceframe-info", handle_qxfer_traceframe_info },
+};
static int
handle_qxfer (char *own_buf, int packet_len, int *new_packet_len_p)
@@ -2011,101 +1990,102 @@ handle_qxfer (char *own_buf, int packet_len, int *new_packet_len_p)
return 1;
}
- for (i = 0;
- i < sizeof (qxfer_packets) / sizeof (qxfer_packets[0]);
- i++)
+ for (i = 0; i < sizeof (qxfer_packets) / sizeof (qxfer_packets[0]); i++)
{
const struct qxfer *q = &qxfer_packets[i];
if (strcmp (object, q->object) == 0)
- {
- if (strcmp (rw, "read") == 0)
- {
- unsigned char *data;
- int n;
- CORE_ADDR ofs;
- unsigned int len;
-
- /* Grab the offset and length. */
- if (decode_xfer_read (offset, &ofs, &len) < 0)
- {
- write_enn (own_buf);
- return 1;
- }
-
- /* Read one extra byte, as an indicator of whether there is
+ {
+ if (strcmp (rw, "read") == 0)
+ {
+ unsigned char *data;
+ int n;
+ CORE_ADDR ofs;
+ unsigned int len;
+
+ /* Grab the offset and length. */
+ if (decode_xfer_read (offset, &ofs, &len) < 0)
+ {
+ write_enn (own_buf);
+ return 1;
+ }
+
+ /* Read one extra byte, as an indicator of whether there is
more. */
- if (len > PBUFSIZ - 2)
- len = PBUFSIZ - 2;
- data = (unsigned char *) malloc (len + 1);
- if (data == NULL)
- {
- write_enn (own_buf);
- return 1;
- }
- n = (*q->xfer) (annex, data, NULL, ofs, len + 1);
- if (n == -2)
- {
- free (data);
- return 0;
- }
- else if (n == -3)
- {
- /* Preserve error message. */
- }
- else if (n < 0)
- write_enn (own_buf);
- else if (n > len)
- *new_packet_len_p = write_qxfer_response (own_buf, data, len, 1);
- else
- *new_packet_len_p = write_qxfer_response (own_buf, data, n, 0);
-
- free (data);
- return 1;
- }
- else if (strcmp (rw, "write") == 0)
- {
- int n;
- unsigned int len;
- CORE_ADDR ofs;
- unsigned char *data;
-
- strcpy (own_buf, "E00");
- data = (unsigned char *) malloc (packet_len - (offset - own_buf));
- if (data == NULL)
- {
- write_enn (own_buf);
- return 1;
- }
- if (decode_xfer_write (offset, packet_len - (offset - own_buf),
- &ofs, &len, data) < 0)
- {
- free (data);
- write_enn (own_buf);
- return 1;
- }
-
- n = (*q->xfer) (annex, NULL, data, ofs, len);
- if (n == -2)
- {
- free (data);
- return 0;
- }
- else if (n == -3)
- {
- /* Preserve error message. */
- }
- else if (n < 0)
- write_enn (own_buf);
- else
- sprintf (own_buf, "%x", n);
-
- free (data);
- return 1;
- }
-
- return 0;
- }
+ if (len > PBUFSIZ - 2)
+ len = PBUFSIZ - 2;
+ data = (unsigned char *) malloc (len + 1);
+ if (data == NULL)
+ {
+ write_enn (own_buf);
+ return 1;
+ }
+ n = (*q->xfer) (annex, data, NULL, ofs, len + 1);
+ if (n == -2)
+ {
+ free (data);
+ return 0;
+ }
+ else if (n == -3)
+ {
+ /* Preserve error message. */
+ }
+ else if (n < 0)
+ write_enn (own_buf);
+ else if (n > len)
+ *new_packet_len_p
+ = write_qxfer_response (own_buf, data, len, 1);
+ else
+ *new_packet_len_p = write_qxfer_response (own_buf, data, n, 0);
+
+ free (data);
+ return 1;
+ }
+ else if (strcmp (rw, "write") == 0)
+ {
+ int n;
+ unsigned int len;
+ CORE_ADDR ofs;
+ unsigned char *data;
+
+ strcpy (own_buf, "E00");
+ data
+ = (unsigned char *) malloc (packet_len - (offset - own_buf));
+ if (data == NULL)
+ {
+ write_enn (own_buf);
+ return 1;
+ }
+ if (decode_xfer_write (offset, packet_len - (offset - own_buf),
+ &ofs, &len, data)
+ < 0)
+ {
+ free (data);
+ write_enn (own_buf);
+ return 1;
+ }
+
+ n = (*q->xfer) (annex, NULL, data, ofs, len);
+ if (n == -2)
+ {
+ free (data);
+ return 0;
+ }
+ else if (n == -3)
+ {
+ /* Preserve error message. */
+ }
+ else if (n < 0)
+ write_enn (own_buf);
+ else
+ sprintf (own_buf, "%x", n);
+
+ free (data);
+ return 1;
+ }
+
+ return 0;
+ }
}
return 0;
@@ -2125,7 +2105,7 @@ crc32 (CORE_ADDR base, int len, unsigned int crc)
/* Return failure if memory read fails. */
if (read_inferior_memory (base, &byte, 1) != 0)
- return (unsigned long long) -1;
+ return (unsigned long long) -1;
crc = xcrc32 (&byte, 1, crc);
base++;
@@ -2137,7 +2117,7 @@ crc32 (CORE_ADDR base, int len, unsigned int crc)
static void
parse_fetch_memtags_request (char *request, CORE_ADDR *addr, size_t *len,
- int *type)
+ int *type)
{
gdb_assert (startswith (request, "qMemTags:"));
@@ -2182,13 +2162,14 @@ handle_query (char *own_buf, int packet_len, int *new_packet_len_p)
ptid_t ptid;
require_running_or_return (own_buf);
- if (cs.general_thread != null_ptid && cs.general_thread != minus_one_ptid)
- ptid = cs.general_thread;
+ if (cs.general_thread != null_ptid
+ && cs.general_thread != minus_one_ptid)
+ ptid = cs.general_thread;
else
- {
- thread_iter = all_threads.begin ();
- ptid = (*thread_iter)->id;
- }
+ {
+ thread_iter = all_threads.begin ();
+ ptid = (*thread_iter)->id;
+ }
sprintf (own_buf, "QC");
own_buf += 2;
@@ -2206,19 +2187,19 @@ handle_query (char *own_buf, int packet_len, int *new_packet_len_p)
the same process. This can happen e.g., if we followed an
exec in a non-leader thread. */
if (current_thread == NULL)
- {
- thread_info *any_thread
- = find_any_thread_of_pid (cs.general_thread.pid ());
- switch_to_thread (any_thread);
+ {
+ thread_info *any_thread
+ = find_any_thread_of_pid (cs.general_thread.pid ());
+ switch_to_thread (any_thread);
- /* Just in case, if we didn't find a thread, then bail out
+ /* Just in case, if we didn't find a thread, then bail out
instead of crashing. */
- if (current_thread == NULL)
- {
- write_enn (own_buf);
- return;
- }
- }
+ if (current_thread == NULL)
+ {
+ write_enn (own_buf);
+ return;
+ }
+ }
/* GDB is suggesting new symbols have been loaded. This may
mean a new shared library has been detected as loaded, so
@@ -2233,10 +2214,10 @@ handle_query (char *own_buf, int packet_len, int *new_packet_len_p)
validate_breakpoints ();
if (target_supports_tracepoints ())
- tracepoint_look_up_symbols ();
+ tracepoint_look_up_symbols ();
if (current_thread != NULL)
- the_target->look_up_symbols ();
+ the_target->look_up_symbols ();
strcpy (own_buf, "OK");
return;
@@ -2245,34 +2226,34 @@ handle_query (char *own_buf, int packet_len, int *new_packet_len_p)
if (!disable_packet_qfThreadInfo)
{
if (strcmp ("qfThreadInfo", own_buf) == 0)
- {
- require_running_or_return (own_buf);
- thread_iter = all_threads.begin ();
+ {
+ require_running_or_return (own_buf);
+ thread_iter = all_threads.begin ();
- *own_buf++ = 'm';
- ptid_t ptid = (*thread_iter)->id;
- write_ptid (own_buf, ptid);
- thread_iter++;
- return;
- }
+ *own_buf++ = 'm';
+ ptid_t ptid = (*thread_iter)->id;
+ write_ptid (own_buf, ptid);
+ thread_iter++;
+ return;
+ }
if (strcmp ("qsThreadInfo", own_buf) == 0)
- {
- require_running_or_return (own_buf);
- if (thread_iter != all_threads.end ())
- {
- *own_buf++ = 'm';
- ptid_t ptid = (*thread_iter)->id;
- write_ptid (own_buf, ptid);
- thread_iter++;
- return;
- }
- else
- {
- sprintf (own_buf, "l");
- return;
- }
- }
+ {
+ require_running_or_return (own_buf);
+ if (thread_iter != all_threads.end ())
+ {
+ *own_buf++ = 'm';
+ ptid_t ptid = (*thread_iter)->id;
+ write_ptid (own_buf, ptid);
+ thread_iter++;
+ return;
+ }
+ else
+ {
+ sprintf (own_buf, "l");
+ return;
+ }
+ }
}
if (the_target->supports_read_offsets ()
@@ -2282,10 +2263,10 @@ handle_query (char *own_buf, int packet_len, int *new_packet_len_p)
require_running_or_return (own_buf);
if (the_target->read_offsets (&text, &data))
- sprintf (own_buf, "Text=%lX;Data=%lX;Bss=%lX",
- (long)text, (long)data, (long)data);
+ sprintf (own_buf, "Text=%lX;Data=%lX;Bss=%lX", (long) text,
+ (long) data, (long) data);
else
- write_enn (own_buf);
+ write_enn (own_buf);
return;
}
@@ -2301,121 +2282,120 @@ handle_query (char *own_buf, int packet_len, int *new_packet_len_p)
feature will follow a ':', and latter features will follow
';'. */
if (*p == ':')
- {
- std::vector<std::string> qsupported;
- std::vector<const char *> unknowns;
+ {
+ std::vector<std::string> qsupported;
+ std::vector<const char *> unknowns;
- /* Two passes, to avoid nested strtok calls in
+ /* Two passes, to avoid nested strtok calls in
target_process_qsupported. */
- char *saveptr;
- for (p = strtok_r (p + 1, ";", &saveptr);
- p != NULL;
- p = strtok_r (NULL, ";", &saveptr))
- qsupported.emplace_back (p);
-
- for (const std::string &feature : qsupported)
- {
- if (feature == "multiprocess+")
- {
- /* GDB supports and wants multi-process support if
+ char *saveptr;
+ for (p = strtok_r (p + 1, ";", &saveptr); p != NULL;
+ p = strtok_r (NULL, ";", &saveptr))
+ qsupported.emplace_back (p);
+
+ for (const std::string &feature : qsupported)
+ {
+ if (feature == "multiprocess+")
+ {
+ /* GDB supports and wants multi-process support if
possible. */
- if (target_supports_multi_process ())
- cs.multi_process = 1;
- }
- else if (feature == "qRelocInsn+")
- {
- /* GDB supports relocate instruction requests. */
- gdb_supports_qRelocInsn = 1;
- }
- else if (feature == "swbreak+")
- {
- /* GDB wants us to report whether a trap is caused
+ if (target_supports_multi_process ())
+ cs.multi_process = 1;
+ }
+ else if (feature == "qRelocInsn+")
+ {
+ /* GDB supports relocate instruction requests. */
+ gdb_supports_qRelocInsn = 1;
+ }
+ else if (feature == "swbreak+")
+ {
+ /* GDB wants us to report whether a trap is caused
by a software breakpoint and for us to handle PC
adjustment if necessary on this target. */
- if (target_supports_stopped_by_sw_breakpoint ())
- cs.swbreak_feature = 1;
- }
- else if (feature == "hwbreak+")
- {
- /* GDB wants us to report whether a trap is caused
+ if (target_supports_stopped_by_sw_breakpoint ())
+ cs.swbreak_feature = 1;
+ }
+ else if (feature == "hwbreak+")
+ {
+ /* GDB wants us to report whether a trap is caused
by a hardware breakpoint. */
- if (target_supports_stopped_by_hw_breakpoint ())
- cs.hwbreak_feature = 1;
- }
- else if (feature == "fork-events+")
- {
- /* GDB supports and wants fork events if possible. */
- if (target_supports_fork_events ())
- cs.report_fork_events = 1;
- }
- else if (feature == "vfork-events+")
- {
- /* GDB supports and wants vfork events if possible. */
- if (target_supports_vfork_events ())
- cs.report_vfork_events = 1;
- }
- else if (feature == "exec-events+")
- {
- /* GDB supports and wants exec events if possible. */
- if (target_supports_exec_events ())
- cs.report_exec_events = 1;
- }
- else if (feature == "vContSupported+")
- cs.vCont_supported = 1;
- else if (feature == "QThreadEvents+")
- ;
- else if (feature == "no-resumed+")
- {
- /* GDB supports and wants TARGET_WAITKIND_NO_RESUMED
+ if (target_supports_stopped_by_hw_breakpoint ())
+ cs.hwbreak_feature = 1;
+ }
+ else if (feature == "fork-events+")
+ {
+ /* GDB supports and wants fork events if possible. */
+ if (target_supports_fork_events ())
+ cs.report_fork_events = 1;
+ }
+ else if (feature == "vfork-events+")
+ {
+ /* GDB supports and wants vfork events if possible. */
+ if (target_supports_vfork_events ())
+ cs.report_vfork_events = 1;
+ }
+ else if (feature == "exec-events+")
+ {
+ /* GDB supports and wants exec events if possible. */
+ if (target_supports_exec_events ())
+ cs.report_exec_events = 1;
+ }
+ else if (feature == "vContSupported+")
+ cs.vCont_supported = 1;
+ else if (feature == "QThreadEvents+")
+ ;
+ else if (feature == "no-resumed+")
+ {
+ /* GDB supports and wants TARGET_WAITKIND_NO_RESUMED
events. */
- report_no_resumed = true;
- }
- else if (feature == "memory-tagging+")
- {
- /* GDB supports memory tagging features. */
- if (target_supports_memory_tagging ())
- cs.memory_tagging_feature = true;
- }
- else
- {
- /* Move the unknown features all together. */
- unknowns.push_back (feature.c_str ());
- }
- }
-
- /* Give the target backend a chance to process the unknown
+ report_no_resumed = true;
+ }
+ else if (feature == "memory-tagging+")
+ {
+ /* GDB supports memory tagging features. */
+ if (target_supports_memory_tagging ())
+ cs.memory_tagging_feature = true;
+ }
+ else
+ {
+ /* Move the unknown features all together. */
+ unknowns.push_back (feature.c_str ());
+ }
+ }
+
+ /* Give the target backend a chance to process the unknown
features. */
- target_process_qsupported (unknowns);
- }
+ target_process_qsupported (unknowns);
+ }
sprintf (own_buf,
- "PacketSize=%x;QPassSignals+;QProgramSignals+;"
- "QStartupWithShell+;QEnvironmentHexEncoded+;"
- "QEnvironmentReset+;QEnvironmentUnset+;"
- "QSetWorkingDir+",
- PBUFSIZ - 1);
+ "PacketSize=%x;QPassSignals+;QProgramSignals+;"
+ "QStartupWithShell+;QEnvironmentHexEncoded+;"
+ "QEnvironmentReset+;QEnvironmentUnset+;"
+ "QSetWorkingDir+",
+ PBUFSIZ - 1);
if (target_supports_catch_syscall ())
- strcat (own_buf, ";QCatchSyscalls+");
+ strcat (own_buf, ";QCatchSyscalls+");
if (the_target->supports_qxfer_libraries_svr4 ())
- strcat (own_buf, ";qXfer:libraries-svr4:read+"
- ";augmented-libraries-svr4-read+");
+ strcat (own_buf, ";qXfer:libraries-svr4:read+"
+ ";augmented-libraries-svr4-read+");
else
- {
- /* We do not have any hook to indicate whether the non-SVR4 target
+ {
+ /* We do not have any hook to indicate whether the non-SVR4 target
backend supports qXfer:libraries:read, so always report it. */
- strcat (own_buf, ";qXfer:libraries:read+");
- }
+ strcat (own_buf, ";qXfer:libraries:read+");
+ }
if (the_target->supports_read_auxv ())
- strcat (own_buf, ";qXfer:auxv:read+");
+ strcat (own_buf, ";qXfer:auxv:read+");
if (the_target->supports_qxfer_siginfo ())
- strcat (own_buf, ";qXfer:siginfo:read+;qXfer:siginfo:write+");
+ strcat (own_buf, ";qXfer:siginfo:read+;qXfer:siginfo:write+");
if (the_target->supports_read_loadmap ())
- strcat (own_buf, ";qXfer:fdpic:read+");
+ strcat (own_buf, ";qXfer:fdpic:read+");
/* We always report qXfer:features:read, as targets may
install XML files on a subsequent call to arch_setup.
@@ -2424,69 +2404,69 @@ handle_query (char *own_buf, int packet_len, int *new_packet_len_p)
strcat (own_buf, ";qXfer:features:read+");
if (cs.transport_is_reliable)
- strcat (own_buf, ";QStartNoAckMode+");
+ strcat (own_buf, ";QStartNoAckMode+");
if (the_target->supports_qxfer_osdata ())
- strcat (own_buf, ";qXfer:osdata:read+");
+ strcat (own_buf, ";qXfer:osdata:read+");
if (target_supports_multi_process ())
- strcat (own_buf, ";multiprocess+");
+ strcat (own_buf, ";multiprocess+");
if (target_supports_fork_events ())
- strcat (own_buf, ";fork-events+");
+ strcat (own_buf, ";fork-events+");
if (target_supports_vfork_events ())
- strcat (own_buf, ";vfork-events+");
+ strcat (own_buf, ";vfork-events+");
if (target_supports_exec_events ())
- strcat (own_buf, ";exec-events+");
+ strcat (own_buf, ";exec-events+");
if (target_supports_non_stop ())
- strcat (own_buf, ";QNonStop+");
+ strcat (own_buf, ";QNonStop+");
if (target_supports_disable_randomization ())
- strcat (own_buf, ";QDisableRandomization+");
+ strcat (own_buf, ";QDisableRandomization+");
strcat (own_buf, ";qXfer:threads:read+");
if (target_supports_tracepoints ())
- {
- strcat (own_buf, ";ConditionalTracepoints+");
- strcat (own_buf, ";TraceStateVariables+");
- strcat (own_buf, ";TracepointSource+");
- strcat (own_buf, ";DisconnectedTracing+");
- if (gdb_supports_qRelocInsn && target_supports_fast_tracepoints ())
- strcat (own_buf, ";FastTracepoints+");
- strcat (own_buf, ";StaticTracepoints+");
- strcat (own_buf, ";InstallInTrace+");
- strcat (own_buf, ";qXfer:statictrace:read+");
- strcat (own_buf, ";qXfer:traceframe-info:read+");
- strcat (own_buf, ";EnableDisableTracepoints+");
- strcat (own_buf, ";QTBuffer:size+");
- strcat (own_buf, ";tracenz+");
- }
+ {
+ strcat (own_buf, ";ConditionalTracepoints+");
+ strcat (own_buf, ";TraceStateVariables+");
+ strcat (own_buf, ";TracepointSource+");
+ strcat (own_buf, ";DisconnectedTracing+");
+ if (gdb_supports_qRelocInsn && target_supports_fast_tracepoints ())
+ strcat (own_buf, ";FastTracepoints+");
+ strcat (own_buf, ";StaticTracepoints+");
+ strcat (own_buf, ";InstallInTrace+");
+ strcat (own_buf, ";qXfer:statictrace:read+");
+ strcat (own_buf, ";qXfer:traceframe-info:read+");
+ strcat (own_buf, ";EnableDisableTracepoints+");
+ strcat (own_buf, ";QTBuffer:size+");
+ strcat (own_buf, ";tracenz+");
+ }
if (target_supports_hardware_single_step ()
- || target_supports_software_single_step () )
- {
- strcat (own_buf, ";ConditionalBreakpoints+");
- }
+ || target_supports_software_single_step ())
+ {
+ strcat (own_buf, ";ConditionalBreakpoints+");
+ }
strcat (own_buf, ";BreakpointCommands+");
if (target_supports_agent ())
- strcat (own_buf, ";QAgent+");
+ strcat (own_buf, ";QAgent+");
if (the_target->supports_btrace ())
- supported_btrace_packets (own_buf);
+ supported_btrace_packets (own_buf);
if (target_supports_stopped_by_sw_breakpoint ())
- strcat (own_buf, ";swbreak+");
+ strcat (own_buf, ";swbreak+");
if (target_supports_stopped_by_hw_breakpoint ())
- strcat (own_buf, ";hwbreak+");
+ strcat (own_buf, ";hwbreak+");
if (the_target->supports_pid_to_exec_file ())
- strcat (own_buf, ";qXfer:exec-file:read+");
+ strcat (own_buf, ";qXfer:exec-file:read+");
strcat (own_buf, ";vContSupported+");
@@ -2495,7 +2475,7 @@ handle_query (char *own_buf, int packet_len, int *new_packet_len_p)
strcat (own_buf, ";no-resumed+");
if (target_supports_memory_tagging ())
- strcat (own_buf, ";memory-tagging+");
+ strcat (own_buf, ";memory-tagging+");
/* Reinitialize components as needed for the new connection. */
hostio_handle_new_gdb_connection ();
@@ -2516,55 +2496,55 @@ handle_query (char *own_buf, int packet_len, int *new_packet_len_p)
require_running_or_return (own_buf);
for (i = 0; i < 3; i++)
- {
- char *p2;
- int len;
-
- if (p == NULL)
- break;
-
- p2 = strchr (p, ',');
- if (p2)
- {
- len = p2 - p;
- p2++;
- }
- else
- {
- len = strlen (p);
- p2 = NULL;
- }
-
- if (i == 0)
- ptid = read_ptid (p, NULL);
- else
- decode_address (&parts[i - 1], p, len);
- p = p2;
- }
+ {
+ char *p2;
+ int len;
+
+ if (p == NULL)
+ break;
+
+ p2 = strchr (p, ',');
+ if (p2)
+ {
+ len = p2 - p;
+ p2++;
+ }
+ else
+ {
+ len = strlen (p);
+ p2 = NULL;
+ }
+
+ if (i == 0)
+ ptid = read_ptid (p, NULL);
+ else
+ decode_address (&parts[i - 1], p, len);
+ p = p2;
+ }
if (p != NULL || i < 3)
- err = 1;
+ err = 1;
else
- {
- struct thread_info *thread = find_thread_ptid (ptid);
+ {
+ struct thread_info *thread = find_thread_ptid (ptid);
- if (thread == NULL)
- err = 2;
- else
- err = the_target->get_tls_address (thread, parts[0], parts[1],
- &address);
- }
+ if (thread == NULL)
+ err = 2;
+ else
+ err = the_target->get_tls_address (thread, parts[0], parts[1],
+ &address);
+ }
if (err == 0)
- {
- strcpy (own_buf, paddress(address));
- return;
- }
+ {
+ strcpy (own_buf, paddress (address));
+ return;
+ }
else if (err > 0)
- {
- write_enn (own_buf);
- return;
- }
+ {
+ write_enn (own_buf);
+ return;
+ }
/* Otherwise, pretend we do not understand this packet. */
}
@@ -2580,15 +2560,15 @@ handle_query (char *own_buf, int packet_len, int *new_packet_len_p)
n = the_target->get_tib_address (ptid, &tlb);
if (n == 1)
- {
- strcpy (own_buf, paddress(tlb));
- return;
- }
+ {
+ strcpy (own_buf, paddress (tlb));
+ return;
+ }
else if (n == 0)
- {
- write_enn (own_buf);
- return;
- }
+ {
+ write_enn (own_buf);
+ return;
+ }
return;
}
@@ -2599,25 +2579,25 @@ handle_query (char *own_buf, int packet_len, int *new_packet_len_p)
int len = strlen (own_buf + 6);
if (mon == NULL)
- {
- write_enn (own_buf);
- return;
- }
+ {
+ write_enn (own_buf);
+ return;
+ }
if ((len % 2) != 0
- || hex2bin (own_buf + 6, (gdb_byte *) mon, len / 2) != len / 2)
- {
- write_enn (own_buf);
- free (mon);
- return;
- }
+ || hex2bin (own_buf + 6, (gdb_byte *) mon, len / 2) != len / 2)
+ {
+ write_enn (own_buf);
+ free (mon);
+ return;
+ }
mon[len / 2] = '\0';
write_ok (own_buf);
if (the_target->handle_monitor_command (mon) == 0)
- /* Default processing. */
- handle_monitor_command (mon, own_buf);
+ /* Default processing. */
+ handle_monitor_command (mon, own_buf);
free (mon);
return;
@@ -2630,27 +2610,26 @@ handle_query (char *own_buf, int packet_len, int *new_packet_len_p)
return;
}
- if (strcmp (own_buf, "qAttached") == 0
- || startswith (own_buf, "qAttached:"))
+ if (strcmp (own_buf, "qAttached") == 0 || startswith (own_buf, "qAttached:"))
{
struct process_info *process;
if (own_buf[sizeof ("qAttached") - 1])
- {
- int pid = strtoul (own_buf + sizeof ("qAttached:") - 1, NULL, 16);
- process = find_process_pid (pid);
- }
+ {
+ int pid = strtoul (own_buf + sizeof ("qAttached:") - 1, NULL, 16);
+ process = find_process_pid (pid);
+ }
else
- {
- require_running_or_return (own_buf);
- process = current_process ();
- }
+ {
+ require_running_or_return (own_buf);
+ process = current_process ();
+ }
if (process == NULL)
- {
- write_enn (own_buf);
- return;
- }
+ {
+ write_enn (own_buf);
+ return;
+ }
strcpy (own_buf, process->attached ? "1" : "0");
return;
@@ -2667,18 +2646,18 @@ handle_query (char *own_buf, int packet_len, int *new_packet_len_p)
require_running_or_return (own_buf);
comma = unpack_varlen_hex (own_buf + 5, &base);
if (*comma++ != ',')
- {
- write_enn (own_buf);
- return;
- }
+ {
+ write_enn (own_buf);
+ return;
+ }
len = strtoul (comma, NULL, 16);
crc = crc32 (base, len, 0xffffffff);
/* Check for memory failure. */
if (crc == (unsigned long long) -1)
- {
- write_enn (own_buf);
- return;
- }
+ {
+ write_enn (own_buf);
+ return;
+ }
sprintf (own_buf, "C%lx", (unsigned long) crc);
return;
}
@@ -2690,8 +2669,7 @@ handle_query (char *own_buf, int packet_len, int *new_packet_len_p)
return;
/* Handle fetch memory tags packets. */
- if (startswith (own_buf, "qMemTags:")
- && target_supports_memory_tagging ())
+ if (startswith (own_buf, "qMemTags:") && target_supports_memory_tagging ())
{
gdb::byte_vector tags;
CORE_ADDR addr = 0;
@@ -2705,10 +2683,10 @@ handle_query (char *own_buf, int packet_len, int *new_packet_len_p)
bool ret = the_target->fetch_memtags (addr, len, tags, type);
if (ret)
- ret = create_fetch_memtags_reply (own_buf, tags);
+ ret = create_fetch_memtags_reply (own_buf, tags);
if (!ret)
- write_enn (own_buf);
+ write_enn (own_buf);
*new_packet_len_p = strlen (own_buf);
return;
@@ -2723,8 +2701,8 @@ static void gdb_wants_all_threads_stopped (void);
static void resume (struct thread_resume *actions, size_t n);
/* The callback that is passed to visit_actioned_threads. */
-typedef int (visit_actioned_threads_callback_ftype)
- (const struct thread_resume *, struct thread_info *);
+typedef int (visit_actioned_threads_callback_ftype) (
+ const struct thread_resume *, struct thread_info *);
/* Call CALLBACK for any thread to which ACTIONS applies to. Returns
true if CALLBACK returns true. Returns false if no matching thread
@@ -2733,23 +2711,21 @@ typedef int (visit_actioned_threads_callback_ftype)
static bool
visit_actioned_threads (thread_info *thread,
- const struct thread_resume *actions,
- size_t num_actions,
- visit_actioned_threads_callback_ftype *callback)
+ const struct thread_resume *actions,
+ size_t num_actions,
+ visit_actioned_threads_callback_ftype *callback)
{
for (size_t i = 0; i < num_actions; i++)
{
const struct thread_resume *action = &actions[i];
- if (action->thread == minus_one_ptid
- || action->thread == thread->id
- || ((action->thread.pid ()
- == thread->id.pid ())
- && action->thread.lwp () == -1))
- {
- if ((*callback) (action, thread))
- return true;
- }
+ if (action->thread == minus_one_ptid || action->thread == thread->id
+ || ((action->thread.pid () == thread->id.pid ())
+ && action->thread.lwp () == -1))
+ {
+ if ((*callback) (action, thread))
+ return true;
+ }
}
return false;
@@ -2760,7 +2736,7 @@ visit_actioned_threads (thread_info *thread,
static int
handle_pending_status (const struct thread_resume *resumption,
- struct thread_info *thread)
+ struct thread_info *thread)
{
client_state &cs = get_client_state ();
if (thread->status_pending_p)
@@ -2782,7 +2758,10 @@ handle_v_cont (char *own_buf)
const char *p;
int n = 0, i = 0;
struct thread_resume *resume_info;
- struct thread_resume default_action { null_ptid };
+ struct thread_resume default_action
+ {
+ null_ptid
+ };
/* Count the number of semicolons in the packet. There should be one
for every action. */
@@ -2806,69 +2785,69 @@ handle_v_cont (char *own_buf)
memset (&resume_info[i], 0, sizeof resume_info[i]);
if (p[0] == 's' || p[0] == 'S')
- resume_info[i].kind = resume_step;
+ resume_info[i].kind = resume_step;
else if (p[0] == 'r')
- resume_info[i].kind = resume_step;
+ resume_info[i].kind = resume_step;
else if (p[0] == 'c' || p[0] == 'C')
- resume_info[i].kind = resume_continue;
+ resume_info[i].kind = resume_continue;
else if (p[0] == 't')
- resume_info[i].kind = resume_stop;
+ resume_info[i].kind = resume_stop;
else
- goto err;
+ goto err;
if (p[0] == 'S' || p[0] == 'C')
- {
- char *q;
- int sig = strtol (p + 1, &q, 16);
- if (p == q)
- goto err;
- p = q;
-
- if (!gdb_signal_to_host_p ((enum gdb_signal) sig))
- goto err;
- resume_info[i].sig = gdb_signal_to_host ((enum gdb_signal) sig);
- }
+ {
+ char *q;
+ int sig = strtol (p + 1, &q, 16);
+ if (p == q)
+ goto err;
+ p = q;
+
+ if (!gdb_signal_to_host_p ((enum gdb_signal) sig))
+ goto err;
+ resume_info[i].sig = gdb_signal_to_host ((enum gdb_signal) sig);
+ }
else if (p[0] == 'r')
- {
- ULONGEST addr;
+ {
+ ULONGEST addr;
- p = unpack_varlen_hex (p + 1, &addr);
- resume_info[i].step_range_start = addr;
+ p = unpack_varlen_hex (p + 1, &addr);
+ resume_info[i].step_range_start = addr;
- if (*p != ',')
- goto err;
+ if (*p != ',')
+ goto err;
- p = unpack_varlen_hex (p + 1, &addr);
- resume_info[i].step_range_end = addr;
- }
+ p = unpack_varlen_hex (p + 1, &addr);
+ resume_info[i].step_range_end = addr;
+ }
else
- {
- p = p + 1;
- }
+ {
+ p = p + 1;
+ }
if (p[0] == 0)
- {
- resume_info[i].thread = minus_one_ptid;
- default_action = resume_info[i];
+ {
+ resume_info[i].thread = minus_one_ptid;
+ default_action = resume_info[i];
- /* Note: we don't increment i here, we'll overwrite this entry
+ /* Note: we don't increment i here, we'll overwrite this entry
the next time through. */
- }
+ }
else if (p[0] == ':')
- {
- const char *q;
- ptid_t ptid = read_ptid (p + 1, &q);
+ {
+ const char *q;
+ ptid_t ptid = read_ptid (p + 1, &q);
- if (p == q)
- goto err;
- p = q;
- if (p[0] != ';' && p[0] != 0)
- goto err;
+ if (p == q)
+ goto err;
+ p = q;
+ if (p[0] != ';' && p[0] != 0)
+ goto err;
- resume_info[i].thread = ptid;
+ resume_info[i].thread = ptid;
- i++;
- }
+ i++;
+ }
}
if (i < n)
@@ -2897,14 +2876,14 @@ resume (struct thread_resume *actions, size_t num_actions)
resuming/stopping and report the pending event
immediately. */
- thread_info *thread_with_status = find_thread ([&] (thread_info *thread)
- {
- return visit_actioned_threads (thread, actions, num_actions,
- handle_pending_status);
- });
+ thread_info *thread_with_status
+ = find_thread ([&] (thread_info *thread) {
+ return visit_actioned_threads (thread, actions, num_actions,
+ handle_pending_status);
+ });
if (thread_with_status != NULL)
- return;
+ return;
enable_async_io ();
}
@@ -2918,19 +2897,19 @@ resume (struct thread_resume *actions, size_t num_actions)
cs.last_ptid = mywait (minus_one_ptid, &cs.last_status, 0, 1);
if (cs.last_status.kind () == TARGET_WAITKIND_NO_RESUMED
- && !report_no_resumed)
- {
- /* The client does not support this stop reply. At least
+ && !report_no_resumed)
+ {
+ /* The client does not support this stop reply. At least
return error. */
- sprintf (cs.own_buf, "E.No unwaited-for children left.");
- disable_async_io ();
- return;
- }
+ sprintf (cs.own_buf, "E.No unwaited-for children left.");
+ disable_async_io ();
+ return;
+ }
if (cs.last_status.kind () != TARGET_WAITKIND_EXITED
- && cs.last_status.kind () != TARGET_WAITKIND_SIGNALLED
- && cs.last_status.kind () != TARGET_WAITKIND_NO_RESUMED)
- current_thread->last_status = cs.last_status;
+ && cs.last_status.kind () != TARGET_WAITKIND_SIGNALLED
+ && cs.last_status.kind () != TARGET_WAITKIND_NO_RESUMED)
+ current_thread->last_status = cs.last_status;
/* From the client's perspective, all-stop mode always stops all
threads implicitly (and the target backend has already done
@@ -2941,8 +2920,8 @@ resume (struct thread_resume *actions, size_t num_actions)
disable_async_io ();
if (cs.last_status.kind () == TARGET_WAITKIND_EXITED
- || cs.last_status.kind () == TARGET_WAITKIND_SIGNALLED)
- target_mourn_inferior (cs.last_ptid);
+ || cs.last_status.kind () == TARGET_WAITKIND_SIGNALLED)
+ target_mourn_inferior (cs.last_ptid);
}
}
@@ -2963,14 +2942,14 @@ handle_v_attach (char *own_buf)
current_process ()->dlls_changed = false;
if (non_stop)
- {
- /* In non-stop, we don't send a resume reply. Stop events
+ {
+ /* In non-stop, we don't send a resume reply. Stop events
will follow up using the normal notification
mechanism. */
- write_ok (own_buf);
- }
+ write_ok (own_buf);
+ }
else
- prepare_resume_reply (own_buf, cs.last_ptid, cs.last_status);
+ prepare_resume_reply (own_buf, cs.last_ptid, cs.last_status);
}
else
write_enn (own_buf);
@@ -2990,73 +2969,73 @@ handle_v_run (char *own_buf)
{
next_p = strchr (p, ';');
if (next_p == NULL)
- next_p = p + strlen (p);
+ next_p = p + strlen (p);
if (i == 0 && p == next_p)
- {
- /* No program specified. */
- new_program_name = NULL;
- }
+ {
+ /* No program specified. */
+ new_program_name = NULL;
+ }
else if (p == next_p)
- {
- /* Empty argument. */
- new_argv.push_back (xstrdup (""));
- }
+ {
+ /* Empty argument. */
+ new_argv.push_back (xstrdup (""));
+ }
else
- {
- size_t len = (next_p - p) / 2;
- /* ARG is the unquoted argument received via the RSP. */
- char *arg = (char *) xmalloc (len + 1);
- /* FULL_ARGS will contain the quoted version of ARG. */
- char *full_arg = (char *) xmalloc ((len + 1) * 2);
- /* These are pointers used to navigate the strings above. */
- char *tmp_arg = arg;
- char *tmp_full_arg = full_arg;
- int need_quote = 0;
-
- hex2bin (p, (gdb_byte *) arg, len);
- arg[len] = '\0';
-
- while (*tmp_arg != '\0')
- {
- switch (*tmp_arg)
- {
- case '\n':
- /* Quote \n. */
- *tmp_full_arg = '\'';
- ++tmp_full_arg;
- need_quote = 1;
- break;
-
- case '\'':
- /* Quote single quote. */
- *tmp_full_arg = '\\';
- ++tmp_full_arg;
- break;
-
- default:
- break;
- }
-
- *tmp_full_arg = *tmp_arg;
- ++tmp_full_arg;
- ++tmp_arg;
- }
-
- if (need_quote)
- *tmp_full_arg++ = '\'';
-
- /* Finish FULL_ARG and push it into the vector containing
+ {
+ size_t len = (next_p - p) / 2;
+ /* ARG is the unquoted argument received via the RSP. */
+ char *arg = (char *) xmalloc (len + 1);
+ /* FULL_ARGS will contain the quoted version of ARG. */
+ char *full_arg = (char *) xmalloc ((len + 1) * 2);
+ /* These are pointers used to navigate the strings above. */
+ char *tmp_arg = arg;
+ char *tmp_full_arg = full_arg;
+ int need_quote = 0;
+
+ hex2bin (p, (gdb_byte *) arg, len);
+ arg[len] = '\0';
+
+ while (*tmp_arg != '\0')
+ {
+ switch (*tmp_arg)
+ {
+ case '\n':
+ /* Quote \n. */
+ *tmp_full_arg = '\'';
+ ++tmp_full_arg;
+ need_quote = 1;
+ break;
+
+ case '\'':
+ /* Quote single quote. */
+ *tmp_full_arg = '\\';
+ ++tmp_full_arg;
+ break;
+
+ default:
+ break;
+ }
+
+ *tmp_full_arg = *tmp_arg;
+ ++tmp_full_arg;
+ ++tmp_arg;
+ }
+
+ if (need_quote)
+ *tmp_full_arg++ = '\'';
+
+ /* Finish FULL_ARG and push it into the vector containing
the argv. */
- *tmp_full_arg = '\0';
- if (i == 0)
- new_program_name = full_arg;
- else
- new_argv.push_back (full_arg);
- xfree (arg);
- }
+ *tmp_full_arg = '\0';
+ if (i == 0)
+ new_program_name = full_arg;
+ else
+ new_argv.push_back (full_arg);
+ xfree (arg);
+ }
if (*next_p)
- next_p++;
+ next_p++;
}
if (new_program_name == NULL)
@@ -3064,11 +3043,11 @@ handle_v_run (char *own_buf)
/* GDB didn't specify a program to run. Use the program from the
last run with the new argument list. */
if (program_path.get () == NULL)
- {
- write_enn (own_buf);
- free_vector_argv (new_argv);
- return;
- }
+ {
+ write_enn (own_buf);
+ free_vector_argv (new_argv);
+ return;
+ }
}
else
program_path.set (new_program_name);
@@ -3087,7 +3066,7 @@ handle_v_run (char *own_buf)
thread, but GDB assumes a vRun sets it (this is so GDB can
query which is the main thread of the new inferior. */
if (non_stop)
- cs.general_thread = cs.last_ptid;
+ cs.general_thread = cs.last_ptid;
}
else
write_enn (own_buf);
@@ -3126,42 +3105,42 @@ handle_v_requests (char *own_buf, int packet_len, int *new_packet_len)
if (!disable_packet_vCont)
{
if (strcmp (own_buf, "vCtrlC") == 0)
- {
- the_target->request_interrupt ();
- write_ok (own_buf);
- return;
- }
+ {
+ the_target->request_interrupt ();
+ write_ok (own_buf);
+ return;
+ }
if (startswith (own_buf, "vCont;"))
- {
- handle_v_cont (own_buf);
- return;
- }
+ {
+ handle_v_cont (own_buf);
+ return;
+ }
if (startswith (own_buf, "vCont?"))
- {
- strcpy (own_buf, "vCont;c;C;t");
-
- if (target_supports_hardware_single_step ()
- || target_supports_software_single_step ()
- || !cs.vCont_supported)
- {
- /* If target supports single step either by hardware or by
+ {
+ strcpy (own_buf, "vCont;c;C;t");
+
+ if (target_supports_hardware_single_step ()
+ || target_supports_software_single_step ()
+ || !cs.vCont_supported)
+ {
+ /* If target supports single step either by hardware or by
software, add actions s and S to the list of supported
actions. On the other hand, if GDB doesn't request the
supported vCont actions in qSupported packet, add s and
S to the list too. */
- own_buf = own_buf + strlen (own_buf);
- strcpy (own_buf, ";s;S");
- }
+ own_buf = own_buf + strlen (own_buf);
+ strcpy (own_buf, ";s;S");
+ }
- if (target_supports_range_stepping ())
- {
- own_buf = own_buf + strlen (own_buf);
- strcpy (own_buf, ";r");
- }
- return;
- }
+ if (target_supports_range_stepping ())
+ {
+ own_buf = own_buf + strlen (own_buf);
+ strcpy (own_buf, ";r");
+ }
+ return;
+ }
}
if (startswith (own_buf, "vFile:")
@@ -3171,11 +3150,11 @@ handle_v_requests (char *own_buf, int packet_len, int *new_packet_len)
if (startswith (own_buf, "vAttach;"))
{
if ((!extended_protocol || !cs.multi_process) && target_running ())
- {
- fprintf (stderr, "Already debugging a process\n");
- write_enn (own_buf);
- return;
- }
+ {
+ fprintf (stderr, "Already debugging a process\n");
+ write_enn (own_buf);
+ return;
+ }
handle_v_attach (own_buf);
return;
}
@@ -3183,11 +3162,11 @@ handle_v_requests (char *own_buf, int packet_len, int *new_packet_len)
if (startswith (own_buf, "vRun;"))
{
if ((!extended_protocol || !cs.multi_process) && target_running ())
- {
- fprintf (stderr, "Already debugging a process\n");
- write_enn (own_buf);
- return;
- }
+ {
+ fprintf (stderr, "Already debugging a process\n");
+ write_enn (own_buf);
+ return;
+ }
handle_v_run (own_buf);
return;
}
@@ -3195,11 +3174,11 @@ handle_v_requests (char *own_buf, int packet_len, int *new_packet_len)
if (startswith (own_buf, "vKill;"))
{
if (!target_running ())
- {
- fprintf (stderr, "No process to kill\n");
- write_enn (own_buf);
- return;
- }
+ {
+ fprintf (stderr, "No process to kill\n");
+ write_enn (own_buf);
+ return;
+ }
handle_v_kill (own_buf);
return;
}
@@ -3224,16 +3203,16 @@ myresume (char *own_buf, int step, int sig)
int n = 0;
int valid_cont_thread;
- valid_cont_thread = (cs.cont_thread != null_ptid
- && cs.cont_thread != minus_one_ptid);
+ valid_cont_thread
+ = (cs.cont_thread != null_ptid && cs.cont_thread != minus_one_ptid);
if (step || sig || valid_cont_thread)
{
resume_info[0].thread = current_ptid;
if (step)
- resume_info[0].kind = resume_step;
+ resume_info[0].kind = resume_step;
else
- resume_info[0].kind = resume_continue;
+ resume_info[0].kind = resume_continue;
resume_info[0].sig = sig;
n++;
}
@@ -3270,18 +3249,18 @@ queue_stop_reply_callback (thread_info *thread)
else
{
if (target_thread_stopped (thread))
- {
- threads_debug_printf
- ("Reporting thread %s as already stopped with %s",
- target_pid_to_str (thread->id).c_str (),
- thread->last_status.to_string ().c_str ());
+ {
+ threads_debug_printf (
+ "Reporting thread %s as already stopped with %s",
+ target_pid_to_str (thread->id).c_str (),
+ thread->last_status.to_string ().c_str ());
- gdb_assert (thread->last_status.kind () != TARGET_WAITKIND_IGNORE);
+ gdb_assert (thread->last_status.kind () != TARGET_WAITKIND_IGNORE);
- /* Pass the last stop reply back to GDB, but don't notify
+ /* Pass the last stop reply back to GDB, but don't notify
yet. */
- queue_stop_reply (thread->id, thread->last_status);
- }
+ queue_stop_reply (thread->id, thread->last_status);
+ }
}
}
@@ -3318,13 +3297,13 @@ set_pending_status_callback (thread_info *thread)
{
if (thread->last_status.kind () != TARGET_WAITKIND_STOPPED
|| (thread->last_status.sig () != GDB_SIGNAL_0
- /* A breakpoint, watchpoint or finished step from a previous
+ /* A breakpoint, watchpoint or finished step from a previous
GDB run isn't considered interesting for a new GDB run.
If we left those pending, the new GDB could consider them
random SIGTRAPs. This leaves out real async traps. We'd
have to peek into the (target-specific) siginfo to
distinguish those. */
- && thread->last_status.sig () != GDB_SIGNAL_TRAP))
+ && thread->last_status.sig () != GDB_SIGNAL_TRAP))
thread->status_pending_p = 1;
}
@@ -3336,9 +3315,7 @@ handle_status (char *own_buf)
client_state &cs = get_client_state ();
/* GDB is connected, don't forward events to the target anymore. */
- for_each_process ([] (process_info *process) {
- process->gdb_detached = 0;
- });
+ for_each_process ([] (process_info *process) { process->gdb_detached = 0; });
/* In non-stop mode, we must send a stop reply for each stopped
thread. In all-stop mode, just send one for the first stopped
@@ -3372,41 +3349,39 @@ handle_status (char *own_buf)
/* Prefer the last thread that reported an event to GDB (even if
that was a GDB_SIGNAL_TRAP). */
if (cs.last_status.kind () != TARGET_WAITKIND_IGNORE
- && cs.last_status.kind () != TARGET_WAITKIND_EXITED
- && cs.last_status.kind () != TARGET_WAITKIND_SIGNALLED)
- thread = find_thread_ptid (cs.last_ptid);
+ && cs.last_status.kind () != TARGET_WAITKIND_EXITED
+ && cs.last_status.kind () != TARGET_WAITKIND_SIGNALLED)
+ thread = find_thread_ptid (cs.last_ptid);
/* If the last event thread is not found for some reason, look
for some other thread that might have an event to report. */
if (thread == NULL)
- thread = find_thread ([] (thread_info *thr_arg)
- {
- return thr_arg->status_pending_p;
- });
+ thread = find_thread (
+ [] (thread_info *thr_arg) { return thr_arg->status_pending_p; });
/* If we're still out of luck, simply pick the first thread in
the thread list. */
if (thread == NULL)
- thread = get_first_thread ();
+ thread = get_first_thread ();
if (thread != NULL)
- {
- struct thread_info *tp = (struct thread_info *) thread;
+ {
+ struct thread_info *tp = (struct thread_info *) thread;
- /* We're reporting this event, so it's no longer
+ /* We're reporting this event, so it's no longer
pending. */
- tp->status_pending_p = 0;
+ tp->status_pending_p = 0;
- /* GDB assumes the current thread is the thread we're
+ /* GDB assumes the current thread is the thread we're
reporting the status for. */
- cs.general_thread = thread->id;
- set_desired_thread ();
+ cs.general_thread = thread->id;
+ set_desired_thread ();
- gdb_assert (tp->last_status.kind () != TARGET_WAITKIND_IGNORE);
- prepare_resume_reply (own_buf, tp->id, tp->last_status);
- }
+ gdb_assert (tp->last_status.kind () != TARGET_WAITKIND_IGNORE);
+ prepare_resume_reply (own_buf, tp->id, tp->last_status);
+ }
else
- strcpy (own_buf, "W00");
+ strcpy (own_buf, "W00");
}
}
@@ -3414,70 +3389,75 @@ static void
gdbserver_version (void)
{
printf ("GNU gdbserver %s%s\n"
- "Copyright (C) 2023 Free Software Foundation, Inc.\n"
- "gdbserver is free software, covered by the "
- "GNU General Public License.\n"
- "This gdbserver was configured as \"%s\"\n",
- PKGVERSION, version, host_name);
+ "Copyright (C) 2023 Free Software Foundation, Inc.\n"
+ "gdbserver is free software, covered by the "
+ "GNU General Public License.\n"
+ "This gdbserver was configured as \"%s\"\n",
+ PKGVERSION, version, host_name);
}
static void
gdbserver_usage (FILE *stream)
{
- fprintf (stream, "Usage:\tgdbserver [OPTIONS] COMM PROG [ARGS ...]\n"
- "\tgdbserver [OPTIONS] --attach COMM PID\n"
- "\tgdbserver [OPTIONS] --multi COMM\n"
- "\n"
- "COMM may either be a tty device (for serial debugging),\n"
- "HOST:PORT to listen for a TCP connection, or '-' or 'stdio' to use \n"
- "stdin/stdout of gdbserver.\n"
- "PROG is the executable program. ARGS are arguments passed to inferior.\n"
- "PID is the process ID to attach to, when --attach is specified.\n"
- "\n"
- "Operating modes:\n"
- "\n"
- " --attach Attach to running process PID.\n"
- " --multi Start server without a specific program, and\n"
- " only quit when explicitly commanded.\n"
- " --once Exit after the first connection has closed.\n"
- " --help Print this message and then exit.\n"
- " --version Display version information and exit.\n"
- "\n"
- "Other options:\n"
- "\n"
- " --wrapper WRAPPER -- Run WRAPPER to start new programs.\n"
- " --disable-randomization\n"
- " Run PROG with address space randomization disabled.\n"
- " --no-disable-randomization\n"
- " Don't disable address space randomization when\n"
- " starting PROG.\n"
- " --startup-with-shell\n"
- " Start PROG using a shell. I.e., execs a shell that\n"
- " then execs PROG. (default)\n"
- " --no-startup-with-shell\n"
- " Exec PROG directly instead of using a shell.\n"
- " Disables argument globbing and variable substitution\n"
- " on UNIX-like systems.\n"
- "\n"
- "Debug options:\n"
- "\n"
- " --debug Enable general debugging output.\n"
- " --debug-format=OPT1[,OPT2,...]\n"
- " Specify extra content in debugging output.\n"
- " Options:\n"
- " all\n"
- " none\n"
- " timestamp\n"
- " --remote-debug Enable remote protocol debugging output.\n"
- " --event-loop-debug Enable event loop debugging output.\n"
- " --disable-packet=OPT1[,OPT2,...]\n"
- " Disable support for RSP packets or features.\n"
- " Options:\n"
- " vCont, T, Tthread, qC, qfThreadInfo and \n"
- " threads (disable all threading packets).\n"
- "\n"
- "For more information, consult the GDB manual (available as on-line \n"
- "info or a printed manual).\n");
+ fprintf (
+ stream,
+ "Usage:\tgdbserver [OPTIONS] COMM PROG [ARGS ...]\n"
+ "\tgdbserver [OPTIONS] --attach COMM PID\n"
+ "\tgdbserver [OPTIONS] --multi COMM\n"
+ "\n"
+ "COMM may either be a tty device (for serial debugging),\n"
+ "HOST:PORT to listen for a TCP connection, or '-' or 'stdio' to use \n"
+ "stdin/stdout of gdbserver.\n"
+ "PROG is the executable program. ARGS are arguments passed to inferior.\n"
+ "PID is the process ID to attach to, when --attach is specified.\n"
+ "\n"
+ "Operating modes:\n"
+ "\n"
+ " --attach Attach to running process PID.\n"
+ " --multi Start server without a specific program, and\n"
+ " only quit when explicitly commanded.\n"
+ " --once Exit after the first connection has closed.\n"
+ " --help Print this message and then exit.\n"
+ " --version Display version information and exit.\n"
+ "\n"
+ "Other options:\n"
+ "\n"
+ " --wrapper WRAPPER -- Run WRAPPER to start new programs.\n"
+ " --disable-randomization\n"
+ " Run PROG with address space randomization "
+ "disabled.\n"
+ " --no-disable-randomization\n"
+ " Don't disable address space randomization when\n"
+ " starting PROG.\n"
+ " --startup-with-shell\n"
+ " Start PROG using a shell. I.e., execs a shell "
+ "that\n"
+ " then execs PROG. (default)\n"
+ " --no-startup-with-shell\n"
+ " Exec PROG directly instead of using a shell.\n"
+ " Disables argument globbing and variable "
+ "substitution\n"
+ " on UNIX-like systems.\n"
+ "\n"
+ "Debug options:\n"
+ "\n"
+ " --debug Enable general debugging output.\n"
+ " --debug-format=OPT1[,OPT2,...]\n"
+ " Specify extra content in debugging output.\n"
+ " Options:\n"
+ " all\n"
+ " none\n"
+ " timestamp\n"
+ " --remote-debug Enable remote protocol debugging output.\n"
+ " --event-loop-debug Enable event loop debugging output.\n"
+ " --disable-packet=OPT1[,OPT2,...]\n"
+ " Disable support for RSP packets or features.\n"
+ " Options:\n"
+ " vCont, T, Tthread, qC, qfThreadInfo and \n"
+ " threads (disable all threading packets).\n"
+ "\n"
+ "For more information, consult the GDB manual (available as on-line \n"
+ "info or a printed manual).\n");
if (REPORT_BUGS_TO[0] && stream == stdout)
fprintf (stream, "Report bugs to \"%s\".\n", REPORT_BUGS_TO);
}
@@ -3486,13 +3466,13 @@ static void
gdbserver_show_disableable (FILE *stream)
{
fprintf (stream, "Disableable packets:\n"
- " vCont \tAll vCont packets\n"
- " qC \tQuerying the current thread\n"
- " qfThreadInfo\tThread listing\n"
- " Tthread \tPassing the thread specifier in the "
- "T stop reply packet\n"
- " threads \tAll of the above\n"
- " T \tAll 'T' packets\n");
+ " vCont \tAll vCont packets\n"
+ " qC \tQuerying the current thread\n"
+ " qfThreadInfo\tThread listing\n"
+ " Tthread \tPassing the thread specifier in the "
+ "T stop reply packet\n"
+ " threads \tAll of the above\n"
+ " T \tAll 'T' packets\n");
}
/* Start up the event loop. This is the entry point to the event
@@ -3514,7 +3494,7 @@ start_event_loop ()
/* Was there an error? */
if (res == -1)
- break;
+ break;
}
/* We are done with the event loop. There are no more event sources
@@ -3544,8 +3524,8 @@ detach_or_kill_for_exit (void)
fprintf (stderr, "Killing process(es):");
for_each_process ([] (process_info *process) {
- if (!process->attached)
- fprintf (stderr, " %d", process->pid);
+ if (!process->attached)
+ fprintf (stderr, " %d", process->pid);
});
fprintf (stderr, "\n");
@@ -3555,8 +3535,8 @@ detach_or_kill_for_exit (void)
fprintf (stderr, "Detaching process(es):");
for_each_process ([] (process_info *process) {
- if (process->attached)
- fprintf (stderr, " %d", process->pid);
+ if (process->attached)
+ fprintf (stderr, " %d", process->pid);
});
fprintf (stderr, "\n");
@@ -3591,15 +3571,15 @@ detach_or_kill_for_exit_cleanup ()
catch (const gdb_exception &exception)
{
fflush (stdout);
- fprintf (stderr, "Detach or kill failed: %s\n",
- exception.what ());
+ fprintf (stderr, "Detach or kill failed: %s\n", exception.what ());
exit_code = 1;
}
}
#if GDB_SELF_TEST
-namespace selftests {
+namespace selftests
+{
static void
test_memory_tagging_functions (void)
@@ -3651,8 +3631,9 @@ test_memory_tagging_functions (void)
type = 255;
tags.resize (5);
strcpy (packet.data (), "QMemTags:0,0:0:");
- SELF_CHECK (parse_store_memtags_request (packet.data (),
- &addr, &len, tags, &type) == true);
+ SELF_CHECK (
+ parse_store_memtags_request (packet.data (), &addr, &len, tags, &type)
+ == true);
SELF_CHECK (addr == 0 && len == 0 && type == 0 && tags.size () == 0);
/* Valid request and non-empty tag data: addr, len, type
@@ -3661,12 +3642,12 @@ test_memory_tagging_functions (void)
len = 0;
type = 0;
tags.resize (0);
- strcpy (packet.data (),
- "QMemTags:deadbeef,ff:5:0001020304");
- SELF_CHECK (parse_store_memtags_request (packet.data (), &addr, &len, tags,
- &type) == true);
+ strcpy (packet.data (), "QMemTags:deadbeef,ff:5:0001020304");
+ SELF_CHECK (
+ parse_store_memtags_request (packet.data (), &addr, &len, tags, &type)
+ == true);
SELF_CHECK (addr == 0xdeadbeef && len == 255 && type == 5
- && tags.size () == 5);
+ && tags.size () == 5);
}
} // namespace selftests
@@ -3691,7 +3672,7 @@ captured_main (int argc, char *argv[])
std::vector<const char *> selftest_filters;
selftests::register_test ("remote_memory_tagging",
- selftests::test_memory_tagging_functions);
+ selftests::test_memory_tagging_functions);
#endif
current_directory = getcwd (NULL, 0);
@@ -3699,154 +3680,154 @@ captured_main (int argc, char *argv[])
if (current_directory == NULL)
{
- error (_("Could not find current working directory: %s"),
- safe_strerror (errno));
+ error (_ ("Could not find current working directory: %s"),
+ safe_strerror (errno));
}
while (*next_arg != NULL && **next_arg == '-')
{
if (strcmp (*next_arg, "--version") == 0)
- {
- gdbserver_version ();
- exit (0);
- }
+ {
+ gdbserver_version ();
+ exit (0);
+ }
else if (strcmp (*next_arg, "--help") == 0)
- {
- gdbserver_usage (stdout);
- exit (0);
- }
+ {
+ gdbserver_usage (stdout);
+ exit (0);
+ }
else if (strcmp (*next_arg, "--attach") == 0)
- attach = 1;
+ attach = 1;
else if (strcmp (*next_arg, "--multi") == 0)
- multi_mode = 1;
+ multi_mode = 1;
else if (strcmp (*next_arg, "--wrapper") == 0)
- {
- char **tmp;
-
- next_arg++;
-
- tmp = next_arg;
- while (*next_arg != NULL && strcmp (*next_arg, "--") != 0)
- {
- wrapper_argv += *next_arg;
- wrapper_argv += ' ';
- next_arg++;
- }
-
- if (!wrapper_argv.empty ())
- {
- /* Erase the last whitespace. */
- wrapper_argv.erase (wrapper_argv.end () - 1);
- }
-
- if (next_arg == tmp || *next_arg == NULL)
- {
- gdbserver_usage (stderr);
- exit (1);
- }
-
- /* Consume the "--". */
- *next_arg = NULL;
- }
+ {
+ char **tmp;
+
+ next_arg++;
+
+ tmp = next_arg;
+ while (*next_arg != NULL && strcmp (*next_arg, "--") != 0)
+ {
+ wrapper_argv += *next_arg;
+ wrapper_argv += ' ';
+ next_arg++;
+ }
+
+ if (!wrapper_argv.empty ())
+ {
+ /* Erase the last whitespace. */
+ wrapper_argv.erase (wrapper_argv.end () - 1);
+ }
+
+ if (next_arg == tmp || *next_arg == NULL)
+ {
+ gdbserver_usage (stderr);
+ exit (1);
+ }
+
+ /* Consume the "--". */
+ *next_arg = NULL;
+ }
else if (strcmp (*next_arg, "--debug") == 0)
- debug_threads = true;
+ debug_threads = true;
else if (startswith (*next_arg, "--debug-format="))
- {
- std::string error_msg
- = parse_debug_format_options ((*next_arg)
- + sizeof ("--debug-format=") - 1, 0);
-
- if (!error_msg.empty ())
- {
- fprintf (stderr, "%s", error_msg.c_str ());
- exit (1);
- }
- }
+ {
+ std::string error_msg
+ = parse_debug_format_options ((*next_arg)
+ + sizeof ("--debug-format=") - 1,
+ 0);
+
+ if (!error_msg.empty ())
+ {
+ fprintf (stderr, "%s", error_msg.c_str ());
+ exit (1);
+ }
+ }
else if (strcmp (*next_arg, "--remote-debug") == 0)
- remote_debug = true;
+ remote_debug = true;
else if (strcmp (*next_arg, "--event-loop-debug") == 0)
- debug_event_loop = debug_event_loop_kind::ALL;
+ debug_event_loop = debug_event_loop_kind::ALL;
else if (startswith (*next_arg, "--debug-file="))
- debug_set_output ((*next_arg) + sizeof ("--debug-file=") -1);
+ debug_set_output ((*next_arg) + sizeof ("--debug-file=") - 1);
else if (strcmp (*next_arg, "--disable-packet") == 0)
- {
- gdbserver_show_disableable (stdout);
- exit (0);
- }
+ {
+ gdbserver_show_disableable (stdout);
+ exit (0);
+ }
else if (startswith (*next_arg, "--disable-packet="))
- {
- char *packets = *next_arg += sizeof ("--disable-packet=") - 1;
- char *saveptr;
- for (char *tok = strtok_r (packets, ",", &saveptr);
- tok != NULL;
- tok = strtok_r (NULL, ",", &saveptr))
- {
- if (strcmp ("vCont", tok) == 0)
- disable_packet_vCont = true;
- else if (strcmp ("Tthread", tok) == 0)
- disable_packet_Tthread = true;
- else if (strcmp ("qC", tok) == 0)
- disable_packet_qC = true;
- else if (strcmp ("qfThreadInfo", tok) == 0)
- disable_packet_qfThreadInfo = true;
- else if (strcmp ("T", tok) == 0)
- disable_packet_T = true;
- else if (strcmp ("threads", tok) == 0)
- {
- disable_packet_vCont = true;
- disable_packet_Tthread = true;
- disable_packet_qC = true;
- disable_packet_qfThreadInfo = true;
- }
- else
- {
- fprintf (stderr, "Don't know how to disable \"%s\".\n\n",
- tok);
- gdbserver_show_disableable (stderr);
- exit (1);
- }
- }
- }
+ {
+ char *packets = *next_arg += sizeof ("--disable-packet=") - 1;
+ char *saveptr;
+ for (char *tok = strtok_r (packets, ",", &saveptr); tok != NULL;
+ tok = strtok_r (NULL, ",", &saveptr))
+ {
+ if (strcmp ("vCont", tok) == 0)
+ disable_packet_vCont = true;
+ else if (strcmp ("Tthread", tok) == 0)
+ disable_packet_Tthread = true;
+ else if (strcmp ("qC", tok) == 0)
+ disable_packet_qC = true;
+ else if (strcmp ("qfThreadInfo", tok) == 0)
+ disable_packet_qfThreadInfo = true;
+ else if (strcmp ("T", tok) == 0)
+ disable_packet_T = true;
+ else if (strcmp ("threads", tok) == 0)
+ {
+ disable_packet_vCont = true;
+ disable_packet_Tthread = true;
+ disable_packet_qC = true;
+ disable_packet_qfThreadInfo = true;
+ }
+ else
+ {
+ fprintf (stderr, "Don't know how to disable \"%s\".\n\n",
+ tok);
+ gdbserver_show_disableable (stderr);
+ exit (1);
+ }
+ }
+ }
else if (strcmp (*next_arg, "-") == 0)
- {
- /* "-" specifies a stdio connection and is a form of port
+ {
+ /* "-" specifies a stdio connection and is a form of port
specification. */
- port = STDIO_CONNECTION_NAME;
- next_arg++;
- break;
- }
+ port = STDIO_CONNECTION_NAME;
+ next_arg++;
+ break;
+ }
else if (strcmp (*next_arg, "--disable-randomization") == 0)
- cs.disable_randomization = 1;
+ cs.disable_randomization = 1;
else if (strcmp (*next_arg, "--no-disable-randomization") == 0)
- cs.disable_randomization = 0;
+ cs.disable_randomization = 0;
else if (strcmp (*next_arg, "--startup-with-shell") == 0)
- startup_with_shell = true;
+ startup_with_shell = true;
else if (strcmp (*next_arg, "--no-startup-with-shell") == 0)
- startup_with_shell = false;
+ startup_with_shell = false;
else if (strcmp (*next_arg, "--once") == 0)
- run_once = true;
+ run_once = true;
else if (strcmp (*next_arg, "--selftest") == 0)
- selftest = true;
+ selftest = true;
else if (startswith (*next_arg, "--selftest="))
- {
- selftest = true;
+ {
+ selftest = true;
#if GDB_SELF_TEST
- const char *filter = *next_arg + strlen ("--selftest=");
- if (*filter == '\0')
- {
- fprintf (stderr, _("Error: selftest filter is empty.\n"));
- exit (1);
- }
-
- selftest_filters.push_back (filter);
+ const char *filter = *next_arg + strlen ("--selftest=");
+ if (*filter == '\0')
+ {
+ fprintf (stderr, _ ("Error: selftest filter is empty.\n"));
+ exit (1);
+ }
+
+ selftest_filters.push_back (filter);
#endif
- }
+ }
else
- {
- fprintf (stderr, "Unknown argument: %s\n", *next_arg);
- exit (1);
- }
+ {
+ fprintf (stderr, "Unknown argument: %s\n", *next_arg);
+ exit (1);
+ }
next_arg++;
continue;
@@ -3858,7 +3839,7 @@ captured_main (int argc, char *argv[])
next_arg++;
}
if ((port == NULL || (!attach && !multi_mode && *next_arg == NULL))
- && !selftest)
+ && !selftest)
{
gdbserver_usage (stderr);
exit (1);
@@ -3889,11 +3870,9 @@ captured_main (int argc, char *argv[])
}
if (attach
- && (*next_arg == NULL
- || (*next_arg)[0] == '\0'
- || (pid = strtoul (*next_arg, &arg_end, 0)) == 0
- || *arg_end != '\0'
- || next_arg[1] != NULL))
+ && (*next_arg == NULL || (*next_arg)[0] == '\0'
+ || (pid = strtoul (*next_arg, &arg_end, 0)) == 0 || *arg_end != '\0'
+ || next_arg[1] != NULL))
bad_attach = 1;
if (bad_attach)
@@ -3918,7 +3897,7 @@ captured_main (int argc, char *argv[])
#if GDB_SELF_TEST
selftests::run_tests (selftest_filters);
#else
- printf (_("Selftests have been disabled for this build.\n"));
+ printf (_ ("Selftests have been disabled for this build.\n"));
#endif
throw_quit ("Quit");
}
@@ -3930,7 +3909,7 @@ captured_main (int argc, char *argv[])
n = argc - (next_arg - argv);
program_path.set (next_arg[0]);
for (i = 1; i < n; i++)
- program_args.push_back (xstrdup (next_arg[i]));
+ program_args.push_back (xstrdup (next_arg[i]));
/* Wait till we are at first instruction in program. */
target_create_inferior (program_path.get (), program_args);
@@ -3942,7 +3921,7 @@ captured_main (int argc, char *argv[])
else if (pid != 0)
{
if (attach_inferior (pid) == -1)
- error ("Attaching not supported on this target");
+ error ("Attaching not supported on this target");
/* Otherwise succeeded. */
}
@@ -3952,7 +3931,10 @@ captured_main (int argc, char *argv[])
cs.last_ptid = minus_one_ptid;
}
- SCOPE_EXIT { detach_or_kill_for_exit_cleanup (); };
+ SCOPE_EXIT
+ {
+ detach_or_kill_for_exit_cleanup ();
+ };
/* Don't report shared library events on the initial connection,
even if some libraries are preloaded. Avoids the "stopped by
@@ -3987,17 +3969,17 @@ captured_main (int argc, char *argv[])
remote_open (port);
try
- {
- /* Wait for events. This will return when all event sources
+ {
+ /* Wait for events. This will return when all event sources
are removed from the event loop. */
- start_event_loop ();
+ start_event_loop ();
- /* If an exit was requested (using the "monitor exit"
+ /* If an exit was requested (using the "monitor exit"
command), terminate now. */
- if (exit_requested)
- throw_quit ("Quit");
+ if (exit_requested)
+ throw_quit ("Quit");
- /* The only other way to get here is for getpkt to fail:
+ /* The only other way to get here is for getpkt to fail:
- If --once was specified, we're done.
@@ -4007,64 +3989,60 @@ captured_main (int argc, char *argv[])
- Otherwise, close the connection and reopen it at the
top of the loop. */
- if (run_once || (!extended_protocol && !target_running ()))
- throw_quit ("Quit");
+ if (run_once || (!extended_protocol && !target_running ()))
+ throw_quit ("Quit");
- fprintf (stderr,
- "Remote side has terminated connection. "
- "GDBserver will reopen the connection.\n");
+ fprintf (stderr, "Remote side has terminated connection. "
+ "GDBserver will reopen the connection.\n");
- /* Get rid of any pending statuses. An eventual reconnection
+ /* Get rid of any pending statuses. An eventual reconnection
(by the same GDB instance or another) will refresh all its
state from scratch. */
- discard_queued_stop_replies (minus_one_ptid);
- for_each_thread ([] (thread_info *thread)
- {
- thread->status_pending_p = 0;
- });
-
- if (tracing)
- {
- if (disconnected_tracing)
- {
- /* Try to enable non-stop/async mode, so we we can
+ discard_queued_stop_replies (minus_one_ptid);
+ for_each_thread (
+ [] (thread_info *thread) { thread->status_pending_p = 0; });
+
+ if (tracing)
+ {
+ if (disconnected_tracing)
+ {
+ /* Try to enable non-stop/async mode, so we we can
both wait for an async socket accept, and handle
async target events simultaneously. There's also
no point either in having the target always stop
all threads, when we're going to pass signals
down without informing GDB. */
- if (!non_stop)
- {
- if (the_target->start_non_stop (true))
- non_stop = 1;
+ if (!non_stop)
+ {
+ if (the_target->start_non_stop (true))
+ non_stop = 1;
- /* Detaching implicitly resumes all threads;
+ /* Detaching implicitly resumes all threads;
simply disconnecting does not. */
- }
- }
- else
- {
- fprintf (stderr,
- "Disconnected tracing disabled; "
- "stopping trace run.\n");
- stop_tracing ();
- }
- }
- }
+ }
+ }
+ else
+ {
+ fprintf (stderr, "Disconnected tracing disabled; "
+ "stopping trace run.\n");
+ stop_tracing ();
+ }
+ }
+ }
catch (const gdb_exception_error &exception)
- {
- fflush (stdout);
- fprintf (stderr, "gdbserver: %s\n", exception.what ());
+ {
+ fflush (stdout);
+ fprintf (stderr, "gdbserver: %s\n", exception.what ());
- if (response_needed)
- {
- write_enn (cs.own_buf);
- putpkt (cs.own_buf);
- }
+ if (response_needed)
+ {
+ write_enn (cs.own_buf);
+ putpkt (cs.own_buf);
+ }
- if (run_once)
- throw_quit ("Quit");
- }
+ if (run_once)
+ throw_quit ("Quit");
+ }
}
}
@@ -4073,7 +4051,6 @@ captured_main (int argc, char *argv[])
int
main (int argc, char *argv[])
{
-
try
{
captured_main (argc, argv);
@@ -4081,12 +4058,12 @@ main (int argc, char *argv[])
catch (const gdb_exception &exception)
{
if (exception.reason == RETURN_ERROR)
- {
- fflush (stdout);
- fprintf (stderr, "%s\n", exception.what ());
- fprintf (stderr, "Exiting\n");
- exit_code = 1;
- }
+ {
+ fflush (stdout);
+ fprintf (stderr, "%s\n", exception.what ());
+ fprintf (stderr, "Exiting\n");
+ exit_code = 1;
+ }
exit (exit_code);
}
@@ -4113,31 +4090,30 @@ process_point_options (struct gdb_breakpoint *bp, const char **packet)
while (*dataptr)
{
if (*dataptr == ';')
- ++dataptr;
+ ++dataptr;
if (*dataptr == 'X')
- {
- /* Conditional expression. */
- threads_debug_printf ("Found breakpoint condition.");
- if (!add_breakpoint_condition (bp, &dataptr))
- dataptr = strchrnul (dataptr, ';');
- }
+ {
+ /* Conditional expression. */
+ threads_debug_printf ("Found breakpoint condition.");
+ if (!add_breakpoint_condition (bp, &dataptr))
+ dataptr = strchrnul (dataptr, ';');
+ }
else if (startswith (dataptr, "cmds:"))
- {
- dataptr += strlen ("cmds:");
- threads_debug_printf ("Found breakpoint commands %s.", dataptr);
- persist = (*dataptr == '1');
- dataptr += 2;
- if (add_breakpoint_commands (bp, &dataptr, persist))
- dataptr = strchrnul (dataptr, ';');
- }
+ {
+ dataptr += strlen ("cmds:");
+ threads_debug_printf ("Found breakpoint commands %s.", dataptr);
+ persist = (*dataptr == '1');
+ dataptr += 2;
+ if (add_breakpoint_commands (bp, &dataptr, persist))
+ dataptr = strchrnul (dataptr, ';');
+ }
else
- {
- fprintf (stderr, "Unknown token %c, ignoring.\n",
- *dataptr);
- /* Skip tokens until we find one that we recognize. */
- dataptr = strchrnul (dataptr, ';');
- }
+ {
+ fprintf (stderr, "Unknown token %c, ignoring.\n", *dataptr);
+ /* Skip tokens until we find one that we recognize. */
+ dataptr = strchrnul (dataptr, ';');
+ }
}
*packet = dataptr;
}
@@ -4191,154 +4167,155 @@ process_serial_event (void)
break;
case 'H':
if (cs.own_buf[1] == 'c' || cs.own_buf[1] == 'g' || cs.own_buf[1] == 's')
- {
- require_running_or_break (cs.own_buf);
-
- ptid_t thread_id = read_ptid (&cs.own_buf[2], NULL);
-
- if (thread_id == null_ptid || thread_id == minus_one_ptid)
- thread_id = null_ptid;
- else if (thread_id.is_pid ())
- {
- /* The ptid represents a pid. */
- thread_info *thread = find_any_thread_of_pid (thread_id.pid ());
-
- if (thread == NULL)
- {
- write_enn (cs.own_buf);
- break;
- }
-
- thread_id = thread->id;
- }
- else
- {
- /* The ptid represents a lwp/tid. */
- if (find_thread_ptid (thread_id) == NULL)
- {
- write_enn (cs.own_buf);
- break;
- }
- }
-
- if (cs.own_buf[1] == 'g')
- {
- if (thread_id == null_ptid)
- {
- /* GDB is telling us to choose any thread. Check if
+ {
+ require_running_or_break (cs.own_buf);
+
+ ptid_t thread_id = read_ptid (&cs.own_buf[2], NULL);
+
+ if (thread_id == null_ptid || thread_id == minus_one_ptid)
+ thread_id = null_ptid;
+ else if (thread_id.is_pid ())
+ {
+ /* The ptid represents a pid. */
+ thread_info *thread = find_any_thread_of_pid (thread_id.pid ());
+
+ if (thread == NULL)
+ {
+ write_enn (cs.own_buf);
+ break;
+ }
+
+ thread_id = thread->id;
+ }
+ else
+ {
+ /* The ptid represents a lwp/tid. */
+ if (find_thread_ptid (thread_id) == NULL)
+ {
+ write_enn (cs.own_buf);
+ break;
+ }
+ }
+
+ if (cs.own_buf[1] == 'g')
+ {
+ if (thread_id == null_ptid)
+ {
+ /* GDB is telling us to choose any thread. Check if
the currently selected thread is still valid. If
it is not, select the first available. */
- thread_info *thread = find_thread_ptid (cs.general_thread);
- if (thread == NULL)
- thread = get_first_thread ();
- thread_id = thread->id;
- }
-
- cs.general_thread = thread_id;
- set_desired_thread ();
- gdb_assert (current_thread != NULL);
- }
- else if (cs.own_buf[1] == 'c')
- cs.cont_thread = thread_id;
-
- write_ok (cs.own_buf);
- }
+ thread_info *thread = find_thread_ptid (cs.general_thread);
+ if (thread == NULL)
+ thread = get_first_thread ();
+ thread_id = thread->id;
+ }
+
+ cs.general_thread = thread_id;
+ set_desired_thread ();
+ gdb_assert (current_thread != NULL);
+ }
+ else if (cs.own_buf[1] == 'c')
+ cs.cont_thread = thread_id;
+
+ write_ok (cs.own_buf);
+ }
else
- {
- /* Silently ignore it so that gdb can extend the protocol
+ {
+ /* Silently ignore it so that gdb can extend the protocol
without compatibility headaches. */
- cs.own_buf[0] = '\0';
- }
+ cs.own_buf[0] = '\0';
+ }
break;
case 'g':
require_running_or_break (cs.own_buf);
if (cs.current_traceframe >= 0)
- {
- struct regcache *regcache
- = new_register_cache (current_target_desc ());
-
- if (fetch_traceframe_registers (cs.current_traceframe,
- regcache, -1) == 0)
- registers_to_string (regcache, cs.own_buf);
- else
- write_enn (cs.own_buf);
- free_register_cache (regcache);
- }
+ {
+ struct regcache *regcache
+ = new_register_cache (current_target_desc ());
+
+ if (fetch_traceframe_registers (cs.current_traceframe, regcache, -1)
+ == 0)
+ registers_to_string (regcache, cs.own_buf);
+ else
+ write_enn (cs.own_buf);
+ free_register_cache (regcache);
+ }
else
- {
- struct regcache *regcache;
-
- if (!set_desired_thread ())
- write_enn (cs.own_buf);
- else
- {
- regcache = get_thread_regcache (current_thread, 1);
- registers_to_string (regcache, cs.own_buf);
- }
- }
+ {
+ struct regcache *regcache;
+
+ if (!set_desired_thread ())
+ write_enn (cs.own_buf);
+ else
+ {
+ regcache = get_thread_regcache (current_thread, 1);
+ registers_to_string (regcache, cs.own_buf);
+ }
+ }
break;
case 'G':
require_running_or_break (cs.own_buf);
if (cs.current_traceframe >= 0)
- write_enn (cs.own_buf);
+ write_enn (cs.own_buf);
else
- {
- struct regcache *regcache;
-
- if (!set_desired_thread ())
- write_enn (cs.own_buf);
- else
- {
- regcache = get_thread_regcache (current_thread, 1);
- registers_from_string (regcache, &cs.own_buf[1]);
- write_ok (cs.own_buf);
- }
- }
+ {
+ struct regcache *regcache;
+
+ if (!set_desired_thread ())
+ write_enn (cs.own_buf);
+ else
+ {
+ regcache = get_thread_regcache (current_thread, 1);
+ registers_from_string (regcache, &cs.own_buf[1]);
+ write_ok (cs.own_buf);
+ }
+ }
break;
case 'm':
{
- require_running_or_break (cs.own_buf);
- decode_m_packet (&cs.own_buf[1], &mem_addr, &len);
- int res = gdb_read_memory (mem_addr, mem_buf, len);
- if (res < 0)
- write_enn (cs.own_buf);
- else
- bin2hex (mem_buf, cs.own_buf, res);
+ require_running_or_break (cs.own_buf);
+ decode_m_packet (&cs.own_buf[1], &mem_addr, &len);
+ int res = gdb_read_memory (mem_addr, mem_buf, len);
+ if (res < 0)
+ write_enn (cs.own_buf);
+ else
+ bin2hex (mem_buf, cs.own_buf, res);
}
break;
case 'M':
require_running_or_break (cs.own_buf);
decode_M_packet (&cs.own_buf[1], &mem_addr, &len, &mem_buf);
if (gdb_write_memory (mem_addr, mem_buf, len) == 0)
- write_ok (cs.own_buf);
+ write_ok (cs.own_buf);
else
- write_enn (cs.own_buf);
+ write_enn (cs.own_buf);
break;
case 'X':
require_running_or_break (cs.own_buf);
- if (decode_X_packet (&cs.own_buf[1], packet_len - 1,
- &mem_addr, &len, &mem_buf) < 0
- || gdb_write_memory (mem_addr, mem_buf, len) != 0)
- write_enn (cs.own_buf);
+ if (decode_X_packet (&cs.own_buf[1], packet_len - 1, &mem_addr, &len,
+ &mem_buf)
+ < 0
+ || gdb_write_memory (mem_addr, mem_buf, len) != 0)
+ write_enn (cs.own_buf);
else
- write_ok (cs.own_buf);
+ write_ok (cs.own_buf);
break;
case 'C':
require_running_or_break (cs.own_buf);
hex2bin (cs.own_buf + 1, &sig, 1);
if (gdb_signal_to_host_p ((enum gdb_signal) sig))
- signal = gdb_signal_to_host ((enum gdb_signal) sig);
+ signal = gdb_signal_to_host ((enum gdb_signal) sig);
else
- signal = 0;
+ signal = 0;
myresume (cs.own_buf, 0, signal);
break;
case 'S':
require_running_or_break (cs.own_buf);
hex2bin (cs.own_buf + 1, &sig, 1);
if (gdb_signal_to_host_p ((enum gdb_signal) sig))
- signal = gdb_signal_to_host ((enum gdb_signal) sig);
+ signal = gdb_signal_to_host ((enum gdb_signal) sig);
else
- signal = 0;
+ signal = 0;
myresume (cs.own_buf, 1, signal);
break;
case 'c':
@@ -4351,58 +4328,58 @@ process_serial_event (void)
signal = 0;
myresume (cs.own_buf, 1, signal);
break;
- case 'Z': /* insert_ ... */
+ case 'Z': /* insert_ ... */
/* Fallthrough. */
- case 'z': /* remove_ ... */
+ case 'z': /* remove_ ... */
{
- char *dataptr;
- ULONGEST addr;
- int kind;
- char type = cs.own_buf[1];
- int res;
- const int insert = ch == 'Z';
- const char *p = &cs.own_buf[3];
-
- p = unpack_varlen_hex (p, &addr);
- kind = strtol (p + 1, &dataptr, 16);
-
- if (insert)
- {
- struct gdb_breakpoint *bp;
-
- bp = set_gdb_breakpoint (type, addr, kind, &res);
- if (bp != NULL)
- {
- res = 0;
-
- /* GDB may have sent us a list of *point parameters to
+ char *dataptr;
+ ULONGEST addr;
+ int kind;
+ char type = cs.own_buf[1];
+ int res;
+ const int insert = ch == 'Z';
+ const char *p = &cs.own_buf[3];
+
+ p = unpack_varlen_hex (p, &addr);
+ kind = strtol (p + 1, &dataptr, 16);
+
+ if (insert)
+ {
+ struct gdb_breakpoint *bp;
+
+ bp = set_gdb_breakpoint (type, addr, kind, &res);
+ if (bp != NULL)
+ {
+ res = 0;
+
+ /* GDB may have sent us a list of *point parameters to
be evaluated on the target's side. Read such list
here. If we already have a list of parameters, GDB
is telling us to drop that list and use this one
instead. */
- clear_breakpoint_conditions_and_commands (bp);
- const char *options = dataptr;
- process_point_options (bp, &options);
- }
- }
- else
- res = delete_gdb_breakpoint (type, addr, kind);
-
- if (res == 0)
- write_ok (cs.own_buf);
- else if (res == 1)
- /* Unsupported. */
- cs.own_buf[0] = '\0';
- else
- write_enn (cs.own_buf);
- break;
+ clear_breakpoint_conditions_and_commands (bp);
+ const char *options = dataptr;
+ process_point_options (bp, &options);
+ }
+ }
+ else
+ res = delete_gdb_breakpoint (type, addr, kind);
+
+ if (res == 0)
+ write_ok (cs.own_buf);
+ else if (res == 1)
+ /* Unsupported. */
+ cs.own_buf[0] = '\0';
+ else
+ write_enn (cs.own_buf);
+ break;
}
case 'k':
response_needed = false;
if (!target_running ())
- /* The packet we received doesn't make sense - but we can't
+ /* The packet we received doesn't make sense - but we can't
reply to it, either. */
- return 0;
+ return 0;
fprintf (stderr, "Killing all inferiors\n");
@@ -4411,28 +4388,28 @@ process_serial_event (void)
/* When using the extended protocol, we wait with no program
running. The traditional protocol will exit instead. */
if (extended_protocol)
- {
- cs.last_status.set_exited (GDB_SIGNAL_KILL);
- return 0;
- }
+ {
+ cs.last_status.set_exited (GDB_SIGNAL_KILL);
+ return 0;
+ }
else
- exit (0);
+ exit (0);
case 'T':
{
- require_running_or_break (cs.own_buf);
-
- ptid_t thread_id = read_ptid (&cs.own_buf[1], NULL);
- if (find_thread_ptid (thread_id) == NULL)
- {
- write_enn (cs.own_buf);
- break;
- }
-
- if (mythread_alive (thread_id))
- write_ok (cs.own_buf);
- else
- write_enn (cs.own_buf);
+ require_running_or_break (cs.own_buf);
+
+ ptid_t thread_id = read_ptid (&cs.own_buf[1], NULL);
+ if (find_thread_ptid (thread_id) == NULL)
+ {
+ write_enn (cs.own_buf);
+ break;
+ }
+
+ if (mythread_alive (thread_id))
+ write_ok (cs.own_buf);
+ else
+ write_enn (cs.own_buf);
}
break;
case 'R':
@@ -4441,43 +4418,43 @@ process_serial_event (void)
/* Restarting the inferior is only supported in the extended
protocol. */
if (extended_protocol)
- {
- if (target_running ())
- for_each_process (kill_inferior_callback);
+ {
+ if (target_running ())
+ for_each_process (kill_inferior_callback);
- fprintf (stderr, "GDBserver restarting\n");
+ fprintf (stderr, "GDBserver restarting\n");
- /* Wait till we are at 1st instruction in prog. */
- if (program_path.get () != NULL)
- {
- target_create_inferior (program_path.get (), program_args);
+ /* Wait till we are at 1st instruction in prog. */
+ if (program_path.get () != NULL)
+ {
+ target_create_inferior (program_path.get (), program_args);
- if (cs.last_status.kind () == TARGET_WAITKIND_STOPPED)
- {
- /* Stopped at the first instruction of the target
+ if (cs.last_status.kind () == TARGET_WAITKIND_STOPPED)
+ {
+ /* Stopped at the first instruction of the target
process. */
- cs.general_thread = cs.last_ptid;
- }
- else
- {
- /* Something went wrong. */
- cs.general_thread = null_ptid;
- }
- }
- else
- {
- cs.last_status.set_exited (GDB_SIGNAL_KILL);
- }
- return 0;
- }
+ cs.general_thread = cs.last_ptid;
+ }
+ else
+ {
+ /* Something went wrong. */
+ cs.general_thread = null_ptid;
+ }
+ }
+ else
+ {
+ cs.last_status.set_exited (GDB_SIGNAL_KILL);
+ }
+ return 0;
+ }
else
- {
- /* It is a request we don't understand. Respond with an
+ {
+ /* It is a request we don't understand. Respond with an
empty packet so that gdb knows that we don't support this
request. */
- cs.own_buf[0] = '\0';
- break;
- }
+ cs.own_buf[0] = '\0';
+ break;
+ }
case 'v':
/* Extended (long) request. */
handle_v_requests (cs.own_buf, packet_len, &new_packet_len);
@@ -4544,13 +4521,12 @@ handle_target_event (int err, gdb_client_data client_data)
client_state &cs = get_client_state ();
threads_debug_printf ("handling possible target event");
- cs.last_ptid = mywait (minus_one_ptid, &cs.last_status,
- TARGET_WNOHANG, 1);
+ cs.last_ptid = mywait (minus_one_ptid, &cs.last_status, TARGET_WNOHANG, 1);
if (cs.last_status.kind () == TARGET_WAITKIND_NO_RESUMED)
{
if (gdb_connected () && report_no_resumed)
- push_stop_notification (null_ptid, cs.last_status);
+ push_stop_notification (null_ptid, cs.last_status);
}
else if (cs.last_status.kind () != TARGET_WAITKIND_IGNORE)
{
@@ -4559,55 +4535,56 @@ handle_target_event (int err, gdb_client_data client_data)
int forward_event = !gdb_connected () || process->gdb_detached;
if (cs.last_status.kind () == TARGET_WAITKIND_EXITED
- || cs.last_status.kind () == TARGET_WAITKIND_SIGNALLED)
- {
- mark_breakpoints_out (process);
- target_mourn_inferior (cs.last_ptid);
- }
+ || cs.last_status.kind () == TARGET_WAITKIND_SIGNALLED)
+ {
+ mark_breakpoints_out (process);
+ target_mourn_inferior (cs.last_ptid);
+ }
else if (cs.last_status.kind () == TARGET_WAITKIND_THREAD_EXITED)
- ;
+ ;
else
- {
- /* We're reporting this thread as stopped. Update its
+ {
+ /* We're reporting this thread as stopped. Update its
"want-stopped" state to what the client wants, until it
gets a new resume action. */
- current_thread->last_resume_kind = resume_stop;
- current_thread->last_status = cs.last_status;
- }
+ current_thread->last_resume_kind = resume_stop;
+ current_thread->last_status = cs.last_status;
+ }
if (forward_event)
- {
- if (!target_running ())
- {
- /* The last process exited. We're done. */
- exit (0);
- }
-
- if (cs.last_status.kind () == TARGET_WAITKIND_EXITED
- || cs.last_status.kind () == TARGET_WAITKIND_SIGNALLED
- || cs.last_status.kind () == TARGET_WAITKIND_THREAD_EXITED)
- ;
- else
- {
- /* A thread stopped with a signal, but gdb isn't
+ {
+ if (!target_running ())
+ {
+ /* The last process exited. We're done. */
+ exit (0);
+ }
+
+ if (cs.last_status.kind () == TARGET_WAITKIND_EXITED
+ || cs.last_status.kind () == TARGET_WAITKIND_SIGNALLED
+ || cs.last_status.kind () == TARGET_WAITKIND_THREAD_EXITED)
+ ;
+ else
+ {
+ /* A thread stopped with a signal, but gdb isn't
connected to handle it. Pass it down to the
inferior, as if it wasn't being traced. */
- enum gdb_signal signal;
-
- threads_debug_printf ("GDB not connected; forwarding event %d for"
- " [%s]",
- (int) cs.last_status.kind (),
- target_pid_to_str (cs.last_ptid).c_str ());
-
- if (cs.last_status.kind () == TARGET_WAITKIND_STOPPED)
- signal = cs.last_status.sig ();
- else
- signal = GDB_SIGNAL_0;
- target_continue (cs.last_ptid, signal);
- }
- }
+ enum gdb_signal signal;
+
+ threads_debug_printf (
+ "GDB not connected; forwarding event %d for"
+ " [%s]",
+ (int) cs.last_status.kind (),
+ target_pid_to_str (cs.last_ptid).c_str ());
+
+ if (cs.last_status.kind () == TARGET_WAITKIND_STOPPED)
+ signal = cs.last_status.sig ();
+ else
+ signal = GDB_SIGNAL_0;
+ target_continue (cs.last_ptid, signal);
+ }
+ }
else
- push_stop_notification (cs.last_ptid, cs.last_status);
+ push_stop_notification (cs.last_ptid, cs.last_status);
}
/* Be sure to not change the selected thread behind GDB's back.
@@ -4643,8 +4620,8 @@ flush_streams ()
/* See gdbsupport/gdb_select.h. */
int
-gdb_select (int n, fd_set *readfds, fd_set *writefds,
- fd_set *exceptfds, struct timeval *timeout)
+gdb_select (int n, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
+ struct timeval *timeout)
{
return select (n, readfds, writefds, exceptfds, timeout);
}
@@ -4655,7 +4632,8 @@ namespace selftests
void
reset ()
-{}
+{
+}
} // namespace selftests
#endif /* GDB_SELF_TEST */
diff --git a/gdbserver/server.h b/gdbserver/server.h
index 7997d1a..6209bbe 100644
--- a/gdbserver/server.h
+++ b/gdbserver/server.h
@@ -40,16 +40,16 @@ extern void perror (const char *);
#endif
#if !HAVE_DECL_VASPRINTF
-extern int vasprintf(char **strp, const char *fmt, va_list ap);
+extern int vasprintf (char **strp, const char *fmt, va_list ap);
#endif
#if !HAVE_DECL_VSNPRINTF
-int vsnprintf(char *str, size_t size, const char *format, va_list ap);
+int vsnprintf (char *str, size_t size, const char *format, va_list ap);
#endif
#ifdef IN_PROCESS_AGENT
-# define PROG "ipa"
+#define PROG "ipa"
#else
-# define PROG "gdbserver"
+#define PROG "gdbserver"
#endif
#include "gdbsupport/buffer.h"
@@ -81,7 +81,7 @@ extern bool non_stop;
/* Functions from server.c. */
extern void handle_v_requests (char *own_buf, int packet_len,
- int *new_packet_len);
+ int *new_packet_len);
extern void handle_serial_event (int err, gdb_client_data client_data);
extern void handle_target_event (int err, gdb_client_data client_data);
@@ -100,7 +100,7 @@ extern int in_queued_stop_replies (ptid_t ptid);
/* Maximum number of bytes to read/write at once. The value here
is chosen to fill up a packet (the headers account for the 32). */
-#define MAXBUFBYTES(N) (((N)-32)/2)
+#define MAXBUFBYTES(N) (((N) -32) / 2)
/* Buffer sizes for transferring memory, registers, etc. Set to a constant
value to accomodate multiple register formats. This value must be at least
@@ -124,15 +124,12 @@ extern gdb_environ *get_environ ();
extern unsigned long signal_pid;
-
/* Description of the client remote protocol state for the currently
connected client. */
struct client_state
{
- client_state ():
- own_buf ((char *) xmalloc (PBUFSIZ + 1))
- {}
+ client_state () : own_buf ((char *) xmalloc (PBUFSIZ + 1)) {}
/* The thread set with an `Hc' packet. `Hc' is deprecated in favor of
`vCont'. Note the multi-process extensions made `vCont' a
@@ -192,7 +189,6 @@ struct client_state
/* If true, memory tagging features are supported. */
bool memory_tagging_feature = false;
-
};
client_state &get_client_state ();
diff --git a/gdbserver/symbol.cc b/gdbserver/symbol.cc
index 2f57fbb..cd65e07 100644
--- a/gdbserver/symbol.cc
+++ b/gdbserver/symbol.cc
@@ -24,7 +24,7 @@
int
find_minimal_symbol_address (const char *name, CORE_ADDR *addr,
- struct objfile *objfile)
+ struct objfile *objfile)
{
gdb_assert (objfile == NULL);
diff --git a/gdbserver/target.cc b/gdbserver/target.cc
index 2658a35..d900c82 100644
--- a/gdbserver/target.cc
+++ b/gdbserver/target.cc
@@ -41,17 +41,17 @@ set_desired_thread ()
{
process_info *proc = find_process_pid (cs.general_thread.pid ());
if (proc == nullptr)
- {
- threads_debug_printf
- ("did not find thread nor process for general_thread %s",
- cs.general_thread.to_string ().c_str ());
- }
+ {
+ threads_debug_printf (
+ "did not find thread nor process for general_thread %s",
+ cs.general_thread.to_string ().c_str ());
+ }
else
- {
- threads_debug_printf
- ("did not find thread for general_thread %s, but found process",
- cs.general_thread.to_string ().c_str ());
- }
+ {
+ threads_debug_printf (
+ "did not find thread for general_thread %s, but found process",
+ cs.general_thread.to_string ().c_str ());
+ }
switch_to_process (proc);
}
else
@@ -70,9 +70,8 @@ set_desired_process ()
process_info *proc = find_process_pid (cs.general_thread.pid ());
if (proc == nullptr)
{
- threads_debug_printf
- ("did not find process for general_thread %s",
- cs.general_thread.to_string ().c_str ());
+ threads_debug_printf ("did not find process for general_thread %s",
+ cs.general_thread.to_string ().c_str ());
}
switch_to_process (proc);
@@ -116,7 +115,7 @@ target_read_uint32 (CORE_ADDR memaddr, uint32_t *result)
int
target_write_memory (CORE_ADDR memaddr, const unsigned char *myaddr,
- ssize_t len)
+ ssize_t len)
{
/* GDB may send X packets with LEN==0, for probing packet support.
If we let such a request go through, then buffer.data() below may
@@ -134,7 +133,7 @@ target_write_memory (CORE_ADDR memaddr, const unsigned char *myaddr,
ptid_t
mywait (ptid_t ptid, struct target_waitstatus *ourstatus,
- target_wait_flags options, int connected_wait)
+ target_wait_flags options, int connected_wait)
{
ptid_t ret;
@@ -157,12 +156,12 @@ mywait (ptid_t ptid, struct target_waitstatus *ourstatus,
if (!remote_connection_is_stdio ())
{
if (ourstatus->kind () == TARGET_WAITKIND_EXITED)
- fprintf (stderr,
- "\nChild exited with status %d\n", ourstatus->exit_status ());
+ fprintf (stderr, "\nChild exited with status %d\n",
+ ourstatus->exit_status ());
else if (ourstatus->kind () == TARGET_WAITKIND_SIGNALLED)
- fprintf (stderr, "\nChild terminated with signal = 0x%x (%s)\n",
- gdb_signal_to_host (ourstatus->sig ()),
- gdb_signal_to_name (ourstatus->sig ()));
+ fprintf (stderr, "\nChild terminated with signal = 0x%x (%s)\n",
+ gdb_signal_to_host (ourstatus->sig ()),
+ gdb_signal_to_name (ourstatus->sig ()));
}
if (connected_wait)
@@ -194,7 +193,7 @@ target_stop_and_wait (ptid_t ptid)
ptid_t
target_wait (ptid_t ptid, struct target_waitstatus *status,
- target_wait_flags options)
+ target_wait_flags options)
{
return the_target->wait (ptid, status, options);
}
@@ -253,19 +252,16 @@ std::string
target_pid_to_str (ptid_t ptid)
{
if (ptid == minus_one_ptid)
- return string_printf("<all threads>");
+ return string_printf ("<all threads>");
else if (ptid == null_ptid)
- return string_printf("<null thread>");
+ return string_printf ("<null thread>");
else if (ptid.tid () != 0)
- return string_printf("Thread %d.0x%s",
- ptid.pid (),
- phex_nz (ptid.tid (), sizeof (ULONGEST)));
+ return string_printf ("Thread %d.0x%s", ptid.pid (),
+ phex_nz (ptid.tid (), sizeof (ULONGEST)));
else if (ptid.lwp () != 0)
- return string_printf("LWP %d.%ld",
- ptid.pid (), ptid.lwp ());
+ return string_printf ("LWP %d.%ld", ptid.pid (), ptid.lwp ());
else
- return string_printf("Process %d",
- ptid.pid ());
+ return string_printf ("Process %d", ptid.pid ());
}
int
@@ -347,7 +343,7 @@ process_stratum_target::supports_read_auxv ()
int
process_stratum_target::read_auxv (int pid, CORE_ADDR offset,
- unsigned char *myaddr, unsigned int len)
+ unsigned char *myaddr, unsigned int len)
{
gdb_assert_not_reached ("target op read_auxv not supported");
}
@@ -359,17 +355,15 @@ process_stratum_target::supports_z_point_type (char z_type)
}
int
-process_stratum_target::insert_point (enum raw_bkpt_type type,
- CORE_ADDR addr,
- int size, raw_breakpoint *bp)
+process_stratum_target::insert_point (enum raw_bkpt_type type, CORE_ADDR addr,
+ int size, raw_breakpoint *bp)
{
return 1;
}
int
-process_stratum_target::remove_point (enum raw_bkpt_type type,
- CORE_ADDR addr,
- int size, raw_breakpoint *bp)
+process_stratum_target::remove_point (enum raw_bkpt_type type, CORE_ADDR addr,
+ int size, raw_breakpoint *bp)
{
return 1;
}
@@ -430,14 +424,14 @@ process_stratum_target::supports_memory_tagging ()
bool
process_stratum_target::fetch_memtags (CORE_ADDR address, size_t len,
- gdb::byte_vector &tags, int type)
+ gdb::byte_vector &tags, int type)
{
gdb_assert_not_reached ("target op fetch_memtags not supported");
}
bool
process_stratum_target::store_memtags (CORE_ADDR address, size_t len,
- const gdb::byte_vector &tags, int type)
+ const gdb::byte_vector &tags, int type)
{
gdb_assert_not_reached ("target op store_memtags not supported");
}
@@ -455,10 +449,9 @@ process_stratum_target::supports_get_tls_address ()
}
int
-process_stratum_target::get_tls_address (thread_info *thread,
- CORE_ADDR offset,
- CORE_ADDR load_module,
- CORE_ADDR *address)
+process_stratum_target::get_tls_address (thread_info *thread, CORE_ADDR offset,
+ CORE_ADDR load_module,
+ CORE_ADDR *address)
{
gdb_assert_not_reached ("target op get_tls_address not supported");
}
@@ -471,9 +464,9 @@ process_stratum_target::supports_qxfer_osdata ()
int
process_stratum_target::qxfer_osdata (const char *annex,
- unsigned char *readbuf,
- unsigned const char *writebuf,
- CORE_ADDR offset, int len)
+ unsigned char *readbuf,
+ unsigned const char *writebuf,
+ CORE_ADDR offset, int len)
{
gdb_assert_not_reached ("target op qxfer_osdata not supported");
}
@@ -486,9 +479,9 @@ process_stratum_target::supports_qxfer_siginfo ()
int
process_stratum_target::qxfer_siginfo (const char *annex,
- unsigned char *readbuf,
- unsigned const char *writebuf,
- CORE_ADDR offset, int len)
+ unsigned char *readbuf,
+ unsigned const char *writebuf,
+ CORE_ADDR offset, int len)
{
gdb_assert_not_reached ("target op qxfer_siginfo not supported");
}
@@ -563,17 +556,15 @@ process_stratum_target::supports_read_loadmap ()
}
int
-process_stratum_target::read_loadmap (const char *annex,
- CORE_ADDR offset,
- unsigned char *myaddr,
- unsigned int len)
+process_stratum_target::read_loadmap (const char *annex, CORE_ADDR offset,
+ unsigned char *myaddr, unsigned int len)
{
gdb_assert_not_reached ("target op read_loadmap not supported");
}
void
-process_stratum_target::process_qsupported
- (gdb::array_view<const char * const> features)
+process_stratum_target::process_qsupported (
+ gdb::array_view<const char *const> features)
{
/* Nop. */
}
@@ -645,16 +636,15 @@ process_stratum_target::supports_fast_tracepoints ()
}
int
-process_stratum_target::install_fast_tracepoint_jump_pad
- (CORE_ADDR tpoint, CORE_ADDR tpaddr, CORE_ADDR collector,
- CORE_ADDR lockaddr, ULONGEST orig_size, CORE_ADDR *jump_entry,
- CORE_ADDR *trampoline, ULONGEST *trampoline_size,
- unsigned char *jjump_pad_insn, ULONGEST *jjump_pad_insn_size,
- CORE_ADDR *adjusted_insn_addr, CORE_ADDR *adjusted_insn_addr_end,
- char *err)
+process_stratum_target::install_fast_tracepoint_jump_pad (
+ CORE_ADDR tpoint, CORE_ADDR tpaddr, CORE_ADDR collector, CORE_ADDR lockaddr,
+ ULONGEST orig_size, CORE_ADDR *jump_entry, CORE_ADDR *trampoline,
+ ULONGEST *trampoline_size, unsigned char *jjump_pad_insn,
+ ULONGEST *jjump_pad_insn_size, CORE_ADDR *adjusted_insn_addr,
+ CORE_ADDR *adjusted_insn_addr_end, char *err)
{
gdb_assert_not_reached ("target op install_fast_tracepoint_jump_pad "
- "not supported");
+ "not supported");
}
int
@@ -683,9 +673,9 @@ process_stratum_target::supports_qxfer_libraries_svr4 ()
int
process_stratum_target::qxfer_libraries_svr4 (const char *annex,
- unsigned char *readbuf,
- unsigned const char *writebuf,
- CORE_ADDR offset, int len)
+ unsigned char *readbuf,
+ unsigned const char *writebuf,
+ CORE_ADDR offset, int len)
{
gdb_assert_not_reached ("target op qxfer_libraries_svr4 not supported");
}
@@ -704,30 +694,29 @@ process_stratum_target::supports_btrace ()
btrace_target_info *
process_stratum_target::enable_btrace (thread_info *tp,
- const btrace_config *conf)
+ const btrace_config *conf)
{
- error (_("Target does not support branch tracing."));
+ error (_ ("Target does not support branch tracing."));
}
int
process_stratum_target::disable_btrace (btrace_target_info *tinfo)
{
- error (_("Target does not support branch tracing."));
+ error (_ ("Target does not support branch tracing."));
}
int
-process_stratum_target::read_btrace (btrace_target_info *tinfo,
- buffer *buffer,
- enum btrace_read_type type)
+process_stratum_target::read_btrace (btrace_target_info *tinfo, buffer *buffer,
+ enum btrace_read_type type)
{
- error (_("Target does not support branch tracing."));
+ error (_ ("Target does not support branch tracing."));
}
int
process_stratum_target::read_btrace_conf (const btrace_target_info *tinfo,
- buffer *buffer)
+ buffer *buffer)
{
- error (_("Target does not support branch tracing."));
+ error (_ ("Target does not support branch tracing."));
}
bool
@@ -755,8 +744,8 @@ process_stratum_target::supports_multifs ()
}
int
-process_stratum_target::multifs_open (int pid, const char *filename,
- int flags, mode_t mode)
+process_stratum_target::multifs_open (int pid, const char *filename, int flags,
+ mode_t mode)
{
return open (filename, flags, mode);
}
@@ -769,7 +758,7 @@ process_stratum_target::multifs_unlink (int pid, const char *filename)
ssize_t
process_stratum_target::multifs_readlink (int pid, const char *filename,
- char *buf, size_t bufsiz)
+ char *buf, size_t bufsiz)
{
return readlink (filename, buf, bufsiz);
}
@@ -798,7 +787,7 @@ process_stratum_target::thread_name (ptid_t thread)
bool
process_stratum_target::thread_handle (ptid_t ptid, gdb_byte **handle,
- int *handle_len)
+ int *handle_len)
{
return false;
}
diff --git a/gdbserver/target.h b/gdbserver/target.h
index 01002c2..a3ce348 100644
--- a/gdbserver/target.h
+++ b/gdbserver/target.h
@@ -61,8 +61,8 @@ struct thread_resume
thread stops in this range. (If the range is empty
[STEP_RANGE_START == STEP_RANGE_END], then this is a single-step
request.) */
- CORE_ADDR step_range_start; /* Inclusive */
- CORE_ADDR step_range_end; /* Exclusive */
+ CORE_ADDR step_range_start; /* Inclusive */
+ CORE_ADDR step_range_end; /* Exclusive */
};
/* GDBserver doesn't have a concept of strata like GDB, but we call
@@ -72,7 +72,6 @@ struct thread_resume
class process_stratum_target
{
public:
-
virtual ~process_stratum_target () = default;
/* Start a new process.
@@ -84,7 +83,8 @@ public:
Returns the new PID on success, -1 on failure. Registers the new
process with the process list. */
virtual int create_inferior (const char *program,
- const std::vector<char *> &program_args) = 0;
+ const std::vector<char *> &program_args)
+ = 0;
/* Do additional setup after a new process is created, including
exec-wrapper completion. */
@@ -129,7 +129,8 @@ public:
no child stop to report, return is
null_ptid/TARGET_WAITKIND_IGNORE. */
virtual ptid_t wait (ptid_t ptid, target_waitstatus *status,
- target_wait_flags options) = 0;
+ target_wait_flags options)
+ = 0;
/* Fetch registers from the inferior process.
@@ -147,8 +148,8 @@ public:
Read LEN bytes at MEMADDR into a buffer at MYADDR.
Returns 0 on success and errno on failure. */
- virtual int read_memory (CORE_ADDR memaddr, unsigned char *myaddr,
- int len) = 0;
+ virtual int read_memory (CORE_ADDR memaddr, unsigned char *myaddr, int len)
+ = 0;
/* Write memory to the inferior process. This should generally be
called through target_write_memory, which handles breakpoint shadowing.
@@ -157,7 +158,8 @@ public:
Returns 0 on success and errno on failure. */
virtual int write_memory (CORE_ADDR memaddr, const unsigned char *myaddr,
- int len) = 0;
+ int len)
+ = 0;
/* Query GDB for the values of any symbols we're interested in.
This function is called whenever we receive a "qSymbols::"
@@ -176,7 +178,7 @@ public:
Read LEN bytes at OFFSET into a buffer at MYADDR. */
virtual int read_auxv (int pid, CORE_ADDR offset, unsigned char *myaddr,
- unsigned int len);
+ unsigned int len);
/* Returns true if GDB Z breakpoint type TYPE is supported, false
otherwise. The type is coded as follows:
@@ -190,11 +192,11 @@ public:
/* Insert and remove a break or watchpoint.
Returns 0 on success, -1 on failure and 1 on unsupported. */
- virtual int insert_point (enum raw_bkpt_type type, CORE_ADDR addr,
- int size, raw_breakpoint *bp);
+ virtual int insert_point (enum raw_bkpt_type type, CORE_ADDR addr, int size,
+ raw_breakpoint *bp);
- virtual int remove_point (enum raw_bkpt_type type, CORE_ADDR addr,
- int size, raw_breakpoint *bp);
+ virtual int remove_point (enum raw_bkpt_type type, CORE_ADDR addr, int size,
+ raw_breakpoint *bp);
/* Returns true if the target stopped because it executed a software
breakpoint instruction, false otherwise. */
@@ -239,23 +241,23 @@ public:
an error code. A return value of -1 means this system does not
support the operation. */
virtual int get_tls_address (thread_info *thread, CORE_ADDR offset,
- CORE_ADDR load_module, CORE_ADDR *address);
+ CORE_ADDR load_module, CORE_ADDR *address);
/* Return true if the qxfer_osdata target op is supported. */
virtual bool supports_qxfer_osdata ();
/* Read/Write OS data using qXfer packets. */
virtual int qxfer_osdata (const char *annex, unsigned char *readbuf,
- unsigned const char *writebuf,
- CORE_ADDR offset, int len);
+ unsigned const char *writebuf, CORE_ADDR offset,
+ int len);
/* Return true if the qxfer_siginfo target op is supported. */
virtual bool supports_qxfer_siginfo ();
/* Read/Write extra signal info. */
virtual int qxfer_siginfo (const char *annex, unsigned char *readbuf,
- unsigned const char *writebuf,
- CORE_ADDR offset, int len);
+ unsigned const char *writebuf, CORE_ADDR offset,
+ int len);
/* Return true if non-stop mode is supported. */
virtual bool supports_non_stop ();
@@ -295,12 +297,12 @@ public:
/* Read loadmaps. Read LEN bytes at OFFSET into a buffer at MYADDR. */
virtual int read_loadmap (const char *annex, CORE_ADDR offset,
- unsigned char *myaddr, unsigned int len);
+ unsigned char *myaddr, unsigned int len);
/* Target specific qSupported support. FEATURES is an array of
features unsupported by the core of GDBserver. */
- virtual void process_qsupported
- (gdb::array_view<const char * const> features);
+ virtual void
+ process_qsupported (gdb::array_view<const char *const> features);
/* Return true if the target supports tracepoints, false otherwise. */
virtual bool supports_tracepoints ();
@@ -357,13 +359,13 @@ public:
return the address range where the instruction at TPADDR was relocated
to. If an error occurs, the ERR may be used to pass on an error
message. */
- virtual int install_fast_tracepoint_jump_pad
- (CORE_ADDR tpoint, CORE_ADDR tpaddr, CORE_ADDR collector,
- CORE_ADDR lockaddr, ULONGEST orig_size, CORE_ADDR *jump_entry,
- CORE_ADDR *trampoline, ULONGEST *trampoline_size,
- unsigned char *jjump_pad_insn, ULONGEST *jjump_pad_insn_size,
- CORE_ADDR *adjusted_insn_addr, CORE_ADDR *adjusted_insn_addr_end,
- char *err);
+ virtual int install_fast_tracepoint_jump_pad (
+ CORE_ADDR tpoint, CORE_ADDR tpaddr, CORE_ADDR collector,
+ CORE_ADDR lockaddr, ULONGEST orig_size, CORE_ADDR *jump_entry,
+ CORE_ADDR *trampoline, ULONGEST *trampoline_size,
+ unsigned char *jjump_pad_insn, ULONGEST *jjump_pad_insn_size,
+ CORE_ADDR *adjusted_insn_addr, CORE_ADDR *adjusted_insn_addr_end,
+ char *err);
/* Return the minimum length of an instruction that can be safely
overwritten for use as a fast tracepoint. */
@@ -380,10 +382,9 @@ public:
virtual bool supports_qxfer_libraries_svr4 ();
/* Read solib info on SVR4 platforms. */
- virtual int qxfer_libraries_svr4 (const char *annex,
- unsigned char *readbuf,
- unsigned const char *writebuf,
- CORE_ADDR offset, int len);
+ virtual int qxfer_libraries_svr4 (const char *annex, unsigned char *readbuf,
+ unsigned const char *writebuf,
+ CORE_ADDR offset, int len);
/* Return true if target supports debugging agent. */
virtual bool supports_agent ();
@@ -394,7 +395,7 @@ public:
/* Enable branch tracing for TP based on CONF and allocate a branch trace
target information struct for reading and for disabling branch trace. */
virtual btrace_target_info *enable_btrace (thread_info *tp,
- const btrace_config *conf);
+ const btrace_config *conf);
/* Disable branch tracing.
Returns zero on success, non-zero otherwise. */
@@ -404,13 +405,12 @@ public:
Return 0 on success; print an error message into BUFFER and return -1,
otherwise. */
virtual int read_btrace (btrace_target_info *tinfo, buffer *buf,
- enum btrace_read_type type);
+ enum btrace_read_type type);
/* Read the branch trace configuration into BUFFER.
Return 0 on success; print an error message into BUFFER and return -1
otherwise. */
- virtual int read_btrace_conf (const btrace_target_info *tinfo,
- buffer *buf);
+ virtual int read_btrace_conf (const btrace_target_info *tinfo, buffer *buf);
/* Return true if target supports range stepping. */
virtual bool supports_range_stepping ();
@@ -433,8 +433,8 @@ public:
the filesystem as it appears to process PID. Systems where all
processes share a common filesystem should not override this.
The default behavior is to use open(2). */
- virtual int multifs_open (int pid, const char *filename,
- int flags, mode_t mode);
+ virtual int multifs_open (int pid, const char *filename, int flags,
+ mode_t mode);
/* Multiple-filesystem-aware unlink. Like unlink(2), but operates
in the filesystem as it appears to process PID. Systems where
@@ -446,8 +446,8 @@ public:
operating in the filesystem as it appears to process PID.
Systems where all processes share a common filesystem should
not override this. The default behavior is to use readlink(2). */
- virtual ssize_t multifs_readlink (int pid, const char *filename,
- char *buf, size_t bufsiz);
+ virtual ssize_t multifs_readlink (int pid, const char *filename, char *buf,
+ size_t bufsiz);
/* Return the breakpoint kind for this target based on PC. The
PCPTR is adjusted to the real memory location in case a flag
@@ -473,8 +473,7 @@ public:
/* Thread ID to (numeric) thread handle: Return true on success and
false for failure. Return pointer to thread handle via HANDLE
and the handle's length via HANDLE_LEN. */
- virtual bool thread_handle (ptid_t ptid, gdb_byte **handle,
- int *handle_len);
+ virtual bool thread_handle (ptid_t ptid, gdb_byte **handle, int *handle_len);
/* If THREAD is a fork child that was not reported to GDB, return its parent
else nullptr. */
@@ -501,126 +500,102 @@ public:
Returns true if successful and false otherwise. */
virtual bool fetch_memtags (CORE_ADDR address, size_t len,
- gdb::byte_vector &tags, int type);
+ gdb::byte_vector &tags, int type);
/* Write the allocation tags of type TYPE contained in TAGS to the
memory range [ADDRESS, ADDRESS + LEN).
Returns true if successful and false otherwise. */
virtual bool store_memtags (CORE_ADDR address, size_t len,
- const gdb::byte_vector &tags, int type);
+ const gdb::byte_vector &tags, int type);
};
extern process_stratum_target *the_target;
void set_target_ops (process_stratum_target *);
-#define target_create_inferior(program, program_args) \
+#define target_create_inferior(program, program_args) \
the_target->create_inferior (program, program_args)
-#define target_post_create_inferior() \
- the_target->post_create_inferior ()
+#define target_post_create_inferior() the_target->post_create_inferior ()
-#define myattach(pid) \
- the_target->attach (pid)
+#define myattach(pid) the_target->attach (pid)
int kill_inferior (process_info *proc);
-#define target_supports_fork_events() \
- the_target->supports_fork_events ()
+#define target_supports_fork_events() the_target->supports_fork_events ()
-#define target_supports_vfork_events() \
- the_target->supports_vfork_events ()
+#define target_supports_vfork_events() the_target->supports_vfork_events ()
-#define target_supports_exec_events() \
- the_target->supports_exec_events ()
+#define target_supports_exec_events() the_target->supports_exec_events ()
-#define target_supports_memory_tagging() \
- the_target->supports_memory_tagging ()
+#define target_supports_memory_tagging() the_target->supports_memory_tagging ()
-#define target_handle_new_gdb_connection() \
+#define target_handle_new_gdb_connection() \
the_target->handle_new_gdb_connection ()
-#define detach_inferior(proc) \
- the_target->detach (proc)
+#define detach_inferior(proc) the_target->detach (proc)
-#define mythread_alive(pid) \
- the_target->thread_alive (pid)
+#define mythread_alive(pid) the_target->thread_alive (pid)
-#define fetch_inferior_registers(regcache, regno) \
+#define fetch_inferior_registers(regcache, regno) \
the_target->fetch_registers (regcache, regno)
#define store_inferior_registers(regcache, regno) \
the_target->store_registers (regcache, regno)
-#define join_inferior(pid) \
- the_target->join (pid)
+#define join_inferior(pid) the_target->join (pid)
-#define target_supports_non_stop() \
- the_target->supports_non_stop ()
+#define target_supports_non_stop() the_target->supports_non_stop ()
-#define target_async(enable) \
- the_target->async (enable)
+#define target_async(enable) the_target->async (enable)
#define target_process_qsupported(features) \
the_target->process_qsupported (features)
-#define target_supports_catch_syscall() \
- the_target->supports_catch_syscall ()
+#define target_supports_catch_syscall() the_target->supports_catch_syscall ()
-#define target_get_ipa_tdesc_idx() \
- the_target->get_ipa_tdesc_idx ()
+#define target_get_ipa_tdesc_idx() the_target->get_ipa_tdesc_idx ()
-#define target_supports_tracepoints() \
- the_target->supports_tracepoints ()
+#define target_supports_tracepoints() the_target->supports_tracepoints ()
-#define target_supports_fast_tracepoints() \
+#define target_supports_fast_tracepoints() \
the_target->supports_fast_tracepoints ()
-#define target_get_min_fast_tracepoint_insn_len() \
+#define target_get_min_fast_tracepoint_insn_len() \
the_target->get_min_fast_tracepoint_insn_len ()
-#define target_thread_stopped(thread) \
- the_target->thread_stopped (thread)
-
-#define target_pause_all(freeze) \
- the_target->pause_all (freeze)
-
-#define target_unpause_all(unfreeze) \
- the_target->unpause_all (unfreeze)
-
-#define target_stabilize_threads() \
- the_target->stabilize_threads ()
-
-#define target_install_fast_tracepoint_jump_pad(tpoint, tpaddr, \
- collector, lockaddr, \
- orig_size, \
- jump_entry, \
- trampoline, trampoline_size, \
- jjump_pad_insn, \
- jjump_pad_insn_size, \
- adjusted_insn_addr, \
- adjusted_insn_addr_end, \
- err) \
- the_target->install_fast_tracepoint_jump_pad (tpoint, tpaddr, \
- collector,lockaddr, \
- orig_size, jump_entry, \
- trampoline, \
- trampoline_size, \
- jjump_pad_insn, \
- jjump_pad_insn_size, \
- adjusted_insn_addr, \
- adjusted_insn_addr_end, \
- err)
-
-#define target_emit_ops() \
- the_target->emit_ops ()
+#define target_thread_stopped(thread) the_target->thread_stopped (thread)
+
+#define target_pause_all(freeze) the_target->pause_all (freeze)
+
+#define target_unpause_all(unfreeze) the_target->unpause_all (unfreeze)
+
+#define target_stabilize_threads() the_target->stabilize_threads ()
+
+#define target_install_fast_tracepoint_jump_pad(tpoint, tpaddr, collector, \
+ lockaddr, orig_size, \
+ jump_entry, trampoline, \
+ trampoline_size, \
+ jjump_pad_insn, \
+ jjump_pad_insn_size, \
+ adjusted_insn_addr, \
+ adjusted_insn_addr_end, err) \
+ the_target->install_fast_tracepoint_jump_pad (tpoint, tpaddr, collector, \
+ lockaddr, orig_size, \
+ jump_entry, trampoline, \
+ trampoline_size, \
+ jjump_pad_insn, \
+ jjump_pad_insn_size, \
+ adjusted_insn_addr, \
+ adjusted_insn_addr_end, err)
+
+#define target_emit_ops() the_target->emit_ops ()
#define target_supports_disable_randomization() \
the_target->supports_disable_randomization ()
-#define target_supports_agent() \
- the_target->supports_agent ()
+#define target_supports_agent() the_target->supports_agent ()
static inline struct btrace_target_info *
target_enable_btrace (thread_info *tp, const struct btrace_config *conf)
@@ -635,22 +610,20 @@ target_disable_btrace (struct btrace_target_info *tinfo)
}
static inline int
-target_read_btrace (struct btrace_target_info *tinfo,
- struct buffer *buffer,
- enum btrace_read_type type)
+target_read_btrace (struct btrace_target_info *tinfo, struct buffer *buffer,
+ enum btrace_read_type type)
{
return the_target->read_btrace (tinfo, buffer, type);
}
static inline int
target_read_btrace_conf (struct btrace_target_info *tinfo,
- struct buffer *buffer)
+ struct buffer *buffer)
{
return the_target->read_btrace_conf (tinfo, buffer);
}
-#define target_supports_range_stepping() \
- the_target->supports_range_stepping ()
+#define target_supports_range_stepping() the_target->supports_range_stepping ()
#define target_supports_stopped_by_sw_breakpoint() \
the_target->supports_stopped_by_sw_breakpoint ()
@@ -677,13 +650,11 @@ target_read_btrace_conf (struct btrace_target_info *tinfo,
the_target->supports_software_single_step ()
ptid_t mywait (ptid_t ptid, struct target_waitstatus *ourstatus,
- target_wait_flags options, int connected_wait);
+ target_wait_flags options, int connected_wait);
-#define target_core_of_thread(ptid) \
- the_target->core_of_thread (ptid)
+#define target_core_of_thread(ptid) the_target->core_of_thread (ptid)
-#define target_thread_name(ptid) \
- the_target->thread_name (ptid)
+#define target_thread_name(ptid) the_target->thread_name (ptid)
#define target_thread_handle(ptid, handle, handle_len) \
the_target->thread_handle (ptid, handle, handle_len)
diff --git a/gdbserver/tdesc.cc b/gdbserver/tdesc.cc
index 2c7257c..3cdaa83 100644
--- a/gdbserver/tdesc.cc
+++ b/gdbserver/tdesc.cc
@@ -27,7 +27,8 @@ target_desc::~target_desc ()
xfree ((char *) osabi);
}
-bool target_desc::operator== (const target_desc &other) const
+bool
+target_desc::operator== (const target_desc &other) const
{
if (reg_defs != other.reg_defs)
return false;
@@ -37,7 +38,7 @@ bool target_desc::operator== (const target_desc &other) const
for (; expedite_regs[i] != NULL; i++)
{
if (strcmp (expedite_regs[i], other.expedite_regs[i]) != 0)
- return false;
+ return false;
}
if (other.expedite_regs[i] != NULL)
return false;
@@ -47,7 +48,8 @@ bool target_desc::operator== (const target_desc &other) const
#endif
-void target_desc::accept (tdesc_element_visitor &v) const
+void
+target_desc::accept (tdesc_element_visitor &v) const
{
#ifndef IN_PROCESS_AGENT
v.visit_pre (this);
@@ -60,8 +62,7 @@ void target_desc::accept (tdesc_element_visitor &v) const
}
void
-init_target_desc (struct target_desc *tdesc,
- const char **expedite_regs)
+init_target_desc (struct target_desc *tdesc, const char **expedite_regs)
{
int offset = 0;
@@ -69,17 +70,17 @@ init_target_desc (struct target_desc *tdesc,
for (const tdesc_feature_up &feature : tdesc->features)
for (const tdesc_reg_up &treg : feature->registers)
{
- int regnum = treg->target_regnum;
+ int regnum = treg->target_regnum;
- /* Register number will increase (possibly with gaps) or be zero. */
- gdb_assert (regnum == 0 || regnum >= tdesc->reg_defs.size ());
+ /* Register number will increase (possibly with gaps) or be zero. */
+ gdb_assert (regnum == 0 || regnum >= tdesc->reg_defs.size ());
- if (regnum != 0)
- tdesc->reg_defs.resize (regnum, gdb::reg (offset));
+ if (regnum != 0)
+ tdesc->reg_defs.resize (regnum, gdb::reg (offset));
- tdesc->reg_defs.emplace_back (treg->name.c_str (), offset,
- treg->bitsize);
- offset += treg->bitsize;
+ tdesc->reg_defs.emplace_back (treg->name.c_str (), offset,
+ treg->bitsize);
+ offset += treg->bitsize;
}
tdesc->registers_size = offset / 8;
@@ -111,11 +112,13 @@ target_desc_deleter::operator() (struct target_desc *target_desc) const
#ifndef IN_PROCESS_AGENT
-static const struct target_desc default_description {};
+static const struct target_desc default_description
+{
+};
void
copy_target_description (struct target_desc *dest,
- const struct target_desc *src)
+ const struct target_desc *src)
{
dest->reg_defs = src->reg_defs;
dest->expedite_regs = src->expedite_regs;
@@ -134,7 +137,9 @@ current_target_desc (void)
/* An empty structure. */
-struct tdesc_compatible_info { };
+struct tdesc_compatible_info
+{
+};
/* See gdbsupport/tdesc.h. */
@@ -164,8 +169,7 @@ tdesc_architecture_name (const struct target_desc *target_desc)
/* See gdbsupport/tdesc.h. */
void
-set_tdesc_architecture (struct target_desc *target_desc,
- const char *name)
+set_tdesc_architecture (struct target_desc *target_desc, const char *name)
{
target_desc->arch = xstrdup (name);
}
@@ -193,8 +197,7 @@ tdesc_get_features_xml (const target_desc *tdesc)
{
/* Either .xmltarget or .features is not NULL. */
gdb_assert (tdesc->xmltarget != NULL
- || (!tdesc->features.empty ()
- && tdesc->arch != NULL));
+ || (!tdesc->features.empty () && tdesc->arch != NULL));
if (tdesc->xmltarget == NULL)
{
@@ -228,7 +231,7 @@ tdesc_contains_feature (const target_desc *tdesc, const std::string &feature)
for (const tdesc_feature_up &f : tdesc->features)
{
if (f->name == feature)
- return true;
+ return true;
}
return false;
diff --git a/gdbserver/tdesc.h b/gdbserver/tdesc.h
index 7fe7d0d..b920775 100644
--- a/gdbserver/tdesc.h
+++ b/gdbserver/tdesc.h
@@ -60,9 +60,7 @@ struct target_desc final : tdesc_element
const char *osabi = NULL;
public:
- target_desc ()
- : registers_size (0)
- {}
+ target_desc () : registers_size (0) {}
~target_desc ();
@@ -80,13 +78,12 @@ public:
/* Copy target description SRC to DEST. */
void copy_target_description (struct target_desc *dest,
- const struct target_desc *src);
+ const struct target_desc *src);
/* Initialize TDESC, and then set its expedite_regs field to
EXPEDITE_REGS. */
-void init_target_desc (struct target_desc *tdesc,
- const char **expedite_regs);
+void init_target_desc (struct target_desc *tdesc, const char **expedite_regs);
/* Return the current inferior's target description. Never returns
NULL. */
@@ -96,6 +93,6 @@ const struct target_desc *current_target_desc (void);
/* Return true if TDESC contains the feature described by string FEATURE.
Return false otherwise. */
bool tdesc_contains_feature (const target_desc *tdesc,
- const std::string &feature);
+ const std::string &feature);
#endif /* GDBSERVER_TDESC_H */
diff --git a/gdbserver/thread-db.cc b/gdbserver/thread-db.cc
index ed27405..5cc30d1 100644
--- a/gdbserver/thread-db.cc
+++ b/gdbserver/thread-db.cc
@@ -177,25 +177,25 @@ find_one_thread (ptid_t ptid)
thread_db *thread_db = proc->priv->thread_db;
td_thrhandle_t th;
int lwpid = ptid.lwp ();
- td_err_e err = thread_db->td_ta_map_lwp2thr_p (thread_db->thread_agent, lwpid,
- &th);
+ td_err_e err
+ = thread_db->td_ta_map_lwp2thr_p (thread_db->thread_agent, lwpid, &th);
if (err != TD_OK)
- error ("Cannot get thread handle for LWP %d: %s",
- lwpid, thread_db_err_str (err));
+ error ("Cannot get thread handle for LWP %d: %s", lwpid,
+ thread_db_err_str (err));
td_thrinfo_t ti;
err = thread_db->td_thr_get_info_p (&th, &ti);
if (err != TD_OK)
- error ("Cannot get thread info for LWP %d: %s",
- lwpid, thread_db_err_str (err));
+ error ("Cannot get thread info for LWP %d: %s", lwpid,
+ thread_db_err_str (err));
- threads_debug_printf ("Found thread %ld (LWP %d)",
- (unsigned long) ti.ti_tid, ti.ti_lid);
+ threads_debug_printf ("Found thread %ld (LWP %d)", (unsigned long) ti.ti_tid,
+ ti.ti_lid);
if (lwpid != ti.ti_lid)
{
- warning ("PID mismatch! Expected %ld, got %ld",
- (long) lwpid, (long) ti.ti_lid);
+ warning ("PID mismatch! Expected %ld, got %ld", (long) lwpid,
+ (long) ti.ti_lid);
return 0;
}
@@ -223,14 +223,14 @@ attach_thread (const td_thrhandle_t *th_p, td_thrinfo_t *ti_p)
int err;
threads_debug_printf ("Attaching to thread %ld (LWP %d)",
- (unsigned long) ti_p->ti_tid, ti_p->ti_lid);
+ (unsigned long) ti_p->ti_tid, ti_p->ti_lid);
err = the_linux_target->attach_lwp (ptid);
if (err != 0)
{
std::string reason = linux_ptrace_attach_fail_reason_string (ptid, err);
warning ("Could not attach to thread %ld (LWP %d): %s",
- (unsigned long) ti_p->ti_tid, ti_p->ti_lid, reason.c_str ());
+ (unsigned long) ti_p->ti_tid, ti_p->ti_lid, reason.c_str ());
return 0;
}
@@ -250,7 +250,7 @@ attach_thread (const td_thrhandle_t *th_p, td_thrinfo_t *ti_p)
static int
maybe_attach_thread (const td_thrhandle_t *th_p, td_thrinfo_t *ti_p,
- int *counter)
+ int *counter)
{
struct lwp_info *lwp;
@@ -287,8 +287,8 @@ find_new_threads_callback (const td_thrhandle_t *th_p, void *data)
terminated and joined threads with kernel thread ID -1. See
glibc PR17707. */
threads_debug_printf ("thread_db: skipping exited and "
- "joined thread (0x%lx)",
- (unsigned long) ti.ti_tid);
+ "joined thread (0x%lx)",
+ (unsigned long) ti.ti_tid);
return 0;
}
@@ -330,19 +330,18 @@ thread_db_find_new_threads (void)
/* Iterate over all user-space threads to discover new threads. */
err = thread_db->td_ta_thr_iter_p (thread_db->thread_agent,
- find_new_threads_callback,
- &new_thread_count,
- TD_THR_ANY_STATE,
- TD_THR_LOWEST_PRIORITY,
- TD_SIGNO_MASK, TD_THR_ANY_USER_FLAGS);
+ find_new_threads_callback,
+ &new_thread_count, TD_THR_ANY_STATE,
+ TD_THR_LOWEST_PRIORITY, TD_SIGNO_MASK,
+ TD_THR_ANY_USER_FLAGS);
threads_debug_printf ("Found %d threads in iteration %d.",
- new_thread_count, iteration);
+ new_thread_count, iteration);
if (new_thread_count != 0)
- {
- /* Found new threads. Restart iteration from beginning. */
- loop = -1;
- }
+ {
+ /* Found new threads. Restart iteration from beginning. */
+ loop = -1;
+ }
}
if (err != TD_OK)
error ("Cannot find new threads: %s", thread_db_err_str (err));
@@ -384,7 +383,7 @@ thread_db_look_up_one_symbol (const char *name, CORE_ADDR *addrp)
int
thread_db_get_tls_address (struct thread_info *thread, CORE_ADDR offset,
- CORE_ADDR load_module, CORE_ADDR *address)
+ CORE_ADDR load_module, CORE_ADDR *address)
{
psaddr_t addr;
td_err_e err;
@@ -419,9 +418,10 @@ thread_db_get_tls_address (struct thread_info *thread, CORE_ADDR offset,
/* Note the cast through uintptr_t: this interface only works if
a target address fits in a psaddr_t, which is a host pointer.
So a 32-bit debugger can not access 64-bit TLS through this. */
- err = thread_db->td_thr_tls_get_addr_p (&lwp->th,
- (psaddr_t) (uintptr_t) load_module,
- offset, &addr);
+ err
+ = thread_db->td_thr_tls_get_addr_p (&lwp->th,
+ (psaddr_t) (uintptr_t) load_module,
+ offset, &addr);
}
else
{
@@ -530,24 +530,24 @@ try_thread_db_load_1 (void *handle)
/* Initialize pointers to the dynamic library functions we will use.
Essential functions first. */
-#define CHK(required, a) \
- do \
- { \
- if ((a) == NULL) \
- { \
- threads_debug_printf ("dlsym: %s", dlerror ()); \
- if (required) \
- { \
- free (tdb); \
- proc->priv->thread_db = NULL; \
- return 0; \
- } \
- } \
- } \
+#define CHK(required, a) \
+ do \
+ { \
+ if ((a) == NULL) \
+ { \
+ threads_debug_printf ("dlsym: %s", dlerror ()); \
+ if (required) \
+ { \
+ free (tdb); \
+ proc->priv->thread_db = NULL; \
+ return 0; \
+ } \
+ } \
+ } \
while (0)
#define TDB_DLSYM(tdb, func) \
- tdb->func ## _p = (func ## _ftype *) dlsym (tdb->handle, #func)
+ tdb->func##_p = (func##_ftype *) dlsym (tdb->handle, #func)
CHK (1, TDB_DLSYM (tdb, td_ta_new));
@@ -599,8 +599,7 @@ try_thread_db_load (const char *library)
{
void *handle;
- threads_debug_printf ("Trying host libthread_db library: %s.",
- library);
+ threads_debug_printf ("Trying host libthread_db library: %s.", library);
handle = dlopen (library, RTLD_NOW);
if (handle == NULL)
{
@@ -615,12 +614,13 @@ try_thread_db_load (const char *library)
td_init = dlsym (handle, "td_init");
if (td_init != NULL)
- {
- const char *const libpath = dladdr_to_soname (td_init);
+ {
+ const char *const libpath = dladdr_to_soname (td_init);
- if (libpath != NULL)
- threads_debug_printf ("Host %s resolved to: %s.", library, libpath);
- }
+ if (libpath != NULL)
+ threads_debug_printf ("Host %s resolved to: %s.", library,
+ libpath);
+ }
}
#endif
@@ -657,8 +657,9 @@ try_thread_db_load_from_dir (const char *dir, size_t dir_len)
memcpy (cp, dir, dir_len);
cp[dir_len] = '\0';
- warning (_("libthread-db-search-path component too long,"
- " ignored: %s."), cp);
+ warning (_ ("libthread-db-search-path component too long,"
+ " ignored: %s."),
+ cp);
free (cp);
return 0;
}
@@ -693,36 +694,35 @@ thread_db_load_search (void)
this_dir_len = strlen (this_dir);
if (strncmp (this_dir, "$pdir", pdir_len) == 0
- && (this_dir[pdir_len] == '\0'
- || this_dir[pdir_len] == '/'))
- {
- /* We don't maintain a list of loaded libraries so we don't know
+ && (this_dir[pdir_len] == '\0' || this_dir[pdir_len] == '/'))
+ {
+ /* We don't maintain a list of loaded libraries so we don't know
where libpthread lives. We *could* fetch the info, but we don't
do that yet. Ignore it. */
- }
+ }
else if (strcmp (this_dir, "$sdir") == 0)
- {
- if (try_thread_db_load_from_sdir ())
- {
- rc = 1;
- break;
- }
- }
+ {
+ if (try_thread_db_load_from_sdir ())
+ {
+ rc = 1;
+ break;
+ }
+ }
else
- {
- if (try_thread_db_load_from_dir (this_dir, this_dir_len))
- {
- rc = 1;
- break;
- }
- }
+ {
+ if (try_thread_db_load_from_dir (this_dir, this_dir_len))
+ {
+ rc = 1;
+ break;
+ }
+ }
}
threads_debug_printf ("thread_db_load_search returning %d", rc);
return rc;
}
-#endif /* USE_LIBTHREAD_DB_DIRECTLY */
+#endif /* USE_LIBTHREAD_DB_DIRECTLY */
int
thread_db_init (void)
@@ -752,7 +752,7 @@ thread_db_init (void)
do not walk libpthread's thread list, so should be safe, as
well as more efficient. */
if (!linux_proc_task_list_dir_exists (pid_of (proc)))
- thread_db_find_new_threads ();
+ thread_db_find_new_threads ();
thread_db_look_up_symbols ();
return 1;
}
@@ -769,28 +769,28 @@ disable_thread_event_reporting (struct process_info *proc)
if (thread_db)
{
td_err_e (*td_ta_clear_event_p) (const td_thragent_t *ta,
- td_thr_events_t *event);
+ td_thr_events_t *event);
#ifndef USE_LIBTHREAD_DB_DIRECTLY
td_ta_clear_event_p
- = (td_ta_clear_event_ftype *) dlsym (thread_db->handle,
- "td_ta_clear_event");
+ = (td_ta_clear_event_ftype *) dlsym (thread_db->handle,
+ "td_ta_clear_event");
#else
td_ta_clear_event_p = &td_ta_clear_event;
#endif
if (td_ta_clear_event_p != NULL)
- {
- scoped_restore_current_thread restore_thread;
- td_thr_events_t events;
+ {
+ scoped_restore_current_thread restore_thread;
+ td_thr_events_t events;
- switch_to_process (proc);
+ switch_to_process (proc);
- /* Set the process wide mask saying we aren't interested
+ /* Set the process wide mask saying we aren't interested
in any events anymore. */
- td_event_fillset (&events);
- (*td_ta_clear_event_p) (thread_db->thread_agent, &events);
- }
+ td_event_fillset (&events);
+ (*td_ta_clear_event_p) (thread_db->thread_agent, &events);
+ }
}
}
@@ -816,17 +816,18 @@ thread_db_mourn (struct process_info *proc)
td_ta_delete_ftype *td_ta_delete_p;
#ifndef USE_LIBTHREAD_DB_DIRECTLY
- td_ta_delete_p = (td_ta_delete_ftype *) dlsym (thread_db->handle, "td_ta_delete");
+ td_ta_delete_p
+ = (td_ta_delete_ftype *) dlsym (thread_db->handle, "td_ta_delete");
#else
td_ta_delete_p = &td_ta_delete;
#endif
if (td_ta_delete_p != NULL)
- (*td_ta_delete_p) (thread_db->thread_agent);
+ (*td_ta_delete_p) (thread_db->thread_agent);
#ifndef USE_LIBTHREAD_DB_DIRECTLY
dlclose (thread_db->handle);
-#endif /* USE_LIBTHREAD_DB_DIRECTLY */
+#endif /* USE_LIBTHREAD_DB_DIRECTLY */
free (thread_db);
proc->priv->thread_db = NULL;
@@ -843,20 +844,19 @@ thread_db_handle_monitor_command (char *mon)
size_t cmd_len = strlen (cmd);
if (strncmp (mon, cmd, cmd_len) == 0
- && (mon[cmd_len] == '\0'
- || mon[cmd_len] == ' '))
+ && (mon[cmd_len] == '\0' || mon[cmd_len] == ' '))
{
const char *cp = mon + cmd_len;
if (libthread_db_search_path != NULL)
- free (libthread_db_search_path);
+ free (libthread_db_search_path);
/* Skip leading space (if any). */
while (isspace (*cp))
- ++cp;
+ ++cp;
if (*cp == '\0')
- cp = LIBTHREAD_DB_SEARCH_PATH;
+ cp = LIBTHREAD_DB_SEARCH_PATH;
libthread_db_search_path = xstrdup (cp);
monitor_output ("libthread-db-search-path set to `");
diff --git a/gdbserver/tracepoint.cc b/gdbserver/tracepoint.cc
index 37a9a8c..45318eb 100644
--- a/gdbserver/tracepoint.cc
+++ b/gdbserver/tracepoint.cc
@@ -77,18 +77,22 @@ trace_vdebug (const char *fmt, ...)
va_end (ap);
}
-#define trace_debug(fmt, args...) \
- do { \
- if (debug_threads) \
- trace_vdebug ((fmt), ##args); \
- } while (0)
+#define trace_debug(fmt, args...) \
+ do \
+ { \
+ if (debug_threads) \
+ trace_vdebug ((fmt), ##args); \
+ } \
+ while (0)
#else
-#define trace_debug(fmt, args...) \
- do { \
- threads_debug_printf ((fmt), ##args); \
- } while (0)
+#define trace_debug(fmt, args...) \
+ do \
+ { \
+ threads_debug_printf ((fmt), ##args); \
+ } \
+ while (0)
#endif
@@ -96,40 +100,43 @@ trace_vdebug (const char *fmt, ...)
that need exporting are defined in this module. Note that all
these symbols must be tagged with IP_AGENT_EXPORT_*. */
#ifdef IN_PROCESS_AGENT
-# define gdb_tp_heap_buffer IPA_SYM_EXPORTED_NAME (gdb_tp_heap_buffer)
-# define gdb_jump_pad_buffer IPA_SYM_EXPORTED_NAME (gdb_jump_pad_buffer)
-# define gdb_jump_pad_buffer_end IPA_SYM_EXPORTED_NAME (gdb_jump_pad_buffer_end)
-# define gdb_trampoline_buffer IPA_SYM_EXPORTED_NAME (gdb_trampoline_buffer)
-# define gdb_trampoline_buffer_end IPA_SYM_EXPORTED_NAME (gdb_trampoline_buffer_end)
-# define gdb_trampoline_buffer_error IPA_SYM_EXPORTED_NAME (gdb_trampoline_buffer_error)
-# define collecting IPA_SYM_EXPORTED_NAME (collecting)
-# define gdb_collect_ptr IPA_SYM_EXPORTED_NAME (gdb_collect_ptr)
-# define stop_tracing IPA_SYM_EXPORTED_NAME (stop_tracing)
-# define flush_trace_buffer IPA_SYM_EXPORTED_NAME (flush_trace_buffer)
-# define about_to_request_buffer_space IPA_SYM_EXPORTED_NAME (about_to_request_buffer_space)
-# define trace_buffer_is_full IPA_SYM_EXPORTED_NAME (trace_buffer_is_full)
-# define stopping_tracepoint IPA_SYM_EXPORTED_NAME (stopping_tracepoint)
-# define expr_eval_result IPA_SYM_EXPORTED_NAME (expr_eval_result)
-# define error_tracepoint IPA_SYM_EXPORTED_NAME (error_tracepoint)
-# define tracepoints IPA_SYM_EXPORTED_NAME (tracepoints)
-# define tracing IPA_SYM_EXPORTED_NAME (tracing)
-# define trace_buffer_ctrl IPA_SYM_EXPORTED_NAME (trace_buffer_ctrl)
-# define trace_buffer_ctrl_curr IPA_SYM_EXPORTED_NAME (trace_buffer_ctrl_curr)
-# define trace_buffer_lo IPA_SYM_EXPORTED_NAME (trace_buffer_lo)
-# define trace_buffer_hi IPA_SYM_EXPORTED_NAME (trace_buffer_hi)
-# define traceframe_read_count IPA_SYM_EXPORTED_NAME (traceframe_read_count)
-# define traceframe_write_count IPA_SYM_EXPORTED_NAME (traceframe_write_count)
-# define traceframes_created IPA_SYM_EXPORTED_NAME (traceframes_created)
-# define trace_state_variables IPA_SYM_EXPORTED_NAME (trace_state_variables)
-# define get_raw_reg_ptr IPA_SYM_EXPORTED_NAME (get_raw_reg_ptr)
-# define get_trace_state_variable_value_ptr \
+#define gdb_tp_heap_buffer IPA_SYM_EXPORTED_NAME (gdb_tp_heap_buffer)
+#define gdb_jump_pad_buffer IPA_SYM_EXPORTED_NAME (gdb_jump_pad_buffer)
+#define gdb_jump_pad_buffer_end IPA_SYM_EXPORTED_NAME (gdb_jump_pad_buffer_end)
+#define gdb_trampoline_buffer IPA_SYM_EXPORTED_NAME (gdb_trampoline_buffer)
+#define gdb_trampoline_buffer_end \
+ IPA_SYM_EXPORTED_NAME (gdb_trampoline_buffer_end)
+#define gdb_trampoline_buffer_error \
+ IPA_SYM_EXPORTED_NAME (gdb_trampoline_buffer_error)
+#define collecting IPA_SYM_EXPORTED_NAME (collecting)
+#define gdb_collect_ptr IPA_SYM_EXPORTED_NAME (gdb_collect_ptr)
+#define stop_tracing IPA_SYM_EXPORTED_NAME (stop_tracing)
+#define flush_trace_buffer IPA_SYM_EXPORTED_NAME (flush_trace_buffer)
+#define about_to_request_buffer_space \
+ IPA_SYM_EXPORTED_NAME (about_to_request_buffer_space)
+#define trace_buffer_is_full IPA_SYM_EXPORTED_NAME (trace_buffer_is_full)
+#define stopping_tracepoint IPA_SYM_EXPORTED_NAME (stopping_tracepoint)
+#define expr_eval_result IPA_SYM_EXPORTED_NAME (expr_eval_result)
+#define error_tracepoint IPA_SYM_EXPORTED_NAME (error_tracepoint)
+#define tracepoints IPA_SYM_EXPORTED_NAME (tracepoints)
+#define tracing IPA_SYM_EXPORTED_NAME (tracing)
+#define trace_buffer_ctrl IPA_SYM_EXPORTED_NAME (trace_buffer_ctrl)
+#define trace_buffer_ctrl_curr IPA_SYM_EXPORTED_NAME (trace_buffer_ctrl_curr)
+#define trace_buffer_lo IPA_SYM_EXPORTED_NAME (trace_buffer_lo)
+#define trace_buffer_hi IPA_SYM_EXPORTED_NAME (trace_buffer_hi)
+#define traceframe_read_count IPA_SYM_EXPORTED_NAME (traceframe_read_count)
+#define traceframe_write_count IPA_SYM_EXPORTED_NAME (traceframe_write_count)
+#define traceframes_created IPA_SYM_EXPORTED_NAME (traceframes_created)
+#define trace_state_variables IPA_SYM_EXPORTED_NAME (trace_state_variables)
+#define get_raw_reg_ptr IPA_SYM_EXPORTED_NAME (get_raw_reg_ptr)
+#define get_trace_state_variable_value_ptr \
IPA_SYM_EXPORTED_NAME (get_trace_state_variable_value_ptr)
-# define set_trace_state_variable_value_ptr \
+#define set_trace_state_variable_value_ptr \
IPA_SYM_EXPORTED_NAME (set_trace_state_variable_value_ptr)
-# define ust_loaded IPA_SYM_EXPORTED_NAME (ust_loaded)
-# define helper_thread_id IPA_SYM_EXPORTED_NAME (helper_thread_id)
-# define cmd_buf IPA_SYM_EXPORTED_NAME (cmd_buf)
-# define ipa_tdesc_idx IPA_SYM_EXPORTED_NAME (ipa_tdesc_idx)
+#define ust_loaded IPA_SYM_EXPORTED_NAME (ust_loaded)
+#define helper_thread_id IPA_SYM_EXPORTED_NAME (helper_thread_id)
+#define cmd_buf IPA_SYM_EXPORTED_NAME (cmd_buf)
+#define ipa_tdesc_idx IPA_SYM_EXPORTED_NAME (ipa_tdesc_idx)
#endif
#ifndef IN_PROCESS_AGENT
@@ -175,36 +182,36 @@ static struct
const char *name;
int offset;
} symbol_list[] = {
- IPA_SYM(gdb_tp_heap_buffer),
- IPA_SYM(gdb_jump_pad_buffer),
- IPA_SYM(gdb_jump_pad_buffer_end),
- IPA_SYM(gdb_trampoline_buffer),
- IPA_SYM(gdb_trampoline_buffer_end),
- IPA_SYM(gdb_trampoline_buffer_error),
- IPA_SYM(collecting),
- IPA_SYM(gdb_collect_ptr),
- IPA_SYM(stop_tracing),
- IPA_SYM(flush_trace_buffer),
- IPA_SYM(about_to_request_buffer_space),
- IPA_SYM(trace_buffer_is_full),
- IPA_SYM(stopping_tracepoint),
- IPA_SYM(expr_eval_result),
- IPA_SYM(error_tracepoint),
- IPA_SYM(tracepoints),
- IPA_SYM(tracing),
- IPA_SYM(trace_buffer_ctrl),
- IPA_SYM(trace_buffer_ctrl_curr),
- IPA_SYM(trace_buffer_lo),
- IPA_SYM(trace_buffer_hi),
- IPA_SYM(traceframe_read_count),
- IPA_SYM(traceframe_write_count),
- IPA_SYM(traceframes_created),
- IPA_SYM(trace_state_variables),
- IPA_SYM(get_raw_reg_ptr),
- IPA_SYM(get_trace_state_variable_value_ptr),
- IPA_SYM(set_trace_state_variable_value_ptr),
- IPA_SYM(ust_loaded),
- IPA_SYM(ipa_tdesc_idx),
+ IPA_SYM (gdb_tp_heap_buffer),
+ IPA_SYM (gdb_jump_pad_buffer),
+ IPA_SYM (gdb_jump_pad_buffer_end),
+ IPA_SYM (gdb_trampoline_buffer),
+ IPA_SYM (gdb_trampoline_buffer_end),
+ IPA_SYM (gdb_trampoline_buffer_error),
+ IPA_SYM (collecting),
+ IPA_SYM (gdb_collect_ptr),
+ IPA_SYM (stop_tracing),
+ IPA_SYM (flush_trace_buffer),
+ IPA_SYM (about_to_request_buffer_space),
+ IPA_SYM (trace_buffer_is_full),
+ IPA_SYM (stopping_tracepoint),
+ IPA_SYM (expr_eval_result),
+ IPA_SYM (error_tracepoint),
+ IPA_SYM (tracepoints),
+ IPA_SYM (tracing),
+ IPA_SYM (trace_buffer_ctrl),
+ IPA_SYM (trace_buffer_ctrl_curr),
+ IPA_SYM (trace_buffer_lo),
+ IPA_SYM (trace_buffer_hi),
+ IPA_SYM (traceframe_read_count),
+ IPA_SYM (traceframe_write_count),
+ IPA_SYM (traceframes_created),
+ IPA_SYM (trace_state_variables),
+ IPA_SYM (get_raw_reg_ptr),
+ IPA_SYM (get_trace_state_variable_value_ptr),
+ IPA_SYM (set_trace_state_variable_value_ptr),
+ IPA_SYM (ust_loaded),
+ IPA_SYM (ipa_tdesc_idx),
};
static struct ipa_sym_addresses ipa_sym_addrs;
@@ -231,10 +238,10 @@ in_process_agent_supports_ust (void)
/* Agent understands static tracepoint, then check whether UST is in
fact loaded in the inferior. */
if (read_inferior_integer (ipa_sym_addrs.addr_ust_loaded, &loaded))
- {
- warning ("Error reading ust_loaded in lib");
- return 0;
- }
+ {
+ warning ("Error reading ust_loaded in lib");
+ return 0;
+ }
return loaded;
}
@@ -245,9 +252,8 @@ in_process_agent_supports_ust (void)
static void
write_e_ipa_not_loaded (char *buffer)
{
- sprintf (buffer,
- "E.In-process agent library not loaded in process. "
- "Fast and static tracepoints unavailable.");
+ sprintf (buffer, "E.In-process agent library not loaded in process. "
+ "Fast and static tracepoints unavailable.");
}
/* Write an error to BUFFER indicating that UST isn't loaded in the
@@ -257,9 +263,8 @@ static void
write_e_ust_not_loaded (char *buffer)
{
#ifdef HAVE_UST
- sprintf (buffer,
- "E.UST library not loaded in process. "
- "Static tracepoints unavailable.");
+ sprintf (buffer, "E.UST library not loaded in process. "
+ "Static tracepoints unavailable.");
#else
sprintf (buffer, "E.GDBserver was built without static tracepoints support");
#endif
@@ -315,14 +320,14 @@ tracepoint_look_up_symbols (void)
for (i = 0; i < sizeof (symbol_list) / sizeof (symbol_list[0]); i++)
{
- CORE_ADDR *addrp =
- (CORE_ADDR *) ((char *) &ipa_sym_addrs + symbol_list[i].offset);
+ CORE_ADDR *addrp
+ = (CORE_ADDR *) ((char *) &ipa_sym_addrs + symbol_list[i].offset);
if (look_up_one_symbol (symbol_list[i].name, addrp, 1) == 0)
- {
- threads_debug_printf ("symbol `%s' not found", symbol_list[i].name);
- return;
- }
+ {
+ threads_debug_printf ("symbol `%s' not found", symbol_list[i].name);
+ return;
+ }
}
agent_look_up_symbols (NULL);
@@ -359,9 +364,13 @@ read_inferior_memory (CORE_ADDR memaddr, unsigned char *myaddr, int len)
to not inline said functions. */
#if defined(__GNUC__)
-# define UNKNOWN_SIDE_EFFECTS() asm ("")
+#define UNKNOWN_SIDE_EFFECTS() asm ("")
#else
-# define UNKNOWN_SIDE_EFFECTS() do {} while (0)
+#define UNKNOWN_SIDE_EFFECTS() \
+ do \
+ { \
+ } \
+ while (0)
#endif
/* This is needed for -Wmissing-declarations. */
@@ -371,7 +380,7 @@ IP_AGENT_EXPORT_FUNC void
stop_tracing (void)
{
/* GDBserver places breakpoint here. */
- UNKNOWN_SIDE_EFFECTS();
+ UNKNOWN_SIDE_EFFECTS ();
}
/* This is needed for -Wmissing-declarations. */
@@ -381,7 +390,7 @@ IP_AGENT_EXPORT_FUNC void
flush_trace_buffer (void)
{
/* GDBserver places breakpoint here. */
- UNKNOWN_SIDE_EFFECTS();
+ UNKNOWN_SIDE_EFFECTS ();
}
#endif
@@ -391,7 +400,7 @@ static int
tracepoint_handler (CORE_ADDR address)
{
trace_debug ("tracepoint_handler: tracepoint at 0x%s hit",
- paddress (address));
+ paddress (address));
return 0;
}
@@ -411,8 +420,7 @@ static int run_inferior_command (char *cmd, int len);
static int
read_inferior_integer (CORE_ADDR symaddr, int *val)
{
- return read_inferior_memory (symaddr, (unsigned char *) val,
- sizeof (*val));
+ return read_inferior_memory (symaddr, (unsigned char *) val, sizeof (*val));
}
struct tracepoint;
@@ -421,8 +429,7 @@ static int tracepoint_send_agent (struct tracepoint *tpoint);
static int
read_inferior_uinteger (CORE_ADDR symaddr, unsigned int *val)
{
- return read_inferior_memory (symaddr, (unsigned char *) val,
- sizeof (*val));
+ return read_inferior_memory (symaddr, (unsigned char *) val, sizeof (*val));
}
static int
@@ -440,8 +447,7 @@ static int
write_inferior_data_pointer (CORE_ADDR symaddr, CORE_ADDR val)
{
void *pval = (void *) (uintptr_t) val;
- return target_write_memory (symaddr,
- (unsigned char *) &pval, sizeof (pval));
+ return target_write_memory (symaddr, (unsigned char *) &pval, sizeof (pval));
}
static int
@@ -464,11 +470,13 @@ write_inferior_uinteger (CORE_ADDR symaddr, unsigned int val)
static CORE_ADDR target_malloc (ULONGEST size);
-#define COPY_FIELD_TO_BUF(BUF, OBJ, FIELD) \
- do { \
- memcpy (BUF, &(OBJ)->FIELD, sizeof ((OBJ)->FIELD)); \
- BUF += sizeof ((OBJ)->FIELD); \
- } while (0)
+#define COPY_FIELD_TO_BUF(BUF, OBJ, FIELD) \
+ do \
+ { \
+ memcpy (BUF, &(OBJ)->FIELD, sizeof ((OBJ)->FIELD)); \
+ BUF += sizeof ((OBJ)->FIELD); \
+ } \
+ while (0)
#endif
@@ -518,7 +526,7 @@ m_tracepoint_action_download (const struct tracepoint_action *action)
CORE_ADDR ipa_action = target_malloc (sizeof (struct collect_memory_action));
target_write_memory (ipa_action, (unsigned char *) action,
- sizeof (struct collect_memory_action));
+ sizeof (struct collect_memory_action));
return ipa_action;
}
@@ -538,10 +546,11 @@ m_tracepoint_action_send (char *buffer, const struct tracepoint_action *action)
static CORE_ADDR
r_tracepoint_action_download (const struct tracepoint_action *action)
{
- CORE_ADDR ipa_action = target_malloc (sizeof (struct collect_registers_action));
+ CORE_ADDR ipa_action
+ = target_malloc (sizeof (struct collect_registers_action));
target_write_memory (ipa_action, (unsigned char *) action,
- sizeof (struct collect_registers_action));
+ sizeof (struct collect_registers_action));
return ipa_action;
}
@@ -561,11 +570,11 @@ x_tracepoint_action_download (const struct tracepoint_action *action)
CORE_ADDR expr;
target_write_memory (ipa_action, (unsigned char *) action,
- sizeof (struct eval_expr_action));
+ sizeof (struct eval_expr_action));
expr = download_agent_expr (((struct eval_expr_action *) action)->expr);
write_inferior_data_pointer (ipa_action
- + offsetof (struct eval_expr_action, expr),
- expr);
+ + offsetof (struct eval_expr_action, expr),
+ expr);
return ipa_action;
}
@@ -586,7 +595,7 @@ agent_expr_send (char *p, const struct agent_expr *aexpr)
else
{
memcpy (p, &aexpr->length, 4);
- p +=4;
+ p += 4;
memcpy (p, aexpr->bytes, aexpr->length);
p += aexpr->length;
@@ -595,7 +604,7 @@ agent_expr_send (char *p, const struct agent_expr *aexpr)
}
static char *
-x_tracepoint_action_send ( char *buffer, const struct tracepoint_action *action)
+x_tracepoint_action_send (char *buffer, const struct tracepoint_action *action)
{
struct eval_expr_action *eaction = (struct eval_expr_action *) action;
@@ -609,7 +618,7 @@ l_tracepoint_action_download (const struct tracepoint_action *action)
= target_malloc (sizeof (struct collect_static_trace_data_action));
target_write_memory (ipa_action, (unsigned char *) action,
- sizeof (struct collect_static_trace_data_action));
+ sizeof (struct collect_static_trace_data_action));
return ipa_action;
}
@@ -690,8 +699,7 @@ enum tracepoint_type
struct tracepoint_hit_ctx;
-typedef enum eval_result_type (*condfn) (unsigned char *,
- ULONGEST *);
+typedef enum eval_result_type (*condfn) (unsigned char *, ULONGEST *);
/* The definition of a tracepoint. */
@@ -797,7 +805,6 @@ struct tracepoint
NULL if we haven't inserted it yet. */
void *handle;
#endif
-
};
#ifndef IN_PROCESS_AGENT
@@ -857,17 +864,12 @@ EXTERN_C_POP
static struct tracepoint *last_tracepoint;
-static const char * const eval_result_names[] =
- {
- "terror:in the attic", /* this should never be reported */
- "terror:empty expression",
- "terror:empty stack",
- "terror:stack overflow",
- "terror:stack underflow",
- "terror:unhandled opcode",
- "terror:unrecognized opcode",
- "terror:divide by zero"
- };
+static const char *const eval_result_names[]
+ = { "terror:in the attic", /* this should never be reported */
+ "terror:empty expression", "terror:empty stack",
+ "terror:stack overflow", "terror:stack underflow",
+ "terror:unhandled opcode", "terror:unrecognized opcode",
+ "terror:divide by zero" };
#endif
@@ -939,11 +941,11 @@ IP_AGENT_EXPORT_VAR struct trace_state_variable *trace_state_variables;
free space ends up in two parts at opposite ends of the buffer. */
#ifndef ATTR_PACKED
-# if defined(__GNUC__)
-# define ATTR_PACKED __attribute__ ((packed))
-# else
-# define ATTR_PACKED /* nothing */
-# endif
+#if defined(__GNUC__)
+#define ATTR_PACKED __attribute__ ((packed))
+#else
+#define ATTR_PACKED /* nothing */
+#endif
#endif
/* The data collected at a tracepoint hit. This object should be as
@@ -1041,7 +1043,6 @@ struct ipa_trace_buffer_control
uintptr_t wrap;
};
-
/* We have possibly both GDBserver and an inferior thread accessing
the same IPA trace buffer memory. The IPA is the producer (tries
to put new frames in the buffer), while GDBserver occasionally
@@ -1139,13 +1140,13 @@ A GDBserver update of `trace_buffer_ctrl_curr' does:
for the counters described below. The cleared bits are used to
hold the index of the items of the `trace_buffer_ctrl' array that
is "current". */
-#define GDBSERVER_FLUSH_COUNT_MASK 0xfffffff0
+#define GDBSERVER_FLUSH_COUNT_MASK 0xfffffff0
/* `trace_buffer_ctrl_curr' contains two counters. The `previous'
counter, and the `current' counter. */
-#define GDBSERVER_FLUSH_COUNT_MASK_PREV 0x7ff00000
-#define GDBSERVER_FLUSH_COUNT_MASK_CURR 0x0007ff00
+#define GDBSERVER_FLUSH_COUNT_MASK_PREV 0x7ff00000
+#define GDBSERVER_FLUSH_COUNT_MASK_CURR 0x0007ff00
/* When GDBserver update the IP agent's `trace_buffer_ctrl_curr', it
always stamps this bit as set. */
@@ -1155,7 +1156,7 @@ A GDBserver update of `trace_buffer_ctrl_curr' does:
IP_AGENT_EXPORT_VAR struct trace_buffer_control trace_buffer_ctrl[3];
IP_AGENT_EXPORT_VAR unsigned int trace_buffer_ctrl_curr;
-# define TRACE_BUFFER_CTRL_CURR \
+#define TRACE_BUFFER_CTRL_CURR \
(trace_buffer_ctrl_curr & ~GDBSERVER_FLUSH_COUNT_MASK)
#else
@@ -1165,7 +1166,7 @@ IP_AGENT_EXPORT_VAR unsigned int trace_buffer_ctrl_curr;
that the rest of the code base doesn't need to care for the
difference. */
static trace_buffer_control trace_buffer_ctrl[1];
-# define TRACE_BUFFER_CTRL_CURR 0
+#define TRACE_BUFFER_CTRL_CURR 0
#endif
/* These are convenience macros used to access the current trace
@@ -1176,7 +1177,6 @@ static trace_buffer_control trace_buffer_ctrl[1];
(trace_buffer_ctrl[TRACE_BUFFER_CTRL_CURR].end_free)
#define trace_buffer_wrap (trace_buffer_ctrl[TRACE_BUFFER_CTRL_CURR].wrap)
-
/* Macro that returns a pointer to the first traceframe in the buffer. */
#define FIRST_TRACEFRAME() ((struct traceframe *) trace_buffer_start)
@@ -1188,11 +1188,11 @@ static trace_buffer_control trace_buffer_ctrl[1];
#define NEXT_TRACEFRAME_1(TF) \
(((unsigned char *) (TF)) + sizeof (struct traceframe) + (TF)->data_size)
-#define NEXT_TRACEFRAME(TF) \
- ((struct traceframe *) (NEXT_TRACEFRAME_1 (TF) \
- - ((NEXT_TRACEFRAME_1 (TF) >= trace_buffer_wrap) \
- ? (trace_buffer_wrap - trace_buffer_lo) \
- : 0)))
+#define NEXT_TRACEFRAME(TF) \
+ ((struct traceframe *) (NEXT_TRACEFRAME_1 (TF) \
+ - ((NEXT_TRACEFRAME_1 (TF) >= trace_buffer_wrap) \
+ ? (trace_buffer_wrap - trace_buffer_lo) \
+ : 0)))
/* The difference between these counters represents the total number
of complete traceframes present in the trace buffer. The IP agent
@@ -1351,7 +1351,7 @@ static int traceframe_read_tsv (int num, LONGEST *val);
#endif
static int condition_true_at_tracepoint (struct tracepoint_hit_ctx *ctx,
- struct tracepoint *tpoint);
+ struct tracepoint *tpoint);
#ifndef IN_PROCESS_AGENT
static void clear_readonly_regions (void);
@@ -1359,20 +1359,20 @@ static void clear_installed_tracepoints (void);
#endif
static void collect_data_at_tracepoint (struct tracepoint_hit_ctx *ctx,
- CORE_ADDR stop_pc,
- struct tracepoint *tpoint);
+ CORE_ADDR stop_pc,
+ struct tracepoint *tpoint);
#ifndef IN_PROCESS_AGENT
static void collect_data_at_step (struct tracepoint_hit_ctx *ctx,
- CORE_ADDR stop_pc,
- struct tracepoint *tpoint, int current_step);
+ CORE_ADDR stop_pc, struct tracepoint *tpoint,
+ int current_step);
static void compile_tracepoint_condition (struct tracepoint *tpoint,
- CORE_ADDR *jump_entry);
+ CORE_ADDR *jump_entry);
#endif
static void do_action_at_tracepoint (struct tracepoint_hit_ctx *ctx,
- CORE_ADDR stop_pc,
- struct tracepoint *tpoint,
- struct traceframe *tframe,
- struct tracepoint_action *taction);
+ CORE_ADDR stop_pc,
+ struct tracepoint *tpoint,
+ struct traceframe *tframe,
+ struct tracepoint_action *taction);
#ifndef IN_PROCESS_AGENT
static struct tracepoint *fast_tracepoint_from_ipa_tpoint_address (CORE_ADDR);
@@ -1381,15 +1381,19 @@ static void install_tracepoint (struct tracepoint *, char *own_buf);
static void download_tracepoint (struct tracepoint *);
static int install_fast_tracepoint (struct tracepoint *, char *errbuf);
static void clone_fast_tracepoint (struct tracepoint *to,
- const struct tracepoint *from);
+ const struct tracepoint *from);
#endif
static LONGEST get_timestamp (void);
#if defined(__GNUC__)
-# define memory_barrier() asm volatile ("" : : : "memory")
+#define memory_barrier() asm volatile ("" : : : "memory")
#else
-# define memory_barrier() do {} while (0)
+#define memory_barrier() \
+ do \
+ { \
+ } \
+ while (0)
#endif
/* We only build the IPA if this builtin is supported, and there are
@@ -1402,16 +1406,15 @@ static LONGEST get_timestamp (void);
static void
record_tracepoint_error (struct tracepoint *tpoint, const char *which,
- enum eval_result_type rtype)
+ enum eval_result_type rtype)
{
- trace_debug ("Tracepoint %d at %s %s eval reports error %d",
- tpoint->number, paddress (tpoint->address), which, rtype);
+ trace_debug ("Tracepoint %d at %s %s eval reports error %d", tpoint->number,
+ paddress (tpoint->address), which, rtype);
#ifdef IN_PROCESS_AGENT
/* Only record the first error we get. */
- if (cmpxchg (&expr_eval_result,
- expr_eval_no_error,
- rtype) != expr_eval_no_error)
+ if (cmpxchg (&expr_eval_result, expr_eval_no_error, rtype)
+ != expr_eval_no_error)
return;
#else
if (expr_eval_result != expr_eval_no_error)
@@ -1448,9 +1451,9 @@ clear_inferior_trace_buffer (void)
struct ipa_trace_buffer_control ipa_trace_buffer_ctrl;
read_inferior_data_pointer (ipa_sym_addrs.addr_trace_buffer_lo,
- &ipa_trace_buffer_lo);
+ &ipa_trace_buffer_lo);
read_inferior_data_pointer (ipa_sym_addrs.addr_trace_buffer_hi,
- &ipa_trace_buffer_hi);
+ &ipa_trace_buffer_hi);
ipa_trace_buffer_ctrl.start = ipa_trace_buffer_lo;
ipa_trace_buffer_ctrl.free = ipa_trace_buffer_lo;
@@ -1459,15 +1462,14 @@ clear_inferior_trace_buffer (void)
/* A traceframe with zeroed fields marks the end of trace data. */
target_write_memory (ipa_sym_addrs.addr_trace_buffer_ctrl,
- (unsigned char *) &ipa_trace_buffer_ctrl,
- sizeof (ipa_trace_buffer_ctrl));
+ (unsigned char *) &ipa_trace_buffer_ctrl,
+ sizeof (ipa_trace_buffer_ctrl));
write_inferior_uinteger (ipa_sym_addrs.addr_trace_buffer_ctrl_curr, 0);
/* A traceframe with zeroed fields marks the end of trace data. */
- target_write_memory (ipa_trace_buffer_lo,
- (unsigned char *) &ipa_traceframe,
- sizeof (ipa_traceframe));
+ target_write_memory (ipa_trace_buffer_lo, (unsigned char *) &ipa_traceframe,
+ sizeof (ipa_traceframe));
write_inferior_uinteger (ipa_sym_addrs.addr_traceframe_write_count, 0);
write_inferior_uinteger (ipa_sym_addrs.addr_traceframe_read_count, 0);
@@ -1485,8 +1487,9 @@ init_trace_buffer (LONGEST bufsize)
/* Make sure to internally allocate at least space for the EOB
marker. */
- alloc_size = (bufsize < TRACEFRAME_EOB_MARKER_SIZE
- ? TRACEFRAME_EOB_MARKER_SIZE : bufsize);
+ alloc_size
+ = (bufsize < TRACEFRAME_EOB_MARKER_SIZE ? TRACEFRAME_EOB_MARKER_SIZE
+ : bufsize);
trace_buffer_lo = (unsigned char *) xrealloc (trace_buffer_lo, alloc_size);
trace_buffer_hi = trace_buffer_lo + trace_buffer_size;
@@ -1504,7 +1507,7 @@ about_to_request_buffer_space (void)
{
/* GDBserver places breakpoint here while it goes about to flush
data at random times. */
- UNKNOWN_SIDE_EFFECTS();
+ UNKNOWN_SIDE_EFFECTS ();
}
#endif
@@ -1528,14 +1531,14 @@ trace_buffer_alloc (size_t amt)
unsigned char *new_start;
#endif
- trace_debug ("Want to allocate %ld+%ld bytes in trace buffer",
- (long) amt, (long) sizeof (struct traceframe));
+ trace_debug ("Want to allocate %ld+%ld bytes in trace buffer", (long) amt,
+ (long) sizeof (struct traceframe));
/* Account for the EOB marker. */
amt += TRACEFRAME_EOB_MARKER_SIZE;
#ifdef IN_PROCESS_AGENT
- again:
+again:
memory_barrier ();
/* Read the current token and extract the index to try to write to,
@@ -1551,8 +1554,7 @@ trace_buffer_alloc (size_t amt)
/* Start out with a copy of the current state. GDBserver may be
midway writing to the PREV_FILTERED TBC, but, that's OK, we won't
be able to commit anyway if that happens. */
- trace_buffer_ctrl[curr]
- = trace_buffer_ctrl[prev_filtered];
+ trace_buffer_ctrl[curr] = trace_buffer_ctrl[prev_filtered];
trace_debug ("trying curr=%u", curr);
#else
/* The GDBserver's agent doesn't need all that syncing, and always
@@ -1565,12 +1567,11 @@ trace_buffer_alloc (size_t amt)
especially for the small trace buffer sizes that are useful for
testing. */
trace_debug ("Trace buffer [%d] start=%d free=%d endfree=%d wrap=%d hi=%d",
- curr,
- (int) (tbctrl->start - trace_buffer_lo),
- (int) (tbctrl->free - trace_buffer_lo),
- (int) (tbctrl->end_free - trace_buffer_lo),
- (int) (tbctrl->wrap - trace_buffer_lo),
- (int) (trace_buffer_hi - trace_buffer_lo));
+ curr, (int) (tbctrl->start - trace_buffer_lo),
+ (int) (tbctrl->free - trace_buffer_lo),
+ (int) (tbctrl->end_free - trace_buffer_lo),
+ (int) (tbctrl->wrap - trace_buffer_lo),
+ (int) (trace_buffer_hi - trace_buffer_lo));
/* The algorithm here is to keep trying to get a contiguous block of
the requested size, possibly discarding older traceframes to free
@@ -1582,25 +1583,25 @@ trace_buffer_alloc (size_t amt)
{
/* First, if we have two free parts, try the upper one first. */
if (tbctrl->end_free < tbctrl->free)
- {
- if (tbctrl->free + amt <= trace_buffer_hi)
- /* We have enough in the upper part. */
- break;
- else
- {
- /* Our high part of free space wasn't enough. Give up
+ {
+ if (tbctrl->free + amt <= trace_buffer_hi)
+ /* We have enough in the upper part. */
+ break;
+ else
+ {
+ /* Our high part of free space wasn't enough. Give up
on it for now, set wraparound. We will recover the
space later, if/when the wrapped-around traceframe is
discarded. */
- trace_debug ("Upper part too small, setting wraparound");
- tbctrl->wrap = tbctrl->free;
- tbctrl->free = trace_buffer_lo;
- }
- }
+ trace_debug ("Upper part too small, setting wraparound");
+ tbctrl->wrap = tbctrl->free;
+ tbctrl->free = trace_buffer_lo;
+ }
+ }
/* The normal case. */
if (tbctrl->free + amt <= tbctrl->end_free)
- break;
+ break;
#ifdef IN_PROCESS_AGENT
/* The IP Agent's buffer is always circular. It isn't used
@@ -1611,10 +1612,10 @@ trace_buffer_alloc (size_t amt)
flush_trace_buffer ();
memory_barrier ();
if (tracing)
- {
- trace_debug ("gdbserver flushed buffer, retrying");
- goto again;
- }
+ {
+ trace_debug ("gdbserver flushed buffer, retrying");
+ goto again;
+ }
/* GDBserver cancelled the tracing. Bail out as well. */
return NULL;
@@ -1622,10 +1623,10 @@ trace_buffer_alloc (size_t amt)
/* If we're here, then neither part is big enough, and
non-circular trace buffers are now full. */
if (!circular_trace_buffer)
- {
- trace_debug ("Not enough space in the trace buffer");
- return NULL;
- }
+ {
+ trace_debug ("Not enough space in the trace buffer");
+ return NULL;
+ }
trace_debug ("Need more space in the trace buffer");
@@ -1633,13 +1634,13 @@ trace_buffer_alloc (size_t amt)
oldest traceframe and see if that helps. */
oldest = FIRST_TRACEFRAME ();
if (oldest->tpnum == 0)
- {
- /* Not good; we have no traceframes to free. Perhaps we're
+ {
+ /* Not good; we have no traceframes to free. Perhaps we're
asking for a block that is larger than the buffer? In
any case, give up. */
- trace_debug ("No traceframes to discard");
- return NULL;
- }
+ trace_debug ("No traceframes to discard");
+ return NULL;
+ }
/* We don't run this code in the in-process agent currently.
E.g., we could leave the in-process agent in autonomous
@@ -1652,22 +1653,21 @@ trace_buffer_alloc (size_t amt)
/* If we freed the traceframe that wrapped around, go back
to the non-wrap case. */
if (new_start < tbctrl->start)
- {
- trace_debug ("Discarding past the wraparound");
- tbctrl->wrap = trace_buffer_hi;
- }
+ {
+ trace_debug ("Discarding past the wraparound");
+ tbctrl->wrap = trace_buffer_hi;
+ }
tbctrl->start = new_start;
tbctrl->end_free = tbctrl->start;
trace_debug ("Discarded a traceframe\n"
- "Trace buffer [%d], start=%d free=%d "
- "endfree=%d wrap=%d hi=%d",
- curr,
- (int) (tbctrl->start - trace_buffer_lo),
- (int) (tbctrl->free - trace_buffer_lo),
- (int) (tbctrl->end_free - trace_buffer_lo),
- (int) (tbctrl->wrap - trace_buffer_lo),
- (int) (trace_buffer_hi - trace_buffer_lo));
+ "Trace buffer [%d], start=%d free=%d "
+ "endfree=%d wrap=%d hi=%d",
+ curr, (int) (tbctrl->start - trace_buffer_lo),
+ (int) (tbctrl->free - trace_buffer_lo),
+ (int) (tbctrl->end_free - trace_buffer_lo),
+ (int) (tbctrl->wrap - trace_buffer_lo),
+ (int) (trace_buffer_hi - trace_buffer_lo));
/* Now go back around the loop. The discard might have resulted
in either one or two pieces of free space, so we want to try
@@ -1691,18 +1691,17 @@ trace_buffer_alloc (size_t amt)
#ifdef IN_PROCESS_AGENT
/* Build the tentative token. */
commit_count = (((prev & GDBSERVER_FLUSH_COUNT_MASK_CURR) + 0x100)
- & GDBSERVER_FLUSH_COUNT_MASK_CURR);
- commit = (((prev & GDBSERVER_FLUSH_COUNT_MASK_CURR) << 12)
- | commit_count
- | curr);
+ & GDBSERVER_FLUSH_COUNT_MASK_CURR);
+ commit
+ = (((prev & GDBSERVER_FLUSH_COUNT_MASK_CURR) << 12) | commit_count | curr);
/* Try to commit it. */
readout = cmpxchg (&trace_buffer_ctrl_curr, prev, commit);
if (readout != prev)
{
trace_debug ("GDBserver has touched the trace buffer, restarting."
- " (prev=%08x, commit=%08x, readout=%08x)",
- prev, commit, readout);
+ " (prev=%08x, commit=%08x, readout=%08x)",
+ prev, commit, readout);
goto again;
}
@@ -1725,19 +1724,19 @@ trace_buffer_alloc (size_t amt)
refetch = trace_buffer_ctrl_curr;
if (refetch == commit
- || ((refetch & GDBSERVER_FLUSH_COUNT_MASK_PREV) >> 12) == commit_count)
+ || ((refetch & GDBSERVER_FLUSH_COUNT_MASK_PREV) >> 12) == commit_count)
{
- /* effective */
- trace_debug ("change is effective: (prev=%08x, commit=%08x, "
- "readout=%08x, refetch=%08x)",
- prev, commit, readout, refetch);
+ /* effective */
+ trace_debug ("change is effective: (prev=%08x, commit=%08x, "
+ "readout=%08x, refetch=%08x)",
+ prev, commit, readout, refetch);
}
else
{
- trace_debug ("GDBserver has touched the trace buffer, not effective."
- " (prev=%08x, commit=%08x, readout=%08x, refetch=%08x)",
- prev, commit, readout, refetch);
- goto again;
+ trace_debug ("GDBserver has touched the trace buffer, not effective."
+ " (prev=%08x, commit=%08x, readout=%08x, refetch=%08x)",
+ prev, commit, readout, refetch);
+ goto again;
}
}
#endif
@@ -1756,13 +1755,12 @@ trace_buffer_alloc (size_t amt)
{
trace_debug ("Allocated %d bytes", (int) amt);
trace_debug ("Trace buffer [%d] start=%d free=%d "
- "endfree=%d wrap=%d hi=%d",
- curr,
- (int) (tbctrl->start - trace_buffer_lo),
- (int) (tbctrl->free - trace_buffer_lo),
- (int) (tbctrl->end_free - trace_buffer_lo),
- (int) (tbctrl->wrap - trace_buffer_lo),
- (int) (trace_buffer_hi - trace_buffer_lo));
+ "endfree=%d wrap=%d hi=%d",
+ curr, (int) (tbctrl->start - trace_buffer_lo),
+ (int) (tbctrl->free - trace_buffer_lo),
+ (int) (tbctrl->end_free - trace_buffer_lo),
+ (int) (tbctrl->wrap - trace_buffer_lo),
+ (int) (trace_buffer_hi - trace_buffer_lo));
}
return rslt;
@@ -1780,7 +1778,7 @@ free_space (void)
return trace_buffer_end_free - trace_buffer_free;
else
return ((trace_buffer_end_free - trace_buffer_lo)
- + (trace_buffer_hi - trace_buffer_free));
+ + (trace_buffer_hi - trace_buffer_free));
}
/* An 'S' in continuation packets indicates remainder are for
@@ -1876,9 +1874,9 @@ remove_tracepoint (struct tracepoint *tpoint)
if (tp)
{
if (tp_prev)
- tp_prev->next = tp->next;
+ tp_prev->next = tp->next;
else
- tracepoints = tp->next;
+ tracepoints = tp->next;
xfree (tp);
}
@@ -1928,112 +1926,109 @@ add_tracepoint_action (struct tracepoint *tpoint, const char *packet)
struct tracepoint_action *action = NULL;
switch (*act)
- {
- case 'M':
- {
- struct collect_memory_action *maction =
- XNEW (struct collect_memory_action);
- ULONGEST basereg;
- int is_neg;
-
- maction->base.type = *act;
- action = &maction->base;
-
- ++act;
- is_neg = (*act == '-');
- if (*act == '-')
- ++act;
- act = unpack_varlen_hex (act, &basereg);
- ++act;
- act = unpack_varlen_hex (act, &maction->addr);
- ++act;
- act = unpack_varlen_hex (act, &maction->len);
- maction->basereg = (is_neg
- ? - (int) basereg
- : (int) basereg);
- trace_debug ("Want to collect %s bytes at 0x%s (basereg %d)",
- pulongest (maction->len),
- paddress (maction->addr), maction->basereg);
- break;
- }
- case 'R':
- {
- struct collect_registers_action *raction =
- XNEW (struct collect_registers_action);
-
- raction->base.type = *act;
- action = &raction->base;
-
- trace_debug ("Want to collect registers");
- ++act;
- /* skip past hex digits of mask for now */
- while (isxdigit(*act))
- ++act;
- break;
- }
- case 'L':
- {
- struct collect_static_trace_data_action *raction =
- XNEW (struct collect_static_trace_data_action);
-
- raction->base.type = *act;
- action = &raction->base;
-
- trace_debug ("Want to collect static trace data");
- ++act;
- break;
- }
- case 'S':
- trace_debug ("Unexpected step action, ignoring");
- ++act;
- break;
- case 'X':
- {
- struct eval_expr_action *xaction = XNEW (struct eval_expr_action);
-
- xaction->base.type = *act;
- action = &xaction->base;
-
- trace_debug ("Want to evaluate expression");
- xaction->expr = gdb_parse_agent_expr (&act);
- break;
- }
- default:
- trace_debug ("unknown trace action '%c', ignoring...", *act);
- break;
- case '-':
- break;
- }
+ {
+ case 'M':
+ {
+ struct collect_memory_action *maction
+ = XNEW (struct collect_memory_action);
+ ULONGEST basereg;
+ int is_neg;
+
+ maction->base.type = *act;
+ action = &maction->base;
+
+ ++act;
+ is_neg = (*act == '-');
+ if (*act == '-')
+ ++act;
+ act = unpack_varlen_hex (act, &basereg);
+ ++act;
+ act = unpack_varlen_hex (act, &maction->addr);
+ ++act;
+ act = unpack_varlen_hex (act, &maction->len);
+ maction->basereg = (is_neg ? -(int) basereg : (int) basereg);
+ trace_debug ("Want to collect %s bytes at 0x%s (basereg %d)",
+ pulongest (maction->len), paddress (maction->addr),
+ maction->basereg);
+ break;
+ }
+ case 'R':
+ {
+ struct collect_registers_action *raction
+ = XNEW (struct collect_registers_action);
+
+ raction->base.type = *act;
+ action = &raction->base;
+
+ trace_debug ("Want to collect registers");
+ ++act;
+ /* skip past hex digits of mask for now */
+ while (isxdigit (*act))
+ ++act;
+ break;
+ }
+ case 'L':
+ {
+ struct collect_static_trace_data_action *raction
+ = XNEW (struct collect_static_trace_data_action);
+
+ raction->base.type = *act;
+ action = &raction->base;
+
+ trace_debug ("Want to collect static trace data");
+ ++act;
+ break;
+ }
+ case 'S':
+ trace_debug ("Unexpected step action, ignoring");
+ ++act;
+ break;
+ case 'X':
+ {
+ struct eval_expr_action *xaction = XNEW (struct eval_expr_action);
+
+ xaction->base.type = *act;
+ action = &xaction->base;
+
+ trace_debug ("Want to evaluate expression");
+ xaction->expr = gdb_parse_agent_expr (&act);
+ break;
+ }
+ default:
+ trace_debug ("unknown trace action '%c', ignoring...", *act);
+ break;
+ case '-':
+ break;
+ }
if (action == NULL)
- break;
+ break;
if (seen_step_action_flag)
- {
- tpoint->num_step_actions++;
-
- tpoint->step_actions
- = XRESIZEVEC (struct tracepoint_action *, tpoint->step_actions,
- tpoint->num_step_actions);
- tpoint->step_actions_str
- = XRESIZEVEC (char *, tpoint->step_actions_str,
- tpoint->num_step_actions);
- tpoint->step_actions[tpoint->num_step_actions - 1] = action;
- tpoint->step_actions_str[tpoint->num_step_actions - 1]
- = savestring (act_start, act - act_start);
- }
+ {
+ tpoint->num_step_actions++;
+
+ tpoint->step_actions
+ = XRESIZEVEC (struct tracepoint_action *, tpoint->step_actions,
+ tpoint->num_step_actions);
+ tpoint->step_actions_str
+ = XRESIZEVEC (char *, tpoint->step_actions_str,
+ tpoint->num_step_actions);
+ tpoint->step_actions[tpoint->num_step_actions - 1] = action;
+ tpoint->step_actions_str[tpoint->num_step_actions - 1]
+ = savestring (act_start, act - act_start);
+ }
else
- {
- tpoint->numactions++;
- tpoint->actions
- = XRESIZEVEC (struct tracepoint_action *, tpoint->actions,
- tpoint->numactions);
- tpoint->actions_str
- = XRESIZEVEC (char *, tpoint->actions_str, tpoint->numactions);
- tpoint->actions[tpoint->numactions - 1] = action;
- tpoint->actions_str[tpoint->numactions - 1]
- = savestring (act_start, act - act_start);
- }
+ {
+ tpoint->numactions++;
+ tpoint->actions = XRESIZEVEC (struct tracepoint_action *,
+ tpoint->actions, tpoint->numactions);
+ tpoint->actions_str
+ = XRESIZEVEC (char *, tpoint->actions_str, tpoint->numactions);
+ tpoint->actions[tpoint->numactions - 1] = action;
+ tpoint->actions_str[tpoint->numactions - 1]
+ = savestring (act_start, act - act_start);
+ }
}
}
@@ -2117,15 +2112,15 @@ get_trace_state_variable_value (int num)
if (tsv->getter)
tsv->value = (tsv->getter) ();
- trace_debug ("get_trace_state_variable_value(%d) ==> %s",
- num, plongest (tsv->value));
+ trace_debug ("get_trace_state_variable_value(%d) ==> %s", num,
+ plongest (tsv->value));
return tsv->value;
}
/* This is needed for -Wmissing-declarations. */
IP_AGENT_EXPORT_FUNC void set_trace_state_variable_value (int num,
- LONGEST val);
+ LONGEST val);
IP_AGENT_EXPORT_FUNC void
set_trace_state_variable_value (int num, LONGEST val)
@@ -2209,8 +2204,8 @@ add_traceframe (struct tracepoint *tpoint)
/* Add a block to the traceframe currently being worked on. */
static unsigned char *
-add_traceframe_block (struct traceframe *tframe,
- struct tracepoint *tpoint, int amt)
+add_traceframe_block (struct traceframe *tframe, struct tracepoint *tpoint,
+ int amt)
{
unsigned char *block;
@@ -2250,12 +2245,11 @@ find_traceframe (int num)
struct traceframe *tframe;
int tfnum = 0;
- for (tframe = FIRST_TRACEFRAME ();
- tframe->tpnum != 0;
+ for (tframe = FIRST_TRACEFRAME (); tframe->tpnum != 0;
tframe = NEXT_TRACEFRAME (tframe))
{
if (tfnum == num)
- return tframe;
+ return tframe;
++tfnum;
}
@@ -2284,7 +2278,7 @@ get_traceframe_address (struct traceframe *tframe)
static struct traceframe *
find_next_traceframe_in_range (CORE_ADDR lo, CORE_ADDR hi, int inside_p,
- int *tfnump)
+ int *tfnump)
{
client_state &cs = get_client_state ();
struct traceframe *tframe;
@@ -2302,10 +2296,9 @@ find_next_traceframe_in_range (CORE_ADDR lo, CORE_ADDR hi, int inside_p,
for (; tframe->tpnum != 0; tframe = NEXT_TRACEFRAME (tframe))
{
tfaddr = get_traceframe_address (tframe);
- if (inside_p
- ? (lo <= tfaddr && tfaddr <= hi)
- : (lo > tfaddr || tfaddr > hi))
- return tframe;
+ if (inside_p ? (lo <= tfaddr && tfaddr <= hi)
+ : (lo > tfaddr || tfaddr > hi))
+ return tframe;
++*tfnump;
}
@@ -2335,7 +2328,7 @@ find_next_traceframe_by_tracepoint (int num, int *tfnump)
for (; tframe->tpnum != 0; tframe = NEXT_TRACEFRAME (tframe))
{
if (tframe->tpnum == num)
- return tframe;
+ return tframe;
++*tfnump;
}
@@ -2383,21 +2376,21 @@ cmd_qtinit (char *packet)
{
trace_debug ("Looking at var %d", tsv->number);
if (tsv->getter == NULL)
- {
- next = tsv->next;
- if (prev)
- prev->next = next;
- else
- trace_state_variables = next;
- trace_debug ("Deleting var %d", tsv->number);
- free (tsv);
- tsv = next;
- }
+ {
+ next = tsv->next;
+ if (prev)
+ prev->next = next;
+ else
+ trace_state_variables = next;
+ trace_debug ("Deleting var %d", tsv->number);
+ free (tsv);
+ tsv = next;
+ }
else
- {
- prev = tsv;
- tsv = tsv->next;
- }
+ {
+ prev = tsv;
+ tsv = tsv->next;
+ }
}
clear_trace_buffer ();
@@ -2437,45 +2430,43 @@ clear_installed_tracepoints (void)
/* Catch the case where we might try to remove a tracepoint that
was never actually installed. */
if (tpoint->handle == NULL)
- {
- trace_debug ("Tracepoint %d at 0x%s was "
- "never installed, nothing to clear",
- tpoint->number, paddress (tpoint->address));
- continue;
- }
+ {
+ trace_debug ("Tracepoint %d at 0x%s was "
+ "never installed, nothing to clear",
+ tpoint->number, paddress (tpoint->address));
+ continue;
+ }
switch (tpoint->type)
- {
- case trap_tracepoint:
- {
- struct breakpoint *bp
- = (struct breakpoint *) tpoint->handle;
-
- delete_breakpoint (bp);
- }
- break;
- case fast_tracepoint:
- {
- struct fast_tracepoint_jump *jump
- = (struct fast_tracepoint_jump *) tpoint->handle;
-
- delete_fast_tracepoint_jump (jump);
- }
- break;
- case static_tracepoint:
- if (prev_stpoint != NULL
- && prev_stpoint->address == tpoint->address)
- /* Nothing to do. We already unprobed a tracepoint set at
+ {
+ case trap_tracepoint:
+ {
+ struct breakpoint *bp = (struct breakpoint *) tpoint->handle;
+
+ delete_breakpoint (bp);
+ }
+ break;
+ case fast_tracepoint:
+ {
+ struct fast_tracepoint_jump *jump
+ = (struct fast_tracepoint_jump *) tpoint->handle;
+
+ delete_fast_tracepoint_jump (jump);
+ }
+ break;
+ case static_tracepoint:
+ if (prev_stpoint != NULL && prev_stpoint->address == tpoint->address)
+ /* Nothing to do. We already unprobed a tracepoint set at
this marker address (and there can only be one probe
per marker). */
- ;
- else
- {
- unprobe_marker_at (tpoint->address);
- prev_stpoint = tpoint;
- }
- break;
- }
+ ;
+ else
+ {
+ unprobe_marker_at (tpoint->address);
+ prev_stpoint = tpoint;
+ }
+ break;
+ }
tpoint->handle = NULL;
}
@@ -2519,13 +2510,13 @@ cmd_qtdp (char *own_buf)
{
/* Duplicate tracepoints are never allowed. */
if (tpoint)
- {
- trace_debug ("Tracepoint error: tracepoint %d"
- " at 0x%s already exists",
- (int) num, paddress (addr));
- write_enn (own_buf);
- return;
- }
+ {
+ trace_debug ("Tracepoint error: tracepoint %d"
+ " at 0x%s already exists",
+ (int) num, paddress (addr));
+ write_enn (own_buf);
+ return;
+ }
tpoint = add_tracepoint (num, addr);
@@ -2539,50 +2530,51 @@ cmd_qtdp (char *own_buf)
tpoint->pass_count = count;
/* See if we have any of the additional optional fields. */
while (*packet == ':')
- {
- ++packet;
- if (*packet == 'F')
- {
- tpoint->type = fast_tracepoint;
- ++packet;
- packet = unpack_varlen_hex (packet, &count);
- tpoint->orig_size = count;
- }
- else if (*packet == 'S')
- {
- tpoint->type = static_tracepoint;
- ++packet;
- }
- else if (*packet == 'X')
- {
- tpoint->cond = gdb_parse_agent_expr (&packet);
- }
- else if (*packet == '-')
- break;
- else if (*packet == '\0')
- break;
- else
- trace_debug ("Unknown optional tracepoint field");
- }
+ {
+ ++packet;
+ if (*packet == 'F')
+ {
+ tpoint->type = fast_tracepoint;
+ ++packet;
+ packet = unpack_varlen_hex (packet, &count);
+ tpoint->orig_size = count;
+ }
+ else if (*packet == 'S')
+ {
+ tpoint->type = static_tracepoint;
+ ++packet;
+ }
+ else if (*packet == 'X')
+ {
+ tpoint->cond = gdb_parse_agent_expr (&packet);
+ }
+ else if (*packet == '-')
+ break;
+ else if (*packet == '\0')
+ break;
+ else
+ trace_debug ("Unknown optional tracepoint field");
+ }
if (*packet == '-')
- {
- trail_hyphen = 1;
- trace_debug ("Also has actions\n");
- }
+ {
+ trail_hyphen = 1;
+ trace_debug ("Also has actions\n");
+ }
trace_debug ("Defined %stracepoint %d at 0x%s, "
- "enabled %d step %" PRIu64 " pass %" PRIu64,
- tpoint->type == fast_tracepoint ? "fast "
- : tpoint->type == static_tracepoint ? "static " : "",
- tpoint->number, paddress (tpoint->address), tpoint->enabled,
- tpoint->step_count, tpoint->pass_count);
+ "enabled %d step %" PRIu64 " pass %" PRIu64,
+ tpoint->type == fast_tracepoint ? "fast "
+ : tpoint->type == static_tracepoint ? "static "
+ : "",
+ tpoint->number, paddress (tpoint->address), tpoint->enabled,
+ tpoint->step_count, tpoint->pass_count);
}
else if (tpoint)
add_tracepoint_action (tpoint, packet);
else
{
trace_debug ("Tracepoint error: tracepoint %d at 0x%s not found",
- (int) num, paddress (addr));
+ (int) num, paddress (addr));
write_enn (own_buf);
return;
}
@@ -2605,52 +2597,51 @@ cmd_qtdp (char *own_buf)
/* Freeze threads. */
target_pause_all (true);
-
if (tpoint->type != trap_tracepoint)
- {
- /* Find another fast or static tracepoint at the same address. */
- for (tp = tracepoints; tp; tp = tp->next)
- {
- if (tp->address == tpoint->address && tp->type == tpoint->type
- && tp->number != tpoint->number)
- break;
- }
-
- /* TPOINT is installed at the same address as TP. */
- if (tp)
- {
- if (tpoint->type == fast_tracepoint)
- clone_fast_tracepoint (tpoint, tp);
- else if (tpoint->type == static_tracepoint)
- tpoint->handle = (void *) -1;
- }
- }
+ {
+ /* Find another fast or static tracepoint at the same address. */
+ for (tp = tracepoints; tp; tp = tp->next)
+ {
+ if (tp->address == tpoint->address && tp->type == tpoint->type
+ && tp->number != tpoint->number)
+ break;
+ }
+
+ /* TPOINT is installed at the same address as TP. */
+ if (tp)
+ {
+ if (tpoint->type == fast_tracepoint)
+ clone_fast_tracepoint (tpoint, tp);
+ else if (tpoint->type == static_tracepoint)
+ tpoint->handle = (void *) -1;
+ }
+ }
if (use_agent && tpoint->type == fast_tracepoint
- && agent_capability_check (AGENT_CAPA_FAST_TRACE))
- {
- /* Download and install fast tracepoint by agent. */
- if (tracepoint_send_agent (tpoint) == 0)
- write_ok (own_buf);
- else
- {
- write_enn (own_buf);
- remove_tracepoint (tpoint);
- }
- }
+ && agent_capability_check (AGENT_CAPA_FAST_TRACE))
+ {
+ /* Download and install fast tracepoint by agent. */
+ if (tracepoint_send_agent (tpoint) == 0)
+ write_ok (own_buf);
+ else
+ {
+ write_enn (own_buf);
+ remove_tracepoint (tpoint);
+ }
+ }
else
- {
- download_tracepoint (tpoint);
-
- if (tpoint->type == trap_tracepoint || tp == NULL)
- {
- install_tracepoint (tpoint, own_buf);
- if (strcmp (own_buf, "OK") != 0)
- remove_tracepoint (tpoint);
- }
- else
- write_ok (own_buf);
- }
+ {
+ download_tracepoint (tpoint);
+
+ if (tpoint->type == trap_tracepoint || tp == NULL)
+ {
+ install_tracepoint (tpoint, own_buf);
+ if (strcmp (own_buf, "OK") != 0)
+ remove_tracepoint (tpoint);
+ }
+ else
+ write_ok (own_buf);
+ }
target_unpause_all (true);
return;
@@ -2683,7 +2674,7 @@ cmd_qtdpsrc (char *own_buf)
if (!tpoint)
{
trace_debug ("Tracepoint error: tracepoint %d at 0x%s not found",
- (int) num, paddress (addr));
+ (int) num, paddress (addr));
write_enn (own_buf);
return;
}
@@ -2712,7 +2703,7 @@ cmd_qtdpsrc (char *own_buf)
if (tpoint->source_strings)
{
for (last = tpoint->source_strings; last->next; last = last->next)
- ;
+ ;
last->next = newlast;
}
else
@@ -2770,41 +2761,40 @@ cmd_qtenable_disable (char *own_buf, int enable)
if (tp)
{
if ((enable && tp->enabled) || (!enable && !tp->enabled))
- {
- trace_debug ("Tracepoint %d at 0x%s is already %s",
- (int) num, paddress (addr),
- enable ? "enabled" : "disabled");
- write_ok (own_buf);
- return;
- }
+ {
+ trace_debug ("Tracepoint %d at 0x%s is already %s", (int) num,
+ paddress (addr), enable ? "enabled" : "disabled");
+ write_ok (own_buf);
+ return;
+ }
trace_debug ("%s tracepoint %d at 0x%s",
- enable ? "Enabling" : "Disabling",
- (int) num, paddress (addr));
+ enable ? "Enabling" : "Disabling", (int) num,
+ paddress (addr));
tp->enabled = enable;
if (tp->type == fast_tracepoint || tp->type == static_tracepoint)
- {
- int offset = offsetof (struct tracepoint, enabled);
- CORE_ADDR obj_addr = tp->obj_addr_on_target + offset;
-
- int ret = write_inferior_int8 (obj_addr, enable);
- if (ret)
- {
- trace_debug ("Cannot write enabled flag into "
- "inferior process memory");
- write_enn (own_buf);
- return;
- }
- }
+ {
+ int offset = offsetof (struct tracepoint, enabled);
+ CORE_ADDR obj_addr = tp->obj_addr_on_target + offset;
+
+ int ret = write_inferior_int8 (obj_addr, enable);
+ if (ret)
+ {
+ trace_debug ("Cannot write enabled flag into "
+ "inferior process memory");
+ write_enn (own_buf);
+ return;
+ }
+ }
write_ok (own_buf);
}
else
{
- trace_debug ("Tracepoint %d at 0x%s not found",
- (int) num, paddress (addr));
+ trace_debug ("Tracepoint %d at 0x%s not found", (int) num,
+ paddress (addr));
write_enn (own_buf);
}
}
@@ -2825,10 +2815,10 @@ cmd_qtv (char *own_buf)
{
err = traceframe_read_tsv ((int) num, &val);
if (err)
- {
- strcpy (own_buf, "U");
- return;
- }
+ {
+ strcpy (own_buf, "U");
+ return;
+ }
}
/* Only make tsv's be undefined before the first trace run. After a
trace run is over, the user might want to see the last value of
@@ -2878,9 +2868,9 @@ cmd_qtro (char *own_buf)
while (*packet == ':')
{
- ++packet; /* skip a colon */
+ ++packet; /* skip a colon */
packet = unpack_varlen_hex (packet, &start);
- ++packet; /* skip a comma */
+ ++packet; /* skip a comma */
packet = unpack_varlen_hex (packet, &end);
roreg = XNEW (struct readonly_region);
@@ -2889,7 +2879,7 @@ cmd_qtro (char *own_buf)
roreg->next = readonly_regions;
readonly_regions = roreg;
trace_debug ("Added readonly region from 0x%s to 0x%s",
- paddress (roreg->start), paddress (roreg->end));
+ paddress (roreg->start), paddress (roreg->end));
}
write_ok (own_buf);
@@ -2921,10 +2911,10 @@ get_jump_space_head (void)
if (gdb_jump_pad_head == 0)
{
if (read_inferior_data_pointer (ipa_sym_addrs.addr_gdb_jump_pad_buffer,
- &gdb_jump_pad_head))
- {
- internal_error ("error extracting jump_pad_buffer");
- }
+ &gdb_jump_pad_head))
+ {
+ internal_error ("error extracting jump_pad_buffer");
+ }
}
return gdb_jump_pad_head;
@@ -2935,8 +2925,8 @@ get_jump_space_head (void)
static void
claim_jump_space (ULONGEST used)
{
- trace_debug ("claim_jump_space reserves %s bytes at %s",
- pulongest (used), paddress (gdb_jump_pad_head));
+ trace_debug ("claim_jump_space reserves %s bytes at %s", pulongest (used),
+ paddress (gdb_jump_pad_head));
gdb_jump_pad_head += used;
}
@@ -2953,16 +2943,17 @@ claim_trampoline_space (ULONGEST used, CORE_ADDR *trampoline)
if (!trampoline_buffer_head)
{
if (read_inferior_data_pointer (ipa_sym_addrs.addr_gdb_trampoline_buffer,
- &trampoline_buffer_tail))
- {
- internal_error ("error extracting trampoline_buffer");
- }
+ &trampoline_buffer_tail))
+ {
+ internal_error ("error extracting trampoline_buffer");
+ }
- if (read_inferior_data_pointer (ipa_sym_addrs.addr_gdb_trampoline_buffer_end,
- &trampoline_buffer_head))
- {
- internal_error ("error extracting trampoline_buffer_end");
- }
+ if (read_inferior_data_pointer (ipa_sym_addrs
+ .addr_gdb_trampoline_buffer_end,
+ &trampoline_buffer_head))
+ {
+ internal_error ("error extracting trampoline_buffer_end");
+ }
}
/* Start claiming space from the top of the trampoline space. If
@@ -2972,14 +2963,14 @@ claim_trampoline_space (ULONGEST used, CORE_ADDR *trampoline)
if (trampoline_buffer_head - trampoline_buffer_tail < used)
{
trace_debug ("claim_trampoline_space failed to reserve %s bytes",
- pulongest (used));
+ pulongest (used));
return 0;
}
trampoline_buffer_head -= used;
trace_debug ("claim_trampoline_space reserves %s bytes at %s",
- pulongest (used), paddress (trampoline_buffer_head));
+ pulongest (used), paddress (trampoline_buffer_head));
*trampoline = trampoline_buffer_head;
return 1;
@@ -2994,20 +2985,20 @@ have_fast_tracepoint_trampoline_buffer (char *buf)
CORE_ADDR trampoline_end, errbuf;
if (read_inferior_data_pointer (ipa_sym_addrs.addr_gdb_trampoline_buffer_end,
- &trampoline_end))
+ &trampoline_end))
{
internal_error ("error extracting trampoline_buffer_end");
}
-
+
if (buf)
{
buf[0] = '\0';
strcpy (buf, "was claiming");
- if (read_inferior_data_pointer (ipa_sym_addrs.addr_gdb_trampoline_buffer_error,
- &errbuf))
- {
- internal_error ("error extracting errbuf");
- }
+ if (read_inferior_data_pointer (
+ ipa_sym_addrs.addr_gdb_trampoline_buffer_error, &errbuf))
+ {
+ internal_error ("error extracting errbuf");
+ }
read_inferior_memory (errbuf, (unsigned char *) buf, 100);
}
@@ -3033,10 +3024,10 @@ probe_marker_at (CORE_ADDR address, char *errout)
if (err == 0)
{
if (*cmd == 'E')
- {
- strcpy (errout, cmd);
- return -1;
- }
+ {
+ strcpy (errout, cmd);
+ return -1;
+ }
}
return err;
@@ -3078,12 +3069,12 @@ install_fast_tracepoint (struct tracepoint *tpoint, char *errbuf)
if (tpoint->orig_size < target_get_min_fast_tracepoint_insn_len ())
{
trace_debug ("Requested a fast tracepoint on an instruction "
- "that is of less than the minimum length.");
+ "that is of less than the minimum length.");
return 0;
}
if (read_inferior_data_pointer (ipa_sym_addrs.addr_gdb_collect_ptr,
- &collect))
+ &collect))
{
error ("error extracting gdb_collect_ptr");
return 1;
@@ -3095,18 +3086,23 @@ install_fast_tracepoint (struct tracepoint *tpoint, char *errbuf)
trampoline_size = 0;
/* Install the jump pad. */
- err = target_install_fast_tracepoint_jump_pad
- (tpoint->obj_addr_on_target, tpoint->address, collect,
- ipa_sym_addrs.addr_collecting, tpoint->orig_size, &jentry,
- &trampoline, &trampoline_size, fjump, &fjump_size,
- &tpoint->adjusted_insn_addr, &tpoint->adjusted_insn_addr_end, errbuf);
+ err
+ = target_install_fast_tracepoint_jump_pad (tpoint->obj_addr_on_target,
+ tpoint->address, collect,
+ ipa_sym_addrs.addr_collecting,
+ tpoint->orig_size, &jentry,
+ &trampoline, &trampoline_size,
+ fjump, &fjump_size,
+ &tpoint->adjusted_insn_addr,
+ &tpoint->adjusted_insn_addr_end,
+ errbuf);
if (err)
return 1;
/* Wire it in. */
- tpoint->handle = set_fast_tracepoint_jump (tpoint->address, fjump,
- fjump_size);
+ tpoint->handle
+ = set_fast_tracepoint_jump (tpoint->address, fjump, fjump_size);
if (tpoint->handle != NULL)
{
@@ -3123,7 +3119,6 @@ install_fast_tracepoint (struct tracepoint *tpoint, char *errbuf)
return 0;
}
-
/* Install tracepoint TPOINT, and write reply message in OWN_BUF. */
static void
@@ -3138,36 +3133,35 @@ install_tracepoint (struct tracepoint *tpoint, char *own_buf)
ahead and install the trap. The breakpoints module
handles duplicated breakpoints, and the memory read
routine handles un-patching traps from memory reads. */
- tpoint->handle = set_breakpoint_at (tpoint->address,
- tracepoint_handler);
+ tpoint->handle = set_breakpoint_at (tpoint->address, tracepoint_handler);
}
- else if (tpoint->type == fast_tracepoint || tpoint->type == static_tracepoint)
+ else if (tpoint->type == fast_tracepoint
+ || tpoint->type == static_tracepoint)
{
if (!agent_loaded_p ())
- {
- trace_debug ("Requested a %s tracepoint, but fast "
- "tracepoints aren't supported.",
- tpoint->type == static_tracepoint ? "static" : "fast");
- write_e_ipa_not_loaded (own_buf);
- return;
- }
+ {
+ trace_debug ("Requested a %s tracepoint, but fast "
+ "tracepoints aren't supported.",
+ tpoint->type == static_tracepoint ? "static" : "fast");
+ write_e_ipa_not_loaded (own_buf);
+ return;
+ }
if (tpoint->type == static_tracepoint
- && !in_process_agent_supports_ust ())
- {
- trace_debug ("Requested a static tracepoint, but static "
- "tracepoints are not supported.");
- write_e_ust_not_loaded (own_buf);
- return;
- }
+ && !in_process_agent_supports_ust ())
+ {
+ trace_debug ("Requested a static tracepoint, but static "
+ "tracepoints are not supported.");
+ write_e_ust_not_loaded (own_buf);
+ return;
+ }
if (tpoint->type == fast_tracepoint)
- install_fast_tracepoint (tpoint, own_buf);
+ install_fast_tracepoint (tpoint, own_buf);
else
- {
- if (probe_marker_at (tpoint->address, own_buf) == 0)
- tpoint->handle = (void *) -1;
- }
-
+ {
+ if (probe_marker_at (tpoint->address, own_buf) == 0)
+ tpoint->handle = (void *) -1;
+ }
}
else
internal_error ("Unknown tracepoint type");
@@ -3175,7 +3169,7 @@ install_tracepoint (struct tracepoint *tpoint, char *own_buf)
if (tpoint->handle == NULL)
{
if (*own_buf == '\0')
- write_enn (own_buf);
+ write_enn (own_buf);
}
else
write_ok (own_buf);
@@ -3219,8 +3213,8 @@ cmd_qtstart (char *packet)
{
/* Tell IPA about the correct tdesc. */
if (write_inferior_integer (ipa_sym_addrs.addr_ipa_tdesc_idx,
- target_get_ipa_tdesc_idx ()))
- error ("Error setting ipa_tdesc_idx variable in lib");
+ target_get_ipa_tdesc_idx ()))
+ error ("Error setting ipa_tdesc_idx variable in lib");
}
/* Start out empty. */
@@ -3235,103 +3229,105 @@ cmd_qtstart (char *packet)
tpoint->traceframe_usage = 0;
if (tpoint->type == trap_tracepoint)
- {
- /* Tracepoints are installed as memory breakpoints. Just go
+ {
+ /* Tracepoints are installed as memory breakpoints. Just go
ahead and install the trap. The breakpoints module
handles duplicated breakpoints, and the memory read
routine handles un-patching traps from memory reads. */
- tpoint->handle = set_breakpoint_at (tpoint->address,
- tracepoint_handler);
- }
+ tpoint->handle
+ = set_breakpoint_at (tpoint->address, tracepoint_handler);
+ }
else if (tpoint->type == fast_tracepoint
- || tpoint->type == static_tracepoint)
- {
- if (maybe_write_ipa_not_loaded (packet))
- {
- trace_debug ("Requested a %s tracepoint, but fast "
- "tracepoints aren't supported.",
- tpoint->type == static_tracepoint
- ? "static" : "fast");
- break;
- }
-
- if (tpoint->type == fast_tracepoint)
- {
- int use_agent_p
- = use_agent && agent_capability_check (AGENT_CAPA_FAST_TRACE);
-
- if (prev_ftpoint != NULL
- && prev_ftpoint->address == tpoint->address)
- {
- if (use_agent_p)
- tracepoint_send_agent (tpoint);
- else
- download_tracepoint_1 (tpoint);
-
- clone_fast_tracepoint (tpoint, prev_ftpoint);
- }
- else
- {
- /* Tracepoint is installed successfully? */
- int installed = 0;
-
- /* Download and install fast tracepoint by agent. */
- if (use_agent_p)
- installed = !tracepoint_send_agent (tpoint);
- else
- {
- download_tracepoint_1 (tpoint);
- installed = !install_fast_tracepoint (tpoint, packet);
- }
-
- if (installed)
- prev_ftpoint = tpoint;
- }
- }
- else
- {
- if (!in_process_agent_supports_ust ())
- {
- trace_debug ("Requested a static tracepoint, but static "
- "tracepoints are not supported.");
- break;
- }
-
- download_tracepoint_1 (tpoint);
- /* Can only probe a given marker once. */
- if (prev_stpoint != NULL
- && prev_stpoint->address == tpoint->address)
- tpoint->handle = (void *) -1;
- else
- {
- if (probe_marker_at (tpoint->address, packet) == 0)
- {
- tpoint->handle = (void *) -1;
-
- /* So that we can handle multiple static tracepoints
+ || tpoint->type == static_tracepoint)
+ {
+ if (maybe_write_ipa_not_loaded (packet))
+ {
+ trace_debug ("Requested a %s tracepoint, but fast "
+ "tracepoints aren't supported.",
+ tpoint->type == static_tracepoint ? "static"
+ : "fast");
+ break;
+ }
+
+ if (tpoint->type == fast_tracepoint)
+ {
+ int use_agent_p
+ = use_agent && agent_capability_check (AGENT_CAPA_FAST_TRACE);
+
+ if (prev_ftpoint != NULL
+ && prev_ftpoint->address == tpoint->address)
+ {
+ if (use_agent_p)
+ tracepoint_send_agent (tpoint);
+ else
+ download_tracepoint_1 (tpoint);
+
+ clone_fast_tracepoint (tpoint, prev_ftpoint);
+ }
+ else
+ {
+ /* Tracepoint is installed successfully? */
+ int installed = 0;
+
+ /* Download and install fast tracepoint by agent. */
+ if (use_agent_p)
+ installed = !tracepoint_send_agent (tpoint);
+ else
+ {
+ download_tracepoint_1 (tpoint);
+ installed = !install_fast_tracepoint (tpoint, packet);
+ }
+
+ if (installed)
+ prev_ftpoint = tpoint;
+ }
+ }
+ else
+ {
+ if (!in_process_agent_supports_ust ())
+ {
+ trace_debug ("Requested a static tracepoint, but static "
+ "tracepoints are not supported.");
+ break;
+ }
+
+ download_tracepoint_1 (tpoint);
+ /* Can only probe a given marker once. */
+ if (prev_stpoint != NULL
+ && prev_stpoint->address == tpoint->address)
+ tpoint->handle = (void *) -1;
+ else
+ {
+ if (probe_marker_at (tpoint->address, packet) == 0)
+ {
+ tpoint->handle = (void *) -1;
+
+ /* So that we can handle multiple static tracepoints
at the same address easily. */
- prev_stpoint = tpoint;
- }
- }
- }
+ prev_stpoint = tpoint;
+ }
+ }
+ }
- prev_tpptr = tpptr;
- tpptr = tpoint->obj_addr_on_target;
+ prev_tpptr = tpptr;
+ tpptr = tpoint->obj_addr_on_target;
- if (tpoint == tracepoints)
- /* First object in list, set the head pointer in the
+ if (tpoint == tracepoints)
+ /* First object in list, set the head pointer in the
inferior. */
- write_inferior_data_pointer (ipa_sym_addrs.addr_tracepoints, tpptr);
- else
- write_inferior_data_pointer (prev_tpptr
- + offsetof (struct tracepoint, next),
- tpptr);
- }
+ write_inferior_data_pointer (ipa_sym_addrs.addr_tracepoints,
+ tpptr);
+ else
+ write_inferior_data_pointer (prev_tpptr
+ + offsetof (struct tracepoint,
+ next),
+ tpptr);
+ }
/* Any failure in the inner loop is sufficient cause to give
up. */
if (tpoint->handle == NULL)
- break;
+ break;
}
/* Any error in tracepoint insertion is unacceptable; better to
@@ -3341,7 +3337,7 @@ cmd_qtstart (char *packet)
{
clear_installed_tracepoints ();
if (*packet == '\0')
- write_enn (packet);
+ write_enn (packet);
target_unpause_all (true);
return;
}
@@ -3358,33 +3354,33 @@ cmd_qtstart (char *packet)
if (agent_loaded_p ())
{
if (write_inferior_integer (ipa_sym_addrs.addr_tracing, 1))
- {
- internal_error ("Error setting tracing variable in lib");
- }
+ {
+ internal_error ("Error setting tracing variable in lib");
+ }
if (write_inferior_data_pointer (ipa_sym_addrs.addr_stopping_tracepoint,
- 0))
- {
- internal_error ("Error clearing stopping_tracepoint variable"
- " in lib");
- }
+ 0))
+ {
+ internal_error ("Error clearing stopping_tracepoint variable"
+ " in lib");
+ }
if (write_inferior_integer (ipa_sym_addrs.addr_trace_buffer_is_full, 0))
- {
- internal_error ("Error clearing trace_buffer_is_full variable"
- " in lib");
- }
+ {
+ internal_error ("Error clearing trace_buffer_is_full variable"
+ " in lib");
+ }
stop_tracing_bkpt = set_breakpoint_at (ipa_sym_addrs.addr_stop_tracing,
- stop_tracing_handler);
+ stop_tracing_handler);
if (stop_tracing_bkpt == NULL)
- error ("Error setting stop_tracing breakpoint");
+ error ("Error setting stop_tracing breakpoint");
flush_trace_buffer_bkpt
- = set_breakpoint_at (ipa_sym_addrs.addr_flush_trace_buffer,
- flush_trace_buffer_handler);
+ = set_breakpoint_at (ipa_sym_addrs.addr_flush_trace_buffer,
+ flush_trace_buffer_handler);
if (flush_trace_buffer_bkpt == NULL)
- error ("Error setting flush_trace_buffer breakpoint");
+ error ("Error setting flush_trace_buffer breakpoint");
}
target_unpause_all (true);
@@ -3422,9 +3418,9 @@ stop_tracing (void)
if (agent_loaded_p ())
{
if (write_inferior_integer (ipa_sym_addrs.addr_tracing, 0))
- {
- internal_error ("Error clearing tracing variable in lib");
- }
+ {
+ internal_error ("Error clearing tracing variable in lib");
+ }
}
tracing_stop_time = get_timestamp ();
@@ -3433,9 +3429,9 @@ stop_tracing (void)
if (stopping_tracepoint)
{
trace_debug ("Stopping the trace because "
- "tracepoint %d was hit %" PRIu64 " times",
- stopping_tracepoint->number,
- stopping_tracepoint->pass_count);
+ "tracepoint %d was hit %" PRIu64 " times",
+ stopping_tracepoint->number,
+ stopping_tracepoint->pass_count);
tracing_stop_reason = "tpasscount";
tracing_stop_tpnum = stopping_tracepoint->number;
}
@@ -3559,7 +3555,7 @@ cmd_qtframe (char *own_buf)
++packet;
unpack_varlen_hex (packet, &hi);
trace_debug ("Want to find next traceframe in the range 0x%s to 0x%s",
- paddress (lo), paddress (hi));
+ paddress (lo), paddress (hi));
tframe = find_next_traceframe_in_range (lo, hi, 1, &tfnum);
}
else if (startswith (packet, "outside:"))
@@ -3569,8 +3565,8 @@ cmd_qtframe (char *own_buf)
++packet;
unpack_varlen_hex (packet, &hi);
trace_debug ("Want to find next traceframe "
- "outside the range 0x%s to 0x%s",
- paddress (lo), paddress (hi));
+ "outside the range 0x%s to 0x%s",
+ paddress (lo), paddress (hi));
tframe = find_next_traceframe_in_range (lo, hi, 0, &tfnum);
}
else if (startswith (packet, "tdp:"))
@@ -3586,12 +3582,12 @@ cmd_qtframe (char *own_buf)
unpack_varlen_hex (packet, &frame);
tfnum = (int) frame;
if (tfnum == -1)
- {
- trace_debug ("Want to stop looking at traceframes");
- cs.current_traceframe = -1;
- write_ok (own_buf);
- return;
- }
+ {
+ trace_debug ("Want to stop looking at traceframes");
+ cs.current_traceframe = -1;
+ write_ok (own_buf);
+ return;
+ }
trace_debug ("Want to look at traceframe %d", tfnum);
tframe = find_traceframe (tfnum);
}
@@ -3631,8 +3627,8 @@ cmd_qtstatus (char *packet)
buf3 = (char *) alloca (slen * 2 + 1);
bin2hex ((gdb_byte *) str, buf3, slen);
- trace_debug ("Returning trace status as %d, stop reason %s",
- tracing, tracing_stop_reason);
+ trace_debug ("Returning trace status as %d, stop reason %s", tracing,
+ tracing_stop_reason);
if (agent_loaded_p ())
{
@@ -3641,7 +3637,7 @@ cmd_qtstatus (char *packet)
upload_fast_traceframes ();
target_unpause_all (true);
- }
+ }
stop_reason_rsp = (char *) tracing_stop_reason;
@@ -3657,7 +3653,7 @@ cmd_qtstatus (char *packet)
result_name = stop_reason_rsp + strlen ("terror:");
hexstr_len = strlen (result_name) * 2;
p = stop_reason_rsp
- = (char *) alloca (strlen ("terror:") + hexstr_len + 1);
+ = (char *) alloca (strlen ("terror:") + hexstr_len + 1);
strcpy (p, "terror:");
p += strlen (p);
bin2hex ((gdb_byte *) result_name, p, strlen (result_name));
@@ -3666,29 +3662,28 @@ cmd_qtstatus (char *packet)
/* If this was a forced stop, include any stop note that was supplied. */
if (strcmp (stop_reason_rsp, "tstop") == 0)
{
- stop_reason_rsp = (char *) alloca (strlen ("tstop:") + strlen (buf3) + 1);
+ stop_reason_rsp
+ = (char *) alloca (strlen ("tstop:") + strlen (buf3) + 1);
strcpy (stop_reason_rsp, "tstop:");
strcat (stop_reason_rsp, buf3);
}
sprintf (packet,
- "T%d;"
- "%s:%x;"
- "tframes:%x;tcreated:%x;"
- "tfree:%x;tsize:%s;"
- "circular:%d;"
- "disconn:%d;"
- "starttime:%s;stoptime:%s;"
- "username:%s;notes:%s:",
- tracing ? 1 : 0,
- stop_reason_rsp, tracing_stop_tpnum,
- traceframe_count, traceframes_created,
- free_space (), phex_nz (trace_buffer_hi - trace_buffer_lo, 0),
- circular_trace_buffer,
- disconnected_tracing,
- phex_nz (tracing_start_time, sizeof (tracing_start_time)),
- phex_nz (tracing_stop_time, sizeof (tracing_stop_time)),
- buf1, buf2);
+ "T%d;"
+ "%s:%x;"
+ "tframes:%x;tcreated:%x;"
+ "tfree:%x;tsize:%s;"
+ "circular:%d;"
+ "disconn:%d;"
+ "starttime:%s;stoptime:%s;"
+ "username:%s;notes:%s:",
+ tracing ? 1 : 0, stop_reason_rsp, tracing_stop_tpnum,
+ traceframe_count, traceframes_created, free_space (),
+ phex_nz (trace_buffer_hi - trace_buffer_lo, 0),
+ circular_trace_buffer, disconnected_tracing,
+ phex_nz (tracing_start_time, sizeof (tracing_start_time)),
+ phex_nz (tracing_stop_time, sizeof (tracing_stop_time)), buf1,
+ buf2);
}
static void
@@ -3710,13 +3705,13 @@ cmd_qtp (char *own_buf)
if (!tpoint)
{
trace_debug ("Tracepoint error: tracepoint %d at 0x%s not found",
- (int) num, paddress (addr));
+ (int) num, paddress (addr));
write_enn (own_buf);
return;
}
sprintf (own_buf, "V%" PRIu64 ":%" PRIu64 "", tpoint->hit_count,
- tpoint->traceframe_usage);
+ tpoint->traceframe_usage);
}
/* State variables to help return all the tracepoint bits. */
@@ -3735,9 +3730,8 @@ response_tracepoint (char *packet, struct tracepoint *tpoint)
char *buf;
sprintf (packet, "T%x:%s:%c:%" PRIx64 ":%" PRIx64, tpoint->number,
- paddress (tpoint->address),
- (tpoint->enabled ? 'E' : 'D'), tpoint->step_count,
- tpoint->pass_count);
+ paddress (tpoint->address), (tpoint->enabled ? 'E' : 'D'),
+ tpoint->step_count, tpoint->pass_count);
if (tpoint->type == fast_tracepoint)
sprintf (packet + strlen (packet), ":F%x", tpoint->orig_size);
else if (tpoint->type == static_tracepoint)
@@ -3746,8 +3740,7 @@ response_tracepoint (char *packet, struct tracepoint *tpoint)
if (tpoint->cond)
{
buf = gdb_unparse_agent_expr (tpoint->cond);
- sprintf (packet + strlen (packet), ":X%x,%s",
- tpoint->cond->length, buf);
+ sprintf (packet + strlen (packet), ":X%x,%s", tpoint->cond->length, buf);
free (buf);
}
}
@@ -3759,20 +3752,19 @@ response_tracepoint (char *packet, struct tracepoint *tpoint)
per-packet. */
static void
-response_action (char *packet, struct tracepoint *tpoint,
- char *taction, int step)
+response_action (char *packet, struct tracepoint *tpoint, char *taction,
+ int step)
{
- sprintf (packet, "%c%x:%s:%s",
- (step ? 'S' : 'A'), tpoint->number, paddress (tpoint->address),
- taction);
+ sprintf (packet, "%c%x:%s:%s", (step ? 'S' : 'A'), tpoint->number,
+ paddress (tpoint->address), taction);
}
/* Compose a response that is an imitation of the syntax by which the
tracepoint source piece was originally downloaded. */
static void
-response_source (char *packet,
- struct tracepoint *tpoint, struct source_string *src)
+response_source (char *packet, struct tracepoint *tpoint,
+ struct source_string *src)
{
char *buf;
int len;
@@ -3781,9 +3773,8 @@ response_source (char *packet,
buf = (char *) alloca (len * 2 + 1);
bin2hex ((gdb_byte *) src->str, buf, len);
- sprintf (packet, "Z%x:%s:%s:%x:%x:%s",
- tpoint->number, paddress (tpoint->address),
- src->type, 0, len, buf);
+ sprintf (packet, "Z%x:%s:%s:%x:%x:%s", tpoint->number,
+ paddress (tpoint->address), src->type, 0, len, buf);
}
/* Return the first piece of tracepoint definition, and initialize the
@@ -3823,24 +3814,23 @@ cmd_qtsp (char *packet)
}
else if (cur_action < cur_tpoint->numactions)
{
- response_action (packet, cur_tpoint,
- cur_tpoint->actions_str[cur_action], 0);
+ response_action (packet, cur_tpoint, cur_tpoint->actions_str[cur_action],
+ 0);
++cur_action;
}
else if (cur_step_action < cur_tpoint->num_step_actions)
{
response_action (packet, cur_tpoint,
- cur_tpoint->step_actions_str[cur_step_action], 1);
+ cur_tpoint->step_actions_str[cur_step_action], 1);
++cur_step_action;
}
- else if ((cur_source_string
- ? cur_source_string->next
- : cur_tpoint->source_strings))
+ else if ((cur_source_string ? cur_source_string->next
+ : cur_tpoint->source_strings))
{
if (cur_source_string)
- cur_source_string = cur_source_string->next;
+ cur_source_string = cur_source_string->next;
else
- cur_source_string = cur_tpoint->source_strings;
+ cur_source_string = cur_tpoint->source_strings;
response_source (packet, cur_tpoint, cur_source_string);
}
else
@@ -3849,9 +3839,9 @@ cmd_qtsp (char *packet)
cur_action = cur_step_action = 0;
cur_source_string = NULL;
if (cur_tpoint)
- response_tracepoint (packet, cur_tpoint);
+ response_tracepoint (packet, cur_tpoint);
else
- strcpy (packet, "l");
+ strcpy (packet, "l");
}
}
@@ -3872,7 +3862,7 @@ response_tsv (char *packet, struct trace_state_variable *tsv)
}
sprintf (packet, "%x:%s:%x:%s", tsv->number, phex_nz (tsv->initial_value, 0),
- tsv->getter ? 1 : 0, buf);
+ tsv->getter ? 1 : 0, buf);
}
/* Return the first trace state variable definition, and initialize
@@ -3902,9 +3892,9 @@ cmd_qtsv (char *packet)
{
cur_tsv = cur_tsv->next;
if (cur_tsv)
- response_tsv (packet, cur_tsv);
+ response_tsv (packet, cur_tsv);
else
- strcpy (packet, "l");
+ strcpy (packet, "l");
}
else
strcpy (packet, "l");
@@ -3993,8 +3983,8 @@ cmd_qtbuffer (char *own_buf)
++packet; /* skip a comma */
unpack_varlen_hex (packet, &num);
- trace_debug ("Want to get trace buffer, %d bytes at offset 0x%s",
- (int) num, phex_nz (offset, 0));
+ trace_debug ("Want to get trace buffer, %d bytes at offset 0x%s", (int) num,
+ phex_nz (offset, 0));
tot = (trace_buffer_hi - trace_buffer_lo) - free_space ();
@@ -4023,7 +4013,7 @@ cmd_qtbuffer (char *own_buf)
num = tot - offset;
/* Trim to available packet size. */
- if (num >= (PBUFSIZ - 16) / 2 )
+ if (num >= (PBUFSIZ - 16) / 2)
num = (PBUFSIZ - 16) / 2;
bin2hex (tbp, own_buf, num);
@@ -4040,7 +4030,7 @@ cmd_bigqtbuffer_circular (char *own_buf)
unpack_varlen_hex (packet, &val);
circular_trace_buffer = val;
trace_debug ("Trace buffer is now %s",
- circular_trace_buffer ? "circular" : "linear");
+ circular_trace_buffer ? "circular" : "linear");
write_ok (own_buf);
}
@@ -4070,8 +4060,7 @@ cmd_bigqtbuffer_size (char *own_buf)
}
init_trace_buffer (sval);
- trace_debug ("Trace buffer is now %s bytes",
- plongest (trace_buffer_size));
+ trace_debug ("Trace buffer is now %s bytes", plongest (trace_buffer_size));
write_ok (own_buf);
}
@@ -4087,49 +4076,49 @@ cmd_qtnotes (char *own_buf)
while (*packet)
{
if (startswith (packet, "user:"))
- {
- packet += strlen ("user:");
- saved = packet;
- packet = strchr (packet, ';');
- nbytes = (packet - saved) / 2;
- user = (char *) xmalloc (nbytes + 1);
- nbytes = hex2bin (saved, (gdb_byte *) user, nbytes);
- user[nbytes] = '\0';
- ++packet; /* skip the semicolon */
- trace_debug ("User is '%s'", user);
- xfree (tracing_user_name);
- tracing_user_name = user;
- }
+ {
+ packet += strlen ("user:");
+ saved = packet;
+ packet = strchr (packet, ';');
+ nbytes = (packet - saved) / 2;
+ user = (char *) xmalloc (nbytes + 1);
+ nbytes = hex2bin (saved, (gdb_byte *) user, nbytes);
+ user[nbytes] = '\0';
+ ++packet; /* skip the semicolon */
+ trace_debug ("User is '%s'", user);
+ xfree (tracing_user_name);
+ tracing_user_name = user;
+ }
else if (startswith (packet, "notes:"))
- {
- packet += strlen ("notes:");
- saved = packet;
- packet = strchr (packet, ';');
- nbytes = (packet - saved) / 2;
- notes = (char *) xmalloc (nbytes + 1);
- nbytes = hex2bin (saved, (gdb_byte *) notes, nbytes);
- notes[nbytes] = '\0';
- ++packet; /* skip the semicolon */
- trace_debug ("Notes is '%s'", notes);
- xfree (tracing_notes);
- tracing_notes = notes;
- }
+ {
+ packet += strlen ("notes:");
+ saved = packet;
+ packet = strchr (packet, ';');
+ nbytes = (packet - saved) / 2;
+ notes = (char *) xmalloc (nbytes + 1);
+ nbytes = hex2bin (saved, (gdb_byte *) notes, nbytes);
+ notes[nbytes] = '\0';
+ ++packet; /* skip the semicolon */
+ trace_debug ("Notes is '%s'", notes);
+ xfree (tracing_notes);
+ tracing_notes = notes;
+ }
else if (startswith (packet, "tstop:"))
- {
- packet += strlen ("tstop:");
- saved = packet;
- packet = strchr (packet, ';');
- nbytes = (packet - saved) / 2;
- stopnote = (char *) xmalloc (nbytes + 1);
- nbytes = hex2bin (saved, (gdb_byte *) stopnote, nbytes);
- stopnote[nbytes] = '\0';
- ++packet; /* skip the semicolon */
- trace_debug ("tstop note is '%s'", stopnote);
- xfree (tracing_stop_note);
- tracing_stop_note = stopnote;
- }
+ {
+ packet += strlen ("tstop:");
+ saved = packet;
+ packet = strchr (packet, ';');
+ nbytes = (packet - saved) / 2;
+ stopnote = (char *) xmalloc (nbytes + 1);
+ nbytes = hex2bin (saved, (gdb_byte *) stopnote, nbytes);
+ stopnote[nbytes] = '\0';
+ ++packet; /* skip the semicolon */
+ trace_debug ("tstop note is '%s'", stopnote);
+ xfree (tracing_stop_note);
+ tracing_stop_note = stopnote;
+ }
else
- break;
+ break;
}
write_ok (own_buf);
@@ -4302,8 +4291,8 @@ handle_tracepoint_query (char *packet)
action covering the whole range. */
static void
-add_while_stepping_state (struct thread_info *tinfo,
- int tp_number, CORE_ADDR tp_address)
+add_while_stepping_state (struct thread_info *tinfo, int tp_number,
+ CORE_ADDR tp_address)
{
struct wstep_state *wstep = XNEW (struct wstep_state);
@@ -4378,8 +4367,8 @@ tracepoint_finished_step (struct thread_info *tinfo, CORE_ADDR stop_pc)
wstep_link = &tinfo->while_stepping;
trace_debug ("Thread %s finished a single-step for tracepoint %d at 0x%s",
- target_pid_to_str (tinfo->id).c_str (),
- wstep->tp_number, paddress (wstep->tp_address));
+ target_pid_to_str (tinfo->id).c_str (), wstep->tp_number,
+ paddress (wstep->tp_address));
ctx.base.type = trap_tracepoint;
ctx.regcache = get_thread_regcache (tinfo, 1);
@@ -4388,59 +4377,57 @@ tracepoint_finished_step (struct thread_info *tinfo, CORE_ADDR stop_pc)
{
tpoint = find_tracepoint (wstep->tp_number, wstep->tp_address);
if (tpoint == NULL)
- {
- trace_debug ("NO TRACEPOINT %d at 0x%s FOR THREAD %s!",
- wstep->tp_number, paddress (wstep->tp_address),
- target_pid_to_str (tinfo->id).c_str ());
-
- /* Unlink. */
- *wstep_link = wstep->next;
- release_while_stepping_state (wstep);
- wstep = *wstep_link;
- continue;
- }
+ {
+ trace_debug ("NO TRACEPOINT %d at 0x%s FOR THREAD %s!",
+ wstep->tp_number, paddress (wstep->tp_address),
+ target_pid_to_str (tinfo->id).c_str ());
+
+ /* Unlink. */
+ *wstep_link = wstep->next;
+ release_while_stepping_state (wstep);
+ wstep = *wstep_link;
+ continue;
+ }
/* We've just finished one step. */
++wstep->current_step;
/* Collect data. */
- collect_data_at_step ((struct tracepoint_hit_ctx *) &ctx,
- stop_pc, tpoint, wstep->current_step);
+ collect_data_at_step ((struct tracepoint_hit_ctx *) &ctx, stop_pc,
+ tpoint, wstep->current_step);
if (wstep->current_step >= tpoint->step_count)
- {
- /* The requested numbers of steps have occurred. */
- trace_debug ("Thread %s done stepping for tracepoint %d at 0x%s",
- target_pid_to_str (tinfo->id).c_str (),
- wstep->tp_number, paddress (wstep->tp_address));
-
- /* Unlink the wstep. */
- *wstep_link = wstep->next;
- release_while_stepping_state (wstep);
- wstep = *wstep_link;
-
- /* Only check the hit count now, which ensure that we do all
+ {
+ /* The requested numbers of steps have occurred. */
+ trace_debug ("Thread %s done stepping for tracepoint %d at 0x%s",
+ target_pid_to_str (tinfo->id).c_str (),
+ wstep->tp_number, paddress (wstep->tp_address));
+
+ /* Unlink the wstep. */
+ *wstep_link = wstep->next;
+ release_while_stepping_state (wstep);
+ wstep = *wstep_link;
+
+ /* Only check the hit count now, which ensure that we do all
our stepping before stopping the run. */
- if (tpoint->pass_count > 0
- && tpoint->hit_count >= tpoint->pass_count
- && stopping_tracepoint == NULL)
- stopping_tracepoint = tpoint;
- }
+ if (tpoint->pass_count > 0 && tpoint->hit_count >= tpoint->pass_count
+ && stopping_tracepoint == NULL)
+ stopping_tracepoint = tpoint;
+ }
else
- {
- /* Keep single-stepping until the requested numbers of steps
+ {
+ /* Keep single-stepping until the requested numbers of steps
have occurred. */
- wstep_link = &wstep->next;
- wstep = *wstep_link;
- }
+ wstep_link = &wstep->next;
+ wstep = *wstep_link;
+ }
- if (stopping_tracepoint
- || trace_buffer_is_full
- || expr_eval_result != expr_eval_no_error)
- {
- stop_tracing ();
- break;
- }
+ if (stopping_tracepoint || trace_buffer_is_full
+ || expr_eval_result != expr_eval_no_error)
+ {
+ stop_tracing ();
+ break;
+ }
}
return 1;
@@ -4473,49 +4460,48 @@ handle_tracepoint_bkpts (struct thread_info *tinfo, CORE_ADDR stop_pc)
trace_debug ("lib stopped at stop_tracing");
read_inferior_integer (ipa_sym_addrs.addr_trace_buffer_is_full,
- &ipa_trace_buffer_is_full);
+ &ipa_trace_buffer_is_full);
read_inferior_data_pointer (ipa_sym_addrs.addr_stopping_tracepoint,
- &ipa_stopping_tracepoint);
+ &ipa_stopping_tracepoint);
write_inferior_data_pointer (ipa_sym_addrs.addr_stopping_tracepoint, 0);
read_inferior_data_pointer (ipa_sym_addrs.addr_error_tracepoint,
- &ipa_error_tracepoint);
+ &ipa_error_tracepoint);
write_inferior_data_pointer (ipa_sym_addrs.addr_error_tracepoint, 0);
read_inferior_integer (ipa_sym_addrs.addr_expr_eval_result,
- &ipa_expr_eval_result);
+ &ipa_expr_eval_result);
write_inferior_integer (ipa_sym_addrs.addr_expr_eval_result, 0);
trace_debug ("lib: trace_buffer_is_full: %d, "
- "stopping_tracepoint: %s, "
- "ipa_expr_eval_result: %d, "
- "error_tracepoint: %s, ",
- ipa_trace_buffer_is_full,
- paddress (ipa_stopping_tracepoint),
- ipa_expr_eval_result,
- paddress (ipa_error_tracepoint));
+ "stopping_tracepoint: %s, "
+ "ipa_expr_eval_result: %d, "
+ "error_tracepoint: %s, ",
+ ipa_trace_buffer_is_full,
+ paddress (ipa_stopping_tracepoint), ipa_expr_eval_result,
+ paddress (ipa_error_tracepoint));
if (ipa_trace_buffer_is_full)
- trace_debug ("lib stopped due to full buffer.");
+ trace_debug ("lib stopped due to full buffer.");
if (ipa_stopping_tracepoint)
- trace_debug ("lib stopped due to tpoint");
+ trace_debug ("lib stopped due to tpoint");
if (ipa_error_tracepoint)
- trace_debug ("lib stopped due to error");
+ trace_debug ("lib stopped due to error");
if (ipa_stopping_tracepoint != 0)
- {
- stopping_tracepoint
- = fast_tracepoint_from_ipa_tpoint_address (ipa_stopping_tracepoint);
- }
+ {
+ stopping_tracepoint = fast_tracepoint_from_ipa_tpoint_address (
+ ipa_stopping_tracepoint);
+ }
else if (ipa_expr_eval_result != expr_eval_no_error)
- {
- expr_eval_result = ipa_expr_eval_result;
- error_tracepoint
- = fast_tracepoint_from_ipa_tpoint_address (ipa_error_tracepoint);
- }
+ {
+ expr_eval_result = ipa_expr_eval_result;
+ error_tracepoint
+ = fast_tracepoint_from_ipa_tpoint_address (ipa_error_tracepoint);
+ }
stop_tracing ();
return 1;
}
@@ -4554,36 +4540,35 @@ tracepoint_was_hit (struct thread_info *tinfo, CORE_ADDR stop_pc)
and probes will be executed in program. So static tracepoints
are collected there. */
if (tpoint->enabled && stop_pc == tpoint->address
- && tpoint->type != static_tracepoint)
- {
- trace_debug ("Thread %s at address of tracepoint %d at 0x%s",
- target_pid_to_str (tinfo->id).c_str (),
- tpoint->number, paddress (tpoint->address));
-
- /* Test the condition if present, and collect if true. */
- if (!tpoint->cond
- || (condition_true_at_tracepoint
- ((struct tracepoint_hit_ctx *) &ctx, tpoint)))
- collect_data_at_tracepoint ((struct tracepoint_hit_ctx *) &ctx,
- stop_pc, tpoint);
-
- if (stopping_tracepoint
- || trace_buffer_is_full
- || expr_eval_result != expr_eval_no_error)
- {
- stop_tracing ();
- }
- /* If the tracepoint had a 'while-stepping' action, then set
+ && tpoint->type != static_tracepoint)
+ {
+ trace_debug ("Thread %s at address of tracepoint %d at 0x%s",
+ target_pid_to_str (tinfo->id).c_str (), tpoint->number,
+ paddress (tpoint->address));
+
+ /* Test the condition if present, and collect if true. */
+ if (!tpoint->cond
+ || (condition_true_at_tracepoint (
+ (struct tracepoint_hit_ctx *) &ctx, tpoint)))
+ collect_data_at_tracepoint ((struct tracepoint_hit_ctx *) &ctx,
+ stop_pc, tpoint);
+
+ if (stopping_tracepoint || trace_buffer_is_full
+ || expr_eval_result != expr_eval_no_error)
+ {
+ stop_tracing ();
+ }
+ /* If the tracepoint had a 'while-stepping' action, then set
the thread to collect this tracepoint on the following
single-steps. */
- else if (tpoint->step_count > 0)
- {
- add_while_stepping_state (tinfo,
- tpoint->number, tpoint->address);
- }
+ else if (tpoint->step_count > 0)
+ {
+ add_while_stepping_state (tinfo, tpoint->number,
+ tpoint->address);
+ }
- ret = 1;
- }
+ ret = 1;
+ }
}
return ret;
@@ -4594,7 +4579,7 @@ tracepoint_was_hit (struct thread_info *tinfo, CORE_ADDR stop_pc)
#if defined IN_PROCESS_AGENT && defined HAVE_UST
struct ust_marker_data;
static void collect_ust_data_at_tracepoint (struct tracepoint_hit_ctx *ctx,
- struct traceframe *tframe);
+ struct traceframe *tframe);
#endif
/* Create a trace frame for the hit of the given tracepoint in the
@@ -4602,7 +4587,7 @@ static void collect_ust_data_at_tracepoint (struct tracepoint_hit_ctx *ctx,
static void
collect_data_at_tracepoint (struct tracepoint_hit_ctx *ctx, CORE_ADDR stop_pc,
- struct tracepoint *tpoint)
+ struct tracepoint *tpoint)
{
struct traceframe *tframe;
int acti;
@@ -4614,30 +4599,28 @@ collect_data_at_tracepoint (struct tracepoint_hit_ctx *ctx, CORE_ADDR stop_pc,
later, and finish the collection for this hit. This test is only
for nonstepping tracepoints, stepping tracepoints test at the end
of their while-stepping loop. */
- if (tpoint->pass_count > 0
- && tpoint->hit_count >= tpoint->pass_count
- && tpoint->step_count == 0
- && stopping_tracepoint == NULL)
+ if (tpoint->pass_count > 0 && tpoint->hit_count >= tpoint->pass_count
+ && tpoint->step_count == 0 && stopping_tracepoint == NULL)
stopping_tracepoint = tpoint;
trace_debug ("Making new traceframe for tracepoint %d at 0x%s, hit %" PRIu64,
- tpoint->number, paddress (tpoint->address), tpoint->hit_count);
+ tpoint->number, paddress (tpoint->address), tpoint->hit_count);
tframe = add_traceframe (tpoint);
if (tframe)
{
for (acti = 0; acti < tpoint->numactions; ++acti)
- {
+ {
#ifndef IN_PROCESS_AGENT
- trace_debug ("Tracepoint %d at 0x%s about to do action '%s'",
- tpoint->number, paddress (tpoint->address),
- tpoint->actions_str[acti]);
+ trace_debug ("Tracepoint %d at 0x%s about to do action '%s'",
+ tpoint->number, paddress (tpoint->address),
+ tpoint->actions_str[acti]);
#endif
- do_action_at_tracepoint (ctx, stop_pc, tpoint, tframe,
- tpoint->actions[acti]);
- }
+ do_action_at_tracepoint (ctx, stop_pc, tpoint, tframe,
+ tpoint->actions[acti]);
+ }
finish_traceframe (tframe);
}
@@ -4649,32 +4632,30 @@ collect_data_at_tracepoint (struct tracepoint_hit_ctx *ctx, CORE_ADDR stop_pc,
#ifndef IN_PROCESS_AGENT
static void
-collect_data_at_step (struct tracepoint_hit_ctx *ctx,
- CORE_ADDR stop_pc,
- struct tracepoint *tpoint, int current_step)
+collect_data_at_step (struct tracepoint_hit_ctx *ctx, CORE_ADDR stop_pc,
+ struct tracepoint *tpoint, int current_step)
{
struct traceframe *tframe;
int acti;
trace_debug ("Making new step traceframe for "
- "tracepoint %d at 0x%s, step %d of %" PRIu64 ", hit %" PRIu64,
- tpoint->number, paddress (tpoint->address),
- current_step, tpoint->step_count,
- tpoint->hit_count);
+ "tracepoint %d at 0x%s, step %d of %" PRIu64 ", hit %" PRIu64,
+ tpoint->number, paddress (tpoint->address), current_step,
+ tpoint->step_count, tpoint->hit_count);
tframe = add_traceframe (tpoint);
if (tframe)
{
for (acti = 0; acti < tpoint->num_step_actions; ++acti)
- {
- trace_debug ("Tracepoint %d at 0x%s about to do step action '%s'",
- tpoint->number, paddress (tpoint->address),
- tpoint->step_actions_str[acti]);
+ {
+ trace_debug ("Tracepoint %d at 0x%s about to do step action '%s'",
+ tpoint->number, paddress (tpoint->address),
+ tpoint->step_actions_str[acti]);
- do_action_at_tracepoint (ctx, stop_pc, tpoint, tframe,
- tpoint->step_actions[acti]);
- }
+ do_action_at_tracepoint (ctx, stop_pc, tpoint, tframe,
+ tpoint->step_actions[acti]);
+ }
finish_traceframe (tframe);
}
@@ -4704,32 +4685,32 @@ get_context_regcache (struct tracepoint_hit_ctx *ctx)
{
struct fast_tracepoint_ctx *fctx = (struct fast_tracepoint_ctx *) ctx;
if (!fctx->regcache_initted)
- {
- fctx->regcache_initted = 1;
- init_register_cache (&fctx->regcache, ipa_tdesc, fctx->regspace);
- supply_regblock (&fctx->regcache, NULL);
- supply_fast_tracepoint_registers (&fctx->regcache, fctx->regs);
- }
+ {
+ fctx->regcache_initted = 1;
+ init_register_cache (&fctx->regcache, ipa_tdesc, fctx->regspace);
+ supply_regblock (&fctx->regcache, NULL);
+ supply_fast_tracepoint_registers (&fctx->regcache, fctx->regs);
+ }
regcache = &fctx->regcache;
}
#ifdef HAVE_UST
if (ctx->type == static_tracepoint)
{
struct static_tracepoint_ctx *sctx
- = (struct static_tracepoint_ctx *) ctx;
+ = (struct static_tracepoint_ctx *) ctx;
if (!sctx->regcache_initted)
- {
- sctx->regcache_initted = 1;
- init_register_cache (&sctx->regcache, ipa_tdesc, sctx->regspace);
- supply_regblock (&sctx->regcache, NULL);
- /* Pass down the tracepoint address, because REGS doesn't
+ {
+ sctx->regcache_initted = 1;
+ init_register_cache (&sctx->regcache, ipa_tdesc, sctx->regspace);
+ supply_regblock (&sctx->regcache, NULL);
+ /* Pass down the tracepoint address, because REGS doesn't
include the PC, but we know what it must have been. */
- supply_static_tracepoint_registers (&sctx->regcache,
- (const unsigned char *)
- sctx->regs,
- sctx->tpoint->address);
- }
+ supply_static_tracepoint_registers (&sctx->regcache,
+ (const unsigned char *)
+ sctx->regs,
+ sctx->tpoint->address);
+ }
regcache = &sctx->regcache;
}
#endif
@@ -4747,11 +4728,9 @@ get_context_regcache (struct tracepoint_hit_ctx *ctx)
}
static void
-do_action_at_tracepoint (struct tracepoint_hit_ctx *ctx,
- CORE_ADDR stop_pc,
- struct tracepoint *tpoint,
- struct traceframe *tframe,
- struct tracepoint_action *taction)
+do_action_at_tracepoint (struct tracepoint_hit_ctx *ctx, CORE_ADDR stop_pc,
+ struct tracepoint *tpoint, struct traceframe *tframe,
+ struct tracepoint_action *taction)
{
enum eval_result_type err;
@@ -4759,54 +4738,54 @@ do_action_at_tracepoint (struct tracepoint_hit_ctx *ctx,
{
case 'M':
{
- struct collect_memory_action *maction;
- struct eval_agent_expr_context ax_ctx;
-
- maction = (struct collect_memory_action *) taction;
- ax_ctx.regcache = NULL;
- ax_ctx.tframe = tframe;
- ax_ctx.tpoint = tpoint;
-
- trace_debug ("Want to collect %s bytes at 0x%s (basereg %d)",
- pulongest (maction->len),
- paddress (maction->addr), maction->basereg);
- /* (should use basereg) */
- agent_mem_read (&ax_ctx, NULL, (CORE_ADDR) maction->addr,
- maction->len);
- break;
+ struct collect_memory_action *maction;
+ struct eval_agent_expr_context ax_ctx;
+
+ maction = (struct collect_memory_action *) taction;
+ ax_ctx.regcache = NULL;
+ ax_ctx.tframe = tframe;
+ ax_ctx.tpoint = tpoint;
+
+ trace_debug ("Want to collect %s bytes at 0x%s (basereg %d)",
+ pulongest (maction->len), paddress (maction->addr),
+ maction->basereg);
+ /* (should use basereg) */
+ agent_mem_read (&ax_ctx, NULL, (CORE_ADDR) maction->addr,
+ maction->len);
+ break;
}
case 'R':
{
- unsigned char *regspace;
- struct regcache tregcache;
- struct regcache *context_regcache;
- int regcache_size;
-
- trace_debug ("Want to collect registers");
-
- context_regcache = get_context_regcache (ctx);
- regcache_size = register_cache_size (context_regcache->tdesc);
-
- /* Collect all registers for now. */
- regspace = add_traceframe_block (tframe, tpoint, 1 + regcache_size);
- if (regspace == NULL)
- {
- trace_debug ("Trace buffer block allocation failed, skipping");
- break;
- }
- /* Identify a register block. */
- *regspace = 'R';
-
- /* Wrap the regblock in a register cache (in the stack, we
+ unsigned char *regspace;
+ struct regcache tregcache;
+ struct regcache *context_regcache;
+ int regcache_size;
+
+ trace_debug ("Want to collect registers");
+
+ context_regcache = get_context_regcache (ctx);
+ regcache_size = register_cache_size (context_regcache->tdesc);
+
+ /* Collect all registers for now. */
+ regspace = add_traceframe_block (tframe, tpoint, 1 + regcache_size);
+ if (regspace == NULL)
+ {
+ trace_debug ("Trace buffer block allocation failed, skipping");
+ break;
+ }
+ /* Identify a register block. */
+ *regspace = 'R';
+
+ /* Wrap the regblock in a register cache (in the stack, we
don't want to malloc here). */
- init_register_cache (&tregcache, context_regcache->tdesc,
- regspace + 1);
+ init_register_cache (&tregcache, context_regcache->tdesc,
+ regspace + 1);
- /* Copy the register data to the regblock. */
- regcache_cpy (&tregcache, context_regcache);
+ /* Copy the register data to the regblock. */
+ regcache_cpy (&tregcache, context_regcache);
#ifndef IN_PROCESS_AGENT
- /* On some platforms, trap-based tracepoints will have the PC
+ /* On some platforms, trap-based tracepoints will have the PC
pointing to the next instruction after the trap, but we
don't want the user or GDB trying to guess whether the
saved PC needs adjusting; so always record the adjusted
@@ -4816,44 +4795,43 @@ do_action_at_tracepoint (struct tracepoint_hit_ctx *ctx,
in-process lib (but not if GDBserver is collecting one
preemptively), since the PC had already been adjusted to
contain the tracepoint's address by the jump pad. */
- trace_debug ("Storing stop pc (0x%s) in regblock",
- paddress (stop_pc));
+ trace_debug ("Storing stop pc (0x%s) in regblock", paddress (stop_pc));
- /* This changes the regblock, not the thread's
+ /* This changes the regblock, not the thread's
regcache. */
- regcache_write_pc (&tregcache, stop_pc);
+ regcache_write_pc (&tregcache, stop_pc);
#endif
}
break;
case 'X':
{
- struct eval_expr_action *eaction;
- struct eval_agent_expr_context ax_ctx;
+ struct eval_expr_action *eaction;
+ struct eval_agent_expr_context ax_ctx;
- eaction = (struct eval_expr_action *) taction;
- ax_ctx.regcache = get_context_regcache (ctx);
- ax_ctx.tframe = tframe;
- ax_ctx.tpoint = tpoint;
+ eaction = (struct eval_expr_action *) taction;
+ ax_ctx.regcache = get_context_regcache (ctx);
+ ax_ctx.tframe = tframe;
+ ax_ctx.tpoint = tpoint;
- trace_debug ("Want to evaluate expression");
+ trace_debug ("Want to evaluate expression");
- err = gdb_eval_agent_expr (&ax_ctx, eaction->expr, NULL);
+ err = gdb_eval_agent_expr (&ax_ctx, eaction->expr, NULL);
- if (err != expr_eval_no_error)
- {
- record_tracepoint_error (tpoint, "action expression", err);
- return;
- }
+ if (err != expr_eval_no_error)
+ {
+ record_tracepoint_error (tpoint, "action expression", err);
+ return;
+ }
}
break;
case 'L':
{
#if defined IN_PROCESS_AGENT && defined HAVE_UST
- trace_debug ("Want to collect static trace data");
- collect_ust_data_at_tracepoint (ctx, tframe);
+ trace_debug ("Want to collect static trace data");
+ collect_ust_data_at_tracepoint (ctx, tframe);
#else
- trace_debug ("warning: collecting static trace data, "
- "but static tracepoints are not supported");
+ trace_debug ("warning: collecting static trace data, "
+ "but static tracepoints are not supported");
#endif
}
break;
@@ -4865,7 +4843,7 @@ do_action_at_tracepoint (struct tracepoint_hit_ctx *ctx,
static int
condition_true_at_tracepoint (struct tracepoint_hit_ctx *ctx,
- struct tracepoint *tpoint)
+ struct tracepoint *tpoint)
{
ULONGEST value = 0;
enum eval_result_type err;
@@ -4888,7 +4866,8 @@ condition_true_at_tracepoint (struct tracepoint_hit_ctx *ctx,
if (tpoint->compiled_cond)
{
struct fast_tracepoint_ctx *fctx = (struct fast_tracepoint_ctx *) ctx;
- err = ((condfn) (uintptr_t) (tpoint->compiled_cond)) (fctx->regs, &value);
+ err
+ = ((condfn) (uintptr_t) (tpoint->compiled_cond)) (fctx->regs, &value);
}
else
#endif
@@ -4908,9 +4887,8 @@ condition_true_at_tracepoint (struct tracepoint_hit_ctx *ctx,
return 0;
}
- trace_debug ("Tracepoint %d at 0x%s condition evals to %s",
- tpoint->number, paddress (tpoint->address),
- pulongest (value));
+ trace_debug ("Tracepoint %d at 0x%s condition evals to %s", tpoint->number,
+ paddress (tpoint->address), pulongest (value));
return (value ? 1 : 0);
}
@@ -4918,8 +4896,8 @@ condition_true_at_tracepoint (struct tracepoint_hit_ctx *ctx,
/* Do the recording of memory blocks for actions and bytecodes. */
int
-agent_mem_read (struct eval_agent_expr_context *ctx,
- unsigned char *to, CORE_ADDR from, ULONGEST len)
+agent_mem_read (struct eval_agent_expr_context *ctx, unsigned char *to,
+ CORE_ADDR from, ULONGEST len)
{
unsigned char *mspace;
ULONGEST remaining = len;
@@ -4941,7 +4919,7 @@ agent_mem_read (struct eval_agent_expr_context *ctx,
sp = 1 + sizeof (from) + sizeof (blocklen) + blocklen;
mspace = add_traceframe_block (ctx->tframe, ctx->tpoint, sp);
if (mspace == NULL)
- return 1;
+ return 1;
/* Identify block as a memory block. */
*mspace = 'M';
++mspace;
@@ -4960,8 +4938,8 @@ agent_mem_read (struct eval_agent_expr_context *ctx,
}
int
-agent_mem_read_string (struct eval_agent_expr_context *ctx,
- unsigned char *to, CORE_ADDR from, ULONGEST len)
+agent_mem_read_string (struct eval_agent_expr_context *ctx, unsigned char *to,
+ CORE_ADDR from, ULONGEST len)
{
unsigned char *buf, *mspace;
ULONGEST remaining = len;
@@ -4980,28 +4958,28 @@ agent_mem_read_string (struct eval_agent_expr_context *ctx,
harder to wrap correctly for the circular case, etc). */
buf = (unsigned char *) xmalloc (blocklen + 1);
for (i = 0; i < blocklen; ++i)
- {
- /* Read the string one byte at a time, in case the string is
+ {
+ /* Read the string one byte at a time, in case the string is
at the end of a valid memory area - we don't want a
correctly-terminated string to engender segvio
complaints. */
- read_inferior_memory (from + i, buf + i, 1);
-
- if (buf[i] == '\0')
- {
- blocklen = i + 1;
- /* Make sure outer loop stops now too. */
- remaining = blocklen;
- break;
- }
- }
+ read_inferior_memory (from + i, buf + i, 1);
+
+ if (buf[i] == '\0')
+ {
+ blocklen = i + 1;
+ /* Make sure outer loop stops now too. */
+ remaining = blocklen;
+ break;
+ }
+ }
sp = 1 + sizeof (from) + sizeof (blocklen) + blocklen;
mspace = add_traceframe_block (ctx->tframe, ctx->tpoint, sp);
if (mspace == NULL)
- {
- xfree (buf);
- return 1;
- }
+ {
+ xfree (buf);
+ return 1;
+ }
/* Identify block as a memory block. */
*mspace = 'M';
++mspace;
@@ -5028,7 +5006,7 @@ agent_tsv_read (struct eval_agent_expr_context *ctx, int n)
LONGEST val;
vspace = add_traceframe_block (ctx->tframe, ctx->tpoint,
- 1 + sizeof (n) + sizeof (LONGEST));
+ 1 + sizeof (n) + sizeof (LONGEST));
if (vspace == NULL)
return 1;
/* Identify block as a variable. */
@@ -5066,11 +5044,10 @@ match_blocktype (char blocktype, unsigned char *dataptr, void *data)
static unsigned char *
traceframe_walk_blocks (unsigned char *database, unsigned int datasize,
- int tfnum,
- int (*callback) (char blocktype,
- unsigned char *dataptr,
- void *data),
- void *data)
+ int tfnum,
+ int (*callback) (char blocktype,
+ unsigned char *dataptr, void *data),
+ void *data)
{
unsigned char *dataptr;
@@ -5082,52 +5059,51 @@ traceframe_walk_blocks (unsigned char *database, unsigned int datasize,
/* Iterate through a traceframe's blocks, looking for a block of the
requested type. */
- for (dataptr = database;
- dataptr < database + datasize;
+ for (dataptr = database; dataptr < database + datasize;
/* nothing */)
{
char blocktype;
unsigned short mlen;
if (dataptr == trace_buffer_wrap)
- {
- /* Adjust to reflect wrapping part of the frame around to
+ {
+ /* Adjust to reflect wrapping part of the frame around to
the beginning. */
- datasize = dataptr - database;
- dataptr = database = trace_buffer_lo;
- }
+ datasize = dataptr - database;
+ dataptr = database = trace_buffer_lo;
+ }
blocktype = *dataptr++;
if ((*callback) (blocktype, dataptr, data))
- return dataptr;
+ return dataptr;
switch (blocktype)
- {
- case 'R':
- /* Skip over the registers block. */
- dataptr += current_target_desc ()->registers_size;
- break;
- case 'M':
- /* Skip over the memory block. */
- dataptr += sizeof (CORE_ADDR);
- memcpy (&mlen, dataptr, sizeof (mlen));
- dataptr += (sizeof (mlen) + mlen);
- break;
- case 'V':
- /* Skip over the TSV block. */
- dataptr += (sizeof (int) + sizeof (LONGEST));
- break;
- case 'S':
- /* Skip over the static trace data block. */
- memcpy (&mlen, dataptr, sizeof (mlen));
- dataptr += (sizeof (mlen) + mlen);
- break;
- default:
- trace_debug ("traceframe %d has unknown block type 0x%x",
- tfnum, blocktype);
- return NULL;
- }
+ {
+ case 'R':
+ /* Skip over the registers block. */
+ dataptr += current_target_desc ()->registers_size;
+ break;
+ case 'M':
+ /* Skip over the memory block. */
+ dataptr += sizeof (CORE_ADDR);
+ memcpy (&mlen, dataptr, sizeof (mlen));
+ dataptr += (sizeof (mlen) + mlen);
+ break;
+ case 'V':
+ /* Skip over the TSV block. */
+ dataptr += (sizeof (int) + sizeof (LONGEST));
+ break;
+ case 'S':
+ /* Skip over the static trace data block. */
+ memcpy (&mlen, dataptr, sizeof (mlen));
+ dataptr += (sizeof (mlen) + mlen);
+ break;
+ default:
+ trace_debug ("traceframe %d has unknown block type 0x%x", tfnum,
+ blocktype);
+ return NULL;
+ }
}
return NULL;
@@ -5139,10 +5115,10 @@ traceframe_walk_blocks (unsigned char *database, unsigned int datasize,
static unsigned char *
traceframe_find_block_type (unsigned char *database, unsigned int datasize,
- int tfnum, char type_wanted)
+ int tfnum, char type_wanted)
{
- return traceframe_walk_blocks (database, datasize, tfnum,
- match_blocktype, &type_wanted);
+ return traceframe_walk_blocks (database, datasize, tfnum, match_blocktype,
+ &type_wanted);
}
static unsigned char *
@@ -5150,9 +5126,8 @@ traceframe_find_regblock (struct traceframe *tframe, int tfnum)
{
unsigned char *regblock;
- regblock = traceframe_find_block_type (tframe->data,
- tframe->data_size,
- tfnum, 'R');
+ regblock
+ = traceframe_find_block_type (tframe->data, tframe->data_size, tfnum, 'R');
if (regblock == NULL)
trace_debug ("traceframe %d has no register data", tfnum);
@@ -5188,7 +5163,7 @@ fetch_traceframe_registers (int tfnum, struct regcache *regcache, int regnum)
tracepoints. */
tpoint = find_next_tracepoint_by_number (NULL, tframe->tpnum);
if (tpoint != NULL)
- regcache_write_pc (regcache, tpoint->address);
+ regcache_write_pc (regcache, tpoint->address);
}
else
supply_regblock (regcache, dataptr);
@@ -5214,9 +5189,8 @@ traceframe_get_pc (struct traceframe *tframe)
/* Read a requested block of memory from a trace frame. */
int
-traceframe_read_mem (int tfnum, CORE_ADDR addr,
- unsigned char *buf, ULONGEST length,
- ULONGEST *nbytes)
+traceframe_read_mem (int tfnum, CORE_ADDR addr, unsigned char *buf,
+ ULONGEST length, ULONGEST *nbytes)
{
struct traceframe *tframe;
unsigned char *database, *dataptr;
@@ -5238,38 +5212,39 @@ traceframe_read_mem (int tfnum, CORE_ADDR addr,
database = dataptr = &tframe->data[0];
/* Iterate through a traceframe's blocks, looking for memory. */
- while ((dataptr = traceframe_find_block_type (dataptr,
- datasize
- - (dataptr - database),
- tfnum, 'M')) != NULL)
+ while (
+ (dataptr
+ = traceframe_find_block_type (dataptr, datasize - (dataptr - database),
+ tfnum, 'M'))
+ != NULL)
{
memcpy (&maddr, dataptr, sizeof (maddr));
dataptr += sizeof (maddr);
memcpy (&mlen, dataptr, sizeof (mlen));
dataptr += sizeof (mlen);
- trace_debug ("traceframe %d has %d bytes at %s",
- tfnum, mlen, paddress (maddr));
+ trace_debug ("traceframe %d has %d bytes at %s", tfnum, mlen,
+ paddress (maddr));
/* If the block includes the first part of the desired range,
return as much it has; GDB will re-request the remainder,
which might be in a different block of this trace frame. */
if (maddr <= addr && addr < (maddr + mlen))
- {
- ULONGEST amt = (maddr + mlen) - addr;
- if (amt > length)
- amt = length;
+ {
+ ULONGEST amt = (maddr + mlen) - addr;
+ if (amt > length)
+ amt = length;
- memcpy (buf, dataptr + (addr - maddr), amt);
- *nbytes = amt;
- return 0;
- }
+ memcpy (buf, dataptr + (addr - maddr), amt);
+ *nbytes = amt;
+ return 0;
+ }
/* Skip over this block. */
dataptr += mlen;
}
trace_debug ("traceframe %d has no memory data for the desired region",
- tfnum);
+ tfnum);
*nbytes = 0;
return 0;
@@ -5309,10 +5284,11 @@ traceframe_read_tsv (int tsvnum, LONGEST *val)
/* Iterate through a traceframe's blocks, looking for the last
matched tsv. */
- while ((dataptr = traceframe_find_block_type (dataptr,
- datasize
- - (dataptr - database),
- tfnum, 'V')) != NULL)
+ while (
+ (dataptr
+ = traceframe_find_block_type (dataptr, datasize - (dataptr - database),
+ tfnum, 'V'))
+ != NULL)
{
memcpy (&vnum, dataptr, sizeof (vnum));
dataptr += sizeof (vnum);
@@ -5321,18 +5297,17 @@ traceframe_read_tsv (int tsvnum, LONGEST *val)
/* Check that this is the variable we want. */
if (tsvnum == vnum)
- {
- memcpy (val, dataptr, sizeof (*val));
- found = 1;
- }
+ {
+ memcpy (val, dataptr, sizeof (*val));
+ found = 1;
+ }
/* Skip over this block. */
dataptr += sizeof (LONGEST);
}
if (!found)
- trace_debug ("traceframe %d has no data for variable %d",
- tfnum, tsvnum);
+ trace_debug ("traceframe %d has no data for variable %d", tfnum, tsvnum);
return !found;
}
@@ -5340,9 +5315,8 @@ traceframe_read_tsv (int tsvnum, LONGEST *val)
frame. */
int
-traceframe_read_sdata (int tfnum, ULONGEST offset,
- unsigned char *buf, ULONGEST length,
- ULONGEST *nbytes)
+traceframe_read_sdata (int tfnum, ULONGEST offset, unsigned char *buf,
+ ULONGEST length, ULONGEST *nbytes)
{
struct traceframe *tframe;
unsigned char *database, *dataptr;
@@ -5364,22 +5338,21 @@ traceframe_read_sdata (int tfnum, ULONGEST offset,
/* Iterate through a traceframe's blocks, looking for static
tracepoint data. */
- dataptr = traceframe_find_block_type (database, datasize,
- tfnum, 'S');
+ dataptr = traceframe_find_block_type (database, datasize, tfnum, 'S');
if (dataptr != NULL)
{
memcpy (&mlen, dataptr, sizeof (mlen));
dataptr += sizeof (mlen);
if (offset < mlen)
- {
- if (offset + length > mlen)
- length = mlen - offset;
+ {
+ if (offset + length > mlen)
+ length = mlen - offset;
- memcpy (buf, dataptr, length);
- *nbytes = length;
- }
+ memcpy (buf, dataptr, length);
+ *nbytes = length;
+ }
else
- *nbytes = 0;
+ *nbytes = 0;
return 0;
}
@@ -5402,35 +5375,35 @@ build_traceframe_info_xml (char blocktype, unsigned char *dataptr, void *data)
{
case 'M':
{
- unsigned short mlen;
- CORE_ADDR maddr;
-
- memcpy (&maddr, dataptr, sizeof (maddr));
- dataptr += sizeof (maddr);
- memcpy (&mlen, dataptr, sizeof (mlen));
- dataptr += sizeof (mlen);
- buffer_xml_printf (buffer,
- "<memory start=\"0x%s\" length=\"0x%s\"/>\n",
- paddress (maddr), phex_nz (mlen, sizeof (mlen)));
- break;
+ unsigned short mlen;
+ CORE_ADDR maddr;
+
+ memcpy (&maddr, dataptr, sizeof (maddr));
+ dataptr += sizeof (maddr);
+ memcpy (&mlen, dataptr, sizeof (mlen));
+ dataptr += sizeof (mlen);
+ buffer_xml_printf (buffer,
+ "<memory start=\"0x%s\" length=\"0x%s\"/>\n",
+ paddress (maddr), phex_nz (mlen, sizeof (mlen)));
+ break;
}
case 'V':
{
- int vnum;
+ int vnum;
- memcpy (&vnum, dataptr, sizeof (vnum));
- buffer_xml_printf (buffer, "<tvar id=\"%d\"/>\n", vnum);
- break;
+ memcpy (&vnum, dataptr, sizeof (vnum));
+ buffer_xml_printf (buffer, "<tvar id=\"%d\"/>\n", vnum);
+ break;
}
case 'R':
case 'S':
{
- break;
+ break;
}
default:
warning ("Unhandled trace block type (%d) '%c ' "
- "while building trace frame info.",
- blocktype, blocktype);
+ "while building trace frame info.",
+ blocktype, blocktype);
break;
}
@@ -5456,8 +5429,8 @@ traceframe_read_info (int tfnum, struct buffer *buffer)
}
buffer_grow_str (buffer, "<traceframe-info>\n");
- traceframe_walk_blocks (tframe->data, tframe->data_size,
- tfnum, build_traceframe_info_xml, buffer);
+ traceframe_walk_blocks (tframe->data, tframe->data_size, tfnum,
+ build_traceframe_info_xml, buffer);
buffer_grow_str0 (buffer, "</traceframe-info>\n");
return 0;
}
@@ -5472,7 +5445,7 @@ fast_tracepoint_from_jump_pad_address (CORE_ADDR pc)
for (tpoint = tracepoints; tpoint; tpoint = tpoint->next)
if (tpoint->type == fast_tracepoint)
if (tpoint->jump_pad <= pc && pc < tpoint->jump_pad_end)
- return tpoint;
+ return tpoint;
return NULL;
}
@@ -5486,9 +5459,9 @@ fast_tracepoint_from_trampoline_address (CORE_ADDR pc)
for (tpoint = tracepoints; tpoint; tpoint = tpoint->next)
{
- if (tpoint->type == fast_tracepoint
- && tpoint->trampoline <= pc && pc < tpoint->trampoline_end)
- return tpoint;
+ if (tpoint->type == fast_tracepoint && tpoint->trampoline <= pc
+ && pc < tpoint->trampoline_end)
+ return tpoint;
}
return NULL;
@@ -5506,7 +5479,7 @@ fast_tracepoint_from_ipa_tpoint_address (CORE_ADDR ipa_tpoint_obj)
for (tpoint = tracepoints; tpoint; tpoint = tpoint->next)
if (tpoint->type == fast_tracepoint)
if (tpoint->obj_addr_on_target == ipa_tpoint_obj)
- return tpoint;
+ return tpoint;
return NULL;
}
@@ -5550,9 +5523,8 @@ force_unlock_trace_buffer (void)
single-step it until this function returns 0. */
fast_tpoint_collect_result
-fast_tracepoint_collecting (CORE_ADDR thread_area,
- CORE_ADDR stop_pc,
- struct fast_tpoint_collect_status *status)
+fast_tracepoint_collecting (CORE_ADDR thread_area, CORE_ADDR stop_pc,
+ struct fast_tpoint_collect_status *status)
{
CORE_ADDR ipa_collecting;
CORE_ADDR ipa_gdb_jump_pad_buffer, ipa_gdb_jump_pad_buffer_end;
@@ -5584,29 +5556,29 @@ fast_tracepoint_collecting (CORE_ADDR thread_area,
in the jump pad. Single-step the thread until it leaves the
jump pad. */
- again:
+again:
tpoint = NULL;
needs_breakpoint = 0;
trace_debug ("fast_tracepoint_collecting");
if (read_inferior_data_pointer (ipa_sym_addrs.addr_gdb_jump_pad_buffer,
- &ipa_gdb_jump_pad_buffer))
+ &ipa_gdb_jump_pad_buffer))
{
internal_error ("error extracting `gdb_jump_pad_buffer'");
}
if (read_inferior_data_pointer (ipa_sym_addrs.addr_gdb_jump_pad_buffer_end,
- &ipa_gdb_jump_pad_buffer_end))
+ &ipa_gdb_jump_pad_buffer_end))
{
internal_error ("error extracting `gdb_jump_pad_buffer_end'");
}
if (read_inferior_data_pointer (ipa_sym_addrs.addr_gdb_trampoline_buffer,
- &ipa_gdb_trampoline_buffer))
+ &ipa_gdb_trampoline_buffer))
{
internal_error ("error extracting `gdb_trampoline_buffer'");
}
if (read_inferior_data_pointer (ipa_sym_addrs.addr_gdb_trampoline_buffer_end,
- &ipa_gdb_trampoline_buffer_end))
+ &ipa_gdb_trampoline_buffer_end))
{
internal_error ("error extracting `gdb_trampoline_buffer_end'");
}
@@ -5618,45 +5590,44 @@ fast_tracepoint_collecting (CORE_ADDR thread_area,
matching the jump pad address back to the tracepoint. */
tpoint = fast_tracepoint_from_jump_pad_address (stop_pc);
if (tpoint == NULL)
- {
- warning ("in jump pad, but no matching tpoint?");
- return fast_tpoint_collect_result::not_collecting;
- }
+ {
+ warning ("in jump pad, but no matching tpoint?");
+ return fast_tpoint_collect_result::not_collecting;
+ }
else
- {
- trace_debug ("in jump pad of tpoint (%d, %s); jump_pad(%s, %s); "
- "adj_insn(%s, %s)",
- tpoint->number, paddress (tpoint->address),
- paddress (tpoint->jump_pad),
- paddress (tpoint->jump_pad_end),
- paddress (tpoint->adjusted_insn_addr),
- paddress (tpoint->adjusted_insn_addr_end));
- }
+ {
+ trace_debug ("in jump pad of tpoint (%d, %s); jump_pad(%s, %s); "
+ "adj_insn(%s, %s)",
+ tpoint->number, paddress (tpoint->address),
+ paddress (tpoint->jump_pad),
+ paddress (tpoint->jump_pad_end),
+ paddress (tpoint->adjusted_insn_addr),
+ paddress (tpoint->adjusted_insn_addr_end));
+ }
/* Definitely in the jump pad. May or may not need
fast-exit-jump-pad breakpoint. */
- if (tpoint->jump_pad <= stop_pc
- && stop_pc < tpoint->adjusted_insn_addr)
- needs_breakpoint = 1;
+ if (tpoint->jump_pad <= stop_pc && stop_pc < tpoint->adjusted_insn_addr)
+ needs_breakpoint = 1;
}
else if (ipa_gdb_trampoline_buffer <= stop_pc
- && stop_pc < ipa_gdb_trampoline_buffer_end)
+ && stop_pc < ipa_gdb_trampoline_buffer_end)
{
/* We can tell which tracepoint(s) the thread is collecting by
matching the trampoline address back to the tracepoint. */
tpoint = fast_tracepoint_from_trampoline_address (stop_pc);
if (tpoint == NULL)
- {
- warning ("in trampoline, but no matching tpoint?");
- return fast_tpoint_collect_result::not_collecting;
- }
+ {
+ warning ("in trampoline, but no matching tpoint?");
+ return fast_tpoint_collect_result::not_collecting;
+ }
else
- {
- trace_debug ("in trampoline of tpoint (%d, %s); trampoline(%s, %s)",
- tpoint->number, paddress (tpoint->address),
- paddress (tpoint->trampoline),
- paddress (tpoint->trampoline_end));
- }
+ {
+ trace_debug ("in trampoline of tpoint (%d, %s); trampoline(%s, %s)",
+ tpoint->number, paddress (tpoint->address),
+ paddress (tpoint->trampoline),
+ paddress (tpoint->trampoline_end));
+ }
/* Have not reached jump pad yet, but treat the trampoline as a
part of the jump pad that is before the adjusted original
@@ -5672,42 +5643,43 @@ fast_tracepoint_collecting (CORE_ADDR thread_area,
lock to find out. */
if (read_inferior_data_pointer (ipa_sym_addrs.addr_collecting,
- &ipa_collecting))
- {
- trace_debug ("fast_tracepoint_collecting:"
- " failed reading 'collecting' in the inferior");
- return fast_tpoint_collect_result::not_collecting;
- }
+ &ipa_collecting))
+ {
+ trace_debug ("fast_tracepoint_collecting:"
+ " failed reading 'collecting' in the inferior");
+ return fast_tpoint_collect_result::not_collecting;
+ }
if (!ipa_collecting)
- {
- trace_debug ("fast_tracepoint_collecting: not collecting"
- " (and nobody is).");
- return fast_tpoint_collect_result::not_collecting;
- }
+ {
+ trace_debug ("fast_tracepoint_collecting: not collecting"
+ " (and nobody is).");
+ return fast_tpoint_collect_result::not_collecting;
+ }
/* Some thread is collecting. Check which. */
if (read_inferior_memory (ipa_collecting,
- (unsigned char *) &ipa_collecting_obj,
- sizeof (ipa_collecting_obj)) != 0)
- goto again;
+ (unsigned char *) &ipa_collecting_obj,
+ sizeof (ipa_collecting_obj))
+ != 0)
+ goto again;
if (ipa_collecting_obj.thread_area != thread_area)
- {
- trace_debug ("fast_tracepoint_collecting: not collecting "
- "(another thread is)");
- return fast_tpoint_collect_result::not_collecting;
- }
+ {
+ trace_debug ("fast_tracepoint_collecting: not collecting "
+ "(another thread is)");
+ return fast_tpoint_collect_result::not_collecting;
+ }
tpoint
- = fast_tracepoint_from_ipa_tpoint_address (ipa_collecting_obj.tpoint);
+ = fast_tracepoint_from_ipa_tpoint_address (ipa_collecting_obj.tpoint);
if (tpoint == NULL)
- {
- warning ("fast_tracepoint_collecting: collecting, "
- "but tpoint %s not found?",
- paddress ((CORE_ADDR) ipa_collecting_obj.tpoint));
- return fast_tpoint_collect_result::not_collecting;
- }
+ {
+ warning ("fast_tracepoint_collecting: collecting, "
+ "but tpoint %s not found?",
+ paddress ((CORE_ADDR) ipa_collecting_obj.tpoint));
+ return fast_tpoint_collect_result::not_collecting;
+ }
/* The thread is within `gdb_collect', skip over the rest of
fast tracepoint collection quickly using a breakpoint. */
@@ -5731,7 +5703,7 @@ fast_tracepoint_collecting (CORE_ADDR thread_area,
trace_debug ("\
fast_tracepoint_collecting, returning continue-until-break at %s",
- paddress (tpoint->adjusted_insn_addr));
+ paddress (tpoint->adjusted_insn_addr));
return fast_tpoint_collect_result::before_insn; /* continue */
}
@@ -5740,9 +5712,9 @@ fast_tracepoint_collecting, returning continue-until-break at %s",
/* Just single-step until exiting the jump pad. */
trace_debug ("fast_tracepoint_collecting, returning "
- "need-single-step (%s-%s)",
- paddress (tpoint->adjusted_insn_addr),
- paddress (tpoint->adjusted_insn_addr_end));
+ "need-single-step (%s-%s)",
+ paddress (tpoint->adjusted_insn_addr),
+ paddress (tpoint->adjusted_insn_addr_end));
return fast_tpoint_collect_result::at_insn; /* single-step */
}
@@ -5763,7 +5735,7 @@ EXTERN_C_POP
/* This is needed for -Wmissing-declarations. */
IP_AGENT_EXPORT_FUNC void gdb_collect (struct tracepoint *tpoint,
- unsigned char *regs);
+ unsigned char *regs);
/* This routine, called from the jump pad (in asm) is designed to be
called from the jump pads of fast tracepoints, thus it is on the
@@ -5797,44 +5769,43 @@ gdb_collect (struct tracepoint *tpoint, unsigned char *regs)
ctx.tpoint = ctx.tpoint->next)
{
if (!ctx.tpoint->enabled)
- continue;
+ continue;
/* Multiple tracepoints of different types, such as fast tracepoint and
static tracepoint, can be set at the same address. */
if (ctx.tpoint->type != tpoint->type)
- continue;
+ continue;
/* Test the condition if present, and collect if true. */
if (ctx.tpoint->cond == NULL
- || condition_true_at_tracepoint ((struct tracepoint_hit_ctx *) &ctx,
- ctx.tpoint))
- {
- collect_data_at_tracepoint ((struct tracepoint_hit_ctx *) &ctx,
- ctx.tpoint->address, ctx.tpoint);
+ || condition_true_at_tracepoint ((struct tracepoint_hit_ctx *) &ctx,
+ ctx.tpoint))
+ {
+ collect_data_at_tracepoint ((struct tracepoint_hit_ctx *) &ctx,
+ ctx.tpoint->address, ctx.tpoint);
- /* Note that this will cause original insns to be written back
+ /* Note that this will cause original insns to be written back
to where we jumped from, but that's OK because we're jumping
back to the next whole instruction. This will go badly if
instruction restoration is not atomic though. */
- if (stopping_tracepoint
- || trace_buffer_is_full
- || expr_eval_result != expr_eval_no_error)
- {
- stop_tracing ();
- break;
- }
- }
+ if (stopping_tracepoint || trace_buffer_is_full
+ || expr_eval_result != expr_eval_no_error)
+ {
+ stop_tracing ();
+ break;
+ }
+ }
else
- {
- /* If there was a condition and it evaluated to false, the only
+ {
+ /* If there was a condition and it evaluated to false, the only
way we would stop tracing is if there was an error during
condition expression evaluation. */
- if (expr_eval_result != expr_eval_no_error)
- {
- stop_tracing ();
- break;
- }
- }
+ if (expr_eval_result != expr_eval_no_error)
+ {
+ stop_tracing ();
+ break;
+ }
+ }
}
}
@@ -5852,9 +5823,11 @@ EXTERN_C_PUSH
IP_AGENT_EXPORT_VAR gdb_collect_ptr_type gdb_collect_ptr = gdb_collect;
IP_AGENT_EXPORT_VAR get_raw_reg_ptr_type get_raw_reg_ptr = get_raw_reg;
IP_AGENT_EXPORT_VAR get_trace_state_variable_value_ptr_type
- get_trace_state_variable_value_ptr = get_trace_state_variable_value;
+ get_trace_state_variable_value_ptr
+ = get_trace_state_variable_value;
IP_AGENT_EXPORT_VAR set_trace_state_variable_value_ptr_type
- set_trace_state_variable_value_ptr = set_trace_state_variable_value;
+ set_trace_state_variable_value_ptr
+ = set_trace_state_variable_value;
EXTERN_C_POP
#endif
@@ -5878,7 +5851,7 @@ get_get_tsv_func_addr (void)
{
CORE_ADDR res;
if (read_inferior_data_pointer (
- ipa_sym_addrs.addr_get_trace_state_variable_value_ptr, &res))
+ ipa_sym_addrs.addr_get_trace_state_variable_value_ptr, &res))
{
error ("error extracting get_trace_state_variable_value_ptr");
return 0;
@@ -5891,7 +5864,7 @@ get_set_tsv_func_addr (void)
{
CORE_ADDR res;
if (read_inferior_data_pointer (
- ipa_sym_addrs.addr_set_trace_state_variable_value_ptr, &res))
+ ipa_sym_addrs.addr_set_trace_state_variable_value_ptr, &res))
{
error ("error extracting set_trace_state_variable_value_ptr");
return 0;
@@ -5900,14 +5873,13 @@ get_set_tsv_func_addr (void)
}
static void
-compile_tracepoint_condition (struct tracepoint *tpoint,
- CORE_ADDR *jump_entry)
+compile_tracepoint_condition (struct tracepoint *tpoint, CORE_ADDR *jump_entry)
{
CORE_ADDR entry_point = *jump_entry;
enum eval_result_type err;
trace_debug ("Starting condition compilation for tracepoint %d\n",
- tpoint->number);
+ tpoint->number);
/* Initialize the global pointer to the code being built. */
current_insn_ptr = *jump_entry;
@@ -5924,7 +5896,7 @@ compile_tracepoint_condition (struct tracepoint *tpoint,
tpoint->compiled_cond = entry_point;
trace_debug ("Condition compilation for tracepoint %d complete\n",
- tpoint->number);
+ tpoint->number);
}
else
{
@@ -5933,8 +5905,8 @@ compile_tracepoint_condition (struct tracepoint *tpoint,
tpoint->compiled_cond = 0;
trace_debug ("Condition compilation for tracepoint %d failed, "
- "error code %d",
- tpoint->number, err);
+ "error code %d",
+ tpoint->number, err);
}
/* Update the code pointer passed in. Note that we do this even if
@@ -5965,10 +5937,10 @@ target_malloc (ULONGEST size)
{
/* We have the pointer *address*, need what it points to. */
if (read_inferior_data_pointer (ipa_sym_addrs.addr_gdb_tp_heap_buffer,
- &target_tp_heap))
- {
- internal_error ("couldn't get target heap head pointer");
- }
+ &target_tp_heap))
+ {
+ internal_error ("couldn't get target heap head pointer");
+ }
}
ptr = target_tp_heap;
@@ -5991,14 +5963,14 @@ download_agent_expr (struct agent_expr *expr)
expr_bytes = target_malloc (expr->length);
write_inferior_data_pointer (expr_addr + offsetof (struct agent_expr, bytes),
- expr_bytes);
+ expr_bytes);
target_write_memory (expr_bytes, expr->bytes, expr->length);
return expr_addr;
}
/* Align V up to N bits. */
-#define UALIGN(V, N) (((V) + ((N) - 1)) & ~((N) - 1))
+#define UALIGN(V, N) (((V) + ((N) -1)) & ~((N) -1))
/* Sync tracepoint with IPA, but leave maintenance of linked list to caller. */
@@ -6009,7 +5981,7 @@ download_tracepoint_1 (struct tracepoint *tpoint)
CORE_ADDR tpptr = 0;
gdb_assert (tpoint->type == fast_tracepoint
- || tpoint->type == static_tracepoint);
+ || tpoint->type == static_tracepoint);
if (tpoint->cond != NULL && target_emit_ops () != NULL)
{
@@ -6018,14 +5990,14 @@ download_tracepoint_1 (struct tracepoint *tpoint)
jentry = jump_entry = get_jump_space_head ();
if (tpoint->cond != NULL)
- {
- /* Pad to 8-byte alignment. (needed?) */
- /* Actually this should be left for the target to
+ {
+ /* Pad to 8-byte alignment. (needed?) */
+ /* Actually this should be left for the target to
decide. */
- jentry = UALIGN (jentry, 8);
+ jentry = UALIGN (jentry, 8);
- compile_tracepoint_condition (tpoint, &jentry);
- }
+ compile_tracepoint_condition (tpoint, &jentry);
+ }
/* Pad to 8-byte alignment. */
jentry = UALIGN (jentry, 8);
@@ -6046,12 +6018,11 @@ download_tracepoint_1 (struct tracepoint *tpoint)
target_tracepoint.hit_count = 0;
target_write_memory (tpptr, (unsigned char *) &target_tracepoint,
- sizeof (target_tracepoint));
+ sizeof (target_tracepoint));
if (tpoint->cond)
- write_inferior_data_pointer (tpptr
- + offsetof (struct tracepoint, cond),
- download_agent_expr (tpoint->cond));
+ write_inferior_data_pointer (tpptr + offsetof (struct tracepoint, cond),
+ download_agent_expr (tpoint->cond));
if (tpoint->numactions)
{
@@ -6060,22 +6031,22 @@ download_tracepoint_1 (struct tracepoint *tpoint)
/* The pointers array. */
actions_array
- = target_malloc (sizeof (*tpoint->actions) * tpoint->numactions);
- write_inferior_data_pointer (tpptr + offsetof (struct tracepoint,
- actions),
- actions_array);
+ = target_malloc (sizeof (*tpoint->actions) * tpoint->numactions);
+ write_inferior_data_pointer (tpptr
+ + offsetof (struct tracepoint, actions),
+ actions_array);
/* Now for each pointer, download the action. */
for (i = 0; i < tpoint->numactions; i++)
- {
- struct tracepoint_action *action = tpoint->actions[i];
- CORE_ADDR ipa_action = tracepoint_action_download (action);
+ {
+ struct tracepoint_action *action = tpoint->actions[i];
+ CORE_ADDR ipa_action = tracepoint_action_download (action);
- if (ipa_action != 0)
- write_inferior_data_pointer (actions_array
- + i * sizeof (*tpoint->actions),
- ipa_action);
- }
+ if (ipa_action != 0)
+ write_inferior_data_pointer (actions_array
+ + i * sizeof (*tpoint->actions),
+ ipa_action);
+ }
}
}
@@ -6140,17 +6111,17 @@ tracepoint_send_agent (struct tracepoint *tpoint)
/* The value of tracepoint's target address is stored in BUF. */
memcpy (&tpoint->obj_addr_on_target,
- &buf[IPA_PROTO_FAST_TRACE_ADDR_ON_TARGET], 8);
+ &buf[IPA_PROTO_FAST_TRACE_ADDR_ON_TARGET], 8);
if (tpoint->type == fast_tracepoint)
{
unsigned char *insn
- = (unsigned char *) &buf[IPA_PROTO_FAST_TRACE_FJUMP_INSN];
+ = (unsigned char *) &buf[IPA_PROTO_FAST_TRACE_FJUMP_INSN];
int fjump_size;
- trace_debug ("agent: read from cmd_buf 0x%x 0x%x\n",
- (unsigned int) tpoint->obj_addr_on_target,
- (unsigned int) gdb_jump_pad_head);
+ trace_debug ("agent: read from cmd_buf 0x%x 0x%x\n",
+ (unsigned int) tpoint->obj_addr_on_target,
+ (unsigned int) gdb_jump_pad_head);
memcpy (&gdb_jump_pad_head, &buf[IPA_PROTO_FAST_TRACE_JUMP_PAD], 8);
@@ -6158,7 +6129,7 @@ tracepoint_send_agent (struct tracepoint *tpoint)
memcpy (&fjump_size, &buf[IPA_PROTO_FAST_TRACE_FJUMP_SIZE], 4);
/* Wire it in. */
tpoint->handle
- = set_fast_tracepoint_jump (tpoint->address, insn, fjump_size);
+ = set_fast_tracepoint_jump (tpoint->address, insn, fjump_size);
}
return 0;
@@ -6169,8 +6140,7 @@ download_tracepoint (struct tracepoint *tpoint)
{
struct tracepoint *tp, *tp_prev;
- if (tpoint->type != fast_tracepoint
- && tpoint->type != static_tracepoint)
+ if (tpoint->type != fast_tracepoint && tpoint->type != static_tracepoint)
return;
download_tracepoint_1 (tpoint);
@@ -6181,7 +6151,7 @@ download_tracepoint (struct tracepoint *tpoint)
for (tp = tracepoints; tp != tpoint; tp = tp->next)
{
if (tp->type == fast_tracepoint || tp->type == static_tracepoint)
- tp_prev = tp;
+ tp_prev = tp;
}
if (tp_prev)
@@ -6190,27 +6160,26 @@ download_tracepoint (struct tracepoint *tpoint)
/* Insert TPOINT after TP_PREV in IPA. */
if (read_inferior_data_pointer (tp_prev->obj_addr_on_target
- + offsetof (struct tracepoint, next),
- &tp_prev_target_next_addr))
- {
- internal_error ("error reading `tp_prev->next'");
- }
+ + offsetof (struct tracepoint, next),
+ &tp_prev_target_next_addr))
+ {
+ internal_error ("error reading `tp_prev->next'");
+ }
/* tpoint->next = tp_prev->next */
write_inferior_data_pointer (tpoint->obj_addr_on_target
- + offsetof (struct tracepoint, next),
- tp_prev_target_next_addr);
+ + offsetof (struct tracepoint, next),
+ tp_prev_target_next_addr);
/* tp_prev->next = tpoint */
write_inferior_data_pointer (tp_prev->obj_addr_on_target
- + offsetof (struct tracepoint, next),
- tpoint->obj_addr_on_target);
+ + offsetof (struct tracepoint, next),
+ tpoint->obj_addr_on_target);
}
else
/* First object in list, set the head pointer in the
inferior. */
write_inferior_data_pointer (ipa_sym_addrs.addr_tracepoints,
- tpoint->obj_addr_on_target);
-
+ tpoint->obj_addr_on_target);
}
static void
@@ -6229,7 +6198,7 @@ download_trace_state_variables (void)
/* TSV's with a getter have been initialized equally in both the
inferior and GDBserver. Skip them. */
if (tsv->getter != NULL)
- continue;
+ continue;
target_tsv = *tsv;
@@ -6237,39 +6206,34 @@ download_trace_state_variables (void)
ptr = target_malloc (sizeof (*tsv));
if (tsv == trace_state_variables)
- {
- /* First object in list, set the head pointer in the
+ {
+ /* First object in list, set the head pointer in the
inferior. */
- write_inferior_data_pointer (ipa_sym_addrs.addr_trace_state_variables,
- ptr);
- }
+ write_inferior_data_pointer (
+ ipa_sym_addrs.addr_trace_state_variables, ptr);
+ }
else
- {
- write_inferior_data_pointer (prev_ptr
- + offsetof (struct trace_state_variable,
- next),
- ptr);
- }
+ {
+ write_inferior_data_pointer (
+ prev_ptr + offsetof (struct trace_state_variable, next), ptr);
+ }
/* Write the whole object. We'll fix up its pointers in a bit.
Assume no next, fixup when needed. */
target_tsv.next = NULL;
target_write_memory (ptr, (unsigned char *) &target_tsv,
- sizeof (target_tsv));
+ sizeof (target_tsv));
if (tsv->name != NULL)
- {
- size_t size = strlen (tsv->name) + 1;
- CORE_ADDR name_addr = target_malloc (size);
- target_write_memory (name_addr,
- (unsigned char *) tsv->name, size);
- write_inferior_data_pointer (ptr
- + offsetof (struct trace_state_variable,
- name),
- name_addr);
- }
+ {
+ size_t size = strlen (tsv->name) + 1;
+ CORE_ADDR name_addr = target_malloc (size);
+ target_write_memory (name_addr, (unsigned char *) tsv->name, size);
+ write_inferior_data_pointer (
+ ptr + offsetof (struct trace_state_variable, name), name_addr);
+ }
gdb_assert (tsv->getter == NULL);
}
@@ -6278,8 +6242,9 @@ download_trace_state_variables (void)
{
/* Fixup the next pointer in the last item in the list. */
write_inferior_data_pointer (prev_ptr
- + offsetof (struct trace_state_variable,
- next), 0);
+ + offsetof (struct trace_state_variable,
+ next),
+ 0);
}
}
@@ -6305,7 +6270,7 @@ upload_fast_traceframes (void)
CORE_ADDR ipa_trace_buffer_hi;
if (read_inferior_uinteger (ipa_sym_addrs.addr_traceframe_read_count,
- &ipa_traceframe_read_count_racy))
+ &ipa_traceframe_read_count_racy))
{
/* This will happen in most targets if the current thread is
running. */
@@ -6313,24 +6278,24 @@ upload_fast_traceframes (void)
}
if (read_inferior_uinteger (ipa_sym_addrs.addr_traceframe_write_count,
- &ipa_traceframe_write_count_racy))
+ &ipa_traceframe_write_count_racy))
return;
trace_debug ("ipa_traceframe_count (racy area): %d (w=%d, r=%d)",
- ipa_traceframe_write_count_racy
- - ipa_traceframe_read_count_racy,
- ipa_traceframe_write_count_racy,
- ipa_traceframe_read_count_racy);
+ ipa_traceframe_write_count_racy
+ - ipa_traceframe_read_count_racy,
+ ipa_traceframe_write_count_racy,
+ ipa_traceframe_read_count_racy);
if (ipa_traceframe_write_count_racy == ipa_traceframe_read_count_racy)
return;
about_to_request_buffer_space_bkpt
= set_breakpoint_at (ipa_sym_addrs.addr_about_to_request_buffer_space,
- NULL);
+ NULL);
if (read_inferior_uinteger (ipa_sym_addrs.addr_trace_buffer_ctrl_curr,
- &ipa_trace_buffer_ctrl_curr))
+ &ipa_trace_buffer_ctrl_curr))
return;
ipa_trace_buffer_ctrl_curr_old = ipa_trace_buffer_ctrl_curr;
@@ -6346,18 +6311,15 @@ upload_fast_traceframes (void)
counter = (prev + 0x100) & GDBSERVER_FLUSH_COUNT_MASK_CURR;
ipa_trace_buffer_ctrl_curr = (GDBSERVER_UPDATED_FLUSH_COUNT_BIT
- | (prev << 12)
- | counter
- | curr_tbctrl_idx);
+ | (prev << 12) | counter | curr_tbctrl_idx);
}
if (write_inferior_uinteger (ipa_sym_addrs.addr_trace_buffer_ctrl_curr,
- ipa_trace_buffer_ctrl_curr))
+ ipa_trace_buffer_ctrl_curr))
return;
- trace_debug ("Lib: Committed %08x -> %08x",
- ipa_trace_buffer_ctrl_curr_old,
- ipa_trace_buffer_ctrl_curr);
+ trace_debug ("Lib: Committed %08x -> %08x", ipa_trace_buffer_ctrl_curr_old,
+ ipa_trace_buffer_ctrl_curr);
/* Re-read these, now that we've installed the
`about_to_request_buffer_space' breakpoint/lock. A thread could
@@ -6369,21 +6331,21 @@ upload_fast_traceframes (void)
nesting), which would break the IP agent's "effective" detection
(see trace_alloc_trace_buffer). */
if (read_inferior_uinteger (ipa_sym_addrs.addr_traceframe_read_count,
- &ipa_traceframe_read_count))
+ &ipa_traceframe_read_count))
return;
if (read_inferior_uinteger (ipa_sym_addrs.addr_traceframe_write_count,
- &ipa_traceframe_write_count))
+ &ipa_traceframe_write_count))
return;
if (debug_threads)
{
trace_debug ("ipa_traceframe_count (blocked area): %d (w=%d, r=%d)",
- ipa_traceframe_write_count - ipa_traceframe_read_count,
- ipa_traceframe_write_count, ipa_traceframe_read_count);
+ ipa_traceframe_write_count - ipa_traceframe_read_count,
+ ipa_traceframe_write_count, ipa_traceframe_read_count);
if (ipa_traceframe_write_count != ipa_traceframe_write_count_racy
- || ipa_traceframe_read_count != ipa_traceframe_read_count_racy)
- trace_debug ("note that ipa_traceframe_count's parts changed");
+ || ipa_traceframe_read_count != ipa_traceframe_read_count_racy)
+ trace_debug ("note that ipa_traceframe_count's parts changed");
}
/* Get the address of the current TBC object (the IP agent has an
@@ -6394,41 +6356,41 @@ upload_fast_traceframes (void)
+= sizeof (struct ipa_trace_buffer_control) * curr_tbctrl_idx;
if (read_inferior_memory (ipa_trace_buffer_ctrl_addr,
- (unsigned char *) &ipa_trace_buffer_ctrl,
- sizeof (struct ipa_trace_buffer_control)))
+ (unsigned char *) &ipa_trace_buffer_ctrl,
+ sizeof (struct ipa_trace_buffer_control)))
return;
if (read_inferior_data_pointer (ipa_sym_addrs.addr_trace_buffer_lo,
- &ipa_trace_buffer_lo))
+ &ipa_trace_buffer_lo))
return;
if (read_inferior_data_pointer (ipa_sym_addrs.addr_trace_buffer_hi,
- &ipa_trace_buffer_hi))
+ &ipa_trace_buffer_hi))
return;
/* Offsets are easier to grok for debugging than raw addresses,
especially for the small trace buffer sizes that are useful for
testing. */
trace_debug ("Lib: Trace buffer [%d] start=%d free=%d "
- "endfree=%d wrap=%d hi=%d",
- curr_tbctrl_idx,
- (int) (ipa_trace_buffer_ctrl.start - ipa_trace_buffer_lo),
- (int) (ipa_trace_buffer_ctrl.free - ipa_trace_buffer_lo),
- (int) (ipa_trace_buffer_ctrl.end_free - ipa_trace_buffer_lo),
- (int) (ipa_trace_buffer_ctrl.wrap - ipa_trace_buffer_lo),
- (int) (ipa_trace_buffer_hi - ipa_trace_buffer_lo));
+ "endfree=%d wrap=%d hi=%d",
+ curr_tbctrl_idx,
+ (int) (ipa_trace_buffer_ctrl.start - ipa_trace_buffer_lo),
+ (int) (ipa_trace_buffer_ctrl.free - ipa_trace_buffer_lo),
+ (int) (ipa_trace_buffer_ctrl.end_free - ipa_trace_buffer_lo),
+ (int) (ipa_trace_buffer_ctrl.wrap - ipa_trace_buffer_lo),
+ (int) (ipa_trace_buffer_hi - ipa_trace_buffer_lo));
/* Note that the IPA's buffer is always circular. */
#define IPA_FIRST_TRACEFRAME() (ipa_trace_buffer_ctrl.start)
-#define IPA_NEXT_TRACEFRAME_1(TF, TFOBJ) \
+#define IPA_NEXT_TRACEFRAME_1(TF, TFOBJ) \
((TF) + sizeof (struct traceframe) + (TFOBJ)->data_size)
-#define IPA_NEXT_TRACEFRAME(TF, TFOBJ) \
- (IPA_NEXT_TRACEFRAME_1 (TF, TFOBJ) \
+#define IPA_NEXT_TRACEFRAME(TF, TFOBJ) \
+ (IPA_NEXT_TRACEFRAME_1 (TF, TFOBJ) \
- ((IPA_NEXT_TRACEFRAME_1 (TF, TFOBJ) >= ipa_trace_buffer_ctrl.wrap) \
- ? (ipa_trace_buffer_ctrl.wrap - ipa_trace_buffer_lo) \
- : 0))
+ ? (ipa_trace_buffer_ctrl.wrap - ipa_trace_buffer_lo) \
+ : 0))
tf = IPA_FIRST_TRACEFRAME ();
@@ -6440,16 +6402,16 @@ upload_fast_traceframes (void)
struct traceframe ipa_tframe;
if (read_inferior_memory (tf, (unsigned char *) &ipa_tframe,
- offsetof (struct traceframe, data)))
- error ("Uploading: couldn't read traceframe at %s\n", paddress (tf));
+ offsetof (struct traceframe, data)))
+ error ("Uploading: couldn't read traceframe at %s\n", paddress (tf));
if (ipa_tframe.tpnum == 0)
- {
- internal_error ("Uploading: No (more) fast traceframes, but"
- " ipa_traceframe_count == %u??\n",
- ipa_traceframe_write_count
- - ipa_traceframe_read_count);
- }
+ {
+ internal_error ("Uploading: No (more) fast traceframes, but"
+ " ipa_traceframe_count == %u??\n",
+ ipa_traceframe_write_count
+ - ipa_traceframe_read_count);
+ }
/* Note that this will be incorrect for multi-location
tracepoints... */
@@ -6457,80 +6419,77 @@ upload_fast_traceframes (void)
tframe = add_traceframe (tpoint);
if (tframe == NULL)
- {
- trace_buffer_is_full = 1;
- trace_debug ("Uploading: trace buffer is full");
- }
+ {
+ trace_buffer_is_full = 1;
+ trace_debug ("Uploading: trace buffer is full");
+ }
else
- {
- /* Copy the whole set of blocks in one go for now. FIXME:
+ {
+ /* Copy the whole set of blocks in one go for now. FIXME:
split this in smaller blocks. */
- block = add_traceframe_block (tframe, tpoint,
- ipa_tframe.data_size);
- if (block != NULL)
- {
- if (read_inferior_memory (tf
- + offsetof (struct traceframe, data),
- block, ipa_tframe.data_size))
- error ("Uploading: Couldn't read traceframe data at %s\n",
- paddress (tf + offsetof (struct traceframe, data)));
- }
-
- trace_debug ("Uploading: traceframe didn't fit");
- finish_traceframe (tframe);
- }
+ block = add_traceframe_block (tframe, tpoint, ipa_tframe.data_size);
+ if (block != NULL)
+ {
+ if (read_inferior_memory (tf
+ + offsetof (struct traceframe, data),
+ block, ipa_tframe.data_size))
+ error ("Uploading: Couldn't read traceframe data at %s\n",
+ paddress (tf + offsetof (struct traceframe, data)));
+ }
+
+ trace_debug ("Uploading: traceframe didn't fit");
+ finish_traceframe (tframe);
+ }
tf = IPA_NEXT_TRACEFRAME (tf, &ipa_tframe);
/* If we freed the traceframe that wrapped around, go back
to the non-wrap case. */
if (tf < ipa_trace_buffer_ctrl.start)
- {
- trace_debug ("Lib: Discarding past the wraparound");
- ipa_trace_buffer_ctrl.wrap = ipa_trace_buffer_hi;
- }
+ {
+ trace_debug ("Lib: Discarding past the wraparound");
+ ipa_trace_buffer_ctrl.wrap = ipa_trace_buffer_hi;
+ }
ipa_trace_buffer_ctrl.start = tf;
ipa_trace_buffer_ctrl.end_free = ipa_trace_buffer_ctrl.start;
++ipa_traceframe_read_count;
if (ipa_trace_buffer_ctrl.start == ipa_trace_buffer_ctrl.free
- && ipa_trace_buffer_ctrl.start == ipa_trace_buffer_ctrl.end_free)
- {
- trace_debug ("Lib: buffer is fully empty. "
- "Trace buffer [%d] start=%d free=%d endfree=%d",
- curr_tbctrl_idx,
- (int) (ipa_trace_buffer_ctrl.start
- - ipa_trace_buffer_lo),
- (int) (ipa_trace_buffer_ctrl.free
- - ipa_trace_buffer_lo),
- (int) (ipa_trace_buffer_ctrl.end_free
- - ipa_trace_buffer_lo));
-
- ipa_trace_buffer_ctrl.start = ipa_trace_buffer_lo;
- ipa_trace_buffer_ctrl.free = ipa_trace_buffer_lo;
- ipa_trace_buffer_ctrl.end_free = ipa_trace_buffer_hi;
- ipa_trace_buffer_ctrl.wrap = ipa_trace_buffer_hi;
- }
+ && ipa_trace_buffer_ctrl.start == ipa_trace_buffer_ctrl.end_free)
+ {
+ trace_debug (
+ "Lib: buffer is fully empty. "
+ "Trace buffer [%d] start=%d free=%d endfree=%d",
+ curr_tbctrl_idx,
+ (int) (ipa_trace_buffer_ctrl.start - ipa_trace_buffer_lo),
+ (int) (ipa_trace_buffer_ctrl.free - ipa_trace_buffer_lo),
+ (int) (ipa_trace_buffer_ctrl.end_free - ipa_trace_buffer_lo));
+
+ ipa_trace_buffer_ctrl.start = ipa_trace_buffer_lo;
+ ipa_trace_buffer_ctrl.free = ipa_trace_buffer_lo;
+ ipa_trace_buffer_ctrl.end_free = ipa_trace_buffer_hi;
+ ipa_trace_buffer_ctrl.wrap = ipa_trace_buffer_hi;
+ }
trace_debug ("Uploaded a traceframe\n"
- "Lib: Trace buffer [%d] start=%d free=%d "
- "endfree=%d wrap=%d hi=%d",
- curr_tbctrl_idx,
- (int) (ipa_trace_buffer_ctrl.start - ipa_trace_buffer_lo),
- (int) (ipa_trace_buffer_ctrl.free - ipa_trace_buffer_lo),
- (int) (ipa_trace_buffer_ctrl.end_free
- - ipa_trace_buffer_lo),
- (int) (ipa_trace_buffer_ctrl.wrap - ipa_trace_buffer_lo),
- (int) (ipa_trace_buffer_hi - ipa_trace_buffer_lo));
+ "Lib: Trace buffer [%d] start=%d free=%d "
+ "endfree=%d wrap=%d hi=%d",
+ curr_tbctrl_idx,
+ (int) (ipa_trace_buffer_ctrl.start - ipa_trace_buffer_lo),
+ (int) (ipa_trace_buffer_ctrl.free - ipa_trace_buffer_lo),
+ (int) (ipa_trace_buffer_ctrl.end_free
+ - ipa_trace_buffer_lo),
+ (int) (ipa_trace_buffer_ctrl.wrap - ipa_trace_buffer_lo),
+ (int) (ipa_trace_buffer_hi - ipa_trace_buffer_lo));
}
if (target_write_memory (ipa_trace_buffer_ctrl_addr,
- (unsigned char *) &ipa_trace_buffer_ctrl,
- sizeof (struct ipa_trace_buffer_control)))
+ (unsigned char *) &ipa_trace_buffer_ctrl,
+ sizeof (struct ipa_trace_buffer_control)))
return;
write_inferior_integer (ipa_sym_addrs.addr_traceframe_read_count,
- ipa_traceframe_read_count);
+ ipa_traceframe_read_count);
trace_debug ("Done uploading traceframes [%d]\n", curr_tbctrl_idx);
@@ -6563,8 +6522,8 @@ IP_AGENT_EXPORT_VAR char cmd_buf[IPA_CMD_BUF_SIZE];
#include <ust/ust.h>
#undef tracepoint
-extern int serialize_to_text (char *outbuf, int bufsize,
- const char *fmt, va_list ap);
+extern int serialize_to_text (char *outbuf, int bufsize, const char *fmt,
+ va_list ap);
#define GDB_PROBE_NAME "gdb"
@@ -6575,16 +6534,16 @@ extern int serialize_to_text (char *outbuf, int bufsize,
static struct
{
- int (*serialize_to_text) (char *outbuf, int bufsize,
- const char *fmt, va_list ap);
+ int (*serialize_to_text) (char *outbuf, int bufsize, const char *fmt,
+ va_list ap);
int (*ltt_probe_register) (struct ltt_available_probe *pdata);
int (*ltt_probe_unregister) (struct ltt_available_probe *pdata);
int (*ltt_marker_connect) (const char *channel, const char *mname,
- const char *pname);
+ const char *pname);
int (*ltt_marker_disconnect) (const char *channel, const char *mname,
- const char *pname);
+ const char *pname);
void (*marker_iter_start) (struct marker_iter *iter);
void (*marker_iter_next) (struct marker_iter *iter);
@@ -6597,14 +6556,15 @@ static struct
/* Cast through typeof to catch incompatible API changes. Since UST
only builds with gcc, we can freely use gcc extensions here
too. */
-#define GET_UST_SYM(SYM) \
- do \
- { \
- if (ust_ops.SYM == NULL) \
- ust_ops.SYM = (typeof (&SYM)) dlsym (RTLD_DEFAULT, #SYM); \
- if (ust_ops.SYM == NULL) \
- return 0; \
- } while (0)
+#define GET_UST_SYM(SYM) \
+ do \
+ { \
+ if (ust_ops.SYM == NULL) \
+ ust_ops.SYM = (typeof (&SYM)) dlsym (RTLD_DEFAULT, #SYM); \
+ if (ust_ops.SYM == NULL) \
+ return 0; \
+ } \
+ while (0)
#define USTF(SYM) ust_ops.SYM
@@ -6640,10 +6600,10 @@ ust_marker_to_static_tracepoint (const struct marker *mdata)
for (tpoint = tracepoints; tpoint; tpoint = tpoint->next)
{
if (tpoint->type != static_tracepoint)
- continue;
+ continue;
if (tpoint->address == (uintptr_t) mdata->location)
- return tpoint;
+ return tpoint;
}
return NULL;
@@ -6656,8 +6616,8 @@ ust_marker_to_static_tracepoint (const struct marker *mdata)
static void
gdb_probe (const struct marker *mdata, void *probe_private,
- struct registers *regs, void *call_private,
- const char *fmt, va_list *args)
+ struct registers *regs, void *call_private, const char *fmt,
+ va_list *args)
{
struct tracepoint *tpoint;
struct static_tracepoint_ctx ctx;
@@ -6690,9 +6650,9 @@ gdb_probe (const struct marker *mdata, void *probe_private,
if (tpoint == NULL)
{
trace_debug ("gdb_probe: marker not known: "
- "loc:0x%p, ch:\"%s\",n:\"%s\",f:\"%s\"",
- mdata->location, mdata->channel,
- mdata->name, mdata->format);
+ "loc:0x%p, ch:\"%s\",n:\"%s\",f:\"%s\"",
+ mdata->location, mdata->channel, mdata->name,
+ mdata->format);
return;
}
@@ -6705,22 +6665,20 @@ gdb_probe (const struct marker *mdata, void *probe_private,
ctx.tpoint = tpoint;
trace_debug ("gdb_probe: collecting marker: "
- "loc:0x%p, ch:\"%s\",n:\"%s\",f:\"%s\"",
- mdata->location, mdata->channel,
- mdata->name, mdata->format);
+ "loc:0x%p, ch:\"%s\",n:\"%s\",f:\"%s\"",
+ mdata->location, mdata->channel, mdata->name, mdata->format);
/* Test the condition if present, and collect if true. */
if (tpoint->cond == NULL
|| condition_true_at_tracepoint ((struct tracepoint_hit_ctx *) &ctx,
- tpoint))
+ tpoint))
{
collect_data_at_tracepoint ((struct tracepoint_hit_ctx *) &ctx,
- tpoint->address, tpoint);
+ tpoint->address, tpoint);
- if (stopping_tracepoint
- || trace_buffer_is_full
- || expr_eval_result != expr_eval_no_error)
- stop_tracing ();
+ if (stopping_tracepoint || trace_buffer_is_full
+ || expr_eval_result != expr_eval_no_error)
+ stop_tracing ();
}
else
{
@@ -6728,7 +6686,7 @@ gdb_probe (const struct marker *mdata, void *probe_private,
way we would stop tracing is if there was an error during
condition expression evaluation. */
if (expr_eval_result != expr_eval_no_error)
- stop_tracing ();
+ stop_tracing ();
}
}
@@ -6744,7 +6702,7 @@ gdb_probe (const struct marker *mdata, void *probe_private,
static void
collect_ust_data_at_tracepoint (struct tracepoint_hit_ctx *ctx,
- struct traceframe *tframe)
+ struct traceframe *tframe)
{
struct static_tracepoint_ctx *umd = (struct static_tracepoint_ctx *) ctx;
unsigned char *bufspace;
@@ -6755,19 +6713,19 @@ collect_ust_data_at_tracepoint (struct tracepoint_hit_ctx *ctx,
if (umd == NULL)
{
trace_debug ("Wanted to collect static trace data, "
- "but there's no static trace data");
+ "but there's no static trace data");
return;
}
va_copy (copy, *umd->args);
- size = USTF(serialize_to_text) (NULL, 0, umd->fmt, copy);
+ size = USTF (serialize_to_text) (NULL, 0, umd->fmt, copy);
va_end (copy);
trace_debug ("Want to collect ust data");
/* 'S' + size + string */
bufspace = add_traceframe_block (tframe, umd->tpoint,
- 1 + sizeof (blocklen) + size + 1);
+ 1 + sizeof (blocklen) + size + 1);
if (bufspace == NULL)
{
trace_debug ("Trace buffer block allocation failed, skipping");
@@ -6781,21 +6739,20 @@ collect_ust_data_at_tracepoint (struct tracepoint_hit_ctx *ctx,
memcpy (bufspace + 1, &blocklen, sizeof (blocklen));
va_copy (copy, *umd->args);
- USTF(serialize_to_text) ((char *) bufspace + 1 + sizeof (blocklen),
- size + 1, umd->fmt, copy);
+ USTF (serialize_to_text)
+ ((char *) bufspace + 1 + sizeof (blocklen), size + 1, umd->fmt, copy);
va_end (copy);
trace_debug ("Storing static tracepoint data in regblock: %s",
- bufspace + 1 + sizeof (blocklen));
+ bufspace + 1 + sizeof (blocklen));
}
/* The probe to register with lttng/ust. */
-static struct ltt_available_probe gdb_ust_probe =
- {
- GDB_PROBE_NAME,
- NULL,
- gdb_probe,
- };
+static struct ltt_available_probe gdb_ust_probe = {
+ GDB_PROBE_NAME,
+ NULL,
+ gdb_probe,
+};
#endif /* HAVE_UST */
#endif /* IN_PROCESS_AGENT */
@@ -6834,7 +6791,7 @@ run_inferior_command (char *cmd, int len)
#include <sys/un.h>
#ifndef UNIX_PATH_MAX
-#define UNIX_PATH_MAX sizeof(((struct sockaddr_un *) NULL)->sun_path)
+#define UNIX_PATH_MAX sizeof (((struct sockaddr_un *) NULL)->sun_path)
#endif
/* Where we put the socked used for synchronization. */
@@ -6863,7 +6820,8 @@ init_named_socket (const char *name)
if (strlen (name) >= ARRAY_SIZE (addr.sun_path))
{
- warning ("socket name too long for sockaddr_un::sun_path field: %s", name);
+ warning ("socket name too long for sockaddr_un::sun_path field: %s",
+ name);
return -1;
}
@@ -6875,11 +6833,11 @@ init_named_socket (const char *name)
/* File exists. */
result = unlink (name);
if (result == -1)
- {
- warning ("unlink failed: %s", safe_strerror (errno));
- close (fd);
- return -1;
- }
+ {
+ warning ("unlink failed: %s", safe_strerror (errno));
+ close (fd);
+ return -1;
+ }
warning ("socket %s already exists; overwriting", name);
}
@@ -6910,7 +6868,7 @@ gdb_agent_socket_init (void)
int result, fd;
result = snprintf (agent_socket_name, UNIX_PATH_MAX, "%s/gdb_ust%d",
- SOCK_DIR, getpid ());
+ SOCK_DIR, getpid ());
if (result >= UNIX_PATH_MAX)
{
trace_debug ("string overflow allocating socket name");
@@ -6920,8 +6878,9 @@ gdb_agent_socket_init (void)
fd = init_named_socket (agent_socket_name);
if (fd < 0)
warning ("Error initializing named socket (%s) for communication with the "
- "ust helper thread. Check that directory exists and that it "
- "is writable.", agent_socket_name);
+ "ust helper thread. Check that directory exists and that it "
+ "is writable.",
+ agent_socket_name);
return fd;
}
@@ -6938,8 +6897,8 @@ first_marker (void)
{
struct marker_iter iter;
- USTF(marker_iter_reset) (&iter);
- USTF(marker_iter_start) (&iter);
+ USTF (marker_iter_reset) (&iter);
+ USTF (marker_iter_start) (&iter);
return iter.marker;
}
@@ -6951,16 +6910,16 @@ next_marker (const struct marker *m)
{
struct marker_iter iter;
- USTF(marker_iter_reset) (&iter);
- USTF(marker_iter_start) (&iter);
+ USTF (marker_iter_reset) (&iter);
+ USTF (marker_iter_start) (&iter);
- for (; iter.marker != NULL; USTF(marker_iter_next) (&iter))
+ for (; iter.marker != NULL; USTF (marker_iter_next) (&iter))
{
if (iter.marker == m)
- {
- USTF(marker_iter_next) (&iter);
- return iter.marker;
- }
+ {
+ USTF (marker_iter_next) (&iter);
+ return iter.marker;
+ }
}
return NULL;
@@ -6988,8 +6947,7 @@ response_ust_marker (char *packet, const struct marker *st)
next_st = next_marker (st);
- tmp = xmalloc (strlen (st->channel) + 1 +
- strlen (st->name) + 1);
+ tmp = xmalloc (strlen (st->channel) + 1 + strlen (st->name) + 1);
sprintf (tmp, "%s/%s", st->channel, st->name);
strid = cstr_to_hexstr (tmp);
@@ -6997,10 +6955,8 @@ response_ust_marker (char *packet, const struct marker *st)
format = cstr_to_hexstr (st->format);
- sprintf (packet, "m%s:%s:%s",
- paddress ((uintptr_t) st->location),
- strid,
- format);
+ sprintf (packet, "m%s:%s:%s", paddress ((uintptr_t) st->location), strid,
+ format);
free (strid);
free (format);
@@ -7046,20 +7002,20 @@ unprobe_marker_at (char *packet)
p = unpack_varlen_hex (p, &address);
- USTF(marker_iter_reset) (&iter);
- USTF(marker_iter_start) (&iter);
- for (; iter.marker != NULL; USTF(marker_iter_next) (&iter))
- if ((uintptr_t ) iter.marker->location == address)
+ USTF (marker_iter_reset) (&iter);
+ USTF (marker_iter_start) (&iter);
+ for (; iter.marker != NULL; USTF (marker_iter_next) (&iter))
+ if ((uintptr_t) iter.marker->location == address)
{
- int result;
-
- result = USTF(ltt_marker_disconnect) (iter.marker->channel,
- iter.marker->name,
- GDB_PROBE_NAME);
- if (result < 0)
- warning ("could not disable marker %s/%s",
- iter.marker->channel, iter.marker->name);
- break;
+ int result;
+
+ result
+ = USTF (ltt_marker_disconnect) (iter.marker->channel,
+ iter.marker->name, GDB_PROBE_NAME);
+ if (result < 0)
+ warning ("could not disable marker %s/%s", iter.marker->channel,
+ iter.marker->name);
+ break;
}
}
@@ -7077,34 +7033,33 @@ probe_marker_at (char *packet)
p = unpack_varlen_hex (p, &address);
- USTF(marker_iter_reset) (&iter);
+ USTF (marker_iter_reset) (&iter);
- for (USTF(marker_iter_start) (&iter), m = iter.marker;
- m != NULL;
- USTF(marker_iter_next) (&iter), m = iter.marker)
- if ((uintptr_t ) m->location == address)
+ for (USTF (marker_iter_start) (&iter), m = iter.marker; m != NULL;
+ USTF (marker_iter_next) (&iter), m = iter.marker)
+ if ((uintptr_t) m->location == address)
{
- int result;
-
- trace_debug ("found marker for address. "
- "ltt_marker_connect (marker = %s/%s)",
- m->channel, m->name);
-
- result = USTF(ltt_marker_connect) (m->channel, m->name,
- GDB_PROBE_NAME);
- if (result && result != -EEXIST)
- trace_debug ("ltt_marker_connect (marker = %s/%s, errno = %d)",
- m->channel, m->name, -result);
-
- if (result < 0)
- {
- sprintf (packet, "E.could not connect marker: channel=%s, name=%s",
- m->channel, m->name);
- return -1;
- }
-
- strcpy (packet, "OK");
- return 0;
+ int result;
+
+ trace_debug ("found marker for address. "
+ "ltt_marker_connect (marker = %s/%s)",
+ m->channel, m->name);
+
+ result
+ = USTF (ltt_marker_connect) (m->channel, m->name, GDB_PROBE_NAME);
+ if (result && result != -EEXIST)
+ trace_debug ("ltt_marker_connect (marker = %s/%s, errno = %d)",
+ m->channel, m->name, -result);
+
+ if (result < 0)
+ {
+ sprintf (packet, "E.could not connect marker: channel=%s, name=%s",
+ m->channel, m->name);
+ return -1;
+ }
+
+ strcpy (packet, "OK");
+ return 0;
}
sprintf (packet, "E.no marker found at 0x%s", paddress (address));
@@ -7123,15 +7078,14 @@ cmd_qtstmat (char *packet)
p = unpack_varlen_hex (p, &address);
- USTF(marker_iter_reset) (&iter);
+ USTF (marker_iter_reset) (&iter);
- for (USTF(marker_iter_start) (&iter), m = iter.marker;
- m != NULL;
- USTF(marker_iter_next) (&iter), m = iter.marker)
- if ((uintptr_t ) m->location == address)
+ for (USTF (marker_iter_start) (&iter), m = iter.marker; m != NULL;
+ USTF (marker_iter_next) (&iter), m = iter.marker)
+ if ((uintptr_t) m->location == address)
{
- response_ust_marker (packet, m);
- return 0;
+ response_ust_marker (packet, m);
+ return 0;
}
strcpy (packet, "l");
@@ -7144,7 +7098,7 @@ gdb_ust_init (void)
if (!dlsym_ust ())
return;
- USTF(ltt_probe_register) (&gdb_ust_probe);
+ USTF (ltt_probe_register) (&gdb_ust_probe);
}
#endif /* HAVE_UST */
@@ -7171,100 +7125,101 @@ gdb_agent_helper_thread (void *arg)
listen_fd = gdb_agent_socket_init ();
if (helper_thread_id == 0)
- helper_thread_id = syscall (SYS_gettid);
+ helper_thread_id = syscall (SYS_gettid);
if (listen_fd == -1)
- {
- warning ("could not create sync socket");
- break;
- }
+ {
+ warning ("could not create sync socket");
+ break;
+ }
while (1)
- {
- socklen_t tmp;
- struct sockaddr_un sockaddr;
- int fd;
- char buf[1];
- int ret;
- int stop_loop = 0;
-
- tmp = sizeof (sockaddr);
-
- do
- {
- fd = accept (listen_fd, (struct sockaddr *) &sockaddr, &tmp);
- }
- /* It seems an ERESTARTSYS can escape out of accept. */
- while (fd == -512 || (fd == -1 && errno == EINTR));
-
- if (fd < 0)
- {
- warning ("Accept returned %d, error: %s",
- fd, safe_strerror (errno));
- break;
- }
-
- do
- {
- ret = read (fd, buf, 1);
- } while (ret == -1 && errno == EINTR);
-
- if (ret == -1)
- {
- warning ("reading socket (fd=%d) failed with %s",
- fd, safe_strerror (errno));
- close (fd);
- break;
- }
-
- if (cmd_buf[0])
- {
- if (startswith (cmd_buf, "close"))
- {
- stop_loop = 1;
- }
+ {
+ socklen_t tmp;
+ struct sockaddr_un sockaddr;
+ int fd;
+ char buf[1];
+ int ret;
+ int stop_loop = 0;
+
+ tmp = sizeof (sockaddr);
+
+ do
+ {
+ fd = accept (listen_fd, (struct sockaddr *) &sockaddr, &tmp);
+ }
+ /* It seems an ERESTARTSYS can escape out of accept. */
+ while (fd == -512 || (fd == -1 && errno == EINTR));
+
+ if (fd < 0)
+ {
+ warning ("Accept returned %d, error: %s", fd,
+ safe_strerror (errno));
+ break;
+ }
+
+ do
+ {
+ ret = read (fd, buf, 1);
+ }
+ while (ret == -1 && errno == EINTR);
+
+ if (ret == -1)
+ {
+ warning ("reading socket (fd=%d) failed with %s", fd,
+ safe_strerror (errno));
+ close (fd);
+ break;
+ }
+
+ if (cmd_buf[0])
+ {
+ if (startswith (cmd_buf, "close"))
+ {
+ stop_loop = 1;
+ }
#ifdef HAVE_UST
- else if (strcmp ("qTfSTM", cmd_buf) == 0)
- {
- cmd_qtfstm (cmd_buf);
- }
- else if (strcmp ("qTsSTM", cmd_buf) == 0)
- {
- cmd_qtsstm (cmd_buf);
- }
- else if (startswith (cmd_buf, "unprobe_marker_at:"))
- {
- unprobe_marker_at (cmd_buf);
- }
- else if (startswith (cmd_buf, "probe_marker_at:"))
- {
- probe_marker_at (cmd_buf);
- }
- else if (startswith (cmd_buf, "qTSTMat:"))
- {
- cmd_qtstmat (cmd_buf);
- }
+ else if (strcmp ("qTfSTM", cmd_buf) == 0)
+ {
+ cmd_qtfstm (cmd_buf);
+ }
+ else if (strcmp ("qTsSTM", cmd_buf) == 0)
+ {
+ cmd_qtsstm (cmd_buf);
+ }
+ else if (startswith (cmd_buf, "unprobe_marker_at:"))
+ {
+ unprobe_marker_at (cmd_buf);
+ }
+ else if (startswith (cmd_buf, "probe_marker_at:"))
+ {
+ probe_marker_at (cmd_buf);
+ }
+ else if (startswith (cmd_buf, "qTSTMat:"))
+ {
+ cmd_qtstmat (cmd_buf);
+ }
#endif /* HAVE_UST */
- }
+ }
- /* Fix compiler's warning: ignoring return value of 'write'. */
- ret = write (fd, buf, 1);
- close (fd);
+ /* Fix compiler's warning: ignoring return value of 'write'. */
+ ret = write (fd, buf, 1);
+ close (fd);
- if (stop_loop)
- {
- close (listen_fd);
- unlink (agent_socket_name);
+ if (stop_loop)
+ {
+ close (listen_fd);
+ unlink (agent_socket_name);
- /* Sleep endlessly to wait the whole inferior stops. This
+ /* Sleep endlessly to wait the whole inferior stops. This
thread can not exit because GDB or GDBserver may still need
'current_thread' (representing this thread) to access
inferior memory. Otherwise, this thread exits earlier than
other threads, and 'current_thread' is set to NULL. */
- while (1)
- sleep (10);
- }
- }
+ while (1)
+ sleep (10);
+ }
+ }
}
return NULL;
@@ -7293,10 +7248,7 @@ gdb_agent_init (void)
if (res)
perror_with_name ("pthread_sigmask (1)");
- res = pthread_create (&thread,
- NULL,
- gdb_agent_helper_thread,
- NULL);
+ res = pthread_create (&thread, NULL, gdb_agent_helper_thread, NULL);
res = pthread_sigmask (SIG_SETMASK, &orig_mask, NULL);
if (res)
@@ -7334,8 +7286,7 @@ set_trampoline_buffer_space (CORE_ADDR begin, CORE_ADDR end, char *errmsg)
strcpy (gdb_trampoline_buffer_error, "no buffer passed");
}
-static void __attribute__ ((constructor))
-initialize_tracepoint_ftlib (void)
+static void __attribute__ ((constructor)) initialize_tracepoint_ftlib (void)
{
initialize_tracepoint ();
@@ -7359,10 +7310,10 @@ getauxval (unsigned long type)
while (fread (data, sizeof (data), 1, f) > 0)
{
if (data[0] == type)
- {
- value = data[1];
- break;
- }
+ {
+ value = data[1];
+ break;
+ }
}
fclose (f);
diff --git a/gdbserver/tracepoint.h b/gdbserver/tracepoint.h
index a30f540..922803f 100644
--- a/gdbserver/tracepoint.h
+++ b/gdbserver/tracepoint.h
@@ -26,23 +26,23 @@
void initialize_tracepoint (void);
#if defined(__GNUC__)
-# define ATTR_USED __attribute__((used))
-# define ATTR_NOINLINE __attribute__((noinline))
+#define ATTR_USED __attribute__ ((used))
+#define ATTR_NOINLINE __attribute__ ((noinline))
#else
-# define ATTR_USED
-# define ATTR_NOINLINE
+#define ATTR_USED
+#define ATTR_NOINLINE
#endif
/* How to make symbol public/exported. */
#if defined _WIN32 || defined __CYGWIN__
-# define EXPORTED_SYMBOL __declspec (dllexport)
+#define EXPORTED_SYMBOL __declspec (dllexport)
#else
-# if __GNUC__ >= 4
-# define EXPORTED_SYMBOL __attribute__ ((visibility ("default")))
-# else
-# define EXPORTED_SYMBOL
-# endif
+#if __GNUC__ >= 4
+#define EXPORTED_SYMBOL __attribute__ ((visibility ("default")))
+#else
+#define EXPORTED_SYMBOL
+#endif
#endif
/* Use these to make sure the functions and variables the IPA needs to
@@ -58,13 +58,13 @@ void initialize_tracepoint (void);
EXTERN_C_PUSH/EXTERN_C_POP around their definition. */
#ifdef IN_PROCESS_AGENT
-# define IP_AGENT_EXPORT_FUNC EXTERN_C EXPORTED_SYMBOL ATTR_NOINLINE ATTR_USED
-# define IP_AGENT_EXPORT_VAR EXPORTED_SYMBOL ATTR_USED
-# define IP_AGENT_EXPORT_VAR_DECL EXTERN_C EXPORTED_SYMBOL
+#define IP_AGENT_EXPORT_FUNC EXTERN_C EXPORTED_SYMBOL ATTR_NOINLINE ATTR_USED
+#define IP_AGENT_EXPORT_VAR EXPORTED_SYMBOL ATTR_USED
+#define IP_AGENT_EXPORT_VAR_DECL EXTERN_C EXPORTED_SYMBOL
#else
-# define IP_AGENT_EXPORT_FUNC static
-# define IP_AGENT_EXPORT_VAR
-# define IP_AGENT_EXPORT_VAR_DECL extern
+#define IP_AGENT_EXPORT_FUNC static
+#define IP_AGENT_EXPORT_VAR
+#define IP_AGENT_EXPORT_VAR_DECL extern
#endif
IP_AGENT_EXPORT_VAR_DECL int tracing;
@@ -84,16 +84,13 @@ int tracepoint_was_hit (struct thread_info *tinfo, CORE_ADDR stop_pc);
void release_while_stepping_state_list (struct thread_info *tinfo);
int in_readonly_region (CORE_ADDR addr, ULONGEST length);
-int traceframe_read_mem (int tfnum, CORE_ADDR addr,
- unsigned char *buf, ULONGEST length,
- ULONGEST *nbytes);
-int fetch_traceframe_registers (int tfnum,
- struct regcache *regcache,
- int regnum);
+int traceframe_read_mem (int tfnum, CORE_ADDR addr, unsigned char *buf,
+ ULONGEST length, ULONGEST *nbytes);
+int fetch_traceframe_registers (int tfnum, struct regcache *regcache,
+ int regnum);
-int traceframe_read_sdata (int tfnum, ULONGEST offset,
- unsigned char *buf, ULONGEST length,
- ULONGEST *nbytes);
+int traceframe_read_sdata (int tfnum, ULONGEST offset, unsigned char *buf,
+ ULONGEST length, ULONGEST *nbytes);
int traceframe_read_info (int tfnum, struct buffer *buffer);
@@ -128,9 +125,9 @@ enum class fast_tpoint_collect_result
at_insn,
};
-fast_tpoint_collect_result fast_tracepoint_collecting
- (CORE_ADDR thread_area, CORE_ADDR stop_pc,
- struct fast_tpoint_collect_status *status);
+fast_tpoint_collect_result
+fast_tracepoint_collecting (CORE_ADDR thread_area, CORE_ADDR stop_pc,
+ struct fast_tpoint_collect_status *status);
void force_unlock_trace_buffer (void);
@@ -140,12 +137,12 @@ int handle_tracepoint_bkpts (struct thread_info *tinfo, CORE_ADDR stop_pc);
void initialize_low_tracepoint (void);
const struct target_desc *get_ipa_tdesc (int idx);
void supply_fast_tracepoint_registers (struct regcache *regcache,
- const unsigned char *regs);
+ const unsigned char *regs);
void supply_static_tracepoint_registers (struct regcache *regcache,
- const unsigned char *regs,
- CORE_ADDR pc);
+ const unsigned char *regs,
+ CORE_ADDR pc);
void set_trampoline_buffer_space (CORE_ADDR begin, CORE_ADDR end,
- char *errmsg);
+ char *errmsg);
void *alloc_jump_pad_buffer (size_t size);
#ifndef HAVE_GETAUXVAL
unsigned long getauxval (unsigned long type);
@@ -164,9 +161,8 @@ struct eval_agent_expr_context;
/* Do memory copies for bytecodes. */
/* Do the recording of memory blocks for actions and bytecodes. */
-int agent_mem_read (struct eval_agent_expr_context *ctx,
- unsigned char *to, CORE_ADDR from,
- ULONGEST len);
+int agent_mem_read (struct eval_agent_expr_context *ctx, unsigned char *to,
+ CORE_ADDR from, ULONGEST len);
LONGEST agent_get_trace_state_variable_value (int num);
void agent_set_trace_state_variable_value (int num, LONGEST val);
@@ -175,9 +171,7 @@ void agent_set_trace_state_variable_value (int num, LONGEST val);
int agent_tsv_read (struct eval_agent_expr_context *ctx, int n);
int agent_mem_read_string (struct eval_agent_expr_context *ctx,
- unsigned char *to,
- CORE_ADDR from,
- ULONGEST len);
+ unsigned char *to, CORE_ADDR from, ULONGEST len);
/* The prototype the get_raw_reg function in the IPA. Each arch's
bytecode compiler emits calls to this function. */
diff --git a/gdbserver/utils.cc b/gdbserver/utils.cc
index a6f5bd7..3f5a23b 100644
--- a/gdbserver/utils.cc
+++ b/gdbserver/utils.cc
@@ -19,11 +19,11 @@
#include "server.h"
#ifdef IN_PROCESS_AGENT
-# define PREFIX "ipa: "
-# define TOOLNAME "GDBserver in-process agent"
+#define PREFIX "ipa: "
+#define TOOLNAME "GDBserver in-process agent"
#else
-# define PREFIX "gdbserver: "
-# define TOOLNAME "GDBserver"
+#define PREFIX "gdbserver: "
+#define TOOLNAME "GDBserver"
#endif
/* Generally useful subroutines used throughout the program. */
@@ -46,8 +46,8 @@ void
malloc_failure (long size)
{
fprintf (stderr,
- PREFIX "ran out of memory while trying to allocate %lu bytes\n",
- (unsigned long) size);
+ PREFIX "ran out of memory while trying to allocate %lu bytes\n",
+ (unsigned long) size);
abort_or_exit ();
}
@@ -101,8 +101,9 @@ vwarning (const char *string, va_list args)
void
internal_verror (const char *file, int line, const char *fmt, va_list args)
{
- fprintf (stderr, "\
-%s:%d: A problem internal to " TOOLNAME " has been detected.\n", file, line);
+ fprintf (stderr, "\
+%s:%d: A problem internal to " TOOLNAME " has been detected.\n",
+ file, line);
vfprintf (stderr, fmt, args);
fprintf (stderr, "\n");
abort_or_exit ();
@@ -113,8 +114,9 @@ internal_verror (const char *file, int line, const char *fmt, va_list args)
void
internal_vwarning (const char *file, int line, const char *fmt, va_list args)
{
- fprintf (stderr, "\
-%s:%d: A problem internal to " TOOLNAME " has been detected.\n", file, line);
+ fprintf (stderr, "\
+%s:%d: A problem internal to " TOOLNAME " has been detected.\n",
+ file, line);
vfprintf (stderr, fmt, args);
fprintf (stderr, "\n");
}
diff --git a/gdbserver/win32-i386-low.cc b/gdbserver/win32-i386-low.cc
index f78e012..9438ca6 100644
--- a/gdbserver/win32-i386-low.cc
+++ b/gdbserver/win32-i386-low.cc
@@ -42,7 +42,8 @@ static struct x86_debug_reg_state debug_reg_state;
static void
update_debug_registers (thread_info *thread)
{
- windows_thread_info *th = (windows_thread_info *) thread_target_data (thread);
+ windows_thread_info *th
+ = (windows_thread_info *) thread_target_data (thread);
/* The actual update is done later just before resuming the lwp,
we just mark that the registers need updating. */
@@ -81,39 +82,39 @@ win32_get_current_dr (int dr)
win32_require_context (th);
#ifdef __x86_64__
-#define RET_DR(DR) \
- case DR: \
- return th->wow64_context.Dr ## DR
+#define RET_DR(DR) \
+ case DR: \
+ return th->wow64_context.Dr##DR
if (windows_process.wow64_process)
{
switch (dr)
- {
- RET_DR (0);
- RET_DR (1);
- RET_DR (2);
- RET_DR (3);
- RET_DR (6);
- RET_DR (7);
- }
+ {
+ RET_DR (0);
+ RET_DR (1);
+ RET_DR (2);
+ RET_DR (3);
+ RET_DR (6);
+ RET_DR (7);
+ }
}
else
#undef RET_DR
#endif
-#define RET_DR(DR) \
- case DR: \
- return th->context.Dr ## DR
+#define RET_DR(DR) \
+ case DR: \
+ return th->context.Dr##DR
{
switch (dr)
- {
- RET_DR (0);
- RET_DR (1);
- RET_DR (2);
- RET_DR (3);
- RET_DR (6);
- RET_DR (7);
- }
+ {
+ RET_DR (0);
+ RET_DR (1);
+ RET_DR (2);
+ RET_DR (3);
+ RET_DR (6);
+ RET_DR (7);
+ }
}
#undef RET_DR
@@ -145,15 +146,10 @@ x86_dr_low_get_status (void)
}
/* Low-level function vector. */
-struct x86_dr_low_type x86_dr_low =
- {
- x86_dr_low_set_control,
- x86_dr_low_set_addr,
- x86_dr_low_get_addr,
- x86_dr_low_get_status,
- x86_dr_low_get_control,
- sizeof (void *),
- };
+struct x86_dr_low_type x86_dr_low = {
+ x86_dr_low_set_control, x86_dr_low_set_addr, x86_dr_low_get_addr,
+ x86_dr_low_get_status, x86_dr_low_get_control, sizeof (void *),
+};
/* Breakpoint/watchpoint support. */
@@ -172,8 +168,8 @@ i386_supports_z_point_type (char z_type)
}
static int
-i386_insert_point (enum raw_bkpt_type type, CORE_ADDR addr,
- int size, struct raw_breakpoint *bp)
+i386_insert_point (enum raw_bkpt_type type, CORE_ADDR addr, int size,
+ struct raw_breakpoint *bp)
{
switch (type)
{
@@ -181,11 +177,11 @@ i386_insert_point (enum raw_bkpt_type type, CORE_ADDR addr,
case raw_bkpt_type_write_wp:
case raw_bkpt_type_access_wp:
{
- enum target_hw_bp_type hw_type
- = raw_bkpt_type_to_target_hw_bp_type (type);
+ enum target_hw_bp_type hw_type
+ = raw_bkpt_type_to_target_hw_bp_type (type);
- return x86_dr_insert_watchpoint (&debug_reg_state,
- hw_type, addr, size);
+ return x86_dr_insert_watchpoint (&debug_reg_state, hw_type, addr,
+ size);
}
default:
/* Unsupported. */
@@ -194,8 +190,8 @@ i386_insert_point (enum raw_bkpt_type type, CORE_ADDR addr,
}
static int
-i386_remove_point (enum raw_bkpt_type type, CORE_ADDR addr,
- int size, struct raw_breakpoint *bp)
+i386_remove_point (enum raw_bkpt_type type, CORE_ADDR addr, int size,
+ struct raw_breakpoint *bp)
{
switch (type)
{
@@ -203,11 +199,11 @@ i386_remove_point (enum raw_bkpt_type type, CORE_ADDR addr,
case raw_bkpt_type_write_wp:
case raw_bkpt_type_access_wp:
{
- enum target_hw_bp_type hw_type
- = raw_bkpt_type_to_target_hw_bp_type (type);
+ enum target_hw_bp_type hw_type
+ = raw_bkpt_type_to_target_hw_bp_type (type);
- return x86_dr_remove_watchpoint (&debug_reg_state,
- hw_type, addr, size);
+ return x86_dr_remove_watchpoint (&debug_reg_state, hw_type, addr,
+ size);
}
default:
/* Unsupported. */
@@ -243,19 +239,17 @@ i386_get_thread_context (windows_thread_info *th)
the system doesn't support extended registers. */
static DWORD extended_registers = CONTEXT_EXTENDED_REGISTERS;
- again:
+again:
#ifdef __x86_64__
if (windows_process.wow64_process)
- th->wow64_context.ContextFlags = (CONTEXT_FULL
- | CONTEXT_FLOATING_POINT
- | CONTEXT_DEBUG_REGISTERS
- | extended_registers);
+ th->wow64_context.ContextFlags
+ = (CONTEXT_FULL | CONTEXT_FLOATING_POINT | CONTEXT_DEBUG_REGISTERS
+ | extended_registers);
else
#endif
- th->context.ContextFlags = (CONTEXT_FULL
- | CONTEXT_FLOATING_POINT
- | CONTEXT_DEBUG_REGISTERS
- | extended_registers);
+ th->context.ContextFlags
+ = (CONTEXT_FULL | CONTEXT_FLOATING_POINT | CONTEXT_DEBUG_REGISTERS
+ | extended_registers);
BOOL ret;
#ifdef __x86_64__
@@ -269,10 +263,10 @@ i386_get_thread_context (windows_thread_info *th)
DWORD e = GetLastError ();
if (extended_registers && e == ERROR_INVALID_PARAMETER)
- {
- extended_registers = 0;
- goto again;
- }
+ {
+ extended_registers = 0;
+ goto again;
+ }
error ("GetThreadContext failure %ld\n", (long) e);
}
@@ -289,26 +283,26 @@ i386_prepare_to_resume (windows_thread_info *th)
#ifdef __x86_64__
if (windows_process.wow64_process)
- {
- th->wow64_context.Dr0 = dr->dr_mirror[0];
- th->wow64_context.Dr1 = dr->dr_mirror[1];
- th->wow64_context.Dr2 = dr->dr_mirror[2];
- th->wow64_context.Dr3 = dr->dr_mirror[3];
- /* th->wow64_context.Dr6 = dr->dr_status_mirror;
+ {
+ th->wow64_context.Dr0 = dr->dr_mirror[0];
+ th->wow64_context.Dr1 = dr->dr_mirror[1];
+ th->wow64_context.Dr2 = dr->dr_mirror[2];
+ th->wow64_context.Dr3 = dr->dr_mirror[3];
+ /* th->wow64_context.Dr6 = dr->dr_status_mirror;
FIXME: should we set dr6 also ?? */
- th->wow64_context.Dr7 = dr->dr_control_mirror;
- }
+ th->wow64_context.Dr7 = dr->dr_control_mirror;
+ }
else
#endif
- {
- th->context.Dr0 = dr->dr_mirror[0];
- th->context.Dr1 = dr->dr_mirror[1];
- th->context.Dr2 = dr->dr_mirror[2];
- th->context.Dr3 = dr->dr_mirror[3];
- /* th->context.Dr6 = dr->dr_status_mirror;
+ {
+ th->context.Dr0 = dr->dr_mirror[0];
+ th->context.Dr1 = dr->dr_mirror[1];
+ th->context.Dr2 = dr->dr_mirror[2];
+ th->context.Dr3 = dr->dr_mirror[3];
+ /* th->context.Dr6 = dr->dr_status_mirror;
FIXME: should we set dr6 also ?? */
- th->context.Dr7 = dr->dr_control_mirror;
- }
+ th->context.Dr7 = dr->dr_control_mirror;
+ }
th->debug_registers_changed = false;
}
@@ -341,120 +335,80 @@ i386_single_step (windows_thread_info *th)
#ifdef __x86_64__
#define context_offset(x) (offsetof (WOW64_CONTEXT, x))
#else
-#define context_offset(x) ((int)&(((CONTEXT *)NULL)->x))
+#define context_offset(x) ((int) &(((CONTEXT *) NULL)->x))
#endif
-static const int i386_mappings[] = {
- context_offset (Eax),
- context_offset (Ecx),
- context_offset (Edx),
- context_offset (Ebx),
- context_offset (Esp),
- context_offset (Ebp),
- context_offset (Esi),
- context_offset (Edi),
- context_offset (Eip),
- context_offset (EFlags),
- context_offset (SegCs),
- context_offset (SegSs),
- context_offset (SegDs),
- context_offset (SegEs),
- context_offset (SegFs),
- context_offset (SegGs),
- context_offset (FloatSave.RegisterArea[0 * 10]),
- context_offset (FloatSave.RegisterArea[1 * 10]),
- context_offset (FloatSave.RegisterArea[2 * 10]),
- context_offset (FloatSave.RegisterArea[3 * 10]),
- context_offset (FloatSave.RegisterArea[4 * 10]),
- context_offset (FloatSave.RegisterArea[5 * 10]),
- context_offset (FloatSave.RegisterArea[6 * 10]),
- context_offset (FloatSave.RegisterArea[7 * 10]),
- context_offset (FloatSave.ControlWord),
- context_offset (FloatSave.StatusWord),
- context_offset (FloatSave.TagWord),
- context_offset (FloatSave.ErrorSelector),
- context_offset (FloatSave.ErrorOffset),
- context_offset (FloatSave.DataSelector),
- context_offset (FloatSave.DataOffset),
- context_offset (FloatSave.ErrorSelector),
- /* XMM0-7 */
- context_offset (ExtendedRegisters[10 * 16]),
- context_offset (ExtendedRegisters[11 * 16]),
- context_offset (ExtendedRegisters[12 * 16]),
- context_offset (ExtendedRegisters[13 * 16]),
- context_offset (ExtendedRegisters[14 * 16]),
- context_offset (ExtendedRegisters[15 * 16]),
- context_offset (ExtendedRegisters[16 * 16]),
- context_offset (ExtendedRegisters[17 * 16]),
- /* MXCSR */
- context_offset (ExtendedRegisters[24])
-};
+static const int i386_mappings[]
+ = { context_offset (Eax), context_offset (Ecx), context_offset (Edx),
+ context_offset (Ebx), context_offset (Esp), context_offset (Ebp),
+ context_offset (Esi), context_offset (Edi), context_offset (Eip),
+ context_offset (EFlags), context_offset (SegCs), context_offset (SegSs),
+ context_offset (SegDs), context_offset (SegEs), context_offset (SegFs),
+ context_offset (SegGs), context_offset (FloatSave.RegisterArea[0 * 10]),
+ context_offset (FloatSave.RegisterArea[1 * 10]),
+ context_offset (FloatSave.RegisterArea[2 * 10]),
+ context_offset (FloatSave.RegisterArea[3 * 10]),
+ context_offset (FloatSave.RegisterArea[4 * 10]),
+ context_offset (FloatSave.RegisterArea[5 * 10]),
+ context_offset (FloatSave.RegisterArea[6 * 10]),
+ context_offset (FloatSave.RegisterArea[7 * 10]),
+ context_offset (FloatSave.ControlWord),
+ context_offset (FloatSave.StatusWord),
+ context_offset (FloatSave.TagWord),
+ context_offset (FloatSave.ErrorSelector),
+ context_offset (FloatSave.ErrorOffset),
+ context_offset (FloatSave.DataSelector),
+ context_offset (FloatSave.DataOffset),
+ context_offset (FloatSave.ErrorSelector),
+ /* XMM0-7 */
+ context_offset (ExtendedRegisters[10 * 16]),
+ context_offset (ExtendedRegisters[11 * 16]),
+ context_offset (ExtendedRegisters[12 * 16]),
+ context_offset (ExtendedRegisters[13 * 16]),
+ context_offset (ExtendedRegisters[14 * 16]),
+ context_offset (ExtendedRegisters[15 * 16]),
+ context_offset (ExtendedRegisters[16 * 16]),
+ context_offset (ExtendedRegisters[17 * 16]),
+ /* MXCSR */
+ context_offset (ExtendedRegisters[24]) };
#undef context_offset
#ifdef __x86_64__
#define context_offset(x) (offsetof (CONTEXT, x))
-static const int amd64_mappings[] =
-{
- context_offset (Rax),
- context_offset (Rbx),
- context_offset (Rcx),
- context_offset (Rdx),
- context_offset (Rsi),
- context_offset (Rdi),
- context_offset (Rbp),
- context_offset (Rsp),
- context_offset (R8),
- context_offset (R9),
- context_offset (R10),
- context_offset (R11),
- context_offset (R12),
- context_offset (R13),
- context_offset (R14),
- context_offset (R15),
- context_offset (Rip),
- context_offset (EFlags),
- context_offset (SegCs),
- context_offset (SegSs),
- context_offset (SegDs),
- context_offset (SegEs),
- context_offset (SegFs),
- context_offset (SegGs),
- context_offset (FloatSave.FloatRegisters[0]),
- context_offset (FloatSave.FloatRegisters[1]),
- context_offset (FloatSave.FloatRegisters[2]),
- context_offset (FloatSave.FloatRegisters[3]),
- context_offset (FloatSave.FloatRegisters[4]),
- context_offset (FloatSave.FloatRegisters[5]),
- context_offset (FloatSave.FloatRegisters[6]),
- context_offset (FloatSave.FloatRegisters[7]),
- context_offset (FloatSave.ControlWord),
- context_offset (FloatSave.StatusWord),
- context_offset (FloatSave.TagWord),
- context_offset (FloatSave.ErrorSelector),
- context_offset (FloatSave.ErrorOffset),
- context_offset (FloatSave.DataSelector),
- context_offset (FloatSave.DataOffset),
- context_offset (FloatSave.ErrorSelector)
- /* XMM0-7 */ ,
- context_offset (Xmm0),
- context_offset (Xmm1),
- context_offset (Xmm2),
- context_offset (Xmm3),
- context_offset (Xmm4),
- context_offset (Xmm5),
- context_offset (Xmm6),
- context_offset (Xmm7),
- context_offset (Xmm8),
- context_offset (Xmm9),
- context_offset (Xmm10),
- context_offset (Xmm11),
- context_offset (Xmm12),
- context_offset (Xmm13),
- context_offset (Xmm14),
- context_offset (Xmm15),
- /* MXCSR */
- context_offset (FloatSave.MxCsr)
-};
+static const int amd64_mappings[]
+ = { context_offset (Rax), context_offset (Rbx), context_offset (Rcx),
+ context_offset (Rdx), context_offset (Rsi), context_offset (Rdi),
+ context_offset (Rbp), context_offset (Rsp), context_offset (R8),
+ context_offset (R9), context_offset (R10), context_offset (R11),
+ context_offset (R12), context_offset (R13), context_offset (R14),
+ context_offset (R15), context_offset (Rip), context_offset (EFlags),
+ context_offset (SegCs), context_offset (SegSs), context_offset (SegDs),
+ context_offset (SegEs), context_offset (SegFs), context_offset (SegGs),
+ context_offset (FloatSave.FloatRegisters[0]),
+ context_offset (FloatSave.FloatRegisters[1]),
+ context_offset (FloatSave.FloatRegisters[2]),
+ context_offset (FloatSave.FloatRegisters[3]),
+ context_offset (FloatSave.FloatRegisters[4]),
+ context_offset (FloatSave.FloatRegisters[5]),
+ context_offset (FloatSave.FloatRegisters[6]),
+ context_offset (FloatSave.FloatRegisters[7]),
+ context_offset (FloatSave.ControlWord),
+ context_offset (FloatSave.StatusWord),
+ context_offset (FloatSave.TagWord),
+ context_offset (FloatSave.ErrorSelector),
+ context_offset (FloatSave.ErrorOffset),
+ context_offset (FloatSave.DataSelector),
+ context_offset (FloatSave.DataOffset),
+ context_offset (FloatSave.ErrorSelector)
+ /* XMM0-7 */,
+ context_offset (Xmm0), context_offset (Xmm1), context_offset (Xmm2),
+ context_offset (Xmm3), context_offset (Xmm4), context_offset (Xmm5),
+ context_offset (Xmm6), context_offset (Xmm7), context_offset (Xmm8),
+ context_offset (Xmm9), context_offset (Xmm10), context_offset (Xmm11),
+ context_offset (Xmm12), context_offset (Xmm13), context_offset (Xmm14),
+ context_offset (Xmm15),
+ /* MXCSR */
+ context_offset (FloatSave.MxCsr) };
#undef context_offset
#endif /* __x86_64__ */
@@ -462,7 +416,7 @@ static const int amd64_mappings[] =
/* Fetch register from gdbserver regcache data. */
static void
i386_fetch_inferior_register (struct regcache *regcache,
- windows_thread_info *th, int r)
+ windows_thread_info *th, int r)
{
const int *mappings;
#ifdef __x86_64__
@@ -498,7 +452,7 @@ i386_fetch_inferior_register (struct regcache *regcache,
/* Store a new register value into the thread context of TH. */
static void
i386_store_inferior_register (struct regcache *regcache,
- windows_thread_info *th, int r)
+ windows_thread_info *th, int r)
{
const int *mappings;
#ifdef __x86_64__
@@ -528,8 +482,8 @@ i386_arch_setup (void)
struct target_desc *tdesc;
#ifdef __x86_64__
- tdesc = amd64_create_target_description (X86_XSTATE_SSE_MASK, false,
- false, false);
+ tdesc = amd64_create_target_description (X86_XSTATE_SSE_MASK, false, false,
+ false);
init_target_desc (tdesc, amd64_expedite_regs);
win32_tdesc = tdesc;
#endif
@@ -602,24 +556,22 @@ i386_win32_set_pc (struct regcache *regcache, CORE_ADDR pc)
}
}
-struct win32_target_ops the_low_target = {
- i386_arch_setup,
- i386_win32_num_regs,
- i386_initial_stuff,
- i386_get_thread_context,
- i386_prepare_to_resume,
- i386_thread_added,
- i386_fetch_inferior_register,
- i386_store_inferior_register,
- i386_single_step,
- &i386_win32_breakpoint,
- i386_win32_breakpoint_len,
- 1,
- i386_win32_get_pc,
- i386_win32_set_pc,
- i386_supports_z_point_type,
- i386_insert_point,
- i386_remove_point,
- x86_stopped_by_watchpoint,
- x86_stopped_data_address
-};
+struct win32_target_ops the_low_target = { i386_arch_setup,
+ i386_win32_num_regs,
+ i386_initial_stuff,
+ i386_get_thread_context,
+ i386_prepare_to_resume,
+ i386_thread_added,
+ i386_fetch_inferior_register,
+ i386_store_inferior_register,
+ i386_single_step,
+ &i386_win32_breakpoint,
+ i386_win32_breakpoint_len,
+ 1,
+ i386_win32_get_pc,
+ i386_win32_set_pc,
+ i386_supports_z_point_type,
+ i386_insert_point,
+ i386_remove_point,
+ x86_stopped_by_watchpoint,
+ x86_stopped_data_address };
diff --git a/gdbserver/win32-low.cc b/gdbserver/win32-low.cc
index 7565077..1ae7bb2 100644
--- a/gdbserver/win32-low.cc
+++ b/gdbserver/win32-low.cc
@@ -45,17 +45,24 @@ gdbserver_windows_process windows_process;
#include <sys/cygwin.h>
#endif
-#define OUTMSG(X) do { printf X; fflush (stderr); } while (0)
-
-#define OUTMSG2(X) \
- do \
- { \
- if (debug_threads) \
- { \
- printf X; \
- fflush (stderr); \
- } \
- } while (0)
+#define OUTMSG(X) \
+ do \
+ { \
+ printf X; \
+ fflush (stderr); \
+ } \
+ while (0)
+
+#define OUTMSG2(X) \
+ do \
+ { \
+ if (debug_threads) \
+ { \
+ printf X; \
+ fflush (stderr); \
+ } \
+ } \
+ while (0)
#ifndef _T
#define _T(x) TEXT (x)
@@ -143,14 +150,15 @@ win32_require_context (windows_thread_info *th)
/* See nat/windows-nat.h. */
windows_thread_info *
-gdbserver_windows_process::thread_rec
- (ptid_t ptid, thread_disposition_type disposition)
+gdbserver_windows_process::thread_rec (ptid_t ptid,
+ thread_disposition_type disposition)
{
thread_info *thread = find_thread_ptid (ptid);
if (thread == NULL)
return NULL;
- windows_thread_info *th = (windows_thread_info *) thread_target_data (thread);
+ windows_thread_info *th
+ = (windows_thread_info *) thread_target_data (thread);
if (disposition != DONT_INVALIDATE_CONTEXT)
win32_require_context (th);
return th;
@@ -187,7 +195,8 @@ child_add_thread (DWORD pid, DWORD tid, HANDLE h, void *tlb)
static void
delete_thread_info (thread_info *thread)
{
- windows_thread_info *th = (windows_thread_info *) thread_target_data (thread);
+ windows_thread_info *th
+ = (windows_thread_info *) thread_target_data (thread);
remove_thread (thread);
delete th;
@@ -215,13 +224,13 @@ bool
win32_process_target::supports_z_point_type (char z_type)
{
return (z_type == Z_PACKET_SW_BP
- || (the_low_target.supports_z_point_type != NULL
- && the_low_target.supports_z_point_type (z_type)));
+ || (the_low_target.supports_z_point_type != NULL
+ && the_low_target.supports_z_point_type (z_type)));
}
int
win32_process_target::insert_point (enum raw_bkpt_type type, CORE_ADDR addr,
- int size, raw_breakpoint *bp)
+ int size, raw_breakpoint *bp)
{
if (type == raw_bkpt_type_sw)
return insert_memory_breakpoint (bp);
@@ -234,7 +243,7 @@ win32_process_target::insert_point (enum raw_bkpt_type type, CORE_ADDR addr,
int
win32_process_target::remove_point (enum raw_bkpt_type type, CORE_ADDR addr,
- int size, raw_breakpoint *bp)
+ int size, raw_breakpoint *bp)
{
if (type == raw_bkpt_type_sw)
return remove_memory_breakpoint (bp);
@@ -263,11 +272,10 @@ win32_process_target::stopped_data_address ()
return 0;
}
-
/* Transfer memory from/to the debugged process. */
static int
-child_xfer_memory (CORE_ADDR memaddr, char *our, int len,
- int write, process_stratum_target *target)
+child_xfer_memory (CORE_ADDR memaddr, char *our, int len, int write,
+ process_stratum_target *target)
{
BOOL success;
SIZE_T done = 0;
@@ -277,17 +285,17 @@ child_xfer_memory (CORE_ADDR memaddr, char *our, int len,
if (write)
{
success = WriteProcessMemory (windows_process.handle, (LPVOID) addr,
- (LPCVOID) our, len, &done);
+ (LPCVOID) our, len, &done);
if (!success)
- lasterror = GetLastError ();
+ lasterror = GetLastError ();
FlushInstructionCache (windows_process.handle, (LPCVOID) addr, len);
}
else
{
success = ReadProcessMemory (windows_process.handle, (LPCVOID) addr,
- (LPVOID) our, len, &done);
+ (LPVOID) our, len, &done);
if (!success)
- lasterror = GetLastError ();
+ lasterror = GetLastError ();
}
if (!success && lasterror == ERROR_PARTIAL_COPY && done > 0)
return done;
@@ -317,21 +325,21 @@ do_initial_child_stuff (HANDLE proch, DWORD pid, int attached)
windows_process.open_process_used = true;
memset (&windows_process.current_event, 0,
- sizeof (windows_process.current_event));
+ sizeof (windows_process.current_event));
#ifdef __x86_64__
BOOL wow64;
if (!IsWow64Process (proch, &wow64))
{
DWORD err = GetLastError ();
- error ("Check if WOW64 process failed (error %d): %s\n",
- (int) err, strwinerror (err));
+ error ("Check if WOW64 process failed (error %d): %s\n", (int) err,
+ strwinerror (err));
}
windows_process.wow64_process = wow64;
if (windows_process.wow64_process
&& (Wow64GetThreadContext == nullptr
- || Wow64SetThreadContext == nullptr))
+ || Wow64SetThreadContext == nullptr))
error ("WOW64 debugging is not supported on this system.\n");
windows_process.ignore_first_breakpoint
@@ -363,19 +371,19 @@ do_initial_child_stuff (HANDLE proch, DWORD pid, int attached)
/* Note win32_wait doesn't return thread events. */
if (status.kind () != TARGET_WAITKIND_LOADED)
- {
- windows_process.cached_status = status;
- break;
- }
+ {
+ windows_process.cached_status = status;
+ break;
+ }
{
- struct thread_resume resume;
+ struct thread_resume resume;
- resume.thread = minus_one_ptid;
- resume.kind = resume_continue;
- resume.sig = 0;
+ resume.thread = minus_one_ptid;
+ resume.kind = resume_continue;
+ resume.sig = 0;
- the_target->resume (&resume, 1);
+ the_target->resume (&resume, 1);
}
}
@@ -404,29 +412,30 @@ do_initial_child_stuff (HANDLE proch, DWORD pid, int attached)
static void
continue_one_thread (thread_info *thread, int thread_id)
{
- windows_thread_info *th = (windows_thread_info *) thread_target_data (thread);
+ windows_thread_info *th
+ = (windows_thread_info *) thread_target_data (thread);
if (thread_id == -1 || thread_id == th->tid)
{
win32_prepare_to_resume (th);
if (th->suspended)
- {
- DWORD *context_flags;
+ {
+ DWORD *context_flags;
#ifdef __x86_64__
- if (windows_process.wow64_process)
- context_flags = &th->wow64_context.ContextFlags;
- else
+ if (windows_process.wow64_process)
+ context_flags = &th->wow64_context.ContextFlags;
+ else
#endif
- context_flags = &th->context.ContextFlags;
- if (*context_flags)
- {
- win32_set_thread_context (th);
- *context_flags = 0;
- }
-
- th->resume ();
- }
+ context_flags = &th->context.ContextFlags;
+ if (*context_flags)
+ {
+ win32_set_thread_context (th);
+ *context_flags = 0;
+ }
+
+ th->resume ();
+ }
}
}
@@ -439,10 +448,8 @@ child_continue (DWORD continue_status, int thread_id)
/* The inferior will only continue after the ContinueDebugEvent
call. */
- for_each_thread ([&] (thread_info *thread)
- {
- continue_one_thread (thread, thread_id);
- });
+ for_each_thread (
+ [&] (thread_info *thread) { continue_one_thread (thread, thread_id); });
windows_process.faked_breakpoint = 0;
return continue_last_debug_event (continue_status, debug_threads);
@@ -454,8 +461,7 @@ child_fetch_inferior_registers (struct regcache *regcache, int r)
{
int regno;
windows_thread_info *th
- = windows_process.thread_rec (current_thread_ptid (),
- INVALIDATE_CONTEXT);
+ = windows_process.thread_rec (current_thread_ptid (), INVALIDATE_CONTEXT);
if (r == -1 || r > NUM_REGS)
child_fetch_inferior_registers (regcache, NUM_REGS);
else
@@ -470,8 +476,7 @@ child_store_inferior_registers (struct regcache *regcache, int r)
{
int regno;
windows_thread_info *th
- = windows_process.thread_rec (current_thread_ptid (),
- INVALIDATE_CONTEXT);
+ = windows_process.thread_rec (current_thread_ptid (), INVALIDATE_CONTEXT);
if (r == -1 || r == 0 || r > NUM_REGS)
child_store_inferior_registers (regcache, NUM_REGS);
else
@@ -480,8 +485,8 @@ child_store_inferior_registers (struct regcache *regcache, int r)
}
static BOOL
-create_process (const char *program, char *args,
- DWORD flags, PROCESS_INFORMATION *pi)
+create_process (const char *program, char *args, DWORD flags,
+ PROCESS_INFORMATION *pi)
{
const std::string &inferior_cwd = get_inferior_cwd ();
BOOL ret;
@@ -496,17 +501,18 @@ create_process (const char *program, char *args,
strcpy (program_and_args, program);
strcat (program_and_args, " ");
strcat (program_and_args, args);
- ret = create_process (program, /* image name */
- program_and_args, /* command line */
- flags, /* start flags */
- NULL, /* environment */
- /* current directory */
- (inferior_cwd.empty ()
- ? NULL
- : gdb_tilde_expand (inferior_cwd.c_str ()).c_str()),
- get_client_state ().disable_randomization,
- &si, /* start info */
- pi); /* proc info */
+ ret
+ = create_process (program, /* image name */
+ program_and_args, /* command line */
+ flags, /* start flags */
+ NULL, /* environment */
+ /* current directory */
+ (inferior_cwd.empty ()
+ ? NULL
+ : gdb_tilde_expand (inferior_cwd.c_str ()).c_str ()),
+ get_client_state ().disable_randomization,
+ &si, /* start info */
+ pi); /* proc info */
return ret;
}
@@ -518,7 +524,7 @@ create_process (const char *program, char *args,
process with the process list. */
int
win32_process_target::create_inferior (const char *program,
- const std::vector<char *> &program_args)
+ const std::vector<char *> &program_args)
{
client_state &cs = get_client_state ();
#ifndef USE_WIN32API
@@ -551,7 +557,7 @@ win32_process_target::create_inferior (const char *program,
strcpy (orig_path, path_ptr);
cygwin_conv_path_list (CCP_POSIX_TO_WIN_A, path_ptr, new_path, size);
setenv ("PATH", new_path, 1);
- }
+ }
cygwin_conv_path (CCP_POSIX_TO_WIN_A, program, real_path, PATH_MAX);
program = real_path;
#endif
@@ -579,8 +585,8 @@ win32_process_target::create_inferior (const char *program,
if (!ret)
{
- error ("Error creating process \"%s %s\", (error %d): %s\n",
- program, args, (int) err, strwinerror (err));
+ error ("Error creating process \"%s %s\", (error %d): %s\n", program,
+ args, (int) err, strwinerror (err));
}
else
{
@@ -614,28 +620,28 @@ win32_process_target::attach (unsigned long pid)
if (h != NULL)
{
if (DebugActiveProcess (pid))
- {
- DebugSetProcessKillOnExit (FALSE);
+ {
+ DebugSetProcessKillOnExit (FALSE);
- /* win32_wait needs to know we're attaching. */
- windows_process.attaching = 1;
- do_initial_child_stuff (h, pid, 1);
- return 0;
- }
+ /* win32_wait needs to know we're attaching. */
+ windows_process.attaching = 1;
+ do_initial_child_stuff (h, pid, 1);
+ return 0;
+ }
CloseHandle (h);
}
err = GetLastError ();
- error ("Attach to process failed (error %d): %s\n",
- (int) err, strwinerror (err));
+ error ("Attach to process failed (error %d): %s\n", (int) err,
+ strwinerror (err));
}
/* See nat/windows-nat.h. */
int
-gdbserver_windows_process::handle_output_debug_string
- (struct target_waitstatus *ourstatus)
+gdbserver_windows_process::handle_output_debug_string (
+ struct target_waitstatus *ourstatus)
{
#define READ_BUFFER_LEN 1024
CORE_ADDR addr;
@@ -656,22 +662,22 @@ gdbserver_windows_process::handle_output_debug_string
in Unicode. */
WCHAR buffer[(READ_BUFFER_LEN + 1) / sizeof (WCHAR)] = { 0 };
if (read_inferior_memory (addr, (unsigned char *) buffer, nbytes) != 0)
- return 0;
+ return 0;
wcstombs (s, buffer, (nbytes + 1) / sizeof (WCHAR));
}
else
{
if (read_inferior_memory (addr, (unsigned char *) s, nbytes) != 0)
- return 0;
+ return 0;
}
if (!startswith (s, "cYg"))
{
if (!server_waiting)
- {
- OUTMSG2(("%s", s));
- return 0;
- }
+ {
+ OUTMSG2 (("%s", s));
+ return 0;
+ }
monitor_output (s);
}
@@ -703,15 +709,15 @@ win32_process_target::kill (process_info *process)
for (;;)
{
if (!child_continue (DBG_CONTINUE, -1))
- break;
+ break;
if (!wait_for_debug_event (&windows_process.current_event, INFINITE))
- break;
+ break;
if (windows_process.current_event.dwDebugEventCode
- == EXIT_PROCESS_DEBUG_EVENT)
- break;
+ == EXIT_PROCESS_DEBUG_EVENT)
+ break;
else if (windows_process.current_event.dwDebugEventCode
- == OUTPUT_DEBUG_STRING_EVENT)
- windows_process.handle_output_debug_string (nullptr);
+ == OUTPUT_DEBUG_STRING_EVENT)
+ windows_process.handle_output_debug_string (nullptr);
}
win32_clear_inferiors ();
@@ -807,16 +813,16 @@ win32_process_target::resume (thread_resume *resume_info, size_t n)
if (sig != GDB_SIGNAL_0)
{
if (windows_process.current_event.dwDebugEventCode
- != EXCEPTION_DEBUG_EVENT)
- {
- OUTMSG (("Cannot continue with signal %s here.\n",
- gdb_signal_to_string (sig)));
- }
+ != EXCEPTION_DEBUG_EVENT)
+ {
+ OUTMSG (("Cannot continue with signal %s here.\n",
+ gdb_signal_to_string (sig)));
+ }
else if (sig == windows_process.last_sig)
- continue_status = DBG_EXCEPTION_NOT_HANDLED;
+ continue_status = DBG_EXCEPTION_NOT_HANDLED;
else
- OUTMSG (("Can only continue with received signal %s.\n",
- gdb_signal_to_string (windows_process.last_sig)));
+ OUTMSG (("Can only continue with received signal %s.\n",
+ gdb_signal_to_string (windows_process.last_sig)));
}
windows_process.last_sig = GDB_SIGNAL_0;
@@ -831,28 +837,28 @@ win32_process_target::resume (thread_resume *resume_info, size_t n)
DWORD *context_flags;
#ifdef __x86_64__
if (windows_process.wow64_process)
- context_flags = &th->wow64_context.ContextFlags;
+ context_flags = &th->wow64_context.ContextFlags;
else
#endif
- context_flags = &th->context.ContextFlags;
+ context_flags = &th->context.ContextFlags;
if (*context_flags)
- {
- /* Move register values from the inferior into the thread
+ {
+ /* Move register values from the inferior into the thread
context structure. */
- regcache_invalidate ();
-
- if (step)
- {
- if (the_low_target.single_step != NULL)
- (*the_low_target.single_step) (th);
- else
- error ("Single stepping is not supported "
- "in this configuration.\n");
- }
-
- win32_set_thread_context (th);
- *context_flags = 0;
- }
+ regcache_invalidate ();
+
+ if (step)
+ {
+ if (the_low_target.single_step != NULL)
+ (*the_low_target.single_step) (th);
+ else
+ error ("Single stepping is not supported "
+ "in this configuration.\n");
+ }
+
+ win32_set_thread_context (th);
+ *context_flags = 0;
+ }
}
/* Allow continuing with the same signal that interrupted us.
@@ -886,17 +892,17 @@ gdbserver_windows_process::handle_load_dll (const char *name, LPVOID base)
FindClose (h);
strcpy (buf, name);
{
- char cwd[MAX_PATH + 1];
- char *p;
- if (GetCurrentDirectoryA (MAX_PATH + 1, cwd))
- {
- p = strrchr (buf, '\\');
- if (p)
- p[1] = '\0';
- SetCurrentDirectoryA (buf);
- GetFullPathNameA (w32_fd.cFileName, MAX_PATH, buf, &p);
- SetCurrentDirectoryA (cwd);
- }
+ char cwd[MAX_PATH + 1];
+ char *p;
+ if (GetCurrentDirectoryA (MAX_PATH + 1, cwd))
+ {
+ p = strrchr (buf, '\\');
+ if (p)
+ p[1] = '\0';
+ SetCurrentDirectoryA (buf);
+ GetFullPathNameA (w32_fd.cFileName, MAX_PATH, buf, &p);
+ SetCurrentDirectoryA (cwd);
+ }
}
}
@@ -920,8 +926,8 @@ gdbserver_windows_process::handle_load_dll (const char *name, LPVOID base)
void
gdbserver_windows_process::handle_unload_dll ()
{
- CORE_ADDR load_addr =
- (CORE_ADDR) (uintptr_t) current_event.u.UnloadDll.lpBaseOfDll;
+ CORE_ADDR load_addr
+ = (CORE_ADDR) (uintptr_t) current_event.u.UnloadDll.lpBaseOfDll;
/* The symbols in a dll are offset by 0x1000, which is the
offset from 0 of the first byte in an image - because
@@ -933,7 +939,8 @@ gdbserver_windows_process::handle_unload_dll ()
static void
suspend_one_thread (thread_info *thread)
{
- windows_thread_info *th = (windows_thread_info *) thread_target_data (thread);
+ windows_thread_info *th
+ = (windows_thread_info *) thread_target_data (thread);
th->suspend ();
}
@@ -941,12 +948,12 @@ suspend_one_thread (thread_info *thread)
static void
fake_breakpoint_event (void)
{
- OUTMSG2(("fake_breakpoint_event\n"));
+ OUTMSG2 (("fake_breakpoint_event\n"));
windows_process.faked_breakpoint = 1;
memset (&windows_process.current_event, 0,
- sizeof (windows_process.current_event));
+ sizeof (windows_process.current_event));
windows_process.current_event.dwThreadId = windows_process.main_thread_id;
windows_process.current_event.dwDebugEventCode = EXCEPTION_DEBUG_EVENT;
windows_process.current_event.u.Exception.ExceptionRecord.ExceptionCode
@@ -958,8 +965,8 @@ fake_breakpoint_event (void)
/* See nat/windows-nat.h. */
bool
-gdbserver_windows_process::handle_access_violation
- (const EXCEPTION_RECORD *rec)
+gdbserver_windows_process::handle_access_violation (
+ const EXCEPTION_RECORD *rec)
{
return false;
}
@@ -976,14 +983,16 @@ maybe_adjust_pc ()
windows_thread_info *th
= windows_process.thread_rec (current_thread_ptid (),
- DONT_INVALIDATE_CONTEXT);
+ DONT_INVALIDATE_CONTEXT);
th->stopped_at_software_breakpoint = false;
if (windows_process.current_event.dwDebugEventCode == EXCEPTION_DEBUG_EVENT
- && ((windows_process.current_event.u.Exception.ExceptionRecord.ExceptionCode
- == EXCEPTION_BREAKPOINT)
- || (windows_process.current_event.u.Exception.ExceptionRecord.ExceptionCode
- == STATUS_WX86_BREAKPOINT))
+ && ((windows_process.current_event.u.Exception.ExceptionRecord
+ .ExceptionCode
+ == EXCEPTION_BREAKPOINT)
+ || (windows_process.current_event.u.Exception.ExceptionRecord
+ .ExceptionCode
+ == STATUS_WX86_BREAKPOINT))
&& windows_process.child_initialization_done)
{
th->stopped_at_software_breakpoint = true;
@@ -997,7 +1006,7 @@ maybe_adjust_pc ()
static int
get_child_debug_event (DWORD *continue_status,
- struct target_waitstatus *ourstatus)
+ struct target_waitstatus *ourstatus)
{
ptid_t ptid;
@@ -1023,11 +1032,11 @@ get_child_debug_event (DWORD *continue_status,
= windows_process.fetch_pending_stop (debug_threads);
if (stop.has_value ())
{
- *ourstatus = stop->status;
- windows_process.current_event = stop->event;
- ptid = debug_event_ptid (&windows_process.current_event);
- switch_to_thread (find_thread_ptid (ptid));
- return 1;
+ *ourstatus = stop->status;
+ windows_process.current_event = stop->event;
+ ptid = debug_event_ptid (&windows_process.current_event);
+ switch_to_thread (find_thread_ptid (ptid));
+ return 1;
}
/* Keep the wait time low enough for comfortable remote
@@ -1035,101 +1044,100 @@ get_child_debug_event (DWORD *continue_status,
bottleneck. */
if (!wait_for_debug_event (&windows_process.current_event, 250))
{
- DWORD e = GetLastError();
+ DWORD e = GetLastError ();
- if (e == ERROR_PIPE_NOT_CONNECTED)
- {
- /* This will happen if the loader fails to succesfully
+ if (e == ERROR_PIPE_NOT_CONNECTED)
+ {
+ /* This will happen if the loader fails to succesfully
load the application, e.g., if the main executable
tries to pull in a non-existing export from a
DLL. */
- ourstatus->set_exited (1);
- return 1;
- }
+ ourstatus->set_exited (1);
+ return 1;
+ }
- return 0;
+ return 0;
}
}
- gotevent:
+gotevent:
switch (current_event->dwDebugEventCode)
{
case CREATE_THREAD_DEBUG_EVENT:
OUTMSG2 (("gdbserver: kernel event CREATE_THREAD_DEBUG_EVENT "
- "for pid=%u tid=%x)\n",
- (unsigned) current_event->dwProcessId,
- (unsigned) current_event->dwThreadId));
+ "for pid=%u tid=%x)\n",
+ (unsigned) current_event->dwProcessId,
+ (unsigned) current_event->dwThreadId));
/* Record the existence of this thread. */
- child_add_thread (current_event->dwProcessId,
- current_event->dwThreadId,
- current_event->u.CreateThread.hThread,
- current_event->u.CreateThread.lpThreadLocalBase);
+ child_add_thread (current_event->dwProcessId, current_event->dwThreadId,
+ current_event->u.CreateThread.hThread,
+ current_event->u.CreateThread.lpThreadLocalBase);
break;
case EXIT_THREAD_DEBUG_EVENT:
OUTMSG2 (("gdbserver: kernel event EXIT_THREAD_DEBUG_EVENT "
- "for pid=%u tid=%x\n",
- (unsigned) current_event->dwProcessId,
- (unsigned) current_event->dwThreadId));
+ "for pid=%u tid=%x\n",
+ (unsigned) current_event->dwProcessId,
+ (unsigned) current_event->dwThreadId));
child_delete_thread (current_event->dwProcessId,
- current_event->dwThreadId);
+ current_event->dwThreadId);
switch_to_thread (get_first_thread ());
return 1;
case CREATE_PROCESS_DEBUG_EVENT:
OUTMSG2 (("gdbserver: kernel event CREATE_PROCESS_DEBUG_EVENT "
- "for pid=%u tid=%x\n",
- (unsigned) current_event->dwProcessId,
- (unsigned) current_event->dwThreadId));
+ "for pid=%u tid=%x\n",
+ (unsigned) current_event->dwProcessId,
+ (unsigned) current_event->dwThreadId));
CloseHandle (current_event->u.CreateProcessInfo.hFile);
if (windows_process.open_process_used)
- {
- CloseHandle (windows_process.handle);
- windows_process.open_process_used = false;
- }
+ {
+ CloseHandle (windows_process.handle);
+ windows_process.open_process_used = false;
+ }
windows_process.handle = current_event->u.CreateProcessInfo.hProcess;
windows_process.main_thread_id = current_event->dwThreadId;
/* Add the main thread. */
child_add_thread (current_event->dwProcessId,
- windows_process.main_thread_id,
- current_event->u.CreateProcessInfo.hThread,
- current_event->u.CreateProcessInfo.lpThreadLocalBase);
+ windows_process.main_thread_id,
+ current_event->u.CreateProcessInfo.hThread,
+ current_event->u.CreateProcessInfo.lpThreadLocalBase);
break;
case EXIT_PROCESS_DEBUG_EVENT:
OUTMSG2 (("gdbserver: kernel event EXIT_PROCESS_DEBUG_EVENT "
- "for pid=%u tid=%x\n",
- (unsigned) current_event->dwProcessId,
- (unsigned) current_event->dwThreadId));
+ "for pid=%u tid=%x\n",
+ (unsigned) current_event->dwProcessId,
+ (unsigned) current_event->dwThreadId));
{
- DWORD exit_status = current_event->u.ExitProcess.dwExitCode;
- /* If the exit status looks like a fatal exception, but we
+ DWORD exit_status = current_event->u.ExitProcess.dwExitCode;
+ /* If the exit status looks like a fatal exception, but we
don't recognize the exception's code, make the original
exit status value available, to avoid losing information. */
- int exit_signal
- = WIFSIGNALED (exit_status) ? WTERMSIG (exit_status) : -1;
- if (exit_signal == -1)
- ourstatus->set_exited (exit_status);
- else
- ourstatus->set_signalled (gdb_signal_from_host (exit_signal));
+ int exit_signal
+ = WIFSIGNALED (exit_status) ? WTERMSIG (exit_status) : -1;
+ if (exit_signal == -1)
+ ourstatus->set_exited (exit_status);
+ else
+ ourstatus->set_signalled (gdb_signal_from_host (exit_signal));
}
child_continue (DBG_CONTINUE, windows_process.desired_stop_thread_id);
break;
case LOAD_DLL_DEBUG_EVENT:
OUTMSG2 (("gdbserver: kernel event LOAD_DLL_DEBUG_EVENT "
- "for pid=%u tid=%x\n",
- (unsigned) current_event->dwProcessId,
- (unsigned) current_event->dwThreadId));
+ "for pid=%u tid=%x\n",
+ (unsigned) current_event->dwProcessId,
+ (unsigned) current_event->dwThreadId));
CloseHandle (current_event->u.LoadDll.hFile);
- if (! windows_process.child_initialization_done)
- break;
+ if (!windows_process.child_initialization_done)
+ break;
windows_process.dll_loaded_event ();
ourstatus->set_loaded ();
@@ -1137,40 +1145,40 @@ get_child_debug_event (DWORD *continue_status,
case UNLOAD_DLL_DEBUG_EVENT:
OUTMSG2 (("gdbserver: kernel event UNLOAD_DLL_DEBUG_EVENT "
- "for pid=%u tid=%x\n",
- (unsigned) current_event->dwProcessId,
- (unsigned) current_event->dwThreadId));
- if (! windows_process.child_initialization_done)
- break;
+ "for pid=%u tid=%x\n",
+ (unsigned) current_event->dwProcessId,
+ (unsigned) current_event->dwThreadId));
+ if (!windows_process.child_initialization_done)
+ break;
windows_process.handle_unload_dll ();
ourstatus->set_loaded ();
break;
case EXCEPTION_DEBUG_EVENT:
OUTMSG2 (("gdbserver: kernel event EXCEPTION_DEBUG_EVENT "
- "for pid=%u tid=%x\n",
- (unsigned) current_event->dwProcessId,
- (unsigned) current_event->dwThreadId));
+ "for pid=%u tid=%x\n",
+ (unsigned) current_event->dwProcessId,
+ (unsigned) current_event->dwThreadId));
if (windows_process.handle_exception (ourstatus, debug_threads)
- == HANDLE_EXCEPTION_UNHANDLED)
- *continue_status = DBG_EXCEPTION_NOT_HANDLED;
+ == HANDLE_EXCEPTION_UNHANDLED)
+ *continue_status = DBG_EXCEPTION_NOT_HANDLED;
break;
case OUTPUT_DEBUG_STRING_EVENT:
/* A message from the kernel (or Cygwin). */
OUTMSG2 (("gdbserver: kernel event OUTPUT_DEBUG_STRING_EVENT "
- "for pid=%u tid=%x\n",
- (unsigned) current_event->dwProcessId,
- (unsigned) current_event->dwThreadId));
+ "for pid=%u tid=%x\n",
+ (unsigned) current_event->dwProcessId,
+ (unsigned) current_event->dwThreadId));
windows_process.handle_output_debug_string (nullptr);
break;
default:
OUTMSG2 (("gdbserver: kernel event unknown "
- "for pid=%u tid=%x code=%x\n",
- (unsigned) current_event->dwProcessId,
- (unsigned) current_event->dwThreadId,
- (unsigned) current_event->dwDebugEventCode));
+ "for pid=%u tid=%x code=%x\n",
+ (unsigned) current_event->dwProcessId,
+ (unsigned) current_event->dwThreadId,
+ (unsigned) current_event->dwDebugEventCode));
break;
}
@@ -1182,11 +1190,11 @@ get_child_debug_event (DWORD *continue_status,
/* Pending stop. See the comment by the definition of
"pending_stops" for details on why this is needed. */
OUTMSG2 (("get_windows_debug_event - "
- "unexpected stop in 0x%lx (expecting 0x%x)\n",
- ptid.lwp (), windows_process.desired_stop_thread_id));
+ "unexpected stop in 0x%lx (expecting 0x%x)\n",
+ ptid.lwp (), windows_process.desired_stop_thread_id));
maybe_adjust_pc ();
- windows_process.pending_stops.push_back
- ({(DWORD) ptid.lwp (), *ourstatus, *current_event});
+ windows_process.pending_stops.push_back (
+ { (DWORD) ptid.lwp (), *ourstatus, *current_event });
ourstatus->set_spurious ();
}
else
@@ -1200,7 +1208,7 @@ get_child_debug_event (DWORD *continue_status,
Returns the signal which caused the process to stop. */
ptid_t
win32_process_target::wait (ptid_t ptid, target_waitstatus *ourstatus,
- target_wait_flags options)
+ target_wait_flags options)
{
if (windows_process.cached_status.kind () != TARGET_WAITKIND_IGNORE)
{
@@ -1217,34 +1225,33 @@ win32_process_target::wait (ptid_t ptid, target_waitstatus *ourstatus,
{
DWORD continue_status;
if (!get_child_debug_event (&continue_status, ourstatus))
- continue;
+ continue;
switch (ourstatus->kind ())
- {
- case TARGET_WAITKIND_EXITED:
- OUTMSG2 (("Child exited with retcode = %x\n",
- ourstatus->exit_status ()));
- win32_clear_inferiors ();
- return ptid_t (windows_process.current_event.dwProcessId);
- case TARGET_WAITKIND_STOPPED:
- case TARGET_WAITKIND_SIGNALLED:
- case TARGET_WAITKIND_LOADED:
- {
- OUTMSG2 (("Child Stopped with signal = %d \n",
- ourstatus->sig ()));
- maybe_adjust_pc ();
- return debug_event_ptid (&windows_process.current_event);
- }
- default:
- OUTMSG (("Ignoring unknown internal event, %d\n",
- ourstatus->kind ()));
- /* fall-through */
- case TARGET_WAITKIND_SPURIOUS:
- /* do nothing, just continue */
- child_continue (continue_status,
- windows_process.desired_stop_thread_id);
- break;
- }
+ {
+ case TARGET_WAITKIND_EXITED:
+ OUTMSG2 (
+ ("Child exited with retcode = %x\n", ourstatus->exit_status ()));
+ win32_clear_inferiors ();
+ return ptid_t (windows_process.current_event.dwProcessId);
+ case TARGET_WAITKIND_STOPPED:
+ case TARGET_WAITKIND_SIGNALLED:
+ case TARGET_WAITKIND_LOADED:
+ {
+ OUTMSG2 (("Child Stopped with signal = %d \n", ourstatus->sig ()));
+ maybe_adjust_pc ();
+ return debug_event_ptid (&windows_process.current_event);
+ }
+ default:
+ OUTMSG (
+ ("Ignoring unknown internal event, %d\n", ourstatus->kind ()));
+ /* fall-through */
+ case TARGET_WAITKIND_SPURIOUS:
+ /* do nothing, just continue */
+ child_continue (continue_status,
+ windows_process.desired_stop_thread_id);
+ break;
+ }
}
}
@@ -1269,7 +1276,7 @@ win32_process_target::store_registers (regcache *regcache, int regno)
Read LEN bytes at MEMADDR into a buffer at MYADDR. */
int
win32_process_target::read_memory (CORE_ADDR memaddr, unsigned char *myaddr,
- int len)
+ int len)
{
return child_xfer_memory (memaddr, (char *) myaddr, len, 0, 0) != len;
}
@@ -1280,7 +1287,7 @@ win32_process_target::read_memory (CORE_ADDR memaddr, unsigned char *myaddr,
Returns 0 on success and errno on failure. */
int
win32_process_target::write_memory (CORE_ADDR memaddr,
- const unsigned char *myaddr, int len)
+ const unsigned char *myaddr, int len)
{
return child_xfer_memory (memaddr, (char *) myaddr, len, 1, 0) != len;
}
@@ -1319,10 +1326,9 @@ win32_process_target::supports_qxfer_siginfo ()
/* Write Windows signal info. */
int
-win32_process_target::qxfer_siginfo (const char *annex,
- unsigned char *readbuf,
- unsigned const char *writebuf,
- CORE_ADDR offset, int len)
+win32_process_target::qxfer_siginfo (const char *annex, unsigned char *readbuf,
+ unsigned const char *writebuf,
+ CORE_ADDR offset, int len)
{
if (windows_process.siginfo_er.ExceptionCode == 0)
return -1;
@@ -1343,14 +1349,14 @@ win32_process_target::qxfer_siginfo (const char *annex,
er32.ExceptionCode = windows_process.siginfo_er.ExceptionCode;
er32.ExceptionFlags = windows_process.siginfo_er.ExceptionFlags;
er32.ExceptionRecord
- = (uintptr_t) windows_process.siginfo_er.ExceptionRecord;
+ = (uintptr_t) windows_process.siginfo_er.ExceptionRecord;
er32.ExceptionAddress
- = (uintptr_t) windows_process.siginfo_er.ExceptionAddress;
+ = (uintptr_t) windows_process.siginfo_er.ExceptionAddress;
er32.NumberParameters = windows_process.siginfo_er.NumberParameters;
int i;
for (i = 0; i < EXCEPTION_MAXIMUM_PARAMETERS; i++)
- er32.ExceptionInformation[i]
- = windows_process.siginfo_er.ExceptionInformation[i];
+ er32.ExceptionInformation[i]
+ = windows_process.siginfo_er.ExceptionInformation[i];
}
#endif
@@ -1399,7 +1405,7 @@ win32_process_target::stopped_by_sw_breakpoint ()
{
windows_thread_info *th
= windows_process.thread_rec (current_thread_ptid (),
- DONT_INVALIDATE_CONTEXT);
+ DONT_INVALIDATE_CONTEXT);
return th == nullptr ? false : th->stopped_at_software_breakpoint;
}
@@ -1426,7 +1432,7 @@ win32_process_target::thread_name (ptid_t thread)
{
windows_thread_info *th
= windows_process.thread_rec (current_thread_ptid (),
- DONT_INVALIDATE_CONTEXT);
+ DONT_INVALIDATE_CONTEXT);
return th->thread_name ();
}
diff --git a/gdbserver/win32-low.h b/gdbserver/win32-low.h
index 6a0b8cf..9da6deb 100644
--- a/gdbserver/win32-low.h
+++ b/gdbserver/win32-low.h
@@ -53,13 +53,13 @@ struct win32_target_ops
/* Fetch register from gdbserver regcache data. */
void (*fetch_inferior_register) (struct regcache *regcache,
- windows_nat::windows_thread_info *th,
- int r);
+ windows_nat::windows_thread_info *th,
+ int r);
/* Store a new register value into the thread context of TH. */
void (*store_inferior_register) (struct regcache *regcache,
- windows_nat::windows_thread_info *th,
- int r);
+ windows_nat::windows_thread_info *th,
+ int r);
void (*single_step) (windows_nat::windows_thread_info *th);
@@ -77,10 +77,10 @@ struct win32_target_ops
/* Breakpoint/Watchpoint related functions. See target.h for comments. */
int (*supports_z_point_type) (char z_type);
- int (*insert_point) (enum raw_bkpt_type type, CORE_ADDR addr,
- int size, struct raw_breakpoint *bp);
- int (*remove_point) (enum raw_bkpt_type type, CORE_ADDR addr,
- int size, struct raw_breakpoint *bp);
+ int (*insert_point) (enum raw_bkpt_type type, CORE_ADDR addr, int size,
+ struct raw_breakpoint *bp);
+ int (*remove_point) (enum raw_bkpt_type type, CORE_ADDR addr, int size,
+ struct raw_breakpoint *bp);
int (*stopped_by_watchpoint) (void);
CORE_ADDR (*stopped_data_address) (void);
};
@@ -92,9 +92,8 @@ extern struct win32_target_ops the_low_target;
class win32_process_target : public process_stratum_target
{
public:
-
int create_inferior (const char *program,
- const std::vector<char *> &program_args) override;
+ const std::vector<char *> &program_args) override;
int attach (unsigned long pid) override;
@@ -111,27 +110,26 @@ public:
void resume (thread_resume *resume_info, size_t n) override;
ptid_t wait (ptid_t ptid, target_waitstatus *status,
- target_wait_flags options) override;
+ target_wait_flags options) override;
void fetch_registers (regcache *regcache, int regno) override;
void store_registers (regcache *regcache, int regno) override;
- int read_memory (CORE_ADDR memaddr, unsigned char *myaddr,
- int len) override;
+ int read_memory (CORE_ADDR memaddr, unsigned char *myaddr, int len) override;
int write_memory (CORE_ADDR memaddr, const unsigned char *myaddr,
- int len) override;
+ int len) override;
void request_interrupt () override;
bool supports_z_point_type (char z_type) override;
- int insert_point (enum raw_bkpt_type type, CORE_ADDR addr,
- int size, raw_breakpoint *bp) override;
+ int insert_point (enum raw_bkpt_type type, CORE_ADDR addr, int size,
+ raw_breakpoint *bp) override;
- int remove_point (enum raw_bkpt_type type, CORE_ADDR addr,
- int size, raw_breakpoint *bp) override;
+ int remove_point (enum raw_bkpt_type type, CORE_ADDR addr, int size,
+ raw_breakpoint *bp) override;
bool supports_hardware_single_step () override;
@@ -142,8 +140,8 @@ public:
bool supports_qxfer_siginfo () override;
int qxfer_siginfo (const char *annex, unsigned char *readbuf,
- unsigned const char *writebuf,
- CORE_ADDR offset, int len) override;
+ unsigned const char *writebuf, CORE_ADDR offset,
+ int len) override;
bool supports_get_tib_address () override;
@@ -161,8 +159,7 @@ public:
const char *thread_name (ptid_t thread) override;
- bool supports_pid_to_exec_file () override
- { return true; }
+ bool supports_pid_to_exec_file () override { return true; }
const char *pid_to_exec_file (int pid) override;
@@ -174,10 +171,11 @@ public:
struct gdbserver_windows_process : public windows_nat::windows_process_info
{
- windows_nat::windows_thread_info *thread_rec
- (ptid_t ptid,
- windows_nat::thread_disposition_type disposition) override;
- int handle_output_debug_string (struct target_waitstatus *ourstatus) override;
+ windows_nat::windows_thread_info *
+ thread_rec (ptid_t ptid,
+ windows_nat::thread_disposition_type disposition) override;
+ int
+ handle_output_debug_string (struct target_waitstatus *ourstatus) override;
void handle_load_dll (const char *dll_name, LPVOID base) override;
void handle_unload_dll () override;
bool handle_access_violation (const EXCEPTION_RECORD *rec) override;
diff --git a/gdbserver/x86-low.cc b/gdbserver/x86-low.cc
index f6f7a3c..eddf963 100644
--- a/gdbserver/x86-low.cc
+++ b/gdbserver/x86-low.cc
@@ -29,10 +29,10 @@ x86_low_init_dregs (struct x86_debug_reg_state *state)
int i;
ALL_DEBUG_ADDRESS_REGISTERS (i)
- {
- state->dr_mirror[i] = 0;
- state->dr_ref_count[i] = 0;
- }
+ {
+ state->dr_mirror[i] = 0;
+ state->dr_ref_count[i] = 0;
+ }
state->dr_control_mirror = 0;
- state->dr_status_mirror = 0;
+ state->dr_status_mirror = 0;
}
diff --git a/gdbserver/x86-tdesc.h b/gdbserver/x86-tdesc.h
index 9610322..eae5ef5 100644
--- a/gdbserver/x86-tdesc.h
+++ b/gdbserver/x86-tdesc.h
@@ -22,11 +22,11 @@
variable is used depends on host/configuration, we mark it
ATTRIBUTE_UNUSED to keep it simple here. */
static const char *i386_expedite_regs[] ATTRIBUTE_UNUSED
- = {"ebp", "esp", "eip", NULL};
+ = { "ebp", "esp", "eip", NULL };
#ifdef __x86_64__
/* The "expedite" registers for x86_64 targets. */
-static const char *amd64_expedite_regs[] = {"rbp", "rsp", "rip", NULL};
+static const char *amd64_expedite_regs[] = { "rbp", "rsp", "rip", NULL };
#endif
#endif /* GDBSERVER_X86_TDESC_H */
diff --git a/gdbserver/xtensa-xtregs.cc b/gdbserver/xtensa-xtregs.cc
index 12a4a25..837e008 100644
--- a/gdbserver/xtensa-xtregs.cc
+++ b/gdbserver/xtensa-xtregs.cc
@@ -16,22 +16,22 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
-
-typedef struct {
- int gdb_regnum;
- int gdb_offset;
- int ptrace_cp_offset;
- int ptrace_offset;
- int size;
- int coproc;
- int dbnum;
- char* name
-;} xtensa_regtable_t;
-
-#define XTENSA_ELF_XTREG_SIZE 4
-
-const xtensa_regtable_t xtensa_regmap_table[] = {
+typedef struct
+{
+ int gdb_regnum;
+ int gdb_offset;
+ int ptrace_cp_offset;
+ int ptrace_offset;
+ int size;
+ int coproc;
+ int dbnum;
+ char *name;
+} xtensa_regtable_t;
+
+#define XTENSA_ELF_XTREG_SIZE 4
+
+const xtensa_regtable_t xtensa_regmap_table[] = {
/* gnum,gofs,cpofs,ofs,siz,cp, dbnum, name */
- { 44, 176, 0, 0, 4, -1, 0x020c, "scompare1" },
+ { 44, 176, 0, 0, 4, -1, 0x020c, "scompare1" },
{ 0 }
};