old-cross-binutils/gdb/uw-thread.c

1074 lines
28 KiB
C
Raw Normal View History

2000-01-18 00:55:13 +00:00
/* Low level interface for debugging UnixWare user-mode threads for
GDB, the GNU debugger.
* breakpoint.c: * arm-tdep.c: * ia64-tdep.c: * i386-tdep.c: * hpread.c: * hppa-tdep.c: * hppa-hpux-tdep.c: * gnu-nat.c: * gdbtypes.c: * gdbarch.h: * gdbarch.c: * eval.c: * dwarf2read.c: * dbxread.c: * copying: * symfile.c: * stabsread.c: * sh64-tdep.c: * sh-tdep.c: * s390-tdep.c: * rs6000-tdep.c: * remote.c: * remote-mips.c: * mips-tdep.c: * mdebugread.c: * linux-nat.c: * infrun.c: * xcoffread.c: * win32-nat.c: * valops.c: * utils.c: * tracepoint.c: * target.c: * symtab.c: * c-exp.y: * ada-valprint.c: * ada-typeprint.c: * ada-lex.l: * ada-lang.h: * ada-lang.c: * ada-exp.y: * alphafbsd-tdep.c: * alphabsd-tdep.h: * alphabsd-tdep.c: * alphabsd-nat.c: * alpha-tdep.h: * alpha-tdep.c: * alpha-osf1-tdep.c: * alpha-nat.c: * alpha-mdebug-tdep.c: * alpha-linux-tdep.c: * alpha-linux-nat.c: * aix-thread.c: * abug-rom.c: * arch-utils.c: * annotate.h: * annotate.c: * amd64obsd-tdep.c: * amd64obsd-nat.c: * amd64nbsd-tdep.c: * amd64nbsd-nat.c: * amd64fbsd-tdep.c: * amd64fbsd-nat.c: * amd64bsd-nat.c: * amd64-tdep.h: * amd64-tdep.c: * amd64-sol2-tdep.c: * amd64-nat.h: * amd64-nat.c: * amd64-linux-tdep.c: * amd64-linux-nat.c: * alphanbsd-tdep.c: * block.h: * block.c: * bfd-target.h: * bfd-target.c: * bcache.h: * bcache.c: * ax.h: * ax-general.c: * ax-gdb.h: * ax-gdb.c: * avr-tdep.c: * auxv.h: * auxv.c: * armnbsd-tdep.c: * armnbsd-nat.c: * arm-tdep.h: * arm-linux-nat.c: * arch-utils.h: * charset.c: * call-cmds.h: * c-valprint.c: * c-typeprint.c: * c-lang.h: * c-lang.c: * buildsym.h: * buildsym.c: * bsd-uthread.h: * bsd-uthread.c: * bsd-kvm.h: * bsd-kvm.c: * breakpoint.h: * core-regset.c: * core-aout.c: * completer.h: * completer.c: * complaints.h: * complaints.c: * command.h: * coffread.c: * coff-solib.h: * coff-solib.c: * coff-pe-read.h: * coff-pe-read.c: * cli-out.h: * cli-out.c: * charset.h: * dink32-rom.c: * dictionary.h: * dictionary.c: * demangle.c: * defs.h: * dcache.h: * dcache.c: * d10v-tdep.c: * cpu32bug-rom.c: * cp-valprint.c: * cp-support.h: * cp-support.c: * cp-namespace.c: * cp-abi.h: * cp-abi.c: * corelow.c: * corefile.c: * environ.c: * elfread.c: * dwarfread.c: * dwarf2loc.c: * dwarf2expr.h: * dwarf2expr.c: * dwarf2-frame.h: * dwarf2-frame.c: * dve3900-rom.c: * dummy-frame.h: * dummy-frame.c: * dsrec.c: * doublest.h: * doublest.c: * disasm.h: * disasm.c: * fork-child.c: * findvar.c: * fbsd-nat.h: * fbsd-nat.c: * f-valprint.c: * f-typeprint.c: * f-lang.h: * f-lang.c: * expression.h: * expprint.c: * exec.h: * exec.c: * exceptions.h: * exceptions.c: * event-top.h: * event-top.c: * event-loop.h: * event-loop.c: * gdb.c: * gdb-stabs.h: * gdb-events.h: * gdb-events.c: * gcore.c: * frv-tdep.h: * frv-tdep.c: * frv-linux-tdep.c: * frame.h: * frame.c: * frame-unwind.h: * frame-unwind.c: * frame-base.h: * frame-base.c: * gdb_vfork.h: * gdb_thread_db.h: * gdb_string.h: * gdb_stat.h: * gdb_regex.h: * gdb_ptrace.h: * gdb_proc_service.h: * gdb_obstack.h: * gdb_locale.h: * gdb_dirent.h: * gdb_curses.h: * gdb_assert.h: * gdbarch.sh: * gdb.h: * hpux-thread.c: * hppabsd-nat.c: * hppa-tdep.h: * hpacc-abi.c: * h8300-tdep.c: * gregset.h: * go32-nat.c: * gnu-v3-abi.c: * gnu-v2-abi.h: * gnu-v2-abi.c: * gnu-nat.h: * glibc-tdep.c: * gdbtypes.h: * gdbcore.h: * gdbcmd.h: * i386nbsd-tdep.c: * i386nbsd-nat.c: * i386gnu-tdep.c: * i386gnu-nat.c: * i386fbsd-tdep.c: * i386fbsd-nat.c: * i386bsd-tdep.c: * i386bsd-nat.h: * i386bsd-nat.c: * i386-tdep.h: * i386-sol2-nat.c: * i386-nto-tdep.c: * i386-nat.c: * i386-linux-tdep.h: * i386-linux-tdep.c: * i386-linux-nat.c: * i386-cygwin-tdep.c: * inf-ttrace.c: * inf-ptrace.h: * inf-ptrace.c: * inf-loop.h: * inf-loop.c: * inf-child.h: * inf-child.c: * ia64-tdep.h: * ia64-linux-nat.c: * i387-tdep.h: * i387-tdep.c: * i386v4-nat.c: * i386v-nat.c: * i386obsd-tdep.c: * i386obsd-nat.c: * kod.c: * jv-valprint.c: * jv-typeprint.c: * jv-lang.h: * jv-lang.c: * irix5-nat.c: * iq2000-tdep.c: * interps.h: * interps.c: * inftarg.c: * inflow.h: * inflow.c: * inferior.h: * infcmd.c: * infcall.h: * infcall.c: * inf-ttrace.h: * m32r-tdep.h: * m32r-tdep.c: * m32r-rom.c: * m32r-linux-tdep.c: * m32r-linux-nat.c: * m2-valprint.c: * m2-typeprint.c: * m2-lang.h: * m2-lang.c: * lynx-nat.c: * linux-thread-db.c: * linux-nat.h: * linespec.c: * libunwind-frame.h: * libunwind-frame.c: * language.h: * language.c: * macroexp.c: * macrocmd.c: * m88kbsd-nat.c: * m88k-tdep.h: * m88k-tdep.c: * m68klinux-tdep.c: * m68klinux-nat.c: * m68kbsd-tdep.c: * m68kbsd-nat.c: * m68k-tdep.h: * m68k-tdep.c: * mips-linux-nat.c: * mips-irix-tdep.c: * minsyms.c: * memattr.h: * memattr.c: * mem-break.c: * mdebugread.h: * main.h: * main.c: * macrotab.h: * macrotab.c: * macroscope.h: * macroscope.c: * macroexp.h: * nbsd-tdep.c: * mt-tdep.c: * monitor.h: * monitor.c: * mn10300-tdep.h: * mn10300-tdep.c: * mn10300-linux-tdep.c: * mipsv4-nat.c: * mipsread.c: * mipsnbsd-tdep.h: * mipsnbsd-tdep.c: * mipsnbsd-nat.c: * mips64obsd-tdep.c: * mips64obsd-nat.c: * mips-tdep.h: * mips-mdebug-tdep.c: * mips-linux-tdep.c: * osabi.h: * osabi.c: * ocd.h: * ocd.c: * observer.c: * objfiles.h: * objfiles.c: * objc-lang.h: * objc-lang.c: * objc-exp.y: * nto-tdep.h: * nto-tdep.c: * nto-procfs.c: * nlmread.c: * nbsd-tdep.h: * ppcobsd-tdep.c: * ppcobsd-nat.c: * ppcnbsd-tdep.h: * ppcnbsd-tdep.c: * ppcnbsd-nat.c: * ppcbug-rom.c: * ppc-tdep.h: * ppc-sysv-tdep.c: * ppc-linux-tdep.c: * ppc-linux-nat.c: * ppc-bdm.c: * parser-defs.h: * parse.c: * p-valprint.c: * p-typeprint.c: * p-lang.h: * p-lang.c: * remote-fileio.h: * remote-fileio.c: * remote-est.c: * remote-e7000.c: * regset.h: * regset.c: * reggroups.h: * reggroups.c: * regcache.h: * regcache.c: * proc-why.c: * proc-service.c: * proc-events.c: * printcmd.c: * ppcobsd-tdep.h: * sentinel-frame.h: * sentinel-frame.c: * scm-valprint.c: * scm-tags.h: * scm-lang.h: * scm-lang.c: * scm-exp.c: * s390-tdep.h: * rom68k-rom.c: * remote.h: * remote-utils.c: * remote-st.c: * remote-sim.c: * remote-sds.c: * remote-rdp.c: * remote-rdi.c: * remote-hms.c: * sim-regno.h: * shnbsd-tdep.h: * shnbsd-tdep.c: * shnbsd-nat.c: * sh-tdep.h: * serial.h: * serial.c: * ser-unix.h: * ser-unix.c: * ser-tcp.c: * ser-pipe.c: * ser-go32.c: * ser-e7kpc.c: * ser-base.h: * ser-base.c: * solib.c: * solib-svr4.h: * solib-svr4.c: * solib-sunos.c: * solib-som.h: * solib-som.c: * solib-pa64.h: * solib-pa64.c: * solib-osf.c: * solib-null.c: * solib-legacy.c: * solib-irix.c: * solib-frv.c: * solib-aix5.c: * sol-thread.c: * sparc64-linux-tdep.c: * sparc64-linux-nat.c: * sparc-tdep.h: * sparc-tdep.c: * sparc-sol2-tdep.c: * sparc-sol2-nat.c: * sparc-nat.h: * sparc-nat.c: * sparc-linux-tdep.c: * sparc-linux-nat.c: * source.h: * source.c: * somread.c: * solist.h: * solib.h: * std-regs.c: * stack.h: * stack.c: * stabsread.h: * sparcobsd-tdep.c: * sparcnbsd-tdep.c: * sparcnbsd-nat.c: * sparc64obsd-tdep.c: * sparc64nbsd-tdep.c: * sparc64nbsd-nat.c: * sparc64fbsd-tdep.c: * sparc64fbsd-nat.c: * sparc64-tdep.h: * sparc64-tdep.c: * sparc64-sol2-tdep.c: * sparc64-nat.c: * ui-file.c: * typeprint.h: * typeprint.c: * tramp-frame.h: * tramp-frame.c: * trad-frame.h: * trad-frame.c: * tracepoint.h: * top.c: * tobs.inc: * thread.c: * terminal.h: * target.h: * symfile.h: * stop-gdb.c: * vaxbsd-nat.c: * vax-tdep.h: * vax-tdep.c: * vax-nat.c: * varobj.h: * varobj.c: * value.h: * value.c: * valprint.h: * valprint.c: * v850-tdep.c: * uw-thread.c: * user-regs.c: * ui-out.h: * ui-out.c: * ui-file.h: * xcoffsolib.h: * xcoffsolib.c: * wrapper.c: * wince.c: * wince-stub.h: * wince-stub.c: * vaxobsd-tdep.c: * vaxnbsd-tdep.c: * gdb_gcore.sh: * copying.c: * configure.ac: * aclocal.m4: * acinclude.m4: * reply_mig_hack.awk: * observer.sh: * gdb_mbuild.sh: * arm-linux-tdep.c: * blockframe.c: * dbug-rom.c: * environ.h: * dwarf2loc.h: * gdb-events.sh: * glibc-tdep.h: * gdb_wait.h: * gdbthread.h: * i386-sol2-tdep.c: * hppabsd-tdep.c: * hppa-linux-nat.c: * hppa-hpux-nat.c: * ia64-linux-tdep.c: * infptrace.c: * linespec.h: * maint.c: * mips-mdebug-tdep.h: * remote-m32r-sdi.c: * s390-nat.c: * rs6000-nat.c: * remote-utils.h: * sh3-rom.c: * sh-linux-tdep.c: * top.h: * symtab.h: * symmisc.c: * symfile-mem.c: * srec.h: * user-regs.h: * version.h: * valarith.c: * xstormy16-tdep.c: * wrapper.h: * Makefile.in: * f-exp.y: * cris-tdep.c: * cp-name-parser.y: * procfs.c: * proc-utils.h: * proc-flags.c: * proc-api.c: * p-exp.y: * m68hc11-tdep.c: * m2-exp.y: * kod.h: * kod-cisco.c: * jv-exp.y: * hppa-linux-tdep.c: Add (c) after Copyright. Update the FSF address.
2005-12-17 22:34:03 +00:00
Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
Written by Nick Duffek <nsd@cygnus.com>.
2000-01-18 00:55:13 +00:00
This file is part of GDB.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
* breakpoint.c: * arm-tdep.c: * ia64-tdep.c: * i386-tdep.c: * hpread.c: * hppa-tdep.c: * hppa-hpux-tdep.c: * gnu-nat.c: * gdbtypes.c: * gdbarch.h: * gdbarch.c: * eval.c: * dwarf2read.c: * dbxread.c: * copying: * symfile.c: * stabsread.c: * sh64-tdep.c: * sh-tdep.c: * s390-tdep.c: * rs6000-tdep.c: * remote.c: * remote-mips.c: * mips-tdep.c: * mdebugread.c: * linux-nat.c: * infrun.c: * xcoffread.c: * win32-nat.c: * valops.c: * utils.c: * tracepoint.c: * target.c: * symtab.c: * c-exp.y: * ada-valprint.c: * ada-typeprint.c: * ada-lex.l: * ada-lang.h: * ada-lang.c: * ada-exp.y: * alphafbsd-tdep.c: * alphabsd-tdep.h: * alphabsd-tdep.c: * alphabsd-nat.c: * alpha-tdep.h: * alpha-tdep.c: * alpha-osf1-tdep.c: * alpha-nat.c: * alpha-mdebug-tdep.c: * alpha-linux-tdep.c: * alpha-linux-nat.c: * aix-thread.c: * abug-rom.c: * arch-utils.c: * annotate.h: * annotate.c: * amd64obsd-tdep.c: * amd64obsd-nat.c: * amd64nbsd-tdep.c: * amd64nbsd-nat.c: * amd64fbsd-tdep.c: * amd64fbsd-nat.c: * amd64bsd-nat.c: * amd64-tdep.h: * amd64-tdep.c: * amd64-sol2-tdep.c: * amd64-nat.h: * amd64-nat.c: * amd64-linux-tdep.c: * amd64-linux-nat.c: * alphanbsd-tdep.c: * block.h: * block.c: * bfd-target.h: * bfd-target.c: * bcache.h: * bcache.c: * ax.h: * ax-general.c: * ax-gdb.h: * ax-gdb.c: * avr-tdep.c: * auxv.h: * auxv.c: * armnbsd-tdep.c: * armnbsd-nat.c: * arm-tdep.h: * arm-linux-nat.c: * arch-utils.h: * charset.c: * call-cmds.h: * c-valprint.c: * c-typeprint.c: * c-lang.h: * c-lang.c: * buildsym.h: * buildsym.c: * bsd-uthread.h: * bsd-uthread.c: * bsd-kvm.h: * bsd-kvm.c: * breakpoint.h: * core-regset.c: * core-aout.c: * completer.h: * completer.c: * complaints.h: * complaints.c: * command.h: * coffread.c: * coff-solib.h: * coff-solib.c: * coff-pe-read.h: * coff-pe-read.c: * cli-out.h: * cli-out.c: * charset.h: * dink32-rom.c: * dictionary.h: * dictionary.c: * demangle.c: * defs.h: * dcache.h: * dcache.c: * d10v-tdep.c: * cpu32bug-rom.c: * cp-valprint.c: * cp-support.h: * cp-support.c: * cp-namespace.c: * cp-abi.h: * cp-abi.c: * corelow.c: * corefile.c: * environ.c: * elfread.c: * dwarfread.c: * dwarf2loc.c: * dwarf2expr.h: * dwarf2expr.c: * dwarf2-frame.h: * dwarf2-frame.c: * dve3900-rom.c: * dummy-frame.h: * dummy-frame.c: * dsrec.c: * doublest.h: * doublest.c: * disasm.h: * disasm.c: * fork-child.c: * findvar.c: * fbsd-nat.h: * fbsd-nat.c: * f-valprint.c: * f-typeprint.c: * f-lang.h: * f-lang.c: * expression.h: * expprint.c: * exec.h: * exec.c: * exceptions.h: * exceptions.c: * event-top.h: * event-top.c: * event-loop.h: * event-loop.c: * gdb.c: * gdb-stabs.h: * gdb-events.h: * gdb-events.c: * gcore.c: * frv-tdep.h: * frv-tdep.c: * frv-linux-tdep.c: * frame.h: * frame.c: * frame-unwind.h: * frame-unwind.c: * frame-base.h: * frame-base.c: * gdb_vfork.h: * gdb_thread_db.h: * gdb_string.h: * gdb_stat.h: * gdb_regex.h: * gdb_ptrace.h: * gdb_proc_service.h: * gdb_obstack.h: * gdb_locale.h: * gdb_dirent.h: * gdb_curses.h: * gdb_assert.h: * gdbarch.sh: * gdb.h: * hpux-thread.c: * hppabsd-nat.c: * hppa-tdep.h: * hpacc-abi.c: * h8300-tdep.c: * gregset.h: * go32-nat.c: * gnu-v3-abi.c: * gnu-v2-abi.h: * gnu-v2-abi.c: * gnu-nat.h: * glibc-tdep.c: * gdbtypes.h: * gdbcore.h: * gdbcmd.h: * i386nbsd-tdep.c: * i386nbsd-nat.c: * i386gnu-tdep.c: * i386gnu-nat.c: * i386fbsd-tdep.c: * i386fbsd-nat.c: * i386bsd-tdep.c: * i386bsd-nat.h: * i386bsd-nat.c: * i386-tdep.h: * i386-sol2-nat.c: * i386-nto-tdep.c: * i386-nat.c: * i386-linux-tdep.h: * i386-linux-tdep.c: * i386-linux-nat.c: * i386-cygwin-tdep.c: * inf-ttrace.c: * inf-ptrace.h: * inf-ptrace.c: * inf-loop.h: * inf-loop.c: * inf-child.h: * inf-child.c: * ia64-tdep.h: * ia64-linux-nat.c: * i387-tdep.h: * i387-tdep.c: * i386v4-nat.c: * i386v-nat.c: * i386obsd-tdep.c: * i386obsd-nat.c: * kod.c: * jv-valprint.c: * jv-typeprint.c: * jv-lang.h: * jv-lang.c: * irix5-nat.c: * iq2000-tdep.c: * interps.h: * interps.c: * inftarg.c: * inflow.h: * inflow.c: * inferior.h: * infcmd.c: * infcall.h: * infcall.c: * inf-ttrace.h: * m32r-tdep.h: * m32r-tdep.c: * m32r-rom.c: * m32r-linux-tdep.c: * m32r-linux-nat.c: * m2-valprint.c: * m2-typeprint.c: * m2-lang.h: * m2-lang.c: * lynx-nat.c: * linux-thread-db.c: * linux-nat.h: * linespec.c: * libunwind-frame.h: * libunwind-frame.c: * language.h: * language.c: * macroexp.c: * macrocmd.c: * m88kbsd-nat.c: * m88k-tdep.h: * m88k-tdep.c: * m68klinux-tdep.c: * m68klinux-nat.c: * m68kbsd-tdep.c: * m68kbsd-nat.c: * m68k-tdep.h: * m68k-tdep.c: * mips-linux-nat.c: * mips-irix-tdep.c: * minsyms.c: * memattr.h: * memattr.c: * mem-break.c: * mdebugread.h: * main.h: * main.c: * macrotab.h: * macrotab.c: * macroscope.h: * macroscope.c: * macroexp.h: * nbsd-tdep.c: * mt-tdep.c: * monitor.h: * monitor.c: * mn10300-tdep.h: * mn10300-tdep.c: * mn10300-linux-tdep.c: * mipsv4-nat.c: * mipsread.c: * mipsnbsd-tdep.h: * mipsnbsd-tdep.c: * mipsnbsd-nat.c: * mips64obsd-tdep.c: * mips64obsd-nat.c: * mips-tdep.h: * mips-mdebug-tdep.c: * mips-linux-tdep.c: * osabi.h: * osabi.c: * ocd.h: * ocd.c: * observer.c: * objfiles.h: * objfiles.c: * objc-lang.h: * objc-lang.c: * objc-exp.y: * nto-tdep.h: * nto-tdep.c: * nto-procfs.c: * nlmread.c: * nbsd-tdep.h: * ppcobsd-tdep.c: * ppcobsd-nat.c: * ppcnbsd-tdep.h: * ppcnbsd-tdep.c: * ppcnbsd-nat.c: * ppcbug-rom.c: * ppc-tdep.h: * ppc-sysv-tdep.c: * ppc-linux-tdep.c: * ppc-linux-nat.c: * ppc-bdm.c: * parser-defs.h: * parse.c: * p-valprint.c: * p-typeprint.c: * p-lang.h: * p-lang.c: * remote-fileio.h: * remote-fileio.c: * remote-est.c: * remote-e7000.c: * regset.h: * regset.c: * reggroups.h: * reggroups.c: * regcache.h: * regcache.c: * proc-why.c: * proc-service.c: * proc-events.c: * printcmd.c: * ppcobsd-tdep.h: * sentinel-frame.h: * sentinel-frame.c: * scm-valprint.c: * scm-tags.h: * scm-lang.h: * scm-lang.c: * scm-exp.c: * s390-tdep.h: * rom68k-rom.c: * remote.h: * remote-utils.c: * remote-st.c: * remote-sim.c: * remote-sds.c: * remote-rdp.c: * remote-rdi.c: * remote-hms.c: * sim-regno.h: * shnbsd-tdep.h: * shnbsd-tdep.c: * shnbsd-nat.c: * sh-tdep.h: * serial.h: * serial.c: * ser-unix.h: * ser-unix.c: * ser-tcp.c: * ser-pipe.c: * ser-go32.c: * ser-e7kpc.c: * ser-base.h: * ser-base.c: * solib.c: * solib-svr4.h: * solib-svr4.c: * solib-sunos.c: * solib-som.h: * solib-som.c: * solib-pa64.h: * solib-pa64.c: * solib-osf.c: * solib-null.c: * solib-legacy.c: * solib-irix.c: * solib-frv.c: * solib-aix5.c: * sol-thread.c: * sparc64-linux-tdep.c: * sparc64-linux-nat.c: * sparc-tdep.h: * sparc-tdep.c: * sparc-sol2-tdep.c: * sparc-sol2-nat.c: * sparc-nat.h: * sparc-nat.c: * sparc-linux-tdep.c: * sparc-linux-nat.c: * source.h: * source.c: * somread.c: * solist.h: * solib.h: * std-regs.c: * stack.h: * stack.c: * stabsread.h: * sparcobsd-tdep.c: * sparcnbsd-tdep.c: * sparcnbsd-nat.c: * sparc64obsd-tdep.c: * sparc64nbsd-tdep.c: * sparc64nbsd-nat.c: * sparc64fbsd-tdep.c: * sparc64fbsd-nat.c: * sparc64-tdep.h: * sparc64-tdep.c: * sparc64-sol2-tdep.c: * sparc64-nat.c: * ui-file.c: * typeprint.h: * typeprint.c: * tramp-frame.h: * tramp-frame.c: * trad-frame.h: * trad-frame.c: * tracepoint.h: * top.c: * tobs.inc: * thread.c: * terminal.h: * target.h: * symfile.h: * stop-gdb.c: * vaxbsd-nat.c: * vax-tdep.h: * vax-tdep.c: * vax-nat.c: * varobj.h: * varobj.c: * value.h: * value.c: * valprint.h: * valprint.c: * v850-tdep.c: * uw-thread.c: * user-regs.c: * ui-out.h: * ui-out.c: * ui-file.h: * xcoffsolib.h: * xcoffsolib.c: * wrapper.c: * wince.c: * wince-stub.h: * wince-stub.c: * vaxobsd-tdep.c: * vaxnbsd-tdep.c: * gdb_gcore.sh: * copying.c: * configure.ac: * aclocal.m4: * acinclude.m4: * reply_mig_hack.awk: * observer.sh: * gdb_mbuild.sh: * arm-linux-tdep.c: * blockframe.c: * dbug-rom.c: * environ.h: * dwarf2loc.h: * gdb-events.sh: * glibc-tdep.h: * gdb_wait.h: * gdbthread.h: * i386-sol2-tdep.c: * hppabsd-tdep.c: * hppa-linux-nat.c: * hppa-hpux-nat.c: * ia64-linux-tdep.c: * infptrace.c: * linespec.h: * maint.c: * mips-mdebug-tdep.h: * remote-m32r-sdi.c: * s390-nat.c: * rs6000-nat.c: * remote-utils.h: * sh3-rom.c: * sh-linux-tdep.c: * top.h: * symtab.h: * symmisc.c: * symfile-mem.c: * srec.h: * user-regs.h: * version.h: * valarith.c: * xstormy16-tdep.c: * wrapper.h: * Makefile.in: * f-exp.y: * cris-tdep.c: * cp-name-parser.y: * procfs.c: * proc-utils.h: * proc-flags.c: * proc-api.c: * p-exp.y: * m68hc11-tdep.c: * m2-exp.y: * kod.h: * kod-cisco.c: * jv-exp.y: * hppa-linux-tdep.c: Add (c) after Copyright. Update the FSF address.
2005-12-17 22:34:03 +00:00
Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA. */
2000-01-18 00:55:13 +00:00
/* Like many systems, UnixWare implements two classes of threads:
kernel-mode threads, which are scheduled by the kernel; and
user-mode threads, which are scheduled by a library. UnixWare
calls these two classes lightweight processes (LWPs) and threads,
respectively.
This module deals with user-mode threads. It calls procfs_ops
functions to deal with LWPs and processes and core_ops functions to
deal with core files.
As of this writing, the user-mode thread debugging interface is not
documented beyond the comments in <thread.h>. The following
description has been gleaned from experience and from information
provided by SCO.
libthread.so, against which all UnixWare user-mode thread programs
link, provides a global thread_debug structure named _thr_debug.
It has three fields:
(1) thr_map is a pointer to a pointer to an element of a
thread_map ring. A thread_map contains a single thread's id
number, state, LWP pointer, recent register state, and other
useful information.
(2) thr_brk is a pointer to a stub function that libthread.so
calls when it changes a thread's state, e.g. by creating it,
switching it to an LWP, or causing it to exit.
(3) thr_debug_on controls whether libthread.so calls thr_brk().
Debuggers are able to track thread activity by setting a private
breakpoint on thr_brk() and setting thr_debug_on to 1.
thr_brk() receives two arguments:
(1) a pointer to a thread_map describing the thread being
changed; and
(2) an enum thread_change specifying one of the following
changes:
invalid unknown
thread_create thread has just been created
thread_exit thread has just exited
switch_begin thread will be switched to an LWP
switch_complete thread has been switched to an LWP
cancel_complete thread wasn't switched to an LWP
thread_suspend thread has been thr_suspend()ed
thread_suspend_pending thread will be thr_suspend()ed
thread_continue thread has been thr_continue()d
The thread_map argument to thr_brk() is NULL under the following
circumstances:
- The main thread is being acted upon. The main thread always
has id 1, so its thread_map is easy to find by scanning through
_thr_debug.thr_map.
- A "switch_complete" change is occurring, which means that the
thread specified in the most recent "switch_begin" change has
moved to an LWP.
- A "cancel_complete" change is occurring, which means that the
thread specified in the most recent "switch_begin" change has
not moved to an LWP after all.
- A spurious "switch_begin" change is occurring after a
"thread_exit" change.
Between switch_begin and switch_complete or cancel_complete, the
affected thread's LWP pointer is not reliable. It is possible that
other parts of the thread's thread_map are also unreliable during
that time. */
2000-01-18 00:55:13 +00:00
#include "defs.h"
#include "gdbthread.h"
#include "target.h"
#include "inferior.h"
#include "regcache.h"
2000-01-18 00:55:13 +00:00
#include <fcntl.h>
/* <thread.h> includes <sys/priocntl.h>, which requires boolean_t from
<sys/types.h>, which doesn't typedef boolean_t with gcc. */
2000-01-18 00:55:13 +00:00
#define boolean_t int
#include <thread.h>
#undef boolean_t
#include <synch.h> /* for UnixWare 2.x */
/* Prototypes for supply_gregset etc. */
#include "gregset.h"
2000-01-18 00:55:13 +00:00
/* Offset from SP to first arg on stack at first instruction of a
function. We provide a default here that's right for most, if not
all, targets that use this file. */
#ifndef SP_ARG0
#define SP_ARG0 (1 * 4)
#endif
/* Whether to emit debugging output. */
2000-01-18 00:55:13 +00:00
#define DEBUG 0
/* Default debugging output file, overridden by envvar UWTHR_DEBUG. */
2000-01-18 00:55:13 +00:00
#define DEBUG_FILE "/dev/tty"
/* #if DEBUG, write string S to the debugging output channel. */
2000-01-18 00:55:13 +00:00
#if !DEBUG
# define DBG(fmt_and_args)
# define DBG2(fmt_and_args)
#else
# define DBG(fmt_and_args) dbg fmt_and_args
# define DBG2(fmt_and_args)
#endif
/* Back end to CALL_BASE() and TRY_BASE(): evaluate CALL, then convert
inferior_ptid to a composite thread/process id. */
2000-01-18 00:55:13 +00:00
#define CALL_BASE_1(call) \
do { \
DBG2(("CALL_BASE(" #call ")")); \
call; \
do_cleanups (infpid_cleanup); \
} while (0)
2001-05-04 04:15:33 +00:00
/* If inferior_ptid can be converted to a composite lwp/process id, do so,
evaluate base_ops function CALL, and then convert inferior_ptid back to a
composite thread/process id.
Otherwise, issue an error message and return nonlocally. */
#define CALL_BASE(call) \
do { \
if (!lwp_infpid ()) \
2005-02-10 Andrew Cagney <cagney@gnu.org> Mark up all error and warning messages. * ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update. * bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update. * core-aout.c, core-regset.c, corefile.c, corelow.c: Update. * cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update. * dbxread.c, demangle.c, doublest.c, dsrec.c: Update. * dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update. * dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update. * event-top.c, exec.c, expprint.c, f-lang.c: Update. * f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update. * frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update. * gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update. * hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update. * hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update. * hpread.c, hpux-thread.c, i386-linux-nat.c: Update. * i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update. * i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update. * ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update. * infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update. * inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update. * kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update. * linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update. * m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update. * m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update. * maint.c, mdebugread.c, mem-break.c, memattr.c: Update. * mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update. * nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update. * observer.c, ocd.c, p-lang.c, p-typeprint.c: Update. * p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update. * ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update. * remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update. * remote-rdp.c, remote-sim.c, remote-st.c: Update. * remote-utils.c, remote-utils.h, remote.c: Update. * rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update. * ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update. * sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update. * solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update. * solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update. * somread.c, somsolib.c, source.c, stabsread.c: Update. * stack.c, std-regs.c, symfile-mem.c, symfile.c: Update. * symmisc.c, symtab.c, target.c, thread.c, top.c: Update. * tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update. * uw-thread.c, valarith.c, valops.c, valprint.c: Update. * value.c, varobj.c, version.in, win32-nat.c, wince.c: Update. * xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update. * cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update. * cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update. * mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update. * mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update. * mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update. * tui/tui-win.c: Update.
2005-02-11 04:06:14 +00:00
error (_("uw-thread: no lwp")); \
CALL_BASE_1 (call); \
2000-01-18 00:55:13 +00:00
} while (0)
/* Like CALL_BASE(), but instead of returning nonlocally on error, set
*CALLED to whether the inferior_ptid conversion was successful. */
2000-01-18 00:55:13 +00:00
#define TRY_BASE(call, called) \
do { \
if ((*(called) = lwp_infpid ())) \
CALL_BASE_1 (call); \
} while (0)
/* Information passed by thread_iter() to its callback parameter. */
2000-01-18 00:55:13 +00:00
typedef struct {
struct thread_map map;
__lwp_desc_t lwp;
CORE_ADDR mapp;
} iter_t;
/* Private thread data for the thread_info struct. */
2000-01-18 00:55:13 +00:00
struct private_thread_info {
int stable; /* 0 if libthread.so is modifying thread map */
int thrid; /* thread id assigned by libthread.so */
int lwpid; /* thread's lwp if .stable, 0 means no lwp */
CORE_ADDR mapp; /* address of thread's map structure */
};
/* procfs.c's target-specific operations. */
2000-01-18 00:55:13 +00:00
extern struct target_ops procfs_ops;
/* Flag to prevent procfs.c from starting inferior processes. */
2000-01-18 00:55:13 +00:00
extern int procfs_suppress_run;
/* This module's target-specific operations. */
2000-01-18 00:55:13 +00:00
static struct target_ops uw_thread_ops;
/* Copy of the target over which uw_thread_ops is pushed. This is
more convenient than a pointer to procfs_ops or core_ops, because
they lack current_target's default callbacks. */
2000-01-18 00:55:13 +00:00
static struct target_ops base_ops;
2004-04-21 Andrew Cagney <cagney@redhat.com> * annotate.h (deprecated_annotate_starting_hook) (deprecated_annotate_stopped_hook) (deprecated_annotate_exited_hook) (deprecated_annotate_signal_hook) (deprecated_annotate_signalled_hook): Deprecate. * tracepoint.h (deprecated_create_tracepoint_hook) (deprecated_delete_tracepoint_hook) (deprecated_modify_tracepoint_hook) (deprecated_trace_find_hook) (deprecated_trace_start_stop_hook): Deprecate. * target.h (deprecated_target_new_objfile_hook): Deprecate. * remote.h (deprecated_target_resume_hook) (deprecated_target_wait_loop_hook): Deprecate. * gdbcore.h (deprecated_exec_file_display_hook) (deprecated_file_changed_hook): Deprecate. * frame.h (deprecated_selected_frame_level_changed_hook): Deprecate. * defs.h (deprecated_modify_breakpoint_hook) (deprecated_command_loop_hook, deprecated_show_load_progress) (deprecated_print_frame_info_listing_hook) (deprecated_query_hook, deprecated_warning_hook) (deprecated_flush_hook, deprecated_create_breakpoint_hook) (deprecated_delete_breakpoint_hook) (deprecated_interactive_hook, deprecated_registers_changed_hook) (deprecated_readline_begin_hook, deprecated_readline_hook) (deprecated_readline_end_hook, deprecated_register_changed_hook) (deprecated_memory_changed_hook, deprecated_init_ui_hook) (deprecated_context_hook, deprecated_target_wait_hook) (deprecated_attach_hook, deprecated_detach_hook) (deprecated_call_command_hook, deprecated_set_hook) (deprecated_error_hook, deprecated_error_begin_hook) (deprecated_ui_load_progress_hook): Deprecate. * valops.c, uw-thread.c, utils.c, tui/tui-io.c: Update. * tui/tui-hooks.c, tracepoint.c, top.c, thread-db.c: Update. * target.c, symfile.c, stack.c, sol-thread.c, rs6000-nat.c: Update. * remote.c, remote-mips.c, regcache.c, mi/mi-interp.c: Update. * main.c, interps.c, infcmd.c, hpux-thread.c, frame.c: Update. * exec.c, dsrec.c, d10v-tdep.c, corefile.c, complaints.c: Update. * cli/cli-script.c, cli/cli-setshow.c, breakpoint.c: Update. * annotate.c, aix-thread.c: Update.
2004-04-21 23:52:21 +00:00
/* Saved pointer to previous owner of
deprecated_target_new_objfile_hook. */
2000-01-18 00:55:13 +00:00
static void (*target_new_objfile_chain)(struct objfile *);
/* Whether we are debugging a user-space thread program. This isn't
set until after libthread.so is loaded by the program being
debugged.
Except for module one-time intialization and where otherwise
documented, no functions in this module get called when
!uw_thread_active. */
2000-01-18 00:55:13 +00:00
static int uw_thread_active;
/* For efficiency, cache the addresses of libthread.so's _thr_debug
structure, its thr_brk stub function, and the main thread's map. */
2000-01-18 00:55:13 +00:00
static CORE_ADDR thr_debug_addr;
static CORE_ADDR thr_brk_addr;
static CORE_ADDR thr_map_main;
/* Remember the thread most recently marked as switching. Necessary because
libthread.so passes null map when calling stub with tc_*_complete. */
2000-01-18 00:55:13 +00:00
static struct thread_info *switchto_thread;
/* Cleanup chain for safely restoring inferior_ptid after CALL_BASE. */
2000-01-18 00:55:13 +00:00
static struct cleanup *infpid_cleanup;
#if DEBUG
/* Helper function for DBG() macro: if printf-style FMT is non-null, format it
with args and display the result on the debugging output channel. */
2000-01-18 00:55:13 +00:00
static void
dbg (char *fmt, ...)
{
static int fd = -1, len;
va_list args;
char buf[1024];
char *path;
if (!fmt)
return;
if (fd < 0)
{
path = getenv ("UWTHR_DEBUG");
if (!path)
path = DEBUG_FILE;
if ((fd = open (path, O_WRONLY | O_CREAT | O_TRUNC, 0664)) < 0)
2005-02-10 Andrew Cagney <cagney@gnu.org> Mark up all error and warning messages. * ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update. * bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update. * core-aout.c, core-regset.c, corefile.c, corelow.c: Update. * cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update. * dbxread.c, demangle.c, doublest.c, dsrec.c: Update. * dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update. * dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update. * event-top.c, exec.c, expprint.c, f-lang.c: Update. * f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update. * frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update. * gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update. * hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update. * hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update. * hpread.c, hpux-thread.c, i386-linux-nat.c: Update. * i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update. * i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update. * ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update. * infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update. * inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update. * kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update. * linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update. * m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update. * m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update. * maint.c, mdebugread.c, mem-break.c, memattr.c: Update. * mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update. * nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update. * observer.c, ocd.c, p-lang.c, p-typeprint.c: Update. * p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update. * ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update. * remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update. * remote-rdp.c, remote-sim.c, remote-st.c: Update. * remote-utils.c, remote-utils.h, remote.c: Update. * rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update. * ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update. * sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update. * solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update. * solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update. * somread.c, somsolib.c, source.c, stabsread.c: Update. * stack.c, std-regs.c, symfile-mem.c, symfile.c: Update. * symmisc.c, symtab.c, target.c, thread.c, top.c: Update. * tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update. * uw-thread.c, valarith.c, valops.c, valprint.c: Update. * value.c, varobj.c, version.in, win32-nat.c, wince.c: Update. * xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update. * cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update. * cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update. * mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update. * mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update. * mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update. * tui/tui-win.c: Update.
2005-02-11 04:06:14 +00:00
error (_("can't open %s."), path);
2000-01-18 00:55:13 +00:00
}
va_start (args, fmt);
vsprintf (buf, fmt, args);
va_end (args);
len = strlen (buf);
buf[len] = '\n';
(void)write (fd, buf, len + 1);
}
#if 0
/* Return a string representing composite PID's components. */
2000-01-18 00:55:13 +00:00
static char *
2001-05-04 04:15:33 +00:00
dbgpid (ptid_t ptid)
2000-01-18 00:55:13 +00:00
{
static char *buf, buf1[80], buf2[80];
if (!buf || buf == buf2)
buf = buf1;
else
buf = buf2;
2001-05-04 04:15:33 +00:00
if (PIDGET (ptid) <= 0)
sprintf (buf, "%d", PIDGET (ptid));
2000-01-18 00:55:13 +00:00
else
2001-05-04 04:15:33 +00:00
sprintf (buf, "%s %ld/%d", ISTID (pid) ? "thr" : "lwp",
2000-01-18 00:55:13 +00:00
TIDGET (pid), PIDGET (pid));
return buf;
}
/* Return a string representing thread state CHANGE. */
2000-01-18 00:55:13 +00:00
static char *
dbgchange (enum thread_change change)
{
switch (change) {
case tc_invalid: return "invalid";
case tc_thread_create: return "thread_create";
case tc_thread_exit: return "thread_exit";
case tc_switch_begin: return "switch_begin";
case tc_switch_complete: return "switch_complete";
case tc_cancel_complete: return "cancel_complete";
case tc_thread_suspend: return "thread_suspend";
case tc_thread_suspend_pending: return "thread_suspend_pending";
case tc_thread_continue: return "thread_continue";
default: return "unknown";
}
}
/* Return a string representing thread STATE. */
2000-01-18 00:55:13 +00:00
static char *
dbgstate (int state)
{
switch (state) {
case TS_ONPROC: return "running";
case TS_SLEEP: return "sleeping";
case TS_RUNNABLE: return "runnable";
case TS_ZOMBIE: return "zombie";
case TS_SUSPENDED: return "suspended";
#ifdef TS_FORK
case TS_FORK: return "forking";
#endif
default: return "confused";
}
}
#endif /* 0 */
#endif /* DEBUG */
/* Read the contents of _thr_debug into *DEBUGP. Return success. */
2000-01-18 00:55:13 +00:00
static int
read_thr_debug (struct thread_debug *debugp)
{
return base_ops.deprecated_xfer_memory (thr_debug_addr, (char *)debugp,
sizeof (*debugp), 0, NULL,
&base_ops);
2000-01-18 00:55:13 +00:00
}
/* Read into MAP the contents of the thread map at inferior process address
MAPP. Return success. */
2000-01-18 00:55:13 +00:00
static int
read_map (CORE_ADDR mapp, struct thread_map *map)
{
return base_ops.deprecated_xfer_memory ((CORE_ADDR)THR_MAP (mapp),
(char *)map, sizeof (*map),
0, NULL, &base_ops);
2000-01-18 00:55:13 +00:00
}
/* Read into LWP the contents of the lwp decriptor at inferior process address
LWPP. Return success. */
2000-01-18 00:55:13 +00:00
static int
read_lwp (CORE_ADDR lwpp, __lwp_desc_t *lwp)
{
return base_ops.deprecated_xfer_memory (lwpp, (char *)lwp,
sizeof (*lwp), 0, NULL, &base_ops);
2000-01-18 00:55:13 +00:00
}
/* Iterate through all user threads, applying FUNC(<map>, <lwp>, DATA) until
(a) FUNC returns nonzero,
(b) FUNC has been applied to all threads, or
(c) an error occurs,
where <map> is the thread's struct thread_map and <lwp> if non-null is the
thread's current __lwp_desc_t.
If a call to FUNC returns nonzero, return that value; otherwise, return 0. */
2000-01-18 00:55:13 +00:00
static int
thread_iter (int (*func)(iter_t *, void *), void *data)
{
struct thread_debug debug;
CORE_ADDR first, mapp;
iter_t iter;
int ret;
if (!read_thr_debug (&debug))
return 0;
if (!base_ops.deprecated_xfer_memory ((CORE_ADDR)debug.thr_map,
(char *)&mapp, sizeof (mapp), 0, NULL,
&base_ops))
2000-01-18 00:55:13 +00:00
return 0;
if (!mapp)
return 0;
for (first = mapp;;)
{
if (!read_map (mapp, &iter.map))
return 0;
if (iter.map.thr_lwpp)
if (!read_lwp ((CORE_ADDR)iter.map.thr_lwpp, &iter.lwp))
return 0;
iter.mapp = mapp;
if ((ret = func (&iter, data)))
return ret;
mapp = (CORE_ADDR)iter.map.thr_next;
if (mapp == first)
return 0;
}
}
/* Deactivate user-mode thread support. */
2000-01-18 00:55:13 +00:00
static void
deactivate_uw_thread (void)
{
remove_thread_event_breakpoints ();
2000-01-18 00:55:13 +00:00
uw_thread_active = 0;
unpush_target (&uw_thread_ops);
}
/* Return the composite lwp/process id corresponding to composite
id PID. If PID is a thread with no lwp, return 0. */
2001-05-04 04:15:33 +00:00
static ptid_t
thr_to_lwp (ptid_t ptid)
2000-01-18 00:55:13 +00:00
{
struct thread_info *info;
2001-05-04 04:15:33 +00:00
ptid_t lid;
2000-01-18 00:55:13 +00:00
2001-05-04 04:15:33 +00:00
if (!ISTID (ptid))
lid = ptid;
else if (!(info = find_thread_pid (ptid)))
lid = null_ptid;
2000-01-18 00:55:13 +00:00
else if (!info->private->lwpid)
2001-05-04 04:15:33 +00:00
lid = null_ptid;
2000-01-18 00:55:13 +00:00
else
2001-05-04 04:15:33 +00:00
lid = MKLID (PIDGET (ptid), info->private->lwpid);
2000-01-18 00:55:13 +00:00
DBG2((" thr_to_lwp(%s) = %s", dbgpid (pid), dbgpid (lid)));
return lid;
}
/* find_thread_lwp() callback: return whether TP describes a thread
associated with lwp id DATA. */
2000-01-18 00:55:13 +00:00
static int
find_thread_lwp_callback (struct thread_info *tp, void *data)
{
int lwpid = (int)data;
2001-05-04 04:15:33 +00:00
if (!ISTID (tp->ptid))
2000-01-18 00:55:13 +00:00
return 0;
if (!tp->private->stable)
return 0;
if (lwpid != tp->private->lwpid)
return 0;
/* match */
return 1;
}
/* If a thread is associated with lwp id LWPID, return the corresponding
member of the global thread list; otherwise, return null. */
2000-01-18 00:55:13 +00:00
static struct thread_info *
find_thread_lwp (int lwpid)
{
return iterate_over_threads (find_thread_lwp_callback, (void *)lwpid);
}
/* Return the composite thread/process id corresponding to composite
id PID. If PID is an lwp with no thread, return PID. */
2001-05-04 04:15:33 +00:00
static ptid_t
lwp_to_thr (ptid_t ptid)
2000-01-18 00:55:13 +00:00
{
struct thread_info *info;
2001-05-04 04:15:33 +00:00
int lwpid;
ptid_t tid = ptid;
2000-01-18 00:55:13 +00:00
2001-05-04 04:15:33 +00:00
if (ISTID (ptid))
2000-01-18 00:55:13 +00:00
goto done;
2001-05-04 04:15:33 +00:00
if (!(lwpid = LIDGET (ptid)))
2000-01-18 00:55:13 +00:00
goto done;
if (!(info = find_thread_lwp (lwpid)))
goto done;
2001-05-04 04:15:33 +00:00
tid = MKTID (PIDGET (ptid), info->private->thrid);
2000-01-18 00:55:13 +00:00
done:
2001-05-04 04:15:33 +00:00
DBG2((ISTID (tid) ? NULL : "lwp_to_thr: no thr for %s", dbgpid (ptid)));
2000-01-18 00:55:13 +00:00
return tid;
}
2001-05-04 04:15:33 +00:00
/* do_cleanups() callback: convert inferior_ptid to a composite
thread/process id after having made a procfs call. */
2000-01-18 00:55:13 +00:00
static void
thr_infpid (void *unused)
{
2001-05-04 04:15:33 +00:00
ptid_t ptid = lwp_to_thr (inferior_ptid);
DBG2((" inferior_ptid from procfs: %s => %s",
dbgpid (inferior_ptid), dbgpid (ptid)));
inferior_ptid = ptid;
2000-01-18 00:55:13 +00:00
}
2001-05-04 04:15:33 +00:00
/* If possible, convert inferior_ptid to a composite lwp/process id in
preparation for making a procfs call. Return success. */
2000-01-18 00:55:13 +00:00
static int
lwp_infpid (void)
{
2001-05-04 04:15:33 +00:00
ptid_t ptid = thr_to_lwp (inferior_ptid);
DBG2((" inferior_ptid to procfs: %s => %s",
dbgpid (inferior_ptid), dbgpid (ptid)));
2000-01-18 00:55:13 +00:00
2001-05-04 04:15:33 +00:00
if (ptid_equal (ptid, null_ptid))
2000-01-18 00:55:13 +00:00
return 0;
2001-05-04 04:15:33 +00:00
inferior_ptid = ptid;
2000-01-18 00:55:13 +00:00
infpid_cleanup = make_cleanup (thr_infpid, NULL);
return 1;
}
/* Add to the global thread list a new user-mode thread with system id THRID,
lwp id LWPID, map address MAPP, and composite thread/process PID. */
2000-01-18 00:55:13 +00:00
static void
2001-05-04 04:15:33 +00:00
add_thread_uw (int thrid, int lwpid, CORE_ADDR mapp, ptid_t ptid)
2000-01-18 00:55:13 +00:00
{
struct thread_info *newthread;
2001-05-04 04:15:33 +00:00
if ((newthread = add_thread (ptid)) == NULL)
2005-02-10 Andrew Cagney <cagney@gnu.org> Mark up all error and warning messages. * ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update. * bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update. * core-aout.c, core-regset.c, corefile.c, corelow.c: Update. * cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update. * dbxread.c, demangle.c, doublest.c, dsrec.c: Update. * dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update. * dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update. * event-top.c, exec.c, expprint.c, f-lang.c: Update. * f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update. * frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update. * gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update. * hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update. * hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update. * hpread.c, hpux-thread.c, i386-linux-nat.c: Update. * i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update. * i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update. * ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update. * infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update. * inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update. * kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update. * linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update. * m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update. * m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update. * maint.c, mdebugread.c, mem-break.c, memattr.c: Update. * mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update. * nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update. * observer.c, ocd.c, p-lang.c, p-typeprint.c: Update. * p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update. * ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update. * remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update. * remote-rdp.c, remote-sim.c, remote-st.c: Update. * remote-utils.c, remote-utils.h, remote.c: Update. * rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update. * ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update. * sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update. * solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update. * solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update. * somread.c, somsolib.c, source.c, stabsread.c: Update. * stack.c, std-regs.c, symfile-mem.c, symfile.c: Update. * symmisc.c, symtab.c, target.c, thread.c, top.c: Update. * tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update. * uw-thread.c, valarith.c, valops.c, valprint.c: Update. * value.c, varobj.c, version.in, win32-nat.c, wince.c: Update. * xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update. * cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update. * cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update. * mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update. * mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update. * mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update. * tui/tui-win.c: Update.
2005-02-11 04:06:14 +00:00
error (_("failed to create new thread structure"));
2000-01-18 00:55:13 +00:00
newthread->private = xmalloc (sizeof (struct private_thread_info));
newthread->private->stable = 1;
newthread->private->thrid = thrid;
newthread->private->lwpid = lwpid;
newthread->private->mapp = mapp;
if (target_has_execution)
2001-05-04 04:15:33 +00:00
printf_unfiltered ("[New %s]\n", target_pid_to_str (ptid));
2000-01-18 00:55:13 +00:00
}
/* notice_threads() and find_main() callback: if the thread list doesn't
already contain the thread described by ITER, add it if it's the main
thread or if !DATA. */
2000-01-18 00:55:13 +00:00
static int
notice_thread (iter_t *iter, void *data)
{
int thrid = iter->map.thr_tid;
int lwpid = !iter->map.thr_lwpp ? 0 : iter->lwp.lwp_id;
2001-05-04 04:15:33 +00:00
ptid_t ptid = MKTID (PIDGET (inferior_ptid), thrid);
2000-01-18 00:55:13 +00:00
2001-05-04 04:15:33 +00:00
if (!find_thread_pid (ptid) && (!data || thrid == 1))
add_thread_uw (thrid, lwpid, iter->mapp, ptid);
2000-01-18 00:55:13 +00:00
return 0;
}
/* Add to the thread list any threads it doesn't already contain. */
2000-01-18 00:55:13 +00:00
static void
notice_threads (void)
{
thread_iter (notice_thread, NULL);
}
/* Return the address of the main thread's map. On error, return 0. */
2000-01-18 00:55:13 +00:00
static CORE_ADDR
find_main (void)
{
if (!thr_map_main)
{
struct thread_info *info;
thread_iter (notice_thread, (void *)1);
2001-05-04 04:15:33 +00:00
if ((info = find_thread_pid (MKTID (PIDGET (inferior_ptid), 1))))
2000-01-18 00:55:13 +00:00
thr_map_main = info->private->mapp;
}
return thr_map_main;
}
/* Attach to process specified by ARGS, then initialize for debugging it
and wait for the trace-trap that results from attaching.
This function only gets called with uw_thread_active == 0. */
2000-01-18 00:55:13 +00:00
static void
uw_thread_attach (char *args, int from_tty)
{
procfs_ops.to_attach (args, from_tty);
if (uw_thread_active)
thr_infpid (NULL);
}
/* Detach from the process attached to by uw_thread_attach(). */
2000-01-18 00:55:13 +00:00
static void
uw_thread_detach (char *args, int from_tty)
{
deactivate_uw_thread ();
base_ops.to_detach (args, from_tty);
}
/* Tell the inferior process to continue running thread PID if >= 0
and all threads otherwise. */
2000-01-18 00:55:13 +00:00
static void
2001-05-04 04:15:33 +00:00
uw_thread_resume (ptid_t ptid, int step, enum target_signal signo)
2000-01-18 00:55:13 +00:00
{
2001-05-04 04:15:33 +00:00
if (PIDGET (ptid) > 0)
{
ptid = thr_to_lwp (ptid);
if (ptid_equal (ptid, null_ptid))
ptid = pid_to_ptid (-1);
}
2000-01-18 00:55:13 +00:00
2001-05-04 04:15:33 +00:00
CALL_BASE (base_ops.to_resume (ptid, step, signo));
2000-01-18 00:55:13 +00:00
}
/* If the trap we just received from lwp PID was due to a breakpoint
on the libthread.so debugging stub, update this module's state
accordingly. */
2000-01-18 00:55:13 +00:00
static void
2001-05-04 04:15:33 +00:00
libthread_stub (ptid_t ptid)
2000-01-18 00:55:13 +00:00
{
CORE_ADDR sp, mapp, mapp_main;
enum thread_change change;
struct thread_map map;
__lwp_desc_t lwp;
2001-05-04 04:15:33 +00:00
int lwpid;
ptid_t tid = null_ptid;
2000-01-18 00:55:13 +00:00
struct thread_info *info;
/* Check for stub breakpoint. */
2001-05-04 04:15:33 +00:00
if (read_pc_pid (ptid) - DECR_PC_AFTER_BREAK != thr_brk_addr)
2000-01-18 00:55:13 +00:00
return;
/* Retrieve stub args. */
2001-05-04 04:15:33 +00:00
sp = read_register_pid (SP_REGNUM, ptid);
if (!base_ops.deprecated_xfer_memory (sp + SP_ARG0, (char *)&mapp,
sizeof (mapp), 0, NULL, &base_ops))
2000-01-18 00:55:13 +00:00
goto err;
if (!base_ops.deprecated_xfer_memory (sp + SP_ARG0 + sizeof (mapp),
(char *)&change, sizeof (change), 0,
NULL, &base_ops))
2000-01-18 00:55:13 +00:00
goto err;
/* create_inferior() may not have finished yet, so notice the main
thread to ensure that it's displayed first by add_thread(). */
2000-01-18 00:55:13 +00:00
mapp_main = find_main ();
/* Notice thread creation, deletion, or stability change. */
2000-01-18 00:55:13 +00:00
switch (change) {
case tc_switch_begin:
if (!mapp) /* usually means main thread */
mapp = mapp_main;
/* fall through */
case tc_thread_create:
case tc_thread_exit:
if (!mapp)
break;
if (!read_map (mapp, &map))
goto err;
2001-05-04 04:15:33 +00:00
tid = MKTID (PIDGET (ptid), map.thr_tid);
2000-01-18 00:55:13 +00:00
switch (change) {
case tc_thread_create: /* new thread */
if (!map.thr_lwpp)
lwpid = 0;
else if (!read_lwp ((CORE_ADDR)map.thr_lwpp, &lwp))
goto err;
else
lwpid = lwp.lwp_id;
add_thread_uw (map.thr_tid, lwpid, mapp, tid);
break;
case tc_thread_exit: /* thread has exited */
printf_unfiltered ("[Exited %s]\n", target_pid_to_str (tid));
delete_thread (tid);
2001-05-04 04:15:33 +00:00
if (ptid_equal (tid, inferior_ptid))
inferior_ptid = ptid;
2000-01-18 00:55:13 +00:00
break;
case tc_switch_begin: /* lwp is switching threads */
if (switchto_thread)
goto err;
if (!(switchto_thread = find_thread_pid (tid)))
goto err;
switchto_thread->private->stable = 0;
break;
default:
break;
}
break;
case tc_switch_complete: /* lwp has switched threads */
case tc_cancel_complete: /* lwp didn't switch threads */
if (!switchto_thread)
goto err;
if (change == tc_switch_complete)
{
/* If switchto_thread is the main thread, then (a) the corresponding
tc_switch_begin probably received a null map argument and therefore
(b) it may have been a spurious switch following a tc_thread_exit.
Therefore, explicitly query the thread's lwp before caching it in
its thread list entry. */
2000-01-18 00:55:13 +00:00
if (!read_map (switchto_thread->private->mapp, &map))
goto err;
if (map.thr_lwpp)
{
if (!read_lwp ((CORE_ADDR)map.thr_lwpp, &lwp))
goto err;
if ((info = find_thread_lwp (lwp.lwp_id)))
info->private->lwpid = 0;
switchto_thread->private->lwpid = lwp.lwp_id;
}
}
switchto_thread->private->stable = 1;
switchto_thread = NULL;
break;
case tc_invalid:
case tc_thread_suspend:
case tc_thread_suspend_pending:
case tc_thread_continue:
err:
DBG(("unexpected condition in libthread_stub()"));
break;
}
DBG2(("libthread_stub(%s): %s %s %s", dbgpid (pid), dbgpid (tid),
dbgchange (change), tid ? dbgstate (map.thr_state) : ""));
}
/* Wait for thread/lwp/process ID if >= 0 or for any thread otherwise. */
2001-05-04 04:15:33 +00:00
static ptid_t
uw_thread_wait (ptid_t ptid, struct target_waitstatus *status)
2000-01-18 00:55:13 +00:00
{
2001-05-04 04:15:33 +00:00
if (PIDGET (ptid) > 0)
ptid = thr_to_lwp (ptid);
if (PIDGET (ptid) <= 0)
ptid = pid_to_ptid (-1);
CALL_BASE (ptid = base_ops.to_wait (ptid, status));
2000-01-18 00:55:13 +00:00
if (status->kind == TARGET_WAITKIND_STOPPED &&
status->value.sig == TARGET_SIGNAL_TRAP)
2001-05-04 04:15:33 +00:00
libthread_stub (ptid);
2000-01-18 00:55:13 +00:00
2001-05-04 04:15:33 +00:00
return lwp_to_thr (ptid);
2000-01-18 00:55:13 +00:00
}
/* Tell gdb about the registers in the thread/lwp/process specified by
inferior_ptid. */
2000-01-18 00:55:13 +00:00
static void
uw_thread_fetch_registers (int regno)
{
int called;
struct thread_info *info;
struct thread_map map;
TRY_BASE (base_ops.to_fetch_registers (regno), &called);
if (called)
return;
2001-05-04 04:15:33 +00:00
if (!(info = find_thread_pid (inferior_ptid)))
2000-01-18 00:55:13 +00:00
return;
if (!read_map (info->private->mapp, &map))
return;
supply_gregset (&map.thr_ucontext.uc_mcontext.gregs);
supply_fpregset (&map.thr_ucontext.uc_mcontext.fpregs);
}
/* Store gdb's current view of the register set into the thread/lwp/process
specified by inferior_ptid. */
2000-01-18 00:55:13 +00:00
static void
uw_thread_store_registers (int regno)
{
CALL_BASE (base_ops.to_store_registers (regno));
}
/* Prepare to modify the registers array. */
2000-01-18 00:55:13 +00:00
static void
uw_thread_prepare_to_store (void)
{
CALL_BASE (base_ops.to_prepare_to_store ());
}
/* Fork an inferior process and start debugging it.
This function only gets called with uw_thread_active == 0. */
2000-01-18 00:55:13 +00:00
static void
uw_thread_create_inferior (char *exec_file, char *allargs, char **env,
int from_tty)
2000-01-18 00:55:13 +00:00
{
if (uw_thread_active)
deactivate_uw_thread ();
procfs_ops.to_create_inferior (exec_file, allargs, env, from_tty);
2000-01-18 00:55:13 +00:00
if (uw_thread_active)
{
find_main ();
thr_infpid (NULL);
}
}
/* Kill and forget about the inferior process. */
2000-01-18 00:55:13 +00:00
static void
uw_thread_kill (void)
{
base_ops.to_kill ();
}
/* Clean up after the inferior exits. */
2000-01-18 00:55:13 +00:00
static void
uw_thread_mourn_inferior (void)
{
deactivate_uw_thread ();
base_ops.to_mourn_inferior ();
}
/* Return whether this module can attach to and run processes.
This function only gets called with uw_thread_active == 0. */
2000-01-18 00:55:13 +00:00
static int
uw_thread_can_run (void)
{
return procfs_suppress_run;
}
/* Return whether thread PID is still valid. */
2000-01-18 00:55:13 +00:00
static int
2001-05-04 04:15:33 +00:00
uw_thread_alive (ptid_t ptid)
2000-01-18 00:55:13 +00:00
{
2001-05-04 04:15:33 +00:00
if (!ISTID (ptid))
return base_ops.to_thread_alive (ptid);
2000-01-18 00:55:13 +00:00
/* If it's in the thread list, it's valid, because otherwise
libthread_stub() would have deleted it. */
2001-05-04 04:15:33 +00:00
return in_thread_list (ptid);
2000-01-18 00:55:13 +00:00
}
/* Add to the thread list any threads and lwps it doesn't already contain. */
2000-01-18 00:55:13 +00:00
static void
uw_thread_find_new_threads (void)
{
CALL_BASE (if (base_ops.to_find_new_threads)
base_ops.to_find_new_threads ());
notice_threads ();
}
/* Return a string for pretty-printing PID in "info threads" output.
This may be called by either procfs.c or by generic gdb. */
2000-01-18 00:55:13 +00:00
static char *
2001-05-04 04:15:33 +00:00
uw_thread_pid_to_str (ptid_t ptid)
2000-01-18 00:55:13 +00:00
{
2001-05-04 04:15:33 +00:00
#define FMT "Thread %ld"
static char buf[sizeof (FMT) + 3 * sizeof (long)];
2000-01-18 00:55:13 +00:00
2001-05-04 04:15:33 +00:00
if (!ISTID (ptid))
/* core_ops says "process foo", so call procfs_ops explicitly. */
2001-05-04 04:15:33 +00:00
return procfs_ops.to_pid_to_str (ptid);
2000-01-18 00:55:13 +00:00
2001-05-04 04:15:33 +00:00
sprintf (buf, FMT, TIDGET (ptid));
2000-01-18 00:55:13 +00:00
#undef FMT
return buf;
}
/* Return a string displaying INFO state information in "info threads"
output. */
2000-01-18 00:55:13 +00:00
static char *
uw_extra_thread_info (struct thread_info *info)
{
static char buf[80];
struct thread_map map;
__lwp_desc_t lwp;
int lwpid;
char *name;
2001-05-04 04:15:33 +00:00
if (!ISTID (info->ptid))
2000-01-18 00:55:13 +00:00
return NULL;
if (!info->private->stable)
return "switching";
if (!read_map (info->private->mapp, &map))
return NULL;
if (!map.thr_lwpp || !read_lwp ((CORE_ADDR)map.thr_lwpp, &lwp))
lwpid = 0;
else
lwpid = lwp.lwp_id;
switch (map.thr_state) {
case TS_ONPROC: name = "running"; break;
case TS_SLEEP: name = "sleeping"; break;
case TS_RUNNABLE: name = "runnable"; break;
case TS_ZOMBIE: name = "zombie"; break;
case TS_SUSPENDED: name = "suspended"; break;
#ifdef TS_FORK
case TS_FORK: name = "forking"; break;
#endif
default: name = "confused"; break;
}
if (!lwpid)
return name;
sprintf (buf, "%s, LWP %d", name, lwpid);
return buf;
}
/* Check whether libthread.so has just been loaded, and if so, try to
initialize user-space thread debugging support.
libthread.so loading happens while (a) an inferior process is being
started by procfs and (b) a core image is being loaded.
This function often gets called with uw_thread_active == 0. */
2000-01-18 00:55:13 +00:00
static void
libthread_init (void)
{
struct minimal_symbol *ms;
struct thread_debug debug;
CORE_ADDR onp;
struct breakpoint *b;
int one = 1;
/* Don't initialize twice. */
2000-01-18 00:55:13 +00:00
if (uw_thread_active)
return;
/* Check whether libthread.so has been loaded. */
2000-01-18 00:55:13 +00:00
if (!(ms = lookup_minimal_symbol ("_thr_debug", NULL, NULL)))
return;
/* Cache _thr_debug's address. */
2000-01-18 00:55:13 +00:00
if (!(thr_debug_addr = SYMBOL_VALUE_ADDRESS (ms)))
return;
/* Initialize base_ops.deprecated_xfer_memory(). */
2000-01-18 00:55:13 +00:00
base_ops = current_target;
/* Load _thr_debug's current contents. */
2000-01-18 00:55:13 +00:00
if (!read_thr_debug (&debug))
return;
/* User code (e.g. my test programs) may dereference _thr_debug,
making it availble to GDB before shared libs are loaded. */
2000-01-18 00:55:13 +00:00
if (!debug.thr_map)
return;
/* libthread.so has been loaded, and the current_target should now
reflect core_ops or procfs_ops. */
2000-01-18 00:55:13 +00:00
push_target (&uw_thread_ops); /* must precede notice_threads() */
uw_thread_active = 1;
if (!target_has_execution)
/* Locate threads in core file. */
2000-01-18 00:55:13 +00:00
notice_threads ();
else
{
/* Set a breakpoint on the stub function provided by libthread.so. */
2000-01-18 00:55:13 +00:00
thr_brk_addr = (CORE_ADDR)debug.thr_brk;
if (!(b = create_thread_event_breakpoint (thr_brk_addr)))
goto err;
/* Activate the stub function. */
2000-01-18 00:55:13 +00:00
onp = (CORE_ADDR)&((struct thread_debug *)thr_debug_addr)->thr_debug_on;
if (!base_ops.deprecated_xfer_memory ((CORE_ADDR)onp, (char *)&one,
sizeof (one), 1, NULL, &base_ops))
2000-01-18 00:55:13 +00:00
{
delete_breakpoint (b);
goto err;
}
/* Prepare for finding the main thread, which doesn't yet exist. */
2000-01-18 00:55:13 +00:00
thr_map_main = 0;
}
return;
err:
2005-02-10 Andrew Cagney <cagney@gnu.org> Mark up all error and warning messages. * ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update. * bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update. * core-aout.c, core-regset.c, corefile.c, corelow.c: Update. * cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update. * dbxread.c, demangle.c, doublest.c, dsrec.c: Update. * dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update. * dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update. * event-top.c, exec.c, expprint.c, f-lang.c: Update. * f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update. * frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update. * gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update. * hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update. * hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update. * hpread.c, hpux-thread.c, i386-linux-nat.c: Update. * i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update. * i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update. * ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update. * infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update. * inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update. * kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update. * linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update. * m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update. * m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update. * maint.c, mdebugread.c, mem-break.c, memattr.c: Update. * mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update. * nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update. * observer.c, ocd.c, p-lang.c, p-typeprint.c: Update. * p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update. * ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update. * remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update. * remote-rdp.c, remote-sim.c, remote-st.c: Update. * remote-utils.c, remote-utils.h, remote.c: Update. * rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update. * ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update. * sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update. * solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update. * solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update. * somread.c, somsolib.c, source.c, stabsread.c: Update. * stack.c, std-regs.c, symfile-mem.c, symfile.c: Update. * symmisc.c, symtab.c, target.c, thread.c, top.c: Update. * tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update. * uw-thread.c, valarith.c, valops.c, valprint.c: Update. * value.c, varobj.c, version.in, win32-nat.c, wince.c: Update. * xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update. * cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update. * cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update. * mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update. * mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update. * mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update. * tui/tui-win.c: Update.
2005-02-11 04:06:14 +00:00
warning (_("uw-thread: unable to initialize user-mode thread debugging."));
2000-01-18 00:55:13 +00:00
deactivate_uw_thread ();
}
2004-04-21 Andrew Cagney <cagney@redhat.com> * annotate.h (deprecated_annotate_starting_hook) (deprecated_annotate_stopped_hook) (deprecated_annotate_exited_hook) (deprecated_annotate_signal_hook) (deprecated_annotate_signalled_hook): Deprecate. * tracepoint.h (deprecated_create_tracepoint_hook) (deprecated_delete_tracepoint_hook) (deprecated_modify_tracepoint_hook) (deprecated_trace_find_hook) (deprecated_trace_start_stop_hook): Deprecate. * target.h (deprecated_target_new_objfile_hook): Deprecate. * remote.h (deprecated_target_resume_hook) (deprecated_target_wait_loop_hook): Deprecate. * gdbcore.h (deprecated_exec_file_display_hook) (deprecated_file_changed_hook): Deprecate. * frame.h (deprecated_selected_frame_level_changed_hook): Deprecate. * defs.h (deprecated_modify_breakpoint_hook) (deprecated_command_loop_hook, deprecated_show_load_progress) (deprecated_print_frame_info_listing_hook) (deprecated_query_hook, deprecated_warning_hook) (deprecated_flush_hook, deprecated_create_breakpoint_hook) (deprecated_delete_breakpoint_hook) (deprecated_interactive_hook, deprecated_registers_changed_hook) (deprecated_readline_begin_hook, deprecated_readline_hook) (deprecated_readline_end_hook, deprecated_register_changed_hook) (deprecated_memory_changed_hook, deprecated_init_ui_hook) (deprecated_context_hook, deprecated_target_wait_hook) (deprecated_attach_hook, deprecated_detach_hook) (deprecated_call_command_hook, deprecated_set_hook) (deprecated_error_hook, deprecated_error_begin_hook) (deprecated_ui_load_progress_hook): Deprecate. * valops.c, uw-thread.c, utils.c, tui/tui-io.c: Update. * tui/tui-hooks.c, tracepoint.c, top.c, thread-db.c: Update. * target.c, symfile.c, stack.c, sol-thread.c, rs6000-nat.c: Update. * remote.c, remote-mips.c, regcache.c, mi/mi-interp.c: Update. * main.c, interps.c, infcmd.c, hpux-thread.c, frame.c: Update. * exec.c, dsrec.c, d10v-tdep.c, corefile.c, complaints.c: Update. * cli/cli-script.c, cli/cli-setshow.c, breakpoint.c: Update. * annotate.c, aix-thread.c: Update.
2004-04-21 23:52:21 +00:00
/* deprecated_target_new_objfile_hook callback.
If OBJFILE is non-null, check whether libthread.so was just loaded,
and if so, prepare for user-mode thread debugging.
If OBJFILE is null, libthread.so has gone away, so stop debugging
user-mode threads.
This function often gets called with uw_thread_active == 0. */
2000-01-18 00:55:13 +00:00
static void
uw_thread_new_objfile (struct objfile *objfile)
{
if (objfile)
libthread_init ();
else if (uw_thread_active)
deactivate_uw_thread ();
if (target_new_objfile_chain)
target_new_objfile_chain (objfile);
}
/* Initialize uw_thread_ops. */
2000-01-18 00:55:13 +00:00
static void
init_uw_thread_ops (void)
{
uw_thread_ops.to_shortname = "unixware-threads";
uw_thread_ops.to_longname = "UnixWare threads and pthread.";
uw_thread_ops.to_doc = "UnixWare threads and pthread support.";
uw_thread_ops.to_attach = uw_thread_attach;
uw_thread_ops.to_detach = uw_thread_detach;
uw_thread_ops.to_resume = uw_thread_resume;
uw_thread_ops.to_wait = uw_thread_wait;
uw_thread_ops.to_fetch_registers = uw_thread_fetch_registers;
uw_thread_ops.to_store_registers = uw_thread_store_registers;
uw_thread_ops.to_prepare_to_store = uw_thread_prepare_to_store;
uw_thread_ops.to_create_inferior = uw_thread_create_inferior;
uw_thread_ops.to_kill = uw_thread_kill;
uw_thread_ops.to_mourn_inferior = uw_thread_mourn_inferior;
uw_thread_ops.to_can_run = uw_thread_can_run;
uw_thread_ops.to_thread_alive = uw_thread_alive;
uw_thread_ops.to_find_new_threads = uw_thread_find_new_threads;
uw_thread_ops.to_pid_to_str = uw_thread_pid_to_str;
uw_thread_ops.to_extra_thread_info = uw_extra_thread_info;
uw_thread_ops.to_stratum = thread_stratum;
uw_thread_ops.to_magic = OPS_MAGIC;
}
/* Module startup initialization function, automagically called by
init.c. */
2000-01-18 00:55:13 +00:00
void
_initialize_uw_thread (void)
{
init_uw_thread_ops ();
add_target (&uw_thread_ops);
procfs_suppress_run = 1;
/* Notice when libthread.so gets loaded. */
2004-04-21 Andrew Cagney <cagney@redhat.com> * annotate.h (deprecated_annotate_starting_hook) (deprecated_annotate_stopped_hook) (deprecated_annotate_exited_hook) (deprecated_annotate_signal_hook) (deprecated_annotate_signalled_hook): Deprecate. * tracepoint.h (deprecated_create_tracepoint_hook) (deprecated_delete_tracepoint_hook) (deprecated_modify_tracepoint_hook) (deprecated_trace_find_hook) (deprecated_trace_start_stop_hook): Deprecate. * target.h (deprecated_target_new_objfile_hook): Deprecate. * remote.h (deprecated_target_resume_hook) (deprecated_target_wait_loop_hook): Deprecate. * gdbcore.h (deprecated_exec_file_display_hook) (deprecated_file_changed_hook): Deprecate. * frame.h (deprecated_selected_frame_level_changed_hook): Deprecate. * defs.h (deprecated_modify_breakpoint_hook) (deprecated_command_loop_hook, deprecated_show_load_progress) (deprecated_print_frame_info_listing_hook) (deprecated_query_hook, deprecated_warning_hook) (deprecated_flush_hook, deprecated_create_breakpoint_hook) (deprecated_delete_breakpoint_hook) (deprecated_interactive_hook, deprecated_registers_changed_hook) (deprecated_readline_begin_hook, deprecated_readline_hook) (deprecated_readline_end_hook, deprecated_register_changed_hook) (deprecated_memory_changed_hook, deprecated_init_ui_hook) (deprecated_context_hook, deprecated_target_wait_hook) (deprecated_attach_hook, deprecated_detach_hook) (deprecated_call_command_hook, deprecated_set_hook) (deprecated_error_hook, deprecated_error_begin_hook) (deprecated_ui_load_progress_hook): Deprecate. * valops.c, uw-thread.c, utils.c, tui/tui-io.c: Update. * tui/tui-hooks.c, tracepoint.c, top.c, thread-db.c: Update. * target.c, symfile.c, stack.c, sol-thread.c, rs6000-nat.c: Update. * remote.c, remote-mips.c, regcache.c, mi/mi-interp.c: Update. * main.c, interps.c, infcmd.c, hpux-thread.c, frame.c: Update. * exec.c, dsrec.c, d10v-tdep.c, corefile.c, complaints.c: Update. * cli/cli-script.c, cli/cli-setshow.c, breakpoint.c: Update. * annotate.c, aix-thread.c: Update.
2004-04-21 23:52:21 +00:00
target_new_objfile_chain = deprecated_target_new_objfile_hook;
deprecated_target_new_objfile_hook = uw_thread_new_objfile;
2000-01-18 00:55:13 +00:00
}