Lines Matching full:core
48 #include "core.h"
78 static bool core_offset(struct procstat_core *core, off_t offset);
79 static bool core_read(struct procstat_core *core, void *buf, size_t len);
80 static ssize_t core_read_mem(struct procstat_core *core, void *buf,
82 static void *get_args(struct procstat_core *core, vm_offset_t psstrings,
88 struct procstat_core *core; in procstat_core_open() local
118 warnx("%s is not a CORE file", filename); in procstat_core_open()
137 core = malloc(sizeof(struct procstat_core)); in procstat_core_open()
138 if (core == NULL) { in procstat_core_open()
142 core->pc_magic = PROCSTAT_CORE_MAGIC; in procstat_core_open()
143 core->pc_fd = fd; in procstat_core_open()
144 core->pc_elf = e; in procstat_core_open()
145 core->pc_ehdr = ehdr; in procstat_core_open()
146 core->pc_phdr = phdr; in procstat_core_open()
148 return (core); in procstat_core_open()
158 procstat_core_close(struct procstat_core *core) in procstat_core_close() argument
161 assert(core->pc_magic == PROCSTAT_CORE_MAGIC); in procstat_core_close()
163 elf_end(core->pc_elf); in procstat_core_close()
164 close(core->pc_fd); in procstat_core_close()
165 free(core); in procstat_core_close()
169 procstat_core_get(struct procstat_core *core, enum psc_type type, void *buf, in procstat_core_get() argument
180 assert(core->pc_magic == PROCSTAT_CORE_MAGIC); in procstat_core_get()
183 warnx("unknown core stat type: %d", type); in procstat_core_get()
187 offset = core->pc_phdr.p_offset; in procstat_core_get()
188 eoffset = offset + core->pc_phdr.p_filesz; in procstat_core_get()
192 if (!core_offset(core, offset)) in procstat_core_get()
194 if (!core_read(core, &nhdr, sizeof(nhdr))) in procstat_core_get()
207 if (!core_read(core, nbuf, sizeof(nbuf))) in procstat_core_get()
212 warnx("corrupted core file"); in procstat_core_get()
215 if (!core_read(core, &cstructsize, sizeof(cstructsize))) in procstat_core_get()
234 if (!core_read(core, (char *)buf + curlen, len)) { in procstat_core_get()
249 buf = get_args(core, psstrings, type, buf, &len); in procstat_core_get()
268 core_offset(struct procstat_core *core, off_t offset) in core_offset() argument
271 assert(core->pc_magic == PROCSTAT_CORE_MAGIC); in core_offset()
273 if (lseek(core->pc_fd, offset, SEEK_SET) == -1) { in core_offset()
274 warn("core: lseek(%jd)", (intmax_t)offset); in core_offset()
281 core_read(struct procstat_core *core, void *buf, size_t len) in core_read() argument
285 assert(core->pc_magic == PROCSTAT_CORE_MAGIC); in core_read()
287 n = read(core->pc_fd, buf, len); in core_read()
289 warn("core: read"); in core_read()
293 warnx("core: short read"); in core_read()
300 core_read_mem(struct procstat_core *core, void *buf, size_t len, in core_read_mem() argument
307 assert(core->pc_magic == PROCSTAT_CORE_MAGIC); in core_read_mem()
309 for (i = 0; i < core->pc_ehdr.e_phnum; i++) { in core_read_mem()
310 if (gelf_getphdr(core->pc_elf, i, &phdr) != &phdr) { in core_read_mem()
327 if (!core_offset(core, offset)) in core_read_mem()
329 if (!core_read(core, buf, len)) in core_read_mem()
340 get_args(struct procstat_core *core, vm_offset_t psstrings, enum psc_type type, in get_args() argument
353 if (core_read_mem(core, &pss, sizeof(pss), psstrings, true) == -1) in get_args()
376 if (core_read_mem(core, argv, size, addr, true) == -1) in get_args()
403 n = core_read_mem(core, p, chunksz, addr, false); in get_args()
425 procstat_core_note_count(struct procstat_core *core, enum psc_type type) in procstat_core_note_count() argument
434 warnx("unknown core stat type: %d", type); in procstat_core_note_count()
438 offset = core->pc_phdr.p_offset; in procstat_core_note_count()
439 eoffset = offset + core->pc_phdr.p_filesz; in procstat_core_note_count()
442 if (!core_offset(core, offset)) in procstat_core_note_count()
444 if (!core_read(core, &nhdr, sizeof(nhdr))) in procstat_core_note_count()
457 if (!core_read(core, nbuf, sizeof(nbuf))) in procstat_core_note_count()
462 warnx("corrupted core file"); in procstat_core_note_count()
465 if (!core_read(core, &cstructsize, sizeof(cstructsize))) in procstat_core_note_count()