Hurd port: update interface to match upstream and fix warnings.

Message ID ZcMo9FIP35iyiVmA@jupiter.tail36e24.ts.net
State New
Headers
Series Hurd port: update interface to match upstream and fix warnings. |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-arm success Testing passed
linaro-tcwg-bot/tcwg_gdb_check--master-arm success Testing passed
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 success Testing passed

Commit Message

Flavio Cruz Feb. 7, 2024, 6:53 a.m. UTC
  We have recently updated the interface for raising exceptions to use
long [1] and updated mach_port_t to be "unsigned int". This patches fixes
those problems and will help us port GDB to Hurd x86_64.

Tested on Hurd i686 and x86_64.

[1] https://git.savannah.gnu.org/cgit/hurd/gnumach.git/tree/include/mach/exc.defs
---
 gdb/exc_request.defs |  2 +-
 gdb/gnu-nat.c        | 37 +++++++++++++++++++------------------
 2 files changed, 20 insertions(+), 19 deletions(-)
  

Comments

Simon Marchi Feb. 7, 2024, 4:47 p.m. UTC | #1
On 2/7/24 01:53, Flavio Cruz wrote:
> We have recently updated the interface for raising exceptions to use
> long [1] and updated mach_port_t to be "unsigned int". This patches fixes
> those problems and will help us port GDB to Hurd x86_64.
> 
> Tested on Hurd i686 and x86_64.
> 
> [1] https://git.savannah.gnu.org/cgit/hurd/gnumach.git/tree/include/mach/exc.defs

I take it that you are not too concerned with backwards compatibility
with previous versions of Hurd (compiling new GDBs on old Hurds)?  If
so, this is fine with me.

Approved-By: Simon Marchi <simon.marchi@efficios.com>

Simon
  
Samuel Thibault Feb. 7, 2024, 5:01 p.m. UTC | #2
Simon Marchi, le mer. 07 févr. 2024 11:47:30 -0500, a ecrit:
> On 2/7/24 01:53, Flavio Cruz wrote:
> > We have recently updated the interface for raising exceptions to use
> > long [1] and updated mach_port_t to be "unsigned int". This patches fixes
> > those problems and will help us port GDB to Hurd x86_64.
> > 
> > Tested on Hurd i686 and x86_64.
> > 
> > [1] https://git.savannah.gnu.org/cgit/hurd/gnumach.git/tree/include/mach/exc.defs
> 
> I take it that you are not too concerned with backwards compatibility
> with previous versions of Hurd (compiling new GDBs on old Hurds)?

We don't have any other 64bit version of the Hurd, and for the 32bit
version this is a no-op.

> If so, this is fine with me.
> 
> Approved-By: Simon Marchi <simon.marchi@efficios.com>

Thanks!

Samuel
  

Patch

diff --git a/gdb/exc_request.defs b/gdb/exc_request.defs
index 9b5ed2ee421..0291e7b30f1 100644
--- a/gdb/exc_request.defs
+++ b/gdb/exc_request.defs
@@ -48,4 +48,4 @@  simpleroutine exception_raise_request (
 	task		: mach_port_t;
 	exception	: integer_t;
 	code		: integer_t;
-	subcode		: integer_t);
+	subcode		: rpc_long_integer_t);
diff --git a/gdb/gnu-nat.c b/gdb/gnu-nat.c
index 0add13e3b89..aba1034396f 100644
--- a/gdb/gnu-nat.c
+++ b/gdb/gnu-nat.c
@@ -134,7 +134,8 @@  static struct inf *make_inf ();
 struct exc_state
   {
     int exception;		/* The exception code.  */
-    int code, subcode;
+    int code;
+    long subcode;
     mach_port_t handler;	/* The real exception port to handle this.  */
     mach_port_t reply;		/* The reply port from the exception call.  */
   };
@@ -389,7 +390,7 @@  gnu_nat_target::proc_get_exception_port (struct proc * proc, mach_port_t * port)
 kern_return_t
 gnu_nat_target::proc_set_exception_port (struct proc * proc, mach_port_t port)
 {
-  proc_debug (proc, "setting exception port: %lu", port);
+  proc_debug (proc, "setting exception port: %u", port);
   if (proc_is_task (proc))
     return task_set_exception_port (proc->port, port);
   else
@@ -429,7 +430,7 @@  gnu_nat_target::proc_steal_exc_port (struct proc *proc, mach_port_t exc_port)
     {
       kern_return_t err = 0;
 
-      proc_debug (proc, "inserting exception port: %lu", exc_port);
+      proc_debug (proc, "inserting exception port: %u", exc_port);
 
       if (cur_exc_port != exc_port)
 	/* Put in our exception port.  */
@@ -450,7 +451,7 @@  gnu_nat_target::proc_steal_exc_port (struct proc *proc, mach_port_t exc_port)
 	  proc->saved_exc_port = cur_exc_port;
 	}
 
-      proc_debug (proc, "saved exception port: %lu", proc->saved_exc_port);
+      proc_debug (proc, "saved exception port: %u", proc->saved_exc_port);
 
       if (!err)
 	proc->exc_port = exc_port;
@@ -562,11 +563,11 @@  gnu_nat_target::make_proc (struct inf *inf, mach_port_t port, int tid)
 				    MACH_MSG_TYPE_MAKE_SEND_ONCE,
 				    &prev_port);
   if (err)
-    warning (_("Couldn't request notification for port %lu: %s"),
+    warning (_("Couldn't request notification for port %u: %s"),
 	     port, safe_strerror (err));
   else
     {
-      proc_debug (proc, "notifications to: %lu", inf->event_port);
+      proc_debug (proc, "notifications to: %u", inf->event_port);
       if (prev_port != MACH_PORT_NULL)
 	mach_port_deallocate (mach_task_self (), prev_port);
     }
@@ -741,7 +742,7 @@  gnu_nat_target::inf_set_pid (struct inf *inf, pid_t pid)
 	       pid, safe_strerror (err));
     }
 
-  inf_debug (inf, "setting task: %lu", task_port);
+  inf_debug (inf, "setting task: %u", task_port);
 
   if (inf->pause_sc)
     task_suspend (task_port);
@@ -1072,7 +1073,7 @@  gnu_nat_target::inf_validate_procs (struct inf *inf)
 	    else
 	      inf->threads = thread;
 	    last = thread;
-	    proc_debug (thread, "new thread: %lu", threads[i]);
+	    proc_debug (thread, "new thread: %u", threads[i]);
 
 	    ptid = ptid_t (inf->pid, thread->tid, 0);
 
@@ -1337,8 +1338,8 @@  gnu_nat_target::inf_signal (struct inf *inf, enum gdb_signal sig)
 	  struct exc_state *e = &w->exc;
 
 	  inf_debug (inf, "passing through exception:"
-		     " task = %lu, thread = %lu, exc = %d"
-		     ", code = %d, subcode = %d",
+		     " task = %u, thread = %u, exc = %d"
+		     ", code = %d, subcode = %ld",
 		     w->thread->port, inf->task->port,
 		     e->exception, e->code, e->subcode);
 	  err =
@@ -1631,13 +1632,13 @@  gnu_nat_target::wait (ptid_t ptid, struct target_waitstatus *status,
 kern_return_t
 S_exception_raise_request (mach_port_t port, mach_port_t reply_port,
 			   thread_t thread_port, task_t task_port,
-			   int exception, int code, int subcode)
+			   int exception, int code, long subcode)
 {
   struct inf *inf = waiting_inf;
   struct proc *thread = inf_port_to_thread (inf, thread_port);
 
   inf_debug (waiting_inf,
-	     "thread = %lu, task = %lu, exc = %d, code = %d, subcode = %d",
+	     "thread = %u, task = %u, exc = %d, code = %d, subcode = %ld",
 	     thread_port, task_port, exception, code, subcode);
 
   if (!thread)
@@ -1671,13 +1672,13 @@  S_exception_raise_request (mach_port_t port, mach_port_t reply_port,
 	{
 	  if (thread->exc_port == port)
 	    {
-	      inf_debug (waiting_inf, "Handler is thread exception port <%lu>",
+	      inf_debug (waiting_inf, "Handler is thread exception port <%u>",
 			 thread->saved_exc_port);
 	      inf->wait.exc.handler = thread->saved_exc_port;
 	    }
 	  else
 	    {
-	      inf_debug (waiting_inf, "Handler is task exception port <%lu>",
+	      inf_debug (waiting_inf, "Handler is task exception port <%u>",
 			 inf->task->saved_exc_port);
 	      inf->wait.exc.handler = inf->task->saved_exc_port;
 	      gdb_assert (inf->task->exc_port == port);
@@ -1727,7 +1728,7 @@  do_mach_notify_dead_name (mach_port_t notify, mach_port_t dead_port)
 {
   struct inf *inf = waiting_inf;
 
-  inf_debug (waiting_inf, "port = %lu", dead_port);
+  inf_debug (waiting_inf, "port = %u", dead_port);
 
   if (inf->task && inf->task->port == dead_port)
     {
@@ -2357,7 +2358,7 @@  gnu_write_inferior (task_t task, CORE_ADDR addr,
 	/* Check for holes in memory.  */
 	if (old_address != region_address)
 	  {
-	    warning (_("No memory at 0x%lx. Nothing written"),
+	    warning (_("No memory at 0x%zx. Nothing written"),
 		     old_address);
 	    err = KERN_SUCCESS;
 	    length = 0;
@@ -2366,7 +2367,7 @@  gnu_write_inferior (task_t task, CORE_ADDR addr,
 
 	if (!(max_protection & VM_PROT_WRITE))
 	  {
-	    warning (_("Memory at address 0x%lx is unwritable. "
+	    warning (_("Memory at address 0x%zx is unwritable. "
 		       "Nothing written"),
 		     old_address);
 	    err = KERN_SUCCESS;
@@ -2870,7 +2871,7 @@  gnu_nat_target::steal_exc_port (struct proc *proc, mach_port_t name)
 				 name, MACH_MSG_TYPE_COPY_SEND,
 				 &port, &port_type);
   if (err)
-    error (_("Couldn't extract send right %lu from inferior: %s"),
+    error (_("Couldn't extract send right %u from inferior: %s"),
 	   name, safe_strerror (err));
 
   if (proc->saved_exc_port)