mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-12-15 04:31:49 +08:00
44122162ae
This is the previously mentioned patch to get rid of unstructured/ioctl-based procfs support in procfs.c. Given that support for structured procfs was introduced in Solaris 2.6 back in 1997 and we're just removing support for Solaris < 10, there's no point in carrying that baggage (and tons of support for IRIX and OSF/1 as well) around any longer. Most of the patch should be straightforward (removing support for !NEW_PROC_API, non-Solaris OSes and pre-Solaris 10 quirks). Only a few points need explanations: * <sys/syscall.h> was already included unconditionally in most places, so there's no need to have guards in a few remaining ones. * configure.host already obsoletes i?86-*-sysv4.2, i?86-*-sysv5, so NEW_PROC_API detection for those in configure.ac can go. * I'm still including <sys/procfs.h> with #define _STRUCTURED_PROC 1. Theoretically, it would be better to include <procfs.h> on Solaris (which includes that define), but that breaks the build over <procfs.h> vs. gdb's "procfs.h", and doesn't exist on Linux. * I've regenerated syscall_table[] in proc-events.c with a small script from Solaris 10, 11.3, 11.4 <sys/syscall.h>, so there should be no traces of older Solaris versions and other OSes left. * prsysent_t and DYNAMIC_SYSCALLS was only used for AIX 5, but AIX doesn't use procfs.c any longer, so all related code can go. The patch was generated with diff -w so one can easier see changes without being distracted by simple reindentations. So far, it has only been compiled and smoke-tested on amd64-pc-solaris2.1[01], sparcv9-sun-solaris2.1[01], and x86_64-pc-linux-gnu. Certainly needs more testing (Solaris 11.3 vs. 11.4, 32-bit gdb, testsuite once I've figured out what's wrong on Solaris 10 etc.), but it's enough to get a first impression how much cleanup is possible here. * configure.ac Don't check for sys/fault.h, sys/syscall.h, sys/proc.h. (NEW_PROC_API): Remove. (prsysent_t, pr_sigset_t, pr_sigaction64_t, pr_siginfo64_t): Likewise. * common/common.m4 (GDB_AC_COMMON): Don't check for sys/syscall.h. * configure: Regenerate. * config.in: Regenerate. * gdbserver/configure: Regenerate. * gdbserver/config.in: Regenerate. * i386-sol2-nat.c (_initialize_amd64_sol2_nat): Remove NEW_PROC_API test. * sparc-sol2-nat.c (_initialize_sparc_sol2_nat): Likewise. * linux-btrace.c: Remove HAVE_SYS_SYSCALL_H test. * proc-api.c: Remove !NEW_PROC_API support. Remove HAVE_SYS_PROC_H and HAVE_SYS_USER_H tests. Remove tests for macros always defined on Solaris. * proc-events.c: Remove !NEW_PROC_API support. Remove Remove HAVE_SYS_SYSCALL_H, HAVE_SYS_PROC_H and HAVE_SYS_USER_H tests. (init_syscall_table): Remove non-Solaris syscalls. Remove tests for syscalls present on all Solaris versions. Add missing Solaris 10+ syscalls. (signal_table): Remove non-Solaris signals. Remove tests for signals present on all Solaris versions. (fault_table): Remove non-Solaris faults. Remove tests for faults present on all Solaris versions. * proc-flags.c: Remove !NEW_PROC_API support. (pr_flag_table): Remove non-Solaris and pre-Solaris 7 comments. Remove non-Solaris flags. * proc-why.c: Remove !NEW_PROC_API support. (pr_why_table): Remove meaningless comments. Remove tests for reasons present on all Solaris versions. Remove OSF/1 cases. (proc_prettyfprint_why): Likewise. * procfs.c: Remove !NEW_PROC_API and DYNAMIC_SYSCALLS support. Remove HAVE_SYS_FAULT_H and HAVE_SYS_SYSCALL_H tests. Remove WA_READ test, IRIX watchpoint support. (gdb_sigset_t, gdb_sigaction_t, gdb_siginfo_t): Replace by base types. Change users. (gdb_praddset, gdb_prdelset, gdb_premptysysset, gdb_praddsysset) (gdb_prdelset, gdb_pr_issyssetmember): Replace by base macros. Change callers. Remove CTL_PROC_NAME_FMT tests. (gdb_prstatus_t, gdb_lwpstatus_t): Replace by base types. Change users. (sysset_t_size): Remove. Use sizeof (sysset_t) in callers. Remove PROCFS_DONT_PIOCSSIG_CURSIG support. (proc_modify_flag): Replace GDBRESET by PCUNSET. Remove PR_ASYNC, PR_KLC tests. (proc_unset_inherit_on_fork): Remove PR_ASYNC test. (proc_parent_pid): Remove PCWATCH etc. tests. (proc_set_watchpoint): Remove !PCWATCH && !PIOCSWATCH support. Remove PCAGENT test. (proc_get_nthreads) [PIOCNTHR && PIOCTLIST]: Remove. Remove SYS_lwpcreate || SYS_lwp_create test. (proc_get_current_thread): Likewise. [PIOCNTHR && PIOCTLIST]: Remove. [PIOCLSTATUS]: Remove. (procfs_debug_inferior): Remove non-Solaris cases, conditionals. [PRFS_STOPEXEC]: Remove. (syscall_is_lwp_exit): Remove non-Solaris cases, conditionals. (syscall_is_exit): Likewise. (syscall_is_exec): Likewise. (syscall_is_lwp_create): Likewise. Remove SYS_syssgi support. (procfs_wait): Remove PR_ASYNC, !PIOCSSPCACT tests. [SYS_syssgi]: Remove. Remove non-Solaris cases, conditionals. (unconditionally_kill_inferior) [PROCFS_NEED_PIOCSSIG_FOR_KILL]: Remove. (procfs_init_inferior) [SYS_syssgi]: Remove. (procfs_set_exec_trap) [PRFS_STOPEXEC]: Remove. (procfs_inferior_created) [SYS_syssgi]: Remove. (procfs_set_watchpoint): Remove !AIX5 test. (procfs_stopped_by_watchpoint): Remove FLTWATCH test, FLTKWATCH case. (mappingflags) [MA_PHYS]: Remove. (info_mappings_callback): Remove PCAGENT test. Remove PIOCOPENLWP || PCAGENT test.
154 lines
4.1 KiB
C
154 lines
4.1 KiB
C
/* Native-dependent code for Solaris x86.
|
|
|
|
Copyright (C) 2004-2017 Free Software Foundation, Inc.
|
|
|
|
This file is part of GDB.
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation; either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
|
|
|
#include "defs.h"
|
|
#include "regcache.h"
|
|
|
|
#include <sys/procfs.h>
|
|
#include "gregset.h"
|
|
#include "target.h"
|
|
#include "procfs.h"
|
|
|
|
/* This file provids the (temporary) glue between the Solaris x86
|
|
target dependent code and the machine independent SVR4 /proc
|
|
support. */
|
|
|
|
/* Solaris 10 (Solaris 2.10, SunOS 5.10) and up support two process
|
|
data models, the traditional 32-bit data model (ILP32) and the
|
|
64-bit data model (LP64). The format of /proc depends on the data
|
|
model of the observer (the controlling process, GDB in our case).
|
|
The Solaris header files conveniently define PR_MODEL_NATIVE to the
|
|
data model of the controlling process. If its value is
|
|
PR_MODEL_LP64, we know that GDB is being compiled as a 64-bit
|
|
program.
|
|
|
|
Note that a 32-bit GDB won't be able to debug a 64-bit target
|
|
process using /proc on Solaris. */
|
|
|
|
#if defined (PR_MODEL_NATIVE) && (PR_MODEL_NATIVE == PR_MODEL_LP64)
|
|
|
|
#include "amd64-nat.h"
|
|
#include "amd64-tdep.h"
|
|
|
|
/* Mapping between the general-purpose registers in gregset_t format
|
|
and GDB's register cache layout. */
|
|
|
|
/* From <sys/regset.h>. */
|
|
static int amd64_sol2_gregset64_reg_offset[] = {
|
|
14 * 8, /* %rax */
|
|
11 * 8, /* %rbx */
|
|
13 * 8, /* %rcx */
|
|
12 * 8, /* %rdx */
|
|
9 * 8, /* %rsi */
|
|
8 * 8, /* %rdi */
|
|
10 * 8, /* %rbp */
|
|
20 * 8, /* %rsp */
|
|
7 * 8, /* %r8 ... */
|
|
6 * 8,
|
|
5 * 8,
|
|
4 * 8,
|
|
3 * 8,
|
|
2 * 8,
|
|
1 * 8,
|
|
0 * 8, /* ... %r15 */
|
|
17 * 8, /* %rip */
|
|
19 * 8, /* %eflags */
|
|
18 * 8, /* %cs */
|
|
21 * 8, /* %ss */
|
|
25 * 8, /* %ds */
|
|
24 * 8, /* %es */
|
|
22 * 8, /* %fs */
|
|
23 * 8 /* %gs */
|
|
};
|
|
|
|
/* 32-bit registers are provided by Solaris in 64-bit format, so just
|
|
give a subset of the list above. */
|
|
static int amd64_sol2_gregset32_reg_offset[] = {
|
|
14 * 8, /* %eax */
|
|
13 * 8, /* %ecx */
|
|
12 * 8, /* %edx */
|
|
11 * 8, /* %ebx */
|
|
20 * 8, /* %esp */
|
|
10 * 8, /* %ebp */
|
|
9 * 8, /* %esi */
|
|
8 * 8, /* %edi */
|
|
17 * 8, /* %eip */
|
|
19 * 8, /* %eflags */
|
|
18 * 8, /* %cs */
|
|
21 * 8, /* %ss */
|
|
25 * 8, /* %ds */
|
|
24 * 8, /* %es */
|
|
22 * 8, /* %fs */
|
|
23 * 8 /* %gs */
|
|
};
|
|
|
|
void
|
|
supply_gregset (struct regcache *regcache, const prgregset_t *gregs)
|
|
{
|
|
amd64_supply_native_gregset (regcache, gregs, -1);
|
|
}
|
|
|
|
void
|
|
supply_fpregset (struct regcache *regcache, const prfpregset_t *fpregs)
|
|
{
|
|
amd64_supply_fxsave (regcache, -1, fpregs);
|
|
}
|
|
|
|
void
|
|
fill_gregset (const struct regcache *regcache,
|
|
prgregset_t *gregs, int regnum)
|
|
{
|
|
amd64_collect_native_gregset (regcache, gregs, regnum);
|
|
}
|
|
|
|
void
|
|
fill_fpregset (const struct regcache *regcache,
|
|
prfpregset_t *fpregs, int regnum)
|
|
{
|
|
amd64_collect_fxsave (regcache, regnum, fpregs);
|
|
}
|
|
|
|
#else
|
|
|
|
/* For 32-bit Solaris x86, we use the Unix SVR4 code in i386v4-nat.c. */
|
|
|
|
#endif
|
|
|
|
void
|
|
_initialize_amd64_sol2_nat (void)
|
|
{
|
|
struct target_ops *t;
|
|
|
|
/* Fill in the generic procfs methods. */
|
|
t = procfs_target ();
|
|
|
|
procfs_use_watchpoints (t);
|
|
|
|
#if defined (PR_MODEL_NATIVE) && (PR_MODEL_NATIVE == PR_MODEL_LP64)
|
|
amd64_native_gregset32_reg_offset = amd64_sol2_gregset32_reg_offset;
|
|
amd64_native_gregset32_num_regs =
|
|
ARRAY_SIZE (amd64_sol2_gregset32_reg_offset);
|
|
amd64_native_gregset64_reg_offset = amd64_sol2_gregset64_reg_offset;
|
|
amd64_native_gregset64_num_regs =
|
|
ARRAY_SIZE (amd64_sol2_gregset64_reg_offset);
|
|
#endif
|
|
|
|
add_target (t);
|
|
}
|