< prev index next >
src/jdk.hotspot.agent/linux/native/libsaproc/ps_proc.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.
*** 337,351 ****
if (*--p=='\n') *p='\0';
}
return rslt;
}
- // callback for read_thread_info
- static bool add_new_thread(struct ps_prochandle* ph, pthread_t pthread_id, lwpid_t lwp_id) {
- return add_thread_info(ph, pthread_id, lwp_id) != NULL;
- }
-
static bool read_lib_info(struct ps_prochandle* ph) {
char fname[32];
char buf[PATH_MAX];
FILE *fp = NULL;
--- 337,346 ----
*** 441,451 ****
.get_lwp_regs= process_get_lwp_regs
};
// attach to the process. One and only one exposed stuff
JNIEXPORT struct ps_prochandle* JNICALL
! Pgrab(pid_t pid, char* err_buf, size_t err_buf_len, bool is_in_container) {
struct ps_prochandle* ph = NULL;
thread_info* thr = NULL;
attach_state_t attach_status = ATTACH_SUCCESS;
if ( (ph = (struct ps_prochandle*) calloc(1, sizeof(struct ps_prochandle))) == NULL) {
--- 436,446 ----
.get_lwp_regs= process_get_lwp_regs
};
// attach to the process. One and only one exposed stuff
JNIEXPORT struct ps_prochandle* JNICALL
! Pgrab(pid_t pid, char* err_buf, size_t err_buf_len) {
struct ps_prochandle* ph = NULL;
thread_info* thr = NULL;
attach_state_t attach_status = ATTACH_SUCCESS;
if ( (ph = (struct ps_prochandle*) calloc(1, sizeof(struct ps_prochandle))) == NULL) {
*** 462,485 ****
return NULL;
}
// initialize ps_prochandle
ph->pid = pid;
// initialize vtable
ph->ops = &process_ops;
// read library info and symbol tables, must do this before attaching threads,
// as the symbols in the pthread library will be used to figure out
// the list of threads within the same process.
read_lib_info(ph);
- // read thread info
- if (is_in_container) {
/*
! * If the process is running in the container, SA scans all tasks in
! * /proc/<PID>/task to read all threads info.
*/
char taskpath[PATH_MAX];
DIR *dirp;
struct dirent *entry;
--- 457,479 ----
return NULL;
}
// initialize ps_prochandle
ph->pid = pid;
+ add_thread_info(ph, ph->pid);
// initialize vtable
ph->ops = &process_ops;
// read library info and symbol tables, must do this before attaching threads,
// as the symbols in the pthread library will be used to figure out
// the list of threads within the same process.
read_lib_info(ph);
/*
! * Read thread info.
! * SA scans all tasks in /proc/<PID>/task to read all threads info.
*/
char taskpath[PATH_MAX];
DIR *dirp;
struct dirent *entry;
*** 492,507 ****
}
lwp_id = atoi(entry->d_name);
if (lwp_id == ph->pid) {
continue;
}
! add_new_thread(ph, -1, lwp_id);
}
- closedir(dirp);
- } else {
- read_thread_info(ph, add_new_thread);
}
// attach to the threads
thr = ph->threads;
while (thr) {
--- 486,500 ----
}
lwp_id = atoi(entry->d_name);
if (lwp_id == ph->pid) {
continue;
}
! if (!process_doesnt_exist(lwp_id)) {
! add_thread_info(ph, lwp_id);
}
}
+ closedir(dirp);
// attach to the threads
thr = ph->threads;
while (thr) {
< prev index next >