0% found this document useful (0 votes)
61 views83 pages

Debugging With GDB The GNU Source Level Debugger 9th Edition Richard M. Stallman Download

The document is a guide for using GDB, the GNU Source-Level Debugger, detailing its features and functionalities. It includes instructions on how to get started, run programs, set breakpoints, examine data, and debug multi-threaded applications. The content is published under the GNU Free Documentation License, allowing for copying and modification.

Uploaded by

aneleyjonben6
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
61 views83 pages

Debugging With GDB The GNU Source Level Debugger 9th Edition Richard M. Stallman Download

The document is a guide for using GDB, the GNU Source-Level Debugger, detailing its features and functionalities. It includes instructions on how to get started, run programs, set breakpoints, examine data, and debug multi-threaded applications. The content is published under the GNU Free Documentation License, allowing for copying and modification.

Uploaded by

aneleyjonben6
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 83

Debugging with GDB The GNU Source Level Debugger

9th Edition Richard M. Stallman pdf download

https://ebookgate.com/product/debugging-with-gdb-the-gnu-source-
level-debugger-9th-edition-richard-m-stallman/

Get Instant Ebook Downloads – Browse at https://ebookgate.com


Instant digital products (PDF, ePub, MOBI) available
Download now and explore formats that suit you...

GNU Emacs manual 14th Edition Richard M. Stallman

https://ebookgate.com/product/gnu-emacs-manual-14th-edition-richard-m-
stallman/

ebookgate.com

Free software free society selected essays of Richard M


Stallman First Printing, Edition Richard M. Stallman

https://ebookgate.com/product/free-software-free-society-selected-
essays-of-richard-m-stallman-first-printing-edition-richard-m-
stallman/
ebookgate.com

Free Software Free Society Selected Essays of Richard


Stallman 2nd Edition Edition Richard Stallman

https://ebookgate.com/product/free-software-free-society-selected-
essays-of-richard-stallman-2nd-edition-edition-richard-stallman/

ebookgate.com

GNU Linux application programming 1st Edition M. Tim(M.


Tim Jones) Jones

https://ebookgate.com/product/gnu-linux-application-programming-1st-
edition-m-timm-tim-jones-jones/

ebookgate.com
Electrical Trainee Guide Level 3 9th Edition Nccer

https://ebookgate.com/product/electrical-trainee-guide-level-3-9th-
edition-nccer/

ebookgate.com

The Debugger s Handbook 1st Edition J.F. Dimarzio

https://ebookgate.com/product/the-debugger-s-handbook-1st-edition-j-f-
dimarzio/

ebookgate.com

Free as in freedom 2 0 Richard Stallman and the free


software revolution 2nd Edition Sam Williams

https://ebookgate.com/product/free-as-in-freedom-2-0-richard-stallman-
and-the-free-software-revolution-2nd-edition-sam-williams/

ebookgate.com

Programming embedded systems with C and GNU development


tools 2nd Edition Michael Barr

https://ebookgate.com/product/programming-embedded-systems-with-c-and-
gnu-development-tools-2nd-edition-michael-barr/

ebookgate.com

Modern Multithreading Implementing Testing and Debugging


Multithreaded Java and C Pthreads Win32 First Edition
Richard H. Carver
https://ebookgate.com/product/modern-multithreading-implementing-
testing-and-debugging-multithreaded-java-and-c-pthreads-win32-first-
edition-richard-h-carver/
ebookgate.com
Debugging with GDB
The gnu Source-Level Debugger

Ninth Edition, for GDB version 5.1.1


January 2002

Richard Stallman, Roland Pesch, Stan Shebs, et al.


Copyright c 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
2002 Free Software Foundation, Inc.

Published by the Free Software Foundation


59 Temple Place - Suite 330,
Boston, MA 02111-1307 USA
ISBN 1-882114-88-4

Permission is granted to copy, distribute and/or modify this document under the terms
of the GNU Free Documentation License, Version 1.1 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 Free Software Foundation’s Back-Cover Text is: “You have freedom to copy and
modify this GNU Manual, like GNU software. Copies published by the Free Software
Foundation raise funds for GNU development.”
i

Table of Contents

Summary of GDB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Free software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Free Software Needs Free Documentation . . . . . . . . . . . . . . . . . . . . . . 1
Contributors to GDB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

1 A Sample GDB Session . . . . . . . . . . . . . . . . . . . . 7

2 Getting In and Out of GDB . . . . . . . . . . . . . . . 11


2.1 Invoking GDB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.1.1 Choosing files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
2.1.2 Choosing modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
2.2 Quitting GDB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
2.3 Shell commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

3 GDB Commands . . . . . . . . . . . . . . . . . . . . . . . . . 17
3.1 Command syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
3.2 Command completion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
3.3 Getting help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19

4 Running Programs Under GDB . . . . . . . . . . . 23


4.1 Compiling for debugging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
4.2 Starting your program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
4.3 Your program’s arguments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
4.4 Your program’s environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
4.5 Your program’s working directory . . . . . . . . . . . . . . . . . . . . . . . 26
4.6 Your program’s input and output . . . . . . . . . . . . . . . . . . . . . . . . 26
4.7 Debugging an already-running process . . . . . . . . . . . . . . . . . . . 27
4.8 Killing the child process . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
4.9 Debugging programs with multiple threads . . . . . . . . . . . . . . . 28
4.10 Debugging programs with multiple processes . . . . . . . . . . . . 30

5 Stopping and Continuing . . . . . . . . . . . . . . . . . . 33


5.1 Breakpoints, watchpoints, and catchpoints . . . . . . . . . . . . . . . 33
5.1.1 Setting breakpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
5.1.2 Setting watchpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
5.1.3 Setting catchpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
5.1.4 Deleting breakpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
5.1.5 Disabling breakpoints . . . . . . . . . . . . . . . . . . . . . . . . . . 41
5.1.6 Break conditions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
5.1.7 Breakpoint command lists . . . . . . . . . . . . . . . . . . . . . . 43
5.1.8 Breakpoint menus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
ii Debugging with GDB

5.1.9 “Cannot insert breakpoints” . . . . . . . . . . . . . . . . . . . . 45


5.2 Continuing and stepping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
5.3 Signals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
5.4 Stopping and starting multi-thread programs . . . . . . . . . . . . . 50

6 Examining the Stack . . . . . . . . . . . . . . . . . . . . . . 53


6.1 Stack frames . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
6.2 Backtraces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
6.3 Selecting a frame . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
6.4 Information about a frame . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56

7 Examining Source Files . . . . . . . . . . . . . . . . . . . 57


7.1 Printing source lines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
7.2 Searching source files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
7.3 Specifying source directories . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
7.4 Source and machine code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59

8 Examining Data . . . . . . . . . . . . . . . . . . . . . . . . . . 63
8.1 Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
8.2 Program variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
8.3 Artificial arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
8.4 Output formats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
8.5 Examining memory. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
8.6 Automatic display . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
8.7 Print settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
8.8 Value history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
8.9 Convenience variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
8.10 Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
8.11 Floating point hardware . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
8.12 Memory Region Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
8.12.1 Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
8.12.1.1 Memory Access Mode . . . . . . . . . . . . . . . . 79
8.12.1.2 Memory Access Size . . . . . . . . . . . . . . . . . . 79
8.12.1.3 Data Cache . . . . . . . . . . . . . . . . . . . . . . . . . . 80

9 Tracepoints. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
9.1 Commands to Set Tracepoints . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
9.1.1 Create and Delete Tracepoints . . . . . . . . . . . . . . . . . . 81
9.1.2 Enable and Disable Tracepoints . . . . . . . . . . . . . . . . . 82
9.1.3 Tracepoint Passcounts . . . . . . . . . . . . . . . . . . . . . . . . . 82
9.1.4 Tracepoint Action Lists . . . . . . . . . . . . . . . . . . . . . . . . 83
9.1.5 Listing Tracepoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
9.1.6 Starting and Stopping Trace Experiment . . . . . . . . 85
9.2 Using the collected data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
9.2.1 tfind n . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
9.2.2 tdump. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
9.2.3 save-tracepoints filename . . . . . . . . . . . . . . . . . . . . 88
9.3 Convenience Variables for Tracepoints . . . . . . . . . . . . . . . . . . . 88
iii

10 Debugging Programs That Use Overlays . . 91


10.1 How Overlays Work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
10.2 Overlay Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
10.3 Automatic Overlay Debugging . . . . . . . . . . . . . . . . . . . . . . . . . 94
10.4 Overlay Sample Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95

11 Using GDB with Different Languages . . . . . 97


11.1 Switching between source languages . . . . . . . . . . . . . . . . . . . . 97
11.1.1 List of filename extensions and languages . . . . . . . 97
11.1.2 Setting the working language . . . . . . . . . . . . . . . . . . 98
11.1.3 Having GDB infer the source language . . . . . . . . . 98
11.2 Displaying the language . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
11.3 Type and range checking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
11.3.1 An overview of type checking . . . . . . . . . . . . . . . . . . 99
11.3.2 An overview of range checking . . . . . . . . . . . . . . . . 100
11.4 Supported languages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
11.4.1 C and C++ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
11.4.1.1 C and C++ operators . . . . . . . . . . . . . . . . 102
11.4.1.2 C and C++ constants . . . . . . . . . . . . . . . . 104
11.4.1.3 C++ expressions . . . . . . . . . . . . . . . . . . . . . 104
11.4.1.4 C and C++ defaults . . . . . . . . . . . . . . . . . 105
11.4.1.5 C and C++ type and range checks . . . . 105
11.4.1.6 GDB and C . . . . . . . . . . . . . . . . . . . . . . . . 106
11.4.1.7 GDB features for C++ . . . . . . . . . . . . . . . 106
11.4.2 Modula-2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
11.4.2.1 Operators . . . . . . . . . . . . . . . . . . . . . . . . . . 107
11.4.2.2 Built-in functions and procedures . . . . 109
11.4.2.3 Constants . . . . . . . . . . . . . . . . . . . . . . . . . . 110
11.4.2.4 Modula-2 defaults . . . . . . . . . . . . . . . . . . . 110
11.4.2.5 Deviations from standard Modula-2 . . 110
11.4.2.6 Modula-2 type and range checks . . . . . 111
11.4.2.7 The scope operators :: and . . . . . . . . . 111
11.4.2.8 GDB and Modula-2 . . . . . . . . . . . . . . . . . 111
11.4.3 Chill . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
11.4.3.1 How modes are displayed . . . . . . . . . . . . 112
11.4.3.2 Locations and their accesses . . . . . . . . . 114
11.4.3.3 Values and their Operations . . . . . . . . . 114
11.4.3.4 Chill type and range checks . . . . . . . . . . 116
11.4.3.5 Chill defaults . . . . . . . . . . . . . . . . . . . . . . . 117

12 Examining the Symbol Table . . . . . . . . . . . . 119


iv Debugging with GDB

13 Altering Execution . . . . . . . . . . . . . . . . . . . . . 123


13.1 Assignment to variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
13.2 Continuing at a different address . . . . . . . . . . . . . . . . . . . . . . 124
13.3 Giving your program a signal . . . . . . . . . . . . . . . . . . . . . . . . . 125
13.4 Returning from a function . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125
13.5 Calling program functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126
13.6 Patching programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126

14 GDB Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127


14.1 Commands to specify files . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127
14.2 Errors reading symbol files . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132

15 Specifying a Debugging Target . . . . . . . . . . 135


15.1 Active targets. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135
15.2 Commands for managing targets . . . . . . . . . . . . . . . . . . . . . . 135
15.3 Choosing target byte order. . . . . . . . . . . . . . . . . . . . . . . . . . . . 137
15.4 Remote debugging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137
15.5 Kernel Object Display . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138

16 Debugging remote programs . . . . . . . . . . . . 139


16.1 Using the gdbserver program. . . . . . . . . . . . . . . . . . . . . . . . . 139
16.2 Using the gdbserve.nlm program . . . . . . . . . . . . . . . . . . . . . 140
16.3 Implementing a remote stub . . . . . . . . . . . . . . . . . . . . . . . . . . 141
16.3.1 What the stub can do for you . . . . . . . . . . . . . . . . 142
16.3.2 What you must do for the stub . . . . . . . . . . . . . . . 142
16.3.3 Putting it all together . . . . . . . . . . . . . . . . . . . . . . . 144

17 Configuration-Specific Information . . . . . . . 147


17.1 Native . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147
17.1.1 HP-UX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147
17.1.2 SVR4 process information . . . . . . . . . . . . . . . . . . . . 147
17.1.3 Features for Debugging djgpp Programs . . . . . . 147
17.1.4 Features for Debugging MS Windows PE
executables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149
17.2 Embedded Operating Systems. . . . . . . . . . . . . . . . . . . . . . . . . 150
17.2.1 Using GDB with VxWorks . . . . . . . . . . . . . . . . . . . 150
17.2.1.1 Connecting to VxWorks . . . . . . . . . . . . . 151
17.2.1.2 VxWorks download . . . . . . . . . . . . . . . . . 151
17.2.1.3 Running tasks . . . . . . . . . . . . . . . . . . . . . . 152
17.3 Embedded Processors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152
17.3.1 ARM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152
17.3.2 Hitachi H8/300 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152
17.3.2.1 Connecting to Hitachi boards . . . . . . . . 153
17.3.2.2 Using the E7000 in-circuit emulator . . 154
17.3.2.3 Special GDB commands for Hitachi micros
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155
17.3.3 H8/500 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155
v

17.3.4 Intel i960 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155


17.3.4.1 Startup with Nindy . . . . . . . . . . . . . . . . . 156
17.3.4.2 Options for Nindy . . . . . . . . . . . . . . . . . . 156
17.3.4.3 Nindy reset command . . . . . . . . . . . . . . . 156
17.3.5 Mitsubishi M32R/D . . . . . . . . . . . . . . . . . . . . . . . . . 156
17.3.6 M68k . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157
17.3.7 M88K . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157
17.3.8 MIPS Embedded . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157
17.3.9 PowerPC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159
17.3.10 HP PA Embedded . . . . . . . . . . . . . . . . . . . . . . . . . . 159
17.3.11 Hitachi SH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159
17.3.12 Tsqware Sparclet . . . . . . . . . . . . . . . . . . . . . . . . . . . 160
17.3.12.1 Setting file to debug. . . . . . . . . . . . . . . . 160
17.3.12.2 Connecting to Sparclet . . . . . . . . . . . . . 160
17.3.12.3 Sparclet download . . . . . . . . . . . . . . . . . 161
17.3.12.4 Running and debugging . . . . . . . . . . . . 161
17.3.13 Fujitsu Sparclite . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161
17.3.14 Tandem ST2000 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161
17.3.15 Zilog Z8000 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162
17.4 Architectures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163
17.4.1 A29K . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163
17.4.2 Alpha . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163
17.4.3 MIPS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163

18 Controlling GDB . . . . . . . . . . . . . . . . . . . . . . . 165


18.1 Prompt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165
18.2 Command editing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165
18.3 Command history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165
18.4 Screen size. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167
18.5 Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167
18.6 Optional warnings and messages . . . . . . . . . . . . . . . . . . . . . . 168
18.7 Optional messages about internal happenings. . . . . . . . . . . 169

19 Canned Sequences of Commands . . . . . . . . 171


19.1 User-defined commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171
19.2 User-defined command hooks . . . . . . . . . . . . . . . . . . . . . . . . . 172
19.3 Command files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173
19.4 Commands for controlled output . . . . . . . . . . . . . . . . . . . . . . 174

20 GDB Text User Interface . . . . . . . . . . . . . . . 177


20.1 TUI overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177
20.2 TUI Key Bindings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177
20.3 TUI specific commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178
20.4 TUI configuration variables . . . . . . . . . . . . . . . . . . . . . . . . . . . 179

21 Using GDB under gnu Emacs . . . . . . . . . . . 181


vi Debugging with GDB

22 GDB Annotations . . . . . . . . . . . . . . . . . . . . . . 183


22.1 What is an Annotation? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183
22.2 The Server Prefix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183
22.3 Values. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184
22.4 Frames . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185
22.5 Displays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187
22.6 Annotation for GDB Input. . . . . . . . . . . . . . . . . . . . . . . . . . . . 187
22.7 Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188
22.8 Information on Breakpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . 188
22.9 Invalidation Notices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189
22.10 Running the Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189
22.11 Displaying Source . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190
22.12 Annotations We Might Want in the Future . . . . . . . . . . . . 190

23 The gdb/mi Interface . . . . . . . . . . . . . . . . . . . 191


Function and Purpose . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191
Notation and Terminology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191
23.1 gdb/mi Command Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191
23.1.1 gdb/mi Input Syntax . . . . . . . . . . . . . . . . . . . . . . . . 191
23.1.2 gdb/mi Output Syntax . . . . . . . . . . . . . . . . . . . . . . 192
23.1.3 Simple Examples of gdb/mi Interaction . . . . . . . 194
23.2 gdb/mi Compatibility with CLI . . . . . . . . . . . . . . . . . . . . . . . 195
23.3 gdb/mi Output Records . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195
23.3.1 gdb/mi Result Records . . . . . . . . . . . . . . . . . . . . . . 195
23.3.2 gdb/mi Stream Records . . . . . . . . . . . . . . . . . . . . . 195
23.3.3 gdb/mi Out-of-band Records . . . . . . . . . . . . . . . . . 196
23.4 gdb/mi Command Description Format . . . . . . . . . . . . . . . . 196
23.5 gdb/mi Breakpoint table commands. . . . . . . . . . . . . . . . . . . 197
23.6 gdb/mi Data Manipulation . . . . . . . . . . . . . . . . . . . . . . . . . . . 205
23.7 gdb/mi Program control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215
23.8 Miscellaneous GDB commands in gdb/mi. . . . . . . . . . . . . . 225
23.9 gdb/mi Stack Manipulation Commands . . . . . . . . . . . . . . . 227
23.10 gdb/mi Symbol Query Commands . . . . . . . . . . . . . . . . . . . 232
23.11 gdb/mi Target Manipulation Commands . . . . . . . . . . . . . 235
23.12 gdb/mi Thread Commands . . . . . . . . . . . . . . . . . . . . . . . . . . 240
23.13 gdb/mi Tracepoint Commands. . . . . . . . . . . . . . . . . . . . . . . 242
23.14 gdb/mi Variable Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242

24 Reporting Bugs in GDB . . . . . . . . . . . . . . . . 247


24.1 Have you found a bug? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 247
24.2 How to report bugs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 247
vii

25 Command Line Editing . . . . . . . . . . . . . . . . . 251


25.1 Introduction to Line Editing . . . . . . . . . . . . . . . . . . . . . . . . . . 251
25.2 Readline Interaction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 251
25.2.1 Readline Bare Essentials . . . . . . . . . . . . . . . . . . . . . 251
25.2.2 Readline Movement Commands . . . . . . . . . . . . . . . 252
25.2.3 Readline Killing Commands . . . . . . . . . . . . . . . . . . 252
25.2.4 Readline Arguments . . . . . . . . . . . . . . . . . . . . . . . . . 253
25.2.5 Searching for Commands in the History . . . . . . . 253
25.3 Readline Init File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 254
25.3.1 Readline Init File Syntax . . . . . . . . . . . . . . . . . . . . . 254
25.3.2 Conditional Init Constructs . . . . . . . . . . . . . . . . . . 258
25.3.3 Sample Init File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 259
25.4 Bindable Readline Commands . . . . . . . . . . . . . . . . . . . . . . . . . 262
25.4.1 Commands For Moving . . . . . . . . . . . . . . . . . . . . . . 262
25.4.2 Commands For Manipulating The History . . . . . 262
25.4.3 Commands For Changing Text . . . . . . . . . . . . . . . 263
25.4.4 Killing And Yanking . . . . . . . . . . . . . . . . . . . . . . . . . 264
25.4.5 Specifying Numeric Arguments . . . . . . . . . . . . . . . 265
25.4.6 Letting Readline Type For You . . . . . . . . . . . . . . . 266
25.4.7 Keyboard Macros. . . . . . . . . . . . . . . . . . . . . . . . . . . . 266
25.4.8 Some Miscellaneous Commands . . . . . . . . . . . . . . . 267
25.5 Readline vi Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 268

26 Using History Interactively. . . . . . . . . . . . . . 269


26.1 History Expansion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269
26.1.1 Event Designators . . . . . . . . . . . . . . . . . . . . . . . . . . . 269
26.1.2 Word Designators . . . . . . . . . . . . . . . . . . . . . . . . . . . 270
26.1.3 Modifiers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 270

Appendix A Formatting Documentation . . . . 273

Appendix B Installing GDB . . . . . . . . . . . . . . . . 275


B.1 Compiling GDB in another directory . . . . . . . . . . . . . . . . . . . 276
B.2 Specifying names for hosts and targets . . . . . . . . . . . . . . . . . 277
B.3 configure options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 277

Appendix C Maintenance Commands . . . . . . . 279

Appendix D GDB Remote Serial Protocol . . 281

Appendix E GNU GENERAL PUBLIC


LICENSE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293
Preamble . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293
TERMS AND CONDITIONS FOR COPYING,
DISTRIBUTION AND MODIFICATION . . . . . . . . . . . . . . . 294
How to Apply These Terms to Your New Programs . . . . . . . . . . . 298
viii Debugging with GDB

Appendix F GNU Free Documentation License


. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 301
ADDENDUM: How to use this License for your documents . . . . 306

Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 307
Summary of GDB 1

Summary of GDB
The purpose of a debugger such as GDB is to allow you to see what is going on “inside”
another program while it executes—or what another program was doing at the moment it
crashed.
GDB can do four main kinds of things (plus other things in support of these) to help
you catch bugs in the act:
• Start your program, specifying anything that might affect its behavior.
• Make your program stop on specified conditions.
• Examine what has happened, when your program has stopped.
• Change things in your program, so you can experiment with correcting the effects of
one bug and go on to learn about another.
You can use GDB to debug programs written in C and C++. For more information, see
Section 11.4 [Supported languages], page 101. For more information, see Section 11.4.1 [C
and C++], page 102.
Support for Modula-2 and Chill is partial. For information on Modula-2, see Sec-
tion 11.4.2 [Modula-2], page 107. For information on Chill, see Section 11.4.3 [Chill],
page 112.
Debugging Pascal programs which use sets, subranges, file variables, or nested functions
does not currently work. GDB does not support entering expressions, printing values, or
similar features using Pascal syntax.
GDB can be used to debug programs written in Fortran, although it may be necessary
to refer to some variables with a trailing underscore.

Free software
GDB is free software, protected by the gnu General Public License (GPL). The GPL
gives you the freedom to copy or adapt a licensed program—but every person getting a
copy also gets with it the freedom to modify that copy (which means that they must get
access to the source code), and the freedom to distribute further copies. Typical software
companies use copyrights to limit your freedoms; the Free Software Foundation uses the
GPL to preserve these freedoms.
Fundamentally, the General Public License is a license which says that you have these
freedoms and that you cannot take these freedoms away from anyone else.

Free Software Needs Free Documentation


The biggest deficiency in the free software community today is not in the software—it is
the lack of good free documentation that we can include with the free software. Many of our
most important programs do not come with free reference manuals and free introductory
texts. Documentation is an essential part of any software package; when an important free
software package does not come with a free manual and a free tutorial, that is a major gap.
We have many such gaps today.
2 Debugging with GDB

Consider Perl, for instance. The tutorial manuals that people normally use are non-free.
How did this come about? Because the authors of those manuals published them with
restrictive terms—no copying, no modification, source files not available—which exclude
them from the free software world.
That wasn’t the first time this sort of thing happened, and it was far from the last.
Many times we have heard a GNU user eagerly describe a manual that he is writing, his
intended contribution to the community, only to learn that he had ruined everything by
signing a publication contract to make it non-free.
Free documentation, like free software, is a matter of freedom, not price. The problem
with the non-free manual is not that publishers charge a price for printed copies—that in
itself is fine. (The Free Software Foundation sells printed copies of manuals, too.) The
problem is the restrictions on the use of the manual. Free manuals are available in source
code form, and give you permission to copy and modify. Non-free manuals do not allow
this.
The criteria of freedom for a free manual are roughly the same as for free software.
Redistribution (including the normal kinds of commercial redistribution) must be permitted,
so that the manual can accompany every copy of the program, both on-line and on paper.
Permission for modification of the technical content is crucial too. When people mod-
ify the software, adding or changing features, if they are conscientious they will change
the manual too—so they can provide accurate and clear documentation for the modified
program. A manual that leaves you no choice but to write a new manual to document a
changed version of the program is not really available to our community.
Some kinds of limits on the way modification is handled are acceptable. For example,
requirements to preserve the original author’s copyright notice, the distribution terms, or
the list of authors, are ok. It is also no problem to require modified versions to include
notice that they were modified. Even entire sections that may not be deleted or changed
are acceptable, as long as they deal with nontechnical topics (like this one). These kinds of
restrictions are acceptable because they don’t obstruct the community’s normal use of the
manual.
However, it must be possible to modify all the technical content of the manual, and then
distribute the result in all the usual media, through all the usual channels. Otherwise, the
restrictions obstruct the use of the manual, it is not free, and we need another manual to
replace it.
Please spread the word about this issue. Our community continues to lose manuals
to proprietary publishing. If we spread the word that free software needs free reference
manuals and free tutorials, perhaps the next person who wants to contribute by writing
documentation will realize, before it is too late, that only free manuals contribute to the
free software community.
If you are writing documentation, please insist on publishing it under the GNU Free
Documentation License or another free documentation license. Remember that this deci-
sion requires your approval—you don’t have to let the publisher decide. Some commercial
publishers will use a free license if you insist, but they will not propose the option; it is up
to you to raise the issue and say firmly that this is what you want. If the publisher you
are dealing with refuses, please try other publishers. If you’re not sure whether a proposed
license is free, write to [email protected].
Summary of GDB 3

You can encourage commercial publishers to sell more free, copylefted manuals and
tutorials by buying them, and particularly by buying copies from the publishers that paid
for their writing or for major improvements. Meanwhile, try to avoid buying non-free
documentation at all. Check the distribution terms of a manual before you buy it, and
insist that whoever seeks your business must respect your freedom. Check the history of
the book, and try to reward the publishers that have paid or pay the authors to work on it.
The Free Software Foundation maintains a list of free documentation published by other
publishers, at http://www.fsf.org/doc/other-free-books.html.

Contributors to GDB
Richard Stallman was the original author of GDB, and of many other gnu programs.
Many others have contributed to its development. This section attempts to credit major
contributors. One of the virtues of free software is that everyone is free to contribute to
it; with regret, we cannot actually acknowledge everyone here. The file ‘ChangeLog’ in the
GDB distribution approximates a blow-by-blow account.
Changes much prior to version 2.0 are lost in the mists of time.
Plea: Additions to this section are particularly welcome. If you or your friends
(or enemies, to be evenhanded) have been unfairly omitted from this list, we
would like to add your names!
So that they may not regard their many labors as thankless, we particularly thank
those who shepherded GDB through major releases: Andrew Cagney (releases 5.0 and 5.1);
Jim Blandy (release 4.18); Jason Molenda (release 4.17); Stan Shebs (release 4.14); Fred
Fish (releases 4.16, 4.15, 4.13, 4.12, 4.11, 4.10, and 4.9); Stu Grossman and John Gilmore
(releases 4.8, 4.7, 4.6, 4.5, and 4.4); John Gilmore (releases 4.3, 4.2, 4.1, 4.0, and 3.9); Jim
Kingdon (releases 3.5, 3.4, and 3.3); and Randy Smith (releases 3.2, 3.1, and 3.0).
Richard Stallman, assisted at various times by Peter TerMaat, Chris Hanson, and
Richard Mlynarik, handled releases through 2.8.
Michael Tiemann is the author of most of the gnu C++ support in GDB, with significant
additional contributions from Per Bothner and Daniel Berlin. James Clark wrote the gnu
C++ demangler. Early work on C++ was by Peter TerMaat (who also did much general
update work leading to release 3.0).
GDB uses the BFD subroutine library to examine multiple object-file formats; BFD
was a joint project of David V. Henkel-Wallace, Rich Pixley, Steve Chamberlain, and John
Gilmore.
David Johnson wrote the original COFF support; Pace Willison did the original support
for encapsulated COFF.
Brent Benson of Harris Computer Systems contributed DWARF2 support.
Adam de Boor and Bradley Davis contributed the ISI Optimum V support. Per Bothner,
Noboyuki Hikichi, and Alessandro Forin contributed MIPS support. Jean-Daniel Fekete
contributed Sun 386i support. Chris Hanson improved the HP9000 support. Noboyuki
Hikichi and Tomoyuki Hasei contributed Sony/News OS 3 support. David Johnson con-
tributed Encore Umax support. Jyrki Kuoppala contributed Altos 3068 support. Jeff
Law contributed HP PA and SOM support. Keith Packard contributed NS32K support.
Doug Rabson contributed Acorn Risc Machine support. Bob Rusk contributed Harris
4 Debugging with GDB

Nighthawk CX-UX support. Chris Smith contributed Convex support (and Fortran de-
bugging). Jonathan Stone contributed Pyramid support. Michael Tiemann contributed
SPARC support. Tim Tucker contributed support for the Gould NP1 and Gould Powern-
ode. Pace Willison contributed Intel 386 support. Jay Vosburgh contributed Symmetry
support.
Andreas Schwab contributed M68K Linux support.
Rich Schaefer and Peter Schauer helped with support of SunOS shared libraries.
Jay Fenlason and Roland McGrath ensured that GDB and GAS agree about several
machine instruction sets.
Patrick Duval, Ted Goldstein, Vikram Koka and Glenn Engel helped develop remote
debugging. Intel Corporation, Wind River Systems, AMD, and ARM contributed remote
debugging modules for the i960, VxWorks, A29K UDI, and RDI targets, respectively.
Brian Fox is the author of the readline libraries providing command-line editing and
command history.
Andrew Beers of SUNY Buffalo wrote the language-switching code, the Modula-2 sup-
port, and contributed the Languages chapter of this manual.
Fred Fish wrote most of the support for Unix System Vr4. He also enhanced the
command-completion support to cover C++ overloaded symbols.
Hitachi America, Ltd. sponsored the support for H8/300, H8/500, and Super-H proces-
sors.
NEC sponsored the support for the v850, Vr4xxx, and Vr5xxx processors.
Mitsubishi sponsored the support for D10V, D30V, and M32R/D processors.
Toshiba sponsored the support for the TX39 Mips processor.
Matsushita sponsored the support for the MN10200 and MN10300 processors.
Fujitsu sponsored the support for SPARClite and FR30 processors.
Kung Hsu, Jeff Law, and Rick Sladkey added support for hardware watchpoints.
Michael Snyder added support for tracepoints.
Stu Grossman wrote gdbserver.
Jim Kingdon, Peter Schauer, Ian Taylor, and Stu Grossman made nearly innumerable
bug fixes and cleanups throughout GDB.
The following people at the Hewlett-Packard Company contributed support for the PA-
RISC 2.0 architecture, HP-UX 10.20, 10.30, and 11.0 (narrow mode), HP’s implementation
of kernel threads, HP’s aC++ compiler, and the terminal user interface: Ben Krepp, Richard
Title, John Bishop, Susan Macchia, Kathy Mann, Satish Pai, India Paul, Steve Rehrauer,
and Elena Zannoni. Kim Haase provided HP-specific information in this manual.
DJ Delorie ported GDB to MS-DOS, for the DJGPP project. Robert Hoehne made
significant contributions to the DJGPP port.
Cygnus Solutions has sponsored GDB maintenance and much of its development since
1991. Cygnus engineers who have worked on GDB fulltime include Mark Alexander, Jim
Blandy, Per Bothner, Kevin Buettner, Edith Epstein, Chris Faylor, Fred Fish, Martin
Hunt, Jim Ingham, John Gilmore, Stu Grossman, Kung Hsu, Jim Kingdon, John Metzler,
Fernando Nasser, Geoffrey Noer, Dawn Perchik, Rich Pixley, Zdenek Radouch, Keith Seitz,
Summary of GDB 5

Stan Shebs, David Taylor, and Elena Zannoni. In addition, Dave Brolley, Ian Carmichael,
Steve Chamberlain, Nick Clifton, JT Conklin, Stan Cox, DJ Delorie, Ulrich Drepper, Frank
Eigler, Doug Evans, Sean Fagan, David Henkel-Wallace, Richard Henderson, Jeff Holcomb,
Jeff Law, Jim Lemke, Tom Lord, Bob Manson, Michael Meissner, Jason Merrill, Catherine
Moore, Drew Moseley, Ken Raeburn, Gavin Romig-Koch, Rob Savoye, Jamie Smith, Mike
Stump, Ian Taylor, Angela Thomas, Michael Tiemann, Tom Tromey, Ron Unrau, Jim
Wilson, and David Zuhn have made contributions both large and small.
6 Debugging with GDB
Chapter 1: A Sample GDB Session 7

1 A Sample GDB Session


You can use this manual at your leisure to read all about GDB. However, a handful
of commands are enough to get started using the debugger. This chapter illustrates those
commands.
In this sample session, we emphasize user input like this: input, to make it easier to pick
out from the surrounding output.
One of the preliminary versions of gnu m4 (a generic macro processor) exhibits the
following bug: sometimes, when we change its quote strings from the default, the commands
used to capture one macro definition within another stop working. In the following short m4
session, we define a macro foo which expands to 0000; we then use the m4 built-in defn to
define bar as the same thing. However, when we change the open quote string to <QUOTE>
and the close quote string to <UNQUOTE>, the same procedure fails to define a new synonym
baz:
$ cd gnu/m4
$ ./m4
define(foo,0000)

foo
0000
define(bar,defn(‘foo’))

bar
0000
changequote(<QUOTE>,<UNQUOTE>)

define(baz,defn(<QUOTE>foo<UNQUOTE>))
baz
C-d
m4: End of input: 0: fatal error: EOF in string
Let us use GDB to try to see what is going on.
$ gdb m4
GDB is free software and you are welcome to distribute copies
of it under certain conditions; type "show copying" to see
the conditions.
There is absolutely no warranty for GDB; type "show warranty"
for details.

GDB 5.2.1, Copyright 1999 Free Software Foundation, Inc...


(gdb)
GDB reads only enough symbol data to know where to find the rest when needed; as a
result, the first prompt comes up very quickly. We now tell GDB to use a narrower display
width than usual, so that examples fit in this manual.
(gdb) set width 70
We need to see how the m4 built-in changequote works. Having looked at the source, we
know the relevant subroutine is m4_changequote, so we set a breakpoint there with the
GDB break command.
8 Debugging with GDB

(gdb) break m4 changequote


Breakpoint 1 at 0x62f4: file builtin.c, line 879.
Using the run command, we start m4 running under GDB control; as long as control does
not reach the m4_changequote subroutine, the program runs as usual:
(gdb) run
Starting program: /work/Editorial/gdb/gnu/m4/m4
define(foo,0000)

foo
0000
To trigger the breakpoint, we call changequote. GDB suspends execution of m4, displaying
information about the context where it stops.
changequote(<QUOTE>,<UNQUOTE>)

Breakpoint 1, m4_changequote (argc=3, argv=0x33c70)


at builtin.c:879
879 if (bad_argc(TOKEN_DATA_TEXT(argv[0]),argc,1,3))
Now we use the command n (next) to advance execution to the next line of the current
function.
(gdb) n
882 set_quotes((argc >= 2) ? TOKEN_DATA_TEXT(argv[1])\
: nil,
set_quotes looks like a promising subroutine. We can go into it by using the command s
(step) instead of next. step goes to the next line to be executed in any subroutine, so it
steps into set_quotes.
(gdb) s
set_quotes (lq=0x34c78 "<QUOTE>", rq=0x34c88 "<UNQUOTE>")
at input.c:530
530 if (lquote != def_lquote)
The display that shows the subroutine where m4 is now suspended (and its arguments) is
called a stack frame display. It shows a summary of the stack. We can use the backtrace
command (which can also be spelled bt), to see where we are in the stack as a whole: the
backtrace command displays a stack frame for each active subroutine.
(gdb) bt
#0 set_quotes (lq=0x34c78 "<QUOTE>", rq=0x34c88 "<UNQUOTE>")
at input.c:530
#1 0x6344 in m4_changequote (argc=3, argv=0x33c70)
at builtin.c:882
#2 0x8174 in expand_macro (sym=0x33320) at macro.c:242
#3 0x7a88 in expand_token (obs=0x0, t=209696, td=0xf7fffa30)
at macro.c:71
#4 0x79dc in expand_input () at macro.c:40
#5 0x2930 in main (argc=0, argv=0xf7fffb20) at m4.c:195
We step through a few more lines to see what happens. The first two times, we can use ‘s’;
the next two times we use n to avoid falling into the xstrdup subroutine.
Chapter 1: A Sample GDB Session 9

(gdb) s
0x3b5c 532 if (rquote != def_rquote)
(gdb) s
0x3b80 535 lquote = (lq == nil || *lq == ’\0’) ? \
def_lquote : xstrdup(lq);
(gdb) n
536 rquote = (rq == nil || *rq == ’\0’) ? def_rquote\
: xstrdup(rq);
(gdb) n
538 len_lquote = strlen(rquote);
The last line displayed looks a little odd; we can examine the variables lquote and rquote
to see if they are in fact the new left and right quotes we specified. We use the command
p (print) to see their values.
(gdb) p lquote
$1 = 0x35d40 "<QUOTE>"
(gdb) p rquote
$2 = 0x35d50 "<UNQUOTE>"
lquote and rquote are indeed the new left and right quotes. To look at some context, we
can display ten lines of source surrounding the current line with the l (list) command.
(gdb) l
533 xfree(rquote);
534
535 lquote = (lq == nil || *lq == ’\0’) ? def_lquote\
: xstrdup (lq);
536 rquote = (rq == nil || *rq == ’\0’) ? def_rquote\
: xstrdup (rq);
537
538 len_lquote = strlen(rquote);
539 len_rquote = strlen(lquote);
540 }
541
542 void
Let us step past the two lines that set len_lquote and len_rquote, and then examine the
values of those variables.
(gdb) n
539 len_rquote = strlen(lquote);
(gdb) n
540 }
(gdb) p len lquote
$3 = 9
(gdb) p len rquote
$4 = 7
That certainly looks wrong, assuming len_lquote and len_rquote are meant to be the
lengths of lquote and rquote respectively. We can set them to better values using the p
command, since it can print the value of any expression—and that expression can include
subroutine calls and assignments.
(gdb) p len lquote=strlen(lquote)
10 Debugging with GDB

$5 = 7
(gdb) p len rquote=strlen(rquote)
$6 = 9
Is that enough to fix the problem of using the new quotes with the m4 built-in defn? We can
allow m4 to continue executing with the c (continue) command, and then try the example
that caused trouble initially:
(gdb) c
Continuing.

define(baz,defn(<QUOTE>foo<UNQUOTE>))

baz
0000
Success! The new quotes now work just as well as the default ones. The problem seems to
have been just the two typos defining the wrong lengths. We allow m4 exit by giving it an
EOF as input:
C-d
Program exited normally.
The message ‘Program exited normally.’ is from GDB; it indicates m4 has finished exe-
cuting. We can end our GDB session with the GDB quit command.
(gdb) quit
Chapter 2: Getting In and Out of GDB 11

2 Getting In and Out of GDB


This chapter discusses how to start GDB, and how to get out of it. The essentials are:
• type ‘gdb’ to start GDB.
• type quit or C-d to exit.

2.1 Invoking GDB


Invoke GDB by running the program gdb. Once started, GDB reads commands from
the terminal until you tell it to exit.
You can also run gdb with a variety of arguments and options, to specify more of your
debugging environment at the outset.
The command-line options described here are designed to cover a variety of situations;
in some environments, some of these options may effectively be unavailable.
The most usual way to start GDB is with one argument, specifying an executable pro-
gram:
gdb program
You can also start with both an executable program and a core file specified:
gdb program core
You can, instead, specify a process ID as a second argument, if you want to debug a
running process:
gdb program 1234
would attach GDB to process 1234 (unless you also have a file named ‘1234’; GDB does
check for a core file first).
Taking advantage of the second command-line argument requires a fairly complete op-
erating system; when you use GDB as a remote debugger attached to a bare board, there
may not be any notion of “process”, and there is often no way to get a core dump. GDB
will warn you if it is unable to attach or to read core dumps.
You can optionally have gdb pass any arguments after the executable file to the inferior
using --args. This option stops option processing.
gdb --args gcc -O2 -c foo.c
This will cause gdb to debug gcc, and to set gcc’s command-line arguments (see Sec-
tion 4.3 [Arguments], page 24) to ‘-O2 -c foo.c’.
You can run gdb without printing the front material, which describes GDB’s non-
warranty, by specifying -silent:
gdb -silent
You can further control how GDB starts up by using command-line options. GDB itself
can remind you of the options available.
Type
gdb -help
to display all available options and briefly describe their use (‘gdb -h’ is a shorter equiva-
lent).
All options and command line arguments you give are processed in sequential order. The
order makes a difference when the ‘-x’ option is used.
12 Debugging with GDB

2.1.1 Choosing files


When GDB starts, it reads any arguments other than options as specifying an executable
file and core file (or process ID). This is the same as if the arguments were specified by the
‘-se’ and ‘-c’ (or ‘-p’ options respectively. (GDB reads the first argument that does not
have an associated option flag as equivalent to the ‘-se’ option followed by that argument;
and the second argument that does not have an associated option flag, if any, as equivalent
to the ‘-c’/‘-p’ option followed by that argument.) If the second argument begins with a
decimal digit, GDB will first attempt to attach to it as a process, and if that fails, attempt
to open it as a corefile. If you have a corefile whose name begins with a digit, you can
prevent GDB from treating it as a pid by prefixing it with ‘./’, eg. ‘./12345’.
If GDB has not been configured to included core file support, such as for most embedded
targets, then it will complain about a second argument and ignore it.
Many options have both long and short forms; both are shown in the following list.
GDB also recognizes the long forms if you truncate them, so long as enough of the option is
present to be unambiguous. (If you prefer, you can flag option arguments with ‘--’ rather
than ‘-’, though we illustrate the more usual convention.)
-symbols file
-s file Read symbol table from file file.
-exec file
-e file Use file file as the executable file to execute when appropriate, and for examining
pure data in conjunction with a core dump.
-se file Read symbol table from file file and use it as the executable file.
-core file
-c file Use file file as a core dump to examine.
-c number
-pid number
-p number
Connect to process ID number, as with the attach command. If there is no
such process, GDB will attempt to open a core file named number.
-command file
-x file Execute GDB commands from file file. See Section 19.3 [Command files],
page 173.
-directory directory
-d directory
Add directory to the path to search for source files.
-m
-mapped Warning: this option depends on operating system facilities that are not sup-
ported on all systems.
If memory-mapped files are available on your system through the mmap system
call, you can use this option to have GDB write the symbols from your program
into a reusable file in the current directory. If the program you are debugging
is called ‘/tmp/fred’, the mapped symbol file is ‘/tmp/fred.syms’. Future
Chapter 2: Getting In and Out of GDB 13

GDB debugging sessions notice the presence of this file, and can quickly map
in symbol information from it, rather than reading the symbol table from the
executable program.
The ‘.syms’ file is specific to the host machine where GDB is run. It holds
an exact image of the internal GDB symbol table. It cannot be shared across
multiple host platforms.
-r
-readnow Read each symbol file’s entire symbol table immediately, rather than the default,
which is to read it incrementally as it is needed. This makes startup slower,
but makes future operations faster.
You typically combine the -mapped and -readnow options in order to build a ‘.syms’
file that contains complete symbol information. (See Section 14.1 [Commands to specify
files], page 127, for information on ‘.syms’ files.) A simple GDB invocation to do nothing
but build a ‘.syms’ file for future use is:
gdb -batch -nx -mapped -readnow programname

2.1.2 Choosing modes


You can run GDB in various alternative modes—for example, in batch mode or quiet
mode.
-nx
-n Do not execute commands found in any initialization files. Normally, GDB exe-
cutes the commands in these files after all the command options and arguments
have been processed. See Section 19.3 [Command files], page 173.
-quiet
-silent
-q “Quiet”. Do not print the introductory and copyright messages. These mes-
sages are also suppressed in batch mode.
-batch Run in batch mode. Exit with status 0 after processing all the command files
specified with ‘-x’ (and all commands from initialization files, if not inhibited
with ‘-n’). Exit with nonzero status if an error occurs in executing the GDB
commands in the command files.
Batch mode may be useful for running GDB as a filter, for example to download
and run a program on another computer; in order to make this more useful, the
message
Program exited normally.
(which is ordinarily issued whenever a program running under GDB control
terminates) is not issued when running in batch mode.
-nowindows
-nw “No windows”. If GDB comes with a graphical user interface (GUI) built in,
then this option tells GDB to only use the command-line interface. If no GUI
is available, this option has no effect.
-windows
-w If GDB includes a GUI, then this option requires it to be used if possible.
14 Debugging with GDB

-cd directory
Run GDB using directory as its working directory, instead of the current direc-
tory.
-fullname
-f gnu Emacs sets this option when it runs GDB as a subprocess. It tells GDB to
output the full file name and line number in a standard, recognizable fashion
each time a stack frame is displayed (which includes each time your program
stops). This recognizable format looks like two ‘\032’ characters, followed by
the file name, line number and character position separated by colons, and a
newline. The Emacs-to-GDB interface program uses the two ‘\032’ characters
as a signal to display the source code for the frame.
-epoch The Epoch Emacs-GDB interface sets this option when it runs GDB as a sub-
process. It tells GDB to modify its print routines so as to allow Epoch to
display values of expressions in a separate window.
-annotate level
This option sets the annotation level inside GDB. Its effect is identical to using
‘set annotate level’ (see Chapter 22 [Annotations], page 183). Annotation
level controls how much information does GDB print together with its prompt,
values of expressions, source lines, and other types of output. Level 0 is the
normal, level 1 is for use when GDB is run as a subprocess of gnu Emacs, level
2 is the maximum annotation suitable for programs that control GDB.
-async Use the asynchronous event loop for the command-line interface. GDB pro-
cesses all events, such as user keyboard input, via a special event loop. This
allows GDB to accept and process user commands in parallel with the debugged
process being run1 , so you don’t need to wait for control to return to GDB be-
fore you type the next command. (Note: as of version 5.1, the target side of
the asynchronous operation is not yet in place, so ‘-async’ does not work fully
yet.)
When the standard input is connected to a terminal device, GDB uses the
asynchronous event loop by default, unless disabled by the ‘-noasync’ option.
-noasync Disable the asynchronous event loop for the command-line interface.
--args Change interpretation of command line so that arguments following the exe-
cutable file are passed as command line arguments to the inferior. This option
stops option processing.
-baud bps
-b bps Set the line speed (baud rate or bits per second) of any serial interface used by
GDB for remote debugging.
-tty device
-t device Run using device for your program’s standard input and output.
-tui Activate the Terminal User Interface when starting. The Terminal User Inter-
face manages several text windows on the terminal, showing source, assembly,
1
GDB built with djgpp tools for MS-DOS/MS-Windows supports this mode of operation, but the event
loop is suspended when the debuggee runs.
Chapter 2: Getting In and Out of GDB 15

registers and GDB command outputs (see Chapter 20 [GDB Text User Inter-
face], page 177). Do not use this option if you run GDB from Emacs (see
Chapter 21 [Using GDB under gnu Emacs], page 181).
-interpreter interp
Use the interpreter interp for interface with the controlling program or device.
This option is meant to be set by programs which communicate with GDB
using it as a back end.
‘--interpreter=mi’ (or ‘--interpreter=mi1’) causes GDB to use the
gdb/mi interface (see Chapter 23 [The gdb/mi Interface], page 191). The
older gdb/mi interface, included in GDB version 5.0 can be selected with
‘--interpreter=mi0’.
-write Open the executable and core files for both reading and writing. This is equiv-
alent to the ‘set write on’ command inside GDB (see Section 13.6 [Patching],
page 126).
-statistics
This option causes GDB to print statistics about time and memory usage after
it completes each command and returns to the prompt.
-version This option causes GDB to print its version number and no-warranty blurb,
and exit.

2.2 Quitting GDB


quit [expression]
q To exit GDB, use the quit command (abbreviated q), or type an end-of-file
character (usually C-d). If you do not supply expression, GDB will terminate
normally; otherwise it will terminate using the result of expression as the error
code.

An interrupt (often C-c) does not exit from GDB, but rather terminates the action of
any GDB command that is in progress and returns to GDB command level. It is safe to
type the interrupt character at any time because GDB does not allow it to take effect until
a time when it is safe.
If you have been using GDB to control an attached process or device, you can release
it with the detach command (see Section 4.7 [Debugging an already-running process],
page 27).

2.3 Shell commands


If you need to execute occasional shell commands during your debugging session, there
is no need to leave or suspend GDB; you can just use the shell command.

shell command string


Invoke a standard shell to execute command string. If it exists, the environment
variable SHELL determines which shell to run. Otherwise GDB uses the default
shell (‘/bin/sh’ on Unix systems, ‘COMMAND.COM’ on MS-DOS, etc.).
16 Debugging with GDB

The utility make is often needed in development environments. You do not have to use
the shell command for this purpose in GDB:

make make-args
Execute the make program with the specified arguments. This is equivalent to
‘shell make make-args’.
Chapter 3: GDB Commands 17

3 GDB Commands
You can abbreviate a GDB command to the first few letters of the command name, if
that abbreviation is unambiguous; and you can repeat certain GDB commands by typing
just hRETi. You can also use the hTABi key to get GDB to fill out the rest of a word in a
command (or to show you the alternatives available, if there is more than one possibility).

3.1 Command syntax


A GDB command is a single line of input. There is no limit on how long it can be.
It starts with a command name, which is followed by arguments whose meaning depends
on the command name. For example, the command step accepts an argument which is
the number of times to step, as in ‘step 5’. You can also use the step command with no
arguments. Some commands do not allow any arguments.
GDB command names may always be truncated if that abbreviation is unambiguous.
Other possible command abbreviations are listed in the documentation for individual com-
mands. In some cases, even ambiguous abbreviations are allowed; for example, s is specially
defined as equivalent to step even though there are other commands whose names start
with s. You can test abbreviations by using them as arguments to the help command.
A blank line as input to GDB (typing just hRETi) means to repeat the previous command.
Certain commands (for example, run) will not repeat this way; these are commands whose
unintentional repetition might cause trouble and which you are unlikely to want to repeat.
The list and x commands, when you repeat them with hRETi, construct new arguments
rather than repeating exactly as typed. This permits easy scanning of source or memory.
GDB can also use hRETi in another way: to partition lengthy output, in a way similar to
the common utility more (see Section 18.4 [Screen size], page 167). Since it is easy to press
one hRETi too many in this situation, GDB disables command repetition after any command
that generates this sort of display.
Any text from a # to the end of the line is a comment; it does nothing. This is useful
mainly in command files (see Section 19.3 [Command files], page 173).
The C-o binding is useful for repeating a complex sequence of commands. This command
accepts the current line, like RET, and then fetches the next line relative to the current line
from the history for editing.

3.2 Command completion


GDB can fill in the rest of a word in a command for you, if there is only one possibility;
it can also show you what the valid possibilities are for the next word in a command, at
any time. This works for GDB commands, GDB subcommands, and the names of symbols
in your program.
Press the hTABi key whenever you want GDB to fill out the rest of a word. If there is
only one possibility, GDB fills in the word, and waits for you to finish the command (or
press hRETi to enter it). For example, if you type
(gdb) info bre hTABi
GDB fills in the rest of the word ‘breakpoints’, since that is the only info subcommand
beginning with ‘bre’:
18 Debugging with GDB

(gdb) info breakpoints


You can either press hRETi at this point, to run the info breakpoints command, or
backspace and enter something else, if ‘breakpoints’ does not look like the command you
expected. (If you were sure you wanted info breakpoints in the first place, you might as
well just type hRETi immediately after ‘info bre’, to exploit command abbreviations rather
than command completion).
If there is more than one possibility for the next word when you press hTABi, GDB sounds
a bell. You can either supply more characters and try again, or just press hTABi a second
time; GDB displays all the possible completions for that word. For example, you might
want to set a breakpoint on a subroutine whose name begins with ‘make_’, but when you
type b make_hTABi GDB just sounds the bell. Typing hTABi again displays all the function
names in your program that begin with those characters, for example:
(gdb) b make_ hTABi
GDB sounds bell; press hTABi again, to see:
make_a_section_from_file make_environ
make_abs_section make_function_type
make_blockvector make_pointer_type
make_cleanup make_reference_type
make_command make_symbol_completion_list
(gdb) b make_
After displaying the available possibilities, GDB copies your partial input (‘b make_’ in the
example) so you can finish the command.
If you just want to see the list of alternatives in the first place, you can press M-? rather
than pressing hTABi twice. M-? means hMETAi ?. You can type this either by holding down
a key designated as the hMETAi shift on your keyboard (if there is one) while typing ?, or as
hESCi followed by ?.
Sometimes the string you need, while logically a “word”, may contain parentheses or
other characters that GDB normally excludes from its notion of a word. To permit word
completion to work in this situation, you may enclose words in ’ (single quote marks) in
GDB commands.
The most likely situation where you might need this is in typing the name of a C++
function. This is because C++ allows function overloading (multiple definitions of the same
function, distinguished by argument type). For example, when you want to set a breakpoint
you may need to distinguish whether you mean the version of name that takes an int
parameter, name(int), or the version that takes a float parameter, name(float). To use
the word-completion facilities in this situation, type a single quote ’ at the beginning of
the function name. This alerts GDB that it may need to consider more information than
usual when you press hTABi or M-? to request word completion:
(gdb) b ’bubble( M-?
bubble(double,double) bubble(int,int)
(gdb) b ’bubble(
In some cases, GDB can tell that completing a name requires using quotes. When this
happens, GDB inserts the quote for you (while completing as much as it can) if you do not
type the quote in the first place:
(gdb) b bub hTABi
Chapter 3: GDB Commands 19

GDB alters your input line to the following, and rings a bell:
(gdb) b ’bubble(
In general, GDB can tell that a quote is needed (and inserts it) if you have not yet started
typing the argument list when you ask for completion on an overloaded symbol.
For more information about overloaded functions, see Section 11.4.1.3 [C++ expressions],
page 104. You can use the command set overload-resolution off to disable overload
resolution; see Section 11.4.1.7 [GDB features for C++], page 106.

3.3 Getting help


You can always ask GDB itself for information on its commands, using the command
help.

help
h You can use help (abbreviated h) with no arguments to display a short list of
named classes of commands:
(gdb) help
List of classes of commands:

aliases -- Aliases of other commands


breakpoints -- Making program stop at certain points
data -- Examining data
files -- Specifying and examining files
internals -- Maintenance commands
obscure -- Obscure features
running -- Running the program
stack -- Examining the stack
status -- Status inquiries
support -- Support facilities
tracepoints -- Tracing of program execution without

stopping the program


user-defined -- User-defined commands

Type "help" followed by a class name for a list of


commands in that class.
Type "help" followed by command name for full
documentation.
Command name abbreviations are allowed if unambiguous.
(gdb)
help class Using one of the general help classes as an argument, you can get a list of the
individual commands in that class. For example, here is the help display for
the class status:
(gdb) help status
Status inquiries.

List of commands:
20 Debugging with GDB

info -- Generic command for showing things


about the program being debugged
show -- Generic command for showing things
about the debugger

Type "help" followed by command name for full


documentation.
Command name abbreviations are allowed if unambiguous.
(gdb)
help command
With a command name as help argument, GDB displays a short paragraph on
how to use that command.
apropos args
The apropos args command searches through all of the GDB commands, and
their documentation, for the regular expression specified in args. It prints out
all matches found. For example:
apropos reload
results in:
set symbol-reloading -- Set dynamic symbol table reloading
multiple times in one run
show symbol-reloading -- Show dynamic symbol table reloading
multiple times in one run
complete args
The complete args command lists all the possible completions for the beginning
of a command. Use args to specify the beginning of the command you want
completed. For example:
complete i
results in:
if
ignore
info
inspect
This is intended for use by gnu Emacs.
In addition to help, you can use the GDB commands info and show to inquire about the
state of your program, or the state of GDB itself. Each command supports many topics of
inquiry; this manual introduces each of them in the appropriate context. The listings under
info and under show in the Index point to all the sub-commands. See [Index], page 307.

info This command (abbreviated i) is for describing the state of your program. For
example, you can list the arguments given to your program with info args,
list the registers currently in use with info registers, or list the breakpoints
you have set with info breakpoints. You can get a complete list of the info
sub-commands with help info.
Chapter 3: GDB Commands 21

set You can assign the result of an expression to an environment variable with set.
For example, you can set the GDB prompt to a $-sign with set prompt $.
show In contrast to info, show is for describing the state of GDB itself. You can
change most of the things you can show, by using the related command set;
for example, you can control what number system is used for displays with set
radix, or simply inquire which is currently in use with show radix.
To display all the settable parameters and their current values, you can use
show with no arguments; you may also use info set. Both commands produce
the same display.
Here are three miscellaneous show subcommands, all of which are exceptional in lacking
corresponding set commands:

show version
Show what version of GDB is running. You should include this information in
GDB bug-reports. If multiple versions of GDB are in use at your site, you may
need to determine which version of GDB you are running; as GDB evolves, new
commands are introduced, and old ones may wither away. Also, many system
vendors ship variant versions of GDB, and there are variant versions of GDB
in gnu/Linux distributions as well. The version number is the same as the one
announced when you start GDB.
show copying
Display information about permission for copying GDB.
show warranty
Display the gnu “NO WARRANTY” statement, or a warranty, if your version
of GDB comes with one.
22 Debugging with GDB
Chapter 4: Running Programs Under GDB 23

4 Running Programs Under GDB


When you run a program under GDB, you must first generate debugging information
when you compile it.
You may start GDB with its arguments, if any, in an environment of your choice. If you
are doing native debugging, you may redirect your program’s input and output, debug an
already running process, or kill a child process.

4.1 Compiling for debugging


In order to debug a program effectively, you need to generate debugging information
when you compile it. This debugging information is stored in the object file; it describes
the data type of each variable or function and the correspondence between source line
numbers and addresses in the executable code.
To request debugging information, specify the ‘-g’ option when you run the compiler.
Many C compilers are unable to handle the ‘-g’ and ‘-O’ options together. Using those
compilers, you cannot generate optimized executables containing debugging information.
GCC, the gnu C compiler, supports ‘-g’ with or without ‘-O’, making it possible to
debug optimized code. We recommend that you always use ‘-g’ whenever you compile a
program. You may think your program is correct, but there is no sense in pushing your
luck.
When you debug a program compiled with ‘-g -O’, remember that the optimizer is
rearranging your code; the debugger shows you what is really there. Do not be too surprised
when the execution path does not exactly match your source file! An extreme example: if
you define a variable, but never use it, GDB never sees that variable—because the compiler
optimizes it out of existence.
Some things do not work as well with ‘-g -O’ as with just ‘-g’, particularly on machines
with instruction scheduling. If in doubt, recompile with ‘-g’ alone, and if this fixes the
problem, please report it to us as a bug (including a test case!).
Older versions of the gnu C compiler permitted a variant option ‘-gg’ for debugging
information. GDB no longer supports this format; if your gnu C compiler has this option,
do not use it.

4.2 Starting your program


run
r Use the run command to start your program under GDB. You must first spec-
ify the program name (except on VxWorks) with an argument to GDB (see
Chapter 2 [Getting In and Out of GDB], page 11), or by using the file or
exec-file command (see Section 14.1 [Commands to specify files], page 127).
If you are running your program in an execution environment that supports processes,
run creates an inferior process and makes that process run your program. (In environments
without processes, run jumps to the start of your program.)
The execution of a program is affected by certain information it receives from its superior.
GDB provides ways to specify this information, which you must do before starting your
24 Debugging with GDB

program. (You can change it after starting your program, but such changes only affect your
program the next time you start it.) This information may be divided into four categories:
The arguments.
Specify the arguments to give your program as the arguments of the run com-
mand. If a shell is available on your target, the shell is used to pass the argu-
ments, so that you may use normal conventions (such as wildcard expansion or
variable substitution) in describing the arguments. In Unix systems, you can
control which shell is used with the SHELL environment variable. See Section 4.3
[Your program’s arguments], page 24.
The environment.
Your program normally inherits its environment from GDB, but you can use the
GDB commands set environment and unset environment to change parts of
the environment that affect your program. See Section 4.4 [Your program’s
environment], page 25.
The working directory.
Your program inherits its working directory from GDB. You can set the GDB
working directory with the cd command in GDB. See Section 4.5 [Your pro-
gram’s working directory], page 26.
The standard input and output.
Your program normally uses the same device for standard input and standard
output as GDB is using. You can redirect input and output in the run command
line, or you can use the tty command to set a different device for your program.
See Section 4.6 [Your program’s input and output], page 26.
Warning: While input and output redirection work, you cannot use pipes to
pass the output of the program you are debugging to another program; if you
attempt this, GDB is likely to wind up debugging the wrong program.
When you issue the run command, your program begins to execute immediately. See
Chapter 5 [Stopping and continuing], page 33, for discussion of how to arrange for your
program to stop. Once your program has stopped, you may call functions in your program,
using the print or call commands. See Chapter 8 [Examining Data], page 63.
If the modification time of your symbol file has changed since the last time GDB read
its symbols, GDB discards its symbol table, and reads it again. When it does this, GDB
tries to retain your current breakpoints.

4.3 Your program’s arguments


The arguments to your program can be specified by the arguments of the run command.
They are passed to a shell, which expands wildcard characters and performs redirection of
I/O, and thence to your program. Your SHELL environment variable (if it exists) specifies
what shell GDB uses. If you do not define SHELL, GDB uses the default shell (‘/bin/sh’
on Unix).
On non-Unix systems, the program is usually invoked directly by GDB, which emulates
I/O redirection via the appropriate system calls, and the wildcard characters are expanded
by the startup code of the program, not by the shell.
Chapter 4: Running Programs Under GDB 25

run with no arguments uses the same arguments used by the previous run, or those set
by the set args command.

set args Specify the arguments to be used the next time your program is run. If set
args has no arguments, run executes your program with no arguments. Once
you have run your program with arguments, using set args before the next
run is the only way to run it again without arguments.
show args Show the arguments to give your program when it is started.

4.4 Your program’s environment


The environment consists of a set of environment variables and their values. Environment
variables conventionally record such things as your user name, your home directory, your
terminal type, and your search path for programs to run. Usually you set up environment
variables with the shell and they are inherited by all the other programs you run. When
debugging, it can be useful to try running your program with a modified environment
without having to start GDB over again.

path directory
Add directory to the front of the PATH environment variable (the search path
for executables) that will be passed to your program. The value of PATH used
by GDB does not change. You may specify several directory names, separated
by whitespace or by a system-dependent separator character (‘:’ on Unix, ‘;’
on MS-DOS and MS-Windows). If directory is already in the path, it is moved
to the front, so it is searched sooner.
You can use the string ‘$cwd’ to refer to whatever is the current working di-
rectory at the time GDB searches the path. If you use ‘.’ instead, it refers
to the directory where you executed the path command. GDB replaces ‘.’ in
the directory argument (with the current path) before adding directory to the
search path.
show paths
Display the list of search paths for executables (the PATH environment variable).
show environment [varname]
Print the value of environment variable varname to be given to your program
when it starts. If you do not supply varname, print the names and values of
all environment variables to be given to your program. You can abbreviate
environment as env.
set environment varname [=value]
Set environment variable varname to value. The value changes for your program
only, not for GDB itself. value may be any string; the values of environment
variables are just strings, and any interpretation is supplied by your program
itself. The value parameter is optional; if it is eliminated, the variable is set to
a null value.
For example, this command:
26 Debugging with GDB

set env USER = foo


tells the debugged program, when subsequently run, that its user is named
‘foo’. (The spaces around ‘=’ are used for clarity here; they are not actually
required.)
unset environment varname
Remove variable varname from the environment to be passed to your program.
This is different from ‘set env varname =’; unset environment removes the
variable from the environment, rather than assigning it an empty value.
Warning: On Unix systems, GDB runs your program using the shell indicated by your
SHELL environment variable if it exists (or /bin/sh if not). If your SHELL variable names a
shell that runs an initialization file—such as ‘.cshrc’ for C-shell, or ‘.bashrc’ for BASH—
any variables you set in that file affect your program. You may wish to move setting of
environment variables to files that are only run when you sign on, such as ‘.login’ or
‘.profile’.

4.5 Your program’s working directory


Each time you start your program with run, it inherits its working directory from the
current working directory of GDB. The GDB working directory is initially whatever it
inherited from its parent process (typically the shell), but you can specify a new working
directory in GDB with the cd command.
The GDB working directory also serves as a default for the commands that specify files
for GDB to operate on. See Section 14.1 [Commands to specify files], page 127.

cd directory
Set the GDB working directory to directory.
pwd Print the GDB working directory.

4.6 Your program’s input and output


By default, the program you run under GDB does input and output to the same terminal
that GDB uses. GDB switches the terminal to its own terminal modes to interact with you,
but it records the terminal modes your program was using and switches back to them when
you continue running your program.

info terminal
Displays information recorded by GDB about the terminal modes your program
is using.
You can redirect your program’s input and/or output using shell redirection with the
run command. For example,
run > outfile
starts your program, diverting its output to the file ‘outfile’.
Another way to specify where your program should do input and output is with the
tty command. This command accepts a file name as argument, and causes this file to be
Chapter 4: Running Programs Under GDB 27

the default for future run commands. It also resets the controlling terminal for the child
process, for future run commands. For example,
tty /dev/ttyb
directs that processes started with subsequent run commands default to do input and output
on the terminal ‘/dev/ttyb’ and have that as their controlling terminal.
An explicit redirection in run overrides the tty command’s effect on the input/output
device, but not its effect on the controlling terminal.
When you use the tty command or redirect input in the run command, only the input
for your program is affected. The input for GDB still comes from your terminal.

4.7 Debugging an already-running process


attach process-id
This command attaches to a running process—one that was started outside
GDB. (info files shows your active targets.) The command takes as argument
a process ID. The usual way to find out the process-id of a Unix process is with
the ps utility, or with the ‘jobs -l’ shell command.
attach does not repeat if you press hRETi a second time after executing the
command.
To use attach, your program must be running in an environment which supports pro-
cesses; for example, attach does not work for programs on bare-board targets that lack an
operating system. You must also have permission to send the process a signal.
When you use attach, the debugger finds the program running in the process first by
looking in the current working directory, then (if the program is not found) by using the
source file search path (see Section 7.3 [Specifying source directories], page 59). You can
also use the file command to load the program. See Section 14.1 [Commands to Specify
Files], page 127.
The first thing GDB does after arranging to debug the specified process is to stop it.
You can examine and modify an attached process with all the GDB commands that are
ordinarily available when you start processes with run. You can insert breakpoints; you
can step and continue; you can modify storage. If you would rather the process continue
running, you may use the continue command after attaching GDB to the process.

detach When you have finished debugging the attached process, you can use the detach
command to release it from GDB control. Detaching the process continues its
execution. After the detach command, that process and GDB become com-
pletely independent once more, and you are ready to attach another process
or start one with run. detach does not repeat if you press hRETi again after
executing the command.
If you exit GDB or use the run command while you have an attached process, you kill
that process. By default, GDB asks for confirmation if you try to do either of these things;
you can control whether or not you need to confirm by using the set confirm command
(see Section 18.6 [Optional warnings and messages], page 168).
28 Debugging with GDB

4.8 Killing the child process


kill Kill the child process in which your program is running under GDB.
This command is useful if you wish to debug a core dump instead of a running process.
GDB ignores any core dump file while your program is running.
On some operating systems, a program cannot be executed outside GDB while you have
breakpoints set on it inside GDB. You can use the kill command in this situation to permit
running your program outside the debugger.
The kill command is also useful if you wish to recompile and relink your program,
since on many systems it is impossible to modify an executable file while it is running in a
process. In this case, when you next type run, GDB notices that the file has changed, and
reads the symbol table again (while trying to preserve your current breakpoint settings).

4.9 Debugging programs with multiple threads


In some operating systems, such as HP-UX and Solaris, a single program may have more
than one thread of execution. The precise semantics of threads differ from one operating
system to another, but in general the threads of a single program are akin to multiple
processes—except that they share one address space (that is, they can all examine and
modify the same variables). On the other hand, each thread has its own registers and
execution stack, and perhaps private memory.
GDB provides these facilities for debugging multi-thread programs:
• automatic notification of new threads
• ‘thread threadno’, a command to switch among threads
• ‘info threads’, a command to inquire about existing threads
• ‘thread apply [threadno] [all] args’, a command to apply a command to a list of
threads
• thread-specific breakpoints
Warning: These facilities are not yet available on every GDB configuration
where the operating system supports threads. If your GDB does not support
threads, these commands have no effect. For example, a system without thread
support shows no output from ‘info threads’, and always rejects the thread
command, like this:
(gdb) info threads
(gdb) thread 1
Thread ID 1 not known. Use the "info threads" command to
see the IDs of currently known threads.
The GDB thread debugging facility allows you to observe all threads while your program
runs—but whenever GDB takes control, one thread in particular is always the focus of
debugging. This thread is called the current thread. Debugging commands show program
information from the perspective of the current thread.
Whenever GDB detects a new thread in your program, it displays the target system’s
identification for the thread with a message in the form ‘[New systag]’. systag is a thread
identifier whose form varies depending on the particular system. For example, on LynxOS,
you might see
Chapter 4: Running Programs Under GDB 29

[New process 35 thread 27]


when GDB notices a new thread. In contrast, on an SGI system, the systag is simply
something like ‘process 368’, with no further qualifier.
For debugging purposes, GDB associates its own thread number—always a single
integer—with each thread in your program.

info threads
Display a summary of all threads currently in your program. GDB displays for
each thread (in this order):
1. the thread number assigned by GDB
2. the target system’s thread identifier (systag)
3. the current stack frame summary for that thread
An asterisk ‘*’ to the left of the GDB thread number indicates the current
thread.
For example,
(gdb) info threads
3 process 35 thread 27 0x34e5 in sigpause ()
2 process 35 thread 23 0x34e5 in sigpause ()
* 1 process 35 thread 13 main (argc=1, argv=0x7ffffff8)
at threadtest.c:68
On HP-UX systems:
For debugging purposes, GDB associates its own thread number—a small integer as-
signed in thread-creation order—with each thread in your program.
Whenever GDB detects a new thread in your program, it displays both GDB’s thread
number and the target system’s identification for the thread with a message in the form
‘[New systag]’. systag is a thread identifier whose form varies depending on the particular
system. For example, on HP-UX, you see
[New thread 2 (system thread 26594)]
when GDB notices a new thread.

info threads
Display a summary of all threads currently in your program. GDB displays for
each thread (in this order):
1. the thread number assigned by GDB
2. the target system’s thread identifier (systag)
3. the current stack frame summary for that thread
An asterisk ‘*’ to the left of the GDB thread number indicates the current
thread.
For example,
(gdb) info threads
* 3 system thread 26607 worker (wptr=0x7b09c318 "@") \

at quicksort.c:137
30 Debugging with GDB

2 system thread 26606 0x7b0030d8 in __ksleep () \

from /usr/lib/libc.2
1 system thread 27905 0x7b003498 in _brk () \

from /usr/lib/libc.2

thread threadno
Make thread number threadno the current thread. The command argument
threadno is the internal GDB thread number, as shown in the first field of the
‘info threads’ display. GDB responds by displaying the system identifier of
the thread you selected, and its current stack frame summary:
(gdb) thread 2
[Switching to process 35 thread 23]
0x34e5 in sigpause ()
As with the ‘[New ...]’ message, the form of the text after ‘Switching to’
depends on your system’s conventions for identifying threads.
thread apply [threadno] [all] args
The thread apply command allows you to apply a command to one or more
threads. Specify the numbers of the threads that you want affected with the
command argument threadno. threadno is the internal GDB thread number,
as shown in the first field of the ‘info threads’ display. To apply a command
to all threads, use thread apply all args.

Whenever GDB stops your program, due to a breakpoint or a signal, it automatically


selects the thread where that breakpoint or signal happened. GDB alerts you to the context
switch with a message of the form ‘[Switching to systag]’ to identify the thread.
See Section 5.4 [Stopping and starting multi-thread programs], page 50, for more infor-
mation about how GDB behaves when you stop and start programs with multiple threads.
See Section 5.1.2 [Setting watchpoints], page 37, for information about watchpoints in
programs with multiple threads.

4.10 Debugging programs with multiple processes


On most systems, GDB has no special support for debugging programs which create
additional processes using the fork function. When a program forks, GDB will continue
to debug the parent process and the child process will run unimpeded. If you have set a
breakpoint in any code which the child then executes, the child will get a SIGTRAP signal
which (unless it catches the signal) will cause it to terminate.
However, if you want to debug the child process there is a workaround which isn’t too
painful. Put a call to sleep in the code which the child process executes after the fork. It
may be useful to sleep only if a certain environment variable is set, or a certain file exists,
so that the delay need not occur when you don’t want to run GDB on the child. While the
child is sleeping, use the ps program to get its process ID. Then tell GDB (a new invocation
of GDB if you are also debugging the parent process) to attach to the child process (see
Chapter 4: Running Programs Under GDB 31

Section 4.7 [Attach], page 27). From that point on you can debug the child process just like
any other process which you attached to.
On HP-UX (11.x and later only?), GDB provides support for debugging programs that
create additional processes using the fork or vfork function.
By default, when a program forks, GDB will continue to debug the parent process and
the child process will run unimpeded.
If you want to follow the child process instead of the parent process, use the command
set follow-fork-mode.

set follow-fork-mode mode


Set the debugger response to a program call of fork or vfork. A call to fork
or vfork creates a new process. The mode can be:
parent The original process is debugged after a fork. The child process
runs unimpeded. This is the default.
child The new process is debugged after a fork. The parent process runs
unimpeded.
ask The debugger will ask for one of the above choices.
show follow-fork-mode
Display the current debugger response to a fork or vfork call.
If you ask to debug a child process and a vfork is followed by an exec, GDB executes
the new target up to the first breakpoint in the new target. If you have a breakpoint set on
main in your original program, the breakpoint will also be set on the child process’s main.
When a child process is spawned by vfork, you cannot debug the child or parent until
an exec call completes.
If you issue a run command to GDB after an exec call executes, the new target restarts.
To restart the parent process, use the file command with the parent executable name as
its argument.
You can use the catch command to make GDB stop whenever a fork, vfork, or exec
call is made. See Section 5.1.3 [Setting catchpoints], page 39.
32 Debugging with GDB
Chapter 5: Stopping and Continuing 33

5 Stopping and Continuing


The principal purposes of using a debugger are so that you can stop your program before
it terminates; or so that, if your program runs into trouble, you can investigate and find
out why.
Inside GDB, your program may stop for any of several reasons, such as a signal, a
breakpoint, or reaching a new line after a GDB command such as step. You may then
examine and change variables, set new breakpoints or remove old ones, and then continue
execution. Usually, the messages shown by GDB provide ample explanation of the status
of your program—but you can also explicitly request this information at any time.

info program
Display information about the status of your program: whether it is running
or not, what process it is, and why it stopped.

5.1 Breakpoints, watchpoints, and catchpoints


A breakpoint makes your program stop whenever a certain point in the program is
reached. For each breakpoint, you can add conditions to control in finer detail whether
your program stops. You can set breakpoints with the break command and its variants
(see Section 5.1.1 [Setting breakpoints], page 34), to specify the place where your program
should stop by line number, function name or exact address in the program.
In HP-UX, SunOS 4.x, SVR4, and Alpha OSF/1 configurations, you can set breakpoints
in shared libraries before the executable is run. There is a minor limitation on HP-UX
systems: you must wait until the executable is run in order to set breakpoints in shared
library routines that are not called directly by the program (for example, routines that are
arguments in a pthread_create call).
A watchpoint is a special breakpoint that stops your program when the value of an
expression changes. You must use a different command to set watchpoints (see Section 5.1.2
[Setting watchpoints], page 37), but aside from that, you can manage a watchpoint like any
other breakpoint: you enable, disable, and delete both breakpoints and watchpoints using
the same commands.
You can arrange to have values from your program displayed automatically whenever
GDB stops at a breakpoint. See Section 8.6 [Automatic display], page 68.
A catchpoint is another special breakpoint that stops your program when a certain kind
of event occurs, such as the throwing of a C++ exception or the loading of a library. As with
watchpoints, you use a different command to set a catchpoint (see Section 5.1.3 [Setting
catchpoints], page 39), but aside from that, you can manage a catchpoint like any other
breakpoint. (To stop when your program receives a signal, use the handle command; see
Section 5.3 [Signals], page 48.)
GDB assigns a number to each breakpoint, watchpoint, or catchpoint when you create
it; these numbers are successive integers starting with one. In many of the commands for
controlling various features of breakpoints you use the breakpoint number to say which
breakpoint you want to change. Each breakpoint may be enabled or disabled; if disabled,
it has no effect on your program until you enable it again.
34 Debugging with GDB

Some GDB commands accept a range of breakpoints on which to operate. A breakpoint


range is either a single breakpoint number, like ‘5’, or two such numbers, in increasing
order, separated by a hyphen, like ‘5-7’. When a breakpoint range is given to a command,
all breakpoint in that range are operated on.

5.1.1 Setting breakpoints


Breakpoints are set with the break command (abbreviated b). The debugger conve-
nience variable ‘$bpnum’ records the number of the breakpoint you’ve set most recently;
see Section 8.9 [Convenience variables], page 76, for a discussion of what you can do with
convenience variables.
You have several ways to say where the breakpoint should go.
break function
Set a breakpoint at entry to function function. When using source languages
that permit overloading of symbols, such as C++, function may refer to more
than one possible place to break. See Section 5.1.8 [Breakpoint menus], page 44,
for a discussion of that situation.
break +offset
break -offset
Set a breakpoint some number of lines forward or back from the position at
which execution stopped in the currently selected stack frame. (See Section 6.1
[Frames], page 53, for a description of stack frames.)
break linenum
Set a breakpoint at line linenum in the current source file. The current source
file is the last file whose source text was printed. The breakpoint will stop your
program just before it executes any of the code on that line.
break filename:linenum
Set a breakpoint at line linenum in source file filename.
break filename:function
Set a breakpoint at entry to function function found in file filename. Specifying
a file name as well as a function name is superfluous except when multiple files
contain similarly named functions.
break *address
Set a breakpoint at address address. You can use this to set breakpoints in
parts of your program which do not have debugging information or source files.
break When called without any arguments, break sets a breakpoint at the next in-
struction to be executed in the selected stack frame (see Chapter 6 [Examining
the Stack], page 53). In any selected frame but the innermost, this makes your
program stop as soon as control returns to that frame. This is similar to the
effect of a finish command in the frame inside the selected frame—except that
finish does not leave an active breakpoint. If you use break without an argu-
ment in the innermost frame, GDB stops the next time it reaches the current
location; this may be useful inside loops.
Other documents randomly have
different content
The Project Gutenberg eBook of Love Potions
Through the Ages: A Study of Amatory Devices
and Mores
This ebook is for the use of anyone anywhere in the United
States and most other parts of the world at no cost and with
almost no restrictions whatsoever. You may copy it, give it away
or re-use it under the terms of the Project Gutenberg License
included with this ebook or online at www.gutenberg.org. If you
are not located in the United States, you will have to check the
laws of the country where you are located before using this
eBook.

Title: Love Potions Through the Ages: A Study of Amatory


Devices and Mores

Author: Harry E. Wedeck

Release date: October 30, 2020 [eBook #63577]


Most recently updated: October 18, 2024

Language: English

Credits: Produced by Richard Tonsing, Tim Lindell and the


Online
Distributed Proofreading Team at
https://www.pgdp.net (This
book was produced from images made available by the
HathiTrust Digital Library.)

*** START OF THE PROJECT GUTENBERG EBOOK LOVE POTIONS


THROUGH THE AGES: A STUDY OF AMATORY DEVICES AND MORES
***
Transcriber's Note:
The cover image was created by the transcriber
and is placed in the public domain.
LOVE POTIONS THROUGH THE AGES
A Study of Amatory Devices and Mores

HARRY E. WEDECK
Lecturer in Classics, Brooklyn College of the City University, N. Y.
Fellow, International Institute of Arts and Letters

THE CITADEL PRESS


NEW YORK
FIRST PAPERBOUND EDITION

Published by The Citadel Press


222 Park Avenue South, New York 3, N. Y.

© Copyright, 1963

by Philosophical Library, Inc.

Library of Congress Catalog Card No. 62–18549

All rights reserved.

Printed in the United States of America


CONTENTS
Introduction ix

I Antiquity 1

Erotic cults. Rites, Periapts. Phallic symbols. Ceremonials.


Concepts. Greece. Asia Minor. Egypt. Literary and historical
testimony. Erotic manifestations in various ethnic areas. Search for
amatory stimulants. Condemnation of pagan mores. Biblical
instances. Sacredness of genitalia. Herodotus on Egyptian cults.
Bacchic cult in European countries. Pervasiveness of phallus.
Phallic emblems. Biblical references. Incantations. Spells. Philtres.
Egyptian love song. Near East. Hittite ritual. Babylon. Canaanites.
Greece and Rome. Biblical ethics. Hellenistic Age. Baths. Phallic
food. Drillipotae. Yellow. Figurae Veneris. Erotic poems. Phallic
divinities. Philodemus of Gadara. Dress. Athens. Panders. Biblical—
phallic. Power of woman. Woman as an evil. Aphrodite. Love as an
end. Initiation. Rites of Venus. Essence of love. Mysticism. Priapic.
Asia Minor. Variant names. Generation. Talisman. Floral.

II Greek 67

Plato. Dioscorides. Nonnus. Theodora. Antonina. Belisarius.


Demosthenes. Concept of love.

III Romans 82

Testimony of the poets. Obscene deities. Amatory philtres.


Amatory foods. Bacchic worship. Ovid on erotic practices. Ovid on
philtres. Roman generative deities. Rites of Bona Dea. Generative
tutelary deities. Phallic breads. Magic love spells. Assignations.
Fescennini versus. Lamps. Larentalia. Heliogabalus. Nonaria. Nose
and lips. Ovid. Imperial Rome.

IV Orient 119

Hindu and Arab treatments and practices. Philtres. Other


provocative preparations. Islam. Sterility. Potions. Perfume. Arab
erotologist. Amatory principles.
V India 135

Erotic manuals. Amatory practices. Philtres. Other means of


stimulation. Temple prostitution. Search for husband.

VI Varieties and Occasions of Potions 155

Examples from Greek and Roman antiquity. Asia. Love cult.

VII Potency of Philtres 167

Literary testimony. Woman in the ascendant. Water. Inducements.

VIII Ingredients of Potions. Recipes. Anecdotes 174

Preparation of philtres. Illustrative legendary, historical, and


literary anecdotes, allusions, and citations confirming potency of
philtres. Divertive philtres. Medieval philtres. Macrobius. Herbs and
plants. The Mill. Amatory procedures. French stimulant. Papyri.
Lucian. River. Black Art potion. Inducements. Oriental. Flowers,
etc. Variety of ingredients.

IX Middle Ages and Later 231

Philtres. Dispensers of preparations. Occultists and alchemists


associated with preparations. Literary and historical references.
Manuals and other erotic texts. Priapus as a saint. Phallic Society.
Erotic mores in Europe. Clauder on philtres. Northern deities. Belts
of chastity. The Congress: and other medieval practices. Divertive
invocation. Privileges. Orgies. Boccaccio. Turkey. Loïstes.
Shakespeare. Villon. Sects. Figurines. Demoniac unions.
Astrological.

X Modern Times 316

Contemporary eroticism. Amatory customs. Potions. Publications.


Experimentation in erotic stimuli. Literary mention. Popular press.
Love spells and potions. Bayadère. Advertisements. Restaurants.
Erotica. Books. Hippomanes.

Selective Bibliography 335


INTRODUCTION

The amatory motif is pervasive, timeless, and universal. In some


of its phases and manifestations it has presented age-old
provocations and, not infrequently, problems that are still
unresolved.
Among such problems are involved the faculty of physiological
potency, the urge to attract amorously, and, conversely, the problem
of preventing such attraction in a designated instance, or of diverting
it to another objective.
That, in brief, is the essence of the material means of effecting
such a realization. In its various mutations, its protean diversities, it
is the love-potion, the philtre, the mystic concoction that, once
quaffed, will instil love and passion and desire and lust, that will
replenish erotic inadequacies, that will awaken the ancient fons
vitae, the symbol of animate being, the source, as the antique
Hellenes sensed and exemplified, of all cosmic creation, of the
totality of living generation.
The potion, then, is at least a hypothetically efficacious
instrument for securing and preserving the amorous interests of the
desired object. It also serves as an apotropaic device for diverting
misplaced love, as the agent sees it, and redirecting it to the proper
and preferred channel.
The actual means for the fulfilment of these erotic purposes
vary with the ages, with ethnic groups and demographic alignments,
with legendary and folk traditions and mores, with the disparate
levels of culture of a specific region. They present variations and
adaptations in correspondence with climatic and epichorial
conditions. But they retain the essentially common characteristic, the
unchanging property, of attempting to shape and mould the amatory
esurgences, in whatever degree, and whether transitory or of more
enduring permanence, by impersonal, palpable, mechanistic and
visual means.
It should be observed, as a terminus a quo, that the term
philtre itself stems from the Greek philtron, a love-potion (from
philein, to love, and tron, an instrumental suffix). It means, then, a
love-charm.
The term potion is derived immediately from the Latin potio, a
draught, whether of medicine or even of poison. The ultimate source
is the Greek potos, a drink. In a general sense, therefore, a love
philtre or potion is a concoction, usually liquid in form, but not
necessarily so, intended to produce or promote amatory sensibilities.
In a wide and comprehensive denotation, the philtre will include any
object or charm or periapt that serves the same erotic purpose.
This present survey touches on the use of the potion in the
course of the centuries, in varying circumstances and disparate
countries: on the fantastic factors that composed the final
preparations; and on anecdotes, both apocryphal and authenticated,
and episodes and occasional allusions that point up the treatment,
its hazards, and even its humors.
With regard to the potions and similar concoctions and
preparations of an amatory nature, a caveat must here be entered.
All such philtres are considered in this book from an exclusively
traditional, historical, and academic viewpoint. They are not
recommended in any instance for personal use, as they may involve
unpredictable or even catastrophic effects: in no sense, therefore,
should such prescriptions be utilized for empirical experimentation.
H.E.W.
LOVE POTIONS THROUGH THE AGES
CHAPTER I
ANTIQUITY

In ancient Greece, the climatic conditions, the long unending


summer days, the broad spaciousness of the sea, wine-dark and
loud-sounding, as Homer describes it, the secluded pools and
fountains and glades, the remote valleys, the snowy mountain
summits were all alive, to the Hellenic perceptive and imaginative
mind, with graceful nymphs and shaggy satyrs, with a multitude of
anthropomorphic divinities, and with the alluring pipes of Pan.
Under such conditions it was not difficult to conceive human life
as dominated by the cosmic creative force, and to do homage and
obeisance to the great god Dionysus, divinity of the fruitful wine,
protector of all procreative and generative functions.
The generative and sexual activities of the Greeks were, in
general, so freed from contrived restrictions, so much in harmony
with their instinctive and developed sensitivity to beauty of form, of
movement, of rhythm, that artificial aids and inducements to
amatory performance were far less necessary than they are in a
highly complex and competitive and in a sense exhausted
contemporary social frame.
Hence we do not constantly hear of the ad hoc use of philtres,
potions, and analogous means of stimulation. Yet their existence is
established, and in particular cases they were brought into effective
use. Xenocrates, a Greek physician of the first century A.D., as Pliny
the Elder records, advised drinking the sap of mallows as a love-
potion. Such a philtre, together with three mallow roots tied into a
bunch, would inflame the erotic passions of women.
Again, Dioscorides of Cilicia, in Asia Minor, an army physician
who flourished in the first century A.D., produced a Materia Medica
that treated drugs, remedies, ingredients in a rational, systematic
manner. His text became a standard work, used for centuries, in
both the East and the West. He recommends the roots of boy-
cabbage, soaked in fresh goat’s milk. A good draught of this drink
would be productive of intense excitation of the sexual impulse.
Many spices, plants, herbs that were described, either by the
encyclopedists and historians or incidentally mentioned in dramatic
literature, in occasional poems, anecdotes or in epitomes of legends
and folklore, were of such obscurity and rarity that it is no longer
possible to ascertain the corresponding modern equivalent. There
was, as an instance, satyrion. It is frequently mentioned, both in
Greek and Roman contexts. Actually unidentifiable botanically, it may
have been analogous to the orchis. In Greek and also Roman
antiquity it was reputed to constitute a potent aphrodisiac, and is
mentioned in an accepted and traditional sense by writers such as
Petronius, who casually alludes to it in the course of his Satyricon as
a common erotic aid.
The name satyrion is evidently associated with the Greek satyr,
a wood spirit, partly goat-like, and partly human. Attendants to the
rustic god Pan, the satyrs were known as bestial and lustful
creatures, symbolic of the basic sexual passion of man.
Botanically, satyrion is a plant with smooth leaves, red-tinted,
and equipped with a two-fold root. The lower part of this root was
credited anciently with promoting male conception, while the other
part was conducive to female conception. In its modern counterpart,
satyrion has been associated with the Iris florantina.
There is another variety of satyrion, called Serapias. This has
pear-shaped leaves and a tall elongated stem. Its root consists of
two tubers that have the appearance of testes. Unquestionably, the
association of the plant as an aphrodisiac derives from the
orchidaceous configuration of the root.
Remarkable properties were attributed to the root of satyrion.
When it was dissolved in goat’s milk, the erotic effect was so
vigorous and urgent that, as the Greek philosopher Theophrastus
asserts in his Enquiry into Plants, the potion produced, on a
particular occasion, some seventy consecutive coital performances.
Still another species of satyrion was erithraicon. This plant had a
peculiar virtue. The mere holding of it, or carrying it, in the hand,
occasioned a lustful desire. This fact is attested by Pliny, in his
Natural History, in Book 26, 96 and 98, as well as by Dioscorides in
his Materia Medica 3. 134. When the libido became too intense,
lettuce was eaten to mitigate the effect, to allay the erotic
provocation.
Greek mythology abounds in references to satyrion as an
efficacious stimulant. The prowess of Hercules, the lusty warrior, as
the Roman Petronius, Arbiter Elegantiarum, calls him, is attested in
an amatory sense by the story of his visit to a certain Thespius.
Entertained lavishly as a guest, Hercules, fortified by satyrion, repaid
the host’s entertainment by having intercourse with all fifty
daughters of Thespius.
In Roman times the effectiveness of the root in arousing erotic
excitation was common knowledge. Petronius, the voluptuary
attached to the court of the Emperor Nero and the author of the
remarkable picaresque novel entitled the Satyricon, alludes to the
matter. One of his characters, describing the frenzied activities in a
brothel, remarks:
We saw many persons of both sexes, at work in the cells, so
much every one of them seemed to have taken satyrion.
In a more general direction, important testimonies to
manipulative and mechanistic means of arousing vigor are the
references in Petronius, particularly the episode involving Quartilla:
Quartilla came up to me to cure me of the ague, but finding her self
disappointed, flew off in a rage, and returning in a little while, told us,
there were certain persons unknown, had a design upon us, and
therefore commanded to remove us into a noble palace.
Here all our courage fail’d us, and nothing but certain death seem’d
to appear before us.
When I began, “If, madam, you design to be more severe with us,
be yet so kind as to dispatch it quickly; for whate’er our offence be, it is
not so heinous that we ought to be rack’d to death for it”: Upon which
her woman, whose name was Psyche, spread a coverlet on the floor.
Sollicitavit inguina mea mille iam mortibus frigida. Ascyltos muffled his
head in his coat, as having had a hint given him, how dangerous it was
to take notice of what did not concern him: In the mean time Psyche
took off her garters, and with one of them bound my feet, and with the
other my hands.
Thus fetter’d as I lay, “This, madam,” said I, “is not the way to rid
you of your ague.”
“I grant it,” answer’d Psyche, “but I have a Dose at hand will
infallibly do it” and therefore brought me a lusty bowl of satyricon and so
merrily ran over the wonderful effects of it, that I had well-nigh suck’d it
all off; but because Ascyltos had slighted her courtship, she finding his
back toward her, threw the bottom of it on him.
Ascyltos perceiving the chat was at an end, “Am not I worthy,” said
he, “to get a sup?” And Psyche fearing my laughter might discover her,
clapped her hands, and told him, “Young man, I made you an offer of it,
but your friend here has drunk it all out.”
“Is it so,” quoth Quartilla, smiling very agreeably, “and has Encolpius
gugg’d it all down?” At last also even Gito laught for company, at what
time the young wench flung her arms about his neck, and meeting no
resistance, half smother’d him with kisses.
A peculiar situation in which erotic provocation or inducement to
passion is conditioned by the concept of social prestige, or, in the
contemporary idiom, status, is exemplified in a later passage in
Petronius’ Satyricon:
Going out full of these thoughts to divert my concern, I resolv’d on a
walk, but I had scarce got into a publick one, e’re a pretty girl made up
to me, and calling me Polyaemus, told me her lady wou’d be proud of an
opportunity to speak with me.
“You’re mistaken, sweet-heart,” return’d I, in a little heat, “I’m but a
servant, of another country too, and not worthy of so great a favor.”
“No, sir,” said she, “I have commands to you; but because you know
what you can do, you’re proud; and if a lady wou’d receive a favor from
you, I see she must buy it: For to what end are all those allurements,
forsooth? the curl’d hair, the complexion advanc’d by a wash, and the
wanton roll of your eyes, the study’d air of your gate? unless by shewing
your parts, to invite a purchaser? For my part I am neither a witch, nor a
conjurer, yet can guess at a man by his physiognomy. And when I find a
spark walking, I know his contemplation. To be short, sir, if so be you are
one of them that sell their ware, I’ll procure you a merchant; but if you’re
a courteous lender, confer the benefit. As for your being a servant, and
below, as you say, such a favor, it increases the flames of her that’s dying
for you. ’Tis the wild extravagance of some women to be in love with
filth, nor can be rais’d to an appetite but by the charms, forsooth of some
slave or lacquy; some can be pleased with nothing but the strutting of a
prize-fighter with a hacktface, and a red ribbon in his shirt: Or an actor
betray’d to prostitute himself on th’ stage, by the vanity of showing his
pretty shapes there; of this sort is my lady; who indeed,” added she,
“prefers the paultry lover of the upper gallery, with his dirty face, and
oaken staff, to all the fine gentlemen of the boxes, with their patches,
gunpowder-spots, and toothpickers.”
When pleas’d with the humor of her talk, “I beseech you, child,” said
I, “are you the she that’s so in love with my person?” Upon which the
maid fell into a fit of laughing.
“I wou’d not,” return’d she, “have you so extremely flatter yourself. I
never yet truckl’d to a waiter, nor will Venus allow I shou’d imbrace a
gibbet. You must address your self to ladies that kiss the ensigns of
slavery; be assur’d that I, though a servant, have too fine a taste to
converse with any below a knight.” I was amaz’d at the relation of such
unequal passions, and thought it miraculous to find a servant, with the
scornful pride of a lady, and a lady with the humility of a servant.
A still more elaborate scene concerns the techniques of
recovering the faculty of erotic consummation. Encolpius, the
narrator of the Satyricon, is attached homosexually to the young
Gito. He is in a state of incapacity. At this juncture he receives a note
from Circe, the mistress of the maid Chrysis, commenting on his
inadequacy:
Chrysis enter’d my chamber, and gave me a billet from her mistress,
in which I found this written:
“Had I rais’d my expectation, I might deceiv’d complain; now I’m
obliged to your impotence, that has made me sensible how much too
long I have trifl’d with mistaken hopes of pleasure. Tell me, sir, how you
design to bestow your self, and whether you dare rashly venture home
on your own legs? for no physician ever allow’d it cou’d be done without
strength. Let me advise your tender years to beware of a palsie: I never
saw any body in such danger before. On my conscience you are just
going! and shou’d the same rude chilliness seize your other parts, I might
be soon, alas! put upon the severe trial of weeping at your funeral. But if
you would not suspect me of not being sincere, tho’ my resentment can’t
equal the injury, yet I shall not envy the cure of a weak unhappy wretch.
If you wou’d recover your strength, ask Gito, or rather not ask him for’t—
I can assure a return of your vigor if you cou’d sleep three nights alone:
As to myself I am not in the least apprehensive of appearing to another
less charming than I have to you. I am told neither my glass nor report
does flatter me. Farewell, if you can.”
When Chrysis found I had read the reproach, “This is the
custom, sir,” said she, “and chiefly of this city, where the women are
skill’d in magick-charms, enough to make the moon confess their
power, therefore the recovery of any useful instrument of love
becomes their care; ’tis only writing some soft tender things to my
lady, and you make her happy in a kind return. For ’tis confest, since
her disappointment, she has not been her self.”
I readily consented, and calling for paper, thus addrest myself:
“’Tis confest, madam, I have often sinned, for I’m not only a man,
but a very young one, yet never left the field so dishonorably before. You
have at your feet a confessing criminal, that deserves whatever you
inflict: I have cut a throat, betray’d my country, committed sacrilege; if a
punishment for any of these will serve, I am ready to receive sentence. If
you fancy my death, I wait you with my sword; but if a beating will
content you, I fly naked to your arms. Only remember, that ’twas not the
workman, but his instruments that fail’d: I was ready to engage, but
wanted arms. Who rob’d me of them I know not; perhaps my eager mind
outrun my body; or while with an unhappy haste I aim’d at all; I was
cheated with abortive joys. I only know I don’t know what I’ve done: You
bid me fear a palsie, as if the disease you’d do greater that has already
rob’d me of that, by which I shou’d have purchas’d you. All I have to say
for my self, is this, that I will certainly pay with interest the arrears of
love, if you allow me time to repair my misfortune.”
Having sent back Chrysis with this answer, to encourage my
jaded body, after the bath and strengthening oyles had a little rais’d
me, I apply’d my self to strong meats, such as strong broths and
eggs, using wine very moderately; upon which to settle my self, I
took a little walk, and returning to my chamber, slept that night
without Gito; so great was my care to acquit my self honorably with
my mistress, that I was afraid he might have tempted my constancy,
by tickling my side.
The next day rising without prejudice, either to my body or
spirits, I went, tho’ I fear’d the place was ominous, to the same
walk, and expected Chrysis to conduct me to her mistress; I had not
been long there, e’re she came to me, and with her a little old
woman. After she had saluted me, “What, my nice Sir Courtly,” said
she, “does your stomach begin to come to you?”
At what time, the old woman, drawing from her bosom, a
wreath of many colors, bound my neck; and having mixed spittle
and dust, she dipt her finger in’t, and markt my forehead, whether I
wou’d or not.
When this part of the charm was over, she made me spit thrice,
and as often prest to my bosom enchanted stones, that she had
wrapt in purple; Admotisque manibus temptare coepit inguinum
vives. Dicto citius nervi paruerunt imperio manusque aniculae ingenti
motu repleverunt. At ilia gaudio exsultans, “Vides,” inquit, “Chrysis
mea, vides quod aliis leporem excitavi?”
Never despair; Priapus I invoke
To help the parts that make his altars smoke.

After this, the old woman presented me to Chrysis; who was


very glad she had recover’d her mistress’s treasure; and therefore
hastening to her, she conducted me to a most pleasant retreat,
deckt with all that nature cou’d produce to please the sight.
Where lofty plains o’re-spread a summer shade,
And well-trimm’d pines their shaking tops display’d,
Where Daphne ’midst the Cyprus crown’d her head.
Near these, a circling river gently flows,
And rolls the pebbles as it murmuring goes.
A place design’d for love, the nightingale
And other wing’d inhabitants can tell.
That on each bush salute the coming day,
And in their orgies sing its hours away.
She was in an undress, reclining on a flowry bank, and diverting
her self with a myrtle branch; as soon as I appear’d, she blusht, as
mindful of her disappointment: Chrysis, very prudently withdrew,
and when we were left together, I approacht the temptation; at what
time she skreen’d my face with the myrtle, and as if there had been
a wall between us, becoming more bold; “what, my chill’d spark,”
began she, “have you brought all your self today?”
“Do you ask, madam,” I return’d, “rather than try?” And
throwing myself to her, that with open arms was eager to receive
me, we last a little age away; when giving the signal to prepare for
other joys, she drew me to a more close imbrace; and now, our
murmuring kisses their sweet fury tell; now, our twining limbs, try’d
each fold of love; now, lockt in each others arms, our bodies and our
souls are join’d; but even here, alas! even amidst these sweet
beginnings, a sudden chilliness prest upon my joys, and made me
leave ’em not compleat.
Circe, enrag’d to be so affronted, had recourse to revenge, and
calling the grooms that belong’d to the house, made them give me a
warming; nor was she satisfi’d with this, but calling all the servant-
wenches, and meanest of the house, she made ’em spit upon me. I
hid my head as well as I cou’d, and, without begging pardon, for I
knew what I had deserv’d, am turn’d out of doors, with a large
retinue of kicks and spittle: Proselenos, the old woman was turn’d
out too, and Chrysis beaten; and the whole family wondering with
themselves, enquir’d the cause of their lady’s disorder.
I hid my bruises as well as I cou’d, lest my rival Eumolpus might
sport with my shame, or Gito be concern’d at it; therefore as the
only way to disguise my misfortune, I began to dissemble sickness,
and having got in bed, to revenge my self of that part of me, that
had been the cause of all my misfortunes; when taking hold of it,
With dreadful steel, the part I wou’d have lopt,
Thrice from my trembling hand the razor dropt.
Now, what I might before, I could not do,
For cold as ice the fearful thing withdrew;
And shrunk behind a wrinkled canopy,
Hiding his head from my revenge and me.
Thus, by his fear, I’m baulkt of my design,
When I in words more killing vent my spleen.

At what time, raising myself on the bed, in this or like manner, I


reproacht the sullen impotent: With what face can you look up, thou
shame of heaven and man? that can’st not be seriously mention’d.
Have I deserv’d from you, when rais’d within sight of heavens of
joys, to be struck down to the lowest hell? To have a scandal fixt on
the very prime and vigor of my years, and to be reduc’d to the
weakness of an old man? I beseech you, sir, give me an epitaph on
my departed vigor; tho’ in a great heat I had thus said:
He still continu’d looking on the ground,
Nor more, at this had rais’d his guilty head
Than th’ drooping poppy on its tender stalk.

Nor when I had done, did I less repent of my ridiculous passion,


and with a conscious blush, began to think, how unaccountable it
was, that forgetting all shame, I shou’d contend with that part of
me, that all men of sense, reckon not worth their thoughts. A little
after, relapsing to my former humor: But what’s the crime, began I,
if by a natural complaint I was eas’d of my grief? or how is it, that
we blame our stomachs or bellies, when ’tis our heads, that are
distemper’d? Did not Ulysses beat his breast, as if that had disturb’d
him? And don’t we see the actors punish their eyes, as if they heard
the tragic scene? Those that have the gout in their legs, swear at
them; Those that have it in their fingers, do so by them: Those that
have sore eyes, are angry with their eyes.
Why do the strickt-liv’d Cato’s of the age,
At my familiar lines so gravely rage?
In measures loosely plain, blunt satyr flows,
And all the people so sincerely shows.
For whose a stranger to the joys of love?
Who, can’t the thoughts of such lost pleasures move?
Such Epicurus own’d the chiefest bliss,
And such fives the gods themselves possess.

There’s nothing more deceitful than a ridiculous opinion, nor


more ridiculous, than an affected gravity. After this, I call’d Gito to
me; and “tell me,” said I, “but sincerely, whether Ascyltos, when he
took you from me, pursu’d the injury that night, or was chastly
content to lye alone?” The boy with his finger at his eyes, took a
solemn oath, that he had no incivility offer’d him by Ascyltos.
This drove me to my wits end, nor did I well know what to say:
For why, I consider’d, shou’d I think of the twice mischievous
accident that lately befell me? At last, I did what I cou’d to recover
my vigor: and willing to invoke the assistance of the gods, I went
out to pay my devotions to Priapus, and as wretched as I was, did
not despair, but kneeling at the entry of the chamber, thus beseecht
the god:
Bacchus and Nymphs delight, O mighty God!
Whom Cynthia gave to rule the blooming wood.
Lesbos and verdant Thasos thee adore,
And Lydians, in loose flowing dress implore,
And raise devoted temples to thy power.
Thou Dryad’s joy, and Bacchus’s guardian, hear
My conscious prayer, with an attentive ear.
My hands with guiltless blood I never stain’d,
Or sacrilegiously the gods prophan’d.
To feeble me, restoring blessings send,
I did not thee, with my whole self offend.
Who sins thro’ weakness is less guilty thought,
Be pacify’d, and spare a venial fault.
On me, when smiling fate shall smiling gifts bestow,
I’ll not ungrateful to thy godhead go.
A destined goat shall on thy altar lye,
And the horn’d parent of my flock shall dye.
A sucking pig appease thy injur’d shrine,
And hallow’d bowls o’re-flow with generous wine.
Then thrice thy frantick votaries shall round
Thy temple dance, with youth and garlands crown’d,
In holy drunkenness thy orgies sound.

While I was thus at prayers, an old woman, with her hair about
her eyes, and disfigur’d with a mournful habit, coming in, disturb’d
my devotions; when taking hold of me, she drew all fear out of the
entry; and “what hag,” said she, “has devour’d your manhood? Or
what ominous carcase have you stumbl’d over in your nightly walks?
You have not acquitted your self above a boy; but faint, weak, and
like a horse o’re-charg’d in a steep, tyr’d have lost your toyl and
sweat; nor content to sin alone, but have unreveng’d against me,
provokt the offended gods?”
When leading me, obedient to all her commands, a second time
to the cell of a neighboring priestess of Priapus, she threw me upon
the bed, and taking up a stick that fastened the door, reveng’d her
self on me, that very patiently receiv’d her fury: and at the first
stroak, if the breaking of the stick had not lessened its force, she
might have broke my head and arm.
I groan’d, and hiding with my arm my head, in a flood of tears
lean’d on the pillow: Nor did she then, less troubled, sit on the bed,
and began in a shrill voice, to blame her age, till the priestess came
in upon us; and “what,” said she, “do you do in my chappel, as if
some funeral had lately been, rather than a holy-day, in which, even
the mournful are merry?”
“Alas, my Enothea!” said she, “this youth was born under an ill
star; for neither boy nor maid can raise him to a perfect appetite;
you ne’re beheld a more unhappy man: In his garden the weak
willow, not the lusty cedar grows; in short, you may guess what he
is, that cou’d rise unblest from Circe’s bed.”
Upon this, Enothea fixt her self between us, and moving her
head a while; “I,” said she, “am the only one that can give remedy
for that disease; and not to delay it, let him sleep with me to-night;
and next morning, examine how vigorous I shall have made him:
“All Nature’s work my magick powers obey,
The blooming earth shall wither and decay,
And when I please, agen be fresh and gay.
From rugged rocks, I make sweet waters flow,
And raging billows to me humbly bow.
With rivers, winds, when I command, obey,
And at my feet, their fans contracted lay,
Tygers and dragons too, my will obey,
But these are small, when of my magick verse,
Descending Cynthia does the power confess.
When my commands, make trembling Phoebus reign,
His fiery steeds, their journey back again.
Such power have charms, by whose prevailing aid
The fury of the raging bulls was laid.
The Heaven-born Circe, with her magic song,
Ulysses’s men, did unto monsters turn.
Proteus, with this assum’d, what shape he wou’d.
I, who this art so long have understood,
Can send proud Ida’s top into the main,
And make the billows bear it up again.”

I shook with fear at such a romantick promise, and began more


intensively to view the old woman; Upon which, she cry’d out, “O
Enothea, be as good as your word”; when, carefully wiping her
hands, she lay down on the bed, and half smother’d me with kisses.
Enothea, in the middle of the altar, plac’d a turf-table, which she
heapt with burning coals, and her old crack cup (for sacrifice)
repair’d with temper’d pitch; when she had fixt it to the smoaking-
wall from which she took it; putting on her habit, she plac’d a kettle
by the fire, and took down a bag that hung near her, in which, a
bean was kept for that use, and a very aged piece of a hog’s
forehead, with the print of a hundred cuts out; when opening the
bag, she threw me a part of the bean, and bid me carefully strip it. I
obey her command, and try, without daubing my fingers, to deliver
the grain from its nasty coverings; but she, blaming my dullness,
snatcht it from me, and skilfully tearing its shells with her teeth, spit
the black morsels from her, that lay like dead flies on the ground.
How ingenious is poverty, and what strange arts will hunger teach?
The priestess seemed so great a lover of this sort of life, that her
humor appear’d in every thing about her, and her hut might be truly
term’d, sacred to poverty:
Here shines no glittering ivory set with gold,
No marble covers the deluded mold,
By its own wealth deluded; but the shrine
With simple natural ornaments does shine.
Round Cere’s bower, but homely willows grow.
Earthen are all the sacred bowls they know.
Osier the dish, sacred to use divine:
Both course and stain’d, the jug that holds the wine.
Mud mixt with straw, make a defending fort,
The temple’s brazen studs, are knobs of dirt.
With rush and reed, is thatcht the hut it self,
Where, besides what is on a smoaky shelf,
Ripe service-berries into garlands bound,
And savory-bunches with dry’d grapes are found.
Such a low cottage Hecale confin’d,
Low was her cottage, but sublime her mind.
Her bounteous heart, a grateful praise shall crown,
And muses make immortal her renown.
After which, she tasted of the flesh, and hanging the rest, old as
her self, on the hook again; the rotten stool on which she was
mounted breaking, threw her into the fire, her fall spilt the kettle,
and what it held put out the fire; she burnt her elbow, and all her
face was hid with the ashes that her fall had rais’d.
Thus disturb’d, I arose, and laughing, took her up; immediately,
lest any thing shou’d hinder the offering, she ran for new fire to the
neighborhood, and had hardly got to the door, e’re I was set upon
by three sacred geese, that daily, I believe, about that time were fed
by the old woman; they made an hideous noise, and, surrounding
me, one tears my coat, another my shoes, while their furious captain
made nothing of doing so by my legs; till seeing my self in danger, I
began to be in earnest, and snatching up one of the feet of our little
table, made the valiant animal feel my arm’d hand; nor content with
a slight blow or two, but reveng’d my self with its death:
Such were the birds Alcides did subdue,
That from his conquering arm t’ward Heaven flew:
Such sure the harpyes were which poyson strow’d,
On cheated Phineus’s false deluding food.
Loud lamentations shake the trembling air,
The powers above the wild confusion share,
Horrors disturb the orders of the sky,
And frighted stars beyond their courses fly.

By this time the other two had eat up the pieces of the bean
that lay scatter’d on the floor, and having lost their leader, return’d to
the temple. When glad of the booty and my revenge, I heal’d the
slight old woman’s anger, I design’d to make off; and taking up my
cloaths, began my march; nor had I reach’d the door, e’re I saw
Enothea bringing in her hand an earthen pot fill’d with fire; upon
which I retreated, and throwing down my cloaths, fixt my self in the
entry, as if I were impatiently expecting her coming.
Enothea, entring, plac’d the fire, that with broken sticks she had
got together, and having heapt more wood upon those, began to
excuse her stay, that her friend wou’d not let her go before she had,
against the laws of drinking, taken off three healths together. When
looking about her, “What,” said she, “have you been doing in my
absence? Where’s the bean?”
I, who thought I had behav’d my self very honorably, told her
the whole fight; and to end her grief for the loss of her bean,
presented the goose: when I shew’d the goose, the old woman set
up such an outcry, that you wou’d have thought the geese were re-
entering the place.
In confusion and amaz’d at so strange a humor, I askt the
meaning of her passion? or why she pity’d the goose rather than
me.
But wringing her hands, “you wicked wretch,” said she, “d’ye
speak too? D’ye know what you’ve done? You’ve killed the gods
delight, a goose the pleasure of all matrons: And, lest you shou’d
think your self innocent, if a magistrate shou’d hear of it, you’d be
hang’d. You have defil’d with blood my cell, that to this day had
been inviolate. You have done that, for which, if any’s so malicious,
he may expel me my office.”
She said, and trembling, rends her aged hairs,
And both her cheeks with wilder fury tears:
Sad murmurs from her troubl’d breast arise,
A shower of tears there issu’d from her eyes.
And down her face a rapid deluge run,
Such as is seen, when a hills frosty crown,
By warm Favonius is melted down.

Upon which, “I beseech you,” said I, “don’t grieve, I’ll


recompence the loss of your goose with an ostrich.”
While amaz’d I spoke, she sat down on the bed, lamented her
loss; at what time Proselenos came in with the sacrifice, and viewing
the murder’d goose, and enquiring the cause, began very earnestly
to cry and pity me, as it had been a father, not a goose I had slain.
But tired with this stuff, “I beseech you,” said I, “tell me, tho’ it had
been a man I kill’d, won’t gold wipe off the guilt? See here are two
pieces of gold: with these you may purchase gods as well as geese.”
Which, when Enothea beheld, “Pardon me, young man,” said
she, “I am only concern’d for your safety, which is an argument of
love, not hatred; therefore we’ll take what care we can to prevent a
discovery: You have nothing to do, but intreat the gods to forgive
the sin.”
Who e’re has money may securely sail,
On all things with all-mighty gold prevail.
May Danae wed, or rival amo’rous Jove,
And make her father pandar to his love.
May be a poet, preacher, lawyer, too:
And bawling win the cause he does not know:
And up to Cato’s fame for wisdom grow.
Wealth without law will gain at bar renown,
How e’re the case appears, the cause is won,
Every rich lawyer is a Littleton.
In short of all you wish you are possest,
All things prevent the wealthy mans’ request,
For Jove himself’s the treasure of his chest.

While my thoughts were thus engag’d, she plac’d a cup of wine


under my hands, and having cleans’d my prophane extended fingers
with sacred leeks and parsley, threw into the wine, with some
ejaculations, hazel-nuts, and as they sunk or swam gave her
judgment; but I well knew the empty rotten ones wou’d swim, and
those of entire kernels go to the bottom.
When applying herself to the goose, from its breast she drew a
lusty liver, and then told me my future fortune. But that no mark of
the murder might be left, she fixt the rent goose to a spit, which, as
she said, she had fatten’d a little before, as sensible it was to die.
In the mean time the wine went briskly round, and now the old
women gladly devour the goose, they so lately lamented; when they
had pickt its bones, Enothea, half drunk, turn’d to me; “and now,”
said she, “I’ll finish the charm that recovers your strength”: When
drawing out a leathern ensign of Priapus, she dipt it in a medley of
oyl, small pepper, and the bruis’d seed of nettles, paulatim coepit
inserere ano meo. Hoc crudelissima anus spurgit subinde umore
femina mea. Nasturcii sucum cum abrotano miscet perfusisque
Welcome to Our Bookstore - The Ultimate Destination for Book Lovers
Are you passionate about books and eager to explore new worlds of
knowledge? At our website, we offer a vast collection of books that
cater to every interest and age group. From classic literature to
specialized publications, self-help books, and children’s stories, we
have it all! Each book is a gateway to new adventures, helping you
expand your knowledge and nourish your soul
Experience Convenient and Enjoyable Book Shopping Our website is more
than just an online bookstore—it’s a bridge connecting readers to the
timeless values of culture and wisdom. With a sleek and user-friendly
interface and a smart search system, you can find your favorite books
quickly and easily. Enjoy special promotions, fast home delivery, and
a seamless shopping experience that saves you time and enhances your
love for reading.
Let us accompany you on the journey of exploring knowledge and
personal growth!

ebookgate.com

You might also like