i386-bsd-tdep.c 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /* Target-dependent code for i386 BSD's.
  2. Copyright (C) 2001-2022 Free Software Foundation, Inc.
  3. This file is part of GDB.
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 3 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program. If not, see <http://www.gnu.org/licenses/>. */
  14. #include "defs.h"
  15. #include "arch-utils.h"
  16. #include "frame.h"
  17. #include "gdbcore.h"
  18. #include "regcache.h"
  19. #include "osabi.h"
  20. #include "i386-tdep.h"
  21. /* Support for signal handlers. */
  22. /* Assuming THIS_FRAME is for a BSD sigtramp routine, return the
  23. address of the associated sigcontext structure. */
  24. static CORE_ADDR
  25. i386bsd_sigcontext_addr (struct frame_info *this_frame)
  26. {
  27. struct gdbarch *gdbarch = get_frame_arch (this_frame);
  28. enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
  29. gdb_byte buf[4];
  30. CORE_ADDR sp;
  31. get_frame_register (this_frame, I386_ESP_REGNUM, buf);
  32. sp = extract_unsigned_integer (buf, 4, byte_order);
  33. return read_memory_unsigned_integer (sp + 8, 4, byte_order);
  34. }
  35. /* Support for shared libraries. */
  36. /* Traditional BSD (4.3 BSD, still used for BSDI and 386BSD). */
  37. /* From <machine/signal.h>. */
  38. int i386bsd_sc_reg_offset[] =
  39. {
  40. -1, /* %eax */
  41. -1, /* %ecx */
  42. -1, /* %edx */
  43. -1, /* %ebx */
  44. 8 + 0 * 4, /* %esp */
  45. 8 + 1 * 4, /* %ebp */
  46. -1, /* %esi */
  47. -1, /* %edi */
  48. 8 + 3 * 4, /* %eip */
  49. 8 + 4 * 4, /* %eflags */
  50. -1, /* %cs */
  51. -1, /* %ss */
  52. -1, /* %ds */
  53. -1, /* %es */
  54. -1, /* %fs */
  55. -1 /* %gs */
  56. };
  57. void
  58. i386bsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
  59. {
  60. i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch);
  61. tdep->jb_pc_offset = 0;
  62. tdep->sigtramp_start = 0xfdbfdfc0;
  63. tdep->sigtramp_end = 0xfdbfe000;
  64. tdep->sigcontext_addr = i386bsd_sigcontext_addr;
  65. tdep->sc_reg_offset = i386bsd_sc_reg_offset;
  66. tdep->sc_num_regs = ARRAY_SIZE (i386bsd_sc_reg_offset);
  67. }