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.

155 lines
7.1KB

  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>Rust (Debugging with GDB)</title>
  17. <meta name="description" content="Rust (Debugging with GDB)">
  18. <meta name="keywords" content="Rust (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="Supported-Languages.html#Supported-Languages" rel="up" title="Supported Languages">
  26. <link href="Modula_002d2.html#Modula_002d2" rel="next" title="Modula-2">
  27. <link href="Pascal.html#Pascal" rel="prev" title="Pascal">
  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="Rust"></a>
  58. <div class="header">
  59. <p>
  60. Next: <a href="Modula_002d2.html#Modula_002d2" accesskey="n" rel="next">Modula-2</a>, Previous: <a href="Pascal.html#Pascal" accesskey="p" rel="prev">Pascal</a>, Up: <a href="Supported-Languages.html#Supported-Languages" accesskey="u" rel="up">Supported Languages</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="Rust-1"></a>
  64. <h4 class="subsection">15.4.8 Rust</h4>
  65. <p><small>GDB</small> supports the <a href="https://www.rust-lang.org/">Rust
  66. Programming Language</a>. Type- and value-printing, and expression
  67. parsing, are reasonably complete. However, there are a few
  68. peculiarities and holes to be aware of.
  69. </p>
  70. <ul>
  71. <li> Linespecs (see <a href="Specify-Location.html#Specify-Location">Specify Location</a>) are never relative to the current
  72. crate. Instead, they act as if there were a global namespace of
  73. crates, somewhat similar to the way <code>extern crate</code> behaves.
  74. <p>That is, if <small>GDB</small> is stopped at a breakpoint in a function in
  75. crate &lsquo;<samp>A</samp>&rsquo;, module &lsquo;<samp>B</samp>&rsquo;, then <code>break B::f</code> will attempt
  76. to set a breakpoint in a function named &lsquo;<samp>f</samp>&rsquo; in a crate named
  77. &lsquo;<samp>B</samp>&rsquo;.
  78. </p>
  79. <p>As a consequence of this approach, linespecs also cannot refer to
  80. items using &lsquo;<samp>self::</samp>&rsquo; or &lsquo;<samp>super::</samp>&rsquo;.
  81. </p>
  82. </li><li> Because <small>GDB</small> implements Rust name-lookup semantics in
  83. expressions, it will sometimes prepend the current crate to a name.
  84. For example, if <small>GDB</small> is stopped at a breakpoint in the crate
  85. &lsquo;<samp>K</samp>&rsquo;, then <code>print ::x::y</code> will try to find the symbol
  86. &lsquo;<samp>K::x::y</samp>&rsquo;.
  87. <p>However, since it is useful to be able to refer to other crates when
  88. debugging, <small>GDB</small> provides the <code>extern</code> extension to
  89. circumvent this. To use the extension, just put <code>extern</code> before
  90. a path expression to refer to the otherwise unavailable &ldquo;global&rdquo;
  91. scope.
  92. </p>
  93. <p>In the above example, if you wanted to refer to the symbol &lsquo;<samp>y</samp>&rsquo; in
  94. the crate &lsquo;<samp>x</samp>&rsquo;, you would use <code>print extern x::y</code>.
  95. </p>
  96. </li><li> The Rust expression evaluator does not support &ldquo;statement-like&rdquo;
  97. expressions such as <code>if</code> or <code>match</code>, or lambda expressions.
  98. </li><li> Tuple expressions are not implemented.
  99. </li><li> The Rust expression evaluator does not currently implement the
  100. <code>Drop</code> trait. Objects that may be created by the evaluator will
  101. never be destroyed.
  102. </li><li> <small>GDB</small> does not implement type inference for generics. In order
  103. to call generic functions or otherwise refer to generic items, you
  104. will have to specify the type parameters manually.
  105. </li><li> <small>GDB</small> currently uses the C<tt>++</tt> demangler for Rust. In most
  106. cases this does not cause any problems. However, in an expression
  107. context, completing a generic function name will give syntactically
  108. invalid results. This happens because Rust requires the &lsquo;<samp>::</samp>&rsquo;
  109. operator between the function name and its generic arguments. For
  110. example, <small>GDB</small> might provide a completion like
  111. <code>crate::f&lt;u32&gt;</code>, where the parser would require
  112. <code>crate::f::&lt;u32&gt;</code>.
  113. </li><li> As of this writing, the Rust compiler (version 1.8) has a few holes in
  114. the debugging information it generates. These holes prevent certain
  115. features from being implemented by <small>GDB</small>:
  116. <ul>
  117. <li> Method calls cannot be made via traits.
  118. </li><li> Operator overloading is not implemented.
  119. </li><li> When debugging in a monomorphized function, you cannot use the generic
  120. type names.
  121. </li><li> The type <code>Self</code> is not available.
  122. </li><li> <code>use</code> statements are not available, so some names may not be
  123. available in the crate.
  124. </li></ul>
  125. </li></ul>
  126. <hr>
  127. <div class="header">
  128. <p>
  129. Next: <a href="Modula_002d2.html#Modula_002d2" accesskey="n" rel="next">Modula-2</a>, Previous: <a href="Pascal.html#Pascal" accesskey="p" rel="prev">Pascal</a>, Up: <a href="Supported-Languages.html#Supported-Languages" accesskey="u" rel="up">Supported Languages</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>
  130. </div>
  131. </body>
  132. </html>