]> sourceware.org Git - newlib-cygwin.git/commitdiff
* dumper.cc (dumper::dumper): Print error code in case of error.
authorEgor Duda <deo@logos-m.ru>
Fri, 14 Sep 2001 15:07:31 +0000 (15:07 +0000)
committerEgor Duda <deo@logos-m.ru>
Fri, 14 Sep 2001 15:07:31 +0000 (15:07 +0000)
(dumper::add_thread): Ditto.
(dumper::collect_memory_sections): Ditto.
(dumper::dump_memory_region): Ditto.
(dumper::collect_process_information): Ditto.
(print_section_name): Fix formatting.

winsup/utils/ChangeLog
winsup/utils/dumper.cc

index 91ee38a8d859f9eef62180f0b40e3a679b970b64..1cad7d9d37b05c8872958a011459ecc50b11d19e 100644 (file)
@@ -1,3 +1,12 @@
+2001-09-14  Egor Duda  <deo@logos-m.ru>
+
+       * dumper.cc (dumper::dumper): Print error code in case of error.
+       (dumper::add_thread): Ditto.
+       (dumper::collect_memory_sections): Ditto.
+       (dumper::dump_memory_region): Ditto.
+       (dumper::collect_process_information): Ditto.
+       (print_section_name): Fix formatting.
+
 2001-09-13  Egor Duda  <deo@logos-m.ru>
 
        * dumper.cc (main): Properly recognize negative pids (used by w9x).
index ab80433e4baf0ee3f918cea38bc097a3582d7542..50e10d255b46730a00382f7df9b9876ef0cc58ff 100644 (file)
@@ -69,7 +69,7 @@ dumper::dumper (DWORD pid, DWORD tid, const char *file_name)
                          pid);
   if (!hProcess)
     {
-      fprintf (stderr, "Failed to open process #%lu\n", pid);
+      fprintf (stderr, "Failed to open process #%lu, error %ld\n", pid, GetLastError ());
       return;
     }
 
@@ -117,7 +117,7 @@ dumper::sane ()
 void
 print_section_name (bfd* abfd, asection* sect, PTR obj)
 {
-  deb_printf ( " %s", bfd_get_section_name (abfd, sect));
+  deb_printf (" %s", bfd_get_section_name (abfd, sect));
 }
 
 void
@@ -167,7 +167,10 @@ dumper::add_thread (DWORD tid, HANDLE hThread)
   pcontext = &(new_entity->u.thread.context);
   pcontext->ContextFlags = CONTEXT_FULL | CONTEXT_FLOATING_POINT;
   if (!GetThreadContext (hThread, pcontext))
-    return 0;
+    {
+      deb_printf ("Failed to read thread context (tid=%x), error %ld\n", tid, GetLastError ());
+      return 0;
+    }
 
   deb_printf ("added thread %u\n", tid);
   return 1;
@@ -294,6 +297,7 @@ dumper::collect_memory_sections ()
             all-nonreadable */
          if (!ReadProcessMemory (hProcess, current_page_address, mem_buf, sizeof (mem_buf), &done))
            {
+             DWORD err = GetLastError ();
              const char *pt[10];
              pt[0] = (mbi.Protect & PAGE_READONLY) ? "RO " : "";
              pt[1] = (mbi.Protect & PAGE_READWRITE) ? "RW " : "";
@@ -310,10 +314,10 @@ 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\n",
+             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,
-                         buf);
+                         buf, err);
              skip_region_p = 1;
            }
        }
@@ -366,7 +370,7 @@ dumper::dump_memory_region (asection * to, process_mem_region * memory)
       todo = min (size, PAGE_BUFFER_SIZE);
       if (!ReadProcessMemory (hProcess, pos, mem_buf, todo, &done))
        {
-         deb_printf ("Error reading process memory at %x(%x) %u\n", pos, todo, GetLastError ());
+         deb_printf ("Failed to read process memory at %x(%x), error %ld\n", pos, todo, GetLastError ());
          return 0;
        }
       size -= done;
@@ -497,7 +501,7 @@ dumper::collect_process_information ()
 
   if (!DebugActiveProcess (pid))
     {
-      fprintf (stderr, "Cannot attach to process #%lu", pid);
+      fprintf (stderr, "Cannot attach to process #%lu, error %ld", pid, GetLastError ());
       return 0;
     }
 
This page took 0.039882 seconds and 5 git commands to generate.