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

View File

@ -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

View File

@ -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;
@ -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);
@ -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,7 +761,8 @@ 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");
@ -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,16 +1013,20 @@ 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);
} }
@ -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;
@ -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");
} }

View File

@ -40,7 +40,8 @@ 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);
@ -74,7 +75,8 @@ dumper::dumper ( DWORD pid, DWORD tid, const char* file_name )
init_core_dump (); init_core_dump ();
if ( ! sane () ) dumper_abort (); if (!sane ())
dumper_abort ();
} }
dumper: :~dumper () dumper: :~dumper ()
@ -93,9 +95,12 @@ dumper::dumper_abort ()
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,17 +109,20 @@ 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)
@ -128,12 +136,14 @@ 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++;
@ -142,7 +152,8 @@ dumper::add_thread ( DWORD tid, HANDLE 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;
@ -151,12 +162,15 @@ dumper::add_thread ( DWORD tid, HANDLE hThread )
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++;
@ -167,16 +181,16 @@ dumper::add_mem_region ( LPBYTE base, DWORD 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;
@ -184,7 +198,8 @@ dumper::split_add_mem_region ( LPBYTE base, DWORD size )
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)
{ {
@ -205,13 +220,16 @@ dumper::split_add_mem_region ( LPBYTE base, DWORD size )
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++;
@ -229,7 +247,8 @@ 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;
@ -240,7 +259,8 @@ dumper::collect_memory_sections ()
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;)
{ {
@ -250,7 +270,8 @@ dumper::collect_memory_sections ()
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)
{ {
@ -272,7 +293,8 @@ dumper::collect_memory_sections ()
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,
@ -311,7 +333,8 @@ dumper::collect_memory_sections ()
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,7 +342,8 @@ 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];
@ -347,9 +371,11 @@ dumper::dump_memory_region ( asection* to, process_mem_region* memory )
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;
@ -396,9 +422,11 @@ dumper::dump_thread ( asection* to, process_thread* thread )
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;
@ -438,7 +466,8 @@ dumper::dump_module ( asection* to, process_module* module )
return 1; return 1;
out: out:
if ( buf ) free ( buf ); if (buf)
free (buf);
dumper_abort (); dumper_abort ();
return 0; return 0;
@ -447,7 +476,8 @@ 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))
{ {
@ -463,7 +493,8 @@ dumper::collect_process_information ()
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)
{ {
@ -521,7 +552,8 @@ dumper::collect_process_information ()
}; };
/* 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;
@ -537,7 +569,8 @@ dumper::collect_process_information ()
} }
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;
} }
@ -571,7 +604,8 @@ 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];
@ -657,11 +691,13 @@ 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,

View File

@ -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;
@ -121,4 +124,3 @@ main (int argc, char **argv)
} }
return 0; return 0;
} }

View File

@ -17,18 +17,19 @@ 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)
@ -48,31 +49,36 @@ psapi_get_module_name ( HANDLE hProcess, DWORD BaseAddress )
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,
"GetModuleFileNameExA");
if (psapi_EnumProcessModules == NULL
|| psapi_GetModuleInformation == NULL
|| psapi_GetModuleFileNameExA == NULL)
goto failed;
} }
ok = (*psapi_EnumProcessModules) (hProcess, ok = (*psapi_EnumProcessModules) (hProcess,
DllHandle, DllHandle, sizeof (HMODULE), &cbNeeded);
sizeof ( HMODULE ),
&cbNeeded );
if ( !ok || !cbNeeded ) goto failed; if (!ok || !cbNeeded)
goto failed;
DllHandle = (HMODULE *) malloc (cbNeeded); DllHandle = (HMODULE *) malloc (cbNeeded);
if ( ! DllHandle ) goto failed; if (!DllHandle)
ok = (*psapi_EnumProcessModules) ( hProcess, goto failed;
DllHandle, ok = (*psapi_EnumProcessModules) (hProcess, DllHandle, cbNeeded, &cbNeeded);
cbNeeded,
&cbNeeded );
if (!ok) if (!ok)
{ {
free (DllHandle); free (DllHandle);
@ -82,18 +88,14 @@ psapi_get_module_name ( HANDLE hProcess, DWORD BaseAddress )
for (i = 0; i < cbNeeded / sizeof (HMODULE); i++) for (i = 0; i < cbNeeded / sizeof (HMODULE); i++)
{ {
if (!(*psapi_GetModuleInformation) (hProcess, if (!(*psapi_GetModuleInformation) (hProcess,
DllHandle [ i ], DllHandle[i], &mi, sizeof (mi)))
&mi,
sizeof ( mi ) ) )
{ {
free (DllHandle); free (DllHandle);
goto failed; goto failed;
} }
len = (*psapi_GetModuleFileNameExA) (hProcess, len = (*psapi_GetModuleFileNameExA) (hProcess,
DllHandle [ i ], DllHandle[i], name_buf, MAX_PATH);
name_buf,
MAX_PATH );
if (len == 0) if (len == 0)
{ {
free (DllHandle); free (DllHandle);

View File

@ -19,16 +19,19 @@ details. */
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)
size += step;
region = (process_mem_region *) realloc (region, size * sizeof (process_mem_region)); region = (process_mem_region *) realloc (region, size * sizeof (process_mem_region));
if ( region == NULL ) return 0; if (region == NULL)
return 0;
region[last].base = mem_base; region[last].base = mem_base;
region[last].size = mem_size; 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;
@ -69,7 +72,8 @@ select_data_section ( bfd *abfd, asection *sect, PTR obj )
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)
@ -85,4 +89,3 @@ parse_pe ( const char* file_name, exclusion* excl_list )
bfd_close (abfd); bfd_close (abfd);
return 1; return 1;
} }

View File

@ -39,7 +39,9 @@ struct child_list
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;
@ -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);
}; };
@ -243,23 +252,22 @@ create_child (char **argv)
/* 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. */
@ -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;
} }
@ -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++;
} }
} }
@ -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

View File

@ -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);
} }