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