예제 #1
0
// Function: dumpMemory
// Description: Outputs the contents of the YESS little-endian memory 
//              WORDSPERLINE four-byte words per line.  A * is displayed 
//              at the end of a line if each line in memory after that 
//              up to the next ine displayed is identical to the * line.
// Params: none
// Returns: none
// Modifies: none
void dumpMemory()
{
    int address = 0;
    int prevLine[WORDSPERLINE];
    int currLine[WORDSPERLINE];
    int star = 0;
    buildLine(prevLine, address);
    dumpLine(prevLine, address);
    for (address=WORDSPERLINE; address < MEMSIZE; address+=WORDSPERLINE)
    {
       buildLine(currLine, address);    
       if (isEqual(prevLine, currLine))
       {
          if (!star)
          {
              printf("*\n");
              star = 1;
          }
       } else
       { 
          printf("\n");
          dumpLine(currLine, address);
          star = 0;
       }
       copy(prevLine, currLine);
    }
    printf("\n");
}
예제 #2
0
static void dumpFont(writer_t*w, state_t*state, gfxfont_t*font)
{
    int oldpos = w->pos;
#ifdef STATS
    int old_size_lines = state->size_lines;
#endif
    writer_writeString(w, font->id);
    writer_writeU32(w, font->num_glyphs);
    writer_writeU32(w, font->max_unicode);
    writer_writeDouble(w, font->ascent);
    writer_writeDouble(w, font->descent);
    int t;
    for(t=0;t<font->num_glyphs;t++) {
	dumpLine(w, state, font->glyphs[t].line);
	writer_writeDouble(w, font->glyphs[t].advance);
	writer_writeU32(w, font->glyphs[t].unicode);
	if(font->glyphs[t].name) {
	    writer_writeString(w,font->glyphs[t].name);
	} else {
	    writer_writeU8(w,0);
	}
    }
    for(t=0;t<font->max_unicode;t++) {
	writer_writeU32(w, font->unicode2glyph[t]);
    }
#ifdef STATS
    state->size_lines = old_size_lines;
    state->size_fonts += w->pos - oldpos;
#endif
}
예제 #3
0
static void record_drawlink(struct _gfxdevice*dev, gfxline_t*line, const char*action)
{
    internal_t*i = (internal_t*)dev->internal;
    msg("<trace> record: %08x DRAWLINK\n", dev);
    writer_writeU8(&i->w, OP_DRAWLINK);
    dumpLine(&i->w, &i->state, line);
    writer_writeString(&i->w, action);
}
예제 #4
0
static void record_fill(struct _gfxdevice*dev, gfxline_t*line, gfxcolor_t*color)
{
    internal_t*i = (internal_t*)dev->internal;
    msg("<trace> record: %08x FILL\n", dev);
    writer_writeU8(&i->w, OP_FILL);
    dumpColor(&i->w, &i->state, color);
    dumpLine(&i->w, &i->state, line);
}
예제 #5
0
static void record_startclip(struct _gfxdevice*dev, gfxline_t*line)
{
    internal_t*i = (internal_t*)dev->internal;
    msg("<trace> record: %08x STARTCLIP\n", dev);
    writer_writeU8(&i->w, OP_STARTCLIP);
    dumpLine(&i->w, &i->state, line);
    i->cliplevel++;
}
예제 #6
0
static void record_fillgradient(struct _gfxdevice*dev, gfxline_t*line, gfxgradient_t*gradient, gfxgradienttype_t type, gfxmatrix_t*matrix)
{
    internal_t*i = (internal_t*)dev->internal;
    msg("<trace> record: %08x FILLGRADIENT %08x\n", dev, gradient);
    writer_writeU8(&i->w, OP_FILLGRADIENT);
    writer_writeU8(&i->w, type);
    dumpGradient(&i->w, &i->state, gradient);
    dumpMatrix(&i->w, &i->state, matrix);
    dumpLine(&i->w, &i->state, line);
}
예제 #7
0
static void record_fillbitmap(struct _gfxdevice*dev, gfxline_t*line, gfximage_t*img, gfxmatrix_t*matrix, gfxcxform_t*cxform)
{
    internal_t*i = (internal_t*)dev->internal;
    msg("<trace> record: %08x FILLBITMAP\n", dev);
    writer_writeU8(&i->w, OP_FILLBITMAP);
    dumpImage(&i->w, &i->state, img);
    dumpMatrix(&i->w, &i->state, matrix);
    dumpLine(&i->w, &i->state, line);
    dumpCXForm(&i->w, &i->state, cxform);
}
예제 #8
0
static void record_stroke(struct _gfxdevice*dev, gfxline_t*line, gfxcoord_t width, gfxcolor_t*color, gfx_capType cap_style, gfx_joinType joint_style, gfxcoord_t miterLimit)
{
    internal_t*i = (internal_t*)dev->internal;
    msg("<trace> record: %08x STROKE\n", dev);
    writer_writeU8(&i->w, OP_STROKE);
    writer_writeDouble(&i->w, width);
    writer_writeDouble(&i->w, miterLimit);
    dumpColor(&i->w, &i->state, color);
    writer_writeU8(&i->w, cap_style);
    writer_writeU8(&i->w, joint_style);
    dumpLine(&i->w, &i->state, line);
}
예제 #9
0
/*
Function that manages the second run and dumping the commands , variables and data to memoryDump struct
Input: 
	RunStatus struct
	MemoryDump struct
Output: Number of errors during the pass
*/
int SecondReadManager(RunStatus *runStatus, MemoryDump *memStatus)
{
	int i = 0;

	/*Validation that all extern labels exists in the code*/
	checkEntryLabels(runStatus);

	/*We are dumping the command lines first*/
	for (i = 0; i < runStatus -> lineCount; i++)
	{
		dumpLine(i, memStatus, runStatus);
	}
	
	/* After finishing with commands we are dumping the data*/
	for (i = 0; i < runStatus -> dataCount; i++)
	{
		dumpData(runStatus -> dataArray[i], memStatus);
	}

	return runStatus -> errNum;
}
예제 #10
0
int getGuess(char* userGuess){
	printf("Guess a number:");
	char temp[MAXSIZE+1];
	int i;
	int returnValue = 0;
	fgets(temp,(MAXSIZE+1), stdin);
	if(temp[MAXSIZE -1] == '\n'){
		strncpy(userGuess, temp, MAXSIZE);
		for(i = 0; i < (MAXSIZE-1); i++){
			if(!isdigit(userGuess[i])){
				returnValue = 2;
			}
		}	
	}
	else{
		returnValue = 1;
		if(((int)strlen(temp)) == MAXSIZE ){	
			dumpLine(stdin);
		}	
	}	
	return returnValue;
	}
예제 #11
0
void NBLog::Reader::dump(int fd, size_t indent)
{
    int32_t rear = android_atomic_acquire_load(&mShared->mRear);
    size_t avail = rear - mFront;
    if (avail == 0) {
        return;
    }
    size_t lost = 0;
    if (avail > mSize) {
        lost = avail - mSize;
        mFront += lost;
        avail = mSize;
    }
    size_t remaining = avail;       // remaining = number of bytes left to read
    size_t front = mFront & (mSize - 1);
    size_t read = mSize - front;    // read = number of bytes that have been read so far
    if (read > remaining) {
        read = remaining;
    }
    // make a copy to avoid race condition with writer
    uint8_t *copy = new uint8_t[avail];
    // copy first part of circular buffer up until the wraparound point
    memcpy(copy, &mShared->mBuffer[front], read);
    if (front + read == mSize) {
        if ((remaining -= read) > 0) {
            // copy second part of circular buffer starting at beginning
            memcpy(&copy[read], mShared->mBuffer, remaining);
            read += remaining;
            // remaining = 0 but not necessary
        }
    }
    mFront += read;
    size_t i = avail;
    Event event;
    size_t length;
    struct timespec ts;
    time_t maxSec = -1;
    while (i >= 3) {
        length = copy[i - 1];
        if (length + 3 > i || copy[i - length - 2] != length) {
            break;
        }
        event = (Event) copy[i - length - 3];
        if (event == EVENT_TIMESTAMP) {
            if (length != sizeof(struct timespec)) {
                // corrupt
                break;
            }
            memcpy(&ts, &copy[i - length - 1], sizeof(struct timespec));
            if (ts.tv_sec > maxSec) {
                maxSec = ts.tv_sec;
            }
        }
        i -= length + 3;
    }
    mFd = fd;
    mIndent = indent;
    String8 timestamp, body;
    lost += i;
    if (lost > 0) {
        body.appendFormat("warning: lost %zu bytes worth of events", lost);
        // TODO timestamp empty here, only other choice to wait for the first timestamp event in the
        //      log to push it out.  Consider keeping the timestamp/body between calls to readAt().
        dumpLine(timestamp, body);
    }
    size_t width = 1;
    while (maxSec >= 10) {
        ++width;
        maxSec /= 10;
    }
    if (maxSec >= 0) {
        timestamp.appendFormat("[%*s]", (int) width + 4, "");
    }
    bool deferredTimestamp = false;
    while (i < avail) {
        event = (Event) copy[i];
        length = copy[i + 1];
        const void *data = &copy[i + 2];
        size_t advance = length + 3;
        switch (event) {
        case EVENT_STRING:
            body.appendFormat("%.*s", (int) length, (const char *) data);
            break;
        case EVENT_TIMESTAMP: {
            // already checked that length == sizeof(struct timespec);
            memcpy(&ts, data, sizeof(struct timespec));
            long prevNsec = ts.tv_nsec;
            long deltaMin = LONG_MAX;
            long deltaMax = -1;
            long deltaTotal = 0;
            size_t j = i;
            for (;;) {
                j += sizeof(struct timespec) + 3;
                if (j >= avail || (Event) copy[j] != EVENT_TIMESTAMP) {
                    break;
                }
                struct timespec tsNext;
                memcpy(&tsNext, &copy[j + 2], sizeof(struct timespec));
                if (tsNext.tv_sec != ts.tv_sec) {
                    break;
                }
                long delta = tsNext.tv_nsec - prevNsec;
                if (delta < 0) {
                    break;
                }
                if (delta < deltaMin) {
                    deltaMin = delta;
                }
                if (delta > deltaMax) {
                    deltaMax = delta;
                }
                deltaTotal += delta;
                prevNsec = tsNext.tv_nsec;
            }
            size_t n = (j - i) / (sizeof(struct timespec) + 3);
            if (deferredTimestamp) {
                dumpLine(timestamp, body);
                deferredTimestamp = false;
            }
            timestamp.clear();
            if (n >= kSquashTimestamp) {
                timestamp.appendFormat("[%d.%03d to .%.03d by .%.03d to .%.03d]",
                        (int) ts.tv_sec, (int) (ts.tv_nsec / 1000000),
                        (int) ((ts.tv_nsec + deltaTotal) / 1000000),
                        (int) (deltaMin / 1000000), (int) (deltaMax / 1000000));
                i = j;
                advance = 0;
                break;
            }
            timestamp.appendFormat("[%d.%03d]", (int) ts.tv_sec,
                    (int) (ts.tv_nsec / 1000000));
            deferredTimestamp = true;
            } break;
        case EVENT_RESERVED:
        default:
            body.appendFormat("warning: unknown event %d", event);
            break;
        }
        i += advance;

        if (!body.isEmpty()) {
            dumpLine(timestamp, body);
            deferredTimestamp = false;
        }
    }
    if (deferredTimestamp) {
        dumpLine(timestamp, body);
    }
    // FIXME it would be more efficient to put a char mCopy[256] as a member variable of the dumper
    delete[] copy;
}