+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.
$(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
#
--- /dev/null
+/* 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;
+}
--- /dev/null
+/* 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 */
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
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)
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
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
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)
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)
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
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)
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)
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)
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
# 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
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
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
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)
+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.
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"
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
;;
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
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
;;
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
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"
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"
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"
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
;;
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
;;
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."
#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"
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. */
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);
#include "gdbcore.h"
#include "observer.h"
#include "linux-nat.h"
+#include "linux-procfs.h"
#include <signal.h>