From: Kevin Rogovin <kevin.rogo...@intel.com> Signed-off-by: Kevin Rogovin <kevin.rogo...@intel.com> --- src/intel/Makefile.tools.am | 5 ++ src/intel/tools/.gitignore | 1 + src/intel/tools/i965_batchbuffer_dump_show.c | 129 +++++++++++++++++++++++++++ 3 files changed, 135 insertions(+) create mode 100644 src/intel/tools/i965_batchbuffer_dump_show.c
diff --git a/src/intel/Makefile.tools.am b/src/intel/Makefile.tools.am index 062c225c89..d1a87e6991 100644 --- a/src/intel/Makefile.tools.am +++ b/src/intel/Makefile.tools.am @@ -30,6 +30,8 @@ noinst_PROGRAMS += \ intellib_LTLIBRARIES = \ tools/libi965_batchbuffer_logger.la +intelbin_PROGRAMS = tools/i965_batchbuffer_dump_show + intelbin_SCRIPTS = tools/i965_batchbuffer_logger_sh CLEANFILES += $(intelbin_SCRIPTS) @@ -98,3 +100,6 @@ tools_libi965_batchbuffer_logger_la_LDFLAGS = \ intel_sed_prefix_vars = sed -e 's,[@]libdir[@],$(intellibdir),g' tools/i965_batchbuffer_logger_sh: tools/i965_batchbuffer_logger_sh.in $(intel_sed_prefix_vars) < tools/i965_batchbuffer_logger_sh.in > tools/i965_batchbuffer_logger_sh + +tools_i965_batchbuffer_dump_show_SOURCES = \ + tools/i965_batchbuffer_dump_show.c diff --git a/src/intel/tools/.gitignore b/src/intel/tools/.gitignore index fa9bf70808..7d95bcdf3a 100644 --- a/src/intel/tools/.gitignore +++ b/src/intel/tools/.gitignore @@ -1,3 +1,4 @@ /aubinator /aubinator_error_decode /i965_batchbuffer_logger_sh +/i965_batchbuffer_dump_show diff --git a/src/intel/tools/i965_batchbuffer_dump_show.c b/src/intel/tools/i965_batchbuffer_dump_show.c new file mode 100644 index 0000000000..0e8c372e63 --- /dev/null +++ b/src/intel/tools/i965_batchbuffer_dump_show.c @@ -0,0 +1,129 @@ +/* + * Copyright © 2017 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#include <stdio.h> +#include <stdlib.h> +#include <stdint.h> +#include <stdbool.h> + +#include "tools/i965_batchbuffer_logger_output.h" + +static +void +print_tabs(int l) +{ + for(int i = 0; i < l; ++i) { + printf("\t"); + } +} + +static +void +print_instrumentation_message(int block_level, + const struct i965_batchbuffer_logger_header *hdr, + FILE *pfile) +{ + bool line_start; + uint32_t i; + char c = 0; + size_t num_read; + + /* assume name has no EOLs */ + print_tabs(block_level); + for (i = 0; !feof(pfile) && i < hdr->name_length; ++i) { + num_read = fread(&c, sizeof(c), 1, pfile); + if (num_read != 1) + return; + printf("%c", c); + } + + if (hdr->value_length > 0) { + printf(" : "); + } + + /* print the value (if there is one). */ + for (i = 0, line_start = false; !feof(pfile) && i < hdr->value_length; ++i) { + num_read = fread(&c, sizeof(c), 1, pfile); + + if (num_read != 1) + break; + + if (line_start) { + print_tabs(block_level); + } + + printf("%c", c); + line_start = (c == '\n'); + } + + if (c != '\n') { + printf("\n"); + } +} + + +int +main(int argc, char **argv) +{ + FILE *pfile; + int block_level = 0; + + if (argc != 2) { + return -1; + } + + pfile = fopen(argv[1], "r"); + if (pfile == NULL) { + return -1; + } + + while (!feof(pfile)) { + struct i965_batchbuffer_logger_header hdr; + size_t num_read; + + num_read = fread(&hdr, sizeof(hdr), 1, pfile); + if (num_read != 1) + break; + + switch(hdr.type) { + case I965_BATCHBUFFER_LOGGER_MESSAGE_BLOCK_BEGIN: { + print_instrumentation_message(block_level, &hdr, pfile); + ++block_level; + } + break; + + case I965_BATCHBUFFER_LOGGER_MESSAGE_BLOCK_END: { + --block_level; + } + break; + + case I965_BATCHBUFFER_LOGGER_MESSAGE_VALUE: { + print_instrumentation_message(block_level, &hdr, pfile); + } + break; + } + } + + fclose(pfile); + return 0; +} -- 2.14.2 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev