You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Core-File-Generation.html 7.8KB

3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3. <!-- Copyright (C) 1988-2020 Free Software Foundation, Inc.
  4. Permission is granted to copy, distribute and/or modify this document
  5. under the terms of the GNU Free Documentation License, Version 1.3 or
  6. any later version published by the Free Software Foundation; with the
  7. Invariant Sections being "Free Software" and "Free Software Needs
  8. Free Documentation", with the Front-Cover Texts being "A GNU Manual,"
  9. and with the Back-Cover Texts as in (a) below.
  10. (a) The FSF's Back-Cover Text is: "You are free to copy and modify
  11. this GNU Manual. Buying copies from GNU Press supports the FSF in
  12. developing GNU and promoting software freedom." -->
  13. <!-- Created by GNU Texinfo 6.5, http://www.gnu.org/software/texinfo/ -->
  14. <head>
  15. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  16. <title>Core File Generation (Debugging with GDB)</title>
  17. <meta name="description" content="Core File Generation (Debugging with GDB)">
  18. <meta name="keywords" content="Core File Generation (Debugging with GDB)">
  19. <meta name="resource-type" content="document">
  20. <meta name="distribution" content="global">
  21. <meta name="Generator" content="makeinfo">
  22. <link href="index.html#Top" rel="start" title="Top">
  23. <link href="Concept-Index.html#Concept-Index" rel="index" title="Concept Index">
  24. <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
  25. <link href="Data.html#Data" rel="up" title="Data">
  26. <link href="Character-Sets.html#Character-Sets" rel="next" title="Character Sets">
  27. <link href="Dump_002fRestore-Files.html#Dump_002fRestore-Files" rel="prev" title="Dump/Restore Files">
  28. <style type="text/css">
  29. <!--
  30. a.summary-letter {text-decoration: none}
  31. blockquote.indentedblock {margin-right: 0em}
  32. blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
  33. blockquote.smallquotation {font-size: smaller}
  34. div.display {margin-left: 3.2em}
  35. div.example {margin-left: 3.2em}
  36. div.lisp {margin-left: 3.2em}
  37. div.smalldisplay {margin-left: 3.2em}
  38. div.smallexample {margin-left: 3.2em}
  39. div.smalllisp {margin-left: 3.2em}
  40. kbd {font-style: oblique}
  41. pre.display {font-family: inherit}
  42. pre.format {font-family: inherit}
  43. pre.menu-comment {font-family: serif}
  44. pre.menu-preformatted {font-family: serif}
  45. pre.smalldisplay {font-family: inherit; font-size: smaller}
  46. pre.smallexample {font-size: smaller}
  47. pre.smallformat {font-family: inherit; font-size: smaller}
  48. pre.smalllisp {font-size: smaller}
  49. span.nolinebreak {white-space: nowrap}
  50. span.roman {font-family: initial; font-weight: normal}
  51. span.sansserif {font-family: sans-serif; font-weight: normal}
  52. ul.no-bullet {list-style: none}
  53. -->
  54. </style>
  55. </head>
  56. <body lang="en">
  57. <a name="Core-File-Generation"></a>
  58. <div class="header">
  59. <p>
  60. Next: <a href="Character-Sets.html#Character-Sets" accesskey="n" rel="next">Character Sets</a>, Previous: <a href="Dump_002fRestore-Files.html#Dump_002fRestore-Files" accesskey="p" rel="prev">Dump/Restore Files</a>, Up: <a href="Data.html#Data" accesskey="u" rel="up">Data</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html#Concept-Index" title="Index" rel="index">Index</a>]</p>
  61. </div>
  62. <hr>
  63. <a name="How-to-Produce-a-Core-File-from-Your-Program"></a>
  64. <h3 class="section">10.19 How to Produce a Core File from Your Program</h3>
  65. <a name="index-dump-core-from-inferior"></a>
  66. <p>A <em>core file</em> or <em>core dump</em> is a file that records the memory
  67. image of a running process and its process status (register values
  68. etc.). Its primary use is post-mortem debugging of a program that
  69. crashed while it ran outside a debugger. A program that crashes
  70. automatically produces a core file, unless this feature is disabled by
  71. the user. See <a href="Files.html#Files">Files</a>, for information on invoking <small>GDB</small> in
  72. the post-mortem debugging mode.
  73. </p>
  74. <p>Occasionally, you may wish to produce a core file of the program you
  75. are debugging in order to preserve a snapshot of its state.
  76. <small>GDB</small> has a special command for that.
  77. </p>
  78. <dl compact="compact">
  79. <dd><a name="index-gcore"></a>
  80. <a name="index-generate_002dcore_002dfile"></a>
  81. </dd>
  82. <dt><code>generate-core-file [<var>file</var>]</code></dt>
  83. <dt><code>gcore [<var>file</var>]</code></dt>
  84. <dd><p>Produce a core dump of the inferior process. The optional argument
  85. <var>file</var> specifies the file name where to put the core dump. If not
  86. specified, the file name defaults to <samp>core.<var>pid</var></samp>, where
  87. <var>pid</var> is the inferior process ID.
  88. </p>
  89. <p>Note that this command is implemented only for some systems (as of
  90. this writing, <small>GNU</small>/Linux, FreeBSD, Solaris, and S390).
  91. </p>
  92. <p>On <small>GNU</small>/Linux, this command can take into account the value of the
  93. file <samp>/proc/<var>pid</var>/coredump_filter</samp> when generating the core
  94. dump (see <a href="#set-use_002dcoredump_002dfilter">set use-coredump-filter</a>), and by default honors the
  95. <code>VM_DONTDUMP</code> flag for mappings where it is present in the file
  96. <samp>/proc/<var>pid</var>/smaps</samp> (see <a href="#set-dump_002dexcluded_002dmappings">set dump-excluded-mappings</a>).
  97. </p>
  98. <a name="index-set-use_002dcoredump_002dfilter"></a>
  99. <a name="set-use_002dcoredump_002dfilter"></a></dd>
  100. <dt><code>set use-coredump-filter on</code></dt>
  101. <dt><code>set use-coredump-filter off</code></dt>
  102. <dd><p>Enable or disable the use of the file
  103. <samp>/proc/<var>pid</var>/coredump_filter</samp> when generating core dump
  104. files. This file is used by the Linux kernel to decide what types of
  105. memory mappings will be dumped or ignored when generating a core dump
  106. file. <var>pid</var> is the process ID of a currently running process.
  107. </p>
  108. <p>To make use of this feature, you have to write in the
  109. <samp>/proc/<var>pid</var>/coredump_filter</samp> file a value, in hexadecimal,
  110. which is a bit mask representing the memory mapping types. If a bit
  111. is set in the bit mask, then the memory mappings of the corresponding
  112. types will be dumped; otherwise, they will be ignored. This
  113. configuration is inherited by child processes. For more information
  114. about the bits that can be set in the
  115. <samp>/proc/<var>pid</var>/coredump_filter</samp> file, please refer to the
  116. manpage of <code>core(5)</code>.
  117. </p>
  118. <p>By default, this option is <code>on</code>. If this option is turned
  119. <code>off</code>, <small>GDB</small> does not read the <samp>coredump_filter</samp> file
  120. and instead uses the same default value as the Linux kernel in order
  121. to decide which pages will be dumped in the core dump file. This
  122. value is currently <code>0x33</code>, which means that bits <code>0</code>
  123. (anonymous private mappings), <code>1</code> (anonymous shared mappings),
  124. <code>4</code> (ELF headers) and <code>5</code> (private huge pages) are active.
  125. This will cause these memory mappings to be dumped automatically.
  126. </p>
  127. <a name="index-set-dump_002dexcluded_002dmappings"></a>
  128. <a name="set-dump_002dexcluded_002dmappings"></a></dd>
  129. <dt><code>set dump-excluded-mappings on</code></dt>
  130. <dt><code>set dump-excluded-mappings off</code></dt>
  131. <dd><p>If <code>on</code> is specified, <small>GDB</small> will dump memory mappings
  132. marked with the <code>VM_DONTDUMP</code> flag. This flag is represented in
  133. the file <samp>/proc/<var>pid</var>/smaps</samp> with the acronym <code>dd</code>.
  134. </p>
  135. <p>The default value is <code>off</code>.
  136. </p></dd>
  137. </dl>
  138. <hr>
  139. <div class="header">
  140. <p>
  141. Next: <a href="Character-Sets.html#Character-Sets" accesskey="n" rel="next">Character Sets</a>, Previous: <a href="Dump_002fRestore-Files.html#Dump_002fRestore-Files" accesskey="p" rel="prev">Dump/Restore Files</a>, Up: <a href="Data.html#Data" accesskey="u" rel="up">Data</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html#Concept-Index" title="Index" rel="index">Index</a>]</p>
  142. </div>
  143. </body>
  144. </html>