pan/decode: Trace to stderr with PANDECODE_DUMP_FILE=stderr
Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com> Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4832>
This commit is contained in:
parent
d6588b87bf
commit
c409428006
|
@ -119,31 +119,33 @@ pointer_as_memory_reference(uint64_t ptr)
|
||||||
static int pandecode_dump_frame_count = 0;
|
static int pandecode_dump_frame_count = 0;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
pandecode_dump_file_open(void)
|
pandecode_dump_file_open(bool force_stderr)
|
||||||
{
|
{
|
||||||
if (pandecode_dump_stream)
|
if (pandecode_dump_stream)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
char buffer[1024];
|
|
||||||
|
|
||||||
/* This does a getenv every frame, so it is possible to use
|
/* This does a getenv every frame, so it is possible to use
|
||||||
* setenv to change the base at runtime.
|
* setenv to change the base at runtime.
|
||||||
*/
|
*/
|
||||||
const char *dump_file_base = debug_get_option("PANDECODE_DUMP_FILE", "pandecode.dump");
|
const char *dump_file_base = debug_get_option("PANDECODE_DUMP_FILE", "pandecode.dump");
|
||||||
snprintf(buffer, sizeof(buffer), "%s.%04d", dump_file_base, pandecode_dump_frame_count);
|
if (force_stderr || !strcmp(dump_file_base, "stderr"))
|
||||||
|
pandecode_dump_stream = stderr;
|
||||||
printf("pandecode: dump command stream to file %s\n", buffer);
|
else {
|
||||||
pandecode_dump_stream = fopen(buffer, "w");
|
char buffer[1024];
|
||||||
|
snprintf(buffer, sizeof(buffer), "%s.%04d", dump_file_base, pandecode_dump_frame_count);
|
||||||
if (!pandecode_dump_stream)
|
printf("pandecode: dump command stream to file %s\n", buffer);
|
||||||
fprintf(stderr,"pandecode: failed to open command stream log file %s\n",
|
pandecode_dump_stream = fopen(buffer, "w");
|
||||||
buffer);
|
if (!pandecode_dump_stream)
|
||||||
|
fprintf(stderr,
|
||||||
|
"pandecode: failed to open command stream log file %s\n",
|
||||||
|
buffer);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
pandecode_dump_file_close(void)
|
pandecode_dump_file_close(void)
|
||||||
{
|
{
|
||||||
if (pandecode_dump_stream) {
|
if (pandecode_dump_stream && pandecode_dump_stream != stderr) {
|
||||||
fclose(pandecode_dump_stream);
|
fclose(pandecode_dump_stream);
|
||||||
pandecode_dump_stream = NULL;
|
pandecode_dump_stream = NULL;
|
||||||
}
|
}
|
||||||
|
@ -153,11 +155,7 @@ void
|
||||||
pandecode_initialize(bool to_stderr)
|
pandecode_initialize(bool to_stderr)
|
||||||
{
|
{
|
||||||
list_inithead(&mmaps.node);
|
list_inithead(&mmaps.node);
|
||||||
|
pandecode_dump_file_open(to_stderr);
|
||||||
if (to_stderr)
|
|
||||||
pandecode_dump_stream = stderr;
|
|
||||||
else
|
|
||||||
pandecode_dump_file_open();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -165,7 +163,7 @@ pandecode_next_frame(void)
|
||||||
{
|
{
|
||||||
pandecode_dump_file_close();
|
pandecode_dump_file_close();
|
||||||
pandecode_dump_frame_count++;
|
pandecode_dump_frame_count++;
|
||||||
pandecode_dump_file_open();
|
pandecode_dump_file_open(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
Loading…
Reference in New Issue