This is the mail archive of the cygwin-patches mailing list for the Cygwin project.


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

Re: [PATCH 64bit] utils: port dumper to 64bit


On Fri, 15 Feb 2013 12:04:31 +0100, Corinna Vinschen wrote:
> On Feb 15 02:02, Yaakov wrote:
> > I just uploaded cygwin64-libiconv, cygwin64-gettext, and
> > cygwin64-libbfd to Ports, so that dumper.exe could be built.  It
> > appears it hasn't been ported yet, so here's a first attempt.  Comments
> > welcome.
> 
> Looks good, I just have a few style nits.

Revised patch attached.


Yaakov
Index: dumper.cc
===================================================================
RCS file: /cvs/src/src/winsup/utils/dumper.cc,v
retrieving revision 1.20.2.1
diff -u -p -r1.20.2.1 dumper.cc
--- dumper.cc	23 Nov 2012 15:14:40 -0000	1.20.2.1
+++ dumper.cc	17 Feb 2013 03:46:21 -0000
@@ -1,6 +1,6 @@
 /* dumper.cc
 
-   Copyright 1999, 2001, 2002, 2004, 2006, 2007, 2011 Red Hat Inc.
+   Copyright 1999, 2001, 2002, 2004, 2006, 2007, 2011, 2013 Red Hat Inc.
 
    Written by Egor Duda <deo@logos-m.ru>
 
@@ -84,7 +84,8 @@ dumper::dumper (DWORD pid, DWORD tid, co
 			  pid);
   if (!hProcess)
     {
-      fprintf (stderr, "Failed to open process #%lu, error %ld\n", pid, GetLastError ());
+      fprintf (stderr, "Failed to open process #%u, error %ld\n",
+	       (unsigned int) pid, (long) GetLastError ());
       return;
     }
 
@@ -192,7 +193,7 @@ dumper::add_thread (DWORD tid, HANDLE hT
 }
 
 int
-dumper::add_mem_region (LPBYTE base, DWORD size)
+dumper::add_mem_region (LPBYTE base, SIZE_T size)
 {
   if (!sane ())
     return 0;
@@ -209,14 +210,14 @@ dumper::add_mem_region (LPBYTE base, DWO
   new_entity->u.memory.base = base;
   new_entity->u.memory.size = size;
 
-  deb_printf ("added memory region %08x-%08x\n", (DWORD) base, (DWORD) base + size);
+  deb_printf ("added memory region %p-%p\n", base, base + size);
   return 1;
 }
 
 /* split_add_mem_region scans list of regions to be excluded from dumping process
    (excl_list) and removes all "excluded" parts from given region. */
 int
-dumper::split_add_mem_region (LPBYTE base, DWORD size)
+dumper::split_add_mem_region (LPBYTE base, SIZE_T size)
 {
   if (!sane ())
     return 0;
@@ -255,7 +256,7 @@ dumper::add_module (LPVOID base_address)
   if (!sane ())
     return 0;
 
-  char *module_name = psapi_get_module_name (hProcess, (DWORD) base_address);
+  char *module_name = psapi_get_module_name (hProcess, base_address);
   if (module_name == NULL)
     return 1;
 
@@ -270,7 +271,7 @@ dumper::add_module (LPVOID base_address)
 
   parse_pe (module_name, excl_list);
 
-  deb_printf ("added module %08x %s\n", base_address, module_name);
+  deb_printf ("added module %p %s\n", base_address, module_name);
   return 1;
 }
 
@@ -284,8 +285,8 @@ dumper::collect_memory_sections ()
 
   LPBYTE current_page_address;
   LPBYTE last_base = (LPBYTE) 0xFFFFFFFF;
-  DWORD last_size = 0;
-  DWORD done;
+  SIZE_T last_size = (SIZE_T) 0;
+  SIZE_T done;
 
   char mem_buf[PAGE_BUFFER_SIZE];
 
@@ -329,9 +330,9 @@ dumper::collect_memory_sections ()
 	      for (int i = 0; i < 10; i++)
 		strcat (buf, pt[i]);
 
-	      deb_printf ("warning: failed to read memory at %08x-%08x (protect = %s), error %ld.\n",
-			  (DWORD) current_page_address,
-			  (DWORD) current_page_address + mbi.RegionSize,
+	      deb_printf ("warning: failed to read memory at %p-%p (protect = %s), error %ld.\n",
+			  current_page_address,
+			  current_page_address + mbi.RegionSize,
 			  buf, err);
 	      skip_region_p = 1;
 	    }
@@ -369,9 +370,9 @@ dumper::dump_memory_region (asection * t
   if (!sane ())
     return 0;
 
-  DWORD size = memory->size;
-  DWORD todo;
-  DWORD done;
+  SIZE_T size = memory->size;
+  SIZE_T todo;
+  SIZE_T done;
   LPBYTE pos = memory->base;
   DWORD sect_pos = 0;
 
@@ -516,12 +517,13 @@ dumper::collect_process_information ()
 
   if (!DebugActiveProcess (pid))
     {
-      fprintf (stderr, "Cannot attach to process #%lu, error %ld", pid, GetLastError ());
+      fprintf (stderr, "Cannot attach to process #%u, error %ld",
+	       (unsigned int) pid, (long) GetLastError ());
       return 0;
     }
 
   char event_name[sizeof ("cygwin_error_start_event") + 20];
-  sprintf (event_name, "cygwin_error_start_event%16lx", pid);
+  sprintf (event_name, "cygwin_error_start_event%16x", (unsigned int) pid);
   HANDLE sync_with_debugee = OpenEvent (EVENT_MODIFY_STATE, FALSE, event_name);
 
   DEBUG_EVENT current_event;
@@ -660,7 +662,7 @@ dumper::prepare_core_dump ()
   char sect_name[50];
 
   flagword sect_flags;
-  DWORD sect_size;
+  SIZE_T sect_size;
   bfd_vma sect_vma;
 
   asection *new_section;
@@ -812,7 +814,7 @@ dumper::write_core_dump ()
       if (p->section == NULL)
 	continue;
 
-      deb_printf ("writing section type=%u base=%08x size=%08x flags=%08x\n",
+      deb_printf ("writing section type=%u base=%p size=%p flags=%08x\n",
 		  p->type,
 		  p->section->vma,
 		  bfd_get_section_size (p->section),
@@ -936,7 +938,7 @@ main (int argc, char **argv)
   DWORD tid = 0;
 
   if (verbose)
-    printf ("dumping process #%lu to %s\n", pid, core_file);
+    printf ("dumping process #%u to %s\n", (unsigned int) pid, core_file);
 
   dumper d (pid, tid, core_file);
   if (!d.sane ())
Index: dumper.h
===================================================================
RCS file: /cvs/src/src/winsup/utils/dumper.h,v
retrieving revision 1.3
diff -u -p -r1.3 dumper.h
--- dumper.h	24 Jul 2007 19:08:23 -0000	1.3
+++ dumper.h	17 Feb 2013 03:46:21 -0000
@@ -1,6 +1,6 @@
 /* dumper.h
 
-   Copyright 1999,2001 Red Hat Inc.
+   Copyright 1999, 2001, 2013 Red Hat Inc.
 
    Written by Egor Duda <deo@logos-m.ru>
 
@@ -28,7 +28,7 @@
 typedef struct
 {
   LPBYTE base;
-  DWORD size;
+  SIZE_T size;
 } process_mem_region;
 
 typedef struct
@@ -67,16 +67,16 @@ typedef struct _process_entity
 class exclusion
 {
 public:
-  int last;
-  int size;
-  int step;
+  size_t last;
+  size_t size;
+  size_t step;
   process_mem_region* region;
 
-  exclusion ( int step ) { last = size = 0;
-			   this->step = step;
-			   region = NULL; }
+  exclusion ( size_t step ) { last = size = 0;
+			      this->step = step;
+			      region = NULL; }
   ~exclusion () { free ( region ); }
-  int add ( LPBYTE mem_base, DWORD mem_size );
+  int add ( LPBYTE mem_base, SIZE_T mem_size );
   int sort_and_check ();
 };
 
@@ -105,10 +105,10 @@ class dumper
 
   process_entity* add_process_entity_to_list ( process_entity_type type );
   int add_thread ( DWORD tid, HANDLE hThread );
-  int add_mem_region ( LPBYTE base, DWORD size );
+  int add_mem_region ( LPBYTE base, SIZE_T size );
 
   /* break mem_region by excl_list and add add all subregions */
-  int split_add_mem_region ( LPBYTE base, DWORD size );
+  int split_add_mem_region ( LPBYTE base, SIZE_T size );
 
   int add_module ( LPVOID base_address );
 
@@ -133,7 +133,7 @@ public:
 
 extern int deb_printf ( const char* format, ... );
 
-extern char* psapi_get_module_name ( HANDLE hProcess, DWORD BaseAddress );
+extern char* psapi_get_module_name ( HANDLE hProcess, LPVOID BaseAddress );
 
 extern int parse_pe ( const char* file_name, exclusion* excl_list );
 
Index: module_info.cc
===================================================================
RCS file: /cvs/src/src/winsup/utils/module_info.cc,v
retrieving revision 1.4.2.1
diff -u -p -r1.4.2.1 module_info.cc
--- module_info.cc	29 Jan 2013 21:54:42 -0000	1.4.2.1
+++ module_info.cc	17 Feb 2013 03:46:21 -0000
@@ -1,6 +1,6 @@
 /* module_info.cc
 
-   Copyright 1999, 2000, 2001, 2010 Red Hat, Inc.
+   Copyright 1999, 2000, 2001, 2010, 2013 Red Hat, Inc.
 
    Written by Egor Duda <deo@logos-m.ru>
 
@@ -33,7 +33,7 @@ static tf_GetModuleFileNameExA *psapi_Ge
    Uses psapi.dll. */
 
 char *
-psapi_get_module_name (HANDLE hProcess, DWORD BaseAddress)
+psapi_get_module_name (HANDLE hProcess, LPVOID BaseAddress)
 {
   DWORD len;
   MODULEINFO mi;
@@ -103,7 +103,7 @@ psapi_get_module_name (HANDLE hProcess, 
 	  goto failed;
 	}
 
-      if ((DWORD) (mi.lpBaseOfDll) == BaseAddress)
+      if (mi.lpBaseOfDll == BaseAddress)
 	{
 	  free (DllHandle);
 	  return strdup (name_buf);
Index: parse_pe.cc
===================================================================
RCS file: /cvs/src/src/winsup/utils/parse_pe.cc,v
retrieving revision 1.9.4.2
diff -u -p -r1.9.4.2 parse_pe.cc
--- parse_pe.cc	29 Jan 2013 21:54:42 -0000	1.9.4.2
+++ parse_pe.cc	17 Feb 2013 03:46:21 -0000
@@ -1,6 +1,6 @@
 /* parse_pe.cc
 
-   Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2012 Red Hat, Inc.
+   Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2012, 2013 Red Hat, Inc.
 
    Written by Egor Duda <deo@logos-m.ru>
 
@@ -28,7 +28,7 @@
 #include "dumper.h"
 
 int
-exclusion::add (LPBYTE mem_base, DWORD mem_size)
+exclusion::add (LPBYTE mem_base, SIZE_T mem_size)
 {
   while (last >= size)
     size += step;
@@ -62,7 +62,7 @@ exclusion::sort_and_check ()
 	continue;
       if (p->base + size > q->base)
 	{
-	  fprintf (stderr, "region error @ (%8p + %d) > %8p\n", p->base, size, q->base);
+	  fprintf (stderr, "region error @ (%p + %zd) > %p\n", p->base, size, q->base);
 	  return 0;
 	}
     }
@@ -77,7 +77,7 @@ select_data_section (bfd * abfd, asectio
   if ((sect->flags & (SEC_CODE | SEC_DEBUGGING)) &&
       sect->vma && bfd_get_section_size (sect))
     {
-      excl_list->add ((LPBYTE) sect->vma, (DWORD) bfd_get_section_size (sect));
+      excl_list->add ((LPBYTE) sect->vma, (SIZE_T) bfd_get_section_size (sect));
       deb_printf ("excluding section: %20s %08lx\n", sect->name,
 		  bfd_get_section_size (sect));
     }

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