This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

further procfs.c targets allround cleanup (removes TARGET_HAS_HARDWARE_WATCHPOINTS and an nm header)


Yet more flushing of solaris patches I had started on months ago.

After having introduced the procfs_target function, this moves
the add_target call from procfs.c to per-target|arch native files,
customizing them a bit along the way, like we do for linux native
targets.

This effectivelly kills TARGET_HAS_HARDWARE_WATCHPOINTS, and ends
up removing one nm header -- the mips irix one.

I've confirmed that watchpoints still work on i386-solaris.

Checked in.

Solaris gdb is still very broken, though, close to unuseable.

-- 
Pedro Alves

2009-06-07  Pedro Alves  <pedro@codesourcery.com>

	* procfs.h: New.
	* proc-utils.h (procfs_first_available): Don't declare here.
	* sol-thread.c: Include procfs.h instead of sys/procfs.h and
	proc-utils.h.
	* procfs.c: Include procfs.h.
	(procfs_target): Make it public.  Don't register
	procfs_can_use_hw_breakpoint here.
	(proc_set_watchpoint): Check for PCWATCH or PIOCSWATCH being
	defined instead of TARGET_HAS_HARDWARE_WATCHPOINTS.
	(procfs_can_use_hw_breakpoint): Remove check of
	TARGET_HAS_HARDWARE_WATCHPOINTS.
	(procfs_use_watchpoints): Register procfs_can_use_hw_breakpoint
	here.
	(_initialize_procfs): Don't add the procfs target here.

	* i386-sol2-nat.c: Include target.h and procfs.h.
	(_initialize_amd64_sol2_nat): Install the procfs target here,
	customized with watchpoints support.
	* irix5-nat.c: Include target.h.
	(_initialize_core_irix5): Rename to ...
	(_initialize_irix5_nat): ... this.  Install the procfs target
	here, customized with watchpoints support.
	* alpha-nat.c: Include procfs.h.
	(_initialize_core_alpha): Rename to...
	(_initialize_alpha_nat): ... this.  Install the procfs target
	here, customized with watchpoints support.
	* sparc-sol2-nat.c: Include target.h and procfs.h.
	(_initialize_sparc_sol2_nat): New.

	* config/i386/nm-i386sol2.h (TARGET_HAS_HARDWARE_WATCHPOINTS): Delete.
	* config/sparc/nm-sol2.h (TARGET_HAS_HARDWARE_WATCHPOINTS): Delete.
	* config/mips/irix5.mh (NAT_FILE): Delete.
	* config/mips/irix6.mh (NAT_FILE): Delete.
	* config/mips/nm-irix5.h: Delete.

doc/
2009-06-07  Pedro Alves  <pedro@codesourcery.com>

	* gdbint.texinfo (TARGET_HAS_HARDWARE_WATCHPOINTS): Delete all
	references.

---
 gdb/alpha-nat.c               |   11 ++++++++++-
 gdb/config/i386/nm-i386sol2.h |    2 --
 gdb/config/mips/irix5.mh      |    1 -
 gdb/config/mips/irix6.mh      |    1 -
 gdb/config/mips/nm-irix5.h    |   21 ---------------------
 gdb/config/sparc/nm-sol2.h    |    9 ---------
 gdb/doc/gdbint.texinfo        |    5 -----
 gdb/i386-sol2-nat.c           |   13 +++++++++++++
 gdb/irix5-nat.c               |   12 +++++++++++-
 gdb/proc-utils.h              |    5 -----
 gdb/procfs.c                  |   24 +++++++-----------------
 gdb/procfs.h                  |   36 ++++++++++++++++++++++++++++++++++++
 gdb/sol-thread.c              |    3 +--
 gdb/sparc-sol2-nat.c          |   17 +++++++++++++++++
 14 files changed, 95 insertions(+), 65 deletions(-)

Index: src/gdb/procfs.h
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ src/gdb/procfs.h	2009-06-07 23:06:53.000000000 +0100
@@ -0,0 +1,36 @@
+/* Native debugging support for procfs targets.
+
+   Copyright (C) 2009 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/>.  */
+
+struct target_ops;
+
+/* Create a prototype generic procfs target.  The client can override
+   it with local methods.  */
+
+extern struct target_ops *procfs_target (void);
+
+/* Call this in the native _initialize routine that creates and
+   customizes the prototype target returned by procfs_target, if the
+   native debug interface supports procfs watchpoints.  */
+
+extern void procfs_use_watchpoints (struct target_ops *t);
+
+/* Return a ptid for which we guarantee we will be able to find a
+   'live' procinfo.  */
+
+extern ptid_t procfs_first_available (void);
Index: src/gdb/proc-utils.h
===================================================================
--- src.orig/gdb/proc-utils.h	2009-06-07 23:06:51.000000000 +0100
+++ src/gdb/proc-utils.h	2009-06-07 23:06:53.000000000 +0100
@@ -96,8 +96,3 @@ typedef PROC_CTL_WORD_TYPE procfs_ctl_t;
 #else
 typedef long procfs_ctl_t;
 #endif
-
-
-/* From procfs.c */
-
-extern ptid_t procfs_first_available (void);
Index: src/gdb/sol-thread.c
===================================================================
--- src.orig/gdb/sol-thread.c	2009-06-07 23:06:51.000000000 +0100
+++ src/gdb/sol-thread.c	2009-06-07 23:06:53.000000000 +0100
@@ -66,8 +66,7 @@
 #include "symfile.h"
 #include "observer.h"
 #include "gdb_string.h"
-#include <sys/procfs.h>
-#include "proc-utils.h"
+#include "procfs.h"
 
 struct target_ops sol_thread_ops;
 
Index: src/gdb/procfs.c
===================================================================
--- src.orig/gdb/procfs.c	2009-06-07 23:06:51.000000000 +0100
+++ src/gdb/procfs.c	2009-06-07 23:06:53.000000000 +0100
@@ -50,6 +50,7 @@
 #include "gdb_assert.h"
 #include "inflow.h"
 #include "auxv.h"
+#include "procfs.h"
 
 /*
  * PROCFS.C
@@ -181,7 +182,7 @@ procfs_auxv_parse (struct target_ops *op
 }
 #endif
 
-static struct target_ops *
+struct target_ops *
 procfs_target (void)
 {
   struct target_ops *t = inf_child_target ();
@@ -212,7 +213,6 @@ procfs_target (void)
   t->to_has_thread_control  = tc_schedlock;
   t->to_find_memory_regions = proc_find_memory_regions;
   t->to_make_corefile_notes = procfs_make_note_section;
-  t->to_can_use_hw_breakpoint = procfs_can_use_hw_breakpoint;
 
 #if defined(PR_MODEL_NATIVE) && (PR_MODEL_NATIVE == PR_MODEL_LP64)
   t->to_auxv_parse = procfs_auxv_parse;
@@ -2902,7 +2902,10 @@ procfs_address_to_host_pointer (CORE_ADD
 int
 proc_set_watchpoint (procinfo *pi, CORE_ADDR addr, int len, int wflags)
 {
-#if !defined (TARGET_HAS_HARDWARE_WATCHPOINTS)
+#if !defined (PCWATCH) && !defined (PIOCSWATCH)
+  /* If neither or these is defined, we can't support watchpoints.
+     This just avoids possibly failing to compile the below on such
+     systems.  */
   return 0;
 #else
 /* Horrible hack!  Detect Solaris 2.5, because this doesn't work on 2.5 */
@@ -5294,9 +5297,6 @@ procfs_set_watchpoint (ptid_t ptid, CORE
 static int
 procfs_can_use_hw_breakpoint (int type, int cnt, int othertype)
 {
-#ifndef TARGET_HAS_HARDWARE_WATCHPOINTS
-  return 0;
-#else
   /* Due to the way that proc_set_watchpoint() is implemented, host
      and target pointers must be of the same size.  If they are not,
      we can't use hardware watchpoints.  This limitation is due to the
@@ -5312,7 +5312,6 @@ procfs_can_use_hw_breakpoint (int type, 
   /* Other tests here???  */
 
   return 1;
-#endif
 }
 
 /*
@@ -5394,6 +5393,7 @@ procfs_use_watchpoints (struct target_op
   t->to_insert_watchpoint = procfs_insert_watchpoint;
   t->to_remove_watchpoint = procfs_remove_watchpoint;
   t->to_region_ok_for_hw_watchpoint = procfs_region_ok_for_hw_watchpoint;
+  t->to_can_use_hw_breakpoint = procfs_can_use_hw_breakpoint;
 }
 
 /*
@@ -5988,16 +5988,6 @@ proc_untrace_sysexit_cmd (char *args, in
 void
 _initialize_procfs (void)
 {
-  struct target_ops * t;
-
-  t = procfs_target ();
-
-#ifdef TARGET_HAS_HARDWARE_WATCHPOINTS
-  procfs_use_watchpoints (t);
-#endif
-
-  add_target (t);
-
   add_info ("proc", info_proc_cmd, _("\
 Show /proc process information about any running process.\n\
 Specify process id, or use the program being debugged by default.\n\
Index: src/gdb/i386-sol2-nat.c
===================================================================
--- src.orig/gdb/i386-sol2-nat.c	2009-06-07 23:06:51.000000000 +0100
+++ src/gdb/i386-sol2-nat.c	2009-06-07 23:06:53.000000000 +0100
@@ -22,6 +22,8 @@
 
 #include <sys/procfs.h>
 #include "gregset.h"
+#include "target.h"
+#include "procfs.h"
 
 /* This file provids the (temporary) glue between the Solaris x86
    target dependent code and the machine independent SVR4 /proc
@@ -134,6 +136,15 @@ extern void _initialize_amd64_sol2_nat (
 void
 _initialize_amd64_sol2_nat (void)
 {
+  struct target_ops *t;
+
+  /* Fill in the generic procfs methods.  */
+  t = procfs_target ();
+
+#ifdef NEW_PROC_API	/* Solaris 6 and above can do HW watchpoints */
+  procfs_use_watchpoints (t);
+#endif
+
 #if defined (PR_MODEL_NATIVE) && (PR_MODEL_NATIVE == PR_MODEL_LP64)
   amd64_native_gregset32_reg_offset = amd64_sol2_gregset32_reg_offset;
   amd64_native_gregset32_num_regs =
@@ -142,4 +153,6 @@ _initialize_amd64_sol2_nat (void)
   amd64_native_gregset64_num_regs =
     ARRAY_SIZE (amd64_sol2_gregset64_reg_offset);
 #endif
+
+  add_target (t);
 }
Index: src/gdb/irix5-nat.c
===================================================================
--- src.orig/gdb/irix5-nat.c	2009-06-07 23:06:51.000000000 +0100
+++ src/gdb/irix5-nat.c	2009-06-07 23:06:53.000000000 +0100
@@ -29,6 +29,7 @@
 #include "gdbcore.h"
 #include "target.h"
 #include "regcache.h"
+#include "procfs.h"
 
 #include "gdb_string.h"
 #include <sys/time.h>
@@ -256,8 +257,17 @@ static struct core_fns irix5_core_fns =
   NULL					/* next */
 };
 
+/* Provide a prototype to silence -Wmissing-prototypes.  */
+extern initialize_file_ftype _initialize_irix5_nat;
+
 void
-_initialize_core_irix5 (void)
+_initialize_irix5_nat (void)
 {
+  struct target_ops *t;
+
+  t = procfs_target ();
+  procfs_use_watchpoints (t);
+  add_target (t);
+
   deprecated_add_core_fns (&irix5_core_fns);
 }
Index: src/gdb/alpha-nat.c
===================================================================
--- src.orig/gdb/alpha-nat.c	2009-06-07 23:06:51.000000000 +0100
+++ src/gdb/alpha-nat.c	2009-06-07 23:06:53.000000000 +0100
@@ -22,6 +22,7 @@
 #include "inferior.h"
 #include "gdbcore.h"
 #include "target.h"
+#include "procfs.h"
 #include "regcache.h"
 
 #include "alpha-tdep.h"
@@ -183,8 +184,16 @@ static struct core_fns alpha_osf_core_fn
   NULL					/* next */
 };
 
+/* Provide a prototype to silence -Wmissing-prototypes.  */
+extern initialize_file_ftype _initialize_alpha_nat;
+
 void
-_initialize_core_alpha (void)
+_initialize_alpha_nat (void)
 {
+  struct target_ops *t;
+
+  t = procfs_target ();
+  add_target (t);
+
   deprecated_add_core_fns (&alpha_osf_core_fns);
 }
Index: src/gdb/sparc-sol2-nat.c
===================================================================
--- src.orig/gdb/sparc-sol2-nat.c	2009-06-07 23:06:51.000000000 +0100
+++ src/gdb/sparc-sol2-nat.c	2009-06-07 23:06:53.000000000 +0100
@@ -24,6 +24,8 @@
 #include "gregset.h"
 
 #include "sparc-tdep.h"
+#include "target.h"
+#include "procfs.h"
 
 /* This file provids the (temporary) glue between the Solaris SPARC
    target dependent code and the machine independent SVR4 /proc
@@ -94,3 +96,18 @@ fill_fpregset (const struct regcache *re
 {
   sparc_collect_fpregset (regcache, regnum, fpregs);
 }
+
+/* Provide a prototype to silence -Wmissing-prototypes.  */
+extern initialize_file_ftype _initialize_sparc_sol2_nat;
+
+void
+_initialize_sparc_sol2_nat (void)
+{
+  struct target_ops *t;
+
+  t = procfs_target ();
+#ifdef NEW_PROC_API	/* Solaris 6 and above can do HW watchpoints */
+  procfs_use_watchpoints (t);
+#endif
+  add_target (t);
+}
Index: src/gdb/config/i386/nm-i386sol2.h
===================================================================
--- src.orig/gdb/config/i386/nm-i386sol2.h	2009-06-07 23:06:51.000000000 +0100
+++ src/gdb/config/i386/nm-i386sol2.h	2009-06-07 23:06:53.000000000 +0100
@@ -18,8 +18,6 @@
 
 #ifdef NEW_PROC_API	/* Solaris 6 and above can do HW watchpoints */
 
-#define TARGET_HAS_HARDWARE_WATCHPOINTS
-
 /* Solaris x86 2.6 and 2.7 targets have a kernel bug when stepping
    over an instruction that causes a page fault without triggering
    a hardware watchpoint. The kernel properly notices that it shouldn't
Index: src/gdb/config/sparc/nm-sol2.h
===================================================================
--- src.orig/gdb/config/sparc/nm-sol2.h	2009-06-07 23:06:51.000000000 +0100
+++ src/gdb/config/sparc/nm-sol2.h	2009-06-07 23:06:53.000000000 +0100
@@ -23,13 +23,4 @@
 #define GDB_GREGSET_T prgregset_t
 #define GDB_FPREGSET_T prfpregset_t
 
-/* Hardware wactchpoints.  */
-
-/* Solaris 2.6 and above can do HW watchpoints.  */
-#ifdef NEW_PROC_API
-
-#define TARGET_HAS_HARDWARE_WATCHPOINTS
-
-#endif /* NEW_PROC_API */
-
 #endif /* nm-sol2.h */
Index: src/gdb/config/mips/irix5.mh
===================================================================
--- src.orig/gdb/config/mips/irix5.mh	2009-06-07 23:06:51.000000000 +0100
+++ src/gdb/config/mips/irix5.mh	2009-06-07 23:06:53.000000000 +0100
@@ -1,4 +1,3 @@
 # Host: SGI Iris running irix 5.x
-NAT_FILE= nm-irix5.h
 NATDEPFILES= fork-child.o irix5-nat.o corelow.o procfs.o \
 	proc-api.o proc-events.o proc-flags.o proc-why.o
Index: src/gdb/config/mips/irix6.mh
===================================================================
--- src.orig/gdb/config/mips/irix6.mh	2009-06-07 23:06:51.000000000 +0100
+++ src/gdb/config/mips/irix6.mh	2009-06-07 23:06:53.000000000 +0100
@@ -1,4 +1,3 @@
 # Host: SGI Iris running irix 6.x
-NAT_FILE= nm-irix5.h
 NATDEPFILES= fork-child.o irix5-nat.o corelow.o procfs.o \
 	proc-api.o proc-events.o proc-flags.o proc-why.o
Index: src/gdb/config/mips/nm-irix5.h
===================================================================
--- src.orig/gdb/config/mips/nm-irix5.h	2009-06-07 23:06:51.000000000 +0100
+++ /dev/null	1970-01-01 00:00:00.000000000 +0000
@@ -1,21 +0,0 @@
-/* Definitions for native support of irix5.
-
-   Copyright 1993, 1996, 1998, 1999, 2000, 2007, 2008, 2009
-   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/>.  */
-
-#define TARGET_HAS_HARDWARE_WATCHPOINTS
Index: src/gdb/doc/gdbint.texinfo
===================================================================
--- src.orig/gdb/doc/gdbint.texinfo	2009-06-07 23:06:51.000000000 +0100
+++ src/gdb/doc/gdbint.texinfo	2009-06-07 23:06:53.000000000 +0100
@@ -694,11 +694,6 @@ changed are announced as hit.
 watchpoints:
 
 @table @code
-@findex TARGET_HAS_HARDWARE_WATCHPOINTS
-@item TARGET_HAS_HARDWARE_WATCHPOINTS
-If defined, the target supports hardware watchpoints.
-(Currently only used for several native configs.)
-
 @findex TARGET_CAN_USE_HARDWARE_WATCHPOINT
 @item TARGET_CAN_USE_HARDWARE_WATCHPOINT (@var{type}, @var{count}, @var{other})
 Return the number of hardware watchpoints of type @var{type} that are


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]