+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).
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;
}
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
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;
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 " : "";
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;
}
}
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;
if (!DebugActiveProcess (pid))
{
- fprintf (stderr, "Cannot attach to process #%lu", pid);
+ fprintf (stderr, "Cannot attach to process #%lu, error %ld", pid, GetLastError ());
return 0;
}