WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH] gdbserver-xen: fix corefile access

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH] gdbserver-xen: fix corefile access
From: Horms <horms@xxxxxxxxxxxx>
Date: Thu, 2 Mar 2006 08:28:43 +0000 (UTC)
Delivery-date: Thu, 02 Mar 2006 08:29:54 +0000
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: tin/1.8.1-20060215 ("Mealasta") (UNIX) (Linux/2.6.15-hls-2006020200 (i686))
# HG changeset patch
# User Horms <horms@xxxxxxxxxxxx>
# Node ID d15c3e045aa21d0753761121ef3c9a0f73c0e82a
# Parent  48cbeecfa8a4b438f72fbe440f0642344f2f24a4
gdbserver-xen: fix corefile access

This patch fixes corefile access by ensuring that the open fd
to the corefile (current_domid) is passed to the underlying
xc_routines as neccessary. Currently the prevailing pid is passed,
which works fine when attaching to a running domain, but fails
for the corefile case.

This is done by creaating a wrapper for curvcpuid(), called
curvcpuid_or_domfd() which returns current_domid if the
global isfile is set. This assumes that isfile is stable,
if this is not the caes, it could easily be saved at
the time that myptrace is set using this variable.

I did not replace curvcpuid(), as it seems to be needed
elsewhere, though it may be possible to eliminate it.

This patch also relocates curvcpuid() (without modifying it).
This is because curvcpuid_or_domfd() needs to below the
declaration of isfile, and it seems to make sense to put
curvcpuid() and curvcpuid_or_domfd() next to each other.

Signed-Off-By: Horms <horms@xxxxxxxxxxxx>

diff -r 48cbeecfa8a4 -r d15c3e045aa2 
tools/debugger/gdb/gdb-6.2.1-xen-sparse/gdb/gdbserver/linux-xen-low.c
--- a/tools/debugger/gdb/gdb-6.2.1-xen-sparse/gdb/gdbserver/linux-xen-low.c     
Thu Mar  2 09:30:54 2006 +0900
+++ b/tools/debugger/gdb/gdb-6.2.1-xen-sparse/gdb/gdbserver/linux-xen-low.c     
Thu Mar  2 17:18:42 2006 +0900
@@ -45,17 +45,6 @@ int (*myxcwait)(int xc_handle, int domai
 int (*myxcwait)(int xc_handle, int domain, int *status, int options) ;
 static int xc_handle;
 
-static inline int
-curvcpuid()
-{
-  struct process_info *process;
-  if (current_inferior == NULL)
-      return 0;
-  process = get_thread_process(current_inferior);
-  return (process->thread_known ? process->tid : 0);
-
-}
-
 
 #define DOMFLAGS_DYING     (1<<0) /* Domain is scheduled to die.             */
 #define DOMFLAGS_SHUTDOWN  (1<<2) /* The guest OS has shut down.             */
@@ -87,6 +76,23 @@ struct pending_signals
 
 static int use_regsets_p = 1;
 
+static inline int
+curvcpuid()
+{
+  struct process_info *process;
+  if (current_inferior == NULL)
+      return 0;
+  process = get_thread_process(current_inferior);
+  return (process->thread_known ? process->tid : 0);
+}
+
+static inline int
+curvcpuid_or_domfd()
+{
+  if(isfile)
+         return current_domid;
+  return curvcpuid();
+}
 
 #define pid_of(proc) ((proc)->head.id)
 
@@ -276,7 +282,7 @@ regsets_fetch_inferior_registers ()
 
       buf = malloc (regset->size);
       res = myptrace (xc_handle, regset->get_request, 
-                     curvcpuid(),
+                     curvcpuid_or_domfd(),
                      0, (PTRACE_XFER_TYPE)buf);
       if (res < 0)
        {
@@ -329,7 +335,7 @@ regsets_store_inferior_registers ()
 
       buf = malloc (regset->size);
       regset->fill_function (buf);
-      res = myptrace (xc_handle, regset->set_request, curvcpuid(), 0, 
(PTRACE_XFER_TYPE)buf);
+      res = myptrace (xc_handle, regset->set_request, curvcpuid_or_domfd(), 0, 
(PTRACE_XFER_TYPE)buf);
       if (res < 0)
        {
          if (errno == EIO)
@@ -407,7 +413,7 @@ linux_read_memory (CORE_ADDR memaddr, ch
   for (i = 0; i < count; i++, addr += sizeof (PTRACE_XFER_TYPE))
     {
       errno = 0;
-      buffer[i] = myptrace (xc_handle, PTRACE_PEEKTEXT, curvcpuid(), 
(PTRACE_ARG3_TYPE) addr, 0);
+      buffer[i] = myptrace (xc_handle, PTRACE_PEEKTEXT, curvcpuid_or_domfd(), 
(PTRACE_ARG3_TYPE) addr, 0);
       if (errno)
        return errno;
     }
@@ -440,13 +446,13 @@ linux_write_memory (CORE_ADDR memaddr, c
 
   /* Fill start and end extra bytes of buffer with existing memory data.  */
 
-  buffer[0] = myptrace (xc_handle, PTRACE_PEEKTEXT, curvcpuid(),
+  buffer[0] = myptrace (xc_handle, PTRACE_PEEKTEXT, curvcpuid_or_domfd(),
                      (PTRACE_ARG3_TYPE) addr, 0);
 
   if (count > 1)
     {
       buffer[count - 1]
-       = myptrace (xc_handle, PTRACE_PEEKTEXT, curvcpuid(),
+       = myptrace (xc_handle, PTRACE_PEEKTEXT, curvcpuid_or_domfd(),
                  (PTRACE_ARG3_TYPE) (addr + (count - 1)
                                      * sizeof (PTRACE_XFER_TYPE)),
                  0);
@@ -460,7 +466,7 @@ linux_write_memory (CORE_ADDR memaddr, c
   for (i = 0; i < count; i++, addr += sizeof (PTRACE_XFER_TYPE))
     {
       errno = 0;
-      myptrace (xc_handle, PTRACE_POKETEXT, curvcpuid(), 
+      myptrace (xc_handle, PTRACE_POKETEXT, current_domid, 
                (PTRACE_ARG3_TYPE) addr, buffer[i]);
       if (errno)
        return errno;


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel