1 /* Low level interface for debugging Solaris threads for GDB, the GNU debugger.
2 Copyright 1996, 1997, 1998 Free Software Foundation, Inc.
4 This file is part of GDB.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
21 /* This module implements a sort of half target that sits between the
22 machine-independent parts of GDB and the /proc interface (procfs.c) to
23 provide access to the Solaris user-mode thread implementation.
25 Solaris threads are true user-mode threads, which are invoked via the thr_*
26 and pthread_* (native and Posix respectivly) interfaces. These are mostly
27 implemented in user-space, with all thread context kept in various
28 structures that live in the user's heap. These should not be confused with
29 lightweight processes (LWPs), which are implemented by the kernel, and
30 scheduled without explicit intervention by the process.
32 Just to confuse things a little, Solaris threads (both native and Posix) are
33 actually implemented using LWPs. In general, there are going to be more
34 threads than LWPs. There is no fixed correspondence between a thread and an
35 LWP. When a thread wants to run, it gets scheduled onto the first available
36 LWP and can therefore migrate from one LWP to another as time goes on. A
37 sleeping thread may not be associated with an LWP at all!
39 To make it possible to mess with threads, Sun provides a library called
40 libthread_db.so.1 (not to be confused with libthread_db.so.0, which doesn't
41 have a published interface). This interface has an upper part, which it
42 provides, and a lower part which I provide. The upper part consists of the
43 td_* routines, which allow me to find all the threads, query their state,
44 etc... The lower part consists of all of the ps_*, which are used by the
45 td_* routines to read/write memory, manipulate LWPs, lookup symbols, etc...
46 The ps_* routines actually do most of their work by calling functions in
51 #include <proc_service.h>
52 #include <thread_db.h>
53 #include "gdbthread.h"
61 extern struct target_ops sol_thread_ops
; /* Forward declaration */
62 extern struct target_ops sol_core_ops
; /* Forward declaration */
64 /* place to store core_ops before we overwrite it */
65 static struct target_ops orig_core_ops
;
67 struct target_ops sol_thread_ops
;
68 struct target_ops sol_core_ops
;
70 extern int procfs_suppress_run
;
71 extern struct target_ops procfs_ops
; /* target vector for procfs.c */
72 extern struct target_ops core_ops
; /* target vector for corelow.c */
73 extern char *procfs_pid_to_str
PARAMS ((int pid
));
75 /* Prototypes for supply_gregset etc. */
78 /* This struct is defined by us, but mainly used for the proc_service interface.
79 We don't have much use for it, except as a handy place to get a real pid
80 for memory accesses. */
93 static struct ps_prochandle main_ph
;
94 static td_thragent_t
*main_ta
;
95 static int sol_thread_active
= 0;
97 static struct cleanup
*save_inferior_pid
PARAMS ((void));
98 static void restore_inferior_pid
PARAMS ((void *pid
));
99 static char *td_err_string
PARAMS ((td_err_e errcode
));
100 static char *td_state_string
PARAMS ((td_thr_state_e statecode
));
101 static int thread_to_lwp
PARAMS ((int thread_id
, int default_lwp
));
102 static void sol_thread_resume
PARAMS ((int pid
, int step
,
103 enum target_signal signo
));
104 static int lwp_to_thread
PARAMS ((int lwp
));
105 static int sol_thread_alive
PARAMS ((int pid
));
106 static void sol_core_close
PARAMS ((int quitting
));
108 static void init_sol_thread_ops
PARAMS ((void));
109 static void init_sol_core_ops
PARAMS ((void));
111 /* Default definitions: These must be defined in tm.h
112 if they are to be shared with a process module such as procfs. */
114 #define THREAD_FLAG 0x80000000
115 #define is_thread(ARG) (((ARG) & THREAD_FLAG) != 0)
116 #define is_lwp(ARG) (((ARG) & THREAD_FLAG) == 0)
117 #define GET_LWP(PID) TIDGET (PID)
118 #define GET_THREAD(PID) TIDGET (PID)
119 #define BUILD_LWP(TID, PID) MERGEPID (PID, TID)
121 #define BUILD_THREAD(TID, PID) (MERGEPID (PID, TID) | THREAD_FLAG)
123 /* Pointers to routines from lithread_db resolved by dlopen() */
125 static void (*p_td_log
) (const int on_off
);
126 static td_err_e (*p_td_ta_new
) (const struct ps_prochandle
* ph_p
,
127 td_thragent_t
** ta_pp
);
128 static td_err_e (*p_td_ta_delete
) (td_thragent_t
* ta_p
);
129 static td_err_e (*p_td_init
) (void);
130 static td_err_e (*p_td_ta_get_ph
) (const td_thragent_t
* ta_p
,
131 struct ps_prochandle
** ph_pp
);
132 static td_err_e (*p_td_ta_get_nthreads
) (const td_thragent_t
* ta_p
,
134 static td_err_e (*p_td_ta_tsd_iter
) (const td_thragent_t
* ta_p
,
137 static td_err_e (*p_td_ta_thr_iter
) (const td_thragent_t
* ta_p
,
140 td_thr_state_e state
,
142 sigset_t
* ti_sigmask_p
,
143 unsigned ti_user_flags
);
144 static td_err_e (*p_td_thr_validate
) (const td_thrhandle_t
* th_p
);
145 static td_err_e (*p_td_thr_tsd
) (const td_thrhandle_t
* th_p
,
146 const thread_key_t key
,
148 static td_err_e (*p_td_thr_get_info
) (const td_thrhandle_t
* th_p
,
149 td_thrinfo_t
* ti_p
);
150 static td_err_e (*p_td_thr_getfpregs
) (const td_thrhandle_t
* th_p
,
151 prfpregset_t
* fpregset
);
152 static td_err_e (*p_td_thr_getxregsize
) (const td_thrhandle_t
* th_p
,
154 static td_err_e (*p_td_thr_getxregs
) (const td_thrhandle_t
* th_p
,
155 const caddr_t xregset
);
156 static td_err_e (*p_td_thr_sigsetmask
) (const td_thrhandle_t
* th_p
,
157 const sigset_t ti_sigmask
);
158 static td_err_e (*p_td_thr_setprio
) (const td_thrhandle_t
* th_p
,
160 static td_err_e (*p_td_thr_setsigpending
) (const td_thrhandle_t
* th_p
,
161 const uchar_t ti_pending_flag
,
162 const sigset_t ti_pending
);
163 static td_err_e (*p_td_thr_setfpregs
) (const td_thrhandle_t
* th_p
,
164 const prfpregset_t
* fpregset
);
165 static td_err_e (*p_td_thr_setxregs
) (const td_thrhandle_t
* th_p
,
166 const caddr_t xregset
);
167 static td_err_e (*p_td_ta_map_id2thr
) (const td_thragent_t
* ta_p
,
169 td_thrhandle_t
* th_p
);
170 static td_err_e (*p_td_ta_map_lwp2thr
) (const td_thragent_t
* ta_p
,
172 td_thrhandle_t
* th_p
);
173 static td_err_e (*p_td_thr_getgregs
) (const td_thrhandle_t
* th_p
,
175 static td_err_e (*p_td_thr_setgregs
) (const td_thrhandle_t
* th_p
,
176 const prgregset_t regset
);
182 td_err_string - Convert a thread_db error code to a string
186 char * td_err_string (errcode)
190 Return the thread_db error string associated with errcode. If errcode
191 is unknown, then return a message.
196 td_err_string (errcode
)
199 static struct string_map
202 {TD_OK
, "generic \"call succeeded\""},
203 {TD_ERR
, "generic error."},
204 {TD_NOTHR
, "no thread can be found to satisfy query"},
205 {TD_NOSV
, "no synch. variable can be found to satisfy query"},
206 {TD_NOLWP
, "no lwp can be found to satisfy query"},
207 {TD_BADPH
, "invalid process handle"},
208 {TD_BADTH
, "invalid thread handle"},
209 {TD_BADSH
, "invalid synchronization handle"},
210 {TD_BADTA
, "invalid thread agent"},
211 {TD_BADKEY
, "invalid key"},
212 {TD_NOMSG
, "td_thr_event_getmsg() called when there was no message"},
213 {TD_NOFPREGS
, "FPU register set not available for given thread"},
214 {TD_NOLIBTHREAD
, "application not linked with libthread"},
215 {TD_NOEVENT
, "requested event is not supported"},
216 {TD_NOCAPAB
, "capability not available"},
217 {TD_DBERR
, "Debugger service failed"},
218 {TD_NOAPLIC
, "Operation not applicable to"},
219 {TD_NOTSD
, "No thread specific data for this thread"},
220 {TD_MALLOC
, "Malloc failed"},
221 {TD_PARTIALREG
, "Only part of register set was writen/read"},
222 {TD_NOXREGS
, "X register set not available for given thread"}
224 const int td_err_size
= sizeof td_err_table
/ sizeof (struct string_map
);
228 for (i
= 0; i
< td_err_size
; i
++)
229 if (td_err_table
[i
].num
== errcode
)
230 return td_err_table
[i
].str
;
232 sprintf (buf
, "Unknown thread_db error code: %d", errcode
);
241 td_state_string - Convert a thread_db state code to a string
245 char * td_state_string (statecode)
249 Return the thread_db state string associated with statecode. If
250 statecode is unknown, then return a message.
255 td_state_string (statecode
)
256 td_thr_state_e statecode
;
258 static struct string_map
259 td_thr_state_table
[] =
261 {TD_THR_ANY_STATE
, "any state"},
262 {TD_THR_UNKNOWN
, "unknown"},
263 {TD_THR_STOPPED
, "stopped"},
265 {TD_THR_ACTIVE
, "active"},
266 {TD_THR_ZOMBIE
, "zombie"},
267 {TD_THR_SLEEP
, "sleep"},
268 {TD_THR_STOPPED_ASLEEP
, "stopped asleep"}
270 const int td_thr_state_table_size
= sizeof td_thr_state_table
/ sizeof (struct string_map
);
274 for (i
= 0; i
< td_thr_state_table_size
; i
++)
275 if (td_thr_state_table
[i
].num
== statecode
)
276 return td_thr_state_table
[i
].str
;
278 sprintf (buf
, "Unknown thread_db state code: %d", statecode
);
287 thread_to_lwp - Convert a Posix or Solaris thread id to a LWP id.
291 int thread_to_lwp (thread_id, default_lwp)
295 This function converts a Posix or Solaris thread id to a lightweight
296 process id. If thread_id is non-existent, that's an error. If it's
297 an inactive thread, then we return default_lwp.
301 This function probably shouldn't call error()...
306 thread_to_lwp (thread_id
, default_lwp
)
314 if (is_lwp (thread_id
))
315 return thread_id
; /* It's already an LWP id */
317 /* It's a thread. Convert to lwp */
319 val
= p_td_ta_map_id2thr (main_ta
, GET_THREAD (thread_id
), &th
);
321 return -1; /* thread must have terminated */
322 else if (val
!= TD_OK
)
323 error ("thread_to_lwp: td_ta_map_id2thr %s", td_err_string (val
));
325 val
= p_td_thr_get_info (&th
, &ti
);
327 return -1; /* thread must have terminated */
328 else if (val
!= TD_OK
)
329 error ("thread_to_lwp: td_thr_get_info: %s", td_err_string (val
));
331 if (ti
.ti_state
!= TD_THR_ACTIVE
)
333 if (default_lwp
!= -1)
335 error ("thread_to_lwp: thread state not active: %s",
336 td_state_string (ti
.ti_state
));
339 return BUILD_LWP (ti
.ti_lid
, PIDGET (thread_id
));
346 lwp_to_thread - Convert a LWP id to a Posix or Solaris thread id.
350 int lwp_to_thread (lwp_id)
354 This function converts a lightweight process id to a Posix or Solaris
355 thread id. If thread_id is non-existent, that's an error.
359 This function probably shouldn't call error()...
372 return lwp
; /* It's already a thread id */
374 /* It's an lwp. Convert it to a thread id. */
376 if (!sol_thread_alive (lwp
))
377 return -1; /* defunct lwp */
379 val
= p_td_ta_map_lwp2thr (main_ta
, GET_LWP (lwp
), &th
);
381 return -1; /* thread must have terminated */
382 else if (val
!= TD_OK
)
383 error ("lwp_to_thread: td_ta_map_lwp2thr: %s.", td_err_string (val
));
385 val
= p_td_thr_validate (&th
);
387 return lwp
; /* libthread doesn't know about it;
389 else if (val
!= TD_OK
)
390 error ("lwp_to_thread: td_thr_validate: %s.", td_err_string (val
));
392 val
= p_td_thr_get_info (&th
, &ti
);
394 return -1; /* thread must have terminated */
395 else if (val
!= TD_OK
)
396 error ("lwp_to_thread: td_thr_get_info: %s.", td_err_string (val
));
398 return BUILD_THREAD (ti
.ti_tid
, PIDGET (lwp
));
405 save_inferior_pid - Save inferior_pid on the cleanup list
406 restore_inferior_pid - Restore inferior_pid from the cleanup list
410 struct cleanup *save_inferior_pid ()
411 void restore_inferior_pid (int pid)
415 These two functions act in unison to restore inferior_pid in
420 inferior_pid is a global variable that needs to be changed by many of
421 these routines before calling functions in procfs.c. In order to
422 guarantee that inferior_pid gets restored (in case of errors), you
423 need to call save_inferior_pid before changing it. At the end of the
424 function, you should invoke do_cleanups to restore it.
429 static struct cleanup
*
432 return make_cleanup (restore_inferior_pid
, (void *) inferior_pid
);
436 restore_inferior_pid (pid
)
439 inferior_pid
= (int) pid
;
443 /* Most target vector functions from here on actually just pass through to
444 procfs.c, as they don't need to do anything specific for threads. */
449 sol_thread_open (arg
, from_tty
)
453 procfs_ops
.to_open (arg
, from_tty
);
456 /* Attach to process PID, then initialize for debugging it
457 and wait for the trace-trap that results from attaching. */
460 sol_thread_attach (args
, from_tty
)
464 procfs_ops
.to_attach (args
, from_tty
);
465 /* Must get symbols from solibs before libthread_db can run! */
466 SOLIB_ADD ((char *) 0, from_tty
, (struct target_ops
*) 0);
467 if (sol_thread_active
)
469 printf_filtered ("sol-thread active.\n");
470 main_ph
.pid
= inferior_pid
; /* Save for xfer_memory */
471 push_target (&sol_thread_ops
);
472 inferior_pid
= lwp_to_thread (inferior_pid
);
473 if (inferior_pid
== -1)
474 inferior_pid
= main_ph
.pid
;
476 add_thread (inferior_pid
);
478 /* XXX - might want to iterate over all the threads and register them. */
481 /* Take a program previously attached to and detaches it.
482 The program resumes execution and will no longer stop
483 on signals, etc. We'd better not have left any breakpoints
484 in the program or it'll die when it hits one. For this
485 to work, it may be necessary for the process to have been
486 previously attached. It *might* work if the program was
487 started via the normal ptrace (PTRACE_TRACEME). */
490 sol_thread_detach (args
, from_tty
)
494 inferior_pid
= PIDGET (main_ph
.pid
);
495 unpush_target (&sol_thread_ops
);
496 procfs_ops
.to_detach (args
, from_tty
);
499 /* Resume execution of process PID. If STEP is nozero, then
500 just single step it. If SIGNAL is nonzero, restart it with that
501 signal activated. We may have to convert pid from a thread-id to an LWP id
505 sol_thread_resume (pid
, step
, signo
)
508 enum target_signal signo
;
510 struct cleanup
*old_chain
;
512 old_chain
= save_inferior_pid ();
514 inferior_pid
= thread_to_lwp (inferior_pid
, main_ph
.pid
);
515 if (inferior_pid
== -1)
516 inferior_pid
= procfs_first_available ();
522 pid
= thread_to_lwp (pid
, -2);
523 if (pid
== -2) /* Inactive thread */
524 error ("This version of Solaris can't start inactive threads.");
525 if (info_verbose
&& pid
== -1)
526 warning ("Specified thread %d seems to have terminated",
527 GET_THREAD (save_pid
));
530 procfs_ops
.to_resume (pid
, step
, signo
);
532 do_cleanups (old_chain
);
535 /* Wait for any threads to stop. We may have to convert PID from a thread id
536 to a LWP id, and vice versa on the way out. */
539 sol_thread_wait (pid
, ourstatus
)
541 struct target_waitstatus
*ourstatus
;
545 struct cleanup
*old_chain
;
547 save_pid
= inferior_pid
;
548 old_chain
= save_inferior_pid ();
550 inferior_pid
= thread_to_lwp (inferior_pid
, main_ph
.pid
);
551 if (inferior_pid
== -1)
552 inferior_pid
= procfs_first_available ();
558 pid
= thread_to_lwp (pid
, -2);
559 if (pid
== -2) /* Inactive thread */
560 error ("This version of Solaris can't start inactive threads.");
561 if (info_verbose
&& pid
== -1)
562 warning ("Specified thread %d seems to have terminated",
563 GET_THREAD (save_pid
));
566 rtnval
= procfs_ops
.to_wait (pid
, ourstatus
);
568 if (ourstatus
->kind
!= TARGET_WAITKIND_EXITED
)
570 /* Map the LWP of interest back to the appropriate thread ID */
571 rtnval
= lwp_to_thread (rtnval
);
575 /* See if we have a new thread */
576 if (is_thread (rtnval
)
577 && rtnval
!= save_pid
578 && !in_thread_list (rtnval
))
580 printf_filtered ("[New %s]\n", target_pid_to_str (rtnval
));
585 /* During process initialization, we may get here without the thread package
586 being initialized, since that can only happen after we've found the shared
589 do_cleanups (old_chain
);
595 sol_thread_fetch_registers (regno
)
599 td_thrhandle_t thandle
;
602 prfpregset_t fpregset
;
608 if (!is_thread (inferior_pid
))
609 { /* LWP: pass the request on to procfs.c */
610 if (target_has_execution
)
611 procfs_ops
.to_fetch_registers (regno
);
613 orig_core_ops
.to_fetch_registers (regno
);
617 /* Solaris thread: convert inferior_pid into a td_thrhandle_t */
619 thread
= GET_THREAD (inferior_pid
);
622 error ("sol_thread_fetch_registers: thread == 0");
624 val
= p_td_ta_map_id2thr (main_ta
, thread
, &thandle
);
626 error ("sol_thread_fetch_registers: td_ta_map_id2thr: %s",
627 td_err_string (val
));
629 /* Get the integer regs */
631 val
= p_td_thr_getgregs (&thandle
, gregset
);
633 && val
!= TD_PARTIALREG
)
634 error ("sol_thread_fetch_registers: td_thr_getgregs %s",
635 td_err_string (val
));
637 /* For the sparc, TD_PARTIALREG means that only i0->i7, l0->l7, pc and sp
638 are saved (by a thread context switch). */
640 /* And, now the fp regs */
642 val
= p_td_thr_getfpregs (&thandle
, &fpregset
);
644 && val
!= TD_NOFPREGS
)
645 error ("sol_thread_fetch_registers: td_thr_getfpregs %s",
646 td_err_string (val
));
648 /* Note that we must call supply_{g fp}regset *after* calling the td routines
649 because the td routines call ps_lget* which affect the values stored in the
652 supply_gregset ((gdb_gregset_t
*) &gregset
);
653 supply_fpregset ((gdb_fpregset_t
*) &fpregset
);
656 /* thread_db doesn't seem to handle this right */
657 val
= td_thr_getxregsize (&thandle
, &xregsize
);
658 if (val
!= TD_OK
&& val
!= TD_NOXREGS
)
659 error ("sol_thread_fetch_registers: td_thr_getxregsize %s",
660 td_err_string (val
));
664 xregset
= alloca (xregsize
);
665 val
= td_thr_getxregs (&thandle
, xregset
);
667 error ("sol_thread_fetch_registers: td_thr_getxregs %s",
668 td_err_string (val
));
674 sol_thread_store_registers (regno
)
678 td_thrhandle_t thandle
;
681 prfpregset_t fpregset
;
687 if (!is_thread (inferior_pid
))
688 { /* LWP: pass the request on to procfs.c */
689 procfs_ops
.to_store_registers (regno
);
693 /* Solaris thread: convert inferior_pid into a td_thrhandle_t */
695 thread
= GET_THREAD (inferior_pid
);
697 val
= p_td_ta_map_id2thr (main_ta
, thread
, &thandle
);
699 error ("sol_thread_store_registers: td_ta_map_id2thr %s",
700 td_err_string (val
));
703 { /* Not writing all the regs */
704 /* save new register value */
705 char old_value
[REGISTER_SIZE
];
706 memcpy (old_value
, ®isters
[REGISTER_BYTE (regno
)], REGISTER_SIZE
);
708 val
= p_td_thr_getgregs (&thandle
, gregset
);
710 error ("sol_thread_store_registers: td_thr_getgregs %s",
711 td_err_string (val
));
712 val
= p_td_thr_getfpregs (&thandle
, &fpregset
);
714 error ("sol_thread_store_registers: td_thr_getfpregs %s",
715 td_err_string (val
));
717 /* restore new register value */
718 memcpy (®isters
[REGISTER_BYTE (regno
)], old_value
, REGISTER_SIZE
);
721 /* thread_db doesn't seem to handle this right */
722 val
= td_thr_getxregsize (&thandle
, &xregsize
);
723 if (val
!= TD_OK
&& val
!= TD_NOXREGS
)
724 error ("sol_thread_store_registers: td_thr_getxregsize %s",
725 td_err_string (val
));
729 xregset
= alloca (xregsize
);
730 val
= td_thr_getxregs (&thandle
, xregset
);
732 error ("sol_thread_store_registers: td_thr_getxregs %s",
733 td_err_string (val
));
738 fill_gregset ((gdb_gregset_t
*) &gregset
, regno
);
739 fill_fpregset ((gdb_fpregset_t
*) &fpregset
, regno
);
741 val
= p_td_thr_setgregs (&thandle
, gregset
);
743 error ("sol_thread_store_registers: td_thr_setgregs %s",
744 td_err_string (val
));
745 val
= p_td_thr_setfpregs (&thandle
, &fpregset
);
747 error ("sol_thread_store_registers: td_thr_setfpregs %s",
748 td_err_string (val
));
751 /* thread_db doesn't seem to handle this right */
752 val
= td_thr_getxregsize (&thandle
, &xregsize
);
753 if (val
!= TD_OK
&& val
!= TD_NOXREGS
)
754 error ("sol_thread_store_registers: td_thr_getxregsize %s",
755 td_err_string (val
));
757 /* Should probably do something about writing the xregs here, but what are
762 /* Get ready to modify the registers array. On machines which store
763 individual registers, this doesn't need to do anything. On machines
764 which store all the registers in one fell swoop, this makes sure
765 that registers contains all the registers from the program being
769 sol_thread_prepare_to_store ()
771 procfs_ops
.to_prepare_to_store ();
775 sol_thread_xfer_memory (memaddr
, myaddr
, len
, dowrite
, target
)
780 struct target_ops
*target
; /* ignored */
783 struct cleanup
*old_chain
;
785 old_chain
= save_inferior_pid ();
787 if (is_thread (inferior_pid
) || /* A thread */
788 !target_thread_alive (inferior_pid
)) /* An lwp, but not alive */
789 inferior_pid
= procfs_first_available (); /* Find any live lwp. */
790 /* Note: don't need to call switch_to_thread; we're just reading memory. */
792 if (target_has_execution
)
793 retval
= procfs_ops
.to_xfer_memory (memaddr
, myaddr
, len
, dowrite
, target
);
795 retval
= orig_core_ops
.to_xfer_memory (memaddr
, myaddr
, len
,
798 do_cleanups (old_chain
);
803 /* Print status information about what we're accessing. */
806 sol_thread_files_info (ignore
)
807 struct target_ops
*ignore
;
809 procfs_ops
.to_files_info (ignore
);
813 sol_thread_kill_inferior ()
815 procfs_ops
.to_kill ();
819 sol_thread_notice_signals (pid
)
822 procfs_ops
.to_notice_signals (PIDGET (pid
));
825 /* Fork an inferior process, and start debugging it with /proc. */
828 sol_thread_create_inferior (exec_file
, allargs
, env
)
833 procfs_ops
.to_create_inferior (exec_file
, allargs
, env
);
835 if (sol_thread_active
&& inferior_pid
!= 0)
837 main_ph
.pid
= inferior_pid
; /* Save for xfer_memory */
839 push_target (&sol_thread_ops
);
841 inferior_pid
= lwp_to_thread (inferior_pid
);
842 if (inferior_pid
== -1)
843 inferior_pid
= main_ph
.pid
;
845 if (!in_thread_list (inferior_pid
))
846 add_thread (inferior_pid
);
850 /* This routine is called whenever a new symbol table is read in, or when all
851 symbol tables are removed. libthread_db can only be initialized when it
852 finds the right variables in libthread.so. Since it's a shared library,
853 those variables don't show up until the library gets mapped and the symbol
856 /* This new_objfile event is now managed by a chained function pointer.
857 * It is the callee's responsability to call the next client on the chain.
860 /* Saved pointer to previous owner of the new_objfile event. */
861 static void (*target_new_objfile_chain
) PARAMS ((struct objfile
*));
864 sol_thread_new_objfile (objfile
)
865 struct objfile
*objfile
;
871 sol_thread_active
= 0;
875 /* don't do anything if init failed to resolve the libthread_db library */
876 if (!procfs_suppress_run
)
879 /* Now, initialize the thread debugging library. This needs to be done after
880 the shared libraries are located because it needs information from the
881 user's thread library. */
886 warning ("sol_thread_new_objfile: td_init: %s", td_err_string (val
));
890 val
= p_td_ta_new (&main_ph
, &main_ta
);
891 if (val
== TD_NOLIBTHREAD
)
893 else if (val
!= TD_OK
)
895 warning ("sol_thread_new_objfile: td_ta_new: %s", td_err_string (val
));
899 sol_thread_active
= 1;
901 /* Call predecessor on chain, if any. */
902 if (target_new_objfile_chain
)
903 target_new_objfile_chain (objfile
);
906 /* Clean up after the inferior dies. */
909 sol_thread_mourn_inferior ()
911 unpush_target (&sol_thread_ops
);
912 procfs_ops
.to_mourn_inferior ();
915 /* Mark our target-struct as eligible for stray "run" and "attach" commands. */
918 sol_thread_can_run ()
920 return procfs_suppress_run
;
927 sol_thread_alive - test thread for "aliveness"
931 static bool sol_thread_alive (int pid);
935 returns true if thread still active in inferior.
940 sol_thread_alive (pid
)
943 if (is_thread (pid
)) /* non-kernel thread */
948 pid
= GET_THREAD (pid
);
949 if ((val
= p_td_ta_map_id2thr (main_ta
, pid
, &th
)) != TD_OK
)
950 return 0; /* thread not found */
951 if ((val
= p_td_thr_validate (&th
)) != TD_OK
)
952 return 0; /* thread not valid */
953 return 1; /* known thread: return true */
956 /* kernel thread (LWP): let procfs test it */
958 if (target_has_execution
)
959 return procfs_ops
.to_thread_alive (pid
);
961 return orig_core_ops
.to_thread_alive (pid
);
968 procfs_ops
.to_stop ();
971 /* These routines implement the lower half of the thread_db interface. Ie: the
974 /* Various versions of <proc_service.h> have slightly
975 different function prototypes. In particular, we have
978 struct ps_prochandle * const struct ps_prochandle *
983 Which one you have depends on solaris version and what
984 patches you've applied. On the theory that there are
985 only two major variants, we have configure check the
986 prototype of ps_pdwrite (), and use that info to make
987 appropriate typedefs here. */
989 #ifdef PROC_SERVICE_IS_OLD
990 typedef const struct ps_prochandle
*gdb_ps_prochandle_t
;
991 typedef char *gdb_ps_read_buf_t
;
992 typedef char *gdb_ps_write_buf_t
;
993 typedef int gdb_ps_size_t
;
994 typedef paddr_t gdb_ps_addr_t
;
996 typedef struct ps_prochandle
*gdb_ps_prochandle_t
;
997 typedef void *gdb_ps_read_buf_t
;
998 typedef const void *gdb_ps_write_buf_t
;
999 typedef size_t gdb_ps_size_t
;
1000 typedef psaddr_t gdb_ps_addr_t
;
1004 /* The next four routines are called by thread_db to tell us to stop and stop
1005 a particular process or lwp. Since GDB ensures that these are all stopped
1006 by the time we call anything in thread_db, these routines need to do
1012 ps_pstop (gdb_ps_prochandle_t ph
)
1017 /* Process continue */
1020 ps_pcontinue (gdb_ps_prochandle_t ph
)
1028 ps_lstop (gdb_ps_prochandle_t ph
, lwpid_t lwpid
)
1036 ps_lcontinue (gdb_ps_prochandle_t ph
, lwpid_t lwpid
)
1041 /* Looks up the symbol LD_SYMBOL_NAME in the debugger's symbol table. */
1044 ps_pglobal_lookup (gdb_ps_prochandle_t ph
, const char *ld_object_name
,
1045 const char *ld_symbol_name
, gdb_ps_addr_t
* ld_symbol_addr
)
1047 struct minimal_symbol
*ms
;
1049 ms
= lookup_minimal_symbol (ld_symbol_name
, NULL
, NULL
);
1054 *ld_symbol_addr
= SYMBOL_VALUE_ADDRESS (ms
);
1059 /* Common routine for reading and writing memory. */
1062 rw_common (int dowrite
, const struct ps_prochandle
*ph
, gdb_ps_addr_t addr
,
1063 char *buf
, int size
)
1065 struct cleanup
*old_chain
;
1067 old_chain
= save_inferior_pid ();
1069 if (is_thread (inferior_pid
) || /* A thread */
1070 !target_thread_alive (inferior_pid
)) /* An lwp, but not alive */
1071 inferior_pid
= procfs_first_available (); /* Find any live lwp. */
1072 /* Note: don't need to call switch_to_thread; we're just reading memory. */
1078 if (target_has_execution
)
1079 cc
= procfs_ops
.to_xfer_memory (addr
, buf
, size
, dowrite
, &procfs_ops
);
1081 cc
= orig_core_ops
.to_xfer_memory (addr
, buf
, size
, dowrite
, &core_ops
);
1086 print_sys_errmsg ("rw_common (): read", errno
);
1088 print_sys_errmsg ("rw_common (): write", errno
);
1090 do_cleanups (old_chain
);
1098 do_cleanups (old_chain
);
1103 /* Copies SIZE bytes from target process .data segment to debugger memory. */
1106 ps_pdread (gdb_ps_prochandle_t ph
, gdb_ps_addr_t addr
,
1107 gdb_ps_read_buf_t buf
, gdb_ps_size_t size
)
1109 return rw_common (0, ph
, addr
, buf
, size
);
1112 /* Copies SIZE bytes from debugger memory .data segment to target process. */
1115 ps_pdwrite (gdb_ps_prochandle_t ph
, gdb_ps_addr_t addr
,
1116 gdb_ps_write_buf_t buf
, gdb_ps_size_t size
)
1118 return rw_common (1, ph
, addr
, (char *) buf
, size
);
1121 /* Copies SIZE bytes from target process .text segment to debugger memory. */
1124 ps_ptread (gdb_ps_prochandle_t ph
, gdb_ps_addr_t addr
,
1125 gdb_ps_read_buf_t buf
, gdb_ps_size_t size
)
1127 return rw_common (0, ph
, addr
, buf
, size
);
1130 /* Copies SIZE bytes from debugger memory .text segment to target process. */
1133 ps_ptwrite (gdb_ps_prochandle_t ph
, gdb_ps_addr_t addr
,
1134 gdb_ps_write_buf_t buf
, gdb_ps_size_t size
)
1136 return rw_common (1, ph
, addr
, (char *) buf
, size
);
1139 /* Get integer regs for LWP */
1142 ps_lgetregs (gdb_ps_prochandle_t ph
, lwpid_t lwpid
,
1143 prgregset_t gregset
)
1145 struct cleanup
*old_chain
;
1147 old_chain
= save_inferior_pid ();
1149 inferior_pid
= BUILD_LWP (lwpid
, PIDGET (inferior_pid
));
1151 if (target_has_execution
)
1152 procfs_ops
.to_fetch_registers (-1);
1154 orig_core_ops
.to_fetch_registers (-1);
1155 fill_gregset ((gdb_gregset_t
*) gregset
, -1);
1157 do_cleanups (old_chain
);
1162 /* Set integer regs for LWP */
1165 ps_lsetregs (gdb_ps_prochandle_t ph
, lwpid_t lwpid
,
1166 const prgregset_t gregset
)
1168 struct cleanup
*old_chain
;
1170 old_chain
= save_inferior_pid ();
1172 inferior_pid
= BUILD_LWP (lwpid
, PIDGET (inferior_pid
));
1174 supply_gregset ((gdb_gregset_t
*) gregset
);
1175 if (target_has_execution
)
1176 procfs_ops
.to_store_registers (-1);
1178 orig_core_ops
.to_store_registers (-1);
1180 do_cleanups (old_chain
);
1185 /* Log a message (sends to gdb_stderr). */
1188 ps_plog (const char *fmt
,...)
1192 va_start (args
, fmt
);
1194 vfprintf_filtered (gdb_stderr
, fmt
, args
);
1197 /* Get size of extra register set. Currently a noop. */
1200 ps_lgetxregsize (gdb_ps_prochandle_t ph
, lwpid_t lwpid
, int *xregsize
)
1207 val
= get_lwp_fd (ph
, lwpid
, &lwp_fd
);
1211 if (ioctl (lwp_fd
, PIOCGXREGSIZE
, ®size
))
1213 if (errno
== EINVAL
)
1214 return PS_NOFREGS
; /* XXX Wrong code, but this is the closest
1215 thing in proc_service.h */
1217 print_sys_errmsg ("ps_lgetxregsize (): PIOCGXREGSIZE", errno
);
1225 /* Get extra register set. Currently a noop. */
1228 ps_lgetxregs (gdb_ps_prochandle_t ph
, lwpid_t lwpid
, caddr_t xregset
)
1234 val
= get_lwp_fd (ph
, lwpid
, &lwp_fd
);
1238 if (ioctl (lwp_fd
, PIOCGXREG
, xregset
))
1240 print_sys_errmsg ("ps_lgetxregs (): PIOCGXREG", errno
);
1248 /* Set extra register set. Currently a noop. */
1251 ps_lsetxregs (gdb_ps_prochandle_t ph
, lwpid_t lwpid
, caddr_t xregset
)
1257 val
= get_lwp_fd (ph
, lwpid
, &lwp_fd
);
1261 if (ioctl (lwp_fd
, PIOCSXREG
, xregset
))
1263 print_sys_errmsg ("ps_lsetxregs (): PIOCSXREG", errno
);
1271 /* Get floating-point regs for LWP */
1274 ps_lgetfpregs (gdb_ps_prochandle_t ph
, lwpid_t lwpid
,
1275 prfpregset_t
* fpregset
)
1277 struct cleanup
*old_chain
;
1279 old_chain
= save_inferior_pid ();
1281 inferior_pid
= BUILD_LWP (lwpid
, PIDGET (inferior_pid
));
1283 if (target_has_execution
)
1284 procfs_ops
.to_fetch_registers (-1);
1286 orig_core_ops
.to_fetch_registers (-1);
1287 fill_fpregset ((gdb_fpregset_t
*) fpregset
, -1);
1289 do_cleanups (old_chain
);
1294 /* Set floating-point regs for LWP */
1297 ps_lsetfpregs (gdb_ps_prochandle_t ph
, lwpid_t lwpid
,
1298 const prfpregset_t
* fpregset
)
1300 struct cleanup
*old_chain
;
1302 old_chain
= save_inferior_pid ();
1304 inferior_pid
= BUILD_LWP (lwpid
, PIDGET (inferior_pid
));
1306 supply_fpregset ((gdb_fpregset_t
*) fpregset
);
1307 if (target_has_execution
)
1308 procfs_ops
.to_store_registers (-1);
1310 orig_core_ops
.to_store_registers (-1);
1312 do_cleanups (old_chain
);
1317 #ifdef TM_I386SOL2_H
1319 /* Reads the local descriptor table of a LWP. */
1322 ps_lgetLDT (gdb_ps_prochandle_t ph
, lwpid_t lwpid
,
1325 /* NOTE: only used on Solaris, therefore OK to refer to procfs.c */
1326 extern struct ssd
*procfs_find_LDT_entry (int);
1329 /* FIXME: can't I get the process ID from the prochandle or something?
1332 if (inferior_pid
<= 0 || lwpid
<= 0)
1335 ret
= procfs_find_LDT_entry (BUILD_LWP (lwpid
, PIDGET (inferior_pid
)));
1338 memcpy (pldt
, ret
, sizeof (struct ssd
));
1341 else /* LDT not found. */
1344 #endif /* TM_I386SOL2_H */
1346 /* Convert a pid to printable form. */
1349 solaris_pid_to_str (pid
)
1352 static char buf
[100];
1354 /* in case init failed to resolve the libthread_db library */
1355 if (!procfs_suppress_run
)
1356 return procfs_pid_to_str (pid
);
1358 if (is_thread (pid
))
1362 lwp
= thread_to_lwp (pid
, -2);
1365 sprintf (buf
, "Thread %d (defunct)", GET_THREAD (pid
));
1367 sprintf (buf
, "Thread %d (LWP %d)", GET_THREAD (pid
), GET_LWP (lwp
));
1369 sprintf (buf
, "Thread %d ", GET_THREAD (pid
));
1371 else if (GET_LWP (pid
) != 0)
1372 sprintf (buf
, "LWP %d ", GET_LWP (pid
));
1374 sprintf (buf
, "process %d ", PIDGET (pid
));
1380 /* Worker bee for find_new_threads
1381 Callback function that gets called once per USER thread (i.e., not
1385 sol_find_new_threads_callback (th
, ignored
)
1386 const td_thrhandle_t
*th
;
1393 if ((retval
= p_td_thr_get_info (th
, &ti
)) != TD_OK
)
1397 pid
= BUILD_THREAD (ti
.ti_tid
, PIDGET (inferior_pid
));
1398 if (!in_thread_list (pid
))
1405 sol_find_new_threads ()
1407 /* don't do anything if init failed to resolve the libthread_db library */
1408 if (!procfs_suppress_run
)
1411 if (inferior_pid
== -1)
1413 printf_filtered ("No process.\n");
1416 procfs_find_new_threads (); /* first find new kernel threads. */
1417 p_td_ta_thr_iter (main_ta
, sol_find_new_threads_callback
, (void *) 0,
1418 TD_THR_ANY_STATE
, TD_THR_LOWEST_PRIORITY
,
1419 TD_SIGNO_MASK
, TD_THR_ANY_USER_FLAGS
);
1423 sol_core_open (filename
, from_tty
)
1427 orig_core_ops
.to_open (filename
, from_tty
);
1431 sol_core_close (quitting
)
1434 orig_core_ops
.to_close (quitting
);
1438 sol_core_detach (args
, from_tty
)
1442 unpush_target (&core_ops
);
1443 orig_core_ops
.to_detach (args
, from_tty
);
1447 sol_core_files_info (t
)
1448 struct target_ops
*t
;
1450 orig_core_ops
.to_files_info (t
);
1453 /* Worker bee for info sol-thread command. This is a callback function that
1454 gets called once for each Solaris thread (ie. not kernel thread) in the
1455 inferior. Print anything interesting that we can think of. */
1459 const td_thrhandle_t
*th
;
1465 if ((ret
= p_td_thr_get_info (th
, &ti
)) == TD_OK
)
1467 printf_filtered ("%s thread #%d, lwp %d, ",
1468 ti
.ti_type
== TD_THR_SYSTEM
? "system" : "user ",
1469 ti
.ti_tid
, ti
.ti_lid
);
1470 switch (ti
.ti_state
)
1473 case TD_THR_UNKNOWN
:
1474 printf_filtered ("<unknown state>");
1476 case TD_THR_STOPPED
:
1477 printf_filtered ("(stopped)");
1480 printf_filtered ("(run) ");
1483 printf_filtered ("(active) ");
1486 printf_filtered ("(zombie) ");
1489 printf_filtered ("(asleep) ");
1491 case TD_THR_STOPPED_ASLEEP
:
1492 printf_filtered ("(stopped asleep)");
1495 /* Print thr_create start function: */
1496 if (ti
.ti_startfunc
!= 0)
1498 struct minimal_symbol
*msym
;
1499 msym
= lookup_minimal_symbol_by_pc (ti
.ti_startfunc
);
1501 printf_filtered (" startfunc: %s\n", SYMBOL_NAME (msym
));
1503 printf_filtered (" startfunc: 0x%s\n", paddr (ti
.ti_startfunc
));
1506 /* If thread is asleep, print function that went to sleep: */
1507 if (ti
.ti_state
== TD_THR_SLEEP
)
1509 struct minimal_symbol
*msym
;
1510 msym
= lookup_minimal_symbol_by_pc (ti
.ti_pc
);
1512 printf_filtered (" - Sleep func: %s\n", SYMBOL_NAME (msym
));
1514 printf_filtered (" - Sleep func: 0x%s\n", paddr (ti
.ti_startfunc
));
1517 /* Wrap up line, if necessary */
1518 if (ti
.ti_state
!= TD_THR_SLEEP
&& ti
.ti_startfunc
== 0)
1519 printf_filtered ("\n"); /* don't you hate counting newlines? */
1522 warning ("info sol-thread: failed to get info for thread.");
1527 /* List some state about each Solaris user thread in the inferior. */
1530 info_solthreads (args
, from_tty
)
1534 p_td_ta_thr_iter (main_ta
, info_cb
, args
,
1535 TD_THR_ANY_STATE
, TD_THR_LOWEST_PRIORITY
,
1536 TD_SIGNO_MASK
, TD_THR_ANY_USER_FLAGS
);
1540 ignore (addr
, contents
)
1549 init_sol_thread_ops ()
1551 sol_thread_ops
.to_shortname
= "solaris-threads";
1552 sol_thread_ops
.to_longname
= "Solaris threads and pthread.";
1553 sol_thread_ops
.to_doc
= "Solaris threads and pthread support.";
1554 sol_thread_ops
.to_open
= sol_thread_open
;
1555 sol_thread_ops
.to_close
= 0;
1556 sol_thread_ops
.to_attach
= sol_thread_attach
;
1557 sol_thread_ops
.to_detach
= sol_thread_detach
;
1558 sol_thread_ops
.to_resume
= sol_thread_resume
;
1559 sol_thread_ops
.to_wait
= sol_thread_wait
;
1560 sol_thread_ops
.to_fetch_registers
= sol_thread_fetch_registers
;
1561 sol_thread_ops
.to_store_registers
= sol_thread_store_registers
;
1562 sol_thread_ops
.to_prepare_to_store
= sol_thread_prepare_to_store
;
1563 sol_thread_ops
.to_xfer_memory
= sol_thread_xfer_memory
;
1564 sol_thread_ops
.to_files_info
= sol_thread_files_info
;
1565 sol_thread_ops
.to_insert_breakpoint
= memory_insert_breakpoint
;
1566 sol_thread_ops
.to_remove_breakpoint
= memory_remove_breakpoint
;
1567 sol_thread_ops
.to_terminal_init
= terminal_init_inferior
;
1568 sol_thread_ops
.to_terminal_inferior
= terminal_inferior
;
1569 sol_thread_ops
.to_terminal_ours_for_output
= terminal_ours_for_output
;
1570 sol_thread_ops
.to_terminal_ours
= terminal_ours
;
1571 sol_thread_ops
.to_terminal_info
= child_terminal_info
;
1572 sol_thread_ops
.to_kill
= sol_thread_kill_inferior
;
1573 sol_thread_ops
.to_load
= 0;
1574 sol_thread_ops
.to_lookup_symbol
= 0;
1575 sol_thread_ops
.to_create_inferior
= sol_thread_create_inferior
;
1576 sol_thread_ops
.to_mourn_inferior
= sol_thread_mourn_inferior
;
1577 sol_thread_ops
.to_can_run
= sol_thread_can_run
;
1578 sol_thread_ops
.to_notice_signals
= sol_thread_notice_signals
;
1579 sol_thread_ops
.to_thread_alive
= sol_thread_alive
;
1580 sol_thread_ops
.to_pid_to_str
= solaris_pid_to_str
;
1581 sol_thread_ops
.to_find_new_threads
= sol_find_new_threads
;
1582 sol_thread_ops
.to_stop
= sol_thread_stop
;
1583 sol_thread_ops
.to_stratum
= process_stratum
;
1584 sol_thread_ops
.to_has_all_memory
= 1;
1585 sol_thread_ops
.to_has_memory
= 1;
1586 sol_thread_ops
.to_has_stack
= 1;
1587 sol_thread_ops
.to_has_registers
= 1;
1588 sol_thread_ops
.to_has_execution
= 1;
1589 sol_thread_ops
.to_has_thread_control
= tc_none
;
1590 sol_thread_ops
.to_sections
= 0;
1591 sol_thread_ops
.to_sections_end
= 0;
1592 sol_thread_ops
.to_magic
= OPS_MAGIC
;
1597 init_sol_core_ops ()
1599 sol_core_ops
.to_shortname
= "solaris-core";
1600 sol_core_ops
.to_longname
= "Solaris core threads and pthread.";
1601 sol_core_ops
.to_doc
= "Solaris threads and pthread support for core files.";
1602 sol_core_ops
.to_open
= sol_core_open
;
1603 sol_core_ops
.to_close
= sol_core_close
;
1604 sol_core_ops
.to_attach
= sol_thread_attach
;
1605 sol_core_ops
.to_detach
= sol_core_detach
;
1606 /* sol_core_ops.to_resume = 0; */
1607 /* sol_core_ops.to_wait = 0; */
1608 sol_core_ops
.to_fetch_registers
= sol_thread_fetch_registers
;
1609 /* sol_core_ops.to_store_registers = 0; */
1610 /* sol_core_ops.to_prepare_to_store = 0; */
1611 sol_core_ops
.to_xfer_memory
= sol_thread_xfer_memory
;
1612 sol_core_ops
.to_files_info
= sol_core_files_info
;
1613 sol_core_ops
.to_insert_breakpoint
= ignore
;
1614 sol_core_ops
.to_remove_breakpoint
= ignore
;
1615 /* sol_core_ops.to_terminal_init = 0; */
1616 /* sol_core_ops.to_terminal_inferior = 0; */
1617 /* sol_core_ops.to_terminal_ours_for_output = 0; */
1618 /* sol_core_ops.to_terminal_ours = 0; */
1619 /* sol_core_ops.to_terminal_info = 0; */
1620 /* sol_core_ops.to_kill = 0; */
1621 /* sol_core_ops.to_load = 0; */
1622 /* sol_core_ops.to_lookup_symbol = 0; */
1623 sol_core_ops
.to_create_inferior
= sol_thread_create_inferior
;
1624 sol_core_ops
.to_stratum
= core_stratum
;
1625 sol_core_ops
.to_has_all_memory
= 0;
1626 sol_core_ops
.to_has_memory
= 1;
1627 sol_core_ops
.to_has_stack
= 1;
1628 sol_core_ops
.to_has_registers
= 1;
1629 sol_core_ops
.to_has_execution
= 0;
1630 sol_core_ops
.to_has_thread_control
= tc_none
;
1631 sol_core_ops
.to_thread_alive
= sol_thread_alive
;
1632 sol_core_ops
.to_pid_to_str
= solaris_pid_to_str
;
1633 /* On Solaris/x86, when debugging a threaded core file from process <n>,
1634 the following causes "info threads" to produce "procfs: couldn't find pid
1635 <n> in procinfo list" where <n> is the pid of the process that produced
1636 the core file. Disable it for now. */
1637 /* sol_core_ops.to_find_new_threads = sol_find_new_threads; */
1638 sol_core_ops
.to_sections
= 0;
1639 sol_core_ops
.to_sections_end
= 0;
1640 sol_core_ops
.to_magic
= OPS_MAGIC
;
1643 /* we suppress the call to add_target of core_ops in corelow because
1644 if there are two targets in the stratum core_stratum, find_core_target
1645 won't know which one to return. see corelow.c for an additonal
1646 comment on coreops_suppress_target. */
1647 int coreops_suppress_target
= 1;
1650 _initialize_sol_thread ()
1654 init_sol_thread_ops ();
1655 init_sol_core_ops ();
1657 dlhandle
= dlopen ("libthread_db.so.1", RTLD_NOW
);
1661 #define resolve(X) \
1662 if (!(p_##X = dlsym (dlhandle, #X))) \
1666 resolve (td_ta_new
);
1667 resolve (td_ta_delete
);
1669 resolve (td_ta_get_ph
);
1670 resolve (td_ta_get_nthreads
);
1671 resolve (td_ta_tsd_iter
);
1672 resolve (td_ta_thr_iter
);
1673 resolve (td_thr_validate
);
1674 resolve (td_thr_tsd
);
1675 resolve (td_thr_get_info
);
1676 resolve (td_thr_getfpregs
);
1677 resolve (td_thr_getxregsize
);
1678 resolve (td_thr_getxregs
);
1679 resolve (td_thr_sigsetmask
);
1680 resolve (td_thr_setprio
);
1681 resolve (td_thr_setsigpending
);
1682 resolve (td_thr_setfpregs
);
1683 resolve (td_thr_setxregs
);
1684 resolve (td_ta_map_id2thr
);
1685 resolve (td_ta_map_lwp2thr
);
1686 resolve (td_thr_getgregs
);
1687 resolve (td_thr_setgregs
);
1689 add_target (&sol_thread_ops
);
1691 procfs_suppress_run
= 1;
1693 add_cmd ("sol-threads", class_maintenance
, info_solthreads
,
1694 "Show info on Solaris user threads.\n", &maintenanceinfolist
);
1696 memcpy (&orig_core_ops
, &core_ops
, sizeof (struct target_ops
));
1697 memcpy (&core_ops
, &sol_core_ops
, sizeof (struct target_ops
));
1698 add_target (&core_ops
);
1700 /* Hook into new_objfile notification. */
1701 target_new_objfile_chain
= target_new_objfile_hook
;
1702 target_new_objfile_hook
= sol_thread_new_objfile
;
1707 fprintf_unfiltered (gdb_stderr
, "[GDB will not be able to debug user-mode threads: %s]\n", dlerror ());
1712 /* allow the user to debug non-threaded core files */
1713 add_target (&core_ops
);