diff options
author | Mike Kestner <mkestner@gmail.com> | 2009-08-19 20:54:06 +0400 |
---|---|---|
committer | Mike Kestner <mkestner@gmail.com> | 2009-08-19 20:54:06 +0400 |
commit | 23a29ab07c351417a8ede62b55765cb0f4dbb391 (patch) | |
tree | 25ce873e14d684eaada51960d7703e2e09cc26fd | |
parent | f568532ae5ab0efa06ccabf9fec0e6ba961633b8 (diff) |
2009-08-19 Massimiliano Mantione <massi@ximian.com>
* Reader.cs:
Return null when file ends without an EndBlock, instead of throwing
an exception. This supports intermediate parsing of log files
during suspend/resume operations.
svn path=/trunk/mono-tools/; revision=140260
-rw-r--r-- | Mono.Profiler/profiler-decoder-library/ChangeLog | 6 | ||||
-rw-r--r-- | Mono.Profiler/profiler-decoder-library/Reader.cs | 10 |
2 files changed, 14 insertions, 2 deletions
diff --git a/Mono.Profiler/profiler-decoder-library/ChangeLog b/Mono.Profiler/profiler-decoder-library/ChangeLog index 42fa12c0..04713220 100644 --- a/Mono.Profiler/profiler-decoder-library/ChangeLog +++ b/Mono.Profiler/profiler-decoder-library/ChangeLog @@ -1,3 +1,9 @@ +2009-08-19 Massimiliano Mantione <massi@ximian.com> + * Reader.cs: + Return null when file ends without an EndBlock, instead of throwing + an exception. This supports intermediate parsing of log files + during suspend/resume operations. + 2009-07-15 Mike Kestner <mkestner@novell.com> * Reader.cs: add a Close method to explicitly close the stream. diff --git a/Mono.Profiler/profiler-decoder-library/Reader.cs b/Mono.Profiler/profiler-decoder-library/Reader.cs index c6f1b537..1fbb4458 100644 --- a/Mono.Profiler/profiler-decoder-library/Reader.cs +++ b/Mono.Profiler/profiler-decoder-library/Reader.cs @@ -85,10 +85,16 @@ namespace Mono.Profiler { byte [] block; BlockCode code; int length; - BlockData result; + int bytesRead; + BlockData result = null; header = new byte [BlockData.BLOCK_HEADER_SIZE]; - stream.Read (header, 0, BlockData.BLOCK_HEADER_SIZE); + bytesRead = stream.Read (header, 0, BlockData.BLOCK_HEADER_SIZE); + if (bytesRead == 0) { + return null; + } else if (bytesRead < BlockData.BLOCK_HEADER_SIZE) { + throw new DecodingException (result, 0, String.Format ("Invalid header: length is {0} instead of {1}", bytesRead, BlockData.BLOCK_HEADER_SIZE)); + } fileOffset += (uint) BlockData.BLOCK_HEADER_SIZE; code = BlockData.DecodeHeaderBlockCode (header); |