< prev index next >

src/jdk.hotspot.agent/linux/native/libsaproc/libproc_impl.c

Print this page

        

*** 1,7 **** /* ! * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. --- 1,7 ---- /* ! * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation.
*** 24,35 **** #include <stdarg.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <fcntl.h> ! #include <thread_db.h> #include "libproc_impl.h" #define SA_ALTROOT "SA_ALTROOT" int pathmap_open(const char* name) { static const char *alt_root = NULL; --- 24,36 ---- #include <stdarg.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <fcntl.h> ! #include <sys/procfs.h> #include "libproc_impl.h" + #include "proc_service.h" #define SA_ALTROOT "SA_ALTROOT" int pathmap_open(const char* name) { static const char *alt_root = NULL;
*** 114,130 **** // initialize libproc JNIEXPORT bool JNICALL init_libproc(bool debug) { // init debug mode _libsaproc_debug = debug; - - // initialize the thread_db library - if (td_init() != TD_OK) { - print_debug("libthread_db's td_init failed\n"); - return false; - } - return true; } static void destroy_lib_info(struct ps_prochandle* ph) { lib_info* lib = ph->libs; --- 115,124 ----
*** 254,272 **** } return NULL; } // add a thread to ps_prochandle ! thread_info* add_thread_info(struct ps_prochandle* ph, pthread_t pthread_id, lwpid_t lwp_id) { thread_info* newthr; if ( (newthr = (thread_info*) calloc(1, sizeof(thread_info))) == NULL) { print_debug("can't allocate memory for thread_info\n"); return NULL; } // initialize thread info - newthr->pthread_id = pthread_id; newthr->lwp_id = lwp_id; // add new thread to the list newthr->next = ph->threads; ph->threads = newthr; --- 248,265 ---- } return NULL; } // add a thread to ps_prochandle ! thread_info* add_thread_info(struct ps_prochandle* ph, lwpid_t lwp_id) { thread_info* newthr; if ( (newthr = (thread_info*) calloc(1, sizeof(thread_info))) == NULL) { print_debug("can't allocate memory for thread_info\n"); return NULL; } // initialize thread info newthr->lwp_id = lwp_id; // add new thread to the list newthr->next = ph->threads; ph->threads = newthr;
*** 293,360 **** } ph->num_threads--; free(current_thr); } - // struct used for client data from thread_db callback - struct thread_db_client_data { - struct ps_prochandle* ph; - thread_info_callback callback; - }; - - // callback function for libthread_db - static int thread_db_callback(const td_thrhandle_t *th_p, void *data) { - struct thread_db_client_data* ptr = (struct thread_db_client_data*) data; - td_thrinfo_t ti; - td_err_e err; - - memset(&ti, 0, sizeof(ti)); - err = td_thr_get_info(th_p, &ti); - if (err != TD_OK) { - print_debug("libthread_db : td_thr_get_info failed, can't get thread info\n"); - return err; - } - - print_debug("thread_db : pthread %d (lwp %d)\n", ti.ti_tid, ti.ti_lid); - - if (ti.ti_state == TD_THR_UNKNOWN || ti.ti_state == TD_THR_ZOMBIE) { - print_debug("Skipping pthread %d (lwp %d)\n", ti.ti_tid, ti.ti_lid); - return TD_OK; - } - - if (ptr->callback(ptr->ph, ti.ti_tid, ti.ti_lid) != true) - return TD_ERR; - - return TD_OK; - } - - // read thread_info using libthread_db - bool read_thread_info(struct ps_prochandle* ph, thread_info_callback cb) { - struct thread_db_client_data mydata; - td_thragent_t* thread_agent = NULL; - if (td_ta_new(ph, &thread_agent) != TD_OK) { - print_debug("can't create libthread_db agent\n"); - return false; - } - - mydata.ph = ph; - mydata.callback = cb; - - // we use libthread_db iterator to iterate thru list of threads. - if (td_ta_thr_iter(thread_agent, thread_db_callback, &mydata, - TD_THR_ANY_STATE, TD_THR_LOWEST_PRIORITY, - TD_SIGNO_MASK, TD_THR_ANY_USER_FLAGS) != TD_OK) { - td_ta_delete(thread_agent); - return false; - } - - // delete thread agent - td_ta_delete(thread_agent); - return true; - } - - // get number of threads int get_num_threads(struct ps_prochandle* ph) { return ph->num_threads; } --- 286,295 ----
*** 482,492 **** ps_lgetregs(struct ps_prochandle *ph, lwpid_t lid, prgregset_t gregset) { print_debug("ps_lgetfpregs not implemented\n"); return PS_OK; } - // new libthread_db of NPTL seem to require this symbol - JNIEXPORT ps_err_e JNICALL - ps_get_thread_area() { - print_debug("ps_get_thread_area not implemented\n"); - return PS_OK; - } --- 417,421 ----
< prev index next >