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]

[RFC] nm header removal: Get rid of config/i386/nm-i386gnu.h header


  I started to work again on a final removal of remaining native header
macros.

  The mist of remaining macros is on 
http://sourceware.org/gdb/current/ari/
Under the sub-title Macro.

  I tried to get rid of all the THREAD_STATE_XXX macros,
which allows to remove config/i386/nm-i386gnu.h

  The problems are:
1) I don't know GNU Hurd :(
2) I have no access to GNU Hurd machine
(I read that it is possible to ask for one to Thomas, but if
GDB is not usable anyhow, I am not sure it is worthwhile...)
3) I tried to use the cross-tools from Thomas Schwinge on gcc45 from
CompilerFarm
but got problems to compile GDB...
4) Saw that there are unfixed problems related to GNU Hurd and GDB.
http://sourceware.org/bugzilla/show_bug.cgi?id=12222

  So that finally my patch is not really tested :(

Maybe someone who can test it can give me some feedback.

All I did was to replace the macros in config/i386/nm-i386gnu.h
by variables and functions declared in gnu-nat.h and implemented in
i386gnu-nat.c

-#define THREAD_STATE_FLAVOR		i386_REGS_SEGS_STATE
replaced by
+extern unsigned int thread_state_flavor;
-#define THREAD_STATE_SIZE		i386_THREAD_STATE_COUNT
replaced by
+extern unsigned int thread_state_size;
-#define THREAD_STATE_SET_TRACED(state) \
-  	((struct i386_thread_state *) (state))->efl |= 0x100
replaced by
+extern void thread_state_set_traced (thread_state_t *state);
-#define THREAD_STATE_CLEAR_TRACED(state) \
-  	((((struct i386_thread_state *) (state))->efl &= ~0x100), 1)
replaced by
+extern void thread_state_clear_traced (thread_state_t *state);

Questions:
  1) Is the type of variable thread_state_flavor correct?
  2) the TRACED macros seems to be ment to return a value
the new flag value for THREAD_STATE_SET_TRACED and 1 for
THREAD_STATE_CLEAR_TRACED
but the return value is unused, so I declared the substitute functions
as returning void, is this OK?


Thanks in advance,


Pierre Muller
GDB pascal language maintainer


2011-03-21  Pierre Muller  <muller@ics.u-strasbg.fr>

	Get rid of i386 GNU hurd native header.
	config/i386/i386nu.mh (NAT_FILE): Remove.
	config/i386/nm-i386gnu.h: Remove file.
	gnu-nat.h (thread_state_flavor): New extern variable replacing
	THREAD_STATE_FLAVOR macro.
	(thread_state_size): New extern variable replacing THREAD_STATE_SIZE
	macro.
	(thread_state_set_traced): New function declaration.
	(thread_state_clear_traced): New function declaration.
	gnu-nat.c (proc_update_sc): Adapt to changes above.
	(proc_get_state): Ditto.
	(proc_trace): Ditto.
	i386gnu-nat.c (thread_state_flavor): New variable.
	(thread_state_size): New variable.
	(thread_state_set_traced): New function.
	(thread_state_clear_traced): New function.

diff --git a/gdb/config/i386/i386gnu.mh b/gdb/config/i386/i386gnu.mh
index d4e09d9..bc4e221 100644
--- a/gdb/config/i386/i386gnu.mh
+++ b/gdb/config/i386/i386gnu.mh
@@ -3,7 +3,7 @@ NATDEPFILES= i386gnu-nat.o gnu-nat.o corelow.o core-regset.o
fork-child.o \
 	     notify_S.o process_reply_S.o msg_reply_S.o \
 	     msg_U.o exc_request_U.o exc_request_S.o
 
-NAT_FILE= nm-i386gnu.h
+# Removed NATFILE nm-i386gnu.h
 MH_CFLAGS = -D_GNU_SOURCE
 
 XM_CLIBS = -lshouldbeinlibc
diff --git a/gdb/config/i386/nm-i386gnu.h b/gdb/config/i386/nm-i386gnu.h
deleted file mode 100644
index 8ce6c79..0000000
--- a/gdb/config/i386/nm-i386gnu.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/* Native-dependent definitions for Intel 386 running the GNU Hurd
-   Copyright 1994, 1995, 1996, 2002, 2007, 2008, 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/>.
*/
-
-#ifndef NM_I386GNU_H
-#define NM_I386GNU_H
-
-#include <unistd.h>
-#include <mach.h>
-#include <mach/exception.h>
-#include "regcache.h"
-
-extern char *gnu_target_pid_to_str (int pid);
-
-/* Thread flavors used in re-setting the T bit.  */
-#define THREAD_STATE_FLAVOR		i386_REGS_SEGS_STATE
-#define THREAD_STATE_SIZE		i386_THREAD_STATE_COUNT
-#define THREAD_STATE_SET_TRACED(state) \
-  	((struct i386_thread_state *) (state))->efl |= 0x100
-#define THREAD_STATE_CLEAR_TRACED(state) \
-  	((((struct i386_thread_state *) (state))->efl &= ~0x100), 1)
-
-#endif /* nm-i386gnu.h */
diff --git a/gdb/gnu-nat.c b/gdb/gnu-nat.c
index 7269694..0e6e6ec 100644
--- a/gdb/gnu-nat.c
+++ b/gdb/gnu-nat.c
@@ -268,8 +268,8 @@ proc_update_sc (struct proc *proc)
     {
       gdb_assert (proc_is_thread (proc));
       proc_debug (proc, "storing back changed thread state");
-      err = thread_set_state (proc->port, THREAD_STATE_FLAVOR,
-			 (thread_state_t) &proc->state, THREAD_STATE_SIZE);
+      err = thread_set_state (proc->port, thread_state_flavor,
+			 (thread_state_t) &proc->state, thread_state_size);
       if (!err)
 	proc->state_changed = 0;
     }
@@ -372,9 +372,9 @@ proc_get_state (struct proc *proc, int will_modify)
 
   if (!proc->state_valid)
     {
-      mach_msg_type_number_t state_size = THREAD_STATE_SIZE;
+      mach_msg_type_number_t state_size = thread_state_size;
       error_t err =
-	thread_get_state (proc->port, THREAD_STATE_FLAVOR,
+	thread_get_state (proc->port, thread_state_flavor,
 			  (thread_state_t) &proc->state, &state_size);
 
       proc_debug (proc, "getting thread state");
@@ -526,10 +526,10 @@ proc_trace (struct proc *proc, int set)
          exception port????  */
       if (proc->exc_port == MACH_PORT_NULL)
 	proc_steal_exc_port (proc, proc->inf->event_port);
-      THREAD_STATE_SET_TRACED (state);
+      thread_state_set_traced (&state);
     }
   else
-    THREAD_STATE_CLEAR_TRACED (state);
+    thread_state_clear_traced (&state);
 
   return 1;
 }
diff --git a/gdb/gnu-nat.h b/gdb/gnu-nat.h
index a213991..8af5965 100644
--- a/gdb/gnu-nat.h
+++ b/gdb/gnu-nat.h
@@ -103,4 +103,12 @@ extern int gnu_debug_flag;
    override it with local methods.  */
 struct target_ops *gnu_target (void);
 
+/* Thread flavors used in re-setting the T bit.
+   Thiese variables and functions are only defined in i386gnu-nat.c
+   which is the only supported architecture for now.  */
+extern unsigned int thread_state_flavor;
+extern unsigned int thread_state_size;
+extern void thread_state_set_traced (thread_state_t *state);
+extern void thread_state_clear_traced (thread_state_t *state);
+
 #endif /* __GNU_NAT_H__ */
diff --git a/gdb/i386gnu-nat.c b/gdb/i386gnu-nat.c
index 89354dc..4ddf708 100644
--- a/gdb/i386gnu-nat.c
+++ b/gdb/i386gnu-nat.c
@@ -297,6 +297,29 @@ gnu_store_registers (struct target_ops *ops,
     }
 }
 
+/* Thread flavors used in re-setting the T bit.  */
+/* Replacement of define THREAD_STATE_FLAVOR macro.  */
+unsigned int thread_state_flavor = i386_REGS_SEGS_STATE;
+/* Remplacement of define THREAD_STATE_SIZE macro.  */
+unsigned int thread_state_size = i386_THREAD_STATE_COUNT;
+
+/* Replacement of define THREAD_STATE_SET_TRACED(state) macro.  */
+void
+thread_state_set_traced (thread_state_t *state)
+{
+  ((struct i386_thread_state *) (state))->efl |= 0x100;
+  return;
+}
+
+/* Replacement of define THREAD_STATE_CLEAR_TRACED(state) macro.  */
+void
+thread_state_clear_traced (thread_state_t *state)
+{
+  ((struct i386_thread_state *) (state))->efl &= ~0x100;
+  return;
+}
+
+
 /* Provide a prototype to silence -Wmissing-prototypes.  */
 extern initialize_file_ftype _initialize_i386gnu_nat;



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