gdb/sparc-sol2-nat.c - gdb

Functions defined

Macros defined

Source code

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

  2.    Copyright (C) 2003-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 "sparc-tdep.h"
  19. #include "target.h"
  20. #include "procfs.h"

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

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

  32.    GNU/Linux uses the same formats as Solaris for its core files (but
  33.    not for ptrace(2)).  The GNU/Linux headers don't define
  34.    PR_MODEL_NATIVE though.  Therefore we rely on the __arch64__ define
  35.    provided by GCC to determine the appropriate data model.

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

  38. #if (defined (__arch64__) || \
  39.      (defined (PR_MODEL_NATIVE) && (PR_MODEL_NATIVE == PR_MODEL_LP64)))

  40. #include "sparc64-tdep.h"

  41. #define sparc_supply_gregset sparc64_supply_gregset
  42. #define sparc_supply_fpregset sparc64_supply_fpregset
  43. #define sparc_collect_gregset sparc64_collect_gregset
  44. #define sparc_collect_fpregset sparc64_collect_fpregset

  45. #define sparc_sol2_gregmap sparc64_sol2_gregmap
  46. #define sparc_sol2_fpregmap sparc64_sol2_fpregmap

  47. #else

  48. #define sparc_supply_gregset sparc32_supply_gregset
  49. #define sparc_supply_fpregset sparc32_supply_fpregset
  50. #define sparc_collect_gregset sparc32_collect_gregset
  51. #define sparc_collect_fpregset sparc32_collect_fpregset

  52. #define sparc_sol2_gregmap sparc32_sol2_gregmap
  53. #define sparc_sol2_fpregmap sparc32_sol2_fpregmap

  54. #endif

  55. void
  56. supply_gregset (struct regcache *regcache, const prgregset_t *gregs)
  57. {
  58.   sparc_supply_gregset (&sparc_sol2_gregmap, regcache, -1, gregs);
  59. }

  60. void
  61. supply_fpregset (struct regcache *regcache, const prfpregset_t *fpregs)
  62. {
  63.   sparc_supply_fpregset (&sparc_sol2_fpregmap, regcache, -1, fpregs);
  64. }

  65. void
  66. fill_gregset (const struct regcache *regcache, prgregset_t *gregs, int regnum)
  67. {
  68.   sparc_collect_gregset (&sparc_sol2_gregmap, regcache, regnum, gregs);
  69. }

  70. void
  71. fill_fpregset (const struct regcache *regcache,
  72.                prfpregset_t *fpregs, int regnum)
  73. {
  74.   sparc_collect_fpregset (&sparc_sol2_fpregmap, regcache, regnum, fpregs);
  75. }

  76. /* Provide a prototype to silence -Wmissing-prototypes.  */
  77. extern initialize_file_ftype _initialize_sparc_sol2_nat;

  78. void
  79. _initialize_sparc_sol2_nat (void)
  80. {
  81.   struct target_ops *t;

  82.   t = procfs_target ();
  83. #ifdef NEW_PROC_API        /* Solaris 6 and above can do HW watchpoints.  */
  84.   procfs_use_watchpoints (t);
  85. #endif
  86.   add_target (t);
  87. }