mirror of
https://github.com/tiagovignatti/intel-gpu-tools.git
synced 2025-06-20 06:16:13 +00:00
intel_error_decode: Factor out common decoding code
4 pieces of code were looking very similar. Let's factor out a common function in the not so unlikely case we need to tweak that code. Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
This commit is contained in:
parent
01eeab9448
commit
1d2ef9553a
@ -39,6 +39,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#define _GNU_SOURCE
|
#define _GNU_SOURCE
|
||||||
|
#include <stdbool.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
@ -319,6 +320,19 @@ static void print_batch(int is_batch, const char *ring_name, uint32_t gtt_offset
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void decode(struct drm_intel_decode *ctx, bool is_batch,
|
||||||
|
const char *ring_name, uint32_t gtt_offset, uint32_t *data,
|
||||||
|
int *count)
|
||||||
|
{
|
||||||
|
if (!*count)
|
||||||
|
return;
|
||||||
|
|
||||||
|
print_batch(is_batch, ring_name, gtt_offset);
|
||||||
|
drm_intel_decode_set_batch_pointer(ctx, data, gtt_offset, *count);
|
||||||
|
drm_intel_decode(ctx);
|
||||||
|
*count = 0;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
read_data_file(FILE *file)
|
read_data_file(FILE *file)
|
||||||
{
|
{
|
||||||
@ -350,14 +364,8 @@ read_data_file(FILE *file)
|
|||||||
matched = sscanf(dashes, "--- gtt_offset = 0x%08x\n",
|
matched = sscanf(dashes, "--- gtt_offset = 0x%08x\n",
|
||||||
&new_gtt_offset);
|
&new_gtt_offset);
|
||||||
if (matched == 1) {
|
if (matched == 1) {
|
||||||
if (count) {
|
decode(decode_ctx, is_batch, ring_name,
|
||||||
print_batch(is_batch, ring_name, gtt_offset);
|
gtt_offset, data, &count);
|
||||||
drm_intel_decode_set_batch_pointer(decode_ctx,
|
|
||||||
data, gtt_offset,
|
|
||||||
count);
|
|
||||||
drm_intel_decode(decode_ctx);
|
|
||||||
count = 0;
|
|
||||||
}
|
|
||||||
gtt_offset = new_gtt_offset;
|
gtt_offset = new_gtt_offset;
|
||||||
is_batch = 1;
|
is_batch = 1;
|
||||||
free(ring_name);
|
free(ring_name);
|
||||||
@ -368,14 +376,8 @@ read_data_file(FILE *file)
|
|||||||
matched = sscanf(dashes, "--- ringbuffer = 0x%08x\n",
|
matched = sscanf(dashes, "--- ringbuffer = 0x%08x\n",
|
||||||
&new_gtt_offset);
|
&new_gtt_offset);
|
||||||
if (matched == 1) {
|
if (matched == 1) {
|
||||||
if (count) {
|
decode(decode_ctx, is_batch, ring_name,
|
||||||
print_batch(is_batch, ring_name, gtt_offset);
|
gtt_offset, data, &count);
|
||||||
drm_intel_decode_set_batch_pointer(decode_ctx,
|
|
||||||
data, gtt_offset,
|
|
||||||
count);
|
|
||||||
drm_intel_decode(decode_ctx);
|
|
||||||
count = 0;
|
|
||||||
}
|
|
||||||
gtt_offset = new_gtt_offset;
|
gtt_offset = new_gtt_offset;
|
||||||
is_batch = 0;
|
is_batch = 0;
|
||||||
free(ring_name);
|
free(ring_name);
|
||||||
@ -389,14 +391,8 @@ read_data_file(FILE *file)
|
|||||||
unsigned int reg;
|
unsigned int reg;
|
||||||
|
|
||||||
/* display reg section is after the ringbuffers, don't mix them */
|
/* display reg section is after the ringbuffers, don't mix them */
|
||||||
if (count) {
|
decode(decode_ctx, is_batch, ring_name, gtt_offset,
|
||||||
print_batch(is_batch, ring_name, gtt_offset);
|
data, &count);
|
||||||
drm_intel_decode_set_batch_pointer(decode_ctx,
|
|
||||||
data, gtt_offset,
|
|
||||||
count);
|
|
||||||
drm_intel_decode(decode_ctx);
|
|
||||||
count = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("%s", line);
|
printf("%s", line);
|
||||||
|
|
||||||
@ -464,13 +460,7 @@ read_data_file(FILE *file)
|
|||||||
data[count-1] = value;
|
data[count-1] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count) {
|
decode(decode_ctx, is_batch, ring_name, gtt_offset, data, &count);
|
||||||
print_batch(is_batch, ring_name, gtt_offset);
|
|
||||||
drm_intel_decode_set_batch_pointer(decode_ctx,
|
|
||||||
data, gtt_offset,
|
|
||||||
count);
|
|
||||||
drm_intel_decode(decode_ctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
free(data);
|
free(data);
|
||||||
free(line);
|
free(line);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user