Deleted Added
full compact
thread_db.c (163540) thread_db.c (177490)
1/*
2 * Copyright (c) 2004 David Xu <davidxu@freebsd.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 11 unchanged lines hidden (view full) ---

20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#include <sys/cdefs.h>
1/*
2 * Copyright (c) 2004 David Xu <davidxu@freebsd.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 11 unchanged lines hidden (view full) ---

20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#include <sys/cdefs.h>
28__FBSDID("$FreeBSD: head/lib/libthread_db/thread_db.c 163540 2006-10-20 14:15:42Z davidxu $");
28__FBSDID("$FreeBSD: head/lib/libthread_db/thread_db.c 177490 2008-03-22 05:40:44Z davidxu $");
29
30#include <proc_service.h>
31#include <stddef.h>
32#include <thread_db.h>
33#include <unistd.h>
29
30#include <proc_service.h>
31#include <stddef.h>
32#include <thread_db.h>
33#include <unistd.h>
34#include <sys/cdefs.h>
35#include <sys/linker_set.h>
34
35#include "thread_db_int.h"
36
37struct td_thragent
38{
39 TD_THRAGENT_FIELDS;
40};
41
42static TAILQ_HEAD(, td_thragent) proclist = TAILQ_HEAD_INITIALIZER(proclist);
43
36
37#include "thread_db_int.h"
38
39struct td_thragent
40{
41 TD_THRAGENT_FIELDS;
42};
43
44static TAILQ_HEAD(, td_thragent) proclist = TAILQ_HEAD_INITIALIZER(proclist);
45
44extern struct ta_ops libpthread_db_ops;
45extern struct ta_ops libthr_db_ops;
46SET_DECLARE(__ta_ops, struct ta_ops);
46
47
47static struct ta_ops *ops[] = {
48 &libpthread_db_ops,
49 &libthr_db_ops,
50};
51
52td_err_e
53td_init(void)
54{
55 td_err_e ret, tmp;
48td_err_e
49td_init(void)
50{
51 td_err_e ret, tmp;
52 struct ta_ops *ops_p, **ops_pp;
56 size_t i;
57
58 ret = 0;
53 size_t i;
54
55 ret = 0;
59 for (i = 0; i < sizeof(ops)/sizeof(ops[0]); i++) {
60 if (ops[i]->to_init != NULL) {
61 tmp = ops[i]->to_init();
56 SET_FOREACH(ops_pp, __ta_ops) {
57 ops_p = *ops_pp;
58 if (ops_p->to_init != NULL) {
59 tmp = ops_p->to_init();
62 if (tmp != TD_OK)
63 ret = tmp;
64 }
65 }
66 return (ret);
67}
68
69td_err_e

--- 32 unchanged lines hidden (view full) ---

102{
103 return (ta->ta_ops->to_ta_map_lwp2thr(ta, lwpid, th));
104}
105
106td_err_e
107td_ta_new(struct ps_prochandle *ph, td_thragent_t **pta)
108{
109 size_t i;
60 if (tmp != TD_OK)
61 ret = tmp;
62 }
63 }
64 return (ret);
65}
66
67td_err_e

--- 32 unchanged lines hidden (view full) ---

100{
101 return (ta->ta_ops->to_ta_map_lwp2thr(ta, lwpid, th));
102}
103
104td_err_e
105td_ta_new(struct ps_prochandle *ph, td_thragent_t **pta)
106{
107 size_t i;
108 struct ta_ops *ops_p, **ops_pp;
110
109
111 for (i = 0; i < sizeof(ops)/sizeof(ops[0]); ++i) {
112 if (ops[i]->to_ta_new(ph, pta) == TD_OK) {
110 SET_FOREACH(ops_pp, __ta_ops) {
111 ops_p = *ops_pp;
112 if (ops_p->to_ta_new(ph, pta) == TD_OK) {
113 TAILQ_INSERT_HEAD(&proclist, *pta, ta_next);
113 TAILQ_INSERT_HEAD(&proclist, *pta, ta_next);
114 (*pta)->ta_ops = ops[i];
114 (*pta)->ta_ops = ops_p;
115 return (TD_OK);
116 }
117 }
118 return (TD_NOLIBTHREAD);
119}
120
121td_err_e
122td_ta_set_event(const td_thragent_t *ta, td_thr_events_t *events)

--- 139 unchanged lines hidden ---
115 return (TD_OK);
116 }
117 }
118 return (TD_NOLIBTHREAD);
119}
120
121td_err_e
122td_ta_set_event(const td_thragent_t *ta, td_thr_events_t *events)

--- 139 unchanged lines hidden ---