* strace.cc: Throughout, track information like start_time, etc. on a
per-process basis.
This commit is contained in:
parent
3f0b493540
commit
22fe0c41ec
@ -1,3 +1,8 @@
|
|||||||
|
Sun Mar 12 21:22:25 2000 Christopher Faylor <cgf@cygnus.com>
|
||||||
|
|
||||||
|
* strace.cc: Throughout, track information like start_time, etc. on a
|
||||||
|
per-process basis.
|
||||||
|
|
||||||
Sun Feb 27 23:37:32 2000 Christopher Faylor <cgf@cygnus.com>
|
Sun Feb 27 23:37:32 2000 Christopher Faylor <cgf@cygnus.com>
|
||||||
|
|
||||||
* strace.cc (handle_output_debug_string): Parse strace output to allow
|
* strace.cc (handle_output_debug_string): Parse strace output to allow
|
||||||
|
@ -23,10 +23,16 @@ struct child_list
|
|||||||
{
|
{
|
||||||
DWORD id;
|
DWORD id;
|
||||||
HANDLE hproc;
|
HANDLE hproc;
|
||||||
|
int saw_stars;
|
||||||
|
char nfields;
|
||||||
|
long long start_time;
|
||||||
|
DWORD last_usecs;
|
||||||
struct child_list *next;
|
struct child_list *next;
|
||||||
|
child_list () : id (0), hproc (NULL), saw_stars (0), nfields (0),
|
||||||
|
start_time (0), last_usecs (0), next (NULL) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
child_list children = {0, NULL, NULL};
|
child_list children;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
warn (int geterrno, const char *fmt, ...)
|
warn (int geterrno, const char *fmt, ...)
|
||||||
@ -84,13 +90,13 @@ add_child (DWORD id, HANDLE hproc)
|
|||||||
lasth = children.next->hproc;
|
lasth = children.next->hproc;
|
||||||
}
|
}
|
||||||
|
|
||||||
static HANDLE
|
static child_list *
|
||||||
get_child_handle (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->hproc;
|
return c;
|
||||||
|
|
||||||
error (0, "no process id %d found", id);
|
error (0, "no process id %d found", id);
|
||||||
}
|
}
|
||||||
@ -317,12 +323,9 @@ handle_output_debug_string (DWORD id, LPVOID p, unsigned mask, FILE *ofile)
|
|||||||
int special;
|
int special;
|
||||||
char alen[3 + 8 + 1];
|
char alen[3 + 8 + 1];
|
||||||
DWORD nbytes;
|
DWORD nbytes;
|
||||||
HANDLE hchild = get_child_handle (id);
|
child_list *child = get_child (id);
|
||||||
|
HANDLE hchild = child->hproc;
|
||||||
#define INTROLEN (sizeof (alen) - 1)
|
#define INTROLEN (sizeof (alen) - 1)
|
||||||
static int saw_stars = 0;
|
|
||||||
static char nfields = 0;
|
|
||||||
static long long start_time;
|
|
||||||
static DWORD last_usecs;
|
|
||||||
|
|
||||||
if (id == lastid && hchild != lasth)
|
if (id == lastid && hchild != lasth)
|
||||||
warn (0, "%p != %p", hchild, lasth);
|
warn (0, "%p != %p", hchild, lasth);
|
||||||
@ -402,71 +405,71 @@ handle_output_debug_string (DWORD id, LPVOID p, unsigned mask, FILE *ofile)
|
|||||||
usecs = dusecs;
|
usecs = dusecs;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (saw_stars == 0)
|
if (child->saw_stars == 0)
|
||||||
{
|
{
|
||||||
FILETIME st;
|
FILETIME st;
|
||||||
char *news;
|
char *news;
|
||||||
|
|
||||||
GetSystemTimeAsFileTime (&st);
|
GetSystemTimeAsFileTime (&st);
|
||||||
FileTimeToLocalFileTime (&st, &st);
|
FileTimeToLocalFileTime (&st, &st);
|
||||||
start_time = st.dwHighDateTime;
|
child->start_time = st.dwHighDateTime;
|
||||||
start_time <<= 32;
|
child->start_time <<= 32;
|
||||||
start_time |= st.dwLowDateTime;
|
child->start_time |= st.dwLowDateTime;
|
||||||
if (*(news = ptrest) != '[')
|
if (*(news = ptrest) != '[')
|
||||||
saw_stars = 2;
|
child->saw_stars = 2;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
saw_stars++;
|
child->saw_stars++;
|
||||||
while ((news = strchr (news, ' ')) != NULL && *++news != '*')
|
while ((news = strchr (news, ' ')) != NULL && *++news != '*')
|
||||||
nfields++;
|
child->nfields++;
|
||||||
if (news == NULL)
|
if (news == NULL)
|
||||||
saw_stars++;
|
child->saw_stars++;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
s = news;
|
s = news;
|
||||||
nfields++;
|
child->nfields++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (saw_stars < 2)
|
else if (child->saw_stars < 2)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
char *news;
|
char *news;
|
||||||
if (*(news = ptrest) != '[')
|
if (*(news = ptrest) != '[')
|
||||||
saw_stars = 2;
|
child->saw_stars = 2;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (i = 0; i < nfields; i++)
|
for (i = 0; i < child->nfields; i++)
|
||||||
if ((news = strchr (news, ' ')) == NULL)
|
if ((news = strchr (news, ' ')) == NULL)
|
||||||
break; // Should never happen
|
break; // Should never happen
|
||||||
else
|
else
|
||||||
news++;
|
news++;
|
||||||
|
|
||||||
if (news == NULL)
|
if (news == NULL)
|
||||||
saw_stars = 2;
|
child->saw_stars = 2;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
s = news;
|
s = news;
|
||||||
if (*s == '*')
|
if (*s == '*')
|
||||||
{
|
{
|
||||||
SYSTEMTIME *st = syst (start_time);
|
SYSTEMTIME *st = syst (child->start_time);
|
||||||
fprintf (ofile, "Date/Time: %d-%02d-%02d %02d:%02d:%02d\n",
|
fprintf (ofile, "Date/Time: %d-%02d-%02d %02d:%02d:%02d\n",
|
||||||
st->wYear, st->wMonth, st->wDay, st->wHour, st->wMinute, st->wSecond);
|
st->wYear, st->wMonth, st->wDay, st->wHour, st->wMinute, st->wSecond);
|
||||||
saw_stars++;
|
child->saw_stars++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
long long d = usecs - last_usecs;
|
long long d = usecs - child->last_usecs;
|
||||||
char intbuf[40];
|
char intbuf[40];
|
||||||
|
|
||||||
if (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;
|
||||||
SYSTEMTIME *st = syst (start_time + (long long) usecs * 10);
|
SYSTEMTIME *st = syst (child->start_time + (long long) usecs * 10);
|
||||||
sprintf (s, "%02d:%02d:%02d", st->wHour, st->wMinute, st->wSecond);
|
sprintf (s, "%02d:%02d:%02d", st->wHour, st->wMinute, st->wSecond);
|
||||||
*strchr (s, '\0') = ' ';
|
*strchr (s, '\0') = ' ';
|
||||||
}
|
}
|
||||||
@ -481,7 +484,7 @@ handle_output_debug_string (DWORD id, LPVOID p, unsigned mask, FILE *ofile)
|
|||||||
memcpy ((s -= len), intbuf, len);
|
memcpy ((s -= len), intbuf, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
last_usecs = usecs;
|
child->last_usecs = usecs;
|
||||||
if (numerror || !output_winerror (ofile, s))
|
if (numerror || !output_winerror (ofile, s))
|
||||||
fputs (s, ofile);
|
fputs (s, ofile);
|
||||||
fflush (ofile);
|
fflush (ofile);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user