Skip to content
Browse files

demmt: output with colors

  • Loading branch information...
1 parent ace4900 commit 0ed18f62ec46431aab5b5146e896283552d265bf @mslusarz mslusarz committed Jul 7, 2014
Showing with 14 additions and 7 deletions.
  1. +8 −2 rnn/demmt.c
  2. +1 −0 rnn/demmt.h
  3. +1 −2 rnn/demmt_objects.c
  4. +4 −3 rnn/demmt_pushbuf.c
View
10 rnn/demmt.c
@@ -57,6 +57,7 @@ int decode_invalid_buffers = 1;
int find_ib_buffer = 0;
int quiet = 0;
int disassembly_shaders = 1;
+const struct envy_colors *colors = NULL;
static void dump(struct buffer *buf)
{
@@ -1076,8 +1077,9 @@ static void usage()
" -o\t\tdump ioctl data\n"
" -q\t\t(quiet) print only the most important data (for now only pushbufs from IB's)\n"
" -a\t\tdisable shader disassembly\n"
+ " -c\t\tenable colors\n"
"\n"
- " -c\t\tdo not \"compress\" obvious buffer clears\n"
+ " -s\t\tdo not \"compress\" obvious buffer clears\n"
" -i\t\tdo not guess invalid pushbufs\n"
" -d\t\thide invalid pushbufs\n"
" -e\t\tdo not decode invalid pushbufs\n"
@@ -1102,7 +1104,7 @@ int main(int argc, char *argv[])
chip += 2;
chipset = strtoul(chip, NULL, 16);
}
- else if (!strcmp(argv[i], "-c"))
+ else if (!strcmp(argv[i], "-s"))
compress_clears = 0;
else if (!strcmp(argv[i], "-i"))
guess_invalid_pushbuf = 0;
@@ -1126,12 +1128,16 @@ int main(int argc, char *argv[])
quiet = 1;
else if (!strcmp(argv[i], "-a"))
disassembly_shaders = 0;
+ else if (!strcmp(argv[i], "-c"))
+ colors = &envy_def_colors;
else
usage();
}
if (chipset == 0)
usage();
+ if (!colors)
+ colors = &envy_null_colors;
/* set up an rnn context */
rnn_init();
View
1 rnn/demmt.h
@@ -7,6 +7,7 @@
extern int find_ib_buffer;
extern int quiet;
extern int disassembly_shaders;
+extern const struct envy_colors *colors;
#define mmt_debug(fmt, ...) do { if (MMT_DEBUG) fprintf(stderr, fmt, __VA_ARGS__); } while (0)
#define mmt_log(fmt, ...) do { if (!find_ib_buffer && !quiet) fprintf(stdout, "%64s" fmt, " ", __VA_ARGS__); } while (0)
View
3 rnn/demmt_objects.c
@@ -108,8 +108,7 @@ void demmt_parse_command(uint32_t class_, int mthd, uint32_t data)
struct varinfo *var = varinfo_new(isa_nvc0->vardata);
envydis(isa_nvc0, stdout, code_buffer->data + reg->start + 20 * 4, 0, \
- reg->end - reg->start - 20 * 4, var, 0, NULL, 0,
- /*1 ? &envy_def_colors :*/ &envy_null_colors);
+ reg->end - reg->start - 20 * 4, var, 0, NULL, 0, colors);
varinfo_del(var);
break;
}
View
7 rnn/demmt_pushbuf.c
@@ -72,6 +72,7 @@ void pushbuf_add_object(uint32_t handle, uint32_t class)
obj->handle = handle;
obj->class = class;
obj->ctx = rnndec_newcontext(rnndb);
+ obj->ctx->colors = colors;
v = NULL;
FINDARRAY(chs->vals, v, v->value == chipset);
@@ -131,9 +132,9 @@ static void decode_method(struct pushbuf_decode_state *state, uint32_t data, cha
/* get an object name */
if (obj && obj->name)
- asprintf(&dec_obj, "%s", obj->name);
+ asprintf(&dec_obj, "%s%s%s", colors->rname, obj->name, colors->reset);
else
- asprintf(&dec_obj, "OBJ%X", obj ? obj->class : 0);
+ asprintf(&dec_obj, "%sOBJ%X%s", colors->err, obj ? obj->class : 0, colors->reset);
/* get the method name and value */
if (obj)
@@ -146,7 +147,7 @@ static void decode_method(struct pushbuf_decode_state *state, uint32_t data, cha
free(ai);
}
else
- asprintf(&dec_addr, "0x%x", state->addr);
+ asprintf(&dec_addr, "%s0x%x%s", colors->err, state->addr, colors->reset);
/* write it */
if (state->addr == 0)

0 comments on commit 0ed18f6

Please sign in to comment.
Something went wrong with that request. Please try again.