Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/kern_ctf.c
Show All 34 Lines | |||||
* (annoyingly) covered by the CDDL. We will just use a few bytes from | * (annoyingly) covered by the CDDL. We will just use a few bytes from | ||||
* it as an integer array where we 'know' what they mean. | * it as an integer array where we 'know' what they mean. | ||||
*/ | */ | ||||
#define CTF_HDR_SIZE 36 | #define CTF_HDR_SIZE 36 | ||||
#define CTF_HDR_STRTAB_U32 7 | #define CTF_HDR_STRTAB_U32 7 | ||||
#define CTF_HDR_STRLEN_U32 8 | #define CTF_HDR_STRLEN_U32 8 | ||||
#ifdef DDB_CTF | #ifdef DDB_CTF | ||||
#include <zlib.h> | |||||
static void * | static void * | ||||
z_alloc(void *nil, u_int items, u_int size) | z_alloc(void *nil, u_int items, u_int size) | ||||
{ | { | ||||
void *ptr; | void *ptr; | ||||
ptr = malloc(items * size, M_TEMP, M_NOWAIT); | ptr = malloc(items * size, M_TEMP, M_NOWAIT); | ||||
return ptr; | return ptr; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 212 Lines • ▼ Show 20 Lines | if (raw != NULL) { | ||||
*/ | */ | ||||
bcopy(ctf_hdr, ctftab, sizeof(ctf_hdr)); | bcopy(ctf_hdr, ctftab, sizeof(ctf_hdr)); | ||||
/* Initialise the zlib structure. */ | /* Initialise the zlib structure. */ | ||||
bzero(&zs, sizeof(zs)); | bzero(&zs, sizeof(zs)); | ||||
zs.zalloc = z_alloc; | zs.zalloc = z_alloc; | ||||
zs.zfree = z_free; | zs.zfree = z_free; | ||||
if (inflateInit(&zs) != Z_OK) { | if (z_inflateInit(&zs) != Z_OK) { | ||||
error = EIO; | error = EIO; | ||||
goto out; | goto out; | ||||
} | } | ||||
zs.avail_in = shdr[i].sh_size - sizeof(ctf_hdr); | zs.avail_in = shdr[i].sh_size - sizeof(ctf_hdr); | ||||
zs.next_in = ((uint8_t *) raw) + sizeof(ctf_hdr); | zs.next_in = ((uint8_t *) raw) + sizeof(ctf_hdr); | ||||
zs.avail_out = sz - sizeof(ctf_hdr); | zs.avail_out = sz - sizeof(ctf_hdr); | ||||
zs.next_out = ((uint8_t *) ctftab) + sizeof(ctf_hdr); | zs.next_out = ((uint8_t *) ctftab) + sizeof(ctf_hdr); | ||||
ret = inflate(&zs, Z_FINISH); | ret = z_inflate(&zs, Z_FINISH); | ||||
inflateEnd(&zs); | z_inflateEnd(&zs); | ||||
if (ret != Z_STREAM_END) { | if (ret != Z_STREAM_END) { | ||||
printf("%s(%d): zlib inflate returned %d\n", __func__, __LINE__, ret); | printf("%s(%d): zlib z_inflate returned %d\n", __func__, __LINE__, ret); | ||||
error = EIO; | error = EIO; | ||||
goto out; | goto out; | ||||
} | } | ||||
} | } | ||||
/* Got the CTF data! */ | /* Got the CTF data! */ | ||||
ef->ctftab = ctftab; | ef->ctftab = ctftab; | ||||
ef->ctfcnt = shdr[i].sh_size; | ef->ctfcnt = shdr[i].sh_size; | ||||
Show All 35 Lines |