From owner-p4-projects@FreeBSD.ORG Mon Jun 28 04:23:42 2004 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 09F8016A4D2; Mon, 28 Jun 2004 04:23:42 +0000 (GMT) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D8B0116A4CF for ; Mon, 28 Jun 2004 04:23:41 +0000 (GMT) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id C4B0F43D4C for ; Mon, 28 Jun 2004 04:23:41 +0000 (GMT) (envelope-from marcel@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.11/8.12.11) with ESMTP id i5S4NfCr034112 for ; Mon, 28 Jun 2004 04:23:41 GMT (envelope-from marcel@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.11/8.12.11/Submit) id i5S4NfaF034109 for perforce@freebsd.org; Mon, 28 Jun 2004 04:23:41 GMT (envelope-from marcel@freebsd.org) Date: Mon, 28 Jun 2004 04:23:41 GMT Message-Id: <200406280423.i5S4NfaF034109@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to marcel@freebsd.org using -f From: Marcel Moolenaar To: Perforce Change Reviews Subject: PERFORCE change 55972 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Jun 2004 04:23:42 -0000 http://perforce.freebsd.org/chv.cgi?CH=55972 Change 55972 by marcel@marcel_nfs on 2004/06/28 04:22:49 Add the getlwpid(2) syscall. The syscall return the TID of the thread that executes the syscall. The primary purpose of this syscall is to allow threading libraries to obtain the TID so that the debugger has a chance to associate threads with the NT_PRSTATUS notes in coredumps. For libc_r this mostly serves the purpose of being able to fill in the td_thrinfo_t structure correctly and to be able to pass the correct lwpid to the proc services provider when asking for the register context. For libthr this is more important in that it's the only way to associate the internal thread structures with the register context in the core file. davidxu@ has been using the mailbox to pass this information to libkse, so he may find the syscall useful as well. Affected files ... .. //depot/projects/gdb/include/unistd.h#3 edit .. //depot/projects/gdb/sys/compat/freebsd32/freebsd32_proto.h#7 edit .. //depot/projects/gdb/sys/compat/freebsd32/freebsd32_syscall.h#7 edit .. //depot/projects/gdb/sys/compat/freebsd32/freebsd32_syscalls.c#7 edit .. //depot/projects/gdb/sys/compat/freebsd32/freebsd32_sysent.c#7 edit .. //depot/projects/gdb/sys/compat/freebsd32/syscalls.master#6 edit .. //depot/projects/gdb/sys/kern/init_sysent.c#7 edit .. //depot/projects/gdb/sys/kern/kern_prot.c#6 edit .. //depot/projects/gdb/sys/kern/syscalls.c#7 edit .. //depot/projects/gdb/sys/kern/syscalls.master#7 edit .. //depot/projects/gdb/sys/sys/syscall.h#7 edit .. //depot/projects/gdb/sys/sys/syscall.mk#7 edit .. //depot/projects/gdb/sys/sys/sysproto.h#7 edit Differences ... ==== //depot/projects/gdb/include/unistd.h#3 (text+ko) ==== @@ -48,6 +48,11 @@ #define _GID_T_DECLARED #endif +#ifndef _LWPID_T_DECLARED +typedef __lwpid_t lwpid_t; +#define _LWPID_T_DECLARED +#endif + #ifndef _OFF_T_DECLARED typedef __off_t off_t; #define _OFF_T_DECLARED @@ -340,6 +345,7 @@ gid_t getgid(void); int getgroups(int, gid_t []); char *getlogin(void); +lwpid_t getlwpid(void); pid_t getpgrp(void); pid_t getpid(void); pid_t getppid(void); ==== //depot/projects/gdb/sys/compat/freebsd32/freebsd32_proto.h#7 (text+ko) ==== @@ -2,7 +2,7 @@ * System call prototypes. * * DO NOT EDIT-- this file is automatically generated. - * $FreeBSD: src/sys/compat/freebsd32/freebsd32_proto.h,v 1.25 2004/04/14 23:17:57 peter Exp $ + * $FreeBSD$ * created from FreeBSD: src/sys/compat/freebsd32/syscalls.master,v 1.37 2004/04/14 23:17:37 peter Exp */ ==== //depot/projects/gdb/sys/compat/freebsd32/freebsd32_syscall.h#7 (text+ko) ==== @@ -2,7 +2,7 @@ * System call numbers. * * DO NOT EDIT-- this file is automatically generated. - * $FreeBSD: src/sys/compat/freebsd32/freebsd32_syscall.h,v 1.25 2004/04/14 23:17:57 peter Exp $ + * $FreeBSD$ * created from FreeBSD: src/sys/compat/freebsd32/syscalls.master,v 1.37 2004/04/14 23:17:37 peter Exp */ @@ -301,4 +301,5 @@ #define FREEBSD32_SYS_jail_attach 436 #define FREEBSD32_SYS_thr_suspend 442 #define FREEBSD32_SYS_thr_wake 443 -#define FREEBSD32_SYS_MAXSYSCALL 444 +#define FREEBSD32_SYS_getlwpid 444 +#define FREEBSD32_SYS_MAXSYSCALL 445 ==== //depot/projects/gdb/sys/compat/freebsd32/freebsd32_syscalls.c#7 (text+ko) ==== @@ -2,7 +2,7 @@ * System call names. * * DO NOT EDIT-- this file is automatically generated. - * $FreeBSD: src/sys/compat/freebsd32/freebsd32_syscalls.c,v 1.16 2004/04/14 23:17:57 peter Exp $ + * $FreeBSD$ * created from FreeBSD: src/sys/compat/freebsd32/syscalls.master,v 1.37 2004/04/14 23:17:37 peter Exp */ @@ -451,4 +451,5 @@ "#441", /* 441 = ksem_timedwait */ "thr_suspend", /* 442 = thr_suspend */ "thr_wake", /* 443 = thr_wake */ + "getlwpid", /* 444 = getlwpid */ }; ==== //depot/projects/gdb/sys/compat/freebsd32/freebsd32_sysent.c#7 (text+ko) ==== @@ -2,7 +2,7 @@ * System call switch table. * * DO NOT EDIT-- this file is automatically generated. - * $FreeBSD: src/sys/compat/freebsd32/freebsd32_sysent.c,v 1.26 2004/04/14 23:17:57 peter Exp $ + * $FreeBSD$ * created from FreeBSD: src/sys/compat/freebsd32/syscalls.master,v 1.37 2004/04/14 23:17:37 peter Exp */ @@ -469,4 +469,5 @@ { 0, (sy_call_t *)nosys }, /* 441 = ksem_timedwait */ { SYF_MPSAFE | AS(thr_suspend_args), (sy_call_t *)thr_suspend }, /* 442 = thr_suspend */ { SYF_MPSAFE | AS(thr_wake_args), (sy_call_t *)thr_wake }, /* 443 = thr_wake */ + { SYF_MPSAFE | 0, (sy_call_t *)getlwpid }, /* 444 = getlwpid */ }; ==== //depot/projects/gdb/sys/compat/freebsd32/syscalls.master#6 (text+ko) ==== @@ -609,3 +609,4 @@ 441 UNIMPL ksem_timedwait 442 MNOPROTO { int thr_suspend(const struct timespec *timeout); } 443 MNOPROTO { int thr_wake(thr_id_t id); } +444 MNOPROTO { lwpid_t getlwpid(void); } ==== //depot/projects/gdb/sys/kern/init_sysent.c#7 (text+ko) ==== @@ -2,7 +2,7 @@ * System call switch table. * * DO NOT EDIT-- this file is automatically generated. - * $FreeBSD: src/sys/kern/init_sysent.c,v 1.172 2004/06/22 04:36:24 rwatson Exp $ + * $FreeBSD$ * created from FreeBSD: src/sys/kern/syscalls.master,v 1.173 2004/06/22 04:34:55 rwatson Exp */ @@ -472,4 +472,5 @@ { SYF_MPSAFE | AS(ksem_timedwait_args), (sy_call_t *)lkmressys }, /* 441 = ksem_timedwait */ { SYF_MPSAFE | AS(thr_suspend_args), (sy_call_t *)thr_suspend }, /* 442 = thr_suspend */ { SYF_MPSAFE | AS(thr_wake_args), (sy_call_t *)thr_wake }, /* 443 = thr_wake */ + { SYF_MPSAFE | 0, (sy_call_t *)getlwpid }, /* 444 = getlwpid */ }; ==== //depot/projects/gdb/sys/kern/kern_prot.c#6 (text+ko) ==== @@ -70,6 +70,23 @@ "BSD security policy"); #ifndef _SYS_SYSPROTO_H_ +struct getlwpid_args { + int dummy; +}; +#endif +/* + * MPSAFE + */ +/* ARGSUSED */ +int +getlwpid(struct thread *td, struct getlwpid_args *uap) +{ + + td->td_retval[0] = td->td_tid; + return (0); +} + +#ifndef _SYS_SYSPROTO_H_ struct getpid_args { int dummy; }; ==== //depot/projects/gdb/sys/kern/syscalls.c#7 (text+ko) ==== @@ -2,7 +2,7 @@ * System call names. * * DO NOT EDIT-- this file is automatically generated. - * $FreeBSD: src/sys/kern/syscalls.c,v 1.158 2004/06/22 04:36:25 rwatson Exp $ + * $FreeBSD$ * created from FreeBSD: src/sys/kern/syscalls.master,v 1.173 2004/06/22 04:34:55 rwatson Exp */ @@ -451,4 +451,5 @@ "ksem_timedwait", /* 441 = ksem_timedwait */ "thr_suspend", /* 442 = thr_suspend */ "thr_wake", /* 443 = thr_wake */ + "getlwpid", /* 444 = getlwpid */ }; ==== //depot/projects/gdb/sys/kern/syscalls.master#7 (text+ko) ==== @@ -631,5 +631,6 @@ 441 MNOSTD { int ksem_timedwait(semid_t id, struct timespec *abstime); } 442 MSTD { int thr_suspend(const struct timespec *timeout); } 443 MSTD { int thr_wake(thr_id_t id); } +444 MSTD { lwpid_t getlwpid(void); } ; Please copy any additions and changes to the following compatability tables: ; sys/compat/freebsd32/syscalls.master ==== //depot/projects/gdb/sys/sys/syscall.h#7 (text+ko) ==== @@ -2,7 +2,7 @@ * System call numbers. * * DO NOT EDIT-- this file is automatically generated. - * $FreeBSD: src/sys/sys/syscall.h,v 1.156 2004/06/22 04:36:25 rwatson Exp $ + * $FreeBSD$ * created from FreeBSD: src/sys/kern/syscalls.master,v 1.173 2004/06/22 04:34:55 rwatson Exp */ @@ -356,4 +356,5 @@ #define SYS_ksem_timedwait 441 #define SYS_thr_suspend 442 #define SYS_thr_wake 443 -#define SYS_MAXSYSCALL 444 +#define SYS_getlwpid 444 +#define SYS_MAXSYSCALL 445 ==== //depot/projects/gdb/sys/sys/syscall.mk#7 (text+ko) ==== @@ -1,6 +1,6 @@ # FreeBSD system call names. # DO NOT EDIT-- this file is automatically generated. -# $FreeBSD: src/sys/sys/syscall.mk,v 1.111 2004/06/22 04:36:25 rwatson Exp $ +# $FreeBSD$ # created from FreeBSD: src/sys/kern/syscalls.master,v 1.173 2004/06/22 04:34:55 rwatson Exp MIASM = \ syscall.o \ @@ -297,4 +297,5 @@ kse_switchin.o \ ksem_timedwait.o \ thr_suspend.o \ - thr_wake.o + thr_wake.o \ + getlwpid.o ==== //depot/projects/gdb/sys/sys/sysproto.h#7 (text+ko) ==== @@ -2,7 +2,7 @@ * System call prototypes. * * DO NOT EDIT-- this file is automatically generated. - * $FreeBSD: src/sys/sys/sysproto.h,v 1.155 2004/06/22 04:36:25 rwatson Exp $ + * $FreeBSD$ * created from FreeBSD: src/sys/kern/syscalls.master,v 1.173 2004/06/22 04:34:55 rwatson Exp */ @@ -1303,6 +1303,9 @@ struct thr_wake_args { char id_l_[PADL_(thr_id_t)]; thr_id_t id; char id_r_[PADR_(thr_id_t)]; }; +struct getlwpid_args { + register_t dummy; +}; int nosys(struct thread *, struct nosys_args *); void sys_exit(struct thread *, struct sys_exit_args *); int fork(struct thread *, struct fork_args *); @@ -1597,6 +1600,7 @@ int ksem_timedwait(struct thread *, struct ksem_timedwait_args *); int thr_suspend(struct thread *, struct thr_suspend_args *); int thr_wake(struct thread *, struct thr_wake_args *); +int getlwpid(struct thread *, struct getlwpid_args *); #ifdef COMPAT_43