mildsunrise / darter

:detective: Dart / Flutter VM snapshot analyzer
GNU Affero General Public License v3.0
305 stars 55 forks source link

KeyError: 3 #8

Open kerneltea opened 2 years ago

kerneltea commented 2 years ago

Hello,

I am trying to use Darter on a libapp.so extracted (unzipped) from a .APK generated by flutter from a Flutter app, Encountered the following problem

Traceback (most recent call last): File "/Users/realcradle/dev/python/disassembly/main.py", line 110, in getFiles('samples/libapp.so', '') File "/Users/realcradle/dev/python/disassembly/main.py", line 91, in getFiles s = parse_elf_snapshot(elfFile) File "/Users/realcradle/dev/python/disassembly/darter/file.py", line 42, in parse_elf_snapshot base = Snapshot(data=blobs[0], data_offset=offsets[0], File "/Users/realcradle/dev/python/disassembly/darter/core.py", line 232, in parse self.initialize_clusters() File "/Users/realcradle/dev/python/disassembly/darter/core.py", line 374, in initialize_clusters key = map1[self.kind] KeyError: 3

image

image

mildsunrise commented 2 years ago

oh, there's a new kind of snapshot? sorry, I've been disconnected from dart development for a while

mildsunrise commented 2 years ago

yes, it seems they added a new kFullCore kind of snapshot, in https://github.com/dart-lang/sdk/commit/d77fff73075426306d2c3d77ccf61afd3eba9ab1?branch=d77fff73075426306d2c3d77ccf61afd3eba9ab1, but they added it at the start so kFullAOT snapshots now have the number 3 rather than 2.

I should fix that but I have no time to get this project up to date, sorry. You can fix the code for your version, by changing:

https://github.com/mildsunrise/darter/blob/3d33042413e898aa914faaddb7d6f1ce20764b6e/darter/constants.py#L41-L48

to

kKind = [
    ('kFull', "Full snapshot of an application"),
    ('kFullCore', "Full snapshot of core libraries. Agnostic to null safety."),
    ('kFullJIT', "Full + JIT code"),
    ('kFullAOT', "Full + AOT code"),
    ('kMessage', "A partial snapshot used only for isolate messaging"),
    ('kNone', "gen_snapshot"),
    ('kInvalid', None),
]