public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH v3 3/3] Update the FreeBSD system call table to match FreeBSD 12.0.
  2018-11-09 20:04 [PATCH v3 0/3] Update FreeBSD's syscall table John Baldwin
@ 2018-11-09 20:04 ` John Baldwin
  2018-11-09 20:04 ` [PATCH v3 2/3] Add an optional "alias" attribute to syscall entries John Baldwin
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 21+ messages in thread
From: John Baldwin @ 2018-11-09 20:04 UTC (permalink / raw)
  To: gdb-patches

Add a script to generate the FreeBSD XML system call table from the
sys/sys/syscall.h file in the kernel source tree.  For ABI
compatiblity system calls used by older binaries (such as
freebsd11_kevent()), the original system call name is used as an
alias.

Run this script against the current syscall.h file in FreeBSD's head
branch which is expected to be the file used in 12.0 (head is
currently in code freeze as part of the 12.0 release process).

gdb/ChangeLog:

	* syscalls/update-freebsd.sh: New file.
	* syscalls/freebsd.xml: Regenerate.
---
 gdb/ChangeLog                  |   5 ++
 gdb/syscalls/freebsd.xml       | 110 ++++++++++++++++++++++++++-------
 gdb/syscalls/update-freebsd.sh |  78 +++++++++++++++++++++++
 3 files changed, 170 insertions(+), 23 deletions(-)
 create mode 100755 gdb/syscalls/update-freebsd.sh

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 002ea3253c..2f2b02d1c0 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
+2018-11-09  John Baldwin  <jhb@FreeBSD.org>
+
+	* syscalls/update-freebsd.sh: New file.
+	* syscalls/freebsd.xml: Regenerate.
+
 2018-11-09  John Baldwin  <jhb@FreeBSD.org>
 
 	* NEWS: Add entry documenting system call aliases.
diff --git a/gdb/syscalls/freebsd.xml b/gdb/syscalls/freebsd.xml
index 810258a850..418a1ea838 100644
--- a/gdb/syscalls/freebsd.xml
+++ b/gdb/syscalls/freebsd.xml
@@ -1,4 +1,5 @@
-<?xml version="1.0"?>
+<?xml version="1.0"?> <!-- THIS FILE IS GENERATED -*- buffer-read-only: t -*-  -->
+<!-- vi:set ro: -->
 <!-- Copyright (C) 2009-2018 Free Software Foundation, Inc.
 
      Copying and distribution of this file, with or without modification,
@@ -24,12 +25,14 @@
   <syscall name="wait4" number="7"/>
   <syscall name="link" number="9"/>
   <syscall name="unlink" number="10"/>
+  <syscall name="execv" number="11"/>
   <syscall name="chdir" number="12"/>
   <syscall name="fchdir" number="13"/>
-  <syscall name="mknod" number="14"/>
+  <syscall name="freebsd11_mknod" number="14" alias="mknod"/>
   <syscall name="chmod" number="15"/>
   <syscall name="chown" number="16"/>
   <syscall name="break" number="17"/>
+  <syscall name="freebsd4_getfsstat" number="18" alias="getfsstat"/>
   <syscall name="getpid" number="20"/>
   <syscall name="mount" number="21"/>
   <syscall name="unmount" number="22"/>
@@ -50,7 +53,7 @@
   <syscall name="kill" number="37"/>
   <syscall name="getppid" number="39"/>
   <syscall name="dup" number="41"/>
-  <syscall name="pipe" number="42"/>
+  <syscall name="freebsd10_pipe" number="42" alias="pipe"/>
   <syscall name="getegid" number="43"/>
   <syscall name="profil" number="44"/>
   <syscall name="ktrace" number="45"/>
@@ -69,12 +72,16 @@
   <syscall name="chroot" number="61"/>
   <syscall name="msync" number="65"/>
   <syscall name="vfork" number="66"/>
+  <syscall name="vread" number="67"/>
+  <syscall name="vwrite" number="68"/>
   <syscall name="sbrk" number="69"/>
   <syscall name="sstk" number="70"/>
-  <syscall name="vadvise" number="72"/>
+  <syscall name="freebsd11_vadvise" number="72" alias="vadvise"/>
   <syscall name="munmap" number="73"/>
   <syscall name="mprotect" number="74"/>
   <syscall name="madvise" number="75"/>
+  <syscall name="vhangup" number="76"/>
+  <syscall name="vlimit" number="77"/>
   <syscall name="mincore" number="78"/>
   <syscall name="getgroups" number="79"/>
   <syscall name="setgroups" number="80"/>
@@ -95,6 +102,8 @@
   <syscall name="bind" number="104"/>
   <syscall name="setsockopt" number="105"/>
   <syscall name="listen" number="106"/>
+  <syscall name="vtimes" number="107"/>
+  <syscall name="vtrace" number="115"/>
   <syscall name="gettimeofday" number="116"/>
   <syscall name="getrusage" number="117"/>
   <syscall name="getsockopt" number="118"/>
@@ -119,27 +128,42 @@
   <syscall name="quotactl" number="148"/>
   <syscall name="nlm_syscall" number="154"/>
   <syscall name="nfssvc" number="155"/>
+  <syscall name="freebsd4_statfs" number="157" alias="statfs"/>
+  <syscall name="freebsd4_fstatfs" number="158" alias="fstatfs"/>
   <syscall name="lgetfh" number="160"/>
   <syscall name="getfh" number="161"/>
+  <syscall name="freebsd4_getdomainname" number="162" alias="getdomainname"/>
+  <syscall name="freebsd4_setdomainname" number="163" alias="setdomainname"/>
+  <syscall name="freebsd4_uname" number="164" alias="uname"/>
   <syscall name="sysarch" number="165"/>
   <syscall name="rtprio" number="166"/>
   <syscall name="semsys" number="169"/>
   <syscall name="msgsys" number="170"/>
   <syscall name="shmsys" number="171"/>
+  <syscall name="freebsd6_pread" number="173" alias="pread"/>
+  <syscall name="freebsd6_pwrite" number="174" alias="pwrite"/>
   <syscall name="setfib" number="175"/>
   <syscall name="ntp_adjtime" number="176"/>
   <syscall name="setgid" number="181"/>
   <syscall name="setegid" number="182"/>
   <syscall name="seteuid" number="183"/>
-  <syscall name="stat" number="188"/>
-  <syscall name="fstat" number="189"/>
-  <syscall name="lstat" number="190"/>
+  <syscall name="lfs_bmapv" number="184"/>
+  <syscall name="lfs_markv" number="185"/>
+  <syscall name="lfs_segclean" number="186"/>
+  <syscall name="lfs_segwait" number="187"/>
+  <syscall name="freebsd11_stat" number="188" alias="stat"/>
+  <syscall name="freebsd11_fstat" number="189" alias="fstat"/>
+  <syscall name="freebsd11_lstat" number="190" alias="lstat"/>
   <syscall name="pathconf" number="191"/>
   <syscall name="fpathconf" number="192"/>
   <syscall name="getrlimit" number="194"/>
   <syscall name="setrlimit" number="195"/>
-  <syscall name="getdirentries" number="196"/>
+  <syscall name="freebsd11_getdirentries" number="196" alias="getdirentries"/>
+  <syscall name="freebsd6_mmap" number="197" alias="mmap"/>
   <syscall name="__syscall" number="198"/>
+  <syscall name="freebsd6_lseek" number="199" alias="lseek"/>
+  <syscall name="freebsd6_truncate" number="200" alias="truncate"/>
+  <syscall name="freebsd6_ftruncate" number="201" alias="ftruncate"/>
   <syscall name="__sysctl" number="202"/>
   <syscall name="mlock" number="203"/>
   <syscall name="munlock" number="204"/>
@@ -147,15 +171,16 @@
   <syscall name="futimes" number="206"/>
   <syscall name="getpgid" number="207"/>
   <syscall name="poll" number="209"/>
-  <syscall name="freebsd7___semctl" number="220"/>
+  <syscall name="freebsd7___semctl" number="220" alias="__semctl"/>
   <syscall name="semget" number="221"/>
   <syscall name="semop" number="222"/>
-  <syscall name="freebsd7_msgctl" number="224"/>
+  <syscall name="semconfig" number="223"/>
+  <syscall name="freebsd7_msgctl" number="224" alias="msgctl"/>
   <syscall name="msgget" number="225"/>
   <syscall name="msgsnd" number="226"/>
   <syscall name="msgrcv" number="227"/>
   <syscall name="shmat" number="228"/>
-  <syscall name="freebsd7_shmctl" number="229"/>
+  <syscall name="freebsd7_shmctl" number="229" alias="shmctl"/>
   <syscall name="shmdt" number="230"/>
   <syscall name="shmget" number="231"/>
   <syscall name="clock_gettime" number="232"/>
@@ -170,6 +195,7 @@
   <syscall name="ffclock_getcounter" number="241"/>
   <syscall name="ffclock_setestimate" number="242"/>
   <syscall name="ffclock_getestimate" number="243"/>
+  <syscall name="clock_nanosleep" number="244"/>
   <syscall name="clock_getcpuclockid2" number="247"/>
   <syscall name="ntp_gettime" number="248"/>
   <syscall name="minherit" number="250"/>
@@ -180,18 +206,19 @@
   <syscall name="aio_read" number="255"/>
   <syscall name="aio_write" number="256"/>
   <syscall name="lio_listio" number="257"/>
-  <syscall name="getdents" number="272"/>
+  <syscall name="freebsd11_getdents" number="272" alias="getdents"/>
   <syscall name="lchmod" number="274"/>
   <syscall name="netbsd_lchown" number="275"/>
   <syscall name="lutimes" number="276"/>
   <syscall name="netbsd_msync" number="277"/>
-  <syscall name="nstat" number="278"/>
-  <syscall name="nfstat" number="279"/>
-  <syscall name="nlstat" number="280"/>
+  <syscall name="freebsd11_nstat" number="278" alias="nstat"/>
+  <syscall name="freebsd11_nfstat" number="279" alias="nfstat"/>
+  <syscall name="freebsd11_nlstat" number="280" alias="nlstat"/>
   <syscall name="preadv" number="289"/>
   <syscall name="pwritev" number="290"/>
+  <syscall name="freebsd4_fhstatfs" number="297" alias="fhstatfs"/>
   <syscall name="fhopen" number="298"/>
-  <syscall name="fhstat" number="299"/>
+  <syscall name="freebsd11_fhstat" number="299" alias="fhstat"/>
   <syscall name="modnext" number="300"/>
   <syscall name="modstat" number="301"/>
   <syscall name="modfnext" number="302"/>
@@ -205,11 +232,17 @@
   <syscall name="getsid" number="310"/>
   <syscall name="setresuid" number="311"/>
   <syscall name="setresgid" number="312"/>
+  <syscall name="signanosleep" number="313"/>
   <syscall name="aio_return" number="314"/>
   <syscall name="aio_suspend" number="315"/>
   <syscall name="aio_cancel" number="316"/>
   <syscall name="aio_error" number="317"/>
+  <syscall name="freebsd6_aio_read" number="318" alias="aio_read"/>
+  <syscall name="freebsd6_aio_write" number="319" alias="aio_write"/>
+  <syscall name="freebsd6_lio_listio" number="320" alias="lio_listio"/>
   <syscall name="yield" number="321"/>
+  <syscall name="thr_sleep" number="322"/>
+  <syscall name="thr_wakeup" number="323"/>
   <syscall name="mlockall" number="324"/>
   <syscall name="munlockall" number="325"/>
   <syscall name="__getcwd" number="326"/>
@@ -222,12 +255,15 @@
   <syscall name="sched_get_priority_min" number="333"/>
   <syscall name="sched_rr_get_interval" number="334"/>
   <syscall name="utrace" number="335"/>
+  <syscall name="freebsd4_sendfile" number="336" alias="sendfile"/>
   <syscall name="kldsym" number="337"/>
   <syscall name="jail" number="338"/>
   <syscall name="nnpfs_syscall" number="339"/>
   <syscall name="sigprocmask" number="340"/>
   <syscall name="sigsuspend" number="341"/>
+  <syscall name="freebsd4_sigaction" number="342" alias="sigaction"/>
   <syscall name="sigpending" number="343"/>
+  <syscall name="freebsd4_sigreturn" number="344" alias="sigreturn"/>
   <syscall name="sigtimedwait" number="345"/>
   <syscall name="sigwaitinfo" number="346"/>
   <syscall name="__acl_get_file" number="347"/>
@@ -246,14 +282,26 @@
   <syscall name="getresuid" number="360"/>
   <syscall name="getresgid" number="361"/>
   <syscall name="kqueue" number="362"/>
-  <syscall name="kevent" number="363"/>
+  <syscall name="freebsd11_kevent" number="363" alias="kevent"/>
+  <syscall name="__cap_get_proc" number="364"/>
+  <syscall name="__cap_set_proc" number="365"/>
+  <syscall name="__cap_get_fd" number="366"/>
+  <syscall name="__cap_get_file" number="367"/>
+  <syscall name="__cap_set_fd" number="368"/>
+  <syscall name="__cap_set_file" number="369"/>
   <syscall name="extattr_set_fd" number="371"/>
   <syscall name="extattr_get_fd" number="372"/>
   <syscall name="extattr_delete_fd" number="373"/>
   <syscall name="__setugid" number="374"/>
+  <syscall name="nfsclnt" number="375"/>
   <syscall name="eaccess" number="376"/>
   <syscall name="afs3_syscall" number="377"/>
   <syscall name="nmount" number="378"/>
+  <syscall name="kse_exit" number="379"/>
+  <syscall name="kse_wakeup" number="380"/>
+  <syscall name="kse_create" number="381"/>
+  <syscall name="kse_thr_interrupt" number="382"/>
+  <syscall name="kse_release" number="383"/>
   <syscall name="__mac_get_proc" number="384"/>
   <syscall name="__mac_set_proc" number="385"/>
   <syscall name="__mac_get_fd" number="386"/>
@@ -265,10 +313,10 @@
   <syscall name="uuidgen" number="392"/>
   <syscall name="sendfile" number="393"/>
   <syscall name="mac_syscall" number="394"/>
-  <syscall name="getfsstat" number="395"/>
-  <syscall name="statfs" number="396"/>
-  <syscall name="fstatfs" number="397"/>
-  <syscall name="fhstatfs" number="398"/>
+  <syscall name="freebsd11_getfsstat" number="395" alias="getfsstat"/>
+  <syscall name="freebsd11_statfs" number="396" alias="statfs"/>
+  <syscall name="freebsd11_fstatfs" number="397" alias="fstatfs"/>
+  <syscall name="freebsd11_fhstatfs" number="398" alias="fhstatfs"/>
   <syscall name="ksem_close" number="400"/>
   <syscall name="ksem_post" number="401"/>
   <syscall name="ksem_wait" number="402"/>
@@ -304,6 +352,7 @@
   <syscall name="extattr_list_fd" number="437"/>
   <syscall name="extattr_list_file" number="438"/>
   <syscall name="extattr_list_link" number="439"/>
+  <syscall name="kse_switchin" number="440"/>
   <syscall name="ksem_timedwait" number="441"/>
   <syscall name="thr_suspend" number="442"/>
   <syscall name="thr_wake" number="443"/>
@@ -352,12 +401,12 @@
   <syscall name="fchmodat" number="490"/>
   <syscall name="fchownat" number="491"/>
   <syscall name="fexecve" number="492"/>
-  <syscall name="fstatat" number="493"/>
+  <syscall name="freebsd11_fstatat" number="493" alias="fstatat"/>
   <syscall name="futimesat" number="494"/>
   <syscall name="linkat" number="495"/>
   <syscall name="mkdirat" number="496"/>
   <syscall name="mkfifoat" number="497"/>
-  <syscall name="mknodat" number="498"/>
+  <syscall name="freebsd11_mknodat" number="498" alias="mknodat"/>
   <syscall name="openat" number="499"/>
   <syscall name="readlinkat" number="500"/>
   <syscall name="renameat" number="501"/>
@@ -373,6 +422,7 @@
   <syscall name="msgctl" number="511"/>
   <syscall name="shmctl" number="512"/>
   <syscall name="lpathconf" number="513"/>
+  <syscall name="cap_new" number="514"/>
   <syscall name="__cap_rights_get" number="515"/>
   <syscall name="cap_enter" number="516"/>
   <syscall name="cap_getmode" number="517"/>
@@ -407,4 +457,18 @@
   <syscall name="utimensat" number="547"/>
   <syscall name="numa_getaffinity" number="548"/>
   <syscall name="numa_setaffinity" number="549"/>
+  <syscall name="fdatasync" number="550"/>
+  <syscall name="fstat" number="551"/>
+  <syscall name="fstatat" number="552"/>
+  <syscall name="fhstat" number="553"/>
+  <syscall name="getdirentries" number="554"/>
+  <syscall name="statfs" number="555"/>
+  <syscall name="fstatfs" number="556"/>
+  <syscall name="getfsstat" number="557"/>
+  <syscall name="fhstatfs" number="558"/>
+  <syscall name="mknodat" number="559"/>
+  <syscall name="kevent" number="560"/>
+  <syscall name="cpuset_getdomain" number="561"/>
+  <syscall name="cpuset_setdomain" number="562"/>
+  <syscall name="getrandom" number="563"/>
 </syscalls_info>
diff --git a/gdb/syscalls/update-freebsd.sh b/gdb/syscalls/update-freebsd.sh
new file mode 100755
index 0000000000..d109367042
--- /dev/null
+++ b/gdb/syscalls/update-freebsd.sh
@@ -0,0 +1,78 @@
+#! /bin/sh
+
+# Copyright (C) 2018 Free Software Foundation, Inc.
+#
+# This file is part of GDB.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Usage: update-freebsd.sh <path-to-syscall.h>
+# Update the freebsd.xml file.
+#
+# FreeBSD uses the same list of system calls on all architectures.
+# The list is defined in the sys/kern/syscalls.master file in the
+# FreeBSD source tree.  This file is used as an input to generate
+# several files that are also stored in FreeBSD's source tree.  This
+# script parses one of those generated files (sys/sys/syscall.h)
+# rather than syscalls.master as syscall.h is easier to parse.
+
+if [ $# -ne 1 ]; then
+   echo "Error: Path to syscall.h missing. Aborting."
+   echo "Usage: update-gnulib.sh <path-to-syscall.h>"
+   exit 1
+fi
+
+cat > freebsd.xml.tmp <<EOF
+<?xml version="1.0"?> <!-- THIS FILE IS GENERATED -*- buffer-read-only: t -*-  -->
+<!-- vi:set ro: -->
+<!-- Copyright (C) 2009-2018 Free Software Foundation, Inc.
+
+     Copying and distribution of this file, with or without modification,
+     are permitted in any medium without royalty provided the copyright
+     notice and this notice are preserved.  -->
+
+<!DOCTYPE feature SYSTEM "gdb-syscalls.dtd">
+
+<!-- This file was generated using the following file:
+
+     /usr/src/sys/sys/syscall.h
+
+     The file mentioned above belongs to the FreeBSD Kernel.  -->
+
+<syscalls_info>
+EOF
+
+awk '
+/MAXSYSCALL/ {
+    next
+}
+/^#define/ {
+    sub(/^SYS_/,"",$2);
+    printf "  <syscall name=\"%s\" number=\"%s\"", $2, $3
+    if (sub(/^freebsd[0-9]*_/,"",$2) != 0)
+        printf " alias=\"%s\"", $2
+    printf "/>\n"
+}
+/\/\* [0-9]* is obsolete [a-z_]* \*\// {
+    printf "  <syscall name=\"%s\" number=\"%s\"/>\n", $5, $2
+}
+/\/\* [0-9]* is freebsd[0-9]* [a-z_]* \*\// {
+    printf "  <syscall name=\"%s_%s\" number=\"%s\" alias=\"%s\"/>\n", $4, $5, $2, $5
+}' $1 >> freebsd.xml.tmp
+
+cat >> freebsd.xml.tmp <<EOF
+</syscalls_info>
+EOF
+
+../../move-if-change freebsd.xml.tmp freebsd.xml
-- 
2.18.0

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [PATCH v3 2/3] Add an optional "alias" attribute to syscall entries.
  2018-11-09 20:04 [PATCH v3 0/3] Update FreeBSD's syscall table John Baldwin
  2018-11-09 20:04 ` [PATCH v3 3/3] Update the FreeBSD system call table to match FreeBSD 12.0 John Baldwin
@ 2018-11-09 20:04 ` John Baldwin
  2018-11-09 20:18   ` Eli Zaretskii
  2018-11-09 20:04 ` [PATCH v3 1/3] Change get_syscalls_by_group to append to an existing vector of integers John Baldwin
  2018-11-26 20:31 ` [PATCH v3 0/3] Update FreeBSD's syscall table John Baldwin
  3 siblings, 1 reply; 21+ messages in thread
From: John Baldwin @ 2018-11-09 20:04 UTC (permalink / raw)
  To: gdb-patches

When setting a syscall catchpoint by name, catch syscalls whose name
or alias matches the requested string.

When the ABI of a system call is changed in the FreeBSD kernel, this
is implemented by leaving a compatibility system call using the old
ABI at the existing "slot" and allocating a new system call for the
version using the new ABI.  For example, new fields were added to the
'struct kevent' used by the kevent() system call in FreeBSD 12.  The
previous kevent() system call in FreeBSD 12 kernels is now called
freebsd11_kevent() and is still used by older binaries compiled
against the older ABI.  The freebsd11_kevent() system call can be
tagged with an "alias" attribute of "kevent" permitting 'catch syscall
kevent' to catch both system calls and providing the expected user
behavior for both old and new binaries.  It also provides the expected
behavior if GDB is compiled on an older host (such as a FreeBSD 11
host).

gdb/ChangeLog:

	* NEWS: Add entry documenting system call aliases.
	* break-catch-syscall.c (catch_syscall_split_args): Pass 'result'
	to get_syscalls_by_name.
	* gdbarch.sh (UNKNOWN_SYSCALL): Remove.
	* gdbarch.h: Regenerate.
	* syscalls/gdb-syscalls.dtd (syscall): Add alias attribute.
	* xml-syscall.c [!HAVE_LIBEXPAT] (get_syscalls_by_name): Rename
	from get_syscall_by_name.  Now accepts a reference to a vector of
	integers and returns a bool.
	[HAVE_LIBEXPAT] (struct syscall_desc): Add alias member.
	(syscall_create_syscall_desc): Add alias parameter and pass it to
	syscall_desc constructor.
	(syscall_start_syscall): Handle alias attribute.
	(syscall_attr): Add alias attribute.
	(xml_get_syscalls_by_name): Rename from xml_get_syscall_number.
	Now accepts a reference to a vector of integers and returns a
	bool.  Add syscalls whose alias or name matches the requested
	name.
	(get_syscalls_by_name): Rename from get_syscall_by_name.  Now
	accepts a reference to a vector of integers and returns a bool.
	* xml-syscall.h (get_syscalls_by_name): Likewise.
---
 gdb/ChangeLog                 | 24 ++++++++++++++
 gdb/NEWS                      |  5 +++
 gdb/break-catch-syscall.c     | 11 ++-----
 gdb/gdbarch.h                 |  3 --
 gdb/gdbarch.sh                |  3 --
 gdb/syscalls/gdb-syscalls.dtd |  1 +
 gdb/xml-syscall.c             | 61 ++++++++++++++++++++---------------
 gdb/xml-syscall.h             | 10 +++---
 8 files changed, 74 insertions(+), 44 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 81faa2994d..002ea3253c 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,27 @@
+2018-11-09  John Baldwin  <jhb@FreeBSD.org>
+
+	* NEWS: Add entry documenting system call aliases.
+	* break-catch-syscall.c (catch_syscall_split_args): Pass 'result'
+	to get_syscalls_by_name.
+	* gdbarch.sh (UNKNOWN_SYSCALL): Remove.
+	* gdbarch.h: Regenerate.
+	* syscalls/gdb-syscalls.dtd (syscall): Add alias attribute.
+	* xml-syscall.c [!HAVE_LIBEXPAT] (get_syscalls_by_name): Rename
+	from get_syscall_by_name.  Now accepts a reference to a vector of
+	integers and returns a bool.
+	[HAVE_LIBEXPAT] (struct syscall_desc): Add alias member.
+	(syscall_create_syscall_desc): Add alias parameter and pass it to
+	syscall_desc constructor.
+	(syscall_start_syscall): Handle alias attribute.
+	(syscall_attr): Add alias attribute.
+	(xml_get_syscalls_by_name): Rename from xml_get_syscall_number.
+	Now accepts a reference to a vector of integers and returns a
+	bool.  Add syscalls whose alias or name matches the requested
+	name.
+	(get_syscalls_by_name): Rename from get_syscall_by_name.  Now
+	accepts a reference to a vector of integers and returns a bool.
+	* xml-syscall.h (get_syscalls_by_name): Likewise.
+
 2018-11-09  John Baldwin  <jhb@FreeBSD.org>
 
 	* break-catch-syscall.c (catch_syscall_split_args): Pass 'result'
diff --git a/gdb/NEWS b/gdb/NEWS
index ff9b192a38..ff225f361e 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -38,6 +38,11 @@
   requires the use of a keyword.  Selecting a frame by level is
   unchanged.  The MI comment "-stack-select-frame" is unchanged.
 
+* System call catchpoints now support system call aliases.  This is
+  used with the FreeBSD system call list so that system call
+  catchpoints will also trigger for legacy system call numbers used by
+  older FreeBSD binaries.
+
 * New targets
 
   NXP S12Z		s12z-*-elf
diff --git a/gdb/break-catch-syscall.c b/gdb/break-catch-syscall.c
index f3740a1673..61c667a261 100644
--- a/gdb/break-catch-syscall.c
+++ b/gdb/break-catch-syscall.c
@@ -419,18 +419,13 @@ catch_syscall_split_args (const char *arg)
 	}
       else
 	{
-	  /* We have a name.  Let's check if it's valid and convert it
-	     to a number.  */
-	  get_syscall_by_name (gdbarch, cur_name, &s);
-
-	  if (s.number == UNKNOWN_SYSCALL)
+	  /* We have a name.  Let's check if it's valid and fetch a
+	     list of matching numbers.  */
+	  if (!get_syscalls_by_name (gdbarch, cur_name, result))
 	    /* Here we have to issue an error instead of a warning,
 	       because GDB cannot do anything useful if there's no
 	       syscall number to be caught.  */
 	    error (_("Unknown syscall name '%s'."), cur_name);
-
-	  /* Ok, it's valid.  */
-	  result.push_back (s.number);
 	}
     }
 
diff --git a/gdb/gdbarch.h b/gdb/gdbarch.h
index 2cb6961083..8e354d2278 100644
--- a/gdb/gdbarch.h
+++ b/gdb/gdbarch.h
@@ -1569,9 +1569,6 @@ typedef ULONGEST (gdbarch_type_align_ftype) (struct gdbarch *gdbarch, struct typ
 extern ULONGEST gdbarch_type_align (struct gdbarch *gdbarch, struct type *type);
 extern void set_gdbarch_type_align (struct gdbarch *gdbarch, gdbarch_type_align_ftype *type_align);
 
-/* Definition for an unknown syscall, used basically in error-cases.  */
-#define UNKNOWN_SYSCALL (-1)
-
 extern struct gdbarch_tdep *gdbarch_tdep (struct gdbarch *gdbarch);
 
 
diff --git a/gdb/gdbarch.sh b/gdb/gdbarch.sh
index bbfa8d2205..ff0e751f48 100755
--- a/gdb/gdbarch.sh
+++ b/gdb/gdbarch.sh
@@ -1393,9 +1393,6 @@ done
 # close it off
 cat <<EOF
 
-/* Definition for an unknown syscall, used basically in error-cases.  */
-#define UNKNOWN_SYSCALL (-1)
-
 extern struct gdbarch_tdep *gdbarch_tdep (struct gdbarch *gdbarch);
 
 
diff --git a/gdb/syscalls/gdb-syscalls.dtd b/gdb/syscalls/gdb-syscalls.dtd
index c2aa478aa4..6aa73f288a 100644
--- a/gdb/syscalls/gdb-syscalls.dtd
+++ b/gdb/syscalls/gdb-syscalls.dtd
@@ -12,4 +12,5 @@
 <!ATTLIST syscall
 	name			CDATA	#REQUIRED
 	number			CDATA	#REQUIRED
+	alias			CDATA	#IMPLIED
 	groups			CDATA	#IMPLIED>
diff --git a/gdb/xml-syscall.c b/gdb/xml-syscall.c
index 664cee77dd..0e763045b4 100644
--- a/gdb/xml-syscall.c
+++ b/gdb/xml-syscall.c
@@ -61,13 +61,12 @@ get_syscall_by_number (struct gdbarch *gdbarch,
   s->name = NULL;
 }
 
-void
-get_syscall_by_name (struct gdbarch *gdbarch, const char *syscall_name,
-		     struct syscall *s)
+bool
+get_syscalls_by_name (struct gdbarch *gdbarch, const char *syscall_name,
+		      std::vector<int> &syscall_numbers)
 {
   syscall_warn_user ();
-  s->number = UNKNOWN_SYSCALL;
-  s->name = syscall_name;
+  return false;
 }
 
 const char **
@@ -97,8 +96,8 @@ get_syscall_group_names (struct gdbarch *gdbarch)
 /* Structure which describes a syscall.  */
 struct syscall_desc
 {
-  syscall_desc (int number_, std::string name_)
-  : number (number_), name (name_)
+  syscall_desc (int number_, std::string name_, std::string alias_)
+  : number (number_), name (name_), alias (alias_)
   {}
 
   /* The syscall number.  */
@@ -108,6 +107,10 @@ struct syscall_desc
   /* The syscall name.  */
 
   std::string name;
+
+  /* An optional alias.  */
+
+  std::string alias;
 };
 
 typedef std::unique_ptr<syscall_desc> syscall_desc_up;
@@ -207,10 +210,11 @@ syscall_group_add_syscall (struct syscalls_info *syscalls_info,
 
 static void
 syscall_create_syscall_desc (struct syscalls_info *syscalls_info,
-			     const char *name, int number,
+			     const char *name, int number, const char *alias,
 			     char *groups)
 {
-  syscall_desc *sysdesc = new syscall_desc (number, name);
+  syscall_desc *sysdesc = new syscall_desc (number, name,
+					    alias != NULL ? alias : "");
 
   syscalls_info->syscalls.emplace_back (sysdesc);
 
@@ -235,6 +239,7 @@ syscall_start_syscall (struct gdb_xml_parser *parser,
   /* syscall info.  */
   char *name = NULL;
   int number = 0;
+  char *alias = NULL;
   char *groups = NULL;
 
   for (const gdb_xml_value &attr : attributes)
@@ -243,6 +248,8 @@ syscall_start_syscall (struct gdb_xml_parser *parser,
         name = (char *) attr.value.get ();
       else if (strcmp (attr.name, "number") == 0)
         number = * (ULONGEST *) attr.value.get ();
+      else if (strcmp (attr.name, "alias") == 0)
+        alias = (char *) attr.value.get ();
       else if (strcmp (attr.name, "groups") == 0)
         groups = (char *) attr.value.get ();
       else
@@ -251,7 +258,8 @@ syscall_start_syscall (struct gdb_xml_parser *parser,
     }
 
   gdb_assert (name);
-  syscall_create_syscall_desc (data->syscalls_info, name, number, groups);
+  syscall_create_syscall_desc (data->syscalls_info, name, number, alias,
+			       groups);
 }
 
 
@@ -259,6 +267,7 @@ syscall_start_syscall (struct gdb_xml_parser *parser,
 static const struct gdb_xml_attribute syscall_attr[] = {
   { "number", GDB_XML_AF_NONE, gdb_xml_parse_attr_ulongest, NULL },
   { "name", GDB_XML_AF_NONE, NULL, NULL },
+  { "alias", GDB_XML_AF_OPTIONAL, NULL, NULL },
   { "groups", GDB_XML_AF_OPTIONAL, NULL, NULL },
   { NULL, GDB_XML_AF_NONE, NULL, NULL }
 };
@@ -390,21 +399,22 @@ syscall_group_get_group_by_name (const struct syscalls_info *syscalls_info,
   return NULL;
 }
 
-static int
-xml_get_syscall_number (struct gdbarch *gdbarch,
-                        const char *syscall_name)
+static bool
+xml_get_syscalls_by_name (struct gdbarch *gdbarch, const char *syscall_name,
+			  std::vector<int> &syscall_numbers)
 {
   struct syscalls_info *syscalls_info = gdbarch_syscalls_info (gdbarch);
 
-  if (syscalls_info == NULL
-      || syscall_name == NULL)
-    return UNKNOWN_SYSCALL;
+  bool found = false;
+  if (syscalls_info != NULL && syscall_name != NULL)
+    for (const syscall_desc_up &sysdesc : syscalls_info->syscalls)
+      if (sysdesc->name == syscall_name || sysdesc->alias == syscall_name)
+	{
+	  syscall_numbers.push_back (sysdesc->number);
+	  found = true;
+	}
 
-  for (const syscall_desc_up &sysdesc : syscalls_info->syscalls)
-    if (sysdesc->name == syscall_name)
-      return sysdesc->number;
-
-  return UNKNOWN_SYSCALL;
+  return found;
 }
 
 static const char *
@@ -510,14 +520,13 @@ get_syscall_by_number (struct gdbarch *gdbarch,
   s->name = xml_get_syscall_name (gdbarch, syscall_number);
 }
 
-void
-get_syscall_by_name (struct gdbarch *gdbarch,
-		     const char *syscall_name, struct syscall *s)
+bool
+get_syscalls_by_name (struct gdbarch *gdbarch, const char *syscall_name,
+		      std::vector<int> &syscall_numbers)
 {
   init_syscalls_info (gdbarch);
 
-  s->number = xml_get_syscall_number (gdbarch, syscall_name);
-  s->name = syscall_name;
+  return xml_get_syscalls_by_name (gdbarch, syscall_name, syscall_numbers);
 }
 
 const char **
diff --git a/gdb/xml-syscall.h b/gdb/xml-syscall.h
index 2e76a9a97f..a3b032aeb3 100644
--- a/gdb/xml-syscall.h
+++ b/gdb/xml-syscall.h
@@ -38,11 +38,13 @@ void set_xml_syscall_file_name (struct gdbarch *gdbarch,
 void get_syscall_by_number (struct gdbarch *gdbarch,
 			    int syscall_number, struct syscall *s);
 
-/* Function that retrieves the syscall number corresponding to the given
-   name.  It puts the requested information inside 'struct syscall'.  */
+/* Function that retrieves the syscall numbers corresponding to the
+   given name.  The numbers of all syscalls with either a name or
+   alias equal to SYSCALL_NAME are appended to SYSCALL_NUMBERS.  If no
+   matching syscalls are found, return false.  */
 
-void get_syscall_by_name (struct gdbarch *gdbarch,
-			  const char *syscall_name, struct syscall *s);
+bool get_syscalls_by_name (struct gdbarch *gdbarch, const char *syscall_name,
+			   std::vector<int> &syscall_numbers);
 
 /* Function used to retrieve the list of syscalls in the system.  This list
    is returned as an array of strings.  Returns the list of syscalls in the
-- 
2.18.0

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [PATCH v3 1/3] Change get_syscalls_by_group to append to an existing vector of integers.
  2018-11-09 20:04 [PATCH v3 0/3] Update FreeBSD's syscall table John Baldwin
  2018-11-09 20:04 ` [PATCH v3 3/3] Update the FreeBSD system call table to match FreeBSD 12.0 John Baldwin
  2018-11-09 20:04 ` [PATCH v3 2/3] Add an optional "alias" attribute to syscall entries John Baldwin
@ 2018-11-09 20:04 ` John Baldwin
  2018-11-26 20:31 ` [PATCH v3 0/3] Update FreeBSD's syscall table John Baldwin
  3 siblings, 0 replies; 21+ messages in thread
From: John Baldwin @ 2018-11-09 20:04 UTC (permalink / raw)
  To: gdb-patches

This removes the need for the caller to explicitly manage the memory
for the returned system call list.  The sole caller only needed the
system call numbers rather than the full syscall structures.

get_syscalls_by_group now uses a boolean return value to indicate if
the requested group exists.

gdb/ChangeLog:

	* break-catch-syscall.c (catch_syscall_split_args): Pass 'result'
	to get_syscalls_by_group.
	* xml-syscall.c [!HAVE_LIBEXPAT] (get_syscalls_by_group): Return
	false.
	[HAVE_LIBEXPAT] (xml_list_syscalls_by_group): Append syscall
	numbers to an existing vector of integers and return a bool.
	(get_syscalls_by_group): Accept reference to vector of integers
	and change return type to bool.
	* xml-syscall.h (get_syscalls_by_group): Likewise.
---
 gdb/ChangeLog             | 12 ++++++++++
 gdb/break-catch-syscall.c | 14 +-----------
 gdb/xml-syscall.c         | 47 +++++++++++++++------------------------
 gdb/xml-syscall.h         | 10 ++++-----
 4 files changed, 35 insertions(+), 48 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index b6c612bd0b..81faa2994d 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,15 @@
+2018-11-09  John Baldwin  <jhb@FreeBSD.org>
+
+	* break-catch-syscall.c (catch_syscall_split_args): Pass 'result'
+	to get_syscalls_by_group.
+	* xml-syscall.c [!HAVE_LIBEXPAT] (get_syscalls_by_group): Return
+	false.
+	[HAVE_LIBEXPAT] (xml_list_syscalls_by_group): Append syscall
+	numbers to an existing vector of integers and return a bool.
+	(get_syscalls_by_group): Accept reference to vector of integers
+	and change return type to bool.
+	* xml-syscall.h (get_syscalls_by_group): Likewise.
+
 2018-11-09  Hafiz Abid Qadeer  <abidh@codesourcery.com>
 
 	* configure: Regenerate.
diff --git a/gdb/break-catch-syscall.c b/gdb/break-catch-syscall.c
index 93ef74c249..f3740a1673 100644
--- a/gdb/break-catch-syscall.c
+++ b/gdb/break-catch-syscall.c
@@ -409,25 +409,13 @@ catch_syscall_split_args (const char *arg)
 	{
 	  /* We have a syscall group.  Let's expand it into a syscall
 	     list before inserting.  */
-	  struct syscall *syscall_list;
 	  const char *group_name;
 
 	  /* Skip over "g:" and "group:" prefix strings.  */
 	  group_name = strchr (cur_name, ':') + 1;
 
-	  syscall_list = get_syscalls_by_group (gdbarch, group_name);
-
-	  if (syscall_list == NULL)
+	  if (!get_syscalls_by_group (gdbarch, group_name, result))
 	    error (_("Unknown syscall group '%s'."), group_name);
-
-	  for (i = 0; syscall_list[i].name != NULL; i++)
-	    {
-	      /* Insert each syscall that are part of the group.  No
-		 need to check if it is valid.  */
-	      result.push_back (syscall_list[i].number);
-	    }
-
-	  xfree (syscall_list);
 	}
       else
 	{
diff --git a/gdb/xml-syscall.c b/gdb/xml-syscall.c
index bf17642911..664cee77dd 100644
--- a/gdb/xml-syscall.c
+++ b/gdb/xml-syscall.c
@@ -77,11 +77,12 @@ get_syscall_names (struct gdbarch *gdbarch)
   return NULL;
 }
 
-struct syscall *
-get_syscalls_by_group (struct gdbarch *gdbarch, const char *group)
+bool
+get_syscalls_by_group (struct gdbarch *gdbarch, const char *group,
+		       std::vector<int> &syscall_numbers)
 {
   syscall_warn_user ();
-  return NULL;
+  return false;
 }
 
 const char **
@@ -444,40 +445,27 @@ xml_list_of_syscalls (struct gdbarch *gdbarch)
 }
 
 /* Iterate over the syscall_group_desc element to return a list of
-   syscalls that are part of the given group, terminated by an empty
-   element.  If the syscall group doesn't exist, return NULL.  */
+   syscalls that are part of the given group.  If the syscall group
+   doesn't exist, return false.  */
 
-static struct syscall *
-xml_list_syscalls_by_group (struct gdbarch *gdbarch, const char *group)
+static bool
+xml_list_syscalls_by_group (struct gdbarch *gdbarch, const char *group,
+			    std::vector<int> &syscalls)
 {
   struct syscalls_info *syscalls_info = gdbarch_syscalls_info (gdbarch);
   struct syscall_group_desc *groupdesc;
-  struct syscall *syscalls = NULL;
-  int nsyscalls;
-  int i;
 
   if (syscalls_info == NULL)
-    return NULL;
+    return false;
 
   groupdesc = syscall_group_get_group_by_name (syscalls_info, group);
   if (groupdesc == NULL)
-    return NULL;
+    return false;
 
-  nsyscalls = groupdesc->syscalls.size ();
-  syscalls = (struct syscall*) xmalloc ((nsyscalls + 1)
-					* sizeof (struct syscall));
+  for (const struct syscall_desc *sysdesc : groupdesc->syscalls)
+    syscalls.push_back (sysdesc->number);
 
-  for (i = 0; i < groupdesc->syscalls.size (); i++)
-    {
-      syscalls[i].name = groupdesc->syscalls[i]->name.c_str ();
-      syscalls[i].number = groupdesc->syscalls[i]->number;
-    }
-
-  /* Add final element marker.  */
-  syscalls[i].name = NULL;
-  syscalls[i].number = 0;
-
-  return syscalls;
+  return true;
 }
 
 /* Return a NULL terminated list of syscall groups or an empty list, if
@@ -542,12 +530,13 @@ get_syscall_names (struct gdbarch *gdbarch)
 
 /* See comment in xml-syscall.h.  */
 
-struct syscall *
-get_syscalls_by_group (struct gdbarch *gdbarch, const char *group)
+bool
+get_syscalls_by_group (struct gdbarch *gdbarch, const char *group,
+		       std::vector<int> &syscall_numbers)
 {
   init_syscalls_info (gdbarch);
 
-  return xml_list_syscalls_by_group (gdbarch, group);
+  return xml_list_syscalls_by_group (gdbarch, group, syscall_numbers);
 }
 
 /* See comment in xml-syscall.h.  */
diff --git a/gdb/xml-syscall.h b/gdb/xml-syscall.h
index 4429d66400..2e76a9a97f 100644
--- a/gdb/xml-syscall.h
+++ b/gdb/xml-syscall.h
@@ -51,13 +51,11 @@ void get_syscall_by_name (struct gdbarch *gdbarch,
 const char **get_syscall_names (struct gdbarch *gdbarch);
 
 /* Function used to retrieve the list of syscalls of a given group in
-   the system.  Return a list of syscalls that are element of the
-   group, terminated by an empty element. The list is malloc'ed
-   and must be freed by the caller.  If group doesn't exist, return
-   NULL.  */
+   the system.  The syscall numbers are appended to SYSCALL_NUMBERS.
+   If the group doesn't exist, return false.  */
 
-struct syscall *get_syscalls_by_group (struct gdbarch *gdbarch,
-				       const char *group);
+bool get_syscalls_by_group (struct gdbarch *gdbarch, const char *group,
+			    std::vector<int> &syscall_numbers);
 
 /* Function used to retrieve the list of syscall groups in the system.
    Return an array of strings terminated by a NULL element.  The list
-- 
2.18.0

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [PATCH v3 0/3] Update FreeBSD's syscall table
@ 2018-11-09 20:04 John Baldwin
  2018-11-09 20:04 ` [PATCH v3 3/3] Update the FreeBSD system call table to match FreeBSD 12.0 John Baldwin
                   ` (3 more replies)
  0 siblings, 4 replies; 21+ messages in thread
From: John Baldwin @ 2018-11-09 20:04 UTC (permalink / raw)
  To: gdb-patches

Relative to V2, this changes the "get syscalls" functions to pass in
an integer vector by reference to append syscall numbers to.  It also
adds a NEWS entry and fixes some other nits noted by reviewers on the
V2 series.

John Baldwin (3):
  Change get_syscalls_by_group to append to an existing vector of
    integers.
  Add an optional "alias" attribute to syscall entries.
  Update the FreeBSD system call table to match FreeBSD 12.0.

 gdb/ChangeLog                  |  41 ++++++++++++
 gdb/NEWS                       |   5 ++
 gdb/break-catch-syscall.c      |  25 ++------
 gdb/gdbarch.h                  |   3 -
 gdb/gdbarch.sh                 |   3 -
 gdb/syscalls/freebsd.xml       | 110 ++++++++++++++++++++++++++-------
 gdb/syscalls/gdb-syscalls.dtd  |   1 +
 gdb/syscalls/update-freebsd.sh |  78 +++++++++++++++++++++++
 gdb/xml-syscall.c              | 108 ++++++++++++++++----------------
 gdb/xml-syscall.h              |  20 +++---
 10 files changed, 279 insertions(+), 115 deletions(-)
 create mode 100755 gdb/syscalls/update-freebsd.sh

-- 
2.18.0

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH v3 2/3] Add an optional "alias" attribute to syscall entries.
  2018-11-09 20:04 ` [PATCH v3 2/3] Add an optional "alias" attribute to syscall entries John Baldwin
@ 2018-11-09 20:18   ` Eli Zaretskii
  2018-11-16 17:44     ` John Baldwin
  2018-11-27 17:13     ` Pedro Alves
  0 siblings, 2 replies; 21+ messages in thread
From: Eli Zaretskii @ 2018-11-09 20:18 UTC (permalink / raw)
  To: John Baldwin; +Cc: gdb-patches

> From: John Baldwin <jhb@FreeBSD.org>
> Date: Fri,  9 Nov 2018 12:04:31 -0800
> 
> diff --git a/gdb/NEWS b/gdb/NEWS
> index ff9b192a38..ff225f361e 100644
> --- a/gdb/NEWS
> +++ b/gdb/NEWS
> @@ -38,6 +38,11 @@
>    requires the use of a keyword.  Selecting a frame by level is
>    unchanged.  The MI comment "-stack-select-frame" is unchanged.
>  
> +* System call catchpoints now support system call aliases.  This is
> +  used with the FreeBSD system call list so that system call
> +  catchpoints will also trigger for legacy system call numbers used by
> +  older FreeBSD binaries.

IMO, this is very abstract and too vague to be useful.  Since we won't
have anything more detailed in the manual, would it be possible to
make this description more concrete?  E.g., how about using some of
the text and examples you used in your description of the issue:

> When setting a syscall catchpoint by name, catch syscalls whose name
> or alias matches the requested string.
> 
> When the ABI of a system call is changed in the FreeBSD kernel, this
> is implemented by leaving a compatibility system call using the old
> ABI at the existing "slot" and allocating a new system call for the
> version using the new ABI.  For example, new fields were added to the
> 'struct kevent' used by the kevent() system call in FreeBSD 12.  The
> previous kevent() system call in FreeBSD 12 kernels is now called
> freebsd11_kevent() and is still used by older binaries compiled
> against the older ABI.  The freebsd11_kevent() system call can be
> tagged with an "alias" attribute of "kevent" permitting 'catch syscall
> kevent' to catch both system calls and providing the expected user
> behavior for both old and new binaries.  It also provides the expected
> behavior if GDB is compiled on an older host (such as a FreeBSD 11
> host).

Thanks.

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH v3 2/3] Add an optional "alias" attribute to syscall entries.
  2018-11-09 20:18   ` Eli Zaretskii
@ 2018-11-16 17:44     ` John Baldwin
  2018-11-16 19:37       ` Eli Zaretskii
  2018-11-27 17:13     ` Pedro Alves
  1 sibling, 1 reply; 21+ messages in thread
From: John Baldwin @ 2018-11-16 17:44 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: gdb-patches

On 11/9/18 12:18 PM, Eli Zaretskii wrote:
>> From: John Baldwin <jhb@FreeBSD.org>
>> Date: Fri,  9 Nov 2018 12:04:31 -0800
>>
>> diff --git a/gdb/NEWS b/gdb/NEWS
>> index ff9b192a38..ff225f361e 100644
>> --- a/gdb/NEWS
>> +++ b/gdb/NEWS
>> @@ -38,6 +38,11 @@
>>    requires the use of a keyword.  Selecting a frame by level is
>>    unchanged.  The MI comment "-stack-select-frame" is unchanged.
>>  
>> +* System call catchpoints now support system call aliases.  This is
>> +  used with the FreeBSD system call list so that system call
>> +  catchpoints will also trigger for legacy system call numbers used by
>> +  older FreeBSD binaries.
> 
> IMO, this is very abstract and too vague to be useful.  Since we won't
> have anything more detailed in the manual, would it be possible to
> make this description more concrete?  E.g., how about using some of
> the text and examples you used in your description of the issue:

Ok.  I wasn't too happy with my first attempt either.  I've tried to give
some more detail while not making it too long.  Let me know what you think:

* System call catchpoints now support system call aliases on FreeBSD.
  When the ABI of a system call changes in FreeBSD, this is
  implemented by leaving a compatibility system call using the old ABI
  at the existing number and allocating a new system call number for
  the new ABI.  For example, FreeBSD 12 altered the layout of 'struct
  kevent' used by the 'kevent' system call.  As a result, FreeBSD 12
  kernels ship with both 'kevent' and 'freebsd11_kevent' system calls.
  The 'freebsd11_kevent' system call is assigned an alias of 'kevent'
  so that a system call catchpoint for the 'kevent' system call will
  catch invocations of both the 'kevent' and 'freebsd11_kevent'
  binaries.  This ensures that 'kevent' system calls are caught for
  binaries using either the old or new ABIs.

-- 
John Baldwin

                                                                            

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH v3 2/3] Add an optional "alias" attribute to syscall entries.
  2018-11-16 17:44     ` John Baldwin
@ 2018-11-16 19:37       ` Eli Zaretskii
  0 siblings, 0 replies; 21+ messages in thread
From: Eli Zaretskii @ 2018-11-16 19:37 UTC (permalink / raw)
  To: John Baldwin; +Cc: gdb-patches

> Cc: gdb-patches@sourceware.org
> From: John Baldwin <jhb@FreeBSD.org>
> Date: Fri, 16 Nov 2018 09:43:56 -0800
> 
> > IMO, this is very abstract and too vague to be useful.  Since we won't
> > have anything more detailed in the manual, would it be possible to
> > make this description more concrete?  E.g., how about using some of
> > the text and examples you used in your description of the issue:
> 
> Ok.  I wasn't too happy with my first attempt either.  I've tried to give
> some more detail while not making it too long.  Let me know what you think:
> 
> * System call catchpoints now support system call aliases on FreeBSD.
>   When the ABI of a system call changes in FreeBSD, this is
>   implemented by leaving a compatibility system call using the old ABI
>   at the existing number and allocating a new system call number for
>   the new ABI.  For example, FreeBSD 12 altered the layout of 'struct
>   kevent' used by the 'kevent' system call.  As a result, FreeBSD 12
>   kernels ship with both 'kevent' and 'freebsd11_kevent' system calls.
>   The 'freebsd11_kevent' system call is assigned an alias of 'kevent'
>   so that a system call catchpoint for the 'kevent' system call will
>   catch invocations of both the 'kevent' and 'freebsd11_kevent'
>   binaries.  This ensures that 'kevent' system calls are caught for
>   binaries using either the old or new ABIs.

LGTM, thanks.

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH v3 0/3] Update FreeBSD's syscall table
  2018-11-09 20:04 [PATCH v3 0/3] Update FreeBSD's syscall table John Baldwin
                   ` (2 preceding siblings ...)
  2018-11-09 20:04 ` [PATCH v3 1/3] Change get_syscalls_by_group to append to an existing vector of integers John Baldwin
@ 2018-11-26 20:31 ` John Baldwin
  2018-11-27 17:20   ` Pedro Alves
  3 siblings, 1 reply; 21+ messages in thread
From: John Baldwin @ 2018-11-26 20:31 UTC (permalink / raw)
  To: gdb-patches

On 11/9/18 12:04 PM, John Baldwin wrote:
> Relative to V2, this changes the "get syscalls" functions to pass in
> an integer vector by reference to append syscall numbers to.  It also
> adds a NEWS entry and fixes some other nits noted by reviewers on the
> V2 series.
> 
> John Baldwin (3):
>   Change get_syscalls_by_group to append to an existing vector of
>     integers.
>   Add an optional "alias" attribute to syscall entries.
>   Update the FreeBSD system call table to match FreeBSD 12.0.
> 
>  gdb/ChangeLog                  |  41 ++++++++++++
>  gdb/NEWS                       |   5 ++
>  gdb/break-catch-syscall.c      |  25 ++------
>  gdb/gdbarch.h                  |   3 -
>  gdb/gdbarch.sh                 |   3 -
>  gdb/syscalls/freebsd.xml       | 110 ++++++++++++++++++++++++++-------
>  gdb/syscalls/gdb-syscalls.dtd  |   1 +
>  gdb/syscalls/update-freebsd.sh |  78 +++++++++++++++++++++++
>  gdb/xml-syscall.c              | 108 ++++++++++++++++----------------
>  gdb/xml-syscall.h              |  20 +++---
>  10 files changed, 279 insertions(+), 115 deletions(-)
>  create mode 100755 gdb/syscalls/update-freebsd.sh

Ping?  Eli signed off on an updated NEWS entry earlier in the thread.  Any
further comments on the code changes?

-- 
John Baldwin

                                                                            

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH v3 2/3] Add an optional "alias" attribute to syscall entries.
  2018-11-09 20:18   ` Eli Zaretskii
  2018-11-16 17:44     ` John Baldwin
@ 2018-11-27 17:13     ` Pedro Alves
  2018-11-27 21:54       ` John Baldwin
  1 sibling, 1 reply; 21+ messages in thread
From: Pedro Alves @ 2018-11-27 17:13 UTC (permalink / raw)
  To: Eli Zaretskii, John Baldwin; +Cc: gdb-patches

On 11/09/2018 08:18 PM, Eli Zaretskii wrote:
>> From: John Baldwin <jhb@FreeBSD.org>
>> Date: Fri,  9 Nov 2018 12:04:31 -0800
>>
>> diff --git a/gdb/NEWS b/gdb/NEWS
>> index ff9b192a38..ff225f361e 100644
>> --- a/gdb/NEWS
>> +++ b/gdb/NEWS
>> @@ -38,6 +38,11 @@
>>    requires the use of a keyword.  Selecting a frame by level is
>>    unchanged.  The MI comment "-stack-select-frame" is unchanged.
>>  
>> +* System call catchpoints now support system call aliases.  This is
>> +  used with the FreeBSD system call list so that system call
>> +  catchpoints will also trigger for legacy system call numbers used by
>> +  older FreeBSD binaries.
> 
> IMO, this is very abstract and too vague to be useful.  Since we won't
> have anything more detailed in the manual, would it be possible to
> make this description more concrete?  E.g., how about using some of
> the text and examples you used in your description of the issue:

Should we, have something in the manual?

Thanks,
Pedro Alves

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH v3 0/3] Update FreeBSD's syscall table
  2018-11-26 20:31 ` [PATCH v3 0/3] Update FreeBSD's syscall table John Baldwin
@ 2018-11-27 17:20   ` Pedro Alves
  2018-11-27 20:00     ` John Baldwin
  0 siblings, 1 reply; 21+ messages in thread
From: Pedro Alves @ 2018-11-27 17:20 UTC (permalink / raw)
  To: John Baldwin, gdb-patches

On 11/26/2018 08:31 PM, John Baldwin wrote:
> On 11/9/18 12:04 PM, John Baldwin wrote:
>> Relative to V2, this changes the "get syscalls" functions to pass in
>> an integer vector by reference to append syscall numbers to.  It also
>> adds a NEWS entry and fixes some other nits noted by reviewers on the
>> V2 series.
>>
>> John Baldwin (3):
>>   Change get_syscalls_by_group to append to an existing vector of
>>     integers.
>>   Add an optional "alias" attribute to syscall entries.
>>   Update the FreeBSD system call table to match FreeBSD 12.0.
>>
>>  gdb/ChangeLog                  |  41 ++++++++++++
>>  gdb/NEWS                       |   5 ++
>>  gdb/break-catch-syscall.c      |  25 ++------
>>  gdb/gdbarch.h                  |   3 -
>>  gdb/gdbarch.sh                 |   3 -
>>  gdb/syscalls/freebsd.xml       | 110 ++++++++++++++++++++++++++-------
>>  gdb/syscalls/gdb-syscalls.dtd  |   1 +
>>  gdb/syscalls/update-freebsd.sh |  78 +++++++++++++++++++++++
>>  gdb/xml-syscall.c              | 108 ++++++++++++++++----------------
>>  gdb/xml-syscall.h              |  20 +++---
>>  10 files changed, 279 insertions(+), 115 deletions(-)
>>  create mode 100755 gdb/syscalls/update-freebsd.sh
> 
> Ping?  Eli signed off on an updated NEWS entry earlier in the thread.  Any
> further comments on the code changes?
This looks good to me, though there's the issue with the non-const
references discussed here:

  https://sourceware.org/ml/gdb-patches/2018-11/msg00351.html
  https://sourceware.org/ml/gdb-patches/2018-11/msg00441.html
  https://sourceware.org/ml/gdb-patches/2018-11/msg00443.html
  https://sourceware.org/ml/gdb-patches/2018-11/msg00444.html

BTW:

> -  <syscall name="mknodat" number="498"/>
> +  <syscall name="freebsd11_mknodat" number="498" alias="mknodat"/>
> ...
> +  <syscall name="mknodat" number="559"/>

Does "catch syscall 498" catch only freebsd11_mknodat calls, or do
we for some reason end up catching calls to 559 as well?
I'd expect only 498.  What about "catch syscall 559"?

Thanks,
Pedro Alves

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH v3 0/3] Update FreeBSD's syscall table
  2018-11-27 17:20   ` Pedro Alves
@ 2018-11-27 20:00     ` John Baldwin
  0 siblings, 0 replies; 21+ messages in thread
From: John Baldwin @ 2018-11-27 20:00 UTC (permalink / raw)
  To: Pedro Alves, gdb-patches

On 11/27/18 9:19 AM, Pedro Alves wrote:
> On 11/26/2018 08:31 PM, John Baldwin wrote:
>> On 11/9/18 12:04 PM, John Baldwin wrote:
>>> Relative to V2, this changes the "get syscalls" functions to pass in
>>> an integer vector by reference to append syscall numbers to.  It also
>>> adds a NEWS entry and fixes some other nits noted by reviewers on the
>>> V2 series.
>>>
>>> John Baldwin (3):
>>>   Change get_syscalls_by_group to append to an existing vector of
>>>     integers.
>>>   Add an optional "alias" attribute to syscall entries.
>>>   Update the FreeBSD system call table to match FreeBSD 12.0.
>>>
>>>  gdb/ChangeLog                  |  41 ++++++++++++
>>>  gdb/NEWS                       |   5 ++
>>>  gdb/break-catch-syscall.c      |  25 ++------
>>>  gdb/gdbarch.h                  |   3 -
>>>  gdb/gdbarch.sh                 |   3 -
>>>  gdb/syscalls/freebsd.xml       | 110 ++++++++++++++++++++++++++-------
>>>  gdb/syscalls/gdb-syscalls.dtd  |   1 +
>>>  gdb/syscalls/update-freebsd.sh |  78 +++++++++++++++++++++++
>>>  gdb/xml-syscall.c              | 108 ++++++++++++++++----------------
>>>  gdb/xml-syscall.h              |  20 +++---
>>>  10 files changed, 279 insertions(+), 115 deletions(-)
>>>  create mode 100755 gdb/syscalls/update-freebsd.sh
>>
>> Ping?  Eli signed off on an updated NEWS entry earlier in the thread.  Any
>> further comments on the code changes?
> This looks good to me, though there's the issue with the non-const
> references discussed here:
> 
>   https://sourceware.org/ml/gdb-patches/2018-11/msg00351.html
>   https://sourceware.org/ml/gdb-patches/2018-11/msg00441.html
>   https://sourceware.org/ml/gdb-patches/2018-11/msg00443.html
>   https://sourceware.org/ml/gdb-patches/2018-11/msg00444.html

Oh, whoops, I skimmed that thread I'm afraid. :(

I used a reference here due to the reasons you mentioned in your first
message, primarily not having to deal with it being NULL.  I'm fine with
updating that to a pointer if that is the preferred route though.

> BTW:
> 
>> -  <syscall name="mknodat" number="498"/>
>> +  <syscall name="freebsd11_mknodat" number="498" alias="mknodat"/>
>> ...
>> +  <syscall name="mknodat" number="559"/>
> 
> Does "catch syscall 498" catch only freebsd11_mknodat calls, or do
> we for some reason end up catching calls to 559 as well?
> I'd expect only 498.  What about "catch syscall 559"?

They work as you would expect:

(gdb) catch syscall 498
Catchpoint 1 (syscall 'freebsd11_mknodat' [498])
(gdb) catch syscall 559
Catchpoint 2 (syscall 'mknodat' [559])
(gdb) info breakpoints 
Num     Type           Disp Enb Address            What
1       catchpoint     keep y                      syscall "freebsd11_mknodat" 
2       catchpoint     keep y                      syscall "mknodat" 

The aliases are only used when a syscall name is given rather than a number.

-- 
John Baldwin

                                                                            

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH v3 2/3] Add an optional "alias" attribute to syscall entries.
  2018-11-27 17:13     ` Pedro Alves
@ 2018-11-27 21:54       ` John Baldwin
  2018-11-28  6:31         ` Eli Zaretskii
  2018-11-28 12:19         ` Pedro Alves
  0 siblings, 2 replies; 21+ messages in thread
From: John Baldwin @ 2018-11-27 21:54 UTC (permalink / raw)
  To: Pedro Alves, Eli Zaretskii; +Cc: gdb-patches

On 11/27/18 9:13 AM, Pedro Alves wrote:
> On 11/09/2018 08:18 PM, Eli Zaretskii wrote:
>>> From: John Baldwin <jhb@FreeBSD.org>
>>> Date: Fri,  9 Nov 2018 12:04:31 -0800
>>>
>>> diff --git a/gdb/NEWS b/gdb/NEWS
>>> index ff9b192a38..ff225f361e 100644
>>> --- a/gdb/NEWS
>>> +++ b/gdb/NEWS
>>> @@ -38,6 +38,11 @@
>>>    requires the use of a keyword.  Selecting a frame by level is
>>>    unchanged.  The MI comment "-stack-select-frame" is unchanged.
>>>  
>>> +* System call catchpoints now support system call aliases.  This is
>>> +  used with the FreeBSD system call list so that system call
>>> +  catchpoints will also trigger for legacy system call numbers used by
>>> +  older FreeBSD binaries.
>>
>> IMO, this is very abstract and too vague to be useful.  Since we won't
>> have anything more detailed in the manual, would it be possible to
>> make this description more concrete?  E.g., how about using some of
>> the text and examples you used in your description of the issue:
> 
> Should we, have something in the manual?

Hmm, here's a patch I came up with for the manual:

diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 944a2c4383..ab4fad3c36 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -4683,6 +4683,22 @@ Catchpoint 2 (syscall 764)
 (@value{GDBP})
 @end smallexample
 
+On some operating systems, a system call name may map to more than one
+system call number.  For example, the FreeBSD kernel allocates new
+system call numbers when changing the ABI of an existing system call.
+The kernel also includes a compatibility system call using the old ABI
+and number.  FreeBSD's system call XML file includes aliases for
+compatibility system calls that are used to catch all versions of a
+system call.  For example, FreeBSD 12 introduced a new variant of the
+@code{kevent} system call.  Both system calls are caught when catching
+the @code{kevent} system call:
+
+@smallexample
+(@value{GDBP}) catch syscall kevent
+Catchpoint 1 (syscalls 'freebsd11_kevent' [363] 'kevent' [560])
+(@value{GDBP})
+@end smallexample
+
 If you configure @value{GDBN} using the @samp{--without-expat} option,
 it will not be able to display syscall names.  Also, if your
 architecture does not have an XML file describing its system calls,


-- 
John Baldwin

                                                                            

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH v3 2/3] Add an optional "alias" attribute to syscall entries.
  2018-11-27 21:54       ` John Baldwin
@ 2018-11-28  6:31         ` Eli Zaretskii
  2018-11-28 12:19         ` Pedro Alves
  1 sibling, 0 replies; 21+ messages in thread
From: Eli Zaretskii @ 2018-11-28  6:31 UTC (permalink / raw)
  To: John Baldwin; +Cc: palves, gdb-patches

> Cc: gdb-patches@sourceware.org
> From: John Baldwin <jhb@FreeBSD.org>
> Date: Tue, 27 Nov 2018 13:53:54 -0800
> 
> diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
> index 944a2c4383..ab4fad3c36 100644
> --- a/gdb/doc/gdb.texinfo
> +++ b/gdb/doc/gdb.texinfo
> @@ -4683,6 +4683,22 @@ Catchpoint 2 (syscall 764)
>  (@value{GDBP})
>  @end smallexample
>  
> +On some operating systems, a system call name may map to more than one
> +system call number.  For example, the FreeBSD kernel allocates new
> +system call numbers when changing the ABI of an existing system call.
> +The kernel also includes a compatibility system call using the old ABI
> +and number.  FreeBSD's system call XML file includes aliases for
> +compatibility system calls that are used to catch all versions of a
> +system call.  For example, FreeBSD 12 introduced a new variant of the
> +@code{kevent} system call.  Both system calls are caught when catching
> +the @code{kevent} system call:
> +
> +@smallexample
> +(@value{GDBP}) catch syscall kevent
> +Catchpoint 1 (syscalls 'freebsd11_kevent' [363] 'kevent' [560])
> +(@value{GDBP})
> +@end smallexample

This text is okay, but is it likely that any other OS will use this
facility?  If not, we are better off describing it in the "Native"
section (adding a new subsection if needed), as a FreeBSD-only
feature.

Thanks.

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH v3 2/3] Add an optional "alias" attribute to syscall entries.
  2018-11-27 21:54       ` John Baldwin
  2018-11-28  6:31         ` Eli Zaretskii
@ 2018-11-28 12:19         ` Pedro Alves
  2018-11-28 17:22           ` John Baldwin
  1 sibling, 1 reply; 21+ messages in thread
From: Pedro Alves @ 2018-11-28 12:19 UTC (permalink / raw)
  To: John Baldwin, Eli Zaretskii; +Cc: gdb-patches

On 11/27/2018 09:53 PM, John Baldwin wrote:
> +On some operating systems, a system call name may map to more than one
> +system call number.  For example, the FreeBSD kernel allocates new
> +system call numbers when changing the ABI of an existing system call.
> +The kernel also includes a compatibility system call using the old ABI
> +and number.  FreeBSD's system call XML file includes aliases for
> +compatibility system calls that are used to catch all versions of a
> +system call.  For example, FreeBSD 12 introduced a new variant of the
> +@code{kevent} system call.  Both system calls are caught when catching
> +the @code{kevent} system call:
> +
> +@smallexample
> +(@value{GDBP}) catch syscall kevent
> +Catchpoint 1 (syscalls 'freebsd11_kevent' [363] 'kevent' [560])
> +(@value{GDBP})
> +@end smallexample
> +

I'd suggest replacing "FreeBSD's system call XML file includes" with
something else that isn't so implementor-speak.  Users needn't
be aware of the XML file.  Maybe something along the lines of
"GDB is aware of aliases for compatibility system calls that
are used to catch ..."  Or maybe remove the sentence altogether.
Maybe simplify it a bit further, as users don't really need
to be told that that's what FreeBSD does for all new syscalls,
just that some syscalls are like that.  I think.  Thus, something
like this is enough, IMHO:


On some operating systems, a system call name may map to more than one
system call number.  

For example, FreeBSD 12 introduced a new variant of the @code{kevent} system
call, and included a compatibility system call using the old ABI and number.
As convenience, both system calls are caught when catching the @code{kevent}
system call by name:

@smallexample
(@value{GDBP}) catch syscall kevent
Catchpoint 1 (syscalls 'freebsd11_kevent' [363] 'kevent' [560])
(@value{GDBP})
@end smallexample

Thanks,
Pedro Alves

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH v3 2/3] Add an optional "alias" attribute to syscall entries.
  2018-11-28 12:19         ` Pedro Alves
@ 2018-11-28 17:22           ` John Baldwin
  2018-11-28 17:44             ` Eli Zaretskii
  0 siblings, 1 reply; 21+ messages in thread
From: John Baldwin @ 2018-11-28 17:22 UTC (permalink / raw)
  To: Pedro Alves, Eli Zaretskii; +Cc: gdb-patches

On 11/28/18 4:19 AM, Pedro Alves wrote:
> On 11/27/2018 09:53 PM, John Baldwin wrote:
>> +On some operating systems, a system call name may map to more than one
>> +system call number.  For example, the FreeBSD kernel allocates new
>> +system call numbers when changing the ABI of an existing system call.
>> +The kernel also includes a compatibility system call using the old ABI
>> +and number.  FreeBSD's system call XML file includes aliases for
>> +compatibility system calls that are used to catch all versions of a
>> +system call.  For example, FreeBSD 12 introduced a new variant of the
>> +@code{kevent} system call.  Both system calls are caught when catching
>> +the @code{kevent} system call:
>> +
>> +@smallexample
>> +(@value{GDBP}) catch syscall kevent
>> +Catchpoint 1 (syscalls 'freebsd11_kevent' [363] 'kevent' [560])
>> +(@value{GDBP})
>> +@end smallexample
>> +
> 
> I'd suggest replacing "FreeBSD's system call XML file includes" with
> something else that isn't so implementor-speak.  Users needn't
> be aware of the XML file.  Maybe something along the lines of
> "GDB is aware of aliases for compatibility system calls that
> are used to catch ..."  Or maybe remove the sentence altogether.
> Maybe simplify it a bit further, as users don't really need
> to be told that that's what FreeBSD does for all new syscalls,
> just that some syscalls are like that.  I think.  Thus, something
> like this is enough, IMHO:
> 
> 
> On some operating systems, a system call name may map to more than one
> system call number.  
> 
> For example, FreeBSD 12 introduced a new variant of the @code{kevent} system
> call, and included a compatibility system call using the old ABI and number.
> As convenience, both system calls are caught when catching the @code{kevent}
> system call by name:
> 
> @smallexample
> (@value{GDBP}) catch syscall kevent
> Catchpoint 1 (syscalls 'freebsd11_kevent' [363] 'kevent' [560])
> (@value{GDBP})
> @end smallexample

Yes, I think this is better as well.  Eli, I don't know if other OS's will
make use of this feature.  Given Pedro's new text above, do you think it
should still be moved into a native section or should it stay in the the
syscall section?

-- 
John Baldwin

                                                                            

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH v3 2/3] Add an optional "alias" attribute to syscall entries.
  2018-11-28 17:22           ` John Baldwin
@ 2018-11-28 17:44             ` Eli Zaretskii
  2018-11-28 18:00               ` John Baldwin
  0 siblings, 1 reply; 21+ messages in thread
From: Eli Zaretskii @ 2018-11-28 17:44 UTC (permalink / raw)
  To: John Baldwin; +Cc: palves, gdb-patches

> Cc: gdb-patches@sourceware.org
> From: John Baldwin <jhb@FreeBSD.org>
> Date: Wed, 28 Nov 2018 09:22:22 -0800
> 
> Yes, I think this is better as well.  Eli, I don't know if other OS's will
> make use of this feature.  Given Pedro's new text above, do you think it
> should still be moved into a native section or should it stay in the the
> syscall section?

I question the need to make this text more general than this feature
will ever become.  But if Pedro thinks we will have similar aliases on
other OSes, then sure, do it as Pedro suggests.

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH v3 2/3] Add an optional "alias" attribute to syscall entries.
  2018-11-28 17:44             ` Eli Zaretskii
@ 2018-11-28 18:00               ` John Baldwin
  2018-11-28 18:31                 ` Eli Zaretskii
  2018-11-28 18:34                 ` Pedro Alves
  0 siblings, 2 replies; 21+ messages in thread
From: John Baldwin @ 2018-11-28 18:00 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: palves, gdb-patches

On 11/28/18 9:44 AM, Eli Zaretskii wrote:
>> Cc: gdb-patches@sourceware.org
>> From: John Baldwin <jhb@FreeBSD.org>
>> Date: Wed, 28 Nov 2018 09:22:22 -0800
>>
>> Yes, I think this is better as well.  Eli, I don't know if other OS's will
>> make use of this feature.  Given Pedro's new text above, do you think it
>> should still be moved into a native section or should it stay in the the
>> syscall section?
> 
> I question the need to make this text more general than this feature
> will ever become.  But if Pedro thinks we will have similar aliases on
> other OSes, then sure, do it as Pedro suggests.

Oh, I was just referring to Pedro's version being shorter.  I'm fine with
moving it.  This is a bit longer as it restores a bit of the FreeBSD-specific
note about syscall ABIs but that seemed relevant when moving it:

diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 944a2c4383..c60c2b80c4 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -22329,6 +22329,7 @@ configurations.
 * Cygwin Native::		Features specific to the Cygwin port
 * Hurd Native::                 Features specific to @sc{gnu} Hurd
 * Darwin::			Features specific to Darwin
+* FreeBSD::			Features specific to FreeBSD
 @end menu
 
 @node BSD libkvm Interface
@@ -23214,6 +23215,26 @@ better understand the cause of a fault.  The default is off.
 Show the current state of exceptions trapping.
 @end table
 
+@node FreeBSD
+@subsection FreeBSD
+@cindex FreeBSD
+
+When the ABI of a system call is changed in the FreeBSD kernel, this
+is implemented by leaving a compatibility system call using the old
+ABI at the existing number and allocating a new system call number for
+the version using the new ABI.  As a convenience, when a system call
+is caught by name, compatibility system calls are also caught.
+
+For example, FreeBSD 12 introduced a new variant of the @code{kevent}
+system call and catching the @code{kevent} system call by name catches
+both variants:
+
+@smallexample
+(@value{GDBP}) catch syscall kevent
+Catchpoint 1 (syscalls 'freebsd11_kevent' [363] 'kevent' [560])
+(@value{GDBP})
+@end smallexample
+
 
 @node Embedded OS
 @section Embedded Operating Systems


-- 
John Baldwin

                                                                            

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH v3 2/3] Add an optional "alias" attribute to syscall entries.
  2018-11-28 18:00               ` John Baldwin
@ 2018-11-28 18:31                 ` Eli Zaretskii
  2018-11-28 18:34                 ` Pedro Alves
  1 sibling, 0 replies; 21+ messages in thread
From: Eli Zaretskii @ 2018-11-28 18:31 UTC (permalink / raw)
  To: John Baldwin; +Cc: palves, gdb-patches

> Cc: palves@redhat.com, gdb-patches@sourceware.org
> From: John Baldwin <jhb@FreeBSD.org>
> Date: Wed, 28 Nov 2018 10:00:48 -0800
> 
> Oh, I was just referring to Pedro's version being shorter.  I'm fine with
> moving it.  This is a bit longer as it restores a bit of the FreeBSD-specific
> note about syscall ABIs but that seemed relevant when moving it:
> 
> diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
> index 944a2c4383..c60c2b80c4 100644
> --- a/gdb/doc/gdb.texinfo
> +++ b/gdb/doc/gdb.texinfo
> @@ -22329,6 +22329,7 @@ configurations.
>  * Cygwin Native::		Features specific to the Cygwin port
>  * Hurd Native::                 Features specific to @sc{gnu} Hurd
>  * Darwin::			Features specific to Darwin
> +* FreeBSD::			Features specific to FreeBSD
>  @end menu
>  
>  @node BSD libkvm Interface
> @@ -23214,6 +23215,26 @@ better understand the cause of a fault.  The default is off.
>  Show the current state of exceptions trapping.
>  @end table
>  
> +@node FreeBSD
> +@subsection FreeBSD
> +@cindex FreeBSD
> +
> +When the ABI of a system call is changed in the FreeBSD kernel, this
> +is implemented by leaving a compatibility system call using the old
> +ABI at the existing number and allocating a new system call number for
> +the version using the new ABI.  As a convenience, when a system call
> +is caught by name, compatibility system calls are also caught.
> +
> +For example, FreeBSD 12 introduced a new variant of the @code{kevent}
> +system call and catching the @code{kevent} system call by name catches
> +both variants:
> +
> +@smallexample
> +(@value{GDBP}) catch syscall kevent
> +Catchpoint 1 (syscalls 'freebsd11_kevent' [363] 'kevent' [560])
> +(@value{GDBP})
> +@end smallexample

This is fine with me, but let's hear what Pedro thinks.

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH v3 2/3] Add an optional "alias" attribute to syscall entries.
  2018-11-28 18:00               ` John Baldwin
  2018-11-28 18:31                 ` Eli Zaretskii
@ 2018-11-28 18:34                 ` Pedro Alves
  2018-11-28 19:15                   ` John Baldwin
  2018-11-28 19:21                   ` Eli Zaretskii
  1 sibling, 2 replies; 21+ messages in thread
From: Pedro Alves @ 2018-11-28 18:34 UTC (permalink / raw)
  To: John Baldwin, Eli Zaretskii; +Cc: gdb-patches

On 11/28/2018 06:00 PM, John Baldwin wrote:
> On 11/28/18 9:44 AM, Eli Zaretskii wrote:
>>> Cc: gdb-patches@sourceware.org
>>> From: John Baldwin <jhb@FreeBSD.org>
>>> Date: Wed, 28 Nov 2018 09:22:22 -0800
>>>
>>> Yes, I think this is better as well.  Eli, I don't know if other OS's will
>>> make use of this feature.  Given Pedro's new text above, do you think it
>>> should still be moved into a native section or should it stay in the the
>>> syscall section?
>>
>> I question the need to make this text more general than this feature
>> will ever become.  But if Pedro thinks we will have similar aliases on
>> other OSes, then sure, do it as Pedro suggests.

Don't other BSD kernels do something similar?

I think Linux always adds new syscalls under a new name, even if the
old replaced one is deprecated.

> Oh, I was just referring to Pedro's version being shorter.  I'm fine with
> moving it.  This is a bit longer as it restores a bit of the FreeBSD-specific
> note about syscall ABIs but that seemed relevant when moving it:
I'm fine with it as well.  It just felt like if the we could keep it short, it'd
avoid fragmenting the information.  IMO, a user reading the "catch syscall"
bits in the manual isn't going to remember to look up the FreeBSD-specific info
in a different node.  Unless we add some xrefs.

Thanks,
Pedro Alves

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH v3 2/3] Add an optional "alias" attribute to syscall entries.
  2018-11-28 18:34                 ` Pedro Alves
@ 2018-11-28 19:15                   ` John Baldwin
  2018-11-28 19:21                   ` Eli Zaretskii
  1 sibling, 0 replies; 21+ messages in thread
From: John Baldwin @ 2018-11-28 19:15 UTC (permalink / raw)
  To: Pedro Alves, Eli Zaretskii; +Cc: gdb-patches

On 11/28/18 10:34 AM, Pedro Alves wrote:
> On 11/28/2018 06:00 PM, John Baldwin wrote:
>> On 11/28/18 9:44 AM, Eli Zaretskii wrote:
>>>> Cc: gdb-patches@sourceware.org
>>>> From: John Baldwin <jhb@FreeBSD.org>
>>>> Date: Wed, 28 Nov 2018 09:22:22 -0800
>>>>
>>>> Yes, I think this is better as well.  Eli, I don't know if other OS's will
>>>> make use of this feature.  Given Pedro's new text above, do you think it
>>>> should still be moved into a native section or should it stay in the the
>>>> syscall section?
>>>
>>> I question the need to make this text more general than this feature
>>> will ever become.  But if Pedro thinks we will have similar aliases on
>>> other OSes, then sure, do it as Pedro suggests.
> 
> Don't other BSD kernels do something similar?

Hmm, it is true that 4.4BSD itself included some compat system calls to handle
some ABI changes which is why the BSD's follow that model.  NetBSD at least
follows FreeBSD's model of renaming old system calls and adding new numbers for
new ABIs.  OpenBSD kind of does, but it retires older ABIs more aggressively
and seems to reuse old numbers unlike FreeBSD and NetBSD.

> I think Linux always adds new syscalls under a new name, even if the
> old replaced one is deprecated.
> 
>> Oh, I was just referring to Pedro's version being shorter.  I'm fine with
>> moving it.  This is a bit longer as it restores a bit of the FreeBSD-specific
>> note about syscall ABIs but that seemed relevant when moving it:
> I'm fine with it as well.  It just felt like if the we could keep it short, it'd
> avoid fragmenting the information.  IMO, a user reading the "catch syscall"
> bits in the manual isn't going to remember to look up the FreeBSD-specific info
> in a different node.  Unless we add some xrefs.

Yes, that is why I started with it in the syscall section.

-- 
John Baldwin

                                                                            

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH v3 2/3] Add an optional "alias" attribute to syscall entries.
  2018-11-28 18:34                 ` Pedro Alves
  2018-11-28 19:15                   ` John Baldwin
@ 2018-11-28 19:21                   ` Eli Zaretskii
  1 sibling, 0 replies; 21+ messages in thread
From: Eli Zaretskii @ 2018-11-28 19:21 UTC (permalink / raw)
  To: Pedro Alves; +Cc: jhb, gdb-patches

> Cc: gdb-patches@sourceware.org
> From: Pedro Alves <palves@redhat.com>
> Date: Wed, 28 Nov 2018 18:34:42 +0000
> 
> IMO, a user reading the "catch syscall" bits in the manual isn't
> going to remember to look up the FreeBSD-specific info in a
> different node.  Unless we add some xrefs.

Then let's add them.

^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2018-11-28 19:21 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-09 20:04 [PATCH v3 0/3] Update FreeBSD's syscall table John Baldwin
2018-11-09 20:04 ` [PATCH v3 3/3] Update the FreeBSD system call table to match FreeBSD 12.0 John Baldwin
2018-11-09 20:04 ` [PATCH v3 2/3] Add an optional "alias" attribute to syscall entries John Baldwin
2018-11-09 20:18   ` Eli Zaretskii
2018-11-16 17:44     ` John Baldwin
2018-11-16 19:37       ` Eli Zaretskii
2018-11-27 17:13     ` Pedro Alves
2018-11-27 21:54       ` John Baldwin
2018-11-28  6:31         ` Eli Zaretskii
2018-11-28 12:19         ` Pedro Alves
2018-11-28 17:22           ` John Baldwin
2018-11-28 17:44             ` Eli Zaretskii
2018-11-28 18:00               ` John Baldwin
2018-11-28 18:31                 ` Eli Zaretskii
2018-11-28 18:34                 ` Pedro Alves
2018-11-28 19:15                   ` John Baldwin
2018-11-28 19:21                   ` Eli Zaretskii
2018-11-09 20:04 ` [PATCH v3 1/3] Change get_syscalls_by_group to append to an existing vector of integers John Baldwin
2018-11-26 20:31 ` [PATCH v3 0/3] Update FreeBSD's syscall table John Baldwin
2018-11-27 17:20   ` Pedro Alves
2018-11-27 20:00     ` John Baldwin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).