CVS commit: src/lib/libpthread_dbg
Module Name:src Committed By: wiz Date: Thu Nov 24 12:18:02 UTC 2016 Modified Files: src/lib/libpthread_dbg: pthread_dbg.3 td_map_pth2thr.3 td_open.3 td_thr_getname.3 td_thr_info.3 td_thr_iter.3 Log Message: Various fixes. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/lib/libpthread_dbg/pthread_dbg.3 cvs rdiff -u -r1.1 -r1.2 src/lib/libpthread_dbg/td_map_pth2thr.3 \ src/lib/libpthread_dbg/td_open.3 src/lib/libpthread_dbg/td_thr_getname.3 \ src/lib/libpthread_dbg/td_thr_info.3 src/lib/libpthread_dbg/td_thr_iter.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libpthread_dbg/pthread_dbg.3 diff -u src/lib/libpthread_dbg/pthread_dbg.3:1.3 src/lib/libpthread_dbg/pthread_dbg.3:1.4 --- src/lib/libpthread_dbg/pthread_dbg.3:1.3 Tue Nov 22 03:52:01 2016 +++ src/lib/libpthread_dbg/pthread_dbg.3 Thu Nov 24 12:18:02 2016 @@ -1,4 +1,4 @@ -.\" $NetBSD: pthread_dbg.3,v 1.3 2016/11/22 03:52:01 kamil Exp $ +.\" $NetBSD: pthread_dbg.3,v 1.4 2016/11/24 12:18:02 wiz Exp $ .\" .\" .\" Copyright (c) 2016 The NetBSD Foundation, Inc. @@ -62,12 +62,12 @@ In order to remain compatible with futur releases, programs must be linked against the dynamic version of the thread library. Statically linked programs using the -.Tn POSIX +.Tn POSIX threads framework may not work when run on a future version of the system. .Pp The .Nm -library is designed to be used in debuggers and to control and introspect +library is designed to be used in debuggers and to control and introspect the .Nx implementation of the .Tn POSIX @@ -75,7 +75,7 @@ threads. Software may use native .Tn LWP threads without -.Xr libpthread 3 +.Xr pthread 3 layer, in that case .Nm @@ -105,8 +105,8 @@ library: .Bl -column -offset indent "td_thr_getname(3)" "convert the pthread_t to a thread handle" .It Sy Function Ta Sy Description .It Xr td_close 3 Ta close connection to a threaded process +.It Xr td_map_pth2thr 3 Ta convert a pthread_t to a thread handle .It Xr td_open 3Ta make connection to a threaded process -.It Xr td_map_pth2thr 3 Ta convert the pthread_t to a thread handle .It Xr td_thr_getname 3 Ta get the user-assigned name of a thread .It Xr td_thr_info 3Ta get information on a thread .It Xr td_thr_iter 3Ta iterate over the threads in the process @@ -116,7 +116,7 @@ library: .Sh STANDARDS The .Nm -library is +library is a .Nx extension. .Sh HISTORY @@ -124,7 +124,7 @@ The .Nm library first appeared in .Nx 2.0 -along with Scheduler Activation thread interface. +along with the Scheduler Activation thread interface. This interface was authored by .An Nathan J. Williams and merged by @@ -133,8 +133,9 @@ In .Nx 5.0 the .Nm -library was moved to new 1:1 thread model. +library was moved to the new 1:1 thread model. .Sh AUTHORS +.An -nosplit .An Nathan J. Williams Aq Mt nath...@netbsd.org .Pp This manual page was written by Index: src/lib/libpthread_dbg/td_map_pth2thr.3 diff -u src/lib/libpthread_dbg/td_map_pth2thr.3:1.1 src/lib/libpthread_dbg/td_map_pth2thr.3:1.2 --- src/lib/libpthread_dbg/td_map_pth2thr.3:1.1 Tue Nov 22 03:52:01 2016 +++ src/lib/libpthread_dbg/td_map_pth2thr.3 Thu Nov 24 12:18:02 2016 @@ -1,4 +1,4 @@ -.\" $NetBSD: td_map_pth2thr.3,v 1.1 2016/11/22 03:52:01 kamil Exp $ +.\" $NetBSD: td_map_pth2thr.3,v 1.2 2016/11/24 12:18:02 wiz Exp $ .\" .\" Copyright (c) 2016 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -29,7 +29,7 @@ .Os .Sh NAME .Nm td_map_pth2thr -.Nd convert the pthread_t to a thread handle +.Nd convert a pthread_t to a thread handle .Sh LIBRARY .Lb libpthread_dbg .Sh SYNOPSIS @@ -39,11 +39,11 @@ .Sh DESCRIPTION The .Nm -function converts +function converts a .Ta POSIX thread .Fa thread -to +to a .Xr pthread_dbg 3 specific thread passed in the .Fa threadp @@ -64,6 +64,7 @@ The function first appeared in .Nx 2.0 . .Sh AUTHORS +.An -nosplit .An Nathan J. Williams Aq Mt nath...@netbsd.org .Pp This manual page was written by Index: src/lib/libpthread_dbg/td_open.3 diff -u src/lib/libpthread_dbg/td_open.3:1.1 src/lib/libpthread_dbg/td_open.3:1.2 --- src/lib/libpthread_dbg/td_open.3:1.1 Mon Nov 21 20:43:25 2016 +++ src/lib/libpthread_dbg/td_open.3 Thu Nov 24 12:18:02 2016 @@ -1,4 +1,4 @@ -.\" $NetBSD: td_open.3,v 1.1 2016/11/21 20:43:25 kamil Exp $ +.\" $NetBSD: td_open.3,v 1.2 2016/11/24 12:18:02 wiz Exp $ .\" .\" Copyright (c) 2016 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -24,14 +24,13 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" - .Dd November 21, 2016 .Dt TD_OPEN 3 .Os .Sh NAME -.Nm td_open +.Nm td_open , .Nm td_close -.Nd make a conection to a threaded process +.Nd make or close a connection to a threaded process .Sh LIBRARY .Lb libpthread_dbg .Sh SYNOPSIS @@ -44,15 +43,15 @@ The .Fn
CVS commit: src/lib/libpthread_dbg
Module Name:src Committed By: kamil Date: Tue Nov 22 04:51:06 UTC 2016 Modified Files: src/lib/libpthread_dbg: pthread_dbg.c pthread_dbg.h Log Message: Obsolete thread_type in td_thread_info_st in The thread_type is irrelevant as all local POSIX threads are in user-space. Keep the thread_type member in td_thread_info_st to preserve ABI compatibility. Later the remnants from M:N will be refactored in one go with library ABI version bump. Sponsored by To generate a diff of this commit: cvs rdiff -u -r1.50 -r1.51 src/lib/libpthread_dbg/pthread_dbg.c cvs rdiff -u -r1.8 -r1.9 src/lib/libpthread_dbg/pthread_dbg.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libpthread_dbg/pthread_dbg.c diff -u src/lib/libpthread_dbg/pthread_dbg.c:1.50 src/lib/libpthread_dbg/pthread_dbg.c:1.51 --- src/lib/libpthread_dbg/pthread_dbg.c:1.50 Tue Nov 22 04:17:05 2016 +++ src/lib/libpthread_dbg/pthread_dbg.c Tue Nov 22 04:51:06 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: pthread_dbg.c,v 1.50 2016/11/22 04:17:05 kamil Exp $ */ +/* $NetBSD: pthread_dbg.c,v 1.51 2016/11/22 04:51:06 kamil Exp $ */ /*- * Copyright (c) 2002 Wasabi Systems, Inc. @@ -36,7 +36,7 @@ */ #include -__RCSID("$NetBSD: pthread_dbg.c,v 1.50 2016/11/22 04:17:05 kamil Exp $"); +__RCSID("$NetBSD: pthread_dbg.c,v 1.51 2016/11/22 04:51:06 kamil Exp $"); #define __EXPOSE_STACK 1 @@ -235,8 +235,6 @@ td_thr_info(td_thread_t *thread, td_thre info->thread_state = TD_STATE_UNKNOWN; } - info->thread_type = TD_TYPE_USER; - if ((val = READ(thread->proc, OFFSET(thread, pt_stack), >thread_stack, sizeof(stack_t))) != 0) return val; Index: src/lib/libpthread_dbg/pthread_dbg.h diff -u src/lib/libpthread_dbg/pthread_dbg.h:1.8 src/lib/libpthread_dbg/pthread_dbg.h:1.9 --- src/lib/libpthread_dbg/pthread_dbg.h:1.8 Mon Nov 21 03:02:34 2016 +++ src/lib/libpthread_dbg/pthread_dbg.h Tue Nov 22 04:51:06 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: pthread_dbg.h,v 1.8 2016/11/21 03:02:34 kamil Exp $ */ +/* $NetBSD: pthread_dbg.h,v 1.9 2016/11/22 04:51:06 kamil Exp $ */ /*- * Copyright (c) 2002 Wasabi Systems, Inc. @@ -84,9 +84,9 @@ typedef struct td_thread_info_st { #define TD_STATE_UNUSED6 6 /* former TD_STATE_SUSPENDED for SA */ #define TD_STATE_DEAD 7 -#define TD_TYPE_UNKNOWN 0 -#define TD_TYPE_USER 1 -#define TD_TYPE_SYSTEM 2 +#define TD_TYPE_UNUSED0 0 +#define TD_TYPE_UNUSED1 1 +#define TD_TYPE_UNUSED2 2 typedef struct { caddr_t sync_addr; /* Address within the process */
CVS commit: src/lib/libpthread_dbg
Module Name:src Committed By: kamil Date: Tue Nov 22 04:17:05 UTC 2016 Modified Files: src/lib/libpthread_dbg: pthread_dbg.c Log Message: Simplify (pthread_t)pt_magic read in td_map_pth2thr(3) No functional change. All ATF tests for pthread_dbg(3) still pass. Sponsored by To generate a diff of this commit: cvs rdiff -u -r1.49 -r1.50 src/lib/libpthread_dbg/pthread_dbg.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libpthread_dbg/pthread_dbg.c diff -u src/lib/libpthread_dbg/pthread_dbg.c:1.49 src/lib/libpthread_dbg/pthread_dbg.c:1.50 --- src/lib/libpthread_dbg/pthread_dbg.c:1.49 Mon Nov 21 03:02:34 2016 +++ src/lib/libpthread_dbg/pthread_dbg.c Tue Nov 22 04:17:05 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: pthread_dbg.c,v 1.49 2016/11/21 03:02:34 kamil Exp $ */ +/* $NetBSD: pthread_dbg.c,v 1.50 2016/11/22 04:17:05 kamil Exp $ */ /*- * Copyright (c) 2002 Wasabi Systems, Inc. @@ -36,7 +36,7 @@ */ #include -__RCSID("$NetBSD: pthread_dbg.c,v 1.49 2016/11/21 03:02:34 kamil Exp $"); +__RCSID("$NetBSD: pthread_dbg.c,v 1.50 2016/11/22 04:17:05 kamil Exp $"); #define __EXPOSE_STACK 1 @@ -345,9 +345,7 @@ td_map_pth2thr(td_proc_t *proc, pthread_ { int magic, val; - val = READ(proc, - (char *)thread + offsetof(struct __pthread_st, pt_magic), - , sizeof(magic)); + val = READ(proc, (caddr_t)>pt_magic, , sizeof(magic)); if (val != 0) return val;
CVS commit: src/lib/libpthread_dbg
Module Name:src Committed By: kamil Date: Mon Nov 21 03:02:34 UTC 2016 Modified Files: src/lib/libpthread_dbg: pthread_dbg.c pthread_dbg.h Log Message: Kill SA thread states (TD_STATE_*) in pthread_dbg and add TD_STATE_DEAD Scheduler Activation types were removed in NetBSD 5.0. Old type set is not matching the new world POSIX threads library. Only TD_STATE_RUNNING, TD_STATE_ZOMBIE are still applicable - keep it. Keep TD_STATE_UNKNOWN as generic unrecognized type. Add new TD_STATE_DEAD one. The TD_STATE_DEAD type is represented by number 6 in the POSIX threads library, but for the sake of compatibility with older software using pthread_dbg - renumber it to 7, as six was reserved for TD_STATE_SUSPENDED. Old removed state types are marked as reserved and unused. Sponsored by To generate a diff of this commit: cvs rdiff -u -r1.48 -r1.49 src/lib/libpthread_dbg/pthread_dbg.c cvs rdiff -u -r1.7 -r1.8 src/lib/libpthread_dbg/pthread_dbg.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libpthread_dbg/pthread_dbg.c diff -u src/lib/libpthread_dbg/pthread_dbg.c:1.48 src/lib/libpthread_dbg/pthread_dbg.c:1.49 --- src/lib/libpthread_dbg/pthread_dbg.c:1.48 Sun Nov 20 21:49:24 2016 +++ src/lib/libpthread_dbg/pthread_dbg.c Mon Nov 21 03:02:34 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: pthread_dbg.c,v 1.48 2016/11/20 21:49:24 kamil Exp $ */ +/* $NetBSD: pthread_dbg.c,v 1.49 2016/11/21 03:02:34 kamil Exp $ */ /*- * Copyright (c) 2002 Wasabi Systems, Inc. @@ -36,7 +36,7 @@ */ #include -__RCSID("$NetBSD: pthread_dbg.c,v 1.48 2016/11/20 21:49:24 kamil Exp $"); +__RCSID("$NetBSD: pthread_dbg.c,v 1.49 2016/11/21 03:02:34 kamil Exp $"); #define __EXPOSE_STACK 1 @@ -225,14 +225,12 @@ td_thr_info(td_thread_t *thread, td_thre case PT_STATE_RUNNING: info->thread_state = TD_STATE_RUNNING; break; -#ifdef XXXLWP - case PT_STATE_SUSPENDED: - info->thread_state = TD_STATE_SUSPENDED; - break; -#endif case PT_STATE_ZOMBIE: info->thread_state = TD_STATE_ZOMBIE; break; + case PT_STATE_DEAD: + info->thread_state = TD_STATE_DEAD; + break; default: info->thread_state = TD_STATE_UNKNOWN; } @@ -306,6 +304,7 @@ td_thr_getregs(td_thread_t *thread, int return val; break; case PT_STATE_ZOMBIE: + case PT_STATE_DEAD: default: return TD_ERR_BADTHREAD; } @@ -333,6 +332,7 @@ td_thr_setregs(td_thread_t *thread, int return val; break; case PT_STATE_ZOMBIE: + case PT_STATE_DEAD: default: return TD_ERR_BADTHREAD; } Index: src/lib/libpthread_dbg/pthread_dbg.h diff -u src/lib/libpthread_dbg/pthread_dbg.h:1.7 src/lib/libpthread_dbg/pthread_dbg.h:1.8 --- src/lib/libpthread_dbg/pthread_dbg.h:1.7 Sat Oct 22 18:04:40 2016 +++ src/lib/libpthread_dbg/pthread_dbg.h Mon Nov 21 03:02:34 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: pthread_dbg.h,v 1.7 2016/10/22 18:04:40 skrll Exp $ */ +/* $NetBSD: pthread_dbg.h,v 1.8 2016/11/21 03:02:34 kamil Exp $ */ /*- * Copyright (c) 2002 Wasabi Systems, Inc. @@ -77,11 +77,12 @@ typedef struct td_thread_info_st { #define TD_STATE_UNKNOWN 0 #define TD_STATE_RUNNING 1 /* On a processor */ -#define TD_STATE_RUNNABLE 2 /* On a run queue */ -#define TD_STATE_BLOCKED 3 /* Blocked in the kernel */ -#define TD_STATE_SLEEPING 4 /* Blocked on a sync object */ +#define TD_STATE_UNUSED2 2 /* former TD_STATE_RUNNABLE for SA */ +#define TD_STATE_UNUSED3 3 /* former TD_STATE_BLOCKED for SA */ +#define TD_STATE_UNUSED4 4 /* former TD_STATE_SLEEPING for SA */ #define TD_STATE_ZOMBIE 5 -#define TD_STATE_SUSPENDED 6 /* Removed from run queues */ +#define TD_STATE_UNUSED6 6 /* former TD_STATE_SUSPENDED for SA */ +#define TD_STATE_DEAD 7 #define TD_TYPE_UNKNOWN 0 #define TD_TYPE_USER 1
CVS commit: src/lib/libpthread_dbg
Module Name:src Committed By: kamil Date: Sun Nov 20 21:49:24 UTC 2016 Modified Files: src/lib/libpthread_dbg: pthread_dbg.c Log Message: Always set trailing '\0' in td_thr_getname() to compose valid ASCIIZ string This fixes threads5 in tests/lib/libpthread_dbg Sponsored by To generate a diff of this commit: cvs rdiff -u -r1.47 -r1.48 src/lib/libpthread_dbg/pthread_dbg.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libpthread_dbg/pthread_dbg.c diff -u src/lib/libpthread_dbg/pthread_dbg.c:1.47 src/lib/libpthread_dbg/pthread_dbg.c:1.48 --- src/lib/libpthread_dbg/pthread_dbg.c:1.47 Sun Nov 20 03:53:47 2016 +++ src/lib/libpthread_dbg/pthread_dbg.c Sun Nov 20 21:49:24 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: pthread_dbg.c,v 1.47 2016/11/20 03:53:47 kamil Exp $ */ +/* $NetBSD: pthread_dbg.c,v 1.48 2016/11/20 21:49:24 kamil Exp $ */ /*- * Copyright (c) 2002 Wasabi Systems, Inc. @@ -36,7 +36,7 @@ */ #include -__RCSID("$NetBSD: pthread_dbg.c,v 1.47 2016/11/20 03:53:47 kamil Exp $"); +__RCSID("$NetBSD: pthread_dbg.c,v 1.48 2016/11/20 21:49:24 kamil Exp $"); #define __EXPOSE_STACK 1 @@ -280,6 +280,9 @@ td_thr_getname(td_thread_t *thread, char name, (size_t)MIN(PTHREAD_MAX_NAMELEN_NP, len))) != 0) return val; + if (len < PTHREAD_MAX_NAMELEN_NP) + name[len - 1] = '\0'; + return 0; }
CVS commit: src/lib/libpthread_dbg
Module Name:src Committed By: kamil Date: Sun Nov 20 03:53:47 UTC 2016 Modified Files: src/lib/libpthread_dbg: pthread_dbg.c Log Message: Fix pt_magic read in td_map_pth2thr() The pt_magic field is not the first one in the pthread_t structure. Sponsored by To generate a diff of this commit: cvs rdiff -u -r1.46 -r1.47 src/lib/libpthread_dbg/pthread_dbg.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libpthread_dbg/pthread_dbg.c diff -u src/lib/libpthread_dbg/pthread_dbg.c:1.46 src/lib/libpthread_dbg/pthread_dbg.c:1.47 --- src/lib/libpthread_dbg/pthread_dbg.c:1.46 Sun Nov 20 03:11:32 2016 +++ src/lib/libpthread_dbg/pthread_dbg.c Sun Nov 20 03:53:47 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: pthread_dbg.c,v 1.46 2016/11/20 03:11:32 kamil Exp $ */ +/* $NetBSD: pthread_dbg.c,v 1.47 2016/11/20 03:53:47 kamil Exp $ */ /*- * Copyright (c) 2002 Wasabi Systems, Inc. @@ -36,7 +36,7 @@ */ #include -__RCSID("$NetBSD: pthread_dbg.c,v 1.46 2016/11/20 03:11:32 kamil Exp $"); +__RCSID("$NetBSD: pthread_dbg.c,v 1.47 2016/11/20 03:53:47 kamil Exp $"); #define __EXPOSE_STACK 1 @@ -342,7 +342,9 @@ td_map_pth2thr(td_proc_t *proc, pthread_ { int magic, val; - val = READ(proc, (void *)thread, , sizeof(magic)); + val = READ(proc, + (char *)thread + offsetof(struct __pthread_st, pt_magic), + , sizeof(magic)); if (val != 0) return val;
CVS commit: src/lib/libpthread_dbg
Module Name:src Committed By: kamil Date: Sun Nov 20 03:11:32 UTC 2016 Modified Files: src/lib/libpthread_dbg: pthread_dbg.c Log Message: Catch up with correct pt_magic reads in td_thr_{getname,suspend,resume} The pt_magic field is not the first one in the pthread_t structure. Sponsored by To generate a diff of this commit: cvs rdiff -u -r1.45 -r1.46 src/lib/libpthread_dbg/pthread_dbg.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libpthread_dbg/pthread_dbg.c diff -u src/lib/libpthread_dbg/pthread_dbg.c:1.45 src/lib/libpthread_dbg/pthread_dbg.c:1.46 --- src/lib/libpthread_dbg/pthread_dbg.c:1.45 Sun Nov 20 02:27:56 2016 +++ src/lib/libpthread_dbg/pthread_dbg.c Sun Nov 20 03:11:32 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: pthread_dbg.c,v 1.45 2016/11/20 02:27:56 kamil Exp $ */ +/* $NetBSD: pthread_dbg.c,v 1.46 2016/11/20 03:11:32 kamil Exp $ */ /*- * Copyright (c) 2002 Wasabi Systems, Inc. @@ -36,7 +36,7 @@ */ #include -__RCSID("$NetBSD: pthread_dbg.c,v 1.45 2016/11/20 02:27:56 kamil Exp $"); +__RCSID("$NetBSD: pthread_dbg.c,v 1.46 2016/11/20 03:11:32 kamil Exp $"); #define __EXPOSE_STACK 1 @@ -263,7 +263,7 @@ td_thr_getname(td_thread_t *thread, char caddr_t nameaddr; - val = READ(thread->proc, thread->addr, , sizeof(tmp)); + val = READ(thread->proc, OFFSET(thread, pt_magic), , sizeof(tmp)); if (val != 0) return val; @@ -441,7 +441,7 @@ td_thr_suspend(td_thread_t *thread) int tmp, val; /* validate the thread */ - val = READ(thread->proc, thread->addr, , sizeof(tmp)); + val = READ(thread->proc, OFFSET(thread, pt_magic), , sizeof(tmp)); if (val != 0) return val; if (tmp != PT_MAGIC) @@ -463,7 +463,7 @@ td_thr_resume(td_thread_t *thread) int tmp, val; /* validate the thread */ - val = READ(thread->proc, thread->addr, , sizeof(tmp)); + val = READ(thread->proc, OFFSET(thread, pt_magic), , sizeof(tmp)); if (val != 0) return val; if (tmp != PT_MAGIC)
CVS commit: src/lib/libpthread_dbg
Module Name:src Committed By: kamil Date: Sun Nov 20 02:27:56 UTC 2016 Modified Files: src/lib/libpthread_dbg: pthread_dbg.c Log Message: Fix pt_magic (part of pthread_t) read in td_thr_info() The pt_magic field is not the first one in the pthread_t structure. After this fix, this code is confirmed to work and function td_thr_info() is functional. Sponsored by To generate a diff of this commit: cvs rdiff -u -r1.44 -r1.45 src/lib/libpthread_dbg/pthread_dbg.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libpthread_dbg/pthread_dbg.c diff -u src/lib/libpthread_dbg/pthread_dbg.c:1.44 src/lib/libpthread_dbg/pthread_dbg.c:1.45 --- src/lib/libpthread_dbg/pthread_dbg.c:1.44 Sat Jan 23 14:02:21 2016 +++ src/lib/libpthread_dbg/pthread_dbg.c Sun Nov 20 02:27:56 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: pthread_dbg.c,v 1.44 2016/01/23 14:02:21 christos Exp $ */ +/* $NetBSD: pthread_dbg.c,v 1.45 2016/11/20 02:27:56 kamil Exp $ */ /*- * Copyright (c) 2002 Wasabi Systems, Inc. @@ -36,7 +36,7 @@ */ #include -__RCSID("$NetBSD: pthread_dbg.c,v 1.44 2016/01/23 14:02:21 christos Exp $"); +__RCSID("$NetBSD: pthread_dbg.c,v 1.45 2016/11/20 02:27:56 kamil Exp $"); #define __EXPOSE_STACK 1 @@ -210,7 +210,7 @@ td_thr_info(td_thread_t *thread, td_thre { int tmp, val; - val = READ(thread->proc, thread->addr, , sizeof(tmp)); + val = READ(thread->proc, OFFSET(thread, pt_magic), , sizeof(tmp)); if (val != 0) return val;
CVS commit: src/lib/libpthread_dbg
Module Name:src Committed By: skrll Date: Sat Oct 22 18:04:40 UTC 2016 Modified Files: src/lib/libpthread_dbg: pthread_dbg.h Log Message: Add multiple inclusion protection and __{BEGIN,END}_DECLS as a native gdb build uses c++ to build nbsd-thread.c To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/lib/libpthread_dbg/pthread_dbg.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libpthread_dbg/pthread_dbg.h diff -u src/lib/libpthread_dbg/pthread_dbg.h:1.6 src/lib/libpthread_dbg/pthread_dbg.h:1.7 --- src/lib/libpthread_dbg/pthread_dbg.h:1.6 Sun Oct 2 18:18:14 2011 +++ src/lib/libpthread_dbg/pthread_dbg.h Sat Oct 22 18:04:40 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: pthread_dbg.h,v 1.6 2011/10/02 18:18:14 christos Exp $ */ +/* $NetBSD: pthread_dbg.h,v 1.7 2016/10/22 18:04:40 skrll Exp $ */ /*- * Copyright (c) 2002 Wasabi Systems, Inc. @@ -35,9 +35,14 @@ * POSSIBILITY OF SUCH DAMAGE. */ +#ifndef _LIB_PTHREAD_DBG_H +#define _LIB_PTHREAD_DBG_H + #include #include +__BEGIN_DECLS + struct td_proc_st; struct td_thread_st; struct td_sync_st; @@ -188,3 +193,7 @@ int td_thr_suspend(td_thread_t *); /* Restore a suspended thread to its previous state */ int td_thr_resume(td_thread_t *); + +__END_DECLS + +#endif /* _LIB_PTHREAD_DBG_H */
CVS commit: src/lib/libpthread_dbg
Module Name:src Committed By: christos Date: Sat Jan 23 14:02:22 UTC 2016 Modified Files: src/lib/libpthread_dbg: pthread_dbg.c pthread_dbg_int.h Log Message: don't use kernel types. To generate a diff of this commit: cvs rdiff -u -r1.43 -r1.44 src/lib/libpthread_dbg/pthread_dbg.c cvs rdiff -u -r1.7 -r1.8 src/lib/libpthread_dbg/pthread_dbg_int.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libpthread_dbg/pthread_dbg.c diff -u src/lib/libpthread_dbg/pthread_dbg.c:1.43 src/lib/libpthread_dbg/pthread_dbg.c:1.44 --- src/lib/libpthread_dbg/pthread_dbg.c:1.43 Fri May 29 03:37:32 2015 +++ src/lib/libpthread_dbg/pthread_dbg.c Sat Jan 23 09:02:21 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: pthread_dbg.c,v 1.43 2015/05/29 07:37:32 manu Exp $ */ +/* $NetBSD: pthread_dbg.c,v 1.44 2016/01/23 14:02:21 christos Exp $ */ /*- * Copyright (c) 2002 Wasabi Systems, Inc. @@ -36,7 +36,7 @@ */ #include -__RCSID("$NetBSD: pthread_dbg.c,v 1.43 2015/05/29 07:37:32 manu Exp $"); +__RCSID("$NetBSD: pthread_dbg.c,v 1.44 2016/01/23 14:02:21 christos Exp $"); #define __EXPOSE_STACK 1 @@ -59,6 +59,8 @@ __RCSID("$NetBSD: pthread_dbg.c,v 1.43 2 #include #define PT_STACKMASK (proc->stackmask) +#define OFFSET(thread, field) \ +(((char *)(thread)->addr) + offsetof(struct __pthread_st, field)) /* Compensate for debuggers that want a zero ID to be a sentinel */ #define TN_OFFSET 1 @@ -216,9 +218,8 @@ td_thr_info(td_thread_t *thread, td_thre return TD_ERR_BADTHREAD; info->thread_addr = thread->addr; - if ((val = READ(thread->proc, - thread->addr + offsetof(struct __pthread_st, pt_state), - , sizeof(tmp))) != 0) + if ((val = READ(thread->proc, + OFFSET(thread, pt_state), , sizeof(tmp))) != 0) return val; switch (tmp) { case PT_STATE_RUNNING: @@ -238,18 +239,15 @@ td_thr_info(td_thread_t *thread, td_thre info->thread_type = TD_TYPE_USER; - if ((val = READ(thread->proc, - thread->addr + offsetof(struct __pthread_st, pt_stack), + if ((val = READ(thread->proc, OFFSET(thread, pt_stack), >thread_stack, sizeof(stack_t))) != 0) return val; - if ((val = READ(thread->proc, - thread->addr + offsetof(struct __pthread_st, pt_errno), + if ((val = READ(thread->proc, OFFSET(thread, pt_errno), >thread_errno, sizeof(info->thread_errno))) != 0) return val; - if ((val = READ(thread->proc, - thread->addr + offsetof(struct __pthread_st, pt_lid), + if ((val = READ(thread->proc, OFFSET(thread, pt_lid), >thread_id, sizeof(info->thread_id))) != 0) return val; @@ -272,8 +270,7 @@ td_thr_getname(td_thread_t *thread, char if (tmp != PT_MAGIC) return TD_ERR_BADTHREAD; - if ((val = READ(thread->proc, - thread->addr + offsetof(struct __pthread_st, pt_name), + if ((val = READ(thread->proc, OFFSET(thread, pt_name), , sizeof(nameaddr))) != 0) return val; @@ -291,9 +288,8 @@ td_thr_getregs(td_thread_t *thread, int { int tmp, val; - if ((val = READ(thread->proc, - thread->addr + offsetof(struct __pthread_st, pt_state), - , sizeof(tmp))) != 0) + if ((val = READ(thread->proc, OFFSET(thread, pt_state), + , sizeof(tmp))) != 0) return val; switch (tmp) { @@ -319,9 +315,8 @@ td_thr_setregs(td_thread_t *thread, int { int val, tmp; - if ((val = READ(thread->proc, - thread->addr + offsetof(struct __pthread_st, pt_state), - , sizeof(tmp))) != 0) + if ((val = READ(thread->proc, OFFSET(thread, pt_state), + , sizeof(tmp))) != 0) return val; switch (tmp) { @@ -378,8 +373,7 @@ td_map_id2thr(td_proc_t *proc, int threa threadid -= TN_OFFSET; next = (void *)allq.ptqh_first; while (next != NULL) { - val = READ(proc, - next + offsetof(struct __pthread_st, pt_lid), + val = READ(proc, next + offsetof(struct __pthread_st, pt_lid), , sizeof(num)); if (num == threadid) @@ -453,9 +447,7 @@ td_thr_suspend(td_thread_t *thread) if (tmp != PT_MAGIC) return TD_ERR_BADTHREAD; - val = READ(thread->proc, thread->addr + - offsetof(struct __pthread_st, pt_lid), - , sizeof(tmp)); + val = READ(thread->proc, OFFSET(thread, pt_lid), , sizeof(tmp)); if (val != 0) return val; @@ -477,9 +469,7 @@ td_thr_resume(td_thread_t *thread) if (tmp != PT_MAGIC) return TD_ERR_BADTHREAD; - val = READ(thread->proc, thread->addr + - offsetof(struct __pthread_st, pt_lid), - , sizeof(tmp)); + val = READ(thread->proc, OFFSET(thread, pt_lid), , sizeof(tmp)); if (val != 0) return val; @@ -522,8 +512,7 @@ td_thr_tsd(td_thread_t *thread, pthread_ { int val; - val = READ(thread->proc, thread->addr + - offsetof(struct __pthread_st, pt_specific) + + val = READ(thread->proc, OFFSET(thread, pt_specific) + key * sizeof(void *), value, sizeof(*value)); return val; Index: src/lib/libpthread_dbg/pthread_dbg_int.h diff -u
CVS commit: src/lib/libpthread_dbg
Module Name:src Committed By: christos Date: Sun Jan 20 18:18:07 UTC 2013 Modified Files: src/lib/libpthread_dbg: pthread_dbg.c pthread_dbg_int.h Log Message: tsd_alloc is no more, use tsd_list, and disable the destructor walking code since it needs work. Fixes gdb. To generate a diff of this commit: cvs rdiff -u -r1.40 -r1.41 src/lib/libpthread_dbg/pthread_dbg.c cvs rdiff -u -r1.6 -r1.7 src/lib/libpthread_dbg/pthread_dbg_int.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libpthread_dbg/pthread_dbg.c diff -u src/lib/libpthread_dbg/pthread_dbg.c:1.40 src/lib/libpthread_dbg/pthread_dbg.c:1.41 --- src/lib/libpthread_dbg/pthread_dbg.c:1.40 Fri Mar 7 17:27:07 2008 +++ src/lib/libpthread_dbg/pthread_dbg.c Sun Jan 20 13:18:07 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: pthread_dbg.c,v 1.40 2008/03/07 22:27:07 ad Exp $ */ +/* $NetBSD: pthread_dbg.c,v 1.41 2013/01/20 18:18:07 christos Exp $ */ /*- * Copyright (c) 2002 Wasabi Systems, Inc. @@ -36,7 +36,7 @@ */ #include sys/cdefs.h -__RCSID($NetBSD: pthread_dbg.c,v 1.40 2008/03/07 22:27:07 ad Exp $); +__RCSID($NetBSD: pthread_dbg.c,v 1.41 2013/01/20 18:18:07 christos Exp $); #define __EXPOSE_STACK 1 @@ -95,13 +95,13 @@ td_open(struct td_proc_callbacks_t *cb, } proc-allqaddr = addr; - val = LOOKUP(proc, pthread__tsd_alloc, addr); + val = LOOKUP(proc, pthread__tsd_list, addr); if (val != 0) { if (val == TD_ERR_NOSYM) val = TD_ERR_NOLIB; goto error; } - proc-tsdallocaddr = addr; + proc-tsdlistaddr = addr; val = LOOKUP(proc, pthread__tsd_destructors, addr); if (val != 0) { @@ -418,13 +418,14 @@ int td_tsd_iter(td_proc_t *proc, int (*call)(pthread_key_t, void (*)(void *), void *), void *arg) { +#ifdef notyet int val; int i; void *allocated; void (*destructor)(void *); for (i = 0; i PTHREAD_KEYS_MAX; i++) { - val = READ(proc, proc-tsdallocaddr + i * sizeof(allocated), + val = READ(proc, proc-tsdlistaddr + i * sizeof(allocated), allocated, sizeof(allocated)); if (val != 0) return val; @@ -441,6 +442,9 @@ td_tsd_iter(td_proc_t *proc, return val; } } +#else + abort(); +#endif return 0; } Index: src/lib/libpthread_dbg/pthread_dbg_int.h diff -u src/lib/libpthread_dbg/pthread_dbg_int.h:1.6 src/lib/libpthread_dbg/pthread_dbg_int.h:1.7 --- src/lib/libpthread_dbg/pthread_dbg_int.h:1.6 Tue Oct 16 11:06:11 2007 +++ src/lib/libpthread_dbg/pthread_dbg_int.h Sun Jan 20 13:18:07 2013 @@ -12,7 +12,7 @@ struct td_proc_st { caddr_t idleqaddr; caddr_t suspqaddr; caddr_t maxlwpsaddr; - caddr_t tsdallocaddr; + caddr_t tsdlistaddr; caddr_t tsddestaddr; caddr_t stacksizeaddr;
CVS commit: src/lib/libpthread_dbg
Module Name:src Committed By: christos Date: Sun Jan 20 18:45:19 UTC 2013 Modified Files: src/lib/libpthread_dbg: pthread_dbg.c Log Message: Only the first symbol (pthread_dbg) should return NOLIB, the rest indicate internal inconsistencies, so let the code return a more vocal error. To generate a diff of this commit: cvs rdiff -u -r1.41 -r1.42 src/lib/libpthread_dbg/pthread_dbg.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libpthread_dbg/pthread_dbg.c diff -u src/lib/libpthread_dbg/pthread_dbg.c:1.41 src/lib/libpthread_dbg/pthread_dbg.c:1.42 --- src/lib/libpthread_dbg/pthread_dbg.c:1.41 Sun Jan 20 13:18:07 2013 +++ src/lib/libpthread_dbg/pthread_dbg.c Sun Jan 20 13:45:19 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: pthread_dbg.c,v 1.41 2013/01/20 18:18:07 christos Exp $ */ +/* $NetBSD: pthread_dbg.c,v 1.42 2013/01/20 18:45:19 christos Exp $ */ /*- * Copyright (c) 2002 Wasabi Systems, Inc. @@ -36,7 +36,7 @@ */ #include sys/cdefs.h -__RCSID($NetBSD: pthread_dbg.c,v 1.41 2013/01/20 18:18:07 christos Exp $); +__RCSID($NetBSD: pthread_dbg.c,v 1.42 2013/01/20 18:45:19 christos Exp $); #define __EXPOSE_STACK 1 @@ -88,27 +88,18 @@ td_open(struct td_proc_callbacks_t *cb, proc-dbgaddr = addr; val = LOOKUP(proc, pthread__allqueue, addr); - if (val != 0) { - if (val == TD_ERR_NOSYM) - val = TD_ERR_NOLIB; + if (val != 0) goto error; - } proc-allqaddr = addr; val = LOOKUP(proc, pthread__tsd_list, addr); - if (val != 0) { - if (val == TD_ERR_NOSYM) - val = TD_ERR_NOLIB; + if (val != 0) goto error; - } proc-tsdlistaddr = addr; val = LOOKUP(proc, pthread__tsd_destructors, addr); - if (val != 0) { - if (val == TD_ERR_NOSYM) - val = TD_ERR_NOLIB; + if (val != 0) goto error; - } proc-tsddestaddr = addr; val = READ(proc, proc-dbgaddr, dbg, sizeof(int));
CVS commit: src/lib/libpthread_dbg
Module Name:src Committed By: joerg Date: Thu Jul 19 06:33:49 UTC 2012 Modified Files: src/lib/libpthread_dbg: Makefile Log Message: Match ARCHSUBDIR logic from libpthread. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/lib/libpthread_dbg/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libpthread_dbg/Makefile diff -u src/lib/libpthread_dbg/Makefile:1.9 src/lib/libpthread_dbg/Makefile:1.10 --- src/lib/libpthread_dbg/Makefile:1.9 Wed Mar 21 05:37:43 2012 +++ src/lib/libpthread_dbg/Makefile Thu Jul 19 06:33:48 2012 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.9 2012/03/21 05:37:43 matt Exp $ +# $NetBSD: Makefile,v 1.10 2012/07/19 06:33:48 joerg Exp $ # WARNS?= 5 @@ -7,7 +7,10 @@ WARNS?= 5 LIBPDIR= ${.CURDIR}/../libpthread -.if exists(${LIBPDIR}/arch/${MACHINE_ARCH}) +.if defined(PTHREAD_MACHINE_ARCH) !empty(PTHREAD_MACHINE_ARCH) \ +exists(${LIBPDIR}/arch/${PTHREAD_MACHINE_ARCH}) +ARCHSUBDIR= ${PTHREAD_MACHINE_ARCH} +.elif exists(${LIBPDIR}/arch/${MACHINE_ARCH}) ARCHSUBDIR= ${MACHINE_ARCH} .elif exists(${LIBPDIR}/arch/${MACHINE_CPU}) ARCHSUBDIR= ${MACHINE_CPU}
CVS commit: src/lib/libpthread_dbg
Module Name:src Committed By: christos Date: Sun Oct 2 18:18:14 UTC 2011 Modified Files: src/lib/libpthread_dbg: pthread_dbg.h Log Message: constify. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/lib/libpthread_dbg/pthread_dbg.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libpthread_dbg/pthread_dbg.h diff -u src/lib/libpthread_dbg/pthread_dbg.h:1.5 src/lib/libpthread_dbg/pthread_dbg.h:1.6 --- src/lib/libpthread_dbg/pthread_dbg.h:1.5 Wed Jun 2 17:18:25 2004 +++ src/lib/libpthread_dbg/pthread_dbg.h Sun Oct 2 14:18:14 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: pthread_dbg.h,v 1.5 2004/06/02 21:18:25 nathanw Exp $ */ +/* $NetBSD: pthread_dbg.h,v 1.6 2011/10/02 18:18:14 christos Exp $ */ /*- * Copyright (c) 2002 Wasabi Systems, Inc. @@ -49,7 +49,7 @@ typedef struct td_sync_st td_sync_t; struct td_proc_callbacks_t { int (*proc_read)(void *arg, caddr_t addr, void *buf, size_t size); int (*proc_write)(void *arg, caddr_t addr, void *buf, size_t size); - int (*proc_lookup)(void *arg, char *sym, caddr_t *addr); + int (*proc_lookup)(void *arg, const char *sym, caddr_t *addr); int (*proc_regsize)(void *arg, int regset, size_t *size); int (*proc_getregs)(void *arg, int regset, int lwp, void *buf); int (*proc_setregs)(void *arg, int regset, int lwp, void *buf);
CVS commit: src/lib/libpthread_dbg
Module Name:src Committed By: matt Date: Thu Mar 17 01:01:15 UTC 2011 Modified Files: src/lib/libpthread_dbg: Makefile Log Message: Since this is use pthread_int.h, it needs __LIBPTHREAD_SOURCE__ to be defined. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/lib/libpthread_dbg/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libpthread_dbg/Makefile diff -u src/lib/libpthread_dbg/Makefile:1.7 src/lib/libpthread_dbg/Makefile:1.8 --- src/lib/libpthread_dbg/Makefile:1.7 Thu Aug 16 01:09:50 2007 +++ src/lib/libpthread_dbg/Makefile Thu Mar 17 01:01:15 2011 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.7 2007/08/16 01:09:50 ad Exp $ +# $NetBSD: Makefile,v 1.8 2011/03/17 01:01:15 matt Exp $ # WARNS= 2 @@ -32,6 +32,8 @@ SRCS= pthread_dbg.c +CPPFLAGS+= -D__LIBPTHREAD_SOURCE__ + INCS= pthread_dbg.h INCSDIR=/usr/include