Cleanup formatting on some files. Remove excessive whitespace.

This commit is contained in:
Christopher Faylor 2000-10-28 05:00:00 +00:00
parent 3c952fed3f
commit eedc36cb12
15 changed files with 753 additions and 675 deletions

@ -1,5 +1,5 @@
dnl Autoconf configure script for Cygwin utilities. dnl Autoconf configure script for Cygwin utilities.
dnl Copyright 1996, 1997 Cygnus Solutions. dnl Copyright 1996, 1997, 1998, 1999, 2000 Cygnus Solutions.
dnl dnl
dnl This file is part of Cygwin. dnl This file is part of Cygwin.
dnl dnl

@ -29,8 +29,7 @@ typedef long long longlong;
typedef __int64 longlong; typedef __int64 longlong;
#endif #endif
const char *known_env_vars[] = const char *known_env_vars[] = {
{
"c_include_path", "c_include_path",
"compiler_path", "compiler_path",
"cxx_include_path", "cxx_include_path",
@ -55,21 +54,45 @@ const char *known_env_vars[] =
0 0
}; };
struct { struct
{
const char *name; const char *name;
int missing_is_good; int missing_is_good;
} common_apps[] = { }
{ "bash", 0 }, common_apps[] =
{ "cat", 0 }, {
{ "cpp", 1 }, {
{ "find", 0 }, "bash", 0}
{ "gcc", 0 }, ,
{ "gdb", 0 }, {
{ "ld", 0 }, "cat", 0}
{ "ls", 0 }, ,
{ "make", 0 }, {
{ "sh", 0 }, "cpp", 1}
{ 0, 0 } ,
{
"find", 0}
,
{
"gcc", 0}
,
{
"gdb", 0}
,
{
"ld", 0}
,
{
"ls", 0}
,
{
"make", 0}
,
{
"sh", 0}
,
{
0, 0}
}; };
int num_paths = 0, max_paths = 0; int num_paths = 0, max_paths = 0;
@ -148,7 +171,7 @@ find_on_path (char *file, char *default_extension,
return file; return file;
if (strchr (file, '.')) if (strchr (file, '.'))
default_extension = (char *)""; default_extension = (char *) "";
for (int i = 0; i < num_paths; i++) for (int i = 0; i < num_paths; i++)
{ {
@ -263,13 +286,13 @@ struct ExpDirectory
}; };
struct ImpDirectory struct ImpDirectory
{ {
unsigned characteristics; unsigned characteristics;
unsigned timestamp; unsigned timestamp;
unsigned forwarder_chain; unsigned forwarder_chain;
unsigned name_rva; unsigned name_rva;
unsigned iat_rva; unsigned iat_rva;
}; };
void track_down (char *file, char *suffix, int lvl); void track_down (char *file, char *suffix, int lvl);
@ -339,8 +362,10 @@ dll_info (const char *path, HANDLE fh, int lvl, int recurse)
int nsections = get_word (fh, pe_header_offset + 4 + 2); int nsections = get_word (fh, pe_header_offset + 4 + 2);
char *sections = (char *) malloc (nsections * 40); char *sections = (char *) malloc (nsections * 40);
SetFilePointer (fh, pe_header_offset + 4 + 20 + get_word (fh, pe_header_offset + 4 + 16), SetFilePointer (fh,
0, FILE_BEGIN); pe_header_offset + 4 + 20 + get_word (fh,
pe_header_offset + 4 +
16), 0, FILE_BEGIN);
ReadFile (fh, sections, nsections * 40, &junk, 0); ReadFile (fh, sections, nsections * 40, &junk, 0);
if (verbose && num_entries >= 1 && export_size > 0) if (verbose && num_entries >= 1 && export_size > 0)
@ -436,7 +461,8 @@ track_down (char *file, char *suffix, int lvl)
printf ("%s", path); printf ("%s", path);
HANDLE fh = CreateFile (path, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, HANDLE fh =
CreateFile (path, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (fh == INVALID_HANDLE_VALUE) if (fh == INVALID_HANDLE_VALUE)
{ {
@ -462,8 +488,7 @@ ls (char *f)
FileTimeToSystemTime (&info.ftLastWriteTime, &systime); FileTimeToSystemTime (&info.ftLastWriteTime, &systime);
printf ("%5dk %04d/%02d/%02d %s", printf ("%5dk %04d/%02d/%02d %s",
(((int) info.nFileSizeLow) + 512) / 1024, (((int) info.nFileSizeLow) + 512) / 1024,
systime.wYear, systime.wMonth, systime.wDay, systime.wYear, systime.wMonth, systime.wDay, f);
f);
dll_info (f, h, 16, 0); dll_info (f, h, 16, 0);
CloseHandle (h); CloseHandle (h);
@ -498,11 +523,11 @@ cygcheck (char *app)
extern char **environ; extern char **environ;
struct RegInfo struct RegInfo
{ {
RegInfo *prev; RegInfo *prev;
char *name; char *name;
HKEY key; HKEY key;
}; };
void void
show_reg (RegInfo * ri, int nest) show_reg (RegInfo * ri, int nest)
@ -538,8 +563,7 @@ scan_registry (RegInfo * prev, HKEY hKey, char *name, int cygnus)
#if 0 #if 0
char tmp[400]; char tmp[400];
FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM, 0, GetLastError (), FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM, 0, GetLastError (),
MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT), tmp, MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT), tmp, 400, 0);
400, 0);
printf ("RegQueryInfoKey: %s\n", tmp); printf ("RegQueryInfoKey: %s\n", tmp);
#endif #endif
return; return;
@ -574,16 +598,6 @@ scan_registry (RegInfo * prev, HKEY hKey, char *name, int cygnus)
break; break;
} }
} }
#if 0
else
{
char tmp[400];
FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM, 0, GetLastError (),
MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT), tmp,
400, 0);
printf ("RegEnumValue: %s\n", tmp);
}
#endif
} }
free (value_name); free (value_name);
free (value_data); free (value_data);
@ -592,7 +606,8 @@ scan_registry (RegInfo * prev, HKEY hKey, char *name, int cygnus)
char *subkey_name = (char *) malloc (max_subkey_len + 1); char *subkey_name = (char *) malloc (max_subkey_len + 1);
for (i = 0; i < num_subkeys; i++) for (i = 0; i < num_subkeys; i++)
{ {
if (RegEnumKey (hKey, i, subkey_name, max_subkey_len + 1) == ERROR_SUCCESS) if (RegEnumKey (hKey, i, subkey_name, max_subkey_len + 1) ==
ERROR_SUCCESS)
{ {
HKEY sKey; HKEY sKey;
if (RegOpenKeyEx (hKey, subkey_name, 0, KEY_ALL_ACCESS, &sKey) if (RegOpenKeyEx (hKey, subkey_name, 0, KEY_ALL_ACCESS, &sKey)
@ -746,11 +761,12 @@ dump_sysinfo ()
printf ("Listing available drives...\n"); printf ("Listing available drives...\n");
printf ("Drv Type Size Free Flags Name\n"); printf ("Drv Type Size Free Flags Name\n");
} }
int prev_mode = SetErrorMode (SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX); int prev_mode =
SetErrorMode (SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX);
int drivemask = GetLogicalDrives (); int drivemask = GetLogicalDrives ();
HINSTANCE k32 = LoadLibrary ("kernel32.dll"); HINSTANCE k32 = LoadLibrary ("kernel32.dll");
BOOL (WINAPI *gdfse) (LPCSTR, long long *, long long *, long long *) = BOOL (WINAPI * gdfse) (LPCSTR, long long *, long long *, long long *) =
(BOOL (WINAPI *) (LPCSTR, long long *, long long *, long long *)) (BOOL (WINAPI *) (LPCSTR, long long *, long long *, long long *))
GetProcAddress (k32, "GetDiskFreeSpaceExA"); GetProcAddress (k32, "GetDiskFreeSpaceExA");
@ -790,8 +806,7 @@ dump_sysinfo ()
int percent_full = -1; int percent_full = -1;
long long free_me = 0ULL, free_bytes = 0ULL, total_bytes = 1ULL; long long free_me = 0ULL, free_bytes = 0ULL, total_bytes = 1ULL;
if (gdfse != NULL if (gdfse != NULL && gdfse (drive, &free_me, &total_bytes, &free_bytes))
&& gdfse (drive, & free_me, & total_bytes, & free_bytes))
{ {
capacity_mb = total_bytes / (1024L * 1024L); capacity_mb = total_bytes / (1024L * 1024L);
percent_full = 100 - (int) ((100.0 * free_me) / total_bytes); percent_full = 100 - (int) ((100.0 * free_me) / total_bytes);
@ -834,7 +849,8 @@ dump_sysinfo ()
{ {
printf ("fd=floppy, hd=hard drive, cd=CD-ROM, net=Network Share\n"); printf ("fd=floppy, hd=hard drive, cd=CD-ROM, net=Network Share\n");
printf ("CP=Case Preserving, CS=Case Sensitive, UN=Unicode\n"); printf ("CP=Case Preserving, CS=Case Sensitive, UN=Unicode\n");
printf ("PA=Persistent ACLS, FC=File Compression, VC=Volume Compression\n"); printf
("PA=Persistent ACLS, FC=File Compression, VC=Volume Compression\n");
} }
printf ("\n"); printf ("\n");
@ -842,10 +858,9 @@ dump_sysinfo ()
if (givehelp) if (givehelp)
{ {
printf ("Mount entries: these map POSIX directories to your NT drives.\n"); printf
printf ("%-*s %-*s %-*s %s\n", ("Mount entries: these map POSIX directories to your NT drives.\n");
ml_fsname, "-NT-", printf ("%-*s %-*s %-*s %s\n", ml_fsname, "-NT-", ml_dir, "-POSIX-",
ml_dir, "-POSIX-",
ml_type, "-Type-", "-Flags-"); ml_type, "-Type-", "-Flags-");
} }
@ -856,16 +871,15 @@ dump_sysinfo ()
{ {
printf ("%-*s %-*s %-*s %s\n", printf ("%-*s %-*s %-*s %s\n",
ml_fsname, mnt->mnt_fsname, ml_fsname, mnt->mnt_fsname,
ml_dir, mnt->mnt_dir, ml_dir, mnt->mnt_dir, ml_type, mnt->mnt_type, mnt->mnt_opts);
ml_type, mnt->mnt_type,
mnt->mnt_opts);
} }
printf ("\n"); printf ("\n");
add_path ((char *) "\\bin", 4); /* just in case */ add_path ((char *) "\\bin", 4); /* just in case */
if (givehelp) if (givehelp)
printf ("Looking to see where common programs can be found, if at all...\n"); printf
("Looking to see where common programs can be found, if at all...\n");
for (i = 0; common_apps[i].name; i++) for (i = 0; common_apps[i].name; i++)
if (!find_on_path ((char *) common_apps[i].name, (char *) ".exe", 1, 0)) if (!find_on_path ((char *) common_apps[i].name, (char *) ".exe", 1, 0))
{ {
@ -999,26 +1013,30 @@ check_keys ()
CloseHandle (h); CloseHandle (h);
return 0; return 0;
} }
void void
usage () usage ()
{ {
fprintf (stderr, "Usage: cygcheck [OPTIONS] [program ...]\n"); fprintf (stderr, "Usage: cygcheck [OPTIONS] [program ...]\n");
fprintf (stderr, " -s, --sysinfo = system information (not with -k)\n"); fprintf (stderr, " -s, --sysinfo = system information (not with -k)\n");
fprintf (stderr, " -v, --verbose = verbose output (indented) (for -s or programs)\n"); fprintf (stderr,
" -v, --verbose = verbose output (indented) (for -s or programs)\n");
fprintf (stderr, " -r, --registry = registry search (requires -s)\n"); fprintf (stderr, " -r, --registry = registry search (requires -s)\n");
fprintf (stderr, " -k, --keycheck = perform a keyboard check session (not with -s)\n"); fprintf (stderr,
" -k, --keycheck = perform a keyboard check session (not with -s)\n");
fprintf (stderr, " -h, --help = give help about the info\n"); fprintf (stderr, " -h, --help = give help about the info\n");
fprintf (stderr, "You must at least give either -s or -k or a program name\n"); fprintf (stderr,
"You must at least give either -s or -k or a program name\n");
exit (1); exit (1);
} }
struct option longopts[] = { struct option longopts[] = {
{ "sysinfo", no_argument, NULL, 's' }, {"sysinfo", no_argument, NULL, 's'},
{ "registry", no_argument, NULL, 'r' }, {"registry", no_argument, NULL, 'r'},
{ "verbose", no_argument, NULL, 'v' }, {"verbose", no_argument, NULL, 'v'},
{ "keycheck", no_argument, NULL, 'k' }, {"keycheck", no_argument, NULL, 'k'},
{ "help", no_argument, NULL, 'h' }, {"help", no_argument, NULL, 'h'},
{ 0, no_argument, NULL, 0 } {0, no_argument, NULL, 0}
}; };
char *opts = "srvkh"; char *opts = "srvkh";
@ -1047,8 +1065,7 @@ main (int argc, char **argv)
break; break;
default: default:
usage (); usage ();
/*NOTREACHED*/ /*NOTREACHED*/}
}
argc -= optind; argc -= optind;
argv += optind; argv += optind;
@ -1059,7 +1076,7 @@ main (int argc, char **argv)
usage (); usage ();
if (keycheck) if (keycheck)
return check_keys(); return check_keys ();
init_paths (); init_paths ();
@ -1067,12 +1084,14 @@ main (int argc, char **argv)
{ {
if (argc == 1) if (argc == 1)
{ {
printf ("Here is where the OS will find your program, and which dlls\n"); printf
("Here is where the OS will find your program, and which dlls\n");
printf ("will be used for it. Use -v to see DLL version info\n"); printf ("will be used for it. Use -v to see DLL version info\n");
} }
else else
{ {
printf ("Here is where the OS will find your programs, and which dlls\n"); printf
("Here is where the OS will find your programs, and which dlls\n");
printf ("will be used for them. Use -v to see DLL version info\n"); printf ("will be used for them. Use -v to see DLL version info\n");
} }

@ -4,11 +4,11 @@
Written by Egor Duda <deo@logos-m.ru> Written by Egor Duda <deo@logos-m.ru>
This file is part of Cygwin. This file is part of Cygwin.
This software is a copyrighted work licensed under the terms of the This software is a copyrighted work licensed under the terms of the
Cygwin license. Please consult the file "CYGWIN_LICENSE" for Cygwin license. Please consult the file "CYGWIN_LICENSE" for
details. */ details. */
#include <bfd.h> #include <bfd.h>
#include <elf/common.h> #include <elf/common.h>
@ -27,35 +27,36 @@ details. */
#define NOTE_NAME_SIZE 16 #define NOTE_NAME_SIZE 16
typedef struct _note_header typedef struct _note_header
{ {
Elf_External_Note elf_note_header; Elf_External_Note elf_note_header;
char name [ NOTE_NAME_SIZE - 1 ]; /* external note contains first byte of data */ char name[NOTE_NAME_SIZE - 1]; /* external note contains first byte of data */
} }
#ifdef __GNUC__ #ifdef __GNUC__
__attribute__ ((packed)) __attribute__ ((packed))
#endif #endif
note_header ; note_header;
BOOL verbose = FALSE; BOOL verbose = FALSE;
int deb_printf ( const char* format, ... ) int deb_printf (const char *format,...)
{ {
if ( !verbose ) return 0; if (!verbose)
return 0;
va_list va; va_list va;
va_start ( va, format ); va_start (va, format);
int ret_val = vprintf ( format, va ); int ret_val = vprintf (format, va);
va_end ( va ); va_end (va);
return ret_val; return ret_val;
} }
dumper::dumper ( DWORD pid, DWORD tid, const char* file_name ) dumper::dumper (DWORD pid, DWORD tid, const char *file_name)
{ {
this->file_name = strdup ( file_name ); this->file_name = strdup (file_name);
this->pid = pid; this->pid = pid;
this->tid = tid; this->tid = tid;
core_bfd = NULL; core_bfd = NULL;
excl_list = new exclusion ( 20 ); excl_list = new exclusion (20);
list = last = NULL; list = last = NULL;
@ -63,39 +64,43 @@ dumper::dumper ( DWORD pid, DWORD tid, const char* file_name )
memory_num = module_num = thread_num = 0; memory_num = module_num = thread_num = 0;
hProcess = OpenProcess ( PROCESS_ALL_ACCESS, hProcess = OpenProcess (PROCESS_ALL_ACCESS,
FALSE, /* no inheritance */ FALSE, /* no inheritance */
pid ); pid);
if ( !hProcess ) if (!hProcess)
{ {
fprintf ( stderr, "Failed to open process #%lu\n", pid ); fprintf (stderr, "Failed to open process #%lu\n", pid);
return; return;
} }
init_core_dump (); init_core_dump ();
if ( ! sane () ) dumper_abort (); if (!sane ())
dumper_abort ();
} }
dumper::~dumper () dumper: :~dumper ()
{ {
close (); close ();
free ( file_name ); free (file_name);
} }
void void
dumper::dumper_abort () dumper::dumper_abort ()
{ {
close (); close ();
unlink ( file_name ); unlink (file_name);
} }
void void
dumper::close () dumper::close ()
{ {
if ( core_bfd ) bfd_close ( core_bfd ); if (core_bfd)
if ( excl_list ) delete excl_list; bfd_close (core_bfd);
if ( hProcess ) CloseHandle ( hProcess ); if (excl_list)
delete excl_list;
if (hProcess)
CloseHandle (hProcess);
core_bfd = NULL; core_bfd = NULL;
hProcess = NULL; hProcess = NULL;
excl_list = NULL; excl_list = NULL;
@ -104,20 +109,23 @@ dumper::close ()
int int
dumper::sane () dumper::sane ()
{ {
if ( hProcess == NULL || core_bfd == NULL || excl_list == NULL ) return 0; if (hProcess == NULL || core_bfd == NULL || excl_list == NULL)
return 0;
return 1; return 1;
} }
process_entity* process_entity *
dumper::add_process_entity_to_list ( process_entity_type type ) dumper::add_process_entity_to_list (process_entity_type type)
{ {
if ( ! sane () ) return NULL; if (!sane ())
return NULL;
process_entity* new_entity = ( process_entity* ) malloc ( sizeof ( process_entity ) ); process_entity *new_entity = (process_entity *) malloc (sizeof (process_entity));
if ( new_entity == NULL ) return NULL; if (new_entity == NULL)
return NULL;
new_entity->next = NULL; new_entity->next = NULL;
new_entity->section = NULL; new_entity->section = NULL;
if ( last == NULL ) if (last == NULL)
list = new_entity; list = new_entity;
else else
last->next = new_entity; last->next = new_entity;
@ -126,101 +134,111 @@ dumper::add_process_entity_to_list ( process_entity_type type )
} }
int int
dumper::add_thread ( DWORD tid, HANDLE hThread ) dumper::add_thread (DWORD tid, HANDLE hThread)
{ {
if ( ! sane () ) return 0 ; if (!sane ())
return 0;
CONTEXT* pcontext; CONTEXT *pcontext;
process_entity* new_entity = add_process_entity_to_list ( pr_ent_thread ); process_entity *new_entity = add_process_entity_to_list (pr_ent_thread);
if ( new_entity == NULL ) return 0; if (new_entity == NULL)
return 0;
new_entity->type = pr_ent_thread; new_entity->type = pr_ent_thread;
thread_num++; thread_num++;
new_entity->u.thread.tid = tid; new_entity->u.thread.tid = tid;
new_entity->u.thread.hThread = hThread; new_entity->u.thread.hThread = hThread;
pcontext = &( new_entity->u.thread.context ); pcontext = &(new_entity->u.thread.context);
pcontext->ContextFlags = CONTEXT_FULL | CONTEXT_FLOATING_POINT; pcontext->ContextFlags = CONTEXT_FULL | CONTEXT_FLOATING_POINT;
if ( ! GetThreadContext ( hThread, pcontext ) ) return 0; if (!GetThreadContext (hThread, pcontext))
return 0;
deb_printf ( "added thread %u\n", tid ); deb_printf ("added thread %u\n", tid);
return 1; return 1;
} }
int int
dumper::add_mem_region ( LPBYTE base, DWORD size ) dumper::add_mem_region (LPBYTE base, DWORD size)
{ {
if ( ! sane () ) return 0; if (!sane ())
return 0;
if ( base == NULL || size == 0 ) return 1; // just ignore empty regions if (base == NULL || size == 0)
return 1; // just ignore empty regions
process_entity* new_entity = add_process_entity_to_list ( pr_ent_memory ); process_entity *new_entity = add_process_entity_to_list (pr_ent_memory);
if ( new_entity == NULL ) return 0; if (new_entity == NULL)
return 0;
new_entity->type = pr_ent_memory; new_entity->type = pr_ent_memory;
memory_num++; memory_num++;
new_entity->u.memory.base = base; new_entity->u.memory.base = base;
new_entity->u.memory.size = size; new_entity->u.memory.size = size;
deb_printf ( "added memory region %08x-%08x\n", (DWORD)base, (DWORD)base + size ); deb_printf ("added memory region %08x-%08x\n", (DWORD) base, (DWORD) base + size);
return 1; return 1;
} }
/* /* split_add_mem_region scans list of regions to be excluded from dumping process
* split_add_mem_region scans list of regions to be excluded from dumping process (excl_list) and removes all "excluded" parts from given region. */
* (excl_list) and removes all "excluded" parts from given region
*/
int int
dumper::split_add_mem_region ( LPBYTE base, DWORD size ) dumper::split_add_mem_region (LPBYTE base, DWORD size)
{ {
if ( ! sane () ) return 0; if (!sane ())
return 0;
if ( base == NULL || size == 0 ) return 1; // just ignore empty regions if (base == NULL || size == 0)
return 1; // just ignore empty regions
LPBYTE last_base = base; LPBYTE last_base = base;
for ( process_mem_region* p = excl_list->region; for (process_mem_region * p = excl_list->region;
p < excl_list->region + excl_list->last; p < excl_list->region + excl_list->last;
p++ ) p++)
{ {
if ( p->base >= base + size || p->base + p->size <= base ) continue; if (p->base >= base + size || p->base + p->size <= base)
continue;
if ( p->base <= base ) if (p->base <= base)
{ {
last_base = p->base + p->size; last_base = p->base + p->size;
continue ; continue;
} }
add_mem_region ( last_base, p->base - last_base ); add_mem_region (last_base, p->base - last_base);
last_base = p->base + p->size; last_base = p->base + p->size;
} }
if ( last_base < base + size ) if (last_base < base + size)
add_mem_region ( last_base, base + size - last_base ); add_mem_region (last_base, base + size - last_base);
return 1; return 1;
} }
int int
dumper::add_module ( LPVOID base_address ) dumper::add_module (LPVOID base_address)
{ {
if ( ! sane () ) return 0; if (!sane ())
return 0;
char* module_name = psapi_get_module_name ( hProcess, (DWORD) base_address ); char *module_name = psapi_get_module_name (hProcess, (DWORD) base_address);
if ( module_name == NULL ) return 1; if (module_name == NULL)
return 1;
process_entity* new_entity = add_process_entity_to_list ( pr_ent_module ); process_entity *new_entity = add_process_entity_to_list (pr_ent_module);
if ( new_entity == NULL ) return 0; if (new_entity == NULL)
return 0;
new_entity->type = pr_ent_module; new_entity->type = pr_ent_module;
module_num++; module_num++;
new_entity->u.module.base_address = base_address; new_entity->u.module.base_address = base_address;
new_entity->u.module.name = module_name; new_entity->u.module.name = module_name;
parse_pe ( module_name, excl_list ); parse_pe (module_name, excl_list);
deb_printf ( "added module %08x %s\n", base_address, module_name ); deb_printf ("added module %08x %s\n", base_address, module_name);
return 1; return 1;
} }
@ -229,73 +247,77 @@ dumper::add_module ( LPVOID base_address )
int int
dumper::collect_memory_sections () dumper::collect_memory_sections ()
{ {
if ( ! sane () ) return 0; if (!sane ())
return 0;
LPBYTE current_page_address; LPBYTE current_page_address;
LPBYTE last_base = (LPBYTE) 0xFFFFFFFF; LPBYTE last_base = (LPBYTE) 0xFFFFFFFF;
DWORD last_size = 0; DWORD last_size = 0;
DWORD done; DWORD done;
char mem_buf [ PAGE_BUFFER_SIZE ]; char mem_buf[PAGE_BUFFER_SIZE];
MEMORY_BASIC_INFORMATION mbi; MEMORY_BASIC_INFORMATION mbi;
if ( hProcess == NULL ) return 0; if (hProcess == NULL)
return 0;
for ( current_page_address = 0; current_page_address < (LPBYTE) 0xFFFF0000; ) for (current_page_address = 0; current_page_address < (LPBYTE) 0xFFFF0000;)
{ {
if ( ! VirtualQueryEx ( hProcess, current_page_address, &mbi, sizeof ( mbi ) ) ) if (!VirtualQueryEx (hProcess, current_page_address, &mbi, sizeof (mbi)))
break ; break;
int skip_region_p = 0; int skip_region_p = 0;
if ( mbi.Protect & ( PAGE_NOACCESS | PAGE_GUARD ) || if (mbi.Protect & (PAGE_NOACCESS | PAGE_GUARD) ||
mbi.State != MEM_COMMIT ) skip_region_p = 1; mbi.State != MEM_COMMIT)
skip_region_p = 1;
if ( ! skip_region_p ) if (!skip_region_p)
{ {
/* just to make sure that later we'll be able to read it. /* just to make sure that later we'll be able to read it.
According to MS docs either region is all-readable or According to MS docs either region is all-readable or
all-nonreadable */ all-nonreadable */
if ( ! ReadProcessMemory ( hProcess, current_page_address, mem_buf, sizeof ( mem_buf ), &done ) ) if (!ReadProcessMemory (hProcess, current_page_address, mem_buf, sizeof (mem_buf), &done))
{ {
const char* pt[10] ; const char *pt[10];
pt[0] = ( mbi.Protect & PAGE_READONLY ) ? "RO " : ""; pt[0] = (mbi.Protect & PAGE_READONLY) ? "RO " : "";
pt[1] = ( mbi.Protect & PAGE_READWRITE ) ? "RW " : ""; pt[1] = (mbi.Protect & PAGE_READWRITE) ? "RW " : "";
pt[2] = ( mbi.Protect & PAGE_WRITECOPY ) ? "WC " : ""; pt[2] = (mbi.Protect & PAGE_WRITECOPY) ? "WC " : "";
pt[3] = ( mbi.Protect & PAGE_EXECUTE ) ? "EX " : ""; pt[3] = (mbi.Protect & PAGE_EXECUTE) ? "EX " : "";
pt[4] = ( mbi.Protect & PAGE_EXECUTE_READ ) ? "EXRO " : ""; pt[4] = (mbi.Protect & PAGE_EXECUTE_READ) ? "EXRO " : "";
pt[5] = ( mbi.Protect & PAGE_EXECUTE_READWRITE ) ? "EXRW " : ""; pt[5] = (mbi.Protect & PAGE_EXECUTE_READWRITE) ? "EXRW " : "";
pt[6] = ( mbi.Protect & PAGE_EXECUTE_WRITECOPY ) ? "EXWC " : ""; pt[6] = (mbi.Protect & PAGE_EXECUTE_WRITECOPY) ? "EXWC " : "";
pt[7] = ( mbi.Protect & PAGE_GUARD ) ? "GRD " : ""; pt[7] = (mbi.Protect & PAGE_GUARD) ? "GRD " : "";
pt[8] = ( mbi.Protect & PAGE_NOACCESS ) ? "NA " : ""; pt[8] = (mbi.Protect & PAGE_NOACCESS) ? "NA " : "";
pt[9] = ( mbi.Protect & PAGE_NOCACHE ) ? "NC " : ""; pt[9] = (mbi.Protect & PAGE_NOCACHE) ? "NC " : "";
char buf [ 10*6 ] ; char buf[10 * 6];
buf [ 0 ] = '\0'; buf[0] = '\0';
for ( int i = 0 ; i < 10 ; i++ ) strcat ( buf, pt[i] ); 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\n",
(DWORD)current_page_address, (DWORD) current_page_address,
(DWORD)current_page_address + mbi.RegionSize, (DWORD) current_page_address + mbi.RegionSize,
buf ); buf);
skip_region_p = 1; skip_region_p = 1;
} }
} }
if ( ! skip_region_p ) if (!skip_region_p)
{ {
if ( last_base + last_size == current_page_address ) if (last_base + last_size == current_page_address)
last_size += mbi.RegionSize; last_size += mbi.RegionSize;
else else
{ {
split_add_mem_region ( last_base, last_size ); split_add_mem_region (last_base, last_size);
last_base = (LPBYTE) mbi.BaseAddress; last_base = (LPBYTE) mbi.BaseAddress;
last_size = mbi.RegionSize; last_size = mbi.RegionSize;
} }
} }
else else
{ {
split_add_mem_region ( last_base, last_size ); split_add_mem_region (last_base, last_size);
last_base = NULL; last_base = NULL;
last_size = 0; last_size = 0;
} }
@ -304,14 +326,15 @@ dumper::collect_memory_sections ()
} }
/* dump last sections, if any */ /* dump last sections, if any */
split_add_mem_region ( last_base, last_size ); split_add_mem_region (last_base, last_size);
return 1; return 1;
}; };
int int
dumper::dump_memory_region ( asection* to, process_mem_region* memory ) dumper::dump_memory_region (asection * to, process_mem_region * memory)
{ {
if ( ! sane () ) return 0; if (!sane ())
return 0;
DWORD size = memory->size; DWORD size = memory->size;
DWORD todo; DWORD todo;
@ -319,126 +342,132 @@ dumper::dump_memory_region ( asection* to, process_mem_region* memory )
LPBYTE pos = memory->base; LPBYTE pos = memory->base;
DWORD sect_pos = 0; DWORD sect_pos = 0;
if ( to == NULL || memory == NULL ) return 0; if (to == NULL || memory == NULL)
return 0;
char mem_buf [ PAGE_BUFFER_SIZE ]; char mem_buf[PAGE_BUFFER_SIZE];
while ( size > 0 ) while (size > 0)
{ {
todo = min ( size, PAGE_BUFFER_SIZE ); todo = min (size, PAGE_BUFFER_SIZE);
if ( ! ReadProcessMemory ( hProcess, pos, mem_buf, todo, &done ) ) if (!ReadProcessMemory (hProcess, pos, mem_buf, todo, &done))
{ {
deb_printf ( "Error reading process memory at %x(%x) %u\n", pos, todo, GetLastError () ); deb_printf ("Error reading process memory at %x(%x) %u\n", pos, todo, GetLastError ());
return 0; return 0;
} }
size -= done; size -= done;
pos += done; pos += done;
if ( ! bfd_set_section_contents ( core_bfd, to, mem_buf, sect_pos, done ) ) if (!bfd_set_section_contents (core_bfd, to, mem_buf, sect_pos, done))
{ {
bfd_perror ( "writing memory region to bfd" ); bfd_perror ("writing memory region to bfd");
dumper_abort (); dumper_abort ();
return 0; return 0;
} ; };
sect_pos += done; sect_pos += done;
} }
return 1; return 1;
} }
int int
dumper::dump_thread ( asection* to, process_thread* thread ) dumper::dump_thread (asection * to, process_thread * thread)
{ {
if ( ! sane () ) return 0; if (!sane ())
return 0;
if ( to == NULL || thread == NULL ) return 0; if (to == NULL || thread == NULL)
return 0;
win32_pstatus thread_pstatus; win32_pstatus thread_pstatus;
note_header header; note_header header;
bfd_putl32 ( NOTE_NAME_SIZE, header.elf_note_header.namesz ); bfd_putl32 (NOTE_NAME_SIZE, header.elf_note_header.namesz);
bfd_putl32 ( sizeof ( thread_pstatus ), header.elf_note_header.descsz ); bfd_putl32 (sizeof (thread_pstatus), header.elf_note_header.descsz);
bfd_putl32 ( NT_WIN32PSTATUS, header.elf_note_header.type ); bfd_putl32 (NT_WIN32PSTATUS, header.elf_note_header.type);
strncpy ( (char*) & header.elf_note_header.name, "win32thread", NOTE_NAME_SIZE ); strncpy ((char *) &header.elf_note_header.name, "win32thread", NOTE_NAME_SIZE);
thread_pstatus.data_type = NOTE_INFO_THREAD; thread_pstatus.data_type = NOTE_INFO_THREAD;
thread_pstatus.data.thread_info.tid = thread->tid; thread_pstatus.data.thread_info.tid = thread->tid;
if ( tid == 0 ) if (tid == 0)
{ {
/* this is a special case. we don't know, which thread /* this is a special case. we don't know, which thread
was active when exception occured, so let's blame was active when exception occured, so let's blame
the first one */ the first one */
thread_pstatus.data.thread_info.is_active_thread = TRUE ; thread_pstatus.data.thread_info.is_active_thread = TRUE;
tid = (DWORD) -1 ; tid = (DWORD) - 1;
} }
else if ( tid > 0 && thread->tid == tid ) else if (tid > 0 && thread->tid == tid)
thread_pstatus.data.thread_info.is_active_thread = TRUE; thread_pstatus.data.thread_info.is_active_thread = TRUE;
else else
thread_pstatus.data.thread_info.is_active_thread = FALSE; thread_pstatus.data.thread_info.is_active_thread = FALSE;
memcpy ( &(thread_pstatus.data.thread_info.thread_context), memcpy (&(thread_pstatus.data.thread_info.thread_context),
&(thread->context), &(thread->context),
sizeof ( thread->context ) ); sizeof (thread->context));
if ( ! bfd_set_section_contents ( core_bfd, to, &header, if (!bfd_set_section_contents (core_bfd, to, &header,
0, 0,
sizeof ( header ) ) || sizeof (header)) ||
! bfd_set_section_contents ( core_bfd, to, &thread_pstatus, !bfd_set_section_contents (core_bfd, to, &thread_pstatus,
sizeof ( header ), sizeof (header),
sizeof ( thread_pstatus ) ) ) sizeof (thread_pstatus)))
{ {
bfd_perror ( "writing thread info to bfd" ); bfd_perror ("writing thread info to bfd");
dumper_abort (); dumper_abort ();
return 0; return 0;
} ; };
return 1; return 1;
} }
int int
dumper::dump_module ( asection* to, process_module* module ) dumper::dump_module (asection * to, process_module * module)
{ {
if ( ! sane () ) return 0; if (!sane ())
return 0;
if ( to == NULL || module == NULL ) return 0; if (to == NULL || module == NULL)
return 0;
struct win32_pstatus* module_pstatus_ptr; struct win32_pstatus *module_pstatus_ptr;
int note_length = sizeof ( struct win32_pstatus ) + strlen ( module->name ); int note_length = sizeof (struct win32_pstatus) + strlen (module->name);
char* buf = (char*) malloc ( note_length ); char *buf = (char *) malloc (note_length);
if ( ! buf ) if (!buf)
{ {
fprintf ( stderr, "Error alloating memory. Dumping aborted.\n" ); fprintf (stderr, "Error alloating memory. Dumping aborted.\n");
goto out; goto out;
} ; };
module_pstatus_ptr = (struct win32_pstatus*) buf; module_pstatus_ptr = (struct win32_pstatus *) buf;
note_header header; note_header header;
bfd_putl32 ( NOTE_NAME_SIZE, header.elf_note_header.namesz ); bfd_putl32 (NOTE_NAME_SIZE, header.elf_note_header.namesz);
bfd_putl32 ( note_length, header.elf_note_header.descsz ); bfd_putl32 (note_length, header.elf_note_header.descsz);
bfd_putl32 ( NT_WIN32PSTATUS, header.elf_note_header.type ); bfd_putl32 (NT_WIN32PSTATUS, header.elf_note_header.type);
strncpy ( (char*) & header.elf_note_header.name, "win32module", NOTE_NAME_SIZE ); strncpy ((char *) &header.elf_note_header.name, "win32module", NOTE_NAME_SIZE);
module_pstatus_ptr->data_type = NOTE_INFO_MODULE; module_pstatus_ptr->data_type = NOTE_INFO_MODULE;
module_pstatus_ptr->data.module_info.base_address = module->base_address; module_pstatus_ptr->data.module_info.base_address = module->base_address;
module_pstatus_ptr->data.module_info.module_name_size = strlen ( module->name ) + 1; module_pstatus_ptr->data.module_info.module_name_size = strlen (module->name) + 1;
strcpy ( module_pstatus_ptr->data.module_info.module_name, module->name ); strcpy (module_pstatus_ptr->data.module_info.module_name, module->name);
if ( ! bfd_set_section_contents ( core_bfd, to, &header, if (!bfd_set_section_contents (core_bfd, to, &header,
0, 0,
sizeof ( header ) ) || sizeof (header)) ||
! bfd_set_section_contents ( core_bfd, to, module_pstatus_ptr, !bfd_set_section_contents (core_bfd, to, module_pstatus_ptr,
sizeof ( header ), sizeof (header),
note_length ) ) note_length))
{ {
bfd_perror ( "writing module info to bfd" ); bfd_perror ("writing module info to bfd");
goto out; goto out;
}; };
return 1; return 1;
out: out:
if ( buf ) free ( buf ); if (buf)
free (buf);
dumper_abort (); dumper_abort ();
return 0; return 0;
@ -447,49 +476,51 @@ out:
int int
dumper::collect_process_information () dumper::collect_process_information ()
{ {
if ( ! sane () ) return 0; if (!sane ())
return 0;
if ( ! DebugActiveProcess ( pid ) ) if (!DebugActiveProcess (pid))
{ {
fprintf ( stderr, "Cannot attach to process #%lu", pid ); fprintf (stderr, "Cannot attach to process #%lu", pid);
return 0; return 0;
} }
char event_name [ sizeof ( "cygwin_error_start_event" ) + 20 ]; 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%16lx", pid);
HANDLE sync_with_debugee = OpenEvent ( EVENT_MODIFY_STATE, FALSE, event_name ); HANDLE sync_with_debugee = OpenEvent (EVENT_MODIFY_STATE, FALSE, event_name);
DEBUG_EVENT current_event; DEBUG_EVENT current_event;
while (1) while (1)
{ {
if ( ! WaitForDebugEvent ( &current_event, 20000 ) ) return 0; if (!WaitForDebugEvent (&current_event, 20000))
return 0;
switch (current_event.dwDebugEventCode) switch (current_event.dwDebugEventCode)
{ {
case CREATE_THREAD_DEBUG_EVENT: case CREATE_THREAD_DEBUG_EVENT:
if ( ! add_thread ( current_event.dwThreadId, if (!add_thread (current_event.dwThreadId,
current_event.u.CreateThread.hThread ) ) current_event.u.CreateThread.hThread))
goto failed; goto failed;
break; break;
case CREATE_PROCESS_DEBUG_EVENT: case CREATE_PROCESS_DEBUG_EVENT:
if ( ! add_module ( current_event.u.CreateProcessInfo.lpBaseOfImage ) || if (!add_module (current_event.u.CreateProcessInfo.lpBaseOfImage) ||
! add_thread ( current_event.dwThreadId, !add_thread (current_event.dwThreadId,
current_event.u.CreateProcessInfo.hThread ) ) current_event.u.CreateProcessInfo.hThread))
goto failed; goto failed;
break; break;
case EXIT_PROCESS_DEBUG_EVENT: case EXIT_PROCESS_DEBUG_EVENT:
deb_printf ( "debugee quits" ); deb_printf ("debugee quits");
ContinueDebugEvent ( current_event.dwProcessId, ContinueDebugEvent (current_event.dwProcessId,
current_event.dwThreadId, current_event.dwThreadId,
DBG_CONTINUE ); DBG_CONTINUE);
return 1; return 1;
@ -497,7 +528,7 @@ dumper::collect_process_information ()
case LOAD_DLL_DEBUG_EVENT: case LOAD_DLL_DEBUG_EVENT:
if ( ! add_module ( current_event.u.LoadDll.lpBaseOfDll ) ) if (!add_module (current_event.u.LoadDll.lpBaseOfDll))
goto failed; goto failed;
break; break;
@ -508,20 +539,21 @@ dumper::collect_process_information ()
/* got all info. time to dump */ /* got all info. time to dump */
if ( ! prepare_core_dump () ) if (!prepare_core_dump ())
{ {
fprintf ( stderr, "Failed to prepare core dump\n" ); fprintf (stderr, "Failed to prepare core dump\n");
goto failed; goto failed;
}; };
if ( ! write_core_dump () ) if (!write_core_dump ())
{ {
fprintf ( stderr, "Failed to write core dump\n" ); fprintf (stderr, "Failed to write core dump\n");
goto failed; goto failed;
}; };
/* signal a debugee that we've finished */ /* signal a debugee that we've finished */
if ( sync_with_debugee ) SetEvent ( sync_with_debugee ); if (sync_with_debugee)
SetEvent (sync_with_debugee);
break; break;
@ -531,13 +563,14 @@ dumper::collect_process_information ()
} }
ContinueDebugEvent ( current_event.dwProcessId, ContinueDebugEvent (current_event.dwProcessId,
current_event.dwThreadId, current_event.dwThreadId,
DBG_CONTINUE ); DBG_CONTINUE);
} }
failed: failed:
/* set debugee free */ /* set debugee free */
if ( sync_with_debugee ) SetEvent ( sync_with_debugee ); if (sync_with_debugee)
SetEvent (sync_with_debugee);
return 0; return 0;
} }
@ -547,16 +580,16 @@ dumper::init_core_dump ()
{ {
bfd_init (); bfd_init ();
core_bfd = bfd_openw ( file_name, "elf32-i386" ); core_bfd = bfd_openw (file_name, "elf32-i386");
if ( core_bfd == NULL ) if (core_bfd == NULL)
{ {
bfd_perror ( "opening bfd" ); bfd_perror ("opening bfd");
goto failed; goto failed;
} }
if ( ! bfd_set_format ( core_bfd, bfd_core ) ) if (!bfd_set_format (core_bfd, bfd_core))
{ {
bfd_perror ( "setting bfd format" ); bfd_perror ("setting bfd format");
goto failed; goto failed;
} }
@ -571,43 +604,44 @@ failed:
int int
dumper::prepare_core_dump () dumper::prepare_core_dump ()
{ {
if ( ! sane () ) return 0; if (!sane ())
return 0;
int sect_no = 0; int sect_no = 0;
char sect_name [ 50 ]; char sect_name[50];
flagword sect_flags; flagword sect_flags;
DWORD sect_size; DWORD sect_size;
bfd_vma sect_vma; bfd_vma sect_vma;
asection* new_section; asection *new_section;
for ( process_entity* p = list; p != NULL; p = p->next ) for (process_entity * p = list; p != NULL; p = p->next)
{ {
sect_no++; sect_no++;
switch ( p->type ) switch (p->type)
{ {
case pr_ent_memory: case pr_ent_memory:
sprintf ( sect_name, ".mem/%u", sect_no ); sprintf (sect_name, ".mem/%u", sect_no);
sect_flags = SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD; sect_flags = SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD;
sect_size = p->u.memory.size; sect_size = p->u.memory.size;
sect_vma = (bfd_vma)(p->u.memory.base); sect_vma = (bfd_vma) (p->u.memory.base);
break; break;
case pr_ent_thread: case pr_ent_thread:
sprintf ( sect_name, ".note/%u", sect_no ); sprintf (sect_name, ".note/%u", sect_no);
sect_flags = SEC_HAS_CONTENTS | SEC_LOAD; sect_flags = SEC_HAS_CONTENTS | SEC_LOAD;
sect_size = sizeof ( note_header ) + sizeof ( struct win32_pstatus ); sect_size = sizeof (note_header) + sizeof (struct win32_pstatus);
sect_vma = 0; sect_vma = 0;
break; break;
case pr_ent_module: case pr_ent_module:
sprintf ( sect_name, ".note/%u", sect_no ); sprintf (sect_name, ".note/%u", sect_no);
sect_flags = SEC_HAS_CONTENTS | SEC_LOAD; sect_flags = SEC_HAS_CONTENTS | SEC_LOAD;
sect_size = sizeof ( note_header ) + sizeof ( struct win32_pstatus ) + sect_size = sizeof (note_header) + sizeof (struct win32_pstatus) +
(bfd_size_type)( strlen (p->u.module.name) ); (bfd_size_type) (strlen (p->u.module.name));
sect_vma = 0; sect_vma = 0;
break; break;
@ -615,29 +649,29 @@ dumper::prepare_core_dump ()
continue; continue;
} }
if ( p->type == pr_ent_module && status_section != NULL ) if (p->type == pr_ent_module && status_section != NULL)
{ {
if ( ! bfd_set_section_size ( core_bfd, if (!bfd_set_section_size (core_bfd,
status_section, status_section,
status_section->_raw_size + sect_size ) ) status_section->_raw_size + sect_size))
{ {
bfd_perror ( "resizing status section" ); bfd_perror ("resizing status section");
goto failed; goto failed;
}; };
continue; continue;
} }
deb_printf ( "creating section (type%u) %s(%u), flags=%08x\n", deb_printf ("creating section (type%u) %s(%u), flags=%08x\n",
p->type, sect_name, sect_size, sect_flags ); p->type, sect_name, sect_size, sect_flags);
char* buf = strdup ( sect_name ); char *buf = strdup (sect_name);
new_section = bfd_make_section ( core_bfd, buf ); new_section = bfd_make_section (core_bfd, buf);
if ( new_section == NULL || if (new_section == NULL ||
! bfd_set_section_flags ( core_bfd, new_section, sect_flags ) || !bfd_set_section_flags (core_bfd, new_section, sect_flags) ||
! bfd_set_section_size ( core_bfd, new_section, sect_size ) ) !bfd_set_section_size (core_bfd, new_section, sect_size))
{ {
bfd_perror ( "creating section" ); bfd_perror ("creating section");
goto failed; goto failed;
}; };
@ -657,30 +691,32 @@ failed:
int int
dumper::write_core_dump () dumper::write_core_dump ()
{ {
if ( ! sane () ) return 0; if (!sane ())
return 0;
for ( process_entity* p = list; p != NULL; p = p->next ) for (process_entity * p = list; p != NULL; p = p->next)
{ {
if ( p->section == NULL ) continue; 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=%08x size=%08x flags=%08x\n",
p->type, p->type,
p->section->vma, p->section->vma,
p->section->_raw_size, p->section->_raw_size,
p->section->flags ); p->section->flags);
switch ( p->type ) switch (p->type)
{ {
case pr_ent_memory: case pr_ent_memory:
dump_memory_region ( p->section, &(p->u.memory) ); dump_memory_region (p->section, &(p->u.memory));
break; break;
case pr_ent_thread: case pr_ent_thread:
dump_thread ( p->section, &(p->u.thread) ); dump_thread (p->section, &(p->u.thread));
break; break;
case pr_ent_module: case pr_ent_module:
dump_module ( p->section, &(p->u.module) ); dump_module (p->section, &(p->u.module));
break; break;
default: default:
@ -694,17 +730,17 @@ dumper::write_core_dump ()
static void static void
usage () usage ()
{ {
fprintf ( stderr, "Usage: dumper [-v] [-c filename] pid\n" ); fprintf (stderr, "Usage: dumper [-v] [-c filename] pid\n");
fprintf ( stderr, "-c filename -- dump core to filename.core\n" ); fprintf (stderr, "-c filename -- dump core to filename.core\n");
fprintf ( stderr, "-d -- print some debugging info while dumping\n" ); fprintf (stderr, "-d -- print some debugging info while dumping\n");
fprintf ( stderr, "pid -- win32-pid of process to dump\n" ); fprintf (stderr, "pid -- win32-pid of process to dump\n");
} }
int int
main( int argc, char** argv ) main (int argc, char **argv)
{ {
int opt; int opt;
char* p = ""; char *p = "";
DWORD pid; DWORD pid;
while ((opt = getopt (argc, argv, "dc:")) != EOF) while ((opt = getopt (argc, argv, "dc:")) != EOF)
@ -714,25 +750,25 @@ main( int argc, char** argv )
verbose = TRUE; verbose = TRUE;
break; break;
case 'c': case 'c':
char win32_name [ MAX_PATH ]; char win32_name[MAX_PATH];
cygwin_conv_to_win32_path ( optarg, win32_name ); cygwin_conv_to_win32_path (optarg, win32_name);
if ( ( p = strrchr ( win32_name, '\\' ) ) ) if ((p = strrchr (win32_name, '\\')))
p++; p++;
else else
p = win32_name; p = win32_name;
break; break;
} }
char* core_file = (char*) malloc ( strlen ( p ) + sizeof ( ".core" ) ); char *core_file = (char *) malloc (strlen (p) + sizeof (".core"));
if ( ! core_file ) if (!core_file)
{ {
fprintf ( stderr, "error allocating memory\n" ); fprintf (stderr, "error allocating memory\n");
return -1; return -1;
} }
sprintf ( core_file, "%s.core", p ); sprintf (core_file, "%s.core", p);
if ( argv && *(argv+optind) ) if (argv && *(argv + optind))
pid = atoi ( *(argv+optind) ); pid = atoi (*(argv + optind));
else else
{ {
usage (); usage ();
@ -741,14 +777,14 @@ main( int argc, char** argv )
DWORD tid = 0; DWORD tid = 0;
if ( verbose ) if (verbose)
printf ( "dumping process #%lu to %s\n", pid, core_file ); printf ("dumping process #%lu to %s\n", pid, core_file);
dumper d ( pid, tid, core_file ); dumper d (pid, tid, core_file);
if ( ! d.sane () ) if (!d.sane ())
return -1; return -1;
d.collect_process_information (); d.collect_process_information ();
free ( core_file ); free (core_file);
return 0; return 0;
}; };

@ -8,7 +8,8 @@
#include <sys/acl.h> #include <sys/acl.h>
#include <sys/stat.h> #include <sys/stat.h>
char *permstr (mode_t perm) char *
permstr (mode_t perm)
{ {
static char pbuf[4]; static char pbuf[4];
@ -20,7 +21,8 @@ char *permstr (mode_t perm)
} }
#if 0 #if 0
char *username (uid_t uid) char *
username (uid_t uid)
{ {
static char ubuf[256]; static char ubuf[256];
struct passwd *pw; struct passwd *pw;
@ -31,7 +33,8 @@ char *username (uid_t uid)
strcpy (ubuf, "<unknown>"); strcpy (ubuf, "<unknown>");
} }
char *groupname (gid_t gid) char *
groupname (gid_t gid)
{ {
static char gbuf[256]; static char gbuf[256];
struct group *gr; struct group *gr;
@ -74,7 +77,7 @@ main (int argc, char **argv)
perror (argv[0]); perror (argv[0]);
continue; continue;
} }
if (! first) if (!first)
putchar ('\n'); putchar ('\n');
first = 0; first = 0;
printf ("# file: %s\n", argv[c]); printf ("# file: %s\n", argv[c]);
@ -121,4 +124,3 @@ main (int argc, char **argv)
} }
return 0; return 0;
} }

@ -17,93 +17,95 @@ details. */
static int psapi_loaded = 0; static int psapi_loaded = 0;
static HMODULE psapi_module_handle = NULL; static HMODULE psapi_module_handle = NULL;
typedef BOOL WINAPI (tf_EnumProcessModules ) ( HANDLE, HMODULE*, DWORD, LPDWORD ); typedef BOOL WINAPI (tf_EnumProcessModules) (HANDLE, HMODULE *, DWORD,
typedef BOOL WINAPI (tf_GetModuleInformation) ( HANDLE, HMODULE, LPMODULEINFO, DWORD ); LPDWORD);
typedef DWORD WINAPI (tf_GetModuleFileNameExA) ( HANDLE, HMODULE, LPSTR, DWORD ); typedef BOOL WINAPI (tf_GetModuleInformation) (HANDLE, HMODULE, LPMODULEINFO,
DWORD);
typedef DWORD WINAPI (tf_GetModuleFileNameExA) (HANDLE, HMODULE, LPSTR,
DWORD);
static tf_EnumProcessModules *psapi_EnumProcessModules = NULL; static tf_EnumProcessModules *psapi_EnumProcessModules = NULL;
static tf_GetModuleInformation *psapi_GetModuleInformation = NULL; static tf_GetModuleInformation *psapi_GetModuleInformation = NULL;
static tf_GetModuleFileNameExA *psapi_GetModuleFileNameExA = NULL; static tf_GetModuleFileNameExA *psapi_GetModuleFileNameExA = NULL;
/* /* Returns full name of Dll, which is loaded by hProcess at BaseAddress.
* Returns full name of Dll, which is loaded by hProcess at BaseAddress Uses psapi.dll. */
* Uses psapi.dll
*/
char* char *
psapi_get_module_name ( HANDLE hProcess, DWORD BaseAddress ) psapi_get_module_name (HANDLE hProcess, DWORD BaseAddress)
{ {
DWORD len; DWORD len;
MODULEINFO mi; MODULEINFO mi;
unsigned int i; unsigned int i;
HMODULE dh_buf [ 1 ]; HMODULE dh_buf[1];
HMODULE* DllHandle = dh_buf; HMODULE *DllHandle = dh_buf;
DWORD cbNeeded; DWORD cbNeeded;
BOOL ok; BOOL ok;
char name_buf [ MAX_PATH + 1 ]; char name_buf[MAX_PATH + 1];
if ( !psapi_loaded || if (!psapi_loaded ||
psapi_EnumProcessModules == NULL || psapi_EnumProcessModules == NULL ||
psapi_GetModuleInformation == NULL || psapi_GetModuleInformation == NULL ||
psapi_GetModuleFileNameExA == NULL ) psapi_GetModuleFileNameExA == NULL)
{ {
if ( psapi_loaded ) goto failed; if (psapi_loaded)
goto failed;
psapi_loaded = 1; psapi_loaded = 1;
psapi_module_handle = LoadLibrary ( "psapi.dll" ); psapi_module_handle = LoadLibrary ("psapi.dll");
if ( ! psapi_module_handle ) if (!psapi_module_handle)
goto failed; goto failed;
psapi_EnumProcessModules = (tf_EnumProcessModules *) GetProcAddress ( psapi_module_handle, "EnumProcessModules" ); psapi_EnumProcessModules =
psapi_GetModuleInformation = (tf_GetModuleInformation *) GetProcAddress ( psapi_module_handle, "GetModuleInformation" ); (tf_EnumProcessModules *) GetProcAddress (psapi_module_handle,
psapi_GetModuleFileNameExA = (tf_GetModuleFileNameExA*) GetProcAddress ( psapi_module_handle, "GetModuleFileNameExA" ); "EnumProcessModules");
if ( psapi_EnumProcessModules == NULL || psapi_GetModuleInformation =
psapi_GetModuleInformation == NULL || (tf_GetModuleInformation *) GetProcAddress (psapi_module_handle,
psapi_GetModuleFileNameExA == NULL ) goto failed; "GetModuleInformation");
} psapi_GetModuleFileNameExA =
(tf_GetModuleFileNameExA *) GetProcAddress (psapi_module_handle,
ok = (*psapi_EnumProcessModules) ( hProcess, "GetModuleFileNameExA");
DllHandle, if (psapi_EnumProcessModules == NULL
sizeof ( HMODULE ), || psapi_GetModuleInformation == NULL
&cbNeeded ); || psapi_GetModuleFileNameExA == NULL)
if ( !ok || !cbNeeded ) goto failed;
DllHandle = (HMODULE*) malloc ( cbNeeded );
if ( ! DllHandle ) goto failed;
ok = (*psapi_EnumProcessModules) ( hProcess,
DllHandle,
cbNeeded,
&cbNeeded );
if ( ! ok )
{
free ( DllHandle );
goto failed; goto failed;
} }
for ( i = 0; i < cbNeeded / sizeof ( HMODULE ); i++ ) ok = (*psapi_EnumProcessModules) (hProcess,
DllHandle, sizeof (HMODULE), &cbNeeded);
if (!ok || !cbNeeded)
goto failed;
DllHandle = (HMODULE *) malloc (cbNeeded);
if (!DllHandle)
goto failed;
ok = (*psapi_EnumProcessModules) (hProcess, DllHandle, cbNeeded, &cbNeeded);
if (!ok)
{ {
if ( ! (*psapi_GetModuleInformation) ( hProcess, free (DllHandle);
DllHandle [ i ],
&mi,
sizeof ( mi ) ) )
{
free ( DllHandle );
goto failed; goto failed;
} }
len = (*psapi_GetModuleFileNameExA) ( hProcess, for (i = 0; i < cbNeeded / sizeof (HMODULE); i++)
DllHandle [ i ],
name_buf,
MAX_PATH );
if ( len == 0 )
{ {
free ( DllHandle ); if (!(*psapi_GetModuleInformation) (hProcess,
DllHandle[i], &mi, sizeof (mi)))
{
free (DllHandle);
goto failed; goto failed;
} }
if ( (DWORD) (mi.lpBaseOfDll) == BaseAddress ) len = (*psapi_GetModuleFileNameExA) (hProcess,
DllHandle[i], name_buf, MAX_PATH);
if (len == 0)
{ {
free ( DllHandle ); free (DllHandle);
return strdup ( name_buf ); goto failed;
}
if ((DWORD) (mi.lpBaseOfDll) == BaseAddress)
{
free (DllHandle);
return strdup (name_buf);
} }
} }

@ -4,11 +4,11 @@
Written by Egor Duda <deo@logos-m.ru> Written by Egor Duda <deo@logos-m.ru>
This file is part of Cygwin. This file is part of Cygwin.
This software is a copyrighted work licensed under the terms of the This software is a copyrighted work licensed under the terms of the
Cygwin license. Please consult the file "CYGWIN_LICENSE" for Cygwin license. Please consult the file "CYGWIN_LICENSE" for
details. */ details. */
#include <bfd.h> #include <bfd.h>
#include <stdio.h> #include <stdio.h>
@ -17,22 +17,25 @@ details. */
#include "dumper.h" #include "dumper.h"
int int
exclusion::add ( LPBYTE mem_base, DWORD mem_size ) exclusion::add (LPBYTE mem_base, DWORD mem_size)
{ {
while ( last >= size ) size += step; while (last >= size)
region = (process_mem_region*) realloc ( region, size * sizeof ( process_mem_region ) ); size += step;
if ( region == NULL ) return 0; region = (process_mem_region *) realloc (region, size * sizeof (process_mem_region));
region [ last ].base = mem_base; if (region == NULL)
region [ last ].size = mem_size; return 0;
region[last].base = mem_base;
region[last].size = mem_size;
last++; last++;
return 1; return 1;
}; };
int cmp_regions ( const void* r1, const void* r2 ) int
cmp_regions (const void *r1, const void *r2)
{ {
if ( ((process_mem_region*) r1)->base < ((process_mem_region*) r2)->base ) if (((process_mem_region *) r1)->base < ((process_mem_region *) r2)->base)
return -1; return -1;
if ( ((process_mem_region*) r1)->base > ((process_mem_region*) r2)->base ) if (((process_mem_region *) r1)->base > ((process_mem_region *) r2)->base)
return 1; return 1;
return 0; return 0;
} }
@ -40,13 +43,13 @@ int cmp_regions ( const void* r1, const void* r2 )
int int
exclusion::sort_and_check () exclusion::sort_and_check ()
{ {
qsort ( region, last, sizeof ( process_mem_region ), &cmp_regions ); qsort (region, last, sizeof (process_mem_region), &cmp_regions);
for ( process_mem_region* p = region; p < region + last - 1; p++ ) for (process_mem_region * p = region; p < region + last - 1; p++)
{ {
process_mem_region* q = p + 1; process_mem_region *q = p + 1;
if ( p->base + size > q->base ) if (p->base + size > q->base)
{ {
fprintf ( stderr, "region error @ %08x", p->base ); fprintf (stderr, "region error @ %08x", p->base);
return 0; return 0;
} }
} }
@ -54,35 +57,35 @@ exclusion::sort_and_check ()
} }
static void static void
select_data_section ( bfd *abfd, asection *sect, PTR obj ) select_data_section (bfd * abfd, asection * sect, PTR obj)
{ {
exclusion* excl_list = (exclusion*) obj; exclusion *excl_list = (exclusion *) obj;
if ( ( sect->flags & ( SEC_CODE | SEC_DEBUGGING ) ) && if ((sect->flags & (SEC_CODE | SEC_DEBUGGING)) &&
sect->vma && sect->_raw_size ) sect->vma && sect->_raw_size)
{ {
excl_list->add ( (LPBYTE)sect->vma, (DWORD)sect->_raw_size ); excl_list->add ((LPBYTE) sect->vma, (DWORD) sect->_raw_size);
deb_printf ( "excluding section: %20s %08lx\n", sect->name, sect->_raw_size); deb_printf ("excluding section: %20s %08lx\n", sect->name, sect->_raw_size);
} }
} }
int int
parse_pe ( const char* file_name, exclusion* excl_list ) parse_pe (const char *file_name, exclusion * excl_list)
{ {
if ( file_name == NULL || excl_list == NULL ) return 0; if (file_name == NULL || excl_list == NULL)
return 0;
bfd* abfd = bfd_openr ( file_name, "pei-i386" ); bfd *abfd = bfd_openr (file_name, "pei-i386");
if ( abfd == NULL ) if (abfd == NULL)
{ {
bfd_perror ( "failed to open file" ); bfd_perror ("failed to open file");
return 0; return 0;
} }
bfd_check_format ( abfd, bfd_object ); bfd_check_format (abfd, bfd_object);
bfd_map_over_sections ( abfd, &select_data_section, (PTR)excl_list ); bfd_map_over_sections (abfd, &select_data_section, (PTR) excl_list);
excl_list->sort_and_check (); excl_list->sort_and_check ();
bfd_close ( abfd ); bfd_close (abfd);
return 1; return 1;
} }

@ -30,7 +30,7 @@ static BOOL close_handle (HANDLE h, DWORD ok);
#define CloseHandle(h) close_handle(h, 0) #define CloseHandle(h) close_handle(h, 0)
struct child_list struct child_list
{ {
DWORD id; DWORD id;
HANDLE hproc; HANDLE hproc;
int saw_stars; int saw_stars;
@ -38,9 +38,11 @@ struct child_list
long long start_time; long long start_time;
DWORD last_usecs; DWORD last_usecs;
struct child_list *next; struct child_list *next;
child_list () : id (0), hproc (NULL), saw_stars (0), nfields (0), child_list ():id (0), hproc (NULL), saw_stars (0), nfields (0),
start_time (0), last_usecs (0), next (NULL) {} start_time (0), last_usecs (0), next (NULL)
}; {
}
};
child_list children; child_list children;
@ -85,7 +87,7 @@ DWORD lastid = 0;
HANDLE lasth; HANDLE lasth;
#define PROCFLAGS \ #define PROCFLAGS \
PROCESS_ALL_ACCESS /*(PROCESS_DUP_HANDLE | PROCESS_TERMINATE | PROCESS_VM_READ | PROCESS_VM_WRITE)*/ PROCESS_ALL_ACCESS /*(PROCESS_DUP_HANDLE | PROCESS_TERMINATE | PROCESS_VM_READ | PROCESS_VM_WRITE) */
static void static void
add_child (DWORD id, HANDLE hproc) add_child (DWORD id, HANDLE hproc)
{ {
@ -101,7 +103,7 @@ static child_list *
get_child (DWORD id) get_child (DWORD id)
{ {
child_list *c; child_list *c;
for (c = &children; (c = c->next) != NULL; ) for (c = &children; (c = c->next) != NULL;)
if (c->id == id) if (c->id == id)
return c; return c;
@ -140,9 +142,16 @@ public:
alloc = 0; alloc = 0;
buf = NULL; buf = NULL;
} }
~linebuf () {if (buf) free (buf);} ~linebuf ()
{
if (buf)
free (buf);
}
void add (const char *what, int len); void add (const char *what, int len);
void add (const char *what) {add (what, strlen (what));} void add (const char *what)
{
add (what, strlen (what));
}
void prepend (const char *what, int len); void prepend (const char *what, int len);
}; };
@ -180,7 +189,7 @@ linebuf::prepend (const char *what, int len)
} }
static void static void
make_command_line (linebuf& one_line, char **argv) make_command_line (linebuf & one_line, char **argv)
{ {
for (; *argv; argv++) for (; *argv; argv++)
{ {
@ -240,26 +249,25 @@ create_child (char **argv)
memset (&si, 0, sizeof (si)); memset (&si, 0, sizeof (si));
si.cb = sizeof (si); si.cb = sizeof (si);
/* cygwin32_conv_to_win32_path (exec_file, real_path);*/ /* cygwin32_conv_to_win32_path (exec_file, real_path); */
flags = forkdebug ? 0 : DEBUG_ONLY_THIS_PROCESS; flags = forkdebug ? 0 : DEBUG_ONLY_THIS_PROCESS;
flags |= /*CREATE_NEW_PROCESS_GROUP | */CREATE_DEFAULT_ERROR_MODE | DEBUG_PROCESS; flags |=
/*CREATE_NEW_PROCESS_GROUP | */ CREATE_DEFAULT_ERROR_MODE | DEBUG_PROCESS;
make_command_line (one_line, argv); make_command_line (one_line, argv);
SetConsoleCtrlHandler (NULL, 0); SetConsoleCtrlHandler (NULL, 0);
ret = CreateProcess (0, ret = CreateProcess (0, one_line.buf, /* command line */
one_line.buf,/* command line */
NULL, /* Security */ NULL, /* Security */
NULL, /* thread */ NULL, /* thread */
TRUE, /* inherit handles */ TRUE, /* inherit handles */
flags, /* start flags */ flags, /* start flags */
NULL, NULL, NULL, /* current directory */
NULL, /* current directory */ &si, &pi);
&si,
&pi);
if (!ret) if (!ret)
error (0, "error creating process %s, (error %d)", *argv, GetLastError()); error (0, "error creating process %s, (error %d)", *argv,
GetLastError ());
CloseHandle (pi.hThread); CloseHandle (pi.hThread);
CloseHandle (pi.hProcess); CloseHandle (pi.hProcess);
@ -294,9 +302,7 @@ output_winerror (FILE *ofile, char *s)
NULL, NULL,
errnum, errnum,
MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT), MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR) buf, (LPTSTR) buf, sizeof (buf), NULL))
sizeof (buf),
NULL))
return 0; return 0;
/* Get rid the trailing CR/NL pair. */ /* Get rid the trailing CR/NL pair. */
@ -331,7 +337,7 @@ handle_output_debug_string (DWORD id, LPVOID p, unsigned mask, FILE *ofile)
DWORD nbytes; DWORD nbytes;
child_list *child = get_child (id); child_list *child = get_child (id);
HANDLE hchild = child->hproc; HANDLE hchild = child->hproc;
#define INTROLEN (sizeof (alen) - 1) #define INTROLEN (sizeof (alen) - 1)
if (id == lastid && hchild != lasth) if (id == lastid && hchild != lasth)
warn (0, "%p != %p", hchild, lasth); warn (0, "%p != %p", hchild, lasth);
@ -341,7 +347,8 @@ handle_output_debug_string (DWORD id, LPVOID p, unsigned mask, FILE *ofile)
#ifndef DEBUGGING #ifndef DEBUGGING
return; return;
#else #else
error (0, "couldn't get message length from subprocess %d<%p>, windows error %d", error (0,
"couldn't get message length from subprocess %d<%p>, windows error %d",
id, hchild, GetLastError ()); id, hchild, GetLastError ());
#endif #endif
@ -379,7 +386,8 @@ handle_output_debug_string (DWORD id, LPVOID p, unsigned mask, FILE *ofile)
DWORD new_flag = 1; DWORD new_flag = 1;
if (!WriteProcessMemory (hchild, (LPVOID) n, &new_flag, if (!WriteProcessMemory (hchild, (LPVOID) n, &new_flag,
sizeof (new_flag), &nbytes)) sizeof (new_flag), &nbytes))
error (0, "couldn't write strace flag to subprocess, windows error %d", error (0,
"couldn't write strace flag to subprocess, windows error %d",
GetLastError ()); GetLastError ());
return; return;
} }
@ -387,7 +395,7 @@ handle_output_debug_string (DWORD id, LPVOID p, unsigned mask, FILE *ofile)
char *origs = s; char *origs = s;
if (mask & n) if (mask & n)
/* got it */; /* got it */ ;
else if (!(mask & _STRACE_ALL) || (n & _STRACE_NOTALL)) else if (!(mask & _STRACE_ALL) || (n & _STRACE_NOTALL))
return; /* This should not be included in "all" output */ return; /* This should not be included in "all" output */
@ -459,8 +467,10 @@ handle_output_debug_string (DWORD id, LPVOID p, unsigned mask, FILE *ofile)
if (*s == '*') if (*s == '*')
{ {
SYSTEMTIME *st = syst (child->start_time); SYSTEMTIME *st = syst (child->start_time);
fprintf (ofile, "Date/Time: %d-%02d-%02d %02d:%02d:%02d\n", fprintf (ofile,
st->wYear, st->wMonth, st->wDay, st->wHour, st->wMinute, st->wSecond); "Date/Time: %d-%02d-%02d %02d:%02d:%02d\n",
st->wYear, st->wMonth, st->wDay, st->wHour,
st->wMinute, st->wSecond);
child->saw_stars++; child->saw_stars++;
} }
} }
@ -471,7 +481,7 @@ handle_output_debug_string (DWORD id, LPVOID p, unsigned mask, FILE *ofile)
char intbuf[40]; char intbuf[40];
if (child->saw_stars < 2 || s != origs) if (child->saw_stars < 2 || s != origs)
/* Nothing */; /* Nothing */ ;
else if (hhmmss) else if (hhmmss)
{ {
s = ptrest - 9; s = ptrest - 9;
@ -537,7 +547,8 @@ proc_child (unsigned mask, FILE *ofile)
remove_child (ev.dwProcessId); remove_child (ev.dwProcessId);
break; break;
case EXCEPTION_DEBUG_EVENT: case EXCEPTION_DEBUG_EVENT:
if (ev.u.Exception.ExceptionRecord.ExceptionCode != STATUS_BREAKPOINT) if (ev.u.Exception.ExceptionRecord.ExceptionCode !=
STATUS_BREAKPOINT)
{ {
status = DBG_EXCEPTION_NOT_HANDLED; status = DBG_EXCEPTION_NOT_HANDLED;
#if 0 #if 0
@ -566,7 +577,7 @@ dostrace (unsigned mask, FILE *ofile, char **argv)
} }
int int
main(int argc, char **argv) main (int argc, char **argv)
{ {
unsigned mask = 0; unsigned mask = 0;
FILE *ofile = NULL; FILE *ofile = NULL;
@ -627,7 +638,7 @@ static BOOL
close_handle (HANDLE h, DWORD ok) close_handle (HANDLE h, DWORD ok)
{ {
child_list *c; child_list *c;
for (c = &children; (c = c->next) != NULL; ) for (c = &children; (c = c->next) != NULL;)
if (c->hproc == h && c->id != ok) if (c->hproc == h && c->id != ok)
error (0, "Closing child handle %p", h); error (0, "Closing child handle %p", h);
return CloseHandle (h); return CloseHandle (h);

@ -27,13 +27,18 @@ static void
usage (void) usage (void)
{ {
fprintf (stderr, "Usage %s [-s] <posixpath>\n", progname); fprintf (stderr, "Usage %s [-s] <posixpath>\n", progname);
fprintf (stderr, "-s = remove mount point from system-wide registry location\n"); fprintf (stderr,
"-s = remove mount point from system-wide registry location\n");
fprintf (stderr, "\n"); fprintf (stderr, "\n");
fprintf (stderr, "--remove-all-mounts = remove all mounts\n"); fprintf (stderr, "--remove-all-mounts = remove all mounts\n");
fprintf (stderr, "--remove-auto-mounts = remove all automatically mounted mounts\n"); fprintf (stderr,
fprintf (stderr, "--remove-user-mounts = remove all mounts in the current user mount registry area, including auto mounts\n"); "--remove-auto-mounts = remove all automatically mounted mounts\n");
fprintf (stderr, "--remove-system-mounts = remove all mounts in the system-wide mount registry area\n"); fprintf (stderr,
fprintf (stderr, "[-s] --remove-cygdrive-prefix = remove cygdrive path prefix\n"); "--remove-user-mounts = remove all mounts in the current user mount registry area, including auto mounts\n");
fprintf (stderr,
"--remove-system-mounts = remove all mounts in the system-wide mount registry area\n");
fprintf (stderr,
"[-s] --remove-cygdrive-prefix = remove cygdrive path prefix\n");
exit (1); exit (1);
} }
@ -194,7 +199,7 @@ remove_all_system_mounts ()
static void static void
remove_cygdrive_prefix (int flags) remove_cygdrive_prefix (int flags)
{ {
int res = cygwin_umount(NULL, flags | MOUNT_AUTO); int res = cygwin_umount (NULL, flags | MOUNT_AUTO);
if (res) if (res)
error ("remove_cygdrive_prefix"); error ("remove_cygdrive_prefix");
} }