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/libpthread_db.c 181341 2008-08-06 03:14:18Z marcel $"); |
29 30#include <stddef.h> 31#include <stdlib.h> 32#include <string.h> 33#include <unistd.h> 34#include <pthread.h> 35#include <sys/types.h> 36#include <sys/linker_set.h> --- 304 unchanged lines hidden (view full) --- 341 if (ret != 0) 342 return (P2T(ret)); 343 } 344 345 return (TD_NOTHR); 346} 347 348static td_err_e |
349pt_ta_thr_iter(const td_thragent_t *ta, td_thr_iter_f *callback, 350 void *cbdata_p, td_thr_state_e state __unused, int ti_pri __unused, 351 sigset_t *ti_sigmask_p __unused, unsigned int ti_user_flags __unused) |
352{ 353 TAILQ_HEAD(, pthread) thread_list; 354 td_thrhandle_t th; 355 psaddr_t pt; 356 ps_err_e pserr; 357 int activated; 358 359 TDBG_FUNC(); --- 27 unchanged lines hidden (view full) --- 387 return (P2T(pserr)); 388 } 389 return (TD_OK); 390} 391 392static td_err_e 393pt_ta_tsd_iter(const td_thragent_t *ta, td_key_iter_f *ki, void *arg) 394{ |
395 void *keytable; |
396 void *destructor; 397 int i, ret, allocated; 398 399 TDBG_FUNC(); 400 401 keytable = malloc(ta->thread_max_keys * ta->thread_size_key); 402 if (keytable == NULL) 403 return (TD_MALLOC); 404 ret = ps_pread(ta->ph, (psaddr_t)ta->thread_keytable_addr, keytable, 405 ta->thread_max_keys * ta->thread_size_key); 406 if (ret != 0) { 407 free(keytable); 408 return (P2T(ret)); 409 } 410 for (i = 0; i < ta->thread_max_keys; i++) { |
411 allocated = *(int *)(void *)((uintptr_t)keytable + 412 i * ta->thread_size_key + ta->thread_off_key_allocated); 413 destructor = *(void **)(void *)((uintptr_t)keytable + 414 i * ta->thread_size_key + ta->thread_off_key_destructor); |
415 if (allocated) { 416 ret = (ki)(i, destructor, arg); 417 if (ret != 0) { 418 free(keytable); 419 return (TD_DBERR); 420 } 421 } 422 } 423 free(keytable); 424 return (TD_OK); 425} 426 427static td_err_e |
428pt_ta_event_addr(const td_thragent_t *ta __unused, td_event_e event __unused, 429 td_notify_t *ptr __unused) |
430{ 431 TDBG_FUNC(); 432 return (TD_ERR); 433} 434 435static td_err_e |
436pt_ta_set_event(const td_thragent_t *ta __unused, 437 td_thr_events_t *events __unused) |
438{ 439 TDBG_FUNC(); 440 return (0); 441} 442 443static td_err_e |
444pt_ta_clear_event(const td_thragent_t *ta __unused, 445 td_thr_events_t *events __unused) |
446{ 447 TDBG_FUNC(); 448 return (0); 449} 450 451static td_err_e |
452pt_ta_event_getmsg(const td_thragent_t *ta __unused, 453 td_event_msg_t *msg __unused) |
454{ 455 TDBG_FUNC(); 456 return (TD_NOMSG); 457} 458 459static td_err_e 460pt_dbsuspend(const td_thrhandle_t *th, int suspend) 461{ |
462 const td_thragent_t *ta = th->th_ta; |
463 psaddr_t tcb_addr, tmbx_addr, ptr; 464 lwpid_t lwp; 465 uint32_t dflags; 466 int attrflags, locklevel, ret; 467 468 TDBG_FUNC(); 469 470 ret = pt_validate(th); --- 477 unchanged lines hidden (view full) --- 948 if (ret != 0) 949 return (P2T(ret)); 950 pt_reg_to_ucontext(gregs, &tmbx.tm_context); 951 ret = ps_pwrite(ta->ph, tmbx_addr, &tmbx, sizeof(tmbx)); 952 return (P2T(ret)); 953} 954 955static td_err_e |
956pt_thr_event_enable(const td_thrhandle_t *th __unused, int en __unused) |
957{ 958 TDBG_FUNC(); 959 return (0); 960} 961 962static td_err_e |
963pt_thr_set_event(const td_thrhandle_t *th __unused, 964 td_thr_events_t *setp __unused) |
965{ 966 TDBG_FUNC(); 967 return (0); 968} 969 970static td_err_e |
971pt_thr_clear_event(const td_thrhandle_t *th __unused, 972 td_thr_events_t *setp __unused) |
973{ 974 TDBG_FUNC(); 975 return (0); 976} 977 978static td_err_e |
979pt_thr_event_getmsg(const td_thrhandle_t *th __unused, 980 td_event_msg_t *msg __unused) |
981{ 982 TDBG_FUNC(); 983 return (TD_NOMSG); 984} 985 986static td_err_e 987pt_thr_sstep(const td_thrhandle_t *th, int step) 988{ --- 167 unchanged lines hidden --- |