5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include <stdio.h>
26 #include <stdlib.h>
27 #include <string.h>
28 #include <signal.h>
29 #include <errno.h>
30 #include <elf.h>
31 #include <sys/types.h>
32 #include <sys/wait.h>
33 #include <sys/ptrace.h>
34 #include <sys/uio.h>
35 #include "libproc_impl.h"
36
37 #if defined(x86_64) && !defined(amd64)
38 #define amd64 1
39 #endif
40
41 #ifndef __WALL
42 #define __WALL 0x40000000 // Copied from /usr/include/linux/wait.h
43 #endif
44
398 // as the symbols in the pthread library will be used to figure out
399 // the list of threads within the same process.
400 read_lib_info(ph);
401
402 // read thread info
403 read_thread_info(ph, add_new_thread);
404
405 // attach to the threads
406 thr = ph->threads;
407 while (thr) {
408 // don't attach to the main thread again
409 if (ph->pid != thr->lwp_id && ptrace_attach(thr->lwp_id, err_buf, err_buf_len) != true) {
410 // even if one attach fails, we get return NULL
411 Prelease(ph);
412 return NULL;
413 }
414 thr = thr->next;
415 }
416 return ph;
417 }
|
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #ifdef INCLUDE_SA_ATTACH
26
27 #include <stdio.h>
28 #include <stdlib.h>
29 #include <string.h>
30 #include <signal.h>
31 #include <errno.h>
32 #include <elf.h>
33 #include <sys/types.h>
34 #include <sys/wait.h>
35 #include <sys/ptrace.h>
36 #include <sys/uio.h>
37 #include "libproc_impl.h"
38
39 #if defined(x86_64) && !defined(amd64)
40 #define amd64 1
41 #endif
42
43 #ifndef __WALL
44 #define __WALL 0x40000000 // Copied from /usr/include/linux/wait.h
45 #endif
46
400 // as the symbols in the pthread library will be used to figure out
401 // the list of threads within the same process.
402 read_lib_info(ph);
403
404 // read thread info
405 read_thread_info(ph, add_new_thread);
406
407 // attach to the threads
408 thr = ph->threads;
409 while (thr) {
410 // don't attach to the main thread again
411 if (ph->pid != thr->lwp_id && ptrace_attach(thr->lwp_id, err_buf, err_buf_len) != true) {
412 // even if one attach fails, we get return NULL
413 Prelease(ph);
414 return NULL;
415 }
416 thr = thr->next;
417 }
418 return ph;
419 }
420
421 #endif // INCLUDE_SA_ATTACH
|