1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-04-06 14:22:31 -07:00
Merge MMdevel_event_string

Copied from Perforce
 Change: 18464
 ServerID: perforce.ravenbrook.com
This commit is contained in:
Gavin Matthews 1997-07-17 19:37:21 +01:00
parent 0c603a85cb
commit 832f52ccfa
3 changed files with 288 additions and 0 deletions

View file

@ -0,0 +1,124 @@
/* impl.c.dumper: Simple Event Dumper
*
* $HopeName: MMsrc!dumper.c(MMdevel_event_string.2) $
* Copyright (C) 1997 Harlequin Group, all rights reserved.
*
* .readership: MM developers.
*
* .purpose: This is a simple tool to dump events as text.
*
* .trans: As a tool, it's allowed to depend on the ANSI C library.
*/
#include <stdio.h>
#include <stddef.h>
#include <stdlib.h>
#include <stdarg.h>
#include <assert.h>
#include "ossu.h"
typedef unsigned long Word;
typedef struct AddrStruct *Addr;
#include "eventcom.h"
#define RELATION(type, code, always, kind, format) \
case Event ## type: \
readEvent(#type, #format, header[0], header[1], header[2]); \
break;
#define AVER(test) \
if(test) do {} while(0); else error("AVER: " #test)
static char *prog;
static void error (const char *format, ...) {
va_list args;
fprintf(stderr, "%s: Error: ", prog);
va_start(args, format);
vfprintf(stderr, format, args);
fputc('\n', stderr);
va_end(args);
exit(EXIT_FAILURE);
assert(0);
}
#define PROCESS(ch, type, _length, printfFormat, cast) \
case ch: { \
type v; \
size_t n = fread(&v, (_length), 1, stdin); \
if(n < 1) \
error("Can't read data for format code >%c<", ch); \
printf(printfFormat " ", (cast)v); \
length -= (_length) / sizeof(Word); \
} break;
static void readEvent(char *type, char *format, Word code, Word length,
Word cpuTime) {
AVER(type != NULL);
AVER(format != NULL);
printf("%-20s ", type);
for(; *format != '\0'; format++) {
switch(*format) {
PROCESS('A', Addr, sizeof(Addr), "0x%08lX", unsigned long)
PROCESS('P', void *, sizeof(void *), "0x%08lX", unsigned long)
PROCESS('U', unsigned, sizeof(unsigned),"%u", unsigned)
PROCESS('W', Word, sizeof(Word),"%lu", Word)
PROCESS('D', double, sizeof(double), "%f", double)
case 'S': {
size_t n;
char *v;
AVER(length > 0);
v = malloc(length * sizeof(Word));
if(v == NULL)
error("Can't allocate string space %u", (unsigned)length);
n = fread(&v, length * sizeof(Word), 1, stdin);
if(n < 1)
error("Can't read data for string");
printf("%s ", v);
length = 0;
} break;
case '0': break;
default:
error("Unknown format >%c<", *format);
break;
}
}
putc('\n', stdout);
AVER(length == 0);
}
int main(int argc, char *argv[]) {
size_t n;
Word header[3];
prog = (argc >= 1 ? argv[0] : "unknown");
while(!feof(stdin)) {
n = fread(header, sizeof(Word), 3, stdin);
if(n < 3) {
if(feof(stdin))
continue;
error("Can't read from input");
}
switch(header[0]) {
#include "eventdef.h"
default:
error("Unknown event code %08lX", header[0]);
}
}
return(0);
}

View file

@ -0,0 +1,76 @@
/* impl.h.eventcom -- Event Logging Common Types
*
* Copyright (C) 1997 Harlequin Group, all rights reserved.
* $HopeName: MMsrc!eventcom.h(MMdevel_event_string.2) $
*
* .readership: MPS developers.
* .sources: mps.design.telemetry
*/
#ifndef eventcom_h
#define eventcom_h
#define EventMaxStringLength ((size_t)256) /* Including NUL */
typedef Word EventType;
/* Event Codes -- see design.mps.telemetry
*
* These names are intended to be mnemonic. They are derived from
* selected letters as indicated, using the transliteration in
* guide.hex.trans.
*
* These definitions will be unnecessary when the event codes are
* changed to 16-bit. See impl.h.eventdef.
*/
/* EVent ... */
#define EventEventTime ((EventType)0xEF213E99) /* TIME */
#define EventSpaceCreate ((EventType)0xEF5BCC6E) /* SPaCe CREate */
#define EventSpaceDestroy ((EventType)0xEF5BCDE5) /* SPaCe DEStroy */
#define EventPoolInit ((EventType)0xEFB07141) /* POoL INIt */
#define EventPoolFinish ((EventType)0xEFB07F14) /* POoL FINish */
#define EventPoolAlloc ((EventType)0xEFB07A77) /* POoL ALLoc */
#define EventPoolFree ((EventType)0xEFB07F6E) /* POoL FREe */
#define EventArenaCreate ((EventType)0xEFA64C6E) /* AReNa CREate */
#define EventArenaDestroy ((EventType)0xEFA64DE5) /* AReNa DEStroy */
#define EventSegAlloc ((EventType)0xEF5E9A77) /* SEG ALLoc */
#define EventSegFree ((EventType)0xEF5E9F6E) /* SEG FREe */
#define EventAMCGenCreate ((EventType)0xEFA3C94C) /* AMC GeN Create */
#define EventAMCGenDestroy ((EventType)0xEFA3C94D) /* AMC GeN Destroy */
#define EventAMCInit ((EventType)0xEFA3C141) /* AMC INIt */
#define EventAMCFinish ((EventType)0xEFA3CF14) /* AMC FINish */
#define EventAMCBufferInit ((EventType)0xEFA3CBF1) /* AMC BuFfer Init */
#define EventAMCBufferFill ((EventType)0xEFA3CBFF) /* AMC BuFfer Fill */
#define EventAMCBufferEmpty ((EventType)0xEFA3CBFE) /* AMC BuFfer Empty */
#define EventAMCTraceBegin ((EventType)0xEFA3C26B) /* AMC TRace Begin */
#define EventAMCCondemn ((EventType)0xEFA3CC04) /* AMC CONdemn */
#define EventAMCScanBegin ((EventType)0xEFA3C5CB) /* AMC SCan Begin */
#define EventAMCScanEnd ((EventType)0xEFA3C5CE) /* AMC SCan End */
#define EventAMCFix ((EventType)0xEFA3CF18) /* AMC FIX */
#define EventAMCFixAmbig ((EventType)0xEFA3CF8A) /* AMC FiX Ambig */
#define EventAMCFixForward ((EventType)0xEFA3CF8F) /* AMC FiX Forward */
#define EventAMCReclaim ((EventType)0xEFA3C6EC) /* AMC REClaim */
#define EventAMCTraceEnd ((EventType)0xEFA3C26E) /* AMC TRace End */
#define EventTraceStart ((EventType)0xEF26AC52) /* TRACe STart */
#define EventTraceCreate ((EventType)0xEF26ACC6) /* TRACe CReate */
#define EventTraceDestroy ((EventType)0xEF26ACDE) /* TRACe DEstroy */
#define EventTraceSegGreyen ((EventType)0xEF26A599) /* TRAce SeG Greyen */
#define EventTraceFlipBegin ((EventType)0xEF26AF7B) /* TRAce FLip Begin */
#define EventTraceFlipEnd ((EventType)0xEF26AF7E) /* TRAce FLip End */
#define EventTraceReclaim ((EventType)0xEF26A6EC) /* TRAce REClaim */
#define EventTraceScan ((EventType)0xEF26AC5C) /* TRACe SCan */
#define EventTraceAccess ((EventType)0xEF26AACC) /* TRAce ACCess */
#define EventTracePoll ((EventType)0xEF26AB01) /* TRAce POLl */
#define EventTraceFix ((EventType)0xEF26AF18) /* TRAce FIX */
#define EventTraceFixSeg ((EventType)0xEF26AF85) /* TRAce FiX Seg */
#define EventTraceFixWhite ((EventType)0xEF26AF83) /* TRAce FiX White */
#define EventTraceScanArea ((EventType)0xEF26A5CA) /* TRAce SCan Area */
#define EventTraceScanAreaTagged ((EventType)0xEF26A5C2) /* TRAce SCan area Tagged */
#define EventVMCreate ((EventType)0xEFF3C6EA) /* VM CREAte */
#define EventVMDestroy ((EventType)0xEFF3DE52) /* VM DESTroy */
#define EventVMMap ((EventType)0xEFF33AB9) /* VM MAP */
#define EventVMUnmap ((EventType)0xEFF3043B) /* VM UNMaP */
#define EventIntern ((EventType)0XEF142E64) /* INTERN */
#endif /* eventcom_h */

View file

@ -0,0 +1,88 @@
/* impl.h.eventdef -- Event Logging Definitions
*
* Copyright (C) 1997 Harlequin Group, all rights reserved.
* $HopeName: MMsrc!eventdef.h(MMdevel_event_string.2) $
*
* .readership: MPS developers.
* .source: design.mps.telemetry
*
* .desc: This file declares relationships that define the various
* event types. It is intended to be used with clever definitions
* of the RELATION macro.
*/
/* No protection because file is re-entrant. */
/* EVENT_VERSION_* -- three part version number
*
* Increment the minor version when adding new events,
* the median version when changing an existing event,
* and the major version when changing the format of the event file.
*/
#define EVENT_VERSION_MAJOR ((unsigned)0)
#define EVENT_VERSION_MEDIAN ((unsigned)0)
#define EVENT_VERSION_MINOR ((unsigned)0)
/* Relations -- Generic definitions of events
*
* These specify:
* - Type: The name of the event type, without the leading "Event";
* - Code: The unique 16-bit code associated with this event type,
* not currently used (see impl.h.eventcom);
* - Always: Whether this event type should appear in optimised
* varieties, not currently used;
* - Kind: Category into which this event falls, without the
* leading "EventKind";
* - Format: Character sequence indicating the format of the event
* parameters, similar to writef (Pointer, Addr, Word, Unsigned,
* String, Double).
*/
RELATION(AMCGenCreate , 0x0001, TRUE, Pool, PP)
RELATION(AMCGenDestroy , 0x0002, TRUE, Pool, P)
RELATION(AMCInit , 0x0003, TRUE, Pool, PP)
RELATION(AMCFinish , 0x0004, TRUE, Pool, P)
RELATION(AMCBufferInit , 0x0005, TRUE, Object, PP)
RELATION(AMCBufferFill , 0x0006, TRUE, Object, PPWAW)
RELATION(AMCBufferEmpty , 0x0007, TRUE, Object, PPW)
RELATION(AMCTraceBegin , 0x0008, TRUE, Trace, PPPP)
RELATION(AMCCondemn , 0x0009, TRUE, Seg, PPPP)
RELATION(AMCScanBegin , 0x000a, TRUE, Trace, PPP)
RELATION(AMCScanEnd , 0x000b, TRUE, Trace, PPP)
RELATION(AMCFix , 0x000c, TRUE, Ref, 0)
RELATION(AMCFixAmbig , 0x000d, TRUE, Ref, 0)
RELATION(AMCFixForward , 0x000e, TRUE, Ref, A)
RELATION(AMCReclaim , 0x000f, TRUE, Seg, PPP)
RELATION(AMCTraceEnd , 0x0010, TRUE, Trace, PPP)
RELATION(ArenaCreate , 0x0011, TRUE, Arena, PP)
RELATION(ArenaDestroy , 0x0012, TRUE, Arena, P)
RELATION(SegAlloc , 0x0013, TRUE, Seg, PPAWP)
RELATION(SegFree , 0x0014, TRUE, Seg, PP)
RELATION(PoolInit , 0x0015, TRUE, Pool, PPP)
RELATION(PoolFinish , 0x0016, TRUE, Pool, P)
RELATION(PoolAlloc , 0x0017, TRUE, Object, PAW)
RELATION(PoolFree , 0x0018, TRUE, Object, PAW)
RELATION(SpaceCreate , 0x001a, TRUE, Arena, P)
RELATION(SpaceDestroy , 0x001b, TRUE, Arena, P)
RELATION(TraceStart , 0x001c, TRUE, Trace, PPP)
RELATION(TraceCreate , 0x001d, TRUE, Trace, PPPU)
RELATION(TraceDestroy , 0x001e, TRUE, Trace, P)
RELATION(TraceSegGreyen , 0x001f, TRUE, Trace, PPU)
RELATION(TraceFlipBegin , 0x0020, TRUE, Trace, PP)
RELATION(TraceFlipEnd , 0x0021, TRUE, Trace, PP)
RELATION(TraceReclaim , 0x0022, TRUE, Trace, P)
RELATION(TraceScan , 0x0023, TRUE, Trace, UUPPP)
RELATION(TraceAccess , 0x0024, TRUE, Seg, PPU)
RELATION(TracePoll , 0x0025, TRUE, Trace, PP)
RELATION(TraceFix , 0x0026, TRUE, Ref, PPAU)
RELATION(TraceFixSeg , 0x0027, TRUE, Ref, P)
RELATION(TraceFixWhite , 0x0028, TRUE, Ref, 0)
RELATION(TraceScanArea , 0x0029, TRUE, Trace, PPP)
RELATION(TraceScanAreaTagged , 0x002a, TRUE, Trace, PPP)
RELATION(VMCreate , 0x002b, TRUE, Arena, PPAA)
RELATION(VMDestroy , 0x002c, TRUE, Arena, P)
RELATION(VMMap , 0x002d, TRUE, Seg, PAA)
RELATION(VMUnmap , 0x002e, TRUE, Seg, PAA)