2013-12-03 12:35:35 +01:00
|
|
|
/* Target-dependent code for FreeBSD, architecture-independent.
|
|
|
|
|
2019-01-01 07:01:51 +01:00
|
|
|
Copyright (C) 2002-2019 Free Software Foundation, Inc.
|
2013-12-03 12:35:35 +01:00
|
|
|
|
|
|
|
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"
|
2016-06-16 06:33:42 +02:00
|
|
|
#include "auxv.h"
|
2013-12-03 12:35:35 +01:00
|
|
|
#include "gdbcore.h"
|
|
|
|
#include "inferior.h"
|
|
|
|
#include "regcache.h"
|
|
|
|
#include "regset.h"
|
|
|
|
#include "gdbthread.h"
|
2019-03-12 21:39:02 +01:00
|
|
|
#include "objfiles.h"
|
2016-06-13 06:24:42 +02:00
|
|
|
#include "xml-syscall.h"
|
Add support for 'info proc files' on FreeBSD core dumps.
Walk the list of struct kinfo_file objects in the
NT_FREEBSD_PROCSTAT_FILES core dump note outputting a description of
each open file descriptor. For sockets, the local and remote socket
addresses are displayed in place of the file name field. For UNIX
local domain sockets, only a single address is displayed since most
UNIX sockets only have one valid address and printing both pathnames
could be quite long. The output format was somewhat inspired by the
output of the "procstat -f" command on FreeBSD, but with a few less
details and some fields were condensed.
gdb/ChangeLog:
* fbsd-tdep.c (KF_FLAGS, KF_OFFSET, KF_VNODE_TYPE, KF_SOCK_DOMAIN)
(KF_SOCK_TYPE, KF_SOCK_PROTOCOL, KF_SA_LOCAL, KF_SA_PEER)
(KINFO_FILE_TYPE_SOCKET, KINFO_FILE_TYPE_PIPE)
(KINFO_FILE_TYPE_FIFO, KINFO_FILE_TYPE_KQUEUE)
(KINFO_FILE_TYPE_CRYPTO, KINFO_FILE_TYPE_MQUEUE)
(KINFO_FILE_TYPE_SHM, KINFO_FILE_TYPE_SEM, KINFO_FILE_TYPE_PTS)
(KINFO_FILE_TYPE_PROCDESC, KINFO_FILE_FD_TYPE_ROOT)
(KINFO_FILE_FD_TYPE_JAIL, KINFO_FILE_FD_TYPE_TRACE)
(KINFO_FILE_FD_TYPE_CTTY, KINFO_FILE_FLAG_READ)
(KINFO_FILE_FLAG_WRITE, KINFO_FILE_FLAG_APPEND)
(KINFO_FILE_FLAG_ASYNC, KINFO_FILE_FLAG_FSYNC)
(KINFO_FILE_FLAG_NONBLOCK, KINFO_FILE_FLAG_DIRECT)
(KINFO_FILE_FLAG_HASLOCK, KINFO_FILE_FLAG_EXEC)
(KINFO_FILE_VTYPE_VREG, KINFO_FILE_VTYPE_VDIR)
(KINFO_FILE_VTYPE_VCHR, KINFO_FILE_VTYPE_VLNK)
(KINFO_FILE_VTYPE_VSOCK, KINFO_FILE_VTYPE_VFIFO, FBSD_AF_UNIX)
(FBSD_AF_INET, FBSD_AF_INET6, FBSD_SOCK_STREAM, FBSD_SOCK_DGRAM)
(FBSD_SOCK_SEQPACKET, FBSD_IPPROTO_ICMP, FBSD_IPPROTO_TCP)
(FBSD_IPPROTO_UDP, FBSD_IPPROTO_SCTP): New defines.
(struct fbsd_sockaddr_in, struct fbsd_sockaddr_in6)
(struct fbsd_sockaddr_un): New types.
(fbsd_file_fd, fbsd_file_type, fbsd_file_flags, fbsd_ipproto)
(fbsd_print_sockaddr_in, fbsd_print_sockaddr_in6)
(fbsd_info_proc_files_header, fbsd_info_proc_files_entry)
(fbsd_core_info_proc_files): New functions.
(fbsd_core_info_proc): List open file descriptors for IP_FILES and
IP_ALL.
* fbsd-tdep.h (fbsd_info_proc_files_header)
(fbsd_info_proc_files_entry): New.
2018-09-18 23:05:47 +02:00
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <arpa/inet.h>
|
2013-12-03 12:35:35 +01:00
|
|
|
|
|
|
|
#include "elf-bfd.h"
|
|
|
|
#include "fbsd-tdep.h"
|
|
|
|
|
2018-11-29 22:26:31 +01:00
|
|
|
/* This enum is derived from FreeBSD's <sys/signal.h>. */
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
FREEBSD_SIGHUP = 1,
|
|
|
|
FREEBSD_SIGINT = 2,
|
|
|
|
FREEBSD_SIGQUIT = 3,
|
|
|
|
FREEBSD_SIGILL = 4,
|
|
|
|
FREEBSD_SIGTRAP = 5,
|
|
|
|
FREEBSD_SIGABRT = 6,
|
|
|
|
FREEBSD_SIGEMT = 7,
|
|
|
|
FREEBSD_SIGFPE = 8,
|
|
|
|
FREEBSD_SIGKILL = 9,
|
|
|
|
FREEBSD_SIGBUS = 10,
|
|
|
|
FREEBSD_SIGSEGV = 11,
|
|
|
|
FREEBSD_SIGSYS = 12,
|
|
|
|
FREEBSD_SIGPIPE = 13,
|
|
|
|
FREEBSD_SIGALRM = 14,
|
|
|
|
FREEBSD_SIGTERM = 15,
|
|
|
|
FREEBSD_SIGURG = 16,
|
|
|
|
FREEBSD_SIGSTOP = 17,
|
|
|
|
FREEBSD_SIGTSTP = 18,
|
|
|
|
FREEBSD_SIGCONT = 19,
|
|
|
|
FREEBSD_SIGCHLD = 20,
|
|
|
|
FREEBSD_SIGTTIN = 21,
|
|
|
|
FREEBSD_SIGTTOU = 22,
|
|
|
|
FREEBSD_SIGIO = 23,
|
|
|
|
FREEBSD_SIGXCPU = 24,
|
|
|
|
FREEBSD_SIGXFSZ = 25,
|
|
|
|
FREEBSD_SIGVTALRM = 26,
|
|
|
|
FREEBSD_SIGPROF = 27,
|
|
|
|
FREEBSD_SIGWINCH = 28,
|
|
|
|
FREEBSD_SIGINFO = 29,
|
|
|
|
FREEBSD_SIGUSR1 = 30,
|
|
|
|
FREEBSD_SIGUSR2 = 31,
|
|
|
|
FREEBSD_SIGTHR = 32,
|
|
|
|
FREEBSD_SIGLIBRT = 33,
|
|
|
|
FREEBSD_SIGRTMIN = 65,
|
|
|
|
FREEBSD_SIGRTMAX = 126,
|
|
|
|
};
|
2013-12-03 12:35:35 +01:00
|
|
|
|
2017-06-28 21:50:56 +02:00
|
|
|
/* FreeBSD kernels 12.0 and later include a copy of the
|
|
|
|
'ptrace_lwpinfo' structure returned by the PT_LWPINFO ptrace
|
|
|
|
operation in an ELF core note (NT_FREEBSD_PTLWPINFO) for each LWP.
|
|
|
|
The constants below define the offset of field members and flags in
|
|
|
|
this structure used by methods in this file. Note that the
|
|
|
|
'ptrace_lwpinfo' struct in the note is preceded by a 4 byte integer
|
|
|
|
containing the size of the structure. */
|
|
|
|
|
|
|
|
#define LWPINFO_OFFSET 0x4
|
|
|
|
|
|
|
|
/* Offsets in ptrace_lwpinfo. */
|
|
|
|
#define LWPINFO_PL_FLAGS 0x8
|
|
|
|
#define LWPINFO64_PL_SIGINFO 0x30
|
|
|
|
#define LWPINFO32_PL_SIGINFO 0x2c
|
|
|
|
|
|
|
|
/* Flags in pl_flags. */
|
|
|
|
#define PL_FLAG_SI 0x20 /* siginfo is valid */
|
|
|
|
|
|
|
|
/* Sizes of siginfo_t. */
|
|
|
|
#define SIZE64_SIGINFO_T 80
|
|
|
|
#define SIZE32_SIGINFO_T 64
|
|
|
|
|
Support 'info proc' for FreeBSD process core dumps.
- Command line arguments are obtained from the pr_psargs[] array
saved in the NT_PRPSINFO note.
- The 'cwd' and 'exe' values are obtained from the per-process file
descriptor table stored in the NT_PROCSTAT_FILES core note.
- 'mappings' is implemented by walking the array of VM map entries
stored in the NT_PROCSTAT_VMMAP core note.
- 'status' output is generated by outputting fields from
the first structure stored in the NT_PROCSTAT_PROC core note.
- 'stat' is aliased to 'status'.
gdb/ChangeLog:
* fbsd-tdep.c (KVE_STRUCTSIZE, KVE_START, KVE_END, KVE_OFFSET)
(KVE_FLAGS, KVE_PROTECTION, KVE_PATH, KINFO_VME_PROT_READ)
(KINFO_VME_PROT_WRITE, KINFO_VME_PROT_EXEC, KINFO_VME_FLAG_COW)
(KINFO_VME_FLAG_NEEDS_COPY, KINFO_VME_FLAG_NOCOREDUMP)
(KINFO_VME_FLAG_SUPER, KINFO_VME_FLAG_GROWS_UP)
(KINFO_VME_FLAG_GROWS_DOWN, KF_STRUCTSIZE, KF_TYPE, KF_FD)
(KF_PATH, KINFO_FILE_TYPE_VNODE, KINFO_FILE_FD_TYPE_CWD)
(KINFO_FILE_FD_TYPE_TEXT, SIG_WORDS, struct kinfo_proc_layout)
(kinfo_proc_layout_32, kinfo_proc_layout_i386)
(kinfo_proc_layout_64, fbsd_vm_map_entry_flags)
(fbsd_core_info_proc_mappings, fbsd_core_vnode_path)
(fbsd_core_fetch_timeval, fbsd_print_sigset)
(fbsd_core_info_proc_status, fbsd_core_info_proc): New.
(fbsd_init_abi): Install gdbarch "core_info_proc" method.
* fbsd-tdep.h (fbsd_vm_map_entry_flags): New.
2018-01-09 22:35:17 +01:00
|
|
|
/* Offsets in data structure used in NT_FREEBSD_PROCSTAT_VMMAP core
|
|
|
|
dump notes. See <sys/user.h> for the definition of struct
|
|
|
|
kinfo_vmentry. This data structure should have the same layout on
|
Add support for 'info proc files' on FreeBSD core dumps.
Walk the list of struct kinfo_file objects in the
NT_FREEBSD_PROCSTAT_FILES core dump note outputting a description of
each open file descriptor. For sockets, the local and remote socket
addresses are displayed in place of the file name field. For UNIX
local domain sockets, only a single address is displayed since most
UNIX sockets only have one valid address and printing both pathnames
could be quite long. The output format was somewhat inspired by the
output of the "procstat -f" command on FreeBSD, but with a few less
details and some fields were condensed.
gdb/ChangeLog:
* fbsd-tdep.c (KF_FLAGS, KF_OFFSET, KF_VNODE_TYPE, KF_SOCK_DOMAIN)
(KF_SOCK_TYPE, KF_SOCK_PROTOCOL, KF_SA_LOCAL, KF_SA_PEER)
(KINFO_FILE_TYPE_SOCKET, KINFO_FILE_TYPE_PIPE)
(KINFO_FILE_TYPE_FIFO, KINFO_FILE_TYPE_KQUEUE)
(KINFO_FILE_TYPE_CRYPTO, KINFO_FILE_TYPE_MQUEUE)
(KINFO_FILE_TYPE_SHM, KINFO_FILE_TYPE_SEM, KINFO_FILE_TYPE_PTS)
(KINFO_FILE_TYPE_PROCDESC, KINFO_FILE_FD_TYPE_ROOT)
(KINFO_FILE_FD_TYPE_JAIL, KINFO_FILE_FD_TYPE_TRACE)
(KINFO_FILE_FD_TYPE_CTTY, KINFO_FILE_FLAG_READ)
(KINFO_FILE_FLAG_WRITE, KINFO_FILE_FLAG_APPEND)
(KINFO_FILE_FLAG_ASYNC, KINFO_FILE_FLAG_FSYNC)
(KINFO_FILE_FLAG_NONBLOCK, KINFO_FILE_FLAG_DIRECT)
(KINFO_FILE_FLAG_HASLOCK, KINFO_FILE_FLAG_EXEC)
(KINFO_FILE_VTYPE_VREG, KINFO_FILE_VTYPE_VDIR)
(KINFO_FILE_VTYPE_VCHR, KINFO_FILE_VTYPE_VLNK)
(KINFO_FILE_VTYPE_VSOCK, KINFO_FILE_VTYPE_VFIFO, FBSD_AF_UNIX)
(FBSD_AF_INET, FBSD_AF_INET6, FBSD_SOCK_STREAM, FBSD_SOCK_DGRAM)
(FBSD_SOCK_SEQPACKET, FBSD_IPPROTO_ICMP, FBSD_IPPROTO_TCP)
(FBSD_IPPROTO_UDP, FBSD_IPPROTO_SCTP): New defines.
(struct fbsd_sockaddr_in, struct fbsd_sockaddr_in6)
(struct fbsd_sockaddr_un): New types.
(fbsd_file_fd, fbsd_file_type, fbsd_file_flags, fbsd_ipproto)
(fbsd_print_sockaddr_in, fbsd_print_sockaddr_in6)
(fbsd_info_proc_files_header, fbsd_info_proc_files_entry)
(fbsd_core_info_proc_files): New functions.
(fbsd_core_info_proc): List open file descriptors for IP_FILES and
IP_ALL.
* fbsd-tdep.h (fbsd_info_proc_files_header)
(fbsd_info_proc_files_entry): New.
2018-09-18 23:05:47 +02:00
|
|
|
all architectures.
|
|
|
|
|
|
|
|
Note that FreeBSD 7.0 used an older version of this structure
|
|
|
|
(struct kinfo_ovmentry), but the NT_FREEBSD_PROCSTAT_VMMAP core
|
|
|
|
dump note wasn't introduced until FreeBSD 9.2. As a result, the
|
|
|
|
core dump note has always used the 7.1 and later structure
|
|
|
|
format. */
|
Support 'info proc' for FreeBSD process core dumps.
- Command line arguments are obtained from the pr_psargs[] array
saved in the NT_PRPSINFO note.
- The 'cwd' and 'exe' values are obtained from the per-process file
descriptor table stored in the NT_PROCSTAT_FILES core note.
- 'mappings' is implemented by walking the array of VM map entries
stored in the NT_PROCSTAT_VMMAP core note.
- 'status' output is generated by outputting fields from
the first structure stored in the NT_PROCSTAT_PROC core note.
- 'stat' is aliased to 'status'.
gdb/ChangeLog:
* fbsd-tdep.c (KVE_STRUCTSIZE, KVE_START, KVE_END, KVE_OFFSET)
(KVE_FLAGS, KVE_PROTECTION, KVE_PATH, KINFO_VME_PROT_READ)
(KINFO_VME_PROT_WRITE, KINFO_VME_PROT_EXEC, KINFO_VME_FLAG_COW)
(KINFO_VME_FLAG_NEEDS_COPY, KINFO_VME_FLAG_NOCOREDUMP)
(KINFO_VME_FLAG_SUPER, KINFO_VME_FLAG_GROWS_UP)
(KINFO_VME_FLAG_GROWS_DOWN, KF_STRUCTSIZE, KF_TYPE, KF_FD)
(KF_PATH, KINFO_FILE_TYPE_VNODE, KINFO_FILE_FD_TYPE_CWD)
(KINFO_FILE_FD_TYPE_TEXT, SIG_WORDS, struct kinfo_proc_layout)
(kinfo_proc_layout_32, kinfo_proc_layout_i386)
(kinfo_proc_layout_64, fbsd_vm_map_entry_flags)
(fbsd_core_info_proc_mappings, fbsd_core_vnode_path)
(fbsd_core_fetch_timeval, fbsd_print_sigset)
(fbsd_core_info_proc_status, fbsd_core_info_proc): New.
(fbsd_init_abi): Install gdbarch "core_info_proc" method.
* fbsd-tdep.h (fbsd_vm_map_entry_flags): New.
2018-01-09 22:35:17 +01:00
|
|
|
|
|
|
|
#define KVE_STRUCTSIZE 0x0
|
|
|
|
#define KVE_START 0x8
|
|
|
|
#define KVE_END 0x10
|
|
|
|
#define KVE_OFFSET 0x18
|
|
|
|
#define KVE_FLAGS 0x2c
|
2018-01-12 21:05:50 +01:00
|
|
|
#define KVE_PROTECTION 0x38
|
Support 'info proc' for FreeBSD process core dumps.
- Command line arguments are obtained from the pr_psargs[] array
saved in the NT_PRPSINFO note.
- The 'cwd' and 'exe' values are obtained from the per-process file
descriptor table stored in the NT_PROCSTAT_FILES core note.
- 'mappings' is implemented by walking the array of VM map entries
stored in the NT_PROCSTAT_VMMAP core note.
- 'status' output is generated by outputting fields from
the first structure stored in the NT_PROCSTAT_PROC core note.
- 'stat' is aliased to 'status'.
gdb/ChangeLog:
* fbsd-tdep.c (KVE_STRUCTSIZE, KVE_START, KVE_END, KVE_OFFSET)
(KVE_FLAGS, KVE_PROTECTION, KVE_PATH, KINFO_VME_PROT_READ)
(KINFO_VME_PROT_WRITE, KINFO_VME_PROT_EXEC, KINFO_VME_FLAG_COW)
(KINFO_VME_FLAG_NEEDS_COPY, KINFO_VME_FLAG_NOCOREDUMP)
(KINFO_VME_FLAG_SUPER, KINFO_VME_FLAG_GROWS_UP)
(KINFO_VME_FLAG_GROWS_DOWN, KF_STRUCTSIZE, KF_TYPE, KF_FD)
(KF_PATH, KINFO_FILE_TYPE_VNODE, KINFO_FILE_FD_TYPE_CWD)
(KINFO_FILE_FD_TYPE_TEXT, SIG_WORDS, struct kinfo_proc_layout)
(kinfo_proc_layout_32, kinfo_proc_layout_i386)
(kinfo_proc_layout_64, fbsd_vm_map_entry_flags)
(fbsd_core_info_proc_mappings, fbsd_core_vnode_path)
(fbsd_core_fetch_timeval, fbsd_print_sigset)
(fbsd_core_info_proc_status, fbsd_core_info_proc): New.
(fbsd_init_abi): Install gdbarch "core_info_proc" method.
* fbsd-tdep.h (fbsd_vm_map_entry_flags): New.
2018-01-09 22:35:17 +01:00
|
|
|
#define KVE_PATH 0x88
|
|
|
|
|
|
|
|
/* Flags in the 'kve_protection' field in struct kinfo_vmentry. These
|
|
|
|
match the KVME_PROT_* constants in <sys/user.h>. */
|
|
|
|
|
|
|
|
#define KINFO_VME_PROT_READ 0x00000001
|
|
|
|
#define KINFO_VME_PROT_WRITE 0x00000002
|
|
|
|
#define KINFO_VME_PROT_EXEC 0x00000004
|
|
|
|
|
|
|
|
/* Flags in the 'kve_flags' field in struct kinfo_vmentry. These
|
|
|
|
match the KVME_FLAG_* constants in <sys/user.h>. */
|
|
|
|
|
|
|
|
#define KINFO_VME_FLAG_COW 0x00000001
|
|
|
|
#define KINFO_VME_FLAG_NEEDS_COPY 0x00000002
|
|
|
|
#define KINFO_VME_FLAG_NOCOREDUMP 0x00000004
|
|
|
|
#define KINFO_VME_FLAG_SUPER 0x00000008
|
|
|
|
#define KINFO_VME_FLAG_GROWS_UP 0x00000010
|
|
|
|
#define KINFO_VME_FLAG_GROWS_DOWN 0x00000020
|
|
|
|
|
|
|
|
/* Offsets in data structure used in NT_FREEBSD_PROCSTAT_FILES core
|
|
|
|
dump notes. See <sys/user.h> for the definition of struct
|
|
|
|
kinfo_file. This data structure should have the same layout on all
|
Add support for 'info proc files' on FreeBSD core dumps.
Walk the list of struct kinfo_file objects in the
NT_FREEBSD_PROCSTAT_FILES core dump note outputting a description of
each open file descriptor. For sockets, the local and remote socket
addresses are displayed in place of the file name field. For UNIX
local domain sockets, only a single address is displayed since most
UNIX sockets only have one valid address and printing both pathnames
could be quite long. The output format was somewhat inspired by the
output of the "procstat -f" command on FreeBSD, but with a few less
details and some fields were condensed.
gdb/ChangeLog:
* fbsd-tdep.c (KF_FLAGS, KF_OFFSET, KF_VNODE_TYPE, KF_SOCK_DOMAIN)
(KF_SOCK_TYPE, KF_SOCK_PROTOCOL, KF_SA_LOCAL, KF_SA_PEER)
(KINFO_FILE_TYPE_SOCKET, KINFO_FILE_TYPE_PIPE)
(KINFO_FILE_TYPE_FIFO, KINFO_FILE_TYPE_KQUEUE)
(KINFO_FILE_TYPE_CRYPTO, KINFO_FILE_TYPE_MQUEUE)
(KINFO_FILE_TYPE_SHM, KINFO_FILE_TYPE_SEM, KINFO_FILE_TYPE_PTS)
(KINFO_FILE_TYPE_PROCDESC, KINFO_FILE_FD_TYPE_ROOT)
(KINFO_FILE_FD_TYPE_JAIL, KINFO_FILE_FD_TYPE_TRACE)
(KINFO_FILE_FD_TYPE_CTTY, KINFO_FILE_FLAG_READ)
(KINFO_FILE_FLAG_WRITE, KINFO_FILE_FLAG_APPEND)
(KINFO_FILE_FLAG_ASYNC, KINFO_FILE_FLAG_FSYNC)
(KINFO_FILE_FLAG_NONBLOCK, KINFO_FILE_FLAG_DIRECT)
(KINFO_FILE_FLAG_HASLOCK, KINFO_FILE_FLAG_EXEC)
(KINFO_FILE_VTYPE_VREG, KINFO_FILE_VTYPE_VDIR)
(KINFO_FILE_VTYPE_VCHR, KINFO_FILE_VTYPE_VLNK)
(KINFO_FILE_VTYPE_VSOCK, KINFO_FILE_VTYPE_VFIFO, FBSD_AF_UNIX)
(FBSD_AF_INET, FBSD_AF_INET6, FBSD_SOCK_STREAM, FBSD_SOCK_DGRAM)
(FBSD_SOCK_SEQPACKET, FBSD_IPPROTO_ICMP, FBSD_IPPROTO_TCP)
(FBSD_IPPROTO_UDP, FBSD_IPPROTO_SCTP): New defines.
(struct fbsd_sockaddr_in, struct fbsd_sockaddr_in6)
(struct fbsd_sockaddr_un): New types.
(fbsd_file_fd, fbsd_file_type, fbsd_file_flags, fbsd_ipproto)
(fbsd_print_sockaddr_in, fbsd_print_sockaddr_in6)
(fbsd_info_proc_files_header, fbsd_info_proc_files_entry)
(fbsd_core_info_proc_files): New functions.
(fbsd_core_info_proc): List open file descriptors for IP_FILES and
IP_ALL.
* fbsd-tdep.h (fbsd_info_proc_files_header)
(fbsd_info_proc_files_entry): New.
2018-09-18 23:05:47 +02:00
|
|
|
architectures.
|
|
|
|
|
|
|
|
Note that FreeBSD 7.0 used an older version of this structure
|
|
|
|
(struct kinfo_ofile), but the NT_FREEBSD_PROCSTAT_FILES core dump
|
|
|
|
note wasn't introduced until FreeBSD 9.2. As a result, the core
|
|
|
|
dump note has always used the 7.1 and later structure format. */
|
Support 'info proc' for FreeBSD process core dumps.
- Command line arguments are obtained from the pr_psargs[] array
saved in the NT_PRPSINFO note.
- The 'cwd' and 'exe' values are obtained from the per-process file
descriptor table stored in the NT_PROCSTAT_FILES core note.
- 'mappings' is implemented by walking the array of VM map entries
stored in the NT_PROCSTAT_VMMAP core note.
- 'status' output is generated by outputting fields from
the first structure stored in the NT_PROCSTAT_PROC core note.
- 'stat' is aliased to 'status'.
gdb/ChangeLog:
* fbsd-tdep.c (KVE_STRUCTSIZE, KVE_START, KVE_END, KVE_OFFSET)
(KVE_FLAGS, KVE_PROTECTION, KVE_PATH, KINFO_VME_PROT_READ)
(KINFO_VME_PROT_WRITE, KINFO_VME_PROT_EXEC, KINFO_VME_FLAG_COW)
(KINFO_VME_FLAG_NEEDS_COPY, KINFO_VME_FLAG_NOCOREDUMP)
(KINFO_VME_FLAG_SUPER, KINFO_VME_FLAG_GROWS_UP)
(KINFO_VME_FLAG_GROWS_DOWN, KF_STRUCTSIZE, KF_TYPE, KF_FD)
(KF_PATH, KINFO_FILE_TYPE_VNODE, KINFO_FILE_FD_TYPE_CWD)
(KINFO_FILE_FD_TYPE_TEXT, SIG_WORDS, struct kinfo_proc_layout)
(kinfo_proc_layout_32, kinfo_proc_layout_i386)
(kinfo_proc_layout_64, fbsd_vm_map_entry_flags)
(fbsd_core_info_proc_mappings, fbsd_core_vnode_path)
(fbsd_core_fetch_timeval, fbsd_print_sigset)
(fbsd_core_info_proc_status, fbsd_core_info_proc): New.
(fbsd_init_abi): Install gdbarch "core_info_proc" method.
* fbsd-tdep.h (fbsd_vm_map_entry_flags): New.
2018-01-09 22:35:17 +01:00
|
|
|
|
|
|
|
#define KF_STRUCTSIZE 0x0
|
|
|
|
#define KF_TYPE 0x4
|
|
|
|
#define KF_FD 0x8
|
Add support for 'info proc files' on FreeBSD core dumps.
Walk the list of struct kinfo_file objects in the
NT_FREEBSD_PROCSTAT_FILES core dump note outputting a description of
each open file descriptor. For sockets, the local and remote socket
addresses are displayed in place of the file name field. For UNIX
local domain sockets, only a single address is displayed since most
UNIX sockets only have one valid address and printing both pathnames
could be quite long. The output format was somewhat inspired by the
output of the "procstat -f" command on FreeBSD, but with a few less
details and some fields were condensed.
gdb/ChangeLog:
* fbsd-tdep.c (KF_FLAGS, KF_OFFSET, KF_VNODE_TYPE, KF_SOCK_DOMAIN)
(KF_SOCK_TYPE, KF_SOCK_PROTOCOL, KF_SA_LOCAL, KF_SA_PEER)
(KINFO_FILE_TYPE_SOCKET, KINFO_FILE_TYPE_PIPE)
(KINFO_FILE_TYPE_FIFO, KINFO_FILE_TYPE_KQUEUE)
(KINFO_FILE_TYPE_CRYPTO, KINFO_FILE_TYPE_MQUEUE)
(KINFO_FILE_TYPE_SHM, KINFO_FILE_TYPE_SEM, KINFO_FILE_TYPE_PTS)
(KINFO_FILE_TYPE_PROCDESC, KINFO_FILE_FD_TYPE_ROOT)
(KINFO_FILE_FD_TYPE_JAIL, KINFO_FILE_FD_TYPE_TRACE)
(KINFO_FILE_FD_TYPE_CTTY, KINFO_FILE_FLAG_READ)
(KINFO_FILE_FLAG_WRITE, KINFO_FILE_FLAG_APPEND)
(KINFO_FILE_FLAG_ASYNC, KINFO_FILE_FLAG_FSYNC)
(KINFO_FILE_FLAG_NONBLOCK, KINFO_FILE_FLAG_DIRECT)
(KINFO_FILE_FLAG_HASLOCK, KINFO_FILE_FLAG_EXEC)
(KINFO_FILE_VTYPE_VREG, KINFO_FILE_VTYPE_VDIR)
(KINFO_FILE_VTYPE_VCHR, KINFO_FILE_VTYPE_VLNK)
(KINFO_FILE_VTYPE_VSOCK, KINFO_FILE_VTYPE_VFIFO, FBSD_AF_UNIX)
(FBSD_AF_INET, FBSD_AF_INET6, FBSD_SOCK_STREAM, FBSD_SOCK_DGRAM)
(FBSD_SOCK_SEQPACKET, FBSD_IPPROTO_ICMP, FBSD_IPPROTO_TCP)
(FBSD_IPPROTO_UDP, FBSD_IPPROTO_SCTP): New defines.
(struct fbsd_sockaddr_in, struct fbsd_sockaddr_in6)
(struct fbsd_sockaddr_un): New types.
(fbsd_file_fd, fbsd_file_type, fbsd_file_flags, fbsd_ipproto)
(fbsd_print_sockaddr_in, fbsd_print_sockaddr_in6)
(fbsd_info_proc_files_header, fbsd_info_proc_files_entry)
(fbsd_core_info_proc_files): New functions.
(fbsd_core_info_proc): List open file descriptors for IP_FILES and
IP_ALL.
* fbsd-tdep.h (fbsd_info_proc_files_header)
(fbsd_info_proc_files_entry): New.
2018-09-18 23:05:47 +02:00
|
|
|
#define KF_FLAGS 0x10
|
|
|
|
#define KF_OFFSET 0x18
|
|
|
|
#define KF_VNODE_TYPE 0x20
|
|
|
|
#define KF_SOCK_DOMAIN 0x24
|
|
|
|
#define KF_SOCK_TYPE 0x28
|
|
|
|
#define KF_SOCK_PROTOCOL 0x2c
|
|
|
|
#define KF_SA_LOCAL 0x30
|
|
|
|
#define KF_SA_PEER 0xb0
|
Support 'info proc' for FreeBSD process core dumps.
- Command line arguments are obtained from the pr_psargs[] array
saved in the NT_PRPSINFO note.
- The 'cwd' and 'exe' values are obtained from the per-process file
descriptor table stored in the NT_PROCSTAT_FILES core note.
- 'mappings' is implemented by walking the array of VM map entries
stored in the NT_PROCSTAT_VMMAP core note.
- 'status' output is generated by outputting fields from
the first structure stored in the NT_PROCSTAT_PROC core note.
- 'stat' is aliased to 'status'.
gdb/ChangeLog:
* fbsd-tdep.c (KVE_STRUCTSIZE, KVE_START, KVE_END, KVE_OFFSET)
(KVE_FLAGS, KVE_PROTECTION, KVE_PATH, KINFO_VME_PROT_READ)
(KINFO_VME_PROT_WRITE, KINFO_VME_PROT_EXEC, KINFO_VME_FLAG_COW)
(KINFO_VME_FLAG_NEEDS_COPY, KINFO_VME_FLAG_NOCOREDUMP)
(KINFO_VME_FLAG_SUPER, KINFO_VME_FLAG_GROWS_UP)
(KINFO_VME_FLAG_GROWS_DOWN, KF_STRUCTSIZE, KF_TYPE, KF_FD)
(KF_PATH, KINFO_FILE_TYPE_VNODE, KINFO_FILE_FD_TYPE_CWD)
(KINFO_FILE_FD_TYPE_TEXT, SIG_WORDS, struct kinfo_proc_layout)
(kinfo_proc_layout_32, kinfo_proc_layout_i386)
(kinfo_proc_layout_64, fbsd_vm_map_entry_flags)
(fbsd_core_info_proc_mappings, fbsd_core_vnode_path)
(fbsd_core_fetch_timeval, fbsd_print_sigset)
(fbsd_core_info_proc_status, fbsd_core_info_proc): New.
(fbsd_init_abi): Install gdbarch "core_info_proc" method.
* fbsd-tdep.h (fbsd_vm_map_entry_flags): New.
2018-01-09 22:35:17 +01:00
|
|
|
#define KF_PATH 0x170
|
|
|
|
|
|
|
|
/* Constants for the 'kf_type' field in struct kinfo_file. These
|
|
|
|
match the KF_TYPE_* constants in <sys/user.h>. */
|
|
|
|
|
|
|
|
#define KINFO_FILE_TYPE_VNODE 1
|
Add support for 'info proc files' on FreeBSD core dumps.
Walk the list of struct kinfo_file objects in the
NT_FREEBSD_PROCSTAT_FILES core dump note outputting a description of
each open file descriptor. For sockets, the local and remote socket
addresses are displayed in place of the file name field. For UNIX
local domain sockets, only a single address is displayed since most
UNIX sockets only have one valid address and printing both pathnames
could be quite long. The output format was somewhat inspired by the
output of the "procstat -f" command on FreeBSD, but with a few less
details and some fields were condensed.
gdb/ChangeLog:
* fbsd-tdep.c (KF_FLAGS, KF_OFFSET, KF_VNODE_TYPE, KF_SOCK_DOMAIN)
(KF_SOCK_TYPE, KF_SOCK_PROTOCOL, KF_SA_LOCAL, KF_SA_PEER)
(KINFO_FILE_TYPE_SOCKET, KINFO_FILE_TYPE_PIPE)
(KINFO_FILE_TYPE_FIFO, KINFO_FILE_TYPE_KQUEUE)
(KINFO_FILE_TYPE_CRYPTO, KINFO_FILE_TYPE_MQUEUE)
(KINFO_FILE_TYPE_SHM, KINFO_FILE_TYPE_SEM, KINFO_FILE_TYPE_PTS)
(KINFO_FILE_TYPE_PROCDESC, KINFO_FILE_FD_TYPE_ROOT)
(KINFO_FILE_FD_TYPE_JAIL, KINFO_FILE_FD_TYPE_TRACE)
(KINFO_FILE_FD_TYPE_CTTY, KINFO_FILE_FLAG_READ)
(KINFO_FILE_FLAG_WRITE, KINFO_FILE_FLAG_APPEND)
(KINFO_FILE_FLAG_ASYNC, KINFO_FILE_FLAG_FSYNC)
(KINFO_FILE_FLAG_NONBLOCK, KINFO_FILE_FLAG_DIRECT)
(KINFO_FILE_FLAG_HASLOCK, KINFO_FILE_FLAG_EXEC)
(KINFO_FILE_VTYPE_VREG, KINFO_FILE_VTYPE_VDIR)
(KINFO_FILE_VTYPE_VCHR, KINFO_FILE_VTYPE_VLNK)
(KINFO_FILE_VTYPE_VSOCK, KINFO_FILE_VTYPE_VFIFO, FBSD_AF_UNIX)
(FBSD_AF_INET, FBSD_AF_INET6, FBSD_SOCK_STREAM, FBSD_SOCK_DGRAM)
(FBSD_SOCK_SEQPACKET, FBSD_IPPROTO_ICMP, FBSD_IPPROTO_TCP)
(FBSD_IPPROTO_UDP, FBSD_IPPROTO_SCTP): New defines.
(struct fbsd_sockaddr_in, struct fbsd_sockaddr_in6)
(struct fbsd_sockaddr_un): New types.
(fbsd_file_fd, fbsd_file_type, fbsd_file_flags, fbsd_ipproto)
(fbsd_print_sockaddr_in, fbsd_print_sockaddr_in6)
(fbsd_info_proc_files_header, fbsd_info_proc_files_entry)
(fbsd_core_info_proc_files): New functions.
(fbsd_core_info_proc): List open file descriptors for IP_FILES and
IP_ALL.
* fbsd-tdep.h (fbsd_info_proc_files_header)
(fbsd_info_proc_files_entry): New.
2018-09-18 23:05:47 +02:00
|
|
|
#define KINFO_FILE_TYPE_SOCKET 2
|
|
|
|
#define KINFO_FILE_TYPE_PIPE 3
|
|
|
|
#define KINFO_FILE_TYPE_FIFO 4
|
|
|
|
#define KINFO_FILE_TYPE_KQUEUE 5
|
|
|
|
#define KINFO_FILE_TYPE_CRYPTO 6
|
|
|
|
#define KINFO_FILE_TYPE_MQUEUE 7
|
|
|
|
#define KINFO_FILE_TYPE_SHM 8
|
|
|
|
#define KINFO_FILE_TYPE_SEM 9
|
|
|
|
#define KINFO_FILE_TYPE_PTS 10
|
|
|
|
#define KINFO_FILE_TYPE_PROCDESC 11
|
Support 'info proc' for FreeBSD process core dumps.
- Command line arguments are obtained from the pr_psargs[] array
saved in the NT_PRPSINFO note.
- The 'cwd' and 'exe' values are obtained from the per-process file
descriptor table stored in the NT_PROCSTAT_FILES core note.
- 'mappings' is implemented by walking the array of VM map entries
stored in the NT_PROCSTAT_VMMAP core note.
- 'status' output is generated by outputting fields from
the first structure stored in the NT_PROCSTAT_PROC core note.
- 'stat' is aliased to 'status'.
gdb/ChangeLog:
* fbsd-tdep.c (KVE_STRUCTSIZE, KVE_START, KVE_END, KVE_OFFSET)
(KVE_FLAGS, KVE_PROTECTION, KVE_PATH, KINFO_VME_PROT_READ)
(KINFO_VME_PROT_WRITE, KINFO_VME_PROT_EXEC, KINFO_VME_FLAG_COW)
(KINFO_VME_FLAG_NEEDS_COPY, KINFO_VME_FLAG_NOCOREDUMP)
(KINFO_VME_FLAG_SUPER, KINFO_VME_FLAG_GROWS_UP)
(KINFO_VME_FLAG_GROWS_DOWN, KF_STRUCTSIZE, KF_TYPE, KF_FD)
(KF_PATH, KINFO_FILE_TYPE_VNODE, KINFO_FILE_FD_TYPE_CWD)
(KINFO_FILE_FD_TYPE_TEXT, SIG_WORDS, struct kinfo_proc_layout)
(kinfo_proc_layout_32, kinfo_proc_layout_i386)
(kinfo_proc_layout_64, fbsd_vm_map_entry_flags)
(fbsd_core_info_proc_mappings, fbsd_core_vnode_path)
(fbsd_core_fetch_timeval, fbsd_print_sigset)
(fbsd_core_info_proc_status, fbsd_core_info_proc): New.
(fbsd_init_abi): Install gdbarch "core_info_proc" method.
* fbsd-tdep.h (fbsd_vm_map_entry_flags): New.
2018-01-09 22:35:17 +01:00
|
|
|
|
|
|
|
/* Special values for the 'kf_fd' field in struct kinfo_file. These
|
|
|
|
match the KF_FD_TYPE_* constants in <sys/user.h>. */
|
|
|
|
|
|
|
|
#define KINFO_FILE_FD_TYPE_CWD -1
|
Add support for 'info proc files' on FreeBSD core dumps.
Walk the list of struct kinfo_file objects in the
NT_FREEBSD_PROCSTAT_FILES core dump note outputting a description of
each open file descriptor. For sockets, the local and remote socket
addresses are displayed in place of the file name field. For UNIX
local domain sockets, only a single address is displayed since most
UNIX sockets only have one valid address and printing both pathnames
could be quite long. The output format was somewhat inspired by the
output of the "procstat -f" command on FreeBSD, but with a few less
details and some fields were condensed.
gdb/ChangeLog:
* fbsd-tdep.c (KF_FLAGS, KF_OFFSET, KF_VNODE_TYPE, KF_SOCK_DOMAIN)
(KF_SOCK_TYPE, KF_SOCK_PROTOCOL, KF_SA_LOCAL, KF_SA_PEER)
(KINFO_FILE_TYPE_SOCKET, KINFO_FILE_TYPE_PIPE)
(KINFO_FILE_TYPE_FIFO, KINFO_FILE_TYPE_KQUEUE)
(KINFO_FILE_TYPE_CRYPTO, KINFO_FILE_TYPE_MQUEUE)
(KINFO_FILE_TYPE_SHM, KINFO_FILE_TYPE_SEM, KINFO_FILE_TYPE_PTS)
(KINFO_FILE_TYPE_PROCDESC, KINFO_FILE_FD_TYPE_ROOT)
(KINFO_FILE_FD_TYPE_JAIL, KINFO_FILE_FD_TYPE_TRACE)
(KINFO_FILE_FD_TYPE_CTTY, KINFO_FILE_FLAG_READ)
(KINFO_FILE_FLAG_WRITE, KINFO_FILE_FLAG_APPEND)
(KINFO_FILE_FLAG_ASYNC, KINFO_FILE_FLAG_FSYNC)
(KINFO_FILE_FLAG_NONBLOCK, KINFO_FILE_FLAG_DIRECT)
(KINFO_FILE_FLAG_HASLOCK, KINFO_FILE_FLAG_EXEC)
(KINFO_FILE_VTYPE_VREG, KINFO_FILE_VTYPE_VDIR)
(KINFO_FILE_VTYPE_VCHR, KINFO_FILE_VTYPE_VLNK)
(KINFO_FILE_VTYPE_VSOCK, KINFO_FILE_VTYPE_VFIFO, FBSD_AF_UNIX)
(FBSD_AF_INET, FBSD_AF_INET6, FBSD_SOCK_STREAM, FBSD_SOCK_DGRAM)
(FBSD_SOCK_SEQPACKET, FBSD_IPPROTO_ICMP, FBSD_IPPROTO_TCP)
(FBSD_IPPROTO_UDP, FBSD_IPPROTO_SCTP): New defines.
(struct fbsd_sockaddr_in, struct fbsd_sockaddr_in6)
(struct fbsd_sockaddr_un): New types.
(fbsd_file_fd, fbsd_file_type, fbsd_file_flags, fbsd_ipproto)
(fbsd_print_sockaddr_in, fbsd_print_sockaddr_in6)
(fbsd_info_proc_files_header, fbsd_info_proc_files_entry)
(fbsd_core_info_proc_files): New functions.
(fbsd_core_info_proc): List open file descriptors for IP_FILES and
IP_ALL.
* fbsd-tdep.h (fbsd_info_proc_files_header)
(fbsd_info_proc_files_entry): New.
2018-09-18 23:05:47 +02:00
|
|
|
#define KINFO_FILE_FD_TYPE_ROOT -2
|
|
|
|
#define KINFO_FILE_FD_TYPE_JAIL -3
|
|
|
|
#define KINFO_FILE_FD_TYPE_TRACE -4
|
Support 'info proc' for FreeBSD process core dumps.
- Command line arguments are obtained from the pr_psargs[] array
saved in the NT_PRPSINFO note.
- The 'cwd' and 'exe' values are obtained from the per-process file
descriptor table stored in the NT_PROCSTAT_FILES core note.
- 'mappings' is implemented by walking the array of VM map entries
stored in the NT_PROCSTAT_VMMAP core note.
- 'status' output is generated by outputting fields from
the first structure stored in the NT_PROCSTAT_PROC core note.
- 'stat' is aliased to 'status'.
gdb/ChangeLog:
* fbsd-tdep.c (KVE_STRUCTSIZE, KVE_START, KVE_END, KVE_OFFSET)
(KVE_FLAGS, KVE_PROTECTION, KVE_PATH, KINFO_VME_PROT_READ)
(KINFO_VME_PROT_WRITE, KINFO_VME_PROT_EXEC, KINFO_VME_FLAG_COW)
(KINFO_VME_FLAG_NEEDS_COPY, KINFO_VME_FLAG_NOCOREDUMP)
(KINFO_VME_FLAG_SUPER, KINFO_VME_FLAG_GROWS_UP)
(KINFO_VME_FLAG_GROWS_DOWN, KF_STRUCTSIZE, KF_TYPE, KF_FD)
(KF_PATH, KINFO_FILE_TYPE_VNODE, KINFO_FILE_FD_TYPE_CWD)
(KINFO_FILE_FD_TYPE_TEXT, SIG_WORDS, struct kinfo_proc_layout)
(kinfo_proc_layout_32, kinfo_proc_layout_i386)
(kinfo_proc_layout_64, fbsd_vm_map_entry_flags)
(fbsd_core_info_proc_mappings, fbsd_core_vnode_path)
(fbsd_core_fetch_timeval, fbsd_print_sigset)
(fbsd_core_info_proc_status, fbsd_core_info_proc): New.
(fbsd_init_abi): Install gdbarch "core_info_proc" method.
* fbsd-tdep.h (fbsd_vm_map_entry_flags): New.
2018-01-09 22:35:17 +01:00
|
|
|
#define KINFO_FILE_FD_TYPE_TEXT -5
|
Add support for 'info proc files' on FreeBSD core dumps.
Walk the list of struct kinfo_file objects in the
NT_FREEBSD_PROCSTAT_FILES core dump note outputting a description of
each open file descriptor. For sockets, the local and remote socket
addresses are displayed in place of the file name field. For UNIX
local domain sockets, only a single address is displayed since most
UNIX sockets only have one valid address and printing both pathnames
could be quite long. The output format was somewhat inspired by the
output of the "procstat -f" command on FreeBSD, but with a few less
details and some fields were condensed.
gdb/ChangeLog:
* fbsd-tdep.c (KF_FLAGS, KF_OFFSET, KF_VNODE_TYPE, KF_SOCK_DOMAIN)
(KF_SOCK_TYPE, KF_SOCK_PROTOCOL, KF_SA_LOCAL, KF_SA_PEER)
(KINFO_FILE_TYPE_SOCKET, KINFO_FILE_TYPE_PIPE)
(KINFO_FILE_TYPE_FIFO, KINFO_FILE_TYPE_KQUEUE)
(KINFO_FILE_TYPE_CRYPTO, KINFO_FILE_TYPE_MQUEUE)
(KINFO_FILE_TYPE_SHM, KINFO_FILE_TYPE_SEM, KINFO_FILE_TYPE_PTS)
(KINFO_FILE_TYPE_PROCDESC, KINFO_FILE_FD_TYPE_ROOT)
(KINFO_FILE_FD_TYPE_JAIL, KINFO_FILE_FD_TYPE_TRACE)
(KINFO_FILE_FD_TYPE_CTTY, KINFO_FILE_FLAG_READ)
(KINFO_FILE_FLAG_WRITE, KINFO_FILE_FLAG_APPEND)
(KINFO_FILE_FLAG_ASYNC, KINFO_FILE_FLAG_FSYNC)
(KINFO_FILE_FLAG_NONBLOCK, KINFO_FILE_FLAG_DIRECT)
(KINFO_FILE_FLAG_HASLOCK, KINFO_FILE_FLAG_EXEC)
(KINFO_FILE_VTYPE_VREG, KINFO_FILE_VTYPE_VDIR)
(KINFO_FILE_VTYPE_VCHR, KINFO_FILE_VTYPE_VLNK)
(KINFO_FILE_VTYPE_VSOCK, KINFO_FILE_VTYPE_VFIFO, FBSD_AF_UNIX)
(FBSD_AF_INET, FBSD_AF_INET6, FBSD_SOCK_STREAM, FBSD_SOCK_DGRAM)
(FBSD_SOCK_SEQPACKET, FBSD_IPPROTO_ICMP, FBSD_IPPROTO_TCP)
(FBSD_IPPROTO_UDP, FBSD_IPPROTO_SCTP): New defines.
(struct fbsd_sockaddr_in, struct fbsd_sockaddr_in6)
(struct fbsd_sockaddr_un): New types.
(fbsd_file_fd, fbsd_file_type, fbsd_file_flags, fbsd_ipproto)
(fbsd_print_sockaddr_in, fbsd_print_sockaddr_in6)
(fbsd_info_proc_files_header, fbsd_info_proc_files_entry)
(fbsd_core_info_proc_files): New functions.
(fbsd_core_info_proc): List open file descriptors for IP_FILES and
IP_ALL.
* fbsd-tdep.h (fbsd_info_proc_files_header)
(fbsd_info_proc_files_entry): New.
2018-09-18 23:05:47 +02:00
|
|
|
#define KINFO_FILE_FD_TYPE_CTTY -6
|
|
|
|
|
|
|
|
/* Flags in the 'kf_flags' field in struct kinfo_file. These match
|
|
|
|
the KF_FLAG_* constants in <sys/user.h>. */
|
|
|
|
|
|
|
|
#define KINFO_FILE_FLAG_READ 0x00000001
|
|
|
|
#define KINFO_FILE_FLAG_WRITE 0x00000002
|
|
|
|
#define KINFO_FILE_FLAG_APPEND 0x00000004
|
|
|
|
#define KINFO_FILE_FLAG_ASYNC 0x00000008
|
|
|
|
#define KINFO_FILE_FLAG_FSYNC 0x00000010
|
|
|
|
#define KINFO_FILE_FLAG_NONBLOCK 0x00000020
|
|
|
|
#define KINFO_FILE_FLAG_DIRECT 0x00000040
|
|
|
|
#define KINFO_FILE_FLAG_HASLOCK 0x00000080
|
|
|
|
#define KINFO_FILE_FLAG_EXEC 0x00004000
|
|
|
|
|
|
|
|
/* Constants for the 'kf_vnode_type' field in struct kinfo_file.
|
|
|
|
These match the KF_VTYPE_* constants in <sys/user.h>. */
|
|
|
|
|
|
|
|
#define KINFO_FILE_VTYPE_VREG 1
|
|
|
|
#define KINFO_FILE_VTYPE_VDIR 2
|
|
|
|
#define KINFO_FILE_VTYPE_VCHR 4
|
|
|
|
#define KINFO_FILE_VTYPE_VLNK 5
|
|
|
|
#define KINFO_FILE_VTYPE_VSOCK 6
|
|
|
|
#define KINFO_FILE_VTYPE_VFIFO 7
|
|
|
|
|
|
|
|
/* Constants for socket address families. These match AF_* constants
|
|
|
|
in <sys/socket.h>. */
|
|
|
|
|
|
|
|
#define FBSD_AF_UNIX 1
|
|
|
|
#define FBSD_AF_INET 2
|
|
|
|
#define FBSD_AF_INET6 28
|
|
|
|
|
|
|
|
/* Constants for socket types. These match SOCK_* constants in
|
|
|
|
<sys/socket.h>. */
|
|
|
|
|
|
|
|
#define FBSD_SOCK_STREAM 1
|
|
|
|
#define FBSD_SOCK_DGRAM 2
|
|
|
|
#define FBSD_SOCK_SEQPACKET 5
|
|
|
|
|
|
|
|
/* Constants for IP protocols. These match IPPROTO_* constants in
|
|
|
|
<netinet/in.h>. */
|
|
|
|
|
|
|
|
#define FBSD_IPPROTO_ICMP 1
|
|
|
|
#define FBSD_IPPROTO_TCP 6
|
|
|
|
#define FBSD_IPPROTO_UDP 17
|
|
|
|
#define FBSD_IPPROTO_SCTP 132
|
|
|
|
|
|
|
|
/* Socket address structures. These have the same layout on all
|
|
|
|
FreeBSD architectures. In addition, multibyte fields such as IP
|
|
|
|
addresses are always stored in network byte order. */
|
|
|
|
|
|
|
|
struct fbsd_sockaddr_in
|
|
|
|
{
|
|
|
|
uint8_t sin_len;
|
|
|
|
uint8_t sin_family;
|
|
|
|
uint8_t sin_port[2];
|
|
|
|
uint8_t sin_addr[4];
|
|
|
|
char sin_zero[8];
|
|
|
|
};
|
|
|
|
|
|
|
|
struct fbsd_sockaddr_in6
|
|
|
|
{
|
|
|
|
uint8_t sin6_len;
|
|
|
|
uint8_t sin6_family;
|
|
|
|
uint8_t sin6_port[2];
|
|
|
|
uint32_t sin6_flowinfo;
|
|
|
|
uint8_t sin6_addr[16];
|
|
|
|
uint32_t sin6_scope_id;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct fbsd_sockaddr_un
|
|
|
|
{
|
|
|
|
uint8_t sun_len;
|
|
|
|
uint8_t sun_family;
|
|
|
|
char sun_path[104];
|
|
|
|
};
|
Support 'info proc' for FreeBSD process core dumps.
- Command line arguments are obtained from the pr_psargs[] array
saved in the NT_PRPSINFO note.
- The 'cwd' and 'exe' values are obtained from the per-process file
descriptor table stored in the NT_PROCSTAT_FILES core note.
- 'mappings' is implemented by walking the array of VM map entries
stored in the NT_PROCSTAT_VMMAP core note.
- 'status' output is generated by outputting fields from
the first structure stored in the NT_PROCSTAT_PROC core note.
- 'stat' is aliased to 'status'.
gdb/ChangeLog:
* fbsd-tdep.c (KVE_STRUCTSIZE, KVE_START, KVE_END, KVE_OFFSET)
(KVE_FLAGS, KVE_PROTECTION, KVE_PATH, KINFO_VME_PROT_READ)
(KINFO_VME_PROT_WRITE, KINFO_VME_PROT_EXEC, KINFO_VME_FLAG_COW)
(KINFO_VME_FLAG_NEEDS_COPY, KINFO_VME_FLAG_NOCOREDUMP)
(KINFO_VME_FLAG_SUPER, KINFO_VME_FLAG_GROWS_UP)
(KINFO_VME_FLAG_GROWS_DOWN, KF_STRUCTSIZE, KF_TYPE, KF_FD)
(KF_PATH, KINFO_FILE_TYPE_VNODE, KINFO_FILE_FD_TYPE_CWD)
(KINFO_FILE_FD_TYPE_TEXT, SIG_WORDS, struct kinfo_proc_layout)
(kinfo_proc_layout_32, kinfo_proc_layout_i386)
(kinfo_proc_layout_64, fbsd_vm_map_entry_flags)
(fbsd_core_info_proc_mappings, fbsd_core_vnode_path)
(fbsd_core_fetch_timeval, fbsd_print_sigset)
(fbsd_core_info_proc_status, fbsd_core_info_proc): New.
(fbsd_init_abi): Install gdbarch "core_info_proc" method.
* fbsd-tdep.h (fbsd_vm_map_entry_flags): New.
2018-01-09 22:35:17 +01:00
|
|
|
|
|
|
|
/* Number of 32-bit words in a signal set. This matches _SIG_WORDS in
|
|
|
|
<sys/_sigset.h> and is the same value on all architectures. */
|
|
|
|
|
|
|
|
#define SIG_WORDS 4
|
|
|
|
|
|
|
|
/* Offsets in data structure used in NT_FREEBSD_PROCSTAT_PROC core
|
|
|
|
dump notes. See <sys/user.h> for the definition of struct
|
|
|
|
kinfo_proc. This data structure has different layouts on different
|
|
|
|
architectures mostly due to ILP32 vs LP64. However, FreeBSD/i386
|
|
|
|
uses a 32-bit time_t while all other architectures use a 64-bit
|
|
|
|
time_t.
|
|
|
|
|
|
|
|
The core dump note actually contains one kinfo_proc structure for
|
|
|
|
each thread, but all of the process-wide data can be obtained from
|
|
|
|
the first structure. One result of this note's format is that some
|
|
|
|
of the process-wide status available in the native target method
|
|
|
|
from the kern.proc.pid.<pid> sysctl such as ki_stat and ki_siglist
|
|
|
|
is not available from a core dump. Instead, the per-thread data
|
|
|
|
structures contain the value of these fields for individual
|
|
|
|
threads. */
|
|
|
|
|
|
|
|
struct kinfo_proc_layout
|
|
|
|
{
|
|
|
|
/* Offsets of struct kinfo_proc members. */
|
|
|
|
int ki_layout;
|
|
|
|
int ki_pid;
|
|
|
|
int ki_ppid;
|
|
|
|
int ki_pgid;
|
|
|
|
int ki_tpgid;
|
|
|
|
int ki_sid;
|
|
|
|
int ki_tdev_freebsd11;
|
|
|
|
int ki_sigignore;
|
|
|
|
int ki_sigcatch;
|
|
|
|
int ki_uid;
|
|
|
|
int ki_ruid;
|
|
|
|
int ki_svuid;
|
|
|
|
int ki_rgid;
|
|
|
|
int ki_svgid;
|
|
|
|
int ki_ngroups;
|
|
|
|
int ki_groups;
|
|
|
|
int ki_size;
|
|
|
|
int ki_rssize;
|
|
|
|
int ki_tsize;
|
|
|
|
int ki_dsize;
|
|
|
|
int ki_ssize;
|
|
|
|
int ki_start;
|
|
|
|
int ki_nice;
|
|
|
|
int ki_comm;
|
|
|
|
int ki_tdev;
|
|
|
|
int ki_rusage;
|
|
|
|
int ki_rusage_ch;
|
|
|
|
|
|
|
|
/* Offsets of struct rusage members. */
|
|
|
|
int ru_utime;
|
|
|
|
int ru_stime;
|
|
|
|
int ru_maxrss;
|
|
|
|
int ru_minflt;
|
|
|
|
int ru_majflt;
|
|
|
|
};
|
|
|
|
|
|
|
|
const struct kinfo_proc_layout kinfo_proc_layout_32 =
|
|
|
|
{
|
|
|
|
.ki_layout = 0x4,
|
|
|
|
.ki_pid = 0x28,
|
|
|
|
.ki_ppid = 0x2c,
|
|
|
|
.ki_pgid = 0x30,
|
|
|
|
.ki_tpgid = 0x34,
|
|
|
|
.ki_sid = 0x38,
|
|
|
|
.ki_tdev_freebsd11 = 0x44,
|
|
|
|
.ki_sigignore = 0x68,
|
|
|
|
.ki_sigcatch = 0x78,
|
|
|
|
.ki_uid = 0x88,
|
|
|
|
.ki_ruid = 0x8c,
|
|
|
|
.ki_svuid = 0x90,
|
|
|
|
.ki_rgid = 0x94,
|
|
|
|
.ki_svgid = 0x98,
|
|
|
|
.ki_ngroups = 0x9c,
|
|
|
|
.ki_groups = 0xa0,
|
|
|
|
.ki_size = 0xe0,
|
|
|
|
.ki_rssize = 0xe4,
|
|
|
|
.ki_tsize = 0xec,
|
|
|
|
.ki_dsize = 0xf0,
|
|
|
|
.ki_ssize = 0xf4,
|
|
|
|
.ki_start = 0x118,
|
|
|
|
.ki_nice = 0x145,
|
|
|
|
.ki_comm = 0x17f,
|
|
|
|
.ki_tdev = 0x1f0,
|
|
|
|
.ki_rusage = 0x220,
|
|
|
|
.ki_rusage_ch = 0x278,
|
|
|
|
|
|
|
|
.ru_utime = 0x0,
|
|
|
|
.ru_stime = 0x10,
|
|
|
|
.ru_maxrss = 0x20,
|
|
|
|
.ru_minflt = 0x30,
|
|
|
|
.ru_majflt = 0x34,
|
|
|
|
};
|
|
|
|
|
|
|
|
const struct kinfo_proc_layout kinfo_proc_layout_i386 =
|
|
|
|
{
|
|
|
|
.ki_layout = 0x4,
|
|
|
|
.ki_pid = 0x28,
|
|
|
|
.ki_ppid = 0x2c,
|
|
|
|
.ki_pgid = 0x30,
|
|
|
|
.ki_tpgid = 0x34,
|
|
|
|
.ki_sid = 0x38,
|
|
|
|
.ki_tdev_freebsd11 = 0x44,
|
|
|
|
.ki_sigignore = 0x68,
|
|
|
|
.ki_sigcatch = 0x78,
|
|
|
|
.ki_uid = 0x88,
|
|
|
|
.ki_ruid = 0x8c,
|
|
|
|
.ki_svuid = 0x90,
|
|
|
|
.ki_rgid = 0x94,
|
|
|
|
.ki_svgid = 0x98,
|
|
|
|
.ki_ngroups = 0x9c,
|
|
|
|
.ki_groups = 0xa0,
|
|
|
|
.ki_size = 0xe0,
|
|
|
|
.ki_rssize = 0xe4,
|
|
|
|
.ki_tsize = 0xec,
|
|
|
|
.ki_dsize = 0xf0,
|
|
|
|
.ki_ssize = 0xf4,
|
|
|
|
.ki_start = 0x118,
|
|
|
|
.ki_nice = 0x135,
|
|
|
|
.ki_comm = 0x16f,
|
|
|
|
.ki_tdev = 0x1e0,
|
|
|
|
.ki_rusage = 0x210,
|
|
|
|
.ki_rusage_ch = 0x258,
|
|
|
|
|
|
|
|
.ru_utime = 0x0,
|
|
|
|
.ru_stime = 0x8,
|
|
|
|
.ru_maxrss = 0x10,
|
|
|
|
.ru_minflt = 0x20,
|
|
|
|
.ru_majflt = 0x24,
|
|
|
|
};
|
|
|
|
|
|
|
|
const struct kinfo_proc_layout kinfo_proc_layout_64 =
|
|
|
|
{
|
|
|
|
.ki_layout = 0x4,
|
|
|
|
.ki_pid = 0x48,
|
|
|
|
.ki_ppid = 0x4c,
|
|
|
|
.ki_pgid = 0x50,
|
|
|
|
.ki_tpgid = 0x54,
|
|
|
|
.ki_sid = 0x58,
|
|
|
|
.ki_tdev_freebsd11 = 0x64,
|
|
|
|
.ki_sigignore = 0x88,
|
|
|
|
.ki_sigcatch = 0x98,
|
|
|
|
.ki_uid = 0xa8,
|
|
|
|
.ki_ruid = 0xac,
|
|
|
|
.ki_svuid = 0xb0,
|
|
|
|
.ki_rgid = 0xb4,
|
|
|
|
.ki_svgid = 0xb8,
|
|
|
|
.ki_ngroups = 0xbc,
|
|
|
|
.ki_groups = 0xc0,
|
|
|
|
.ki_size = 0x100,
|
|
|
|
.ki_rssize = 0x108,
|
|
|
|
.ki_tsize = 0x118,
|
|
|
|
.ki_dsize = 0x120,
|
|
|
|
.ki_ssize = 0x128,
|
|
|
|
.ki_start = 0x150,
|
|
|
|
.ki_nice = 0x185,
|
|
|
|
.ki_comm = 0x1bf,
|
|
|
|
.ki_tdev = 0x230,
|
|
|
|
.ki_rusage = 0x260,
|
|
|
|
.ki_rusage_ch = 0x2f0,
|
|
|
|
|
|
|
|
.ru_utime = 0x0,
|
|
|
|
.ru_stime = 0x10,
|
|
|
|
.ru_maxrss = 0x20,
|
|
|
|
.ru_minflt = 0x40,
|
|
|
|
.ru_majflt = 0x48,
|
|
|
|
};
|
|
|
|
|
2017-06-28 17:14:06 +02:00
|
|
|
static struct gdbarch_data *fbsd_gdbarch_data_handle;
|
|
|
|
|
|
|
|
struct fbsd_gdbarch_data
|
|
|
|
{
|
|
|
|
struct type *siginfo_type;
|
|
|
|
};
|
|
|
|
|
|
|
|
static void *
|
|
|
|
init_fbsd_gdbarch_data (struct gdbarch *gdbarch)
|
|
|
|
{
|
|
|
|
return GDBARCH_OBSTACK_ZALLOC (gdbarch, struct fbsd_gdbarch_data);
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct fbsd_gdbarch_data *
|
|
|
|
get_fbsd_gdbarch_data (struct gdbarch *gdbarch)
|
|
|
|
{
|
|
|
|
return ((struct fbsd_gdbarch_data *)
|
|
|
|
gdbarch_data (gdbarch, fbsd_gdbarch_data_handle));
|
|
|
|
}
|
|
|
|
|
2019-03-12 21:39:02 +01:00
|
|
|
/* Per-program-space data for FreeBSD architectures. */
|
|
|
|
static const struct program_space_data *fbsd_pspace_data_handle;
|
|
|
|
|
|
|
|
struct fbsd_pspace_data
|
|
|
|
{
|
|
|
|
/* Offsets in the runtime linker's 'Obj_Entry' structure. */
|
|
|
|
LONGEST off_linkmap;
|
|
|
|
LONGEST off_tlsindex;
|
|
|
|
bool rtld_offsets_valid;
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct fbsd_pspace_data *
|
|
|
|
get_fbsd_pspace_data (struct program_space *pspace)
|
|
|
|
{
|
|
|
|
struct fbsd_pspace_data *data;
|
|
|
|
|
|
|
|
data = ((struct fbsd_pspace_data *)
|
|
|
|
program_space_data (pspace, fbsd_pspace_data_handle));
|
|
|
|
if (data == NULL)
|
|
|
|
{
|
|
|
|
data = XCNEW (struct fbsd_pspace_data);
|
|
|
|
set_program_space_data (pspace, fbsd_pspace_data_handle, data);
|
|
|
|
}
|
|
|
|
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* The cleanup callback for FreeBSD architecture per-program-space data. */
|
|
|
|
|
|
|
|
static void
|
|
|
|
fbsd_pspace_data_cleanup (struct program_space *pspace, void *data)
|
|
|
|
{
|
|
|
|
xfree (data);
|
|
|
|
}
|
|
|
|
|
2015-12-14 06:49:52 +01:00
|
|
|
/* This is how we want PTIDs from core files to be printed. */
|
|
|
|
|
2017-04-05 20:21:34 +02:00
|
|
|
static const char *
|
2015-12-14 06:49:52 +01:00
|
|
|
fbsd_core_pid_to_str (struct gdbarch *gdbarch, ptid_t ptid)
|
|
|
|
{
|
|
|
|
static char buf[80];
|
|
|
|
|
2018-06-11 20:10:09 +02:00
|
|
|
if (ptid.lwp () != 0)
|
2015-12-14 06:49:52 +01:00
|
|
|
{
|
2018-06-11 20:10:09 +02:00
|
|
|
xsnprintf (buf, sizeof buf, "LWP %ld", ptid.lwp ());
|
2015-12-14 06:49:52 +01:00
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
return normal_pid_to_str (ptid);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Extract the name assigned to a thread from a core. Returns the
|
|
|
|
string in a static buffer. */
|
|
|
|
|
|
|
|
static const char *
|
|
|
|
fbsd_core_thread_name (struct gdbarch *gdbarch, struct thread_info *thr)
|
|
|
|
{
|
|
|
|
static char buf[80];
|
|
|
|
struct bfd_section *section;
|
|
|
|
bfd_size_type size;
|
|
|
|
|
2018-06-11 20:10:09 +02:00
|
|
|
if (thr->ptid.lwp () != 0)
|
2015-12-14 06:49:52 +01:00
|
|
|
{
|
|
|
|
/* FreeBSD includes a NT_FREEBSD_THRMISC note for each thread
|
|
|
|
whose contents are defined by a "struct thrmisc" declared in
|
|
|
|
<sys/procfs.h> on FreeBSD. The per-thread name is stored as
|
|
|
|
a null-terminated string as the first member of the
|
|
|
|
structure. Rather than define the full structure here, just
|
|
|
|
extract the null-terminated name from the start of the
|
|
|
|
note. */
|
2017-06-28 20:21:10 +02:00
|
|
|
thread_section_name section_name (".thrmisc", thr->ptid);
|
|
|
|
|
|
|
|
section = bfd_get_section_by_name (core_bfd, section_name.c_str ());
|
2015-12-14 06:49:52 +01:00
|
|
|
if (section != NULL && bfd_section_size (core_bfd, section) > 0)
|
|
|
|
{
|
|
|
|
/* Truncate the name if it is longer than "buf". */
|
|
|
|
size = bfd_section_size (core_bfd, section);
|
|
|
|
if (size > sizeof buf - 1)
|
|
|
|
size = sizeof buf - 1;
|
|
|
|
if (bfd_get_section_contents (core_bfd, section, buf, (file_ptr) 0,
|
|
|
|
size)
|
|
|
|
&& buf[0] != '\0')
|
|
|
|
{
|
|
|
|
buf[size] = '\0';
|
|
|
|
|
|
|
|
/* Note that each thread will report the process command
|
|
|
|
as its thread name instead of an empty name if a name
|
|
|
|
has not been set explicitly. Return a NULL name in
|
|
|
|
that case. */
|
|
|
|
if (strcmp (buf, elf_tdata (core_bfd)->core->program) != 0)
|
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2017-06-28 21:50:56 +02:00
|
|
|
/* Implement the "core_xfer_siginfo" gdbarch method. */
|
|
|
|
|
|
|
|
static LONGEST
|
|
|
|
fbsd_core_xfer_siginfo (struct gdbarch *gdbarch, gdb_byte *readbuf,
|
|
|
|
ULONGEST offset, ULONGEST len)
|
|
|
|
{
|
|
|
|
size_t siginfo_size;
|
|
|
|
|
2017-10-09 18:54:42 +02:00
|
|
|
if (gdbarch_long_bit (gdbarch) == 32)
|
2017-06-28 21:50:56 +02:00
|
|
|
siginfo_size = SIZE32_SIGINFO_T;
|
|
|
|
else
|
|
|
|
siginfo_size = SIZE64_SIGINFO_T;
|
|
|
|
if (offset > siginfo_size)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
thread_section_name section_name (".note.freebsdcore.lwpinfo", inferior_ptid);
|
|
|
|
asection *section = bfd_get_section_by_name (core_bfd, section_name.c_str ());
|
|
|
|
if (section == NULL)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
gdb_byte buf[4];
|
|
|
|
if (!bfd_get_section_contents (core_bfd, section, buf,
|
|
|
|
LWPINFO_OFFSET + LWPINFO_PL_FLAGS, 4))
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
int pl_flags = extract_signed_integer (buf, 4, gdbarch_byte_order (gdbarch));
|
|
|
|
if (!(pl_flags & PL_FLAG_SI))
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (offset + len > siginfo_size)
|
|
|
|
len = siginfo_size - offset;
|
|
|
|
|
|
|
|
ULONGEST siginfo_offset;
|
2017-10-09 18:54:42 +02:00
|
|
|
if (gdbarch_long_bit (gdbarch) == 32)
|
2017-06-28 21:50:56 +02:00
|
|
|
siginfo_offset = LWPINFO_OFFSET + LWPINFO32_PL_SIGINFO;
|
|
|
|
else
|
|
|
|
siginfo_offset = LWPINFO_OFFSET + LWPINFO64_PL_SIGINFO;
|
|
|
|
|
|
|
|
if (!bfd_get_section_contents (core_bfd, section, readbuf,
|
|
|
|
siginfo_offset + offset, len))
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
return len;
|
|
|
|
}
|
|
|
|
|
2013-12-03 12:35:35 +01:00
|
|
|
static int
|
|
|
|
find_signalled_thread (struct thread_info *info, void *data)
|
|
|
|
{
|
|
|
|
if (info->suspend.stop_signal != GDB_SIGNAL_0
|
2018-06-11 20:05:27 +02:00
|
|
|
&& info->ptid.pid () == inferior_ptid.pid ())
|
2013-12-03 12:35:35 +01:00
|
|
|
return 1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-12-22 01:34:15 +01:00
|
|
|
/* Structure for passing information from
|
|
|
|
fbsd_collect_thread_registers via an iterator to
|
|
|
|
fbsd_collect_regset_section_cb. */
|
2013-12-03 12:35:35 +01:00
|
|
|
|
|
|
|
struct fbsd_collect_regset_section_cb_data
|
|
|
|
{
|
|
|
|
const struct regcache *regcache;
|
|
|
|
bfd *obfd;
|
|
|
|
char *note_data;
|
|
|
|
int *note_size;
|
2015-12-22 01:34:15 +01:00
|
|
|
unsigned long lwp;
|
|
|
|
enum gdb_signal stop_signal;
|
|
|
|
int abort_iteration;
|
2013-12-03 12:35:35 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
2018-08-13 11:04:11 +02:00
|
|
|
fbsd_collect_regset_section_cb (const char *sect_name, int supply_size,
|
|
|
|
int collect_size, const struct regset *regset,
|
2013-12-03 12:35:35 +01:00
|
|
|
const char *human_name, void *cb_data)
|
|
|
|
{
|
|
|
|
char *buf;
|
2015-10-09 15:41:30 +02:00
|
|
|
struct fbsd_collect_regset_section_cb_data *data
|
|
|
|
= (struct fbsd_collect_regset_section_cb_data *) cb_data;
|
2013-12-03 12:35:35 +01:00
|
|
|
|
2015-12-22 01:34:15 +01:00
|
|
|
if (data->abort_iteration)
|
|
|
|
return;
|
|
|
|
|
2013-12-03 12:35:35 +01:00
|
|
|
gdb_assert (regset->collect_regset);
|
|
|
|
|
2018-08-13 11:04:11 +02:00
|
|
|
buf = (char *) xmalloc (collect_size);
|
|
|
|
regset->collect_regset (regset, data->regcache, -1, buf, collect_size);
|
2013-12-03 12:35:35 +01:00
|
|
|
|
|
|
|
/* PRSTATUS still needs to be treated specially. */
|
|
|
|
if (strcmp (sect_name, ".reg") == 0)
|
|
|
|
data->note_data = (char *) elfcore_write_prstatus
|
2015-12-22 01:34:15 +01:00
|
|
|
(data->obfd, data->note_data, data->note_size, data->lwp,
|
|
|
|
gdb_signal_to_host (data->stop_signal), buf);
|
2013-12-03 12:35:35 +01:00
|
|
|
else
|
|
|
|
data->note_data = (char *) elfcore_write_register_note
|
|
|
|
(data->obfd, data->note_data, data->note_size,
|
2018-08-13 11:04:11 +02:00
|
|
|
sect_name, buf, collect_size);
|
2013-12-03 12:35:35 +01:00
|
|
|
xfree (buf);
|
2015-12-22 01:34:15 +01:00
|
|
|
|
|
|
|
if (data->note_data == NULL)
|
|
|
|
data->abort_iteration = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Records the thread's register state for the corefile note
|
|
|
|
section. */
|
|
|
|
|
|
|
|
static char *
|
|
|
|
fbsd_collect_thread_registers (const struct regcache *regcache,
|
|
|
|
ptid_t ptid, bfd *obfd,
|
|
|
|
char *note_data, int *note_size,
|
|
|
|
enum gdb_signal stop_signal)
|
|
|
|
{
|
2017-10-25 17:37:03 +02:00
|
|
|
struct gdbarch *gdbarch = regcache->arch ();
|
2015-12-22 01:34:15 +01:00
|
|
|
struct fbsd_collect_regset_section_cb_data data;
|
|
|
|
|
|
|
|
data.regcache = regcache;
|
|
|
|
data.obfd = obfd;
|
|
|
|
data.note_data = note_data;
|
|
|
|
data.note_size = note_size;
|
|
|
|
data.stop_signal = stop_signal;
|
|
|
|
data.abort_iteration = 0;
|
2018-06-11 20:10:09 +02:00
|
|
|
data.lwp = ptid.lwp ();
|
2015-12-22 01:34:15 +01:00
|
|
|
|
|
|
|
gdbarch_iterate_over_regset_sections (gdbarch,
|
|
|
|
fbsd_collect_regset_section_cb,
|
|
|
|
&data, regcache);
|
|
|
|
return data.note_data;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct fbsd_corefile_thread_data
|
|
|
|
{
|
|
|
|
struct gdbarch *gdbarch;
|
|
|
|
bfd *obfd;
|
|
|
|
char *note_data;
|
|
|
|
int *note_size;
|
|
|
|
enum gdb_signal stop_signal;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Records the thread's register state for the corefile note
|
|
|
|
section. */
|
|
|
|
|
|
|
|
static void
|
|
|
|
fbsd_corefile_thread (struct thread_info *info,
|
|
|
|
struct fbsd_corefile_thread_data *args)
|
|
|
|
{
|
|
|
|
struct regcache *regcache;
|
|
|
|
|
|
|
|
regcache = get_thread_arch_regcache (info->ptid, args->gdbarch);
|
|
|
|
|
|
|
|
target_fetch_registers (regcache, -1);
|
|
|
|
|
|
|
|
args->note_data = fbsd_collect_thread_registers
|
|
|
|
(regcache, info->ptid, args->obfd, args->note_data,
|
|
|
|
args->note_size, args->stop_signal);
|
2013-12-03 12:35:35 +01:00
|
|
|
}
|
|
|
|
|
2018-09-07 00:03:19 +02:00
|
|
|
/* Return a byte_vector containing the contents of a core dump note
|
|
|
|
for the target object of type OBJECT. If STRUCTSIZE is non-zero,
|
|
|
|
the data is prefixed with a 32-bit integer size to match the format
|
|
|
|
used in FreeBSD NT_PROCSTAT_* notes. */
|
|
|
|
|
|
|
|
static gdb::optional<gdb::byte_vector>
|
|
|
|
fbsd_make_note_desc (enum target_object object, uint32_t structsize)
|
|
|
|
{
|
|
|
|
gdb::optional<gdb::byte_vector> buf =
|
|
|
|
target_read_alloc (current_top_target (), object, NULL);
|
|
|
|
if (!buf || buf->empty ())
|
|
|
|
return {};
|
|
|
|
|
|
|
|
if (structsize == 0)
|
|
|
|
return buf;
|
|
|
|
|
|
|
|
gdb::byte_vector desc (sizeof (structsize) + buf->size ());
|
|
|
|
memcpy (desc.data (), &structsize, sizeof (structsize));
|
|
|
|
memcpy (desc.data () + sizeof (structsize), buf->data (), buf->size ());
|
|
|
|
return desc;
|
|
|
|
}
|
|
|
|
|
2013-12-03 12:35:35 +01:00
|
|
|
/* Create appropriate note sections for a corefile, returning them in
|
|
|
|
allocated memory. */
|
|
|
|
|
|
|
|
static char *
|
|
|
|
fbsd_make_corefile_notes (struct gdbarch *gdbarch, bfd *obfd, int *note_size)
|
|
|
|
{
|
2015-12-22 01:34:15 +01:00
|
|
|
struct fbsd_corefile_thread_data thread_args;
|
|
|
|
char *note_data = NULL;
|
2013-12-03 12:35:35 +01:00
|
|
|
Elf_Internal_Ehdr *i_ehdrp;
|
Per-inferior thread list, thread ranges/iterators, down with ALL_THREADS, etc.
As preparation for multi-target, this patch makes each inferior have
its own thread list.
This isn't absolutely necessary for multi-target, but simplifies
things. It originally stemmed from the desire to eliminate the
init_thread_list calls sprinkled around, plus it makes it more
efficient to iterate over threads of a given inferior (no need to
always iterate over threads of all inferiors).
We still need to iterate over threads of all inferiors in a number of
places, which means we'd need adjust the ALL_THREADS /
ALL_NON_EXITED_THREADS macros. However, naively tweaking those macros
to have an extra for loop, like:
#define ALL_THREADS (thr, inf) \
for (inf = inferior_list; inf; inf = inf->next) \
for (thr = inf->thread_list; thr; thr = thr->next)
causes problems with code that does "break" or "continue" within the
ALL_THREADS loop body. Plus, we need to declare the extra "inf" local
variable in order to pass it as temporary variable to ALL_THREADS
(etc.)
It gets even trickier when we consider extending the macros to filter
out threads matching a ptid_t and a target. The macros become tricker
to read/write. Been there.
An alternative (which was my next attempt), is to replace the
ALL_THREADS etc. iteration style with for_each_all_threads,
for_each_non_exited_threads, etc. functions which would take a
callback as parameter, which would usually be passed a lambda.
However, I did not find that satisfactory at all, because the
resulting code ends up a little less natural / more noisy to read,
write and debug/step-through (due to use of lambdas), and in many
places where we use "continue;" to skip to the next thread now need to
use "return;". (I ran into hard to debug bugs caused by a
continue/return confusion.)
I.e., before:
ALL_NON_EXITED_THREADS (tp)
{
if (tp->not_what_I_want)
continue;
// do something
}
would turn into:
for_each_non_exited_thread ([&] (thread_info *tp)
{
if (tp->not_what_I_want)
return;
// do something
});
Lastly, the solution I settled with was to replace the ALL_THREADS /
ALL_NON_EXITED_THREADS / ALL_INFERIORS macros with (C++20-like) ranges
and iterators, such that you can instead naturaly iterate over
threads/inferiors using range-for, like e.g,.:
// all threads, including THREAD_EXITED threads.
for (thread_info *tp : all_threads ())
{ .... }
// all non-exited threads.
for (thread_info *tp : all_non_exited_threads ())
{ .... }
// all non-exited threads of INF inferior.
for (thread_info *tp : inf->non_exited_threads ())
{ .... }
The all_non_exited_threads() function takes an optional filter ptid_t as
parameter, which is quite convenient when we need to iterate over
threads matching that filter. See e.g., how the
set_executing/set_stop_requested/finish_thread_state etc. functions in
thread.c end up being simplified.
Most of the patch thus is about adding the infrustructure for allowing
the above. Later on when we get to actual multi-target, these
functions/ranges/iterators will gain a "target_ops *" parameter so
that e.g., we can iterate over all threads of a given target that
match a given filter ptid_t.
The only entry points users needs to be aware of are the
all_threads/all_non_exited_threads etc. functions seen above. Thus,
those functions are declared in gdbthread.h/inferior.h. The actual
iterators/ranges are mainly "internals" and thus are put out of view
in the new thread-iter.h/thread-iter.c/inferior-iter.h files. That
keeps the gdbthread.h/inferior.h headers quite a bit more readable.
A common/safe-iterator.h header is added which adds a template that
can be used to build "safe" iterators, which are forward iterators
that can be used to replace the ALL_THREADS_SAFE macro and other
instances of the same idiom in future.
There's a little bit of shuffling of code between
gdbthread.h/thread.c/inferior.h in the patch. That is necessary in
order to avoid circular dependencies between the
gdbthread.h/inferior.h headers.
As for the init_thread_list calls sprinkled around, they're all
eliminated by this patch, and a new, central call is added to
inferior_appeared. Note how also related to that, there's a call to
init_wait_for_inferior in remote.c that is eliminated.
init_wait_for_inferior is currently responsible for discarding skipped
inline frames, which had to be moved elsewhere. Given that nowadays
we always have a thread even for single-threaded processes, the
natural place is to delete a frame's inline frame info when we delete
the thread. I.e., from clear_thread_inferior_resources.
gdb/ChangeLog:
2018-11-22 Pedro Alves <palves@redhat.com>
* Makefile.in (COMMON_SFILES): Add thread-iter.c.
* breakpoint.c (breakpoints_should_be_inserted_now): Replace
ALL_NON_EXITED_THREADS with all_non_exited_threads.
(print_one_breakpoint_location): Replace ALL_INFERIORS with
all_inferiors.
* bsd-kvm.c: Include inferior.h.
* btrace.c (btrace_free_objfile): Replace ALL_NON_EXITED_THREADS
with all_non_exited_threads.
* common/filtered-iterator.h: New.
* common/safe-iterator.h: New.
* corelow.c (core_target_open): Don't call init_thread_list here.
* darwin-nat.c (thread_info_from_private_thread_info): Replace
ALL_THREADS with all_threads.
* fbsd-nat.c (fbsd_nat_target::resume): Replace
ALL_NON_EXITED_THREADS with inf->non_exited_threads.
* fbsd-tdep.c (fbsd_make_corefile_notes): Replace
ALL_NON_EXITED_THREADS with inf->non_exited_threads.
* fork-child.c (postfork_hook): Don't call init_thread_list here.
* gdbarch-selftests.c (register_to_value_test): Adjust.
* gdbthread.h: Don't include "inferior.h" here.
(struct inferior): Forward declare.
(enum step_over_calls_kind): Moved here from inferior.h.
(thread_info::deletable): Definition moved to thread.c.
(find_thread_ptid (inferior *, ptid_t)): Declare.
(ALL_THREADS, ALL_THREADS_BY_INFERIOR, ALL_THREADS_SAFE): Delete.
Include "thread-iter.h".
(all_threads, all_non_exited_threads, all_threads_safe): New.
(any_thread_p): Declare.
(thread_list): Delete.
* infcmd.c (signal_command): Replace ALL_NON_EXITED_THREADS with
all_non_exited_threads.
(proceed_after_attach_callback): Delete.
(proceed_after_attach): Take an inferior pointer instead of an
integer PID. Adjust to use range-for.
(attach_post_wait): Pass down inferior pointer instead of pid.
Use range-for instead of ALL_NON_EXITED_THREADS.
(detach_command): Remove init_thread_list call.
* inferior-iter.h: New.
* inferior.c (struct delete_thread_of_inferior_arg): Delete.
(delete_thread_of_inferior): Delete.
(delete_inferior, exit_inferior_1): Use range-for with
inf->threads_safe() instead of iterate_over_threads.
(inferior_appeared): Call init_thread_list here.
(discard_all_inferiors): Use all_non_exited_inferiors.
(find_inferior_id, find_inferior_pid): Use all_inferiors.
(iterate_over_inferiors): Use all_inferiors_safe.
(have_inferiors, number_of_live_inferiors): Use
all_non_exited_inferiors.
(number_of_inferiors): Use all_inferiors and std::distance.
(print_inferior): Use all_inferiors.
* inferior.h: Include gdbthread.h.
(enum step_over_calls_kind): Moved to gdbthread.h.
(struct inferior) <thread_list>: New field.
<threads, non_exited_threads, threads_safe>: New methods.
(ALL_INFERIORS): Delete.
Include "inferior-iter.h".
(ALL_NON_EXITED_INFERIORS): Delete.
(all_inferiors_safe, all_inferiors, all_non_exited_inferiors): New
functions.
* inflow.c (child_interrupt, child_pass_ctrlc): Replace
ALL_NON_EXITED_THREADS with all_non_exited_threads.
* infrun.c (follow_exec): Use all_threads_safe.
(clear_proceed_status, proceed): Use all_non_exited_threads.
(init_wait_for_inferior): Don't clear inline frame state here.
(infrun_thread_stop_requested, for_each_just_stopped_thread): Use
all_threads instead of ALL_NON_EXITED_THREADS.
(random_pending_event_thread): Use all_non_exited_threads instead
of ALL_NON_EXITED_THREADS. Use a lambda for repeated code.
(clean_up_just_stopped_threads_fsms): Use all_non_exited_threads
instead of ALL_NON_EXITED_THREADS.
(handle_no_resumed): Use all_non_exited_threads instead of
ALL_NON_EXITED_THREADS. Use all_inferiors instead of
ALL_INFERIORS.
(restart_threads, switch_back_to_stepped_thread): Use
all_non_exited_threads instead of ALL_NON_EXITED_THREADS.
* linux-nat.c (check_zombie_leaders): Replace ALL_INFERIORS with
all_inferiors.
(kill_unfollowed_fork_children): Use inf->non_exited_threads
instead of ALL_NON_EXITED_THREADS.
* linux-tdep.c (linux_make_corefile_notes): Use
inf->non_exited_threads instead of ALL_NON_EXITED_THREADS.
* linux-thread-db.c (thread_db_target::update_thread_list):
Replace ALL_INFERIORS with all_inferiors.
(thread_db_target::thread_handle_to_thread_info): Use
inf->non_exited_threads instead of ALL_NON_EXITED_THREADS.
* mi/mi-interp.c (multiple_inferiors_p): New.
(mi_on_resume_1): Simplify using all_non_exited_threads and
multiple_inferiors_p.
* mi/mi-main.c (mi_cmd_thread_list_ids): Use all_non_exited_threads
instead of ALL_NON_EXITED_THREADS.
* nto-procfs.c (nto_procfs_target::open): Don't call
init_thread_list here.
* record-btrace.c (record_btrace_target_open)
(record_btrace_target::stop_recording)
(record_btrace_target::close)
(record_btrace_target::record_is_replaying)
(record_btrace_target::resume, record_btrace_target::wait)
(record_btrace_target::record_stop_replaying): Use
all_non_exited_threads instead of ALL_NON_EXITED_THREADS.
* record-full.c (record_full_wait_1): Use all_non_exited_threads
instead of ALL_NON_EXITED_THREADS.
* regcache.c (cooked_read_test): Remove reference to global
thread_list.
* remote-sim.c (gdbsim_target::create_inferior): Don't call
init_thread_list here.
* remote.c (remote_target::update_thread_list): Use
all_threads_safe instead of ALL_NON_EXITED_THREADS.
(remote_target::process_initial_stop_replies): Replace
ALL_INFERIORS with all_non_exited_inferiors and use
all_non_exited_threads instead of ALL_NON_EXITED_THREADS.
(remote_target::open_1): Don't call init_thread_list here.
(remote_target::append_pending_thread_resumptions)
(remote_target::remote_resume_with_hc): Use all_non_exited_threads
instead of ALL_NON_EXITED_THREADS.
(remote_target::commit_resume)
(remote_target::remove_new_fork_children): Replace ALL_INFERIORS
with all_non_exited_inferiors and use all_non_exited_threads
instead of ALL_NON_EXITED_THREADS.
(remote_target::kill_new_fork_children): Use
all_non_exited_threads instead of ALL_NON_EXITED_THREADS. Remove
init_thread_list and init_wait_for_inferior calls.
(remote_target::remote_btrace_maybe_reopen)
(remote_target::thread_handle_to_thread_info): Use
all_non_exited_threads instead of ALL_NON_EXITED_THREADS.
* target.c (target_terminal::restore_inferior)
(target_terminal_is_ours_kind): Replace ALL_INFERIORS with
all_non_exited_inferiors.
* thread-iter.c: New file.
* thread-iter.h: New file.
* thread.c: Include "inline-frame.h".
(thread_list): Delete.
(clear_thread_inferior_resources): Call clear_inline_frame_state.
(init_thread_list): Use all_threads_safe instead of
ALL_THREADS_SAFE. Adjust to per-inferior thread lists.
(new_thread): Adjust to per-inferior thread lists.
(add_thread_silent): Pass inferior to find_thread_ptid.
(thread_info::deletable): New, moved from the header.
(delete_thread_1): Adjust to per-inferior thread lists.
(find_thread_global_id): Use inf->threads().
(find_thread_ptid): Use find_inferior_ptid and pass inferior to
find_thread_ptid.
(find_thread_ptid(inferior*, ptid_t)): New overload.
(iterate_over_threads): Use all_threads_safe.
(any_thread_p): New.
(thread_count): Use all_threads and std::distance.
(live_threads_count): Use all_non_exited_threads and
std::distance.
(valid_global_thread_id): Use all_threads.
(in_thread_list): Use find_thread_ptid.
(first_thread_of_inferior): Adjust to per-inferior thread lists.
(any_thread_of_inferior, any_live_thread_of_inferior): Use
inf->non_exited_threads().
(prune_threads, delete_exited_threads): Use all_threads_safe.
(thread_change_ptid): Pass inferior pointer to find_thread_ptid.
(set_resumed, set_running): Use all_non_exited_threads.
(is_thread_state, is_stopped, is_exited, is_running)
(is_executing): Delete.
(set_executing, set_stop_requested, finish_thread_state): Use
all_non_exited_threads.
(print_thread_info_1): Use all_inferiors and all_threads.
(thread_apply_all_command): Use all_non_exited_threads.
(thread_find_command): Use all_threads.
(update_threads_executing): Use all_non_exited_threads.
* tid-parse.c (parse_thread_id): Use inf->threads.
* x86-bsd-nat.c (x86bsd_dr_set): Use inf->non_exited_threads ().
2018-11-22 17:09:14 +01:00
|
|
|
struct thread_info *curr_thr, *signalled_thr;
|
2013-12-03 12:35:35 +01:00
|
|
|
|
|
|
|
/* Put a "FreeBSD" label in the ELF header. */
|
|
|
|
i_ehdrp = elf_elfheader (obfd);
|
|
|
|
i_ehdrp->e_ident[EI_OSABI] = ELFOSABI_FREEBSD;
|
|
|
|
|
|
|
|
gdb_assert (gdbarch_iterate_over_regset_sections_p (gdbarch));
|
|
|
|
|
|
|
|
if (get_exec_file (0))
|
|
|
|
{
|
|
|
|
const char *fname = lbasename (get_exec_file (0));
|
|
|
|
char *psargs = xstrdup (fname);
|
|
|
|
|
|
|
|
if (get_inferior_args ())
|
|
|
|
psargs = reconcat (psargs, psargs, " ", get_inferior_args (),
|
|
|
|
(char *) NULL);
|
|
|
|
|
|
|
|
note_data = elfcore_write_prpsinfo (obfd, note_data, note_size,
|
|
|
|
fname, psargs);
|
|
|
|
}
|
|
|
|
|
2015-12-22 01:34:15 +01:00
|
|
|
/* Thread register information. */
|
|
|
|
TRY
|
|
|
|
{
|
|
|
|
update_thread_list ();
|
|
|
|
}
|
|
|
|
CATCH (e, RETURN_MASK_ERROR)
|
|
|
|
{
|
|
|
|
exception_print (gdb_stderr, e);
|
|
|
|
}
|
|
|
|
END_CATCH
|
|
|
|
|
|
|
|
/* Like the kernel, prefer dumping the signalled thread first.
|
|
|
|
"First thread" is what tools use to infer the signalled thread.
|
|
|
|
In case there's more than one signalled thread, prefer the
|
|
|
|
current thread, if it is signalled. */
|
|
|
|
curr_thr = inferior_thread ();
|
|
|
|
if (curr_thr->suspend.stop_signal != GDB_SIGNAL_0)
|
|
|
|
signalled_thr = curr_thr;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
signalled_thr = iterate_over_threads (find_signalled_thread, NULL);
|
|
|
|
if (signalled_thr == NULL)
|
|
|
|
signalled_thr = curr_thr;
|
|
|
|
}
|
|
|
|
|
|
|
|
thread_args.gdbarch = gdbarch;
|
|
|
|
thread_args.obfd = obfd;
|
|
|
|
thread_args.note_data = note_data;
|
|
|
|
thread_args.note_size = note_size;
|
|
|
|
thread_args.stop_signal = signalled_thr->suspend.stop_signal;
|
|
|
|
|
|
|
|
fbsd_corefile_thread (signalled_thr, &thread_args);
|
Per-inferior thread list, thread ranges/iterators, down with ALL_THREADS, etc.
As preparation for multi-target, this patch makes each inferior have
its own thread list.
This isn't absolutely necessary for multi-target, but simplifies
things. It originally stemmed from the desire to eliminate the
init_thread_list calls sprinkled around, plus it makes it more
efficient to iterate over threads of a given inferior (no need to
always iterate over threads of all inferiors).
We still need to iterate over threads of all inferiors in a number of
places, which means we'd need adjust the ALL_THREADS /
ALL_NON_EXITED_THREADS macros. However, naively tweaking those macros
to have an extra for loop, like:
#define ALL_THREADS (thr, inf) \
for (inf = inferior_list; inf; inf = inf->next) \
for (thr = inf->thread_list; thr; thr = thr->next)
causes problems with code that does "break" or "continue" within the
ALL_THREADS loop body. Plus, we need to declare the extra "inf" local
variable in order to pass it as temporary variable to ALL_THREADS
(etc.)
It gets even trickier when we consider extending the macros to filter
out threads matching a ptid_t and a target. The macros become tricker
to read/write. Been there.
An alternative (which was my next attempt), is to replace the
ALL_THREADS etc. iteration style with for_each_all_threads,
for_each_non_exited_threads, etc. functions which would take a
callback as parameter, which would usually be passed a lambda.
However, I did not find that satisfactory at all, because the
resulting code ends up a little less natural / more noisy to read,
write and debug/step-through (due to use of lambdas), and in many
places where we use "continue;" to skip to the next thread now need to
use "return;". (I ran into hard to debug bugs caused by a
continue/return confusion.)
I.e., before:
ALL_NON_EXITED_THREADS (tp)
{
if (tp->not_what_I_want)
continue;
// do something
}
would turn into:
for_each_non_exited_thread ([&] (thread_info *tp)
{
if (tp->not_what_I_want)
return;
// do something
});
Lastly, the solution I settled with was to replace the ALL_THREADS /
ALL_NON_EXITED_THREADS / ALL_INFERIORS macros with (C++20-like) ranges
and iterators, such that you can instead naturaly iterate over
threads/inferiors using range-for, like e.g,.:
// all threads, including THREAD_EXITED threads.
for (thread_info *tp : all_threads ())
{ .... }
// all non-exited threads.
for (thread_info *tp : all_non_exited_threads ())
{ .... }
// all non-exited threads of INF inferior.
for (thread_info *tp : inf->non_exited_threads ())
{ .... }
The all_non_exited_threads() function takes an optional filter ptid_t as
parameter, which is quite convenient when we need to iterate over
threads matching that filter. See e.g., how the
set_executing/set_stop_requested/finish_thread_state etc. functions in
thread.c end up being simplified.
Most of the patch thus is about adding the infrustructure for allowing
the above. Later on when we get to actual multi-target, these
functions/ranges/iterators will gain a "target_ops *" parameter so
that e.g., we can iterate over all threads of a given target that
match a given filter ptid_t.
The only entry points users needs to be aware of are the
all_threads/all_non_exited_threads etc. functions seen above. Thus,
those functions are declared in gdbthread.h/inferior.h. The actual
iterators/ranges are mainly "internals" and thus are put out of view
in the new thread-iter.h/thread-iter.c/inferior-iter.h files. That
keeps the gdbthread.h/inferior.h headers quite a bit more readable.
A common/safe-iterator.h header is added which adds a template that
can be used to build "safe" iterators, which are forward iterators
that can be used to replace the ALL_THREADS_SAFE macro and other
instances of the same idiom in future.
There's a little bit of shuffling of code between
gdbthread.h/thread.c/inferior.h in the patch. That is necessary in
order to avoid circular dependencies between the
gdbthread.h/inferior.h headers.
As for the init_thread_list calls sprinkled around, they're all
eliminated by this patch, and a new, central call is added to
inferior_appeared. Note how also related to that, there's a call to
init_wait_for_inferior in remote.c that is eliminated.
init_wait_for_inferior is currently responsible for discarding skipped
inline frames, which had to be moved elsewhere. Given that nowadays
we always have a thread even for single-threaded processes, the
natural place is to delete a frame's inline frame info when we delete
the thread. I.e., from clear_thread_inferior_resources.
gdb/ChangeLog:
2018-11-22 Pedro Alves <palves@redhat.com>
* Makefile.in (COMMON_SFILES): Add thread-iter.c.
* breakpoint.c (breakpoints_should_be_inserted_now): Replace
ALL_NON_EXITED_THREADS with all_non_exited_threads.
(print_one_breakpoint_location): Replace ALL_INFERIORS with
all_inferiors.
* bsd-kvm.c: Include inferior.h.
* btrace.c (btrace_free_objfile): Replace ALL_NON_EXITED_THREADS
with all_non_exited_threads.
* common/filtered-iterator.h: New.
* common/safe-iterator.h: New.
* corelow.c (core_target_open): Don't call init_thread_list here.
* darwin-nat.c (thread_info_from_private_thread_info): Replace
ALL_THREADS with all_threads.
* fbsd-nat.c (fbsd_nat_target::resume): Replace
ALL_NON_EXITED_THREADS with inf->non_exited_threads.
* fbsd-tdep.c (fbsd_make_corefile_notes): Replace
ALL_NON_EXITED_THREADS with inf->non_exited_threads.
* fork-child.c (postfork_hook): Don't call init_thread_list here.
* gdbarch-selftests.c (register_to_value_test): Adjust.
* gdbthread.h: Don't include "inferior.h" here.
(struct inferior): Forward declare.
(enum step_over_calls_kind): Moved here from inferior.h.
(thread_info::deletable): Definition moved to thread.c.
(find_thread_ptid (inferior *, ptid_t)): Declare.
(ALL_THREADS, ALL_THREADS_BY_INFERIOR, ALL_THREADS_SAFE): Delete.
Include "thread-iter.h".
(all_threads, all_non_exited_threads, all_threads_safe): New.
(any_thread_p): Declare.
(thread_list): Delete.
* infcmd.c (signal_command): Replace ALL_NON_EXITED_THREADS with
all_non_exited_threads.
(proceed_after_attach_callback): Delete.
(proceed_after_attach): Take an inferior pointer instead of an
integer PID. Adjust to use range-for.
(attach_post_wait): Pass down inferior pointer instead of pid.
Use range-for instead of ALL_NON_EXITED_THREADS.
(detach_command): Remove init_thread_list call.
* inferior-iter.h: New.
* inferior.c (struct delete_thread_of_inferior_arg): Delete.
(delete_thread_of_inferior): Delete.
(delete_inferior, exit_inferior_1): Use range-for with
inf->threads_safe() instead of iterate_over_threads.
(inferior_appeared): Call init_thread_list here.
(discard_all_inferiors): Use all_non_exited_inferiors.
(find_inferior_id, find_inferior_pid): Use all_inferiors.
(iterate_over_inferiors): Use all_inferiors_safe.
(have_inferiors, number_of_live_inferiors): Use
all_non_exited_inferiors.
(number_of_inferiors): Use all_inferiors and std::distance.
(print_inferior): Use all_inferiors.
* inferior.h: Include gdbthread.h.
(enum step_over_calls_kind): Moved to gdbthread.h.
(struct inferior) <thread_list>: New field.
<threads, non_exited_threads, threads_safe>: New methods.
(ALL_INFERIORS): Delete.
Include "inferior-iter.h".
(ALL_NON_EXITED_INFERIORS): Delete.
(all_inferiors_safe, all_inferiors, all_non_exited_inferiors): New
functions.
* inflow.c (child_interrupt, child_pass_ctrlc): Replace
ALL_NON_EXITED_THREADS with all_non_exited_threads.
* infrun.c (follow_exec): Use all_threads_safe.
(clear_proceed_status, proceed): Use all_non_exited_threads.
(init_wait_for_inferior): Don't clear inline frame state here.
(infrun_thread_stop_requested, for_each_just_stopped_thread): Use
all_threads instead of ALL_NON_EXITED_THREADS.
(random_pending_event_thread): Use all_non_exited_threads instead
of ALL_NON_EXITED_THREADS. Use a lambda for repeated code.
(clean_up_just_stopped_threads_fsms): Use all_non_exited_threads
instead of ALL_NON_EXITED_THREADS.
(handle_no_resumed): Use all_non_exited_threads instead of
ALL_NON_EXITED_THREADS. Use all_inferiors instead of
ALL_INFERIORS.
(restart_threads, switch_back_to_stepped_thread): Use
all_non_exited_threads instead of ALL_NON_EXITED_THREADS.
* linux-nat.c (check_zombie_leaders): Replace ALL_INFERIORS with
all_inferiors.
(kill_unfollowed_fork_children): Use inf->non_exited_threads
instead of ALL_NON_EXITED_THREADS.
* linux-tdep.c (linux_make_corefile_notes): Use
inf->non_exited_threads instead of ALL_NON_EXITED_THREADS.
* linux-thread-db.c (thread_db_target::update_thread_list):
Replace ALL_INFERIORS with all_inferiors.
(thread_db_target::thread_handle_to_thread_info): Use
inf->non_exited_threads instead of ALL_NON_EXITED_THREADS.
* mi/mi-interp.c (multiple_inferiors_p): New.
(mi_on_resume_1): Simplify using all_non_exited_threads and
multiple_inferiors_p.
* mi/mi-main.c (mi_cmd_thread_list_ids): Use all_non_exited_threads
instead of ALL_NON_EXITED_THREADS.
* nto-procfs.c (nto_procfs_target::open): Don't call
init_thread_list here.
* record-btrace.c (record_btrace_target_open)
(record_btrace_target::stop_recording)
(record_btrace_target::close)
(record_btrace_target::record_is_replaying)
(record_btrace_target::resume, record_btrace_target::wait)
(record_btrace_target::record_stop_replaying): Use
all_non_exited_threads instead of ALL_NON_EXITED_THREADS.
* record-full.c (record_full_wait_1): Use all_non_exited_threads
instead of ALL_NON_EXITED_THREADS.
* regcache.c (cooked_read_test): Remove reference to global
thread_list.
* remote-sim.c (gdbsim_target::create_inferior): Don't call
init_thread_list here.
* remote.c (remote_target::update_thread_list): Use
all_threads_safe instead of ALL_NON_EXITED_THREADS.
(remote_target::process_initial_stop_replies): Replace
ALL_INFERIORS with all_non_exited_inferiors and use
all_non_exited_threads instead of ALL_NON_EXITED_THREADS.
(remote_target::open_1): Don't call init_thread_list here.
(remote_target::append_pending_thread_resumptions)
(remote_target::remote_resume_with_hc): Use all_non_exited_threads
instead of ALL_NON_EXITED_THREADS.
(remote_target::commit_resume)
(remote_target::remove_new_fork_children): Replace ALL_INFERIORS
with all_non_exited_inferiors and use all_non_exited_threads
instead of ALL_NON_EXITED_THREADS.
(remote_target::kill_new_fork_children): Use
all_non_exited_threads instead of ALL_NON_EXITED_THREADS. Remove
init_thread_list and init_wait_for_inferior calls.
(remote_target::remote_btrace_maybe_reopen)
(remote_target::thread_handle_to_thread_info): Use
all_non_exited_threads instead of ALL_NON_EXITED_THREADS.
* target.c (target_terminal::restore_inferior)
(target_terminal_is_ours_kind): Replace ALL_INFERIORS with
all_non_exited_inferiors.
* thread-iter.c: New file.
* thread-iter.h: New file.
* thread.c: Include "inline-frame.h".
(thread_list): Delete.
(clear_thread_inferior_resources): Call clear_inline_frame_state.
(init_thread_list): Use all_threads_safe instead of
ALL_THREADS_SAFE. Adjust to per-inferior thread lists.
(new_thread): Adjust to per-inferior thread lists.
(add_thread_silent): Pass inferior to find_thread_ptid.
(thread_info::deletable): New, moved from the header.
(delete_thread_1): Adjust to per-inferior thread lists.
(find_thread_global_id): Use inf->threads().
(find_thread_ptid): Use find_inferior_ptid and pass inferior to
find_thread_ptid.
(find_thread_ptid(inferior*, ptid_t)): New overload.
(iterate_over_threads): Use all_threads_safe.
(any_thread_p): New.
(thread_count): Use all_threads and std::distance.
(live_threads_count): Use all_non_exited_threads and
std::distance.
(valid_global_thread_id): Use all_threads.
(in_thread_list): Use find_thread_ptid.
(first_thread_of_inferior): Adjust to per-inferior thread lists.
(any_thread_of_inferior, any_live_thread_of_inferior): Use
inf->non_exited_threads().
(prune_threads, delete_exited_threads): Use all_threads_safe.
(thread_change_ptid): Pass inferior pointer to find_thread_ptid.
(set_resumed, set_running): Use all_non_exited_threads.
(is_thread_state, is_stopped, is_exited, is_running)
(is_executing): Delete.
(set_executing, set_stop_requested, finish_thread_state): Use
all_non_exited_threads.
(print_thread_info_1): Use all_inferiors and all_threads.
(thread_apply_all_command): Use all_non_exited_threads.
(thread_find_command): Use all_threads.
(update_threads_executing): Use all_non_exited_threads.
* tid-parse.c (parse_thread_id): Use inf->threads.
* x86-bsd-nat.c (x86bsd_dr_set): Use inf->non_exited_threads ().
2018-11-22 17:09:14 +01:00
|
|
|
for (thread_info *thr : current_inferior ()->non_exited_threads ())
|
2015-12-22 01:34:15 +01:00
|
|
|
{
|
|
|
|
if (thr == signalled_thr)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
fbsd_corefile_thread (thr, &thread_args);
|
|
|
|
}
|
|
|
|
|
|
|
|
note_data = thread_args.note_data;
|
|
|
|
|
2018-09-07 00:03:19 +02:00
|
|
|
/* Auxiliary vector. */
|
|
|
|
uint32_t structsize = gdbarch_ptr_bit (gdbarch) / 4; /* Elf_Auxinfo */
|
|
|
|
gdb::optional<gdb::byte_vector> note_desc =
|
|
|
|
fbsd_make_note_desc (TARGET_OBJECT_AUXV, structsize);
|
|
|
|
if (note_desc && !note_desc->empty ())
|
|
|
|
{
|
|
|
|
note_data = elfcore_write_note (obfd, note_data, note_size, "FreeBSD",
|
|
|
|
NT_FREEBSD_PROCSTAT_AUXV,
|
|
|
|
note_desc->data (), note_desc->size ());
|
|
|
|
if (!note_data)
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Virtual memory mappings. */
|
|
|
|
note_desc = fbsd_make_note_desc (TARGET_OBJECT_FREEBSD_VMMAP, 0);
|
|
|
|
if (note_desc && !note_desc->empty ())
|
|
|
|
{
|
|
|
|
note_data = elfcore_write_note (obfd, note_data, note_size, "FreeBSD",
|
|
|
|
NT_FREEBSD_PROCSTAT_VMMAP,
|
|
|
|
note_desc->data (), note_desc->size ());
|
|
|
|
if (!note_data)
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
note_desc = fbsd_make_note_desc (TARGET_OBJECT_FREEBSD_PS_STRINGS, 0);
|
|
|
|
if (note_desc && !note_desc->empty ())
|
|
|
|
{
|
|
|
|
note_data = elfcore_write_note (obfd, note_data, note_size, "FreeBSD",
|
|
|
|
NT_FREEBSD_PROCSTAT_PSSTRINGS,
|
|
|
|
note_desc->data (), note_desc->size ());
|
|
|
|
if (!note_data)
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2013-12-03 12:35:35 +01:00
|
|
|
return note_data;
|
|
|
|
}
|
|
|
|
|
Add support for 'info proc files' on FreeBSD core dumps.
Walk the list of struct kinfo_file objects in the
NT_FREEBSD_PROCSTAT_FILES core dump note outputting a description of
each open file descriptor. For sockets, the local and remote socket
addresses are displayed in place of the file name field. For UNIX
local domain sockets, only a single address is displayed since most
UNIX sockets only have one valid address and printing both pathnames
could be quite long. The output format was somewhat inspired by the
output of the "procstat -f" command on FreeBSD, but with a few less
details and some fields were condensed.
gdb/ChangeLog:
* fbsd-tdep.c (KF_FLAGS, KF_OFFSET, KF_VNODE_TYPE, KF_SOCK_DOMAIN)
(KF_SOCK_TYPE, KF_SOCK_PROTOCOL, KF_SA_LOCAL, KF_SA_PEER)
(KINFO_FILE_TYPE_SOCKET, KINFO_FILE_TYPE_PIPE)
(KINFO_FILE_TYPE_FIFO, KINFO_FILE_TYPE_KQUEUE)
(KINFO_FILE_TYPE_CRYPTO, KINFO_FILE_TYPE_MQUEUE)
(KINFO_FILE_TYPE_SHM, KINFO_FILE_TYPE_SEM, KINFO_FILE_TYPE_PTS)
(KINFO_FILE_TYPE_PROCDESC, KINFO_FILE_FD_TYPE_ROOT)
(KINFO_FILE_FD_TYPE_JAIL, KINFO_FILE_FD_TYPE_TRACE)
(KINFO_FILE_FD_TYPE_CTTY, KINFO_FILE_FLAG_READ)
(KINFO_FILE_FLAG_WRITE, KINFO_FILE_FLAG_APPEND)
(KINFO_FILE_FLAG_ASYNC, KINFO_FILE_FLAG_FSYNC)
(KINFO_FILE_FLAG_NONBLOCK, KINFO_FILE_FLAG_DIRECT)
(KINFO_FILE_FLAG_HASLOCK, KINFO_FILE_FLAG_EXEC)
(KINFO_FILE_VTYPE_VREG, KINFO_FILE_VTYPE_VDIR)
(KINFO_FILE_VTYPE_VCHR, KINFO_FILE_VTYPE_VLNK)
(KINFO_FILE_VTYPE_VSOCK, KINFO_FILE_VTYPE_VFIFO, FBSD_AF_UNIX)
(FBSD_AF_INET, FBSD_AF_INET6, FBSD_SOCK_STREAM, FBSD_SOCK_DGRAM)
(FBSD_SOCK_SEQPACKET, FBSD_IPPROTO_ICMP, FBSD_IPPROTO_TCP)
(FBSD_IPPROTO_UDP, FBSD_IPPROTO_SCTP): New defines.
(struct fbsd_sockaddr_in, struct fbsd_sockaddr_in6)
(struct fbsd_sockaddr_un): New types.
(fbsd_file_fd, fbsd_file_type, fbsd_file_flags, fbsd_ipproto)
(fbsd_print_sockaddr_in, fbsd_print_sockaddr_in6)
(fbsd_info_proc_files_header, fbsd_info_proc_files_entry)
(fbsd_core_info_proc_files): New functions.
(fbsd_core_info_proc): List open file descriptors for IP_FILES and
IP_ALL.
* fbsd-tdep.h (fbsd_info_proc_files_header)
(fbsd_info_proc_files_entry): New.
2018-09-18 23:05:47 +02:00
|
|
|
/* Helper function to generate the file descriptor description for a
|
|
|
|
single open file in 'info proc files'. */
|
|
|
|
|
|
|
|
static const char *
|
|
|
|
fbsd_file_fd (int kf_fd)
|
|
|
|
{
|
|
|
|
switch (kf_fd)
|
|
|
|
{
|
|
|
|
case KINFO_FILE_FD_TYPE_CWD:
|
|
|
|
return "cwd";
|
|
|
|
case KINFO_FILE_FD_TYPE_ROOT:
|
|
|
|
return "root";
|
|
|
|
case KINFO_FILE_FD_TYPE_JAIL:
|
|
|
|
return "jail";
|
|
|
|
case KINFO_FILE_FD_TYPE_TRACE:
|
|
|
|
return "trace";
|
|
|
|
case KINFO_FILE_FD_TYPE_TEXT:
|
|
|
|
return "text";
|
|
|
|
case KINFO_FILE_FD_TYPE_CTTY:
|
|
|
|
return "ctty";
|
|
|
|
default:
|
|
|
|
return int_string (kf_fd, 10, 1, 0, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Helper function to generate the file type for a single open file in
|
|
|
|
'info proc files'. */
|
|
|
|
|
|
|
|
static const char *
|
|
|
|
fbsd_file_type (int kf_type, int kf_vnode_type)
|
|
|
|
{
|
|
|
|
switch (kf_type)
|
|
|
|
{
|
|
|
|
case KINFO_FILE_TYPE_VNODE:
|
|
|
|
switch (kf_vnode_type)
|
|
|
|
{
|
|
|
|
case KINFO_FILE_VTYPE_VREG:
|
|
|
|
return "file";
|
|
|
|
case KINFO_FILE_VTYPE_VDIR:
|
|
|
|
return "dir";
|
|
|
|
case KINFO_FILE_VTYPE_VCHR:
|
|
|
|
return "chr";
|
|
|
|
case KINFO_FILE_VTYPE_VLNK:
|
|
|
|
return "link";
|
|
|
|
case KINFO_FILE_VTYPE_VSOCK:
|
|
|
|
return "socket";
|
|
|
|
case KINFO_FILE_VTYPE_VFIFO:
|
|
|
|
return "fifo";
|
|
|
|
default:
|
|
|
|
{
|
|
|
|
char *str = get_print_cell ();
|
|
|
|
|
|
|
|
xsnprintf (str, PRINT_CELL_SIZE, "vn:%d", kf_vnode_type);
|
|
|
|
return str;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
case KINFO_FILE_TYPE_SOCKET:
|
|
|
|
return "socket";
|
|
|
|
case KINFO_FILE_TYPE_PIPE:
|
|
|
|
return "pipe";
|
|
|
|
case KINFO_FILE_TYPE_FIFO:
|
|
|
|
return "fifo";
|
|
|
|
case KINFO_FILE_TYPE_KQUEUE:
|
|
|
|
return "kqueue";
|
|
|
|
case KINFO_FILE_TYPE_CRYPTO:
|
|
|
|
return "crypto";
|
|
|
|
case KINFO_FILE_TYPE_MQUEUE:
|
|
|
|
return "mqueue";
|
|
|
|
case KINFO_FILE_TYPE_SHM:
|
|
|
|
return "shm";
|
|
|
|
case KINFO_FILE_TYPE_SEM:
|
|
|
|
return "sem";
|
|
|
|
case KINFO_FILE_TYPE_PTS:
|
|
|
|
return "pts";
|
|
|
|
case KINFO_FILE_TYPE_PROCDESC:
|
|
|
|
return "proc";
|
|
|
|
default:
|
|
|
|
return int_string (kf_type, 10, 1, 0, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Helper function to generate the file flags for a single open file in
|
|
|
|
'info proc files'. */
|
|
|
|
|
|
|
|
static const char *
|
|
|
|
fbsd_file_flags (int kf_flags)
|
|
|
|
{
|
|
|
|
static char file_flags[10];
|
|
|
|
|
|
|
|
file_flags[0] = (kf_flags & KINFO_FILE_FLAG_READ) ? 'r' : '-';
|
|
|
|
file_flags[1] = (kf_flags & KINFO_FILE_FLAG_WRITE) ? 'w' : '-';
|
|
|
|
file_flags[2] = (kf_flags & KINFO_FILE_FLAG_EXEC) ? 'x' : '-';
|
|
|
|
file_flags[3] = (kf_flags & KINFO_FILE_FLAG_APPEND) ? 'a' : '-';
|
|
|
|
file_flags[4] = (kf_flags & KINFO_FILE_FLAG_ASYNC) ? 's' : '-';
|
|
|
|
file_flags[5] = (kf_flags & KINFO_FILE_FLAG_FSYNC) ? 'f' : '-';
|
|
|
|
file_flags[6] = (kf_flags & KINFO_FILE_FLAG_NONBLOCK) ? 'n' : '-';
|
|
|
|
file_flags[7] = (kf_flags & KINFO_FILE_FLAG_DIRECT) ? 'd' : '-';
|
|
|
|
file_flags[8] = (kf_flags & KINFO_FILE_FLAG_HASLOCK) ? 'l' : '-';
|
|
|
|
file_flags[9] = '\0';
|
|
|
|
|
|
|
|
return file_flags;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Helper function to generate the name of an IP protocol. */
|
|
|
|
|
|
|
|
static const char *
|
|
|
|
fbsd_ipproto (int protocol)
|
|
|
|
{
|
|
|
|
switch (protocol)
|
|
|
|
{
|
|
|
|
case FBSD_IPPROTO_ICMP:
|
|
|
|
return "icmp";
|
|
|
|
case FBSD_IPPROTO_TCP:
|
|
|
|
return "tcp";
|
|
|
|
case FBSD_IPPROTO_UDP:
|
|
|
|
return "udp";
|
|
|
|
case FBSD_IPPROTO_SCTP:
|
|
|
|
return "sctp";
|
|
|
|
default:
|
|
|
|
{
|
|
|
|
char *str = get_print_cell ();
|
|
|
|
|
|
|
|
xsnprintf (str, PRINT_CELL_SIZE, "ip<%d>", protocol);
|
|
|
|
return str;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Helper function to print out an IPv4 socket address. */
|
|
|
|
|
|
|
|
static void
|
|
|
|
fbsd_print_sockaddr_in (const void *sockaddr)
|
|
|
|
{
|
|
|
|
const struct fbsd_sockaddr_in *sin =
|
|
|
|
reinterpret_cast<const struct fbsd_sockaddr_in *> (sockaddr);
|
|
|
|
char buf[INET_ADDRSTRLEN];
|
|
|
|
|
2018-09-19 18:44:51 +02:00
|
|
|
if (inet_ntop (AF_INET, sin->sin_addr, buf, sizeof buf) == nullptr)
|
Add support for 'info proc files' on FreeBSD core dumps.
Walk the list of struct kinfo_file objects in the
NT_FREEBSD_PROCSTAT_FILES core dump note outputting a description of
each open file descriptor. For sockets, the local and remote socket
addresses are displayed in place of the file name field. For UNIX
local domain sockets, only a single address is displayed since most
UNIX sockets only have one valid address and printing both pathnames
could be quite long. The output format was somewhat inspired by the
output of the "procstat -f" command on FreeBSD, but with a few less
details and some fields were condensed.
gdb/ChangeLog:
* fbsd-tdep.c (KF_FLAGS, KF_OFFSET, KF_VNODE_TYPE, KF_SOCK_DOMAIN)
(KF_SOCK_TYPE, KF_SOCK_PROTOCOL, KF_SA_LOCAL, KF_SA_PEER)
(KINFO_FILE_TYPE_SOCKET, KINFO_FILE_TYPE_PIPE)
(KINFO_FILE_TYPE_FIFO, KINFO_FILE_TYPE_KQUEUE)
(KINFO_FILE_TYPE_CRYPTO, KINFO_FILE_TYPE_MQUEUE)
(KINFO_FILE_TYPE_SHM, KINFO_FILE_TYPE_SEM, KINFO_FILE_TYPE_PTS)
(KINFO_FILE_TYPE_PROCDESC, KINFO_FILE_FD_TYPE_ROOT)
(KINFO_FILE_FD_TYPE_JAIL, KINFO_FILE_FD_TYPE_TRACE)
(KINFO_FILE_FD_TYPE_CTTY, KINFO_FILE_FLAG_READ)
(KINFO_FILE_FLAG_WRITE, KINFO_FILE_FLAG_APPEND)
(KINFO_FILE_FLAG_ASYNC, KINFO_FILE_FLAG_FSYNC)
(KINFO_FILE_FLAG_NONBLOCK, KINFO_FILE_FLAG_DIRECT)
(KINFO_FILE_FLAG_HASLOCK, KINFO_FILE_FLAG_EXEC)
(KINFO_FILE_VTYPE_VREG, KINFO_FILE_VTYPE_VDIR)
(KINFO_FILE_VTYPE_VCHR, KINFO_FILE_VTYPE_VLNK)
(KINFO_FILE_VTYPE_VSOCK, KINFO_FILE_VTYPE_VFIFO, FBSD_AF_UNIX)
(FBSD_AF_INET, FBSD_AF_INET6, FBSD_SOCK_STREAM, FBSD_SOCK_DGRAM)
(FBSD_SOCK_SEQPACKET, FBSD_IPPROTO_ICMP, FBSD_IPPROTO_TCP)
(FBSD_IPPROTO_UDP, FBSD_IPPROTO_SCTP): New defines.
(struct fbsd_sockaddr_in, struct fbsd_sockaddr_in6)
(struct fbsd_sockaddr_un): New types.
(fbsd_file_fd, fbsd_file_type, fbsd_file_flags, fbsd_ipproto)
(fbsd_print_sockaddr_in, fbsd_print_sockaddr_in6)
(fbsd_info_proc_files_header, fbsd_info_proc_files_entry)
(fbsd_core_info_proc_files): New functions.
(fbsd_core_info_proc): List open file descriptors for IP_FILES and
IP_ALL.
* fbsd-tdep.h (fbsd_info_proc_files_header)
(fbsd_info_proc_files_entry): New.
2018-09-18 23:05:47 +02:00
|
|
|
error (_("Failed to format IPv4 address"));
|
|
|
|
printf_filtered ("%s:%u", buf,
|
|
|
|
(sin->sin_port[0] << 8) | sin->sin_port[1]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Helper function to print out an IPv6 socket address. */
|
|
|
|
|
|
|
|
static void
|
|
|
|
fbsd_print_sockaddr_in6 (const void *sockaddr)
|
|
|
|
{
|
|
|
|
const struct fbsd_sockaddr_in6 *sin6 =
|
|
|
|
reinterpret_cast<const struct fbsd_sockaddr_in6 *> (sockaddr);
|
|
|
|
char buf[INET6_ADDRSTRLEN];
|
|
|
|
|
2018-09-19 18:44:51 +02:00
|
|
|
if (inet_ntop (AF_INET6, sin6->sin6_addr, buf, sizeof buf) == nullptr)
|
Add support for 'info proc files' on FreeBSD core dumps.
Walk the list of struct kinfo_file objects in the
NT_FREEBSD_PROCSTAT_FILES core dump note outputting a description of
each open file descriptor. For sockets, the local and remote socket
addresses are displayed in place of the file name field. For UNIX
local domain sockets, only a single address is displayed since most
UNIX sockets only have one valid address and printing both pathnames
could be quite long. The output format was somewhat inspired by the
output of the "procstat -f" command on FreeBSD, but with a few less
details and some fields were condensed.
gdb/ChangeLog:
* fbsd-tdep.c (KF_FLAGS, KF_OFFSET, KF_VNODE_TYPE, KF_SOCK_DOMAIN)
(KF_SOCK_TYPE, KF_SOCK_PROTOCOL, KF_SA_LOCAL, KF_SA_PEER)
(KINFO_FILE_TYPE_SOCKET, KINFO_FILE_TYPE_PIPE)
(KINFO_FILE_TYPE_FIFO, KINFO_FILE_TYPE_KQUEUE)
(KINFO_FILE_TYPE_CRYPTO, KINFO_FILE_TYPE_MQUEUE)
(KINFO_FILE_TYPE_SHM, KINFO_FILE_TYPE_SEM, KINFO_FILE_TYPE_PTS)
(KINFO_FILE_TYPE_PROCDESC, KINFO_FILE_FD_TYPE_ROOT)
(KINFO_FILE_FD_TYPE_JAIL, KINFO_FILE_FD_TYPE_TRACE)
(KINFO_FILE_FD_TYPE_CTTY, KINFO_FILE_FLAG_READ)
(KINFO_FILE_FLAG_WRITE, KINFO_FILE_FLAG_APPEND)
(KINFO_FILE_FLAG_ASYNC, KINFO_FILE_FLAG_FSYNC)
(KINFO_FILE_FLAG_NONBLOCK, KINFO_FILE_FLAG_DIRECT)
(KINFO_FILE_FLAG_HASLOCK, KINFO_FILE_FLAG_EXEC)
(KINFO_FILE_VTYPE_VREG, KINFO_FILE_VTYPE_VDIR)
(KINFO_FILE_VTYPE_VCHR, KINFO_FILE_VTYPE_VLNK)
(KINFO_FILE_VTYPE_VSOCK, KINFO_FILE_VTYPE_VFIFO, FBSD_AF_UNIX)
(FBSD_AF_INET, FBSD_AF_INET6, FBSD_SOCK_STREAM, FBSD_SOCK_DGRAM)
(FBSD_SOCK_SEQPACKET, FBSD_IPPROTO_ICMP, FBSD_IPPROTO_TCP)
(FBSD_IPPROTO_UDP, FBSD_IPPROTO_SCTP): New defines.
(struct fbsd_sockaddr_in, struct fbsd_sockaddr_in6)
(struct fbsd_sockaddr_un): New types.
(fbsd_file_fd, fbsd_file_type, fbsd_file_flags, fbsd_ipproto)
(fbsd_print_sockaddr_in, fbsd_print_sockaddr_in6)
(fbsd_info_proc_files_header, fbsd_info_proc_files_entry)
(fbsd_core_info_proc_files): New functions.
(fbsd_core_info_proc): List open file descriptors for IP_FILES and
IP_ALL.
* fbsd-tdep.h (fbsd_info_proc_files_header)
(fbsd_info_proc_files_entry): New.
2018-09-18 23:05:47 +02:00
|
|
|
error (_("Failed to format IPv6 address"));
|
|
|
|
printf_filtered ("%s.%u", buf,
|
|
|
|
(sin6->sin6_port[0] << 8) | sin6->sin6_port[1]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* See fbsd-tdep.h. */
|
|
|
|
|
|
|
|
void
|
|
|
|
fbsd_info_proc_files_header ()
|
|
|
|
{
|
|
|
|
printf_filtered (_("Open files:\n\n"));
|
|
|
|
printf_filtered (" %6s %6s %10s %9s %s\n",
|
|
|
|
"FD", "Type", "Offset", "Flags ", "Name");
|
|
|
|
}
|
|
|
|
|
|
|
|
/* See fbsd-tdep.h. */
|
|
|
|
|
|
|
|
void
|
|
|
|
fbsd_info_proc_files_entry (int kf_type, int kf_fd, int kf_flags,
|
|
|
|
LONGEST kf_offset, int kf_vnode_type,
|
|
|
|
int kf_sock_domain, int kf_sock_type,
|
|
|
|
int kf_sock_protocol, const void *kf_sa_local,
|
|
|
|
const void *kf_sa_peer, const void *kf_path)
|
|
|
|
{
|
|
|
|
printf_filtered (" %6s %6s %10s %8s ",
|
|
|
|
fbsd_file_fd (kf_fd),
|
|
|
|
fbsd_file_type (kf_type, kf_vnode_type),
|
|
|
|
kf_offset > -1 ? hex_string (kf_offset) : "-",
|
|
|
|
fbsd_file_flags (kf_flags));
|
|
|
|
if (kf_type == KINFO_FILE_TYPE_SOCKET)
|
|
|
|
{
|
|
|
|
switch (kf_sock_domain)
|
|
|
|
{
|
|
|
|
case FBSD_AF_UNIX:
|
|
|
|
{
|
|
|
|
switch (kf_sock_type)
|
|
|
|
{
|
|
|
|
case FBSD_SOCK_STREAM:
|
|
|
|
printf_filtered ("unix stream:");
|
|
|
|
break;
|
|
|
|
case FBSD_SOCK_DGRAM:
|
|
|
|
printf_filtered ("unix dgram:");
|
|
|
|
break;
|
|
|
|
case FBSD_SOCK_SEQPACKET:
|
|
|
|
printf_filtered ("unix seqpacket:");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
printf_filtered ("unix <%d>:", kf_sock_type);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* For local sockets, print out the first non-nul path
|
|
|
|
rather than both paths. */
|
|
|
|
const struct fbsd_sockaddr_un *sun
|
|
|
|
= reinterpret_cast<const struct fbsd_sockaddr_un *> (kf_sa_local);
|
|
|
|
if (sun->sun_path[0] == 0)
|
|
|
|
sun = reinterpret_cast<const struct fbsd_sockaddr_un *>
|
|
|
|
(kf_sa_peer);
|
|
|
|
printf_filtered ("%s", sun->sun_path);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case FBSD_AF_INET:
|
|
|
|
printf_filtered ("%s4 ", fbsd_ipproto (kf_sock_protocol));
|
|
|
|
fbsd_print_sockaddr_in (kf_sa_local);
|
|
|
|
printf_filtered (" -> ");
|
|
|
|
fbsd_print_sockaddr_in (kf_sa_peer);
|
|
|
|
break;
|
|
|
|
case FBSD_AF_INET6:
|
|
|
|
printf_filtered ("%s6 ", fbsd_ipproto (kf_sock_protocol));
|
|
|
|
fbsd_print_sockaddr_in6 (kf_sa_local);
|
|
|
|
printf_filtered (" -> ");
|
|
|
|
fbsd_print_sockaddr_in6 (kf_sa_peer);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
printf_filtered ("%s", reinterpret_cast<const char *> (kf_path));
|
|
|
|
printf_filtered ("\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Implement "info proc files" for a corefile. */
|
|
|
|
|
|
|
|
static void
|
|
|
|
fbsd_core_info_proc_files (struct gdbarch *gdbarch)
|
|
|
|
{
|
|
|
|
asection *section
|
|
|
|
= bfd_get_section_by_name (core_bfd, ".note.freebsdcore.files");
|
|
|
|
if (section == NULL)
|
|
|
|
{
|
|
|
|
warning (_("unable to find open files in core file"));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t note_size = bfd_get_section_size (section);
|
|
|
|
if (note_size < 4)
|
|
|
|
error (_("malformed core note - too short for header"));
|
|
|
|
|
|
|
|
gdb::def_vector<unsigned char> contents (note_size);
|
|
|
|
if (!bfd_get_section_contents (core_bfd, section, contents.data (),
|
|
|
|
0, note_size))
|
|
|
|
error (_("could not get core note contents"));
|
|
|
|
|
|
|
|
unsigned char *descdata = contents.data ();
|
|
|
|
unsigned char *descend = descdata + note_size;
|
|
|
|
|
|
|
|
/* Skip over the structure size. */
|
|
|
|
descdata += 4;
|
|
|
|
|
|
|
|
fbsd_info_proc_files_header ();
|
|
|
|
|
|
|
|
while (descdata + KF_PATH < descend)
|
|
|
|
{
|
|
|
|
ULONGEST structsize = bfd_get_32 (core_bfd, descdata + KF_STRUCTSIZE);
|
|
|
|
if (structsize < KF_PATH)
|
|
|
|
error (_("malformed core note - file structure too small"));
|
|
|
|
|
|
|
|
LONGEST type = bfd_get_signed_32 (core_bfd, descdata + KF_TYPE);
|
|
|
|
LONGEST fd = bfd_get_signed_32 (core_bfd, descdata + KF_FD);
|
|
|
|
LONGEST flags = bfd_get_signed_32 (core_bfd, descdata + KF_FLAGS);
|
|
|
|
LONGEST offset = bfd_get_signed_64 (core_bfd, descdata + KF_OFFSET);
|
|
|
|
LONGEST vnode_type = bfd_get_signed_32 (core_bfd,
|
|
|
|
descdata + KF_VNODE_TYPE);
|
|
|
|
LONGEST sock_domain = bfd_get_signed_32 (core_bfd,
|
|
|
|
descdata + KF_SOCK_DOMAIN);
|
|
|
|
LONGEST sock_type = bfd_get_signed_32 (core_bfd, descdata + KF_SOCK_TYPE);
|
|
|
|
LONGEST sock_protocol = bfd_get_signed_32 (core_bfd,
|
|
|
|
descdata + KF_SOCK_PROTOCOL);
|
|
|
|
fbsd_info_proc_files_entry (type, fd, flags, offset, vnode_type,
|
|
|
|
sock_domain, sock_type, sock_protocol,
|
|
|
|
descdata + KF_SA_LOCAL, descdata + KF_SA_PEER,
|
|
|
|
descdata + KF_PATH);
|
|
|
|
|
|
|
|
descdata += structsize;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Support 'info proc' for FreeBSD process core dumps.
- Command line arguments are obtained from the pr_psargs[] array
saved in the NT_PRPSINFO note.
- The 'cwd' and 'exe' values are obtained from the per-process file
descriptor table stored in the NT_PROCSTAT_FILES core note.
- 'mappings' is implemented by walking the array of VM map entries
stored in the NT_PROCSTAT_VMMAP core note.
- 'status' output is generated by outputting fields from
the first structure stored in the NT_PROCSTAT_PROC core note.
- 'stat' is aliased to 'status'.
gdb/ChangeLog:
* fbsd-tdep.c (KVE_STRUCTSIZE, KVE_START, KVE_END, KVE_OFFSET)
(KVE_FLAGS, KVE_PROTECTION, KVE_PATH, KINFO_VME_PROT_READ)
(KINFO_VME_PROT_WRITE, KINFO_VME_PROT_EXEC, KINFO_VME_FLAG_COW)
(KINFO_VME_FLAG_NEEDS_COPY, KINFO_VME_FLAG_NOCOREDUMP)
(KINFO_VME_FLAG_SUPER, KINFO_VME_FLAG_GROWS_UP)
(KINFO_VME_FLAG_GROWS_DOWN, KF_STRUCTSIZE, KF_TYPE, KF_FD)
(KF_PATH, KINFO_FILE_TYPE_VNODE, KINFO_FILE_FD_TYPE_CWD)
(KINFO_FILE_FD_TYPE_TEXT, SIG_WORDS, struct kinfo_proc_layout)
(kinfo_proc_layout_32, kinfo_proc_layout_i386)
(kinfo_proc_layout_64, fbsd_vm_map_entry_flags)
(fbsd_core_info_proc_mappings, fbsd_core_vnode_path)
(fbsd_core_fetch_timeval, fbsd_print_sigset)
(fbsd_core_info_proc_status, fbsd_core_info_proc): New.
(fbsd_init_abi): Install gdbarch "core_info_proc" method.
* fbsd-tdep.h (fbsd_vm_map_entry_flags): New.
2018-01-09 22:35:17 +01:00
|
|
|
/* Helper function to generate mappings flags for a single VM map
|
|
|
|
entry in 'info proc mappings'. */
|
|
|
|
|
2018-10-17 20:41:30 +02:00
|
|
|
static const char *
|
Support 'info proc' for FreeBSD process core dumps.
- Command line arguments are obtained from the pr_psargs[] array
saved in the NT_PRPSINFO note.
- The 'cwd' and 'exe' values are obtained from the per-process file
descriptor table stored in the NT_PROCSTAT_FILES core note.
- 'mappings' is implemented by walking the array of VM map entries
stored in the NT_PROCSTAT_VMMAP core note.
- 'status' output is generated by outputting fields from
the first structure stored in the NT_PROCSTAT_PROC core note.
- 'stat' is aliased to 'status'.
gdb/ChangeLog:
* fbsd-tdep.c (KVE_STRUCTSIZE, KVE_START, KVE_END, KVE_OFFSET)
(KVE_FLAGS, KVE_PROTECTION, KVE_PATH, KINFO_VME_PROT_READ)
(KINFO_VME_PROT_WRITE, KINFO_VME_PROT_EXEC, KINFO_VME_FLAG_COW)
(KINFO_VME_FLAG_NEEDS_COPY, KINFO_VME_FLAG_NOCOREDUMP)
(KINFO_VME_FLAG_SUPER, KINFO_VME_FLAG_GROWS_UP)
(KINFO_VME_FLAG_GROWS_DOWN, KF_STRUCTSIZE, KF_TYPE, KF_FD)
(KF_PATH, KINFO_FILE_TYPE_VNODE, KINFO_FILE_FD_TYPE_CWD)
(KINFO_FILE_FD_TYPE_TEXT, SIG_WORDS, struct kinfo_proc_layout)
(kinfo_proc_layout_32, kinfo_proc_layout_i386)
(kinfo_proc_layout_64, fbsd_vm_map_entry_flags)
(fbsd_core_info_proc_mappings, fbsd_core_vnode_path)
(fbsd_core_fetch_timeval, fbsd_print_sigset)
(fbsd_core_info_proc_status, fbsd_core_info_proc): New.
(fbsd_init_abi): Install gdbarch "core_info_proc" method.
* fbsd-tdep.h (fbsd_vm_map_entry_flags): New.
2018-01-09 22:35:17 +01:00
|
|
|
fbsd_vm_map_entry_flags (int kve_flags, int kve_protection)
|
|
|
|
{
|
|
|
|
static char vm_flags[9];
|
|
|
|
|
|
|
|
vm_flags[0] = (kve_protection & KINFO_VME_PROT_READ) ? 'r' : '-';
|
|
|
|
vm_flags[1] = (kve_protection & KINFO_VME_PROT_WRITE) ? 'w' : '-';
|
|
|
|
vm_flags[2] = (kve_protection & KINFO_VME_PROT_EXEC) ? 'x' : '-';
|
|
|
|
vm_flags[3] = ' ';
|
|
|
|
vm_flags[4] = (kve_flags & KINFO_VME_FLAG_COW) ? 'C' : '-';
|
|
|
|
vm_flags[5] = (kve_flags & KINFO_VME_FLAG_NEEDS_COPY) ? 'N' : '-';
|
|
|
|
vm_flags[6] = (kve_flags & KINFO_VME_FLAG_SUPER) ? 'S' : '-';
|
|
|
|
vm_flags[7] = (kve_flags & KINFO_VME_FLAG_GROWS_UP) ? 'U'
|
|
|
|
: (kve_flags & KINFO_VME_FLAG_GROWS_DOWN) ? 'D' : '-';
|
|
|
|
vm_flags[8] = '\0';
|
|
|
|
|
|
|
|
return vm_flags;
|
|
|
|
}
|
|
|
|
|
2018-10-17 20:41:30 +02:00
|
|
|
/* See fbsd-tdep.h. */
|
|
|
|
|
|
|
|
void
|
|
|
|
fbsd_info_proc_mappings_header (int addr_bit)
|
|
|
|
{
|
|
|
|
printf_filtered (_("Mapped address spaces:\n\n"));
|
|
|
|
if (addr_bit == 64)
|
|
|
|
{
|
|
|
|
printf_filtered (" %18s %18s %10s %10s %9s %s\n",
|
|
|
|
"Start Addr",
|
|
|
|
" End Addr",
|
|
|
|
" Size", " Offset", "Flags ", "File");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
printf_filtered ("\t%10s %10s %10s %10s %9s %s\n",
|
|
|
|
"Start Addr",
|
|
|
|
" End Addr",
|
|
|
|
" Size", " Offset", "Flags ", "File");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* See fbsd-tdep.h. */
|
|
|
|
|
|
|
|
void
|
|
|
|
fbsd_info_proc_mappings_entry (int addr_bit, ULONGEST kve_start,
|
|
|
|
ULONGEST kve_end, ULONGEST kve_offset,
|
|
|
|
int kve_flags, int kve_protection,
|
|
|
|
const void *kve_path)
|
|
|
|
{
|
|
|
|
if (addr_bit == 64)
|
|
|
|
{
|
|
|
|
printf_filtered (" %18s %18s %10s %10s %9s %s\n",
|
|
|
|
hex_string (kve_start),
|
|
|
|
hex_string (kve_end),
|
|
|
|
hex_string (kve_end - kve_start),
|
|
|
|
hex_string (kve_offset),
|
|
|
|
fbsd_vm_map_entry_flags (kve_flags, kve_protection),
|
|
|
|
reinterpret_cast<const char *> (kve_path));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
printf_filtered ("\t%10s %10s %10s %10s %9s %s\n",
|
|
|
|
hex_string (kve_start),
|
|
|
|
hex_string (kve_end),
|
|
|
|
hex_string (kve_end - kve_start),
|
|
|
|
hex_string (kve_offset),
|
|
|
|
fbsd_vm_map_entry_flags (kve_flags, kve_protection),
|
|
|
|
reinterpret_cast<const char *> (kve_path));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Support 'info proc' for FreeBSD process core dumps.
- Command line arguments are obtained from the pr_psargs[] array
saved in the NT_PRPSINFO note.
- The 'cwd' and 'exe' values are obtained from the per-process file
descriptor table stored in the NT_PROCSTAT_FILES core note.
- 'mappings' is implemented by walking the array of VM map entries
stored in the NT_PROCSTAT_VMMAP core note.
- 'status' output is generated by outputting fields from
the first structure stored in the NT_PROCSTAT_PROC core note.
- 'stat' is aliased to 'status'.
gdb/ChangeLog:
* fbsd-tdep.c (KVE_STRUCTSIZE, KVE_START, KVE_END, KVE_OFFSET)
(KVE_FLAGS, KVE_PROTECTION, KVE_PATH, KINFO_VME_PROT_READ)
(KINFO_VME_PROT_WRITE, KINFO_VME_PROT_EXEC, KINFO_VME_FLAG_COW)
(KINFO_VME_FLAG_NEEDS_COPY, KINFO_VME_FLAG_NOCOREDUMP)
(KINFO_VME_FLAG_SUPER, KINFO_VME_FLAG_GROWS_UP)
(KINFO_VME_FLAG_GROWS_DOWN, KF_STRUCTSIZE, KF_TYPE, KF_FD)
(KF_PATH, KINFO_FILE_TYPE_VNODE, KINFO_FILE_FD_TYPE_CWD)
(KINFO_FILE_FD_TYPE_TEXT, SIG_WORDS, struct kinfo_proc_layout)
(kinfo_proc_layout_32, kinfo_proc_layout_i386)
(kinfo_proc_layout_64, fbsd_vm_map_entry_flags)
(fbsd_core_info_proc_mappings, fbsd_core_vnode_path)
(fbsd_core_fetch_timeval, fbsd_print_sigset)
(fbsd_core_info_proc_status, fbsd_core_info_proc): New.
(fbsd_init_abi): Install gdbarch "core_info_proc" method.
* fbsd-tdep.h (fbsd_vm_map_entry_flags): New.
2018-01-09 22:35:17 +01:00
|
|
|
/* Implement "info proc mappings" for a corefile. */
|
|
|
|
|
|
|
|
static void
|
|
|
|
fbsd_core_info_proc_mappings (struct gdbarch *gdbarch)
|
|
|
|
{
|
|
|
|
asection *section;
|
|
|
|
unsigned char *descdata, *descend;
|
|
|
|
size_t note_size;
|
|
|
|
|
|
|
|
section = bfd_get_section_by_name (core_bfd, ".note.freebsdcore.vmmap");
|
|
|
|
if (section == NULL)
|
|
|
|
{
|
|
|
|
warning (_("unable to find mappings in core file"));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
note_size = bfd_get_section_size (section);
|
|
|
|
if (note_size < 4)
|
|
|
|
error (_("malformed core note - too short for header"));
|
|
|
|
|
|
|
|
gdb::def_vector<unsigned char> contents (note_size);
|
|
|
|
if (!bfd_get_section_contents (core_bfd, section, contents.data (),
|
|
|
|
0, note_size))
|
|
|
|
error (_("could not get core note contents"));
|
|
|
|
|
|
|
|
descdata = contents.data ();
|
|
|
|
descend = descdata + note_size;
|
|
|
|
|
|
|
|
/* Skip over the structure size. */
|
|
|
|
descdata += 4;
|
|
|
|
|
2018-10-17 20:41:30 +02:00
|
|
|
fbsd_info_proc_mappings_header (gdbarch_addr_bit (gdbarch));
|
Support 'info proc' for FreeBSD process core dumps.
- Command line arguments are obtained from the pr_psargs[] array
saved in the NT_PRPSINFO note.
- The 'cwd' and 'exe' values are obtained from the per-process file
descriptor table stored in the NT_PROCSTAT_FILES core note.
- 'mappings' is implemented by walking the array of VM map entries
stored in the NT_PROCSTAT_VMMAP core note.
- 'status' output is generated by outputting fields from
the first structure stored in the NT_PROCSTAT_PROC core note.
- 'stat' is aliased to 'status'.
gdb/ChangeLog:
* fbsd-tdep.c (KVE_STRUCTSIZE, KVE_START, KVE_END, KVE_OFFSET)
(KVE_FLAGS, KVE_PROTECTION, KVE_PATH, KINFO_VME_PROT_READ)
(KINFO_VME_PROT_WRITE, KINFO_VME_PROT_EXEC, KINFO_VME_FLAG_COW)
(KINFO_VME_FLAG_NEEDS_COPY, KINFO_VME_FLAG_NOCOREDUMP)
(KINFO_VME_FLAG_SUPER, KINFO_VME_FLAG_GROWS_UP)
(KINFO_VME_FLAG_GROWS_DOWN, KF_STRUCTSIZE, KF_TYPE, KF_FD)
(KF_PATH, KINFO_FILE_TYPE_VNODE, KINFO_FILE_FD_TYPE_CWD)
(KINFO_FILE_FD_TYPE_TEXT, SIG_WORDS, struct kinfo_proc_layout)
(kinfo_proc_layout_32, kinfo_proc_layout_i386)
(kinfo_proc_layout_64, fbsd_vm_map_entry_flags)
(fbsd_core_info_proc_mappings, fbsd_core_vnode_path)
(fbsd_core_fetch_timeval, fbsd_print_sigset)
(fbsd_core_info_proc_status, fbsd_core_info_proc): New.
(fbsd_init_abi): Install gdbarch "core_info_proc" method.
* fbsd-tdep.h (fbsd_vm_map_entry_flags): New.
2018-01-09 22:35:17 +01:00
|
|
|
while (descdata + KVE_PATH < descend)
|
|
|
|
{
|
2018-10-17 20:41:30 +02:00
|
|
|
ULONGEST structsize = bfd_get_32 (core_bfd, descdata + KVE_STRUCTSIZE);
|
Support 'info proc' for FreeBSD process core dumps.
- Command line arguments are obtained from the pr_psargs[] array
saved in the NT_PRPSINFO note.
- The 'cwd' and 'exe' values are obtained from the per-process file
descriptor table stored in the NT_PROCSTAT_FILES core note.
- 'mappings' is implemented by walking the array of VM map entries
stored in the NT_PROCSTAT_VMMAP core note.
- 'status' output is generated by outputting fields from
the first structure stored in the NT_PROCSTAT_PROC core note.
- 'stat' is aliased to 'status'.
gdb/ChangeLog:
* fbsd-tdep.c (KVE_STRUCTSIZE, KVE_START, KVE_END, KVE_OFFSET)
(KVE_FLAGS, KVE_PROTECTION, KVE_PATH, KINFO_VME_PROT_READ)
(KINFO_VME_PROT_WRITE, KINFO_VME_PROT_EXEC, KINFO_VME_FLAG_COW)
(KINFO_VME_FLAG_NEEDS_COPY, KINFO_VME_FLAG_NOCOREDUMP)
(KINFO_VME_FLAG_SUPER, KINFO_VME_FLAG_GROWS_UP)
(KINFO_VME_FLAG_GROWS_DOWN, KF_STRUCTSIZE, KF_TYPE, KF_FD)
(KF_PATH, KINFO_FILE_TYPE_VNODE, KINFO_FILE_FD_TYPE_CWD)
(KINFO_FILE_FD_TYPE_TEXT, SIG_WORDS, struct kinfo_proc_layout)
(kinfo_proc_layout_32, kinfo_proc_layout_i386)
(kinfo_proc_layout_64, fbsd_vm_map_entry_flags)
(fbsd_core_info_proc_mappings, fbsd_core_vnode_path)
(fbsd_core_fetch_timeval, fbsd_print_sigset)
(fbsd_core_info_proc_status, fbsd_core_info_proc): New.
(fbsd_init_abi): Install gdbarch "core_info_proc" method.
* fbsd-tdep.h (fbsd_vm_map_entry_flags): New.
2018-01-09 22:35:17 +01:00
|
|
|
if (structsize < KVE_PATH)
|
|
|
|
error (_("malformed core note - vmmap entry too small"));
|
|
|
|
|
2018-10-17 20:41:30 +02:00
|
|
|
ULONGEST start = bfd_get_64 (core_bfd, descdata + KVE_START);
|
|
|
|
ULONGEST end = bfd_get_64 (core_bfd, descdata + KVE_END);
|
|
|
|
ULONGEST offset = bfd_get_64 (core_bfd, descdata + KVE_OFFSET);
|
|
|
|
LONGEST flags = bfd_get_signed_32 (core_bfd, descdata + KVE_FLAGS);
|
|
|
|
LONGEST prot = bfd_get_signed_32 (core_bfd, descdata + KVE_PROTECTION);
|
|
|
|
fbsd_info_proc_mappings_entry (gdbarch_addr_bit (gdbarch), start, end,
|
|
|
|
offset, flags, prot, descdata + KVE_PATH);
|
Support 'info proc' for FreeBSD process core dumps.
- Command line arguments are obtained from the pr_psargs[] array
saved in the NT_PRPSINFO note.
- The 'cwd' and 'exe' values are obtained from the per-process file
descriptor table stored in the NT_PROCSTAT_FILES core note.
- 'mappings' is implemented by walking the array of VM map entries
stored in the NT_PROCSTAT_VMMAP core note.
- 'status' output is generated by outputting fields from
the first structure stored in the NT_PROCSTAT_PROC core note.
- 'stat' is aliased to 'status'.
gdb/ChangeLog:
* fbsd-tdep.c (KVE_STRUCTSIZE, KVE_START, KVE_END, KVE_OFFSET)
(KVE_FLAGS, KVE_PROTECTION, KVE_PATH, KINFO_VME_PROT_READ)
(KINFO_VME_PROT_WRITE, KINFO_VME_PROT_EXEC, KINFO_VME_FLAG_COW)
(KINFO_VME_FLAG_NEEDS_COPY, KINFO_VME_FLAG_NOCOREDUMP)
(KINFO_VME_FLAG_SUPER, KINFO_VME_FLAG_GROWS_UP)
(KINFO_VME_FLAG_GROWS_DOWN, KF_STRUCTSIZE, KF_TYPE, KF_FD)
(KF_PATH, KINFO_FILE_TYPE_VNODE, KINFO_FILE_FD_TYPE_CWD)
(KINFO_FILE_FD_TYPE_TEXT, SIG_WORDS, struct kinfo_proc_layout)
(kinfo_proc_layout_32, kinfo_proc_layout_i386)
(kinfo_proc_layout_64, fbsd_vm_map_entry_flags)
(fbsd_core_info_proc_mappings, fbsd_core_vnode_path)
(fbsd_core_fetch_timeval, fbsd_print_sigset)
(fbsd_core_info_proc_status, fbsd_core_info_proc): New.
(fbsd_init_abi): Install gdbarch "core_info_proc" method.
* fbsd-tdep.h (fbsd_vm_map_entry_flags): New.
2018-01-09 22:35:17 +01:00
|
|
|
|
|
|
|
descdata += structsize;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Fetch the pathname of a vnode for a single file descriptor from the
|
|
|
|
file table core note. */
|
|
|
|
|
|
|
|
static gdb::unique_xmalloc_ptr<char>
|
|
|
|
fbsd_core_vnode_path (struct gdbarch *gdbarch, int fd)
|
|
|
|
{
|
|
|
|
asection *section;
|
|
|
|
unsigned char *descdata, *descend;
|
|
|
|
size_t note_size;
|
|
|
|
|
|
|
|
section = bfd_get_section_by_name (core_bfd, ".note.freebsdcore.files");
|
|
|
|
if (section == NULL)
|
|
|
|
return nullptr;
|
|
|
|
|
|
|
|
note_size = bfd_get_section_size (section);
|
|
|
|
if (note_size < 4)
|
|
|
|
error (_("malformed core note - too short for header"));
|
|
|
|
|
|
|
|
gdb::def_vector<unsigned char> contents (note_size);
|
|
|
|
if (!bfd_get_section_contents (core_bfd, section, contents.data (),
|
|
|
|
0, note_size))
|
|
|
|
error (_("could not get core note contents"));
|
|
|
|
|
|
|
|
descdata = contents.data ();
|
|
|
|
descend = descdata + note_size;
|
|
|
|
|
|
|
|
/* Skip over the structure size. */
|
|
|
|
descdata += 4;
|
|
|
|
|
2018-09-18 23:05:47 +02:00
|
|
|
while (descdata + KF_PATH < descend)
|
Support 'info proc' for FreeBSD process core dumps.
- Command line arguments are obtained from the pr_psargs[] array
saved in the NT_PRPSINFO note.
- The 'cwd' and 'exe' values are obtained from the per-process file
descriptor table stored in the NT_PROCSTAT_FILES core note.
- 'mappings' is implemented by walking the array of VM map entries
stored in the NT_PROCSTAT_VMMAP core note.
- 'status' output is generated by outputting fields from
the first structure stored in the NT_PROCSTAT_PROC core note.
- 'stat' is aliased to 'status'.
gdb/ChangeLog:
* fbsd-tdep.c (KVE_STRUCTSIZE, KVE_START, KVE_END, KVE_OFFSET)
(KVE_FLAGS, KVE_PROTECTION, KVE_PATH, KINFO_VME_PROT_READ)
(KINFO_VME_PROT_WRITE, KINFO_VME_PROT_EXEC, KINFO_VME_FLAG_COW)
(KINFO_VME_FLAG_NEEDS_COPY, KINFO_VME_FLAG_NOCOREDUMP)
(KINFO_VME_FLAG_SUPER, KINFO_VME_FLAG_GROWS_UP)
(KINFO_VME_FLAG_GROWS_DOWN, KF_STRUCTSIZE, KF_TYPE, KF_FD)
(KF_PATH, KINFO_FILE_TYPE_VNODE, KINFO_FILE_FD_TYPE_CWD)
(KINFO_FILE_FD_TYPE_TEXT, SIG_WORDS, struct kinfo_proc_layout)
(kinfo_proc_layout_32, kinfo_proc_layout_i386)
(kinfo_proc_layout_64, fbsd_vm_map_entry_flags)
(fbsd_core_info_proc_mappings, fbsd_core_vnode_path)
(fbsd_core_fetch_timeval, fbsd_print_sigset)
(fbsd_core_info_proc_status, fbsd_core_info_proc): New.
(fbsd_init_abi): Install gdbarch "core_info_proc" method.
* fbsd-tdep.h (fbsd_vm_map_entry_flags): New.
2018-01-09 22:35:17 +01:00
|
|
|
{
|
|
|
|
ULONGEST structsize;
|
|
|
|
|
|
|
|
structsize = bfd_get_32 (core_bfd, descdata + KF_STRUCTSIZE);
|
2018-09-18 23:05:47 +02:00
|
|
|
if (structsize < KF_PATH)
|
|
|
|
error (_("malformed core note - file structure too small"));
|
Support 'info proc' for FreeBSD process core dumps.
- Command line arguments are obtained from the pr_psargs[] array
saved in the NT_PRPSINFO note.
- The 'cwd' and 'exe' values are obtained from the per-process file
descriptor table stored in the NT_PROCSTAT_FILES core note.
- 'mappings' is implemented by walking the array of VM map entries
stored in the NT_PROCSTAT_VMMAP core note.
- 'status' output is generated by outputting fields from
the first structure stored in the NT_PROCSTAT_PROC core note.
- 'stat' is aliased to 'status'.
gdb/ChangeLog:
* fbsd-tdep.c (KVE_STRUCTSIZE, KVE_START, KVE_END, KVE_OFFSET)
(KVE_FLAGS, KVE_PROTECTION, KVE_PATH, KINFO_VME_PROT_READ)
(KINFO_VME_PROT_WRITE, KINFO_VME_PROT_EXEC, KINFO_VME_FLAG_COW)
(KINFO_VME_FLAG_NEEDS_COPY, KINFO_VME_FLAG_NOCOREDUMP)
(KINFO_VME_FLAG_SUPER, KINFO_VME_FLAG_GROWS_UP)
(KINFO_VME_FLAG_GROWS_DOWN, KF_STRUCTSIZE, KF_TYPE, KF_FD)
(KF_PATH, KINFO_FILE_TYPE_VNODE, KINFO_FILE_FD_TYPE_CWD)
(KINFO_FILE_FD_TYPE_TEXT, SIG_WORDS, struct kinfo_proc_layout)
(kinfo_proc_layout_32, kinfo_proc_layout_i386)
(kinfo_proc_layout_64, fbsd_vm_map_entry_flags)
(fbsd_core_info_proc_mappings, fbsd_core_vnode_path)
(fbsd_core_fetch_timeval, fbsd_print_sigset)
(fbsd_core_info_proc_status, fbsd_core_info_proc): New.
(fbsd_init_abi): Install gdbarch "core_info_proc" method.
* fbsd-tdep.h (fbsd_vm_map_entry_flags): New.
2018-01-09 22:35:17 +01:00
|
|
|
|
|
|
|
if (bfd_get_32 (core_bfd, descdata + KF_TYPE) == KINFO_FILE_TYPE_VNODE
|
|
|
|
&& bfd_get_signed_32 (core_bfd, descdata + KF_FD) == fd)
|
|
|
|
{
|
|
|
|
char *path = (char *) descdata + KF_PATH;
|
|
|
|
return gdb::unique_xmalloc_ptr<char> (xstrdup (path));
|
|
|
|
}
|
|
|
|
|
|
|
|
descdata += structsize;
|
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Helper function to read a struct timeval. */
|
|
|
|
|
|
|
|
static void
|
|
|
|
fbsd_core_fetch_timeval (struct gdbarch *gdbarch, unsigned char *data,
|
|
|
|
LONGEST &sec, ULONGEST &usec)
|
|
|
|
{
|
|
|
|
if (gdbarch_addr_bit (gdbarch) == 64)
|
|
|
|
{
|
|
|
|
sec = bfd_get_signed_64 (core_bfd, data);
|
|
|
|
usec = bfd_get_64 (core_bfd, data + 8);
|
|
|
|
}
|
|
|
|
else if (bfd_get_arch (core_bfd) == bfd_arch_i386)
|
|
|
|
{
|
|
|
|
sec = bfd_get_signed_32 (core_bfd, data);
|
|
|
|
usec = bfd_get_32 (core_bfd, data + 4);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sec = bfd_get_signed_64 (core_bfd, data);
|
|
|
|
usec = bfd_get_32 (core_bfd, data + 8);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Print out the contents of a signal set. */
|
|
|
|
|
|
|
|
static void
|
|
|
|
fbsd_print_sigset (const char *descr, unsigned char *sigset)
|
|
|
|
{
|
|
|
|
printf_filtered ("%s: ", descr);
|
|
|
|
for (int i = 0; i < SIG_WORDS; i++)
|
|
|
|
printf_filtered ("%08x ",
|
|
|
|
(unsigned int) bfd_get_32 (core_bfd, sigset + i * 4));
|
|
|
|
printf_filtered ("\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Implement "info proc status" for a corefile. */
|
|
|
|
|
|
|
|
static void
|
|
|
|
fbsd_core_info_proc_status (struct gdbarch *gdbarch)
|
|
|
|
{
|
|
|
|
const struct kinfo_proc_layout *kp;
|
|
|
|
asection *section;
|
|
|
|
unsigned char *descdata;
|
|
|
|
int addr_bit, long_bit;
|
|
|
|
size_t note_size;
|
|
|
|
ULONGEST value;
|
|
|
|
LONGEST sec;
|
|
|
|
|
|
|
|
section = bfd_get_section_by_name (core_bfd, ".note.freebsdcore.proc");
|
|
|
|
if (section == NULL)
|
|
|
|
{
|
|
|
|
warning (_("unable to find process info in core file"));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
addr_bit = gdbarch_addr_bit (gdbarch);
|
|
|
|
if (addr_bit == 64)
|
|
|
|
kp = &kinfo_proc_layout_64;
|
|
|
|
else if (bfd_get_arch (core_bfd) == bfd_arch_i386)
|
|
|
|
kp = &kinfo_proc_layout_i386;
|
|
|
|
else
|
|
|
|
kp = &kinfo_proc_layout_32;
|
|
|
|
long_bit = gdbarch_long_bit (gdbarch);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Ensure that the note is large enough for all of the fields fetched
|
|
|
|
* by this function. In particular, the note must contain the 32-bit
|
|
|
|
* structure size, then it must be long enough to access the last
|
|
|
|
* field used (ki_rusage_ch.ru_majflt) which is the size of a long.
|
|
|
|
*/
|
|
|
|
note_size = bfd_get_section_size (section);
|
|
|
|
if (note_size < (4 + kp->ki_rusage_ch + kp->ru_majflt
|
|
|
|
+ long_bit / TARGET_CHAR_BIT))
|
|
|
|
error (_("malformed core note - too short"));
|
|
|
|
|
|
|
|
gdb::def_vector<unsigned char> contents (note_size);
|
|
|
|
if (!bfd_get_section_contents (core_bfd, section, contents.data (),
|
|
|
|
0, note_size))
|
|
|
|
error (_("could not get core note contents"));
|
|
|
|
|
|
|
|
descdata = contents.data ();
|
|
|
|
|
|
|
|
/* Skip over the structure size. */
|
|
|
|
descdata += 4;
|
|
|
|
|
|
|
|
/* Verify 'ki_layout' is 0. */
|
|
|
|
if (bfd_get_32 (core_bfd, descdata + kp->ki_layout) != 0)
|
|
|
|
{
|
|
|
|
warning (_("unsupported process information in core file"));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
printf_filtered ("Name: %.19s\n", descdata + kp->ki_comm);
|
|
|
|
printf_filtered ("Process ID: %s\n",
|
|
|
|
pulongest (bfd_get_32 (core_bfd, descdata + kp->ki_pid)));
|
|
|
|
printf_filtered ("Parent process: %s\n",
|
|
|
|
pulongest (bfd_get_32 (core_bfd, descdata + kp->ki_ppid)));
|
|
|
|
printf_filtered ("Process group: %s\n",
|
|
|
|
pulongest (bfd_get_32 (core_bfd, descdata + kp->ki_pgid)));
|
|
|
|
printf_filtered ("Session id: %s\n",
|
|
|
|
pulongest (bfd_get_32 (core_bfd, descdata + kp->ki_sid)));
|
|
|
|
|
|
|
|
/* FreeBSD 12.0 and later store a 64-bit dev_t at 'ki_tdev'. Older
|
|
|
|
kernels store a 32-bit dev_t at 'ki_tdev_freebsd11'. In older
|
|
|
|
kernels the 64-bit 'ki_tdev' field is in a reserved section of
|
|
|
|
the structure that is cleared to zero. Assume that a zero value
|
|
|
|
in ki_tdev indicates a core dump from an older kernel and use the
|
|
|
|
value in 'ki_tdev_freebsd11' instead. */
|
|
|
|
value = bfd_get_64 (core_bfd, descdata + kp->ki_tdev);
|
|
|
|
if (value == 0)
|
|
|
|
value = bfd_get_32 (core_bfd, descdata + kp->ki_tdev_freebsd11);
|
|
|
|
printf_filtered ("TTY: %s\n", pulongest (value));
|
|
|
|
printf_filtered ("TTY owner process group: %s\n",
|
|
|
|
pulongest (bfd_get_32 (core_bfd, descdata + kp->ki_tpgid)));
|
|
|
|
printf_filtered ("User IDs (real, effective, saved): %s %s %s\n",
|
|
|
|
pulongest (bfd_get_32 (core_bfd, descdata + kp->ki_ruid)),
|
|
|
|
pulongest (bfd_get_32 (core_bfd, descdata + kp->ki_uid)),
|
|
|
|
pulongest (bfd_get_32 (core_bfd, descdata + kp->ki_svuid)));
|
|
|
|
printf_filtered ("Group IDs (real, effective, saved): %s %s %s\n",
|
|
|
|
pulongest (bfd_get_32 (core_bfd, descdata + kp->ki_rgid)),
|
|
|
|
pulongest (bfd_get_32 (core_bfd, descdata + kp->ki_groups)),
|
|
|
|
pulongest (bfd_get_32 (core_bfd, descdata + kp->ki_svgid)));
|
|
|
|
printf_filtered ("Groups: ");
|
|
|
|
uint16_t ngroups = bfd_get_16 (core_bfd, descdata + kp->ki_ngroups);
|
|
|
|
for (int i = 0; i < ngroups; i++)
|
|
|
|
printf_filtered ("%s ",
|
|
|
|
pulongest (bfd_get_32 (core_bfd,
|
|
|
|
descdata + kp->ki_groups + i * 4)));
|
|
|
|
printf_filtered ("\n");
|
|
|
|
value = bfd_get (long_bit, core_bfd,
|
|
|
|
descdata + kp->ki_rusage + kp->ru_minflt);
|
|
|
|
printf_filtered ("Minor faults (no memory page): %s\n", pulongest (value));
|
|
|
|
value = bfd_get (long_bit, core_bfd,
|
|
|
|
descdata + kp->ki_rusage_ch + kp->ru_minflt);
|
|
|
|
printf_filtered ("Minor faults, children: %s\n", pulongest (value));
|
|
|
|
value = bfd_get (long_bit, core_bfd,
|
|
|
|
descdata + kp->ki_rusage + kp->ru_majflt);
|
|
|
|
printf_filtered ("Major faults (memory page faults): %s\n",
|
|
|
|
pulongest (value));
|
|
|
|
value = bfd_get (long_bit, core_bfd,
|
|
|
|
descdata + kp->ki_rusage_ch + kp->ru_majflt);
|
|
|
|
printf_filtered ("Major faults, children: %s\n", pulongest (value));
|
|
|
|
fbsd_core_fetch_timeval (gdbarch,
|
|
|
|
descdata + kp->ki_rusage + kp->ru_utime,
|
|
|
|
sec, value);
|
|
|
|
printf_filtered ("utime: %s.%06d\n", plongest (sec), (int) value);
|
|
|
|
fbsd_core_fetch_timeval (gdbarch,
|
|
|
|
descdata + kp->ki_rusage + kp->ru_stime,
|
|
|
|
sec, value);
|
|
|
|
printf_filtered ("stime: %s.%06d\n", plongest (sec), (int) value);
|
|
|
|
fbsd_core_fetch_timeval (gdbarch,
|
|
|
|
descdata + kp->ki_rusage_ch + kp->ru_utime,
|
|
|
|
sec, value);
|
|
|
|
printf_filtered ("utime, children: %s.%06d\n", plongest (sec), (int) value);
|
|
|
|
fbsd_core_fetch_timeval (gdbarch,
|
|
|
|
descdata + kp->ki_rusage_ch + kp->ru_stime,
|
|
|
|
sec, value);
|
|
|
|
printf_filtered ("stime, children: %s.%06d\n", plongest (sec), (int) value);
|
|
|
|
printf_filtered ("'nice' value: %d\n",
|
|
|
|
bfd_get_signed_8 (core_bfd, descdata + kp->ki_nice));
|
|
|
|
fbsd_core_fetch_timeval (gdbarch, descdata + kp->ki_start, sec, value);
|
|
|
|
printf_filtered ("Start time: %s.%06d\n", plongest (sec), (int) value);
|
|
|
|
printf_filtered ("Virtual memory size: %s kB\n",
|
|
|
|
pulongest (bfd_get (addr_bit, core_bfd,
|
|
|
|
descdata + kp->ki_size) / 1024));
|
|
|
|
printf_filtered ("Data size: %s pages\n",
|
|
|
|
pulongest (bfd_get (addr_bit, core_bfd,
|
|
|
|
descdata + kp->ki_dsize)));
|
|
|
|
printf_filtered ("Stack size: %s pages\n",
|
|
|
|
pulongest (bfd_get (addr_bit, core_bfd,
|
|
|
|
descdata + kp->ki_ssize)));
|
|
|
|
printf_filtered ("Text size: %s pages\n",
|
|
|
|
pulongest (bfd_get (addr_bit, core_bfd,
|
|
|
|
descdata + kp->ki_tsize)));
|
|
|
|
printf_filtered ("Resident set size: %s pages\n",
|
|
|
|
pulongest (bfd_get (addr_bit, core_bfd,
|
|
|
|
descdata + kp->ki_rssize)));
|
|
|
|
printf_filtered ("Maximum RSS: %s pages\n",
|
|
|
|
pulongest (bfd_get (long_bit, core_bfd,
|
|
|
|
descdata + kp->ki_rusage
|
|
|
|
+ kp->ru_maxrss)));
|
|
|
|
fbsd_print_sigset ("Ignored Signals", descdata + kp->ki_sigignore);
|
|
|
|
fbsd_print_sigset ("Caught Signals", descdata + kp->ki_sigcatch);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Implement the "core_info_proc" gdbarch method. */
|
|
|
|
|
|
|
|
static void
|
|
|
|
fbsd_core_info_proc (struct gdbarch *gdbarch, const char *args,
|
|
|
|
enum info_proc_what what)
|
|
|
|
{
|
|
|
|
bool do_cmdline = false;
|
|
|
|
bool do_cwd = false;
|
|
|
|
bool do_exe = false;
|
Add support for 'info proc files' on FreeBSD core dumps.
Walk the list of struct kinfo_file objects in the
NT_FREEBSD_PROCSTAT_FILES core dump note outputting a description of
each open file descriptor. For sockets, the local and remote socket
addresses are displayed in place of the file name field. For UNIX
local domain sockets, only a single address is displayed since most
UNIX sockets only have one valid address and printing both pathnames
could be quite long. The output format was somewhat inspired by the
output of the "procstat -f" command on FreeBSD, but with a few less
details and some fields were condensed.
gdb/ChangeLog:
* fbsd-tdep.c (KF_FLAGS, KF_OFFSET, KF_VNODE_TYPE, KF_SOCK_DOMAIN)
(KF_SOCK_TYPE, KF_SOCK_PROTOCOL, KF_SA_LOCAL, KF_SA_PEER)
(KINFO_FILE_TYPE_SOCKET, KINFO_FILE_TYPE_PIPE)
(KINFO_FILE_TYPE_FIFO, KINFO_FILE_TYPE_KQUEUE)
(KINFO_FILE_TYPE_CRYPTO, KINFO_FILE_TYPE_MQUEUE)
(KINFO_FILE_TYPE_SHM, KINFO_FILE_TYPE_SEM, KINFO_FILE_TYPE_PTS)
(KINFO_FILE_TYPE_PROCDESC, KINFO_FILE_FD_TYPE_ROOT)
(KINFO_FILE_FD_TYPE_JAIL, KINFO_FILE_FD_TYPE_TRACE)
(KINFO_FILE_FD_TYPE_CTTY, KINFO_FILE_FLAG_READ)
(KINFO_FILE_FLAG_WRITE, KINFO_FILE_FLAG_APPEND)
(KINFO_FILE_FLAG_ASYNC, KINFO_FILE_FLAG_FSYNC)
(KINFO_FILE_FLAG_NONBLOCK, KINFO_FILE_FLAG_DIRECT)
(KINFO_FILE_FLAG_HASLOCK, KINFO_FILE_FLAG_EXEC)
(KINFO_FILE_VTYPE_VREG, KINFO_FILE_VTYPE_VDIR)
(KINFO_FILE_VTYPE_VCHR, KINFO_FILE_VTYPE_VLNK)
(KINFO_FILE_VTYPE_VSOCK, KINFO_FILE_VTYPE_VFIFO, FBSD_AF_UNIX)
(FBSD_AF_INET, FBSD_AF_INET6, FBSD_SOCK_STREAM, FBSD_SOCK_DGRAM)
(FBSD_SOCK_SEQPACKET, FBSD_IPPROTO_ICMP, FBSD_IPPROTO_TCP)
(FBSD_IPPROTO_UDP, FBSD_IPPROTO_SCTP): New defines.
(struct fbsd_sockaddr_in, struct fbsd_sockaddr_in6)
(struct fbsd_sockaddr_un): New types.
(fbsd_file_fd, fbsd_file_type, fbsd_file_flags, fbsd_ipproto)
(fbsd_print_sockaddr_in, fbsd_print_sockaddr_in6)
(fbsd_info_proc_files_header, fbsd_info_proc_files_entry)
(fbsd_core_info_proc_files): New functions.
(fbsd_core_info_proc): List open file descriptors for IP_FILES and
IP_ALL.
* fbsd-tdep.h (fbsd_info_proc_files_header)
(fbsd_info_proc_files_entry): New.
2018-09-18 23:05:47 +02:00
|
|
|
bool do_files = false;
|
Support 'info proc' for FreeBSD process core dumps.
- Command line arguments are obtained from the pr_psargs[] array
saved in the NT_PRPSINFO note.
- The 'cwd' and 'exe' values are obtained from the per-process file
descriptor table stored in the NT_PROCSTAT_FILES core note.
- 'mappings' is implemented by walking the array of VM map entries
stored in the NT_PROCSTAT_VMMAP core note.
- 'status' output is generated by outputting fields from
the first structure stored in the NT_PROCSTAT_PROC core note.
- 'stat' is aliased to 'status'.
gdb/ChangeLog:
* fbsd-tdep.c (KVE_STRUCTSIZE, KVE_START, KVE_END, KVE_OFFSET)
(KVE_FLAGS, KVE_PROTECTION, KVE_PATH, KINFO_VME_PROT_READ)
(KINFO_VME_PROT_WRITE, KINFO_VME_PROT_EXEC, KINFO_VME_FLAG_COW)
(KINFO_VME_FLAG_NEEDS_COPY, KINFO_VME_FLAG_NOCOREDUMP)
(KINFO_VME_FLAG_SUPER, KINFO_VME_FLAG_GROWS_UP)
(KINFO_VME_FLAG_GROWS_DOWN, KF_STRUCTSIZE, KF_TYPE, KF_FD)
(KF_PATH, KINFO_FILE_TYPE_VNODE, KINFO_FILE_FD_TYPE_CWD)
(KINFO_FILE_FD_TYPE_TEXT, SIG_WORDS, struct kinfo_proc_layout)
(kinfo_proc_layout_32, kinfo_proc_layout_i386)
(kinfo_proc_layout_64, fbsd_vm_map_entry_flags)
(fbsd_core_info_proc_mappings, fbsd_core_vnode_path)
(fbsd_core_fetch_timeval, fbsd_print_sigset)
(fbsd_core_info_proc_status, fbsd_core_info_proc): New.
(fbsd_init_abi): Install gdbarch "core_info_proc" method.
* fbsd-tdep.h (fbsd_vm_map_entry_flags): New.
2018-01-09 22:35:17 +01:00
|
|
|
bool do_mappings = false;
|
|
|
|
bool do_status = false;
|
|
|
|
int pid;
|
|
|
|
|
|
|
|
switch (what)
|
|
|
|
{
|
|
|
|
case IP_MINIMAL:
|
|
|
|
do_cmdline = true;
|
|
|
|
do_cwd = true;
|
|
|
|
do_exe = true;
|
|
|
|
break;
|
|
|
|
case IP_MAPPINGS:
|
|
|
|
do_mappings = true;
|
|
|
|
break;
|
|
|
|
case IP_STATUS:
|
|
|
|
case IP_STAT:
|
|
|
|
do_status = true;
|
|
|
|
break;
|
|
|
|
case IP_CMDLINE:
|
|
|
|
do_cmdline = true;
|
|
|
|
break;
|
|
|
|
case IP_EXE:
|
|
|
|
do_exe = true;
|
|
|
|
break;
|
|
|
|
case IP_CWD:
|
|
|
|
do_cwd = true;
|
|
|
|
break;
|
Add support for 'info proc files' on FreeBSD core dumps.
Walk the list of struct kinfo_file objects in the
NT_FREEBSD_PROCSTAT_FILES core dump note outputting a description of
each open file descriptor. For sockets, the local and remote socket
addresses are displayed in place of the file name field. For UNIX
local domain sockets, only a single address is displayed since most
UNIX sockets only have one valid address and printing both pathnames
could be quite long. The output format was somewhat inspired by the
output of the "procstat -f" command on FreeBSD, but with a few less
details and some fields were condensed.
gdb/ChangeLog:
* fbsd-tdep.c (KF_FLAGS, KF_OFFSET, KF_VNODE_TYPE, KF_SOCK_DOMAIN)
(KF_SOCK_TYPE, KF_SOCK_PROTOCOL, KF_SA_LOCAL, KF_SA_PEER)
(KINFO_FILE_TYPE_SOCKET, KINFO_FILE_TYPE_PIPE)
(KINFO_FILE_TYPE_FIFO, KINFO_FILE_TYPE_KQUEUE)
(KINFO_FILE_TYPE_CRYPTO, KINFO_FILE_TYPE_MQUEUE)
(KINFO_FILE_TYPE_SHM, KINFO_FILE_TYPE_SEM, KINFO_FILE_TYPE_PTS)
(KINFO_FILE_TYPE_PROCDESC, KINFO_FILE_FD_TYPE_ROOT)
(KINFO_FILE_FD_TYPE_JAIL, KINFO_FILE_FD_TYPE_TRACE)
(KINFO_FILE_FD_TYPE_CTTY, KINFO_FILE_FLAG_READ)
(KINFO_FILE_FLAG_WRITE, KINFO_FILE_FLAG_APPEND)
(KINFO_FILE_FLAG_ASYNC, KINFO_FILE_FLAG_FSYNC)
(KINFO_FILE_FLAG_NONBLOCK, KINFO_FILE_FLAG_DIRECT)
(KINFO_FILE_FLAG_HASLOCK, KINFO_FILE_FLAG_EXEC)
(KINFO_FILE_VTYPE_VREG, KINFO_FILE_VTYPE_VDIR)
(KINFO_FILE_VTYPE_VCHR, KINFO_FILE_VTYPE_VLNK)
(KINFO_FILE_VTYPE_VSOCK, KINFO_FILE_VTYPE_VFIFO, FBSD_AF_UNIX)
(FBSD_AF_INET, FBSD_AF_INET6, FBSD_SOCK_STREAM, FBSD_SOCK_DGRAM)
(FBSD_SOCK_SEQPACKET, FBSD_IPPROTO_ICMP, FBSD_IPPROTO_TCP)
(FBSD_IPPROTO_UDP, FBSD_IPPROTO_SCTP): New defines.
(struct fbsd_sockaddr_in, struct fbsd_sockaddr_in6)
(struct fbsd_sockaddr_un): New types.
(fbsd_file_fd, fbsd_file_type, fbsd_file_flags, fbsd_ipproto)
(fbsd_print_sockaddr_in, fbsd_print_sockaddr_in6)
(fbsd_info_proc_files_header, fbsd_info_proc_files_entry)
(fbsd_core_info_proc_files): New functions.
(fbsd_core_info_proc): List open file descriptors for IP_FILES and
IP_ALL.
* fbsd-tdep.h (fbsd_info_proc_files_header)
(fbsd_info_proc_files_entry): New.
2018-09-18 23:05:47 +02:00
|
|
|
case IP_FILES:
|
|
|
|
do_files = true;
|
|
|
|
break;
|
Support 'info proc' for FreeBSD process core dumps.
- Command line arguments are obtained from the pr_psargs[] array
saved in the NT_PRPSINFO note.
- The 'cwd' and 'exe' values are obtained from the per-process file
descriptor table stored in the NT_PROCSTAT_FILES core note.
- 'mappings' is implemented by walking the array of VM map entries
stored in the NT_PROCSTAT_VMMAP core note.
- 'status' output is generated by outputting fields from
the first structure stored in the NT_PROCSTAT_PROC core note.
- 'stat' is aliased to 'status'.
gdb/ChangeLog:
* fbsd-tdep.c (KVE_STRUCTSIZE, KVE_START, KVE_END, KVE_OFFSET)
(KVE_FLAGS, KVE_PROTECTION, KVE_PATH, KINFO_VME_PROT_READ)
(KINFO_VME_PROT_WRITE, KINFO_VME_PROT_EXEC, KINFO_VME_FLAG_COW)
(KINFO_VME_FLAG_NEEDS_COPY, KINFO_VME_FLAG_NOCOREDUMP)
(KINFO_VME_FLAG_SUPER, KINFO_VME_FLAG_GROWS_UP)
(KINFO_VME_FLAG_GROWS_DOWN, KF_STRUCTSIZE, KF_TYPE, KF_FD)
(KF_PATH, KINFO_FILE_TYPE_VNODE, KINFO_FILE_FD_TYPE_CWD)
(KINFO_FILE_FD_TYPE_TEXT, SIG_WORDS, struct kinfo_proc_layout)
(kinfo_proc_layout_32, kinfo_proc_layout_i386)
(kinfo_proc_layout_64, fbsd_vm_map_entry_flags)
(fbsd_core_info_proc_mappings, fbsd_core_vnode_path)
(fbsd_core_fetch_timeval, fbsd_print_sigset)
(fbsd_core_info_proc_status, fbsd_core_info_proc): New.
(fbsd_init_abi): Install gdbarch "core_info_proc" method.
* fbsd-tdep.h (fbsd_vm_map_entry_flags): New.
2018-01-09 22:35:17 +01:00
|
|
|
case IP_ALL:
|
|
|
|
do_cmdline = true;
|
|
|
|
do_cwd = true;
|
|
|
|
do_exe = true;
|
Add support for 'info proc files' on FreeBSD core dumps.
Walk the list of struct kinfo_file objects in the
NT_FREEBSD_PROCSTAT_FILES core dump note outputting a description of
each open file descriptor. For sockets, the local and remote socket
addresses are displayed in place of the file name field. For UNIX
local domain sockets, only a single address is displayed since most
UNIX sockets only have one valid address and printing both pathnames
could be quite long. The output format was somewhat inspired by the
output of the "procstat -f" command on FreeBSD, but with a few less
details and some fields were condensed.
gdb/ChangeLog:
* fbsd-tdep.c (KF_FLAGS, KF_OFFSET, KF_VNODE_TYPE, KF_SOCK_DOMAIN)
(KF_SOCK_TYPE, KF_SOCK_PROTOCOL, KF_SA_LOCAL, KF_SA_PEER)
(KINFO_FILE_TYPE_SOCKET, KINFO_FILE_TYPE_PIPE)
(KINFO_FILE_TYPE_FIFO, KINFO_FILE_TYPE_KQUEUE)
(KINFO_FILE_TYPE_CRYPTO, KINFO_FILE_TYPE_MQUEUE)
(KINFO_FILE_TYPE_SHM, KINFO_FILE_TYPE_SEM, KINFO_FILE_TYPE_PTS)
(KINFO_FILE_TYPE_PROCDESC, KINFO_FILE_FD_TYPE_ROOT)
(KINFO_FILE_FD_TYPE_JAIL, KINFO_FILE_FD_TYPE_TRACE)
(KINFO_FILE_FD_TYPE_CTTY, KINFO_FILE_FLAG_READ)
(KINFO_FILE_FLAG_WRITE, KINFO_FILE_FLAG_APPEND)
(KINFO_FILE_FLAG_ASYNC, KINFO_FILE_FLAG_FSYNC)
(KINFO_FILE_FLAG_NONBLOCK, KINFO_FILE_FLAG_DIRECT)
(KINFO_FILE_FLAG_HASLOCK, KINFO_FILE_FLAG_EXEC)
(KINFO_FILE_VTYPE_VREG, KINFO_FILE_VTYPE_VDIR)
(KINFO_FILE_VTYPE_VCHR, KINFO_FILE_VTYPE_VLNK)
(KINFO_FILE_VTYPE_VSOCK, KINFO_FILE_VTYPE_VFIFO, FBSD_AF_UNIX)
(FBSD_AF_INET, FBSD_AF_INET6, FBSD_SOCK_STREAM, FBSD_SOCK_DGRAM)
(FBSD_SOCK_SEQPACKET, FBSD_IPPROTO_ICMP, FBSD_IPPROTO_TCP)
(FBSD_IPPROTO_UDP, FBSD_IPPROTO_SCTP): New defines.
(struct fbsd_sockaddr_in, struct fbsd_sockaddr_in6)
(struct fbsd_sockaddr_un): New types.
(fbsd_file_fd, fbsd_file_type, fbsd_file_flags, fbsd_ipproto)
(fbsd_print_sockaddr_in, fbsd_print_sockaddr_in6)
(fbsd_info_proc_files_header, fbsd_info_proc_files_entry)
(fbsd_core_info_proc_files): New functions.
(fbsd_core_info_proc): List open file descriptors for IP_FILES and
IP_ALL.
* fbsd-tdep.h (fbsd_info_proc_files_header)
(fbsd_info_proc_files_entry): New.
2018-09-18 23:05:47 +02:00
|
|
|
do_files = true;
|
Support 'info proc' for FreeBSD process core dumps.
- Command line arguments are obtained from the pr_psargs[] array
saved in the NT_PRPSINFO note.
- The 'cwd' and 'exe' values are obtained from the per-process file
descriptor table stored in the NT_PROCSTAT_FILES core note.
- 'mappings' is implemented by walking the array of VM map entries
stored in the NT_PROCSTAT_VMMAP core note.
- 'status' output is generated by outputting fields from
the first structure stored in the NT_PROCSTAT_PROC core note.
- 'stat' is aliased to 'status'.
gdb/ChangeLog:
* fbsd-tdep.c (KVE_STRUCTSIZE, KVE_START, KVE_END, KVE_OFFSET)
(KVE_FLAGS, KVE_PROTECTION, KVE_PATH, KINFO_VME_PROT_READ)
(KINFO_VME_PROT_WRITE, KINFO_VME_PROT_EXEC, KINFO_VME_FLAG_COW)
(KINFO_VME_FLAG_NEEDS_COPY, KINFO_VME_FLAG_NOCOREDUMP)
(KINFO_VME_FLAG_SUPER, KINFO_VME_FLAG_GROWS_UP)
(KINFO_VME_FLAG_GROWS_DOWN, KF_STRUCTSIZE, KF_TYPE, KF_FD)
(KF_PATH, KINFO_FILE_TYPE_VNODE, KINFO_FILE_FD_TYPE_CWD)
(KINFO_FILE_FD_TYPE_TEXT, SIG_WORDS, struct kinfo_proc_layout)
(kinfo_proc_layout_32, kinfo_proc_layout_i386)
(kinfo_proc_layout_64, fbsd_vm_map_entry_flags)
(fbsd_core_info_proc_mappings, fbsd_core_vnode_path)
(fbsd_core_fetch_timeval, fbsd_print_sigset)
(fbsd_core_info_proc_status, fbsd_core_info_proc): New.
(fbsd_init_abi): Install gdbarch "core_info_proc" method.
* fbsd-tdep.h (fbsd_vm_map_entry_flags): New.
2018-01-09 22:35:17 +01:00
|
|
|
do_mappings = true;
|
|
|
|
do_status = true;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
pid = bfd_core_file_pid (core_bfd);
|
|
|
|
if (pid != 0)
|
|
|
|
printf_filtered (_("process %d\n"), pid);
|
|
|
|
|
|
|
|
if (do_cmdline)
|
|
|
|
{
|
|
|
|
const char *cmdline;
|
|
|
|
|
|
|
|
cmdline = bfd_core_file_failing_command (core_bfd);
|
|
|
|
if (cmdline)
|
|
|
|
printf_filtered ("cmdline = '%s'\n", cmdline);
|
|
|
|
else
|
|
|
|
warning (_("Command line unavailable"));
|
|
|
|
}
|
|
|
|
if (do_cwd)
|
|
|
|
{
|
|
|
|
gdb::unique_xmalloc_ptr<char> cwd =
|
|
|
|
fbsd_core_vnode_path (gdbarch, KINFO_FILE_FD_TYPE_CWD);
|
|
|
|
if (cwd)
|
|
|
|
printf_filtered ("cwd = '%s'\n", cwd.get ());
|
|
|
|
else
|
|
|
|
warning (_("unable to read current working directory"));
|
|
|
|
}
|
|
|
|
if (do_exe)
|
|
|
|
{
|
|
|
|
gdb::unique_xmalloc_ptr<char> exe =
|
|
|
|
fbsd_core_vnode_path (gdbarch, KINFO_FILE_FD_TYPE_TEXT);
|
|
|
|
if (exe)
|
|
|
|
printf_filtered ("exe = '%s'\n", exe.get ());
|
|
|
|
else
|
|
|
|
warning (_("unable to read executable path name"));
|
|
|
|
}
|
Add support for 'info proc files' on FreeBSD core dumps.
Walk the list of struct kinfo_file objects in the
NT_FREEBSD_PROCSTAT_FILES core dump note outputting a description of
each open file descriptor. For sockets, the local and remote socket
addresses are displayed in place of the file name field. For UNIX
local domain sockets, only a single address is displayed since most
UNIX sockets only have one valid address and printing both pathnames
could be quite long. The output format was somewhat inspired by the
output of the "procstat -f" command on FreeBSD, but with a few less
details and some fields were condensed.
gdb/ChangeLog:
* fbsd-tdep.c (KF_FLAGS, KF_OFFSET, KF_VNODE_TYPE, KF_SOCK_DOMAIN)
(KF_SOCK_TYPE, KF_SOCK_PROTOCOL, KF_SA_LOCAL, KF_SA_PEER)
(KINFO_FILE_TYPE_SOCKET, KINFO_FILE_TYPE_PIPE)
(KINFO_FILE_TYPE_FIFO, KINFO_FILE_TYPE_KQUEUE)
(KINFO_FILE_TYPE_CRYPTO, KINFO_FILE_TYPE_MQUEUE)
(KINFO_FILE_TYPE_SHM, KINFO_FILE_TYPE_SEM, KINFO_FILE_TYPE_PTS)
(KINFO_FILE_TYPE_PROCDESC, KINFO_FILE_FD_TYPE_ROOT)
(KINFO_FILE_FD_TYPE_JAIL, KINFO_FILE_FD_TYPE_TRACE)
(KINFO_FILE_FD_TYPE_CTTY, KINFO_FILE_FLAG_READ)
(KINFO_FILE_FLAG_WRITE, KINFO_FILE_FLAG_APPEND)
(KINFO_FILE_FLAG_ASYNC, KINFO_FILE_FLAG_FSYNC)
(KINFO_FILE_FLAG_NONBLOCK, KINFO_FILE_FLAG_DIRECT)
(KINFO_FILE_FLAG_HASLOCK, KINFO_FILE_FLAG_EXEC)
(KINFO_FILE_VTYPE_VREG, KINFO_FILE_VTYPE_VDIR)
(KINFO_FILE_VTYPE_VCHR, KINFO_FILE_VTYPE_VLNK)
(KINFO_FILE_VTYPE_VSOCK, KINFO_FILE_VTYPE_VFIFO, FBSD_AF_UNIX)
(FBSD_AF_INET, FBSD_AF_INET6, FBSD_SOCK_STREAM, FBSD_SOCK_DGRAM)
(FBSD_SOCK_SEQPACKET, FBSD_IPPROTO_ICMP, FBSD_IPPROTO_TCP)
(FBSD_IPPROTO_UDP, FBSD_IPPROTO_SCTP): New defines.
(struct fbsd_sockaddr_in, struct fbsd_sockaddr_in6)
(struct fbsd_sockaddr_un): New types.
(fbsd_file_fd, fbsd_file_type, fbsd_file_flags, fbsd_ipproto)
(fbsd_print_sockaddr_in, fbsd_print_sockaddr_in6)
(fbsd_info_proc_files_header, fbsd_info_proc_files_entry)
(fbsd_core_info_proc_files): New functions.
(fbsd_core_info_proc): List open file descriptors for IP_FILES and
IP_ALL.
* fbsd-tdep.h (fbsd_info_proc_files_header)
(fbsd_info_proc_files_entry): New.
2018-09-18 23:05:47 +02:00
|
|
|
if (do_files)
|
|
|
|
fbsd_core_info_proc_files (gdbarch);
|
Support 'info proc' for FreeBSD process core dumps.
- Command line arguments are obtained from the pr_psargs[] array
saved in the NT_PRPSINFO note.
- The 'cwd' and 'exe' values are obtained from the per-process file
descriptor table stored in the NT_PROCSTAT_FILES core note.
- 'mappings' is implemented by walking the array of VM map entries
stored in the NT_PROCSTAT_VMMAP core note.
- 'status' output is generated by outputting fields from
the first structure stored in the NT_PROCSTAT_PROC core note.
- 'stat' is aliased to 'status'.
gdb/ChangeLog:
* fbsd-tdep.c (KVE_STRUCTSIZE, KVE_START, KVE_END, KVE_OFFSET)
(KVE_FLAGS, KVE_PROTECTION, KVE_PATH, KINFO_VME_PROT_READ)
(KINFO_VME_PROT_WRITE, KINFO_VME_PROT_EXEC, KINFO_VME_FLAG_COW)
(KINFO_VME_FLAG_NEEDS_COPY, KINFO_VME_FLAG_NOCOREDUMP)
(KINFO_VME_FLAG_SUPER, KINFO_VME_FLAG_GROWS_UP)
(KINFO_VME_FLAG_GROWS_DOWN, KF_STRUCTSIZE, KF_TYPE, KF_FD)
(KF_PATH, KINFO_FILE_TYPE_VNODE, KINFO_FILE_FD_TYPE_CWD)
(KINFO_FILE_FD_TYPE_TEXT, SIG_WORDS, struct kinfo_proc_layout)
(kinfo_proc_layout_32, kinfo_proc_layout_i386)
(kinfo_proc_layout_64, fbsd_vm_map_entry_flags)
(fbsd_core_info_proc_mappings, fbsd_core_vnode_path)
(fbsd_core_fetch_timeval, fbsd_print_sigset)
(fbsd_core_info_proc_status, fbsd_core_info_proc): New.
(fbsd_init_abi): Install gdbarch "core_info_proc" method.
* fbsd-tdep.h (fbsd_vm_map_entry_flags): New.
2018-01-09 22:35:17 +01:00
|
|
|
if (do_mappings)
|
|
|
|
fbsd_core_info_proc_mappings (gdbarch);
|
|
|
|
if (do_status)
|
|
|
|
fbsd_core_info_proc_status (gdbarch);
|
|
|
|
}
|
|
|
|
|
2016-06-16 06:33:42 +02:00
|
|
|
/* Print descriptions of FreeBSD-specific AUXV entries to FILE. */
|
|
|
|
|
|
|
|
static void
|
|
|
|
fbsd_print_auxv_entry (struct gdbarch *gdbarch, struct ui_file *file,
|
|
|
|
CORE_ADDR type, CORE_ADDR val)
|
|
|
|
{
|
2018-10-26 19:20:56 +02:00
|
|
|
const char *name = "???";
|
|
|
|
const char *description = "";
|
|
|
|
enum auxv_format format = AUXV_FORMAT_HEX;
|
2016-06-16 06:33:42 +02:00
|
|
|
|
|
|
|
switch (type)
|
|
|
|
{
|
2018-10-26 19:20:56 +02:00
|
|
|
case AT_NULL:
|
|
|
|
case AT_IGNORE:
|
|
|
|
case AT_EXECFD:
|
|
|
|
case AT_PHDR:
|
|
|
|
case AT_PHENT:
|
|
|
|
case AT_PHNUM:
|
|
|
|
case AT_PAGESZ:
|
|
|
|
case AT_BASE:
|
|
|
|
case AT_FLAGS:
|
|
|
|
case AT_ENTRY:
|
|
|
|
case AT_NOTELF:
|
|
|
|
case AT_UID:
|
|
|
|
case AT_EUID:
|
|
|
|
case AT_GID:
|
|
|
|
case AT_EGID:
|
|
|
|
default_print_auxv_entry (gdbarch, file, type, val);
|
|
|
|
return;
|
2016-06-16 06:33:42 +02:00
|
|
|
#define _TAGNAME(tag) #tag
|
|
|
|
#define TAGNAME(tag) _TAGNAME(AT_##tag)
|
|
|
|
#define TAG(tag, text, kind) \
|
|
|
|
case AT_FREEBSD_##tag: name = TAGNAME(tag); description = text; format = kind; break
|
|
|
|
TAG (EXECPATH, _("Executable path"), AUXV_FORMAT_STR);
|
|
|
|
TAG (CANARY, _("Canary for SSP"), AUXV_FORMAT_HEX);
|
|
|
|
TAG (CANARYLEN, ("Length of the SSP canary"), AUXV_FORMAT_DEC);
|
|
|
|
TAG (OSRELDATE, _("OSRELDATE"), AUXV_FORMAT_DEC);
|
|
|
|
TAG (NCPUS, _("Number of CPUs"), AUXV_FORMAT_DEC);
|
|
|
|
TAG (PAGESIZES, _("Pagesizes"), AUXV_FORMAT_HEX);
|
|
|
|
TAG (PAGESIZESLEN, _("Number of pagesizes"), AUXV_FORMAT_DEC);
|
|
|
|
TAG (TIMEKEEP, _("Pointer to timehands"), AUXV_FORMAT_HEX);
|
|
|
|
TAG (STACKPROT, _("Initial stack protection"), AUXV_FORMAT_HEX);
|
2017-10-05 18:50:01 +02:00
|
|
|
TAG (EHDRFLAGS, _("ELF header e_flags"), AUXV_FORMAT_HEX);
|
|
|
|
TAG (HWCAP, _("Machine-dependent CPU capability hints"), AUXV_FORMAT_HEX);
|
2018-10-26 19:20:56 +02:00
|
|
|
TAG (HWCAP2, _("Extension of AT_HWCAP"), AUXV_FORMAT_HEX);
|
2016-06-16 06:33:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
fprint_auxv_entry (file, name, description, format, type, val);
|
|
|
|
}
|
|
|
|
|
2017-06-28 17:14:06 +02:00
|
|
|
/* Implement the "get_siginfo_type" gdbarch method. */
|
|
|
|
|
|
|
|
static struct type *
|
|
|
|
fbsd_get_siginfo_type (struct gdbarch *gdbarch)
|
|
|
|
{
|
|
|
|
struct fbsd_gdbarch_data *fbsd_gdbarch_data;
|
|
|
|
struct type *int_type, *int32_type, *uint32_type, *long_type, *void_ptr_type;
|
|
|
|
struct type *uid_type, *pid_type;
|
|
|
|
struct type *sigval_type, *reason_type;
|
|
|
|
struct type *siginfo_type;
|
|
|
|
struct type *type;
|
|
|
|
|
|
|
|
fbsd_gdbarch_data = get_fbsd_gdbarch_data (gdbarch);
|
|
|
|
if (fbsd_gdbarch_data->siginfo_type != NULL)
|
|
|
|
return fbsd_gdbarch_data->siginfo_type;
|
|
|
|
|
|
|
|
int_type = arch_integer_type (gdbarch, gdbarch_int_bit (gdbarch),
|
|
|
|
0, "int");
|
|
|
|
int32_type = arch_integer_type (gdbarch, 32, 0, "int32_t");
|
|
|
|
uint32_type = arch_integer_type (gdbarch, 32, 1, "uint32_t");
|
|
|
|
long_type = arch_integer_type (gdbarch, gdbarch_long_bit (gdbarch),
|
|
|
|
0, "long");
|
|
|
|
void_ptr_type = lookup_pointer_type (builtin_type (gdbarch)->builtin_void);
|
|
|
|
|
|
|
|
/* union sigval */
|
|
|
|
sigval_type = arch_composite_type (gdbarch, NULL, TYPE_CODE_UNION);
|
|
|
|
TYPE_NAME (sigval_type) = xstrdup ("sigval");
|
|
|
|
append_composite_type_field (sigval_type, "sival_int", int_type);
|
|
|
|
append_composite_type_field (sigval_type, "sival_ptr", void_ptr_type);
|
|
|
|
|
|
|
|
/* __pid_t */
|
|
|
|
pid_type = arch_type (gdbarch, TYPE_CODE_TYPEDEF,
|
2017-09-27 19:02:00 +02:00
|
|
|
TYPE_LENGTH (int32_type) * TARGET_CHAR_BIT, "__pid_t");
|
2017-06-28 17:14:06 +02:00
|
|
|
TYPE_TARGET_TYPE (pid_type) = int32_type;
|
|
|
|
TYPE_TARGET_STUB (pid_type) = 1;
|
|
|
|
|
|
|
|
/* __uid_t */
|
|
|
|
uid_type = arch_type (gdbarch, TYPE_CODE_TYPEDEF,
|
2017-09-27 19:02:00 +02:00
|
|
|
TYPE_LENGTH (uint32_type) * TARGET_CHAR_BIT,
|
|
|
|
"__uid_t");
|
2017-06-28 17:14:06 +02:00
|
|
|
TYPE_TARGET_TYPE (uid_type) = uint32_type;
|
|
|
|
TYPE_TARGET_STUB (uid_type) = 1;
|
|
|
|
|
|
|
|
/* _reason */
|
|
|
|
reason_type = arch_composite_type (gdbarch, NULL, TYPE_CODE_UNION);
|
|
|
|
|
|
|
|
/* _fault */
|
|
|
|
type = arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT);
|
|
|
|
append_composite_type_field (type, "si_trapno", int_type);
|
|
|
|
append_composite_type_field (reason_type, "_fault", type);
|
|
|
|
|
|
|
|
/* _timer */
|
|
|
|
type = arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT);
|
|
|
|
append_composite_type_field (type, "si_timerid", int_type);
|
|
|
|
append_composite_type_field (type, "si_overrun", int_type);
|
|
|
|
append_composite_type_field (reason_type, "_timer", type);
|
|
|
|
|
|
|
|
/* _mesgq */
|
|
|
|
type = arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT);
|
|
|
|
append_composite_type_field (type, "si_mqd", int_type);
|
|
|
|
append_composite_type_field (reason_type, "_mesgq", type);
|
|
|
|
|
|
|
|
/* _poll */
|
|
|
|
type = arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT);
|
|
|
|
append_composite_type_field (type, "si_band", long_type);
|
|
|
|
append_composite_type_field (reason_type, "_poll", type);
|
|
|
|
|
|
|
|
/* __spare__ */
|
|
|
|
type = arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT);
|
|
|
|
append_composite_type_field (type, "__spare1__", long_type);
|
|
|
|
append_composite_type_field (type, "__spare2__",
|
|
|
|
init_vector_type (int_type, 7));
|
|
|
|
append_composite_type_field (reason_type, "__spare__", type);
|
|
|
|
|
|
|
|
/* struct siginfo */
|
|
|
|
siginfo_type = arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT);
|
|
|
|
TYPE_NAME (siginfo_type) = xstrdup ("siginfo");
|
|
|
|
append_composite_type_field (siginfo_type, "si_signo", int_type);
|
|
|
|
append_composite_type_field (siginfo_type, "si_errno", int_type);
|
|
|
|
append_composite_type_field (siginfo_type, "si_code", int_type);
|
|
|
|
append_composite_type_field (siginfo_type, "si_pid", pid_type);
|
|
|
|
append_composite_type_field (siginfo_type, "si_uid", uid_type);
|
|
|
|
append_composite_type_field (siginfo_type, "si_status", int_type);
|
|
|
|
append_composite_type_field (siginfo_type, "si_addr", void_ptr_type);
|
|
|
|
append_composite_type_field (siginfo_type, "si_value", sigval_type);
|
|
|
|
append_composite_type_field (siginfo_type, "_reason", reason_type);
|
|
|
|
|
|
|
|
fbsd_gdbarch_data->siginfo_type = siginfo_type;
|
|
|
|
|
|
|
|
return siginfo_type;
|
|
|
|
}
|
|
|
|
|
2018-11-29 22:26:31 +01:00
|
|
|
/* Implement the "gdb_signal_from_target" gdbarch method. */
|
|
|
|
|
|
|
|
static enum gdb_signal
|
|
|
|
fbsd_gdb_signal_from_target (struct gdbarch *gdbarch, int signal)
|
|
|
|
{
|
|
|
|
switch (signal)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
return GDB_SIGNAL_0;
|
|
|
|
|
|
|
|
case FREEBSD_SIGHUP:
|
|
|
|
return GDB_SIGNAL_HUP;
|
|
|
|
|
|
|
|
case FREEBSD_SIGINT:
|
|
|
|
return GDB_SIGNAL_INT;
|
|
|
|
|
|
|
|
case FREEBSD_SIGQUIT:
|
|
|
|
return GDB_SIGNAL_QUIT;
|
|
|
|
|
|
|
|
case FREEBSD_SIGILL:
|
|
|
|
return GDB_SIGNAL_ILL;
|
|
|
|
|
|
|
|
case FREEBSD_SIGTRAP:
|
|
|
|
return GDB_SIGNAL_TRAP;
|
|
|
|
|
|
|
|
case FREEBSD_SIGABRT:
|
|
|
|
return GDB_SIGNAL_ABRT;
|
|
|
|
|
|
|
|
case FREEBSD_SIGEMT:
|
|
|
|
return GDB_SIGNAL_EMT;
|
|
|
|
|
|
|
|
case FREEBSD_SIGFPE:
|
|
|
|
return GDB_SIGNAL_FPE;
|
|
|
|
|
|
|
|
case FREEBSD_SIGKILL:
|
|
|
|
return GDB_SIGNAL_KILL;
|
|
|
|
|
|
|
|
case FREEBSD_SIGBUS:
|
|
|
|
return GDB_SIGNAL_BUS;
|
|
|
|
|
|
|
|
case FREEBSD_SIGSEGV:
|
|
|
|
return GDB_SIGNAL_SEGV;
|
|
|
|
|
|
|
|
case FREEBSD_SIGSYS:
|
|
|
|
return GDB_SIGNAL_SYS;
|
|
|
|
|
|
|
|
case FREEBSD_SIGPIPE:
|
|
|
|
return GDB_SIGNAL_PIPE;
|
|
|
|
|
|
|
|
case FREEBSD_SIGALRM:
|
|
|
|
return GDB_SIGNAL_ALRM;
|
|
|
|
|
|
|
|
case FREEBSD_SIGTERM:
|
|
|
|
return GDB_SIGNAL_TERM;
|
|
|
|
|
|
|
|
case FREEBSD_SIGURG:
|
|
|
|
return GDB_SIGNAL_URG;
|
|
|
|
|
|
|
|
case FREEBSD_SIGSTOP:
|
|
|
|
return GDB_SIGNAL_STOP;
|
|
|
|
|
|
|
|
case FREEBSD_SIGTSTP:
|
|
|
|
return GDB_SIGNAL_TSTP;
|
|
|
|
|
|
|
|
case FREEBSD_SIGCONT:
|
|
|
|
return GDB_SIGNAL_CONT;
|
|
|
|
|
|
|
|
case FREEBSD_SIGCHLD:
|
|
|
|
return GDB_SIGNAL_CHLD;
|
|
|
|
|
|
|
|
case FREEBSD_SIGTTIN:
|
|
|
|
return GDB_SIGNAL_TTIN;
|
|
|
|
|
|
|
|
case FREEBSD_SIGTTOU:
|
|
|
|
return GDB_SIGNAL_TTOU;
|
|
|
|
|
|
|
|
case FREEBSD_SIGIO:
|
|
|
|
return GDB_SIGNAL_IO;
|
|
|
|
|
|
|
|
case FREEBSD_SIGXCPU:
|
|
|
|
return GDB_SIGNAL_XCPU;
|
|
|
|
|
|
|
|
case FREEBSD_SIGXFSZ:
|
|
|
|
return GDB_SIGNAL_XFSZ;
|
|
|
|
|
|
|
|
case FREEBSD_SIGVTALRM:
|
|
|
|
return GDB_SIGNAL_VTALRM;
|
|
|
|
|
|
|
|
case FREEBSD_SIGPROF:
|
|
|
|
return GDB_SIGNAL_PROF;
|
|
|
|
|
|
|
|
case FREEBSD_SIGWINCH:
|
|
|
|
return GDB_SIGNAL_WINCH;
|
|
|
|
|
|
|
|
case FREEBSD_SIGINFO:
|
|
|
|
return GDB_SIGNAL_INFO;
|
|
|
|
|
|
|
|
case FREEBSD_SIGUSR1:
|
|
|
|
return GDB_SIGNAL_USR1;
|
|
|
|
|
|
|
|
case FREEBSD_SIGUSR2:
|
|
|
|
return GDB_SIGNAL_USR2;
|
|
|
|
|
|
|
|
/* SIGTHR is the same as SIGLWP on FreeBSD. */
|
|
|
|
case FREEBSD_SIGTHR:
|
|
|
|
return GDB_SIGNAL_LWP;
|
|
|
|
|
|
|
|
case FREEBSD_SIGLIBRT:
|
|
|
|
return GDB_SIGNAL_LIBRT;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (signal >= FREEBSD_SIGRTMIN && signal <= FREEBSD_SIGRTMAX)
|
|
|
|
{
|
|
|
|
int offset = signal - FREEBSD_SIGRTMIN;
|
|
|
|
|
|
|
|
return (enum gdb_signal) ((int) GDB_SIGNAL_REALTIME_65 + offset);
|
|
|
|
}
|
|
|
|
|
|
|
|
return GDB_SIGNAL_UNKNOWN;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Implement the "gdb_signal_to_target" gdbarch method. */
|
|
|
|
|
|
|
|
static int
|
|
|
|
fbsd_gdb_signal_to_target (struct gdbarch *gdbarch,
|
|
|
|
enum gdb_signal signal)
|
|
|
|
{
|
|
|
|
switch (signal)
|
|
|
|
{
|
|
|
|
case GDB_SIGNAL_0:
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
case GDB_SIGNAL_HUP:
|
|
|
|
return FREEBSD_SIGHUP;
|
|
|
|
|
|
|
|
case GDB_SIGNAL_INT:
|
|
|
|
return FREEBSD_SIGINT;
|
|
|
|
|
|
|
|
case GDB_SIGNAL_QUIT:
|
|
|
|
return FREEBSD_SIGQUIT;
|
|
|
|
|
|
|
|
case GDB_SIGNAL_ILL:
|
|
|
|
return FREEBSD_SIGILL;
|
|
|
|
|
|
|
|
case GDB_SIGNAL_TRAP:
|
|
|
|
return FREEBSD_SIGTRAP;
|
|
|
|
|
|
|
|
case GDB_SIGNAL_ABRT:
|
|
|
|
return FREEBSD_SIGABRT;
|
|
|
|
|
|
|
|
case GDB_SIGNAL_EMT:
|
|
|
|
return FREEBSD_SIGEMT;
|
|
|
|
|
|
|
|
case GDB_SIGNAL_FPE:
|
|
|
|
return FREEBSD_SIGFPE;
|
|
|
|
|
|
|
|
case GDB_SIGNAL_KILL:
|
|
|
|
return FREEBSD_SIGKILL;
|
|
|
|
|
|
|
|
case GDB_SIGNAL_BUS:
|
|
|
|
return FREEBSD_SIGBUS;
|
|
|
|
|
|
|
|
case GDB_SIGNAL_SEGV:
|
|
|
|
return FREEBSD_SIGSEGV;
|
|
|
|
|
|
|
|
case GDB_SIGNAL_SYS:
|
|
|
|
return FREEBSD_SIGSYS;
|
|
|
|
|
|
|
|
case GDB_SIGNAL_PIPE:
|
|
|
|
return FREEBSD_SIGPIPE;
|
|
|
|
|
|
|
|
case GDB_SIGNAL_ALRM:
|
|
|
|
return FREEBSD_SIGALRM;
|
|
|
|
|
|
|
|
case GDB_SIGNAL_TERM:
|
|
|
|
return FREEBSD_SIGTERM;
|
|
|
|
|
|
|
|
case GDB_SIGNAL_URG:
|
|
|
|
return FREEBSD_SIGURG;
|
|
|
|
|
|
|
|
case GDB_SIGNAL_STOP:
|
|
|
|
return FREEBSD_SIGSTOP;
|
|
|
|
|
|
|
|
case GDB_SIGNAL_TSTP:
|
|
|
|
return FREEBSD_SIGTSTP;
|
|
|
|
|
|
|
|
case GDB_SIGNAL_CONT:
|
|
|
|
return FREEBSD_SIGCONT;
|
|
|
|
|
|
|
|
case GDB_SIGNAL_CHLD:
|
|
|
|
return FREEBSD_SIGCHLD;
|
|
|
|
|
|
|
|
case GDB_SIGNAL_TTIN:
|
|
|
|
return FREEBSD_SIGTTIN;
|
|
|
|
|
|
|
|
case GDB_SIGNAL_TTOU:
|
|
|
|
return FREEBSD_SIGTTOU;
|
|
|
|
|
|
|
|
case GDB_SIGNAL_IO:
|
|
|
|
return FREEBSD_SIGIO;
|
|
|
|
|
|
|
|
case GDB_SIGNAL_XCPU:
|
|
|
|
return FREEBSD_SIGXCPU;
|
|
|
|
|
|
|
|
case GDB_SIGNAL_XFSZ:
|
|
|
|
return FREEBSD_SIGXFSZ;
|
|
|
|
|
|
|
|
case GDB_SIGNAL_VTALRM:
|
|
|
|
return FREEBSD_SIGVTALRM;
|
|
|
|
|
|
|
|
case GDB_SIGNAL_PROF:
|
|
|
|
return FREEBSD_SIGPROF;
|
|
|
|
|
|
|
|
case GDB_SIGNAL_WINCH:
|
|
|
|
return FREEBSD_SIGWINCH;
|
|
|
|
|
|
|
|
case GDB_SIGNAL_INFO:
|
|
|
|
return FREEBSD_SIGINFO;
|
|
|
|
|
|
|
|
case GDB_SIGNAL_USR1:
|
|
|
|
return FREEBSD_SIGUSR1;
|
|
|
|
|
|
|
|
case GDB_SIGNAL_USR2:
|
|
|
|
return FREEBSD_SIGUSR2;
|
|
|
|
|
|
|
|
case GDB_SIGNAL_LWP:
|
|
|
|
return FREEBSD_SIGTHR;
|
|
|
|
|
|
|
|
case GDB_SIGNAL_LIBRT:
|
|
|
|
return FREEBSD_SIGLIBRT;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (signal >= GDB_SIGNAL_REALTIME_65
|
|
|
|
&& signal <= GDB_SIGNAL_REALTIME_126)
|
|
|
|
{
|
|
|
|
int offset = signal - GDB_SIGNAL_REALTIME_65;
|
|
|
|
|
|
|
|
return FREEBSD_SIGRTMIN + offset;
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2016-06-13 06:24:42 +02:00
|
|
|
/* Implement the "get_syscall_number" gdbarch method. */
|
|
|
|
|
|
|
|
static LONGEST
|
Use thread_info and inferior pointers more throughout
This is more preparation bits for multi-target support.
In a multi-target scenario, we need to address the case of different
processes/threads running on different targets that happen to have the
same PID/PTID. E.g., we can have both process 123 in target 1, and
process 123 in target 2, while they're in reality different processes
running on different machines. Or maybe we've loaded multiple
instances of the same core file. Etc.
To address this, in my WIP multi-target branch, threads and processes
are uniquely identified by the (process_stratum target_ops *, ptid_t)
and (process_stratum target_ops *, pid) tuples respectively. I.e.,
each process_stratum instance has its own thread/process number space.
As you can imagine, that requires passing around target_ops * pointers
in a number of functions where we're currently passing only a ptid_t
or an int. E.g., when we look up a thread_info object by ptid_t in
find_thread_ptid, the ptid_t alone isn't sufficient.
In many cases though, we already have the thread_info or inferior
pointer handy, but we "lose" it somewhere along the call stack, only
to look it up again by ptid_t/pid. Since thread_info or inferior
objects know their parent target, if we pass around thread_info or
inferior pointers when possible, we avoid having to add extra
target_ops parameters to many functions, and also, we eliminate a
number of by ptid_t/int lookups.
So that's what this patch does. In a bit more detail:
- Changes a number of functions and methods to take a thread_info or
inferior pointer instead of a ptid_t or int parameter.
- Changes a number of structure fields from ptid_t/int to inferior or
thread_info pointers.
- Uses the inferior_thread() function whenever possible instead of
inferior_ptid.
- Uses thread_info pointers directly when possible instead of the
is_running/is_stopped etc. routines that require a lookup.
- A number of functions are eliminated along the way, such as:
int valid_gdb_inferior_id (int num);
int pid_to_gdb_inferior_id (int pid);
int gdb_inferior_id_to_pid (int num);
int in_inferior_list (int pid);
- A few structures and places hold a thread_info pointer across
inferior execution, so now they take a strong reference to the
(refcounted) thread_info object to avoid the thread_info pointer
getting stale. This is done in enable_thread_stack_temporaries and
in the infcall.c code.
- Related, there's a spot in infcall.c where using a RAII object to
handle the refcount would be handy, so a gdb::ref_ptr specialization
for thread_info is added (thread_info_ref, in gdbthread.h), along
with a gdb_ref_ptr policy that works for all refcounted_object types
(in common/refcounted-object.h).
gdb/ChangeLog:
2018-06-21 Pedro Alves <palves@redhat.com>
* ada-lang.h (ada_get_task_number): Take a thread_info pointer
instead of a ptid_t. All callers adjusted.
* ada-tasks.c (ada_get_task_number): Likewise. All callers
adjusted.
(print_ada_task_info, display_current_task_id, task_command_1):
Adjust.
* breakpoint.c (watchpoint_in_thread_scope): Adjust to use
inferior_thread.
(breakpoint_kind): Adjust.
(remove_breakpoints_pid): Rename to ...
(remove_breakpoints_inf): ... this. Adjust to take an inferior
pointer. All callers adjusted.
(bpstat_clear_actions): Use inferior_thread.
(get_bpstat_thread): New.
(bpstat_do_actions): Use it.
(bpstat_check_breakpoint_conditions, bpstat_stop_status): Adjust
to take a thread_info pointer. All callers adjusted.
(set_longjmp_breakpoint_for_call_dummy, set_momentary_breakpoint)
(breakpoint_re_set_thread): Use inferior_thread.
* breakpoint.h (struct inferior): Forward declare.
(bpstat_stop_status): Update.
(remove_breakpoints_pid): Delete.
(remove_breakpoints_inf): New.
* bsd-uthread.c (bsd_uthread_target::wait)
(bsd_uthread_target::update_thread_list): Use find_thread_ptid.
* btrace.c (btrace_add_pc, btrace_enable, btrace_fetch)
(maint_btrace_packet_history_cmd)
(maint_btrace_clear_packet_history_cmd): Adjust.
(maint_btrace_clear_cmd, maint_info_btrace_cmd): Adjust to use
inferior_thread.
* cli/cli-interp.c: Include "inferior.h".
* common/refcounted-object.h (struct
refcounted_object_ref_policy): New.
* compile/compile-object-load.c: Include gdbthread.h.
(store_regs): Use inferior_thread.
* corelow.c (core_target::close): Use current_inferior.
(core_target_open): Adjust to use first_thread_of_inferior and use
the current inferior.
* ctf.c (ctf_target::close): Adjust to use current_inferior.
* dummy-frame.c (dummy_frame_id) <ptid>: Delete, replaced by ...
<thread>: ... this new field. All references adjusted.
(dummy_frame_pop, dummy_frame_discard, register_dummy_frame_dtor):
Take a thread_info pointer instead of a ptid_t.
* dummy-frame.h (dummy_frame_push, dummy_frame_pop)
(dummy_frame_discard, register_dummy_frame_dtor): Take a
thread_info pointer instead of a ptid_t.
* elfread.c: Include "inferior.h".
(elf_gnu_ifunc_resolver_stop, elf_gnu_ifunc_resolver_return_stop):
Use inferior_thread.
* eval.c (evaluate_subexp): Likewise.
* frame.c (frame_pop, has_stack_frames, find_frame_sal): Use
inferior_thread.
* gdb_proc_service.h (struct thread_info): Forward declare.
(struct ps_prochandle) <ptid>: Delete, replaced by ...
<thread>: ... this new field. All references adjusted.
* gdbarch.h, gdbarch.c: Regenerate.
* gdbarch.sh (get_syscall_number): Replace 'ptid' parameter with a
'thread' parameter. All implementations and callers adjusted.
* gdbthread.h (thread_info) <set_running>: New method.
(delete_thread, delete_thread_silent): Take a thread_info pointer
instead of a ptid.
(global_thread_id_to_ptid, ptid_to_global_thread_id): Delete.
(first_thread_of_process): Delete, replaced by ...
(first_thread_of_inferior): ... this new function. All callers
adjusted.
(any_live_thread_of_process): Delete, replaced by ...
(any_live_thread_of_inferior): ... this new function. All callers
adjusted.
(switch_to_thread, switch_to_no_thread): Declare.
(is_executing): Delete.
(enable_thread_stack_temporaries): Update comment.
<enable_thread_stack_temporaries>: Take a thread_info pointer
instead of a ptid_t. Incref the thread.
<~enable_thread_stack_temporaries>: Decref the thread.
<m_ptid>: Delete
<m_thr>: New.
(thread_stack_temporaries_enabled_p, push_thread_stack_temporary)
(get_last_thread_stack_temporary)
(value_in_thread_stack_temporaries, can_access_registers_thread):
Take a thread_info pointer instead of a ptid_t. All callers
adjusted.
* infcall.c (get_call_return_value): Use inferior_thread.
(run_inferior_call): Work with thread pointers instead of ptid_t.
(call_function_by_hand_dummy): Work with thread pointers instead
of ptid_t. Use thread_info_ref.
* infcmd.c (proceed_thread_callback): Access thread's state
directly.
(ensure_valid_thread, ensure_not_running): Use inferior_thread,
access thread's state directly.
(continue_command): Use inferior_thread.
(info_program_command): Use find_thread_ptid and access thread
state directly.
(proceed_after_attach_callback): Use thread state directly.
(notice_new_inferior): Take a thread_info pointer instead of a
ptid_t. All callers adjusted.
(exit_inferior): Take an inferior pointer instead of a pid. All
callers adjusted.
(exit_inferior_silent): New.
(detach_inferior): Delete.
(valid_gdb_inferior_id, pid_to_gdb_inferior_id)
(gdb_inferior_id_to_pid, in_inferior_list): Delete.
(detach_inferior_command, kill_inferior_command): Use
find_inferior_id instead of valid_gdb_inferior_id and
gdb_inferior_id_to_pid.
(inferior_command): Use inferior and thread pointers.
* inferior.h (struct thread_info): Forward declare.
(notice_new_inferior): Take a thread_info pointer instead of a
ptid_t. All callers adjusted.
(detach_inferior): Delete declaration.
(exit_inferior, exit_inferior_silent): Take an inferior pointer
instead of a pid. All callers adjusted.
(gdb_inferior_id_to_pid, pid_to_gdb_inferior_id, in_inferior_list)
(valid_gdb_inferior_id): Delete.
* infrun.c (follow_fork_inferior, proceed_after_vfork_done)
(handle_vfork_child_exec_or_exit, follow_exec): Adjust.
(struct displaced_step_inferior_state) <pid>: Delete, replaced by
...
<inf>: ... this new field.
<step_ptid>: Delete, replaced by ...
<step_thread>: ... this new field.
(get_displaced_stepping_state): Take an inferior pointer instead
of a pid. All callers adjusted.
(displaced_step_in_progress_any_inferior): Adjust.
(displaced_step_in_progress_thread): Take a thread pointer instead
of a ptid_t. All callers adjusted.
(displaced_step_in_progress, add_displaced_stepping_state): Take
an inferior pointer instead of a pid. All callers adjusted.
(get_displaced_step_closure_by_addr): Adjust.
(remove_displaced_stepping_state): Take an inferior pointer
instead of a pid. All callers adjusted.
(displaced_step_prepare_throw, displaced_step_prepare)
(displaced_step_fixup): Take a thread pointer instead of a ptid_t.
All callers adjusted.
(start_step_over): Adjust.
(infrun_thread_ptid_changed): Remove bit updating ptids in the
displaced step queue.
(do_target_resume): Adjust.
(fetch_inferior_event): Use inferior_thread.
(context_switch, get_inferior_stop_soon): Take an
execution_control_state pointer instead of a ptid_t. All callers
adjusted.
(switch_to_thread_cleanup): Delete.
(stop_all_threads): Use scoped_restore_current_thread.
* inline-frame.c: Include "gdbthread.h".
(inline_state) <inline_state>: Take a thread pointer instead of a
ptid_t. All callers adjusted.
<ptid>: Delete, replaced by ...
<thread>: ... this new field.
(find_inline_frame_state): Take a thread pointer instead of a
ptid_t. All callers adjusted.
(skip_inline_frames, step_into_inline_frame)
(inline_skipped_frames, inline_skipped_symbol): Take a thread
pointer instead of a ptid_t. All callers adjusted.
* inline-frame.h (skip_inline_frames, step_into_inline_frame)
(inline_skipped_frames, inline_skipped_symbol): Likewise.
* linux-fork.c (delete_checkpoint_command): Adjust to use thread
pointers directly.
* linux-nat.c (get_detach_signal): Likewise.
* linux-thread-db.c (thread_from_lwp): New 'stopped' parameter.
(thread_db_notice_clone): Adjust.
(thread_db_find_new_threads_silently)
(thread_db_find_new_threads_2, thread_db_find_new_threads_1): Take
a thread pointer instead of a ptid_t. All callers adjusted.
* mi/mi-cmd-var.c: Include "inferior.h".
(mi_cmd_var_update_iter): Update to use thread pointers.
* mi/mi-interp.c (mi_new_thread): Update to use the thread's
inferior directly.
(mi_output_running_pid, mi_inferior_count): Delete, bits factored
out to ...
(mi_output_running): ... this new function.
(mi_on_resume_1): Adjust to use it.
(mi_user_selected_context_changed): Adjust to use inferior_thread.
* mi/mi-main.c (proceed_thread): Adjust to use thread pointers
directly.
(interrupt_thread_callback): : Adjust to use thread and inferior
pointers.
* proc-service.c: Include "gdbthread.h".
(ps_pglobal_lookup): Adjust to use the thread's inferior directly.
* progspace-and-thread.c: Include "inferior.h".
* progspace.c: Include "inferior.h".
* python/py-exitedevent.c (create_exited_event_object): Adjust to
hold a reference to an inferior_object.
* python/py-finishbreakpoint.c (bpfinishpy_init): Adjust to use
inferior_thread.
* python/py-inferior.c (struct inferior_object): Give the type a
tag name instead of a typedef.
(python_on_normal_stop): No need to check if the current thread is
listed.
(inferior_to_inferior_object): Change return type to
inferior_object. All callers adjusted.
(find_thread_object): Delete, bits factored out to ...
(thread_to_thread_object): ... this new function.
* python/py-infthread.c (create_thread_object): Use
inferior_to_inferior_object.
(thpy_is_stopped): Use thread pointer directly.
(gdbpy_selected_thread): Use inferior_thread.
* python/py-record-btrace.c (btpy_list_object) <ptid>: Delete
field, replaced with ...
<thread>: ... this new field. All users adjusted.
(btpy_insn_or_gap_new): Drop const.
(btpy_list_new): Take a thread pointer instead of a ptid_t. All
callers adjusted.
* python/py-record.c: Include "gdbthread.h".
(recpy_insn_new, recpy_func_new): Take a thread pointer instead of
a ptid_t. All callers adjusted.
(gdbpy_current_recording): Use inferior_thread.
* python/py-record.h (recpy_record_object) <ptid>: Delete
field, replaced with ...
<thread>: ... this new field. All users adjusted.
(recpy_element_object) <ptid>: Delete
field, replaced with ...
<thread>: ... this new field. All users adjusted.
(recpy_insn_new, recpy_func_new): Take a thread pointer instead of
a ptid_t. All callers adjusted.
* python/py-threadevent.c: Include "gdbthread.h".
(get_event_thread): Use thread_to_thread_object.
* python/python-internal.h (struct inferior_object): Forward
declare.
(find_thread_object, find_inferior_object): Delete declarations.
(thread_to_thread_object, inferior_to_inferior_object): New
declarations.
* record-btrace.c: Include "inferior.h".
(require_btrace_thread): Use inferior_thread.
(record_btrace_frame_sniffer)
(record_btrace_tailcall_frame_sniffer): Use inferior_thread.
(get_thread_current_frame): Use scoped_restore_current_thread and
switch_to_thread.
(get_thread_current_frame): Use thread pointer directly.
(record_btrace_replay_at_breakpoint): Use thread's inferior
pointer directly.
* record-full.c: Include "inferior.h".
* regcache.c: Include "gdbthread.h".
(get_thread_arch_regcache): Use the inferior's address space
directly.
(get_thread_regcache, registers_changed_thread): New.
* regcache.h (get_thread_regcache(thread_info *thread)): New
overload.
(registers_changed_thread): New.
(remote_target) <remote_detach_1>: Swap order of parameters.
(remote_add_thread): <remote_add_thread>: Return the new thread.
(get_remote_thread_info(ptid_t)): New overload.
(remote_target::remote_notice_new_inferior): Use thread pointers
directly.
(remote_target::process_initial_stop_replies): Use
thread_info::set_running.
(remote_target::remote_detach_1, remote_target::detach)
(extended_remote_target::detach): Adjust.
* stack.c (frame_show_address): Use inferior_thread.
* target-debug.h (target_debug_print_thread_info_pp): New.
* target-delegates.c: Regenerate.
* target.c (default_thread_address_space): Delete.
(memory_xfer_partial_1): Use current_inferior.
(target_detach): Use current_inferior.
(target_thread_address_space): Delete.
(generic_mourn_inferior): Use current_inferior.
* target.h (struct target_ops) <thread_address_space>: Delete.
(target_thread_address_space): Delete.
* thread.c (init_thread_list): Use ALL_THREADS_SAFE. Use thread
pointers directly.
(delete_thread_1, delete_thread, delete_thread_silent): Take a
thread pointer instead of a ptid_t. Adjust all callers.
(ptid_to_global_thread_id, global_thread_id_to_ptid): Delete.
(first_thread_of_process): Delete, replaced by ...
(first_thread_of_inferior): ... this new function. All callers
adjusted.
(any_thread_of_process): Rename to ...
(any_thread_of_inferior): ... this, and take an inferior pointer.
(any_live_thread_of_process): Rename to ...
(any_live_thread_of_inferior): ... this, and take an inferior
pointer.
(thread_stack_temporaries_enabled_p, push_thread_stack_temporary)
(value_in_thread_stack_temporaries)
(get_last_thread_stack_temporary): Take a thread pointer instead
of a ptid_t. Adjust all callers.
(thread_info::set_running): New.
(validate_registers_access): Use inferior_thread.
(can_access_registers_ptid): Rename to ...
(can_access_registers_thread): ... this, and take a thread
pointer.
(print_thread_info_1): Adjust to compare thread pointers instead
of ptids.
(switch_to_no_thread, switch_to_thread): Make extern.
(scoped_restore_current_thread::~scoped_restore_current_thread):
Use m_thread pointer directly.
(scoped_restore_current_thread::scoped_restore_current_thread):
Use inferior_thread.
(thread_command): Use thread pointer directly.
(thread_num_make_value_helper): Use inferior_thread.
* top.c (execute_command): Use inferior_thread.
* tui/tui-interp.c: Include "inferior.h".
* varobj.c (varobj_create): Use inferior_thread.
(value_of_root_1): Use find_thread_global_id instead of
global_thread_id_to_ptid.
2018-06-21 18:09:31 +02:00
|
|
|
fbsd_get_syscall_number (struct gdbarch *gdbarch, thread_info *thread)
|
2016-06-13 06:24:42 +02:00
|
|
|
{
|
|
|
|
|
|
|
|
/* FreeBSD doesn't use gdbarch_get_syscall_number since FreeBSD
|
|
|
|
native targets fetch the system call number from the
|
|
|
|
'pl_syscall_code' member of struct ptrace_lwpinfo in fbsd_wait.
|
|
|
|
However, system call catching requires this function to be
|
|
|
|
set. */
|
|
|
|
|
|
|
|
internal_error (__FILE__, __LINE__, _("fbsd_get_sycall_number called"));
|
|
|
|
}
|
|
|
|
|
2019-03-12 21:39:02 +01:00
|
|
|
/* Read an integer symbol value from the current target. */
|
|
|
|
|
|
|
|
static LONGEST
|
|
|
|
fbsd_read_integer_by_name (struct gdbarch *gdbarch, const char *name)
|
|
|
|
{
|
|
|
|
bound_minimal_symbol ms = lookup_minimal_symbol (name, NULL, NULL);
|
|
|
|
if (ms.minsym == NULL)
|
|
|
|
error (_("Unable to resolve symbol '%s'"), name);
|
|
|
|
|
|
|
|
gdb_byte buf[4];
|
|
|
|
if (target_read_memory (BMSYMBOL_VALUE_ADDRESS (ms), buf, sizeof buf) != 0)
|
|
|
|
error (_("Unable to read value of '%s'"), name);
|
|
|
|
|
|
|
|
return extract_signed_integer (buf, sizeof buf, gdbarch_byte_order (gdbarch));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Lookup offsets of fields in the runtime linker's 'Obj_Entry'
|
|
|
|
structure needed to determine the TLS index of an object file. */
|
|
|
|
|
|
|
|
static void
|
|
|
|
fbsd_fetch_rtld_offsets (struct gdbarch *gdbarch, struct fbsd_pspace_data *data)
|
|
|
|
{
|
|
|
|
TRY
|
|
|
|
{
|
|
|
|
/* Fetch offsets from debug symbols in rtld. */
|
|
|
|
struct symbol *obj_entry_sym
|
|
|
|
= lookup_symbol_in_language ("Struct_Obj_Entry", NULL, STRUCT_DOMAIN,
|
|
|
|
language_c, NULL).symbol;
|
|
|
|
if (obj_entry_sym == NULL)
|
|
|
|
error (_("Unable to find Struct_Obj_Entry symbol"));
|
|
|
|
data->off_linkmap = lookup_struct_elt (SYMBOL_TYPE(obj_entry_sym),
|
|
|
|
"linkmap", 0).offset / 8;
|
|
|
|
data->off_tlsindex = lookup_struct_elt (SYMBOL_TYPE(obj_entry_sym),
|
|
|
|
"tlsindex", 0).offset / 8;
|
|
|
|
data->rtld_offsets_valid = true;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
CATCH (e, RETURN_MASK_ERROR)
|
|
|
|
{
|
|
|
|
data->off_linkmap = -1;
|
|
|
|
}
|
|
|
|
END_CATCH
|
|
|
|
|
|
|
|
TRY
|
|
|
|
{
|
|
|
|
/* Fetch offsets from global variables in libthr. Note that
|
|
|
|
this does not work for single-threaded processes that are not
|
|
|
|
linked against libthr. */
|
|
|
|
data->off_linkmap = fbsd_read_integer_by_name (gdbarch,
|
|
|
|
"_thread_off_linkmap");
|
|
|
|
data->off_tlsindex = fbsd_read_integer_by_name (gdbarch,
|
|
|
|
"_thread_off_tlsindex");
|
|
|
|
data->rtld_offsets_valid = true;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
CATCH (e, RETURN_MASK_ERROR)
|
|
|
|
{
|
|
|
|
data->off_linkmap = -1;
|
|
|
|
}
|
|
|
|
END_CATCH
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Helper function to read the TLS index of an object file associated
|
|
|
|
with a link map entry at LM_ADDR. */
|
|
|
|
|
|
|
|
static LONGEST
|
|
|
|
fbsd_get_tls_index (struct gdbarch *gdbarch, CORE_ADDR lm_addr)
|
|
|
|
{
|
|
|
|
struct fbsd_pspace_data *data = get_fbsd_pspace_data (current_program_space);
|
|
|
|
|
|
|
|
if (!data->rtld_offsets_valid)
|
|
|
|
fbsd_fetch_rtld_offsets (gdbarch, data);
|
|
|
|
|
|
|
|
if (data->off_linkmap == -1)
|
|
|
|
throw_error (TLS_GENERIC_ERROR,
|
|
|
|
_("Cannot fetch runtime linker structure offsets"));
|
|
|
|
|
|
|
|
/* Simulate container_of to convert from LM_ADDR to the Obj_Entry
|
|
|
|
pointer and then compute the offset of the tlsindex member. */
|
|
|
|
CORE_ADDR tlsindex_addr = lm_addr - data->off_linkmap + data->off_tlsindex;
|
|
|
|
|
|
|
|
gdb_byte buf[4];
|
|
|
|
if (target_read_memory (tlsindex_addr, buf, sizeof buf) != 0)
|
|
|
|
throw_error (TLS_GENERIC_ERROR,
|
|
|
|
_("Cannot find thread-local variables on this target"));
|
|
|
|
|
|
|
|
return extract_signed_integer (buf, sizeof buf, gdbarch_byte_order (gdbarch));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* See fbsd-tdep.h. */
|
|
|
|
|
|
|
|
CORE_ADDR
|
|
|
|
fbsd_get_thread_local_address (struct gdbarch *gdbarch, CORE_ADDR dtv_addr,
|
|
|
|
CORE_ADDR lm_addr, CORE_ADDR offset)
|
|
|
|
{
|
|
|
|
LONGEST tls_index = fbsd_get_tls_index (gdbarch, lm_addr);
|
|
|
|
|
|
|
|
gdb_byte buf[gdbarch_ptr_bit (gdbarch) / TARGET_CHAR_BIT];
|
|
|
|
if (target_read_memory (dtv_addr, buf, sizeof buf) != 0)
|
|
|
|
throw_error (TLS_GENERIC_ERROR,
|
|
|
|
_("Cannot find thread-local variables on this target"));
|
|
|
|
|
|
|
|
const struct builtin_type *builtin = builtin_type (gdbarch);
|
|
|
|
CORE_ADDR addr = gdbarch_pointer_to_address (gdbarch,
|
|
|
|
builtin->builtin_data_ptr, buf);
|
|
|
|
|
|
|
|
addr += (tls_index + 1) * TYPE_LENGTH (builtin->builtin_data_ptr);
|
|
|
|
if (target_read_memory (addr, buf, sizeof buf) != 0)
|
|
|
|
throw_error (TLS_GENERIC_ERROR,
|
|
|
|
_("Cannot find thread-local variables on this target"));
|
|
|
|
|
|
|
|
addr = gdbarch_pointer_to_address (gdbarch, builtin->builtin_data_ptr, buf);
|
|
|
|
return addr + offset;
|
|
|
|
}
|
|
|
|
|
2016-12-09 17:08:49 +01:00
|
|
|
/* To be called from GDB_OSABI_FREEBSD handlers. */
|
2013-12-03 12:35:35 +01:00
|
|
|
|
|
|
|
void
|
|
|
|
fbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
|
|
|
|
{
|
2015-12-14 06:49:52 +01:00
|
|
|
set_gdbarch_core_pid_to_str (gdbarch, fbsd_core_pid_to_str);
|
|
|
|
set_gdbarch_core_thread_name (gdbarch, fbsd_core_thread_name);
|
2017-06-28 21:50:56 +02:00
|
|
|
set_gdbarch_core_xfer_siginfo (gdbarch, fbsd_core_xfer_siginfo);
|
2013-12-03 12:35:35 +01:00
|
|
|
set_gdbarch_make_corefile_notes (gdbarch, fbsd_make_corefile_notes);
|
Support 'info proc' for FreeBSD process core dumps.
- Command line arguments are obtained from the pr_psargs[] array
saved in the NT_PRPSINFO note.
- The 'cwd' and 'exe' values are obtained from the per-process file
descriptor table stored in the NT_PROCSTAT_FILES core note.
- 'mappings' is implemented by walking the array of VM map entries
stored in the NT_PROCSTAT_VMMAP core note.
- 'status' output is generated by outputting fields from
the first structure stored in the NT_PROCSTAT_PROC core note.
- 'stat' is aliased to 'status'.
gdb/ChangeLog:
* fbsd-tdep.c (KVE_STRUCTSIZE, KVE_START, KVE_END, KVE_OFFSET)
(KVE_FLAGS, KVE_PROTECTION, KVE_PATH, KINFO_VME_PROT_READ)
(KINFO_VME_PROT_WRITE, KINFO_VME_PROT_EXEC, KINFO_VME_FLAG_COW)
(KINFO_VME_FLAG_NEEDS_COPY, KINFO_VME_FLAG_NOCOREDUMP)
(KINFO_VME_FLAG_SUPER, KINFO_VME_FLAG_GROWS_UP)
(KINFO_VME_FLAG_GROWS_DOWN, KF_STRUCTSIZE, KF_TYPE, KF_FD)
(KF_PATH, KINFO_FILE_TYPE_VNODE, KINFO_FILE_FD_TYPE_CWD)
(KINFO_FILE_FD_TYPE_TEXT, SIG_WORDS, struct kinfo_proc_layout)
(kinfo_proc_layout_32, kinfo_proc_layout_i386)
(kinfo_proc_layout_64, fbsd_vm_map_entry_flags)
(fbsd_core_info_proc_mappings, fbsd_core_vnode_path)
(fbsd_core_fetch_timeval, fbsd_print_sigset)
(fbsd_core_info_proc_status, fbsd_core_info_proc): New.
(fbsd_init_abi): Install gdbarch "core_info_proc" method.
* fbsd-tdep.h (fbsd_vm_map_entry_flags): New.
2018-01-09 22:35:17 +01:00
|
|
|
set_gdbarch_core_info_proc (gdbarch, fbsd_core_info_proc);
|
2016-06-16 06:33:42 +02:00
|
|
|
set_gdbarch_print_auxv_entry (gdbarch, fbsd_print_auxv_entry);
|
2017-06-28 17:14:06 +02:00
|
|
|
set_gdbarch_get_siginfo_type (gdbarch, fbsd_get_siginfo_type);
|
2018-11-29 22:26:31 +01:00
|
|
|
set_gdbarch_gdb_signal_from_target (gdbarch, fbsd_gdb_signal_from_target);
|
|
|
|
set_gdbarch_gdb_signal_to_target (gdbarch, fbsd_gdb_signal_to_target);
|
2016-06-13 06:24:42 +02:00
|
|
|
|
|
|
|
/* `catch syscall' */
|
|
|
|
set_xml_syscall_file_name (gdbarch, "syscalls/freebsd.xml");
|
|
|
|
set_gdbarch_get_syscall_number (gdbarch, fbsd_get_syscall_number);
|
2013-12-03 12:35:35 +01:00
|
|
|
}
|
2017-06-28 17:14:06 +02:00
|
|
|
|
|
|
|
void
|
|
|
|
_initialize_fbsd_tdep (void)
|
|
|
|
{
|
|
|
|
fbsd_gdbarch_data_handle =
|
|
|
|
gdbarch_data_register_post_init (init_fbsd_gdbarch_data);
|
2019-03-12 21:39:02 +01:00
|
|
|
fbsd_pspace_data_handle
|
|
|
|
= register_program_space_data_with_cleanup (NULL, fbsd_pspace_data_cleanup);
|
2017-06-28 17:14:06 +02:00
|
|
|
}
|