core.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /* $OpenBSD: core.h,v 1.6 2015/05/05 02:13:46 guenther Exp $ */
  2. /* $NetBSD: core.h,v 1.4 1994/10/29 08:20:14 cgd Exp $ */
  3. /*
  4. * Copyright (c) 1994 Paul Kranenburg
  5. * All rights reserved.
  6. *
  7. * Redistribution and use in source and binary forms, with or without
  8. * modification, are permitted provided that the following conditions
  9. * are met:
  10. * 1. Redistributions of source code must retain the above copyright
  11. * notice, this list of conditions and the following disclaimer.
  12. * 2. Redistributions in binary form must reproduce the above copyright
  13. * notice, this list of conditions and the following disclaimer in the
  14. * documentation and/or other materials provided with the distribution.
  15. * 3. All advertising materials mentioning features or use of this software
  16. * must display the following acknowledgement:
  17. * This product includes software developed by Paul Kranenburg.
  18. * 4. The name of the author may not be used to endorse or promote products
  19. * derived from this software without specific prior written permission
  20. *
  21. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  22. * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  23. * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  24. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  25. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  26. * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  27. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  28. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  29. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  30. * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  31. */
  32. #define COREMAGIC 0507
  33. #define CORESEGMAGIC 0510
  34. /*
  35. * The core structure's c_midmag field (like exec's a_midmag) is a
  36. * network-byteorder encoding of this int
  37. * FFFFFFmmmmmmmmmmMMMMMMMMMMMMMMMM
  38. * Where `F' is 6 bits of flag (currently unused),
  39. * `m' is 10 bits of machine-id, and
  40. * `M' is 16 bits worth of magic number, ie. COREMAGIC.
  41. * The macros below will set/get the needed fields.
  42. */
  43. #define CORE_GETMAGIC(c) ( ntohl(((c).c_midmag)) & 0xffff )
  44. #define CORE_GETMID(c) ( (ntohl(((c).c_midmag)) >> 16) & 0x03ff )
  45. #define CORE_GETFLAG(c) ( (ntohl(((c).c_midmag)) >> 26) & 0x03f )
  46. #define CORE_SETMAGIC(c,mag,mid,flag) ( (c).c_midmag = htonl ( \
  47. ( ((flag) & 0x3f) << 26) | \
  48. ( ((mid) & 0x03ff) << 16) | \
  49. ( ((mag) & 0xffff) ) ) )
  50. /* Flag definitions */
  51. #define CORE_CPU 1
  52. #define CORE_DATA 2
  53. #define CORE_STACK 4
  54. #ifndef _KERNEL
  55. /*
  56. * XXX OBSOLETE, NO LONGER USED
  57. * A core file consists of a header followed by a number of segments.
  58. * Each segment is preceded by a `coreseg' structure giving the
  59. * segment's type, the virtual address where the bits resided in
  60. * process address space and the size of the segment.
  61. *
  62. * The core header specifies the lengths of the core header itself and
  63. * each of the following core segment headers to allow for any machine
  64. * dependent alignment requirements.
  65. */
  66. struct core {
  67. u_int32_t c_midmag; /* magic, id, flags */
  68. u_int16_t c_hdrsize; /* Size of this header (machdep algn) */
  69. u_int16_t c_seghdrsize; /* Size of a segment header */
  70. u_int32_t c_nseg; /* # of core segments */
  71. char c_name[MAXCOMLEN+1]; /* Copy of p->p_comm */
  72. u_int32_t c_signo; /* Killing signal */
  73. u_long c_ucode; /* Hmm ? */
  74. u_long c_cpusize; /* Size of machine dependent segment */
  75. u_long c_tsize; /* Size of traditional text segment */
  76. u_long c_dsize; /* Size of traditional data segment */
  77. u_long c_ssize; /* Size of traditional stack segment */
  78. };
  79. struct coreseg {
  80. u_int32_t c_midmag; /* magic, id, flags */
  81. u_long c_addr; /* Virtual address of segment */
  82. u_long c_size; /* Size of this segment */
  83. };
  84. #else
  85. int coredump_write(void *, enum uio_seg, const void *, size_t);
  86. void coredump_unmap(void *, vaddr_t, vaddr_t);
  87. #endif