Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 562128
Collapse All | Expand All

(-)a/gdb/alpha-tdep.c (-7 / +10 lines)
Lines 766-775 Link Here
766
   the sequence.  */
766
   the sequence.  */
767
767
768
static VEC (CORE_ADDR) *
768
static VEC (CORE_ADDR) *
769
alpha_deal_with_atomic_sequence (struct regcache *regcache)
769
alpha_deal_with_atomic_sequence (struct gdbarch *gdbarch, CORE_ADDR pc)
770
{
770
{
771
  struct gdbarch *gdbarch = get_regcache_arch (regcache);
772
  CORE_ADDR pc = regcache_read_pc (regcache);
773
  CORE_ADDR breaks[2] = {-1, -1};
771
  CORE_ADDR breaks[2] = {-1, -1};
774
  CORE_ADDR loc = pc;
772
  CORE_ADDR loc = pc;
775
  CORE_ADDR closing_insn; /* Instruction that closes the atomic sequence.  */
773
  CORE_ADDR closing_insn; /* Instruction that closes the atomic sequence.  */
Lines 1721-1732 Link Here
1721
alpha_software_single_step (struct regcache *regcache)
1719
alpha_software_single_step (struct regcache *regcache)
1722
{
1720
{
1723
  struct gdbarch *gdbarch = get_regcache_arch (regcache);
1721
  struct gdbarch *gdbarch = get_regcache_arch (regcache);
1724
  CORE_ADDR pc;
1722
  CORE_ADDR pc, next_pc;
1725
  VEC (CORE_ADDR) *next_pcs = NULL;
1723
  VEC (CORE_ADDR) *next_pcs;
1726
1724
1727
  pc = regcache_read_pc (regcache);
1725
  pc = regcache_read_pc (regcache);
1726
  next_pcs = alpha_deal_with_atomic_sequence (gdbarch, pc);
1727
  if (next_pcs != NULL)
1728
    return next_pcs;
1729
1730
  next_pc = alpha_next_pc (regcache, pc);
1728
1731
1729
  VEC_safe_push (CORE_ADDR, next_pcs, alpha_next_pc (regcache, pc));
1732
  VEC_safe_push (CORE_ADDR, next_pcs, next_pc);
1730
  return next_pcs;
1733
  return next_pcs;
1731
}
1734
}
1732
1735
Lines 1826-1832 Link Here
1826
  set_gdbarch_cannot_step_breakpoint (gdbarch, 1);
1829
  set_gdbarch_cannot_step_breakpoint (gdbarch, 1);
1827
1830
1828
  /* Handles single stepping of atomic sequences.  */
1831
  /* Handles single stepping of atomic sequences.  */
1829
  set_gdbarch_software_single_step (gdbarch, alpha_deal_with_atomic_sequence);
1832
  set_gdbarch_software_single_step (gdbarch, alpha_software_single_step);
1830
1833
1831
  /* Hook in ABI-specific overrides, if they have been registered.  */
1834
  /* Hook in ABI-specific overrides, if they have been registered.  */
1832
  gdbarch_init_osabi (info, gdbarch);
1835
  gdbarch_init_osabi (info, gdbarch);
(-)a/gdb/nat/linux-ptrace.h (+51 lines)
Lines 88-93 struct buffer; Link Here
88
#define __WALL          0x40000000 /* Wait for any child.  */
88
#define __WALL          0x40000000 /* Wait for any child.  */
89
#endif
89
#endif
90
90
91
/* True if whether a breakpoint/watchpoint triggered can be determined
92
   from the si_code of SIGTRAP's siginfo_t (TRAP_BRKPT/TRAP_HWBKPT).
93
   That is, if the kernel can tell us whether the thread executed a
94
   software breakpoint, we trust it.  The kernel will be determining
95
   that from the hardware (e.g., from which exception was raised in
96
   the CPU).  Relying on whether a breakpoint is planted in memory at
97
   the time the SIGTRAP is processed to determine whether the thread
98
   stopped for a software breakpoint can be too late.  E.g., the
99
   breakpoint could have been removed since.  Or the thread could have
100
   stepped an instruction the size of a breakpoint instruction, and
101
   before the stop is processed a breakpoint is inserted at its
102
   address.  Getting these wrong is disastrous on decr_pc_after_break
103
   architectures.  The moribund location mechanism helps with that
104
   somewhat but it is an heuristic, and can well fail.  Getting that
105
   information out of the kernel and ultimately out of the CPU is the
106
   way to go.  That said, some architecture may get the si_code wrong,
107
   and as such we're leaving fallback code in place.  We'll remove
108
   this after a while if no problem is reported.  */
109
#define USE_SIGTRAP_SIGINFO 1
110
111
/* The x86 kernel gets some of the si_code values backwards, like
112
   this:
113
114
   | what                                     | si_code    |
115
   |------------------------------------------+------------|
116
   | software breakpoints (int3)              | SI_KERNEL  |
117
   | single-steps                             | TRAP_TRACE |
118
   | single-stepping a syscall                | TRAP_BRKPT |
119
   | user sent SIGTRAP                        | 0          |
120
   | exec SIGTRAP (when no PTRACE_EVENT_EXEC) | 0          |
121
   | hardware breakpoints/watchpoints         | TRAP_HWBPT |
122
123
   That is, it reports SI_KERNEL for software breakpoints (and only
124
   for those), and TRAP_BRKPT for single-stepping a syscall...  If the
125
   kernel is ever fixed, we'll just have to detect it like we detect
126
   optional ptrace features: by forking and debugging ourselves,
127
   running to a breakpoint and checking what comes out of
128
   siginfo->si_code.
129
130
   The generic Linux target code should use GDB_ARCH_TRAP_BRKPT
131
   instead of TRAP_BRKPT to abstract out this x86 peculiarity.  */
132
#if defined __i386__ || defined __x86_64__
133
# define GDB_ARCH_TRAP_BRKPT SI_KERNEL
134
#else
135
# define GDB_ARCH_TRAP_BRKPT TRAP_BRKPT
136
#endif
137
138
#ifndef TRAP_HWBKPT
139
# define TRAP_HWBKPT 4
140
#endif
141
91
extern void linux_ptrace_attach_fail_reason (pid_t pid, struct buffer *buffer);
142
extern void linux_ptrace_attach_fail_reason (pid_t pid, struct buffer *buffer);

Return to bug 562128