gdb/i386-sol2-nat.c - gdb

Global variables defined

Functions defined

Source code

  1. /* Native-dependent code for Solaris x86.

  2.    Copyright (C) 2004-2015 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 "regcache.h"

  16. #include <sys/procfs.h>
  17. #include "gregset.h"
  18. #include "target.h"
  19. #include "procfs.h"

  20. /* This file provids the (temporary) glue between the Solaris x86
  21.    target dependent code and the machine independent SVR4 /proc
  22.    support.  */

  23. /* Solaris 10 (Solaris 2.10, SunOS 5.10) and up support two process
  24.    data models, the traditional 32-bit data model (ILP32) and the
  25.    64-bit data model (LP64).  The format of /proc depends on the data
  26.    model of the observer (the controlling process, GDB in our case).
  27.    The Solaris header files conveniently define PR_MODEL_NATIVE to the
  28.    data model of the controlling process.  If its value is
  29.    PR_MODEL_LP64, we know that GDB is being compiled as a 64-bit
  30.    program.

  31.    Note that a 32-bit GDB won't be able to debug a 64-bit target
  32.    process using /proc on Solaris.  */

  33. #if defined (PR_MODEL_NATIVE) && (PR_MODEL_NATIVE == PR_MODEL_LP64)

  34. #include "amd64-nat.h"
  35. #include "amd64-tdep.h"

  36. /* Mapping between the general-purpose registers in gregset_t format
  37.    and GDB's register cache layout.  */

  38. /* From <sys/regset.h>.  */
  39. static int amd64_sol2_gregset64_reg_offset[] = {
  40.   14 * 8,                        /* %rax */
  41.   11 * 8,                        /* %rbx */
  42.   13 * 8,                        /* %rcx */
  43.   12 * 8,                        /* %rdx */
  44.   9 * 8,                        /* %rsi */
  45.   8 * 8,                        /* %rdi */
  46.   10 * 8,                        /* %rbp */
  47.   20 * 8,                        /* %rsp */
  48.   7 * 8,                        /* %r8 ...  */
  49.   6 * 8,
  50.   5 * 8,
  51.   4 * 8,
  52.   3 * 8,
  53.   2 * 8,
  54.   1 * 8,
  55.   0 * 8,                        /* ... %r15 */
  56.   17 * 8,                        /* %rip */
  57.   19 * 8,                        /* %eflags */
  58.   18 * 8,                        /* %cs */
  59.   21 * 8,                        /* %ss */
  60.   25 * 8,                        /* %ds */
  61.   24 * 8,                        /* %es */
  62.   22 * 8,                        /* %fs */
  63.   23 * 8                        /* %gs */
  64. };

  65. /* 32-bit registers are provided by Solaris in 64-bit format, so just
  66.    give a subset of the list above.  */
  67. static int amd64_sol2_gregset32_reg_offset[] = {
  68.   14 * 8,                        /* %eax */
  69.   13 * 8,                        /* %ecx */
  70.   12 * 8,                        /* %edx */
  71.   11 * 8,                        /* %ebx */
  72.   20 * 8,                        /* %esp */
  73.   10 * 8,                        /* %ebp */
  74.   9 * 8,                        /* %esi */
  75.   8 * 8,                        /* %edi */
  76.   17 * 8,                        /* %eip */
  77.   19 * 8,                        /* %eflags */
  78.   18 * 8,                        /* %cs */
  79.   21 * 8,                        /* %ss */
  80.   25 * 8,                        /* %ds */
  81.   24 * 8,                        /* %es */
  82.   22 * 8,                        /* %fs */
  83.   23 * 8                        /* %gs */
  84. };

  85. void
  86. supply_gregset (struct regcache *regcache, const prgregset_t *gregs)
  87. {
  88.   amd64_supply_native_gregset (regcache, gregs, -1);
  89. }

  90. void
  91. supply_fpregset (struct regcache *regcache, const prfpregset_t *fpregs)
  92. {
  93.   amd64_supply_fxsave (regcache, -1, fpregs);
  94. }

  95. void
  96. fill_gregset (const struct regcache *regcache,
  97.               prgregset_t *gregs, int regnum)
  98. {
  99.   amd64_collect_native_gregset (regcache, gregs, regnum);
  100. }

  101. void
  102. fill_fpregset (const struct regcache *regcache,
  103.                prfpregset_t *fpregs, int regnum)
  104. {
  105.   amd64_collect_fxsave (regcache, regnum, fpregs);
  106. }

  107. #else

  108. /* For 32-bit Solaris x86, we use the Unix SVR4 code in i386v4-nat.c.  */

  109. #endif

  110. /* Provide a prototype to silence -Wmissing-prototypes.  */
  111. extern void _initialize_amd64_sol2_nat (void);

  112. void
  113. _initialize_amd64_sol2_nat (void)
  114. {
  115.   struct target_ops *t;

  116.   /* Fill in the generic procfs methods.  */
  117.   t = procfs_target ();

  118. #ifdef NEW_PROC_API        /* Solaris 6 and above can do HW watchpoints.  */
  119.   procfs_use_watchpoints (t);
  120. #endif

  121. #if defined (PR_MODEL_NATIVE) && (PR_MODEL_NATIVE == PR_MODEL_LP64)
  122.   amd64_native_gregset32_reg_offset = amd64_sol2_gregset32_reg_offset;
  123.   amd64_native_gregset32_num_regs =
  124.     ARRAY_SIZE (amd64_sol2_gregset32_reg_offset);
  125.   amd64_native_gregset64_reg_offset = amd64_sol2_gregset64_reg_offset;
  126.   amd64_native_gregset64_num_regs =
  127.     ARRAY_SIZE (amd64_sol2_gregset64_reg_offset);
  128. #endif

  129.   add_target (t);
  130. }