Permalink
Browse files

demmt: add option to find possible IB

  • Loading branch information...
mslusarz committed Jul 5, 2014
1 parent 30fc4a1 commit 0ecc81b94d010b9c826b6f598d40f769e4c331c3
Showing with 36 additions and 4 deletions.
  1. +32 −1 rnn/demmt.c
  2. +4 −3 rnn/demmt.h
View
@@ -59,6 +59,7 @@ int chipset;
int guess_invalid_pushbuf = 1;
int invalid_pushbufs_visible = 1;
int decode_invalid_buffers = 1;
+int find_ib_buffer = 0;
static void dump(int id)
{
@@ -89,6 +90,30 @@ static void dump_writes(int id)
comment[0][0] = 0;
comment[1][0] = 0;
+ if (find_ib_buffer)
+ {
+ if (cur->start != 0 || cur->end < 8)
+ return;
+ uint32_t *data = (uint32_t *)buffers[id]->data;
+ if (!data[0] || !data[1])
+ return;
+ if (data[0] & 0x3)
+ return;
+ uint64_t gpu_addr = (((uint64_t)(data[1] & 0xff)) << 32) | (data[0] & 0xfffffffc);
+ int i;
+ for (i = 0; i < MAX_ID; ++i)
+ {
+ if (buffers[i] && buffers[i]->gpu_start == gpu_addr &&
+ buffers[i]->length >= 4 * ((data[1] & 0x7fffffff) >> 10))
+ {
+ fprintf(stdout, "possible IB buffer: %d\n", id);
+ break;
+ }
+ }
+
+ return;
+ }
+
mmt_log("currently buffered writes for id: %d:\n", id);
while (cur)
{
@@ -521,6 +546,9 @@ static void clear_buffered_writes()
static void demmt_memread(struct mmt_read *w, void *state)
{
+ if (find_ib_buffer)
+ return;
+
char comment[50];
if (print_gpu_addresses && buffers[w->id]->gpu_start)
sprintf(comment, " (gpu=0x%08lx)", buffers[w->id]->gpu_start + w->offset);
@@ -924,7 +952,8 @@ static void usage()
fprintf(stderr, "Usage: demmt [OPTION]\n"
"Decodes binary trace files generated by Valgrind MMT. Reads standard input.\n\n"
" -m 'chipset'\tset chipset version\n"
- " -n id\t\tassume buffer \"id\" contains IB entries\n"
+ " -f\t\tfind possible IB buffer(s)\n"
+ " -n id\t\tset buffer \"id\" as IB\n"
" -g\t\tprint gpu addresses\n"
" -o\t\tdump ioctl data\n"
"\n"
@@ -971,6 +1000,8 @@ int main(int argc, char *argv[])
dump_ioctls = 1;
else if (!strcmp(argv[i], "-g"))
print_gpu_addresses = 1;
+ else if (!strcmp(argv[i], "-f"))
+ find_ib_buffer = 1;
else
usage();
}
View
@@ -4,10 +4,11 @@
#include "demmt_pushbuf.h"
#define MMT_DEBUG 0
+extern int find_ib_buffer;
-#define mmt_debug(fmt, ...) do { if (MMT_DEBUG) fprintf(stderr, fmt, __VA_ARGS__); } while (0)
-#define mmt_log(fmt, ...) do { fprintf(stdout, "%64s" fmt, " ", __VA_ARGS__); } while (0)
-#define mmt_log_cont(fmt, ...) do { fprintf(stdout, fmt, __VA_ARGS__); } while (0)
+#define mmt_debug(fmt, ...) do { if (MMT_DEBUG) fprintf(stderr, fmt, __VA_ARGS__); } while (0)
+#define mmt_log(fmt, ...) do { if (!find_ib_buffer) fprintf(stdout, "%64s" fmt, " ", __VA_ARGS__); } while (0)
+#define mmt_log_cont(fmt, ...) do { if (!find_ib_buffer) fprintf(stdout, fmt, __VA_ARGS__); } while (0)
#define mmt_error(fmt, ...) do { fprintf(stderr, fmt, __VA_ARGS__); } while (0)
struct buffer

0 comments on commit 0ecc81b

Please sign in to comment.