diff options
author | davidxu <davidxu@FreeBSD.org> | 2004-07-13 22:54:23 +0000 |
---|---|---|
committer | davidxu <davidxu@FreeBSD.org> | 2004-07-13 22:54:23 +0000 |
commit | b241de25233d4ef491311be116b62ee7e73ec7a8 (patch) | |
tree | df1c09fab5a1acab32cdbcd83297249f5dd01df1 | |
parent | 16b35fe1ee51b288cfd0114a4442ced2c2d1eddc (diff) | |
download | FreeBSD-src-b241de25233d4ef491311be116b62ee7e73ec7a8.zip FreeBSD-src-b241de25233d4ef491311be116b62ee7e73ec7a8.tar.gz |
Call kse_switchin to switch context when being debugged.
-rw-r--r-- | lib/libkse/arch/amd64/include/pthread_md.h | 30 | ||||
-rw-r--r-- | lib/libkse/arch/arm/include/pthread_md.h | 19 | ||||
-rw-r--r-- | lib/libkse/arch/i386/include/pthread_md.h | 24 | ||||
-rw-r--r-- | lib/libkse/arch/sparc64/include/pthread_md.h | 20 | ||||
-rw-r--r-- | lib/libpthread/arch/alpha/include/pthread_md.h | 27 | ||||
-rw-r--r-- | lib/libpthread/arch/amd64/include/pthread_md.h | 30 | ||||
-rw-r--r-- | lib/libpthread/arch/arm/include/pthread_md.h | 19 | ||||
-rw-r--r-- | lib/libpthread/arch/i386/include/pthread_md.h | 24 | ||||
-rw-r--r-- | lib/libpthread/arch/sparc64/include/pthread_md.h | 20 |
9 files changed, 158 insertions, 55 deletions
diff --git a/lib/libkse/arch/amd64/include/pthread_md.h b/lib/libkse/arch/amd64/include/pthread_md.h index b6f05a8..1b39f08 100644 --- a/lib/libkse/arch/amd64/include/pthread_md.h +++ b/lib/libkse/arch/amd64/include/pthread_md.h @@ -235,17 +235,31 @@ _thread_enter_uts(struct tcb *tcb, struct kcb *kcb) static __inline int _thread_switch(struct kcb *kcb, struct tcb *tcb, int setmbox) { + extern int _libkse_debug; + if ((kcb == NULL) || (tcb == NULL)) return (-1); kcb->kcb_curtcb = tcb; - if (setmbox != 0) - _amd64_restore_context(&tcb->tcb_tmbx.tm_context.uc_mcontext, - (intptr_t)&tcb->tcb_tmbx, - (intptr_t *)&kcb->kcb_kmbx.km_curthread); - else - _amd64_restore_context(&tcb->tcb_tmbx.tm_context.uc_mcontext, - 0, NULL); - /* We should not reach here. */ + + if (_libkse_debug == 0) { + tcb->tcb_tmbx.tm_lwp = kcb->kcb_kmbx.km_lwp; + if (setmbox != 0) + _amd64_restore_context( + &tcb->tcb_tmbx.tm_context.uc_mcontext, + (intptr_t)&tcb->tcb_tmbx, + (intptr_t *)&kcb->kcb_kmbx.km_curthread); + else + _amd64_restore_context( + &tcb->tcb_tmbx.tm_context.uc_mcontext, + 0, NULL); + /* We should not reach here. */ + } else { + if (setmbox) + kse_switchin(&tcb->tcb_tmbx, KSE_SWITCHIN_SETTMBX); + else + kse_switchin(&tcb->tcb_tmbx, 0); + } + return (-1); } #endif diff --git a/lib/libkse/arch/arm/include/pthread_md.h b/lib/libkse/arch/arm/include/pthread_md.h index 107eb03..4cce212 100644 --- a/lib/libkse/arch/arm/include/pthread_md.h +++ b/lib/libkse/arch/arm/include/pthread_md.h @@ -227,15 +227,24 @@ _thread_enter_uts(struct tcb *tcb, struct kcb *kcb) static __inline int _thread_switch(struct kcb *kcb, struct tcb *tcb, int setmbox) { + extern int _libkse_debug; mcontext_t *mc; _tcb_set(kcb, tcb); mc = &tcb->tcb_tmbx.tm_context.uc_mcontext; - if (setmbox) - _thr_setcontext(mc, (intptr_t)&tcb->tcb_tmbx, - (intptr_t *)&kcb->kcb_kmbx.km_curthread); - else - _thr_setcontext(mc, 0, NULL); + if (_libkse_debug == 0) { + if (setmbox) + _thr_setcontext(mc, (intptr_t)&tcb->tcb_tmbx, + (intptr_t *)&kcb->kcb_kmbx.km_curthread); + else + _thr_setcontext(mc, 0, NULL); + } else { + if (setmbox) + kse_switchin(&tcb->tcb_tmbx, KSE_SWITCHIN_SETTMBX); + else + kse_switchin(&tcb->tcb_tmbx, 0); + } + /* We should not reach here. */ return (-1); } diff --git a/lib/libkse/arch/i386/include/pthread_md.h b/lib/libkse/arch/i386/include/pthread_md.h index 4bcb130..28eefc1 100644 --- a/lib/libkse/arch/i386/include/pthread_md.h +++ b/lib/libkse/arch/i386/include/pthread_md.h @@ -237,15 +237,27 @@ _thread_enter_uts(struct tcb *tcb, struct kcb *kcb) static __inline int _thread_switch(struct kcb *kcb, struct tcb *tcb, int setmbox) { + extern int _libkse_debug; + if ((kcb == NULL) || (tcb == NULL)) return (-1); kcb->kcb_curtcb = tcb; - if (setmbox != 0) - _thr_setcontext(&tcb->tcb_tmbx.tm_context.uc_mcontext, - (intptr_t)&tcb->tcb_tmbx, - (intptr_t *)&kcb->kcb_kmbx.km_curthread); - else - _thr_setcontext(&tcb->tcb_tmbx.tm_context.uc_mcontext, 0, NULL); + if (_libkse_debug == 0) { + tcb->tcb_tmbx.tm_lwp = kcb->kcb_kmbx.km_lwp; + if (setmbox != 0) + _thr_setcontext(&tcb->tcb_tmbx.tm_context.uc_mcontext, + (intptr_t)&tcb->tcb_tmbx, + (intptr_t *)&kcb->kcb_kmbx.km_curthread); + else + _thr_setcontext(&tcb->tcb_tmbx.tm_context.uc_mcontext, + 0, NULL); + } else { + if (setmbox) + kse_switchin(&tcb->tcb_tmbx, KSE_SWITCHIN_SETTMBX); + else + kse_switchin(&tcb->tcb_tmbx, 0); + } + /* We should not reach here. */ return (-1); } diff --git a/lib/libkse/arch/sparc64/include/pthread_md.h b/lib/libkse/arch/sparc64/include/pthread_md.h index 17ebc3b..b180e0a 100644 --- a/lib/libkse/arch/sparc64/include/pthread_md.h +++ b/lib/libkse/arch/sparc64/include/pthread_md.h @@ -227,15 +227,25 @@ _thread_enter_uts(struct tcb *tcb, struct kcb *kcb) static __inline int _thread_switch(struct kcb *kcb, struct tcb *tcb, int setmbox) { + extern int _libkse_debug; mcontext_t *mc; _tcb_set(kcb, tcb); mc = &tcb->tcb_tmbx.tm_context.uc_mcontext; - if (setmbox) - _thr_setcontext(mc, (intptr_t)&tcb->tcb_tmbx, - (intptr_t *)&kcb->kcb_kmbx.km_curthread); - else - _thr_setcontext(mc, 0, NULL); + if (_libkse_debug == 0) { + tcb->tcb_tmbx.tm_lwp = kcb->kcb_kmbx.km_lwp; + if (setmbox) + _thr_setcontext(mc, (intptr_t)&tcb->tcb_tmbx, + (intptr_t *)&kcb->kcb_kmbx.km_curthread); + else + _thr_setcontext(mc, 0, NULL); + } else { + if (setmbox) + kse_switchin(&tcb->tcb_tmbx, KSE_SWITCHIN_SETTMBX); + else + kse_switchin(&tcb->tcb_tmbx, 0); + } + /* We should not reach here. */ return (-1); } diff --git a/lib/libpthread/arch/alpha/include/pthread_md.h b/lib/libpthread/arch/alpha/include/pthread_md.h index fd82aad..f4702e0 100644 --- a/lib/libpthread/arch/alpha/include/pthread_md.h +++ b/lib/libpthread/arch/alpha/include/pthread_md.h @@ -218,14 +218,27 @@ _thread_enter_uts(struct tcb *tcb, struct kcb *kcb) static __inline int _thread_switch(struct kcb *kcb, struct tcb *tcb, int setmbox) { + extern int _libkse_debug; + _tcb_set(kcb, tcb); - if (setmbox != 0) - _alpha_restore_context(&tcb->tcb_tmbx.tm_context.uc_mcontext, - (intptr_t)&tcb->tcb_tmbx, - (intptr_t *)&kcb->kcb_kmbx.km_curthread); - else - _alpha_restore_context(&tcb->tcb_tmbx.tm_context.uc_mcontext, - 0, NULL); + if (_libkse_debug == 0) { + tcb->tcb_tmbx.tm_lwp = kcb->kcb_kmbx.km_lwp; + if (setmbox != 0) + _alpha_restore_context( + &tcb->tcb_tmbx.tm_context.uc_mcontext, + (intptr_t)&tcb->tcb_tmbx, + (intptr_t *)&kcb->kcb_kmbx.km_curthread); + else + _alpha_restore_context( + &tcb->tcb_tmbx.tm_context.uc_mcontext, + 0, NULL); + } else { + if (setmbox) + kse_switchin(&tcb->tcb_tmbx, KSE_SWITCHIN_SETTMBX); + else + kse_switchin(&tcb->tcb_tmbx, 0); + } + /* We should not reach here. */ return (-1); } diff --git a/lib/libpthread/arch/amd64/include/pthread_md.h b/lib/libpthread/arch/amd64/include/pthread_md.h index b6f05a8..1b39f08 100644 --- a/lib/libpthread/arch/amd64/include/pthread_md.h +++ b/lib/libpthread/arch/amd64/include/pthread_md.h @@ -235,17 +235,31 @@ _thread_enter_uts(struct tcb *tcb, struct kcb *kcb) static __inline int _thread_switch(struct kcb *kcb, struct tcb *tcb, int setmbox) { + extern int _libkse_debug; + if ((kcb == NULL) || (tcb == NULL)) return (-1); kcb->kcb_curtcb = tcb; - if (setmbox != 0) - _amd64_restore_context(&tcb->tcb_tmbx.tm_context.uc_mcontext, - (intptr_t)&tcb->tcb_tmbx, - (intptr_t *)&kcb->kcb_kmbx.km_curthread); - else - _amd64_restore_context(&tcb->tcb_tmbx.tm_context.uc_mcontext, - 0, NULL); - /* We should not reach here. */ + + if (_libkse_debug == 0) { + tcb->tcb_tmbx.tm_lwp = kcb->kcb_kmbx.km_lwp; + if (setmbox != 0) + _amd64_restore_context( + &tcb->tcb_tmbx.tm_context.uc_mcontext, + (intptr_t)&tcb->tcb_tmbx, + (intptr_t *)&kcb->kcb_kmbx.km_curthread); + else + _amd64_restore_context( + &tcb->tcb_tmbx.tm_context.uc_mcontext, + 0, NULL); + /* We should not reach here. */ + } else { + if (setmbox) + kse_switchin(&tcb->tcb_tmbx, KSE_SWITCHIN_SETTMBX); + else + kse_switchin(&tcb->tcb_tmbx, 0); + } + return (-1); } #endif diff --git a/lib/libpthread/arch/arm/include/pthread_md.h b/lib/libpthread/arch/arm/include/pthread_md.h index 107eb03..4cce212 100644 --- a/lib/libpthread/arch/arm/include/pthread_md.h +++ b/lib/libpthread/arch/arm/include/pthread_md.h @@ -227,15 +227,24 @@ _thread_enter_uts(struct tcb *tcb, struct kcb *kcb) static __inline int _thread_switch(struct kcb *kcb, struct tcb *tcb, int setmbox) { + extern int _libkse_debug; mcontext_t *mc; _tcb_set(kcb, tcb); mc = &tcb->tcb_tmbx.tm_context.uc_mcontext; - if (setmbox) - _thr_setcontext(mc, (intptr_t)&tcb->tcb_tmbx, - (intptr_t *)&kcb->kcb_kmbx.km_curthread); - else - _thr_setcontext(mc, 0, NULL); + if (_libkse_debug == 0) { + if (setmbox) + _thr_setcontext(mc, (intptr_t)&tcb->tcb_tmbx, + (intptr_t *)&kcb->kcb_kmbx.km_curthread); + else + _thr_setcontext(mc, 0, NULL); + } else { + if (setmbox) + kse_switchin(&tcb->tcb_tmbx, KSE_SWITCHIN_SETTMBX); + else + kse_switchin(&tcb->tcb_tmbx, 0); + } + /* We should not reach here. */ return (-1); } diff --git a/lib/libpthread/arch/i386/include/pthread_md.h b/lib/libpthread/arch/i386/include/pthread_md.h index 4bcb130..28eefc1 100644 --- a/lib/libpthread/arch/i386/include/pthread_md.h +++ b/lib/libpthread/arch/i386/include/pthread_md.h @@ -237,15 +237,27 @@ _thread_enter_uts(struct tcb *tcb, struct kcb *kcb) static __inline int _thread_switch(struct kcb *kcb, struct tcb *tcb, int setmbox) { + extern int _libkse_debug; + if ((kcb == NULL) || (tcb == NULL)) return (-1); kcb->kcb_curtcb = tcb; - if (setmbox != 0) - _thr_setcontext(&tcb->tcb_tmbx.tm_context.uc_mcontext, - (intptr_t)&tcb->tcb_tmbx, - (intptr_t *)&kcb->kcb_kmbx.km_curthread); - else - _thr_setcontext(&tcb->tcb_tmbx.tm_context.uc_mcontext, 0, NULL); + if (_libkse_debug == 0) { + tcb->tcb_tmbx.tm_lwp = kcb->kcb_kmbx.km_lwp; + if (setmbox != 0) + _thr_setcontext(&tcb->tcb_tmbx.tm_context.uc_mcontext, + (intptr_t)&tcb->tcb_tmbx, + (intptr_t *)&kcb->kcb_kmbx.km_curthread); + else + _thr_setcontext(&tcb->tcb_tmbx.tm_context.uc_mcontext, + 0, NULL); + } else { + if (setmbox) + kse_switchin(&tcb->tcb_tmbx, KSE_SWITCHIN_SETTMBX); + else + kse_switchin(&tcb->tcb_tmbx, 0); + } + /* We should not reach here. */ return (-1); } diff --git a/lib/libpthread/arch/sparc64/include/pthread_md.h b/lib/libpthread/arch/sparc64/include/pthread_md.h index 17ebc3b..b180e0a 100644 --- a/lib/libpthread/arch/sparc64/include/pthread_md.h +++ b/lib/libpthread/arch/sparc64/include/pthread_md.h @@ -227,15 +227,25 @@ _thread_enter_uts(struct tcb *tcb, struct kcb *kcb) static __inline int _thread_switch(struct kcb *kcb, struct tcb *tcb, int setmbox) { + extern int _libkse_debug; mcontext_t *mc; _tcb_set(kcb, tcb); mc = &tcb->tcb_tmbx.tm_context.uc_mcontext; - if (setmbox) - _thr_setcontext(mc, (intptr_t)&tcb->tcb_tmbx, - (intptr_t *)&kcb->kcb_kmbx.km_curthread); - else - _thr_setcontext(mc, 0, NULL); + if (_libkse_debug == 0) { + tcb->tcb_tmbx.tm_lwp = kcb->kcb_kmbx.km_lwp; + if (setmbox) + _thr_setcontext(mc, (intptr_t)&tcb->tcb_tmbx, + (intptr_t *)&kcb->kcb_kmbx.km_curthread); + else + _thr_setcontext(mc, 0, NULL); + } else { + if (setmbox) + kse_switchin(&tcb->tcb_tmbx, KSE_SWITCHIN_SETTMBX); + else + kse_switchin(&tcb->tcb_tmbx, 0); + } + /* We should not reach here. */ return (-1); } |