diff options
-rw-r--r-- | gdb/ChangeLog | 14 | ||||
-rw-r--r-- | gdb/Makefile.in | 4 | ||||
-rw-r--r-- | gdb/config/i386/nbsdaout.mh | 2 | ||||
-rw-r--r-- | gdb/config/i386/nbsdelf.mh | 2 | ||||
-rw-r--r-- | gdb/i386nbsd-nat.c | 9 | ||||
-rw-r--r-- | gdb/nbsd-nat.c | 47 | ||||
-rw-r--r-- | gdb/nbsd-nat.h | 30 |
7 files changed, 103 insertions, 5 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 10c769d..084534e 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,17 @@ +2006-12-17 Nick Hudson <skrll@netbsd.org> + Mark Kettenis <kettenis@gnu.org> + + * i386nbsd-nat.c: Include "nbsd-nat.h". + (_initialize_i386nbsd_nat): Update target vector to use + nbsd_pid_to_exec_file. + * config/i386/nbsdelf.mh (NATDEPFILES): Add nbsd-nat.o. + * config/i386/nbsdaout.mh (NATDEPFILES): Add nbsd-nat.o. + * nbsd-nat.c: New file. + * nbsd-nat.h: New file. + * Makefile.in (ALLDEPFILES): Add nbsd-nat.c. + (nbsd_nat_h): New variable. + (nbsd-nat.o): New dependency. + 2006-12-16 Daniel Jacobowitz <dan@codesourcery.com> * Makefile.in (ALLDEPFILES): Remove mipsv4-nat.c. diff --git a/gdb/Makefile.in b/gdb/Makefile.in index 136ad81..6b390df 100644 --- a/gdb/Makefile.in +++ b/gdb/Makefile.in @@ -758,6 +758,7 @@ mips_tdep_h = mips-tdep.h memory_map_h = memory-map.h $(memattr_h) mn10300_tdep_h = mn10300-tdep.h monitor_h = monitor.h +nbsd_nat_h = nbsd-nat.h nbsd_tdep_h = nbsd-tdep.h nto_tdep_h = nto-tdep.h $(defs_h) $(solist_h) $(osabi_h) $(regset_h) objc_lang_h = objc-lang.h @@ -1476,7 +1477,7 @@ ALLDEPFILES = \ mips-tdep.c \ mipsnbsd-nat.c mipsnbsd-tdep.c \ mips64obsd-nat.c mips64obsd-tdep.c \ - nbsd-tdep.c obsd-tdep.c \ + nbsd-nat.c nbsd-tdep.c obsd-tdep.c \ solib-osf.c \ somread.c solib-som.c $(HPREAD_SOURCE) \ posix-hdep.c \ @@ -2400,6 +2401,7 @@ ms1-tdep.o: ms1-tdep.c $(defs_h) $(frame_h) $(frame_unwind_h) $(frame_base_h) \ $(gdb_string_h) $(regcache_h) $(reggroups_h) $(gdbcore_h) \ $(trad_frame_h) $(inferior_h) $(dwarf2_frame_h) $(infcall_h) \ $(gdb_assert_h) +nbsd-nat.o: nbsd-nat.c $(defs_h) $(nbsd_nat_h) nbsd-tdep.o: nbsd-tdep.c $(defs_h) $(gdb_string_h) $(solib_svr4_h) nlmread.o: nlmread.c $(defs_h) $(bfd_h) $(symtab_h) $(symfile_h) \ $(objfiles_h) $(buildsym_h) $(stabsread_h) $(block_h) diff --git a/gdb/config/i386/nbsdaout.mh b/gdb/config/i386/nbsdaout.mh index a14130a..9ea1952 100644 --- a/gdb/config/i386/nbsdaout.mh +++ b/gdb/config/i386/nbsdaout.mh @@ -1,6 +1,6 @@ # Host: NetBSD/i386 a.out NATDEPFILES= fork-child.o inf-ptrace.o \ - i386bsd-nat.o i386nbsd-nat.o bsd-kvm.o \ + nbsd-nat.o i386bsd-nat.o i386nbsd-nat.o bsd-kvm.o \ solib.o solib-sunos.o LOADLIBES= -lkvm diff --git a/gdb/config/i386/nbsdelf.mh b/gdb/config/i386/nbsdelf.mh index be18b4d..d27c842 100644 --- a/gdb/config/i386/nbsdelf.mh +++ b/gdb/config/i386/nbsdelf.mh @@ -1,5 +1,5 @@ # Host: NetBSD/i386 ELF NATDEPFILES= fork-child.o inf-ptrace.o \ - i386bsd-nat.o i386nbsd-nat.o bsd-kvm.o + nbsd-nat.o i386bsd-nat.o i386nbsd-nat.o bsd-kvm.o LOADLIBES= -lkvm diff --git a/gdb/i386nbsd-nat.c b/gdb/i386nbsd-nat.c index 80a7691..831f775 100644 --- a/gdb/i386nbsd-nat.c +++ b/gdb/i386nbsd-nat.c @@ -33,6 +33,7 @@ #include <machine/frame.h> #include <machine/pcb.h> +#include "nbsd-nat.h" #include "bsd-kvm.h" static int @@ -79,9 +80,13 @@ void _initialize_i386nbsd_nat (void); void _initialize_i386nbsd_nat (void) { - /* We've got nothing to add to the common *BSD/i386 target. */ - add_target (i386bsd_target ()); + struct target_ops *t; + /* Add some extra features to the common *BSD/i386 target. */ + t = i386bsd_target (); + t->to_pid_to_exec_file = nbsd_pid_to_exec_file; + add_target (t); + /* Support debugging kernel virtual memory images. */ bsd_kvm_add_target (i386nbsd_supply_pcb); } diff --git a/gdb/nbsd-nat.c b/gdb/nbsd-nat.c new file mode 100644 index 0000000..e0b9ecf --- /dev/null +++ b/gdb/nbsd-nat.c @@ -0,0 +1,47 @@ +/* Native-dependent code for NetBSD. + + Copyright (C) 2006 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 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 + Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include "defs.h" + +#include <sys/param.h> + +#include "nbsd-nat.h" + +/* Return a the name of file that can be opened to get the symbols for + the child process identified by PID. */ + +char * +nbsd_pid_to_exec_file (int pid) +{ + size_t len = MAXPATHLEN; + char *buf = xcalloc (len, sizeof (char)); + char *path; + + path = xstrprintf ("/proc/%d/exe", pid); + if (readlink (path, buf, MAXPATHLEN) == -1) + { + xfree (buf); + buf = NULL; + } + + xfree (path); + return buf; +} diff --git a/gdb/nbsd-nat.h b/gdb/nbsd-nat.h new file mode 100644 index 0000000..a050af2 --- /dev/null +++ b/gdb/nbsd-nat.h @@ -0,0 +1,30 @@ +/* Native-dependent code for NetBSD. + + Copyright (C) 2006 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 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 + Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. */ + +#ifndef NBSD_NAT_H +#define NBSD_NAT_H + +/* Return a the name of file that can be opened to get the symbols for + the child process identified by PID. */ + +extern char *nbsd_pid_to_exec_file (int pid); + +#endif /* nbsd-nat.h */ |