Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

848 Zeilen
34KB

  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>Print Settings (Debugging with GDB)</title>
  17. <meta name="description" content="Print Settings (Debugging with GDB)">
  18. <meta name="keywords" content="Print Settings (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="Pretty-Printing.html#Pretty-Printing" rel="next" title="Pretty Printing">
  27. <link href="Auto-Display.html#Auto-Display" rel="prev" title="Auto Display">
  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="Print-Settings"></a>
  58. <div class="header">
  59. <p>
  60. Next: <a href="Pretty-Printing.html#Pretty-Printing" accesskey="n" rel="next">Pretty Printing</a>, Previous: <a href="Auto-Display.html#Auto-Display" accesskey="p" rel="prev">Auto Display</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="Print-Settings-1"></a>
  64. <h3 class="section">10.8 Print Settings</h3>
  65. <a name="index-format-options"></a>
  66. <a name="index-print-settings"></a>
  67. <p><small>GDB</small> provides the following ways to control how arrays, structures,
  68. and symbols are printed.
  69. </p>
  70. <p>These settings are useful for debugging programs in any language:
  71. </p>
  72. <dl compact="compact">
  73. <dd><a name="index-set-print"></a>
  74. <a name="set-print-address"></a></dd>
  75. <dt><code>set print address</code></dt>
  76. <dt><code>set print address on</code></dt>
  77. <dd><a name="index-print_002fdon_0027t-print-memory-addresses"></a>
  78. <p><small>GDB</small> prints memory addresses showing the location of stack
  79. traces, structure values, pointer values, breakpoints, and so forth,
  80. even when it also displays the contents of those addresses. The default
  81. is <code>on</code>. For example, this is what a stack frame display looks like with
  82. <code>set print address on</code>:
  83. </p>
  84. <div class="smallexample">
  85. <pre class="smallexample">(gdb) f
  86. #0 set_quotes (lq=0x34c78 &quot;&lt;&lt;&quot;, rq=0x34c88 &quot;&gt;&gt;&quot;)
  87. at input.c:530
  88. 530 if (lquote != def_lquote)
  89. </pre></div>
  90. </dd>
  91. <dt><code>set print address off</code></dt>
  92. <dd><p>Do not print addresses when displaying their contents. For example,
  93. this is the same stack frame displayed with <code>set print address off</code>:
  94. </p>
  95. <div class="smallexample">
  96. <pre class="smallexample">(gdb) set print addr off
  97. (gdb) f
  98. #0 set_quotes (lq=&quot;&lt;&lt;&quot;, rq=&quot;&gt;&gt;&quot;) at input.c:530
  99. 530 if (lquote != def_lquote)
  100. </pre></div>
  101. <p>You can use &lsquo;<samp>set print address off</samp>&rsquo; to eliminate all machine
  102. dependent displays from the <small>GDB</small> interface. For example, with
  103. <code>print address off</code>, you should get the same text for backtraces on
  104. all machines&mdash;whether or not they involve pointer arguments.
  105. </p>
  106. <a name="index-show-print"></a>
  107. </dd>
  108. <dt><code>show print address</code></dt>
  109. <dd><p>Show whether or not addresses are to be printed.
  110. </p></dd>
  111. </dl>
  112. <p>When <small>GDB</small> prints a symbolic address, it normally prints the
  113. closest earlier symbol plus an offset. If that symbol does not uniquely
  114. identify the address (for example, it is a name whose scope is a single
  115. source file), you may need to clarify. One way to do this is with
  116. <code>info line</code>, for example &lsquo;<samp>info line *0x4537</samp>&rsquo;. Alternately,
  117. you can set <small>GDB</small> to print the source file and line number when
  118. it prints a symbolic address:
  119. </p>
  120. <dl compact="compact">
  121. <dt><code>set print symbol-filename on</code></dt>
  122. <dd><a name="index-source-file-and-line-of-a-symbol"></a>
  123. <a name="index-symbol_002c-source-file-and-line"></a>
  124. <p>Tell <small>GDB</small> to print the source file name and line number of a
  125. symbol in the symbolic form of an address.
  126. </p>
  127. </dd>
  128. <dt><code>set print symbol-filename off</code></dt>
  129. <dd><p>Do not print source file name and line number of a symbol. This is the
  130. default.
  131. </p>
  132. </dd>
  133. <dt><code>show print symbol-filename</code></dt>
  134. <dd><p>Show whether or not <small>GDB</small> will print the source file name and
  135. line number of a symbol in the symbolic form of an address.
  136. </p></dd>
  137. </dl>
  138. <p>Another situation where it is helpful to show symbol filenames and line
  139. numbers is when disassembling code; <small>GDB</small> shows you the line
  140. number and source file that corresponds to each instruction.
  141. </p>
  142. <p>Also, you may wish to see the symbolic form only if the address being
  143. printed is reasonably close to the closest earlier symbol:
  144. </p>
  145. <dl compact="compact">
  146. <dt><code>set print max-symbolic-offset <var>max-offset</var></code></dt>
  147. <dt><code>set print max-symbolic-offset unlimited</code></dt>
  148. <dd><a name="index-maximum-value-for-offset-of-closest-symbol"></a>
  149. <p>Tell <small>GDB</small> to only display the symbolic form of an address if the
  150. offset between the closest earlier symbol and the address is less than
  151. <var>max-offset</var>. The default is <code>unlimited</code>, which tells <small>GDB</small>
  152. to always print the symbolic form of an address if any symbol precedes
  153. it. Zero is equivalent to <code>unlimited</code>.
  154. </p>
  155. </dd>
  156. <dt><code>show print max-symbolic-offset</code></dt>
  157. <dd><p>Ask how large the maximum offset is that <small>GDB</small> prints in a
  158. symbolic address.
  159. </p></dd>
  160. </dl>
  161. <a name="index-wild-pointer_002c-interpreting"></a>
  162. <a name="index-pointer_002c-finding-referent"></a>
  163. <p>If you have a pointer and you are not sure where it points, try
  164. &lsquo;<samp>set print symbol-filename on</samp>&rsquo;. Then you can determine the name
  165. and source file location of the variable where it points, using
  166. &lsquo;<samp>p/a <var>pointer</var></samp>&rsquo;. This interprets the address in symbolic form.
  167. For example, here <small>GDB</small> shows that a variable <code>ptt</code> points
  168. at another variable <code>t</code>, defined in <samp>hi2.c</samp>:
  169. </p>
  170. <div class="smallexample">
  171. <pre class="smallexample">(gdb) set print symbol-filename on
  172. (gdb) p/a ptt
  173. $4 = 0xe008 &lt;t in hi2.c&gt;
  174. </pre></div>
  175. <blockquote>
  176. <p><em>Warning:</em> For pointers that point to a local variable, &lsquo;<samp>p/a</samp>&rsquo;
  177. does not show the symbol name and filename of the referent, even with
  178. the appropriate <code>set print</code> options turned on.
  179. </p></blockquote>
  180. <p>You can also enable &lsquo;<samp>/a</samp>&rsquo;-like formatting all the time using
  181. &lsquo;<samp>set print symbol on</samp>&rsquo;:
  182. </p>
  183. <a name="set-print-symbol"></a><dl compact="compact">
  184. <dt><code>set print symbol on</code></dt>
  185. <dd><p>Tell <small>GDB</small> to print the symbol corresponding to an address, if
  186. one exists.
  187. </p>
  188. </dd>
  189. <dt><code>set print symbol off</code></dt>
  190. <dd><p>Tell <small>GDB</small> not to print the symbol corresponding to an
  191. address. In this mode, <small>GDB</small> will still print the symbol
  192. corresponding to pointers to functions. This is the default.
  193. </p>
  194. </dd>
  195. <dt><code>show print symbol</code></dt>
  196. <dd><p>Show whether <small>GDB</small> will display the symbol corresponding to an
  197. address.
  198. </p></dd>
  199. </dl>
  200. <p>Other settings control how different kinds of objects are printed:
  201. </p>
  202. <dl compact="compact">
  203. <dd><a name="set-print-array"></a></dd>
  204. <dt><code>set print array</code></dt>
  205. <dt><code>set print array on</code></dt>
  206. <dd><a name="index-pretty-print-arrays"></a>
  207. <p>Pretty print arrays. This format is more convenient to read,
  208. but uses more space. The default is off.
  209. </p>
  210. </dd>
  211. <dt><code>set print array off</code></dt>
  212. <dd><p>Return to compressed format for arrays.
  213. </p>
  214. </dd>
  215. <dt><code>show print array</code></dt>
  216. <dd><p>Show whether compressed or pretty format is selected for displaying
  217. arrays.
  218. </p>
  219. <a name="index-print-array-indexes"></a>
  220. <a name="set-print-array_002dindexes"></a></dd>
  221. <dt><code>set print array-indexes</code></dt>
  222. <dt><code>set print array-indexes on</code></dt>
  223. <dd><p>Print the index of each element when displaying arrays. May be more
  224. convenient to locate a given element in the array or quickly find the
  225. index of a given element in that printed array. The default is off.
  226. </p>
  227. </dd>
  228. <dt><code>set print array-indexes off</code></dt>
  229. <dd><p>Stop printing element indexes when displaying arrays.
  230. </p>
  231. </dd>
  232. <dt><code>show print array-indexes</code></dt>
  233. <dd><p>Show whether the index of each element is printed when displaying
  234. arrays.
  235. </p>
  236. <a name="set-print-elements"></a></dd>
  237. <dt><code>set print elements <var>number-of-elements</var></code></dt>
  238. <dt><code>set print elements unlimited</code></dt>
  239. <dd><a name="index-number-of-array-elements-to-print"></a>
  240. <a name="index-limit-on-number-of-printed-array-elements"></a>
  241. <p>Set a limit on how many elements of an array <small>GDB</small> will print.
  242. If <small>GDB</small> is printing a large array, it stops printing after it has
  243. printed the number of elements set by the <code>set print elements</code> command.
  244. This limit also applies to the display of strings.
  245. When <small>GDB</small> starts, this limit is set to 200.
  246. Setting <var>number-of-elements</var> to <code>unlimited</code> or zero means
  247. that the number of elements to print is unlimited.
  248. </p>
  249. </dd>
  250. <dt><code>show print elements</code></dt>
  251. <dd><p>Display the number of elements of a large array that <small>GDB</small> will print.
  252. If the number is 0, then the printing is unlimited.
  253. </p>
  254. <a name="set-print-frame_002darguments"></a></dd>
  255. <dt><code>set print frame-arguments <var>value</var></code></dt>
  256. <dd><a name="index-set-print-frame_002darguments"></a>
  257. <a name="index-printing-frame-argument-values"></a>
  258. <a name="index-print-all-frame-argument-values"></a>
  259. <a name="index-print-frame-argument-values-for-scalars-only"></a>
  260. <a name="index-do-not-print-frame-arguments"></a>
  261. <p>This command allows to control how the values of arguments are printed
  262. when the debugger prints a frame (see <a href="Frames.html#Frames">Frames</a>). The possible
  263. values are:
  264. </p>
  265. <dl compact="compact">
  266. <dt><code>all</code></dt>
  267. <dd><p>The values of all arguments are printed.
  268. </p>
  269. </dd>
  270. <dt><code>scalars</code></dt>
  271. <dd><p>Print the value of an argument only if it is a scalar. The value of more
  272. complex arguments such as arrays, structures, unions, etc, is replaced
  273. by <code>&hellip;</code>. This is the default. Here is an example where
  274. only scalar arguments are shown:
  275. </p>
  276. <div class="smallexample">
  277. <pre class="smallexample">#1 0x08048361 in call_me (i=3, s=&hellip;, ss=0xbf8d508c, u=&hellip;, e=green)
  278. at frame-args.c:23
  279. </pre></div>
  280. </dd>
  281. <dt><code>none</code></dt>
  282. <dd><p>None of the argument values are printed. Instead, the value of each argument
  283. is replaced by <code>&hellip;</code>. In this case, the example above now becomes:
  284. </p>
  285. <div class="smallexample">
  286. <pre class="smallexample">#1 0x08048361 in call_me (i=&hellip;, s=&hellip;, ss=&hellip;, u=&hellip;, e=&hellip;)
  287. at frame-args.c:23
  288. </pre></div>
  289. </dd>
  290. <dt><code>presence</code></dt>
  291. <dd><p>Only the presence of arguments is indicated by <code>&hellip;</code>.
  292. The <code>&hellip;</code> are not printed for function without any arguments.
  293. None of the argument names and values are printed.
  294. In this case, the example above now becomes:
  295. </p>
  296. <div class="smallexample">
  297. <pre class="smallexample">#1 0x08048361 in call_me (&hellip;) at frame-args.c:23
  298. </pre></div>
  299. </dd>
  300. </dl>
  301. <p>By default, only scalar arguments are printed. This command can be used
  302. to configure the debugger to print the value of all arguments, regardless
  303. of their type. However, it is often advantageous to not print the value
  304. of more complex parameters. For instance, it reduces the amount of
  305. information printed in each frame, making the backtrace more readable.
  306. Also, it improves performance when displaying Ada frames, because
  307. the computation of large arguments can sometimes be CPU-intensive,
  308. especially in large applications. Setting <code>print frame-arguments</code>
  309. to <code>scalars</code> (the default), <code>none</code> or <code>presence</code> avoids
  310. this computation, thus speeding up the display of each Ada frame.
  311. </p>
  312. </dd>
  313. <dt><code>show print frame-arguments</code></dt>
  314. <dd><p>Show how the value of arguments should be displayed when printing a frame.
  315. </p>
  316. <a name="set-print-raw_002dframe_002darguments"></a></dd>
  317. <dt><code>set print raw-frame-arguments on</code></dt>
  318. <dd><p>Print frame arguments in raw, non pretty-printed, form.
  319. </p>
  320. </dd>
  321. <dt><code>set print raw-frame-arguments off</code></dt>
  322. <dd><p>Print frame arguments in pretty-printed form, if there is a pretty-printer
  323. for the value (see <a href="Pretty-Printing.html#Pretty-Printing">Pretty Printing</a>),
  324. otherwise print the value in raw form.
  325. This is the default.
  326. </p>
  327. </dd>
  328. <dt><code>show print raw-frame-arguments</code></dt>
  329. <dd><p>Show whether to print frame arguments in raw form.
  330. </p>
  331. <a name="set-print-entry_002dvalues"></a></dd>
  332. <dt><code>set print entry-values <var>value</var></code></dt>
  333. <dd><a name="index-set-print-entry_002dvalues"></a>
  334. <p>Set printing of frame argument values at function entry. In some cases
  335. <small>GDB</small> can determine the value of function argument which was passed by
  336. the function caller, even if the value was modified inside the called function
  337. and therefore is different. With optimized code, the current value could be
  338. unavailable, but the entry value may still be known.
  339. </p>
  340. <p>The default value is <code>default</code> (see below for its description). Older
  341. <small>GDB</small> behaved as with the setting <code>no</code>. Compilers not supporting
  342. this feature will behave in the <code>default</code> setting the same way as with the
  343. <code>no</code> setting.
  344. </p>
  345. <p>This functionality is currently supported only by DWARF 2 debugging format and
  346. the compiler has to produce &lsquo;<samp>DW_TAG_call_site</samp>&rsquo; tags. With
  347. <small>GCC</small>, you need to specify <samp>-O -g</samp> during compilation, to get
  348. this information.
  349. </p>
  350. <p>The <var>value</var> parameter can be one of the following:
  351. </p>
  352. <dl compact="compact">
  353. <dt><code>no</code></dt>
  354. <dd><p>Print only actual parameter values, never print values from function entry
  355. point.
  356. </p><div class="smallexample">
  357. <pre class="smallexample">#0 equal (val=5)
  358. #0 different (val=6)
  359. #0 lost (val=&lt;optimized out&gt;)
  360. #0 born (val=10)
  361. #0 invalid (val=&lt;optimized out&gt;)
  362. </pre></div>
  363. </dd>
  364. <dt><code>only</code></dt>
  365. <dd><p>Print only parameter values from function entry point. The actual parameter
  366. values are never printed.
  367. </p><div class="smallexample">
  368. <pre class="smallexample">#0 equal (val@entry=5)
  369. #0 different (val@entry=5)
  370. #0 lost (val@entry=5)
  371. #0 born (val@entry=&lt;optimized out&gt;)
  372. #0 invalid (val@entry=&lt;optimized out&gt;)
  373. </pre></div>
  374. </dd>
  375. <dt><code>preferred</code></dt>
  376. <dd><p>Print only parameter values from function entry point. If value from function
  377. entry point is not known while the actual value is known, print the actual
  378. value for such parameter.
  379. </p><div class="smallexample">
  380. <pre class="smallexample">#0 equal (val@entry=5)
  381. #0 different (val@entry=5)
  382. #0 lost (val@entry=5)
  383. #0 born (val=10)
  384. #0 invalid (val@entry=&lt;optimized out&gt;)
  385. </pre></div>
  386. </dd>
  387. <dt><code>if-needed</code></dt>
  388. <dd><p>Print actual parameter values. If actual parameter value is not known while
  389. value from function entry point is known, print the entry point value for such
  390. parameter.
  391. </p><div class="smallexample">
  392. <pre class="smallexample">#0 equal (val=5)
  393. #0 different (val=6)
  394. #0 lost (val@entry=5)
  395. #0 born (val=10)
  396. #0 invalid (val=&lt;optimized out&gt;)
  397. </pre></div>
  398. </dd>
  399. <dt><code>both</code></dt>
  400. <dd><p>Always print both the actual parameter value and its value from function entry
  401. point, even if values of one or both are not available due to compiler
  402. optimizations.
  403. </p><div class="smallexample">
  404. <pre class="smallexample">#0 equal (val=5, val@entry=5)
  405. #0 different (val=6, val@entry=5)
  406. #0 lost (val=&lt;optimized out&gt;, val@entry=5)
  407. #0 born (val=10, val@entry=&lt;optimized out&gt;)
  408. #0 invalid (val=&lt;optimized out&gt;, val@entry=&lt;optimized out&gt;)
  409. </pre></div>
  410. </dd>
  411. <dt><code>compact</code></dt>
  412. <dd><p>Print the actual parameter value if it is known and also its value from
  413. function entry point if it is known. If neither is known, print for the actual
  414. value <code>&lt;optimized out&gt;</code>. If not in MI mode (see <a href="GDB_002fMI.html#GDB_002fMI">GDB/MI</a>) and if both
  415. values are known and identical, print the shortened
  416. <code>param=param@entry=VALUE</code> notation.
  417. </p><div class="smallexample">
  418. <pre class="smallexample">#0 equal (val=val@entry=5)
  419. #0 different (val=6, val@entry=5)
  420. #0 lost (val@entry=5)
  421. #0 born (val=10)
  422. #0 invalid (val=&lt;optimized out&gt;)
  423. </pre></div>
  424. </dd>
  425. <dt><code>default</code></dt>
  426. <dd><p>Always print the actual parameter value. Print also its value from function
  427. entry point, but only if it is known. If not in MI mode (see <a href="GDB_002fMI.html#GDB_002fMI">GDB/MI</a>) and
  428. if both values are known and identical, print the shortened
  429. <code>param=param@entry=VALUE</code> notation.
  430. </p><div class="smallexample">
  431. <pre class="smallexample">#0 equal (val=val@entry=5)
  432. #0 different (val=6, val@entry=5)
  433. #0 lost (val=&lt;optimized out&gt;, val@entry=5)
  434. #0 born (val=10)
  435. #0 invalid (val=&lt;optimized out&gt;)
  436. </pre></div>
  437. </dd>
  438. </dl>
  439. <p>For analysis messages on possible failures of frame argument values at function
  440. entry resolution see <a href="Tail-Call-Frames.html#set-debug-entry_002dvalues">set debug entry-values</a>.
  441. </p>
  442. </dd>
  443. <dt><code>show print entry-values</code></dt>
  444. <dd><p>Show the method being used for printing of frame argument values at function
  445. entry.
  446. </p>
  447. <a name="set-print-frame_002dinfo"></a></dd>
  448. <dt><code>set print frame-info <var>value</var></code></dt>
  449. <dd><a name="index-set-print-frame_002dinfo"></a>
  450. <a name="index-printing-frame-information"></a>
  451. <a name="index-frame-information_002c-printing"></a>
  452. <p>This command allows to control the information printed when
  453. the debugger prints a frame. See <a href="Frames.html#Frames">Frames</a>, <a href="Backtrace.html#Backtrace">Backtrace</a>,
  454. for a general explanation about frames and frame information.
  455. Note that some other settings (such as <code>set print frame-arguments</code>
  456. and <code>set print address</code>) are also influencing if and how some frame
  457. information is displayed. In particular, the frame program counter is never
  458. printed if <code>set print address</code> is off.
  459. </p>
  460. <p>The possible values for <code>set print frame-info</code> are:
  461. </p><dl compact="compact">
  462. <dt><code>short-location</code></dt>
  463. <dd><p>Print the frame level, the program counter (if not at the
  464. beginning of the location source line), the function, the function
  465. arguments.
  466. </p></dd>
  467. <dt><code>location</code></dt>
  468. <dd><p>Same as <code>short-location</code> but also print the source file and source line
  469. number.
  470. </p></dd>
  471. <dt><code>location-and-address</code></dt>
  472. <dd><p>Same as <code>location</code> but print the program counter even if located at the
  473. beginning of the location source line.
  474. </p></dd>
  475. <dt><code>source-line</code></dt>
  476. <dd><p>Print the program counter (if not at the beginning of the location
  477. source line), the line number and the source line.
  478. </p></dd>
  479. <dt><code>source-and-location</code></dt>
  480. <dd><p>Print what <code>location</code> and <code>source-line</code> are printing.
  481. </p></dd>
  482. <dt><code>auto</code></dt>
  483. <dd><p>The information printed for a frame is decided automatically
  484. by the <small>GDB</small> command that prints a frame.
  485. For example, <code>frame</code> prints the information printed by
  486. <code>source-and-location</code> while <code>stepi</code> will switch between
  487. <code>source-line</code> and <code>source-and-location</code> depending on the program
  488. counter.
  489. The default value is <code>auto</code>.
  490. </p></dd>
  491. </dl>
  492. <a name="set-print-repeats"></a></dd>
  493. <dt><code>set print repeats <var>number-of-repeats</var></code></dt>
  494. <dt><code>set print repeats unlimited</code></dt>
  495. <dd><a name="index-repeated-array-elements"></a>
  496. <p>Set the threshold for suppressing display of repeated array
  497. elements. When the number of consecutive identical elements of an
  498. array exceeds the threshold, <small>GDB</small> prints the string
  499. <code>&quot;&lt;repeats <var>n</var> times&gt;&quot;</code>, where <var>n</var> is the number of
  500. identical repetitions, instead of displaying the identical elements
  501. themselves. Setting the threshold to <code>unlimited</code> or zero will
  502. cause all elements to be individually printed. The default threshold
  503. is 10.
  504. </p>
  505. </dd>
  506. <dt><code>show print repeats</code></dt>
  507. <dd><p>Display the current threshold for printing repeated identical
  508. elements.
  509. </p>
  510. <a name="set-print-max_002ddepth"></a></dd>
  511. <dt><code>set print max-depth <var>depth</var></code></dt>
  512. <dt><code>set print max-depth unlimited</code></dt>
  513. <dd><a name="index-printing-nested-structures"></a>
  514. <p>Set the threshold after which nested structures are replaced with
  515. ellipsis, this can make visualising deeply nested structures easier.
  516. </p>
  517. <p>For example, given this C code
  518. </p>
  519. <div class="smallexample">
  520. <pre class="smallexample">typedef struct s1 { int a; } s1;
  521. typedef struct s2 { s1 b; } s2;
  522. typedef struct s3 { s2 c; } s3;
  523. typedef struct s4 { s3 d; } s4;
  524. s4 var = { { { { 3 } } } };
  525. </pre></div>
  526. <p>The following table shows how different values of <var>depth</var> will
  527. effect how <code>var</code> is printed by <small>GDB</small>:
  528. </p>
  529. <table>
  530. <thead><tr><th width="30%"><var>depth</var> setting</th><th width="70%">Result of &lsquo;<samp>p var</samp>&rsquo;</th></tr></thead>
  531. <tr><td width="30%">unlimited</td><td width="70%"><code>$1 = {d = {c = {b = {a = 3}}}}</code></td></tr>
  532. <tr><td width="30%"><code>0</code></td><td width="70%"><code>$1 = {...}</code></td></tr>
  533. <tr><td width="30%"><code>1</code></td><td width="70%"><code>$1 = {d = {...}}</code></td></tr>
  534. <tr><td width="30%"><code>2</code></td><td width="70%"><code>$1 = {d = {c = {...}}}</code></td></tr>
  535. <tr><td width="30%"><code>3</code></td><td width="70%"><code>$1 = {d = {c = {b = {...}}}}</code></td></tr>
  536. <tr><td width="30%"><code>4</code></td><td width="70%"><code>$1 = {d = {c = {b = {a = 3}}}}</code></td></tr>
  537. </table>
  538. <p>To see the contents of structures that have been hidden the user can
  539. either increase the print max-depth, or they can print the elements of
  540. the structure that are visible, for example
  541. </p>
  542. <div class="smallexample">
  543. <pre class="smallexample">(gdb) set print max-depth 2
  544. (gdb) p var
  545. $1 = {d = {c = {...}}}
  546. (gdb) p var.d
  547. $2 = {c = {b = {...}}}
  548. (gdb) p var.d.c
  549. $3 = {b = {a = 3}}
  550. </pre></div>
  551. <p>The pattern used to replace nested structures varies based on
  552. language, for most languages <code>{...}</code> is used, but Fortran uses
  553. <code>(...)</code>.
  554. </p>
  555. </dd>
  556. <dt><code>show print max-depth</code></dt>
  557. <dd><p>Display the current threshold after which nested structures are
  558. replaces with ellipsis.
  559. </p>
  560. <a name="set-print-null_002dstop"></a></dd>
  561. <dt><code>set print null-stop</code></dt>
  562. <dd><a name="index-NULL-elements-in-arrays"></a>
  563. <p>Cause <small>GDB</small> to stop printing the characters of an array when the first
  564. <small>NULL</small> is encountered. This is useful when large arrays actually
  565. contain only short strings.
  566. The default is off.
  567. </p>
  568. </dd>
  569. <dt><code>show print null-stop</code></dt>
  570. <dd><p>Show whether <small>GDB</small> stops printing an array on the first
  571. <small>NULL</small> character.
  572. </p>
  573. <a name="set-print-pretty"></a></dd>
  574. <dt><code>set print pretty on</code></dt>
  575. <dd><a name="index-print-structures-in-indented-form"></a>
  576. <a name="index-indentation-in-structure-display"></a>
  577. <p>Cause <small>GDB</small> to print structures in an indented format with one member
  578. per line, like this:
  579. </p>
  580. <div class="smallexample">
  581. <pre class="smallexample">$1 = {
  582. next = 0x0,
  583. flags = {
  584. sweet = 1,
  585. sour = 1
  586. },
  587. meat = 0x54 &quot;Pork&quot;
  588. }
  589. </pre></div>
  590. </dd>
  591. <dt><code>set print pretty off</code></dt>
  592. <dd><p>Cause <small>GDB</small> to print structures in a compact format, like this:
  593. </p>
  594. <div class="smallexample">
  595. <pre class="smallexample">$1 = {next = 0x0, flags = {sweet = 1, sour = 1}, \
  596. meat = 0x54 &quot;Pork&quot;}
  597. </pre></div>
  598. <p>This is the default format.
  599. </p>
  600. </dd>
  601. <dt><code>show print pretty</code></dt>
  602. <dd><p>Show which format <small>GDB</small> is using to print structures.
  603. </p>
  604. <a name="set-print-raw_002dvalues"></a></dd>
  605. <dt><code>set print raw-values on</code></dt>
  606. <dd><p>Print values in raw form, without applying the pretty
  607. printers for the value.
  608. </p>
  609. </dd>
  610. <dt><code>set print raw-values off</code></dt>
  611. <dd><p>Print values in pretty-printed form, if there is a pretty-printer
  612. for the value (see <a href="Pretty-Printing.html#Pretty-Printing">Pretty Printing</a>),
  613. otherwise print the value in raw form.
  614. </p>
  615. <p>The default setting is &ldquo;off&rdquo;.
  616. </p>
  617. </dd>
  618. <dt><code>show print raw-values</code></dt>
  619. <dd><p>Show whether to print values in raw form.
  620. </p>
  621. </dd>
  622. <dt><code>set print sevenbit-strings on</code></dt>
  623. <dd><a name="index-eight_002dbit-characters-in-strings"></a>
  624. <a name="index-octal-escapes-in-strings"></a>
  625. <p>Print using only seven-bit characters; if this option is set,
  626. <small>GDB</small> displays any eight-bit characters (in strings or
  627. character values) using the notation <code>\</code><var>nnn</var>. This setting is
  628. best if you are working in English (<small>ASCII</small>) and you use the
  629. high-order bit of characters as a marker or &ldquo;meta&rdquo; bit.
  630. </p>
  631. </dd>
  632. <dt><code>set print sevenbit-strings off</code></dt>
  633. <dd><p>Print full eight-bit characters. This allows the use of more
  634. international character sets, and is the default.
  635. </p>
  636. </dd>
  637. <dt><code>show print sevenbit-strings</code></dt>
  638. <dd><p>Show whether or not <small>GDB</small> is printing only seven-bit characters.
  639. </p>
  640. <a name="set-print-union"></a></dd>
  641. <dt><code>set print union on</code></dt>
  642. <dd><a name="index-unions-in-structures_002c-printing"></a>
  643. <p>Tell <small>GDB</small> to print unions which are contained in structures
  644. and other unions. This is the default setting.
  645. </p>
  646. </dd>
  647. <dt><code>set print union off</code></dt>
  648. <dd><p>Tell <small>GDB</small> not to print unions which are contained in
  649. structures and other unions. <small>GDB</small> will print <code>&quot;{...}&quot;</code>
  650. instead.
  651. </p>
  652. </dd>
  653. <dt><code>show print union</code></dt>
  654. <dd><p>Ask <small>GDB</small> whether or not it will print unions which are contained in
  655. structures and other unions.
  656. </p>
  657. <p>For example, given the declarations
  658. </p>
  659. <div class="smallexample">
  660. <pre class="smallexample">typedef enum {Tree, Bug} Species;
  661. typedef enum {Big_tree, Acorn, Seedling} Tree_forms;
  662. typedef enum {Caterpillar, Cocoon, Butterfly}
  663. Bug_forms;
  664. struct thing {
  665. Species it;
  666. union {
  667. Tree_forms tree;
  668. Bug_forms bug;
  669. } form;
  670. };
  671. struct thing foo = {Tree, {Acorn}};
  672. </pre></div>
  673. <p>with <code>set print union on</code> in effect &lsquo;<samp>p foo</samp>&rsquo; would print
  674. </p>
  675. <div class="smallexample">
  676. <pre class="smallexample">$1 = {it = Tree, form = {tree = Acorn, bug = Cocoon}}
  677. </pre></div>
  678. <p>and with <code>set print union off</code> in effect it would print
  679. </p>
  680. <div class="smallexample">
  681. <pre class="smallexample">$1 = {it = Tree, form = {...}}
  682. </pre></div>
  683. <p><code>set print union</code> affects programs written in C-like languages
  684. and in Pascal.
  685. </p></dd>
  686. </dl>
  687. <p>These settings are of interest when debugging C<tt>++</tt> programs:
  688. </p>
  689. <dl compact="compact">
  690. <dd><a name="index-demangling-C_002b_002b-names"></a>
  691. </dd>
  692. <dt><code>set print demangle</code></dt>
  693. <dt><code>set print demangle on</code></dt>
  694. <dd><p>Print C<tt>++</tt> names in their source form rather than in the encoded
  695. (&ldquo;mangled&rdquo;) form passed to the assembler and linker for type-safe
  696. linkage. The default is on.
  697. </p>
  698. </dd>
  699. <dt><code>show print demangle</code></dt>
  700. <dd><p>Show whether C<tt>++</tt> names are printed in mangled or demangled form.
  701. </p>
  702. </dd>
  703. <dt><code>set print asm-demangle</code></dt>
  704. <dt><code>set print asm-demangle on</code></dt>
  705. <dd><p>Print C<tt>++</tt> names in their source form rather than their mangled form, even
  706. in assembler code printouts such as instruction disassemblies.
  707. The default is off.
  708. </p>
  709. </dd>
  710. <dt><code>show print asm-demangle</code></dt>
  711. <dd><p>Show whether C<tt>++</tt> names in assembly listings are printed in mangled
  712. or demangled form.
  713. </p>
  714. <a name="index-C_002b_002b-symbol-decoding-style"></a>
  715. <a name="index-symbol-decoding-style_002c-C_002b_002b"></a>
  716. <a name="index-set-demangle_002dstyle"></a>
  717. </dd>
  718. <dt><code>set demangle-style <var>style</var></code></dt>
  719. <dd><p>Choose among several encoding schemes used by different compilers to represent
  720. C<tt>++</tt> names. If you omit <var>style</var>, you will see a list of possible
  721. formats. The default value is <var>auto</var>, which lets <small>GDB</small> choose a
  722. decoding style by inspecting your program.
  723. </p>
  724. </dd>
  725. <dt><code>show demangle-style</code></dt>
  726. <dd><p>Display the encoding style currently in use for decoding C<tt>++</tt> symbols.
  727. </p>
  728. <a name="set-print-object"></a></dd>
  729. <dt><code>set print object</code></dt>
  730. <dt><code>set print object on</code></dt>
  731. <dd><a name="index-derived-type-of-an-object_002c-printing"></a>
  732. <a name="index-display-derived-types"></a>
  733. <p>When displaying a pointer to an object, identify the <em>actual</em>
  734. (derived) type of the object rather than the <em>declared</em> type, using
  735. the virtual function table. Note that the virtual function table is
  736. required&mdash;this feature can only work for objects that have run-time
  737. type identification; a single virtual method in the object&rsquo;s declared
  738. type is sufficient. Note that this setting is also taken into account when
  739. working with variable objects via MI (see <a href="GDB_002fMI.html#GDB_002fMI">GDB/MI</a>).
  740. </p>
  741. </dd>
  742. <dt><code>set print object off</code></dt>
  743. <dd><p>Display only the declared type of objects, without reference to the
  744. virtual function table. This is the default setting.
  745. </p>
  746. </dd>
  747. <dt><code>show print object</code></dt>
  748. <dd><p>Show whether actual, or declared, object types are displayed.
  749. </p>
  750. <a name="set-print-static_002dmembers"></a></dd>
  751. <dt><code>set print static-members</code></dt>
  752. <dt><code>set print static-members on</code></dt>
  753. <dd><a name="index-static-members-of-C_002b_002b-objects"></a>
  754. <p>Print static members when displaying a C<tt>++</tt> object. The default is on.
  755. </p>
  756. </dd>
  757. <dt><code>set print static-members off</code></dt>
  758. <dd><p>Do not print static members when displaying a C<tt>++</tt> object.
  759. </p>
  760. </dd>
  761. <dt><code>show print static-members</code></dt>
  762. <dd><p>Show whether C<tt>++</tt> static members are printed or not.
  763. </p>
  764. </dd>
  765. <dt><code>set print pascal_static-members</code></dt>
  766. <dt><code>set print pascal_static-members on</code></dt>
  767. <dd><a name="index-static-members-of-Pascal-objects"></a>
  768. <a name="index-Pascal-objects_002c-static-members-display"></a>
  769. <p>Print static members when displaying a Pascal object. The default is on.
  770. </p>
  771. </dd>
  772. <dt><code>set print pascal_static-members off</code></dt>
  773. <dd><p>Do not print static members when displaying a Pascal object.
  774. </p>
  775. </dd>
  776. <dt><code>show print pascal_static-members</code></dt>
  777. <dd><p>Show whether Pascal static members are printed or not.
  778. </p>
  779. <a name="set-print-vtbl"></a></dd>
  780. <dt><code>set print vtbl</code></dt>
  781. <dt><code>set print vtbl on</code></dt>
  782. <dd><a name="index-pretty-print-C_002b_002b-virtual-function-tables"></a>
  783. <a name="index-virtual-functions-_0028C_002b_002b_0029-display"></a>
  784. <a name="index-VTBL-display"></a>
  785. <p>Pretty print C<tt>++</tt> virtual function tables. The default is off.
  786. (The <code>vtbl</code> commands do not work on programs compiled with the HP
  787. ANSI C<tt>++</tt> compiler (<code>aCC</code>).)
  788. </p>
  789. </dd>
  790. <dt><code>set print vtbl off</code></dt>
  791. <dd><p>Do not pretty print C<tt>++</tt> virtual function tables.
  792. </p>
  793. </dd>
  794. <dt><code>show print vtbl</code></dt>
  795. <dd><p>Show whether C<tt>++</tt> virtual function tables are pretty printed, or not.
  796. </p></dd>
  797. </dl>
  798. <hr>
  799. <div class="header">
  800. <p>
  801. Next: <a href="Pretty-Printing.html#Pretty-Printing" accesskey="n" rel="next">Pretty Printing</a>, Previous: <a href="Auto-Display.html#Auto-Display" accesskey="p" rel="prev">Auto Display</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>
  802. </div>
  803. </body>
  804. </html>