Created
August 12, 2019 12:06
-
-
Save smarr/8fb2afe90f7292e29876cb163e722ac5 to your computer and use it in GitHub Desktop.
SOMns Trace file Binary Template for Hex Fiend
This file contains 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
## Binary Template for Hex Fiend | |
## https://github.com/ridiculousfish/HexFiend | |
## This gives a very basic way to navigate through a trace file | |
set event_types [dict create \ | |
0 "ACTOR_CREATION" \ | |
1 "ACTOR_CONTEXT" \ | |
2 "MESSAGE" \ | |
3 "PROMISE_MESSAGE" \ | |
4 "SYSTEM_CALL" \ | |
5 "CHANNEL_CREATION" \ | |
6 "PROCESS_CONTEXT" \ | |
7 "CHANNEL_READ" \ | |
8 "CHANNEL_WRITE" \ | |
9 "PROCESS_CREATION" \ | |
] | |
while {![end]} { | |
set save_pos [pos] | |
set record_type [uint8] | |
if { [dict exists $event_types $record_type] } { | |
set type [dict get $event_types $record_type] | |
} else { | |
set type "unknown???" | |
} | |
move -1 | |
section $type { | |
entry "Offset" $save_pos | |
entry "Record Type" $record_type 1 | |
} | |
if { $record_type == 0 || $record_type == 5 || $record_type == 9 } { | |
move 8 | |
} elseif { $record_type == 1 || $record_type == 6} { | |
move 10 | |
} elseif { $record_type == 2 } { | |
move 8 | |
} elseif { $record_type == 3 } { | |
set type "" | |
move 16 | |
} elseif { $record_type == 4} { | |
move 4 | |
} elseif { $record_type == 7 || $record_type == 8 } { | |
move 16 | |
} else { | |
# TODO EXTERNAL_MESSAGE | |
# EXTERNAL_PROMISE_MESSAGE | |
move 1 | |
} | |
move 1 | |
} | |
# ACTOR_CREATION(0), | |
# ACTOR_CONTEXT(1), | |
# MESSAGE(2), | |
# PROMISE_MESSAGE(3), | |
# SYSTEM_CALL(4), | |
# CHANNEL_CREATION(5), | |
# PROCESS_CONTEXT(6), | |
# CHANNEL_READ(7), | |
# CHANNEL_WRITE(8), | |
# PROCESS_CREATION(9); | |
# ONE_EVENT_SIZE = 1 + Long.BYTES; | |
# TWO_EVENT_SIZE = 1 + (2 * Long.BYTES); | |
# THREE_EVENT_SIZE = 1 + (3 * Long.BYTES); | |
# case ACTOR_CREATION: | |
# case CHANNEL_CREATION: | |
# case PROCESS_CREATION: | |
# long newEntityId = getId(b, numbytes); | |
# | |
# if (scanning) { | |
# if (newEntityId == 0) { | |
# assert !ctx.readMainActor : "There should be only one main actor."; | |
# ctx.readMainActor = true; | |
# } | |
# | |
# EntityNode newEntity = getOrCreateEntityEntry(recordType, newEntityId); | |
# newEntity.ordering = ctx.ordering; | |
# ctx.currentEntity.addChild(newEntity); | |
# ctx.parsedEntities++; | |
# } | |
# assert b.position() == start + RecordEventNodes.ONE_EVENT_SIZE; | |
# break; | |
# | |
# case ACTOR_CONTEXT: | |
# case PROCESS_CONTEXT: | |
# if (scanning) { | |
# // if (startPosition + start > 748120) { | |
# // System.out.println("ddd"); | |
# // } | |
# | |
# if (ctx.currentEntity != null) { | |
# ctx.currentEntity.setLength(startPosition + start | |
# // + Byte.BYTES /* This is the recordType, so we reach the `return true` below */ | |
# - ctx.entityStartOffset); | |
# } | |
# ctx.ordering = Short.toUnsignedInt(b.getShort()); | |
# long currentEntityId = getId(b, Long.BYTES); | |
# ctx.currentEntity = getOrCreateEntityEntry(recordType, currentEntityId); | |
# assert ctx.currentEntity != null; | |
# ctx.currentEntity.registerContext(ctx.ordering, startPosition + start); | |
# | |
# assert b.position() == start + 11; | |
# ctx.entityStartOffset = startPosition + start; | |
# | |
# } else { | |
# if (ctx.once) { | |
# ctx.ordering = Short.toUnsignedInt(b.getShort()); | |
# getId(b, Long.BYTES); | |
# ctx.once = false; | |
# } else { | |
# // When we are not scanning for contexts, this means that the context we wanted | |
# // to process is over. | |
# return true; | |
# } | |
# } | |
# | |
# break; | |
# | |
# case MESSAGE: | |
# ctx.parsedMessages++; | |
# sender = getId(b, numbytes); | |
# | |
# if (external) { | |
# edat = b.getLong(); | |
# if (!scanning) { | |
# method = (short) (edat >> 32); | |
# dataId = (int) edat; | |
# ((ActorNode) ctx.currentEntity).addMessageRecord( | |
# new ExternalMessageRecord(sender, method, dataId)); | |
# } | |
# assert b.position() == start + RecordEventNodes.TWO_EVENT_SIZE; | |
# return false; | |
# } | |
# | |
# if (!scanning) { | |
# ((ActorNode) ctx.currentEntity).addMessageRecord(new MessageRecord(sender)); | |
# } | |
# assert b.position() == start + RecordEventNodes.ONE_EVENT_SIZE; | |
# break; | |
# case PROMISE_MESSAGE: | |
# ctx.parsedMessages++; | |
# sender = getId(b, numbytes); | |
# resolver = getId(b, numbytes); | |
# | |
# if (external) { | |
# edat = b.getLong(); | |
# method = (short) (edat >> 32); | |
# dataId = (int) edat; | |
# if (!scanning) { | |
# ((ActorNode) ctx.currentEntity).addMessageRecord( | |
# new ExternalPromiseMessageRecord(sender, resolver, method, dataId)); | |
# } | |
# assert b.position() == start + RecordEventNodes.THREE_EVENT_SIZE; | |
# return false; | |
# } | |
# if (!scanning) { | |
# ((ActorNode) ctx.currentEntity).addMessageRecord( | |
# new PromiseMessageRecord(sender, resolver)); | |
# } | |
# assert b.position() == start + RecordEventNodes.TWO_EVENT_SIZE; | |
# | |
# break; | |
# case SYSTEM_CALL: | |
# dataId = b.getInt(); | |
# break; | |
# case CHANNEL_READ: | |
# long channelRId = b.getLong(); | |
# long nread = b.getLong(); | |
# ctx.currentEntity.addReplayEvent(new ChannelReadRecord(channelRId, nread)); | |
# assert b.position() == start + RecordEventNodes.TWO_EVENT_SIZE; | |
# break; | |
# case CHANNEL_WRITE: | |
# long channelWId = b.getLong(); | |
# long nwrite = b.getLong(); | |
# ctx.currentEntity.addReplayEvent(new ChannelWriteRecord(channelWId, nwrite)); | |
# assert b.position() == start + RecordEventNodes.TWO_EVENT_SIZE; | |
# break; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment