MCPcopy Create free account
hub / github.com/F-Stack/f-stack / dumpsys_generic

Function dumpsys_generic

freebsd/kern/kern_dump.c:283–387  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

281}
282
283int
284dumpsys_generic(struct dumperinfo *di)
285{
286 static struct kerneldumpheader kdh;
287 Elf_Ehdr ehdr;
288 uint64_t dumpsize;
289 off_t hdrgap;
290 size_t hdrsz;
291 int error;
292
293#if MINIDUMP_PAGE_TRACKING == 1
294 if (do_minidump)
295 return (minidumpsys(di));
296#endif
297
298 bzero(&ehdr, sizeof(ehdr));
299 ehdr.e_ident[EI_MAG0] = ELFMAG0;
300 ehdr.e_ident[EI_MAG1] = ELFMAG1;
301 ehdr.e_ident[EI_MAG2] = ELFMAG2;
302 ehdr.e_ident[EI_MAG3] = ELFMAG3;
303 ehdr.e_ident[EI_CLASS] = ELF_CLASS;
304#if BYTE_ORDER == LITTLE_ENDIAN
305 ehdr.e_ident[EI_DATA] = ELFDATA2LSB;
306#else
307 ehdr.e_ident[EI_DATA] = ELFDATA2MSB;
308#endif
309 ehdr.e_ident[EI_VERSION] = EV_CURRENT;
310 ehdr.e_ident[EI_OSABI] = ELFOSABI_STANDALONE; /* XXX big picture? */
311 ehdr.e_type = ET_CORE;
312 ehdr.e_machine = EM_VALUE;
313 ehdr.e_phoff = sizeof(ehdr);
314 ehdr.e_flags = 0;
315 ehdr.e_ehsize = sizeof(ehdr);
316 ehdr.e_phentsize = sizeof(Elf_Phdr);
317 ehdr.e_shentsize = sizeof(Elf_Shdr);
318
319 dumpsys_pa_init();
320
321 /* Calculate dump size. */
322 dumpsize = 0L;
323 ehdr.e_phnum = dumpsys_foreach_chunk(cb_size, &dumpsize) +
324 DUMPSYS_NUM_AUX_HDRS;
325 hdrsz = ehdr.e_phoff + ehdr.e_phnum * ehdr.e_phentsize;
326 fileofs = MD_ALIGN(hdrsz);
327 dumpsize += fileofs;
328 hdrgap = fileofs - roundup2((off_t)hdrsz, di->blocksize);
329
330 dump_init_header(di, &kdh, KERNELDUMPMAGIC, KERNELDUMP_ARCH_VERSION,
331 dumpsize);
332
333 error = dump_start(di, &kdh);
334 if (error != 0)
335 goto fail;
336
337 printf("Dumping %ju MB (%d chunks)\n", (uintmax_t)dumpsize >> 20,
338 ehdr.e_phnum - DUMPSYS_NUM_AUX_HDRS);
339
340 /* Dump ELF header */

Callers 4

dumpsysFunction · 0.85
dumpsysFunction · 0.85
dumpsysFunction · 0.85
dumpsysFunction · 0.85

Calls 12

bzeroFunction · 0.85
dumpsys_foreach_chunkFunction · 0.85
dump_init_headerFunction · 0.85
dump_startFunction · 0.85
dumpsys_buf_writeFunction · 0.85
dumpsys_buf_flushFunction · 0.85
dumpsys_buf_seekFunction · 0.85
dump_finishFunction · 0.85
printfFunction · 0.70
minidumpsysFunction · 0.50
dumpsys_pa_initFunction · 0.50

Tested by

no test coverage detected