+ return gdb_sys_no_syscall;
+}
+
+/* Value of the sigcode in case of a boundary fault. */
+
+#define SIG_CODE_BONDARY_FAULT 3
+
+/* i386 GNU/Linux implementation of the handle_segmentation_fault
+ gdbarch hook. Displays information related to MPX bound
+ violations. */
+void
+i386_linux_handle_segmentation_fault (struct gdbarch *gdbarch,
+ struct ui_out *uiout)
+{
+ /* -Wmaybe-uninitialized */
+ CORE_ADDR lower_bound = 0, upper_bound = 0, access = 0;
+ int is_upper;
+ long sig_code = 0;
+
+ if (!i386_mpx_enabled ())
+ return;
+
+ try
+ {
+ /* Sigcode evaluates if the actual segfault is a boundary violation. */
+ sig_code = parse_and_eval_long ("$_siginfo.si_code\n");
+
+ lower_bound
+ = parse_and_eval_long ("$_siginfo._sifields._sigfault._addr_bnd._lower");
+ upper_bound
+ = parse_and_eval_long ("$_siginfo._sifields._sigfault._addr_bnd._upper");
+ access
+ = parse_and_eval_long ("$_siginfo._sifields._sigfault.si_addr");
+ }
+ catch (const gdb_exception &exception)
+ {
+ return;
+ }
+
+ /* If this is not a boundary violation just return. */
+ if (sig_code != SIG_CODE_BONDARY_FAULT)
+ return;
+
+ is_upper = (access > upper_bound ? 1 : 0);
+
+ uiout->text ("\n");
+ if (is_upper)
+ uiout->field_string ("sigcode-meaning", _("Upper bound violation"));
+ else
+ uiout->field_string ("sigcode-meaning", _("Lower bound violation"));
+
+ uiout->text (_(" while accessing address "));
+ uiout->field_core_addr ("bound-access", gdbarch, access);
+
+ uiout->text (_("\nBounds: [lower = "));
+ uiout->field_core_addr ("lower-bound", gdbarch, lower_bound);
+
+ uiout->text (_(", upper = "));
+ uiout->field_core_addr ("upper-bound", gdbarch, upper_bound);
+
+ uiout->text (_("]"));