/* Target-dependent code for GNU/Linux i386.
- Copyright (C) 2000-2020 Free Software Foundation, Inc.
+ Copyright (C) 2000-2021 Free Software Foundation, Inc.
This file is part of GDB.
#include "symtab.h"
#include "arch-utils.h"
#include "xml-syscall.h"
+#include "infrun.h"
#include "i387-tdep.h"
#include "gdbsupport/x86-xstate.h"
PC is not at the start of the instruction sequence, there will be
a few trailing readable bytes on the stack. */
- if (!safe_frame_unwind_memory (this_frame, pc, buf, LINUX_SIGTRAMP_LEN))
+ if (!safe_frame_unwind_memory (this_frame, pc, buf))
return 0;
if (buf[0] != LINUX_SIGTRAMP_INSN0)
pc -= adjust;
- if (!safe_frame_unwind_memory (this_frame, pc, buf, LINUX_SIGTRAMP_LEN))
+ if (!safe_frame_unwind_memory (this_frame, pc, buf))
return 0;
}
PC is not at the start of the instruction sequence, there will be
a few trailing readable bytes on the stack. */
- if (!safe_frame_unwind_memory (this_frame, pc, buf, LINUX_RT_SIGTRAMP_LEN))
+ if (!safe_frame_unwind_memory (this_frame, pc, buf))
return 0;
if (buf[0] != LINUX_RT_SIGTRAMP_INSN0)
pc -= LINUX_RT_SIGTRAMP_OFFSET1;
- if (!safe_frame_unwind_memory (this_frame, pc, buf,
- LINUX_RT_SIGTRAMP_LEN))
+ if (!safe_frame_unwind_memory (this_frame, pc,
+ buf))
return 0;
}
#define SIG_CODE_BONDARY_FAULT 3
-/* i386 GNU/Linux implementation of the handle_segmentation_fault
+/* i386 GNU/Linux implementation of the report_signal_info
gdbarch hook. Displays information related to MPX bound
violations. */
void
-i386_linux_handle_segmentation_fault (struct gdbarch *gdbarch,
- struct ui_out *uiout)
+i386_linux_report_signal_info (struct gdbarch *gdbarch, struct ui_out *uiout,
+ enum gdb_signal siggnal)
{
/* -Wmaybe-uninitialized */
CORE_ADDR lower_bound = 0, upper_bound = 0, access = 0;
int is_upper;
long sig_code = 0;
- if (!i386_mpx_enabled ())
+ if (!i386_mpx_enabled () || siggnal != GDB_SIGNAL_SEGV)
return;
try
sig_code = parse_and_eval_long ("$_siginfo.si_code\n");
lower_bound
- = parse_and_eval_long ("$_siginfo._sifields._sigfault._addr_bnd._lower");
+ = parse_and_eval_long ("$_siginfo._sifields._sigfault._addr_bnd._lower");
upper_bound
- = parse_and_eval_long ("$_siginfo._sifields._sigfault._addr_bnd._upper");
+ = parse_and_eval_long ("$_siginfo._sifields._sigfault._addr_bnd._upper");
access
- = parse_and_eval_long ("$_siginfo._sifields._sigfault.si_addr");
+ = parse_and_eval_long ("$_siginfo._sifields._sigfault.si_addr");
}
catch (const gdb_exception &exception)
{
if (syscall_gdb < 0)
{
printf_unfiltered (_("Process record and replay target doesn't "
- "support syscall number %s\n"),
+ "support syscall number %s\n"),
plongest (syscall_native));
return -1;
}
static int
i386_linux_record_signal (struct gdbarch *gdbarch,
- struct regcache *regcache,
- enum gdb_signal signal)
+ struct regcache *regcache,
+ enum gdb_signal signal)
{
ULONGEST esp;
PC should get relocated back to its vDSO address. Hide the 'ret'
instruction by 'nop' so that i386_displaced_step_fixup is not confused.
- It is not fully correct as the bytes in struct displaced_step_closure will
- not match the inferior code. But we would need some new flag in
- displaced_step_closure otherwise to keep the state that syscall is finishing
- for the later i386_displaced_step_fixup execution as the syscall execution
- is already no longer detectable there. The new flag field would mean
- i386-linux-tdep.c needs to wrap all the displacement methods of i386-tdep.c
- which does not seem worth it. The same effect is achieved by patching that
- 'nop' instruction there instead. */
-
-static struct displaced_step_closure *
+ It is not fully correct as the bytes in struct
+ displaced_step_copy_insn_closure will not match the inferior code. But we
+ would need some new flag in displaced_step_copy_insn_closure otherwise to
+ keep the state that syscall is finishing for the later
+ i386_displaced_step_fixup execution as the syscall execution is already no
+ longer detectable there. The new flag field would mean i386-linux-tdep.c
+ needs to wrap all the displacement methods of i386-tdep.c which does not seem
+ worth it. The same effect is achieved by patching that 'nop' instruction
+ there instead. */
+
+static displaced_step_copy_insn_closure_up
i386_linux_displaced_step_copy_insn (struct gdbarch *gdbarch,
CORE_ADDR from, CORE_ADDR to,
struct regcache *regs)
{
- displaced_step_closure *closure_
+ displaced_step_copy_insn_closure_up closure_
= i386_displaced_step_copy_insn (gdbarch, from, to, regs);
if (i386_linux_get_syscall_number_from_regcache (regs) != -1)
{
/* The closure returned by i386_displaced_step_copy_insn is simply a
buffer with a copy of the instruction. */
- i386_displaced_step_closure *closure
- = (i386_displaced_step_closure *) closure_;
+ i386_displaced_step_copy_insn_closure *closure
+ = (i386_displaced_step_copy_insn_closure *) closure_.get ();
/* Fake nop. */
closure->buf[0] = 0x90;
gdb_assert (tdesc_data);
- linux_init_abi (info, gdbarch);
+ linux_init_abi (info, gdbarch, 1);
/* GNU/Linux uses ELF. */
i386_elf_init_abi (info, gdbarch);
/* Enable TLS support. */
set_gdbarch_fetch_tls_load_module_address (gdbarch,
- svr4_fetch_objfile_link_map);
+ svr4_fetch_objfile_link_map);
/* Core file support. */
set_gdbarch_iterate_over_regset_sections
/* Displaced stepping. */
set_gdbarch_displaced_step_copy_insn (gdbarch,
- i386_linux_displaced_step_copy_insn);
+ i386_linux_displaced_step_copy_insn);
set_gdbarch_displaced_step_fixup (gdbarch, i386_displaced_step_fixup);
- set_gdbarch_displaced_step_location (gdbarch,
- linux_displaced_step_location);
/* Functions for 'catch syscall'. */
set_xml_syscall_file_name (gdbarch, XML_SYSCALL_FILENAME_I386);
set_gdbarch_get_syscall_number (gdbarch,
- i386_linux_get_syscall_number);
+ i386_linux_get_syscall_number);
set_gdbarch_get_siginfo_type (gdbarch, x86_linux_get_siginfo_type);
- set_gdbarch_handle_segmentation_fault (gdbarch,
- i386_linux_handle_segmentation_fault);
+ set_gdbarch_report_signal_info (gdbarch, i386_linux_report_signal_info);
}
void _initialize_i386_linux_tdep ();