|
- <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
- <html>
- <!-- Copyright (C) 1988-2020 Free Software Foundation, Inc.
-
- Permission is granted to copy, distribute and/or modify this document
- under the terms of the GNU Free Documentation License, Version 1.3 or
- any later version published by the Free Software Foundation; with the
- Invariant Sections being "Free Software" and "Free Software Needs
- Free Documentation", with the Front-Cover Texts being "A GNU Manual,"
- and with the Back-Cover Texts as in (a) below.
-
- (a) The FSF's Back-Cover Text is: "You are free to copy and modify
- this GNU Manual. Buying copies from GNU Press supports the FSF in
- developing GNU and promoting software freedom." -->
- <!-- Created by GNU Texinfo 6.5, http://www.gnu.org/software/texinfo/ -->
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
- <title>Non-debug DLL Symbols (Debugging with GDB)</title>
-
- <meta name="description" content="Non-debug DLL Symbols (Debugging with GDB)">
- <meta name="keywords" content="Non-debug DLL Symbols (Debugging with GDB)">
- <meta name="resource-type" content="document">
- <meta name="distribution" content="global">
- <meta name="Generator" content="makeinfo">
- <link href="index.html#Top" rel="start" title="Top">
- <link href="Concept-Index.html#Concept-Index" rel="index" title="Concept Index">
- <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
- <link href="Cygwin-Native.html#Cygwin-Native" rel="up" title="Cygwin Native">
- <link href="Hurd-Native.html#Hurd-Native" rel="next" title="Hurd Native">
- <link href="Cygwin-Native.html#Cygwin-Native" rel="prev" title="Cygwin Native">
- <style type="text/css">
- <!--
- a.summary-letter {text-decoration: none}
- blockquote.indentedblock {margin-right: 0em}
- blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
- blockquote.smallquotation {font-size: smaller}
- div.display {margin-left: 3.2em}
- div.example {margin-left: 3.2em}
- div.lisp {margin-left: 3.2em}
- div.smalldisplay {margin-left: 3.2em}
- div.smallexample {margin-left: 3.2em}
- div.smalllisp {margin-left: 3.2em}
- kbd {font-style: oblique}
- pre.display {font-family: inherit}
- pre.format {font-family: inherit}
- pre.menu-comment {font-family: serif}
- pre.menu-preformatted {font-family: serif}
- pre.smalldisplay {font-family: inherit; font-size: smaller}
- pre.smallexample {font-size: smaller}
- pre.smallformat {font-family: inherit; font-size: smaller}
- pre.smalllisp {font-size: smaller}
- span.nolinebreak {white-space: nowrap}
- span.roman {font-family: initial; font-weight: normal}
- span.sansserif {font-family: sans-serif; font-weight: normal}
- ul.no-bullet {list-style: none}
- -->
- </style>
-
-
- </head>
-
- <body lang="en">
- <a name="Non_002ddebug-DLL-Symbols"></a>
- <div class="header">
- <p>
- Up: <a href="Cygwin-Native.html#Cygwin-Native" accesskey="u" rel="up">Cygwin Native</a> [<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>
- </div>
- <hr>
- <a name="Support-for-DLLs-without-Debugging-Symbols"></a>
- <h4 class="subsubsection">21.1.4.1 Support for DLLs without Debugging Symbols</h4>
- <a name="index-DLLs-with-no-debugging-symbols"></a>
- <a name="index-Minimal-symbols-and-DLLs"></a>
-
- <p>Very often on windows, some of the DLLs that your program relies on do
- not include symbolic debugging information (for example,
- <samp>kernel32.dll</samp>). When <small>GDB</small> doesn’t recognize any debugging
- symbols in a DLL, it relies on the minimal amount of symbolic
- information contained in the DLL’s export table. This section
- describes working with such symbols, known internally to <small>GDB</small> as
- “minimal symbols”.
- </p>
- <p>Note that before the debugged program has started execution, no DLLs
- will have been loaded. The easiest way around this problem is simply to
- start the program — either by setting a breakpoint or letting the
- program run once to completion.
- </p>
- <a name="DLL-Name-Prefixes"></a>
- <h4 class="subsubsection">21.1.4.2 DLL Name Prefixes</h4>
-
- <p>In keeping with the naming conventions used by the Microsoft debugging
- tools, DLL export symbols are made available with a prefix based on the
- DLL name, for instance <code>KERNEL32!CreateFileA</code>. The plain name is
- also entered into the symbol table, so <code>CreateFileA</code> is often
- sufficient. In some cases there will be name clashes within a program
- (particularly if the executable itself includes full debugging symbols)
- necessitating the use of the fully qualified name when referring to the
- contents of the DLL. Use single-quotes around the name to avoid the
- exclamation mark (“!”) being interpreted as a language operator.
- </p>
- <p>Note that the internal name of the DLL may be all upper-case, even
- though the file name of the DLL is lower-case, or vice-versa. Since
- symbols within <small>GDB</small> are <em>case-sensitive</em> this may cause
- some confusion. If in doubt, try the <code>info functions</code> and
- <code>info variables</code> commands or even <code>maint print msymbols</code>
- (see <a href="Symbols.html#Symbols">Symbols</a>). Here’s an example:
- </p>
- <div class="smallexample">
- <pre class="smallexample">(gdb) info function CreateFileA
- All functions matching regular expression "CreateFileA":
-
- Non-debugging symbols:
- 0x77e885f4 CreateFileA
- 0x77e885f4 KERNEL32!CreateFileA
- </pre></div>
-
- <div class="smallexample">
- <pre class="smallexample">(gdb) info function !
- All functions matching regular expression "!":
-
- Non-debugging symbols:
- 0x6100114c cygwin1!__assert
- 0x61004034 cygwin1!_dll_crt0@0
- 0x61004240 cygwin1!dll_crt0(per_process *)
- [etc...]
- </pre></div>
-
- <a name="Working-with-Minimal-Symbols"></a>
- <h4 class="subsubsection">21.1.4.3 Working with Minimal Symbols</h4>
-
- <p>Symbols extracted from a DLL’s export table do not contain very much
- type information. All that <small>GDB</small> can do is guess whether a symbol
- refers to a function or variable depending on the linker section that
- contains the symbol. Also note that the actual contents of the memory
- contained in a DLL are not available unless the program is running. This
- means that you cannot examine the contents of a variable or disassemble
- a function within a DLL without a running program.
- </p>
- <p>Variables are generally treated as pointers and dereferenced
- automatically. For this reason, it is often necessary to prefix a
- variable name with the address-of operator (“&”) and provide explicit
- type information in the command. Here’s an example of the type of
- problem:
- </p>
- <div class="smallexample">
- <pre class="smallexample">(gdb) print 'cygwin1!__argv'
- 'cygwin1!__argv' has unknown type; cast it to its declared type
- </pre></div>
-
- <div class="smallexample">
- <pre class="smallexample">(gdb) x 'cygwin1!__argv'
- 'cygwin1!__argv' has unknown type; cast it to its declared type
- </pre></div>
-
- <p>And two possible solutions:
- </p>
- <div class="smallexample">
- <pre class="smallexample">(gdb) print ((char **)'cygwin1!__argv')[0]
- $2 = 0x22fd98 "/cygdrive/c/mydirectory/myprogram"
- </pre></div>
-
- <div class="smallexample">
- <pre class="smallexample">(gdb) x/2x &'cygwin1!__argv'
- 0x610c0aa8 <cygwin1!__argv>: 0x10021608 0x00000000
- (gdb) x/x 0x10021608
- 0x10021608: 0x0022fd98
- (gdb) x/s 0x0022fd98
- 0x22fd98: "/cygdrive/c/mydirectory/myprogram"
- </pre></div>
-
- <p>Setting a break point within a DLL is possible even before the program
- starts execution. However, under these circumstances, <small>GDB</small> can’t
- examine the initial instructions of the function in order to skip the
- function’s frame set-up code. You can work around this by using “*&”
- to set the breakpoint at a raw memory address:
- </p>
- <div class="smallexample">
- <pre class="smallexample">(gdb) break *&'python22!PyOS_Readline'
- Breakpoint 1 at 0x1e04eff0
- </pre></div>
-
- <p>The author of these extensions is not entirely convinced that setting a
- break point within a shared DLL like <samp>kernel32.dll</samp> is completely
- safe.
- </p>
- <hr>
- <div class="header">
- <p>
- Up: <a href="Cygwin-Native.html#Cygwin-Native" accesskey="u" rel="up">Cygwin Native</a> [<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>
- </div>
-
-
-
- </body>
- </html>
|