1 /* Low level interface for debugging UnixWare user-mode threads for
4 Copyright 1999, 2000 Free Software Foundation, Inc.
5 Written by Nick Duffek <nsd@cygnus.com>.
7 This file is part of GDB.
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place - Suite 330,
22 Boston, MA 02111-1307, USA. */
25 /* Like many systems, UnixWare implements two classes of threads:
26 kernel-mode threads, which are scheduled by the kernel; and
27 user-mode threads, which are scheduled by a library. UnixWare
28 calls these two classes lightweight processes (LWPs) and threads,
31 This module deals with user-mode threads. It calls procfs_ops
32 functions to deal with LWPs and processes and core_ops functions to
35 As of this writing, the user-mode thread debugging interface is not
36 documented beyond the comments in <thread.h>. The following
37 description has been gleaned from experience and from information
40 libthread.so, against which all UnixWare user-mode thread programs
41 link, provides a global thread_debug structure named _thr_debug.
44 (1) thr_map is a pointer to a pointer to an element of a
45 thread_map ring. A thread_map contains a single thread's id
46 number, state, LWP pointer, recent register state, and other
49 (2) thr_brk is a pointer to a stub function that libthread.so
50 calls when it changes a thread's state, e.g. by creating it,
51 switching it to an LWP, or causing it to exit.
53 (3) thr_debug_on controls whether libthread.so calls thr_brk().
55 Debuggers are able to track thread activity by setting a private
56 breakpoint on thr_brk() and setting thr_debug_on to 1.
58 thr_brk() receives two arguments:
60 (1) a pointer to a thread_map describing the thread being
63 (2) an enum thread_change specifying one of the following
67 thread_create thread has just been created
68 thread_exit thread has just exited
69 switch_begin thread will be switched to an LWP
70 switch_complete thread has been switched to an LWP
71 cancel_complete thread wasn't switched to an LWP
72 thread_suspend thread has been thr_suspend()ed
73 thread_suspend_pending thread will be thr_suspend()ed
74 thread_continue thread has been thr_continue()d
76 The thread_map argument to thr_brk() is NULL under the following
79 - The main thread is being acted upon. The main thread always
80 has id 1, so its thread_map is easy to find by scanning through
83 - A "switch_complete" change is occurring, which means that the
84 thread specified in the most recent "switch_begin" change has
87 - A "cancel_complete" change is occurring, which means that the
88 thread specified in the most recent "switch_begin" change has
89 not moved to an LWP after all.
91 - A spurious "switch_begin" change is occurring after a
94 Between switch_begin and switch_complete or cancel_complete, the
95 affected thread's LWP pointer is not reliable. It is possible that
96 other parts of the thread's thread_map are also unreliable during
101 #include "gdbthread.h"
103 #include "inferior.h"
107 * <thread.h> includes <sys/priocntl.h>, which requires boolean_t from
108 * <sys/types.h>, which doesn't typedef boolean_t with gcc.
110 #define boolean_t int
114 #include <synch.h> /* for UnixWare 2.x */
118 * Whether to emit debugging output.
123 * Default debugging output file, overridden by envvar UWTHR_DEBUG.
125 #define DEBUG_FILE "/dev/tty"
128 * #if DEBUG, write string S to the debugging output channel.
131 # define DBG(fmt_and_args)
132 # define DBG2(fmt_and_args)
134 # define DBG(fmt_and_args) dbg fmt_and_args
135 # define DBG2(fmt_and_args)
139 * Back end to CALL_BASE() and TRY_BASE(): evaluate CALL, then convert
140 * inferior_pid to a composite thread/process id.
142 #define CALL_BASE_1(call) \
144 DBG2(("CALL_BASE(" #call ")")); \
146 do_cleanups (infpid_cleanup); \
150 * If inferior_pid can be converted to a composite lwp/process id, do so,
151 * evaluate base_ops function CALL, and then convert inferior_pid back to a
152 * composite thread/process id.
154 * Otherwise, issue an error message and return nonlocally.
156 #define CALL_BASE(call) \
158 if (!lwp_infpid ()) \
159 error ("uw-thread: no lwp"); \
160 CALL_BASE_1 (call); \
164 * Like CALL_BASE(), but instead of returning nonlocally on error, set
165 * *CALLED to whether the inferior_pid conversion was successful.
167 #define TRY_BASE(call, called) \
169 if ((*(called) = lwp_infpid ())) \
170 CALL_BASE_1 (call); \
174 * Information passed by thread_iter() to its callback parameter.
177 struct thread_map map
;
183 * Private thread data for the thread_info struct.
185 struct private_thread_info
{
186 int stable
; /* 0 if libthread.so is modifying thread map */
187 int thrid
; /* thread id assigned by libthread.so */
188 int lwpid
; /* thread's lwp if .stable, 0 means no lwp */
189 CORE_ADDR mapp
; /* address of thread's map structure */
193 /* procfs.c's target-specific operations. */
194 extern struct target_ops procfs_ops
;
196 /* Flag to prevent procfs.c from starting inferior processes. */
197 extern int procfs_suppress_run
;
199 /* This module's target-specific operations. */
200 static struct target_ops uw_thread_ops
;
202 /* Copy of the target over which uw_thread_ops is pushed. This is
203 more convenient than a pointer to procfs_ops or core_ops, because
204 they lack current_target's default callbacks. */
205 static struct target_ops base_ops
;
207 /* Saved pointer to previous owner of target_new_objfile_hook. */
208 static void (*target_new_objfile_chain
)(struct objfile
*);
210 /* Whether we are debugging a user-space thread program. This isn't
211 set until after libthread.so is loaded by the program being
214 Except for module one-time intialization and where otherwise
215 documented, no functions in this module get called when
216 !uw_thread_active. */
217 static int uw_thread_active
;
219 /* For efficiency, cache the addresses of libthread.so's _thr_debug
220 structure, its thr_brk stub function, and the main thread's map. */
221 static CORE_ADDR thr_debug_addr
;
222 static CORE_ADDR thr_brk_addr
;
223 static CORE_ADDR thr_map_main
;
225 /* Remember the thread most recently marked as switching. Necessary because
226 libthread.so passes null map when calling stub with tc_*_complete. */
227 static struct thread_info
*switchto_thread
;
229 /* Cleanup chain for safely restoring inferior_pid after CALL_BASE. */
230 static struct cleanup
*infpid_cleanup
;
235 * Helper function for DBG() macro: if printf-style FMT is non-null, format it
236 * with args and display the result on the debugging output channel.
241 static int fd
= -1, len
;
251 path
= getenv ("UWTHR_DEBUG");
254 if ((fd
= open (path
, O_WRONLY
| O_CREAT
| O_TRUNC
, 0664)) < 0)
255 error ("can't open %s\n", path
);
258 va_start (args
, fmt
);
259 vsprintf (buf
, fmt
, args
);
264 (void)write (fd
, buf
, len
+ 1);
269 * Return a string representing composite PID's components.
274 static char *buf
, buf1
[80], buf2
[80];
275 if (!buf
|| buf
== buf2
)
281 sprintf (buf
, "%d", pid
);
283 sprintf (buf
, "%s %d/%d", ISTID (pid
) ? "thr" : "lwp",
284 TIDGET (pid
), PIDGET (pid
));
290 * Return a string representing thread state CHANGE.
293 dbgchange (enum thread_change change
)
296 case tc_invalid
: return "invalid";
297 case tc_thread_create
: return "thread_create";
298 case tc_thread_exit
: return "thread_exit";
299 case tc_switch_begin
: return "switch_begin";
300 case tc_switch_complete
: return "switch_complete";
301 case tc_cancel_complete
: return "cancel_complete";
302 case tc_thread_suspend
: return "thread_suspend";
303 case tc_thread_suspend_pending
: return "thread_suspend_pending";
304 case tc_thread_continue
: return "thread_continue";
305 default: return "unknown";
310 * Return a string representing thread STATE.
316 case TS_ONPROC
: return "running";
317 case TS_SLEEP
: return "sleeping";
318 case TS_RUNNABLE
: return "runnable";
319 case TS_ZOMBIE
: return "zombie";
320 case TS_SUSPENDED
: return "suspended";
322 case TS_FORK
: return "forking";
324 default: return "confused";
332 * Read the contents of _thr_debug into *DEBUGP. Return success.
335 read_thr_debug (struct thread_debug
*debugp
)
337 return base_ops
.to_xfer_memory (thr_debug_addr
, (char *)debugp
,
338 sizeof (*debugp
), 0, &base_ops
);
342 * Read into MAP the contents of the thread map at inferior process address
343 * MAPP. Return success.
346 read_map (CORE_ADDR mapp
, struct thread_map
*map
)
348 return base_ops
.to_xfer_memory ((CORE_ADDR
)THR_MAP (mapp
), (char *)map
,
349 sizeof (*map
), 0, &base_ops
);
353 * Read into LWP the contents of the lwp decriptor at inferior process address
354 * LWPP. Return success.
357 read_lwp (CORE_ADDR lwpp
, __lwp_desc_t
*lwp
)
359 return base_ops
.to_xfer_memory (lwpp
, (char *)lwp
,
360 sizeof (*lwp
), 0, &base_ops
);
364 * Iterate through all user threads, applying FUNC(<map>, <lwp>, DATA) until
365 * (a) FUNC returns nonzero,
366 * (b) FUNC has been applied to all threads, or
367 * (c) an error occurs,
368 * where <map> is the thread's struct thread_map and <lwp> if non-null is the
369 * thread's current __lwp_desc_t.
371 * If a call to FUNC returns nonzero, return that value; otherwise, return 0.
374 thread_iter (int (*func
)(iter_t
*, void *), void *data
)
376 struct thread_debug debug
;
377 CORE_ADDR first
, mapp
;
381 if (!read_thr_debug (&debug
))
383 if (!base_ops
.to_xfer_memory ((CORE_ADDR
)debug
.thr_map
, (char *)&mapp
,
384 sizeof (mapp
), 0, &base_ops
))
391 if (!read_map (mapp
, &iter
.map
))
394 if (iter
.map
.thr_lwpp
)
395 if (!read_lwp ((CORE_ADDR
)iter
.map
.thr_lwpp
, &iter
.lwp
))
399 if ((ret
= func (&iter
, data
)))
402 mapp
= (CORE_ADDR
)iter
.map
.thr_next
;
409 * Deactivate user-mode thread support.
412 deactivate_uw_thread (void)
414 uw_thread_active
= 0;
415 unpush_target (&uw_thread_ops
);
419 * Return the composite lwp/process id corresponding to composite
420 * id PID. If PID is a thread with no lwp, return 0.
425 struct thread_info
*info
;
430 else if (!(info
= find_thread_pid (pid
)))
432 else if (!info
->private->lwpid
)
435 lid
= MKLID (pid
, info
->private->lwpid
);
437 DBG2((" thr_to_lwp(%s) = %s", dbgpid (pid
), dbgpid (lid
)));
442 * find_thread_lwp() callback: return whether TP describes a thread
443 * associated with lwp id DATA.
446 find_thread_lwp_callback (struct thread_info
*tp
, void *data
)
448 int lwpid
= (int)data
;
450 if (!ISTID (tp
->pid
))
452 if (!tp
->private->stable
)
454 if (lwpid
!= tp
->private->lwpid
)
462 * If a thread is associated with lwp id LWPID, return the corresponding
463 * member of the global thread list; otherwise, return null.
465 static struct thread_info
*
466 find_thread_lwp (int lwpid
)
468 return iterate_over_threads (find_thread_lwp_callback
, (void *)lwpid
);
472 * Return the composite thread/process id corresponding to composite
473 * id PID. If PID is an lwp with no thread, return PID.
478 struct thread_info
*info
;
479 int tid
= pid
, lwpid
;
483 if (!(lwpid
= LIDGET (pid
)))
485 if (!(info
= find_thread_lwp (lwpid
)))
487 tid
= MKTID (pid
, info
->private->thrid
);
490 DBG2((ISTID (tid
) ? NULL
: "lwp_to_thr: no thr for %s", dbgpid (pid
)));
495 * do_cleanups() callback: convert inferior_pid to a composite
496 * thread/process id after having made a procfs call.
499 thr_infpid (void *unused
)
501 int pid
= lwp_to_thr (inferior_pid
);
502 DBG2((" inferior_pid from procfs: %s => %s",
503 dbgpid (inferior_pid
), dbgpid (pid
)));
508 * If possible, convert inferior_pid to a composite lwp/process id in
509 * preparation for making a procfs call. Return success.
514 int pid
= thr_to_lwp (inferior_pid
);
515 DBG2((" inferior_pid to procfs: %s => %s",
516 dbgpid (inferior_pid
), dbgpid (pid
)));
522 infpid_cleanup
= make_cleanup (thr_infpid
, NULL
);
527 * Add to the global thread list a new user-mode thread with system id THRID,
528 * lwp id LWPID, map address MAPP, and composite thread/process PID.
531 add_thread_uw (int thrid
, int lwpid
, CORE_ADDR mapp
, int pid
)
533 struct thread_info
*newthread
;
535 if ((newthread
= add_thread (pid
)) == NULL
)
536 error ("failed to create new thread structure");
538 newthread
->private = xmalloc (sizeof (struct private_thread_info
));
539 newthread
->private->stable
= 1;
540 newthread
->private->thrid
= thrid
;
541 newthread
->private->lwpid
= lwpid
;
542 newthread
->private->mapp
= mapp
;
544 if (target_has_execution
)
545 printf_unfiltered ("[New %s]\n", target_pid_to_str (pid
));
549 * notice_threads() and find_main() callback: if the thread list doesn't
550 * already contain the thread described by ITER, add it if it's the main
551 * thread or if !DATA.
554 notice_thread (iter_t
*iter
, void *data
)
556 int thrid
= iter
->map
.thr_tid
;
557 int lwpid
= !iter
->map
.thr_lwpp
? 0 : iter
->lwp
.lwp_id
;
558 int pid
= MKTID (inferior_pid
, thrid
);
560 if (!find_thread_pid (pid
) && (!data
|| thrid
== 1))
561 add_thread_uw (thrid
, lwpid
, iter
->mapp
, pid
);
567 * Add to the thread list any threads it doesn't already contain.
570 notice_threads (void)
572 thread_iter (notice_thread
, NULL
);
576 * Return the address of the main thread's map. On error, return 0.
583 struct thread_info
*info
;
584 thread_iter (notice_thread
, (void *)1);
585 if ((info
= find_thread_pid (MKTID (inferior_pid
, 1))))
586 thr_map_main
= info
->private->mapp
;
592 * Attach to process specified by ARGS, then initialize for debugging it
593 * and wait for the trace-trap that results from attaching.
595 * This function only gets called with uw_thread_active == 0.
598 uw_thread_attach (char *args
, int from_tty
)
600 procfs_ops
.to_attach (args
, from_tty
);
601 if (uw_thread_active
)
606 * Detach from the process attached to by uw_thread_attach().
609 uw_thread_detach (char *args
, int from_tty
)
611 deactivate_uw_thread ();
612 base_ops
.to_detach (args
, from_tty
);
616 * Tell the inferior process to continue running thread PID if >= 0
617 * and all threads otherwise.
620 uw_thread_resume (int pid
, int step
, enum target_signal signo
)
622 if (pid
> 0 && !(pid
= thr_to_lwp (pid
)))
625 CALL_BASE (base_ops
.to_resume (pid
, step
, signo
));
629 * If the trap we just received from lwp PID was due to a breakpoint
630 * on the libthread.so debugging stub, update this module's state
634 libthread_stub (int pid
)
636 CORE_ADDR sp
, mapp
, mapp_main
;
637 enum thread_change change
;
638 struct thread_map map
;
641 struct thread_info
*info
;
643 /* Check for stub breakpoint. */
644 if (read_pc_pid (pid
) - DECR_PC_AFTER_BREAK
!= thr_brk_addr
)
647 /* Retrieve stub args. */
648 sp
= read_register_pid (SP_REGNUM
, pid
);
649 if (!base_ops
.to_xfer_memory (sp
+ SP_ARG0
, (char *)&mapp
,
650 sizeof (mapp
), 0, &base_ops
))
652 if (!base_ops
.to_xfer_memory (sp
+ SP_ARG0
+ sizeof (mapp
), (char *)&change
,
653 sizeof (change
), 0, &base_ops
))
656 /* create_inferior() may not have finished yet, so notice the main
657 thread to ensure that it's displayed first by add_thread(). */
658 mapp_main
= find_main ();
660 /* Notice thread creation, deletion, or stability change. */
662 case tc_switch_begin
:
663 if (!mapp
) /* usually means main thread */
667 case tc_thread_create
:
671 if (!read_map (mapp
, &map
))
673 tid
= MKTID (pid
, map
.thr_tid
);
676 case tc_thread_create
: /* new thread */
679 else if (!read_lwp ((CORE_ADDR
)map
.thr_lwpp
, &lwp
))
683 add_thread_uw (map
.thr_tid
, lwpid
, mapp
, tid
);
686 case tc_thread_exit
: /* thread has exited */
687 printf_unfiltered ("[Exited %s]\n", target_pid_to_str (tid
));
689 if (tid
== inferior_pid
)
693 case tc_switch_begin
: /* lwp is switching threads */
696 if (!(switchto_thread
= find_thread_pid (tid
)))
698 switchto_thread
->private->stable
= 0;
706 case tc_switch_complete
: /* lwp has switched threads */
707 case tc_cancel_complete
: /* lwp didn't switch threads */
708 if (!switchto_thread
)
711 if (change
== tc_switch_complete
)
714 * If switchto_thread is the main thread, then (a) the corresponding
715 * tc_switch_begin probably received a null map argument and therefore
716 * (b) it may have been a spurious switch following a tc_thread_exit.
718 * Therefore, explicitly query the thread's lwp before caching it in
719 * its thread list entry.
721 if (!read_map (switchto_thread
->private->mapp
, &map
))
725 if (!read_lwp ((CORE_ADDR
)map
.thr_lwpp
, &lwp
))
727 if ((info
= find_thread_lwp (lwp
.lwp_id
)))
728 info
->private->lwpid
= 0;
729 switchto_thread
->private->lwpid
= lwp
.lwp_id
;
733 switchto_thread
->private->stable
= 1;
734 switchto_thread
= NULL
;
738 case tc_thread_suspend
:
739 case tc_thread_suspend_pending
:
740 case tc_thread_continue
:
742 DBG(("unexpected condition in libthread_stub()"));
746 DBG2(("libthread_stub(%s): %s %s %s", dbgpid (pid
), dbgpid (tid
),
747 dbgchange (change
), tid
? dbgstate (map
.thr_state
) : ""));
751 * Wait for thread/lwp/process ID if >= 0 or for any thread otherwise.
754 uw_thread_wait (int pid
, struct target_waitstatus
*status
)
757 pid
= thr_to_lwp (pid
);
758 CALL_BASE (pid
= base_ops
.to_wait (pid
> 0 ? pid
: -1, status
));
760 if (status
->kind
== TARGET_WAITKIND_STOPPED
&&
761 status
->value
.sig
== TARGET_SIGNAL_TRAP
)
762 libthread_stub (pid
);
764 return lwp_to_thr (pid
);
768 * Tell gdb about the registers in the thread/lwp/process specified by
772 uw_thread_fetch_registers (int regno
)
775 struct thread_info
*info
;
776 struct thread_map map
;
778 TRY_BASE (base_ops
.to_fetch_registers (regno
), &called
);
782 if (!(info
= find_thread_pid (inferior_pid
)))
784 if (!read_map (info
->private->mapp
, &map
))
787 supply_gregset (&map
.thr_ucontext
.uc_mcontext
.gregs
);
788 supply_fpregset (&map
.thr_ucontext
.uc_mcontext
.fpregs
);
792 * Store gdb's current view of the register set into the thread/lwp/process
793 * specified by inferior_pid.
796 uw_thread_store_registers (int regno
)
798 CALL_BASE (base_ops
.to_store_registers (regno
));
802 * Prepare to modify the registers array.
805 uw_thread_prepare_to_store (void)
807 CALL_BASE (base_ops
.to_prepare_to_store ());
811 * Fork an inferior process and start debugging it.
813 * This function only gets called with uw_thread_active == 0.
816 uw_thread_create_inferior (char *exec_file
, char *allargs
, char **env
)
818 if (uw_thread_active
)
819 deactivate_uw_thread ();
821 procfs_ops
.to_create_inferior (exec_file
, allargs
, env
);
822 if (uw_thread_active
)
830 * Kill and forget about the inferior process.
833 uw_thread_kill (void)
839 * Clean up after the inferior exits.
842 uw_thread_mourn_inferior (void)
844 remove_thread_event_breakpoints ();
845 deactivate_uw_thread ();
846 base_ops
.to_mourn_inferior ();
850 * Return whether this module can attach to and run processes.
852 * This function only gets called with uw_thread_active == 0.
855 uw_thread_can_run (void)
857 return procfs_suppress_run
;
861 * Return whether thread PID is still valid.
864 uw_thread_alive (int pid
)
867 return base_ops
.to_thread_alive (pid
);
869 /* If it's in the thread list, it's valid, because otherwise
870 libthread_stub() would have deleted it. */
871 return in_thread_list (pid
);
875 * Add to the thread list any threads and lwps it doesn't already contain.
878 uw_thread_find_new_threads (void)
880 CALL_BASE (if (base_ops
.to_find_new_threads
)
881 base_ops
.to_find_new_threads ());
886 * Return a string for pretty-printing PID in "info threads" output.
887 * This may be called by either procfs.c or by generic gdb.
890 uw_thread_pid_to_str (int pid
)
892 #define FMT "Thread %d"
893 static char buf
[sizeof (FMT
) + 3 * sizeof (pid
)];
896 /* core_ops says "process foo", so call procfs_ops explicitly. */
897 return procfs_ops
.to_pid_to_str (pid
);
899 sprintf (buf
, FMT
, TIDGET (pid
));
905 * Return a string displaying INFO state information in "info threads"
909 uw_extra_thread_info (struct thread_info
*info
)
912 struct thread_map map
;
917 if (!ISTID (info
->pid
))
920 if (!info
->private->stable
)
923 if (!read_map (info
->private->mapp
, &map
))
926 if (!map
.thr_lwpp
|| !read_lwp ((CORE_ADDR
)map
.thr_lwpp
, &lwp
))
931 switch (map
.thr_state
) {
932 case TS_ONPROC
: name
= "running"; break;
933 case TS_SLEEP
: name
= "sleeping"; break;
934 case TS_RUNNABLE
: name
= "runnable"; break;
935 case TS_ZOMBIE
: name
= "zombie"; break;
936 case TS_SUSPENDED
: name
= "suspended"; break;
938 case TS_FORK
: name
= "forking"; break;
940 default: name
= "confused"; break;
946 sprintf (buf
, "%s, LWP %d", name
, lwpid
);
951 * Check whether libthread.so has just been loaded, and if so, try to
952 * initialize user-space thread debugging support.
954 * libthread.so loading happens while (a) an inferior process is being
955 * started by procfs and (b) a core image is being loaded.
957 * This function often gets called with uw_thread_active == 0.
960 libthread_init (void)
962 struct minimal_symbol
*ms
;
963 struct thread_debug debug
;
965 struct breakpoint
*b
;
968 /* Don't initialize twice. */
969 if (uw_thread_active
)
972 /* Check whether libthread.so has been loaded. */
973 if (!(ms
= lookup_minimal_symbol ("_thr_debug", NULL
, NULL
)))
976 /* Cache _thr_debug's address. */
977 if (!(thr_debug_addr
= SYMBOL_VALUE_ADDRESS (ms
)))
980 /* Initialize base_ops.to_xfer_memory(). */
981 base_ops
= current_target
;
983 /* Load _thr_debug's current contents. */
984 if (!read_thr_debug (&debug
))
987 /* User code (e.g. my test programs) may dereference _thr_debug,
988 making it availble to GDB before shared libs are loaded. */
992 /* libthread.so has been loaded, and the current_target should now
993 reflect core_ops or procfs_ops. */
994 push_target (&uw_thread_ops
); /* must precede notice_threads() */
995 uw_thread_active
= 1;
997 if (!target_has_execution
)
999 /* Locate threads in core file. */
1004 /* Set a breakpoint on the stub function provided by libthread.so. */
1005 thr_brk_addr
= (CORE_ADDR
)debug
.thr_brk
;
1006 if (!(b
= create_thread_event_breakpoint (thr_brk_addr
)))
1009 /* Activate the stub function. */
1010 onp
= (CORE_ADDR
)&((struct thread_debug
*)thr_debug_addr
)->thr_debug_on
;
1011 if (!base_ops
.to_xfer_memory ((CORE_ADDR
)onp
, (char *)&one
,
1012 sizeof (one
), 1, &base_ops
))
1014 delete_breakpoint (b
);
1018 /* Prepare for finding the main thread, which doesn't yet exist. */
1025 warning ("uw-thread: unable to initialize user-mode thread debugging\n");
1026 deactivate_uw_thread ();
1030 * target_new_objfile_hook callback.
1032 * If OBJFILE is non-null, check whether libthread.so was just loaded,
1033 * and if so, prepare for user-mode thread debugging.
1035 * If OBJFILE is null, libthread.so has gone away, so stop debugging
1036 * user-mode threads.
1038 * This function often gets called with uw_thread_active == 0.
1041 uw_thread_new_objfile (struct objfile
*objfile
)
1046 else if (uw_thread_active
)
1047 deactivate_uw_thread ();
1049 if (target_new_objfile_chain
)
1050 target_new_objfile_chain (objfile
);
1054 * Initialize uw_thread_ops.
1057 init_uw_thread_ops (void)
1059 uw_thread_ops
.to_shortname
= "unixware-threads";
1060 uw_thread_ops
.to_longname
= "UnixWare threads and pthread.";
1061 uw_thread_ops
.to_doc
= "UnixWare threads and pthread support.";
1062 uw_thread_ops
.to_attach
= uw_thread_attach
;
1063 uw_thread_ops
.to_detach
= uw_thread_detach
;
1064 uw_thread_ops
.to_resume
= uw_thread_resume
;
1065 uw_thread_ops
.to_wait
= uw_thread_wait
;
1066 uw_thread_ops
.to_fetch_registers
= uw_thread_fetch_registers
;
1067 uw_thread_ops
.to_store_registers
= uw_thread_store_registers
;
1068 uw_thread_ops
.to_prepare_to_store
= uw_thread_prepare_to_store
;
1069 uw_thread_ops
.to_create_inferior
= uw_thread_create_inferior
;
1070 uw_thread_ops
.to_kill
= uw_thread_kill
;
1071 uw_thread_ops
.to_mourn_inferior
= uw_thread_mourn_inferior
;
1072 uw_thread_ops
.to_can_run
= uw_thread_can_run
;
1073 uw_thread_ops
.to_thread_alive
= uw_thread_alive
;
1074 uw_thread_ops
.to_find_new_threads
= uw_thread_find_new_threads
;
1075 uw_thread_ops
.to_pid_to_str
= uw_thread_pid_to_str
;
1076 uw_thread_ops
.to_extra_thread_info
= uw_extra_thread_info
;
1077 uw_thread_ops
.to_stratum
= thread_stratum
;
1078 uw_thread_ops
.to_magic
= OPS_MAGIC
;
1082 * Module startup initialization function, automagically called by
1086 _initialize_uw_thread (void)
1088 init_uw_thread_ops ();
1089 add_target (&uw_thread_ops
);
1091 procfs_suppress_run
= 1;
1093 /* Notice when libthread.so gets loaded. */
1094 target_new_objfile_chain
= target_new_objfile_hook
;
1095 target_new_objfile_hook
= uw_thread_new_objfile
;