diff options
-rw-r--r-- | gdb/ChangeLog | 26 | ||||
-rw-r--r-- | gdb/Makefile.in | 4 | ||||
-rw-r--r-- | gdb/common/linux-procfs.c | 55 | ||||
-rw-r--r-- | gdb/common/linux-procfs.h | 29 | ||||
-rw-r--r-- | gdb/config/alpha/alpha-linux.mh | 2 | ||||
-rw-r--r-- | gdb/config/arm/linux.mh | 2 | ||||
-rw-r--r-- | gdb/config/i386/linux.mh | 2 | ||||
-rw-r--r-- | gdb/config/i386/linux64.mh | 3 | ||||
-rw-r--r-- | gdb/config/ia64/linux.mh | 3 | ||||
-rw-r--r-- | gdb/config/m32r/linux.mh | 2 | ||||
-rw-r--r-- | gdb/config/m68k/linux.mh | 2 | ||||
-rw-r--r-- | gdb/config/mips/linux.mh | 3 | ||||
-rw-r--r-- | gdb/config/pa/linux.mh | 3 | ||||
-rw-r--r-- | gdb/config/powerpc/linux.mh | 2 | ||||
-rw-r--r-- | gdb/config/powerpc/ppc64-linux.mh | 2 | ||||
-rw-r--r-- | gdb/config/powerpc/spu-linux.mh | 3 | ||||
-rw-r--r-- | gdb/config/sparc/linux.mh | 3 | ||||
-rw-r--r-- | gdb/config/sparc/linux64.mh | 3 | ||||
-rw-r--r-- | gdb/config/xtensa/linux.mh | 2 | ||||
-rw-r--r-- | gdb/gdbserver/ChangeLog | 4 | ||||
-rw-r--r-- | gdb/gdbserver/configure.srv | 34 | ||||
-rw-r--r-- | gdb/linux-nat.c | 29 | ||||
-rw-r--r-- | gdb/linux-nat.h | 4 | ||||
-rw-r--r-- | gdb/linux-thread-db.c | 1 |
24 files changed, 159 insertions, 64 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 4779484..1da536e 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,29 @@ +2011-08-24 Luis Machado <lgustavo@codesourcery.com> + + * linux-nat.h (linux_proc_get_tgid): Remove declaration. + * linux-nat.c: Include linux-procfs.h. + (linux_proc_get_tgid): Move to ... + * common/linux-procfs.c: ... here. New file. + * common/linux-procfs.h: New file. + * linux-thread-db.c: Include linux-procfs.h. + * Makefile.in: Update dependencies. + * config/alpha/alpha-linux.mh: Add linux-procfs.o dependency. + * config/arm/linux.mh: Likewise. + * config/i386/linux.mh: Likewise. + * config/i386/linux64.mh: Likewise. + * config/ia64/linux.mh: Likewise. + * config/m32r/linux.mh: Likewise. + * config/m68k/linux.mh: Likewise. + * config/mips/linux.mh: Likewise. + * config/pa/linux.mh: Likewise. + * config/pa/linux.mh: Likewise. + * config/powerpc/linux.mh: Likewise. + * config/powerpc/ppc64-linux.mh: Likewise. + * config/powerpc/spu-linux.mh: Likewise. + * config/sparc/linux.mh: Likewise. + * config/sparc/linux64.mh: Likewise. + * config/xtensa/linux.mh: Likewise. + 2011-08-24 Hui Zhu <teawater@gmail.com> * tracepoint.c (cond_string_is_same): New function. diff --git a/gdb/Makefile.in b/gdb/Makefile.in index bd00644..a3bd1f9 100644 --- a/gdb/Makefile.in +++ b/gdb/Makefile.in @@ -1959,6 +1959,10 @@ linux-osdata.o: ${srcdir}/common/linux-osdata.c $(COMPILE) $(srcdir)/common/linux-osdata.c $(POSTCOMPILE) +linux-procfs.o: $(srcdir)/common/linux-procfs.c + $(COMPILE) $(srcdir)/common/linux-procfs.c + $(POSTCOMPILE) + # # gdb/tui/ dependencies # diff --git a/gdb/common/linux-procfs.c b/gdb/common/linux-procfs.c new file mode 100644 index 0000000..33730b2 --- /dev/null +++ b/gdb/common/linux-procfs.c @@ -0,0 +1,55 @@ +/* Linux-specific PROCFS manipulation routines. + Copyright (C) 2009, 2010, 2011 Free Software Foundation, Inc. + + 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 3 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, see <http://www.gnu.org/licenses/>. */ + +#ifdef GDBSERVER +#include "server.h" +#else +#include "defs.h" +#include "gdb_string.h" +#endif + +#include "linux-procfs.h" + +/* Return the TGID of LWPID from /proc/pid/status. Returns -1 if not + found. */ + +int +linux_proc_get_tgid (int lwpid) +{ + FILE *status_file; + char buf[100]; + int tgid = -1; + + snprintf (buf, sizeof (buf), "/proc/%d/status", (int) lwpid); + status_file = fopen (buf, "r"); + if (status_file != NULL) + { + while (fgets (buf, sizeof (buf), status_file)) + { + if (strncmp (buf, "Tgid:", 5) == 0) + { + tgid = strtoul (buf + strlen ("Tgid:"), NULL, 10); + break; + } + } + + fclose (status_file); + } + + return tgid; +} diff --git a/gdb/common/linux-procfs.h b/gdb/common/linux-procfs.h new file mode 100644 index 0000000..bdfa569 --- /dev/null +++ b/gdb/common/linux-procfs.h @@ -0,0 +1,29 @@ +/* Linux-specific PROCFS manipulation routines. + Copyright (C) 2011 Free Software Foundation, Inc. + + 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 3 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, see <http://www.gnu.org/licenses/>. */ + +#ifndef COMMON_LINUX_PROCFS_H +#define COMMON_LINUX_PROCFS_H + +#include <unistd.h> + +/* Return the TGID of LWPID from /proc/pid/status. Returns -1 if not + found. */ + +extern int linux_proc_get_tgid (int lwpid); + +#endif /* COMMON_LINUX_PROCFS_H */ diff --git a/gdb/config/alpha/alpha-linux.mh b/gdb/config/alpha/alpha-linux.mh index 1a6949d..ddfb19b 100644 --- a/gdb/config/alpha/alpha-linux.mh +++ b/gdb/config/alpha/alpha-linux.mh @@ -2,7 +2,7 @@ NAT_FILE= config/nm-linux.h NATDEPFILES= inf-ptrace.o corelow.o alpha-linux-nat.o \ fork-child.o proc-service.o linux-thread-db.o \ - linux-nat.o linux-osdata.o linux-fork.o + linux-nat.o linux-osdata.o linux-fork.o linux-procfs.o NAT_CDEPS = $(srcdir)/proc-service.list # The dynamically loaded libthread_db needs access to symbols in the diff --git a/gdb/config/arm/linux.mh b/gdb/config/arm/linux.mh index c5e93f3..78918d2 100644 --- a/gdb/config/arm/linux.mh +++ b/gdb/config/arm/linux.mh @@ -3,7 +3,7 @@ NAT_FILE= config/nm-linux.h NATDEPFILES= inf-ptrace.o fork-child.o arm-linux-nat.o \ proc-service.o linux-thread-db.o \ - linux-nat.o linux-osdata.o linux-fork.o + linux-nat.o linux-osdata.o linux-fork.o linux-procfs.o NAT_CDEPS = $(srcdir)/proc-service.list LOADLIBES= -ldl $(RDYNAMIC) diff --git a/gdb/config/i386/linux.mh b/gdb/config/i386/linux.mh index 3d7745b..3a158c6 100644 --- a/gdb/config/i386/linux.mh +++ b/gdb/config/i386/linux.mh @@ -4,7 +4,7 @@ NAT_FILE= config/nm-linux.h NATDEPFILES= inf-ptrace.o fork-child.o \ i386-nat.o i386-linux-nat.o \ proc-service.o linux-thread-db.o \ - linux-nat.o linux-osdata.o linux-fork.o + linux-nat.o linux-osdata.o linux-fork.o linux-procfs.o NAT_CDEPS = $(srcdir)/proc-service.list # The dynamically loaded libthread_db needs access to symbols in the diff --git a/gdb/config/i386/linux64.mh b/gdb/config/i386/linux64.mh index c826dc9..a5e8c14 100644 --- a/gdb/config/i386/linux64.mh +++ b/gdb/config/i386/linux64.mh @@ -2,7 +2,8 @@ NATDEPFILES= inf-ptrace.o fork-child.o \ i386-nat.o amd64-nat.o amd64-linux-nat.o \ linux-nat.o linux-osdata.o \ - proc-service.o linux-thread-db.o linux-fork.o + proc-service.o linux-thread-db.o linux-fork.o \ + linux-procfs.o NAT_FILE= config/nm-linux.h NAT_CDEPS = $(srcdir)/proc-service.list diff --git a/gdb/config/ia64/linux.mh b/gdb/config/ia64/linux.mh index df45b97..5114899 100644 --- a/gdb/config/ia64/linux.mh +++ b/gdb/config/ia64/linux.mh @@ -4,7 +4,8 @@ NAT_FILE= config/nm-linux.h NATDEPFILES= inf-ptrace.o fork-child.o corelow.o \ core-regset.o ia64-linux-nat.o \ proc-service.o linux-thread-db.o \ - linux-nat.o linux-osdata.o linux-fork.o + linux-nat.o linux-osdata.o linux-fork.o \ + linux-procfs.o NAT_CDEPS = $(srcdir)/proc-service.list LOADLIBES = -ldl $(RDYNAMIC) diff --git a/gdb/config/m32r/linux.mh b/gdb/config/m32r/linux.mh index 241520d..b4849ae 100644 --- a/gdb/config/m32r/linux.mh +++ b/gdb/config/m32r/linux.mh @@ -3,7 +3,7 @@ NAT_FILE= config/nm-linux.h NATDEPFILES= inf-ptrace.o fork-child.o corelow.o \ m32r-linux-nat.o proc-service.o linux-thread-db.o \ - linux-nat.o linux-osdata.o linux-fork.o + linux-nat.o linux-osdata.o linux-fork.o linux-procfs.o NAT_CDEPS = $(srcdir)/proc-service.list LOADLIBES= -ldl $(RDYNAMIC) diff --git a/gdb/config/m68k/linux.mh b/gdb/config/m68k/linux.mh index b54921c..3a95828 100644 --- a/gdb/config/m68k/linux.mh +++ b/gdb/config/m68k/linux.mh @@ -4,7 +4,7 @@ NAT_FILE= config/nm-linux.h NATDEPFILES= inf-ptrace.o fork-child.o \ corelow.o m68klinux-nat.o \ proc-service.o linux-thread-db.o \ - linux-nat.o linux-osdata.o linux-fork.o + linux-nat.o linux-osdata.o linux-fork.o linux-procfs.o NAT_CDEPS = $(srcdir)/proc-service.list # The dynamically loaded libthread_db needs access to symbols in the diff --git a/gdb/config/mips/linux.mh b/gdb/config/mips/linux.mh index 4f735ba..1ef3bce 100644 --- a/gdb/config/mips/linux.mh +++ b/gdb/config/mips/linux.mh @@ -2,7 +2,8 @@ NAT_FILE= config/nm-linux.h NATDEPFILES= inf-ptrace.o fork-child.o mips-linux-nat.o \ linux-thread-db.o proc-service.o \ - linux-nat.o linux-osdata.o linux-fork.o + linux-nat.o linux-osdata.o linux-fork.o \ + linux-procfs.o NAT_CDEPS = $(srcdir)/proc-service.list LOADLIBES = -ldl $(RDYNAMIC) diff --git a/gdb/config/pa/linux.mh b/gdb/config/pa/linux.mh index e49c91e..4ed8cbf 100644 --- a/gdb/config/pa/linux.mh +++ b/gdb/config/pa/linux.mh @@ -2,7 +2,8 @@ NAT_FILE= config/nm-linux.h NATDEPFILES= inf-ptrace.o fork-child.o corelow.o \ hppa-linux-nat.o proc-service.o linux-thread-db.o \ - linux-nat.o linux-osdata.o linux-fork.o + linux-nat.o linux-osdata.o linux-fork.o \ + linux-procfs.o NAT_CDEPS = $(srcdir)/proc-service.list LOADLIBES = -ldl $(RDYNAMIC) diff --git a/gdb/config/powerpc/linux.mh b/gdb/config/powerpc/linux.mh index 49fac1d..0ae9368 100644 --- a/gdb/config/powerpc/linux.mh +++ b/gdb/config/powerpc/linux.mh @@ -5,7 +5,7 @@ XM_CLIBS= NAT_FILE= config/nm-linux.h NATDEPFILES= inf-ptrace.o fork-child.o \ ppc-linux-nat.o proc-service.o linux-thread-db.o \ - linux-nat.o linux-osdata.o linux-fork.o + linux-nat.o linux-osdata.o linux-fork.o linux-procfs.o NAT_CDEPS = $(srcdir)/proc-service.list LOADLIBES = -ldl $(RDYNAMIC) diff --git a/gdb/config/powerpc/ppc64-linux.mh b/gdb/config/powerpc/ppc64-linux.mh index c822e83..bf1bb5b 100644 --- a/gdb/config/powerpc/ppc64-linux.mh +++ b/gdb/config/powerpc/ppc64-linux.mh @@ -5,7 +5,7 @@ XM_CLIBS= NAT_FILE= config/nm-linux.h NATDEPFILES= inf-ptrace.o fork-child.o \ ppc-linux-nat.o proc-service.o linux-thread-db.o \ - linux-nat.o linux-osdata.o linux-fork.o + linux-nat.o linux-osdata.o linux-fork.o linux-procfs.o NAT_CDEPS = $(srcdir)/proc-service.list # The PowerPC has severe limitations on TOC size, and uses them even diff --git a/gdb/config/powerpc/spu-linux.mh b/gdb/config/powerpc/spu-linux.mh index 068d294..f6e7396 100644 --- a/gdb/config/powerpc/spu-linux.mh +++ b/gdb/config/powerpc/spu-linux.mh @@ -3,5 +3,6 @@ # This implements a 'pseudo-native' GDB running on the # PPU side of the Cell BE and debugging the SPU side. -NATDEPFILES = spu-linux-nat.o fork-child.o inf-ptrace.o +NATDEPFILES = spu-linux-nat.o fork-child.o inf-ptrace.o \ + linux-procfs.o diff --git a/gdb/config/sparc/linux.mh b/gdb/config/sparc/linux.mh index fe8e1e7..a9a768c 100644 --- a/gdb/config/sparc/linux.mh +++ b/gdb/config/sparc/linux.mh @@ -3,7 +3,8 @@ NAT_FILE= config/nm-linux.h NATDEPFILES= sparc-nat.o sparc-linux-nat.o \ corelow.o core-regset.o fork-child.o inf-ptrace.o \ proc-service.o linux-thread-db.o \ - linux-nat.o linux-osdata.o linux-fork.o + linux-nat.o linux-osdata.o linux-fork.o \ + linux-procfs.o NAT_CDEPS = $(srcdir)/proc-service.list # The dynamically loaded libthread_db needs access to symbols in the diff --git a/gdb/config/sparc/linux64.mh b/gdb/config/sparc/linux64.mh index 639e3d0..30eef2b 100644 --- a/gdb/config/sparc/linux64.mh +++ b/gdb/config/sparc/linux64.mh @@ -4,7 +4,8 @@ NATDEPFILES= sparc-nat.o sparc64-nat.o sparc64-linux-nat.o \ corelow.o core-regset.o \ fork-child.o inf-ptrace.o \ proc-service.o linux-thread-db.o \ - linux-nat.o linux-osdata.o linux-fork.o + linux-nat.o linux-osdata.o linux-fork.o \ + linux-procfs.o NAT_CDEPS = $(srcdir)/proc-service.list # The dynamically loaded libthread_db needs access to symbols in the diff --git a/gdb/config/xtensa/linux.mh b/gdb/config/xtensa/linux.mh index 4abd242..c637ec7 100644 --- a/gdb/config/xtensa/linux.mh +++ b/gdb/config/xtensa/linux.mh @@ -4,7 +4,7 @@ NAT_FILE= config/nm-linux.h NATDEPFILES= inf-ptrace.o fork-child.o xtensa-linux-nat.o \ linux-thread-db.o proc-service.o \ - linux-nat.o linux-osdata.o linux-fork.o + linux-nat.o linux-osdata.o linux-fork.o linux-procfs.o NAT_CDEPS = $(srcdir)/proc-service.list LOADLIBES = -ldl $(RDYNAMIC) diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog index c9a1375..7176e8b 100644 --- a/gdb/gdbserver/ChangeLog +++ b/gdb/gdbserver/ChangeLog @@ -1,3 +1,7 @@ +2011-08-24 Luis Machado <lgustavo@codesourcery.com> + + * configure.srv: Add linux-procfs.o dependencies. + 2011-08-14 Yao Qi <yao@codesourcery.com> * target.h (struct target_ops): Fix indent. diff --git a/gdb/gdbserver/configure.srv b/gdb/gdbserver/configure.srv index 811dfdc..5c4900e 100644 --- a/gdb/gdbserver/configure.srv +++ b/gdb/gdbserver/configure.srv @@ -46,7 +46,7 @@ case "${target}" in srv_regobj="${srv_regobj} arm-with-vfpv2.o" srv_regobj="${srv_regobj} arm-with-vfpv3.o" srv_regobj="${srv_regobj} arm-with-neon.o" - srv_tgtobj="linux-low.o linux-osdata.o linux-arm-low.o" + srv_tgtobj="linux-low.o linux-osdata.o linux-arm-low.o linux-procfs.o" srv_xmlfiles="arm-with-iwmmxt.xml" srv_xmlfiles="${srv_xmlfiles} arm-with-vfpv2.xml" srv_xmlfiles="${srv_xmlfiles} arm-with-vfpv3.xml" @@ -68,17 +68,17 @@ case "${target}" in srv_mingwce=yes ;; bfin-*-*linux*) srv_regobj=reg-bfin.o - srv_tgtobj="linux-low.o linux-osdata.o linux-bfin-low.o" + srv_tgtobj="linux-low.o linux-osdata.o linux-bfin-low.o linux-procfs.o" srv_linux_usrregs=yes srv_linux_thread_db=yes ;; crisv32-*-linux*) srv_regobj=reg-crisv32.o - srv_tgtobj="linux-low.o linux-osdata.o linux-crisv32-low.o" + srv_tgtobj="linux-low.o linux-osdata.o linux-crisv32-low.o linux-procfs.o" srv_linux_regsets=yes srv_linux_thread_db=yes ;; cris-*-linux*) srv_regobj=reg-cris.o - srv_tgtobj="linux-low.o linux-osdata.o linux-cris-low.o" + srv_tgtobj="linux-low.o linux-osdata.o linux-cris-low.o linux-procfs.o" srv_linux_usrregs=yes srv_linux_thread_db=yes ;; @@ -92,7 +92,7 @@ case "${target}" in srv_regobj="$srv_regobj $srv_amd64_linux_regobj" srv_xmlfiles="${srv_xmlfiles} $srv_amd64_linux_xmlfiles" fi - srv_tgtobj="linux-low.o linux-osdata.o linux-x86-low.o i386-low.o i387-fp.o" + srv_tgtobj="linux-low.o linux-osdata.o linux-x86-low.o i386-low.o i387-fp.o linux-procfs.o" srv_linux_usrregs=yes srv_linux_regsets=yes srv_linux_thread_db=yes @@ -123,11 +123,11 @@ case "${target}" in srv_qnx="yes" ;; ia64-*-linux*) srv_regobj=reg-ia64.o - srv_tgtobj="linux-low.o linux-osdata.o linux-ia64-low.o" + srv_tgtobj="linux-low.o linux-osdata.o linux-ia64-low.o linux-procfs.o" srv_linux_usrregs=yes ;; m32r*-*-linux*) srv_regobj=reg-m32r.o - srv_tgtobj="linux-low.o linux-osdata.o linux-m32r-low.o" + srv_tgtobj="linux-low.o linux-osdata.o linux-m32r-low.o linux-procfs.o" srv_linux_usrregs=yes srv_linux_thread_db=yes ;; @@ -136,7 +136,7 @@ case "${target}" in else srv_regobj=reg-m68k.o fi - srv_tgtobj="linux-low.o linux-osdata.o linux-m68k-low.o" + srv_tgtobj="linux-low.o linux-osdata.o linux-m68k-low.o linux-procfs.o" srv_linux_usrregs=yes srv_linux_regsets=yes srv_linux_thread_db=yes @@ -146,13 +146,13 @@ case "${target}" in else srv_regobj=reg-m68k.o fi - srv_tgtobj="linux-low.o linux-osdata.o linux-m68k-low.o" + srv_tgtobj="linux-low.o linux-osdata.o linux-m68k-low.o linux-procfs.o" srv_linux_usrregs=yes srv_linux_regsets=yes srv_linux_thread_db=yes ;; mips*-*-linux*) srv_regobj="mips-linux.o mips64-linux.o" - srv_tgtobj="linux-low.o linux-osdata.o linux-mips-low.o" + srv_tgtobj="linux-low.o linux-osdata.o linux-mips-low.o linux-procfs.o" srv_xmlfiles="mips-linux.xml" srv_xmlfiles="${srv_xmlfiles} mips-cpu.xml" srv_xmlfiles="${srv_xmlfiles} mips-cp0.xml" @@ -180,7 +180,7 @@ case "${target}" in srv_regobj="${srv_regobj} powerpc-isa205-64l.o" srv_regobj="${srv_regobj} powerpc-isa205-altivec64l.o" srv_regobj="${srv_regobj} powerpc-isa205-vsx64l.o" - srv_tgtobj="linux-low.o linux-osdata.o linux-ppc-low.o" + srv_tgtobj="linux-low.o linux-osdata.o linux-ppc-low.o linux-procfs.o" srv_xmlfiles="rs6000/powerpc-32l.xml" srv_xmlfiles="${srv_xmlfiles} rs6000/powerpc-altivec32l.xml" srv_xmlfiles="${srv_xmlfiles} rs6000/powerpc-cell32l.xml" @@ -216,7 +216,7 @@ case "${target}" in s390*-*-linux*) srv_regobj="s390-linux32.o" srv_regobj="${srv_regobj} s390-linux64.o" srv_regobj="${srv_regobj} s390x-linux64.o" - srv_tgtobj="linux-low.o linux-osdata.o linux-s390-low.o" + srv_tgtobj="linux-low.o linux-osdata.o linux-s390-low.o linux-procfs.o" srv_xmlfiles="s390-linux32.xml" srv_xmlfiles="${srv_xmlfiles} s390-linux64.xml" srv_xmlfiles="${srv_xmlfiles} s390x-linux64.xml" @@ -230,13 +230,13 @@ case "${target}" in srv_linux_thread_db=yes ;; sh*-*-linux*) srv_regobj=reg-sh.o - srv_tgtobj="linux-low.o linux-osdata.o linux-sh-low.o" + srv_tgtobj="linux-low.o linux-osdata.o linux-sh-low.o linux-procfs.o" srv_linux_usrregs=yes srv_linux_regsets=yes srv_linux_thread_db=yes ;; sparc*-*-linux*) srv_regobj=reg-sparc64.o - srv_tgtobj="linux-low.o linux-osdata.o linux-sparc-low.o" + srv_tgtobj="linux-low.o linux-osdata.o linux-sparc-low.o linux-procfs.o" srv_linux_regsets=yes srv_linux_thread_db=yes ;; @@ -252,13 +252,13 @@ case "${target}" in srv_xmlfiles="${srv_xmlfiles} tic6x-core.xml" srv_xmlfiles="${srv_xmlfiles} tic6x-gp.xml" srv_xmlfiles="${srv_xmlfiles} tic6x-c6xp.xml" - srv_tgtobj="linux-low.o linux-osdata.o linux-tic6x-low.o" + srv_tgtobj="linux-low.o linux-osdata.o linux-tic6x-low.o linux-procfs.o" srv_linux_regsets=yes srv_linux_usrregs=yes srv_linux_thread_db=yes ;; x86_64-*-linux*) srv_regobj="$srv_amd64_linux_regobj $srv_i386_linux_regobj" - srv_tgtobj="linux-low.o linux-osdata.o linux-x86-low.o i386-low.o i387-fp.o" + srv_tgtobj="linux-low.o linux-osdata.o linux-x86-low.o i386-low.o i387-fp.o linux-procfs.o" srv_xmlfiles="$srv_i386_linux_xmlfiles $srv_amd64_linux_xmlfiles" srv_linux_usrregs=yes # This is for i386 progs. srv_linux_regsets=yes @@ -272,7 +272,7 @@ case "${target}" in ;; xtensa*-*-linux*) srv_regobj=reg-xtensa.o - srv_tgtobj="linux-low.o linux-osdata.o linux-xtensa-low.o" + srv_tgtobj="linux-low.o linux-osdata.o linux-xtensa-low.o linux-procfs.o" srv_linux_regsets=yes ;; *) echo "Error: target not supported by gdbserver." diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c index c832902..b146888 100644 --- a/gdb/linux-nat.c +++ b/gdb/linux-nat.c @@ -31,6 +31,7 @@ #include <sys/ptrace.h> #include "linux-nat.h" #include "linux-ptrace.h" +#include "linux-procfs.h" #include "linux-fork.h" #include "gdbthread.h" #include "gdbcmd.h" @@ -1285,34 +1286,6 @@ exit_lwp (struct lwp_info *lp) delete_lwp (lp->ptid); } -/* Return an lwp's tgid, found in `/proc/PID/status'. */ - -int -linux_proc_get_tgid (int lwpid) -{ - FILE *status_file; - char buf[100]; - int tgid = -1; - - snprintf (buf, sizeof (buf), "/proc/%d/status", (int) lwpid); - status_file = fopen (buf, "r"); - if (status_file != NULL) - { - while (fgets (buf, sizeof (buf), status_file)) - { - if (strncmp (buf, "Tgid:", 5) == 0) - { - tgid = strtoul (buf + strlen ("Tgid:"), NULL, 10); - break; - } - } - - fclose (status_file); - } - - return tgid; -} - /* Detect `T (stopped)' in `/proc/PID/status'. Other states including `T (tracing stop)' are reported as false. */ diff --git a/gdb/linux-nat.h b/gdb/linux-nat.h index 42cb2fc..12fda0f 100644 --- a/gdb/linux-nat.h +++ b/gdb/linux-nat.h @@ -125,10 +125,6 @@ extern void lin_thread_get_thread_signals (sigset_t *mask); void linux_proc_pending_signals (int pid, sigset_t *pending, sigset_t *blocked, sigset_t *ignored); -/* Return the TGID of LWPID from /proc/pid/status. Returns -1 if not - found. */ -extern int linux_proc_get_tgid (int lwpid); - /* linux-nat functions for handling fork events. */ extern void linux_enable_event_reporting (ptid_t ptid); diff --git a/gdb/linux-thread-db.c b/gdb/linux-thread-db.c index 6427f8b..dda2bff 100644 --- a/gdb/linux-thread-db.c +++ b/gdb/linux-thread-db.c @@ -40,6 +40,7 @@ #include "gdbcore.h" #include "observer.h" #include "linux-nat.h" +#include "linux-procfs.h" #include <signal.h> |