PERFORCE change 74939 for review
David Xu
davidxu at FreeBSD.org
Mon Apr 11 16:33:50 PDT 2005
http://perforce.freebsd.org/chv.cgi?CH=74939
Change 74939 by davidxu at davidxu_tiger on 2005/04/11 23:32:56
Use thread_db.h in libthr.
Rename some symbols.
Affected files ...
.. //depot/projects/davidxu_thread/src/lib/libthr/Makefile#4 edit
.. //depot/projects/davidxu_thread/src/lib/libthr/pthread.map#9 edit
.. //depot/projects/davidxu_thread/src/lib/libthr/thread/thr_event.c#11 edit
.. //depot/projects/davidxu_thread/src/lib/libthr/thread/thr_private.h#16 edit
.. //depot/projects/davidxu_thread/src/lib/libthr/thread/thr_symbols.c#8 edit
.. //depot/projects/davidxu_thread/src/lib/libthread_db/libthr_db.c#11 edit
.. //depot/projects/davidxu_thread/src/lib/libthread_db/thread_db.h#4 edit
Differences ...
==== //depot/projects/davidxu_thread/src/lib/libthr/Makefile#4 (text+ko) ====
@@ -16,6 +16,7 @@
CFLAGS+=-I${.CURDIR}/sys
CFLAGS+=-I${.CURDIR}/../../libexec/rtld-elf
CFLAGS+=-I${.CURDIR}/../../libexec/rtld-elf/${MACHINE_ARCH}
+CFLAGS+=-I${.CURDIR}/../libthread_db
CFLAGS+=-Winline
# CFLAGS+=-DSYSTEM_SCOPE_ONLY
==== //depot/projects/davidxu_thread/src/lib/libthr/pthread.map#9 (text+ko) ====
@@ -344,28 +344,29 @@
# Debugger needs these.
_libthr_debug;
_thread_active_threads;
+ _thread_bp_create;
+ _thread_bp_death;
+ _thread_event_mask;
_thread_keytable;
+ _thread_last_event;
_thread_list;
_thread_max_keys;
_thread_off_attr_flags;
_thread_off_dtv;
+ _thread_off_event_mask;
+ _thread_off_event_buf;
+ _thread_off_key_allocated;
+ _thread_off_key_destructor;
_thread_off_linkmap;
_thread_off_next;
+ _thread_off_report_events;
+ _thread_off_state;
_thread_off_tcb;
_thread_off_tid;
- _thread_off_key_allocated;
- _thread_off_key_destructor;
- _thread_off_state;
_thread_off_tlsindex;
- _thread_off_report_events;
- _thread_off_event_mask;
_thread_size_key;
_thread_state_running;
_thread_state_zoombie;
- _thread_event;
- _thread_event_mask;
- _thread_create_bp;
- _thread_death_bp;
local:
*;
};
==== //depot/projects/davidxu_thread/src/lib/libthr/thread/thr_event.c#11 (text+ko) ====
@@ -29,33 +29,37 @@
#include "thr_private.h"
void
-_thread_create_bp(void)
+_thread_bp_create(void)
{
}
void
-_thread_death_bp(void)
+_thread_bp_death(void)
{
}
void
_thr_report_creation(struct pthread *curthread, struct pthread *newthread)
{
+ curthread->event_buf.event = TD_CREATE;
+ curthread->event_buf.th_p = (td_thrhandle_t *)newthread;
+ curthread->event_buf.data = 0;
THR_UMTX_LOCK(curthread, &_thr_event_lock);
- _thread_event.event = TD_CREATE;
- _thread_event.thread = newthread;
- _thread_event.data = 0;
- _thread_create_bp();
+ _thread_last_event = curthread;
+ _thread_bp_create();
+ _thread_last_event = NULL;
THR_UMTX_UNLOCK(curthread, &_thr_event_lock);
}
void
_thr_report_death(struct pthread *curthread)
{
+ curthread->event_buf.event = TD_DEATH;
+ curthread->event_buf.th_p = (td_thrhandle_t *)curthread;
+ curthread->event_buf.data = 0;
THR_UMTX_LOCK(curthread, &_thr_event_lock);
- _thread_event.event = TD_DEATH;
- _thread_event.thread = curthread;
- _thread_event.data = 0;
- _thread_death_bp();
+ _thread_last_event = curthread;
+ _thread_bp_death();
+ _thread_last_event = NULL;
THR_UMTX_UNLOCK(curthread, &_thr_event_lock);
}
==== //depot/projects/davidxu_thread/src/lib/libthr/thread/thr_private.h#16 (text+ko) ====
@@ -56,6 +56,7 @@
#include "pthread_md.h"
#include "thr_umtx.h"
+#include "thread_db.h"
/*
* Evaluate the storage class specifier.
@@ -490,9 +491,14 @@
/* Cleanup handlers Link List */
struct pthread_cleanup *cleanup;
- /* Event reporting masks */
+ /* Enable event reporting */
int report_events;
+
+ /* Event mask */
int event_mask;
+
+ /* Event */
+ td_event_msg_t event_buf;
};
#define THR_UMTX_TRYLOCK(thrd, lck) \
@@ -575,16 +581,6 @@
#define THR_IN_SYNCQ(thrd) (((thrd)->sflags & THR_FLAGS_IN_SYNCQ) != 0)
-struct pthread_event
-{
- int event;
- struct pthread *thread;
- void *data;
-};
-
-/* XXX this must match thread_db.h */
-#define TD_CREATE 0x0004
-#define TD_DEATH 0x0008
#define SHOULD_REPORT_EVENT(curthr, e) \
(curthr->report_events && \
(((curthr)->event_mask | _thread_event_mask ) & e) != 0)
@@ -602,7 +598,7 @@
/* For debugger */
SCLASS int _libthr_debug SCLASS_PRESET(0);
SCLASS int _thread_event_mask SCLASS_PRESET(0);
-SCLASS struct pthread_event _thread_event;
+SCLASS struct pthread *_thread_last_event;
/* List of all threads: */
SCLASS TAILQ_HEAD(, pthread) _thread_list
@@ -743,8 +739,8 @@
void _thr_report_creation(struct pthread *curthread,
struct pthread *newthread);
void _thr_report_death(struct pthread *curthread);
-void _thread_create_bp(void);
-void _thread_death_bp(void);
+void _thread_bp_create(void);
+void _thread_bp_death(void);
/* #include <sys/aio.h> */
#ifdef _SYS_AIO_H_
==== //depot/projects/davidxu_thread/src/lib/libthr/thread/thr_symbols.c#8 (text+ko) ====
@@ -49,6 +49,7 @@
int _thread_off_tlsindex = offsetof(Obj_Entry, tlsindex);
int _thread_off_report_events = offsetof(struct pthread, report_events);
int _thread_off_event_mask = offsetof(struct pthread, event_mask);
+int _thread_off_event_buf = offsetof(struct pthread, event_buf);
int _thread_size_key = sizeof(struct pthread_key);
int _thread_off_key_allocated = offsetof(struct pthread_key, allocated);
int _thread_off_key_destructor = offsetof(struct pthread_key, destructor);
==== //depot/projects/davidxu_thread/src/lib/libthread_db/libthr_db.c#11 (text+ko) ====
@@ -53,10 +53,10 @@
psaddr_t thread_list_addr;
psaddr_t thread_active_threads_addr;
psaddr_t thread_keytable_addr;
- psaddr_t thread_event_addr;
+ psaddr_t thread_last_event_addr;
psaddr_t thread_event_mask_addr;
- psaddr_t thread_create_bp_addr;
- psaddr_t thread_death_bp_addr;
+ psaddr_t thread_bp_create_addr;
+ psaddr_t thread_bp_death_addr;
int thread_inited;
int thread_off_dtv;
int thread_off_tlsindex;
@@ -200,10 +200,10 @@
LOOKUP_SYM(ph, "_thread_list", &ta->thread_list_addr);
LOOKUP_SYM(ph, "_thread_active_threads",&ta->thread_active_threads_addr);
LOOKUP_SYM(ph, "_thread_keytable", &ta->thread_keytable_addr);
- LOOKUP_SYM(ph, "_thread_event", &ta->thread_event_addr);
+ LOOKUP_SYM(ph, "_thread_last_event", &ta->thread_last_event_addr);
LOOKUP_SYM(ph, "_thread_event_mask", &ta->thread_event_mask_addr);
- LOOKUP_SYM(ph, "_thread_create_bp", &ta->thread_create_bp_addr);
- LOOKUP_SYM(ph, "_thread_death_bp", &ta->thread_death_bp_addr);
+ LOOKUP_SYM(ph, "_thread_bp_create", &ta->thread_bp_create_addr);
+ LOOKUP_SYM(ph, "_thread_bp_death", &ta->thread_bp_death_addr);
LOOKUP_VAL(ph, "_thread_off_dtv", &ta->thread_off_dtv);
LOOKUP_VAL(ph, "_thread_off_tlsindex", &ta->thread_off_tlsindex);
LOOKUP_VAL(ph, "_thread_off_attr_flags", &ta->thread_off_attr_flags);
@@ -438,11 +438,11 @@
switch (event) {
case TD_CREATE:
ptr->type = NOTIFY_BPT;
- ptr->u.bptaddr = ta->thread_create_bp_addr;
+ ptr->u.bptaddr = ta->thread_bp_create_addr;
return (0);
case TD_DEATH:
ptr->type = NOTIFY_BPT;
- ptr->u.bptaddr = ta->thread_death_bp_addr;
+ ptr->u.bptaddr = ta->thread_bp_death_addr;
return (0);
default:
return (TD_ERR);
==== //depot/projects/davidxu_thread/src/lib/libthread_db/thread_db.h#4 (text+ko) ====
@@ -57,6 +57,7 @@
TD_PARTIALREG
} td_err_e;
+struct ps_prochandle;
typedef struct td_thragent td_thragent_t;
typedef long thread_t; /* Must be an integral type. */
More information about the p4-projects
mailing list