7003401: Implement VM error-reporting functionality on erroneous termination

Add support for distribution-specific error reporting

Reviewed-by: coleenp, phh, jcoomes, ohair
This commit is contained in:
Keith McGuigan 2011-02-08 17:20:45 -05:00
parent 2fcd065a0d
commit 9acb43fa6d
23 changed files with 518 additions and 165 deletions

View file

@ -314,6 +314,11 @@ fileStream::fileStream(const char* file_name) {
_need_close = true;
}
fileStream::fileStream(const char* file_name, const char* opentype) {
_file = fopen(file_name, opentype);
_need_close = true;
}
void fileStream::write(const char* s, size_t len) {
if (_file != NULL) {
// Make an unused local variable to avoid warning from gcc 4.x compiler.
@ -322,6 +327,25 @@ void fileStream::write(const char* s, size_t len) {
update_position(s, len);
}
long fileStream::fileSize() {
long size = -1;
if (_file != NULL) {
long pos = ::ftell(_file);
if (::fseek(_file, 0, SEEK_END) == 0) {
size = ::ftell(_file);
}
::fseek(_file, pos, SEEK_SET);
}
return size;
}
char* fileStream::readln(char *data, int count ) {
char * ret = ::fgets(data, count, _file);
//Get rid of annoying \n char
data[::strlen(data)-1] = '\0';
return ret;
}
fileStream::~fileStream() {
if (_file != NULL) {
if (_need_close) fclose(_file);