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 (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 (void);
98 static void restore_inferior_pid (void *pid
);
99 static char *td_err_string (td_err_e errcode
);
100 static char *td_state_string (td_thr_state_e statecode
);
101 static int thread_to_lwp (int thread_id
, int default_lwp
);
102 static void sol_thread_resume (int pid
, int step
, enum target_signal signo
);
103 static int lwp_to_thread (int lwp
);
104 static int sol_thread_alive (int pid
);
105 static void sol_core_close (int quitting
);
107 static void init_sol_thread_ops (void);
108 static void init_sol_core_ops (void);
110 /* Default definitions: These must be defined in tm.h
111 if they are to be shared with a process module such as procfs. */
113 #define THREAD_FLAG 0x80000000
114 #define is_thread(ARG) (((ARG) & THREAD_FLAG) != 0)
115 #define is_lwp(ARG) (((ARG) & THREAD_FLAG) == 0)
116 #define GET_LWP(PID) TIDGET (PID)
117 #define GET_THREAD(PID) TIDGET (PID)
118 #define BUILD_LWP(TID, PID) MERGEPID (PID, TID)
120 #define BUILD_THREAD(TID, PID) (MERGEPID (PID, TID) | THREAD_FLAG)
122 /* Pointers to routines from lithread_db resolved by dlopen() */
124 static void (*p_td_log
) (const int on_off
);
125 static td_err_e (*p_td_ta_new
) (const struct ps_prochandle
* ph_p
,
126 td_thragent_t
** ta_pp
);
127 static td_err_e (*p_td_ta_delete
) (td_thragent_t
* ta_p
);
128 static td_err_e (*p_td_init
) (void);
129 static td_err_e (*p_td_ta_get_ph
) (const td_thragent_t
* ta_p
,
130 struct ps_prochandle
** ph_pp
);
131 static td_err_e (*p_td_ta_get_nthreads
) (const td_thragent_t
* ta_p
,
133 static td_err_e (*p_td_ta_tsd_iter
) (const td_thragent_t
* ta_p
,
136 static td_err_e (*p_td_ta_thr_iter
) (const td_thragent_t
* ta_p
,
139 td_thr_state_e state
,
141 sigset_t
* ti_sigmask_p
,
142 unsigned ti_user_flags
);
143 static td_err_e (*p_td_thr_validate
) (const td_thrhandle_t
* th_p
);
144 static td_err_e (*p_td_thr_tsd
) (const td_thrhandle_t
* th_p
,
145 const thread_key_t key
,
147 static td_err_e (*p_td_thr_get_info
) (const td_thrhandle_t
* th_p
,
148 td_thrinfo_t
* ti_p
);
149 static td_err_e (*p_td_thr_getfpregs
) (const td_thrhandle_t
* th_p
,
150 prfpregset_t
* fpregset
);
151 static td_err_e (*p_td_thr_getxregsize
) (const td_thrhandle_t
* th_p
,
153 static td_err_e (*p_td_thr_getxregs
) (const td_thrhandle_t
* th_p
,
154 const caddr_t xregset
);
155 static td_err_e (*p_td_thr_sigsetmask
) (const td_thrhandle_t
* th_p
,
156 const sigset_t ti_sigmask
);
157 static td_err_e (*p_td_thr_setprio
) (const td_thrhandle_t
* th_p
,
159 static td_err_e (*p_td_thr_setsigpending
) (const td_thrhandle_t
* th_p
,
160 const uchar_t ti_pending_flag
,
161 const sigset_t ti_pending
);
162 static td_err_e (*p_td_thr_setfpregs
) (const td_thrhandle_t
* th_p
,
163 const prfpregset_t
* fpregset
);
164 static td_err_e (*p_td_thr_setxregs
) (const td_thrhandle_t
* th_p
,
165 const caddr_t xregset
);
166 static td_err_e (*p_td_ta_map_id2thr
) (const td_thragent_t
* ta_p
,
168 td_thrhandle_t
* th_p
);
169 static td_err_e (*p_td_ta_map_lwp2thr
) (const td_thragent_t
* ta_p
,
171 td_thrhandle_t
* th_p
);
172 static td_err_e (*p_td_thr_getgregs
) (const td_thrhandle_t
* th_p
,
174 static td_err_e (*p_td_thr_setgregs
) (const td_thrhandle_t
* th_p
,
175 const prgregset_t regset
);
181 td_err_string - Convert a thread_db error code to a string
185 char * td_err_string (errcode)
189 Return the thread_db error string associated with errcode. If errcode
190 is unknown, then return a message.
195 td_err_string (td_err_e errcode
)
197 static struct string_map
200 {TD_OK
, "generic \"call succeeded\""},
201 {TD_ERR
, "generic error."},
202 {TD_NOTHR
, "no thread can be found to satisfy query"},
203 {TD_NOSV
, "no synch. variable can be found to satisfy query"},
204 {TD_NOLWP
, "no lwp can be found to satisfy query"},
205 {TD_BADPH
, "invalid process handle"},
206 {TD_BADTH
, "invalid thread handle"},
207 {TD_BADSH
, "invalid synchronization handle"},
208 {TD_BADTA
, "invalid thread agent"},
209 {TD_BADKEY
, "invalid key"},
210 {TD_NOMSG
, "td_thr_event_getmsg() called when there was no message"},
211 {TD_NOFPREGS
, "FPU register set not available for given thread"},
212 {TD_NOLIBTHREAD
, "application not linked with libthread"},
213 {TD_NOEVENT
, "requested event is not supported"},
214 {TD_NOCAPAB
, "capability not available"},
215 {TD_DBERR
, "Debugger service failed"},
216 {TD_NOAPLIC
, "Operation not applicable to"},
217 {TD_NOTSD
, "No thread specific data for this thread"},
218 {TD_MALLOC
, "Malloc failed"},
219 {TD_PARTIALREG
, "Only part of register set was writen/read"},
220 {TD_NOXREGS
, "X register set not available for given thread"}
222 const int td_err_size
= sizeof td_err_table
/ sizeof (struct string_map
);
226 for (i
= 0; i
< td_err_size
; i
++)
227 if (td_err_table
[i
].num
== errcode
)
228 return td_err_table
[i
].str
;
230 sprintf (buf
, "Unknown thread_db error code: %d", errcode
);
239 td_state_string - Convert a thread_db state code to a string
243 char * td_state_string (statecode)
247 Return the thread_db state string associated with statecode. If
248 statecode is unknown, then return a message.
253 td_state_string (td_thr_state_e statecode
)
255 static struct string_map
256 td_thr_state_table
[] =
258 {TD_THR_ANY_STATE
, "any state"},
259 {TD_THR_UNKNOWN
, "unknown"},
260 {TD_THR_STOPPED
, "stopped"},
262 {TD_THR_ACTIVE
, "active"},
263 {TD_THR_ZOMBIE
, "zombie"},
264 {TD_THR_SLEEP
, "sleep"},
265 {TD_THR_STOPPED_ASLEEP
, "stopped asleep"}
267 const int td_thr_state_table_size
= sizeof td_thr_state_table
/ sizeof (struct string_map
);
271 for (i
= 0; i
< td_thr_state_table_size
; i
++)
272 if (td_thr_state_table
[i
].num
== statecode
)
273 return td_thr_state_table
[i
].str
;
275 sprintf (buf
, "Unknown thread_db state code: %d", statecode
);
284 thread_to_lwp - Convert a Posix or Solaris thread id to a LWP id.
288 int thread_to_lwp (thread_id, default_lwp)
292 This function converts a Posix or Solaris thread id to a lightweight
293 process id. If thread_id is non-existent, that's an error. If it's
294 an inactive thread, then we return default_lwp.
298 This function probably shouldn't call error()...
303 thread_to_lwp (int thread_id
, int default_lwp
)
309 if (is_lwp (thread_id
))
310 return thread_id
; /* It's already an LWP id */
312 /* It's a thread. Convert to lwp */
314 val
= p_td_ta_map_id2thr (main_ta
, GET_THREAD (thread_id
), &th
);
316 return -1; /* thread must have terminated */
317 else if (val
!= TD_OK
)
318 error ("thread_to_lwp: td_ta_map_id2thr %s", td_err_string (val
));
320 val
= p_td_thr_get_info (&th
, &ti
);
322 return -1; /* thread must have terminated */
323 else if (val
!= TD_OK
)
324 error ("thread_to_lwp: td_thr_get_info: %s", td_err_string (val
));
326 if (ti
.ti_state
!= TD_THR_ACTIVE
)
328 if (default_lwp
!= -1)
330 error ("thread_to_lwp: thread state not active: %s",
331 td_state_string (ti
.ti_state
));
334 return BUILD_LWP (ti
.ti_lid
, PIDGET (thread_id
));
341 lwp_to_thread - Convert a LWP id to a Posix or Solaris thread id.
345 int lwp_to_thread (lwp_id)
349 This function converts a lightweight process id to a Posix or Solaris
350 thread id. If thread_id is non-existent, that's an error.
354 This function probably shouldn't call error()...
359 lwp_to_thread (int lwp
)
366 return lwp
; /* It's already a thread id */
368 /* It's an lwp. Convert it to a thread id. */
370 if (!sol_thread_alive (lwp
))
371 return -1; /* defunct lwp */
373 val
= p_td_ta_map_lwp2thr (main_ta
, GET_LWP (lwp
), &th
);
375 return -1; /* thread must have terminated */
376 else if (val
!= TD_OK
)
377 error ("lwp_to_thread: td_ta_map_lwp2thr: %s.", td_err_string (val
));
379 val
= p_td_thr_validate (&th
);
381 return lwp
; /* libthread doesn't know about it;
383 else if (val
!= TD_OK
)
384 error ("lwp_to_thread: td_thr_validate: %s.", td_err_string (val
));
386 val
= p_td_thr_get_info (&th
, &ti
);
388 return -1; /* thread must have terminated */
389 else if (val
!= TD_OK
)
390 error ("lwp_to_thread: td_thr_get_info: %s.", td_err_string (val
));
392 return BUILD_THREAD (ti
.ti_tid
, PIDGET (lwp
));
399 save_inferior_pid - Save inferior_pid on the cleanup list
400 restore_inferior_pid - Restore inferior_pid from the cleanup list
404 struct cleanup *save_inferior_pid ()
405 void restore_inferior_pid (int pid)
409 These two functions act in unison to restore inferior_pid in
414 inferior_pid is a global variable that needs to be changed by many of
415 these routines before calling functions in procfs.c. In order to
416 guarantee that inferior_pid gets restored (in case of errors), you
417 need to call save_inferior_pid before changing it. At the end of the
418 function, you should invoke do_cleanups to restore it.
423 static struct cleanup
*
424 save_inferior_pid (void)
426 return make_cleanup (restore_inferior_pid
, (void *) inferior_pid
);
430 restore_inferior_pid (void *pid
)
432 inferior_pid
= (int) pid
;
436 /* Most target vector functions from here on actually just pass through to
437 procfs.c, as they don't need to do anything specific for threads. */
442 sol_thread_open (char *arg
, int from_tty
)
444 procfs_ops
.to_open (arg
, from_tty
);
447 /* Attach to process PID, then initialize for debugging it
448 and wait for the trace-trap that results from attaching. */
451 sol_thread_attach (char *args
, int from_tty
)
453 procfs_ops
.to_attach (args
, from_tty
);
454 /* Must get symbols from solibs before libthread_db can run! */
455 SOLIB_ADD ((char *) 0, from_tty
, (struct target_ops
*) 0);
456 if (sol_thread_active
)
458 printf_filtered ("sol-thread active.\n");
459 main_ph
.pid
= inferior_pid
; /* Save for xfer_memory */
460 push_target (&sol_thread_ops
);
461 inferior_pid
= lwp_to_thread (inferior_pid
);
462 if (inferior_pid
== -1)
463 inferior_pid
= main_ph
.pid
;
465 add_thread (inferior_pid
);
467 /* XXX - might want to iterate over all the threads and register them. */
470 /* Take a program previously attached to and detaches it.
471 The program resumes execution and will no longer stop
472 on signals, etc. We'd better not have left any breakpoints
473 in the program or it'll die when it hits one. For this
474 to work, it may be necessary for the process to have been
475 previously attached. It *might* work if the program was
476 started via the normal ptrace (PTRACE_TRACEME). */
479 sol_thread_detach (char *args
, int from_tty
)
481 inferior_pid
= PIDGET (main_ph
.pid
);
482 unpush_target (&sol_thread_ops
);
483 procfs_ops
.to_detach (args
, from_tty
);
486 /* Resume execution of process PID. If STEP is nozero, then
487 just single step it. If SIGNAL is nonzero, restart it with that
488 signal activated. We may have to convert pid from a thread-id to an LWP id
492 sol_thread_resume (int pid
, int step
, enum target_signal signo
)
494 struct cleanup
*old_chain
;
496 old_chain
= save_inferior_pid ();
498 inferior_pid
= thread_to_lwp (inferior_pid
, main_ph
.pid
);
499 if (inferior_pid
== -1)
500 inferior_pid
= procfs_first_available ();
506 pid
= thread_to_lwp (pid
, -2);
507 if (pid
== -2) /* Inactive thread */
508 error ("This version of Solaris can't start inactive threads.");
509 if (info_verbose
&& pid
== -1)
510 warning ("Specified thread %d seems to have terminated",
511 GET_THREAD (save_pid
));
514 procfs_ops
.to_resume (pid
, step
, signo
);
516 do_cleanups (old_chain
);
519 /* Wait for any threads to stop. We may have to convert PID from a thread id
520 to a LWP id, and vice versa on the way out. */
523 sol_thread_wait (int pid
, struct target_waitstatus
*ourstatus
)
527 struct cleanup
*old_chain
;
529 save_pid
= inferior_pid
;
530 old_chain
= save_inferior_pid ();
532 inferior_pid
= thread_to_lwp (inferior_pid
, main_ph
.pid
);
533 if (inferior_pid
== -1)
534 inferior_pid
= procfs_first_available ();
540 pid
= thread_to_lwp (pid
, -2);
541 if (pid
== -2) /* Inactive thread */
542 error ("This version of Solaris can't start inactive threads.");
543 if (info_verbose
&& pid
== -1)
544 warning ("Specified thread %d seems to have terminated",
545 GET_THREAD (save_pid
));
548 rtnval
= procfs_ops
.to_wait (pid
, ourstatus
);
550 if (ourstatus
->kind
!= TARGET_WAITKIND_EXITED
)
552 /* Map the LWP of interest back to the appropriate thread ID */
553 rtnval
= lwp_to_thread (rtnval
);
557 /* See if we have a new thread */
558 if (is_thread (rtnval
)
559 && rtnval
!= save_pid
560 && !in_thread_list (rtnval
))
562 printf_filtered ("[New %s]\n", target_pid_to_str (rtnval
));
567 /* During process initialization, we may get here without the thread package
568 being initialized, since that can only happen after we've found the shared
571 do_cleanups (old_chain
);
577 sol_thread_fetch_registers (int regno
)
580 td_thrhandle_t thandle
;
583 prfpregset_t fpregset
;
589 if (!is_thread (inferior_pid
))
590 { /* LWP: pass the request on to procfs.c */
591 if (target_has_execution
)
592 procfs_ops
.to_fetch_registers (regno
);
594 orig_core_ops
.to_fetch_registers (regno
);
598 /* Solaris thread: convert inferior_pid into a td_thrhandle_t */
600 thread
= GET_THREAD (inferior_pid
);
603 error ("sol_thread_fetch_registers: thread == 0");
605 val
= p_td_ta_map_id2thr (main_ta
, thread
, &thandle
);
607 error ("sol_thread_fetch_registers: td_ta_map_id2thr: %s",
608 td_err_string (val
));
610 /* Get the integer regs */
612 val
= p_td_thr_getgregs (&thandle
, gregset
);
614 && val
!= TD_PARTIALREG
)
615 error ("sol_thread_fetch_registers: td_thr_getgregs %s",
616 td_err_string (val
));
618 /* For the sparc, TD_PARTIALREG means that only i0->i7, l0->l7, pc and sp
619 are saved (by a thread context switch). */
621 /* And, now the fp regs */
623 val
= p_td_thr_getfpregs (&thandle
, &fpregset
);
625 && val
!= TD_NOFPREGS
)
626 error ("sol_thread_fetch_registers: td_thr_getfpregs %s",
627 td_err_string (val
));
629 /* Note that we must call supply_{g fp}regset *after* calling the td routines
630 because the td routines call ps_lget* which affect the values stored in the
633 supply_gregset ((gdb_gregset_t
*) &gregset
);
634 supply_fpregset ((gdb_fpregset_t
*) &fpregset
);
637 /* thread_db doesn't seem to handle this right */
638 val
= td_thr_getxregsize (&thandle
, &xregsize
);
639 if (val
!= TD_OK
&& val
!= TD_NOXREGS
)
640 error ("sol_thread_fetch_registers: td_thr_getxregsize %s",
641 td_err_string (val
));
645 xregset
= alloca (xregsize
);
646 val
= td_thr_getxregs (&thandle
, xregset
);
648 error ("sol_thread_fetch_registers: td_thr_getxregs %s",
649 td_err_string (val
));
655 sol_thread_store_registers (int regno
)
658 td_thrhandle_t thandle
;
661 prfpregset_t fpregset
;
667 if (!is_thread (inferior_pid
))
668 { /* LWP: pass the request on to procfs.c */
669 procfs_ops
.to_store_registers (regno
);
673 /* Solaris thread: convert inferior_pid into a td_thrhandle_t */
675 thread
= GET_THREAD (inferior_pid
);
677 val
= p_td_ta_map_id2thr (main_ta
, thread
, &thandle
);
679 error ("sol_thread_store_registers: td_ta_map_id2thr %s",
680 td_err_string (val
));
683 { /* Not writing all the regs */
684 /* save new register value */
685 char old_value
[REGISTER_SIZE
];
686 memcpy (old_value
, ®isters
[REGISTER_BYTE (regno
)], REGISTER_SIZE
);
688 val
= p_td_thr_getgregs (&thandle
, gregset
);
690 error ("sol_thread_store_registers: td_thr_getgregs %s",
691 td_err_string (val
));
692 val
= p_td_thr_getfpregs (&thandle
, &fpregset
);
694 error ("sol_thread_store_registers: td_thr_getfpregs %s",
695 td_err_string (val
));
697 /* restore new register value */
698 memcpy (®isters
[REGISTER_BYTE (regno
)], old_value
, REGISTER_SIZE
);
701 /* thread_db doesn't seem to handle this right */
702 val
= td_thr_getxregsize (&thandle
, &xregsize
);
703 if (val
!= TD_OK
&& val
!= TD_NOXREGS
)
704 error ("sol_thread_store_registers: td_thr_getxregsize %s",
705 td_err_string (val
));
709 xregset
= alloca (xregsize
);
710 val
= td_thr_getxregs (&thandle
, xregset
);
712 error ("sol_thread_store_registers: td_thr_getxregs %s",
713 td_err_string (val
));
718 fill_gregset ((gdb_gregset_t
*) &gregset
, regno
);
719 fill_fpregset ((gdb_fpregset_t
*) &fpregset
, regno
);
721 val
= p_td_thr_setgregs (&thandle
, gregset
);
723 error ("sol_thread_store_registers: td_thr_setgregs %s",
724 td_err_string (val
));
725 val
= p_td_thr_setfpregs (&thandle
, &fpregset
);
727 error ("sol_thread_store_registers: td_thr_setfpregs %s",
728 td_err_string (val
));
731 /* thread_db doesn't seem to handle this right */
732 val
= td_thr_getxregsize (&thandle
, &xregsize
);
733 if (val
!= TD_OK
&& val
!= TD_NOXREGS
)
734 error ("sol_thread_store_registers: td_thr_getxregsize %s",
735 td_err_string (val
));
737 /* Should probably do something about writing the xregs here, but what are
742 /* Get ready to modify the registers array. On machines which store
743 individual registers, this doesn't need to do anything. On machines
744 which store all the registers in one fell swoop, this makes sure
745 that registers contains all the registers from the program being
749 sol_thread_prepare_to_store (void)
751 procfs_ops
.to_prepare_to_store ();
755 sol_thread_xfer_memory (memaddr
, myaddr
, len
, dowrite
, target
)
760 struct target_ops
*target
; /* ignored */
763 struct cleanup
*old_chain
;
765 old_chain
= save_inferior_pid ();
767 if (is_thread (inferior_pid
) || /* A thread */
768 !target_thread_alive (inferior_pid
)) /* An lwp, but not alive */
769 inferior_pid
= procfs_first_available (); /* Find any live lwp. */
770 /* Note: don't need to call switch_to_thread; we're just reading memory. */
772 if (target_has_execution
)
773 retval
= procfs_ops
.to_xfer_memory (memaddr
, myaddr
, len
, dowrite
, target
);
775 retval
= orig_core_ops
.to_xfer_memory (memaddr
, myaddr
, len
,
778 do_cleanups (old_chain
);
783 /* Print status information about what we're accessing. */
786 sol_thread_files_info (struct target_ops
*ignore
)
788 procfs_ops
.to_files_info (ignore
);
792 sol_thread_kill_inferior (void)
794 procfs_ops
.to_kill ();
798 sol_thread_notice_signals (int pid
)
800 procfs_ops
.to_notice_signals (PIDGET (pid
));
803 /* Fork an inferior process, and start debugging it with /proc. */
806 sol_thread_create_inferior (char *exec_file
, char *allargs
, char **env
)
808 procfs_ops
.to_create_inferior (exec_file
, allargs
, env
);
810 if (sol_thread_active
&& inferior_pid
!= 0)
812 main_ph
.pid
= inferior_pid
; /* Save for xfer_memory */
814 push_target (&sol_thread_ops
);
816 inferior_pid
= lwp_to_thread (inferior_pid
);
817 if (inferior_pid
== -1)
818 inferior_pid
= main_ph
.pid
;
820 if (!in_thread_list (inferior_pid
))
821 add_thread (inferior_pid
);
825 /* This routine is called whenever a new symbol table is read in, or when all
826 symbol tables are removed. libthread_db can only be initialized when it
827 finds the right variables in libthread.so. Since it's a shared library,
828 those variables don't show up until the library gets mapped and the symbol
831 /* This new_objfile event is now managed by a chained function pointer.
832 * It is the callee's responsability to call the next client on the chain.
835 /* Saved pointer to previous owner of the new_objfile event. */
836 static void (*target_new_objfile_chain
) (struct objfile
*);
839 sol_thread_new_objfile (struct objfile
*objfile
)
845 sol_thread_active
= 0;
849 /* don't do anything if init failed to resolve the libthread_db library */
850 if (!procfs_suppress_run
)
853 /* Now, initialize the thread debugging library. This needs to be done after
854 the shared libraries are located because it needs information from the
855 user's thread library. */
860 warning ("sol_thread_new_objfile: td_init: %s", td_err_string (val
));
864 val
= p_td_ta_new (&main_ph
, &main_ta
);
865 if (val
== TD_NOLIBTHREAD
)
867 else if (val
!= TD_OK
)
869 warning ("sol_thread_new_objfile: td_ta_new: %s", td_err_string (val
));
873 sol_thread_active
= 1;
875 /* Call predecessor on chain, if any. */
876 if (target_new_objfile_chain
)
877 target_new_objfile_chain (objfile
);
880 /* Clean up after the inferior dies. */
883 sol_thread_mourn_inferior (void)
885 unpush_target (&sol_thread_ops
);
886 procfs_ops
.to_mourn_inferior ();
889 /* Mark our target-struct as eligible for stray "run" and "attach" commands. */
892 sol_thread_can_run (void)
894 return procfs_suppress_run
;
901 sol_thread_alive - test thread for "aliveness"
905 static bool sol_thread_alive (int pid);
909 returns true if thread still active in inferior.
914 sol_thread_alive (int pid
)
916 if (is_thread (pid
)) /* non-kernel thread */
921 pid
= GET_THREAD (pid
);
922 if ((val
= p_td_ta_map_id2thr (main_ta
, pid
, &th
)) != TD_OK
)
923 return 0; /* thread not found */
924 if ((val
= p_td_thr_validate (&th
)) != TD_OK
)
925 return 0; /* thread not valid */
926 return 1; /* known thread: return true */
929 /* kernel thread (LWP): let procfs test it */
931 if (target_has_execution
)
932 return procfs_ops
.to_thread_alive (pid
);
934 return orig_core_ops
.to_thread_alive (pid
);
939 sol_thread_stop (void)
941 procfs_ops
.to_stop ();
944 /* These routines implement the lower half of the thread_db interface. Ie: the
947 /* Various versions of <proc_service.h> have slightly
948 different function prototypes. In particular, we have
951 struct ps_prochandle * const struct ps_prochandle *
956 Which one you have depends on solaris version and what
957 patches you've applied. On the theory that there are
958 only two major variants, we have configure check the
959 prototype of ps_pdwrite (), and use that info to make
960 appropriate typedefs here. */
962 #ifdef PROC_SERVICE_IS_OLD
963 typedef const struct ps_prochandle
*gdb_ps_prochandle_t
;
964 typedef char *gdb_ps_read_buf_t
;
965 typedef char *gdb_ps_write_buf_t
;
966 typedef int gdb_ps_size_t
;
967 typedef paddr_t gdb_ps_addr_t
;
969 typedef struct ps_prochandle
*gdb_ps_prochandle_t
;
970 typedef void *gdb_ps_read_buf_t
;
971 typedef const void *gdb_ps_write_buf_t
;
972 typedef size_t gdb_ps_size_t
;
973 typedef psaddr_t gdb_ps_addr_t
;
977 /* The next four routines are called by thread_db to tell us to stop and stop
978 a particular process or lwp. Since GDB ensures that these are all stopped
979 by the time we call anything in thread_db, these routines need to do
985 ps_pstop (gdb_ps_prochandle_t ph
)
990 /* Process continue */
993 ps_pcontinue (gdb_ps_prochandle_t ph
)
1001 ps_lstop (gdb_ps_prochandle_t ph
, lwpid_t lwpid
)
1009 ps_lcontinue (gdb_ps_prochandle_t ph
, lwpid_t lwpid
)
1014 /* Looks up the symbol LD_SYMBOL_NAME in the debugger's symbol table. */
1017 ps_pglobal_lookup (gdb_ps_prochandle_t ph
, const char *ld_object_name
,
1018 const char *ld_symbol_name
, gdb_ps_addr_t
* ld_symbol_addr
)
1020 struct minimal_symbol
*ms
;
1022 ms
= lookup_minimal_symbol (ld_symbol_name
, NULL
, NULL
);
1027 *ld_symbol_addr
= SYMBOL_VALUE_ADDRESS (ms
);
1032 /* Common routine for reading and writing memory. */
1035 rw_common (int dowrite
, const struct ps_prochandle
*ph
, gdb_ps_addr_t addr
,
1036 char *buf
, int size
)
1038 struct cleanup
*old_chain
;
1040 old_chain
= save_inferior_pid ();
1042 if (is_thread (inferior_pid
) || /* A thread */
1043 !target_thread_alive (inferior_pid
)) /* An lwp, but not alive */
1044 inferior_pid
= procfs_first_available (); /* Find any live lwp. */
1045 /* Note: don't need to call switch_to_thread; we're just reading memory. */
1051 if (target_has_execution
)
1052 cc
= procfs_ops
.to_xfer_memory (addr
, buf
, size
, dowrite
, &procfs_ops
);
1054 cc
= orig_core_ops
.to_xfer_memory (addr
, buf
, size
, dowrite
, &core_ops
);
1059 print_sys_errmsg ("rw_common (): read", errno
);
1061 print_sys_errmsg ("rw_common (): write", errno
);
1063 do_cleanups (old_chain
);
1070 warning ("rw_common (): unable to read at addr 0x%lx",
1073 warning ("rw_common (): unable to write at addr 0x%lx",
1076 do_cleanups (old_chain
);
1085 do_cleanups (old_chain
);
1090 /* Copies SIZE bytes from target process .data segment to debugger memory. */
1093 ps_pdread (gdb_ps_prochandle_t ph
, gdb_ps_addr_t addr
,
1094 gdb_ps_read_buf_t buf
, gdb_ps_size_t size
)
1096 return rw_common (0, ph
, addr
, buf
, size
);
1099 /* Copies SIZE bytes from debugger memory .data segment to target process. */
1102 ps_pdwrite (gdb_ps_prochandle_t ph
, gdb_ps_addr_t addr
,
1103 gdb_ps_write_buf_t buf
, gdb_ps_size_t size
)
1105 return rw_common (1, ph
, addr
, (char *) buf
, size
);
1108 /* Copies SIZE bytes from target process .text segment to debugger memory. */
1111 ps_ptread (gdb_ps_prochandle_t ph
, gdb_ps_addr_t addr
,
1112 gdb_ps_read_buf_t buf
, gdb_ps_size_t size
)
1114 return rw_common (0, ph
, addr
, buf
, size
);
1117 /* Copies SIZE bytes from debugger memory .text segment to target process. */
1120 ps_ptwrite (gdb_ps_prochandle_t ph
, gdb_ps_addr_t addr
,
1121 gdb_ps_write_buf_t buf
, gdb_ps_size_t size
)
1123 return rw_common (1, ph
, addr
, (char *) buf
, size
);
1126 /* Get integer regs for LWP */
1129 ps_lgetregs (gdb_ps_prochandle_t ph
, lwpid_t lwpid
,
1130 prgregset_t gregset
)
1132 struct cleanup
*old_chain
;
1134 old_chain
= save_inferior_pid ();
1136 inferior_pid
= BUILD_LWP (lwpid
, PIDGET (inferior_pid
));
1138 if (target_has_execution
)
1139 procfs_ops
.to_fetch_registers (-1);
1141 orig_core_ops
.to_fetch_registers (-1);
1142 fill_gregset ((gdb_gregset_t
*) gregset
, -1);
1144 do_cleanups (old_chain
);
1149 /* Set integer regs for LWP */
1152 ps_lsetregs (gdb_ps_prochandle_t ph
, lwpid_t lwpid
,
1153 const prgregset_t gregset
)
1155 struct cleanup
*old_chain
;
1157 old_chain
= save_inferior_pid ();
1159 inferior_pid
= BUILD_LWP (lwpid
, PIDGET (inferior_pid
));
1161 supply_gregset ((gdb_gregset_t
*) gregset
);
1162 if (target_has_execution
)
1163 procfs_ops
.to_store_registers (-1);
1165 orig_core_ops
.to_store_registers (-1);
1167 do_cleanups (old_chain
);
1172 /* Log a message (sends to gdb_stderr). */
1175 ps_plog (const char *fmt
,...)
1179 va_start (args
, fmt
);
1181 vfprintf_filtered (gdb_stderr
, fmt
, args
);
1184 /* Get size of extra register set. Currently a noop. */
1187 ps_lgetxregsize (gdb_ps_prochandle_t ph
, lwpid_t lwpid
, int *xregsize
)
1194 val
= get_lwp_fd (ph
, lwpid
, &lwp_fd
);
1198 if (ioctl (lwp_fd
, PIOCGXREGSIZE
, ®size
))
1200 if (errno
== EINVAL
)
1201 return PS_NOFREGS
; /* XXX Wrong code, but this is the closest
1202 thing in proc_service.h */
1204 print_sys_errmsg ("ps_lgetxregsize (): PIOCGXREGSIZE", errno
);
1212 /* Get extra register set. Currently a noop. */
1215 ps_lgetxregs (gdb_ps_prochandle_t ph
, lwpid_t lwpid
, caddr_t xregset
)
1221 val
= get_lwp_fd (ph
, lwpid
, &lwp_fd
);
1225 if (ioctl (lwp_fd
, PIOCGXREG
, xregset
))
1227 print_sys_errmsg ("ps_lgetxregs (): PIOCGXREG", errno
);
1235 /* Set extra register set. Currently a noop. */
1238 ps_lsetxregs (gdb_ps_prochandle_t ph
, lwpid_t lwpid
, caddr_t xregset
)
1244 val
= get_lwp_fd (ph
, lwpid
, &lwp_fd
);
1248 if (ioctl (lwp_fd
, PIOCSXREG
, xregset
))
1250 print_sys_errmsg ("ps_lsetxregs (): PIOCSXREG", errno
);
1258 /* Get floating-point regs for LWP */
1261 ps_lgetfpregs (gdb_ps_prochandle_t ph
, lwpid_t lwpid
,
1262 prfpregset_t
* fpregset
)
1264 struct cleanup
*old_chain
;
1266 old_chain
= save_inferior_pid ();
1268 inferior_pid
= BUILD_LWP (lwpid
, PIDGET (inferior_pid
));
1270 if (target_has_execution
)
1271 procfs_ops
.to_fetch_registers (-1);
1273 orig_core_ops
.to_fetch_registers (-1);
1274 fill_fpregset ((gdb_fpregset_t
*) fpregset
, -1);
1276 do_cleanups (old_chain
);
1281 /* Set floating-point regs for LWP */
1284 ps_lsetfpregs (gdb_ps_prochandle_t ph
, lwpid_t lwpid
,
1285 const prfpregset_t
* fpregset
)
1287 struct cleanup
*old_chain
;
1289 old_chain
= save_inferior_pid ();
1291 inferior_pid
= BUILD_LWP (lwpid
, PIDGET (inferior_pid
));
1293 supply_fpregset ((gdb_fpregset_t
*) fpregset
);
1294 if (target_has_execution
)
1295 procfs_ops
.to_store_registers (-1);
1297 orig_core_ops
.to_store_registers (-1);
1299 do_cleanups (old_chain
);
1304 #ifdef TM_I386SOL2_H
1306 /* Reads the local descriptor table of a LWP. */
1309 ps_lgetLDT (gdb_ps_prochandle_t ph
, lwpid_t lwpid
,
1312 /* NOTE: only used on Solaris, therefore OK to refer to procfs.c */
1313 extern struct ssd
*procfs_find_LDT_entry (int);
1316 /* FIXME: can't I get the process ID from the prochandle or something?
1319 if (inferior_pid
<= 0 || lwpid
<= 0)
1322 ret
= procfs_find_LDT_entry (BUILD_LWP (lwpid
, PIDGET (inferior_pid
)));
1325 memcpy (pldt
, ret
, sizeof (struct ssd
));
1328 else /* LDT not found. */
1331 #endif /* TM_I386SOL2_H */
1333 /* Convert a pid to printable form. */
1336 solaris_pid_to_str (int pid
)
1338 static char buf
[100];
1340 /* in case init failed to resolve the libthread_db library */
1341 if (!procfs_suppress_run
)
1342 return procfs_pid_to_str (pid
);
1344 if (is_thread (pid
))
1348 lwp
= thread_to_lwp (pid
, -2);
1351 sprintf (buf
, "Thread %d (defunct)", GET_THREAD (pid
));
1353 sprintf (buf
, "Thread %d (LWP %d)", GET_THREAD (pid
), GET_LWP (lwp
));
1355 sprintf (buf
, "Thread %d ", GET_THREAD (pid
));
1357 else if (GET_LWP (pid
) != 0)
1358 sprintf (buf
, "LWP %d ", GET_LWP (pid
));
1360 sprintf (buf
, "process %d ", PIDGET (pid
));
1366 /* Worker bee for find_new_threads
1367 Callback function that gets called once per USER thread (i.e., not
1371 sol_find_new_threads_callback (const td_thrhandle_t
*th
, void *ignored
)
1377 if ((retval
= p_td_thr_get_info (th
, &ti
)) != TD_OK
)
1381 pid
= BUILD_THREAD (ti
.ti_tid
, PIDGET (inferior_pid
));
1382 if (!in_thread_list (pid
))
1389 sol_find_new_threads (void)
1391 /* don't do anything if init failed to resolve the libthread_db library */
1392 if (!procfs_suppress_run
)
1395 if (inferior_pid
== -1)
1397 printf_filtered ("No process.\n");
1400 procfs_find_new_threads (); /* first find new kernel threads. */
1401 p_td_ta_thr_iter (main_ta
, sol_find_new_threads_callback
, (void *) 0,
1402 TD_THR_ANY_STATE
, TD_THR_LOWEST_PRIORITY
,
1403 TD_SIGNO_MASK
, TD_THR_ANY_USER_FLAGS
);
1407 sol_core_open (char *filename
, int from_tty
)
1409 orig_core_ops
.to_open (filename
, from_tty
);
1413 sol_core_close (int quitting
)
1415 orig_core_ops
.to_close (quitting
);
1419 sol_core_detach (char *args
, int from_tty
)
1421 unpush_target (&core_ops
);
1422 orig_core_ops
.to_detach (args
, from_tty
);
1426 sol_core_files_info (struct target_ops
*t
)
1428 orig_core_ops
.to_files_info (t
);
1431 /* Worker bee for info sol-thread command. This is a callback function that
1432 gets called once for each Solaris thread (ie. not kernel thread) in the
1433 inferior. Print anything interesting that we can think of. */
1436 info_cb (const td_thrhandle_t
*th
, void *s
)
1441 if ((ret
= p_td_thr_get_info (th
, &ti
)) == TD_OK
)
1443 printf_filtered ("%s thread #%d, lwp %d, ",
1444 ti
.ti_type
== TD_THR_SYSTEM
? "system" : "user ",
1445 ti
.ti_tid
, ti
.ti_lid
);
1446 switch (ti
.ti_state
)
1449 case TD_THR_UNKNOWN
:
1450 printf_filtered ("<unknown state>");
1452 case TD_THR_STOPPED
:
1453 printf_filtered ("(stopped)");
1456 printf_filtered ("(run) ");
1459 printf_filtered ("(active) ");
1462 printf_filtered ("(zombie) ");
1465 printf_filtered ("(asleep) ");
1467 case TD_THR_STOPPED_ASLEEP
:
1468 printf_filtered ("(stopped asleep)");
1471 /* Print thr_create start function: */
1472 if (ti
.ti_startfunc
!= 0)
1474 struct minimal_symbol
*msym
;
1475 msym
= lookup_minimal_symbol_by_pc (ti
.ti_startfunc
);
1477 printf_filtered (" startfunc: %s\n", SYMBOL_NAME (msym
));
1479 printf_filtered (" startfunc: 0x%s\n", paddr (ti
.ti_startfunc
));
1482 /* If thread is asleep, print function that went to sleep: */
1483 if (ti
.ti_state
== TD_THR_SLEEP
)
1485 struct minimal_symbol
*msym
;
1486 msym
= lookup_minimal_symbol_by_pc (ti
.ti_pc
);
1488 printf_filtered (" - Sleep func: %s\n", SYMBOL_NAME (msym
));
1490 printf_filtered (" - Sleep func: 0x%s\n", paddr (ti
.ti_startfunc
));
1493 /* Wrap up line, if necessary */
1494 if (ti
.ti_state
!= TD_THR_SLEEP
&& ti
.ti_startfunc
== 0)
1495 printf_filtered ("\n"); /* don't you hate counting newlines? */
1498 warning ("info sol-thread: failed to get info for thread.");
1503 /* List some state about each Solaris user thread in the inferior. */
1506 info_solthreads (char *args
, int from_tty
)
1508 p_td_ta_thr_iter (main_ta
, info_cb
, args
,
1509 TD_THR_ANY_STATE
, TD_THR_LOWEST_PRIORITY
,
1510 TD_SIGNO_MASK
, TD_THR_ANY_USER_FLAGS
);
1514 ignore (CORE_ADDR addr
, char *contents
)
1521 init_sol_thread_ops (void)
1523 sol_thread_ops
.to_shortname
= "solaris-threads";
1524 sol_thread_ops
.to_longname
= "Solaris threads and pthread.";
1525 sol_thread_ops
.to_doc
= "Solaris threads and pthread support.";
1526 sol_thread_ops
.to_open
= sol_thread_open
;
1527 sol_thread_ops
.to_close
= 0;
1528 sol_thread_ops
.to_attach
= sol_thread_attach
;
1529 sol_thread_ops
.to_detach
= sol_thread_detach
;
1530 sol_thread_ops
.to_resume
= sol_thread_resume
;
1531 sol_thread_ops
.to_wait
= sol_thread_wait
;
1532 sol_thread_ops
.to_fetch_registers
= sol_thread_fetch_registers
;
1533 sol_thread_ops
.to_store_registers
= sol_thread_store_registers
;
1534 sol_thread_ops
.to_prepare_to_store
= sol_thread_prepare_to_store
;
1535 sol_thread_ops
.to_xfer_memory
= sol_thread_xfer_memory
;
1536 sol_thread_ops
.to_files_info
= sol_thread_files_info
;
1537 sol_thread_ops
.to_insert_breakpoint
= memory_insert_breakpoint
;
1538 sol_thread_ops
.to_remove_breakpoint
= memory_remove_breakpoint
;
1539 sol_thread_ops
.to_terminal_init
= terminal_init_inferior
;
1540 sol_thread_ops
.to_terminal_inferior
= terminal_inferior
;
1541 sol_thread_ops
.to_terminal_ours_for_output
= terminal_ours_for_output
;
1542 sol_thread_ops
.to_terminal_ours
= terminal_ours
;
1543 sol_thread_ops
.to_terminal_info
= child_terminal_info
;
1544 sol_thread_ops
.to_kill
= sol_thread_kill_inferior
;
1545 sol_thread_ops
.to_load
= 0;
1546 sol_thread_ops
.to_lookup_symbol
= 0;
1547 sol_thread_ops
.to_create_inferior
= sol_thread_create_inferior
;
1548 sol_thread_ops
.to_mourn_inferior
= sol_thread_mourn_inferior
;
1549 sol_thread_ops
.to_can_run
= sol_thread_can_run
;
1550 sol_thread_ops
.to_notice_signals
= sol_thread_notice_signals
;
1551 sol_thread_ops
.to_thread_alive
= sol_thread_alive
;
1552 sol_thread_ops
.to_pid_to_str
= solaris_pid_to_str
;
1553 sol_thread_ops
.to_find_new_threads
= sol_find_new_threads
;
1554 sol_thread_ops
.to_stop
= sol_thread_stop
;
1555 sol_thread_ops
.to_stratum
= process_stratum
;
1556 sol_thread_ops
.to_has_all_memory
= 1;
1557 sol_thread_ops
.to_has_memory
= 1;
1558 sol_thread_ops
.to_has_stack
= 1;
1559 sol_thread_ops
.to_has_registers
= 1;
1560 sol_thread_ops
.to_has_execution
= 1;
1561 sol_thread_ops
.to_has_thread_control
= tc_none
;
1562 sol_thread_ops
.to_sections
= 0;
1563 sol_thread_ops
.to_sections_end
= 0;
1564 sol_thread_ops
.to_magic
= OPS_MAGIC
;
1569 init_sol_core_ops (void)
1571 sol_core_ops
.to_shortname
= "solaris-core";
1572 sol_core_ops
.to_longname
= "Solaris core threads and pthread.";
1573 sol_core_ops
.to_doc
= "Solaris threads and pthread support for core files.";
1574 sol_core_ops
.to_open
= sol_core_open
;
1575 sol_core_ops
.to_close
= sol_core_close
;
1576 sol_core_ops
.to_attach
= sol_thread_attach
;
1577 sol_core_ops
.to_detach
= sol_core_detach
;
1578 /* sol_core_ops.to_resume = 0; */
1579 /* sol_core_ops.to_wait = 0; */
1580 sol_core_ops
.to_fetch_registers
= sol_thread_fetch_registers
;
1581 /* sol_core_ops.to_store_registers = 0; */
1582 /* sol_core_ops.to_prepare_to_store = 0; */
1583 sol_core_ops
.to_xfer_memory
= sol_thread_xfer_memory
;
1584 sol_core_ops
.to_files_info
= sol_core_files_info
;
1585 sol_core_ops
.to_insert_breakpoint
= ignore
;
1586 sol_core_ops
.to_remove_breakpoint
= ignore
;
1587 /* sol_core_ops.to_terminal_init = 0; */
1588 /* sol_core_ops.to_terminal_inferior = 0; */
1589 /* sol_core_ops.to_terminal_ours_for_output = 0; */
1590 /* sol_core_ops.to_terminal_ours = 0; */
1591 /* sol_core_ops.to_terminal_info = 0; */
1592 /* sol_core_ops.to_kill = 0; */
1593 /* sol_core_ops.to_load = 0; */
1594 /* sol_core_ops.to_lookup_symbol = 0; */
1595 sol_core_ops
.to_create_inferior
= sol_thread_create_inferior
;
1596 sol_core_ops
.to_stratum
= core_stratum
;
1597 sol_core_ops
.to_has_all_memory
= 0;
1598 sol_core_ops
.to_has_memory
= 1;
1599 sol_core_ops
.to_has_stack
= 1;
1600 sol_core_ops
.to_has_registers
= 1;
1601 sol_core_ops
.to_has_execution
= 0;
1602 sol_core_ops
.to_has_thread_control
= tc_none
;
1603 sol_core_ops
.to_thread_alive
= sol_thread_alive
;
1604 sol_core_ops
.to_pid_to_str
= solaris_pid_to_str
;
1605 /* On Solaris/x86, when debugging a threaded core file from process <n>,
1606 the following causes "info threads" to produce "procfs: couldn't find pid
1607 <n> in procinfo list" where <n> is the pid of the process that produced
1608 the core file. Disable it for now. */
1609 /* sol_core_ops.to_find_new_threads = sol_find_new_threads; */
1610 sol_core_ops
.to_sections
= 0;
1611 sol_core_ops
.to_sections_end
= 0;
1612 sol_core_ops
.to_magic
= OPS_MAGIC
;
1615 /* we suppress the call to add_target of core_ops in corelow because
1616 if there are two targets in the stratum core_stratum, find_core_target
1617 won't know which one to return. see corelow.c for an additonal
1618 comment on coreops_suppress_target. */
1619 int coreops_suppress_target
= 1;
1622 _initialize_sol_thread (void)
1626 init_sol_thread_ops ();
1627 init_sol_core_ops ();
1629 dlhandle
= dlopen ("libthread_db.so.1", RTLD_NOW
);
1633 #define resolve(X) \
1634 if (!(p_##X = dlsym (dlhandle, #X))) \
1638 resolve (td_ta_new
);
1639 resolve (td_ta_delete
);
1641 resolve (td_ta_get_ph
);
1642 resolve (td_ta_get_nthreads
);
1643 resolve (td_ta_tsd_iter
);
1644 resolve (td_ta_thr_iter
);
1645 resolve (td_thr_validate
);
1646 resolve (td_thr_tsd
);
1647 resolve (td_thr_get_info
);
1648 resolve (td_thr_getfpregs
);
1649 resolve (td_thr_getxregsize
);
1650 resolve (td_thr_getxregs
);
1651 resolve (td_thr_sigsetmask
);
1652 resolve (td_thr_setprio
);
1653 resolve (td_thr_setsigpending
);
1654 resolve (td_thr_setfpregs
);
1655 resolve (td_thr_setxregs
);
1656 resolve (td_ta_map_id2thr
);
1657 resolve (td_ta_map_lwp2thr
);
1658 resolve (td_thr_getgregs
);
1659 resolve (td_thr_setgregs
);
1661 add_target (&sol_thread_ops
);
1663 procfs_suppress_run
= 1;
1665 add_cmd ("sol-threads", class_maintenance
, info_solthreads
,
1666 "Show info on Solaris user threads.\n", &maintenanceinfolist
);
1668 memcpy (&orig_core_ops
, &core_ops
, sizeof (struct target_ops
));
1669 memcpy (&core_ops
, &sol_core_ops
, sizeof (struct target_ops
));
1670 add_target (&core_ops
);
1672 /* Hook into new_objfile notification. */
1673 target_new_objfile_chain
= target_new_objfile_hook
;
1674 target_new_objfile_hook
= sol_thread_new_objfile
;
1679 fprintf_unfiltered (gdb_stderr
, "[GDB will not be able to debug user-mode threads: %s]\n", dlerror ());
1684 /* allow the user to debug non-threaded core files */
1685 add_target (&core_ops
);