public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Please define thread_info as struct thread_info (and other stuff)
@ 2018-12-15 19:36 Svante Signell
  2018-12-15 22:48 ` Tom Tromey
  2018-12-16  9:20 ` Andreas Schwab
  0 siblings, 2 replies; 20+ messages in thread
From: Svante Signell @ 2018-12-15 19:36 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 1460 bytes --]

Hello,

When building gdb version 8.2 on GNU/Hurd several problems arise that need to be
solved. One problem is that most files in gdb/ have sloppy definitions of struct
thread_info, causing a build stop fore every occurrence. They are excluding the
struct part, making the build (and port) on Hurd very cumbersome. Can you please
fix all bad references to thread_info upstream? I don't really understand how
gcc can let these errors pass on GNU/Linux.

Attached are a lot of patches and files fixing these problems, 61 in total. A
test build of Debian version gdb-8.2-1 on GNU/Linux with the attached patches
(and patched files) applied works fine! 

Furthermore the script gdbarch.sh needs patching and the resulting files
gdbarch.{c,h} are used in the Linux build. They are not included here due to
size constraints. The generated file target-delegates.c was also used after
patching target.h and generating it with: make-target-delegates target.h >
target-delegates.c. Not included here either, also due to size constraints.

Attached are also four old patches needed to build the 8.1 version of gdb:
gdb_configure.nat.patch
gdb-PATH_MAX.patch
gnu-nat.c.patch
struct-thread_info.patch
and a very old Debian PATH_MAX patch: solve_PATH_MAX_issue.patch. Includes is
also the original and new Debian 8.2-1 patch file: series.

More patches will be needed for a successful port of gdb-8.2 to GNU/hurd, but
please fix the above problems upstream first.

Thanks!

[-- Attachment #2: gdb_aarch64-linux-tdep.c.patch --]
[-- Type: text/x-patch, Size: 511 bytes --]

Index: gdb-8.2/gdb/aarch64-linux-tdep.c
===================================================================
--- gdb-8.2.orig/gdb/aarch64-linux-tdep.c
+++ gdb-8.2/gdb/aarch64-linux-tdep.c
@@ -567,7 +567,7 @@ aarch64_stap_parse_special_token (struct
 
 static LONGEST
 aarch64_linux_get_syscall_number (struct gdbarch *gdbarch,
-				  thread_info *thread)
+				  struct thread_info *thread)
 {
   struct regcache *regs = get_thread_regcache (thread);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);

[-- Attachment #3: gdb_ada-lang.h.patch --]
[-- Type: text/x-patch, Size: 521 bytes --]

Index: gdb-8.2/gdb/ada-lang.h
===================================================================
--- gdb-8.2.orig/gdb/ada-lang.h
+++ gdb-8.2/gdb/ada-lang.h
@@ -401,7 +401,7 @@ extern int valid_task_id (int);
 
 extern struct ada_task_info *ada_get_task_info_from_ptid (ptid_t ptid);
 
-extern int ada_get_task_number (thread_info *thread);
+extern int ada_get_task_number (struct thread_info *thread);
 
 typedef void (ada_task_list_iterator_ftype) (struct ada_task_info *task);
 extern void iterate_over_live_ada_tasks

[-- Attachment #4: gdb_ada-tasks.c.patch --]
[-- Type: text/x-patch, Size: 1315 bytes --]

Index: gdb-8.2/gdb/ada-tasks.c
===================================================================
--- gdb-8.2.orig/gdb/ada-tasks.c
+++ gdb-8.2/gdb/ada-tasks.c
@@ -292,7 +292,7 @@ get_ada_tasks_inferior_data (struct infe
    if the task could not be found.  */
 
 int
-ada_get_task_number (thread_info *thread)
+ada_get_task_number (struct thread_info *thread)
 {
   int i;
   struct inferior *inf = thread->inf;
@@ -1124,7 +1124,7 @@ print_ada_task_info (struct ui_out *uiou
       /* Print the associated Thread ID.  */
       if (uiout->is_mi_like_p ())
         {
-	  thread_info *thread = find_thread_ptid (task_info->ptid);
+	  struct thread_info *thread = find_thread_ptid (task_info->ptid);
 
 	  if (thread != NULL)
 	    uiout->field_int ("thread-id", thread->global_num);
@@ -1326,7 +1326,7 @@ task_command_1 (const char *taskno_str,
      computed if target_get_ada_task_ptid has not been implemented for
      our target (yet).  Rather than cause an assertion error in that case,
      it's nicer for the user to just refuse to perform the task switch.  */
-  thread_info *tp = find_thread_ptid (task_info->ptid);
+  struct thread_info *tp = find_thread_ptid (task_info->ptid);
   if (tp == NULL)
     error (_("Unable to compute thread ID for task %d.\n"
              "Cannot switch to this task."),

[-- Attachment #5: gdb_amd64-linux-tdep.c.patch --]
[-- Type: text/x-patch, Size: 503 bytes --]

Index: gdb-8.2/gdb/amd64-linux-tdep.c
===================================================================
--- gdb-8.2.orig/gdb/amd64-linux-tdep.c
+++ gdb-8.2/gdb/amd64-linux-tdep.c
@@ -222,7 +222,7 @@ amd64_linux_sigcontext_addr (struct fram
 
 static LONGEST
 amd64_linux_get_syscall_number (struct gdbarch *gdbarch,
-				thread_info *thread)
+				struct thread_info *thread)
 {
   struct regcache *regcache = get_thread_regcache (thread);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);

[-- Attachment #6: gdb_arm-linux-tdep.c.patch --]
[-- Type: text/x-patch, Size: 441 bytes --]

Index: gdb-8.2/gdb/arm-linux-tdep.c
===================================================================
--- gdb-8.2.orig/gdb/arm-linux-tdep.c
+++ gdb-8.2/gdb/arm-linux-tdep.c
@@ -820,7 +820,7 @@ arm_linux_sigreturn_next_pc (struct regc
 
 static LONGEST
 arm_linux_get_syscall_number (struct gdbarch *gdbarch,
-			      thread_info *thread)
+			      struct thread_info *thread)
 {
   struct regcache *regs = get_thread_regcache (thread);
 

[-- Attachment #7: gdb_breakpoint.c.patch --]
[-- Type: text/x-patch, Size: 1885 bytes --]

Index: gdb-8.2/gdb/breakpoint.c
===================================================================
--- gdb-8.2.orig/gdb/breakpoint.c
+++ gdb-8.2/gdb/breakpoint.c
@@ -4339,7 +4339,7 @@ bpstat_clear_actions (void)
   if (inferior_ptid == null_ptid)
     return;
 
-  thread_info *tp = inferior_thread ();
+  struct thread_info *tp = inferior_thread ();
   for (bs = tp->control.stop_bpstat; bs != NULL; bs = bs->next)
     {
       bs->commands = NULL;
@@ -4470,13 +4470,13 @@ bpstat_do_actions_1 (bpstat *bsp)
 /* Helper for bpstat_do_actions.  Get the current thread, if there's
    one, is alive and has execution.  Return NULL otherwise.  */
 
-static thread_info *
+static struct thread_info *
 get_bpstat_thread ()
 {
   if (inferior_ptid == null_ptid || !target_has_execution)
     return NULL;
 
-  thread_info *tp = inferior_thread ();
+  struct thread_info *tp = inferior_thread ();
   if (tp->state == THREAD_EXITED || tp->executing)
     return NULL;
   return tp;
@@ -4486,7 +4486,7 @@ void
 bpstat_do_actions (void)
 {
   struct cleanup *cleanup_if_error = make_bpstat_clear_actions_cleanup ();
-  thread_info *tp;
+  struct thread_info *tp;
 
   /* Do any commands attached to breakpoint we are stopped at.  */
   while ((tp = get_bpstat_thread ()) != NULL)
@@ -5170,7 +5170,7 @@ bpstat_check_watchpoint (bpstat bs)
    breakpoint, set BS->stop to 0.  */
 
 static void
-bpstat_check_breakpoint_conditions (bpstat bs, thread_info *thread)
+bpstat_check_breakpoint_conditions (bpstat bs, struct thread_info *thread)
 {
   const struct bp_location *bl;
   struct breakpoint *b;
@@ -5402,7 +5402,7 @@ build_bpstat_chain (const address_space
 
 bpstat
 bpstat_stop_status (const address_space *aspace,
-		    CORE_ADDR bp_addr, thread_info *thread,
+		    CORE_ADDR bp_addr, struct thread_info *thread,
 		    const struct target_waitstatus *ws,
 		    bpstat stop_chain)
 {

[-- Attachment #8: gdb_breakpoint.h.patch --]
[-- Type: text/x-patch, Size: 495 bytes --]

Index: gdb-8.2/gdb/breakpoint.h
===================================================================
--- gdb-8.2.orig/gdb/breakpoint.h
+++ gdb-8.2/gdb/breakpoint.h
@@ -947,7 +947,7 @@ extern bpstat build_bpstat_chain (const
    commands, FIXME??? fields.  */
 
 extern bpstat bpstat_stop_status (const address_space *aspace,
-				  CORE_ADDR pc, thread_info *thread,
+				  CORE_ADDR pc, struct thread_info *thread,
 				  const struct target_waitstatus *ws,
 				  bpstat stop_chain = NULL);
 \f

[-- Attachment #9: gdb_btrace.c.patch --]
[-- Type: text/x-patch, Size: 1299 bytes --]

Index: gdb-8.2/gdb/btrace.c
===================================================================
--- gdb-8.2.orig/gdb/btrace.c
+++ gdb-8.2/gdb/btrace.c
@@ -3233,7 +3233,7 @@ maint_btrace_packet_history_cmd (const c
   struct btrace_thread_info *btinfo;
   unsigned int size, begin, end, from, to;
 
-  thread_info *tp = find_thread_ptid (inferior_ptid);
+  struct thread_info *tp = find_thread_ptid (inferior_ptid);
   if (tp == NULL)
     error (_("No thread."));
 
@@ -3340,7 +3340,7 @@ maint_btrace_clear_packet_history_cmd (c
   if (inferior_ptid == null_ptid)
     error (_("No thread."));
 
-  thread_info *tp = inferior_thread ();
+  struct thread_info *tp = inferior_thread ();
   btrace_thread_info *btinfo = &tp->btrace;
 
   /* Must clear the maint data before - it depends on BTINFO->DATA.  */
@@ -3359,7 +3359,7 @@ maint_btrace_clear_cmd (const char *args
   if (inferior_ptid == null_ptid)
     error (_("No thread."));
 
-  thread_info *tp = inferior_thread ();
+  struct thread_info *tp = inferior_thread ();
   btrace_clear (tp);
 }
 
@@ -3422,7 +3422,7 @@ maint_info_btrace_cmd (const char *args,
   if (inferior_ptid == null_ptid)
     error (_("No thread."));
 
-  thread_info *tp = inferior_thread ();
+  struct thread_info *tp = inferior_thread ();
 
   btinfo = &tp->btrace;
 

[-- Attachment #10: gdb_compile_compile-object-load.c.patch --]
[-- Type: text/x-patch, Size: 570 bytes --]

Index: gdb-8.2/gdb/compile/compile-object-load.c
===================================================================
--- gdb-8.2.orig/gdb/compile/compile-object-load.c
+++ gdb-8.2/gdb/compile/compile-object-load.c
@@ -555,7 +555,7 @@ get_regs_type (struct symbol *func_sym,
 static void
 store_regs (struct type *regs_type, CORE_ADDR regs_base)
 {
-  thread_info *thread = inferior_thread ();
+  struct thread_info *thread = inferior_thread ();
   struct gdbarch *gdbarch = target_gdbarch ();
   struct regcache *regcache = get_thread_regcache (thread);
   int fieldno;

[-- Attachment #11: gdb_configure.nat.patch --]
[-- Type: text/x-patch, Size: 539 bytes --]

Index: gdb-8.1/gdb/configure.nat
===================================================================
--- gdb-8.1.orig/gdb/configure.nat
+++ gdb-8.1/gdb/configure.nat
@@ -209,7 +209,7 @@ case ${gdb_host} in
 	    i386)
 		# Host: Intel 386 running the GNU Hurd
 		NATDEPFILES='i386-gnu-nat.o gnu-nat.o \
-		     x86-nat.o x86-dregs.o fork-child.o \
+		     x86-nat.o x86-dregs.o fork-child.o fork-inferior.o \
 		     notify_S.o process_reply_S.o msg_reply_S.o \
 		     msg_U.o exc_request_U.o exc_request_S.o'
 		HAVE_NATIVE_GCORE_HOST=1

[-- Attachment #12: gdb_corelow.c.patch --]
[-- Type: text/x-patch, Size: 575 bytes --]

Index: gdb-8.2/gdb/corelow.c
===================================================================
--- gdb-8.2.orig/gdb/corelow.c
+++ gdb-8.2/gdb/corelow.c
@@ -452,7 +452,7 @@ core_target_open (const char *arg, int f
 	 which was the "main" thread.  The latter case shouldn't
 	 usually happen, but we're dealing with input here, which can
 	 always be broken in different ways.  */
-      thread_info *thread = first_thread_of_inferior (current_inferior ());
+      struct thread_info *thread = first_thread_of_inferior (current_inferior ());
 
       if (thread == NULL)
 	{

[-- Attachment #13: gdb_dummy-frame.c.patch --]
[-- Type: text/x-patch, Size: 1690 bytes --]

Index: gdb-8.2/gdb/dummy-frame.c
===================================================================
--- gdb-8.2.orig/gdb/dummy-frame.c
+++ gdb-8.2/gdb/dummy-frame.c
@@ -37,7 +37,7 @@ struct dummy_frame_id
   struct frame_id id;
 
   /* The thread this dummy_frame relates to.  */
-  thread_info *thread;
+  struct thread_info *thread;
 };
 
 /* Return whether dummy_frame_id *ID1 and *ID2 are equal.  */
@@ -89,7 +89,7 @@ static struct dummy_frame *dummy_frame_s
 
 void
 dummy_frame_push (struct infcall_suspend_state *caller_state,
-		  const frame_id *dummy_id, thread_info *thread)
+		  const frame_id *dummy_id, struct thread_info *thread)
 {
   struct dummy_frame *dummy_frame;
 
@@ -202,7 +202,7 @@ lookup_dummy_frame (struct dummy_frame_i
    If the frame isn't found, flag an internal error.  */
 
 void
-dummy_frame_pop (frame_id dummy_id, thread_info *thread)
+dummy_frame_pop (frame_id dummy_id, struct thread_info *thread)
 {
   struct dummy_frame **dp;
   struct dummy_frame_id id = { dummy_id, thread };
@@ -218,7 +218,7 @@ dummy_frame_pop (frame_id dummy_id, thre
    free its memory.  */
 
 void
-dummy_frame_discard (struct frame_id dummy_id, thread_info *thread)
+dummy_frame_discard (struct frame_id dummy_id, struct thread_info *thread)
 {
   struct dummy_frame **dp;
   struct dummy_frame_id id = { dummy_id, thread };
@@ -231,7 +231,7 @@ dummy_frame_discard (struct frame_id dum
 /* See dummy-frame.h.  */
 
 void
-register_dummy_frame_dtor (frame_id dummy_id, thread_info *thread,
+register_dummy_frame_dtor (frame_id dummy_id, struct thread_info *thread,
 			   dummy_frame_dtor_ftype *dtor, void *dtor_data)
 {
   struct dummy_frame_id id = { dummy_id, thread };

[-- Attachment #14: gdb_dummy-frame.h.patch --]
[-- Type: text/x-patch, Size: 1456 bytes --]

Index: gdb-8.2/gdb/dummy-frame.h
===================================================================
--- gdb-8.2.orig/gdb/dummy-frame.h
+++ gdb-8.2/gdb/dummy-frame.h
@@ -35,7 +35,7 @@ struct frame_unwind;
 
 extern void dummy_frame_push (infcall_suspend_state *caller_state,
 			      const frame_id *dummy_id,
-			      thread_info *thread);
+			      struct thread_info *thread);
 
 /* Pop the dummy frame DUMMY_ID, restoring program state to that before the
    frame was created.
@@ -46,9 +46,9 @@ extern void dummy_frame_push (infcall_su
    stack, because the other frames may be for different threads, and there's
    currently no way to tell which stack frame is for which thread.  */
 
-extern void dummy_frame_pop (frame_id dummy_id, thread_info *thread);
+extern void dummy_frame_pop (frame_id dummy_id, struct thread_info *thread);
 
-extern void dummy_frame_discard (frame_id dummy_id, thread_info *thread);
+extern void dummy_frame_discard (frame_id dummy_id, struct thread_info *thread);
 
 /* If the PC falls in a dummy frame, return a dummy frame
    unwinder.  */
@@ -64,7 +64,7 @@ typedef void (dummy_frame_dtor_ftype) (v
    destructors may be registered, they will be called in the reverse
    order of registrations (LIFO).  */
 extern void register_dummy_frame_dtor (frame_id dummy_id,
-				       thread_info *thread,
+				       struct thread_info *thread,
 				       dummy_frame_dtor_ftype *dtor,
 				       void *dtor_data);
 

[-- Attachment #15: gdb_elfread.c.patch --]
[-- Type: text/x-patch, Size: 595 bytes --]

Index: gdb-8.2/gdb/elfread.c
===================================================================
--- gdb-8.2.orig/gdb/elfread.c
+++ gdb-8.2/gdb/elfread.c
@@ -972,7 +972,7 @@ elf_gnu_ifunc_resolver_stop (struct brea
 static void
 elf_gnu_ifunc_resolver_return_stop (struct breakpoint *b)
 {
-  thread_info *thread = inferior_thread ();
+  struct thread_info *thread = inferior_thread ();
   struct gdbarch *gdbarch = get_frame_arch (get_current_frame ());
   struct type *func_func_type = builtin_type (gdbarch)->builtin_func_func;
   struct type *value_type = TYPE_TARGET_TYPE (func_func_type);

[-- Attachment #16: gdb_frame.c.patch --]
[-- Type: text/x-patch, Size: 447 bytes --]

Index: gdb-8.2/gdb/frame.c
===================================================================
--- gdb-8.2.orig/gdb/frame.c
+++ gdb-8.2/gdb/frame.c
@@ -1625,7 +1625,7 @@ has_stack_frames (void)
       if (inferior_ptid == null_ptid)
 	return 0;
 
-      thread_info *tp = inferior_thread ();
+      struct thread_info *tp = inferior_thread ();
       /* Don't try to read from a dead thread.  */
       if (tp->state == THREAD_EXITED)
 	return 0;

[-- Attachment #17: gdb_gdbarch.h.patch --]
[-- Type: text/x-patch, Size: 791 bytes --]

--- a/gdb/gdbarch.h	2018-09-05 09:44:28.000000000 +0200
+++ b/gdb/gdbarch.h	2034-05-25 01:25:18.000000000 +0200
@@ -1170,8 +1170,8 @@
 
 extern int gdbarch_get_syscall_number_p (struct gdbarch *gdbarch);
 
-typedef LONGEST (gdbarch_get_syscall_number_ftype) (struct gdbarch *gdbarch, thread_info *thread);
-extern LONGEST gdbarch_get_syscall_number (struct gdbarch *gdbarch, thread_info *thread);
+typedef LONGEST (gdbarch_get_syscall_number_ftype) (struct gdbarch *gdbarch, struct thread_info *thread);
+extern LONGEST gdbarch_get_syscall_number (struct gdbarch *gdbarch, struct thread_info *thread);
 extern void set_gdbarch_get_syscall_number (struct gdbarch *gdbarch, gdbarch_get_syscall_number_ftype *get_syscall_number);
 
 /* The filename of the XML syscall for this architecture. */

[-- Attachment #18: gdb_gdbarch.sh.patch --]
[-- Type: text/x-patch, Size: 594 bytes --]

Index: gdb-8.2/gdb/gdbarch.sh
===================================================================
--- gdb-8.2.orig/gdb/gdbarch.sh
+++ gdb-8.2/gdb/gdbarch.sh
@@ -904,7 +904,7 @@ M;void;record_special_symbol;struct objf
 # Function for the 'catch syscall' feature.
 
 # Get architecture-specific system calls information from registers.
-M;LONGEST;get_syscall_number;thread_info *thread;thread
+M;LONGEST;get_syscall_number;struct thread_info *thread;thread
 
 # The filename of the XML syscall for this architecture.
 v;const char *;xml_syscall_file;;;0;0;;0;pstring (gdbarch->xml_syscall_file)

[-- Attachment #19: gdb_gnu-nat.c.patch --]
[-- Type: text/x-patch, Size: 874 bytes --]

Index: gdb-8.2/gdb/gnu-nat.c
===================================================================
--- gdb-8.2.orig/gdb/gnu-nat.c
+++ gdb-8.2/gdb/gnu-nat.c
@@ -45,6 +45,14 @@ extern "C"
 #include <portinfo.h>
 }
 
+#ifdef __STDC_LIMIT_MACROS
+#undef __STDC_LIMIT_MACROS
+#endif
+
+#ifdef __STDC_CONSTANT_MACROS
+#undef __STDC_CONSTANT_MACROS
+#endif
+
 #include "defs.h"
 
 #include <ctype.h>
@@ -2264,7 +2272,7 @@ gnu_nat_target::attach (const char *args
 void
 gnu_nat_target::detach (inferior *inf, int from_tty)
 {
-  int pid;
+  int pid = -1;
 
   if (from_tty)
     {
@@ -2283,9 +2291,10 @@ gnu_nat_target::detach (inferior *inf, i
   inf_detach (gnu_current_inf);
 
   inferior_ptid = null_ptid;
-  detach_inferior (pid);
+  detach_inferior (inf);
 
-  inf_child_maybe_unpush_target (ops);
+  //  inf_child_maybe_unpush_target (ops);
+  maybe_unpush_target ();
 }
 \f
 

[-- Attachment #20: gdb_gnu-nat.h.patch --]
[-- Type: text/x-patch, Size: 557 bytes --]

Index: gdb-8.2/gdb/gnu-nat.h
===================================================================
--- gdb-8.2.orig/gdb/gnu-nat.h
+++ gdb-8.2/gdb/gnu-nat.h
@@ -21,6 +21,8 @@
 
 #include <unistd.h>
 #include <mach.h>
+#include "target.h"
+#include "inf-child.h"
 
 struct inf;
 
@@ -108,6 +110,11 @@ extern int gnu_debug_flag;
 
 struct gnu_nat_target : public inf_child_target
 {
+  /*
+public:
+  gnu_nat_target ();
+  ~gnu_nat_target () override = 0;
+  */
   void attach (const char *, int) override;
   bool attach_no_wait () override
   { return true; }

[-- Attachment #21: gdb_i386-gnu-nat.c.patch --]
[-- Type: text/x-patch, Size: 1912 bytes --]

Index: gdb-8.2/gdb/i386-gnu-nat.c
===================================================================
--- gdb-8.2.orig/gdb/i386-gnu-nat.c
+++ gdb-8.2/gdb/i386-gnu-nat.c
@@ -63,6 +63,7 @@ using gnu_base_target = x86_nat_target<g
 using gnu_base_target = gnu_nat_target;
 #endif
 
+#if 0
 struct i386_gnu_nat_target final : public gnu_base_target
 {
   void fetch_registers (struct regcache *, int) override;
@@ -70,6 +71,7 @@ struct i386_gnu_nat_target final : publi
 };
 
 static i386_gnu_nat_target the_i386_gnu_nat_target;
+#endif
 
 /* Get the whole floating-point state of THREAD and record the values
    of the corresponding (pseudo) registers.  */
@@ -103,6 +105,7 @@ fetch_fpregs (struct regcache *regcache,
 }
 
 /* Fetch register REGNO, or all regs if REGNO is -1.  */
+#if 0
 static void
 gnu_fetch_registers (struct target_ops *ops,
 		     struct regcache *regcache, int regno)
@@ -159,10 +162,12 @@ gnu_fetch_registers (struct target_ops *
       fetch_fpregs (regcache, thread);
     }
 }
+#endif
 \f
 
 /* Store the whole floating-point state into THREAD using information
    from the corresponding (pseudo) registers.  */
+#if 0
 static void
 store_fpregs (const struct regcache *regcache, struct proc *thread, int regno)
 {
@@ -192,8 +197,10 @@ store_fpregs (const struct regcache *reg
       return;
     }
 }
+#endif
 
 /* Store at least register REGNO, or all regs if REGNO == -1.  */
+#if 0
 static void
 gnu_store_registers (struct target_ops *ops,
 		     struct regcache *regcache, int regno)
@@ -288,6 +295,7 @@ gnu_store_registers (struct target_ops *
       store_fpregs (regcache, thread, regno);
     }
 }
+#endif
 
 \f
 /* Support for debug registers.  */
@@ -439,5 +447,5 @@ _initialize_i386gnu_nat (void)
 #endif /* i386_DEBUG_STATE */
 
   /* Register the target.  */
-  add_inf_child_target (&the_i386_gnu_nat_target);
+  //  add_inf_child_target (&the_i386_gnu_nat_target);
 }

[-- Attachment #22: gdb_i386-linux-tdep.c.patch --]
[-- Type: text/x-patch, Size: 451 bytes --]

Index: gdb-8.2/gdb/i386-linux-tdep.c
===================================================================
--- gdb-8.2.orig/gdb/i386-linux-tdep.c
+++ gdb-8.2/gdb/i386-linux-tdep.c
@@ -559,7 +559,7 @@ i386_linux_get_syscall_number_from_regca
 
 static LONGEST
 i386_linux_get_syscall_number (struct gdbarch *gdbarch,
-			       thread_info *thread)
+			       struct thread_info *thread)
 {
   struct regcache *regcache = get_thread_regcache (thread);
 

[-- Attachment #23: gdb_infcall.c.patch --]
[-- Type: text/x-patch, Size: 505 bytes --]

Index: gdb-8.2/gdb/infcall.c
===================================================================
--- gdb-8.2.orig/gdb/infcall.c
+++ gdb-8.2/gdb/infcall.c
@@ -422,7 +422,7 @@ static struct value *
 get_call_return_value (struct call_return_meta_info *ri)
 {
   struct value *retval = NULL;
-  thread_info *thr = inferior_thread ();
+  struct thread_info *thr = inferior_thread ();
   bool stack_temporaries = thread_stack_temporaries_enabled_p (thr);
 
   if (TYPE_CODE (ri->value_type) == TYPE_CODE_VOID)

[-- Attachment #24: gdb_infcmd.c.patch --]
[-- Type: text/x-patch, Size: 1191 bytes --]

Index: gdb-8.2/gdb/infcmd.c
===================================================================
--- gdb-8.2.orig/gdb/infcmd.c
+++ gdb-8.2/gdb/infcmd.c
@@ -444,7 +444,7 @@ post_create_inferior (struct target_ops
   /* Now that we know the register layout, retrieve current PC.  But
      if the PC is unavailable (e.g., we're opening a core file with
      missing registers info), ignore it.  */
-  thread_info *thr = inferior_thread ();
+  struct thread_info *thr = inferior_thread ();
 
   thr->suspend.stop_pc = 0;
   TRY
@@ -2094,7 +2094,7 @@ info_program_command (const char *args,
   if (ptid == null_ptid)
     error (_("No selected thread."));
 
-  thread_info *tp = find_thread_ptid (ptid);
+  struct thread_info *tp = find_thread_ptid (ptid);
 
   if (tp->state == THREAD_EXITED)
     error (_("Invalid selected thread."));
@@ -2940,7 +2940,7 @@ attach_command (const char *args, int fr
    as stopped.  */
 
 void
-notice_new_inferior (thread_info *thr, int leave_running, int from_tty)
+notice_new_inferior (struct thread_info *thr, int leave_running, int from_tty)
 {
   enum attach_post_wait_mode mode
     = leave_running ? ATTACH_POST_WAIT_RESUME : ATTACH_POST_WAIT_NOTHING;

[-- Attachment #25: gdb_inferior.c.patch --]
[-- Type: text/x-patch, Size: 1007 bytes --]

Index: gdb-8.2/gdb/inferior.c
===================================================================
--- gdb-8.2.orig/gdb/inferior.c
+++ gdb-8.2/gdb/inferior.c
@@ -575,7 +575,7 @@ detach_inferior_command (const char *arg
 	  continue;
 	}
 
-      thread_info *tp = any_thread_of_inferior (inf);
+      struct thread_info *tp = any_thread_of_inferior (inf);
       if (tp == NULL)
 	{
 	  warning (_("Inferior ID %d has no threads."), num);
@@ -612,7 +612,7 @@ kill_inferior_command (const char *args,
 	  continue;
 	}
 
-      thread_info *tp = any_thread_of_inferior (inf);
+      struct thread_info *tp = any_thread_of_inferior (inf);
       if (tp == NULL)
 	{
 	  warning (_("Inferior ID %d has no threads."), num);
@@ -643,7 +643,7 @@ inferior_command (const char *args, int
     {
       if (inf != current_inferior ())
 	{
-	  thread_info *tp = any_thread_of_inferior (inf);
+	  struct thread_info *tp = any_thread_of_inferior (inf);
 	  if (tp == NULL)
 	    error (_("Inferior has no threads."));
 

[-- Attachment #26: gdb_inflow.c.patch --]
[-- Type: text/x-patch, Size: 474 bytes --]

Index: gdb-8.2/gdb/inflow.c
===================================================================
--- gdb-8.2.orig/gdb/inflow.c
+++ gdb-8.2/gdb/inflow.c
@@ -544,8 +544,8 @@ void
 child_interrupt (struct target_ops *self)
 {
   /* Interrupt the first inferior that has a resumed thread.  */
-  thread_info *thr;
-  thread_info *resumed = NULL;
+  struct thread_info *thr;
+  struct thread_info *resumed = NULL;
   ALL_NON_EXITED_THREADS (thr)
     {
       if (thr->executing)

[-- Attachment #27: gdb_infrun.c.patch --]
[-- Type: text/x-patch, Size: 3221 bytes --]

Index: gdb-8.2/gdb/infrun.c
===================================================================
--- gdb-8.2.orig/gdb/infrun.c
+++ gdb-8.2/gdb/infrun.c
@@ -694,7 +694,7 @@ follow_fork (void)
 	     target to follow it (in either direction).  We'll
 	     afterwards refuse to resume, and inform the user what
 	     happened.  */
-	  thread_info *wait_thread
+	  struct thread_info *wait_thread
 	    = find_thread_ptid (wait_ptid);
 	  switch_to_thread (wait_thread);
 	  should_resume = 0;
@@ -767,7 +767,7 @@ follow_fork (void)
 	    /* If we followed the child, switch to it...  */
 	    if (follow_child)
 	      {
-		thread_info *child_thr = find_thread_ptid (child);
+		struct thread_info *child_thr = find_thread_ptid (child);
 		switch_to_thread (child_thr);
 
 		/* ... and preserve the stepping state, in case the
@@ -1493,7 +1493,7 @@ struct displaced_step_inferior_state
   /* If this is not nullptr, this is the thread carrying out a
      displaced single-step in process PID.  This thread's state will
      require fixing up once it has completed its step.  */
-  thread_info *step_thread;
+  struct thread_info *step_thread;
 
   /* The architecture the thread had when we stepped it.  */
   struct gdbarch *step_gdbarch;
@@ -1551,7 +1551,7 @@ displaced_step_in_progress_any_inferior
    step.  */
 
 static int
-displaced_step_in_progress_thread (thread_info *thread)
+displaced_step_in_progress_thread (struct thread_info *thread)
 {
   struct displaced_step_inferior_state *displaced;
 
@@ -1746,7 +1746,7 @@ displaced_step_dump_bytes (struct ui_fil
    if this instruction can't be displaced stepped.  */
 
 static int
-displaced_step_prepare_throw (thread_info *tp)
+displaced_step_prepare_throw (struct thread_info *tp)
 {
   struct cleanup *ignore_cleanups;
   regcache *regcache = get_thread_regcache (tp);
@@ -1885,7 +1885,7 @@ displaced_step_prepare_throw (thread_inf
    attempts at displaced stepping if we get a memory error.  */
 
 static int
-displaced_step_prepare (thread_info *thread)
+displaced_step_prepare (struct thread_info *thread)
 {
   int prepared = -1;
 
@@ -1960,7 +1960,7 @@ displaced_step_restore (struct displaced
    -1.  If the thread wasn't displaced stepping, return 0.  */
 
 static int
-displaced_step_fixup (thread_info *event_thread, enum gdb_signal signal)
+displaced_step_fixup (struct thread_info *event_thread, enum gdb_signal signal)
 {
   struct cleanup *old_cleanups;
   struct displaced_step_inferior_state *displaced
@@ -4751,7 +4751,7 @@ handle_no_resumed (struct execution_cont
       if (inf->pid == 0)
 	continue;
 
-      thread_info *thread = any_live_thread_of_inferior (inf);
+      struct thread_info *thread = any_live_thread_of_inferior (inf);
       if (thread == NULL)
 	{
 	  if (debug_infrun)
@@ -5212,8 +5212,8 @@ Cannot fill $_exitsignal with the correc
 
 	  should_resume = follow_fork ();
 
-	  thread_info *parent = ecs->event_thread;
-	  thread_info *child = find_thread_ptid (ecs->ws.value.related_pid);
+	  struct thread_info *parent = ecs->event_thread;
+	  struct thread_info *child = find_thread_ptid (ecs->ws.value.related_pid);
 
 	  /* At this point, the parent is marked running, and the
 	     child is marked stopped.  */

[-- Attachment #28: gdb_inline-frame.c.patch --]
[-- Type: text/x-patch, Size: 2323 bytes --]

Index: gdb-8.2/gdb/inline-frame.c
===================================================================
--- gdb-8.2.orig/gdb/inline-frame.c
+++ gdb-8.2/gdb/inline-frame.c
@@ -37,7 +37,7 @@
    keep our own list.  */
 struct inline_state
 {
-  inline_state (thread_info *thread_, int skipped_frames_, CORE_ADDR saved_pc_,
+  inline_state (struct thread_info *thread_, int skipped_frames_, CORE_ADDR saved_pc_,
 		symbol *skipped_symbol_)
     : thread (thread_), skipped_frames (skipped_frames_), saved_pc (saved_pc_),
       skipped_symbol (skipped_symbol_)
@@ -45,7 +45,7 @@ struct inline_state
 
   /* The thread this data relates to.  It should be a currently
      stopped thread.  */
-  thread_info *thread;
+  struct thread_info *thread;
 
   /* The number of inlined functions we are skipping.  Each of these
      functions can be stepped in to.  */
@@ -69,7 +69,7 @@ static std::vector<inline_state> inline_
    valid.  */
 
 static struct inline_state *
-find_inline_frame_state (thread_info *thread)
+find_inline_frame_state (struct thread_info *thread)
 {
   auto state_it = std::find_if (inline_states.begin (), inline_states.end (),
 				[thread] (const inline_state &state)
@@ -321,7 +321,7 @@ stopped_by_user_bp_inline_frame (const b
 /* See inline-frame.h.  */
 
 void
-skip_inline_frames (thread_info *thread, bpstat stop_chain)
+skip_inline_frames (struct thread_info *thread, bpstat stop_chain)
 {
   const struct block *frame_block, *cur_block;
   struct symbol *last_sym = NULL;
@@ -374,7 +374,7 @@ skip_inline_frames (thread_info *thread,
 /* Step into an inlined function by unhiding it.  */
 
 void
-step_into_inline_frame (thread_info *thread)
+step_into_inline_frame (struct thread_info *thread)
 {
   inline_state *state = find_inline_frame_state (thread);
 
@@ -387,7 +387,7 @@ step_into_inline_frame (thread_info *thr
    frame.  */
 
 int
-inline_skipped_frames (thread_info *thread)
+inline_skipped_frames (struct thread_info *thread)
 {
   inline_state *state = find_inline_frame_state (thread);
 
@@ -401,7 +401,7 @@ inline_skipped_frames (thread_info *thre
    the function inlined into the current frame.  */
 
 struct symbol *
-inline_skipped_symbol (thread_info *thread)
+inline_skipped_symbol (struct thread_info *thread)
 {
   inline_state *state = find_inline_frame_state (thread);
 

[-- Attachment #29: gdb_inline-frame.h.patch --]
[-- Type: text/x-patch, Size: 1428 bytes --]

Index: gdb-8.2/gdb/inline-frame.h
===================================================================
--- gdb-8.2.orig/gdb/inline-frame.h
+++ gdb-8.2/gdb/inline-frame.h
@@ -36,7 +36,7 @@ extern const struct frame_unwind inline_
    user's perspective.  GDB will stop "in" the inlined frame instead of
    the caller.  */
 
-void skip_inline_frames (thread_info *thread, struct bpstats *stop_chain);
+void skip_inline_frames (struct thread_info *thread, struct bpstats *stop_chain);
 
 /* Forget about any hidden inlined functions in PTID, which is new or
    about to be resumed.  If PTID is minus_one_ptid, forget about all
@@ -46,17 +46,17 @@ void clear_inline_frame_state (ptid_t pt
 
 /* Step into an inlined function by unhiding it.  */
 
-void step_into_inline_frame (thread_info *thread);
+void step_into_inline_frame (struct thread_info *thread);
 
 /* Return the number of hidden functions inlined into the current
    frame.  */
 
-int inline_skipped_frames (thread_info *thread);
+int inline_skipped_frames (struct thread_info *thread);
 
 /* If one or more inlined functions are hidden, return the symbol for
    the function inlined into the current frame.  */
 
-struct symbol *inline_skipped_symbol (thread_info *thread);
+struct symbol *inline_skipped_symbol (struct thread_info *thread);
 
 /* Return the number of functions inlined into THIS_FRAME.  Some of
    the callees may not have associated frames (see

[-- Attachment #30: gdb_mi_mi-cmd-var.c.patch --]
[-- Type: text/x-patch, Size: 457 bytes --]

Index: gdb-8.2/gdb/mi/mi-cmd-var.c
===================================================================
--- gdb-8.2.orig/gdb/mi/mi-cmd-var.c
+++ gdb-8.2/gdb/mi/mi-cmd-var.c
@@ -612,7 +612,7 @@ mi_cmd_var_update_iter (struct varobj *v
     }
   else
     {
-      thread_info *tp = find_thread_global_id (thread_id);
+      struct thread_info *tp = find_thread_global_id (thread_id);
 
       thread_stopped = (tp == NULL
 			|| tp->state == THREAD_STOPPED);

[-- Attachment #31: gdb_mi_mi-interp.c.patch --]
[-- Type: text/x-patch, Size: 693 bytes --]

Index: gdb-8.2/gdb/mi/mi-interp.c
===================================================================
--- gdb-8.2.orig/gdb/mi/mi-interp.c
+++ gdb-8.2/gdb/mi/mi-interp.c
@@ -990,7 +990,7 @@ mi_on_resume_1 (struct mi_interp *mi, pt
 	fprintf_unfiltered (mi->raw_stdout, "*running,thread-id=\"all\"\n");
       else
 	{
-	  thread_info *tp;
+	  struct thread_info *tp;
 	  inferior *curinf = current_inferior ();
 
 	  ALL_NON_EXITED_THREADS (tp)
@@ -1000,7 +1000,7 @@ mi_on_resume_1 (struct mi_interp *mi, pt
     }
   else
     {
-      thread_info *ti = find_thread_ptid (ptid);
+      struct thread_info *ti = find_thread_ptid (ptid);
 
       gdb_assert (ti);
       mi_output_running (ti);

[-- Attachment #32: gdb_mi_mi-main.c.patch --]
[-- Type: text/x-patch, Size: 749 bytes --]

Index: gdb-8.2/gdb/mi/mi-main.c
===================================================================
--- gdb-8.2.orig/gdb/mi/mi-main.c
+++ gdb-8.2/gdb/mi/mi-main.c
@@ -409,7 +409,7 @@ run_one_inferior (struct inferior *inf,
 
   if (inf->pid != 0)
     {
-      thread_info *tp = any_thread_of_inferior (inf);
+      struct thread_info *tp = any_thread_of_inferior (inf);
       if (tp == NULL)
 	error (_("Inferior has no threads."));
 
@@ -2066,7 +2066,7 @@ mi_cmd_execute (struct mi_parse *parse)
 
   if (parse->thread != -1)
     {
-      thread_info *tp = find_thread_global_id (parse->thread);
+      struct thread_info *tp = find_thread_global_id (parse->thread);
 
       if (tp == NULL)
 	error (_("Invalid thread id: %d"), parse->thread);

[-- Attachment #33: gdb_mips-linux-tdep.c.patch --]
[-- Type: text/x-patch, Size: 506 bytes --]

Index: gdb-8.2/gdb/mips-linux-tdep.c
===================================================================
--- gdb-8.2.orig/gdb/mips-linux-tdep.c
+++ gdb-8.2/gdb/mips-linux-tdep.c
@@ -1316,7 +1316,7 @@ mips_linux_syscall_next_pc (struct frame
 
 static LONGEST
 mips_linux_get_syscall_number (struct gdbarch *gdbarch,
-			       thread_info *thread)
+			       struct thread_info *thread)
 {
   struct regcache *regcache = get_thread_regcache (thread);
   struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);

[-- Attachment #34: gdb-PATH_MAX.patch --]
[-- Type: text/x-patch, Size: 975 bytes --]

Index: gdb/gdb/remote.c
===================================================================
--- gdb.orig/gdb/remote.c
+++ gdb/gdb/remote.c
@@ -7333,7 +7333,7 @@ Packet: '%s'\n"),
 	  else if (strprefix (p, p1, "exec"))
 	    {
 	      ULONGEST ignored;
-	      char pathname[PATH_MAX];
+	      char *pathname = NULL;
 	      int pathlen;
 
 	      /* Determine the length of the execd pathname.  */
@@ -7342,12 +7342,14 @@ Packet: '%s'\n"),
 
 	      /* Save the pathname for event reporting and for
 		 the next run command.  */
+	      pathname = (char *) xmalloc(pathlen + 1);
 	      hex2bin (p1, (gdb_byte *) pathname, pathlen);
 	      pathname[pathlen] = '\0';
 
 	      /* This is freed during event handling.  */
 	      event->ws.value.execd_pathname = xstrdup (pathname);
 	      event->ws.kind = TARGET_WAITKIND_EXECD;
+	      xfree (pathname);
 
 	      /* Skip the registers included in this packet, since
 		 they may be for an architecture different from the

[-- Attachment #35: gdb_ppc-linux-tdep.c.patch --]
[-- Type: text/x-patch, Size: 558 bytes --]

Index: gdb-8.2/gdb/ppc-linux-tdep.c
===================================================================
--- gdb-8.2.orig/gdb/ppc-linux-tdep.c
+++ gdb-8.2/gdb/ppc-linux-tdep.c
@@ -803,7 +803,7 @@ ppc_linux_trap_reg_p (struct gdbarch *gd
    r0 register.  When the function fails, it returns -1.  */
 static LONGEST
 ppc_linux_get_syscall_number (struct gdbarch *gdbarch,
-			      thread_info *thread)
+			      struct thread_info *thread)
 {
   struct regcache *regcache = get_thread_regcache (thread);
   struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);

[-- Attachment #36: gdb_python_py-inferior.c.patch --]
[-- Type: text/x-patch, Size: 462 bytes --]

Index: gdb-8.2/gdb/python/py-inferior.c
===================================================================
--- gdb-8.2.orig/gdb/python/py-inferior.c
+++ gdb-8.2/gdb/python/py-inferior.c
@@ -307,7 +307,7 @@ find_inferior_object (int pid)
 }
 
 thread_object *
-thread_to_thread_object (thread_info *thr)
+thread_to_thread_object (struct thread_info *thr)
 {
   gdbpy_ref<inferior_object> inf_obj (inferior_to_inferior_object (thr->inf));
   if (inf_obj == NULL)

[-- Attachment #37: gdb_python_py-record.c.patch --]
[-- Type: text/x-patch, Size: 999 bytes --]

Index: gdb-8.2/gdb/python/py-record.c
===================================================================
--- gdb-8.2.orig/gdb/python/py-record.c
+++ gdb-8.2/gdb/python/py-record.c
@@ -177,7 +177,7 @@ recpy_end (PyObject *self, void* closure
 /* Create a new gdb.RecordInstruction object.  */
 
 PyObject *
-recpy_insn_new (thread_info *thread, enum record_method method, Py_ssize_t number)
+recpy_insn_new (struct thread_info *thread, enum record_method method, Py_ssize_t number)
 {
   recpy_element_object * const obj = PyObject_New (recpy_element_object,
 						   &recpy_insn_type);
@@ -273,7 +273,7 @@ recpy_insn_is_speculative (PyObject *sel
 /* Create a new gdb.RecordFunctionSegment object.  */
 
 PyObject *
-recpy_func_new (thread_info *thread, enum record_method method, Py_ssize_t number)
+recpy_func_new (struct thread_info *thread, enum record_method method, Py_ssize_t number)
 {
   recpy_element_object * const obj = PyObject_New (recpy_element_object,
 						   &recpy_func_type);

[-- Attachment #38: gdb_python_py-record.h.patch --]
[-- Type: text/x-patch, Size: 1271 bytes --]

Index: gdb-8.2/gdb/python/py-record.h
===================================================================
--- gdb-8.2.orig/gdb/python/py-record.h
+++ gdb-8.2/gdb/python/py-record.h
@@ -30,7 +30,7 @@ typedef struct
   PyObject_HEAD
 
   /* The thread this object refers to.  */
-  thread_info *thread;
+  struct thread_info *thread;
 
   /* The current recording method.  */
   enum record_method method;
@@ -44,7 +44,7 @@ typedef struct
   PyObject_HEAD
 
   /* The thread this object refers to.  */
-  thread_info *thread;
+  struct thread_info *thread;
 
   /* The current recording method.  */
   enum record_method method;
@@ -60,11 +60,11 @@ extern PyTypeObject recpy_insn_type;
 extern PyTypeObject recpy_func_type;
 
 /* Create a new gdb.RecordInstruction object.  */
-extern PyObject *recpy_insn_new (thread_info *thread, enum record_method method,
+extern PyObject *recpy_insn_new (struct thread_info *thread, enum record_method method,
 				 Py_ssize_t number);
 
 /* Create a new gdb.RecordFunctionSegment object.  */
-extern PyObject *recpy_func_new (thread_info *thread, enum record_method method,
+extern PyObject *recpy_func_new (struct thread_info *thread, enum record_method method,
 				 Py_ssize_t number);
 
 /* Create a new gdb.RecordGap object.  */

[-- Attachment #39: gdb_python_py-record-btrace.c.patch --]
[-- Type: text/x-patch, Size: 2869 bytes --]

Index: gdb-8.2/gdb/python/py-record-btrace.c
===================================================================
--- gdb-8.2.orig/gdb/python/py-record-btrace.c
+++ gdb-8.2/gdb/python/py-record-btrace.c
@@ -43,7 +43,7 @@ typedef struct {
   PyObject_HEAD
 
   /* The thread this list belongs to.  */
-  thread_info *thread;
+  struct thread_info *thread;
 
   /* The first index being part of this list.  */
   Py_ssize_t first;
@@ -178,7 +178,7 @@ btpy_insn_or_gap_new (struct thread_info
 /* Create a new gdb.BtraceList object.  */
 
 static PyObject *
-btpy_list_new (thread_info *thread, Py_ssize_t first, Py_ssize_t last, Py_ssize_t step,
+btpy_list_new (struct thread_info *thread, Py_ssize_t first, Py_ssize_t last, Py_ssize_t step,
 	       PyTypeObject *element_type)
 {
   btpy_list_object * const obj = PyObject_New (btpy_list_object,
@@ -654,7 +654,7 @@ PyObject *
 recpy_bt_replay_position (PyObject *self, void *closure)
 {
   const recpy_record_object * const record = (recpy_record_object *) self;
-  thread_info * tinfo = record->thread;
+  struct thread_info * tinfo = record->thread;
 
   if (tinfo == NULL)
     Py_RETURN_NONE;
@@ -673,7 +673,7 @@ PyObject *
 recpy_bt_begin (PyObject *self, void *closure)
 {
   const recpy_record_object * const record = (recpy_record_object *) self;
-  thread_info *const tinfo = record->thread;
+  struct thread_info *const tinfo = record->thread;
   struct btrace_insn_iterator iterator;
 
   if (tinfo == NULL)
@@ -695,7 +695,7 @@ PyObject *
 recpy_bt_end (PyObject *self, void *closure)
 {
   const recpy_record_object * const record = (recpy_record_object *) self;
-  thread_info *const tinfo = record->thread;
+  struct thread_info *const tinfo = record->thread;
   struct btrace_insn_iterator iterator;
 
   if (tinfo == NULL)
@@ -717,7 +717,7 @@ PyObject *
 recpy_bt_instruction_history (PyObject *self, void *closure)
 {
   const recpy_record_object * const record = (recpy_record_object *) self;
-  thread_info *const tinfo = record->thread;
+  struct thread_info *const tinfo = record->thread;
   struct btrace_insn_iterator iterator;
   unsigned long first = 0;
   unsigned long last = 0;
@@ -746,7 +746,7 @@ PyObject *
 recpy_bt_function_call_history (PyObject *self, void *closure)
 {
   const recpy_record_object * const record = (recpy_record_object *) self;
-  thread_info *const tinfo = record->thread;
+  struct thread_info *const tinfo = record->thread;
   struct btrace_call_iterator iterator;
   unsigned long first = 0;
   unsigned long last = 0;
@@ -774,7 +774,7 @@ PyObject *
 recpy_bt_goto (PyObject *self, PyObject *args)
 {
   const recpy_record_object * const record = (recpy_record_object *) self;
-  thread_info *const tinfo = record->thread;
+  struct thread_info *const tinfo = record->thread;
   const recpy_element_object *obj;
 
   if (tinfo == NULL || btrace_is_empty (tinfo))

[-- Attachment #40: gdb_python_python-internal.h.patch --]
[-- Type: text/x-patch, Size: 612 bytes --]

Index: gdb-8.2/gdb/python/python-internal.h
===================================================================
--- gdb-8.2.orig/gdb/python/python-internal.h
+++ gdb-8.2/gdb/python/python-internal.h
@@ -534,7 +534,7 @@ PyObject *gdbpy_lookup_objfile (PyObject
 PyObject *gdbarch_to_arch_object (struct gdbarch *gdbarch);
 
 thread_object *create_thread_object (struct thread_info *tp);
-thread_object *thread_to_thread_object (thread_info *thr)
+thread_object *thread_to_thread_object (struct thread_info *thr)
   CPYCHECKER_RETURNS_BORROWED_REF;
 inferior_object *inferior_to_inferior_object (inferior *inf);
 

[-- Attachment #41: gdb_python_py-threadevent.c.patch --]
[-- Type: text/x-patch, Size: 486 bytes --]

Index: gdb-8.2/gdb/python/py-threadevent.c
===================================================================
--- gdb-8.2.orig/gdb/python/py-threadevent.c
+++ gdb-8.2/gdb/python/py-threadevent.c
@@ -29,7 +29,7 @@ py_get_event_thread (ptid_t ptid)
 
   if (non_stop)
     {
-      thread_info *thread = find_thread_ptid (ptid);
+      struct thread_info *thread = find_thread_ptid (ptid);
       if (thread != nullptr)
 	pythread = (PyObject *) thread_to_thread_object (thread);
     }

[-- Attachment #42: gdb_ravenscar-thread.c.patch --]
[-- Type: text/x-patch, Size: 417 bytes --]

Index: gdb-8.2/gdb/ravenscar-thread.c
===================================================================
--- gdb-8.2.orig/gdb/ravenscar-thread.c
+++ gdb-8.2/gdb/ravenscar-thread.c
@@ -388,7 +388,7 @@ ravenscar_active_task (int cpu)
 }
 
 const char *
-ravenscar_thread_target::extra_thread_info (thread_info *tp)
+ravenscar_thread_target::extra_thread_info (struct thread_info *tp)
 {
   return "Ravenscar task";
 }

[-- Attachment #43: gdb_record-btrace.c.patch --]
[-- Type: text/x-patch, Size: 2498 bytes --]

Index: gdb-8.2/gdb/record-btrace.c
===================================================================
--- gdb-8.2.orig/gdb/record-btrace.c
+++ gdb-8.2/gdb/record-btrace.c
@@ -250,7 +250,7 @@ require_btrace_thread (void)
   if (inferior_ptid == null_ptid)
     error (_("No thread."));
 
-  thread_info *tp = inferior_thread ();
+  struct thread_info *tp = inferior_thread ();
 
   validate_registers_access ();
 
@@ -353,11 +353,11 @@ struct scoped_btrace_disable
 
   ~scoped_btrace_disable ()
   {
-    for (thread_info *tp : m_threads)
+    for (struct thread_info *tp : m_threads)
       btrace_disable (tp);
   }
 
-  void add_thread (thread_info *thread)
+  void add_thread (struct thread_info *thread)
   {
     m_threads.push_front (thread);
   }
@@ -368,7 +368,7 @@ struct scoped_btrace_disable
   }
 
 private:
-  std::forward_list<thread_info *> m_threads;
+  std::forward_list<struct thread_info *> m_threads;
 };
 
 /* Open target record-btrace.  */
@@ -2513,8 +2513,8 @@ record_btrace_step_thread (struct thread
 
 static void
 record_btrace_maybe_mark_async_event
-  (const std::vector<thread_info *> &moving,
-   const std::vector<thread_info *> &no_history)
+  (const std::vector<struct thread_info *> &moving,
+   const std::vector<struct thread_info *> &no_history)
 {
   bool more_moving = !moving.empty ();
   bool more_no_history = !no_history.empty ();;
@@ -2537,8 +2537,8 @@ ptid_t
 record_btrace_target::wait (ptid_t ptid, struct target_waitstatus *status,
 			    int options)
 {
-  std::vector<thread_info *> moving;
-  std::vector<thread_info *> no_history;
+  std::vector<struct thread_info *> moving;
+  std::vector<struct thread_info *> no_history;
 
   DEBUG ("wait %s (0x%x)", target_pid_to_str (ptid), options);
 
@@ -2551,7 +2551,7 @@ record_btrace_target::wait (ptid_t ptid,
 
   /* Keep a work list of moving threads.  */
   {
-    thread_info *tp;
+    struct thread_info *tp;
 
     ALL_NON_EXITED_THREADS (tp)
       {
@@ -2593,7 +2593,7 @@ record_btrace_target::wait (ptid_t ptid,
     {
       for (unsigned int ix = 0; eventing == NULL && ix < moving.size ();)
 	{
-	  thread_info *tp = moving[ix];
+	  struct thread_info *tp = moving[ix];
 
 	  *status = record_btrace_step_thread (tp);
 
@@ -2640,7 +2640,7 @@ record_btrace_target::wait (ptid_t ptid,
   /* Stop all other threads. */
   if (!target_is_non_stop_p ())
     {
-      thread_info *tp;
+      struct thread_info *tp;
 
       ALL_NON_EXITED_THREADS (tp)
 	record_btrace_cancel_resume (tp);

[-- Attachment #44: gdb_regcache.c.patch --]
[-- Type: text/x-patch, Size: 1029 bytes --]

Index: gdb-8.2/gdb/regcache.c
===================================================================
--- gdb-8.2.orig/gdb/regcache.c
+++ gdb-8.2/gdb/regcache.c
@@ -394,7 +394,7 @@ get_thread_regcache (ptid_t ptid)
 /* See regcache.h.  */
 
 struct regcache *
-get_thread_regcache (thread_info *thread)
+get_thread_regcache (struct thread_info *thread)
 {
   return get_thread_regcache (thread->ptid);
 }
@@ -478,7 +478,7 @@ registers_changed_ptid (ptid_t ptid)
 /* See regcache.h.  */
 
 void
-registers_changed_thread (thread_info *thread)
+registers_changed_thread (struct thread_info *thread)
 {
   registers_changed_ptid (thread->ptid);
 }
@@ -1575,7 +1575,7 @@ cooked_read_test (struct gdbarch *gdbarc
   address_space mock_aspace {};
   mock_inferior.gdbarch = gdbarch;
   mock_inferior.aspace = &mock_aspace;
-  thread_info mock_thread (&mock_inferior, mock_ptid);
+  struct thread_info mock_thread (&mock_inferior, mock_ptid);
 
   scoped_restore restore_thread_list
     = make_scoped_restore (&thread_list, &mock_thread);

[-- Attachment #45: gdb_regcache.h.patch --]
[-- Type: text/x-patch, Size: 1081 bytes --]

Index: gdb-8.2/gdb/regcache.h
===================================================================
--- gdb-8.2.orig/gdb/regcache.h
+++ gdb-8.2/gdb/regcache.h
@@ -21,6 +21,7 @@
 #define REGCACHE_H
 
 #include "common-regcache.h"
+#include "function-view.h"
 #include <forward_list>
 
 struct regcache;
@@ -32,7 +33,7 @@ extern struct regcache *get_current_regc
 extern struct regcache *get_thread_regcache (ptid_t ptid);
 
 /* Get the regcache of THREAD.  */
-extern struct regcache *get_thread_regcache (thread_info *thread);
+extern struct regcache *get_thread_regcache (struct thread_info *thread);
 
 extern struct regcache *get_thread_arch_regcache (ptid_t, struct gdbarch *);
 extern struct regcache *get_thread_arch_aspace_regcache (ptid_t,
@@ -436,7 +437,7 @@ extern void registers_changed_ptid (ptid
 
 /* Indicate that registers of THREAD may have changed, so invalidate
    the cache.  */
-extern void registers_changed_thread (thread_info *thread);
+extern void registers_changed_thread (struct thread_info *thread);
 
 /* An abstract base class for register dump.  */
 

[-- Attachment #46: gdb_remote.c.patch --]
[-- Type: text/x-patch, Size: 3597 bytes --]

Index: gdb-8.2/gdb/remote.c
===================================================================
--- gdb-8.2.orig/gdb/remote.c
+++ gdb-8.2/gdb/remote.c
@@ -495,7 +495,7 @@ public:
 
   ptid_t get_ada_task_ptid (long lwp, long thread) override;
 
-  thread_info *thread_handle_to_thread_info (const gdb_byte *thread_handle,
+  struct thread_info *thread_handle_to_thread_info (const gdb_byte *thread_handle,
 					     int handle_len,
 					     inferior *inf) override;
 
@@ -758,7 +758,7 @@ public: /* Remote specific methods.  */
 
   void process_initial_stop_replies (int from_tty);
 
-  thread_info *remote_add_thread (ptid_t ptid, bool running, bool executing);
+  struct thread_info *remote_add_thread (ptid_t ptid, bool running, bool executing);
 
   void btrace_sync_conf (const btrace_config *conf);
 
@@ -2379,7 +2379,7 @@ static remote_thread_info *get_remote_th
 /* Add thread PTID to GDB's thread list.  Tag it as executing/running
    according to RUNNING.  */
 
-thread_info *
+struct thread_info *
 remote_target::remote_add_thread (ptid_t ptid, bool running, bool executing)
 {
   struct remote_state *rs = get_remote_state ();
@@ -2421,7 +2421,7 @@ remote_target::remote_notice_new_inferio
   /* If this is a new thread, add it to GDB's thread list.
      If we leave it up to WFI to do this, bad things will happen.  */
 
-  thread_info *tp = find_thread_ptid (currthread);
+  struct thread_info *tp = find_thread_ptid (currthread);
   if (tp != NULL && tp->state == THREAD_EXITED)
     {
       /* We're seeing an event on a thread id we knew had exited.
@@ -2478,7 +2478,7 @@ remote_target::remote_notice_new_inferio
 	}
 
       /* This is really a new thread.  Add it.  */
-      thread_info *new_thr
+      struct thread_info *new_thr
 	= remote_add_thread (currthread, running, executing);
 
       /* If we found a new inferior, let the common code do whatever
@@ -2511,7 +2511,7 @@ get_remote_thread_info (struct thread_in
 static remote_thread_info *
 get_remote_thread_info (ptid_t ptid)
 {
-  thread_info *thr = find_thread_ptid (ptid);
+  struct thread_info *thr = find_thread_ptid (ptid);
   return get_remote_thread_info (thr);
 }
 
@@ -3797,7 +3797,7 @@ remote_target::update_thread_list ()
 
 	      remote_notice_new_inferior (item.ptid, executing);
 
-	      thread_info *tp = find_thread_ptid (item.ptid);
+	      struct thread_info *tp = find_thread_ptid (item.ptid);
 	      remote_thread_info *info = get_remote_thread_info (tp);
 	      info->core = item.core;
 	      info->extra = std::move (item.extra);
@@ -3827,7 +3827,7 @@ remote_target::update_thread_list ()
  */
 
 const char *
-remote_target::extra_thread_info (thread_info *tp)
+remote_target::extra_thread_info (struct thread_info *tp)
 {
   struct remote_state *rs = get_remote_state ();
   int set;
@@ -5872,7 +5872,7 @@ extended_remote_target::attach (const ch
       inferior_ptid = remote_current_thread (inferior_ptid);
 
       /* Add the main thread to the thread list.  */
-      thread_info *thr = add_thread_silent (inferior_ptid);
+      struct thread_info *thr = add_thread_silent (inferior_ptid);
       /* Don't consider the thread stopped until we've processed the
 	 saved stop reply.  */
       set_executing (thr->ptid, true);
@@ -13969,7 +13969,7 @@ remote_target::execution_direction ()
 /* Return pointer to the thread_info struct which corresponds to
    THREAD_HANDLE (having length HANDLE_LEN).  */
 
-thread_info *
+struct thread_info *
 remote_target::thread_handle_to_thread_info (const gdb_byte *thread_handle,
 					     int handle_len,
 					     inferior *inf)

[-- Attachment #47: gdb_s390-linux-tdep.c.patch --]
[-- Type: text/x-patch, Size: 500 bytes --]

Index: gdb-8.2/gdb/s390-linux-tdep.c
===================================================================
--- gdb-8.2.orig/gdb/s390-linux-tdep.c
+++ gdb-8.2/gdb/s390-linux-tdep.c
@@ -558,7 +558,7 @@ static const struct frame_unwind s390_si
 
 static LONGEST
 s390_linux_get_syscall_number (struct gdbarch *gdbarch,
-			       thread_info *thread)
+			       struct thread_info *thread)
 {
   struct regcache *regs = get_thread_regcache (thread);
   struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);

[-- Attachment #48: gdb_sparc64-linux-tdep.c.patch --]
[-- Type: text/x-patch, Size: 514 bytes --]

Index: gdb-8.2/gdb/sparc64-linux-tdep.c
===================================================================
--- gdb-8.2.orig/gdb/sparc64-linux-tdep.c
+++ gdb-8.2/gdb/sparc64-linux-tdep.c
@@ -282,7 +282,7 @@ sparc64_linux_write_pc (struct regcache
 
 static LONGEST
 sparc64_linux_get_syscall_number (struct gdbarch *gdbarch,
-				  thread_info *thread)
+				  struct thread_info *thread)
 {
   struct regcache *regcache = get_thread_regcache (thread);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);

[-- Attachment #49: gdb_sparc-linux-tdep.c.patch --]
[-- Type: text/x-patch, Size: 509 bytes --]

Index: gdb-8.2/gdb/sparc-linux-tdep.c
===================================================================
--- gdb-8.2.orig/gdb/sparc-linux-tdep.c
+++ gdb-8.2/gdb/sparc-linux-tdep.c
@@ -274,7 +274,7 @@ sparc_linux_write_pc (struct regcache *r
 
 static LONGEST
 sparc32_linux_get_syscall_number (struct gdbarch *gdbarch,
-				  thread_info *thread)
+				  struct thread_info *thread)
 {
   struct regcache *regcache = get_thread_regcache (thread);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);

[-- Attachment #50: gdb_target.c.patch --]
[-- Type: text/x-patch, Size: 457 bytes --]

Index: gdb-8.2/gdb/target.c
===================================================================
--- gdb-8.2.orig/gdb/target.c
+++ gdb-8.2/gdb/target.c
@@ -2025,7 +2025,7 @@ target_pre_inferior (int from_tty)
 static int
 dispose_inferior (struct inferior *inf, void *args)
 {
-  thread_info *thread = any_thread_of_inferior (inf);
+  struct thread_info *thread = any_thread_of_inferior (inf);
   if (thread != NULL)
     {
       switch_to_thread (thread);

[-- Attachment #51: gdb_target.h.patch --]
[-- Type: text/x-patch, Size: 870 bytes --]

Index: gdb-8.2/gdb/target.h
===================================================================
--- gdb-8.2.orig/gdb/target.h
+++ gdb-8.2/gdb/target.h
@@ -649,11 +649,11 @@ struct target_ops
       TARGET_DEFAULT_IGNORE ();
     virtual const char *pid_to_str (ptid_t)
       TARGET_DEFAULT_FUNC (default_pid_to_str);
-    virtual const char *extra_thread_info (thread_info *)
+    virtual const char *extra_thread_info (struct thread_info *)
       TARGET_DEFAULT_RETURN (NULL);
-    virtual const char *thread_name (thread_info *)
+    virtual const char *thread_name (struct thread_info *)
       TARGET_DEFAULT_RETURN (NULL);
-    virtual thread_info *thread_handle_to_thread_info (const gdb_byte *,
+    virtual struct thread_info *thread_handle_to_thread_info (const gdb_byte *,
 						       int,
 						       inferior *inf)
       TARGET_DEFAULT_RETURN (NULL);

[-- Attachment #52: gdb_thread.c.patch --]
[-- Type: text/x-patch, Size: 5360 bytes --]

Index: gdb-8.2/gdb/thread.c
===================================================================
--- gdb-8.2.orig/gdb/thread.c
+++ gdb-8.2/gdb/thread.c
@@ -281,7 +281,7 @@ add_thread_silent (ptid_t ptid)
 
       if (inferior_ptid == ptid)
 	{
-	  thread_info *new_thr = new_thread (inf, null_ptid);
+	  struct thread_info *new_thr = new_thread (inf, null_ptid);
 
 	  /* Make switch_to_thread not read from the thread.  */
 	  new_thr->state = THREAD_EXITED;
@@ -436,7 +436,7 @@ thread_step_over_chain_remove (struct th
    exit.  */
 
 static void
-delete_thread_1 (thread_info *thr, bool silent)
+delete_thread_1 (struct thread_info *thr, bool silent)
 {
   struct thread_info *tp, *tpprev;
 
@@ -471,13 +471,13 @@ delete_thread_1 (thread_info *thr, bool
    it.  */
 
 void
-delete_thread (thread_info *thread)
+delete_thread (struct thread_info *thread)
 {
   delete_thread_1 (thread, false /* not silent */);
 }
 
 void
-delete_thread_silent (thread_info *thread)
+delete_thread_silent (struct thread_info *thread)
 {
   delete_thread_1 (thread, true /* silent */);
 }
@@ -613,7 +613,7 @@ in_thread_list (ptid_t ptid)
 
 /* Finds the first thread of the inferior.  */
 
-thread_info *
+struct thread_info *
 first_thread_of_inferior (inferior *inf)
 {
   struct thread_info *tp, *ret = NULL;
@@ -626,7 +626,7 @@ first_thread_of_inferior (inferior *inf)
   return ret;
 }
 
-thread_info *
+struct thread_info *
 any_thread_of_inferior (inferior *inf)
 {
   struct thread_info *tp;
@@ -644,7 +644,7 @@ any_thread_of_inferior (inferior *inf)
   return NULL;
 }
 
-thread_info *
+struct thread_info *
 any_live_thread_of_inferior (inferior *inf)
 {
   struct thread_info *curr_tp = NULL;
@@ -727,7 +727,7 @@ delete_exited_threads (void)
    TP.  */
 
 bool
-thread_stack_temporaries_enabled_p (thread_info *tp)
+thread_stack_temporaries_enabled_p (struct thread_info *tp)
 {
   if (tp == NULL)
     return false;
@@ -738,7 +738,7 @@ thread_stack_temporaries_enabled_p (thre
 /* Push V on to the stack temporaries of the thread with id PTID.  */
 
 void
-push_thread_stack_temporary (thread_info *tp, struct value *v)
+push_thread_stack_temporary (struct thread_info *tp, struct value *v)
 {
   gdb_assert (tp != NULL && tp->stack_temporaries_enabled);
   tp->stack_temporaries.push_back (v);
@@ -748,7 +748,7 @@ push_thread_stack_temporary (thread_info
    TP.  Return false otherwise.  */
 
 bool
-value_in_thread_stack_temporaries (struct value *val, thread_info *tp)
+value_in_thread_stack_temporaries (struct value *val, struct thread_info *tp)
 {
   gdb_assert (tp != NULL && tp->stack_temporaries_enabled);
   for (value *v : tp->stack_temporaries)
@@ -762,7 +762,7 @@ value_in_thread_stack_temporaries (struc
    Return NULL if there are no stack temporaries for the thread.  */
 
 value *
-get_last_thread_stack_temporary (thread_info *tp)
+get_last_thread_stack_temporary (struct thread_info *tp)
 {
   struct value *lastval = NULL;
 
@@ -923,7 +923,7 @@ is_executing (ptid_t ptid)
    stop_pc.  */
 
 static void
-set_executing_thread (thread_info *thr, bool executing)
+set_executing_thread (struct thread_info *thr, bool executing)
 {
   thr->executing = executing;
   if (executing)
@@ -1037,7 +1037,7 @@ validate_registers_access (void)
   if (inferior_ptid == null_ptid)
     error (_("No thread selected."));
 
-  thread_info *tp = inferior_thread ();
+  struct thread_info *tp = inferior_thread ();
 
   /* Don't try to read from a dead thread.  */
   if (tp->state == THREAD_EXITED)
@@ -1055,7 +1055,7 @@ validate_registers_access (void)
 /* See gdbthread.h.  */
 
 bool
-can_access_registers_thread (thread_info *thread)
+can_access_registers_thread (struct thread_info *thread)
 {
   /* No thread, no registers.  */
   if (thread == NULL)
@@ -1123,7 +1123,7 @@ should_print_thread (const char *request
    column, for TP.  */
 
 static std::string
-thread_target_id_str (thread_info *tp)
+thread_target_id_str (struct thread_info *tp)
 {
   const char *target_id = target_pid_to_str (tp->ptid);
   const char *extra_info = target_extra_thread_info (tp);
@@ -1159,7 +1159,7 @@ print_thread_info_1 (struct ui_out *uiou
   /* Whether the current thread is exited.  */
   bool current_exited = false;
 
-  thread_info *current_thread = (inferior_ptid != null_ptid
+  struct thread_info *current_thread = (inferior_ptid != null_ptid
 				 ? inferior_thread () : NULL);
 
   {
@@ -1378,7 +1378,7 @@ switch_to_no_thread ()
 /* See gdbthread.h.  */
 
 void
-switch_to_thread (thread_info *thr)
+switch_to_thread (struct thread_info *thr)
 {
   gdb_assert (thr != NULL);
 
@@ -1395,7 +1395,7 @@ switch_to_thread (thread_info *thr)
 void
 switch_to_thread (ptid_t ptid)
 {
-  thread_info *thr = find_thread_ptid (ptid);
+  struct thread_info *thr = find_thread_ptid (ptid);
   switch_to_thread (thr);
 }
 
@@ -1498,7 +1498,7 @@ scoped_restore_current_thread::scoped_re
 
   if (inferior_ptid != null_ptid)
     {
-      thread_info *tp = inferior_thread ();
+      struct thread_info *tp = inferior_thread ();
       struct frame_info *frame;
 
       m_was_stopped = tp->state == THREAD_STOPPED;
@@ -1962,7 +1962,7 @@ thread_num_make_value_helper (struct gdb
     int_val = 0;
   else
     {
-      thread_info *tp = inferior_thread ();
+      struct thread_info *tp = inferior_thread ();
       if (global)
 	int_val = tp->global_num;
       else

[-- Attachment #53: gdb_top.c.patch --]
[-- Type: text/x-patch, Size: 425 bytes --]

Index: gdb-8.2/gdb/top.c
===================================================================
--- gdb-8.2.orig/gdb/top.c
+++ gdb-8.2/gdb/top.c
@@ -1504,7 +1504,7 @@ kill_or_detach (struct inferior *inf, vo
   if (inf->pid == 0)
     return 0;
 
-  thread_info *thread = any_thread_of_inferior (inf);
+  struct thread_info *thread = any_thread_of_inferior (inf);
   if (thread != NULL)
     {
       switch_to_thread (thread);

[-- Attachment #54: gdb_varobj.c.patch --]
[-- Type: text/x-patch, Size: 426 bytes --]

Index: gdb-8.2/gdb/varobj.c
===================================================================
--- gdb-8.2.orig/gdb/varobj.c
+++ gdb-8.2/gdb/varobj.c
@@ -2122,7 +2122,7 @@ value_of_root_1 (struct varobj **var_han
     }
   else
     {
-      thread_info *thread = find_thread_global_id (var->root->thread_id);
+      struct thread_info *thread = find_thread_global_id (var->root->thread_id);
 
       if (thread != NULL)
 	{

[-- Attachment #55: gnu-nat.c.patch --]
[-- Type: text/x-patch, Size: 2981 bytes --]

Index: gdb/gdb/gnu-nat.c
===================================================================
--- gdb.orig/gdb/gnu-nat.c
+++ gdb/gdb/gnu-nat.c
@@ -67,6 +67,7 @@ extern "C"
 #include "gdb_obstack.h"
 #include "tid-parse.h"
 
+#include "nat/fork-inferior.h"
 #include "gnu-nat.h"
 #include "inf-child.h"
 
@@ -1872,22 +1873,28 @@ S_proc_wait_reply (mach_port_t reply, ke
   return 0;
 }
 
+/* Note: The third argument to S_proc_getmsgport_reply, S_proc_task2proc_reply and
+   S_proc_pid2proc_reply is of type mach_port_poly_t. Look at gdb/process_reply_S.h
+   derived from process_reply.defs to find out the fourth argument */
+
 ILL_RPC (S_proc_setmsgport_reply,
 	 mach_port_t reply_port, kern_return_t return_code,
 	 mach_port_t oldmsgport)
 ILL_RPC (S_proc_getmsgport_reply,
 	 mach_port_t reply_port, kern_return_t return_code,
-	 mach_port_t msgports)
+	 mach_port_t msgports, mach_msg_type_name_t msgportsPoly)
 ILL_RPC (S_proc_pid2task_reply,
 	 mach_port_t reply_port, kern_return_t return_code, mach_port_t task)
 ILL_RPC (S_proc_task2pid_reply,
 	 mach_port_t reply_port, kern_return_t return_code, pid_t pid)
 ILL_RPC (S_proc_task2proc_reply,
-	 mach_port_t reply_port, kern_return_t return_code, mach_port_t proc)
+	 mach_port_t reply_port, kern_return_t return_code, mach_port_t proc,
+	 mach_msg_type_name_t procPoly)
 ILL_RPC (S_proc_proc2task_reply,
 	 mach_port_t reply_port, kern_return_t return_code, mach_port_t task)
 ILL_RPC (S_proc_pid2proc_reply,
-	 mach_port_t reply_port, kern_return_t return_code, mach_port_t proc)
+	 mach_port_t reply_port, kern_return_t return_code, mach_port_t proc,
+	 mach_msg_type_name_t procPoly)
 ILL_RPC (S_proc_getprocinfo_reply,
 	 mach_port_t reply_port, kern_return_t return_code,
 	 int flags, procinfo_t procinfo, mach_msg_type_number_t procinfoCnt,
@@ -2358,7 +2365,7 @@ gnu_write_inferior (task_t task, CORE_AD
   mach_msg_type_number_t copy_count;
   int deallocate = 0;
 
-  char *errstr = "Bug in gnu_write_inferior";
+  const char *errstr = "Bug in gnu_write_inferior";
 
   struct vm_region_list *region_element;
   struct vm_region_list *region_head = NULL;
@@ -2775,7 +2782,7 @@ show_thread_default_cmd (const char *arg
 }
 
 static int
-parse_int_arg (const char *args, char *cmd_prefix)
+parse_int_arg (const char *args, const char *cmd_prefix)
 {
   if (args)
     {
@@ -2790,7 +2797,7 @@ parse_int_arg (const char *args, char *c
 }
 
 static int
-_parse_bool_arg (const char *args, char *t_val, char *f_val, char *cmd_prefix)
+_parse_bool_arg (const char *args, const char *t_val, const char *f_val, const char *cmd_prefix)
 {
   if (!args || strcmp (args, t_val) == 0)
     return 1;
@@ -2806,7 +2813,7 @@ _parse_bool_arg (const char *args, char
   _parse_bool_arg (args, "on", "off", cmd_prefix)
 
 static void
-check_empty (const char *args, char *cmd_prefix)
+check_empty (const char *args, const char *cmd_prefix)
 {
   if (args)
     error (_("Garbage after \"%s\" command: `%s'"), cmd_prefix, args);

[-- Attachment #56: series --]
[-- Type: text/plain, Size: 1514 bytes --]

gdb-fortran-main.patch
solve_PATH_MAX_issue.patch
gdb-6.5-bz185337-resolve-tls-without-debuginfo-v2.patch
python-config.patch
gdb-glibc-vdso-workaround.patch
load-versioned-libcc1.patch
gdb_configure.nat.patch
gdb-PATH_MAX.patch
gnu-nat.c.patch
struct-thread_info.patch
gdb_gdbarch.sh.patch
gdb_regcache.h.patch
gdb_dummy-frame.h.patch
#gdb_gdbarch.h.patch
gdb_breakpoint.h.patch
gdb_target.h.patch
gdb_gnu-nat.h.patch
gdb_gnu-nat.c.patch
gdb_ada-lang.h.patch
gdb_mi_mi-cmd-var.c.patch
gdb_mi_mi-interp.c.patch
gdb_mi_mi-main.c.patch
gdb_python_python-internal.h.patch
gdb_python_py-inferior.c.patch
gdb_python_py-record.h.patch
gdb_python_py-record.c.patch
gdb_python_py-record-btrace.c.patch
gdb_python_py-threadevent.c.patch
gdb_elfread.c.patch
gdb_ada-tasks.c.patch
gdb_inline-frame.h.patch
gdb_breakpoint.c.patch
gdb_btrace.c.patch
gdb_corelow.c.patch
gdb_dummy-frame.c.patch
gdb_frame.c.patch
gdb_infcall.c.patch
gdb_infcmd.c.patch
gdb_inferior.c.patch
gdb_infrun.c.patch
gdb_inline-frame.c.patch
gdb_record-btrace.c.patch
gdb_regcache.c.patch
gdb_remote.c.patch
gdb_target.c.patch
gdb_thread.c.patch
gdb_top.c.patch
gdb_varobj.c.patch
gdb_compile_compile-object-load.c.patch
gdb_inflow.c.patch
gdb_aarch64-linux-tdep.c.patch
gdb_arm-linux-tdep.c.patch
gdb_amd64-linux-tdep.c.patch
gdb_i386-linux-tdep.c.patch
gdb_mips-linux-tdep.c.patch
gdb_ppc-linux-tdep.c.patch
gdb_ravenscar-thread.c.patch
gdb_s390-linux-tdep.c.patch
gdb_sparc64-linux-tdep.c.patch
gdb_sparc-linux-tdep.c.patch
gdb_i386-gnu-nat.c.patch


[-- Attachment #57: series.orig --]
[-- Type: text/plain, Size: 270 bytes --]

gdb-fortran-main.patch
solve_PATH_MAX_issue.patch
gdb-6.5-bz185337-resolve-tls-without-debuginfo-v2.patch
python-config.patch
gdb-glibc-vdso-workaround.patch
load-versioned-libcc1.patch
gdb_configure.nat.patch
gdb-PATH_MAX.patch
gnu-nat.c.patch
struct-thread_info.patch

[-- Attachment #58: solve_PATH_MAX_issue.patch --]
[-- Type: text/x-patch, Size: 1471 bytes --]

Description: Patch out a PATH_MAX usage, for Hurd's benefit

Author: Svante Signell <svante.signell@gmail.com>
Bug-Debian: http://bugs.debian.org/709508
Forwarded: http://sourceware.org/ml/gdb-patches/2013-05/msg00878.html
Reviewed-By: Héctor Orón Martínez <zumbi@debian.org>
Last-Update: 2013-06-08

Index: gdb/gdb/nto-tdep.c
===================================================================
--- gdb.orig/gdb/nto-tdep.c	2017-06-04 20:17:55.347905828 +0200
+++ gdb/gdb/nto-tdep.c	2017-06-04 20:17:55.343905913 +0200
@@ -153,10 +153,12 @@
 void
 nto_init_solib_absolute_prefix (void)
 {
-  char buf[PATH_MAX * 2], arch_path[PATH_MAX];
+  char *buf, *arch_path;
   char *nto_root;
   const char *endian;
   const char *arch;
+  int arch_len, len;
+#define FMT "set solib-absolute-prefix %s"
 
   nto_root = nto_target ();
   if (strcmp (gdbarch_bfd_arch_info (target_gdbarch ())->arch_name, "i386") == 0)
@@ -179,9 +181,13 @@
 	       == BFD_ENDIAN_BIG ? "be" : "le";
     }
 
-  xsnprintf (arch_path, sizeof (arch_path), "%s/%s%s", nto_root, arch, endian);
+  arch_len = strlen (nto_root) + 1 + strlen (arch) + strlen (endian) + 1;
+  arch_path = alloca (arch_len);
+  xsnprintf (arch_path, arch_len, "%s/%s%s", nto_root, arch, endian);
 
-  xsnprintf (buf, sizeof (buf), "set solib-absolute-prefix %s", arch_path);
+  len = strlen (FMT) - 2 + strlen (arch_path) + 1;
+  buf =  alloca (len);
+  xsnprintf (buf, len, FMT, arch_path);
   execute_command (buf, 0);
 }
 

[-- Attachment #59: struct-thread_info.patch --]
[-- Type: text/x-patch, Size: 7958 bytes --]

Index: gdb/gdb/thread.c
===================================================================
--- gdb.orig/gdb/thread.c
+++ gdb/gdb/thread.c
@@ -68,21 +68,21 @@ static int thread_alive (struct thread_i
 class scoped_inc_dec_ref
 {
 public:
-  explicit scoped_inc_dec_ref (const std::vector<thread_info *> &thrds)
+  explicit scoped_inc_dec_ref (const std::vector<struct thread_info *> &thrds)
     : m_thrds (thrds)
   {
-    for (thread_info *thr : m_thrds)
+    for (struct thread_info *thr : m_thrds)
       thr->incref ();
   }
 
   ~scoped_inc_dec_ref ()
   {
-    for (thread_info *thr : m_thrds)
+    for (struct thread_info *thr : m_thrds)
       thr->decref ();
   }
 
 private:
-  const std::vector<thread_info *> &m_thrds;
+  const std::vector<struct thread_info *> &m_thrds;
 };
 
 
@@ -199,7 +199,7 @@ clear_thread_inferior_resources (struct
 /* Set the TP's state as exited.  */
 
 static void
-set_thread_exited (thread_info *tp, int silent)
+set_thread_exited (struct thread_info *tp, int silent)
 {
   /* Dead threads don't need to step-over.  Remove from queue.  */
   if (tp->step_over_next != NULL)
@@ -242,7 +242,7 @@ init_thread_list (void)
 static struct thread_info *
 new_thread (struct inferior *inf, ptid_t ptid)
 {
-  thread_info *tp = new thread_info (inf, ptid);
+  struct thread_info *tp = new struct thread_info (inf, ptid);
 
   if (thread_list == NULL)
     thread_list = tp;
@@ -1567,7 +1567,7 @@ static bool tp_array_compar_ascending;
    order is determined by TP_ARRAY_COMPAR_ASCENDING.  */
 
 static bool
-tp_array_compar (const thread_info *a, const thread_info *b)
+tp_array_compar (const struct thread_info *a, const struct thread_info *b)
 {
   if (a->inf->num != b->inf->num)
     {
@@ -1615,11 +1615,11 @@ thread_apply_all_command (const char *cm
 	 thread, in case the command is one that wipes threads.  E.g.,
 	 detach, kill, disconnect, etc., or even normally continuing
 	 over an inferior or thread exit.  */
-      std::vector<thread_info *> thr_list_cpy;
+      std::vector<struct thread_info *> thr_list_cpy;
       thr_list_cpy.reserve (tc);
 
       {
-	thread_info *tp;
+	struct thread_info *tp;
 
 	ALL_NON_EXITED_THREADS (tp)
 	  {
@@ -1637,7 +1637,7 @@ thread_apply_all_command (const char *cm
 
       scoped_restore_current_thread restore_thread;
 
-      for (thread_info *thr : thr_list_cpy)
+      for (struct thread_info *thr : thr_list_cpy)
 	if (thread_alive (thr))
 	  {
 	    switch_to_thread (thr);
@@ -1868,7 +1868,7 @@ show_print_thread_events (struct ui_file
 /* See gdbthread.h.  */
 
 void
-thread_select (const char *tidstr, thread_info *tp)
+thread_select (const char *tidstr, struct thread_info *tp)
 {
   if (!thread_alive (tp))
     error (_("Thread ID %s has terminated."), tidstr);
Index: gdb/gdb/breakpoint.c
===================================================================
--- gdb.orig/gdb/breakpoint.c
+++ gdb/gdb/breakpoint.c
@@ -12771,7 +12771,7 @@ momentary_bkpt_print_mention (struct bre
 
 longjmp_breakpoint::~longjmp_breakpoint ()
 {
-  thread_info *tp = find_thread_global_id (this->thread);
+  struct thread_info *tp = find_thread_global_id (this->thread);
 
   if (tp != NULL)
     tp->initiating_frame = null_frame_id;
Index: gdb/gdb/infcmd.c
===================================================================
--- gdb.orig/gdb/infcmd.c
+++ gdb/gdb/infcmd.c
@@ -663,7 +663,7 @@ run_command_1 (const char *args, int fro
   /* Queue a pending event so that the program stops immediately.  */
   if (run_how == RUN_STOP_AT_FIRST_INSN)
     {
-      thread_info *thr = inferior_thread ();
+      struct thread_info *thr = inferior_thread ();
       thr->suspend.waitstatus_pending_p = 1;
       thr->suspend.waitstatus.kind = TARGET_WAITKIND_STOPPED;
       thr->suspend.waitstatus.value.sig = GDB_SIGNAL_0;
@@ -913,7 +913,7 @@ set_step_frame (void)
   set_step_info (frame, sal);
 
   CORE_ADDR pc = get_frame_pc (frame);
-  thread_info *tp = inferior_thread ();
+  struct thread_info *tp = inferior_thread ();
   tp->control.step_start_function = find_pc_function (pc);
 }
 
Index: gdb/gdb/progspace-and-thread.c
===================================================================
--- gdb.orig/gdb/progspace-and-thread.c
+++ gdb/gdb/progspace-and-thread.c
@@ -28,7 +28,7 @@ switch_to_program_space_and_thread (prog
 
   if (inf != NULL && inf->pid != 0)
     {
-      thread_info *tp = any_live_thread_of_inferior (inf);
+      struct thread_info *tp = any_live_thread_of_inferior (inf);
 
       if (tp != NULL)
 	{
Index: gdb/gdb/remote.c
===================================================================
--- gdb.orig/gdb/remote.c
+++ gdb/gdb/remote.c
@@ -2373,7 +2373,7 @@ remote_target::remote_add_inferior (int
   return inf;
 }
 
-static remote_thread_info *get_remote_thread_info (thread_info *thread);
+static remote_thread_info *get_remote_thread_info (struct thread_info *thread);
 static remote_thread_info *get_remote_thread_info (ptid_t ptid);
 
 /* Add thread PTID to GDB's thread list.  Tag it as executing/running
@@ -2498,7 +2498,7 @@ remote_target::remote_notice_new_inferio
 /* Return THREAD's private thread data, creating it if necessary.  */
 
 static remote_thread_info *
-get_remote_thread_info (thread_info *thread)
+get_remote_thread_info (struct thread_info *thread)
 {
   gdb_assert (thread != NULL);
 
@@ -4315,7 +4315,7 @@ remote_target::add_current_inferior_and_
   /* Add the main thread and switch to it.  Don't try reading
      registers yet, since we haven't fetched the target description
      yet.  */
-  thread_info *tp = add_thread_silent (curr_ptid);
+  struct thread_info *tp = add_thread_silent (curr_ptid);
   switch_to_thread_no_regs (tp);
 }
 
Index: gdb/gdb/linux-tdep.c
===================================================================
--- gdb.orig/gdb/linux-tdep.c
+++ gdb/gdb/linux-tdep.c
@@ -1652,7 +1652,7 @@ linux_collect_thread_registers (const st
    buffer.  */
 
 static gdb::byte_vector
-linux_get_siginfo_data (thread_info *thread, struct gdbarch *gdbarch)
+linux_get_siginfo_data (struct thread_info *thread, struct gdbarch *gdbarch)
 {
   struct type *siginfo_type;
   LONGEST bytes_read;
Index: gdb/gdb/mi/mi-main.c
===================================================================
--- gdb.orig/gdb/mi/mi-main.c
+++ gdb/gdb/mi/mi-main.c
@@ -554,7 +554,7 @@ mi_cmd_thread_select (const char *comman
     error (_("-thread-select: USAGE: threadnum."));
 
   int num = value_as_long (parse_and_eval (argv[0]));
-  thread_info *thr = find_thread_global_id (num);
+  struct thread_info *thr = find_thread_global_id (num);
   if (thr == NULL)
     error (_("Thread ID %d not known."), num);
 
Index: gdb/gdb/python/py-record-btrace.c
===================================================================
--- gdb.orig/gdb/python/py-record-btrace.c
+++ gdb/gdb/python/py-record-btrace.c
@@ -72,7 +72,7 @@ btrace_insn_from_recpy_insn (const PyObj
 {
   const btrace_insn *insn;
   const recpy_element_object *obj;
-  thread_info *tinfo;
+  struct thread_info *tinfo;
   btrace_insn_iterator iter;
 
   if (Py_TYPE (pyobject) != &recpy_insn_type)
@@ -115,7 +115,7 @@ btrace_func_from_recpy_func (const PyObj
 {
   const btrace_function *func;
   const recpy_element_object *obj;
-  thread_info *tinfo;
+  struct thread_info *tinfo;
   btrace_call_iterator iter;
 
   if (Py_TYPE (pyobject) != &recpy_func_type)
@@ -153,7 +153,7 @@ btrace_func_from_recpy_func (const PyObj
    gdb.RecordInstruction or gdb.RecordGap object for it accordingly.  */
 
 static PyObject *
-btpy_insn_or_gap_new (thread_info *tinfo, Py_ssize_t number)
+btpy_insn_or_gap_new (struct thread_info *tinfo, Py_ssize_t number)
 {
   btrace_insn_iterator iter;
   int err_code;
@@ -339,7 +339,7 @@ PyObject *
 recpy_bt_func_level (PyObject *self, void *closure)
 {
   const btrace_function * const func = btrace_func_from_recpy_func (self);
-  thread_info *tinfo;
+  struct thread_info *tinfo;
 
   if (func == NULL)
     return NULL;

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH] Please define thread_info as struct thread_info (and other stuff)
  2018-12-15 19:36 [PATCH] Please define thread_info as struct thread_info (and other stuff) Svante Signell
@ 2018-12-15 22:48 ` Tom Tromey
  2018-12-15 23:01   ` Svante Signell
  2018-12-16  9:20 ` Andreas Schwab
  1 sibling, 1 reply; 20+ messages in thread
From: Tom Tromey @ 2018-12-15 22:48 UTC (permalink / raw)
  To: Svante Signell; +Cc: gdb-patches

>>>>> "Svante" == Svante Signell <svante.signell@gmail.com> writes:

Svante> When building gdb version 8.2 on GNU/Hurd several problems arise that need to be
Svante> solved. One problem is that most files in gdb/ have sloppy definitions of struct
Svante> thread_info, causing a build stop fore every occurrence. They are excluding the
Svante> struct part, making the build (and port) on Hurd very cumbersome. Can you please
Svante> fix all bad references to thread_info upstream? I don't really understand how
Svante> gcc can let these errors pass on GNU/Linux.

In C++ there's an implicit typedef for a struct tag, so "struct
thread_info" can also just be referred to as "thread_info".  So, I tend
to think the code is fine and something else is going wrong.

You didn't post the text of the error or the version of the compiler
that you are using, so it's hard to say more about what the problem is.
Could you send that info?

Svante> More patches will be needed for a successful port of gdb-8.2 to GNU/hurd, but
Svante> please fix the above problems upstream first.

I didn't go through all the patches, but I suggest sending a series
rather than one large message; following the contribution checklist; and
finally, working off git master rather than a branch.

thanks,
Tom

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH] Please define thread_info as struct thread_info (and other stuff)
  2018-12-15 22:48 ` Tom Tromey
@ 2018-12-15 23:01   ` Svante Signell
  2018-12-16  4:31     ` Simon Marchi
  0 siblings, 1 reply; 20+ messages in thread
From: Svante Signell @ 2018-12-15 23:01 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On Sat, 2018-12-15 at 15:48 -0700, Tom Tromey wrote:
> > > > > > "Svante" == Svante Signell <svante.signell@gmail.com> writes:
> 
> Svante> When building gdb version 8.2 on GNU/Hurd several problems arise that
> need to be
> Svante> solved. One problem is that most files in gdb/ have sloppy definitions
> of struct
> Svante> thread_info, causing a build stop fore every occurrence. They are
> excluding the
> Svante> struct part, making the build (and port) on Hurd very cumbersome. Can
> you please
> Svante> fix all bad references to thread_info upstream? I don't really
> understand how
> Svante> gcc can let these errors pass on GNU/Linux.
> 
> In C++ there's an implicit typedef for a struct tag, so "struct
> thread_info" can also just be referred to as "thread_info".  So, I tend
> to think the code is fine and something else is going wrong.
> 
> You didn't post the text of the error or the version of the compiler
> that you are using, so it's hard to say more about what the problem is.
> Could you send that info?

A typical error output:
CXX    target.o
/home/srs/DEBs/gdb/gdb-8.2/gdb/target.c: In function ‘int
dispose_inferior(inferior*, void*)’:
/home/srs/DEBs/gdb/gdb-8.2/gdb/target.c:2028:16: error: ‘thread’ was not
declared 
in this scope
   thread_info *thread = any_thread_of_inferior (inf);
                ^~~~~~
/home/srs/DEBs/gdb/gdb-8.2/gdb/target.c:2028:16: note: suggested alternative:
‘myread’
   thread_info *thread = any_thread_of_inferior (inf);
                ^~~~~~
                myread

Sorry, but the compiler directive is hidden from the output (by libtool??).

ii  gcc            4:8.2.0-2    hurd-i386    GNU C compiler
ii  g++            4:8.2.0-2    hurd-i386    GNU C++ compiler

I would be very happy if you could be consistent in the coding: Either use
struct thread_info everywhere or not.

Thanks!


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH] Please define thread_info as struct thread_info (and other stuff)
  2018-12-15 23:01   ` Svante Signell
@ 2018-12-16  4:31     ` Simon Marchi
  2018-12-16  5:14       ` Svante Signell
  0 siblings, 1 reply; 20+ messages in thread
From: Simon Marchi @ 2018-12-16  4:31 UTC (permalink / raw)
  To: svante.signell, Tom Tromey; +Cc: gdb-patches

On 2018-12-15 6:01 p.m., Svante Signell wrote:
> A typical error output:
> CXX    target.o
> /home/srs/DEBs/gdb/gdb-8.2/gdb/target.c: In function ‘int
> dispose_inferior(inferior*, void*)’:
> /home/srs/DEBs/gdb/gdb-8.2/gdb/target.c:2028:16: error: ‘thread’ was not
> declared 
> in this scope
>    thread_info *thread = any_thread_of_inferior (inf);
>                 ^~~~~~
> /home/srs/DEBs/gdb/gdb-8.2/gdb/target.c:2028:16: note: suggested alternative:
> ‘myread’
>    thread_info *thread = any_thread_of_inferior (inf);
>                 ^~~~~~
>                 myread
> 
> Sorry, but the compiler directive is hidden from the output (by libtool??).

You can do "make V=1" to show the compiler invocation (same as if we would use automake).
> 
> ii  gcc            4:8.2.0-2    hurd-i386    GNU C compiler
> ii  g++            4:8.2.0-2    hurd-i386    GNU C++ compiler
> 
> I would be very happy if you could be consistent in the coding: Either use
> struct thread_info everywhere or not.

Well, we started with the "struct" keyword everywhere (because C), and many people get
rid of it in the parts of the code they touch (though not everyone, and I don't turn
down a patch just for this).  We also won't make a big change to remove the use of
"struct" throughout, as it would be a lot of work for nothing, it would create
unnecessary conflicts for people who maintain external patches and it would pollute
the history when git-blaming.

What you compiler is doing is very strange, as Tom mentioned the use of the "struct"
or "class" keyword when declaring a variable in C++ is optional.  What does your
compiler say when compiling the following code (g++ -c foo.cpp)?

struct Foo
{
	int a;
};

void func()
{
	Foo f2;
}


Simon

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH] Please define thread_info as struct thread_info (and other stuff)
  2018-12-16  4:31     ` Simon Marchi
@ 2018-12-16  5:14       ` Svante Signell
  2018-12-16  6:02         ` Simon Marchi
  2018-12-16 16:22         ` Tom Tromey
  0 siblings, 2 replies; 20+ messages in thread
From: Svante Signell @ 2018-12-16  5:14 UTC (permalink / raw)
  To: Simon Marchi, Tom Tromey; +Cc: gdb-patches

On Sat, 2018-12-15 at 23:31 -0500, Simon Marchi wrote:
> On 2018-12-15 6:01 p.m., Svante Signell wrote:
> > A typical error output:
> > CXX    target.o
> > /home/srs/DEBs/gdb/gdb-8.2/gdb/target.c: In function ‘int
> > dispose_inferior(inferior*, void*)’:
> > /home/srs/DEBs/gdb/gdb-8.2/gdb/target.c:2028:16: error: ‘thread’ was not
> > declared 
> > in this scope
> >    thread_info *thread = any_thread_of_inferior (inf);
> >                 ^~~~~~
> > /home/srs/DEBs/gdb/gdb-8.2/gdb/target.c:2028:16: note: suggested
> > alternative:
> > ‘myread’
> >    thread_info *thread = any_thread_of_inferior (inf);
> >                 ^~~~~~
> >                 myread
> > 
> > Sorry, but the compiler directive is hidden from the output (by libtool??).
> 
> You can do "make V=1" to show the compiler invocation (same as if we would use
> automake).

Here is an example output with make make V=1 -C build/objdir/gdb/ elfread.o

i686-gnu-g++ -x c++  -g -O2 -fdebug-prefix-map=/home/srs/DEBs/gdb/gdb-8.2=.
-fstack-protector-strong -Wformat -Werror=format-security -D_GNU_SOURCE  -I.
-I/home/srs/DEBs/gdb/gdb-8.2/gdb -I/home/srs/DEBs/gdb/gdb-8.2/gdb/common
-I/home/srs/DEBs/gdb/gdb-8.2/gdb/config -DLOCALEDIR="\"/usr/share/locale\""
-DHAVE_CONFIG_H -I/home/srs/DEBs/gdb/gdb-8.2/gdb/../include/opcode
-I/home/srs/DEBs/gdb/gdb-8.2/gdb/../opcodes/..   -I../bfd
-I/home/srs/DEBs/gdb/gdb-8.2/gdb/../bfd -I/home/srs/DEBs/gdb/gdb-
8.2/gdb/../include -I../libdecnumber -I/home/srs/DEBs/gdb/gdb-
8.2/gdb/../libdecnumber  -I/home/srs/DEBs/gdb/gdb-8.2/gdb/gnulib/import -Ibuild-
gnulib/import   -DTUI=1  -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC  -
I/usr/include/python3.7m -I/usr/include/python3.7m -Wall -Wpointer-arith -Wno-
unused -Wunused-value -Wunused-function -Wno-switch -Wno-char-subscripts
-Wempty-body -Wunused-but-set-parameter -Wunused-but-set-variable -Wno-sign-
compare -Wno-narrowing -Wno-error=maybe-uninitialized -Wsuggest-override
-Wimplicit-fallthrough=3 -Wduplicated-cond -Wformat-nonliteral  -c -o elfread.o
-MT elfread.o -MMD -MP -MF ./.deps/elfread.Tpo /home/srs/DEBs/gdb/gdb-
8.2/gdb/elfread.c
In file included from ./nm.h:25,
                 from /home/srs/DEBs/gdb/gdb-8.2/gdb/defs.h:420,
                 from /home/srs/DEBs/gdb/gdb-8.2/gdb/elfread.c:22:
/home/srs/DEBs/gdb/gdb-8.2/gdb/regcache.h:35:46: warning: ‘get_thread_regcache’
initialized and declared ‘extern’
 extern struct regcache *get_thread_regcache (thread_info *thread);
                                              ^~~~~~~~~~~
/home/srs/DEBs/gdb/gdb-8.2/gdb/regcache.h:35:46: error: ‘regcache*
get_thread_regcache’ redeclared as different kind of symbol
/home/srs/DEBs/gdb/gdb-8.2/gdb/regcache.h:32:25: note: previous declaration
‘regcache* get_thread_regcache(ptid_t)’
 extern struct regcache *get_thread_regcache (ptid_t ptid);
                         ^~~~~~~~~~~~~~~~~~~
/home/srs/DEBs/gdb/gdb-8.2/gdb/regcache.h:35:59: error: ‘thread’ was not
declared in this scope
 extern struct regcache *get_thread_regcache (thread_info *thread);
                                                           ^~~~~~
/home/srs/DEBs/gdb/gdb-8.2/gdb/regcache.h:35:59: note: suggested alternative:
‘thread_t’
 extern struct regcache *get_thread_regcache (thread_info *thread);
                                                           ^~~~~~
                                                           thread_t
/home/srs/DEBs/gdb/gdb-8.2/gdb/regcache.h:144:14: error: ‘function_view’ in
namespace ‘gdb’ does not name a template type
 typedef gdb::function_view<register_status (int regnum, gdb_byte *buf)>
              ^~~~~~~~~~~~~
/home/srs/DEBs/gdb/gdb-8.2/gdb/regcache.h:228:14: error: ‘register_read_ftype’
has not been declared
   void save (register_read_ftype cooked_read);
              ^~~~~~~~~~~~~~~~~~~
/home/srs/DEBs/gdb/gdb-8.2/gdb/regcache.h:422:49: error: ‘register_read_ftype’
has not been declared
   readonly_detached_regcache (gdbarch *gdbarch, register_read_ftype
cooked_read)
                                                 ^~~~~~~~~~~~~~~~~~~
/home/srs/DEBs/gdb/gdb-8.2/gdb/regcache.h:439:39: error: variable or field
‘registers_changed_thread’ declared void
 extern void registers_changed_thread (thread_info *thread);
                                       ^~~~~~~~~~~
/home/srs/DEBs/gdb/gdb-8.2/gdb/regcache.h:439:52: error: ‘thread’ was not
declared in this scope
 extern void registers_changed_thread (thread_info *thread);
                                                    ^~~~~~
/home/srs/DEBs/gdb/gdb-8.2/gdb/regcache.h:439:52: note: suggested alternative:
‘thread_t’
 extern void registers_changed_thread (thread_info *thread);
                                                    ^~~~~~
                                                    thread_t
In file included from /home/srs/DEBs/gdb/gdb-8.2/gdb/target.h:44,
                 from /home/srs/DEBs/gdb/gdb-8.2/gdb/progspace.h:24,
                 from /home/srs/DEBs/gdb/gdb-8.2/gdb/objfiles.h:27,
                 from /home/srs/DEBs/gdb/gdb-8.2/gdb/elfread.c:30:
/home/srs/DEBs/gdb/gdb-8.2/gdb/breakpoint.h:950:21: error: ‘thread_info’ is not
a type
       CORE_ADDR pc, thread_info *thread,
                     ^~~~~~~~~~~
In file included from /home/srs/DEBs/gdb/gdb-8.2/gdb/progspace.h:24,
                 from /home/srs/DEBs/gdb/gdb-8.2/gdb/objfiles.h:27,
                 from /home/srs/DEBs/gdb/gdb-8.2/gdb/elfread.c:30:
/home/srs/DEBs/gdb/gdb-8.2/gdb/target.h:652:44: error: ‘extra_thread_info’
declared as a ‘virtual’ field
     virtual const char *extra_thread_info (thread_info *)
                                            ^~~~~~~~~~~
/home/srs/DEBs/gdb/gdb-8.2/gdb/target.h:652:25: error: expected ‘;’ at end of
member declaration
     virtual const char *extra_thread_info (thread_info *)
                         ^~~~~~~~~~~~~~~~~
                                          ;
/home/srs/DEBs/gdb/gdb-8.2/gdb/target.h:652:55: error: expected ‘)’ before ‘*’
token
     virtual const char *extra_thread_info (thread_info *)
                                           ~           ^~
                                                       )
/home/srs/DEBs/gdb/gdb-8.2/gdb/target.h:654:38: error: ‘thread_name’ declared as
a ‘virtual’ field
     virtual const char *thread_name (thread_info *)
                                      ^~~~~~~~~~~
/home/srs/DEBs/gdb/gdb-8.2/gdb/target.h:654:25: error: expected ‘;’ at end of
member declaration
     virtual const char *thread_name (thread_info *)
                         ^~~~~~~~~~~
                                    ;
/home/srs/DEBs/gdb/gdb-8.2/gdb/target.h:654:49: error: expected ‘)’ before ‘*’
token
     virtual const char *thread_name (thread_info *)
                                     ~           ^~
                                                 )
/home/srs/DEBs/gdb/gdb-8.2/gdb/target.h:656:13: error: ‘thread_info’ does not
name a type
     virtual thread_info *thread_handle_to_thread_info (const gdb_byte *,
             ^~~~~~~~~~~
In file included from /home/srs/DEBs/gdb/gdb-8.2/gdb/infcall.h:23,
                 from /home/srs/DEBs/gdb/gdb-8.2/gdb/elfread.c:42:
/home/srs/DEBs/gdb/gdb-8.2/gdb/dummy-frame.h:38:10: error: ‘thread_info’ is not
a type
          thread_info *thread);
          ^~~~~~~~~~~
/home/srs/DEBs/gdb/gdb-8.2/gdb/dummy-frame.h:49:49: error: ‘thread_info’ is not
a type
 extern void dummy_frame_pop (frame_id dummy_id, thread_info *thread);
                                                 ^~~~~~~~~~~
/home/srs/DEBs/gdb/gdb-8.2/gdb/dummy-frame.h:51:53: error: ‘thread_info’ is not
a type
 extern void dummy_frame_discard (frame_id dummy_id, thread_info *thread);
                                                     ^~~~~~~~~~~
/home/srs/DEBs/gdb/gdb-8.2/gdb/dummy-frame.h:67:12: error: ‘thread_info’ is not
a type
            thread_info *thread,
            ^~~~~~~~~~~
/home/srs/DEBs/gdb/gdb-8.2/gdb/elfread.c: In function ‘void
elf_gnu_ifunc_resolver_return_stop(breakpoint*)’:
/home/srs/DEBs/gdb/gdb-8.2/gdb/elfread.c:975:16: error: ‘thread’ was not
declared in this scope
   thread_info *thread = inferior_thread ();
                ^~~~~~
/home/srs/DEBs/gdb/gdb-8.2/gdb/elfread.c:975:16: note: suggested alternative:
‘myread’
   thread_info *thread = inferior_thread ();
                ^~~~~~
                myread
Makefile:1651: recipe for target 'elfread.o' failed
make: *** [elfread.o] Error 1

In gdb/regcache.h we have:
extern struct regcache *get_thread_regcache (ptid_t ptid);
extern struct regcache *get_thread_regcache (struct thread_info *thread);

> What you compiler is doing is very strange, as Tom mentioned the use of the
> "struct" or "class" keyword when declaring a variable in C++ is
> optional.  What does your
> compiler say when compiling the following code (g++ -c foo.cpp)?
> 
> struct Foo
> {
> 	int a;
> };
> 
> void func()
> {
> 	Foo f2;
> }

g++ -c -Wall foo.cpp 
foo.cpp: In function ‘void func()’:
foo.cpp:8:13: warning: unused variable ‘f2’ [-Wunused-variable]
         Foo f2;


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH] Please define thread_info as struct thread_info (and other stuff)
  2018-12-16  5:14       ` Svante Signell
@ 2018-12-16  6:02         ` Simon Marchi
  2018-12-16 16:22         ` Tom Tromey
  1 sibling, 0 replies; 20+ messages in thread
From: Simon Marchi @ 2018-12-16  6:02 UTC (permalink / raw)
  To: svante.signell, Tom Tromey; +Cc: gdb-patches

On 2018-12-16 12:15 a.m., Svante Signell wrote:
> Here is an example output with make make V=1 -C build/objdir/gdb/ elfread.o
> 
> i686-gnu-g++ -x c++  -g -O2 -fdebug-prefix-map=/home/srs/DEBs/gdb/gdb-8.2=.
> -fstack-protector-strong -Wformat -Werror=format-security -D_GNU_SOURCE  -I.
> -I/home/srs/DEBs/gdb/gdb-8.2/gdb -I/home/srs/DEBs/gdb/gdb-8.2/gdb/common
> -I/home/srs/DEBs/gdb/gdb-8.2/gdb/config -DLOCALEDIR="\"/usr/share/locale\""
> -DHAVE_CONFIG_H -I/home/srs/DEBs/gdb/gdb-8.2/gdb/../include/opcode
> -I/home/srs/DEBs/gdb/gdb-8.2/gdb/../opcodes/..   -I../bfd
> -I/home/srs/DEBs/gdb/gdb-8.2/gdb/../bfd -I/home/srs/DEBs/gdb/gdb-
> 8.2/gdb/../include -I../libdecnumber -I/home/srs/DEBs/gdb/gdb-
> 8.2/gdb/../libdecnumber  -I/home/srs/DEBs/gdb/gdb-8.2/gdb/gnulib/import -Ibuild-
> gnulib/import   -DTUI=1  -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC  -
> I/usr/include/python3.7m -I/usr/include/python3.7m -Wall -Wpointer-arith -Wno-
> unused -Wunused-value -Wunused-function -Wno-switch -Wno-char-subscripts
> -Wempty-body -Wunused-but-set-parameter -Wunused-but-set-variable -Wno-sign-
> compare -Wno-narrowing -Wno-error=maybe-uninitialized -Wsuggest-override
> -Wimplicit-fallthrough=3 -Wduplicated-cond -Wformat-nonliteral  -c -o elfread.o
> -MT elfread.o -MMD -MP -MF ./.deps/elfread.Tpo /home/srs/DEBs/gdb/gdb-
> 8.2/gdb/elfread.c
> In file included from ./nm.h:25,
>                  from /home/srs/DEBs/gdb/gdb-8.2/gdb/defs.h:420,
>                  from /home/srs/DEBs/gdb/gdb-8.2/gdb/elfread.c:22:
> /home/srs/DEBs/gdb/gdb-8.2/gdb/regcache.h:35:46: warning: ‘get_thread_regcache’
> initialized and declared ‘extern’
>  extern struct regcache *get_thread_regcache (thread_info *thread);
>                                               ^~~~~~~~~~~
> /home/srs/DEBs/gdb/gdb-8.2/gdb/regcache.h:35:46: error: ‘regcache*
> get_thread_regcache’ redeclared as different kind of symbol
> /home/srs/DEBs/gdb/gdb-8.2/gdb/regcache.h:32:25: note: previous declaration
> ‘regcache* get_thread_regcache(ptid_t)’
>  extern struct regcache *get_thread_regcache (ptid_t ptid);
>                          ^~~~~~~~~~~~~~~~~~~
> /home/srs/DEBs/gdb/gdb-8.2/gdb/regcache.h:35:59: error: ‘thread’ was not
> declared in this scope
>  extern struct regcache *get_thread_regcache (thread_info *thread);
>                                                            ^~~~~~
> /home/srs/DEBs/gdb/gdb-8.2/gdb/regcache.h:35:59: note: suggested alternative:
> ‘thread_t’
>  extern struct regcache *get_thread_regcache (thread_info *thread);
>                                                            ^~~~~~
>                                                            thread_t
> /home/srs/DEBs/gdb/gdb-8.2/gdb/regcache.h:144:14: error: ‘function_view’ in
> namespace ‘gdb’ does not name a template type
>  typedef gdb::function_view<register_status (int regnum, gdb_byte *buf)>
>               ^~~~~~~~~~~~~
> /home/srs/DEBs/gdb/gdb-8.2/gdb/regcache.h:228:14: error: ‘register_read_ftype’
> has not been declared
>    void save (register_read_ftype cooked_read);
>               ^~~~~~~~~~~~~~~~~~~
> /home/srs/DEBs/gdb/gdb-8.2/gdb/regcache.h:422:49: error: ‘register_read_ftype’
> has not been declared
>    readonly_detached_regcache (gdbarch *gdbarch, register_read_ftype
> cooked_read)
>                                                  ^~~~~~~~~~~~~~~~~~~
> /home/srs/DEBs/gdb/gdb-8.2/gdb/regcache.h:439:39: error: variable or field
> ‘registers_changed_thread’ declared void
>  extern void registers_changed_thread (thread_info *thread);
>                                        ^~~~~~~~~~~
> /home/srs/DEBs/gdb/gdb-8.2/gdb/regcache.h:439:52: error: ‘thread’ was not
> declared in this scope
>  extern void registers_changed_thread (thread_info *thread);
>                                                     ^~~~~~
> /home/srs/DEBs/gdb/gdb-8.2/gdb/regcache.h:439:52: note: suggested alternative:
> ‘thread_t’
>  extern void registers_changed_thread (thread_info *thread);
>                                                     ^~~~~~
>                                                     thread_t
> In file included from /home/srs/DEBs/gdb/gdb-8.2/gdb/target.h:44,
>                  from /home/srs/DEBs/gdb/gdb-8.2/gdb/progspace.h:24,
>                  from /home/srs/DEBs/gdb/gdb-8.2/gdb/objfiles.h:27,
>                  from /home/srs/DEBs/gdb/gdb-8.2/gdb/elfread.c:30:
> /home/srs/DEBs/gdb/gdb-8.2/gdb/breakpoint.h:950:21: error: ‘thread_info’ is not
> a type
>        CORE_ADDR pc, thread_info *thread,
>                      ^~~~~~~~~~~
> In file included from /home/srs/DEBs/gdb/gdb-8.2/gdb/progspace.h:24,
>                  from /home/srs/DEBs/gdb/gdb-8.2/gdb/objfiles.h:27,
>                  from /home/srs/DEBs/gdb/gdb-8.2/gdb/elfread.c:30:
> /home/srs/DEBs/gdb/gdb-8.2/gdb/target.h:652:44: error: ‘extra_thread_info’
> declared as a ‘virtual’ field
>      virtual const char *extra_thread_info (thread_info *)
>                                             ^~~~~~~~~~~
> /home/srs/DEBs/gdb/gdb-8.2/gdb/target.h:652:25: error: expected ‘;’ at end of
> member declaration
>      virtual const char *extra_thread_info (thread_info *)
>                          ^~~~~~~~~~~~~~~~~
>                                           ;
> /home/srs/DEBs/gdb/gdb-8.2/gdb/target.h:652:55: error: expected ‘)’ before ‘*’
> token
>      virtual const char *extra_thread_info (thread_info *)
>                                            ~           ^~
>                                                        )
> /home/srs/DEBs/gdb/gdb-8.2/gdb/target.h:654:38: error: ‘thread_name’ declared as
> a ‘virtual’ field
>      virtual const char *thread_name (thread_info *)
>                                       ^~~~~~~~~~~
> /home/srs/DEBs/gdb/gdb-8.2/gdb/target.h:654:25: error: expected ‘;’ at end of
> member declaration
>      virtual const char *thread_name (thread_info *)
>                          ^~~~~~~~~~~
>                                     ;
> /home/srs/DEBs/gdb/gdb-8.2/gdb/target.h:654:49: error: expected ‘)’ before ‘*’
> token
>      virtual const char *thread_name (thread_info *)
>                                      ~           ^~
>                                                  )
> /home/srs/DEBs/gdb/gdb-8.2/gdb/target.h:656:13: error: ‘thread_info’ does not
> name a type
>      virtual thread_info *thread_handle_to_thread_info (const gdb_byte *,
>              ^~~~~~~~~~~
> In file included from /home/srs/DEBs/gdb/gdb-8.2/gdb/infcall.h:23,
>                  from /home/srs/DEBs/gdb/gdb-8.2/gdb/elfread.c:42:
> /home/srs/DEBs/gdb/gdb-8.2/gdb/dummy-frame.h:38:10: error: ‘thread_info’ is not
> a type
>           thread_info *thread);
>           ^~~~~~~~~~~
> /home/srs/DEBs/gdb/gdb-8.2/gdb/dummy-frame.h:49:49: error: ‘thread_info’ is not
> a type
>  extern void dummy_frame_pop (frame_id dummy_id, thread_info *thread);
>                                                  ^~~~~~~~~~~
> /home/srs/DEBs/gdb/gdb-8.2/gdb/dummy-frame.h:51:53: error: ‘thread_info’ is not
> a type
>  extern void dummy_frame_discard (frame_id dummy_id, thread_info *thread);
>                                                      ^~~~~~~~~~~
> /home/srs/DEBs/gdb/gdb-8.2/gdb/dummy-frame.h:67:12: error: ‘thread_info’ is not
> a type
>             thread_info *thread,
>             ^~~~~~~~~~~
> /home/srs/DEBs/gdb/gdb-8.2/gdb/elfread.c: In function ‘void
> elf_gnu_ifunc_resolver_return_stop(breakpoint*)’:
> /home/srs/DEBs/gdb/gdb-8.2/gdb/elfread.c:975:16: error: ‘thread’ was not
> declared in this scope
>    thread_info *thread = inferior_thread ();
>                 ^~~~~~
> /home/srs/DEBs/gdb/gdb-8.2/gdb/elfread.c:975:16: note: suggested alternative:
> ‘myread’
>    thread_info *thread = inferior_thread ();
>                 ^~~~~~
>                 myread
> Makefile:1651: recipe for target 'elfread.o' failed
> make: *** [elfread.o] Error 1
> 
> In gdb/regcache.h we have:
> extern struct regcache *get_thread_regcache (ptid_t ptid);
> extern struct regcache *get_thread_regcache (struct thread_info *thread);
> 
>> What you compiler is doing is very strange, as Tom mentioned the use of the
>> "struct" or "class" keyword when declaring a variable in C++ is
>> optional.  What does your
>> compiler say when compiling the following code (g++ -c foo.cpp)?
>>
>> struct Foo
>> {
>> 	int a;
>> };
>>
>> void func()
>> {
>> 	Foo f2;
>> }
> 
> g++ -c -Wall foo.cpp 
> foo.cpp: In function ‘void func()’:
> foo.cpp:8:13: warning: unused variable ‘f2’ [-Wunused-variable]
>          Foo f2;
> 
> 

Sorry, I don't have anything to add, except that it looks like a compiler
problem.  I'm compiling the same code with the same compiler version (gcc 8.2),
so I'm at lost here.  I'd try to reduce to a minimal reproducer to try to understand
the problem better...

Simon

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH] Please define thread_info as struct thread_info (and other stuff)
  2018-12-15 19:36 [PATCH] Please define thread_info as struct thread_info (and other stuff) Svante Signell
  2018-12-15 22:48 ` Tom Tromey
@ 2018-12-16  9:20 ` Andreas Schwab
  2018-12-16 19:08   ` Svante Signell
  1 sibling, 1 reply; 20+ messages in thread
From: Andreas Schwab @ 2018-12-16  9:20 UTC (permalink / raw)
  To: Svante Signell; +Cc: gdb-patches

On Dez 15 2018, Svante Signell <svante.signell@gmail.com> wrote:

> Index: gdb-8.2/gdb/regcache.h
> ===================================================================
> --- gdb-8.2.orig/gdb/regcache.h
> +++ gdb-8.2/gdb/regcache.h
> @@ -21,6 +21,7 @@
>  #define REGCACHE_H
>  
>  #include "common-regcache.h"
> +#include "function-view.h"
>  #include <forward_list>
>  
>  struct regcache;
> @@ -32,7 +33,7 @@ extern struct regcache *get_current_regc
>  extern struct regcache *get_thread_regcache (ptid_t ptid);
>  
>  /* Get the regcache of THREAD.  */
> -extern struct regcache *get_thread_regcache (thread_info *thread);
> +extern struct regcache *get_thread_regcache (struct thread_info *thread);
>  
>  extern struct regcache *get_thread_arch_regcache (ptid_t, struct gdbarch *);
>  extern struct regcache *get_thread_arch_aspace_regcache (ptid_t,
> @@ -436,7 +437,7 @@ extern void registers_changed_ptid (ptid
>  
>  /* Indicate that registers of THREAD may have changed, so invalidate
>     the cache.  */
> -extern void registers_changed_thread (thread_info *thread);
> +extern void registers_changed_thread (struct thread_info *thread);
>  
>  /* An abstract base class for register dump.  */

Try adding a forward declaration of struct thead_info.  Note that
config/i386/nm-i386gnu.h includes "regcache.h", making it unique among
the nm.h files.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH] Please define thread_info as struct thread_info (and other stuff)
  2018-12-16  5:14       ` Svante Signell
  2018-12-16  6:02         ` Simon Marchi
@ 2018-12-16 16:22         ` Tom Tromey
  1 sibling, 0 replies; 20+ messages in thread
From: Tom Tromey @ 2018-12-16 16:22 UTC (permalink / raw)
  To: Svante Signell; +Cc: Simon Marchi, Tom Tromey, gdb-patches

>>>>> "Svante" == Svante Signell <svante.signell@gmail.com> writes:

Svante> /home/srs/DEBs/gdb/gdb-8.2/gdb/regcache.h:35:46: warning: ‘get_thread_regcache’
Svante> initialized and declared ‘extern’

Ok, I was able to reproduce this error with:

    int Foo;

    struct Foo
    {
      int a;
    };

    extern int f(Foo x);

I didn't see a definition of thread_info anywhere, but maybe somehow it
comes from one of your system headers.  You could compile with 'gcc -E'
and search for it.

clang will tell you where the conflicting definition appears; I've filed
a gcc bug about this: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88520

Tom

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH] Please define thread_info as struct thread_info (and other stuff)
  2018-12-16  9:20 ` Andreas Schwab
@ 2018-12-16 19:08   ` Svante Signell
  2018-12-16 23:10     ` Tom Tromey
  0 siblings, 1 reply; 20+ messages in thread
From: Svante Signell @ 2018-12-16 19:08 UTC (permalink / raw)
  To: Andreas Schwab, Tom Tromey, Simon Marchi; +Cc: gdb-patches

On Sun, 2018-12-16 at 10:20 +0100, Andreas Schwab wrote:
> On Dez 15 2018, Svante Signell <svante.signell@gmail.com> wrote:

> 
> Try adding a forward declaration of struct thead_info.  Note that
> config/i386/nm-i386gnu.h includes "regcache.h", making it unique among
> the nm.h files.

From what I've leraned forward declarations is bad coding, an should be avoided
as much as possible. Right or wrong?

Furthermore, not defining thread_info as struct everywhere is in my opinion very
lazy coding. Another issue is to compile C-code (and C++-code) in *.c files.
Please rename these to *.cpp (and eventually the header files to *.hpp)! As it
is now it is very confusing.

Finally, I've found the problem (but no workaround yet): thread_info is an RPC
on GNU/Hurs, and including mach.h in gdb/config/i386/nm-i386gnu.h:#include
<mach.h> further includes <mach/mach_interface.h> which has the conflicting name
of that RPC:
kern_return_t thread_info
(
        mach_port_t target_thread,
        int flavor,
        thread_info_t thread_info_out,
        mach_msg_type_number_t *thread_info_outCnt
);

Please reconsider your coding stype for gdb.

Thanks!

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH] Please define thread_info as struct thread_info (and other stuff)
  2018-12-16 19:08   ` Svante Signell
@ 2018-12-16 23:10     ` Tom Tromey
  2018-12-17 20:51       ` Svante Signell
  0 siblings, 1 reply; 20+ messages in thread
From: Tom Tromey @ 2018-12-16 23:10 UTC (permalink / raw)
  To: Svante Signell; +Cc: Andreas Schwab, Tom Tromey, Simon Marchi, gdb-patches

>>>>> "Svante" == Svante Signell <svante.signell@gmail.com> writes:

>> Try adding a forward declaration of struct thead_info.  Note that
>> config/i386/nm-i386gnu.h includes "regcache.h", making it unique among
>> the nm.h files.

Svante> From what I've leraned forward declarations is bad coding, an should be avoided
Svante> as much as possible. Right or wrong?

Opinions vary -- I think the Google style has a rule against it? -- but
gdb generally does not avoid it.

Svante> Furthermore, not defining thread_info as struct everywhere is in my opinion very
Svante> lazy coding.

I disagree here, C++ provides the typedef, there's nothing really wrong
with using it.

Svante> Another issue is to compile C-code (and C++-code) in *.c files.
Svante> Please rename these to *.cpp (and eventually the header files to *.hpp)! As it
Svante> is now it is very confusing.

I think this was discussed When we made this switch, and the conclusion
was that a mass rename would be worse.

Svante> Finally, I've found the problem (but no workaround yet): thread_info is an RPC
Svante> on GNU/Hurs, and including mach.h in gdb/config/i386/nm-i386gnu.h:#include
Svante> <mach.h> further includes <mach/mach_interface.h> which has the conflicting name
Svante> of that RPC:
Svante> kern_return_t thread_info
Svante> (

Typical answers for this kind of thing are either to segregate the use
of the system header somehow, or maybe namespacing or some other kind of
renaming.  I haven't looked into the details much in this case I'm
afraid.

Tom

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH] Please define thread_info as struct thread_info (and other stuff)
  2018-12-16 23:10     ` Tom Tromey
@ 2018-12-17 20:51       ` Svante Signell
  2018-12-17 21:41         ` John Baldwin
  2018-12-20 13:31         ` Svante Signell
  0 siblings, 2 replies; 20+ messages in thread
From: Svante Signell @ 2018-12-17 20:51 UTC (permalink / raw)
  To: Tom Tromey; +Cc: Andreas Schwab, Simon Marchi, gdb-patches

On Sun, 2018-12-16 at 16:10 -0700, Tom Tromey wrote:
> > > > > > "Svante" == Svante Signell <svante.signell@gmail.com> writes:
> > > Try adding a forward declaration of struct thead_info.  Note that
> > > config/i386/nm-i386gnu.h includes "regcache.h", making it unique among
> > > the nm.h files.
> 
> Svante> From what I've learned forward declarations is bad coding, an should
> be avoided
> Svante> as much as possible. Right or wrong?
> 
> Opinions vary -- I think the Google style has a rule against it? -- but
> gdb generally does not avoid it.
> 
> Svante> Furthermore, not defining thread_info as struct everywhere is in my
> opinion very
> Svante> lazy coding.
> 
> I disagree here, C++ provides the typedef, there's nothing really wrong
> with using it.

Well, the basis is C-code, where that is a requirement.

> Svante> Another issue is to compile C-code (and C++-code) in *.c files.
> Svante> Please rename these to *.cpp (and eventually the header files to
> *.hpp)! As it is now it is very confusing.
> 
> I think this was discussed When we made this switch, and the conclusion
> was that a mass rename would be worse.

Do you really need to compile all files with a C++ compiler? Pure C-code could
still be compiled with a C compiler.
 
> Svante> Finally, I've found the problem (but no workaround yet): thread_info
> is an RPC on GNU/Hurd, and including mach.h in gdb/config/i386/nm-
> i386gnu.h:#include <mach.h> further includes <mach/mach_interface.h> which has
> the conflicting name Svante> of that RPC: kern_return_t thread_info
> 
> Typical answers for this kind of thing are either to segregate the use
> of the system header somehow, or maybe namespacing or some other kind of
> renaming.  I haven't looked into the details much in this case I'm
> afraid.

As I see it you need to:

1) Apply the patches submitted earlier in this thread using struct thread_info
consistently everywhere (simplest).
2) Rename all usage of the struct thread_info to something else e.g. struct
gdb_thread_info (not future-proof though).
3) Create a gdb namespace for all your code to avoid conflicts.
4) Segregate the use of system header files as you write above. Dunno how to do
that though, but some of you should.

Thanks!

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH] Please define thread_info as struct thread_info (and other stuff)
  2018-12-17 20:51       ` Svante Signell
@ 2018-12-17 21:41         ` John Baldwin
  2019-02-14 15:16           ` Thomas Schwinge
  2018-12-20 13:31         ` Svante Signell
  1 sibling, 1 reply; 20+ messages in thread
From: John Baldwin @ 2018-12-17 21:41 UTC (permalink / raw)
  To: svante.signell, Tom Tromey; +Cc: Andreas Schwab, Simon Marchi, gdb-patches

On 12/17/18 12:51 PM, Svante Signell wrote:
> On Sun, 2018-12-16 at 16:10 -0700, Tom Tromey wrote:
>>>>>>> "Svante" == Svante Signell <svante.signell@gmail.com> writes:
>> Svante> Another issue is to compile C-code (and C++-code) in *.c files.
>> Svante> Please rename these to *.cpp (and eventually the header files to
>> *.hpp)! As it is now it is very confusing.
>>
>> I think this was discussed When we made this switch, and the conclusion
>> was that a mass rename would be worse.
> 
> Do you really need to compile all files with a C++ compiler? Pure C-code could
> still be compiled with a C compiler.

GDB isn't written in C anymore.  target_ops is a class with virtual methods,
the use of gdb::unique_ptr<> (basically std::unique_ptr<>) is rather
ubiquitous now, etc.  In fact, I think we even require C++11 and not just
C++03.

>> Svante> Finally, I've found the problem (but no workaround yet): thread_info
>> is an RPC on GNU/Hurd, and including mach.h in gdb/config/i386/nm-
>> i386gnu.h:#include <mach.h> further includes <mach/mach_interface.h> which has
>> the conflicting name Svante> of that RPC: kern_return_t thread_info
>>
>> Typical answers for this kind of thing are either to segregate the use
>> of the system header somehow, or maybe namespacing or some other kind of
>> renaming.  I haven't looked into the details much in this case I'm
>> afraid.
> 
> As I see it you need to:
> 
> 1) Apply the patches submitted earlier in this thread using struct thread_info
> consistently everywhere (simplest).
> 2) Rename all usage of the struct thread_info to something else e.g. struct
> gdb_thread_info (not future-proof though).
> 3) Create a gdb namespace for all your code to avoid conflicts.
> 4) Segregate the use of system header files as you write above. Dunno how to do
> that though, but some of you should.

Normally code for native targets do 4).  I've had to be careful about which
includes I use in native FreeBSD targets to avoid namespace collisions, etc.
3) might not be a terrible idea eventually, but you'd have to make it explict
and avoid using 'using namespace gdb' for it to actually be useful.

-- 
John Baldwin

                                                                            

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH] Please define thread_info as struct thread_info (and other stuff)
  2018-12-17 20:51       ` Svante Signell
  2018-12-17 21:41         ` John Baldwin
@ 2018-12-20 13:31         ` Svante Signell
  2018-12-20 22:34           ` Tom Tromey
  1 sibling, 1 reply; 20+ messages in thread
From: Svante Signell @ 2018-12-20 13:31 UTC (permalink / raw)
  To: Tom Tromey; +Cc: Andreas Schwab, Simon Marchi, gdb-patches

On Mon, 2018-12-17 at 21:51 +0100, Svante Signell wrote:
> On Sun, 2018-12-16 at 16:10 -0700, Tom Tromey wrote:

> > Svante> Finally, I've found the problem (but no workaround yet):
> > thread_info is an RPC on GNU/Hurd, and including mach.h in
> > gdb/config/i386/nm-i386gnu.h:#include <mach.h> further includes
> > <mach/mach_interface.h> which has the conflicting name of that RPC:
> > kern_return_t thread_info
> > 
> > Typical answers for this kind of thing are either to segregate the
> > use of the system header somehow, or maybe namespacing or some
> > other kind of renaming. I haven't looked into the details much in
> > this case I'm afraid.
> 
> As I see it you need to:
> 
> 1) Apply the patches submitted earlier in this thread using struct
> thread_info
> consistently everywhere (simplest).
> 2) Rename all usage of the struct thread_info to something else e.g.
> struct gdb_thread_info (not future-proof though).
> 3) Create a gdb namespace for all your code to avoid conflicts.
> 4) Segregate the use of system header files as you write above. Dunno
> how to do that though, but some of you should.

Hi again. Seem like I did not get the reply from John Baldwin on this
thread, some gmail issue? Can somebody forward it to me, I've only seen
it on the mailing list archives: https://sourceware.org/ml/gdb-patches/
2018-12/msg00202.html

Seems like nothing is happening so far. Did you expect me to take
action on this issue? Or is this a low-prio problem for you, Hurd being
a second class citizen?

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH] Please define thread_info as struct thread_info (and other stuff)
  2018-12-20 13:31         ` Svante Signell
@ 2018-12-20 22:34           ` Tom Tromey
  2018-12-20 23:26             ` Simon Marchi
                               ` (2 more replies)
  0 siblings, 3 replies; 20+ messages in thread
From: Tom Tromey @ 2018-12-20 22:34 UTC (permalink / raw)
  To: Svante Signell; +Cc: Tom Tromey, Andreas Schwab, Simon Marchi, gdb-patches

>>>>> "Svante" == Svante Signell <svante.signell@gmail.com> writes:

Svante> Seems like nothing is happening so far. Did you expect me to
Svante> take action on this issue? Or is this a low-prio problem for
Svante> you, Hurd being a second class citizen?

It's not so much second-class as that the usual way gdb development
works is that ports need maintainers, and the current contributors are
pretty busy and/or have other interests.

I took a quick look at it and one question I have is whether
nm-i386gnu.h really needs to include any of the headers it does.  defs.h
already includes unistd.h, and regcache.h should probably not be needed;
and removing the mach includes would at least reduce the number of spots
needing the "struct".  Could you try removing these lines?

Also I happened to notice that file declares gnu_target_pid_to_str --
but I didn't see a definition.  So perhaps that could be removed as
well.

thanks,
Tom

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH] Please define thread_info as struct thread_info (and other stuff)
  2018-12-20 22:34           ` Tom Tromey
@ 2018-12-20 23:26             ` Simon Marchi
  2018-12-21 18:17             ` John Baldwin
  2018-12-24 21:51             ` Tom Tromey
  2 siblings, 0 replies; 20+ messages in thread
From: Simon Marchi @ 2018-12-20 23:26 UTC (permalink / raw)
  To: Tom Tromey; +Cc: Svante Signell, Andreas Schwab, gdb-patches, Pedro Alves

On 2018-12-20 17:34, Tom Tromey wrote:
>>>>>> "Svante" == Svante Signell <svante.signell@gmail.com> writes:
> 
> Svante> Seems like nothing is happening so far. Did you expect me to
> Svante> take action on this issue? Or is this a low-prio problem for
> Svante> you, Hurd being a second class citizen?
> 
> It's not so much second-class as that the usual way gdb development
> works is that ports need maintainers, and the current contributors are
> pretty busy and/or have other interests.

That's an important point.  For example, the Freebsd port is in pretty 
good shape, because somebody (thanks John) uses it daily and is able to 
report quickly any breakage to us non-Freebsd users.

I have tried earlier to give it a shot and build GDB using the image 
available here:

   https://www.gnu.org/software/hurd/hurd/running/qemu.html

but couldn't get very far (apt-get install wouldn't work).  Or at least, 
is there an easy way to get a cross-compiling environment for 
Debian/Hurd, let's say on Debian/Linux stable?

> I took a quick look at it and one question I have is whether
> nm-i386gnu.h really needs to include any of the headers it does.  
> defs.h
> already includes unistd.h, and regcache.h should probably not be 
> needed;
> and removing the mach includes would at least reduce the number of 
> spots
> needing the "struct".  Could you try removing these lines?
> 
> Also I happened to notice that file declares gnu_target_pid_to_str --
> but I didn't see a definition.  So perhaps that could be removed as
> well.

And to answer Svante's question about "what to do next", I think the 
intention long term was to put all of gdb in its own namespace, 
initially for fixing some gnulib clashes.  That's what triggered Pedro 
to do some C++ improvements (including wild matching).  For more 
details, see this, around the 15:00 mark:

https://slideslive.com/38902352/gdb-c-conversion-dogfooding-c

Looks like the prototype he did is on this branch:

https://github.com/palves/gdb/commits/palves/cxx-gdb-namespace

If this would fix the Hurd case, then maybe we can go with this.  Pedro, 
do you think we would be ready for such a move?  I would prefer to do 
that than to re-add a ton of "struct" keywords.

Simon

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH] Please define thread_info as struct thread_info (and other stuff)
  2018-12-20 22:34           ` Tom Tromey
  2018-12-20 23:26             ` Simon Marchi
@ 2018-12-21 18:17             ` John Baldwin
  2018-12-24 21:51             ` Tom Tromey
  2 siblings, 0 replies; 20+ messages in thread
From: John Baldwin @ 2018-12-21 18:17 UTC (permalink / raw)
  To: Svante Signell; +Cc: Tom Tromey, Andreas Schwab, Simon Marchi, gdb-patches

On 12/20/18 2:34 PM, Tom Tromey wrote:
>>>>>> "Svante" == Svante Signell <svante.signell@gmail.com> writes:
> 
> Svante> Seems like nothing is happening so far. Did you expect me to
> Svante> take action on this issue? Or is this a low-prio problem for
> Svante> you, Hurd being a second class citizen?
> 
> It's not so much second-class as that the usual way gdb development
> works is that ports need maintainers, and the current contributors are
> pretty busy and/or have other interests.
> 
> I took a quick look at it and one question I have is whether
> nm-i386gnu.h really needs to include any of the headers it does.  defs.h
> already includes unistd.h, and regcache.h should probably not be needed;
> and removing the mach includes would at least reduce the number of spots
> needing the "struct".  Could you try removing these lines?
> 
> Also I happened to notice that file declares gnu_target_pid_to_str --
> but I didn't see a definition.  So perhaps that could be removed as
> well.

I think this entire file can probably be removed.  The only useful content
it has that I can see are the THREAD_STATE_* macros, and those are only
used in one file: gnu-nat.c.  You could just move those there.  If in your
pending out-of-tree patches you need them in multiple files, you could
move the macros to gnu-nat.h.  If you have different versions (64-bit
vs 32-bit), then I think it would be fine to use #ifdef's to define the
appropriate version in whatever file you move the macros to.  That is
probably the simplest and quickest solution as moving everything into a
gdb namespace is probably a fairly large (and tedious) patch.

-- 
John Baldwin

                                                                            

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH] Please define thread_info as struct thread_info (and other stuff)
  2018-12-20 22:34           ` Tom Tromey
  2018-12-20 23:26             ` Simon Marchi
  2018-12-21 18:17             ` John Baldwin
@ 2018-12-24 21:51             ` Tom Tromey
  2019-01-12 18:37               ` Svante Signell
  2 siblings, 1 reply; 20+ messages in thread
From: Tom Tromey @ 2018-12-24 21:51 UTC (permalink / raw)
  To: Tom Tromey; +Cc: Svante Signell, Andreas Schwab, Simon Marchi, gdb-patches

>>>>> "Tom" == Tom Tromey <tom@tromey.com> writes:

Tom> I took a quick look at it and one question I have is whether
Tom> nm-i386gnu.h really needs to include any of the headers it does.  defs.h
Tom> already includes unistd.h, and regcache.h should probably not be needed;
Tom> and removing the mach includes would at least reduce the number of spots
Tom> needing the "struct".  Could you try removing these lines?

Tom> Also I happened to notice that file declares gnu_target_pid_to_str --
Tom> but I didn't see a definition.  So perhaps that could be removed as
Tom> well.

As John pointed out, the file seems not to be needed at all.
Could you try this patch?  I have no way to test it.

Tom

commit 86d2fb04c1890b381a24d3508087d11cc88388c8
Author: Tom Tromey <tom@tromey.com>
Date:   Mon Dec 24 14:49:27 2018 -0700

    Attempt to fix Hurd build
    
    gdb/ChangeLog
    2018-12-24  Tom Tromey  <tom@tromey.com>
    
            * gnu-nat.c (THREAD_STATE_FLAVOR, THREAD_STATE_SIZE)
            (THREAD_STATE_SET_TRACED, THREAD_STATE_CLEAR_TRACED): Move
            definitions from nm-i386gnu.h.
            * configure.nat: Don't reference nm-i386gnu.h.
            * config/i386/nm-i386gnu.h: Remove.

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 21731be98d..bc408fe748 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,11 @@
+2018-12-24  Tom Tromey  <tom@tromey.com>
+
+	* gnu-nat.c (THREAD_STATE_FLAVOR, THREAD_STATE_SIZE)
+	(THREAD_STATE_SET_TRACED, THREAD_STATE_CLEAR_TRACED): Move
+	definitions from nm-i386gnu.h.
+	* configure.nat: Don't reference nm-i386gnu.h.
+	* config/i386/nm-i386gnu.h: Remove.
+
 2018-12-18  Tom Tromey  <tom@tromey.com>
 
 	* dwarf2read.c (dwarf2_find_containing_comp_unit): Don't take
diff --git a/gdb/config/i386/nm-i386gnu.h b/gdb/config/i386/nm-i386gnu.h
deleted file mode 100644
index 4b2ca907fd..0000000000
--- a/gdb/config/i386/nm-i386gnu.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/* Native-dependent definitions for Intel 386 running the GNU Hurd
-   Copyright (C) 1994-2018 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/configure.nat b/gdb/configure.nat
index 200b716924..aa6f9c5c4e 100644
--- a/gdb/configure.nat
+++ b/gdb/configure.nat
@@ -218,7 +218,6 @@ case ${gdb_host} in
 		     msg_U.o exc_request_U.o exc_request_S.o'
 		HAVE_NATIVE_GCORE_HOST=1
 
-		NAT_FILE='nm-i386gnu.h'
 		MH_CFLAGS='-D_GNU_SOURCE'
 
 		XM_CLIBS='-lshouldbeinlibc'
diff --git a/gdb/gnu-nat.c b/gdb/gnu-nat.c
index a886c2b80c..612815f8ae 100644
--- a/gdb/gnu-nat.c
+++ b/gdb/gnu-nat.c
@@ -81,6 +81,14 @@ extern "C"
 #include "msg_U.h"
 }
 
+/* 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)
+
 static process_t proc_server = MACH_PORT_NULL;
 
 /* If we've sent a proc_wait_request to the proc server, the pid of the

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH] Please define thread_info as struct thread_info (and other stuff)
  2018-12-24 21:51             ` Tom Tromey
@ 2019-01-12 18:37               ` Svante Signell
  2019-01-12 20:50                 ` Tom Tromey
  0 siblings, 1 reply; 20+ messages in thread
From: Svante Signell @ 2019-01-12 18:37 UTC (permalink / raw)
  To: Tom Tromey; +Cc: Andreas Schwab, Simon Marchi, gdb-patches

Hi,

Just to make clear that the patch below is not enough to make gdb building on
GNU/Hurd. It helps but there are more issues. I'll continue to try to make gdb
building when time permits.

Thanks!

On Mon, 2018-12-24 at 14:51 -0700, Tom Tromey wrote:
> > > > > > "Tom" == Tom Tromey <tom@tromey.com> writes:
> 
> Tom> I took a quick look at it and one question I have is whether
> Tom> nm-i386gnu.h really needs to include any of the headers it does.  defs.h
> Tom> already includes unistd.h, and regcache.h should probably not be needed;
> Tom> and removing the mach includes would at least reduce the number of spots
> Tom> needing the "struct".  Could you try removing these lines?
> 
> Tom> Also I happened to notice that file declares gnu_target_pid_to_str --
> Tom> but I didn't see a definition.  So perhaps that could be removed as
> Tom> well.
> 
> As John pointed out, the file seems not to be needed at all.
> Could you try this patch?  I have no way to test it.
> 
> Tom
> 
> commit 86d2fb04c1890b381a24d3508087d11cc88388c8
> Author: Tom Tromey <tom@tromey.com>
> Date:   Mon Dec 24 14:49:27 2018 -0700
> 
>     Attempt to fix Hurd build
>     
>     gdb/ChangeLog
>     2018-12-24  Tom Tromey  <tom@tromey.com>
>     
>             * gnu-nat.c (THREAD_STATE_FLAVOR, THREAD_STATE_SIZE)
>             (THREAD_STATE_SET_TRACED, THREAD_STATE_CLEAR_TRACED): Move
>             definitions from nm-i386gnu.h.
>             * configure.nat: Don't reference nm-i386gnu.h.
>             * config/i386/nm-i386gnu.h: Remove.
> 
> diff --git a/gdb/ChangeLog b/gdb/ChangeLog
> index 21731be98d..bc408fe748 100644
> --- a/gdb/ChangeLog
> +++ b/gdb/ChangeLog
> @@ -1,3 +1,11 @@
> +2018-12-24  Tom Tromey  <tom@tromey.com>
> +
> +	* gnu-nat.c (THREAD_STATE_FLAVOR, THREAD_STATE_SIZE)
> +	(THREAD_STATE_SET_TRACED, THREAD_STATE_CLEAR_TRACED): Move
> +	definitions from nm-i386gnu.h.
> +	* configure.nat: Don't reference nm-i386gnu.h.
> +	* config/i386/nm-i386gnu.h: Remove.
> +
>  2018-12-18  Tom Tromey  <tom@tromey.com>
>  
>  	* dwarf2read.c (dwarf2_find_containing_comp_unit): Don't take
> diff --git a/gdb/config/i386/nm-i386gnu.h b/gdb/config/i386/nm-i386gnu.h
> deleted file mode 100644
> index 4b2ca907fd..0000000000
> --- a/gdb/config/i386/nm-i386gnu.h
> +++ /dev/null
> @@ -1,37 +0,0 @@
> -/* Native-dependent definitions for Intel 386 running the GNU Hurd
> -   Copyright (C) 1994-2018 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/configure.nat b/gdb/configure.nat
> index 200b716924..aa6f9c5c4e 100644
> --- a/gdb/configure.nat
> +++ b/gdb/configure.nat
> @@ -218,7 +218,6 @@ case ${gdb_host} in
>  		     msg_U.o exc_request_U.o exc_request_S.o'
>  		HAVE_NATIVE_GCORE_HOST=1
>  
> -		NAT_FILE='nm-i386gnu.h'
>  		MH_CFLAGS='-D_GNU_SOURCE'
>  
>  		XM_CLIBS='-lshouldbeinlibc'
> diff --git a/gdb/gnu-nat.c b/gdb/gnu-nat.c
> index a886c2b80c..612815f8ae 100644
> --- a/gdb/gnu-nat.c
> +++ b/gdb/gnu-nat.c
> @@ -81,6 +81,14 @@ extern "C"
>  #include "msg_U.h"
>  }
>  
> +/* 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)
> +
>  static process_t proc_server = MACH_PORT_NULL;
>  
>  /* If we've sent a proc_wait_request to the proc server, the pid of the

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH] Please define thread_info as struct thread_info (and other stuff)
  2019-01-12 18:37               ` Svante Signell
@ 2019-01-12 20:50                 ` Tom Tromey
  0 siblings, 0 replies; 20+ messages in thread
From: Tom Tromey @ 2019-01-12 20:50 UTC (permalink / raw)
  To: Svante Signell; +Cc: Tom Tromey, Andreas Schwab, Simon Marchi, gdb-patches

>>>>> "Svante" == Svante Signell <svante.signell@gmail.com> writes:

Svante> Just to make clear that the patch below is not enough to make gdb building on
Svante> GNU/Hurd. It helps but there are more issues. I'll continue to try to make gdb
Svante> building when time permits.

Since it helps, do you think I should check it in?

Also, what are the other problems?

thanks,
Tom

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH] Please define thread_info as struct thread_info (and other stuff)
  2018-12-17 21:41         ` John Baldwin
@ 2019-02-14 15:16           ` Thomas Schwinge
  0 siblings, 0 replies; 20+ messages in thread
From: Thomas Schwinge @ 2019-02-14 15:16 UTC (permalink / raw)
  To: gdb-patches
  Cc: Andreas Schwab, Simon Marchi, John Baldwin, svante.signell, Tom Tromey

[-- Attachment #1: Type: text/plain, Size: 1993 bytes --]

Hi!

On Mon, 17 Dec 2018 13:41:25 -0800, John Baldwin <jhb@FreeBSD.org> wrote:
> On 12/17/18 12:51 PM, Svante Signell wrote:
> > On Sun, 2018-12-16 at 16:10 -0700, Tom Tromey wrote:
> >>>>>>> "Svante" == Svante Signell <svante.signell@gmail.com> writes:
> >> Svante> Finally, I've found the problem (but no workaround yet): thread_info
> >> is an RPC on GNU/Hurd, and including mach.h in gdb/config/i386/nm-
> >> i386gnu.h:#include <mach.h> further includes <mach/mach_interface.h> which has
> >> the conflicting name Svante> of that RPC: kern_return_t thread_info
> >>
> >> Typical answers for this kind of thing are either to segregate the use
> >> of the system header somehow, or maybe namespacing or some other kind of
> >> renaming.  I haven't looked into the details much in this case I'm
> >> afraid.
> > 
> > As I see it you need to:
> > 
> > 1) Apply the patches submitted earlier in this thread using struct thread_info
> > consistently everywhere (simplest).

(We probably wouldn't be able to do that: necessary to work around some
compiler bug, I've seen a number of commits that changed "new-style C++
for iterators" away from 'for (struct thread_info *ti : [something])' to
just 'thread_info *ti' (without 'class' or 'struct').)

> > 2) Rename all usage of the struct thread_info to something else e.g. struct
> > gdb_thread_info (not future-proof though).
> > 3) Create a gdb namespace for all your code to avoid conflicts.
> > 4) Segregate the use of system header files as you write above. Dunno how to do
> > that though, but some of you should.
> 
> Normally code for native targets do 4).  I've had to be careful about which
> includes I use in native FreeBSD targets to avoid namespace collisions, etc.

Right.  I have now pushed to master the attached commit
cabb5f067daa9227bf0323cbf64c6065d6e4796f "[gdb, hurd] Work around
conflict between Mach's 'thread_info' function, and GDB's 'thread_info'
class".


Grüße
 Thomas



[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-gdb-hurd-Work-around-conflict-between-Mach-s-thread_.patch --]
[-- Type: text/x-diff, Size: 5377 bytes --]

From cabb5f067daa9227bf0323cbf64c6065d6e4796f Mon Sep 17 00:00:00 2001
From: Thomas Schwinge <thomas@codesourcery.com>
Date: Wed, 13 Feb 2019 12:02:20 +0100
Subject: [PATCH] [gdb, hurd] Work around conflict between Mach's 'thread_info'
 function, and GDB's 'thread_info' class

    In file included from ./nm.h:25:0,
                     from [...]/gdb/defs.h:423,
                     from [...]/gdb/gdb.c:19:
    [...]/gdb/regcache.h:35:46: warning: 'get_thread_regcache' initialized and declared 'extern'
     extern struct regcache *get_thread_regcache (thread_info *thread);
                                                  ^~~~~~~~~~~
    [...]/gdb/regcache.h:35:46: error: 'regcache* get_thread_regcache' redeclared as different kind of symbol
    [...]
    [...]/gdb/gdbarch.h:1203:69: error: 'thread_info' is not a type
     extern LONGEST gdbarch_get_syscall_number (struct gdbarch *gdbarch, thread_info *thread);
                                                                         ^~~~~~~~~~~

Fixed with a different (self-contained, more maintainable?) approach compared
to what has been done in commit 7aabaf9d4ad52a1df1f551908fbd8cafc5e7597a
"Create private_thread_info hierarchy", and commit
75cbc781e371279f4403045be93b07fd8fe7fde5 "gdb: For macOS, s/thread_info/struct
thread_info/".  We don't want to change all the GDB code to everywhere use
'class thread_info' or 'struct thread_info' instead of plain 'thread_info'.

	gdb/
	* config/i386/nm-i386gnu.h: Don't "#include" any files.
	* gnu-nat.h (mach_thread_info): New function.
	* gnu-nat.c (thread_takeover_sc_cmd): Use it.
---
 gdb/ChangeLog                |  4 ++++
 gdb/config/i386/nm-i386gnu.h |  5 -----
 gdb/gnu-nat.c                |  9 ++++++---
 gdb/gnu-nat.h                | 15 ++++++++++++++-
 gdb/i386-gnu-nat.c           |  4 +++-
 5 files changed, 27 insertions(+), 10 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index e6d86e2552..c88216b94b 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,9 @@
 2019-02-14  Thomas Schwinge  <thomas@codesourcery.com>
 
+	* config/i386/nm-i386gnu.h: Don't "#include" any files.
+	* gnu-nat.h (mach_thread_info): New function.
+	* gnu-nat.c (thread_takeover_sc_cmd): Use it.
+
 	* config/i386/nm-i386gnu.h (gnu_target_pid_to_str): Remove.
 
 2019-02-14  Frederic Konrad  <konrad@adacore.com>
diff --git a/gdb/config/i386/nm-i386gnu.h b/gdb/config/i386/nm-i386gnu.h
index 8f36102da4..e859b23f2b 100644
--- a/gdb/config/i386/nm-i386gnu.h
+++ b/gdb/config/i386/nm-i386gnu.h
@@ -19,11 +19,6 @@
 #ifndef CONFIG_I386_NM_I386GNU_H
 #define CONFIG_I386_NM_I386GNU_H
 
-#include <unistd.h>
-#include <mach.h>
-#include <mach/exception.h>
-#include "regcache.h"
-
 /* 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
diff --git a/gdb/gnu-nat.c b/gdb/gnu-nat.c
index cb8331daaf..bd8fcb6e59 100644
--- a/gdb/gnu-nat.c
+++ b/gdb/gnu-nat.c
@@ -20,6 +20,9 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
+/* Include this first, to pick up the <mach.h> 'thread_info' diversion.  */
+#include "gnu-nat.h"
+
 /* Mach/Hurd headers are not yet ready for C++ compilation.  */
 extern "C"
 {
@@ -67,7 +70,6 @@ extern "C"
 #include "gdb_obstack.h"
 #include "tid-parse.h"
 
-#include "gnu-nat.h"
 #include "inf-child.h"
 
 /* MIG stubs are not yet ready for C++ compilation.  */
@@ -3429,8 +3431,9 @@ thread_takeover_sc_cmd (const char *args, int from_tty)
   thread_basic_info_data_t _info;
   thread_basic_info_t info = &_info;
   mach_msg_type_number_t info_len = THREAD_BASIC_INFO_COUNT;
-  kern_return_t err =
-  thread_info (thread->port, THREAD_BASIC_INFO, (int *) &info, &info_len);
+  kern_return_t err
+    = mach_thread_info (thread->port, THREAD_BASIC_INFO,
+			(int *) &info, &info_len);
   if (err)
     error (("%s."), safe_strerror (err));
   thread->sc = info->suspend_count;
diff --git a/gdb/gnu-nat.h b/gdb/gnu-nat.h
index 9df479c850..dbad0cac93 100644
--- a/gdb/gnu-nat.h
+++ b/gdb/gnu-nat.h
@@ -19,8 +19,21 @@
 #ifndef GNU_NAT_H
 #define GNU_NAT_H
 
-#include <unistd.h>
+#include "defs.h"
+
+/* Work around conflict between Mach's 'thread_info' function, and GDB's
+   'thread_info' class.  Make the former available as 'mach_thread_info'.  */
+#define thread_info mach_thread_info
+/* Mach headers are not yet ready for C++ compilation.  */
+extern "C"
+{
 #include <mach.h>
+}
+#undef thread_info
+/* Divert 'mach_thread_info' to the original Mach 'thread_info' function.  */
+extern __typeof__ (mach_thread_info) mach_thread_info asm ("thread_info");
+
+#include <unistd.h>
 
 struct inf;
 
diff --git a/gdb/i386-gnu-nat.c b/gdb/i386-gnu-nat.c
index ffba941eef..c23c4bc79c 100644
--- a/gdb/i386-gnu-nat.c
+++ b/gdb/i386-gnu-nat.c
@@ -17,6 +17,9 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
+/* Include this first, to pick up the <mach.h> 'thread_info' diversion.  */
+#include "gnu-nat.h"
+
 /* Mach/Hurd headers are not yet ready for C++ compilation.  */
 extern "C"
 {
@@ -34,7 +37,6 @@ extern "C"
 
 #include "i386-tdep.h"
 
-#include "gnu-nat.h"
 #include "inf-child.h"
 #include "i387-tdep.h"
 
-- 
2.19.2


^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2019-02-14 15:16 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-15 19:36 [PATCH] Please define thread_info as struct thread_info (and other stuff) Svante Signell
2018-12-15 22:48 ` Tom Tromey
2018-12-15 23:01   ` Svante Signell
2018-12-16  4:31     ` Simon Marchi
2018-12-16  5:14       ` Svante Signell
2018-12-16  6:02         ` Simon Marchi
2018-12-16 16:22         ` Tom Tromey
2018-12-16  9:20 ` Andreas Schwab
2018-12-16 19:08   ` Svante Signell
2018-12-16 23:10     ` Tom Tromey
2018-12-17 20:51       ` Svante Signell
2018-12-17 21:41         ` John Baldwin
2019-02-14 15:16           ` Thomas Schwinge
2018-12-20 13:31         ` Svante Signell
2018-12-20 22:34           ` Tom Tromey
2018-12-20 23:26             ` Simon Marchi
2018-12-21 18:17             ` John Baldwin
2018-12-24 21:51             ` Tom Tromey
2019-01-12 18:37               ` Svante Signell
2019-01-12 20:50                 ` Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).