Rust.html 7.2 KB

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 5.1, http://www.gnu.org/software/texinfo/ -->
  14. <head>
  15. <title>Debugging with GDB: Rust</title>
  16. <meta name="description" content="Debugging with GDB: Rust">
  17. <meta name="keywords" content="Debugging with GDB: Rust">
  18. <meta name="resource-type" content="document">
  19. <meta name="distribution" content="global">
  20. <meta name="Generator" content="makeinfo">
  21. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  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="previous" title="Pascal">
  28. <style type="text/css">
  29. <!--
  30. a.summary-letter {text-decoration: none}
  31. blockquote.smallquotation {font-size: smaller}
  32. div.display {margin-left: 3.2em}
  33. div.example {margin-left: 3.2em}
  34. div.indentedblock {margin-left: 3.2em}
  35. div.lisp {margin-left: 3.2em}
  36. div.smalldisplay {margin-left: 3.2em}
  37. div.smallexample {margin-left: 3.2em}
  38. div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
  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.nocodebreak {white-space:nowrap}
  50. span.nolinebreak {white-space:nowrap}
  51. span.roman {font-family:serif; font-weight:normal}
  52. span.sansserif {font-family:sans-serif; font-weight:normal}
  53. ul.no-bullet {list-style: none}
  54. -->
  55. </style>
  56. </head>
  57. <body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
  58. <a name="Rust"></a>
  59. <div class="header">
  60. <p>
  61. Next: <a href="Modula_002d2.html#Modula_002d2" accesskey="n" rel="next">Modula-2</a>, Previous: <a href="Pascal.html#Pascal" accesskey="p" rel="previous">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>
  62. </div>
  63. <hr>
  64. <a name="Rust-1"></a>
  65. <h4 class="subsection">15.4.8 Rust</h4>
  66. <p><small>GDB</small> supports the <a href="https://www.rust-lang.org/">Rust
  67. Programming Language</a>. Type- and value-printing, and expression
  68. parsing, are reasonably complete. However, there are a few
  69. peculiarities and holes to be aware of.
  70. </p>
  71. <ul>
  72. <li> Linespecs (see <a href="Specify-Location.html#Specify-Location">Specify Location</a>) are never relative to the current
  73. crate. Instead, they act as if there were a global namespace of
  74. crates, somewhat similar to the way <code>extern crate</code> behaves.
  75. <p>That is, if <small>GDB</small> is stopped at a breakpoint in a function in
  76. crate &lsquo;<samp>A</samp>&rsquo;, module &lsquo;<samp>B</samp>&rsquo;, then <code>break B::f</code> will attempt
  77. to set a breakpoint in a function named &lsquo;<samp>f</samp>&rsquo; in a crate named
  78. &lsquo;<samp>B</samp>&rsquo;.
  79. </p>
  80. <p>As a consequence of this approach, linespecs also cannot refer to
  81. items using &lsquo;<samp>self::</samp>&rsquo; or &lsquo;<samp>super::</samp>&rsquo;.
  82. </p>
  83. </li><li> Because <small>GDB</small> implements Rust name-lookup semantics in
  84. expressions, it will sometimes prepend the current crate to a name.
  85. For example, if <small>GDB</small> is stopped at a breakpoint in the crate
  86. &lsquo;<samp>K</samp>&rsquo;, then <code>print ::x::y</code> will try to find the symbol
  87. &lsquo;<samp>K::x::y</samp>&rsquo;.
  88. <p>However, since it is useful to be able to refer to other crates when
  89. debugging, <small>GDB</small> provides the <code>extern</code> extension to
  90. circumvent this. To use the extension, just put <code>extern</code> before
  91. a path expression to refer to the otherwise unavailable &ldquo;global&rdquo;
  92. scope.
  93. </p>
  94. <p>In the above example, if you wanted to refer to the symbol &lsquo;<samp>y</samp>&rsquo; in
  95. the crate &lsquo;<samp>x</samp>&rsquo;, you would use <code>print extern x::y</code>.
  96. </p>
  97. </li><li> The Rust expression evaluator does not support &ldquo;statement-like&rdquo;
  98. expressions such as <code>if</code> or <code>match</code>, or lambda expressions.
  99. </li><li> Tuple expressions are not implemented.
  100. </li><li> The Rust expression evaluator does not currently implement the
  101. <code>Drop</code> trait. Objects that may be created by the evaluator will
  102. never be destroyed.
  103. </li><li> <small>GDB</small> does not implement type inference for generics. In order
  104. to call generic functions or otherwise refer to generic items, you
  105. will have to specify the type parameters manually.
  106. </li><li> <small>GDB</small> currently uses the C<tt>++</tt> demangler for Rust. In most
  107. cases this does not cause any problems. However, in an expression
  108. context, completing a generic function name will give syntactically
  109. invalid results. This happens because Rust requires the &lsquo;<samp>::</samp>&rsquo;
  110. operator between the function name and its generic arguments. For
  111. example, <small>GDB</small> might provide a completion like
  112. <code>crate::f&lt;u32&gt;</code>, where the parser would require
  113. <code>crate::f::&lt;u32&gt;</code>.
  114. </li><li> As of this writing, the Rust compiler (version 1.8) has a few holes in
  115. the debugging information it generates. These holes prevent certain
  116. features from being implemented by <small>GDB</small>:
  117. <ul>
  118. <li> Method calls cannot be made via traits.
  119. </li><li> Operator overloading is not implemented.
  120. </li><li> When debugging in a monomorphized function, you cannot use the generic
  121. type names.
  122. </li><li> The type <code>Self</code> is not available.
  123. </li><li> <code>use</code> statements are not available, so some names may not be
  124. available in the crate.
  125. </li></ul>
  126. </li></ul>
  127. <hr>
  128. <div class="header">
  129. <p>
  130. Next: <a href="Modula_002d2.html#Modula_002d2" accesskey="n" rel="next">Modula-2</a>, Previous: <a href="Pascal.html#Pascal" accesskey="p" rel="previous">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>
  131. </div>
  132. </body>
  133. </html>