freedreno/crashdec: handle section name typos
authorRob Clark <robdclark@chromium.org>
Sat, 8 Aug 2020 16:50:08 +0000 (09:50 -0700)
committerMarge Bot <eric+marge@anholt.net>
Tue, 11 Aug 2020 03:13:42 +0000 (03:13 +0000)
The fixes tag isn't so much because it was incorrect before, but because
I'm going to send a kernel patch to fix the typo, and that will break
old crashdec.

Fixes: 1ea4ef0d3be ("freedreno: slurp in decode tools")
Signed-off-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6242>

src/freedreno/.gitlab-ci/reference/crash.log
src/freedreno/decode/crashdec.c

index 4cbc4e42bed45d4e21384b004261edd99e5d769b..e0c20435ae7ce2e71d22d9485a0f080a003bbe1f 100644 (file)
@@ -2452,7 +2452,7 @@ registers-gmu:
        00000000        0x12b: 00000000
        00000000        0x140: 00000000
 indexed-registers:
-  - regs-name: CP_SEQ_STAT
+  - regs-name: CP_SQE_STAT
     dwords: 51
         PC: 00c5
        $01: deadd00d           $11: 00000000
index 8c5ccb562c735690489f257ce724fd52b492ca0d..933da0ddec06849f21237939888aafdae5d76a3b 100644 (file)
@@ -101,6 +101,23 @@ regval(const char *name)
  * Line reading and string helpers:
  */
 
+static char *
+replacestr(char *line, const char *find, const char *replace)
+{
+       char *tail, *s;
+
+       if (!(s = strstr(line, find)))
+               return line;
+
+       tail = s + strlen(find);
+
+       char *newline;
+       asprintf(&newline, "%.*s%s%s", (int)(s - line), line, replace, tail);
+       free(line);
+
+       return newline;
+}
+
 static char *lastline;
 static char *pushedline;
 
@@ -120,6 +137,10 @@ popline(void)
        if (getline(&r, &n, in) < 0)
                exit(0);
 
+       /* Handle section name typo's from earlier kernels: */
+       r = replacestr(r, "CP_MEMPOOOL", "CP_MEMPOOL");
+       r = replacestr(r, "CP_SEQ_STAT", "CP_SQE_STAT");
+
        lastline = r;
        return r;
 }
@@ -471,7 +492,7 @@ decode_clusters(void)
  */
 
 static void
-dump_cp_seq_stat(uint32_t *stat)
+dump_cp_sqe_stat(uint32_t *stat)
 {
        printf("\t PC: %04x\n", stat[0]);
        stat++;
@@ -850,23 +871,23 @@ decode_indexed_registers(void)
                         * so far) not useful, so skip them if not in verbose mode:
                         */
                        bool dump = verbose ||
-                               !strcmp(name, "CP_SEQ_STAT") ||
+                               !strcmp(name, "CP_SQE_STAT") ||
                                !strcmp(name, "CP_DRAW_STATE") ||
                                !strcmp(name, "CP_ROQ") ||
                                0;
 
-                       if (!strcmp(name, "CP_SEQ_STAT"))
-                               dump_cp_seq_stat(buf);
+                       if (!strcmp(name, "CP_SQE_STAT"))
+                               dump_cp_sqe_stat(buf);
 
                        if (!strcmp(name, "CP_UCODE_DBG_DATA"))
                                dump_cp_ucode_dbg(buf);
 
-                       /* note that name was typo'd in earlier kernels: */
-                       if (!strcmp(name, "CP_MEMPOOL") || !strcmp(name, "CP_MEMPOOOL"))
+                       if (!strcmp(name, "CP_MEMPOOL"))
                                dump_cp_mem_pool(buf);
 
                        if (dump)
                                dump_hex_ascii(buf, 4 * sizedwords, 1);
+
                        free(buf);
 
                        continue;