您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

Command-Settings.html 7.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  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>Command Settings (Debugging with GDB)</title>
  17. <meta name="description" content="Command Settings (Debugging with GDB)">
  18. <meta name="keywords" content="Command 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="Commands.html#Commands" rel="up" title="Commands">
  26. <link href="Completion.html#Completion" rel="next" title="Completion">
  27. <link href="Command-Syntax.html#Command-Syntax" rel="prev" title="Command Syntax">
  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="Command-Settings"></a>
  58. <div class="header">
  59. <p>
  60. Next: <a href="Completion.html#Completion" accesskey="n" rel="next">Completion</a>, Previous: <a href="Command-Syntax.html#Command-Syntax" accesskey="p" rel="prev">Command Syntax</a>, Up: <a href="Commands.html#Commands" accesskey="u" rel="up">Commands</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="Command-Settings-1"></a>
  64. <h3 class="section">3.2 Command Settings</h3>
  65. <a name="index-default-behavior-of-commands_002c-changing"></a>
  66. <a name="index-default-settings_002c-changing"></a>
  67. <p>Many commands change their behavior according to command-specific
  68. variables or settings. These settings can be changed with the
  69. <code>set</code> subcommands. For example, the <code>print</code> command
  70. (see <a href="Data.html#Data">Examining Data</a>) prints arrays differently depending on
  71. settings changeable with the commands <code>set print elements
  72. NUMBER-OF-ELEMENTS</code> and <code>set print array-indexes</code>, among others.
  73. </p>
  74. <p>You can change these settings to your preference in the gdbinit files
  75. loaded at <small>GDB</small> startup. See <a href="Startup.html#Startup">Startup</a>.
  76. </p>
  77. <p>The settings can also be changed interactively during the debugging
  78. session. For example, to change the limit of array elements to print,
  79. you can do the following:
  80. </p><div class="smallexample">
  81. <pre class="smallexample">(GDB) set print elements 10
  82. (GDB) print some_array
  83. $1 = {0, 10, 20, 30, 40, 50, 60, 70, 80, 90...}
  84. </pre></div>
  85. <p>The above <code>set print elements 10</code> command changes the number of
  86. elements to print from the default of 200 to 10. If you only intend
  87. this limit of 10 to be used for printing <code>some_array</code>, then you
  88. must restore the limit back to 200, with <code>set print elements
  89. 200</code>.
  90. </p>
  91. <p>Some commands allow overriding settings with command options. For
  92. example, the <code>print</code> command supports a number of options that
  93. allow overriding relevant global print settings as set by <code>set
  94. print</code> subcommands. See <a href="Data.html#print-options">print options</a>. The example above could be
  95. rewritten as:
  96. </p><div class="smallexample">
  97. <pre class="smallexample">(GDB) print -elements 10 -- some_array
  98. $1 = {0, 10, 20, 30, 40, 50, 60, 70, 80, 90...}
  99. </pre></div>
  100. <p>Alternatively, you can use the <code>with</code> command to change a setting
  101. temporarily, for the duration of a command invocation.
  102. </p>
  103. <dl compact="compact">
  104. <dd><a name="index-with-command"></a>
  105. <a name="index-w-_0028with_0029"></a>
  106. <a name="index-settings"></a>
  107. <a name="index-temporarily-change-settings"></a>
  108. </dd>
  109. <dt><code>with <var>setting</var> [<var>value</var>] [-- <var>command</var>]</code></dt>
  110. <dt><code>w <var>setting</var> [<var>value</var>] [-- <var>command</var>]</code></dt>
  111. <dd><p>Temporarily set <var>setting</var> to <var>value</var> for the duration of
  112. <var>command</var>.
  113. </p>
  114. <p><var>setting</var> is any setting you can change with the <code>set</code>
  115. subcommands. <var>value</var> is the value to assign to <code>setting</code>
  116. while running <code>command</code>.
  117. </p>
  118. <p>If no <var>command</var> is provided, the last command executed is
  119. repeated.
  120. </p>
  121. <p>If a <var>command</var> is provided, it must be preceded by a double dash
  122. (<code>--</code>) separator. This is required because some settings accept
  123. free-form arguments, such as expressions or filenames.
  124. </p>
  125. <p>For example, the command
  126. </p><div class="smallexample">
  127. <pre class="smallexample">(GDB) with print array on -- print some_array
  128. </pre></div>
  129. <p>is equivalent to the following 3 commands:
  130. </p><div class="smallexample">
  131. <pre class="smallexample">(GDB) set print array on
  132. (GDB) print some_array
  133. (GDB) set print array off
  134. </pre></div>
  135. <p>The <code>with</code> command is particularly useful when you want to
  136. override a setting while running user-defined commands, or commands
  137. defined in Python or Guile. See <a href="Extending-GDB.html#Extending-GDB">Extending GDB</a>.
  138. </p>
  139. <div class="smallexample">
  140. <pre class="smallexample">(GDB) with print pretty on -- my_complex_command
  141. </pre></div>
  142. <p>To change several settings for the same command, you can nest
  143. <code>with</code> commands. For example, <code>with language ada -- with
  144. print elements 10</code> temporarily changes the language to Ada and sets a
  145. limit of 10 elements to print for arrays and strings.
  146. </p>
  147. </dd>
  148. </dl>
  149. <hr>
  150. <div class="header">
  151. <p>
  152. Next: <a href="Completion.html#Completion" accesskey="n" rel="next">Completion</a>, Previous: <a href="Command-Syntax.html#Command-Syntax" accesskey="p" rel="prev">Command Syntax</a>, Up: <a href="Commands.html#Commands" accesskey="u" rel="up">Commands</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>
  153. </div>
  154. </body>
  155. </html>