mirror of https://gitlab.freedesktop.org/mesa/mesa
intel/tools/error2hangdump: Move code that will be shared with Xe parser to error2hangdump_lib
No changes in behavior expected here. Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Signed-off-by: José Roberto de Souza <jose.souza@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28720>
This commit is contained in:
parent
a7651d8337
commit
52d2d4ae2c
|
@ -34,34 +34,10 @@
|
|||
|
||||
#include "util/list.h"
|
||||
|
||||
#include "common/intel_hang_dump.h"
|
||||
|
||||
#include "error_decode_lib.h"
|
||||
#include "error2hangdump_lib.h"
|
||||
#include "intel/dev/intel_device_info.h"
|
||||
|
||||
static inline void
|
||||
_fail(const char *prefix, const char *format, ...)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
va_start(args, format);
|
||||
if (prefix)
|
||||
fprintf(stderr, "%s: ", prefix);
|
||||
vfprintf(stderr, format, args);
|
||||
va_end(args);
|
||||
|
||||
abort();
|
||||
}
|
||||
|
||||
#define _fail_if(cond, prefix, ...) do { \
|
||||
if (cond) \
|
||||
_fail(prefix, __VA_ARGS__); \
|
||||
} while (0)
|
||||
|
||||
#define fail_if(cond, ...) _fail_if(cond, NULL, __VA_ARGS__)
|
||||
|
||||
#define fail(...) fail_if(true, __VA_ARGS__)
|
||||
|
||||
static int zlib_inflate(uint32_t **ptr, int len)
|
||||
{
|
||||
struct z_stream_s zstream;
|
||||
|
@ -234,67 +210,6 @@ engine_from_name(const char *engine_name,
|
|||
fail("Unknown engine %s\n", engine_name);
|
||||
}
|
||||
|
||||
static void
|
||||
write_header(FILE *f)
|
||||
{
|
||||
struct intel_hang_dump_block_header header = {
|
||||
.base = {
|
||||
.type = INTEL_HANG_DUMP_BLOCK_TYPE_HEADER,
|
||||
},
|
||||
.magic = INTEL_HANG_DUMP_MAGIC,
|
||||
.version = INTEL_HANG_DUMP_VERSION,
|
||||
};
|
||||
|
||||
fwrite(&header, sizeof(header), 1, f);
|
||||
}
|
||||
|
||||
static void
|
||||
write_buffer(FILE *f,
|
||||
uint64_t offset,
|
||||
const void *data,
|
||||
uint64_t size,
|
||||
const char *name)
|
||||
{
|
||||
struct intel_hang_dump_block_bo header = {
|
||||
.base = {
|
||||
.type = INTEL_HANG_DUMP_BLOCK_TYPE_BO,
|
||||
},
|
||||
.offset = offset,
|
||||
.size = size,
|
||||
};
|
||||
snprintf(header.name, sizeof(header.name), "%s", name);
|
||||
|
||||
fwrite(&header, sizeof(header), 1, f);
|
||||
fwrite(data, size, 1, f);
|
||||
}
|
||||
|
||||
static void
|
||||
write_hw_image_buffer(FILE *f, const void *data, uint64_t size)
|
||||
{
|
||||
struct intel_hang_dump_block_hw_image header = {
|
||||
.base = {
|
||||
.type = INTEL_HANG_DUMP_BLOCK_TYPE_HW_IMAGE,
|
||||
},
|
||||
.size = size,
|
||||
};
|
||||
|
||||
fwrite(&header, sizeof(header), 1, f);
|
||||
fwrite(data, size, 1, f);
|
||||
}
|
||||
|
||||
static void
|
||||
write_exec(FILE *f, uint64_t offset)
|
||||
{
|
||||
struct intel_hang_dump_block_exec header = {
|
||||
.base = {
|
||||
.type = INTEL_HANG_DUMP_BLOCK_TYPE_EXEC,
|
||||
},
|
||||
.offset = offset,
|
||||
};
|
||||
|
||||
fwrite(&header, sizeof(header), 1, f);
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
|
|
|
@ -0,0 +1,69 @@
|
|||
/*
|
||||
* Copyright 2024 Intel Corporation
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#include "error2hangdump_lib.h"
|
||||
|
||||
#include "common/intel_hang_dump.h"
|
||||
|
||||
void
|
||||
write_header(FILE *f)
|
||||
{
|
||||
struct intel_hang_dump_block_header header = {
|
||||
.base = {
|
||||
.type = INTEL_HANG_DUMP_BLOCK_TYPE_HEADER,
|
||||
},
|
||||
.magic = INTEL_HANG_DUMP_MAGIC,
|
||||
.version = INTEL_HANG_DUMP_VERSION,
|
||||
};
|
||||
|
||||
fwrite(&header, sizeof(header), 1, f);
|
||||
}
|
||||
|
||||
void
|
||||
write_buffer(FILE *f,
|
||||
uint64_t offset,
|
||||
const void *data,
|
||||
uint64_t size,
|
||||
const char *name)
|
||||
{
|
||||
struct intel_hang_dump_block_bo header = {
|
||||
.base = {
|
||||
.type = INTEL_HANG_DUMP_BLOCK_TYPE_BO,
|
||||
},
|
||||
.offset = offset,
|
||||
.size = size,
|
||||
};
|
||||
snprintf(header.name, sizeof(header.name), "%s", name);
|
||||
|
||||
fwrite(&header, sizeof(header), 1, f);
|
||||
fwrite(data, size, 1, f);
|
||||
}
|
||||
|
||||
void
|
||||
write_hw_image_buffer(FILE *f, const void *data, uint64_t size)
|
||||
{
|
||||
struct intel_hang_dump_block_hw_image header = {
|
||||
.base = {
|
||||
.type = INTEL_HANG_DUMP_BLOCK_TYPE_HW_IMAGE,
|
||||
},
|
||||
.size = size,
|
||||
};
|
||||
|
||||
fwrite(&header, sizeof(header), 1, f);
|
||||
fwrite(data, size, 1, f);
|
||||
}
|
||||
|
||||
void
|
||||
write_exec(FILE *f, uint64_t offset)
|
||||
{
|
||||
struct intel_hang_dump_block_exec header = {
|
||||
.base = {
|
||||
.type = INTEL_HANG_DUMP_BLOCK_TYPE_EXEC,
|
||||
},
|
||||
.offset = offset,
|
||||
};
|
||||
|
||||
fwrite(&header, sizeof(header), 1, f);
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* Copyright 2024 Intel Corporation
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
static inline void
|
||||
_fail(const char *prefix, const char *format, ...)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
va_start(args, format);
|
||||
if (prefix)
|
||||
fprintf(stderr, "%s: ", prefix);
|
||||
vfprintf(stderr, format, args);
|
||||
va_end(args);
|
||||
|
||||
abort();
|
||||
}
|
||||
|
||||
#define _fail_if(cond, prefix, ...) do { \
|
||||
if (cond) \
|
||||
_fail(prefix, __VA_ARGS__); \
|
||||
} while (0)
|
||||
|
||||
#define fail_if(cond, ...) _fail_if(cond, NULL, __VA_ARGS__)
|
||||
|
||||
#define fail(...) fail_if(true, __VA_ARGS__)
|
||||
|
||||
void write_header(FILE *f);
|
||||
void write_buffer(FILE *f, uint64_t offset, const void *data, uint64_t size, const char *name);
|
||||
void write_hw_image_buffer(FILE *f, const void *data, uint64_t size);
|
||||
void write_exec(FILE *f, uint64_t offset);
|
|
@ -80,6 +80,8 @@ error2aub = executable(
|
|||
error2hangdump = executable(
|
||||
'intel_error2hangdump',
|
||||
files('error2hangdump.c',
|
||||
'error2hangdump_lib.c',
|
||||
'error2hangdump_lib.h',
|
||||
'error_decode_lib.c',
|
||||
'error_decode_lib.h'),
|
||||
dependencies : [dep_zlib, dep_dl, dep_thread, dep_m, idep_intel_dev],
|
||||
|
|
Loading…
Reference in New Issue