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