HprofPrimitiveArrayStripper: sync with android-register, fix bugs, clean up#2736
Open
HprofPrimitiveArrayStripper: sync with android-register, fix bugs, clean up#2736
Conversation
- Add StreamingSinkProvider (mirrors StreamingSourceProvider pattern) - Replace BufferedSink parameter with StreamingSinkProvider so the sink is opened and closed inside the function - Refactor parsing logic into a private stripPrimitiveArrays(CopyingSource) method (cleaner separation, matches android-register structure) - Fix INSTANCE_DUMP: stackTraceSerialNumber is u4 (intByteSize), not identifier-sized — this was wrong for 8-byte identifier heaps - Fix PRIMITIVE_ARRAY_DUMP: remove extra sink.writeByte(type) that was writing the type byte twice (CopyingSource.transferUnsignedByte already copies it) - Add CopyingSource.indexOf delegate - Use repeat() instead of for (i in 0 until ...) loops - Remove TODO comment from CHAR array handling - Add deleteInputHprofFile parameter to SharkLog logging path - Clean up test: remove debugging @test fun foo() and raw-byte helpers, replace with proper writeRawTestHprof fixture using HprofWriter that tests LongArray zeroing, CharArray '?' replacement, and instance dump wrapper value zeroing; remove duplicate ByteArraySourceProvider class Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
9a58fb7 to
89c3121
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Sync
HprofPrimitiveArrayStripperwith the battle-tested android-register implementation, fixing two correctness bugs in the process, and clean up the tests.Changes
Bug fixes
INSTANCE_DUMPparsing:stackTraceSerialNumberis always au4(4 bytes), not identifier-sized. This was silently corrupting output for heap dumps with 8-byte identifiers (most Android heap dumps).PRIMITIVE_ARRAY_DUMPdouble-write:CopyingSource.transferUnsignedByte()already copies the byte to the sink — the extrasink.writeByte(type)call was writing the type byte twice, corrupting all primitive array records.API / structure
StreamingSinkProvider(mirrorsStreamingSourceProvider) so the sink lifecycle is managed inside the function via.use {}, consistent with how source opening worksBufferedSinkparameter withStreamingSinkProviderin the streaming overloadstripPrimitiveArrays(CopyingSource)methodCopyingSource.indexOfdelegate (needed by the refactored private method)repeat()instead offor (i in 0 until ...)loopsTests
@Test fun foo()debugging test (broken assertions, println noise)writeRawTestHproffixture usingHprofWriter, testing LongArray zeroing, CharArray'?'replacement, and instance dump wrapper value zeroingByteArraySourceProviderinner class (it's already in main source)