2 * Copyright (C) 2019 Alyssa Rosenzweig
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
35 pandecode_read_filename(const char *base
, const char *name
)
38 asprintf(&fn
, "%s/%s", base
, name
);
40 FILE *fp
= fopen(fn
, "rb");
47 pandecode_read_memory(const char *base
, const char *name
, mali_ptr gpu_va
)
49 FILE *fp
= pandecode_read_filename(base
, name
);
52 fprintf(stderr
, "Warning: missing %s\n", name
);
56 fseek(fp
, 0, SEEK_END
);
58 fseek(fp
, 0, SEEK_SET
);
60 char *buf
= malloc(sz
);
62 fread(buf
, 1, sz
, fp
);
65 pandecode_inject_mmap(gpu_va
, buf
, sz
, name
);
69 pandecode_read_mmap(const char *base
, const char *line
)
71 assert(strlen(line
) < 500);
76 sscanf(line
, "MMAP %" PRIx64
" %s", &addr
, name
);
77 pandecode_read_memory(base
, name
, addr
);
81 pandecode_read_job_submit(const char *base
, const char *line
)
87 sscanf(line
, "JS %" PRIx64
" %x %x", &addr
, &core_req
, &is_bifrost
);
88 pandecode_replay_jc(addr
, is_bifrost
);
93 /* Reads the control file, processing as it goes. */
96 pandecode_read_control(const char *base
)
98 FILE *fp
= pandecode_read_filename(base
, "control.log");
101 fprintf(stderr
, "Invalid directory path\n");
108 while (getline(&line
, &len
, fp
) != -1) {
111 pandecode_read_mmap(base
, line
);
115 pandecode_read_job_submit(base
, line
);
126 main(int argc
, char **argv
)
129 fprintf(stderr
, "Usage: pandecode [directory]\n");
133 pandecode_initialize();
134 pandecode_read_control(argv
[1]);