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.

195 lines
8.3KB

  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>Non-debug DLL Symbols (Debugging with GDB)</title>
  17. <meta name="description" content="Non-debug DLL Symbols (Debugging with GDB)">
  18. <meta name="keywords" content="Non-debug DLL Symbols (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="Cygwin-Native.html#Cygwin-Native" rel="up" title="Cygwin Native">
  26. <link href="Hurd-Native.html#Hurd-Native" rel="next" title="Hurd Native">
  27. <link href="Cygwin-Native.html#Cygwin-Native" rel="prev" title="Cygwin Native">
  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="Non_002ddebug-DLL-Symbols"></a>
  58. <div class="header">
  59. <p>
  60. Up: <a href="Cygwin-Native.html#Cygwin-Native" accesskey="u" rel="up">Cygwin Native</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="Support-for-DLLs-without-Debugging-Symbols"></a>
  64. <h4 class="subsubsection">21.1.4.1 Support for DLLs without Debugging Symbols</h4>
  65. <a name="index-DLLs-with-no-debugging-symbols"></a>
  66. <a name="index-Minimal-symbols-and-DLLs"></a>
  67. <p>Very often on windows, some of the DLLs that your program relies on do
  68. not include symbolic debugging information (for example,
  69. <samp>kernel32.dll</samp>). When <small>GDB</small> doesn&rsquo;t recognize any debugging
  70. symbols in a DLL, it relies on the minimal amount of symbolic
  71. information contained in the DLL&rsquo;s export table. This section
  72. describes working with such symbols, known internally to <small>GDB</small> as
  73. &ldquo;minimal symbols&rdquo;.
  74. </p>
  75. <p>Note that before the debugged program has started execution, no DLLs
  76. will have been loaded. The easiest way around this problem is simply to
  77. start the program &mdash; either by setting a breakpoint or letting the
  78. program run once to completion.
  79. </p>
  80. <a name="DLL-Name-Prefixes"></a>
  81. <h4 class="subsubsection">21.1.4.2 DLL Name Prefixes</h4>
  82. <p>In keeping with the naming conventions used by the Microsoft debugging
  83. tools, DLL export symbols are made available with a prefix based on the
  84. DLL name, for instance <code>KERNEL32!CreateFileA</code>. The plain name is
  85. also entered into the symbol table, so <code>CreateFileA</code> is often
  86. sufficient. In some cases there will be name clashes within a program
  87. (particularly if the executable itself includes full debugging symbols)
  88. necessitating the use of the fully qualified name when referring to the
  89. contents of the DLL. Use single-quotes around the name to avoid the
  90. exclamation mark (&ldquo;!&rdquo;) being interpreted as a language operator.
  91. </p>
  92. <p>Note that the internal name of the DLL may be all upper-case, even
  93. though the file name of the DLL is lower-case, or vice-versa. Since
  94. symbols within <small>GDB</small> are <em>case-sensitive</em> this may cause
  95. some confusion. If in doubt, try the <code>info functions</code> and
  96. <code>info variables</code> commands or even <code>maint print msymbols</code>
  97. (see <a href="Symbols.html#Symbols">Symbols</a>). Here&rsquo;s an example:
  98. </p>
  99. <div class="smallexample">
  100. <pre class="smallexample">(gdb) info function CreateFileA
  101. All functions matching regular expression &quot;CreateFileA&quot;:
  102. Non-debugging symbols:
  103. 0x77e885f4 CreateFileA
  104. 0x77e885f4 KERNEL32!CreateFileA
  105. </pre></div>
  106. <div class="smallexample">
  107. <pre class="smallexample">(gdb) info function !
  108. All functions matching regular expression &quot;!&quot;:
  109. Non-debugging symbols:
  110. 0x6100114c cygwin1!__assert
  111. 0x61004034 cygwin1!_dll_crt0@0
  112. 0x61004240 cygwin1!dll_crt0(per_process *)
  113. [etc...]
  114. </pre></div>
  115. <a name="Working-with-Minimal-Symbols"></a>
  116. <h4 class="subsubsection">21.1.4.3 Working with Minimal Symbols</h4>
  117. <p>Symbols extracted from a DLL&rsquo;s export table do not contain very much
  118. type information. All that <small>GDB</small> can do is guess whether a symbol
  119. refers to a function or variable depending on the linker section that
  120. contains the symbol. Also note that the actual contents of the memory
  121. contained in a DLL are not available unless the program is running. This
  122. means that you cannot examine the contents of a variable or disassemble
  123. a function within a DLL without a running program.
  124. </p>
  125. <p>Variables are generally treated as pointers and dereferenced
  126. automatically. For this reason, it is often necessary to prefix a
  127. variable name with the address-of operator (&ldquo;&amp;&rdquo;) and provide explicit
  128. type information in the command. Here&rsquo;s an example of the type of
  129. problem:
  130. </p>
  131. <div class="smallexample">
  132. <pre class="smallexample">(gdb) print 'cygwin1!__argv'
  133. 'cygwin1!__argv' has unknown type; cast it to its declared type
  134. </pre></div>
  135. <div class="smallexample">
  136. <pre class="smallexample">(gdb) x 'cygwin1!__argv'
  137. 'cygwin1!__argv' has unknown type; cast it to its declared type
  138. </pre></div>
  139. <p>And two possible solutions:
  140. </p>
  141. <div class="smallexample">
  142. <pre class="smallexample">(gdb) print ((char **)'cygwin1!__argv')[0]
  143. $2 = 0x22fd98 &quot;/cygdrive/c/mydirectory/myprogram&quot;
  144. </pre></div>
  145. <div class="smallexample">
  146. <pre class="smallexample">(gdb) x/2x &amp;'cygwin1!__argv'
  147. 0x610c0aa8 &lt;cygwin1!__argv&gt;: 0x10021608 0x00000000
  148. (gdb) x/x 0x10021608
  149. 0x10021608: 0x0022fd98
  150. (gdb) x/s 0x0022fd98
  151. 0x22fd98: &quot;/cygdrive/c/mydirectory/myprogram&quot;
  152. </pre></div>
  153. <p>Setting a break point within a DLL is possible even before the program
  154. starts execution. However, under these circumstances, <small>GDB</small> can&rsquo;t
  155. examine the initial instructions of the function in order to skip the
  156. function&rsquo;s frame set-up code. You can work around this by using &ldquo;*&amp;&rdquo;
  157. to set the breakpoint at a raw memory address:
  158. </p>
  159. <div class="smallexample">
  160. <pre class="smallexample">(gdb) break *&amp;'python22!PyOS_Readline'
  161. Breakpoint 1 at 0x1e04eff0
  162. </pre></div>
  163. <p>The author of these extensions is not entirely convinced that setting a
  164. break point within a shared DLL like <samp>kernel32.dll</samp> is completely
  165. safe.
  166. </p>
  167. <hr>
  168. <div class="header">
  169. <p>
  170. Up: <a href="Cygwin-Native.html#Cygwin-Native" accesskey="u" rel="up">Cygwin Native</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>
  171. </div>
  172. </body>
  173. </html>