This is gdb.info, produced by makeinfo version 4.13 from ./gdb.texinfo.
|
This is gdb.info, produced by makeinfo version 4.13 from ./gdb.texinfo.
|
|
|
INFO-DIR-SECTION Software development
|
INFO-DIR-SECTION Software development
|
START-INFO-DIR-ENTRY
|
START-INFO-DIR-ENTRY
|
* Gdb: (gdb). The GNU debugger.
|
* Gdb: (gdb). The GNU debugger.
|
END-INFO-DIR-ENTRY
|
END-INFO-DIR-ENTRY
|
|
|
Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996,
|
Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996,
|
1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
|
1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
|
2010 Free Software Foundation, Inc.
|
2010 Free Software Foundation, Inc.
|
|
|
Permission is granted to copy, distribute and/or modify this document
|
Permission is granted to copy, distribute and/or modify this document
|
under the terms of the GNU Free Documentation License, Version 1.3 or
|
under the terms of the GNU Free Documentation License, Version 1.3 or
|
any later version published by the Free Software Foundation; with the
|
any later version published by the Free Software Foundation; with the
|
Invariant Sections being "Free Software" and "Free Software Needs Free
|
Invariant Sections being "Free Software" and "Free Software Needs Free
|
Documentation", with the Front-Cover Texts being "A GNU Manual," and
|
Documentation", with the Front-Cover Texts being "A GNU Manual," and
|
with the Back-Cover Texts as in (a) below.
|
with the Back-Cover Texts as in (a) below.
|
|
|
(a) The FSF's Back-Cover Text is: "You are free to copy and modify
|
(a) The FSF's Back-Cover Text is: "You are free to copy and modify
|
this GNU Manual. Buying copies from GNU Press supports the FSF in
|
this GNU Manual. Buying copies from GNU Press supports the FSF in
|
developing GNU and promoting software freedom."
|
developing GNU and promoting software freedom."
|
|
|
This file documents the GNU debugger GDB.
|
This file documents the GNU debugger GDB.
|
|
|
This is the Ninth Edition, of `Debugging with GDB: the GNU
|
This is the Ninth Edition, of `Debugging with GDB: the GNU
|
Source-Level Debugger' for GDB (GDB) Version 7.2-or32-1.0rc1.
|
Source-Level Debugger' for GDB (GDB) Version 7.2-or32-1.0rc3.
|
|
|
Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996,
|
Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996,
|
1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
|
1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
|
2010 Free Software Foundation, Inc.
|
2010 Free Software Foundation, Inc.
|
|
|
Permission is granted to copy, distribute and/or modify this document
|
Permission is granted to copy, distribute and/or modify this document
|
under the terms of the GNU Free Documentation License, Version 1.3 or
|
under the terms of the GNU Free Documentation License, Version 1.3 or
|
any later version published by the Free Software Foundation; with the
|
any later version published by the Free Software Foundation; with the
|
Invariant Sections being "Free Software" and "Free Software Needs Free
|
Invariant Sections being "Free Software" and "Free Software Needs Free
|
Documentation", with the Front-Cover Texts being "A GNU Manual," and
|
Documentation", with the Front-Cover Texts being "A GNU Manual," and
|
with the Back-Cover Texts as in (a) below.
|
with the Back-Cover Texts as in (a) below.
|
|
|
(a) The FSF's Back-Cover Text is: "You are free to copy and modify
|
(a) The FSF's Back-Cover Text is: "You are free to copy and modify
|
this GNU Manual. Buying copies from GNU Press supports the FSF in
|
this GNU Manual. Buying copies from GNU Press supports the FSF in
|
developing GNU and promoting software freedom."
|
developing GNU and promoting software freedom."
|
|
|
|
|
File: gdb.info, Node: Registers, Next: Floating Point Hardware, Prev: Convenience Vars, Up: Data
|
File: gdb.info, Node: Registers, Next: Floating Point Hardware, Prev: Convenience Vars, Up: Data
|
|
|
10.12 Registers
|
10.12 Registers
|
===============
|
===============
|
|
|
You can refer to machine register contents, in expressions, as variables
|
You can refer to machine register contents, in expressions, as variables
|
with names starting with `$'. The names of registers are different for
|
with names starting with `$'. The names of registers are different for
|
each machine; use `info registers' to see the names used on your
|
each machine; use `info registers' to see the names used on your
|
machine.
|
machine.
|
|
|
`info registers'
|
`info registers'
|
Print the names and values of all registers except floating-point
|
Print the names and values of all registers except floating-point
|
and vector registers (in the selected stack frame).
|
and vector registers (in the selected stack frame).
|
|
|
`info all-registers'
|
`info all-registers'
|
Print the names and values of all registers, including
|
Print the names and values of all registers, including
|
floating-point and vector registers (in the selected stack frame).
|
floating-point and vector registers (in the selected stack frame).
|
|
|
`info registers REGNAME ...'
|
`info registers REGNAME ...'
|
Print the "relativized" value of each specified register REGNAME.
|
Print the "relativized" value of each specified register REGNAME.
|
As discussed in detail below, register values are normally
|
As discussed in detail below, register values are normally
|
relative to the selected stack frame. REGNAME may be any register
|
relative to the selected stack frame. REGNAME may be any register
|
name valid on the machine you are using, with or without the
|
name valid on the machine you are using, with or without the
|
initial `$'.
|
initial `$'.
|
|
|
GDB has four "standard" register names that are available (in
|
GDB has four "standard" register names that are available (in
|
expressions) on most machines--whenever they do not conflict with an
|
expressions) on most machines--whenever they do not conflict with an
|
architecture's canonical mnemonics for registers. The register names
|
architecture's canonical mnemonics for registers. The register names
|
`$pc' and `$sp' are used for the program counter register and the stack
|
`$pc' and `$sp' are used for the program counter register and the stack
|
pointer. `$fp' is used for a register that contains a pointer to the
|
pointer. `$fp' is used for a register that contains a pointer to the
|
current stack frame, and `$ps' is used for a register that contains the
|
current stack frame, and `$ps' is used for a register that contains the
|
processor status. For example, you could print the program counter in
|
processor status. For example, you could print the program counter in
|
hex with
|
hex with
|
|
|
p/x $pc
|
p/x $pc
|
|
|
or print the instruction to be executed next with
|
or print the instruction to be executed next with
|
|
|
x/i $pc
|
x/i $pc
|
|
|
or add four to the stack pointer(1) with
|
or add four to the stack pointer(1) with
|
|
|
set $sp += 4
|
set $sp += 4
|
|
|
Whenever possible, these four standard register names are available
|
Whenever possible, these four standard register names are available
|
on your machine even though the machine has different canonical
|
on your machine even though the machine has different canonical
|
mnemonics, so long as there is no conflict. The `info registers'
|
mnemonics, so long as there is no conflict. The `info registers'
|
command shows the canonical names. For example, on the SPARC, `info
|
command shows the canonical names. For example, on the SPARC, `info
|
registers' displays the processor status register as `$psr' but you can
|
registers' displays the processor status register as `$psr' but you can
|
also refer to it as `$ps'; and on x86-based machines `$ps' is an alias
|
also refer to it as `$ps'; and on x86-based machines `$ps' is an alias
|
for the EFLAGS register.
|
for the EFLAGS register.
|
|
|
GDB always considers the contents of an ordinary register as an
|
GDB always considers the contents of an ordinary register as an
|
integer when the register is examined in this way. Some machines have
|
integer when the register is examined in this way. Some machines have
|
special registers which can hold nothing but floating point; these
|
special registers which can hold nothing but floating point; these
|
registers are considered to have floating point values. There is no way
|
registers are considered to have floating point values. There is no way
|
to refer to the contents of an ordinary register as floating point value
|
to refer to the contents of an ordinary register as floating point value
|
(although you can _print_ it as a floating point value with `print/f
|
(although you can _print_ it as a floating point value with `print/f
|
$REGNAME').
|
$REGNAME').
|
|
|
Some registers have distinct "raw" and "virtual" data formats. This
|
Some registers have distinct "raw" and "virtual" data formats. This
|
means that the data format in which the register contents are saved by
|
means that the data format in which the register contents are saved by
|
the operating system is not the same one that your program normally
|
the operating system is not the same one that your program normally
|
sees. For example, the registers of the 68881 floating point
|
sees. For example, the registers of the 68881 floating point
|
coprocessor are always saved in "extended" (raw) format, but all C
|
coprocessor are always saved in "extended" (raw) format, but all C
|
programs expect to work with "double" (virtual) format. In such cases,
|
programs expect to work with "double" (virtual) format. In such cases,
|
GDB normally works with the virtual format only (the format that makes
|
GDB normally works with the virtual format only (the format that makes
|
sense for your program), but the `info registers' command prints the
|
sense for your program), but the `info registers' command prints the
|
data in both formats.
|
data in both formats.
|
|
|
Some machines have special registers whose contents can be
|
Some machines have special registers whose contents can be
|
interpreted in several different ways. For example, modern x86-based
|
interpreted in several different ways. For example, modern x86-based
|
machines have SSE and MMX registers that can hold several values packed
|
machines have SSE and MMX registers that can hold several values packed
|
together in several different formats. GDB refers to such registers in
|
together in several different formats. GDB refers to such registers in
|
`struct' notation:
|
`struct' notation:
|
|
|
(gdb) print $xmm1
|
(gdb) print $xmm1
|
$1 = {
|
$1 = {
|
v4_float = {0, 3.43859137e-038, 1.54142831e-044, 1.821688e-044},
|
v4_float = {0, 3.43859137e-038, 1.54142831e-044, 1.821688e-044},
|
v2_double = {9.92129282474342e-303, 2.7585945287983262e-313},
|
v2_double = {9.92129282474342e-303, 2.7585945287983262e-313},
|
v16_int8 = "\000\000\000\000\3706;\001\v\000\000\000\r\000\000",
|
v16_int8 = "\000\000\000\000\3706;\001\v\000\000\000\r\000\000",
|
v8_int16 = {0, 0, 14072, 315, 11, 0, 13, 0},
|
v8_int16 = {0, 0, 14072, 315, 11, 0, 13, 0},
|
v4_int32 = {0, 20657912, 11, 13},
|
v4_int32 = {0, 20657912, 11, 13},
|
v2_int64 = {88725056443645952, 55834574859},
|
v2_int64 = {88725056443645952, 55834574859},
|
uint128 = 0x0000000d0000000b013b36f800000000
|
uint128 = 0x0000000d0000000b013b36f800000000
|
}
|
}
|
|
|
To set values of such registers, you need to tell GDB which view of the
|
To set values of such registers, you need to tell GDB which view of the
|
register you wish to change, as if you were assigning value to a
|
register you wish to change, as if you were assigning value to a
|
`struct' member:
|
`struct' member:
|
|
|
(gdb) set $xmm1.uint128 = 0x000000000000000000000000FFFFFFFF
|
(gdb) set $xmm1.uint128 = 0x000000000000000000000000FFFFFFFF
|
|
|
Normally, register values are relative to the selected stack frame
|
Normally, register values are relative to the selected stack frame
|
(*note Selecting a Frame: Selection.). This means that you get the
|
(*note Selecting a Frame: Selection.). This means that you get the
|
value that the register would contain if all stack frames farther in
|
value that the register would contain if all stack frames farther in
|
were exited and their saved registers restored. In order to see the
|
were exited and their saved registers restored. In order to see the
|
true contents of hardware registers, you must select the innermost
|
true contents of hardware registers, you must select the innermost
|
frame (with `frame 0').
|
frame (with `frame 0').
|
|
|
However, GDB must deduce where registers are saved, from the machine
|
However, GDB must deduce where registers are saved, from the machine
|
code generated by your compiler. If some registers are not saved, or if
|
code generated by your compiler. If some registers are not saved, or if
|
GDB is unable to locate the saved registers, the selected stack frame
|
GDB is unable to locate the saved registers, the selected stack frame
|
makes no difference.
|
makes no difference.
|
|
|
---------- Footnotes ----------
|
---------- Footnotes ----------
|
|
|
(1) This is a way of removing one word from the stack, on machines
|
(1) This is a way of removing one word from the stack, on machines
|
where stacks grow downward in memory (most machines, nowadays). This
|
where stacks grow downward in memory (most machines, nowadays). This
|
assumes that the innermost stack frame is selected; setting `$sp' is
|
assumes that the innermost stack frame is selected; setting `$sp' is
|
not allowed when other stack frames are selected. To pop entire frames
|
not allowed when other stack frames are selected. To pop entire frames
|
off the stack, regardless of machine architecture, use `return'; see
|
off the stack, regardless of machine architecture, use `return'; see
|
*note Returning from a Function: Returning.
|
*note Returning from a Function: Returning.
|
|
|
|
|
File: gdb.info, Node: Floating Point Hardware, Next: Vector Unit, Prev: Registers, Up: Data
|
File: gdb.info, Node: Floating Point Hardware, Next: Vector Unit, Prev: Registers, Up: Data
|
|
|
10.13 Floating Point Hardware
|
10.13 Floating Point Hardware
|
=============================
|
=============================
|
|
|
Depending on the configuration, GDB may be able to give you more
|
Depending on the configuration, GDB may be able to give you more
|
information about the status of the floating point hardware.
|
information about the status of the floating point hardware.
|
|
|
`info float'
|
`info float'
|
Display hardware-dependent information about the floating point
|
Display hardware-dependent information about the floating point
|
unit. The exact contents and layout vary depending on the
|
unit. The exact contents and layout vary depending on the
|
floating point chip. Currently, `info float' is supported on the
|
floating point chip. Currently, `info float' is supported on the
|
ARM and x86 machines.
|
ARM and x86 machines.
|
|
|
|
|
File: gdb.info, Node: Vector Unit, Next: OS Information, Prev: Floating Point Hardware, Up: Data
|
File: gdb.info, Node: Vector Unit, Next: OS Information, Prev: Floating Point Hardware, Up: Data
|
|
|
10.14 Vector Unit
|
10.14 Vector Unit
|
=================
|
=================
|
|
|
Depending on the configuration, GDB may be able to give you more
|
Depending on the configuration, GDB may be able to give you more
|
information about the status of the vector unit.
|
information about the status of the vector unit.
|
|
|
`info vector'
|
`info vector'
|
Display information about the vector unit. The exact contents and
|
Display information about the vector unit. The exact contents and
|
layout vary depending on the hardware.
|
layout vary depending on the hardware.
|
|
|
|
|
File: gdb.info, Node: OS Information, Next: Memory Region Attributes, Prev: Vector Unit, Up: Data
|
File: gdb.info, Node: OS Information, Next: Memory Region Attributes, Prev: Vector Unit, Up: Data
|
|
|
10.15 Operating System Auxiliary Information
|
10.15 Operating System Auxiliary Information
|
============================================
|
============================================
|
|
|
GDB provides interfaces to useful OS facilities that can help you debug
|
GDB provides interfaces to useful OS facilities that can help you debug
|
your program.
|
your program.
|
|
|
When GDB runs on a "Posix system" (such as GNU or Unix machines), it
|
When GDB runs on a "Posix system" (such as GNU or Unix machines), it
|
interfaces with the inferior via the `ptrace' system call. The
|
interfaces with the inferior via the `ptrace' system call. The
|
operating system creates a special sata structure, called `struct
|
operating system creates a special sata structure, called `struct
|
user', for this interface. You can use the command `info udot' to
|
user', for this interface. You can use the command `info udot' to
|
display the contents of this data structure.
|
display the contents of this data structure.
|
|
|
`info udot'
|
`info udot'
|
Display the contents of the `struct user' maintained by the OS
|
Display the contents of the `struct user' maintained by the OS
|
kernel for the program being debugged. GDB displays the contents
|
kernel for the program being debugged. GDB displays the contents
|
of `struct user' as a list of hex numbers, similar to the
|
of `struct user' as a list of hex numbers, similar to the
|
`examine' command.
|
`examine' command.
|
|
|
Some operating systems supply an "auxiliary vector" to programs at
|
Some operating systems supply an "auxiliary vector" to programs at
|
startup. This is akin to the arguments and environment that you
|
startup. This is akin to the arguments and environment that you
|
specify for a program, but contains a system-dependent variety of
|
specify for a program, but contains a system-dependent variety of
|
binary values that tell system libraries important details about the
|
binary values that tell system libraries important details about the
|
hardware, operating system, and process. Each value's purpose is
|
hardware, operating system, and process. Each value's purpose is
|
identified by an integer tag; the meanings are well-known but
|
identified by an integer tag; the meanings are well-known but
|
system-specific. Depending on the configuration and operating system
|
system-specific. Depending on the configuration and operating system
|
facilities, GDB may be able to show you this information. For remote
|
facilities, GDB may be able to show you this information. For remote
|
targets, this functionality may further depend on the remote stub's
|
targets, this functionality may further depend on the remote stub's
|
support of the `qXfer:auxv:read' packet, see *note qXfer auxiliary
|
support of the `qXfer:auxv:read' packet, see *note qXfer auxiliary
|
vector read::.
|
vector read::.
|
|
|
`info auxv'
|
`info auxv'
|
Display the auxiliary vector of the inferior, which can be either a
|
Display the auxiliary vector of the inferior, which can be either a
|
live process or a core dump file. GDB prints each tag value
|
live process or a core dump file. GDB prints each tag value
|
numerically, and also shows names and text descriptions for
|
numerically, and also shows names and text descriptions for
|
recognized tags. Some values in the vector are numbers, some bit
|
recognized tags. Some values in the vector are numbers, some bit
|
masks, and some pointers to strings or other data. GDB displays
|
masks, and some pointers to strings or other data. GDB displays
|
each value in the most appropriate form for a recognized tag, and
|
each value in the most appropriate form for a recognized tag, and
|
in hexadecimal for an unrecognized tag.
|
in hexadecimal for an unrecognized tag.
|
|
|
On some targets, GDB can access operating-system-specific information
|
On some targets, GDB can access operating-system-specific information
|
and display it to user, without interpretation. For remote targets,
|
and display it to user, without interpretation. For remote targets,
|
this functionality depends on the remote stub's support of the
|
this functionality depends on the remote stub's support of the
|
`qXfer:osdata:read' packet, see *note qXfer osdata read::.
|
`qXfer:osdata:read' packet, see *note qXfer osdata read::.
|
|
|
`info os'
|
`info os'
|
List the types of OS information available for the target. If the
|
List the types of OS information available for the target. If the
|
target does not return a list of possible types, this command will
|
target does not return a list of possible types, this command will
|
report an error.
|
report an error.
|
|
|
`info os processes'
|
`info os processes'
|
Display the list of processes on the target. For each process,
|
Display the list of processes on the target. For each process,
|
GDB prints the process identifier, the name of the user, and the
|
GDB prints the process identifier, the name of the user, and the
|
command corresponding to the process.
|
command corresponding to the process.
|
|
|
|
|
File: gdb.info, Node: Memory Region Attributes, Next: Dump/Restore Files, Prev: OS Information, Up: Data
|
File: gdb.info, Node: Memory Region Attributes, Next: Dump/Restore Files, Prev: OS Information, Up: Data
|
|
|
10.16 Memory Region Attributes
|
10.16 Memory Region Attributes
|
==============================
|
==============================
|
|
|
"Memory region attributes" allow you to describe special handling
|
"Memory region attributes" allow you to describe special handling
|
required by regions of your target's memory. GDB uses attributes to
|
required by regions of your target's memory. GDB uses attributes to
|
determine whether to allow certain types of memory accesses; whether to
|
determine whether to allow certain types of memory accesses; whether to
|
use specific width accesses; and whether to cache target memory. By
|
use specific width accesses; and whether to cache target memory. By
|
default the description of memory regions is fetched from the target
|
default the description of memory regions is fetched from the target
|
(if the current target supports this), but the user can override the
|
(if the current target supports this), but the user can override the
|
fetched regions.
|
fetched regions.
|
|
|
Defined memory regions can be individually enabled and disabled.
|
Defined memory regions can be individually enabled and disabled.
|
When a memory region is disabled, GDB uses the default attributes when
|
When a memory region is disabled, GDB uses the default attributes when
|
accessing memory in that region. Similarly, if no memory regions have
|
accessing memory in that region. Similarly, if no memory regions have
|
been defined, GDB uses the default attributes when accessing all memory.
|
been defined, GDB uses the default attributes when accessing all memory.
|
|
|
When a memory region is defined, it is given a number to identify it;
|
When a memory region is defined, it is given a number to identify it;
|
to enable, disable, or remove a memory region, you specify that number.
|
to enable, disable, or remove a memory region, you specify that number.
|
|
|
`mem LOWER UPPER ATTRIBUTES...'
|
`mem LOWER UPPER ATTRIBUTES...'
|
Define a memory region bounded by LOWER and UPPER with attributes
|
Define a memory region bounded by LOWER and UPPER with attributes
|
ATTRIBUTES..., and add it to the list of regions monitored by GDB.
|
ATTRIBUTES..., and add it to the list of regions monitored by GDB.
|
Note that UPPER == 0 is a special case: it is treated as the
|
Note that UPPER == 0 is a special case: it is treated as the
|
target's maximum memory address. (0xffff on 16 bit targets,
|
target's maximum memory address. (0xffff on 16 bit targets,
|
0xffffffff on 32 bit targets, etc.)
|
0xffffffff on 32 bit targets, etc.)
|
|
|
`mem auto'
|
`mem auto'
|
Discard any user changes to the memory regions and use
|
Discard any user changes to the memory regions and use
|
target-supplied regions, if available, or no regions if the target
|
target-supplied regions, if available, or no regions if the target
|
does not support.
|
does not support.
|
|
|
`delete mem NUMS...'
|
`delete mem NUMS...'
|
Remove memory regions NUMS... from the list of regions monitored
|
Remove memory regions NUMS... from the list of regions monitored
|
by GDB.
|
by GDB.
|
|
|
`disable mem NUMS...'
|
`disable mem NUMS...'
|
Disable monitoring of memory regions NUMS.... A disabled memory
|
Disable monitoring of memory regions NUMS.... A disabled memory
|
region is not forgotten. It may be enabled again later.
|
region is not forgotten. It may be enabled again later.
|
|
|
`enable mem NUMS...'
|
`enable mem NUMS...'
|
Enable monitoring of memory regions NUMS....
|
Enable monitoring of memory regions NUMS....
|
|
|
`info mem'
|
`info mem'
|
Print a table of all defined memory regions, with the following
|
Print a table of all defined memory regions, with the following
|
columns for each region:
|
columns for each region:
|
|
|
_Memory Region Number_
|
_Memory Region Number_
|
|
|
_Enabled or Disabled._
|
_Enabled or Disabled._
|
Enabled memory regions are marked with `y'. Disabled memory
|
Enabled memory regions are marked with `y'. Disabled memory
|
regions are marked with `n'.
|
regions are marked with `n'.
|
|
|
_Lo Address_
|
_Lo Address_
|
The address defining the inclusive lower bound of the memory
|
The address defining the inclusive lower bound of the memory
|
region.
|
region.
|
|
|
_Hi Address_
|
_Hi Address_
|
The address defining the exclusive upper bound of the memory
|
The address defining the exclusive upper bound of the memory
|
region.
|
region.
|
|
|
_Attributes_
|
_Attributes_
|
The list of attributes set for this memory region.
|
The list of attributes set for this memory region.
|
|
|
10.16.1 Attributes
|
10.16.1 Attributes
|
------------------
|
------------------
|
|
|
10.16.1.1 Memory Access Mode
|
10.16.1.1 Memory Access Mode
|
............................
|
............................
|
|
|
The access mode attributes set whether GDB may make read or write
|
The access mode attributes set whether GDB may make read or write
|
accesses to a memory region.
|
accesses to a memory region.
|
|
|
While these attributes prevent GDB from performing invalid memory
|
While these attributes prevent GDB from performing invalid memory
|
accesses, they do nothing to prevent the target system, I/O DMA, etc.
|
accesses, they do nothing to prevent the target system, I/O DMA, etc.
|
from accessing memory.
|
from accessing memory.
|
|
|
`ro'
|
`ro'
|
Memory is read only.
|
Memory is read only.
|
|
|
`wo'
|
`wo'
|
Memory is write only.
|
Memory is write only.
|
|
|
`rw'
|
`rw'
|
Memory is read/write. This is the default.
|
Memory is read/write. This is the default.
|
|
|
10.16.1.2 Memory Access Size
|
10.16.1.2 Memory Access Size
|
............................
|
............................
|
|
|
The access size attribute tells GDB to use specific sized accesses in
|
The access size attribute tells GDB to use specific sized accesses in
|
the memory region. Often memory mapped device registers require
|
the memory region. Often memory mapped device registers require
|
specific sized accesses. If no access size attribute is specified, GDB
|
specific sized accesses. If no access size attribute is specified, GDB
|
may use accesses of any size.
|
may use accesses of any size.
|
|
|
`8'
|
`8'
|
Use 8 bit memory accesses.
|
Use 8 bit memory accesses.
|
|
|
`16'
|
`16'
|
Use 16 bit memory accesses.
|
Use 16 bit memory accesses.
|
|
|
`32'
|
`32'
|
Use 32 bit memory accesses.
|
Use 32 bit memory accesses.
|
|
|
`64'
|
`64'
|
Use 64 bit memory accesses.
|
Use 64 bit memory accesses.
|
|
|
10.16.1.3 Data Cache
|
10.16.1.3 Data Cache
|
....................
|
....................
|
|
|
The data cache attributes set whether GDB will cache target memory.
|
The data cache attributes set whether GDB will cache target memory.
|
While this generally improves performance by reducing debug protocol
|
While this generally improves performance by reducing debug protocol
|
overhead, it can lead to incorrect results because GDB does not know
|
overhead, it can lead to incorrect results because GDB does not know
|
about volatile variables or memory mapped device registers.
|
about volatile variables or memory mapped device registers.
|
|
|
`cache'
|
`cache'
|
Enable GDB to cache target memory.
|
Enable GDB to cache target memory.
|
|
|
`nocache'
|
`nocache'
|
Disable GDB from caching target memory. This is the default.
|
Disable GDB from caching target memory. This is the default.
|
|
|
10.16.2 Memory Access Checking
|
10.16.2 Memory Access Checking
|
------------------------------
|
------------------------------
|
|
|
GDB can be instructed to refuse accesses to memory that is not
|
GDB can be instructed to refuse accesses to memory that is not
|
explicitly described. This can be useful if accessing such regions has
|
explicitly described. This can be useful if accessing such regions has
|
undesired effects for a specific target, or to provide better error
|
undesired effects for a specific target, or to provide better error
|
checking. The following commands control this behaviour.
|
checking. The following commands control this behaviour.
|
|
|
`set mem inaccessible-by-default [on|off]'
|
`set mem inaccessible-by-default [on|off]'
|
If `on' is specified, make GDB treat memory not explicitly
|
If `on' is specified, make GDB treat memory not explicitly
|
described by the memory ranges as non-existent and refuse accesses
|
described by the memory ranges as non-existent and refuse accesses
|
to such memory. The checks are only performed if there's at least
|
to such memory. The checks are only performed if there's at least
|
one memory range defined. If `off' is specified, make GDB treat
|
one memory range defined. If `off' is specified, make GDB treat
|
the memory not explicitly described by the memory ranges as RAM.
|
the memory not explicitly described by the memory ranges as RAM.
|
The default value is `on'.
|
The default value is `on'.
|
|
|
`show mem inaccessible-by-default'
|
`show mem inaccessible-by-default'
|
Show the current handling of accesses to unknown memory.
|
Show the current handling of accesses to unknown memory.
|
|
|
|
|
File: gdb.info, Node: Dump/Restore Files, Next: Core File Generation, Prev: Memory Region Attributes, Up: Data
|
File: gdb.info, Node: Dump/Restore Files, Next: Core File Generation, Prev: Memory Region Attributes, Up: Data
|
|
|
10.17 Copy Between Memory and a File
|
10.17 Copy Between Memory and a File
|
====================================
|
====================================
|
|
|
You can use the commands `dump', `append', and `restore' to copy data
|
You can use the commands `dump', `append', and `restore' to copy data
|
between target memory and a file. The `dump' and `append' commands
|
between target memory and a file. The `dump' and `append' commands
|
write data to a file, and the `restore' command reads data from a file
|
write data to a file, and the `restore' command reads data from a file
|
back into the inferior's memory. Files may be in binary, Motorola
|
back into the inferior's memory. Files may be in binary, Motorola
|
S-record, Intel hex, or Tektronix Hex format; however, GDB can only
|
S-record, Intel hex, or Tektronix Hex format; however, GDB can only
|
append to binary files.
|
append to binary files.
|
|
|
`dump [FORMAT] memory FILENAME START_ADDR END_ADDR'
|
`dump [FORMAT] memory FILENAME START_ADDR END_ADDR'
|
`dump [FORMAT] value FILENAME EXPR'
|
`dump [FORMAT] value FILENAME EXPR'
|
Dump the contents of memory from START_ADDR to END_ADDR, or the
|
Dump the contents of memory from START_ADDR to END_ADDR, or the
|
value of EXPR, to FILENAME in the given format.
|
value of EXPR, to FILENAME in the given format.
|
|
|
The FORMAT parameter may be any one of:
|
The FORMAT parameter may be any one of:
|
`binary'
|
`binary'
|
Raw binary form.
|
Raw binary form.
|
|
|
`ihex'
|
`ihex'
|
Intel hex format.
|
Intel hex format.
|
|
|
`srec'
|
`srec'
|
Motorola S-record format.
|
Motorola S-record format.
|
|
|
`tekhex'
|
`tekhex'
|
Tektronix Hex format.
|
Tektronix Hex format.
|
|
|
GDB uses the same definitions of these formats as the GNU binary
|
GDB uses the same definitions of these formats as the GNU binary
|
utilities, like `objdump' and `objcopy'. If FORMAT is omitted,
|
utilities, like `objdump' and `objcopy'. If FORMAT is omitted,
|
GDB dumps the data in raw binary form.
|
GDB dumps the data in raw binary form.
|
|
|
`append [binary] memory FILENAME START_ADDR END_ADDR'
|
`append [binary] memory FILENAME START_ADDR END_ADDR'
|
`append [binary] value FILENAME EXPR'
|
`append [binary] value FILENAME EXPR'
|
Append the contents of memory from START_ADDR to END_ADDR, or the
|
Append the contents of memory from START_ADDR to END_ADDR, or the
|
value of EXPR, to the file FILENAME, in raw binary form. (GDB can
|
value of EXPR, to the file FILENAME, in raw binary form. (GDB can
|
only append data to files in raw binary form.)
|
only append data to files in raw binary form.)
|
|
|
`restore FILENAME [binary] BIAS START END'
|
`restore FILENAME [binary] BIAS START END'
|
Restore the contents of file FILENAME into memory. The `restore'
|
Restore the contents of file FILENAME into memory. The `restore'
|
command can automatically recognize any known BFD file format,
|
command can automatically recognize any known BFD file format,
|
except for raw binary. To restore a raw binary file you must
|
except for raw binary. To restore a raw binary file you must
|
specify the optional keyword `binary' after the filename.
|
specify the optional keyword `binary' after the filename.
|
|
|
If BIAS is non-zero, its value will be added to the addresses
|
If BIAS is non-zero, its value will be added to the addresses
|
contained in the file. Binary files always start at address zero,
|
contained in the file. Binary files always start at address zero,
|
so they will be restored at address BIAS. Other bfd files have a
|
so they will be restored at address BIAS. Other bfd files have a
|
built-in location; they will be restored at offset BIAS from that
|
built-in location; they will be restored at offset BIAS from that
|
location.
|
location.
|
|
|
If START and/or END are non-zero, then only data between file
|
If START and/or END are non-zero, then only data between file
|
offset START and file offset END will be restored. These offsets
|
offset START and file offset END will be restored. These offsets
|
are relative to the addresses in the file, before the BIAS
|
are relative to the addresses in the file, before the BIAS
|
argument is applied.
|
argument is applied.
|
|
|
|
|
|
|
File: gdb.info, Node: Core File Generation, Next: Character Sets, Prev: Dump/Restore Files, Up: Data
|
File: gdb.info, Node: Core File Generation, Next: Character Sets, Prev: Dump/Restore Files, Up: Data
|
|
|
10.18 How to Produce a Core File from Your Program
|
10.18 How to Produce a Core File from Your Program
|
==================================================
|
==================================================
|
|
|
A "core file" or "core dump" is a file that records the memory image of
|
A "core file" or "core dump" is a file that records the memory image of
|
a running process and its process status (register values etc.). Its
|
a running process and its process status (register values etc.). Its
|
primary use is post-mortem debugging of a program that crashed while it
|
primary use is post-mortem debugging of a program that crashed while it
|
ran outside a debugger. A program that crashes automatically produces
|
ran outside a debugger. A program that crashes automatically produces
|
a core file, unless this feature is disabled by the user. *Note
|
a core file, unless this feature is disabled by the user. *Note
|
Files::, for information on invoking GDB in the post-mortem debugging
|
Files::, for information on invoking GDB in the post-mortem debugging
|
mode.
|
mode.
|
|
|
Occasionally, you may wish to produce a core file of the program you
|
Occasionally, you may wish to produce a core file of the program you
|
are debugging in order to preserve a snapshot of its state. GDB has a
|
are debugging in order to preserve a snapshot of its state. GDB has a
|
special command for that.
|
special command for that.
|
|
|
`generate-core-file [FILE]'
|
`generate-core-file [FILE]'
|
`gcore [FILE]'
|
`gcore [FILE]'
|
Produce a core dump of the inferior process. The optional argument
|
Produce a core dump of the inferior process. The optional argument
|
FILE specifies the file name where to put the core dump. If not
|
FILE specifies the file name where to put the core dump. If not
|
specified, the file name defaults to `core.PID', where PID is the
|
specified, the file name defaults to `core.PID', where PID is the
|
inferior process ID.
|
inferior process ID.
|
|
|
Note that this command is implemented only for some systems (as of
|
Note that this command is implemented only for some systems (as of
|
this writing, GNU/Linux, FreeBSD, Solaris, Unixware, and S390).
|
this writing, GNU/Linux, FreeBSD, Solaris, Unixware, and S390).
|
|
|
|
|
File: gdb.info, Node: Character Sets, Next: Caching Remote Data, Prev: Core File Generation, Up: Data
|
File: gdb.info, Node: Character Sets, Next: Caching Remote Data, Prev: Core File Generation, Up: Data
|
|
|
10.19 Character Sets
|
10.19 Character Sets
|
====================
|
====================
|
|
|
If the program you are debugging uses a different character set to
|
If the program you are debugging uses a different character set to
|
represent characters and strings than the one GDB uses itself, GDB can
|
represent characters and strings than the one GDB uses itself, GDB can
|
automatically translate between the character sets for you. The
|
automatically translate between the character sets for you. The
|
character set GDB uses we call the "host character set"; the one the
|
character set GDB uses we call the "host character set"; the one the
|
inferior program uses we call the "target character set".
|
inferior program uses we call the "target character set".
|
|
|
For example, if you are running GDB on a GNU/Linux system, which
|
For example, if you are running GDB on a GNU/Linux system, which
|
uses the ISO Latin 1 character set, but you are using GDB's remote
|
uses the ISO Latin 1 character set, but you are using GDB's remote
|
protocol (*note Remote Debugging::) to debug a program running on an
|
protocol (*note Remote Debugging::) to debug a program running on an
|
IBM mainframe, which uses the EBCDIC character set, then the host
|
IBM mainframe, which uses the EBCDIC character set, then the host
|
character set is Latin-1, and the target character set is EBCDIC. If
|
character set is Latin-1, and the target character set is EBCDIC. If
|
you give GDB the command `set target-charset EBCDIC-US', then GDB
|
you give GDB the command `set target-charset EBCDIC-US', then GDB
|
translates between EBCDIC and Latin 1 as you print character or string
|
translates between EBCDIC and Latin 1 as you print character or string
|
values, or use character and string literals in expressions.
|
values, or use character and string literals in expressions.
|
|
|
GDB has no way to automatically recognize which character set the
|
GDB has no way to automatically recognize which character set the
|
inferior program uses; you must tell it, using the `set target-charset'
|
inferior program uses; you must tell it, using the `set target-charset'
|
command, described below.
|
command, described below.
|
|
|
Here are the commands for controlling GDB's character set support:
|
Here are the commands for controlling GDB's character set support:
|
|
|
`set target-charset CHARSET'
|
`set target-charset CHARSET'
|
Set the current target character set to CHARSET. To display the
|
Set the current target character set to CHARSET. To display the
|
list of supported target character sets, type
|
list of supported target character sets, type
|
`set target-charset '.
|
`set target-charset '.
|
|
|
`set host-charset CHARSET'
|
`set host-charset CHARSET'
|
Set the current host character set to CHARSET.
|
Set the current host character set to CHARSET.
|
|
|
By default, GDB uses a host character set appropriate to the
|
By default, GDB uses a host character set appropriate to the
|
system it is running on; you can override that default using the
|
system it is running on; you can override that default using the
|
`set host-charset' command. On some systems, GDB cannot
|
`set host-charset' command. On some systems, GDB cannot
|
automatically determine the appropriate host character set. In
|
automatically determine the appropriate host character set. In
|
this case, GDB uses `UTF-8'.
|
this case, GDB uses `UTF-8'.
|
|
|
GDB can only use certain character sets as its host character set.
|
GDB can only use certain character sets as its host character set.
|
If you type `set target-charset ', GDB will list the
|
If you type `set target-charset ', GDB will list the
|
host character sets it supports.
|
host character sets it supports.
|
|
|
`set charset CHARSET'
|
`set charset CHARSET'
|
Set the current host and target character sets to CHARSET. As
|
Set the current host and target character sets to CHARSET. As
|
above, if you type `set charset ', GDB will list the
|
above, if you type `set charset ', GDB will list the
|
names of the character sets that can be used for both host and
|
names of the character sets that can be used for both host and
|
target.
|
target.
|
|
|
`show charset'
|
`show charset'
|
Show the names of the current host and target character sets.
|
Show the names of the current host and target character sets.
|
|
|
`show host-charset'
|
`show host-charset'
|
Show the name of the current host character set.
|
Show the name of the current host character set.
|
|
|
`show target-charset'
|
`show target-charset'
|
Show the name of the current target character set.
|
Show the name of the current target character set.
|
|
|
`set target-wide-charset CHARSET'
|
`set target-wide-charset CHARSET'
|
Set the current target's wide character set to CHARSET. This is
|
Set the current target's wide character set to CHARSET. This is
|
the character set used by the target's `wchar_t' type. To display
|
the character set used by the target's `wchar_t' type. To display
|
the list of supported wide character sets, type
|
the list of supported wide character sets, type
|
`set target-wide-charset '.
|
`set target-wide-charset '.
|
|
|
`show target-wide-charset'
|
`show target-wide-charset'
|
Show the name of the current target's wide character set.
|
Show the name of the current target's wide character set.
|
|
|
Here is an example of GDB's character set support in action. Assume
|
Here is an example of GDB's character set support in action. Assume
|
that the following source code has been placed in the file
|
that the following source code has been placed in the file
|
`charset-test.c':
|
`charset-test.c':
|
|
|
#include
|
#include
|
|
|
char ascii_hello[]
|
char ascii_hello[]
|
= {72, 101, 108, 108, 111, 44, 32, 119,
|
= {72, 101, 108, 108, 111, 44, 32, 119,
|
111, 114, 108, 100, 33, 10, 0};
|
111, 114, 108, 100, 33, 10, 0};
|
char ibm1047_hello[]
|
char ibm1047_hello[]
|
= {200, 133, 147, 147, 150, 107, 64, 166,
|
= {200, 133, 147, 147, 150, 107, 64, 166,
|
150, 153, 147, 132, 90, 37, 0};
|
150, 153, 147, 132, 90, 37, 0};
|
|
|
main ()
|
main ()
|
{
|
{
|
printf ("Hello, world!\n");
|
printf ("Hello, world!\n");
|
}
|
}
|
|
|
In this program, `ascii_hello' and `ibm1047_hello' are arrays
|
In this program, `ascii_hello' and `ibm1047_hello' are arrays
|
containing the string `Hello, world!' followed by a newline, encoded in
|
containing the string `Hello, world!' followed by a newline, encoded in
|
the ASCII and IBM1047 character sets.
|
the ASCII and IBM1047 character sets.
|
|
|
We compile the program, and invoke the debugger on it:
|
We compile the program, and invoke the debugger on it:
|
|
|
$ gcc -g charset-test.c -o charset-test
|
$ gcc -g charset-test.c -o charset-test
|
$ gdb -nw charset-test
|
$ gdb -nw charset-test
|
GNU gdb 2001-12-19-cvs
|
GNU gdb 2001-12-19-cvs
|
Copyright 2001 Free Software Foundation, Inc.
|
Copyright 2001 Free Software Foundation, Inc.
|
...
|
...
|
(gdb)
|
(gdb)
|
|
|
We can use the `show charset' command to see what character sets GDB
|
We can use the `show charset' command to see what character sets GDB
|
is currently using to interpret and display characters and strings:
|
is currently using to interpret and display characters and strings:
|
|
|
(gdb) show charset
|
(gdb) show charset
|
The current host and target character set is `ISO-8859-1'.
|
The current host and target character set is `ISO-8859-1'.
|
(gdb)
|
(gdb)
|
|
|
For the sake of printing this manual, let's use ASCII as our initial
|
For the sake of printing this manual, let's use ASCII as our initial
|
character set:
|
character set:
|
(gdb) set charset ASCII
|
(gdb) set charset ASCII
|
(gdb) show charset
|
(gdb) show charset
|
The current host and target character set is `ASCII'.
|
The current host and target character set is `ASCII'.
|
(gdb)
|
(gdb)
|
|
|
Let's assume that ASCII is indeed the correct character set for our
|
Let's assume that ASCII is indeed the correct character set for our
|
host system -- in other words, let's assume that if GDB prints
|
host system -- in other words, let's assume that if GDB prints
|
characters using the ASCII character set, our terminal will display
|
characters using the ASCII character set, our terminal will display
|
them properly. Since our current target character set is also ASCII,
|
them properly. Since our current target character set is also ASCII,
|
the contents of `ascii_hello' print legibly:
|
the contents of `ascii_hello' print legibly:
|
|
|
(gdb) print ascii_hello
|
(gdb) print ascii_hello
|
$1 = 0x401698 "Hello, world!\n"
|
$1 = 0x401698 "Hello, world!\n"
|
(gdb) print ascii_hello[0]
|
(gdb) print ascii_hello[0]
|
$2 = 72 'H'
|
$2 = 72 'H'
|
(gdb)
|
(gdb)
|
|
|
GDB uses the target character set for character and string literals
|
GDB uses the target character set for character and string literals
|
you use in expressions:
|
you use in expressions:
|
|
|
(gdb) print '+'
|
(gdb) print '+'
|
$3 = 43 '+'
|
$3 = 43 '+'
|
(gdb)
|
(gdb)
|
|
|
The ASCII character set uses the number 43 to encode the `+'
|
The ASCII character set uses the number 43 to encode the `+'
|
character.
|
character.
|
|
|
GDB relies on the user to tell it which character set the target
|
GDB relies on the user to tell it which character set the target
|
program uses. If we print `ibm1047_hello' while our target character
|
program uses. If we print `ibm1047_hello' while our target character
|
set is still ASCII, we get jibberish:
|
set is still ASCII, we get jibberish:
|
|
|
(gdb) print ibm1047_hello
|
(gdb) print ibm1047_hello
|
$4 = 0x4016a8 "\310\205\223\223\226k@\246\226\231\223\204Z%"
|
$4 = 0x4016a8 "\310\205\223\223\226k@\246\226\231\223\204Z%"
|
(gdb) print ibm1047_hello[0]
|
(gdb) print ibm1047_hello[0]
|
$5 = 200 '\310'
|
$5 = 200 '\310'
|
(gdb)
|
(gdb)
|
|
|
If we invoke the `set target-charset' followed by , GDB
|
If we invoke the `set target-charset' followed by , GDB
|
tells us the character sets it supports:
|
tells us the character sets it supports:
|
|
|
(gdb) set target-charset
|
(gdb) set target-charset
|
ASCII EBCDIC-US IBM1047 ISO-8859-1
|
ASCII EBCDIC-US IBM1047 ISO-8859-1
|
(gdb) set target-charset
|
(gdb) set target-charset
|
|
|
We can select IBM1047 as our target character set, and examine the
|
We can select IBM1047 as our target character set, and examine the
|
program's strings again. Now the ASCII string is wrong, but GDB
|
program's strings again. Now the ASCII string is wrong, but GDB
|
translates the contents of `ibm1047_hello' from the target character
|
translates the contents of `ibm1047_hello' from the target character
|
set, IBM1047, to the host character set, ASCII, and they display
|
set, IBM1047, to the host character set, ASCII, and they display
|
correctly:
|
correctly:
|
|
|
(gdb) set target-charset IBM1047
|
(gdb) set target-charset IBM1047
|
(gdb) show charset
|
(gdb) show charset
|
The current host character set is `ASCII'.
|
The current host character set is `ASCII'.
|
The current target character set is `IBM1047'.
|
The current target character set is `IBM1047'.
|
(gdb) print ascii_hello
|
(gdb) print ascii_hello
|
$6 = 0x401698 "\110\145%%?\054\040\167?\162%\144\041\012"
|
$6 = 0x401698 "\110\145%%?\054\040\167?\162%\144\041\012"
|
(gdb) print ascii_hello[0]
|
(gdb) print ascii_hello[0]
|
$7 = 72 '\110'
|
$7 = 72 '\110'
|
(gdb) print ibm1047_hello
|
(gdb) print ibm1047_hello
|
$8 = 0x4016a8 "Hello, world!\n"
|
$8 = 0x4016a8 "Hello, world!\n"
|
(gdb) print ibm1047_hello[0]
|
(gdb) print ibm1047_hello[0]
|
$9 = 200 'H'
|
$9 = 200 'H'
|
(gdb)
|
(gdb)
|
|
|
As above, GDB uses the target character set for character and string
|
As above, GDB uses the target character set for character and string
|
literals you use in expressions:
|
literals you use in expressions:
|
|
|
(gdb) print '+'
|
(gdb) print '+'
|
$10 = 78 '+'
|
$10 = 78 '+'
|
(gdb)
|
(gdb)
|
|
|
The IBM1047 character set uses the number 78 to encode the `+'
|
The IBM1047 character set uses the number 78 to encode the `+'
|
character.
|
character.
|
|
|
|
|
File: gdb.info, Node: Caching Remote Data, Next: Searching Memory, Prev: Character Sets, Up: Data
|
File: gdb.info, Node: Caching Remote Data, Next: Searching Memory, Prev: Character Sets, Up: Data
|
|
|
10.20 Caching Data of Remote Targets
|
10.20 Caching Data of Remote Targets
|
====================================
|
====================================
|
|
|
GDB caches data exchanged between the debugger and a remote target
|
GDB caches data exchanged between the debugger and a remote target
|
(*note Remote Debugging::). Such caching generally improves
|
(*note Remote Debugging::). Such caching generally improves
|
performance, because it reduces the overhead of the remote protocol by
|
performance, because it reduces the overhead of the remote protocol by
|
bundling memory reads and writes into large chunks. Unfortunately,
|
bundling memory reads and writes into large chunks. Unfortunately,
|
simply caching everything would lead to incorrect results, since GDB
|
simply caching everything would lead to incorrect results, since GDB
|
does not necessarily know anything about volatile values, memory-mapped
|
does not necessarily know anything about volatile values, memory-mapped
|
I/O addresses, etc. Furthermore, in non-stop mode (*note Non-Stop
|
I/O addresses, etc. Furthermore, in non-stop mode (*note Non-Stop
|
Mode::) memory can be changed _while_ a gdb command is executing.
|
Mode::) memory can be changed _while_ a gdb command is executing.
|
Therefore, by default, GDB only caches data known to be on the stack(1).
|
Therefore, by default, GDB only caches data known to be on the stack(1).
|
Other regions of memory can be explicitly marked as cacheable; see
|
Other regions of memory can be explicitly marked as cacheable; see
|
*note Memory Region Attributes::.
|
*note Memory Region Attributes::.
|
|
|
`set remotecache on'
|
`set remotecache on'
|
`set remotecache off'
|
`set remotecache off'
|
This option no longer does anything; it exists for compatibility
|
This option no longer does anything; it exists for compatibility
|
with old scripts.
|
with old scripts.
|
|
|
`show remotecache'
|
`show remotecache'
|
Show the current state of the obsolete remotecache flag.
|
Show the current state of the obsolete remotecache flag.
|
|
|
`set stack-cache on'
|
`set stack-cache on'
|
`set stack-cache off'
|
`set stack-cache off'
|
Enable or disable caching of stack accesses. When `ON', use
|
Enable or disable caching of stack accesses. When `ON', use
|
caching. By default, this option is `ON'.
|
caching. By default, this option is `ON'.
|
|
|
`show stack-cache'
|
`show stack-cache'
|
Show the current state of data caching for memory accesses.
|
Show the current state of data caching for memory accesses.
|
|
|
`info dcache [line]'
|
`info dcache [line]'
|
Print the information about the data cache performance. The
|
Print the information about the data cache performance. The
|
information displayed includes the dcache width and depth, and for
|
information displayed includes the dcache width and depth, and for
|
each cache line, its number, address, and how many times it was
|
each cache line, its number, address, and how many times it was
|
referenced. This command is useful for debugging the data cache
|
referenced. This command is useful for debugging the data cache
|
operation.
|
operation.
|
|
|
If a line number is specified, the contents of that line will be
|
If a line number is specified, the contents of that line will be
|
printed in hex.
|
printed in hex.
|
|
|
---------- Footnotes ----------
|
---------- Footnotes ----------
|
|
|
(1) In non-stop mode, it is moderately rare for a running thread to
|
(1) In non-stop mode, it is moderately rare for a running thread to
|
modify the stack of a stopped thread in a way that would interfere with
|
modify the stack of a stopped thread in a way that would interfere with
|
a backtrace, and caching of stack reads provides a significant speed up
|
a backtrace, and caching of stack reads provides a significant speed up
|
of remote backtraces.
|
of remote backtraces.
|
|
|
|
|
File: gdb.info, Node: Searching Memory, Prev: Caching Remote Data, Up: Data
|
File: gdb.info, Node: Searching Memory, Prev: Caching Remote Data, Up: Data
|
|
|
10.21 Search Memory
|
10.21 Search Memory
|
===================
|
===================
|
|
|
Memory can be searched for a particular sequence of bytes with the
|
Memory can be searched for a particular sequence of bytes with the
|
`find' command.
|
`find' command.
|
|
|
`find [/SN] START_ADDR, +LEN, VAL1 [, VAL2, ...]'
|
`find [/SN] START_ADDR, +LEN, VAL1 [, VAL2, ...]'
|
`find [/SN] START_ADDR, END_ADDR, VAL1 [, VAL2, ...]'
|
`find [/SN] START_ADDR, END_ADDR, VAL1 [, VAL2, ...]'
|
Search memory for the sequence of bytes specified by VAL1, VAL2,
|
Search memory for the sequence of bytes specified by VAL1, VAL2,
|
etc. The search begins at address START_ADDR and continues for
|
etc. The search begins at address START_ADDR and continues for
|
either LEN bytes or through to END_ADDR inclusive.
|
either LEN bytes or through to END_ADDR inclusive.
|
|
|
S and N are optional parameters. They may be specified in either
|
S and N are optional parameters. They may be specified in either
|
order, apart or together.
|
order, apart or together.
|
|
|
S, search query size
|
S, search query size
|
The size of each search query value.
|
The size of each search query value.
|
|
|
`b'
|
`b'
|
bytes
|
bytes
|
|
|
`h'
|
`h'
|
halfwords (two bytes)
|
halfwords (two bytes)
|
|
|
`w'
|
`w'
|
words (four bytes)
|
words (four bytes)
|
|
|
`g'
|
`g'
|
giant words (eight bytes)
|
giant words (eight bytes)
|
|
|
All values are interpreted in the current language. This means,
|
All values are interpreted in the current language. This means,
|
for example, that if the current source language is C/C++ then
|
for example, that if the current source language is C/C++ then
|
searching for the string "hello" includes the trailing '\0'.
|
searching for the string "hello" includes the trailing '\0'.
|
|
|
If the value size is not specified, it is taken from the value's
|
If the value size is not specified, it is taken from the value's
|
type in the current language. This is useful when one wants to
|
type in the current language. This is useful when one wants to
|
specify the search pattern as a mixture of types. Note that this
|
specify the search pattern as a mixture of types. Note that this
|
means, for example, that in the case of C-like languages a search
|
means, for example, that in the case of C-like languages a search
|
for an untyped 0x42 will search for `(int) 0x42' which is
|
for an untyped 0x42 will search for `(int) 0x42' which is
|
typically four bytes.
|
typically four bytes.
|
|
|
N, maximum number of finds
|
N, maximum number of finds
|
The maximum number of matches to print. The default is to print
|
The maximum number of matches to print. The default is to print
|
all finds.
|
all finds.
|
|
|
You can use strings as search values. Quote them with double-quotes
|
You can use strings as search values. Quote them with double-quotes
|
(`"'). The string value is copied into the search pattern byte by byte,
|
(`"'). The string value is copied into the search pattern byte by byte,
|
regardless of the endianness of the target and the size specification.
|
regardless of the endianness of the target and the size specification.
|
|
|
The address of each match found is printed as well as a count of the
|
The address of each match found is printed as well as a count of the
|
number of matches found.
|
number of matches found.
|
|
|
The address of the last value found is stored in convenience variable
|
The address of the last value found is stored in convenience variable
|
`$_'. A count of the number of matches is stored in `$numfound'.
|
`$_'. A count of the number of matches is stored in `$numfound'.
|
|
|
For example, if stopped at the `printf' in this function:
|
For example, if stopped at the `printf' in this function:
|
|
|
void
|
void
|
hello ()
|
hello ()
|
{
|
{
|
static char hello[] = "hello-hello";
|
static char hello[] = "hello-hello";
|
static struct { char c; short s; int i; }
|
static struct { char c; short s; int i; }
|
__attribute__ ((packed)) mixed
|
__attribute__ ((packed)) mixed
|
= { 'c', 0x1234, 0x87654321 };
|
= { 'c', 0x1234, 0x87654321 };
|
printf ("%s\n", hello);
|
printf ("%s\n", hello);
|
}
|
}
|
|
|
you get during debugging:
|
you get during debugging:
|
|
|
(gdb) find &hello[0], +sizeof(hello), "hello"
|
(gdb) find &hello[0], +sizeof(hello), "hello"
|
0x804956d
|
0x804956d
|
1 pattern found
|
1 pattern found
|
(gdb) find &hello[0], +sizeof(hello), 'h', 'e', 'l', 'l', 'o'
|
(gdb) find &hello[0], +sizeof(hello), 'h', 'e', 'l', 'l', 'o'
|
0x8049567
|
0x8049567
|
0x804956d
|
0x804956d
|
2 patterns found
|
2 patterns found
|
(gdb) find /b1 &hello[0], +sizeof(hello), 'h', 0x65, 'l'
|
(gdb) find /b1 &hello[0], +sizeof(hello), 'h', 0x65, 'l'
|
0x8049567
|
0x8049567
|
1 pattern found
|
1 pattern found
|
(gdb) find &mixed, +sizeof(mixed), (char) 'c', (short) 0x1234, (int) 0x87654321
|
(gdb) find &mixed, +sizeof(mixed), (char) 'c', (short) 0x1234, (int) 0x87654321
|
0x8049560
|
0x8049560
|
1 pattern found
|
1 pattern found
|
(gdb) print $numfound
|
(gdb) print $numfound
|
$1 = 1
|
$1 = 1
|
(gdb) print $_
|
(gdb) print $_
|
$2 = (void *) 0x8049560
|
$2 = (void *) 0x8049560
|
|
|
|
|
File: gdb.info, Node: Optimized Code, Next: Macros, Prev: Data, Up: Top
|
File: gdb.info, Node: Optimized Code, Next: Macros, Prev: Data, Up: Top
|
|
|
11 Debugging Optimized Code
|
11 Debugging Optimized Code
|
***************************
|
***************************
|
|
|
Almost all compilers support optimization. With optimization disabled,
|
Almost all compilers support optimization. With optimization disabled,
|
the compiler generates assembly code that corresponds directly to your
|
the compiler generates assembly code that corresponds directly to your
|
source code, in a simplistic way. As the compiler applies more
|
source code, in a simplistic way. As the compiler applies more
|
powerful optimizations, the generated assembly code diverges from your
|
powerful optimizations, the generated assembly code diverges from your
|
original source code. With help from debugging information generated
|
original source code. With help from debugging information generated
|
by the compiler, GDB can map from the running program back to
|
by the compiler, GDB can map from the running program back to
|
constructs from your original source.
|
constructs from your original source.
|
|
|
GDB is more accurate with optimization disabled. If you can
|
GDB is more accurate with optimization disabled. If you can
|
recompile without optimization, it is easier to follow the progress of
|
recompile without optimization, it is easier to follow the progress of
|
your program during debugging. But, there are many cases where you may
|
your program during debugging. But, there are many cases where you may
|
need to debug an optimized version.
|
need to debug an optimized version.
|
|
|
When you debug a program compiled with `-g -O', remember that the
|
When you debug a program compiled with `-g -O', remember that the
|
optimizer has rearranged your code; the debugger shows you what is
|
optimizer has rearranged your code; the debugger shows you what is
|
really there. Do not be too surprised when the execution path does not
|
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
|
exactly match your source file! An extreme example: if you define a
|
variable, but never use it, GDB never sees that variable--because the
|
variable, but never use it, GDB never sees that variable--because the
|
compiler optimizes it out of existence.
|
compiler optimizes it out of existence.
|
|
|
Some things do not work as well with `-g -O' as with just `-g',
|
Some things do not work as well with `-g -O' as with just `-g',
|
particularly on machines with instruction scheduling. If in doubt,
|
particularly on machines with instruction scheduling. If in doubt,
|
recompile with `-g' alone, and if this fixes the problem, please report
|
recompile with `-g' alone, and if this fixes the problem, please report
|
it to us as a bug (including a test case!). *Note Variables::, for
|
it to us as a bug (including a test case!). *Note Variables::, for
|
more information about debugging optimized code.
|
more information about debugging optimized code.
|
|
|
* Menu:
|
* Menu:
|
|
|
* Inline Functions:: How GDB presents inlining
|
* Inline Functions:: How GDB presents inlining
|
|
|
|
|
File: gdb.info, Node: Inline Functions, Up: Optimized Code
|
File: gdb.info, Node: Inline Functions, Up: Optimized Code
|
|
|
11.1 Inline Functions
|
11.1 Inline Functions
|
=====================
|
=====================
|
|
|
"Inlining" is an optimization that inserts a copy of the function body
|
"Inlining" is an optimization that inserts a copy of the function body
|
directly at each call site, instead of jumping to a shared routine.
|
directly at each call site, instead of jumping to a shared routine.
|
GDB displays inlined functions just like non-inlined functions. They
|
GDB displays inlined functions just like non-inlined functions. They
|
appear in backtraces. You can view their arguments and local
|
appear in backtraces. You can view their arguments and local
|
variables, step into them with `step', skip them with `next', and
|
variables, step into them with `step', skip them with `next', and
|
escape from them with `finish'. You can check whether a function was
|
escape from them with `finish'. You can check whether a function was
|
inlined by using the `info frame' command.
|
inlined by using the `info frame' command.
|
|
|
For GDB to support inlined functions, the compiler must record
|
For GDB to support inlined functions, the compiler must record
|
information about inlining in the debug information -- GCC using the
|
information about inlining in the debug information -- GCC using the
|
DWARF 2 format does this, and several other compilers do also. GDB
|
DWARF 2 format does this, and several other compilers do also. GDB
|
only supports inlined functions when using DWARF 2. Versions of GCC
|
only supports inlined functions when using DWARF 2. Versions of GCC
|
before 4.1 do not emit two required attributes (`DW_AT_call_file' and
|
before 4.1 do not emit two required attributes (`DW_AT_call_file' and
|
`DW_AT_call_line'); GDB does not display inlined function calls with
|
`DW_AT_call_line'); GDB does not display inlined function calls with
|
earlier versions of GCC. It instead displays the arguments and local
|
earlier versions of GCC. It instead displays the arguments and local
|
variables of inlined functions as local variables in the caller.
|
variables of inlined functions as local variables in the caller.
|
|
|
The body of an inlined function is directly included at its call
|
The body of an inlined function is directly included at its call
|
site; unlike a non-inlined function, there are no instructions devoted
|
site; unlike a non-inlined function, there are no instructions devoted
|
to the call. GDB still pretends that the call site and the start of
|
to the call. GDB still pretends that the call site and the start of
|
the inlined function are different instructions. Stepping to the call
|
the inlined function are different instructions. Stepping to the call
|
site shows the call site, and then stepping again shows the first line
|
site shows the call site, and then stepping again shows the first line
|
of the inlined function, even though no additional instructions are
|
of the inlined function, even though no additional instructions are
|
executed.
|
executed.
|
|
|
This makes source-level debugging much clearer; you can see both the
|
This makes source-level debugging much clearer; you can see both the
|
context of the call and then the effect of the call. Only stepping by
|
context of the call and then the effect of the call. Only stepping by
|
a single instruction using `stepi' or `nexti' does not do this; single
|
a single instruction using `stepi' or `nexti' does not do this; single
|
instruction steps always show the inlined body.
|
instruction steps always show the inlined body.
|
|
|
There are some ways that GDB does not pretend that inlined function
|
There are some ways that GDB does not pretend that inlined function
|
calls are the same as normal calls:
|
calls are the same as normal calls:
|
|
|
* You cannot set breakpoints on inlined functions. GDB either
|
* You cannot set breakpoints on inlined functions. GDB either
|
reports that there is no symbol with that name, or else sets the
|
reports that there is no symbol with that name, or else sets the
|
breakpoint only on non-inlined copies of the function. This
|
breakpoint only on non-inlined copies of the function. This
|
limitation will be removed in a future version of GDB; until then,
|
limitation will be removed in a future version of GDB; until then,
|
set a breakpoint by line number on the first line of the inlined
|
set a breakpoint by line number on the first line of the inlined
|
function instead.
|
function instead.
|
|
|
* Setting breakpoints at the call site of an inlined function may not
|
* Setting breakpoints at the call site of an inlined function may not
|
work, because the call site does not contain any code. GDB may
|
work, because the call site does not contain any code. GDB may
|
incorrectly move the breakpoint to the next line of the enclosing
|
incorrectly move the breakpoint to the next line of the enclosing
|
function, after the call. This limitation will be removed in a
|
function, after the call. This limitation will be removed in a
|
future version of GDB; until then, set a breakpoint on an earlier
|
future version of GDB; until then, set a breakpoint on an earlier
|
line or inside the inlined function instead.
|
line or inside the inlined function instead.
|
|
|
* GDB cannot locate the return value of inlined calls after using
|
* GDB cannot locate the return value of inlined calls after using
|
the `finish' command. This is a limitation of compiler-generated
|
the `finish' command. This is a limitation of compiler-generated
|
debugging information; after `finish', you can step to the next
|
debugging information; after `finish', you can step to the next
|
line and print a variable where your program stored the return
|
line and print a variable where your program stored the return
|
value.
|
value.
|
|
|
|
|
|
|
File: gdb.info, Node: Macros, Next: Tracepoints, Prev: Optimized Code, Up: Top
|
File: gdb.info, Node: Macros, Next: Tracepoints, Prev: Optimized Code, Up: Top
|
|
|
12 C Preprocessor Macros
|
12 C Preprocessor Macros
|
************************
|
************************
|
|
|
Some languages, such as C and C++, provide a way to define and invoke
|
Some languages, such as C and C++, provide a way to define and invoke
|
"preprocessor macros" which expand into strings of tokens. GDB can
|
"preprocessor macros" which expand into strings of tokens. GDB can
|
evaluate expressions containing macro invocations, show the result of
|
evaluate expressions containing macro invocations, show the result of
|
macro expansion, and show a macro's definition, including where it was
|
macro expansion, and show a macro's definition, including where it was
|
defined.
|
defined.
|
|
|
You may need to compile your program specially to provide GDB with
|
You may need to compile your program specially to provide GDB with
|
information about preprocessor macros. Most compilers do not include
|
information about preprocessor macros. Most compilers do not include
|
macros in their debugging information, even when you compile with the
|
macros in their debugging information, even when you compile with the
|
`-g' flag. *Note Compilation::.
|
`-g' flag. *Note Compilation::.
|
|
|
A program may define a macro at one point, remove that definition
|
A program may define a macro at one point, remove that definition
|
later, and then provide a different definition after that. Thus, at
|
later, and then provide a different definition after that. Thus, at
|
different points in the program, a macro may have different
|
different points in the program, a macro may have different
|
definitions, or have no definition at all. If there is a current stack
|
definitions, or have no definition at all. If there is a current stack
|
frame, GDB uses the macros in scope at that frame's source code line.
|
frame, GDB uses the macros in scope at that frame's source code line.
|
Otherwise, GDB uses the macros in scope at the current listing location;
|
Otherwise, GDB uses the macros in scope at the current listing location;
|
see *note List::.
|
see *note List::.
|
|
|
Whenever GDB evaluates an expression, it always expands any macro
|
Whenever GDB evaluates an expression, it always expands any macro
|
invocations present in the expression. GDB also provides the following
|
invocations present in the expression. GDB also provides the following
|
commands for working with macros explicitly.
|
commands for working with macros explicitly.
|
|
|
`macro expand EXPRESSION'
|
`macro expand EXPRESSION'
|
`macro exp EXPRESSION'
|
`macro exp EXPRESSION'
|
Show the results of expanding all preprocessor macro invocations in
|
Show the results of expanding all preprocessor macro invocations in
|
EXPRESSION. Since GDB simply expands macros, but does not parse
|
EXPRESSION. Since GDB simply expands macros, but does not parse
|
the result, EXPRESSION need not be a valid expression; it can be
|
the result, EXPRESSION need not be a valid expression; it can be
|
any string of tokens.
|
any string of tokens.
|
|
|
`macro expand-once EXPRESSION'
|
`macro expand-once EXPRESSION'
|
`macro exp1 EXPRESSION'
|
`macro exp1 EXPRESSION'
|
(This command is not yet implemented.) Show the results of
|
(This command is not yet implemented.) Show the results of
|
expanding those preprocessor macro invocations that appear
|
expanding those preprocessor macro invocations that appear
|
explicitly in EXPRESSION. Macro invocations appearing in that
|
explicitly in EXPRESSION. Macro invocations appearing in that
|
expansion are left unchanged. This command allows you to see the
|
expansion are left unchanged. This command allows you to see the
|
effect of a particular macro more clearly, without being confused
|
effect of a particular macro more clearly, without being confused
|
by further expansions. Since GDB simply expands macros, but does
|
by further expansions. Since GDB simply expands macros, but does
|
not parse the result, EXPRESSION need not be a valid expression; it
|
not parse the result, EXPRESSION need not be a valid expression; it
|
can be any string of tokens.
|
can be any string of tokens.
|
|
|
`info macro MACRO'
|
`info macro MACRO'
|
Show the definition of the macro named MACRO, and describe the
|
Show the definition of the macro named MACRO, and describe the
|
source location or compiler command-line where that definition was
|
source location or compiler command-line where that definition was
|
established.
|
established.
|
|
|
`macro define MACRO REPLACEMENT-LIST'
|
`macro define MACRO REPLACEMENT-LIST'
|
`macro define MACRO(ARGLIST) REPLACEMENT-LIST'
|
`macro define MACRO(ARGLIST) REPLACEMENT-LIST'
|
Introduce a definition for a preprocessor macro named MACRO,
|
Introduce a definition for a preprocessor macro named MACRO,
|
invocations of which are replaced by the tokens given in
|
invocations of which are replaced by the tokens given in
|
REPLACEMENT-LIST. The first form of this command defines an
|
REPLACEMENT-LIST. The first form of this command defines an
|
"object-like" macro, which takes no arguments; the second form
|
"object-like" macro, which takes no arguments; the second form
|
defines a "function-like" macro, which takes the arguments given in
|
defines a "function-like" macro, which takes the arguments given in
|
ARGLIST.
|
ARGLIST.
|
|
|
A definition introduced by this command is in scope in every
|
A definition introduced by this command is in scope in every
|
expression evaluated in GDB, until it is removed with the `macro
|
expression evaluated in GDB, until it is removed with the `macro
|
undef' command, described below. The definition overrides all
|
undef' command, described below. The definition overrides all
|
definitions for MACRO present in the program being debugged, as
|
definitions for MACRO present in the program being debugged, as
|
well as any previous user-supplied definition.
|
well as any previous user-supplied definition.
|
|
|
`macro undef MACRO'
|
`macro undef MACRO'
|
Remove any user-supplied definition for the macro named MACRO.
|
Remove any user-supplied definition for the macro named MACRO.
|
This command only affects definitions provided with the `macro
|
This command only affects definitions provided with the `macro
|
define' command, described above; it cannot remove definitions
|
define' command, described above; it cannot remove definitions
|
present in the program being debugged.
|
present in the program being debugged.
|
|
|
`macro list'
|
`macro list'
|
List all the macros defined using the `macro define' command.
|
List all the macros defined using the `macro define' command.
|
|
|
Here is a transcript showing the above commands in action. First, we
|
Here is a transcript showing the above commands in action. First, we
|
show our source files:
|
show our source files:
|
|
|
$ cat sample.c
|
$ cat sample.c
|
#include
|
#include
|
#include "sample.h"
|
#include "sample.h"
|
|
|
#define M 42
|
#define M 42
|
#define ADD(x) (M + x)
|
#define ADD(x) (M + x)
|
|
|
main ()
|
main ()
|
{
|
{
|
#define N 28
|
#define N 28
|
printf ("Hello, world!\n");
|
printf ("Hello, world!\n");
|
#undef N
|
#undef N
|
printf ("We're so creative.\n");
|
printf ("We're so creative.\n");
|
#define N 1729
|
#define N 1729
|
printf ("Goodbye, world!\n");
|
printf ("Goodbye, world!\n");
|
}
|
}
|
$ cat sample.h
|
$ cat sample.h
|
#define Q <
|
#define Q <
|
$
|
$
|
|
|
Now, we compile the program using the GNU C compiler, GCC. We pass
|
Now, we compile the program using the GNU C compiler, GCC. We pass
|
the `-gdwarf-2' and `-g3' flags to ensure the compiler includes
|
the `-gdwarf-2' and `-g3' flags to ensure the compiler includes
|
information about preprocessor macros in the debugging information.
|
information about preprocessor macros in the debugging information.
|
|
|
$ gcc -gdwarf-2 -g3 sample.c -o sample
|
$ gcc -gdwarf-2 -g3 sample.c -o sample
|
$
|
$
|
|
|
Now, we start GDB on our sample program:
|
Now, we start GDB on our sample program:
|
|
|
$ gdb -nw sample
|
$ gdb -nw sample
|
GNU gdb 2002-05-06-cvs
|
GNU gdb 2002-05-06-cvs
|
Copyright 2002 Free Software Foundation, Inc.
|
Copyright 2002 Free Software Foundation, Inc.
|
GDB is free software, ...
|
GDB is free software, ...
|
(gdb)
|
(gdb)
|
|
|
We can expand macros and examine their definitions, even when the
|
We can expand macros and examine their definitions, even when the
|
program is not running. GDB uses the current listing position to
|
program is not running. GDB uses the current listing position to
|
decide which macro definitions are in scope:
|
decide which macro definitions are in scope:
|
|
|
(gdb) list main
|
(gdb) list main
|
3
|
3
|
4 #define M 42
|
4 #define M 42
|
5 #define ADD(x) (M + x)
|
5 #define ADD(x) (M + x)
|
6
|
6
|
7 main ()
|
7 main ()
|
8 {
|
8 {
|
9 #define N 28
|
9 #define N 28
|
10 printf ("Hello, world!\n");
|
10 printf ("Hello, world!\n");
|
11 #undef N
|
11 #undef N
|
12 printf ("We're so creative.\n");
|
12 printf ("We're so creative.\n");
|
(gdb) info macro ADD
|
(gdb) info macro ADD
|
Defined at /home/jimb/gdb/macros/play/sample.c:5
|
Defined at /home/jimb/gdb/macros/play/sample.c:5
|
#define ADD(x) (M + x)
|
#define ADD(x) (M + x)
|
(gdb) info macro Q
|
(gdb) info macro Q
|
Defined at /home/jimb/gdb/macros/play/sample.h:1
|
Defined at /home/jimb/gdb/macros/play/sample.h:1
|
included at /home/jimb/gdb/macros/play/sample.c:2
|
included at /home/jimb/gdb/macros/play/sample.c:2
|
#define Q <
|
#define Q <
|
(gdb) macro expand ADD(1)
|
(gdb) macro expand ADD(1)
|
expands to: (42 + 1)
|
expands to: (42 + 1)
|
(gdb) macro expand-once ADD(1)
|
(gdb) macro expand-once ADD(1)
|
expands to: once (M + 1)
|
expands to: once (M + 1)
|
(gdb)
|
(gdb)
|
|
|
In the example above, note that `macro expand-once' expands only the
|
In the example above, note that `macro expand-once' expands only the
|
macro invocation explicit in the original text -- the invocation of
|
macro invocation explicit in the original text -- the invocation of
|
`ADD' -- but does not expand the invocation of the macro `M', which was
|
`ADD' -- but does not expand the invocation of the macro `M', which was
|
introduced by `ADD'.
|
introduced by `ADD'.
|
|
|
Once the program is running, GDB uses the macro definitions in force
|
Once the program is running, GDB uses the macro definitions in force
|
at the source line of the current stack frame:
|
at the source line of the current stack frame:
|
|
|
(gdb) break main
|
(gdb) break main
|
Breakpoint 1 at 0x8048370: file sample.c, line 10.
|
Breakpoint 1 at 0x8048370: file sample.c, line 10.
|
(gdb) run
|
(gdb) run
|
Starting program: /home/jimb/gdb/macros/play/sample
|
Starting program: /home/jimb/gdb/macros/play/sample
|
|
|
Breakpoint 1, main () at sample.c:10
|
Breakpoint 1, main () at sample.c:10
|
10 printf ("Hello, world!\n");
|
10 printf ("Hello, world!\n");
|
(gdb)
|
(gdb)
|
|
|
At line 10, the definition of the macro `N' at line 9 is in force:
|
At line 10, the definition of the macro `N' at line 9 is in force:
|
|
|
(gdb) info macro N
|
(gdb) info macro N
|
Defined at /home/jimb/gdb/macros/play/sample.c:9
|
Defined at /home/jimb/gdb/macros/play/sample.c:9
|
#define N 28
|
#define N 28
|
(gdb) macro expand N Q M
|
(gdb) macro expand N Q M
|
expands to: 28 < 42
|
expands to: 28 < 42
|
(gdb) print N Q M
|
(gdb) print N Q M
|
$1 = 1
|
$1 = 1
|
(gdb)
|
(gdb)
|
|
|
As we step over directives that remove `N''s definition, and then
|
As we step over directives that remove `N''s definition, and then
|
give it a new definition, GDB finds the definition (or lack thereof) in
|
give it a new definition, GDB finds the definition (or lack thereof) in
|
force at each point:
|
force at each point:
|
|
|
(gdb) next
|
(gdb) next
|
Hello, world!
|
Hello, world!
|
12 printf ("We're so creative.\n");
|
12 printf ("We're so creative.\n");
|
(gdb) info macro N
|
(gdb) info macro N
|
The symbol `N' has no definition as a C/C++ preprocessor macro
|
The symbol `N' has no definition as a C/C++ preprocessor macro
|
at /home/jimb/gdb/macros/play/sample.c:12
|
at /home/jimb/gdb/macros/play/sample.c:12
|
(gdb) next
|
(gdb) next
|
We're so creative.
|
We're so creative.
|
14 printf ("Goodbye, world!\n");
|
14 printf ("Goodbye, world!\n");
|
(gdb) info macro N
|
(gdb) info macro N
|
Defined at /home/jimb/gdb/macros/play/sample.c:13
|
Defined at /home/jimb/gdb/macros/play/sample.c:13
|
#define N 1729
|
#define N 1729
|
(gdb) macro expand N Q M
|
(gdb) macro expand N Q M
|
expands to: 1729 < 42
|
expands to: 1729 < 42
|
(gdb) print N Q M
|
(gdb) print N Q M
|
$2 = 0
|
$2 = 0
|
(gdb)
|
(gdb)
|
|
|
In addition to source files, macros can be defined on the
|
In addition to source files, macros can be defined on the
|
compilation command line using the `-DNAME=VALUE' syntax. For macros
|
compilation command line using the `-DNAME=VALUE' syntax. For macros
|
defined in such a way, GDB displays the location of their definition as
|
defined in such a way, GDB displays the location of their definition as
|
line zero of the source file submitted to the compiler.
|
line zero of the source file submitted to the compiler.
|
|
|
(gdb) info macro __STDC__
|
(gdb) info macro __STDC__
|
Defined at /home/jimb/gdb/macros/play/sample.c:0
|
Defined at /home/jimb/gdb/macros/play/sample.c:0
|
-D__STDC__=1
|
-D__STDC__=1
|
(gdb)
|
(gdb)
|
|
|
|
|
File: gdb.info, Node: Tracepoints, Next: Overlays, Prev: Macros, Up: Top
|
File: gdb.info, Node: Tracepoints, Next: Overlays, Prev: Macros, Up: Top
|
|
|
13 Tracepoints
|
13 Tracepoints
|
**************
|
**************
|
|
|
In some applications, it is not feasible for the debugger to interrupt
|
In some applications, it is not feasible for the debugger to interrupt
|
the program's execution long enough for the developer to learn anything
|
the program's execution long enough for the developer to learn anything
|
helpful about its behavior. If the program's correctness depends on
|
helpful about its behavior. If the program's correctness depends on
|
its real-time behavior, delays introduced by a debugger might cause the
|
its real-time behavior, delays introduced by a debugger might cause the
|
program to change its behavior drastically, or perhaps fail, even when
|
program to change its behavior drastically, or perhaps fail, even when
|
the code itself is correct. It is useful to be able to observe the
|
the code itself is correct. It is useful to be able to observe the
|
program's behavior without interrupting it.
|
program's behavior without interrupting it.
|
|
|
Using GDB's `trace' and `collect' commands, you can specify
|
Using GDB's `trace' and `collect' commands, you can specify
|
locations in the program, called "tracepoints", and arbitrary
|
locations in the program, called "tracepoints", and arbitrary
|
expressions to evaluate when those tracepoints are reached. Later,
|
expressions to evaluate when those tracepoints are reached. Later,
|
using the `tfind' command, you can examine the values those expressions
|
using the `tfind' command, you can examine the values those expressions
|
had when the program hit the tracepoints. The expressions may also
|
had when the program hit the tracepoints. The expressions may also
|
denote objects in memory--structures or arrays, for example--whose
|
denote objects in memory--structures or arrays, for example--whose
|
values GDB should record; while visiting a particular tracepoint, you
|
values GDB should record; while visiting a particular tracepoint, you
|
may inspect those objects as if they were in memory at that moment.
|
may inspect those objects as if they were in memory at that moment.
|
However, because GDB records these values without interacting with you,
|
However, because GDB records these values without interacting with you,
|
it can do so quickly and unobtrusively, hopefully not disturbing the
|
it can do so quickly and unobtrusively, hopefully not disturbing the
|
program's behavior.
|
program's behavior.
|
|
|
The tracepoint facility is currently available only for remote
|
The tracepoint facility is currently available only for remote
|
targets. *Note Targets::. In addition, your remote target must know
|
targets. *Note Targets::. In addition, your remote target must know
|
how to collect trace data. This functionality is implemented in the
|
how to collect trace data. This functionality is implemented in the
|
remote stub; however, none of the stubs distributed with GDB support
|
remote stub; however, none of the stubs distributed with GDB support
|
tracepoints as of this writing. The format of the remote packets used
|
tracepoints as of this writing. The format of the remote packets used
|
to implement tracepoints are described in *note Tracepoint Packets::.
|
to implement tracepoints are described in *note Tracepoint Packets::.
|
|
|
It is also possible to get trace data from a file, in a manner
|
It is also possible to get trace data from a file, in a manner
|
reminiscent of corefiles; you specify the filename, and use `tfind' to
|
reminiscent of corefiles; you specify the filename, and use `tfind' to
|
search through the file. *Note Trace Files::, for more details.
|
search through the file. *Note Trace Files::, for more details.
|
|
|
This chapter describes the tracepoint commands and features.
|
This chapter describes the tracepoint commands and features.
|
|
|
* Menu:
|
* Menu:
|
|
|
* Set Tracepoints::
|
* Set Tracepoints::
|
* Analyze Collected Data::
|
* Analyze Collected Data::
|
* Tracepoint Variables::
|
* Tracepoint Variables::
|
* Trace Files::
|
* Trace Files::
|
|
|
|
|
File: gdb.info, Node: Set Tracepoints, Next: Analyze Collected Data, Up: Tracepoints
|
File: gdb.info, Node: Set Tracepoints, Next: Analyze Collected Data, Up: Tracepoints
|
|
|
13.1 Commands to Set Tracepoints
|
13.1 Commands to Set Tracepoints
|
================================
|
================================
|
|
|
Before running such a "trace experiment", an arbitrary number of
|
Before running such a "trace experiment", an arbitrary number of
|
tracepoints can be set. A tracepoint is actually a special type of
|
tracepoints can be set. A tracepoint is actually a special type of
|
breakpoint (*note Set Breaks::), so you can manipulate it using
|
breakpoint (*note Set Breaks::), so you can manipulate it using
|
standard breakpoint commands. For instance, as with breakpoints,
|
standard breakpoint commands. For instance, as with breakpoints,
|
tracepoint numbers are successive integers starting from one, and many
|
tracepoint numbers are successive integers starting from one, and many
|
of the commands associated with tracepoints take the tracepoint number
|
of the commands associated with tracepoints take the tracepoint number
|
as their argument, to identify which tracepoint to work on.
|
as their argument, to identify which tracepoint to work on.
|
|
|
For each tracepoint, you can specify, in advance, some arbitrary set
|
For each tracepoint, you can specify, in advance, some arbitrary set
|
of data that you want the target to collect in the trace buffer when it
|
of data that you want the target to collect in the trace buffer when it
|
hits that tracepoint. The collected data can include registers, local
|
hits that tracepoint. The collected data can include registers, local
|
variables, or global data. Later, you can use GDB commands to examine
|
variables, or global data. Later, you can use GDB commands to examine
|
the values these data had at the time the tracepoint was hit.
|
the values these data had at the time the tracepoint was hit.
|
|
|
Tracepoints do not support every breakpoint feature. Ignore counts
|
Tracepoints do not support every breakpoint feature. Ignore counts
|
on tracepoints have no effect, and tracepoints cannot run GDB commands
|
on tracepoints have no effect, and tracepoints cannot run GDB commands
|
when they are hit. Tracepoints may not be thread-specific either.
|
when they are hit. Tracepoints may not be thread-specific either.
|
|
|
Some targets may support "fast tracepoints", which are inserted in a
|
Some targets may support "fast tracepoints", which are inserted in a
|
different way (such as with a jump instead of a trap), that is faster
|
different way (such as with a jump instead of a trap), that is faster
|
but possibly restricted in where they may be installed.
|
but possibly restricted in where they may be installed.
|
|
|
Regular and fast tracepoints are dynamic tracing facilities, meaning
|
Regular and fast tracepoints are dynamic tracing facilities, meaning
|
that they can be used to insert tracepoints at (almost) any location in
|
that they can be used to insert tracepoints at (almost) any location in
|
the target. Some targets may also support controlling "static
|
the target. Some targets may also support controlling "static
|
tracepoints" from GDB. With static tracing, a set of instrumentation
|
tracepoints" from GDB. With static tracing, a set of instrumentation
|
points, also known as "markers", are embedded in the target program,
|
points, also known as "markers", are embedded in the target program,
|
and can be activated or deactivated by name or address. These are
|
and can be activated or deactivated by name or address. These are
|
usually placed at locations which facilitate investigating what the
|
usually placed at locations which facilitate investigating what the
|
target is actually doing. GDB's support for static tracing includes
|
target is actually doing. GDB's support for static tracing includes
|
being able to list instrumentation points, and attach them with GDB
|
being able to list instrumentation points, and attach them with GDB
|
defined high level tracepoints that expose the whole range of
|
defined high level tracepoints that expose the whole range of
|
convenience of GDB's tracepoints support. Namelly, support for
|
convenience of GDB's tracepoints support. Namelly, support for
|
collecting registers values and values of global or local (to the
|
collecting registers values and values of global or local (to the
|
instrumentation point) variables; tracepoint conditions and trace state
|
instrumentation point) variables; tracepoint conditions and trace state
|
variables. The act of installing a GDB static tracepoint on an
|
variables. The act of installing a GDB static tracepoint on an
|
instrumentation point, or marker, is referred to as "probing" a static
|
instrumentation point, or marker, is referred to as "probing" a static
|
tracepoint marker.
|
tracepoint marker.
|
|
|
`gdbserver' supports tracepoints on some target systems. *Note
|
`gdbserver' supports tracepoints on some target systems. *Note
|
Tracepoints support in `gdbserver': Server.
|
Tracepoints support in `gdbserver': Server.
|
|
|
This section describes commands to set tracepoints and associated
|
This section describes commands to set tracepoints and associated
|
conditions and actions.
|
conditions and actions.
|
|
|
* Menu:
|
* Menu:
|
|
|
* Create and Delete Tracepoints::
|
* Create and Delete Tracepoints::
|
* Enable and Disable Tracepoints::
|
* Enable and Disable Tracepoints::
|
* Tracepoint Passcounts::
|
* Tracepoint Passcounts::
|
* Tracepoint Conditions::
|
* Tracepoint Conditions::
|
* Trace State Variables::
|
* Trace State Variables::
|
* Tracepoint Actions::
|
* Tracepoint Actions::
|
* Listing Tracepoints::
|
* Listing Tracepoints::
|
* Listing Static Tracepoint Markers::
|
* Listing Static Tracepoint Markers::
|
* Starting and Stopping Trace Experiments::
|
* Starting and Stopping Trace Experiments::
|
* Tracepoint Restrictions::
|
* Tracepoint Restrictions::
|
|
|
|
|
File: gdb.info, Node: Create and Delete Tracepoints, Next: Enable and Disable Tracepoints, Up: Set Tracepoints
|
File: gdb.info, Node: Create and Delete Tracepoints, Next: Enable and Disable Tracepoints, Up: Set Tracepoints
|
|
|
13.1.1 Create and Delete Tracepoints
|
13.1.1 Create and Delete Tracepoints
|
------------------------------------
|
------------------------------------
|
|
|
`trace LOCATION'
|
`trace LOCATION'
|
The `trace' command is very similar to the `break' command. Its
|
The `trace' command is very similar to the `break' command. Its
|
argument LOCATION can be a source line, a function name, or an
|
argument LOCATION can be a source line, a function name, or an
|
address in the target program. *Note Specify Location::. The
|
address in the target program. *Note Specify Location::. The
|
`trace' command defines a tracepoint, which is a point in the
|
`trace' command defines a tracepoint, which is a point in the
|
target program where the debugger will briefly stop, collect some
|
target program where the debugger will briefly stop, collect some
|
data, and then allow the program to continue. Setting a
|
data, and then allow the program to continue. Setting a
|
tracepoint or changing its actions doesn't take effect until the
|
tracepoint or changing its actions doesn't take effect until the
|
next `tstart' command, and once a trace experiment is running,
|
next `tstart' command, and once a trace experiment is running,
|
further changes will not have any effect until the next trace
|
further changes will not have any effect until the next trace
|
experiment starts.
|
experiment starts.
|
|
|
Here are some examples of using the `trace' command:
|
Here are some examples of using the `trace' command:
|
|
|
(gdb) trace foo.c:121 // a source file and line number
|
(gdb) trace foo.c:121 // a source file and line number
|
|
|
(gdb) trace +2 // 2 lines forward
|
(gdb) trace +2 // 2 lines forward
|
|
|
(gdb) trace my_function // first source line of function
|
(gdb) trace my_function // first source line of function
|
|
|
(gdb) trace *my_function // EXACT start address of function
|
(gdb) trace *my_function // EXACT start address of function
|
|
|
(gdb) trace *0x2117c4 // an address
|
(gdb) trace *0x2117c4 // an address
|
|
|
You can abbreviate `trace' as `tr'.
|
You can abbreviate `trace' as `tr'.
|
|
|
`trace LOCATION if COND'
|
`trace LOCATION if COND'
|
Set a tracepoint with condition COND; evaluate the expression COND
|
Set a tracepoint with condition COND; evaluate the expression COND
|
each time the tracepoint is reached, and collect data only if the
|
each time the tracepoint is reached, and collect data only if the
|
value is nonzero--that is, if COND evaluates as true. *Note
|
value is nonzero--that is, if COND evaluates as true. *Note
|
Tracepoint Conditions: Tracepoint Conditions, for more information
|
Tracepoint Conditions: Tracepoint Conditions, for more information
|
on tracepoint conditions.
|
on tracepoint conditions.
|
|
|
`ftrace LOCATION [ if COND ]'
|
`ftrace LOCATION [ if COND ]'
|
The `ftrace' command sets a fast tracepoint. For targets that
|
The `ftrace' command sets a fast tracepoint. For targets that
|
support them, fast tracepoints will use a more efficient but
|
support them, fast tracepoints will use a more efficient but
|
possibly less general technique to trigger data collection, such
|
possibly less general technique to trigger data collection, such
|
as a jump instruction instead of a trap, or some sort of hardware
|
as a jump instruction instead of a trap, or some sort of hardware
|
support. It may not be possible to create a fast tracepoint at
|
support. It may not be possible to create a fast tracepoint at
|
the desired location, in which case the command will exit with an
|
the desired location, in which case the command will exit with an
|
explanatory message.
|
explanatory message.
|
|
|
GDB handles arguments to `ftrace' exactly as for `trace'.
|
GDB handles arguments to `ftrace' exactly as for `trace'.
|
|
|
`strace LOCATION [ if COND ]'
|
`strace LOCATION [ if COND ]'
|
The `strace' command sets a static tracepoint. For targets that
|
The `strace' command sets a static tracepoint. For targets that
|
support it, setting a static tracepoint probes a static
|
support it, setting a static tracepoint probes a static
|
instrumentation point, or marker, found at LOCATION. It may not
|
instrumentation point, or marker, found at LOCATION. It may not
|
be possible to set a static tracepoint at the desired location, in
|
be possible to set a static tracepoint at the desired location, in
|
which case the command will exit with an explanatory message.
|
which case the command will exit with an explanatory message.
|
|
|
GDB handles arguments to `strace' exactly as for `trace', with the
|
GDB handles arguments to `strace' exactly as for `trace', with the
|
addition that the user can also specify `-m MARKER' as LOCATION.
|
addition that the user can also specify `-m MARKER' as LOCATION.
|
This probes the marker identified by the MARKER string identifier.
|
This probes the marker identified by the MARKER string identifier.
|
This identifier depends on the static tracepoint backend library
|
This identifier depends on the static tracepoint backend library
|
your program is using. You can find all the marker identifiers in
|
your program is using. You can find all the marker identifiers in
|
the `ID' field of the `info static-tracepoint-markers' command
|
the `ID' field of the `info static-tracepoint-markers' command
|
output. *Note Listing Static Tracepoint Markers: Listing Static
|
output. *Note Listing Static Tracepoint Markers: Listing Static
|
Tracepoint Markers. For example, in the following small program
|
Tracepoint Markers. For example, in the following small program
|
using the UST tracing engine:
|
using the UST tracing engine:
|
|
|
main ()
|
main ()
|
{
|
{
|
trace_mark(ust, bar33, "str %s", "FOOBAZ");
|
trace_mark(ust, bar33, "str %s", "FOOBAZ");
|
}
|
}
|
|
|
the marker id is composed of joining the first two arguments to the
|
the marker id is composed of joining the first two arguments to the
|
`trace_mark' call with a slash, which translates to:
|
`trace_mark' call with a slash, which translates to:
|
|
|
(gdb) info static-tracepoint-markers
|
(gdb) info static-tracepoint-markers
|
Cnt Enb ID Address What
|
Cnt Enb ID Address What
|
1 n ust/bar33 0x0000000000400ddc in main at stexample.c:22
|
1 n ust/bar33 0x0000000000400ddc in main at stexample.c:22
|
Data: "str %s"
|
Data: "str %s"
|
[etc...]
|
[etc...]
|
|
|
so you may probe the marker above with:
|
so you may probe the marker above with:
|
|
|
(gdb) strace -m ust/bar33
|
(gdb) strace -m ust/bar33
|
|
|
Static tracepoints accept an extra collect action -- `collect
|
Static tracepoints accept an extra collect action -- `collect
|
$_sdata'. This collects arbitrary user data passed in the probe
|
$_sdata'. This collects arbitrary user data passed in the probe
|
point call to the tracing library. In the UST example above,
|
point call to the tracing library. In the UST example above,
|
you'll see that the third argument to `trace_mark' is a
|
you'll see that the third argument to `trace_mark' is a
|
printf-like format string. The user data is then the result of
|
printf-like format string. The user data is then the result of
|
running that formating string against the following arguments.
|
running that formating string against the following arguments.
|
Note that `info static-tracepoint-markers' command output lists
|
Note that `info static-tracepoint-markers' command output lists
|
that format string in the `Data:' field.
|
that format string in the `Data:' field.
|
|
|
You can inspect this data when analyzing the trace buffer, by
|
You can inspect this data when analyzing the trace buffer, by
|
printing the $_sdata variable like any other variable available to
|
printing the $_sdata variable like any other variable available to
|
GDB. *Note Tracepoint Action Lists: Tracepoint Actions.
|
GDB. *Note Tracepoint Action Lists: Tracepoint Actions.
|
|
|
The convenience variable `$tpnum' records the tracepoint number of
|
The convenience variable `$tpnum' records the tracepoint number of
|
the most recently set tracepoint.
|
the most recently set tracepoint.
|
|
|
`delete tracepoint [NUM]'
|
`delete tracepoint [NUM]'
|
Permanently delete one or more tracepoints. With no argument, the
|
Permanently delete one or more tracepoints. With no argument, the
|
default is to delete all tracepoints. Note that the regular
|
default is to delete all tracepoints. Note that the regular
|
`delete' command can remove tracepoints also.
|
`delete' command can remove tracepoints also.
|
|
|
Examples:
|
Examples:
|
|
|
(gdb) delete trace 1 2 3 // remove three tracepoints
|
(gdb) delete trace 1 2 3 // remove three tracepoints
|
|
|
(gdb) delete trace // remove all tracepoints
|
(gdb) delete trace // remove all tracepoints
|
|
|
You can abbreviate this command as `del tr'.
|
You can abbreviate this command as `del tr'.
|
|
|
|
|
File: gdb.info, Node: Enable and Disable Tracepoints, Next: Tracepoint Passcounts, Prev: Create and Delete Tracepoints, Up: Set Tracepoints
|
File: gdb.info, Node: Enable and Disable Tracepoints, Next: Tracepoint Passcounts, Prev: Create and Delete Tracepoints, Up: Set Tracepoints
|
|
|
13.1.2 Enable and Disable Tracepoints
|
13.1.2 Enable and Disable Tracepoints
|
-------------------------------------
|
-------------------------------------
|
|
|
These commands are deprecated; they are equivalent to plain `disable'
|
These commands are deprecated; they are equivalent to plain `disable'
|
and `enable'.
|
and `enable'.
|
|
|
`disable tracepoint [NUM]'
|
`disable tracepoint [NUM]'
|
Disable tracepoint NUM, or all tracepoints if no argument NUM is
|
Disable tracepoint NUM, or all tracepoints if no argument NUM is
|
given. A disabled tracepoint will have no effect during the next
|
given. A disabled tracepoint will have no effect during the next
|
trace experiment, but it is not forgotten. You can re-enable a
|
trace experiment, but it is not forgotten. You can re-enable a
|
disabled tracepoint using the `enable tracepoint' command.
|
disabled tracepoint using the `enable tracepoint' command.
|
|
|
`enable tracepoint [NUM]'
|
`enable tracepoint [NUM]'
|
Enable tracepoint NUM, or all tracepoints. The enabled
|
Enable tracepoint NUM, or all tracepoints. The enabled
|
tracepoints will become effective the next time a trace experiment
|
tracepoints will become effective the next time a trace experiment
|
is run.
|
is run.
|
|
|
|
|
File: gdb.info, Node: Tracepoint Passcounts, Next: Tracepoint Conditions, Prev: Enable and Disable Tracepoints, Up: Set Tracepoints
|
File: gdb.info, Node: Tracepoint Passcounts, Next: Tracepoint Conditions, Prev: Enable and Disable Tracepoints, Up: Set Tracepoints
|
|
|
13.1.3 Tracepoint Passcounts
|
13.1.3 Tracepoint Passcounts
|
----------------------------
|
----------------------------
|
|
|
`passcount [N [NUM]]'
|
`passcount [N [NUM]]'
|
Set the "passcount" of a tracepoint. The passcount is a way to
|
Set the "passcount" of a tracepoint. The passcount is a way to
|
automatically stop a trace experiment. If a tracepoint's
|
automatically stop a trace experiment. If a tracepoint's
|
passcount is N, then the trace experiment will be automatically
|
passcount is N, then the trace experiment will be automatically
|
stopped on the N'th time that tracepoint is hit. If the
|
stopped on the N'th time that tracepoint is hit. If the
|
tracepoint number NUM is not specified, the `passcount' command
|
tracepoint number NUM is not specified, the `passcount' command
|
sets the passcount of the most recently defined tracepoint. If no
|
sets the passcount of the most recently defined tracepoint. If no
|
passcount is given, the trace experiment will run until stopped
|
passcount is given, the trace experiment will run until stopped
|
explicitly by the user.
|
explicitly by the user.
|
|
|
Examples:
|
Examples:
|
|
|
(gdb) passcount 5 2 // Stop on the 5th execution of
|
(gdb) passcount 5 2 // Stop on the 5th execution of
|
`// tracepoint 2'
|
`// tracepoint 2'
|
|
|
(gdb) passcount 12 // Stop on the 12th execution of the
|
(gdb) passcount 12 // Stop on the 12th execution of the
|
`// most recently defined tracepoint.'
|
`// most recently defined tracepoint.'
|
(gdb) trace foo
|
(gdb) trace foo
|
(gdb) pass 3
|
(gdb) pass 3
|
(gdb) trace bar
|
(gdb) trace bar
|
(gdb) pass 2
|
(gdb) pass 2
|
(gdb) trace baz
|
(gdb) trace baz
|
(gdb) pass 1 // Stop tracing when foo has been
|
(gdb) pass 1 // Stop tracing when foo has been
|
`// executed 3 times OR when bar has'
|
`// executed 3 times OR when bar has'
|
`// been executed 2 times'
|
`// been executed 2 times'
|
`// OR when baz has been executed 1 time.'
|
`// OR when baz has been executed 1 time.'
|
|
|
|
|
|
|
File: gdb.info, Node: Tracepoint Conditions, Next: Trace State Variables, Prev: Tracepoint Passcounts, Up: Set Tracepoints
|
File: gdb.info, Node: Tracepoint Conditions, Next: Trace State Variables, Prev: Tracepoint Passcounts, Up: Set Tracepoints
|
|
|
13.1.4 Tracepoint Conditions
|
13.1.4 Tracepoint Conditions
|
----------------------------
|
----------------------------
|
|
|
The simplest sort of tracepoint collects data every time your program
|
The simplest sort of tracepoint collects data every time your program
|
reaches a specified place. You can also specify a "condition" for a
|
reaches a specified place. You can also specify a "condition" for a
|
tracepoint. A condition is just a Boolean expression in your
|
tracepoint. A condition is just a Boolean expression in your
|
programming language (*note Expressions: Expressions.). A tracepoint
|
programming language (*note Expressions: Expressions.). A tracepoint
|
with a condition evaluates the expression each time your program
|
with a condition evaluates the expression each time your program
|
reaches it, and data collection happens only if the condition is true.
|
reaches it, and data collection happens only if the condition is true.
|
|
|
Tracepoint conditions can be specified when a tracepoint is set, by
|
Tracepoint conditions can be specified when a tracepoint is set, by
|
using `if' in the arguments to the `trace' command. *Note Setting
|
using `if' in the arguments to the `trace' command. *Note Setting
|
Tracepoints: Create and Delete Tracepoints. They can also be set or
|
Tracepoints: Create and Delete Tracepoints. They can also be set or
|
changed at any time with the `condition' command, just as with
|
changed at any time with the `condition' command, just as with
|
breakpoints.
|
breakpoints.
|
|
|
Unlike breakpoint conditions, GDB does not actually evaluate the
|
Unlike breakpoint conditions, GDB does not actually evaluate the
|
conditional expression itself. Instead, GDB encodes the expression
|
conditional expression itself. Instead, GDB encodes the expression
|
into an agent expression (*note Agent Expressions:: suitable for
|
into an agent expression (*note Agent Expressions:: suitable for
|
execution on the target, independently of GDB. Global variables become
|
execution on the target, independently of GDB. Global variables become
|
raw memory locations, locals become stack accesses, and so forth.
|
raw memory locations, locals become stack accesses, and so forth.
|
|
|
For instance, suppose you have a function that is usually called
|
For instance, suppose you have a function that is usually called
|
frequently, but should not be called after an error has occurred. You
|
frequently, but should not be called after an error has occurred. You
|
could use the following tracepoint command to collect data about calls
|
could use the following tracepoint command to collect data about calls
|
of that function that happen while the error code is propagating
|
of that function that happen while the error code is propagating
|
through the program; an unconditional tracepoint could end up
|
through the program; an unconditional tracepoint could end up
|
collecting thousands of useless trace frames that you would have to
|
collecting thousands of useless trace frames that you would have to
|
search through.
|
search through.
|
|
|
(gdb) trace normal_operation if errcode > 0
|
(gdb) trace normal_operation if errcode > 0
|
|
|
|
|
File: gdb.info, Node: Trace State Variables, Next: Tracepoint Actions, Prev: Tracepoint Conditions, Up: Set Tracepoints
|
File: gdb.info, Node: Trace State Variables, Next: Tracepoint Actions, Prev: Tracepoint Conditions, Up: Set Tracepoints
|
|
|
13.1.5 Trace State Variables
|
13.1.5 Trace State Variables
|
----------------------------
|
----------------------------
|
|
|
A "trace state variable" is a special type of variable that is created
|
A "trace state variable" is a special type of variable that is created
|
and managed by target-side code. The syntax is the same as that for
|
and managed by target-side code. The syntax is the same as that for
|
GDB's convenience variables (a string prefixed with "$"), but they are
|
GDB's convenience variables (a string prefixed with "$"), but they are
|
stored on the target. They must be created explicitly, using a
|
stored on the target. They must be created explicitly, using a
|
`tvariable' command. They are always 64-bit signed integers.
|
`tvariable' command. They are always 64-bit signed integers.
|
|
|
Trace state variables are remembered by GDB, and downloaded to the
|
Trace state variables are remembered by GDB, and downloaded to the
|
target along with tracepoint information when the trace experiment
|
target along with tracepoint information when the trace experiment
|
starts. There are no intrinsic limits on the number of trace state
|
starts. There are no intrinsic limits on the number of trace state
|
variables, beyond memory limitations of the target.
|
variables, beyond memory limitations of the target.
|
|
|
Although trace state variables are managed by the target, you can use
|
Although trace state variables are managed by the target, you can use
|
them in print commands and expressions as if they were convenience
|
them in print commands and expressions as if they were convenience
|
variables; GDB will get the current value from the target while the
|
variables; GDB will get the current value from the target while the
|
trace experiment is running. Trace state variables share the same
|
trace experiment is running. Trace state variables share the same
|
namespace as other "$" variables, which means that you cannot have
|
namespace as other "$" variables, which means that you cannot have
|
trace state variables with names like `$23' or `$pc', nor can you have
|
trace state variables with names like `$23' or `$pc', nor can you have
|
a trace state variable and a convenience variable with the same name.
|
a trace state variable and a convenience variable with the same name.
|
|
|
`tvariable $NAME [ = EXPRESSION ]'
|
`tvariable $NAME [ = EXPRESSION ]'
|
The `tvariable' command creates a new trace state variable named
|
The `tvariable' command creates a new trace state variable named
|
`$NAME', and optionally gives it an initial value of EXPRESSION.
|
`$NAME', and optionally gives it an initial value of EXPRESSION.
|
EXPRESSION is evaluated when this command is entered; the result
|
EXPRESSION is evaluated when this command is entered; the result
|
will be converted to an integer if possible, otherwise GDB will
|
will be converted to an integer if possible, otherwise GDB will
|
report an error. A subsequent `tvariable' command specifying the
|
report an error. A subsequent `tvariable' command specifying the
|
same name does not create a variable, but instead assigns the
|
same name does not create a variable, but instead assigns the
|
supplied initial value to the existing variable of that name,
|
supplied initial value to the existing variable of that name,
|
overwriting any previous initial value. The default initial value
|
overwriting any previous initial value. The default initial value
|
is 0.
|
is 0.
|
|
|
`info tvariables'
|
`info tvariables'
|
List all the trace state variables along with their initial values.
|
List all the trace state variables along with their initial values.
|
Their current values may also be displayed, if the trace
|
Their current values may also be displayed, if the trace
|
experiment is currently running.
|
experiment is currently running.
|
|
|
`delete tvariable [ $NAME ... ]'
|
`delete tvariable [ $NAME ... ]'
|
Delete the given trace state variables, or all of them if no
|
Delete the given trace state variables, or all of them if no
|
arguments are specified.
|
arguments are specified.
|
|
|
|
|
|
|
File: gdb.info, Node: Tracepoint Actions, Next: Listing Tracepoints, Prev: Trace State Variables, Up: Set Tracepoints
|
File: gdb.info, Node: Tracepoint Actions, Next: Listing Tracepoints, Prev: Trace State Variables, Up: Set Tracepoints
|
|
|
13.1.6 Tracepoint Action Lists
|
13.1.6 Tracepoint Action Lists
|
------------------------------
|
------------------------------
|
|
|
`actions [NUM]'
|
`actions [NUM]'
|
This command will prompt for a list of actions to be taken when the
|
This command will prompt for a list of actions to be taken when the
|
tracepoint is hit. If the tracepoint number NUM is not specified,
|
tracepoint is hit. If the tracepoint number NUM is not specified,
|
this command sets the actions for the one that was most recently
|
this command sets the actions for the one that was most recently
|
defined (so that you can define a tracepoint and then say
|
defined (so that you can define a tracepoint and then say
|
`actions' without bothering about its number). You specify the
|
`actions' without bothering about its number). You specify the
|
actions themselves on the following lines, one action at a time,
|
actions themselves on the following lines, one action at a time,
|
and terminate the actions list with a line containing just `end'.
|
and terminate the actions list with a line containing just `end'.
|
So far, the only defined actions are `collect', `teval', and
|
So far, the only defined actions are `collect', `teval', and
|
`while-stepping'.
|
`while-stepping'.
|
|
|
`actions' is actually equivalent to `commands' (*note Breakpoint
|
`actions' is actually equivalent to `commands' (*note Breakpoint
|
Command Lists: Break Commands.), except that only the defined
|
Command Lists: Break Commands.), except that only the defined
|
actions are allowed; any other GDB command is rejected.
|
actions are allowed; any other GDB command is rejected.
|
|
|
To remove all actions from a tracepoint, type `actions NUM' and
|
To remove all actions from a tracepoint, type `actions NUM' and
|
follow it immediately with `end'.
|
follow it immediately with `end'.
|
|
|
(gdb) collect DATA // collect some data
|
(gdb) collect DATA // collect some data
|
|
|
(gdb) while-stepping 5 // single-step 5 times, collect data
|
(gdb) while-stepping 5 // single-step 5 times, collect data
|
|
|
(gdb) end // signals the end of actions.
|
(gdb) end // signals the end of actions.
|
|
|
In the following example, the action list begins with `collect'
|
In the following example, the action list begins with `collect'
|
commands indicating the things to be collected when the tracepoint
|
commands indicating the things to be collected when the tracepoint
|
is hit. Then, in order to single-step and collect additional data
|
is hit. Then, in order to single-step and collect additional data
|
following the tracepoint, a `while-stepping' command is used,
|
following the tracepoint, a `while-stepping' command is used,
|
followed by the list of things to be collected after each step in a
|
followed by the list of things to be collected after each step in a
|
sequence of single steps. The `while-stepping' command is
|
sequence of single steps. The `while-stepping' command is
|
terminated by its own separate `end' command. Lastly, the action
|
terminated by its own separate `end' command. Lastly, the action
|
list is terminated by an `end' command.
|
list is terminated by an `end' command.
|
|
|
(gdb) trace foo
|
(gdb) trace foo
|
(gdb) actions
|
(gdb) actions
|
Enter actions for tracepoint 1, one per line:
|
Enter actions for tracepoint 1, one per line:
|
> collect bar,baz
|
> collect bar,baz
|
> collect $regs
|
> collect $regs
|
> while-stepping 12
|
> while-stepping 12
|
> collect $pc, arr[i]
|
> collect $pc, arr[i]
|
> end
|
> end
|
end
|
end
|
|
|
`collect EXPR1, EXPR2, ...'
|
`collect EXPR1, EXPR2, ...'
|
Collect values of the given expressions when the tracepoint is hit.
|
Collect values of the given expressions when the tracepoint is hit.
|
This command accepts a comma-separated list of any valid
|
This command accepts a comma-separated list of any valid
|
expressions. In addition to global, static, or local variables,
|
expressions. In addition to global, static, or local variables,
|
the following special arguments are supported:
|
the following special arguments are supported:
|
|
|
`$regs'
|
`$regs'
|
Collect all registers.
|
Collect all registers.
|
|
|
`$args'
|
`$args'
|
Collect all function arguments.
|
Collect all function arguments.
|
|
|
`$locals'
|
`$locals'
|
Collect all local variables.
|
Collect all local variables.
|
|
|
`$_sdata'
|
`$_sdata'
|
Collect static tracepoint marker specific data. Only
|
Collect static tracepoint marker specific data. Only
|
available for static tracepoints. *Note Tracepoint Action
|
available for static tracepoints. *Note Tracepoint Action
|
Lists: Tracepoint Actions. On the UST static tracepoints
|
Lists: Tracepoint Actions. On the UST static tracepoints
|
library backend, an instrumentation point resembles a
|
library backend, an instrumentation point resembles a
|
`printf' function call. The tracing library is able to
|
`printf' function call. The tracing library is able to
|
collect user specified data formatted to a character string
|
collect user specified data formatted to a character string
|
using the format provided by the programmer that instrumented
|
using the format provided by the programmer that instrumented
|
the program. Other backends have similar mechanisms. Here's
|
the program. Other backends have similar mechanisms. Here's
|
an example of a UST marker call:
|
an example of a UST marker call:
|
|
|
const char master_name[] = "$your_name";
|
const char master_name[] = "$your_name";
|
trace_mark(channel1, marker1, "hello %s", master_name)
|
trace_mark(channel1, marker1, "hello %s", master_name)
|
|
|
In this case, collecting `$_sdata' collects the string `hello
|
In this case, collecting `$_sdata' collects the string `hello
|
$yourname'. When analyzing the trace buffer, you can inspect
|
$yourname'. When analyzing the trace buffer, you can inspect
|
`$_sdata' like any other variable available to GDB.
|
`$_sdata' like any other variable available to GDB.
|
|
|
You can give several consecutive `collect' commands, each one with
|
You can give several consecutive `collect' commands, each one with
|
a single argument, or one `collect' command with several arguments
|
a single argument, or one `collect' command with several arguments
|
separated by commas; the effect is the same.
|
separated by commas; the effect is the same.
|
|
|
The command `info scope' (*note info scope: Symbols.) is
|
The command `info scope' (*note info scope: Symbols.) is
|
particularly useful for figuring out what data to collect.
|
particularly useful for figuring out what data to collect.
|
|
|
`teval EXPR1, EXPR2, ...'
|
`teval EXPR1, EXPR2, ...'
|
Evaluate the given expressions when the tracepoint is hit. This
|
Evaluate the given expressions when the tracepoint is hit. This
|
command accepts a comma-separated list of expressions. The results
|
command accepts a comma-separated list of expressions. The results
|
are discarded, so this is mainly useful for assigning values to
|
are discarded, so this is mainly useful for assigning values to
|
trace state variables (*note Trace State Variables::) without
|
trace state variables (*note Trace State Variables::) without
|
adding those values to the trace buffer, as would be the case if
|
adding those values to the trace buffer, as would be the case if
|
the `collect' action were used.
|
the `collect' action were used.
|
|
|
`while-stepping N'
|
`while-stepping N'
|
Perform N single-step instruction traces after the tracepoint,
|
Perform N single-step instruction traces after the tracepoint,
|
collecting new data after each step. The `while-stepping' command
|
collecting new data after each step. The `while-stepping' command
|
is followed by the list of what to collect while stepping
|
is followed by the list of what to collect while stepping
|
(followed by its own `end' command):
|
(followed by its own `end' command):
|
|
|
> while-stepping 12
|
> while-stepping 12
|
> collect $regs, myglobal
|
> collect $regs, myglobal
|
> end
|
> end
|
>
|
>
|
|
|
Note that `$pc' is not automatically collected by
|
Note that `$pc' is not automatically collected by
|
`while-stepping'; you need to explicitly collect that register if
|
`while-stepping'; you need to explicitly collect that register if
|
you need it. You may abbreviate `while-stepping' as `ws' or
|
you need it. You may abbreviate `while-stepping' as `ws' or
|
`stepping'.
|
`stepping'.
|
|
|
`set default-collect EXPR1, EXPR2, ...'
|
`set default-collect EXPR1, EXPR2, ...'
|
This variable is a list of expressions to collect at each
|
This variable is a list of expressions to collect at each
|
tracepoint hit. It is effectively an additional `collect' action
|
tracepoint hit. It is effectively an additional `collect' action
|
prepended to every tracepoint action list. The expressions are
|
prepended to every tracepoint action list. The expressions are
|
parsed individually for each tracepoint, so for instance a
|
parsed individually for each tracepoint, so for instance a
|
variable named `xyz' may be interpreted as a global for one
|
variable named `xyz' may be interpreted as a global for one
|
tracepoint, and a local for another, as appropriate to the
|
tracepoint, and a local for another, as appropriate to the
|
tracepoint's location.
|
tracepoint's location.
|
|
|
`show default-collect'
|
`show default-collect'
|
Show the list of expressions that are collected by default at each
|
Show the list of expressions that are collected by default at each
|
tracepoint hit.
|
tracepoint hit.
|
|
|
|
|
|
|
File: gdb.info, Node: Listing Tracepoints, Next: Listing Static Tracepoint Markers, Prev: Tracepoint Actions, Up: Set Tracepoints
|
File: gdb.info, Node: Listing Tracepoints, Next: Listing Static Tracepoint Markers, Prev: Tracepoint Actions, Up: Set Tracepoints
|
|
|
13.1.7 Listing Tracepoints
|
13.1.7 Listing Tracepoints
|
--------------------------
|
--------------------------
|
|
|
`info tracepoints [NUM]'
|
`info tracepoints [NUM]'
|
Display information about the tracepoint NUM. If you don't
|
Display information about the tracepoint NUM. If you don't
|
specify a tracepoint number, displays information about all the
|
specify a tracepoint number, displays information about all the
|
tracepoints defined so far. The format is similar to that used for
|
tracepoints defined so far. The format is similar to that used for
|
`info breakpoints'; in fact, `info tracepoints' is the same
|
`info breakpoints'; in fact, `info tracepoints' is the same
|
command, simply restricting itself to tracepoints.
|
command, simply restricting itself to tracepoints.
|
|
|
A tracepoint's listing may include additional information specific
|
A tracepoint's listing may include additional information specific
|
to tracing:
|
to tracing:
|
|
|
* its passcount as given by the `passcount N' command
|
* its passcount as given by the `passcount N' command
|
|
|
(gdb) info trace
|
(gdb) info trace
|
Num Type Disp Enb Address What
|
Num Type Disp Enb Address What
|
1 tracepoint keep y 0x0804ab57 in foo() at main.cxx:7
|
1 tracepoint keep y 0x0804ab57 in foo() at main.cxx:7
|
while-stepping 20
|
while-stepping 20
|
collect globfoo, $regs
|
collect globfoo, $regs
|
end
|
end
|
collect globfoo2
|
collect globfoo2
|
end
|
end
|
pass count 1200
|
pass count 1200
|
(gdb)
|
(gdb)
|
|
|
This command can be abbreviated `info tp'.
|
This command can be abbreviated `info tp'.
|
|
|
|
|
File: gdb.info, Node: Listing Static Tracepoint Markers, Next: Starting and Stopping Trace Experiments, Prev: Listing Tracepoints, Up: Set Tracepoints
|
File: gdb.info, Node: Listing Static Tracepoint Markers, Next: Starting and Stopping Trace Experiments, Prev: Listing Tracepoints, Up: Set Tracepoints
|
|
|
13.1.8 Listing Static Tracepoint Markers
|
13.1.8 Listing Static Tracepoint Markers
|
----------------------------------------
|
----------------------------------------
|
|
|
`info static-tracepoint-markers'
|
`info static-tracepoint-markers'
|
Display information about all static tracepoint markers defined in
|
Display information about all static tracepoint markers defined in
|
the program.
|
the program.
|
|
|
For each marker, the following columns are printed:
|
For each marker, the following columns are printed:
|
|
|
_Count_
|
_Count_
|
An incrementing counter, output to help readability. This is
|
An incrementing counter, output to help readability. This is
|
not a stable identifier.
|
not a stable identifier.
|
|
|
_ID_
|
_ID_
|
The marker ID, as reported by the target.
|
The marker ID, as reported by the target.
|
|
|
_Enabled or Disabled_
|
_Enabled or Disabled_
|
Probed markers are tagged with `y'. `n' identifies marks
|
Probed markers are tagged with `y'. `n' identifies marks
|
that are not enabled.
|
that are not enabled.
|
|
|
_Address_
|
_Address_
|
Where the marker is in your program, as a memory address.
|
Where the marker is in your program, as a memory address.
|
|
|
_What_
|
_What_
|
Where the marker is in the source for your program, as a file
|
Where the marker is in the source for your program, as a file
|
and line number. If the debug information included in the
|
and line number. If the debug information included in the
|
program does not allow GDB to locate the source of the
|
program does not allow GDB to locate the source of the
|
marker, this column will be left blank.
|
marker, this column will be left blank.
|
|
|
In addition, the following information may be printed for each
|
In addition, the following information may be printed for each
|
marker:
|
marker:
|
|
|
_Data_
|
_Data_
|
User data passed to the tracing library by the marker call.
|
User data passed to the tracing library by the marker call.
|
In the UST backend, this is the format string passed as
|
In the UST backend, this is the format string passed as
|
argument to the marker call.
|
argument to the marker call.
|
|
|
_Static tracepoints probing the marker_
|
_Static tracepoints probing the marker_
|
The list of static tracepoints attached to the marker.
|
The list of static tracepoints attached to the marker.
|
|
|
(gdb) info static-tracepoint-markers
|
(gdb) info static-tracepoint-markers
|
Cnt ID Enb Address What
|
Cnt ID Enb Address What
|
1 ust/bar2 y 0x0000000000400e1a in main at stexample.c:25
|
1 ust/bar2 y 0x0000000000400e1a in main at stexample.c:25
|
Data: number1 %d number2 %d
|
Data: number1 %d number2 %d
|
Probed by static tracepoints: #2
|
Probed by static tracepoints: #2
|
2 ust/bar33 n 0x0000000000400c87 in main at stexample.c:24
|
2 ust/bar33 n 0x0000000000400c87 in main at stexample.c:24
|
Data: str %s
|
Data: str %s
|
(gdb)
|
(gdb)
|
|
|
|
|
File: gdb.info, Node: Starting and Stopping Trace Experiments, Next: Tracepoint Restrictions, Prev: Listing Static Tracepoint Markers, Up: Set Tracepoints
|
File: gdb.info, Node: Starting and Stopping Trace Experiments, Next: Tracepoint Restrictions, Prev: Listing Static Tracepoint Markers, Up: Set Tracepoints
|
|
|
13.1.9 Starting and Stopping Trace Experiments
|
13.1.9 Starting and Stopping Trace Experiments
|
----------------------------------------------
|
----------------------------------------------
|
|
|
`tstart'
|
`tstart'
|
This command takes no arguments. It starts the trace experiment,
|
This command takes no arguments. It starts the trace experiment,
|
and begins collecting data. This has the side effect of
|
and begins collecting data. This has the side effect of
|
discarding all the data collected in the trace buffer during the
|
discarding all the data collected in the trace buffer during the
|
previous trace experiment.
|
previous trace experiment.
|
|
|
`tstop'
|
`tstop'
|
This command takes no arguments. It ends the trace experiment, and
|
This command takes no arguments. It ends the trace experiment, and
|
stops collecting data.
|
stops collecting data.
|
|
|
*Note*: a trace experiment and data collection may stop
|
*Note*: a trace experiment and data collection may stop
|
automatically if any tracepoint's passcount is reached (*note
|
automatically if any tracepoint's passcount is reached (*note
|
Tracepoint Passcounts::), or if the trace buffer becomes full.
|
Tracepoint Passcounts::), or if the trace buffer becomes full.
|
|
|
`tstatus'
|
`tstatus'
|
This command displays the status of the current trace data
|
This command displays the status of the current trace data
|
collection.
|
collection.
|
|
|
Here is an example of the commands we described so far:
|
Here is an example of the commands we described so far:
|
|
|
(gdb) trace gdb_c_test
|
(gdb) trace gdb_c_test
|
(gdb) actions
|
(gdb) actions
|
Enter actions for tracepoint #1, one per line.
|
Enter actions for tracepoint #1, one per line.
|
> collect $regs,$locals,$args
|
> collect $regs,$locals,$args
|
> while-stepping 11
|
> while-stepping 11
|
> collect $regs
|
> collect $regs
|
> end
|
> end
|
> end
|
> end
|
(gdb) tstart
|
(gdb) tstart
|
[time passes ...]
|
[time passes ...]
|
(gdb) tstop
|
(gdb) tstop
|
|
|
You can choose to continue running the trace experiment even if GDB
|
You can choose to continue running the trace experiment even if GDB
|
disconnects from the target, voluntarily or involuntarily. For
|
disconnects from the target, voluntarily or involuntarily. For
|
commands such as `detach', the debugger will ask what you want to do
|
commands such as `detach', the debugger will ask what you want to do
|
with the trace. But for unexpected terminations (GDB crash, network
|
with the trace. But for unexpected terminations (GDB crash, network
|
outage), it would be unfortunate to lose hard-won trace data, so the
|
outage), it would be unfortunate to lose hard-won trace data, so the
|
variable `disconnected-tracing' lets you decide whether the trace should
|
variable `disconnected-tracing' lets you decide whether the trace should
|
continue running without GDB.
|
continue running without GDB.
|
|
|
`set disconnected-tracing on'
|
`set disconnected-tracing on'
|
`set disconnected-tracing off'
|
`set disconnected-tracing off'
|
Choose whether a tracing run should continue to run if GDB has
|
Choose whether a tracing run should continue to run if GDB has
|
disconnected from the target. Note that `detach' or `quit' will
|
disconnected from the target. Note that `detach' or `quit' will
|
ask you directly what to do about a running trace no matter what
|
ask you directly what to do about a running trace no matter what
|
this variable's setting, so the variable is mainly useful for
|
this variable's setting, so the variable is mainly useful for
|
handling unexpected situations, such as loss of the network.
|
handling unexpected situations, such as loss of the network.
|
|
|
`show disconnected-tracing'
|
`show disconnected-tracing'
|
Show the current choice for disconnected tracing.
|
Show the current choice for disconnected tracing.
|
|
|
|
|
When you reconnect to the target, the trace experiment may or may not
|
When you reconnect to the target, the trace experiment may or may not
|
still be running; it might have filled the trace buffer in the
|
still be running; it might have filled the trace buffer in the
|
meantime, or stopped for one of the other reasons. If it is running,
|
meantime, or stopped for one of the other reasons. If it is running,
|
it will continue after reconnection.
|
it will continue after reconnection.
|
|
|
Upon reconnection, the target will upload information about the
|
Upon reconnection, the target will upload information about the
|
tracepoints in effect. GDB will then compare that information to the
|
tracepoints in effect. GDB will then compare that information to the
|
set of tracepoints currently defined, and attempt to match them up,
|
set of tracepoints currently defined, and attempt to match them up,
|
allowing for the possibility that the numbers may have changed due to
|
allowing for the possibility that the numbers may have changed due to
|
creation and deletion in the meantime. If one of the target's
|
creation and deletion in the meantime. If one of the target's
|
tracepoints does not match any in GDB, the debugger will create a new
|
tracepoints does not match any in GDB, the debugger will create a new
|
tracepoint, so that you have a number with which to specify that
|
tracepoint, so that you have a number with which to specify that
|
tracepoint. This matching-up process is necessarily heuristic, and it
|
tracepoint. This matching-up process is necessarily heuristic, and it
|
may result in useless tracepoints being created; you may simply delete
|
may result in useless tracepoints being created; you may simply delete
|
them if they are of no use.
|
them if they are of no use.
|
|
|
If your target agent supports a "circular trace buffer", then you
|
If your target agent supports a "circular trace buffer", then you
|
can run a trace experiment indefinitely without filling the trace
|
can run a trace experiment indefinitely without filling the trace
|
buffer; when space runs out, the agent deletes already-collected trace
|
buffer; when space runs out, the agent deletes already-collected trace
|
frames, oldest first, until there is enough room to continue
|
frames, oldest first, until there is enough room to continue
|
collecting. This is especially useful if your tracepoints are being
|
collecting. This is especially useful if your tracepoints are being
|
hit too often, and your trace gets terminated prematurely because the
|
hit too often, and your trace gets terminated prematurely because the
|
buffer is full. To ask for a circular trace buffer, simply set
|
buffer is full. To ask for a circular trace buffer, simply set
|
`circular_trace_buffer' to on. You can set this at any time, including
|
`circular_trace_buffer' to on. You can set this at any time, including
|
during tracing; if the agent can do it, it will change buffer handling
|
during tracing; if the agent can do it, it will change buffer handling
|
on the fly, otherwise it will not take effect until the next run.
|
on the fly, otherwise it will not take effect until the next run.
|
|
|
`set circular-trace-buffer on'
|
`set circular-trace-buffer on'
|
`set circular-trace-buffer off'
|
`set circular-trace-buffer off'
|
Choose whether a tracing run should use a linear or circular buffer
|
Choose whether a tracing run should use a linear or circular buffer
|
for trace data. A linear buffer will not lose any trace data, but
|
for trace data. A linear buffer will not lose any trace data, but
|
may fill up prematurely, while a circular buffer will discard old
|
may fill up prematurely, while a circular buffer will discard old
|
trace data, but it will have always room for the latest tracepoint
|
trace data, but it will have always room for the latest tracepoint
|
hits.
|
hits.
|
|
|
`show circular-trace-buffer'
|
`show circular-trace-buffer'
|
Show the current choice for the trace buffer. Note that this may
|
Show the current choice for the trace buffer. Note that this may
|
not match the agent's current buffer handling, nor is it
|
not match the agent's current buffer handling, nor is it
|
guaranteed to match the setting that might have been in effect
|
guaranteed to match the setting that might have been in effect
|
during a past run, for instance if you are looking at frames from
|
during a past run, for instance if you are looking at frames from
|
a trace file.
|
a trace file.
|
|
|
|
|
|
|
File: gdb.info, Node: Tracepoint Restrictions, Prev: Starting and Stopping Trace Experiments, Up: Set Tracepoints
|
File: gdb.info, Node: Tracepoint Restrictions, Prev: Starting and Stopping Trace Experiments, Up: Set Tracepoints
|
|
|
13.1.10 Tracepoint Restrictions
|
13.1.10 Tracepoint Restrictions
|
-------------------------------
|
-------------------------------
|
|
|
There are a number of restrictions on the use of tracepoints. As
|
There are a number of restrictions on the use of tracepoints. As
|
described above, tracepoint data gathering occurs on the target without
|
described above, tracepoint data gathering occurs on the target without
|
interaction from GDB. Thus the full capabilities of the debugger are
|
interaction from GDB. Thus the full capabilities of the debugger are
|
not available during data gathering, and then at data examination time,
|
not available during data gathering, and then at data examination time,
|
you will be limited by only having what was collected. The following
|
you will be limited by only having what was collected. The following
|
items describe some common problems, but it is not exhaustive, and you
|
items describe some common problems, but it is not exhaustive, and you
|
may run into additional difficulties not mentioned here.
|
may run into additional difficulties not mentioned here.
|
|
|
* Tracepoint expressions are intended to gather objects (lvalues).
|
* Tracepoint expressions are intended to gather objects (lvalues).
|
Thus the full flexibility of GDB's expression evaluator is not
|
Thus the full flexibility of GDB's expression evaluator is not
|
available. You cannot call functions, cast objects to aggregate
|
available. You cannot call functions, cast objects to aggregate
|
types, access convenience variables or modify values (except by
|
types, access convenience variables or modify values (except by
|
assignment to trace state variables). Some language features may
|
assignment to trace state variables). Some language features may
|
implicitly call functions (for instance Objective-C fields with
|
implicitly call functions (for instance Objective-C fields with
|
accessors), and therefore cannot be collected either.
|
accessors), and therefore cannot be collected either.
|
|
|
* Collection of local variables, either individually or in bulk with
|
* Collection of local variables, either individually or in bulk with
|
`$locals' or `$args', during `while-stepping' may behave
|
`$locals' or `$args', during `while-stepping' may behave
|
erratically. The stepping action may enter a new scope (for
|
erratically. The stepping action may enter a new scope (for
|
instance by stepping into a function), or the location of the
|
instance by stepping into a function), or the location of the
|
variable may change (for instance it is loaded into a register).
|
variable may change (for instance it is loaded into a register).
|
The tracepoint data recorded uses the location information for the
|
The tracepoint data recorded uses the location information for the
|
variables that is correct for the tracepoint location. When the
|
variables that is correct for the tracepoint location. When the
|
tracepoint is created, it is not possible, in general, to determine
|
tracepoint is created, it is not possible, in general, to determine
|
where the steps of a `while-stepping' sequence will advance the
|
where the steps of a `while-stepping' sequence will advance the
|
program--particularly if a conditional branch is stepped.
|
program--particularly if a conditional branch is stepped.
|
|
|
* Collection of an incompletely-initialized or partially-destroyed
|
* Collection of an incompletely-initialized or partially-destroyed
|
object may result in something that GDB cannot display, or displays
|
object may result in something that GDB cannot display, or displays
|
in a misleading way.
|
in a misleading way.
|
|
|
* When GDB displays a pointer to character it automatically
|
* When GDB displays a pointer to character it automatically
|
dereferences the pointer to also display characters of the string
|
dereferences the pointer to also display characters of the string
|
being pointed to. However, collecting the pointer during tracing
|
being pointed to. However, collecting the pointer during tracing
|
does not automatically collect the string. You need to explicitly
|
does not automatically collect the string. You need to explicitly
|
dereference the pointer and provide size information if you want to
|
dereference the pointer and provide size information if you want to
|
collect not only the pointer, but the memory pointed to. For
|
collect not only the pointer, but the memory pointed to. For
|
example, `*ptr@50' can be used to collect the 50 element array
|
example, `*ptr@50' can be used to collect the 50 element array
|
pointed to by `ptr'.
|
pointed to by `ptr'.
|
|
|
* It is not possible to collect a complete stack backtrace at a
|
* It is not possible to collect a complete stack backtrace at a
|
tracepoint. Instead, you may collect the registers and a few
|
tracepoint. Instead, you may collect the registers and a few
|
hundred bytes from the stack pointer with something like
|
hundred bytes from the stack pointer with something like
|
`*$esp@300' (adjust to use the name of the actual stack pointer
|
`*$esp@300' (adjust to use the name of the actual stack pointer
|
register on your target architecture, and the amount of stack you
|
register on your target architecture, and the amount of stack you
|
wish to capture). Then the `backtrace' command will show a
|
wish to capture). Then the `backtrace' command will show a
|
partial backtrace when using a trace frame. The number of stack
|
partial backtrace when using a trace frame. The number of stack
|
frames that can be examined depends on the sizes of the frames in
|
frames that can be examined depends on the sizes of the frames in
|
the collected stack. Note that if you ask for a block so large
|
the collected stack. Note that if you ask for a block so large
|
that it goes past the bottom of the stack, the target agent may
|
that it goes past the bottom of the stack, the target agent may
|
report an error trying to read from an invalid address.
|
report an error trying to read from an invalid address.
|
|
|
* If you do not collect registers at a tracepoint, GDB can infer
|
* If you do not collect registers at a tracepoint, GDB can infer
|
that the value of `$pc' must be the same as the address of the
|
that the value of `$pc' must be the same as the address of the
|
tracepoint and use that when you are looking at a trace frame for
|
tracepoint and use that when you are looking at a trace frame for
|
that tracepoint. However, this cannot work if the tracepoint has
|
that tracepoint. However, this cannot work if the tracepoint has
|
multiple locations (for instance if it was set in a function that
|
multiple locations (for instance if it was set in a function that
|
was inlined), or if it has a `while-stepping' loop. In those cases
|
was inlined), or if it has a `while-stepping' loop. In those cases
|
GDB will warn you that it can't infer `$pc', and default it to
|
GDB will warn you that it can't infer `$pc', and default it to
|
zero.
|
zero.
|
|
|
|
|
|
|
File: gdb.info, Node: Analyze Collected Data, Next: Tracepoint Variables, Prev: Set Tracepoints, Up: Tracepoints
|
File: gdb.info, Node: Analyze Collected Data, Next: Tracepoint Variables, Prev: Set Tracepoints, Up: Tracepoints
|
|
|
13.2 Using the Collected Data
|
13.2 Using the Collected Data
|
=============================
|
=============================
|
|
|
After the tracepoint experiment ends, you use GDB commands for
|
After the tracepoint experiment ends, you use GDB commands for
|
examining the trace data. The basic idea is that each tracepoint
|
examining the trace data. The basic idea is that each tracepoint
|
collects a trace "snapshot" every time it is hit and another snapshot
|
collects a trace "snapshot" every time it is hit and another snapshot
|
every time it single-steps. All these snapshots are consecutively
|
every time it single-steps. All these snapshots are consecutively
|
numbered from zero and go into a buffer, and you can examine them
|
numbered from zero and go into a buffer, and you can examine them
|
later. The way you examine them is to "focus" on a specific trace
|
later. The way you examine them is to "focus" on a specific trace
|
snapshot. When the remote stub is focused on a trace snapshot, it will
|
snapshot. When the remote stub is focused on a trace snapshot, it will
|
respond to all GDB requests for memory and registers by reading from
|
respond to all GDB requests for memory and registers by reading from
|
the buffer which belongs to that snapshot, rather than from _real_
|
the buffer which belongs to that snapshot, rather than from _real_
|
memory or registers of the program being debugged. This means that
|
memory or registers of the program being debugged. This means that
|
*all* GDB commands (`print', `info registers', `backtrace', etc.) will
|
*all* GDB commands (`print', `info registers', `backtrace', etc.) will
|
behave as if we were currently debugging the program state as it was
|
behave as if we were currently debugging the program state as it was
|
when the tracepoint occurred. Any requests for data that are not in
|
when the tracepoint occurred. Any requests for data that are not in
|
the buffer will fail.
|
the buffer will fail.
|
|
|
* Menu:
|
* Menu:
|
|
|
* tfind:: How to select a trace snapshot
|
* tfind:: How to select a trace snapshot
|
* tdump:: How to display all data for a snapshot
|
* tdump:: How to display all data for a snapshot
|
* save tracepoints:: How to save tracepoints for a future run
|
* save tracepoints:: How to save tracepoints for a future run
|
|
|
|
|
File: gdb.info, Node: tfind, Next: tdump, Up: Analyze Collected Data
|
File: gdb.info, Node: tfind, Next: tdump, Up: Analyze Collected Data
|
|
|
13.2.1 `tfind N'
|
13.2.1 `tfind N'
|
----------------
|
----------------
|
|
|
The basic command for selecting a trace snapshot from the buffer is
|
The basic command for selecting a trace snapshot from the buffer is
|
`tfind N', which finds trace snapshot number N, counting from zero. If
|
`tfind N', which finds trace snapshot number N, counting from zero. If
|
no argument N is given, the next snapshot is selected.
|
no argument N is given, the next snapshot is selected.
|
|
|
Here are the various forms of using the `tfind' command.
|
Here are the various forms of using the `tfind' command.
|
|
|
`tfind start'
|
`tfind start'
|
Find the first snapshot in the buffer. This is a synonym for
|
Find the first snapshot in the buffer. This is a synonym for
|
`tfind 0' (since 0 is the number of the first snapshot).
|
`tfind 0' (since 0 is the number of the first snapshot).
|
|
|
`tfind none'
|
`tfind none'
|
Stop debugging trace snapshots, resume _live_ debugging.
|
Stop debugging trace snapshots, resume _live_ debugging.
|
|
|
`tfind end'
|
`tfind end'
|
Same as `tfind none'.
|
Same as `tfind none'.
|
|
|
`tfind'
|
`tfind'
|
No argument means find the next trace snapshot.
|
No argument means find the next trace snapshot.
|
|
|
`tfind -'
|
`tfind -'
|
Find the previous trace snapshot before the current one. This
|
Find the previous trace snapshot before the current one. This
|
permits retracing earlier steps.
|
permits retracing earlier steps.
|
|
|
`tfind tracepoint NUM'
|
`tfind tracepoint NUM'
|
Find the next snapshot associated with tracepoint NUM. Search
|
Find the next snapshot associated with tracepoint NUM. Search
|
proceeds forward from the last examined trace snapshot. If no
|
proceeds forward from the last examined trace snapshot. If no
|
argument NUM is given, it means find the next snapshot collected
|
argument NUM is given, it means find the next snapshot collected
|
for the same tracepoint as the current snapshot.
|
for the same tracepoint as the current snapshot.
|
|
|
`tfind pc ADDR'
|
`tfind pc ADDR'
|
Find the next snapshot associated with the value ADDR of the
|
Find the next snapshot associated with the value ADDR of the
|
program counter. Search proceeds forward from the last examined
|
program counter. Search proceeds forward from the last examined
|
trace snapshot. If no argument ADDR is given, it means find the
|
trace snapshot. If no argument ADDR is given, it means find the
|
next snapshot with the same value of PC as the current snapshot.
|
next snapshot with the same value of PC as the current snapshot.
|
|
|
`tfind outside ADDR1, ADDR2'
|
`tfind outside ADDR1, ADDR2'
|
Find the next snapshot whose PC is outside the given range of
|
Find the next snapshot whose PC is outside the given range of
|
addresses (exclusive).
|
addresses (exclusive).
|
|
|
`tfind range ADDR1, ADDR2'
|
`tfind range ADDR1, ADDR2'
|
Find the next snapshot whose PC is between ADDR1 and ADDR2
|
Find the next snapshot whose PC is between ADDR1 and ADDR2
|
(inclusive).
|
(inclusive).
|
|
|
`tfind line [FILE:]N'
|
`tfind line [FILE:]N'
|
Find the next snapshot associated with the source line N. If the
|
Find the next snapshot associated with the source line N. If the
|
optional argument FILE is given, refer to line N in that source
|
optional argument FILE is given, refer to line N in that source
|
file. Search proceeds forward from the last examined trace
|
file. Search proceeds forward from the last examined trace
|
snapshot. If no argument N is given, it means find the next line
|
snapshot. If no argument N is given, it means find the next line
|
other than the one currently being examined; thus saying `tfind
|
other than the one currently being examined; thus saying `tfind
|
line' repeatedly can appear to have the same effect as stepping
|
line' repeatedly can appear to have the same effect as stepping
|
from line to line in a _live_ debugging session.
|
from line to line in a _live_ debugging session.
|
|
|
The default arguments for the `tfind' commands are specifically
|
The default arguments for the `tfind' commands are specifically
|
designed to make it easy to scan through the trace buffer. For
|
designed to make it easy to scan through the trace buffer. For
|
instance, `tfind' with no argument selects the next trace snapshot, and
|
instance, `tfind' with no argument selects the next trace snapshot, and
|
`tfind -' with no argument selects the previous trace snapshot. So, by
|
`tfind -' with no argument selects the previous trace snapshot. So, by
|
giving one `tfind' command, and then simply hitting repeatedly
|
giving one `tfind' command, and then simply hitting repeatedly
|
you can examine all the trace snapshots in order. Or, by saying `tfind
|
you can examine all the trace snapshots in order. Or, by saying `tfind
|
-' and then hitting repeatedly you can examine the snapshots in
|
-' and then hitting repeatedly you can examine the snapshots in
|
reverse order. The `tfind line' command with no argument selects the
|
reverse order. The `tfind line' command with no argument selects the
|
snapshot for the next source line executed. The `tfind pc' command with
|
snapshot for the next source line executed. The `tfind pc' command with
|
no argument selects the next snapshot with the same program counter
|
no argument selects the next snapshot with the same program counter
|
(PC) as the current frame. The `tfind tracepoint' command with no
|
(PC) as the current frame. The `tfind tracepoint' command with no
|
argument selects the next trace snapshot collected by the same
|
argument selects the next trace snapshot collected by the same
|
tracepoint as the current one.
|
tracepoint as the current one.
|
|
|
In addition to letting you scan through the trace buffer manually,
|
In addition to letting you scan through the trace buffer manually,
|
these commands make it easy to construct GDB scripts that scan through
|
these commands make it easy to construct GDB scripts that scan through
|
the trace buffer and print out whatever collected data you are
|
the trace buffer and print out whatever collected data you are
|
interested in. Thus, if we want to examine the PC, FP, and SP
|
interested in. Thus, if we want to examine the PC, FP, and SP
|
registers from each trace frame in the buffer, we can say this:
|
registers from each trace frame in the buffer, we can say this:
|
|
|
(gdb) tfind start
|
(gdb) tfind start
|
(gdb) while ($trace_frame != -1)
|
(gdb) while ($trace_frame != -1)
|
> printf "Frame %d, PC = %08X, SP = %08X, FP = %08X\n", \
|
> printf "Frame %d, PC = %08X, SP = %08X, FP = %08X\n", \
|
$trace_frame, $pc, $sp, $fp
|
$trace_frame, $pc, $sp, $fp
|
> tfind
|
> tfind
|
> end
|
> end
|
|
|
Frame 0, PC = 0020DC64, SP = 0030BF3C, FP = 0030BF44
|
Frame 0, PC = 0020DC64, SP = 0030BF3C, FP = 0030BF44
|
Frame 1, PC = 0020DC6C, SP = 0030BF38, FP = 0030BF44
|
Frame 1, PC = 0020DC6C, SP = 0030BF38, FP = 0030BF44
|
Frame 2, PC = 0020DC70, SP = 0030BF34, FP = 0030BF44
|
Frame 2, PC = 0020DC70, SP = 0030BF34, FP = 0030BF44
|
Frame 3, PC = 0020DC74, SP = 0030BF30, FP = 0030BF44
|
Frame 3, PC = 0020DC74, SP = 0030BF30, FP = 0030BF44
|
Frame 4, PC = 0020DC78, SP = 0030BF2C, FP = 0030BF44
|
Frame 4, PC = 0020DC78, SP = 0030BF2C, FP = 0030BF44
|
Frame 5, PC = 0020DC7C, SP = 0030BF28, FP = 0030BF44
|
Frame 5, PC = 0020DC7C, SP = 0030BF28, FP = 0030BF44
|
Frame 6, PC = 0020DC80, SP = 0030BF24, FP = 0030BF44
|
Frame 6, PC = 0020DC80, SP = 0030BF24, FP = 0030BF44
|
Frame 7, PC = 0020DC84, SP = 0030BF20, FP = 0030BF44
|
Frame 7, PC = 0020DC84, SP = 0030BF20, FP = 0030BF44
|
Frame 8, PC = 0020DC88, SP = 0030BF1C, FP = 0030BF44
|
Frame 8, PC = 0020DC88, SP = 0030BF1C, FP = 0030BF44
|
Frame 9, PC = 0020DC8E, SP = 0030BF18, FP = 0030BF44
|
Frame 9, PC = 0020DC8E, SP = 0030BF18, FP = 0030BF44
|
Frame 10, PC = 00203F6C, SP = 0030BE3C, FP = 0030BF14
|
Frame 10, PC = 00203F6C, SP = 0030BE3C, FP = 0030BF14
|
|
|
Or, if we want to examine the variable `X' at each source line in
|
Or, if we want to examine the variable `X' at each source line in
|
the buffer:
|
the buffer:
|
|
|
(gdb) tfind start
|
(gdb) tfind start
|
(gdb) while ($trace_frame != -1)
|
(gdb) while ($trace_frame != -1)
|
> printf "Frame %d, X == %d\n", $trace_frame, X
|
> printf "Frame %d, X == %d\n", $trace_frame, X
|
> tfind line
|
> tfind line
|
> end
|
> end
|
|
|
Frame 0, X = 1
|
Frame 0, X = 1
|
Frame 7, X = 2
|
Frame 7, X = 2
|
Frame 13, X = 255
|
Frame 13, X = 255
|
|
|
|
|
File: gdb.info, Node: tdump, Next: save tracepoints, Prev: tfind, Up: Analyze Collected Data
|
File: gdb.info, Node: tdump, Next: save tracepoints, Prev: tfind, Up: Analyze Collected Data
|
|
|
13.2.2 `tdump'
|
13.2.2 `tdump'
|
--------------
|
--------------
|
|
|
This command takes no arguments. It prints all the data collected at
|
This command takes no arguments. It prints all the data collected at
|
the current trace snapshot.
|
the current trace snapshot.
|
|
|
(gdb) trace 444
|
(gdb) trace 444
|
(gdb) actions
|
(gdb) actions
|
Enter actions for tracepoint #2, one per line:
|
Enter actions for tracepoint #2, one per line:
|
> collect $regs, $locals, $args, gdb_long_test
|
> collect $regs, $locals, $args, gdb_long_test
|
> end
|
> end
|
|
|
(gdb) tstart
|
(gdb) tstart
|
|
|
(gdb) tfind line 444
|
(gdb) tfind line 444
|
#0 gdb_test (p1=0x11, p2=0x22, p3=0x33, p4=0x44, p5=0x55, p6=0x66)
|
#0 gdb_test (p1=0x11, p2=0x22, p3=0x33, p4=0x44, p5=0x55, p6=0x66)
|
at gdb_test.c:444
|
at gdb_test.c:444
|
444 printp( "%s: arguments = 0x%X 0x%X 0x%X 0x%X 0x%X 0x%X\n", )
|
444 printp( "%s: arguments = 0x%X 0x%X 0x%X 0x%X 0x%X 0x%X\n", )
|
|
|
(gdb) tdump
|
(gdb) tdump
|
Data collected at tracepoint 2, trace frame 1:
|
Data collected at tracepoint 2, trace frame 1:
|
d0 0xc4aa0085 -995491707
|
d0 0xc4aa0085 -995491707
|
d1 0x18 24
|
d1 0x18 24
|
d2 0x80 128
|
d2 0x80 128
|
d3 0x33 51
|
d3 0x33 51
|
d4 0x71aea3d 119204413
|
d4 0x71aea3d 119204413
|
d5 0x22 34
|
d5 0x22 34
|
d6 0xe0 224
|
d6 0xe0 224
|
d7 0x380035 3670069
|
d7 0x380035 3670069
|
a0 0x19e24a 1696330
|
a0 0x19e24a 1696330
|
a1 0x3000668 50333288
|
a1 0x3000668 50333288
|
a2 0x100 256
|
a2 0x100 256
|
a3 0x322000 3284992
|
a3 0x322000 3284992
|
a4 0x3000698 50333336
|
a4 0x3000698 50333336
|
a5 0x1ad3cc 1758156
|
a5 0x1ad3cc 1758156
|
fp 0x30bf3c 0x30bf3c
|
fp 0x30bf3c 0x30bf3c
|
sp 0x30bf34 0x30bf34
|
sp 0x30bf34 0x30bf34
|
ps 0x0 0
|
ps 0x0 0
|
pc 0x20b2c8 0x20b2c8
|
pc 0x20b2c8 0x20b2c8
|
fpcontrol 0x0 0
|
fpcontrol 0x0 0
|
fpstatus 0x0 0
|
fpstatus 0x0 0
|
fpiaddr 0x0 0
|
fpiaddr 0x0 0
|
p = 0x20e5b4 "gdb-test"
|
p = 0x20e5b4 "gdb-test"
|
p1 = (void *) 0x11
|
p1 = (void *) 0x11
|
p2 = (void *) 0x22
|
p2 = (void *) 0x22
|
p3 = (void *) 0x33
|
p3 = (void *) 0x33
|
p4 = (void *) 0x44
|
p4 = (void *) 0x44
|
p5 = (void *) 0x55
|
p5 = (void *) 0x55
|
p6 = (void *) 0x66
|
p6 = (void *) 0x66
|
gdb_long_test = 17 '\021'
|
gdb_long_test = 17 '\021'
|
|
|
(gdb)
|
(gdb)
|
|
|
`tdump' works by scanning the tracepoint's current collection
|
`tdump' works by scanning the tracepoint's current collection
|
actions and printing the value of each expression listed. So `tdump'
|
actions and printing the value of each expression listed. So `tdump'
|
can fail, if after a run, you change the tracepoint's actions to
|
can fail, if after a run, you change the tracepoint's actions to
|
mention variables that were not collected during the run.
|
mention variables that were not collected during the run.
|
|
|
Also, for tracepoints with `while-stepping' loops, `tdump' uses the
|
Also, for tracepoints with `while-stepping' loops, `tdump' uses the
|
collected value of `$pc' to distinguish between trace frames that were
|
collected value of `$pc' to distinguish between trace frames that were
|
collected at the tracepoint hit, and frames that were collected while
|
collected at the tracepoint hit, and frames that were collected while
|
stepping. This allows it to correctly choose whether to display the
|
stepping. This allows it to correctly choose whether to display the
|
basic list of collections, or the collections from the body of the
|
basic list of collections, or the collections from the body of the
|
while-stepping loop. However, if `$pc' was not collected, then `tdump'
|
while-stepping loop. However, if `$pc' was not collected, then `tdump'
|
will always attempt to dump using the basic collection list, and may
|
will always attempt to dump using the basic collection list, and may
|
fail if a while-stepping frame does not include all the same data that
|
fail if a while-stepping frame does not include all the same data that
|
is collected at the tracepoint hit.
|
is collected at the tracepoint hit.
|
|
|
|
|
File: gdb.info, Node: save tracepoints, Prev: tdump, Up: Analyze Collected Data
|
File: gdb.info, Node: save tracepoints, Prev: tdump, Up: Analyze Collected Data
|
|
|
13.2.3 `save tracepoints FILENAME'
|
13.2.3 `save tracepoints FILENAME'
|
----------------------------------
|
----------------------------------
|
|
|
This command saves all current tracepoint definitions together with
|
This command saves all current tracepoint definitions together with
|
their actions and passcounts, into a file `FILENAME' suitable for use
|
their actions and passcounts, into a file `FILENAME' suitable for use
|
in a later debugging session. To read the saved tracepoint
|
in a later debugging session. To read the saved tracepoint
|
definitions, use the `source' command (*note Command Files::). The
|
definitions, use the `source' command (*note Command Files::). The
|
`save-tracepoints' command is a deprecated alias for `save tracepoints'
|
`save-tracepoints' command is a deprecated alias for `save tracepoints'
|
|
|
|
|
File: gdb.info, Node: Tracepoint Variables, Next: Trace Files, Prev: Analyze Collected Data, Up: Tracepoints
|
File: gdb.info, Node: Tracepoint Variables, Next: Trace Files, Prev: Analyze Collected Data, Up: Tracepoints
|
|
|
13.3 Convenience Variables for Tracepoints
|
13.3 Convenience Variables for Tracepoints
|
==========================================
|
==========================================
|
|
|
`(int) $trace_frame'
|
`(int) $trace_frame'
|
The current trace snapshot (a.k.a. "frame") number, or -1 if no
|
The current trace snapshot (a.k.a. "frame") number, or -1 if no
|
snapshot is selected.
|
snapshot is selected.
|
|
|
`(int) $tracepoint'
|
`(int) $tracepoint'
|
The tracepoint for the current trace snapshot.
|
The tracepoint for the current trace snapshot.
|
|
|
`(int) $trace_line'
|
`(int) $trace_line'
|
The line number for the current trace snapshot.
|
The line number for the current trace snapshot.
|
|
|
`(char []) $trace_file'
|
`(char []) $trace_file'
|
The source file for the current trace snapshot.
|
The source file for the current trace snapshot.
|
|
|
`(char []) $trace_func'
|
`(char []) $trace_func'
|
The name of the function containing `$tracepoint'.
|
The name of the function containing `$tracepoint'.
|
|
|
Note: `$trace_file' is not suitable for use in `printf', use
|
Note: `$trace_file' is not suitable for use in `printf', use
|
`output' instead.
|
`output' instead.
|
|
|
Here's a simple example of using these convenience variables for
|
Here's a simple example of using these convenience variables for
|
stepping through all the trace snapshots and printing some of their
|
stepping through all the trace snapshots and printing some of their
|
data. Note that these are not the same as trace state variables, which
|
data. Note that these are not the same as trace state variables, which
|
are managed by the target.
|
are managed by the target.
|
|
|
(gdb) tfind start
|
(gdb) tfind start
|
|
|
(gdb) while $trace_frame != -1
|
(gdb) while $trace_frame != -1
|
> output $trace_file
|
> output $trace_file
|
> printf ", line %d (tracepoint #%d)\n", $trace_line, $tracepoint
|
> printf ", line %d (tracepoint #%d)\n", $trace_line, $tracepoint
|
> tfind
|
> tfind
|
> end
|
> end
|
|
|
|
|
File: gdb.info, Node: Trace Files, Prev: Tracepoint Variables, Up: Tracepoints
|
File: gdb.info, Node: Trace Files, Prev: Tracepoint Variables, Up: Tracepoints
|
|
|
13.4 Using Trace Files
|
13.4 Using Trace Files
|
======================
|
======================
|
|
|
In some situations, the target running a trace experiment may no longer
|
In some situations, the target running a trace experiment may no longer
|
be available; perhaps it crashed, or the hardware was needed for a
|
be available; perhaps it crashed, or the hardware was needed for a
|
different activity. To handle these cases, you can arrange to dump the
|
different activity. To handle these cases, you can arrange to dump the
|
trace data into a file, and later use that file as a source of trace
|
trace data into a file, and later use that file as a source of trace
|
data, via the `target tfile' command.
|
data, via the `target tfile' command.
|
|
|
`tsave [ -r ] FILENAME'
|
`tsave [ -r ] FILENAME'
|
Save the trace data to FILENAME. By default, this command assumes
|
Save the trace data to FILENAME. By default, this command assumes
|
that FILENAME refers to the host filesystem, so if necessary GDB
|
that FILENAME refers to the host filesystem, so if necessary GDB
|
will copy raw trace data up from the target and then save it. If
|
will copy raw trace data up from the target and then save it. If
|
the target supports it, you can also supply the optional argument
|
the target supports it, you can also supply the optional argument
|
`-r' ("remote") to direct the target to save the data directly
|
`-r' ("remote") to direct the target to save the data directly
|
into FILENAME in its own filesystem, which may be more efficient
|
into FILENAME in its own filesystem, which may be more efficient
|
if the trace buffer is very large. (Note, however, that `target
|
if the trace buffer is very large. (Note, however, that `target
|
tfile' can only read from files accessible to the host.)
|
tfile' can only read from files accessible to the host.)
|
|
|
`target tfile FILENAME'
|
`target tfile FILENAME'
|
Use the file named FILENAME as a source of trace data. Commands
|
Use the file named FILENAME as a source of trace data. Commands
|
that examine data work as they do with a live target, but it is not
|
that examine data work as they do with a live target, but it is not
|
possible to run any new trace experiments. `tstatus' will report
|
possible to run any new trace experiments. `tstatus' will report
|
the state of the trace run at the moment the data was saved, as
|
the state of the trace run at the moment the data was saved, as
|
well as the current trace frame you are examining. FILENAME must
|
well as the current trace frame you are examining. FILENAME must
|
be on a filesystem accessible to the host.
|
be on a filesystem accessible to the host.
|
|
|
|
|
|
|
File: gdb.info, Node: Overlays, Next: Languages, Prev: Tracepoints, Up: Top
|
File: gdb.info, Node: Overlays, Next: Languages, Prev: Tracepoints, Up: Top
|
|
|
14 Debugging Programs That Use Overlays
|
14 Debugging Programs That Use Overlays
|
***************************************
|
***************************************
|
|
|
If your program is too large to fit completely in your target system's
|
If your program is too large to fit completely in your target system's
|
memory, you can sometimes use "overlays" to work around this problem.
|
memory, you can sometimes use "overlays" to work around this problem.
|
GDB provides some support for debugging programs that use overlays.
|
GDB provides some support for debugging programs that use overlays.
|
|
|
* Menu:
|
* Menu:
|
|
|
* How Overlays Work:: A general explanation of overlays.
|
* How Overlays Work:: A general explanation of overlays.
|
* Overlay Commands:: Managing overlays in GDB.
|
* Overlay Commands:: Managing overlays in GDB.
|
* Automatic Overlay Debugging:: GDB can find out which overlays are
|
* Automatic Overlay Debugging:: GDB can find out which overlays are
|
mapped by asking the inferior.
|
mapped by asking the inferior.
|
* Overlay Sample Program:: A sample program using overlays.
|
* Overlay Sample Program:: A sample program using overlays.
|
|
|
|
|
File: gdb.info, Node: How Overlays Work, Next: Overlay Commands, Up: Overlays
|
File: gdb.info, Node: How Overlays Work, Next: Overlay Commands, Up: Overlays
|
|
|
14.1 How Overlays Work
|
14.1 How Overlays Work
|
======================
|
======================
|
|
|
Suppose you have a computer whose instruction address space is only 64
|
Suppose you have a computer whose instruction address space is only 64
|
kilobytes long, but which has much more memory which can be accessed by
|
kilobytes long, but which has much more memory which can be accessed by
|
other means: special instructions, segment registers, or memory
|
other means: special instructions, segment registers, or memory
|
management hardware, for example. Suppose further that you want to
|
management hardware, for example. Suppose further that you want to
|
adapt a program which is larger than 64 kilobytes to run on this system.
|
adapt a program which is larger than 64 kilobytes to run on this system.
|
|
|
One solution is to identify modules of your program which are
|
One solution is to identify modules of your program which are
|
relatively independent, and need not call each other directly; call
|
relatively independent, and need not call each other directly; call
|
these modules "overlays". Separate the overlays from the main program,
|
these modules "overlays". Separate the overlays from the main program,
|
and place their machine code in the larger memory. Place your main
|
and place their machine code in the larger memory. Place your main
|
program in instruction memory, but leave at least enough space there to
|
program in instruction memory, but leave at least enough space there to
|
hold the largest overlay as well.
|
hold the largest overlay as well.
|
|
|
Now, to call a function located in an overlay, you must first copy
|
Now, to call a function located in an overlay, you must first copy
|
that overlay's machine code from the large memory into the space set
|
that overlay's machine code from the large memory into the space set
|
aside for it in the instruction memory, and then jump to its entry point
|
aside for it in the instruction memory, and then jump to its entry point
|
there.
|
there.
|
|
|
Data Instruction Larger
|
Data Instruction Larger
|
Address Space Address Space Address Space
|
Address Space Address Space Address Space
|
+-----------+ +-----------+ +-----------+
|
+-----------+ +-----------+ +-----------+
|
| | | | | |
|
| | | | | |
|
+-----------+ +-----------+ +-----------+<-- overlay 1
|
+-----------+ +-----------+ +-----------+<-- overlay 1
|
| program | | main | .----| overlay 1 | load address
|
| program | | main | .----| overlay 1 | load address
|
| variables | | program | | +-----------+
|
| variables | | program | | +-----------+
|
| and heap | | | | | |
|
| and heap | | | | | |
|
+-----------+ | | | +-----------+<-- overlay 2
|
+-----------+ | | | +-----------+<-- overlay 2
|
| | +-----------+ | | | load address
|
| | +-----------+ | | | load address
|
+-----------+ | | | .-| overlay 2 |
|
+-----------+ | | | .-| overlay 2 |
|
| | | | | |
|
| | | | | |
|
mapped --->+-----------+ | | +-----------+
|
mapped --->+-----------+ | | +-----------+
|
address | | | | | |
|
address | | | | | |
|
| overlay | <-' | | |
|
| overlay | <-' | | |
|
| area | <---' +-----------+<-- overlay 3
|
| area | <---' +-----------+<-- overlay 3
|
| | <---. | | load address
|
| | <---. | | load address
|
+-----------+ `--| overlay 3 |
|
+-----------+ `--| overlay 3 |
|
| | | |
|
| | | |
|
+-----------+ | |
|
+-----------+ | |
|
+-----------+
|
+-----------+
|
| |
|
| |
|
+-----------+
|
+-----------+
|
|
|
A code overlay
|
A code overlay
|
|
|
The diagram (*note A code overlay::) shows a system with separate
|
The diagram (*note A code overlay::) shows a system with separate
|
data and instruction address spaces. To map an overlay, the program
|
data and instruction address spaces. To map an overlay, the program
|
copies its code from the larger address space to the instruction
|
copies its code from the larger address space to the instruction
|
address space. Since the overlays shown here all use the same mapped
|
address space. Since the overlays shown here all use the same mapped
|
address, only one may be mapped at a time. For a system with a single
|
address, only one may be mapped at a time. For a system with a single
|
address space for data and instructions, the diagram would be similar,
|
address space for data and instructions, the diagram would be similar,
|
except that the program variables and heap would share an address space
|
except that the program variables and heap would share an address space
|
with the main program and the overlay area.
|
with the main program and the overlay area.
|
|
|
An overlay loaded into instruction memory and ready for use is
|
An overlay loaded into instruction memory and ready for use is
|
called a "mapped" overlay; its "mapped address" is its address in the
|
called a "mapped" overlay; its "mapped address" is its address in the
|
instruction memory. An overlay not present (or only partially present)
|
instruction memory. An overlay not present (or only partially present)
|
in instruction memory is called "unmapped"; its "load address" is its
|
in instruction memory is called "unmapped"; its "load address" is its
|
address in the larger memory. The mapped address is also called the
|
address in the larger memory. The mapped address is also called the
|
"virtual memory address", or "VMA"; the load address is also called the
|
"virtual memory address", or "VMA"; the load address is also called the
|
"load memory address", or "LMA".
|
"load memory address", or "LMA".
|
|
|
Unfortunately, overlays are not a completely transparent way to
|
Unfortunately, overlays are not a completely transparent way to
|
adapt a program to limited instruction memory. They introduce a new
|
adapt a program to limited instruction memory. They introduce a new
|
set of global constraints you must keep in mind as you design your
|
set of global constraints you must keep in mind as you design your
|
program:
|
program:
|
|
|
* Before calling or returning to a function in an overlay, your
|
* Before calling or returning to a function in an overlay, your
|
program must make sure that overlay is actually mapped.
|
program must make sure that overlay is actually mapped.
|
Otherwise, the call or return will transfer control to the right
|
Otherwise, the call or return will transfer control to the right
|
address, but in the wrong overlay, and your program will probably
|
address, but in the wrong overlay, and your program will probably
|
crash.
|
crash.
|
|
|
* If the process of mapping an overlay is expensive on your system,
|
* If the process of mapping an overlay is expensive on your system,
|
you will need to choose your overlays carefully to minimize their
|
you will need to choose your overlays carefully to minimize their
|
effect on your program's performance.
|
effect on your program's performance.
|
|
|
* The executable file you load onto your system must contain each
|
* The executable file you load onto your system must contain each
|
overlay's instructions, appearing at the overlay's load address,
|
overlay's instructions, appearing at the overlay's load address,
|
not its mapped address. However, each overlay's instructions must
|
not its mapped address. However, each overlay's instructions must
|
be relocated and its symbols defined as if the overlay were at its
|
be relocated and its symbols defined as if the overlay were at its
|
mapped address. You can use GNU linker scripts to specify
|
mapped address. You can use GNU linker scripts to specify
|
different load and relocation addresses for pieces of your
|
different load and relocation addresses for pieces of your
|
program; see *note Overlay Description: (ld.info)Overlay
|
program; see *note Overlay Description: (ld.info)Overlay
|
Description.
|
Description.
|
|
|
* The procedure for loading executable files onto your system must
|
* The procedure for loading executable files onto your system must
|
be able to load their contents into the larger address space as
|
be able to load their contents into the larger address space as
|
well as the instruction and data spaces.
|
well as the instruction and data spaces.
|
|
|
|
|
The overlay system described above is rather simple, and could be
|
The overlay system described above is rather simple, and could be
|
improved in many ways:
|
improved in many ways:
|
|
|
* If your system has suitable bank switch registers or memory
|
* If your system has suitable bank switch registers or memory
|
management hardware, you could use those facilities to make an
|
management hardware, you could use those facilities to make an
|
overlay's load area contents simply appear at their mapped address
|
overlay's load area contents simply appear at their mapped address
|
in instruction space. This would probably be faster than copying
|
in instruction space. This would probably be faster than copying
|
the overlay to its mapped area in the usual way.
|
the overlay to its mapped area in the usual way.
|
|
|
* If your overlays are small enough, you could set aside more than
|
* If your overlays are small enough, you could set aside more than
|
one overlay area, and have more than one overlay mapped at a time.
|
one overlay area, and have more than one overlay mapped at a time.
|
|
|
* You can use overlays to manage data, as well as instructions. In
|
* You can use overlays to manage data, as well as instructions. In
|
general, data overlays are even less transparent to your design
|
general, data overlays are even less transparent to your design
|
than code overlays: whereas code overlays only require care when
|
than code overlays: whereas code overlays only require care when
|
you call or return to functions, data overlays require care every
|
you call or return to functions, data overlays require care every
|
time you access the data. Also, if you change the contents of a
|
time you access the data. Also, if you change the contents of a
|
data overlay, you must copy its contents back out to its load
|
data overlay, you must copy its contents back out to its load
|
address before you can copy a different data overlay into the same
|
address before you can copy a different data overlay into the same
|
mapped area.
|
mapped area.
|
|
|
|
|
|
|
File: gdb.info, Node: Overlay Commands, Next: Automatic Overlay Debugging, Prev: How Overlays Work, Up: Overlays
|
File: gdb.info, Node: Overlay Commands, Next: Automatic Overlay Debugging, Prev: How Overlays Work, Up: Overlays
|
|
|
14.2 Overlay Commands
|
14.2 Overlay Commands
|
=====================
|
=====================
|
|
|
To use GDB's overlay support, each overlay in your program must
|
To use GDB's overlay support, each overlay in your program must
|
correspond to a separate section of the executable file. The section's
|
correspond to a separate section of the executable file. The section's
|
virtual memory address and load memory address must be the overlay's
|
virtual memory address and load memory address must be the overlay's
|
mapped and load addresses. Identifying overlays with sections allows
|
mapped and load addresses. Identifying overlays with sections allows
|
GDB to determine the appropriate address of a function or variable,
|
GDB to determine the appropriate address of a function or variable,
|
depending on whether the overlay is mapped or not.
|
depending on whether the overlay is mapped or not.
|
|
|
GDB's overlay commands all start with the word `overlay'; you can
|
GDB's overlay commands all start with the word `overlay'; you can
|
abbreviate this as `ov' or `ovly'. The commands are:
|
abbreviate this as `ov' or `ovly'. The commands are:
|
|
|
`overlay off'
|
`overlay off'
|
Disable GDB's overlay support. When overlay support is disabled,
|
Disable GDB's overlay support. When overlay support is disabled,
|
GDB assumes that all functions and variables are always present at
|
GDB assumes that all functions and variables are always present at
|
their mapped addresses. By default, GDB's overlay support is
|
their mapped addresses. By default, GDB's overlay support is
|
disabled.
|
disabled.
|
|
|
`overlay manual'
|
`overlay manual'
|
Enable "manual" overlay debugging. In this mode, GDB relies on
|
Enable "manual" overlay debugging. In this mode, GDB relies on
|
you to tell it which overlays are mapped, and which are not, using
|
you to tell it which overlays are mapped, and which are not, using
|
the `overlay map-overlay' and `overlay unmap-overlay' commands
|
the `overlay map-overlay' and `overlay unmap-overlay' commands
|
described below.
|
described below.
|
|
|
`overlay map-overlay OVERLAY'
|
`overlay map-overlay OVERLAY'
|
`overlay map OVERLAY'
|
`overlay map OVERLAY'
|
Tell GDB that OVERLAY is now mapped; OVERLAY must be the name of
|
Tell GDB that OVERLAY is now mapped; OVERLAY must be the name of
|
the object file section containing the overlay. When an overlay
|
the object file section containing the overlay. When an overlay
|
is mapped, GDB assumes it can find the overlay's functions and
|
is mapped, GDB assumes it can find the overlay's functions and
|
variables at their mapped addresses. GDB assumes that any other
|
variables at their mapped addresses. GDB assumes that any other
|
overlays whose mapped ranges overlap that of OVERLAY are now
|
overlays whose mapped ranges overlap that of OVERLAY are now
|
unmapped.
|
unmapped.
|
|
|
`overlay unmap-overlay OVERLAY'
|
`overlay unmap-overlay OVERLAY'
|
`overlay unmap OVERLAY'
|
`overlay unmap OVERLAY'
|
Tell GDB that OVERLAY is no longer mapped; OVERLAY must be the
|
Tell GDB that OVERLAY is no longer mapped; OVERLAY must be the
|
name of the object file section containing the overlay. When an
|
name of the object file section containing the overlay. When an
|
overlay is unmapped, GDB assumes it can find the overlay's
|
overlay is unmapped, GDB assumes it can find the overlay's
|
functions and variables at their load addresses.
|
functions and variables at their load addresses.
|
|
|
`overlay auto'
|
`overlay auto'
|
Enable "automatic" overlay debugging. In this mode, GDB consults
|
Enable "automatic" overlay debugging. In this mode, GDB consults
|
a data structure the overlay manager maintains in the inferior to
|
a data structure the overlay manager maintains in the inferior to
|
see which overlays are mapped. For details, see *note Automatic
|
see which overlays are mapped. For details, see *note Automatic
|
Overlay Debugging::.
|
Overlay Debugging::.
|
|
|
`overlay load-target'
|
`overlay load-target'
|
`overlay load'
|
`overlay load'
|
Re-read the overlay table from the inferior. Normally, GDB
|
Re-read the overlay table from the inferior. Normally, GDB
|
re-reads the table GDB automatically each time the inferior stops,
|
re-reads the table GDB automatically each time the inferior stops,
|
so this command should only be necessary if you have changed the
|
so this command should only be necessary if you have changed the
|
overlay mapping yourself using GDB. This command is only useful
|
overlay mapping yourself using GDB. This command is only useful
|
when using automatic overlay debugging.
|
when using automatic overlay debugging.
|
|
|
`overlay list-overlays'
|
`overlay list-overlays'
|
`overlay list'
|
`overlay list'
|
Display a list of the overlays currently mapped, along with their
|
Display a list of the overlays currently mapped, along with their
|
mapped addresses, load addresses, and sizes.
|
mapped addresses, load addresses, and sizes.
|
|
|
|
|
Normally, when GDB prints a code address, it includes the name of
|
Normally, when GDB prints a code address, it includes the name of
|
the function the address falls in:
|
the function the address falls in:
|
|
|
(gdb) print main
|
(gdb) print main
|
$3 = {int ()} 0x11a0
|
$3 = {int ()} 0x11a0
|
When overlay debugging is enabled, GDB recognizes code in unmapped
|
When overlay debugging is enabled, GDB recognizes code in unmapped
|
overlays, and prints the names of unmapped functions with asterisks
|
overlays, and prints the names of unmapped functions with asterisks
|
around them. For example, if `foo' is a function in an unmapped
|
around them. For example, if `foo' is a function in an unmapped
|
overlay, GDB prints it this way:
|
overlay, GDB prints it this way:
|
|
|
(gdb) overlay list
|
(gdb) overlay list
|
No sections are mapped.
|
No sections are mapped.
|
(gdb) print foo
|
(gdb) print foo
|
$5 = {int (int)} 0x100000 <*foo*>
|
$5 = {int (int)} 0x100000 <*foo*>
|
When `foo''s overlay is mapped, GDB prints the function's name
|
When `foo''s overlay is mapped, GDB prints the function's name
|
normally:
|
normally:
|
|
|
(gdb) overlay list
|
(gdb) overlay list
|
Section .ov.foo.text, loaded at 0x100000 - 0x100034,
|
Section .ov.foo.text, loaded at 0x100000 - 0x100034,
|
mapped at 0x1016 - 0x104a
|
mapped at 0x1016 - 0x104a
|
(gdb) print foo
|
(gdb) print foo
|
$6 = {int (int)} 0x1016
|
$6 = {int (int)} 0x1016
|
|
|
When overlay debugging is enabled, GDB can find the correct address
|
When overlay debugging is enabled, GDB can find the correct address
|
for functions and variables in an overlay, whether or not the overlay
|
for functions and variables in an overlay, whether or not the overlay
|
is mapped. This allows most GDB commands, like `break' and
|
is mapped. This allows most GDB commands, like `break' and
|
`disassemble', to work normally, even on unmapped code. However, GDB's
|
`disassemble', to work normally, even on unmapped code. However, GDB's
|
breakpoint support has some limitations:
|
breakpoint support has some limitations:
|
|
|
* You can set breakpoints in functions in unmapped overlays, as long
|
* You can set breakpoints in functions in unmapped overlays, as long
|
as GDB can write to the overlay at its load address.
|
as GDB can write to the overlay at its load address.
|
|
|
* GDB can not set hardware or simulator-based breakpoints in
|
* GDB can not set hardware or simulator-based breakpoints in
|
unmapped overlays. However, if you set a breakpoint at the end of
|
unmapped overlays. However, if you set a breakpoint at the end of
|
your overlay manager (and tell GDB which overlays are now mapped,
|
your overlay manager (and tell GDB which overlays are now mapped,
|
if you are using manual overlay management), GDB will re-set its
|
if you are using manual overlay management), GDB will re-set its
|
breakpoints properly.
|
breakpoints properly.
|
|
|
|
|
File: gdb.info, Node: Automatic Overlay Debugging, Next: Overlay Sample Program, Prev: Overlay Commands, Up: Overlays
|
File: gdb.info, Node: Automatic Overlay Debugging, Next: Overlay Sample Program, Prev: Overlay Commands, Up: Overlays
|
|
|
14.3 Automatic Overlay Debugging
|
14.3 Automatic Overlay Debugging
|
================================
|
================================
|
|
|
GDB can automatically track which overlays are mapped and which are
|
GDB can automatically track which overlays are mapped and which are
|
not, given some simple co-operation from the overlay manager in the
|
not, given some simple co-operation from the overlay manager in the
|
inferior. If you enable automatic overlay debugging with the `overlay
|
inferior. If you enable automatic overlay debugging with the `overlay
|
auto' command (*note Overlay Commands::), GDB looks in the inferior's
|
auto' command (*note Overlay Commands::), GDB looks in the inferior's
|
memory for certain variables describing the current state of the
|
memory for certain variables describing the current state of the
|
overlays.
|
overlays.
|
|
|
Here are the variables your overlay manager must define to support
|
Here are the variables your overlay manager must define to support
|
GDB's automatic overlay debugging:
|
GDB's automatic overlay debugging:
|
|
|
`_ovly_table':
|
`_ovly_table':
|
This variable must be an array of the following structures:
|
This variable must be an array of the following structures:
|
|
|
struct
|
struct
|
{
|
{
|
/* The overlay's mapped address. */
|
/* The overlay's mapped address. */
|
unsigned long vma;
|
unsigned long vma;
|
|
|
/* The size of the overlay, in bytes. */
|
/* The size of the overlay, in bytes. */
|
unsigned long size;
|
unsigned long size;
|
|
|
/* The overlay's load address. */
|
/* The overlay's load address. */
|
unsigned long lma;
|
unsigned long lma;
|
|
|
/* Non-zero if the overlay is currently mapped;
|
/* Non-zero if the overlay is currently mapped;
|
zero otherwise. */
|
zero otherwise. */
|
unsigned long mapped;
|
unsigned long mapped;
|
}
|
}
|
|
|
`_novlys':
|
`_novlys':
|
This variable must be a four-byte signed integer, holding the total
|
This variable must be a four-byte signed integer, holding the total
|
number of elements in `_ovly_table'.
|
number of elements in `_ovly_table'.
|
|
|
|
|
To decide whether a particular overlay is mapped or not, GDB looks
|
To decide whether a particular overlay is mapped or not, GDB looks
|
for an entry in `_ovly_table' whose `vma' and `lma' members equal the
|
for an entry in `_ovly_table' whose `vma' and `lma' members equal the
|
VMA and LMA of the overlay's section in the executable file. When GDB
|
VMA and LMA of the overlay's section in the executable file. When GDB
|
finds a matching entry, it consults the entry's `mapped' member to
|
finds a matching entry, it consults the entry's `mapped' member to
|
determine whether the overlay is currently mapped.
|
determine whether the overlay is currently mapped.
|
|
|
In addition, your overlay manager may define a function called
|
In addition, your overlay manager may define a function called
|
`_ovly_debug_event'. If this function is defined, GDB will silently
|
`_ovly_debug_event'. If this function is defined, GDB will silently
|
set a breakpoint there. If the overlay manager then calls this
|
set a breakpoint there. If the overlay manager then calls this
|
function whenever it has changed the overlay table, this will enable
|
function whenever it has changed the overlay table, this will enable
|
GDB to accurately keep track of which overlays are in program memory,
|
GDB to accurately keep track of which overlays are in program memory,
|
and update any breakpoints that may be set in overlays. This will
|
and update any breakpoints that may be set in overlays. This will
|
allow breakpoints to work even if the overlays are kept in ROM or other
|
allow breakpoints to work even if the overlays are kept in ROM or other
|
non-writable memory while they are not being executed.
|
non-writable memory while they are not being executed.
|
|
|
|
|
File: gdb.info, Node: Overlay Sample Program, Prev: Automatic Overlay Debugging, Up: Overlays
|
File: gdb.info, Node: Overlay Sample Program, Prev: Automatic Overlay Debugging, Up: Overlays
|
|
|
14.4 Overlay Sample Program
|
14.4 Overlay Sample Program
|
===========================
|
===========================
|
|
|
When linking a program which uses overlays, you must place the overlays
|
When linking a program which uses overlays, you must place the overlays
|
at their load addresses, while relocating them to run at their mapped
|
at their load addresses, while relocating them to run at their mapped
|
addresses. To do this, you must write a linker script (*note Overlay
|
addresses. To do this, you must write a linker script (*note Overlay
|
Description: (ld.info)Overlay Description.). Unfortunately, since
|
Description: (ld.info)Overlay Description.). Unfortunately, since
|
linker scripts are specific to a particular host system, target
|
linker scripts are specific to a particular host system, target
|
architecture, and target memory layout, this manual cannot provide
|
architecture, and target memory layout, this manual cannot provide
|
portable sample code demonstrating GDB's overlay support.
|
portable sample code demonstrating GDB's overlay support.
|
|
|
However, the GDB source distribution does contain an overlaid
|
However, the GDB source distribution does contain an overlaid
|
program, with linker scripts for a few systems, as part of its test
|
program, with linker scripts for a few systems, as part of its test
|
suite. The program consists of the following files from
|
suite. The program consists of the following files from
|
`gdb/testsuite/gdb.base':
|
`gdb/testsuite/gdb.base':
|
|
|
`overlays.c'
|
`overlays.c'
|
The main program file.
|
The main program file.
|
|
|
`ovlymgr.c'
|
`ovlymgr.c'
|
A simple overlay manager, used by `overlays.c'.
|
A simple overlay manager, used by `overlays.c'.
|
|
|
`foo.c'
|
`foo.c'
|
`bar.c'
|
`bar.c'
|
`baz.c'
|
`baz.c'
|
`grbx.c'
|
`grbx.c'
|
Overlay modules, loaded and used by `overlays.c'.
|
Overlay modules, loaded and used by `overlays.c'.
|
|
|
`d10v.ld'
|
`d10v.ld'
|
`m32r.ld'
|
`m32r.ld'
|
Linker scripts for linking the test program on the `d10v-elf' and
|
Linker scripts for linking the test program on the `d10v-elf' and
|
`m32r-elf' targets.
|
`m32r-elf' targets.
|
|
|
You can build the test program using the `d10v-elf' GCC
|
You can build the test program using the `d10v-elf' GCC
|
cross-compiler like this:
|
cross-compiler like this:
|
|
|
$ d10v-elf-gcc -g -c overlays.c
|
$ d10v-elf-gcc -g -c overlays.c
|
$ d10v-elf-gcc -g -c ovlymgr.c
|
$ d10v-elf-gcc -g -c ovlymgr.c
|
$ d10v-elf-gcc -g -c foo.c
|
$ d10v-elf-gcc -g -c foo.c
|
$ d10v-elf-gcc -g -c bar.c
|
$ d10v-elf-gcc -g -c bar.c
|
$ d10v-elf-gcc -g -c baz.c
|
$ d10v-elf-gcc -g -c baz.c
|
$ d10v-elf-gcc -g -c grbx.c
|
$ d10v-elf-gcc -g -c grbx.c
|
$ d10v-elf-gcc -g overlays.o ovlymgr.o foo.o bar.o \
|
$ d10v-elf-gcc -g overlays.o ovlymgr.o foo.o bar.o \
|
baz.o grbx.o -Wl,-Td10v.ld -o overlays
|
baz.o grbx.o -Wl,-Td10v.ld -o overlays
|
|
|
The build process is identical for any other architecture, except
|
The build process is identical for any other architecture, except
|
that you must substitute the appropriate compiler and linker script for
|
that you must substitute the appropriate compiler and linker script for
|
the target system for `d10v-elf-gcc' and `d10v.ld'.
|
the target system for `d10v-elf-gcc' and `d10v.ld'.
|
|
|
|
|
File: gdb.info, Node: Languages, Next: Symbols, Prev: Overlays, Up: Top
|
File: gdb.info, Node: Languages, Next: Symbols, Prev: Overlays, Up: Top
|
|
|
15 Using GDB with Different Languages
|
15 Using GDB with Different Languages
|
*************************************
|
*************************************
|
|
|
Although programming languages generally have common aspects, they are
|
Although programming languages generally have common aspects, they are
|
rarely expressed in the same manner. For instance, in ANSI C,
|
rarely expressed in the same manner. For instance, in ANSI C,
|
dereferencing a pointer `p' is accomplished by `*p', but in Modula-2,
|
dereferencing a pointer `p' is accomplished by `*p', but in Modula-2,
|
it is accomplished by `p^'. Values can also be represented (and
|
it is accomplished by `p^'. Values can also be represented (and
|
displayed) differently. Hex numbers in C appear as `0x1ae', while in
|
displayed) differently. Hex numbers in C appear as `0x1ae', while in
|
Modula-2 they appear as `1AEH'.
|
Modula-2 they appear as `1AEH'.
|
|
|
Language-specific information is built into GDB for some languages,
|
Language-specific information is built into GDB for some languages,
|
allowing you to express operations like the above in your program's
|
allowing you to express operations like the above in your program's
|
native language, and allowing GDB to output values in a manner
|
native language, and allowing GDB to output values in a manner
|
consistent with the syntax of your program's native language. The
|
consistent with the syntax of your program's native language. The
|
language you use to build expressions is called the "working language".
|
language you use to build expressions is called the "working language".
|
|
|
* Menu:
|
* Menu:
|
|
|
* Setting:: Switching between source languages
|
* Setting:: Switching between source languages
|
* Show:: Displaying the language
|
* Show:: Displaying the language
|
* Checks:: Type and range checks
|
* Checks:: Type and range checks
|
* Supported Languages:: Supported languages
|
* Supported Languages:: Supported languages
|
* Unsupported Languages:: Unsupported languages
|
* Unsupported Languages:: Unsupported languages
|
|
|
|
|
File: gdb.info, Node: Setting, Next: Show, Up: Languages
|
File: gdb.info, Node: Setting, Next: Show, Up: Languages
|
|
|
15.1 Switching Between Source Languages
|
15.1 Switching Between Source Languages
|
=======================================
|
=======================================
|
|
|
There are two ways to control the working language--either have GDB set
|
There are two ways to control the working language--either have GDB set
|
it automatically, or select it manually yourself. You can use the `set
|
it automatically, or select it manually yourself. You can use the `set
|
language' command for either purpose. On startup, GDB defaults to
|
language' command for either purpose. On startup, GDB defaults to
|
setting the language automatically. The working language is used to
|
setting the language automatically. The working language is used to
|
determine how expressions you type are interpreted, how values are
|
determine how expressions you type are interpreted, how values are
|
printed, etc.
|
printed, etc.
|
|
|
In addition to the working language, every source file that GDB
|
In addition to the working language, every source file that GDB
|
knows about has its own working language. For some object file
|
knows about has its own working language. For some object file
|
formats, the compiler might indicate which language a particular source
|
formats, the compiler might indicate which language a particular source
|
file is in. However, most of the time GDB infers the language from the
|
file is in. However, most of the time GDB infers the language from the
|
name of the file. The language of a source file controls whether C++
|
name of the file. The language of a source file controls whether C++
|
names are demangled--this way `backtrace' can show each frame
|
names are demangled--this way `backtrace' can show each frame
|
appropriately for its own language. There is no way to set the
|
appropriately for its own language. There is no way to set the
|
language of a source file from within GDB, but you can set the language
|
language of a source file from within GDB, but you can set the language
|
associated with a filename extension. *Note Displaying the Language:
|
associated with a filename extension. *Note Displaying the Language:
|
Show.
|
Show.
|
|
|
This is most commonly a problem when you use a program, such as
|
This is most commonly a problem when you use a program, such as
|
`cfront' or `f2c', that generates C but is written in another language.
|
`cfront' or `f2c', that generates C but is written in another language.
|
In that case, make the program use `#line' directives in its C output;
|
In that case, make the program use `#line' directives in its C output;
|
that way GDB will know the correct language of the source code of the
|
that way GDB will know the correct language of the source code of the
|
original program, and will display that source code, not the generated
|
original program, and will display that source code, not the generated
|
C code.
|
C code.
|
|
|
* Menu:
|
* Menu:
|
|
|
* Filenames:: Filename extensions and languages.
|
* Filenames:: Filename extensions and languages.
|
* Manually:: Setting the working language manually
|
* Manually:: Setting the working language manually
|
* Automatically:: Having GDB infer the source language
|
* Automatically:: Having GDB infer the source language
|
|
|
|
|
File: gdb.info, Node: Filenames, Next: Manually, Up: Setting
|
File: gdb.info, Node: Filenames, Next: Manually, Up: Setting
|
|
|
15.1.1 List of Filename Extensions and Languages
|
15.1.1 List of Filename Extensions and Languages
|
------------------------------------------------
|
------------------------------------------------
|
|
|
If a source file name ends in one of the following extensions, then GDB
|
If a source file name ends in one of the following extensions, then GDB
|
infers that its language is the one indicated.
|
infers that its language is the one indicated.
|
|
|
`.ada'
|
`.ada'
|
`.ads'
|
`.ads'
|
`.adb'
|
`.adb'
|
`.a'
|
`.a'
|
Ada source file.
|
Ada source file.
|
|
|
`.c'
|
`.c'
|
C source file
|
C source file
|
|
|
`.C'
|
`.C'
|
`.cc'
|
`.cc'
|
`.cp'
|
`.cp'
|
`.cpp'
|
`.cpp'
|
`.cxx'
|
`.cxx'
|
`.c++'
|
`.c++'
|
C++ source file
|
C++ source file
|
|
|
`.d'
|
`.d'
|
D source file
|
D source file
|
|
|
`.m'
|
`.m'
|
Objective-C source file
|
Objective-C source file
|
|
|
`.f'
|
`.f'
|
`.F'
|
`.F'
|
Fortran source file
|
Fortran source file
|
|
|
`.mod'
|
`.mod'
|
Modula-2 source file
|
Modula-2 source file
|
|
|
`.s'
|
`.s'
|
`.S'
|
`.S'
|
Assembler source file. This actually behaves almost like C, but
|
Assembler source file. This actually behaves almost like C, but
|
GDB does not skip over function prologues when stepping.
|
GDB does not skip over function prologues when stepping.
|
|
|
In addition, you may set the language associated with a filename
|
In addition, you may set the language associated with a filename
|
extension. *Note Displaying the Language: Show.
|
extension. *Note Displaying the Language: Show.
|
|
|
|
|
File: gdb.info, Node: Manually, Next: Automatically, Prev: Filenames, Up: Setting
|
File: gdb.info, Node: Manually, Next: Automatically, Prev: Filenames, Up: Setting
|
|
|
15.1.2 Setting the Working Language
|
15.1.2 Setting the Working Language
|
-----------------------------------
|
-----------------------------------
|
|
|
If you allow GDB to set the language automatically, expressions are
|
If you allow GDB to set the language automatically, expressions are
|
interpreted the same way in your debugging session and your program.
|
interpreted the same way in your debugging session and your program.
|
|
|
If you wish, you may set the language manually. To do this, issue
|
If you wish, you may set the language manually. To do this, issue
|
the command `set language LANG', where LANG is the name of a language,
|
the command `set language LANG', where LANG is the name of a language,
|
such as `c' or `modula-2'. For a list of the supported languages, type
|
such as `c' or `modula-2'. For a list of the supported languages, type
|
`set language'.
|
`set language'.
|
|
|
Setting the language manually prevents GDB from updating the working
|
Setting the language manually prevents GDB from updating the working
|
language automatically. This can lead to confusion if you try to debug
|
language automatically. This can lead to confusion if you try to debug
|
a program when the working language is not the same as the source
|
a program when the working language is not the same as the source
|
language, when an expression is acceptable to both languages--but means
|
language, when an expression is acceptable to both languages--but means
|
different things. For instance, if the current source file were
|
different things. For instance, if the current source file were
|
written in C, and GDB was parsing Modula-2, a command such as:
|
written in C, and GDB was parsing Modula-2, a command such as:
|
|
|
print a = b + c
|
print a = b + c
|
|
|
might not have the effect you intended. In C, this means to add `b'
|
might not have the effect you intended. In C, this means to add `b'
|
and `c' and place the result in `a'. The result printed would be the
|
and `c' and place the result in `a'. The result printed would be the
|
value of `a'. In Modula-2, this means to compare `a' to the result of
|
value of `a'. In Modula-2, this means to compare `a' to the result of
|
`b+c', yielding a `BOOLEAN' value.
|
`b+c', yielding a `BOOLEAN' value.
|
|
|
|
|
File: gdb.info, Node: Automatically, Prev: Manually, Up: Setting
|
File: gdb.info, Node: Automatically, Prev: Manually, Up: Setting
|
|
|
15.1.3 Having GDB Infer the Source Language
|
15.1.3 Having GDB Infer the Source Language
|
-------------------------------------------
|
-------------------------------------------
|
|
|
To have GDB set the working language automatically, use `set language
|
To have GDB set the working language automatically, use `set language
|
local' or `set language auto'. GDB then infers the working language.
|
local' or `set language auto'. GDB then infers the working language.
|
That is, when your program stops in a frame (usually by encountering a
|
That is, when your program stops in a frame (usually by encountering a
|
breakpoint), GDB sets the working language to the language recorded for
|
breakpoint), GDB sets the working language to the language recorded for
|
the function in that frame. If the language for a frame is unknown
|
the function in that frame. If the language for a frame is unknown
|
(that is, if the function or block corresponding to the frame was
|
(that is, if the function or block corresponding to the frame was
|
defined in a source file that does not have a recognized extension),
|
defined in a source file that does not have a recognized extension),
|
the current working language is not changed, and GDB issues a warning.
|
the current working language is not changed, and GDB issues a warning.
|
|
|
This may not seem necessary for most programs, which are written
|
This may not seem necessary for most programs, which are written
|
entirely in one source language. However, program modules and libraries
|
entirely in one source language. However, program modules and libraries
|
written in one source language can be used by a main program written in
|
written in one source language can be used by a main program written in
|
a different source language. Using `set language auto' in this case
|
a different source language. Using `set language auto' in this case
|
frees you from having to set the working language manually.
|
frees you from having to set the working language manually.
|
|
|
|
|
File: gdb.info, Node: Show, Next: Checks, Prev: Setting, Up: Languages
|
File: gdb.info, Node: Show, Next: Checks, Prev: Setting, Up: Languages
|
|
|
15.2 Displaying the Language
|
15.2 Displaying the Language
|
============================
|
============================
|
|
|
The following commands help you find out which language is the working
|
The following commands help you find out which language is the working
|
language, and also what language source files were written in.
|
language, and also what language source files were written in.
|
|
|
`show language'
|
`show language'
|
Display the current working language. This is the language you
|
Display the current working language. This is the language you
|
can use with commands such as `print' to build and compute
|
can use with commands such as `print' to build and compute
|
expressions that may involve variables in your program.
|
expressions that may involve variables in your program.
|
|
|
`info frame'
|
`info frame'
|
Display the source language for this frame. This language becomes
|
Display the source language for this frame. This language becomes
|
the working language if you use an identifier from this frame.
|
the working language if you use an identifier from this frame.
|
*Note Information about a Frame: Frame Info, to identify the other
|
*Note Information about a Frame: Frame Info, to identify the other
|
information listed here.
|
information listed here.
|
|
|
`info source'
|
`info source'
|
Display the source language of this source file. *Note Examining
|
Display the source language of this source file. *Note Examining
|
the Symbol Table: Symbols, to identify the other information
|
the Symbol Table: Symbols, to identify the other information
|
listed here.
|
listed here.
|
|
|
In unusual circumstances, you may have source files with extensions
|
In unusual circumstances, you may have source files with extensions
|
not in the standard list. You can then set the extension associated
|
not in the standard list. You can then set the extension associated
|
with a language explicitly:
|
with a language explicitly:
|
|
|
`set extension-language EXT LANGUAGE'
|
`set extension-language EXT LANGUAGE'
|
Tell GDB that source files with extension EXT are to be assumed as
|
Tell GDB that source files with extension EXT are to be assumed as
|
written in the source language LANGUAGE.
|
written in the source language LANGUAGE.
|
|
|
`info extensions'
|
`info extensions'
|
List all the filename extensions and the associated languages.
|
List all the filename extensions and the associated languages.
|
|
|
|
|
File: gdb.info, Node: Checks, Next: Supported Languages, Prev: Show, Up: Languages
|
File: gdb.info, Node: Checks, Next: Supported Languages, Prev: Show, Up: Languages
|
|
|
15.3 Type and Range Checking
|
15.3 Type and Range Checking
|
============================
|
============================
|
|
|
_Warning:_ In this release, the GDB commands for type and range
|
_Warning:_ In this release, the GDB commands for type and range
|
checking are included, but they do not yet have any effect. This
|
checking are included, but they do not yet have any effect. This
|
section documents the intended facilities.
|
section documents the intended facilities.
|
|
|
Some languages are designed to guard you against making seemingly
|
Some languages are designed to guard you against making seemingly
|
common errors through a series of compile- and run-time checks. These
|
common errors through a series of compile- and run-time checks. These
|
include checking the type of arguments to functions and operators, and
|
include checking the type of arguments to functions and operators, and
|
making sure mathematical overflows are caught at run time. Checks such
|
making sure mathematical overflows are caught at run time. Checks such
|
as these help to ensure a program's correctness once it has been
|
as these help to ensure a program's correctness once it has been
|
compiled by eliminating type mismatches, and providing active checks
|
compiled by eliminating type mismatches, and providing active checks
|
for range errors when your program is running.
|
for range errors when your program is running.
|
|
|
GDB can check for conditions like the above if you wish. Although
|
GDB can check for conditions like the above if you wish. Although
|
GDB does not check the statements in your program, it can check
|
GDB does not check the statements in your program, it can check
|
expressions entered directly into GDB for evaluation via the `print'
|
expressions entered directly into GDB for evaluation via the `print'
|
command, for example. As with the working language, GDB can also
|
command, for example. As with the working language, GDB can also
|
decide whether or not to check automatically based on your program's
|
decide whether or not to check automatically based on your program's
|
source language. *Note Supported Languages: Supported Languages, for
|
source language. *Note Supported Languages: Supported Languages, for
|
the default settings of supported languages.
|
the default settings of supported languages.
|
|
|
* Menu:
|
* Menu:
|
|
|
* Type Checking:: An overview of type checking
|
* Type Checking:: An overview of type checking
|
* Range Checking:: An overview of range checking
|
* Range Checking:: An overview of range checking
|
|
|
|
|
File: gdb.info, Node: Type Checking, Next: Range Checking, Up: Checks
|
File: gdb.info, Node: Type Checking, Next: Range Checking, Up: Checks
|
|
|
15.3.1 An Overview of Type Checking
|
15.3.1 An Overview of Type Checking
|
-----------------------------------
|
-----------------------------------
|
|
|
Some languages, such as Modula-2, are strongly typed, meaning that the
|
Some languages, such as Modula-2, are strongly typed, meaning that the
|
arguments to operators and functions have to be of the correct type,
|
arguments to operators and functions have to be of the correct type,
|
otherwise an error occurs. These checks prevent type mismatch errors
|
otherwise an error occurs. These checks prevent type mismatch errors
|
from ever causing any run-time problems. For example,
|
from ever causing any run-time problems. For example,
|
|
|
1 + 2 => 3
|
1 + 2 => 3
|
but
|
but
|
error--> 1 + 2.3
|
error--> 1 + 2.3
|
|
|
The second example fails because the `CARDINAL' 1 is not
|
The second example fails because the `CARDINAL' 1 is not
|
type-compatible with the `REAL' 2.3.
|
type-compatible with the `REAL' 2.3.
|
|
|
For the expressions you use in GDB commands, you can tell the GDB
|
For the expressions you use in GDB commands, you can tell the GDB
|
type checker to skip checking; to treat any mismatches as errors and
|
type checker to skip checking; to treat any mismatches as errors and
|
abandon the expression; or to only issue warnings when type mismatches
|
abandon the expression; or to only issue warnings when type mismatches
|
occur, but evaluate the expression anyway. When you choose the last of
|
occur, but evaluate the expression anyway. When you choose the last of
|
these, GDB evaluates expressions like the second example above, but
|
these, GDB evaluates expressions like the second example above, but
|
also issues a warning.
|
also issues a warning.
|
|
|
Even if you turn type checking off, there may be other reasons
|
Even if you turn type checking off, there may be other reasons
|
related to type that prevent GDB from evaluating an expression. For
|
related to type that prevent GDB from evaluating an expression. For
|
instance, GDB does not know how to add an `int' and a `struct foo'.
|
instance, GDB does not know how to add an `int' and a `struct foo'.
|
These particular type errors have nothing to do with the language in
|
These particular type errors have nothing to do with the language in
|
use, and usually arise from expressions, such as the one described
|
use, and usually arise from expressions, such as the one described
|
above, which make little sense to evaluate anyway.
|
above, which make little sense to evaluate anyway.
|
|
|
Each language defines to what degree it is strict about type. For
|
Each language defines to what degree it is strict about type. For
|
instance, both Modula-2 and C require the arguments to arithmetical
|
instance, both Modula-2 and C require the arguments to arithmetical
|
operators to be numbers. In C, enumerated types and pointers can be
|
operators to be numbers. In C, enumerated types and pointers can be
|
represented as numbers, so that they are valid arguments to mathematical
|
represented as numbers, so that they are valid arguments to mathematical
|
operators. *Note Supported Languages: Supported Languages, for further
|
operators. *Note Supported Languages: Supported Languages, for further
|
details on specific languages.
|
details on specific languages.
|
|
|
GDB provides some additional commands for controlling the type
|
GDB provides some additional commands for controlling the type
|
checker:
|
checker:
|
|
|
`set check type auto'
|
`set check type auto'
|
Set type checking on or off based on the current working language.
|
Set type checking on or off based on the current working language.
|
*Note Supported Languages: Supported Languages, for the default
|
*Note Supported Languages: Supported Languages, for the default
|
settings for each language.
|
settings for each language.
|
|
|
`set check type on'
|
`set check type on'
|
`set check type off'
|
`set check type off'
|
Set type checking on or off, overriding the default setting for the
|
Set type checking on or off, overriding the default setting for the
|
current working language. Issue a warning if the setting does not
|
current working language. Issue a warning if the setting does not
|
match the language default. If any type mismatches occur in
|
match the language default. If any type mismatches occur in
|
evaluating an expression while type checking is on, GDB prints a
|
evaluating an expression while type checking is on, GDB prints a
|
message and aborts evaluation of the expression.
|
message and aborts evaluation of the expression.
|
|
|
`set check type warn'
|
`set check type warn'
|
Cause the type checker to issue warnings, but to always attempt to
|
Cause the type checker to issue warnings, but to always attempt to
|
evaluate the expression. Evaluating the expression may still be
|
evaluate the expression. Evaluating the expression may still be
|
impossible for other reasons. For example, GDB cannot add numbers
|
impossible for other reasons. For example, GDB cannot add numbers
|
and structures.
|
and structures.
|
|
|
`show type'
|
`show type'
|
Show the current setting of the type checker, and whether or not
|
Show the current setting of the type checker, and whether or not
|
GDB is setting it automatically.
|
GDB is setting it automatically.
|
|
|
|
|
File: gdb.info, Node: Range Checking, Prev: Type Checking, Up: Checks
|
File: gdb.info, Node: Range Checking, Prev: Type Checking, Up: Checks
|
|
|
15.3.2 An Overview of Range Checking
|
15.3.2 An Overview of Range Checking
|
------------------------------------
|
------------------------------------
|
|
|
In some languages (such as Modula-2), it is an error to exceed the
|
In some languages (such as Modula-2), it is an error to exceed the
|
bounds of a type; this is enforced with run-time checks. Such range
|
bounds of a type; this is enforced with run-time checks. Such range
|
checking is meant to ensure program correctness by making sure
|
checking is meant to ensure program correctness by making sure
|
computations do not overflow, or indices on an array element access do
|
computations do not overflow, or indices on an array element access do
|
not exceed the bounds of the array.
|
not exceed the bounds of the array.
|
|
|
For expressions you use in GDB commands, you can tell GDB to treat
|
For expressions you use in GDB commands, you can tell GDB to treat
|
range errors in one of three ways: ignore them, always treat them as
|
range errors in one of three ways: ignore them, always treat them as
|
errors and abandon the expression, or issue warnings but evaluate the
|
errors and abandon the expression, or issue warnings but evaluate the
|
expression anyway.
|
expression anyway.
|
|
|
A range error can result from numerical overflow, from exceeding an
|
A range error can result from numerical overflow, from exceeding an
|
array index bound, or when you type a constant that is not a member of
|
array index bound, or when you type a constant that is not a member of
|
any type. Some languages, however, do not treat overflows as an error.
|
any type. Some languages, however, do not treat overflows as an error.
|
In many implementations of C, mathematical overflow causes the result
|
In many implementations of C, mathematical overflow causes the result
|
to "wrap around" to lower values--for example, if M is the largest
|
to "wrap around" to lower values--for example, if M is the largest
|
integer value, and S is the smallest, then
|
integer value, and S is the smallest, then
|
|
|
M + 1 => S
|
M + 1 => S
|
|
|
This, too, is specific to individual languages, and in some cases
|
This, too, is specific to individual languages, and in some cases
|
specific to individual compilers or machines. *Note Supported
|
specific to individual compilers or machines. *Note Supported
|
Languages: Supported Languages, for further details on specific
|
Languages: Supported Languages, for further details on specific
|
languages.
|
languages.
|
|
|
GDB provides some additional commands for controlling the range
|
GDB provides some additional commands for controlling the range
|
checker:
|
checker:
|
|
|
`set check range auto'
|
`set check range auto'
|
Set range checking on or off based on the current working language.
|
Set range checking on or off based on the current working language.
|
*Note Supported Languages: Supported Languages, for the default
|
*Note Supported Languages: Supported Languages, for the default
|
settings for each language.
|
settings for each language.
|
|
|
`set check range on'
|
`set check range on'
|
`set check range off'
|
`set check range off'
|
Set range checking on or off, overriding the default setting for
|
Set range checking on or off, overriding the default setting for
|
the current working language. A warning is issued if the setting
|
the current working language. A warning is issued if the setting
|
does not match the language default. If a range error occurs and
|
does not match the language default. If a range error occurs and
|
range checking is on, then a message is printed and evaluation of
|
range checking is on, then a message is printed and evaluation of
|
the expression is aborted.
|
the expression is aborted.
|
|
|
`set check range warn'
|
`set check range warn'
|
Output messages when the GDB range checker detects a range error,
|
Output messages when the GDB range checker detects a range error,
|
but attempt to evaluate the expression anyway. Evaluating the
|
but attempt to evaluate the expression anyway. Evaluating the
|
expression may still be impossible for other reasons, such as
|
expression may still be impossible for other reasons, such as
|
accessing memory that the process does not own (a typical example
|
accessing memory that the process does not own (a typical example
|
from many Unix systems).
|
from many Unix systems).
|
|
|
`show range'
|
`show range'
|
Show the current setting of the range checker, and whether or not
|
Show the current setting of the range checker, and whether or not
|
it is being set automatically by GDB.
|
it is being set automatically by GDB.
|
|
|
|
|
File: gdb.info, Node: Supported Languages, Next: Unsupported Languages, Prev: Checks, Up: Languages
|
File: gdb.info, Node: Supported Languages, Next: Unsupported Languages, Prev: Checks, Up: Languages
|
|
|
15.4 Supported Languages
|
15.4 Supported Languages
|
========================
|
========================
|
|
|
GDB supports C, C++, D, Objective-C, Fortran, Java, Pascal, assembly,
|
GDB supports C, C++, D, Objective-C, Fortran, Java, Pascal, assembly,
|
Modula-2, and Ada. Some GDB features may be used in expressions
|
Modula-2, and Ada. Some GDB features may be used in expressions
|
regardless of the language you use: the GDB `@' and `::' operators, and
|
regardless of the language you use: the GDB `@' and `::' operators, and
|
the `{type}addr' construct (*note Expressions: Expressions.) can be
|
the `{type}addr' construct (*note Expressions: Expressions.) can be
|
used with the constructs of any supported language.
|
used with the constructs of any supported language.
|
|
|
The following sections detail to what degree each source language is
|
The following sections detail to what degree each source language is
|
supported by GDB. These sections are not meant to be language
|
supported by GDB. These sections are not meant to be language
|
tutorials or references, but serve only as a reference guide to what the
|
tutorials or references, but serve only as a reference guide to what the
|
GDB expression parser accepts, and what input and output formats should
|
GDB expression parser accepts, and what input and output formats should
|
look like for different languages. There are many good books written
|
look like for different languages. There are many good books written
|
on each of these languages; please look to these for a language
|
on each of these languages; please look to these for a language
|
reference or tutorial.
|
reference or tutorial.
|
|
|
* Menu:
|
* Menu:
|
|
|
* C:: C and C++
|
* C:: C and C++
|
* D:: D
|
* D:: D
|
* Objective-C:: Objective-C
|
* Objective-C:: Objective-C
|
* Fortran:: Fortran
|
* Fortran:: Fortran
|
* Pascal:: Pascal
|
* Pascal:: Pascal
|
* Modula-2:: Modula-2
|
* Modula-2:: Modula-2
|
* Ada:: Ada
|
* Ada:: Ada
|
|
|
|
|
File: gdb.info, Node: C, Next: D, Up: Supported Languages
|
File: gdb.info, Node: C, Next: D, Up: Supported Languages
|
|
|
15.4.1 C and C++
|
15.4.1 C and C++
|
----------------
|
----------------
|
|
|
Since C and C++ are so closely related, many features of GDB apply to
|
Since C and C++ are so closely related, many features of GDB apply to
|
both languages. Whenever this is the case, we discuss those languages
|
both languages. Whenever this is the case, we discuss those languages
|
together.
|
together.
|
|
|
The C++ debugging facilities are jointly implemented by the C++
|
The C++ debugging facilities are jointly implemented by the C++
|
compiler and GDB. Therefore, to debug your C++ code effectively, you
|
compiler and GDB. Therefore, to debug your C++ code effectively, you
|
must compile your C++ programs with a supported C++ compiler, such as
|
must compile your C++ programs with a supported C++ compiler, such as
|
GNU `g++', or the HP ANSI C++ compiler (`aCC').
|
GNU `g++', or the HP ANSI C++ compiler (`aCC').
|
|
|
For best results when using GNU C++, use the DWARF 2 debugging
|
For best results when using GNU C++, use the DWARF 2 debugging
|
format; if it doesn't work on your system, try the stabs+ debugging
|
format; if it doesn't work on your system, try the stabs+ debugging
|
format. You can select those formats explicitly with the `g++'
|
format. You can select those formats explicitly with the `g++'
|
command-line options `-gdwarf-2' and `-gstabs+'. *Note Options for
|
command-line options `-gdwarf-2' and `-gstabs+'. *Note Options for
|
Debugging Your Program or GCC: (gcc.info)Debugging Options.
|
Debugging Your Program or GCC: (gcc.info)Debugging Options.
|
|
|
* Menu:
|
* Menu:
|
|
|
* C Operators:: C and C++ operators
|
* C Operators:: C and C++ operators
|
* C Constants:: C and C++ constants
|
* C Constants:: C and C++ constants
|
* C Plus Plus Expressions:: C++ expressions
|
* C Plus Plus Expressions:: C++ expressions
|
* C Defaults:: Default settings for C and C++
|
* C Defaults:: Default settings for C and C++
|
* C Checks:: C and C++ type and range checks
|
* C Checks:: C and C++ type and range checks
|
* Debugging C:: GDB and C
|
* Debugging C:: GDB and C
|
* Debugging C Plus Plus:: GDB features for C++
|
* Debugging C Plus Plus:: GDB features for C++
|
* Decimal Floating Point:: Numbers in Decimal Floating Point format
|
* Decimal Floating Point:: Numbers in Decimal Floating Point format
|
|
|
|
|
File: gdb.info, Node: C Operators, Next: C Constants, Up: C
|
File: gdb.info, Node: C Operators, Next: C Constants, Up: C
|
|
|
15.4.1.1 C and C++ Operators
|
15.4.1.1 C and C++ Operators
|
............................
|
............................
|
|
|
Operators must be defined on values of specific types. For instance,
|
Operators must be defined on values of specific types. For instance,
|
`+' is defined on numbers, but not on structures. Operators are often
|
`+' is defined on numbers, but not on structures. Operators are often
|
defined on groups of types.
|
defined on groups of types.
|
|
|
For the purposes of C and C++, the following definitions hold:
|
For the purposes of C and C++, the following definitions hold:
|
|
|
* _Integral types_ include `int' with any of its storage-class
|
* _Integral types_ include `int' with any of its storage-class
|
specifiers; `char'; `enum'; and, for C++, `bool'.
|
specifiers; `char'; `enum'; and, for C++, `bool'.
|
|
|
* _Floating-point types_ include `float', `double', and `long
|
* _Floating-point types_ include `float', `double', and `long
|
double' (if supported by the target platform).
|
double' (if supported by the target platform).
|
|
|
* _Pointer types_ include all types defined as `(TYPE *)'.
|
* _Pointer types_ include all types defined as `(TYPE *)'.
|
|
|
* _Scalar types_ include all of the above.
|
* _Scalar types_ include all of the above.
|
|
|
|
|
The following operators are supported. They are listed here in order
|
The following operators are supported. They are listed here in order
|
of increasing precedence:
|
of increasing precedence:
|
|
|
`,'
|
`,'
|
The comma or sequencing operator. Expressions in a
|
The comma or sequencing operator. Expressions in a
|
comma-separated list are evaluated from left to right, with the
|
comma-separated list are evaluated from left to right, with the
|
result of the entire expression being the last expression
|
result of the entire expression being the last expression
|
evaluated.
|
evaluated.
|
|
|
`='
|
`='
|
Assignment. The value of an assignment expression is the value
|
Assignment. The value of an assignment expression is the value
|
assigned. Defined on scalar types.
|
assigned. Defined on scalar types.
|
|
|
`OP='
|
`OP='
|
Used in an expression of the form `A OP= B', and translated to
|
Used in an expression of the form `A OP= B', and translated to
|
`A = A OP B'. `OP=' and `=' have the same precedence. OP is any
|
`A = A OP B'. `OP=' and `=' have the same precedence. OP is any
|
one of the operators `|', `^', `&', `<<', `>>', `+', `-', `*',
|
one of the operators `|', `^', `&', `<<', `>>', `+', `-', `*',
|
`/', `%'.
|
`/', `%'.
|
|
|
`?:'
|
`?:'
|
The ternary operator. `A ? B : C' can be thought of as: if A
|
The ternary operator. `A ? B : C' can be thought of as: if A
|
then B else C. A should be of an integral type.
|
then B else C. A should be of an integral type.
|
|
|
`||'
|
`||'
|
Logical OR. Defined on integral types.
|
Logical OR. Defined on integral types.
|
|
|
`&&'
|
`&&'
|
Logical AND. Defined on integral types.
|
Logical AND. Defined on integral types.
|
|
|
`|'
|
`|'
|
Bitwise OR. Defined on integral types.
|
Bitwise OR. Defined on integral types.
|
|
|
`^'
|
`^'
|
Bitwise exclusive-OR. Defined on integral types.
|
Bitwise exclusive-OR. Defined on integral types.
|
|
|
`&'
|
`&'
|
Bitwise AND. Defined on integral types.
|
Bitwise AND. Defined on integral types.
|
|
|
`==, !='
|
`==, !='
|
Equality and inequality. Defined on scalar types. The value of
|
Equality and inequality. Defined on scalar types. The value of
|
these expressions is 0 for false and non-zero for true.
|
these expressions is 0 for false and non-zero for true.
|
|
|
`<, >, <=, >='
|
`<, >, <=, >='
|
Less than, greater than, less than or equal, greater than or equal.
|
Less than, greater than, less than or equal, greater than or equal.
|
Defined on scalar types. The value of these expressions is 0 for
|
Defined on scalar types. The value of these expressions is 0 for
|
false and non-zero for true.
|
false and non-zero for true.
|
|
|
`<<, >>'
|
`<<, >>'
|
left shift, and right shift. Defined on integral types.
|
left shift, and right shift. Defined on integral types.
|
|
|
`@'
|
`@'
|
The GDB "artificial array" operator (*note Expressions:
|
The GDB "artificial array" operator (*note Expressions:
|
Expressions.).
|
Expressions.).
|
|
|
`+, -'
|
`+, -'
|
Addition and subtraction. Defined on integral types,
|
Addition and subtraction. Defined on integral types,
|
floating-point types and pointer types.
|
floating-point types and pointer types.
|
|
|
`*, /, %'
|
`*, /, %'
|
Multiplication, division, and modulus. Multiplication and
|
Multiplication, division, and modulus. Multiplication and
|
division are defined on integral and floating-point types.
|
division are defined on integral and floating-point types.
|
Modulus is defined on integral types.
|
Modulus is defined on integral types.
|
|
|
`++, --'
|
`++, --'
|
Increment and decrement. When appearing before a variable, the
|
Increment and decrement. When appearing before a variable, the
|
operation is performed before the variable is used in an
|
operation is performed before the variable is used in an
|
expression; when appearing after it, the variable's value is used
|
expression; when appearing after it, the variable's value is used
|
before the operation takes place.
|
before the operation takes place.
|
|
|
`*'
|
`*'
|
Pointer dereferencing. Defined on pointer types. Same precedence
|
Pointer dereferencing. Defined on pointer types. Same precedence
|
as `++'.
|
as `++'.
|
|
|
`&'
|
`&'
|
Address operator. Defined on variables. Same precedence as `++'.
|
Address operator. Defined on variables. Same precedence as `++'.
|
|
|
For debugging C++, GDB implements a use of `&' beyond what is
|
For debugging C++, GDB implements a use of `&' beyond what is
|
allowed in the C++ language itself: you can use `&(&REF)' to
|
allowed in the C++ language itself: you can use `&(&REF)' to
|
examine the address where a C++ reference variable (declared with
|
examine the address where a C++ reference variable (declared with
|
`&REF') is stored.
|
`&REF') is stored.
|
|
|
`-'
|
`-'
|
Negative. Defined on integral and floating-point types. Same
|
Negative. Defined on integral and floating-point types. Same
|
precedence as `++'.
|
precedence as `++'.
|
|
|
`!'
|
`!'
|
Logical negation. Defined on integral types. Same precedence as
|
Logical negation. Defined on integral types. Same precedence as
|
`++'.
|
`++'.
|
|
|
`~'
|
`~'
|
Bitwise complement operator. Defined on integral types. Same
|
Bitwise complement operator. Defined on integral types. Same
|
precedence as `++'.
|
precedence as `++'.
|
|
|
`., ->'
|
`., ->'
|
Structure member, and pointer-to-structure member. For
|
Structure member, and pointer-to-structure member. For
|
convenience, GDB regards the two as equivalent, choosing whether
|
convenience, GDB regards the two as equivalent, choosing whether
|
to dereference a pointer based on the stored type information.
|
to dereference a pointer based on the stored type information.
|
Defined on `struct' and `union' data.
|
Defined on `struct' and `union' data.
|
|
|
`.*, ->*'
|
`.*, ->*'
|
Dereferences of pointers to members.
|
Dereferences of pointers to members.
|
|
|
`[]'
|
`[]'
|
Array indexing. `A[I]' is defined as `*(A+I)'. Same precedence
|
Array indexing. `A[I]' is defined as `*(A+I)'. Same precedence
|
as `->'.
|
as `->'.
|
|
|
`()'
|
`()'
|
Function parameter list. Same precedence as `->'.
|
Function parameter list. Same precedence as `->'.
|
|
|
`::'
|
`::'
|
C++ scope resolution operator. Defined on `struct', `union', and
|
C++ scope resolution operator. Defined on `struct', `union', and
|
`class' types.
|
`class' types.
|
|
|
`::'
|
`::'
|
Doubled colons also represent the GDB scope operator (*note
|
Doubled colons also represent the GDB scope operator (*note
|
Expressions: Expressions.). Same precedence as `::', above.
|
Expressions: Expressions.). Same precedence as `::', above.
|
|
|
If an operator is redefined in the user code, GDB usually attempts
|
If an operator is redefined in the user code, GDB usually attempts
|
to invoke the redefined version instead of using the operator's
|
to invoke the redefined version instead of using the operator's
|
predefined meaning.
|
predefined meaning.
|
|
|
|
|
File: gdb.info, Node: C Constants, Next: C Plus Plus Expressions, Prev: C Operators, Up: C
|
File: gdb.info, Node: C Constants, Next: C Plus Plus Expressions, Prev: C Operators, Up: C
|
|
|
15.4.1.2 C and C++ Constants
|
15.4.1.2 C and C++ Constants
|
............................
|
............................
|
|
|
GDB allows you to express the constants of C and C++ in the following
|
GDB allows you to express the constants of C and C++ in the following
|
ways:
|
ways:
|
|
|
* Integer constants are a sequence of digits. Octal constants are
|
* Integer constants are a sequence of digits. Octal constants are
|
specified by a leading `0' (i.e. zero), and hexadecimal constants
|
specified by a leading `0' (i.e. zero), and hexadecimal constants
|
by a leading `0x' or `0X'. Constants may also end with a letter
|
by a leading `0x' or `0X'. Constants may also end with a letter
|
`l', specifying that the constant should be treated as a `long'
|
`l', specifying that the constant should be treated as a `long'
|
value.
|
value.
|
|
|
* Floating point constants are a sequence of digits, followed by a
|
* Floating point constants are a sequence of digits, followed by a
|
decimal point, followed by a sequence of digits, and optionally
|
decimal point, followed by a sequence of digits, and optionally
|
followed by an exponent. An exponent is of the form:
|
followed by an exponent. An exponent is of the form:
|
`e[[+]|-]NNN', where NNN is another sequence of digits. The `+'
|
`e[[+]|-]NNN', where NNN is another sequence of digits. The `+'
|
is optional for positive exponents. A floating-point constant may
|
is optional for positive exponents. A floating-point constant may
|
also end with a letter `f' or `F', specifying that the constant
|
also end with a letter `f' or `F', specifying that the constant
|
should be treated as being of the `float' (as opposed to the
|
should be treated as being of the `float' (as opposed to the
|
default `double') type; or with a letter `l' or `L', which
|
default `double') type; or with a letter `l' or `L', which
|
specifies a `long double' constant.
|
specifies a `long double' constant.
|
|
|
* Enumerated constants consist of enumerated identifiers, or their
|
* Enumerated constants consist of enumerated identifiers, or their
|
integral equivalents.
|
integral equivalents.
|
|
|
* Character constants are a single character surrounded by single
|
* Character constants are a single character surrounded by single
|
quotes (`''), or a number--the ordinal value of the corresponding
|
quotes (`''), or a number--the ordinal value of the corresponding
|
character (usually its ASCII value). Within quotes, the single
|
character (usually its ASCII value). Within quotes, the single
|
character may be represented by a letter or by "escape sequences",
|
character may be represented by a letter or by "escape sequences",
|
which are of the form `\NNN', where NNN is the octal representation
|
which are of the form `\NNN', where NNN is the octal representation
|
of the character's ordinal value; or of the form `\X', where `X'
|
of the character's ordinal value; or of the form `\X', where `X'
|
is a predefined special character--for example, `\n' for newline.
|
is a predefined special character--for example, `\n' for newline.
|
|
|
* String constants are a sequence of character constants surrounded
|
* String constants are a sequence of character constants surrounded
|
by double quotes (`"'). Any valid character constant (as described
|
by double quotes (`"'). Any valid character constant (as described
|
above) may appear. Double quotes within the string must be
|
above) may appear. Double quotes within the string must be
|
preceded by a backslash, so for instance `"a\"b'c"' is a string of
|
preceded by a backslash, so for instance `"a\"b'c"' is a string of
|
five characters.
|
five characters.
|
|
|
* Pointer constants are an integral value. You can also write
|
* Pointer constants are an integral value. You can also write
|
pointers to constants using the C operator `&'.
|
pointers to constants using the C operator `&'.
|
|
|
* Array constants are comma-separated lists surrounded by braces `{'
|
* Array constants are comma-separated lists surrounded by braces `{'
|
and `}'; for example, `{1,2,3}' is a three-element array of
|
and `}'; for example, `{1,2,3}' is a three-element array of
|
integers, `{{1,2}, {3,4}, {5,6}}' is a three-by-two array, and
|
integers, `{{1,2}, {3,4}, {5,6}}' is a three-by-two array, and
|
`{&"hi", &"there", &"fred"}' is a three-element array of pointers.
|
`{&"hi", &"there", &"fred"}' is a three-element array of pointers.
|
|
|
|
|
File: gdb.info, Node: C Plus Plus Expressions, Next: C Defaults, Prev: C Constants, Up: C
|
File: gdb.info, Node: C Plus Plus Expressions, Next: C Defaults, Prev: C Constants, Up: C
|
|
|
15.4.1.3 C++ Expressions
|
15.4.1.3 C++ Expressions
|
........................
|
........................
|
|
|
GDB expression handling can interpret most C++ expressions.
|
GDB expression handling can interpret most C++ expressions.
|
|
|
_Warning:_ GDB can only debug C++ code if you use the proper
|
_Warning:_ GDB can only debug C++ code if you use the proper
|
compiler and the proper debug format. Currently, GDB works best
|
compiler and the proper debug format. Currently, GDB works best
|
when debugging C++ code that is compiled with GCC 2.95.3 or with
|
when debugging C++ code that is compiled with GCC 2.95.3 or with
|
GCC 3.1 or newer, using the options `-gdwarf-2' or `-gstabs+'.
|
GCC 3.1 or newer, using the options `-gdwarf-2' or `-gstabs+'.
|
DWARF 2 is preferred over stabs+. Most configurations of GCC emit
|
DWARF 2 is preferred over stabs+. Most configurations of GCC emit
|
either DWARF 2 or stabs+ as their default debug format, so you
|
either DWARF 2 or stabs+ as their default debug format, so you
|
usually don't need to specify a debug format explicitly. Other
|
usually don't need to specify a debug format explicitly. Other
|
compilers and/or debug formats are likely to work badly or not at
|
compilers and/or debug formats are likely to work badly or not at
|
all when using GDB to debug C++ code.
|
all when using GDB to debug C++ code.
|
|
|
1. Member function calls are allowed; you can use expressions like
|
1. Member function calls are allowed; you can use expressions like
|
|
|
count = aml->GetOriginal(x, y)
|
count = aml->GetOriginal(x, y)
|
|
|
2. While a member function is active (in the selected stack frame),
|
2. While a member function is active (in the selected stack frame),
|
your expressions have the same namespace available as the member
|
your expressions have the same namespace available as the member
|
function; that is, GDB allows implicit references to the class
|
function; that is, GDB allows implicit references to the class
|
instance pointer `this' following the same rules as C++.
|
instance pointer `this' following the same rules as C++.
|
|
|
3. You can call overloaded functions; GDB resolves the function call
|
3. You can call overloaded functions; GDB resolves the function call
|
to the right definition, with some restrictions. GDB does not
|
to the right definition, with some restrictions. GDB does not
|
perform overload resolution involving user-defined type
|
perform overload resolution involving user-defined type
|
conversions, calls to constructors, or instantiations of templates
|
conversions, calls to constructors, or instantiations of templates
|
that do not exist in the program. It also cannot handle ellipsis
|
that do not exist in the program. It also cannot handle ellipsis
|
argument lists or default arguments.
|
argument lists or default arguments.
|
|
|
It does perform integral conversions and promotions, floating-point
|
It does perform integral conversions and promotions, floating-point
|
promotions, arithmetic conversions, pointer conversions,
|
promotions, arithmetic conversions, pointer conversions,
|
conversions of class objects to base classes, and standard
|
conversions of class objects to base classes, and standard
|
conversions such as those of functions or arrays to pointers; it
|
conversions such as those of functions or arrays to pointers; it
|
requires an exact match on the number of function arguments.
|
requires an exact match on the number of function arguments.
|
|
|
Overload resolution is always performed, unless you have specified
|
Overload resolution is always performed, unless you have specified
|
`set overload-resolution off'. *Note GDB Features for C++:
|
`set overload-resolution off'. *Note GDB Features for C++:
|
Debugging C Plus Plus.
|
Debugging C Plus Plus.
|
|
|
You must specify `set overload-resolution off' in order to use an
|
You must specify `set overload-resolution off' in order to use an
|
explicit function signature to call an overloaded function, as in
|
explicit function signature to call an overloaded function, as in
|
p 'foo(char,int)'('x', 13)
|
p 'foo(char,int)'('x', 13)
|
|
|
The GDB command-completion facility can simplify this; see *note
|
The GDB command-completion facility can simplify this; see *note
|
Command Completion: Completion.
|
Command Completion: Completion.
|
|
|
4. GDB understands variables declared as C++ references; you can use
|
4. GDB understands variables declared as C++ references; you can use
|
them in expressions just as you do in C++ source--they are
|
them in expressions just as you do in C++ source--they are
|
automatically dereferenced.
|
automatically dereferenced.
|
|
|
In the parameter list shown when GDB displays a frame, the values
|
In the parameter list shown when GDB displays a frame, the values
|
of reference variables are not displayed (unlike other variables);
|
of reference variables are not displayed (unlike other variables);
|
this avoids clutter, since references are often used for large
|
this avoids clutter, since references are often used for large
|
structures. The _address_ of a reference variable is always
|
structures. The _address_ of a reference variable is always
|
shown, unless you have specified `set print address off'.
|
shown, unless you have specified `set print address off'.
|
|
|
5. GDB supports the C++ name resolution operator `::'--your
|
5. GDB supports the C++ name resolution operator `::'--your
|
expressions can use it just as expressions in your program do.
|
expressions can use it just as expressions in your program do.
|
Since one scope may be defined in another, you can use `::'
|
Since one scope may be defined in another, you can use `::'
|
repeatedly if necessary, for example in an expression like
|
repeatedly if necessary, for example in an expression like
|
`SCOPE1::SCOPE2::NAME'. GDB also allows resolving name scope by
|
`SCOPE1::SCOPE2::NAME'. GDB also allows resolving name scope by
|
reference to source files, in both C and C++ debugging (*note
|
reference to source files, in both C and C++ debugging (*note
|
Program Variables: Variables.).
|
Program Variables: Variables.).
|
|
|
In addition, when used with HP's C++ compiler, GDB supports calling
|
In addition, when used with HP's C++ compiler, GDB supports calling
|
virtual functions correctly, printing out virtual bases of objects,
|
virtual functions correctly, printing out virtual bases of objects,
|
calling functions in a base subobject, casting objects, and invoking
|
calling functions in a base subobject, casting objects, and invoking
|
user-defined operators.
|
user-defined operators.
|
|
|
|
|
File: gdb.info, Node: C Defaults, Next: C Checks, Prev: C Plus Plus Expressions, Up: C
|
File: gdb.info, Node: C Defaults, Next: C Checks, Prev: C Plus Plus Expressions, Up: C
|
|
|
15.4.1.4 C and C++ Defaults
|
15.4.1.4 C and C++ Defaults
|
...........................
|
...........................
|
|
|
If you allow GDB to set type and range checking automatically, they
|
If you allow GDB to set type and range checking automatically, they
|
both default to `off' whenever the working language changes to C or
|
both default to `off' whenever the working language changes to C or
|
C++. This happens regardless of whether you or GDB selects the working
|
C++. This happens regardless of whether you or GDB selects the working
|
language.
|
language.
|
|
|
If you allow GDB to set the language automatically, it recognizes
|
If you allow GDB to set the language automatically, it recognizes
|
source files whose names end with `.c', `.C', or `.cc', etc, and when
|
source files whose names end with `.c', `.C', or `.cc', etc, and when
|
GDB enters code compiled from one of these files, it sets the working
|
GDB enters code compiled from one of these files, it sets the working
|
language to C or C++. *Note Having GDB Infer the Source Language:
|
language to C or C++. *Note Having GDB Infer the Source Language:
|
Automatically, for further details.
|
Automatically, for further details.
|
|
|
|
|
File: gdb.info, Node: C Checks, Next: Debugging C, Prev: C Defaults, Up: C
|
File: gdb.info, Node: C Checks, Next: Debugging C, Prev: C Defaults, Up: C
|
|
|
15.4.1.5 C and C++ Type and Range Checks
|
15.4.1.5 C and C++ Type and Range Checks
|
........................................
|
........................................
|
|
|
By default, when GDB parses C or C++ expressions, type checking is not
|
By default, when GDB parses C or C++ expressions, type checking is not
|
used. However, if you turn type checking on, GDB considers two
|
used. However, if you turn type checking on, GDB considers two
|
variables type equivalent if:
|
variables type equivalent if:
|
|
|
* The two variables are structured and have the same structure,
|
* The two variables are structured and have the same structure,
|
union, or enumerated tag.
|
union, or enumerated tag.
|
|
|
* The two variables have the same type name, or types that have been
|
* The two variables have the same type name, or types that have been
|
declared equivalent through `typedef'.
|
declared equivalent through `typedef'.
|
|
|
|
|
Range checking, if turned on, is done on mathematical operations.
|
Range checking, if turned on, is done on mathematical operations.
|
Array indices are not checked, since they are often used to index a
|
Array indices are not checked, since they are often used to index a
|
pointer that is not itself an array.
|
pointer that is not itself an array.
|
|
|
|
|
File: gdb.info, Node: Debugging C, Next: Debugging C Plus Plus, Prev: C Checks, Up: C
|
File: gdb.info, Node: Debugging C, Next: Debugging C Plus Plus, Prev: C Checks, Up: C
|
|
|
15.4.1.6 GDB and C
|
15.4.1.6 GDB and C
|
..................
|
..................
|
|
|
The `set print union' and `show print union' commands apply to the
|
The `set print union' and `show print union' commands apply to the
|
`union' type. When set to `on', any `union' that is inside a `struct'
|
`union' type. When set to `on', any `union' that is inside a `struct'
|
or `class' is also printed. Otherwise, it appears as `{...}'.
|
or `class' is also printed. Otherwise, it appears as `{...}'.
|
|
|
The `@' operator aids in the debugging of dynamic arrays, formed
|
The `@' operator aids in the debugging of dynamic arrays, formed
|
with pointers and a memory allocation function. *Note Expressions:
|
with pointers and a memory allocation function. *Note Expressions:
|
Expressions.
|
Expressions.
|
|
|
|
|
File: gdb.info, Node: Debugging C Plus Plus, Next: Decimal Floating Point, Prev: Debugging C, Up: C
|
File: gdb.info, Node: Debugging C Plus Plus, Next: Decimal Floating Point, Prev: Debugging C, Up: C
|
|
|
15.4.1.7 GDB Features for C++
|
15.4.1.7 GDB Features for C++
|
.............................
|
.............................
|
|
|
Some GDB commands are particularly useful with C++, and some are
|
Some GDB commands are particularly useful with C++, and some are
|
designed specifically for use with C++. Here is a summary:
|
designed specifically for use with C++. Here is a summary:
|
|
|
`breakpoint menus'
|
`breakpoint menus'
|
When you want a breakpoint in a function whose name is overloaded,
|
When you want a breakpoint in a function whose name is overloaded,
|
GDB has the capability to display a menu of possible breakpoint
|
GDB has the capability to display a menu of possible breakpoint
|
locations to help you specify which function definition you want.
|
locations to help you specify which function definition you want.
|
*Note Ambiguous Expressions: Ambiguous Expressions.
|
*Note Ambiguous Expressions: Ambiguous Expressions.
|
|
|
`rbreak REGEX'
|
`rbreak REGEX'
|
Setting breakpoints using regular expressions is helpful for
|
Setting breakpoints using regular expressions is helpful for
|
setting breakpoints on overloaded functions that are not members
|
setting breakpoints on overloaded functions that are not members
|
of any special classes. *Note Setting Breakpoints: Set Breaks.
|
of any special classes. *Note Setting Breakpoints: Set Breaks.
|
|
|
`catch throw'
|
`catch throw'
|
`catch catch'
|
`catch catch'
|
Debug C++ exception handling using these commands. *Note Setting
|
Debug C++ exception handling using these commands. *Note Setting
|
Catchpoints: Set Catchpoints.
|
Catchpoints: Set Catchpoints.
|
|
|
`ptype TYPENAME'
|
`ptype TYPENAME'
|
Print inheritance relationships as well as other information for
|
Print inheritance relationships as well as other information for
|
type TYPENAME. *Note Examining the Symbol Table: Symbols.
|
type TYPENAME. *Note Examining the Symbol Table: Symbols.
|
|
|
`set print demangle'
|
`set print demangle'
|
`show print demangle'
|
`show print demangle'
|
`set print asm-demangle'
|
`set print asm-demangle'
|
`show print asm-demangle'
|
`show print asm-demangle'
|
Control whether C++ symbols display in their source form, both when
|
Control whether C++ symbols display in their source form, both when
|
displaying code as C++ source and when displaying disassemblies.
|
displaying code as C++ source and when displaying disassemblies.
|
*Note Print Settings: Print Settings.
|
*Note Print Settings: Print Settings.
|
|
|
`set print object'
|
`set print object'
|
`show print object'
|
`show print object'
|
Choose whether to print derived (actual) or declared types of
|
Choose whether to print derived (actual) or declared types of
|
objects. *Note Print Settings: Print Settings.
|
objects. *Note Print Settings: Print Settings.
|
|
|
`set print vtbl'
|
`set print vtbl'
|
`show print vtbl'
|
`show print vtbl'
|
Control the format for printing virtual function tables. *Note
|
Control the format for printing virtual function tables. *Note
|
Print Settings: Print Settings. (The `vtbl' commands do not work
|
Print Settings: Print Settings. (The `vtbl' commands do not work
|
on programs compiled with the HP ANSI C++ compiler (`aCC').)
|
on programs compiled with the HP ANSI C++ compiler (`aCC').)
|
|
|
`set overload-resolution on'
|
`set overload-resolution on'
|
Enable overload resolution for C++ expression evaluation. The
|
Enable overload resolution for C++ expression evaluation. The
|
default is on. For overloaded functions, GDB evaluates the
|
default is on. For overloaded functions, GDB evaluates the
|
arguments and searches for a function whose signature matches the
|
arguments and searches for a function whose signature matches the
|
argument types, using the standard C++ conversion rules (see *note
|
argument types, using the standard C++ conversion rules (see *note
|
C++ Expressions: C Plus Plus Expressions, for details). If it
|
C++ Expressions: C Plus Plus Expressions, for details). If it
|
cannot find a match, it emits a message.
|
cannot find a match, it emits a message.
|
|
|
`set overload-resolution off'
|
`set overload-resolution off'
|
Disable overload resolution for C++ expression evaluation. For
|
Disable overload resolution for C++ expression evaluation. For
|
overloaded functions that are not class member functions, GDB
|
overloaded functions that are not class member functions, GDB
|
chooses the first function of the specified name that it finds in
|
chooses the first function of the specified name that it finds in
|
the symbol table, whether or not its arguments are of the correct
|
the symbol table, whether or not its arguments are of the correct
|
type. For overloaded functions that are class member functions,
|
type. For overloaded functions that are class member functions,
|
GDB searches for a function whose signature _exactly_ matches the
|
GDB searches for a function whose signature _exactly_ matches the
|
argument types.
|
argument types.
|
|
|
`show overload-resolution'
|
`show overload-resolution'
|
Show the current setting of overload resolution.
|
Show the current setting of overload resolution.
|
|
|
`Overloaded symbol names'
|
`Overloaded symbol names'
|
You can specify a particular definition of an overloaded symbol,
|
You can specify a particular definition of an overloaded symbol,
|
using the same notation that is used to declare such symbols in
|
using the same notation that is used to declare such symbols in
|
C++: type `SYMBOL(TYPES)' rather than just SYMBOL. You can also
|
C++: type `SYMBOL(TYPES)' rather than just SYMBOL. You can also
|
use the GDB command-line word completion facilities to list the
|
use the GDB command-line word completion facilities to list the
|
available choices, or to finish the type list for you. *Note
|
available choices, or to finish the type list for you. *Note
|
Command Completion: Completion, for details on how to do this.
|
Command Completion: Completion, for details on how to do this.
|
|
|
|
|
File: gdb.info, Node: Decimal Floating Point, Prev: Debugging C Plus Plus, Up: C
|
File: gdb.info, Node: Decimal Floating Point, Prev: Debugging C Plus Plus, Up: C
|
|
|
15.4.1.8 Decimal Floating Point format
|
15.4.1.8 Decimal Floating Point format
|
......................................
|
......................................
|
|
|
GDB can examine, set and perform computations with numbers in decimal
|
GDB can examine, set and perform computations with numbers in decimal
|
floating point format, which in the C language correspond to the
|
floating point format, which in the C language correspond to the
|
`_Decimal32', `_Decimal64' and `_Decimal128' types as specified by the
|
`_Decimal32', `_Decimal64' and `_Decimal128' types as specified by the
|
extension to support decimal floating-point arithmetic.
|
extension to support decimal floating-point arithmetic.
|
|
|
There are two encodings in use, depending on the architecture: BID
|
There are two encodings in use, depending on the architecture: BID
|
(Binary Integer Decimal) for x86 and x86-64, and DPD (Densely Packed
|
(Binary Integer Decimal) for x86 and x86-64, and DPD (Densely Packed
|
Decimal) for PowerPC. GDB will use the appropriate encoding for the
|
Decimal) for PowerPC. GDB will use the appropriate encoding for the
|
configured target.
|
configured target.
|
|
|
Because of a limitation in `libdecnumber', the library used by GDB
|
Because of a limitation in `libdecnumber', the library used by GDB
|
to manipulate decimal floating point numbers, it is not possible to
|
to manipulate decimal floating point numbers, it is not possible to
|
convert (using a cast, for example) integers wider than 32-bit to
|
convert (using a cast, for example) integers wider than 32-bit to
|
decimal float.
|
decimal float.
|
|
|
In addition, in order to imitate GDB's behaviour with binary floating
|
In addition, in order to imitate GDB's behaviour with binary floating
|
point computations, error checking in decimal float operations ignores
|
point computations, error checking in decimal float operations ignores
|
underflow, overflow and divide by zero exceptions.
|
underflow, overflow and divide by zero exceptions.
|
|
|
In the PowerPC architecture, GDB provides a set of pseudo-registers
|
In the PowerPC architecture, GDB provides a set of pseudo-registers
|
to inspect `_Decimal128' values stored in floating point registers.
|
to inspect `_Decimal128' values stored in floating point registers.
|
See *note PowerPC: PowerPC. for more details.
|
See *note PowerPC: PowerPC. for more details.
|
|
|
|
|
File: gdb.info, Node: D, Next: Objective-C, Prev: C, Up: Supported Languages
|
File: gdb.info, Node: D, Next: Objective-C, Prev: C, Up: Supported Languages
|
|
|
15.4.2 D
|
15.4.2 D
|
--------
|
--------
|
|
|
GDB can be used to debug programs written in D and compiled with GDC,
|
GDB can be used to debug programs written in D and compiled with GDC,
|
LDC or DMD compilers. Currently GDB supports only one D specific
|
LDC or DMD compilers. Currently GDB supports only one D specific
|
feature -- dynamic arrays.
|
feature -- dynamic arrays.
|
|
|
|
|
File: gdb.info, Node: Objective-C, Next: Fortran, Prev: D, Up: Supported Languages
|
File: gdb.info, Node: Objective-C, Next: Fortran, Prev: D, Up: Supported Languages
|
|
|
15.4.3 Objective-C
|
15.4.3 Objective-C
|
------------------
|
------------------
|
|
|
This section provides information about some commands and command
|
This section provides information about some commands and command
|
options that are useful for debugging Objective-C code. See also *note
|
options that are useful for debugging Objective-C code. See also *note
|
info classes: Symbols, and *note info selectors: Symbols, for a few
|
info classes: Symbols, and *note info selectors: Symbols, for a few
|
more commands specific to Objective-C support.
|
more commands specific to Objective-C support.
|
|
|
* Menu:
|
* Menu:
|
|
|
* Method Names in Commands::
|
* Method Names in Commands::
|
* The Print Command with Objective-C::
|
* The Print Command with Objective-C::
|
|
|
|
|
File: gdb.info, Node: Method Names in Commands, Next: The Print Command with Objective-C, Up: Objective-C
|
File: gdb.info, Node: Method Names in Commands, Next: The Print Command with Objective-C, Up: Objective-C
|
|
|
15.4.3.1 Method Names in Commands
|
15.4.3.1 Method Names in Commands
|
.................................
|
.................................
|
|
|
The following commands have been extended to accept Objective-C method
|
The following commands have been extended to accept Objective-C method
|
names as line specifications:
|
names as line specifications:
|
|
|
* `clear'
|
* `clear'
|
|
|
* `break'
|
* `break'
|
|
|
* `info line'
|
* `info line'
|
|
|
* `jump'
|
* `jump'
|
|
|
* `list'
|
* `list'
|
|
|
A fully qualified Objective-C method name is specified as
|
A fully qualified Objective-C method name is specified as
|
|
|
-[CLASS METHODNAME]
|
-[CLASS METHODNAME]
|
|
|
where the minus sign is used to indicate an instance method and a
|
where the minus sign is used to indicate an instance method and a
|
plus sign (not shown) is used to indicate a class method. The class
|
plus sign (not shown) is used to indicate a class method. The class
|
name CLASS and method name METHODNAME are enclosed in brackets, similar
|
name CLASS and method name METHODNAME are enclosed in brackets, similar
|
to the way messages are specified in Objective-C source code. For
|
to the way messages are specified in Objective-C source code. For
|
example, to set a breakpoint at the `create' instance method of class
|
example, to set a breakpoint at the `create' instance method of class
|
`Fruit' in the program currently being debugged, enter:
|
`Fruit' in the program currently being debugged, enter:
|
|
|
break -[Fruit create]
|
break -[Fruit create]
|
|
|
To list ten program lines around the `initialize' class method,
|
To list ten program lines around the `initialize' class method,
|
enter:
|
enter:
|
|
|
list +[NSText initialize]
|
list +[NSText initialize]
|
|
|
In the current version of GDB, the plus or minus sign is required.
|
In the current version of GDB, the plus or minus sign is required.
|
In future versions of GDB, the plus or minus sign will be optional, but
|
In future versions of GDB, the plus or minus sign will be optional, but
|
you can use it to narrow the search. It is also possible to specify
|
you can use it to narrow the search. It is also possible to specify
|
just a method name:
|
just a method name:
|
|
|
break create
|
break create
|
|
|
You must specify the complete method name, including any colons. If
|
You must specify the complete method name, including any colons. If
|
your program's source files contain more than one `create' method,
|
your program's source files contain more than one `create' method,
|
you'll be presented with a numbered list of classes that implement that
|
you'll be presented with a numbered list of classes that implement that
|
method. Indicate your choice by number, or type `0' to exit if none
|
method. Indicate your choice by number, or type `0' to exit if none
|
apply.
|
apply.
|
|
|
As another example, to clear a breakpoint established at the
|
As another example, to clear a breakpoint established at the
|
`makeKeyAndOrderFront:' method of the `NSWindow' class, enter:
|
`makeKeyAndOrderFront:' method of the `NSWindow' class, enter:
|
|
|
clear -[NSWindow makeKeyAndOrderFront:]
|
clear -[NSWindow makeKeyAndOrderFront:]
|
|
|
|
|
File: gdb.info, Node: The Print Command with Objective-C, Prev: Method Names in Commands, Up: Objective-C
|
File: gdb.info, Node: The Print Command with Objective-C, Prev: Method Names in Commands, Up: Objective-C
|
|
|
15.4.3.2 The Print Command With Objective-C
|
15.4.3.2 The Print Command With Objective-C
|
...........................................
|
...........................................
|
|
|
The print command has also been extended to accept methods. For
|
The print command has also been extended to accept methods. For
|
example:
|
example:
|
|
|
print -[OBJECT hash]
|
print -[OBJECT hash]
|
|
|
will tell GDB to send the `hash' message to OBJECT and print the
|
will tell GDB to send the `hash' message to OBJECT and print the
|
result. Also, an additional command has been added, `print-object' or
|
result. Also, an additional command has been added, `print-object' or
|
`po' for short, which is meant to print the description of an object.
|
`po' for short, which is meant to print the description of an object.
|
However, this command may only work with certain Objective-C libraries
|
However, this command may only work with certain Objective-C libraries
|
that have a particular hook function, `_NSPrintForDebugger', defined.
|
that have a particular hook function, `_NSPrintForDebugger', defined.
|
|
|
|
|
File: gdb.info, Node: Fortran, Next: Pascal, Prev: Objective-C, Up: Supported Languages
|
File: gdb.info, Node: Fortran, Next: Pascal, Prev: Objective-C, Up: Supported Languages
|
|
|
15.4.4 Fortran
|
15.4.4 Fortran
|
--------------
|
--------------
|
|
|
GDB can be used to debug programs written in Fortran, but it currently
|
GDB can be used to debug programs written in Fortran, but it currently
|
supports only the features of Fortran 77 language.
|
supports only the features of Fortran 77 language.
|
|
|
Some Fortran compilers (GNU Fortran 77 and Fortran 95 compilers
|
Some Fortran compilers (GNU Fortran 77 and Fortran 95 compilers
|
among them) append an underscore to the names of variables and
|
among them) append an underscore to the names of variables and
|
functions. When you debug programs compiled by those compilers, you
|
functions. When you debug programs compiled by those compilers, you
|
will need to refer to variables and functions with a trailing
|
will need to refer to variables and functions with a trailing
|
underscore.
|
underscore.
|
|
|
* Menu:
|
* Menu:
|
|
|
* Fortran Operators:: Fortran operators and expressions
|
* Fortran Operators:: Fortran operators and expressions
|
* Fortran Defaults:: Default settings for Fortran
|
* Fortran Defaults:: Default settings for Fortran
|
* Special Fortran Commands:: Special GDB commands for Fortran
|
* Special Fortran Commands:: Special GDB commands for Fortran
|
|
|
|
|
File: gdb.info, Node: Fortran Operators, Next: Fortran Defaults, Up: Fortran
|
File: gdb.info, Node: Fortran Operators, Next: Fortran Defaults, Up: Fortran
|
|
|
15.4.4.1 Fortran Operators and Expressions
|
15.4.4.1 Fortran Operators and Expressions
|
..........................................
|
..........................................
|
|
|
Operators must be defined on values of specific types. For instance,
|
Operators must be defined on values of specific types. For instance,
|
`+' is defined on numbers, but not on characters or other non-
|
`+' is defined on numbers, but not on characters or other non-
|
arithmetic types. Operators are often defined on groups of types.
|
arithmetic types. Operators are often defined on groups of types.
|
|
|
`**'
|
`**'
|
The exponentiation operator. It raises the first operand to the
|
The exponentiation operator. It raises the first operand to the
|
power of the second one.
|
power of the second one.
|
|
|
`:'
|
`:'
|
The range operator. Normally used in the form of array(low:high)
|
The range operator. Normally used in the form of array(low:high)
|
to represent a section of array.
|
to represent a section of array.
|
|
|
`%'
|
`%'
|
The access component operator. Normally used to access elements
|
The access component operator. Normally used to access elements
|
in derived types. Also suitable for unions. As unions aren't
|
in derived types. Also suitable for unions. As unions aren't
|
part of regular Fortran, this can only happen when accessing a
|
part of regular Fortran, this can only happen when accessing a
|
register that uses a gdbarch-defined union type.
|
register that uses a gdbarch-defined union type.
|
|
|
|
|
File: gdb.info, Node: Fortran Defaults, Next: Special Fortran Commands, Prev: Fortran Operators, Up: Fortran
|
File: gdb.info, Node: Fortran Defaults, Next: Special Fortran Commands, Prev: Fortran Operators, Up: Fortran
|
|
|
15.4.4.2 Fortran Defaults
|
15.4.4.2 Fortran Defaults
|
.........................
|
.........................
|
|
|
Fortran symbols are usually case-insensitive, so GDB by default uses
|
Fortran symbols are usually case-insensitive, so GDB by default uses
|
case-insensitive matches for Fortran symbols. You can change that with
|
case-insensitive matches for Fortran symbols. You can change that with
|
the `set case-insensitive' command, see *note Symbols::, for the
|
the `set case-insensitive' command, see *note Symbols::, for the
|
details.
|
details.
|
|
|
|
|
File: gdb.info, Node: Special Fortran Commands, Prev: Fortran Defaults, Up: Fortran
|
File: gdb.info, Node: Special Fortran Commands, Prev: Fortran Defaults, Up: Fortran
|
|
|
15.4.4.3 Special Fortran Commands
|
15.4.4.3 Special Fortran Commands
|
.................................
|
.................................
|
|
|
GDB has some commands to support Fortran-specific features, such as
|
GDB has some commands to support Fortran-specific features, such as
|
displaying common blocks.
|
displaying common blocks.
|
|
|
`info common [COMMON-NAME]'
|
`info common [COMMON-NAME]'
|
This command prints the values contained in the Fortran `COMMON'
|
This command prints the values contained in the Fortran `COMMON'
|
block whose name is COMMON-NAME. With no argument, the names of
|
block whose name is COMMON-NAME. With no argument, the names of
|
all `COMMON' blocks visible at the current program location are
|
all `COMMON' blocks visible at the current program location are
|
printed.
|
printed.
|
|
|
|
|
File: gdb.info, Node: Pascal, Next: Modula-2, Prev: Fortran, Up: Supported Languages
|
File: gdb.info, Node: Pascal, Next: Modula-2, Prev: Fortran, Up: Supported Languages
|
|
|
15.4.5 Pascal
|
15.4.5 Pascal
|
-------------
|
-------------
|
|
|
Debugging Pascal programs which use sets, subranges, file variables, or
|
Debugging Pascal programs which use sets, subranges, file variables, or
|
nested functions does not currently work. GDB does not support
|
nested functions does not currently work. GDB does not support
|
entering expressions, printing values, or similar features using Pascal
|
entering expressions, printing values, or similar features using Pascal
|
syntax.
|
syntax.
|
|
|
The Pascal-specific command `set print pascal_static-members'
|
The Pascal-specific command `set print pascal_static-members'
|
controls whether static members of Pascal objects are displayed. *Note
|
controls whether static members of Pascal objects are displayed. *Note
|
pascal_static-members: Print Settings.
|
pascal_static-members: Print Settings.
|
|
|
|
|
File: gdb.info, Node: Modula-2, Next: Ada, Prev: Pascal, Up: Supported Languages
|
File: gdb.info, Node: Modula-2, Next: Ada, Prev: Pascal, Up: Supported Languages
|
|
|
15.4.6 Modula-2
|
15.4.6 Modula-2
|
---------------
|
---------------
|
|
|
The extensions made to GDB to support Modula-2 only support output from
|
The extensions made to GDB to support Modula-2 only support output from
|
the GNU Modula-2 compiler (which is currently being developed). Other
|
the GNU Modula-2 compiler (which is currently being developed). Other
|
Modula-2 compilers are not currently supported, and attempting to debug
|
Modula-2 compilers are not currently supported, and attempting to debug
|
executables produced by them is most likely to give an error as GDB
|
executables produced by them is most likely to give an error as GDB
|
reads in the executable's symbol table.
|
reads in the executable's symbol table.
|
|
|
* Menu:
|
* Menu:
|
|
|
* M2 Operators:: Built-in operators
|
* M2 Operators:: Built-in operators
|
* Built-In Func/Proc:: Built-in functions and procedures
|
* Built-In Func/Proc:: Built-in functions and procedures
|
* M2 Constants:: Modula-2 constants
|
* M2 Constants:: Modula-2 constants
|
* M2 Types:: Modula-2 types
|
* M2 Types:: Modula-2 types
|
* M2 Defaults:: Default settings for Modula-2
|
* M2 Defaults:: Default settings for Modula-2
|
* Deviations:: Deviations from standard Modula-2
|
* Deviations:: Deviations from standard Modula-2
|
* M2 Checks:: Modula-2 type and range checks
|
* M2 Checks:: Modula-2 type and range checks
|
* M2 Scope:: The scope operators `::' and `.'
|
* M2 Scope:: The scope operators `::' and `.'
|
* GDB/M2:: GDB and Modula-2
|
* GDB/M2:: GDB and Modula-2
|
|
|
|
|
File: gdb.info, Node: M2 Operators, Next: Built-In Func/Proc, Up: Modula-2
|
File: gdb.info, Node: M2 Operators, Next: Built-In Func/Proc, Up: Modula-2
|
|
|
15.4.6.1 Operators
|
15.4.6.1 Operators
|
..................
|
..................
|
|
|
Operators must be defined on values of specific types. For instance,
|
Operators must be defined on values of specific types. For instance,
|
`+' is defined on numbers, but not on structures. Operators are often
|
`+' is defined on numbers, but not on structures. Operators are often
|
defined on groups of types. For the purposes of Modula-2, the
|
defined on groups of types. For the purposes of Modula-2, the
|
following definitions hold:
|
following definitions hold:
|
|
|
* _Integral types_ consist of `INTEGER', `CARDINAL', and their
|
* _Integral types_ consist of `INTEGER', `CARDINAL', and their
|
subranges.
|
subranges.
|
|
|
* _Character types_ consist of `CHAR' and its subranges.
|
* _Character types_ consist of `CHAR' and its subranges.
|
|
|
* _Floating-point types_ consist of `REAL'.
|
* _Floating-point types_ consist of `REAL'.
|
|
|
* _Pointer types_ consist of anything declared as `POINTER TO TYPE'.
|
* _Pointer types_ consist of anything declared as `POINTER TO TYPE'.
|
|
|
* _Scalar types_ consist of all of the above.
|
* _Scalar types_ consist of all of the above.
|
|
|
* _Set types_ consist of `SET' and `BITSET' types.
|
* _Set types_ consist of `SET' and `BITSET' types.
|
|
|
* _Boolean types_ consist of `BOOLEAN'.
|
* _Boolean types_ consist of `BOOLEAN'.
|
|
|
The following operators are supported, and appear in order of
|
The following operators are supported, and appear in order of
|
increasing precedence:
|
increasing precedence:
|
|
|
`,'
|
`,'
|
Function argument or array index separator.
|
Function argument or array index separator.
|
|
|
`:='
|
`:='
|
Assignment. The value of VAR `:=' VALUE is VALUE.
|
Assignment. The value of VAR `:=' VALUE is VALUE.
|
|
|
`<, >'
|
`<, >'
|
Less than, greater than on integral, floating-point, or enumerated
|
Less than, greater than on integral, floating-point, or enumerated
|
types.
|
types.
|
|
|
`<=, >='
|
`<=, >='
|
Less than or equal to, greater than or equal to on integral,
|
Less than or equal to, greater than or equal to on integral,
|
floating-point and enumerated types, or set inclusion on set
|
floating-point and enumerated types, or set inclusion on set
|
types. Same precedence as `<'.
|
types. Same precedence as `<'.
|
|
|
`=, <>, #'
|
`=, <>, #'
|
Equality and two ways of expressing inequality, valid on scalar
|
Equality and two ways of expressing inequality, valid on scalar
|
types. Same precedence as `<'. In GDB scripts, only `<>' is
|
types. Same precedence as `<'. In GDB scripts, only `<>' is
|
available for inequality, since `#' conflicts with the script
|
available for inequality, since `#' conflicts with the script
|
comment character.
|
comment character.
|
|
|
`IN'
|
`IN'
|
Set membership. Defined on set types and the types of their
|
Set membership. Defined on set types and the types of their
|
members. Same precedence as `<'.
|
members. Same precedence as `<'.
|
|
|
`OR'
|
`OR'
|
Boolean disjunction. Defined on boolean types.
|
Boolean disjunction. Defined on boolean types.
|
|
|
`AND, &'
|
`AND, &'
|
Boolean conjunction. Defined on boolean types.
|
Boolean conjunction. Defined on boolean types.
|
|
|
`@'
|
`@'
|
The GDB "artificial array" operator (*note Expressions:
|
The GDB "artificial array" operator (*note Expressions:
|
Expressions.).
|
Expressions.).
|
|
|
`+, -'
|
`+, -'
|
Addition and subtraction on integral and floating-point types, or
|
Addition and subtraction on integral and floating-point types, or
|
union and difference on set types.
|
union and difference on set types.
|
|
|
`*'
|
`*'
|
Multiplication on integral and floating-point types, or set
|
Multiplication on integral and floating-point types, or set
|
intersection on set types.
|
intersection on set types.
|
|
|
`/'
|
`/'
|
Division on floating-point types, or symmetric set difference on
|
Division on floating-point types, or symmetric set difference on
|
set types. Same precedence as `*'.
|
set types. Same precedence as `*'.
|
|
|
`DIV, MOD'
|
`DIV, MOD'
|
Integer division and remainder. Defined on integral types. Same
|
Integer division and remainder. Defined on integral types. Same
|
precedence as `*'.
|
precedence as `*'.
|
|
|
`-'
|
`-'
|
Negative. Defined on `INTEGER' and `REAL' data.
|
Negative. Defined on `INTEGER' and `REAL' data.
|
|
|
`^'
|
`^'
|
Pointer dereferencing. Defined on pointer types.
|
Pointer dereferencing. Defined on pointer types.
|
|
|
`NOT'
|
`NOT'
|
Boolean negation. Defined on boolean types. Same precedence as
|
Boolean negation. Defined on boolean types. Same precedence as
|
`^'.
|
`^'.
|
|
|
`.'
|
`.'
|
`RECORD' field selector. Defined on `RECORD' data. Same
|
`RECORD' field selector. Defined on `RECORD' data. Same
|
precedence as `^'.
|
precedence as `^'.
|
|
|
`[]'
|
`[]'
|
Array indexing. Defined on `ARRAY' data. Same precedence as `^'.
|
Array indexing. Defined on `ARRAY' data. Same precedence as `^'.
|
|
|
`()'
|
`()'
|
Procedure argument list. Defined on `PROCEDURE' objects. Same
|
Procedure argument list. Defined on `PROCEDURE' objects. Same
|
precedence as `^'.
|
precedence as `^'.
|
|
|
`::, .'
|
`::, .'
|
GDB and Modula-2 scope operators.
|
GDB and Modula-2 scope operators.
|
|
|
_Warning:_ Set expressions and their operations are not yet
|
_Warning:_ Set expressions and their operations are not yet
|
supported, so GDB treats the use of the operator `IN', or the use
|
supported, so GDB treats the use of the operator `IN', or the use
|
of operators `+', `-', `*', `/', `=', , `<>', `#', `<=', and `>='
|
of operators `+', `-', `*', `/', `=', , `<>', `#', `<=', and `>='
|
on sets as an error.
|
on sets as an error.
|
|
|
|
|
File: gdb.info, Node: Built-In Func/Proc, Next: M2 Constants, Prev: M2 Operators, Up: Modula-2
|
File: gdb.info, Node: Built-In Func/Proc, Next: M2 Constants, Prev: M2 Operators, Up: Modula-2
|
|
|
15.4.6.2 Built-in Functions and Procedures
|
15.4.6.2 Built-in Functions and Procedures
|
..........................................
|
..........................................
|
|
|
Modula-2 also makes available several built-in procedures and functions.
|
Modula-2 also makes available several built-in procedures and functions.
|
In describing these, the following metavariables are used:
|
In describing these, the following metavariables are used:
|
|
|
A
|
A
|
represents an `ARRAY' variable.
|
represents an `ARRAY' variable.
|
|
|
C
|
C
|
represents a `CHAR' constant or variable.
|
represents a `CHAR' constant or variable.
|
|
|
I
|
I
|
represents a variable or constant of integral type.
|
represents a variable or constant of integral type.
|
|
|
M
|
M
|
represents an identifier that belongs to a set. Generally used in
|
represents an identifier that belongs to a set. Generally used in
|
the same function with the metavariable S. The type of S should
|
the same function with the metavariable S. The type of S should
|
be `SET OF MTYPE' (where MTYPE is the type of M).
|
be `SET OF MTYPE' (where MTYPE is the type of M).
|
|
|
N
|
N
|
represents a variable or constant of integral or floating-point
|
represents a variable or constant of integral or floating-point
|
type.
|
type.
|
|
|
R
|
R
|
represents a variable or constant of floating-point type.
|
represents a variable or constant of floating-point type.
|
|
|
T
|
T
|
represents a type.
|
represents a type.
|
|
|
V
|
V
|
represents a variable.
|
represents a variable.
|
|
|
X
|
X
|
represents a variable or constant of one of many types. See the
|
represents a variable or constant of one of many types. See the
|
explanation of the function for details.
|
explanation of the function for details.
|
|
|
All Modula-2 built-in procedures also return a result, described
|
All Modula-2 built-in procedures also return a result, described
|
below.
|
below.
|
|
|
`ABS(N)'
|
`ABS(N)'
|
Returns the absolute value of N.
|
Returns the absolute value of N.
|
|
|
`CAP(C)'
|
`CAP(C)'
|
If C is a lower case letter, it returns its upper case equivalent,
|
If C is a lower case letter, it returns its upper case equivalent,
|
otherwise it returns its argument.
|
otherwise it returns its argument.
|
|
|
`CHR(I)'
|
`CHR(I)'
|
Returns the character whose ordinal value is I.
|
Returns the character whose ordinal value is I.
|
|
|
`DEC(V)'
|
`DEC(V)'
|
Decrements the value in the variable V by one. Returns the new
|
Decrements the value in the variable V by one. Returns the new
|
value.
|
value.
|
|
|
`DEC(V,I)'
|
`DEC(V,I)'
|
Decrements the value in the variable V by I. Returns the new
|
Decrements the value in the variable V by I. Returns the new
|
value.
|
value.
|
|
|
`EXCL(M,S)'
|
`EXCL(M,S)'
|
Removes the element M from the set S. Returns the new set.
|
Removes the element M from the set S. Returns the new set.
|
|
|
`FLOAT(I)'
|
`FLOAT(I)'
|
Returns the floating point equivalent of the integer I.
|
Returns the floating point equivalent of the integer I.
|
|
|
`HIGH(A)'
|
`HIGH(A)'
|
Returns the index of the last member of A.
|
Returns the index of the last member of A.
|
|
|
`INC(V)'
|
`INC(V)'
|
Increments the value in the variable V by one. Returns the new
|
Increments the value in the variable V by one. Returns the new
|
value.
|
value.
|
|
|
`INC(V,I)'
|
`INC(V,I)'
|
Increments the value in the variable V by I. Returns the new
|
Increments the value in the variable V by I. Returns the new
|
value.
|
value.
|
|
|
`INCL(M,S)'
|
`INCL(M,S)'
|
Adds the element M to the set S if it is not already there.
|
Adds the element M to the set S if it is not already there.
|
Returns the new set.
|
Returns the new set.
|
|
|
`MAX(T)'
|
`MAX(T)'
|
Returns the maximum value of the type T.
|
Returns the maximum value of the type T.
|
|
|
`MIN(T)'
|
`MIN(T)'
|
Returns the minimum value of the type T.
|
Returns the minimum value of the type T.
|
|
|
`ODD(I)'
|
`ODD(I)'
|
Returns boolean TRUE if I is an odd number.
|
Returns boolean TRUE if I is an odd number.
|
|
|
`ORD(X)'
|
`ORD(X)'
|
Returns the ordinal value of its argument. For example, the
|
Returns the ordinal value of its argument. For example, the
|
ordinal value of a character is its ASCII value (on machines
|
ordinal value of a character is its ASCII value (on machines
|
supporting the ASCII character set). X must be of an ordered
|
supporting the ASCII character set). X must be of an ordered
|
type, which include integral, character and enumerated types.
|
type, which include integral, character and enumerated types.
|
|
|
`SIZE(X)'
|
`SIZE(X)'
|
Returns the size of its argument. X can be a variable or a type.
|
Returns the size of its argument. X can be a variable or a type.
|
|
|
`TRUNC(R)'
|
`TRUNC(R)'
|
Returns the integral part of R.
|
Returns the integral part of R.
|
|
|
`TSIZE(X)'
|
`TSIZE(X)'
|
Returns the size of its argument. X can be a variable or a type.
|
Returns the size of its argument. X can be a variable or a type.
|
|
|
`VAL(T,I)'
|
`VAL(T,I)'
|
Returns the member of the type T whose ordinal value is I.
|
Returns the member of the type T whose ordinal value is I.
|
|
|
_Warning:_ Sets and their operations are not yet supported, so
|
_Warning:_ Sets and their operations are not yet supported, so
|
GDB treats the use of procedures `INCL' and `EXCL' as an error.
|
GDB treats the use of procedures `INCL' and `EXCL' as an error.
|
|
|
|
|
File: gdb.info, Node: M2 Constants, Next: M2 Types, Prev: Built-In Func/Proc, Up: Modula-2
|
File: gdb.info, Node: M2 Constants, Next: M2 Types, Prev: Built-In Func/Proc, Up: Modula-2
|
|
|
15.4.6.3 Constants
|
15.4.6.3 Constants
|
..................
|
..................
|
|
|
GDB allows you to express the constants of Modula-2 in the following
|
GDB allows you to express the constants of Modula-2 in the following
|
ways:
|
ways:
|
|
|
* Integer constants are simply a sequence of digits. When used in an
|
* Integer constants are simply a sequence of digits. When used in an
|
expression, a constant is interpreted to be type-compatible with
|
expression, a constant is interpreted to be type-compatible with
|
the rest of the expression. Hexadecimal integers are specified by
|
the rest of the expression. Hexadecimal integers are specified by
|
a trailing `H', and octal integers by a trailing `B'.
|
a trailing `H', and octal integers by a trailing `B'.
|
|
|
* Floating point constants appear as a sequence of digits, followed
|
* Floating point constants appear as a sequence of digits, followed
|
by a decimal point and another sequence of digits. An optional
|
by a decimal point and another sequence of digits. An optional
|
exponent can then be specified, in the form `E[+|-]NNN', where
|
exponent can then be specified, in the form `E[+|-]NNN', where
|
`[+|-]NNN' is the desired exponent. All of the digits of the
|
`[+|-]NNN' is the desired exponent. All of the digits of the
|
floating point constant must be valid decimal (base 10) digits.
|
floating point constant must be valid decimal (base 10) digits.
|
|
|
* Character constants consist of a single character enclosed by a
|
* Character constants consist of a single character enclosed by a
|
pair of like quotes, either single (`'') or double (`"'). They may
|
pair of like quotes, either single (`'') or double (`"'). They may
|
also be expressed by their ordinal value (their ASCII value,
|
also be expressed by their ordinal value (their ASCII value,
|
usually) followed by a `C'.
|
usually) followed by a `C'.
|
|
|
* String constants consist of a sequence of characters enclosed by a
|
* String constants consist of a sequence of characters enclosed by a
|
pair of like quotes, either single (`'') or double (`"'). Escape
|
pair of like quotes, either single (`'') or double (`"'). Escape
|
sequences in the style of C are also allowed. *Note C and C++
|
sequences in the style of C are also allowed. *Note C and C++
|
Constants: C Constants, for a brief explanation of escape
|
Constants: C Constants, for a brief explanation of escape
|
sequences.
|
sequences.
|
|
|
* Enumerated constants consist of an enumerated identifier.
|
* Enumerated constants consist of an enumerated identifier.
|
|
|
* Boolean constants consist of the identifiers `TRUE' and `FALSE'.
|
* Boolean constants consist of the identifiers `TRUE' and `FALSE'.
|
|
|
* Pointer constants consist of integral values only.
|
* Pointer constants consist of integral values only.
|
|
|
* Set constants are not yet supported.
|
* Set constants are not yet supported.
|
|
|
|
|
File: gdb.info, Node: M2 Types, Next: M2 Defaults, Prev: M2 Constants, Up: Modula-2
|
File: gdb.info, Node: M2 Types, Next: M2 Defaults, Prev: M2 Constants, Up: Modula-2
|
|
|
15.4.6.4 Modula-2 Types
|
15.4.6.4 Modula-2 Types
|
.......................
|
.......................
|
|
|
Currently GDB can print the following data types in Modula-2 syntax:
|
Currently GDB can print the following data types in Modula-2 syntax:
|
array types, record types, set types, pointer types, procedure types,
|
array types, record types, set types, pointer types, procedure types,
|
enumerated types, subrange types and base types. You can also print
|
enumerated types, subrange types and base types. You can also print
|
the contents of variables declared using these type. This section
|
the contents of variables declared using these type. This section
|
gives a number of simple source code examples together with sample GDB
|
gives a number of simple source code examples together with sample GDB
|
sessions.
|
sessions.
|
|
|
The first example contains the following section of code:
|
The first example contains the following section of code:
|
|
|
VAR
|
VAR
|
s: SET OF CHAR ;
|
s: SET OF CHAR ;
|
r: [20..40] ;
|
r: [20..40] ;
|
|
|
and you can request GDB to interrogate the type and value of `r' and
|
and you can request GDB to interrogate the type and value of `r' and
|
`s'.
|
`s'.
|
|
|
(gdb) print s
|
(gdb) print s
|
{'A'..'C', 'Z'}
|
{'A'..'C', 'Z'}
|
(gdb) ptype s
|
(gdb) ptype s
|
SET OF CHAR
|
SET OF CHAR
|
(gdb) print r
|
(gdb) print r
|
21
|
21
|
(gdb) ptype r
|
(gdb) ptype r
|
[20..40]
|
[20..40]
|
|
|
Likewise if your source code declares `s' as:
|
Likewise if your source code declares `s' as:
|
|
|
VAR
|
VAR
|
s: SET ['A'..'Z'] ;
|
s: SET ['A'..'Z'] ;
|
|
|
then you may query the type of `s' by:
|
then you may query the type of `s' by:
|
|
|
(gdb) ptype s
|
(gdb) ptype s
|
type = SET ['A'..'Z']
|
type = SET ['A'..'Z']
|
|
|
Note that at present you cannot interactively manipulate set
|
Note that at present you cannot interactively manipulate set
|
expressions using the debugger.
|
expressions using the debugger.
|
|
|
The following example shows how you might declare an array in
|
The following example shows how you might declare an array in
|
Modula-2 and how you can interact with GDB to print its type and
|
Modula-2 and how you can interact with GDB to print its type and
|
contents:
|
contents:
|
|
|
VAR
|
VAR
|
s: ARRAY [-10..10] OF CHAR ;
|
s: ARRAY [-10..10] OF CHAR ;
|
|
|
(gdb) ptype s
|
(gdb) ptype s
|
ARRAY [-10..10] OF CHAR
|
ARRAY [-10..10] OF CHAR
|
|
|
Note that the array handling is not yet complete and although the
|
Note that the array handling is not yet complete and although the
|
type is printed correctly, expression handling still assumes that all
|
type is printed correctly, expression handling still assumes that all
|
arrays have a lower bound of zero and not `-10' as in the example above.
|
arrays have a lower bound of zero and not `-10' as in the example above.
|
|
|
Here are some more type related Modula-2 examples:
|
Here are some more type related Modula-2 examples:
|
|
|
TYPE
|
TYPE
|
colour = (blue, red, yellow, green) ;
|
colour = (blue, red, yellow, green) ;
|
t = [blue..yellow] ;
|
t = [blue..yellow] ;
|
VAR
|
VAR
|
s: t ;
|
s: t ;
|
BEGIN
|
BEGIN
|
s := blue ;
|
s := blue ;
|
|
|
The GDB interaction shows how you can query the data type and value of
|
The GDB interaction shows how you can query the data type and value of
|
a variable.
|
a variable.
|
|
|
(gdb) print s
|
(gdb) print s
|
$1 = blue
|
$1 = blue
|
(gdb) ptype t
|
(gdb) ptype t
|
type = [blue..yellow]
|
type = [blue..yellow]
|
|
|
In this example a Modula-2 array is declared and its contents
|
In this example a Modula-2 array is declared and its contents
|
displayed. Observe that the contents are written in the same way as
|
displayed. Observe that the contents are written in the same way as
|
their `C' counterparts.
|
their `C' counterparts.
|
|
|
VAR
|
VAR
|
s: ARRAY [1..5] OF CARDINAL ;
|
s: ARRAY [1..5] OF CARDINAL ;
|
BEGIN
|
BEGIN
|
s[1] := 1 ;
|
s[1] := 1 ;
|
|
|
(gdb) print s
|
(gdb) print s
|
$1 = {1, 0, 0, 0, 0}
|
$1 = {1, 0, 0, 0, 0}
|
(gdb) ptype s
|
(gdb) ptype s
|
type = ARRAY [1..5] OF CARDINAL
|
type = ARRAY [1..5] OF CARDINAL
|
|
|
The Modula-2 language interface to GDB also understands pointer
|
The Modula-2 language interface to GDB also understands pointer
|
types as shown in this example:
|
types as shown in this example:
|
|
|
VAR
|
VAR
|
s: POINTER TO ARRAY [1..5] OF CARDINAL ;
|
s: POINTER TO ARRAY [1..5] OF CARDINAL ;
|
BEGIN
|
BEGIN
|
NEW(s) ;
|
NEW(s) ;
|
s^[1] := 1 ;
|
s^[1] := 1 ;
|
|
|
and you can request that GDB describes the type of `s'.
|
and you can request that GDB describes the type of `s'.
|
|
|
(gdb) ptype s
|
(gdb) ptype s
|
type = POINTER TO ARRAY [1..5] OF CARDINAL
|
type = POINTER TO ARRAY [1..5] OF CARDINAL
|
|
|
GDB handles compound types as we can see in this example. Here we
|
GDB handles compound types as we can see in this example. Here we
|
combine array types, record types, pointer types and subrange types:
|
combine array types, record types, pointer types and subrange types:
|
|
|
TYPE
|
TYPE
|
foo = RECORD
|
foo = RECORD
|
f1: CARDINAL ;
|
f1: CARDINAL ;
|
f2: CHAR ;
|
f2: CHAR ;
|
f3: myarray ;
|
f3: myarray ;
|
END ;
|
END ;
|
|
|
myarray = ARRAY myrange OF CARDINAL ;
|
myarray = ARRAY myrange OF CARDINAL ;
|
myrange = [-2..2] ;
|
myrange = [-2..2] ;
|
VAR
|
VAR
|
s: POINTER TO ARRAY myrange OF foo ;
|
s: POINTER TO ARRAY myrange OF foo ;
|
|
|
and you can ask GDB to describe the type of `s' as shown below.
|
and you can ask GDB to describe the type of `s' as shown below.
|
|
|
(gdb) ptype s
|
(gdb) ptype s
|
type = POINTER TO ARRAY [-2..2] OF foo = RECORD
|
type = POINTER TO ARRAY [-2..2] OF foo = RECORD
|
f1 : CARDINAL;
|
f1 : CARDINAL;
|
f2 : CHAR;
|
f2 : CHAR;
|
f3 : ARRAY [-2..2] OF CARDINAL;
|
f3 : ARRAY [-2..2] OF CARDINAL;
|
END
|
END
|
|
|
|
|
File: gdb.info, Node: M2 Defaults, Next: Deviations, Prev: M2 Types, Up: Modula-2
|
File: gdb.info, Node: M2 Defaults, Next: Deviations, Prev: M2 Types, Up: Modula-2
|
|
|
15.4.6.5 Modula-2 Defaults
|
15.4.6.5 Modula-2 Defaults
|
..........................
|
..........................
|
|
|
If type and range checking are set automatically by GDB, they both
|
If type and range checking are set automatically by GDB, they both
|
default to `on' whenever the working language changes to Modula-2.
|
default to `on' whenever the working language changes to Modula-2.
|
This happens regardless of whether you or GDB selected the working
|
This happens regardless of whether you or GDB selected the working
|
language.
|
language.
|
|
|
If you allow GDB to set the language automatically, then entering
|
If you allow GDB to set the language automatically, then entering
|
code compiled from a file whose name ends with `.mod' sets the working
|
code compiled from a file whose name ends with `.mod' sets the working
|
language to Modula-2. *Note Having GDB Infer the Source Language:
|
language to Modula-2. *Note Having GDB Infer the Source Language:
|
Automatically, for further details.
|
Automatically, for further details.
|
|
|
|
|
File: gdb.info, Node: Deviations, Next: M2 Checks, Prev: M2 Defaults, Up: Modula-2
|
File: gdb.info, Node: Deviations, Next: M2 Checks, Prev: M2 Defaults, Up: Modula-2
|
|
|
15.4.6.6 Deviations from Standard Modula-2
|
15.4.6.6 Deviations from Standard Modula-2
|
..........................................
|
..........................................
|
|
|
A few changes have been made to make Modula-2 programs easier to debug.
|
A few changes have been made to make Modula-2 programs easier to debug.
|
This is done primarily via loosening its type strictness:
|
This is done primarily via loosening its type strictness:
|
|
|
* Unlike in standard Modula-2, pointer constants can be formed by
|
* Unlike in standard Modula-2, pointer constants can be formed by
|
integers. This allows you to modify pointer variables during
|
integers. This allows you to modify pointer variables during
|
debugging. (In standard Modula-2, the actual address contained in
|
debugging. (In standard Modula-2, the actual address contained in
|
a pointer variable is hidden from you; it can only be modified
|
a pointer variable is hidden from you; it can only be modified
|
through direct assignment to another pointer variable or
|
through direct assignment to another pointer variable or
|
expression that returned a pointer.)
|
expression that returned a pointer.)
|
|
|
* C escape sequences can be used in strings and characters to
|
* C escape sequences can be used in strings and characters to
|
represent non-printable characters. GDB prints out strings with
|
represent non-printable characters. GDB prints out strings with
|
these escape sequences embedded. Single non-printable characters
|
these escape sequences embedded. Single non-printable characters
|
are printed using the `CHR(NNN)' format.
|
are printed using the `CHR(NNN)' format.
|
|
|
* The assignment operator (`:=') returns the value of its right-hand
|
* The assignment operator (`:=') returns the value of its right-hand
|
argument.
|
argument.
|
|
|
* All built-in procedures both modify _and_ return their argument.
|
* All built-in procedures both modify _and_ return their argument.
|
|
|
|
|
File: gdb.info, Node: M2 Checks, Next: M2 Scope, Prev: Deviations, Up: Modula-2
|
File: gdb.info, Node: M2 Checks, Next: M2 Scope, Prev: Deviations, Up: Modula-2
|
|
|
15.4.6.7 Modula-2 Type and Range Checks
|
15.4.6.7 Modula-2 Type and Range Checks
|
.......................................
|
.......................................
|
|
|
_Warning:_ in this release, GDB does not yet perform type or range
|
_Warning:_ in this release, GDB does not yet perform type or range
|
checking.
|
checking.
|
|
|
GDB considers two Modula-2 variables type equivalent if:
|
GDB considers two Modula-2 variables type equivalent if:
|
|
|
* They are of types that have been declared equivalent via a `TYPE
|
* They are of types that have been declared equivalent via a `TYPE
|
T1 = T2' statement
|
T1 = T2' statement
|
|
|
* They have been declared on the same line. (Note: This is true of
|
* They have been declared on the same line. (Note: This is true of
|
the GNU Modula-2 compiler, but it may not be true of other
|
the GNU Modula-2 compiler, but it may not be true of other
|
compilers.)
|
compilers.)
|
|
|
As long as type checking is enabled, any attempt to combine variables
|
As long as type checking is enabled, any attempt to combine variables
|
whose types are not equivalent is an error.
|
whose types are not equivalent is an error.
|
|
|
Range checking is done on all mathematical operations, assignment,
|
Range checking is done on all mathematical operations, assignment,
|
array index bounds, and all built-in functions and procedures.
|
array index bounds, and all built-in functions and procedures.
|
|
|
|
|
File: gdb.info, Node: M2 Scope, Next: GDB/M2, Prev: M2 Checks, Up: Modula-2
|
File: gdb.info, Node: M2 Scope, Next: GDB/M2, Prev: M2 Checks, Up: Modula-2
|
|
|
15.4.6.8 The Scope Operators `::' and `.'
|
15.4.6.8 The Scope Operators `::' and `.'
|
.........................................
|
.........................................
|
|
|
There are a few subtle differences between the Modula-2 scope operator
|
There are a few subtle differences between the Modula-2 scope operator
|
(`.') and the GDB scope operator (`::'). The two have similar syntax:
|
(`.') and the GDB scope operator (`::'). The two have similar syntax:
|
|
|
|
|
MODULE . ID
|
MODULE . ID
|
SCOPE :: ID
|
SCOPE :: ID
|
|
|
where SCOPE is the name of a module or a procedure, MODULE the name of
|
where SCOPE is the name of a module or a procedure, MODULE the name of
|
a module, and ID is any declared identifier within your program, except
|
a module, and ID is any declared identifier within your program, except
|
another module.
|
another module.
|
|
|
Using the `::' operator makes GDB search the scope specified by
|
Using the `::' operator makes GDB search the scope specified by
|
SCOPE for the identifier ID. If it is not found in the specified
|
SCOPE for the identifier ID. If it is not found in the specified
|
scope, then GDB searches all scopes enclosing the one specified by
|
scope, then GDB searches all scopes enclosing the one specified by
|
SCOPE.
|
SCOPE.
|
|
|
Using the `.' operator makes GDB search the current scope for the
|
Using the `.' operator makes GDB search the current scope for the
|
identifier specified by ID that was imported from the definition module
|
identifier specified by ID that was imported from the definition module
|
specified by MODULE. With this operator, it is an error if the
|
specified by MODULE. With this operator, it is an error if the
|
identifier ID was not imported from definition module MODULE, or if ID
|
identifier ID was not imported from definition module MODULE, or if ID
|
is not an identifier in MODULE.
|
is not an identifier in MODULE.
|
|
|
|
|
File: gdb.info, Node: GDB/M2, Prev: M2 Scope, Up: Modula-2
|
File: gdb.info, Node: GDB/M2, Prev: M2 Scope, Up: Modula-2
|
|
|
15.4.6.9 GDB and Modula-2
|
15.4.6.9 GDB and Modula-2
|
.........................
|
.........................
|
|
|
Some GDB commands have little use when debugging Modula-2 programs.
|
Some GDB commands have little use when debugging Modula-2 programs.
|
Five subcommands of `set print' and `show print' apply specifically to
|
Five subcommands of `set print' and `show print' apply specifically to
|
C and C++: `vtbl', `demangle', `asm-demangle', `object', and `union'.
|
C and C++: `vtbl', `demangle', `asm-demangle', `object', and `union'.
|
The first four apply to C++, and the last to the C `union' type, which
|
The first four apply to C++, and the last to the C `union' type, which
|
has no direct analogue in Modula-2.
|
has no direct analogue in Modula-2.
|
|
|
The `@' operator (*note Expressions: Expressions.), while available
|
The `@' operator (*note Expressions: Expressions.), while available
|
with any language, is not useful with Modula-2. Its intent is to aid
|
with any language, is not useful with Modula-2. Its intent is to aid
|
the debugging of "dynamic arrays", which cannot be created in Modula-2
|
the debugging of "dynamic arrays", which cannot be created in Modula-2
|
as they can in C or C++. However, because an address can be specified
|
as they can in C or C++. However, because an address can be specified
|
by an integral constant, the construct `{TYPE}ADREXP' is still useful.
|
by an integral constant, the construct `{TYPE}ADREXP' is still useful.
|
|
|
In GDB scripts, the Modula-2 inequality operator `#' is interpreted
|
In GDB scripts, the Modula-2 inequality operator `#' is interpreted
|
as the beginning of a comment. Use `<>' instead.
|
as the beginning of a comment. Use `<>' instead.
|
|
|
|
|
File: gdb.info, Node: Ada, Prev: Modula-2, Up: Supported Languages
|
File: gdb.info, Node: Ada, Prev: Modula-2, Up: Supported Languages
|
|
|
15.4.7 Ada
|
15.4.7 Ada
|
----------
|
----------
|
|
|
The extensions made to GDB for Ada only support output from the GNU Ada
|
The extensions made to GDB for Ada only support output from the GNU Ada
|
(GNAT) compiler. Other Ada compilers are not currently supported, and
|
(GNAT) compiler. Other Ada compilers are not currently supported, and
|
attempting to debug executables produced by them is most likely to be
|
attempting to debug executables produced by them is most likely to be
|
difficult.
|
difficult.
|
|
|
* Menu:
|
* Menu:
|
|
|
* Ada Mode Intro:: General remarks on the Ada syntax
|
* Ada Mode Intro:: General remarks on the Ada syntax
|
and semantics supported by Ada mode
|
and semantics supported by Ada mode
|
in GDB.
|
in GDB.
|
* Omissions from Ada:: Restrictions on the Ada expression syntax.
|
* Omissions from Ada:: Restrictions on the Ada expression syntax.
|
* Additions to Ada:: Extensions of the Ada expression syntax.
|
* Additions to Ada:: Extensions of the Ada expression syntax.
|
* Stopping Before Main Program:: Debugging the program during elaboration.
|
* Stopping Before Main Program:: Debugging the program during elaboration.
|
* Ada Tasks:: Listing and setting breakpoints in tasks.
|
* Ada Tasks:: Listing and setting breakpoints in tasks.
|
* Ada Tasks and Core Files:: Tasking Support when Debugging Core Files
|
* Ada Tasks and Core Files:: Tasking Support when Debugging Core Files
|
* Ada Glitches:: Known peculiarities of Ada mode.
|
* Ada Glitches:: Known peculiarities of Ada mode.
|
|
|
|
|
File: gdb.info, Node: Ada Mode Intro, Next: Omissions from Ada, Up: Ada
|
File: gdb.info, Node: Ada Mode Intro, Next: Omissions from Ada, Up: Ada
|
|
|
15.4.7.1 Introduction
|
15.4.7.1 Introduction
|
.....................
|
.....................
|
|
|
The Ada mode of GDB supports a fairly large subset of Ada expression
|
The Ada mode of GDB supports a fairly large subset of Ada expression
|
syntax, with some extensions. The philosophy behind the design of this
|
syntax, with some extensions. The philosophy behind the design of this
|
subset is
|
subset is
|
|
|
* That GDB should provide basic literals and access to operations for
|
* That GDB should provide basic literals and access to operations for
|
arithmetic, dereferencing, field selection, indexing, and
|
arithmetic, dereferencing, field selection, indexing, and
|
subprogram calls, leaving more sophisticated computations to
|
subprogram calls, leaving more sophisticated computations to
|
subprograms written into the program (which therefore may be
|
subprograms written into the program (which therefore may be
|
called from GDB).
|
called from GDB).
|
|
|
* That type safety and strict adherence to Ada language restrictions
|
* That type safety and strict adherence to Ada language restrictions
|
are not particularly important to the GDB user.
|
are not particularly important to the GDB user.
|
|
|
* That brevity is important to the GDB user.
|
* That brevity is important to the GDB user.
|
|
|
Thus, for brevity, the debugger acts as if all names declared in
|
Thus, for brevity, the debugger acts as if all names declared in
|
user-written packages are directly visible, even if they are not visible
|
user-written packages are directly visible, even if they are not visible
|
according to Ada rules, thus making it unnecessary to fully qualify most
|
according to Ada rules, thus making it unnecessary to fully qualify most
|
names with their packages, regardless of context. Where this causes
|
names with their packages, regardless of context. Where this causes
|
ambiguity, GDB asks the user's intent.
|
ambiguity, GDB asks the user's intent.
|
|
|
The debugger will start in Ada mode if it detects an Ada main
|
The debugger will start in Ada mode if it detects an Ada main
|
program. As for other languages, it will enter Ada mode when stopped
|
program. As for other languages, it will enter Ada mode when stopped
|
in a program that was translated from an Ada source file.
|
in a program that was translated from an Ada source file.
|
|
|
While in Ada mode, you may use `-' for comments. This is useful
|
While in Ada mode, you may use `-' for comments. This is useful
|
mostly for documenting command files. The standard GDB comment (`#')
|
mostly for documenting command files. The standard GDB comment (`#')
|
still works at the beginning of a line in Ada mode, but not in the
|
still works at the beginning of a line in Ada mode, but not in the
|
middle (to allow based literals).
|
middle (to allow based literals).
|
|
|
The debugger supports limited overloading. Given a subprogram call
|
The debugger supports limited overloading. Given a subprogram call
|
in which the function symbol has multiple definitions, it will use the
|
in which the function symbol has multiple definitions, it will use the
|
number of actual parameters and some information about their types to
|
number of actual parameters and some information about their types to
|
attempt to narrow the set of definitions. It also makes very limited
|
attempt to narrow the set of definitions. It also makes very limited
|
use of context, preferring procedures to functions in the context of
|
use of context, preferring procedures to functions in the context of
|
the `call' command, and functions to procedures elsewhere.
|
the `call' command, and functions to procedures elsewhere.
|
|
|
|
|
File: gdb.info, Node: Omissions from Ada, Next: Additions to Ada, Prev: Ada Mode Intro, Up: Ada
|
File: gdb.info, Node: Omissions from Ada, Next: Additions to Ada, Prev: Ada Mode Intro, Up: Ada
|
|
|
15.4.7.2 Omissions from Ada
|
15.4.7.2 Omissions from Ada
|
...........................
|
...........................
|
|
|
Here are the notable omissions from the subset:
|
Here are the notable omissions from the subset:
|
|
|
* Only a subset of the attributes are supported:
|
* Only a subset of the attributes are supported:
|
|
|
- 'First, 'Last, and 'Length on array objects (not on types
|
- 'First, 'Last, and 'Length on array objects (not on types
|
and subtypes).
|
and subtypes).
|
|
|
- 'Min and 'Max.
|
- 'Min and 'Max.
|
|
|
- 'Pos and 'Val.
|
- 'Pos and 'Val.
|
|
|
- 'Tag.
|
- 'Tag.
|
|
|
- 'Range on array objects (not subtypes), but only as the right
|
- 'Range on array objects (not subtypes), but only as the right
|
operand of the membership (`in') operator.
|
operand of the membership (`in') operator.
|
|
|
- 'Access, 'Unchecked_Access, and 'Unrestricted_Access (a GNAT
|
- 'Access, 'Unchecked_Access, and 'Unrestricted_Access (a GNAT
|
extension).
|
extension).
|
|
|
- 'Address.
|
- 'Address.
|
|
|
* The names in `Characters.Latin_1' are not available and
|
* The names in `Characters.Latin_1' are not available and
|
concatenation is not implemented. Thus, escape characters in
|
concatenation is not implemented. Thus, escape characters in
|
strings are not currently available.
|
strings are not currently available.
|
|
|
* Equality tests (`=' and `/=') on arrays test for bitwise equality
|
* Equality tests (`=' and `/=') on arrays test for bitwise equality
|
of representations. They will generally work correctly for
|
of representations. They will generally work correctly for
|
strings and arrays whose elements have integer or enumeration
|
strings and arrays whose elements have integer or enumeration
|
types. They may not work correctly for arrays whose element types
|
types. They may not work correctly for arrays whose element types
|
have user-defined equality, for arrays of real values (in
|
have user-defined equality, for arrays of real values (in
|
particular, IEEE-conformant floating point, because of negative
|
particular, IEEE-conformant floating point, because of negative
|
zeroes and NaNs), and for arrays whose elements contain unused
|
zeroes and NaNs), and for arrays whose elements contain unused
|
bits with indeterminate values.
|
bits with indeterminate values.
|
|
|
* The other component-by-component array operations (`and', `or',
|
* The other component-by-component array operations (`and', `or',
|
`xor', `not', and relational tests other than equality) are not
|
`xor', `not', and relational tests other than equality) are not
|
implemented.
|
implemented.
|
|
|
* There is limited support for array and record aggregates. They are
|
* There is limited support for array and record aggregates. They are
|
permitted only on the right sides of assignments, as in these
|
permitted only on the right sides of assignments, as in these
|
examples:
|
examples:
|
|
|
(gdb) set An_Array := (1, 2, 3, 4, 5, 6)
|
(gdb) set An_Array := (1, 2, 3, 4, 5, 6)
|
(gdb) set An_Array := (1, others => 0)
|
(gdb) set An_Array := (1, others => 0)
|
(gdb) set An_Array := (0|4 => 1, 1..3 => 2, 5 => 6)
|
(gdb) set An_Array := (0|4 => 1, 1..3 => 2, 5 => 6)
|
(gdb) set A_2D_Array := ((1, 2, 3), (4, 5, 6), (7, 8, 9))
|
(gdb) set A_2D_Array := ((1, 2, 3), (4, 5, 6), (7, 8, 9))
|
(gdb) set A_Record := (1, "Peter", True);
|
(gdb) set A_Record := (1, "Peter", True);
|
(gdb) set A_Record := (Name => "Peter", Id => 1, Alive => True)
|
(gdb) set A_Record := (Name => "Peter", Id => 1, Alive => True)
|
|
|
Changing a discriminant's value by assigning an aggregate has an
|
Changing a discriminant's value by assigning an aggregate has an
|
undefined effect if that discriminant is used within the record.
|
undefined effect if that discriminant is used within the record.
|
However, you can first modify discriminants by directly assigning
|
However, you can first modify discriminants by directly assigning
|
to them (which normally would not be allowed in Ada), and then
|
to them (which normally would not be allowed in Ada), and then
|
performing an aggregate assignment. For example, given a variable
|
performing an aggregate assignment. For example, given a variable
|
`A_Rec' declared to have a type such as:
|
`A_Rec' declared to have a type such as:
|
|
|
type Rec (Len : Small_Integer := 0) is record
|
type Rec (Len : Small_Integer := 0) is record
|
Id : Integer;
|
Id : Integer;
|
Vals : IntArray (1 .. Len);
|
Vals : IntArray (1 .. Len);
|
end record;
|
end record;
|
|
|
you can assign a value with a different size of `Vals' with two
|
you can assign a value with a different size of `Vals' with two
|
assignments:
|
assignments:
|
|
|
(gdb) set A_Rec.Len := 4
|
(gdb) set A_Rec.Len := 4
|
(gdb) set A_Rec := (Id => 42, Vals => (1, 2, 3, 4))
|
(gdb) set A_Rec := (Id => 42, Vals => (1, 2, 3, 4))
|
|
|
As this example also illustrates, GDB is very loose about the usual
|
As this example also illustrates, GDB is very loose about the usual
|
rules concerning aggregates. You may leave out some of the
|
rules concerning aggregates. You may leave out some of the
|
components of an array or record aggregate (such as the `Len'
|
components of an array or record aggregate (such as the `Len'
|
component in the assignment to `A_Rec' above); they will retain
|
component in the assignment to `A_Rec' above); they will retain
|
their original values upon assignment. You may freely use dynamic
|
their original values upon assignment. You may freely use dynamic
|
values as indices in component associations. You may even use
|
values as indices in component associations. You may even use
|
overlapping or redundant component associations, although which
|
overlapping or redundant component associations, although which
|
component values are assigned in such cases is not defined.
|
component values are assigned in such cases is not defined.
|
|
|
* Calls to dispatching subprograms are not implemented.
|
* Calls to dispatching subprograms are not implemented.
|
|
|
* The overloading algorithm is much more limited (i.e., less
|
* The overloading algorithm is much more limited (i.e., less
|
selective) than that of real Ada. It makes only limited use of
|
selective) than that of real Ada. It makes only limited use of
|
the context in which a subexpression appears to resolve its
|
the context in which a subexpression appears to resolve its
|
meaning, and it is much looser in its rules for allowing type
|
meaning, and it is much looser in its rules for allowing type
|
matches. As a result, some function calls will be ambiguous, and
|
matches. As a result, some function calls will be ambiguous, and
|
the user will be asked to choose the proper resolution.
|
the user will be asked to choose the proper resolution.
|
|
|
* The `new' operator is not implemented.
|
* The `new' operator is not implemented.
|
|
|
* Entry calls are not implemented.
|
* Entry calls are not implemented.
|
|
|
* Aside from printing, arithmetic operations on the native VAX
|
* Aside from printing, arithmetic operations on the native VAX
|
floating-point formats are not supported.
|
floating-point formats are not supported.
|
|
|
* It is not possible to slice a packed array.
|
* It is not possible to slice a packed array.
|
|
|
* The names `True' and `False', when not part of a qualified name,
|
* The names `True' and `False', when not part of a qualified name,
|
are interpreted as if implicitly prefixed by `Standard',
|
are interpreted as if implicitly prefixed by `Standard',
|
regardless of context. Should your program redefine these names
|
regardless of context. Should your program redefine these names
|
in a package or procedure (at best a dubious practice), you will
|
in a package or procedure (at best a dubious practice), you will
|
have to use fully qualified names to access their new definitions.
|
have to use fully qualified names to access their new definitions.
|
|
|
|
|
File: gdb.info, Node: Additions to Ada, Next: Stopping Before Main Program, Prev: Omissions from Ada, Up: Ada
|
File: gdb.info, Node: Additions to Ada, Next: Stopping Before Main Program, Prev: Omissions from Ada, Up: Ada
|
|
|
15.4.7.3 Additions to Ada
|
15.4.7.3 Additions to Ada
|
.........................
|
.........................
|
|
|
As it does for other languages, GDB makes certain generic extensions to
|
As it does for other languages, GDB makes certain generic extensions to
|
Ada (*note Expressions::):
|
Ada (*note Expressions::):
|
|
|
* If the expression E is a variable residing in memory (typically a
|
* If the expression E is a variable residing in memory (typically a
|
local variable or array element) and N is a positive integer, then
|
local variable or array element) and N is a positive integer, then
|
`E@N' displays the values of E and the N-1 adjacent variables
|
`E@N' displays the values of E and the N-1 adjacent variables
|
following it in memory as an array. In Ada, this operator is
|
following it in memory as an array. In Ada, this operator is
|
generally not necessary, since its prime use is in displaying
|
generally not necessary, since its prime use is in displaying
|
parts of an array, and slicing will usually do this in Ada.
|
parts of an array, and slicing will usually do this in Ada.
|
However, there are occasional uses when debugging programs in
|
However, there are occasional uses when debugging programs in
|
which certain debugging information has been optimized away.
|
which certain debugging information has been optimized away.
|
|
|
* `B::VAR' means "the variable named VAR that appears in function or
|
* `B::VAR' means "the variable named VAR that appears in function or
|
file B." When B is a file name, you must typically surround it in
|
file B." When B is a file name, you must typically surround it in
|
single quotes.
|
single quotes.
|
|
|
* The expression `{TYPE} ADDR' means "the variable of type TYPE that
|
* The expression `{TYPE} ADDR' means "the variable of type TYPE that
|
appears at address ADDR."
|
appears at address ADDR."
|
|
|
* A name starting with `$' is a convenience variable (*note
|
* A name starting with `$' is a convenience variable (*note
|
Convenience Vars::) or a machine register (*note Registers::).
|
Convenience Vars::) or a machine register (*note Registers::).
|
|
|
In addition, GDB provides a few other shortcuts and outright
|
In addition, GDB provides a few other shortcuts and outright
|
additions specific to Ada:
|
additions specific to Ada:
|
|
|
* The assignment statement is allowed as an expression, returning
|
* The assignment statement is allowed as an expression, returning
|
its right-hand operand as its value. Thus, you may enter
|
its right-hand operand as its value. Thus, you may enter
|
|
|
(gdb) set x := y + 3
|
(gdb) set x := y + 3
|
(gdb) print A(tmp := y + 1)
|
(gdb) print A(tmp := y + 1)
|
|
|
* The semicolon is allowed as an "operator," returning as its value
|
* The semicolon is allowed as an "operator," returning as its value
|
the value of its right-hand operand. This allows, for example,
|
the value of its right-hand operand. This allows, for example,
|
complex conditional breaks:
|
complex conditional breaks:
|
|
|
(gdb) break f
|
(gdb) break f
|
(gdb) condition 1 (report(i); k += 1; A(k) > 100)
|
(gdb) condition 1 (report(i); k += 1; A(k) > 100)
|
|
|
* Rather than use catenation and symbolic character names to
|
* Rather than use catenation and symbolic character names to
|
introduce special characters into strings, one may instead use a
|
introduce special characters into strings, one may instead use a
|
special bracket notation, which is also used to print strings. A
|
special bracket notation, which is also used to print strings. A
|
sequence of characters of the form `["XX"]' within a string or
|
sequence of characters of the form `["XX"]' within a string or
|
character literal denotes the (single) character whose numeric
|
character literal denotes the (single) character whose numeric
|
encoding is XX in hexadecimal. The sequence of characters `["""]'
|
encoding is XX in hexadecimal. The sequence of characters `["""]'
|
also denotes a single quotation mark in strings. For example,
|
also denotes a single quotation mark in strings. For example,
|
"One line.["0a"]Next line.["0a"]"
|
"One line.["0a"]Next line.["0a"]"
|
contains an ASCII newline character (`Ada.Characters.Latin_1.LF')
|
contains an ASCII newline character (`Ada.Characters.Latin_1.LF')
|
after each period.
|
after each period.
|
|
|
* The subtype used as a prefix for the attributes 'Pos, 'Min, and
|
* The subtype used as a prefix for the attributes 'Pos, 'Min, and
|
'Max is optional (and is ignored in any case). For example, it is
|
'Max is optional (and is ignored in any case). For example, it is
|
valid to write
|
valid to write
|
|
|
(gdb) print 'max(x, y)
|
(gdb) print 'max(x, y)
|
|
|
* When printing arrays, GDB uses positional notation when the array
|
* When printing arrays, GDB uses positional notation when the array
|
has a lower bound of 1, and uses a modified named notation
|
has a lower bound of 1, and uses a modified named notation
|
otherwise. For example, a one-dimensional array of three integers
|
otherwise. For example, a one-dimensional array of three integers
|
with a lower bound of 3 might print as
|
with a lower bound of 3 might print as
|
|
|
(3 => 10, 17, 1)
|
(3 => 10, 17, 1)
|
|
|
That is, in contrast to valid Ada, only the first component has a
|
That is, in contrast to valid Ada, only the first component has a
|
`=>' clause.
|
`=>' clause.
|
|
|
* You may abbreviate attributes in expressions with any unique,
|
* You may abbreviate attributes in expressions with any unique,
|
multi-character subsequence of their names (an exact match gets
|
multi-character subsequence of their names (an exact match gets
|
preference). For example, you may use a'len, a'gth, or a'lh in
|
preference). For example, you may use a'len, a'gth, or a'lh in
|
place of a'length.
|
place of a'length.
|
|
|
* Since Ada is case-insensitive, the debugger normally maps
|
* Since Ada is case-insensitive, the debugger normally maps
|
identifiers you type to lower case. The GNAT compiler uses
|
identifiers you type to lower case. The GNAT compiler uses
|
upper-case characters for some of its internal identifiers, which
|
upper-case characters for some of its internal identifiers, which
|
are normally of no interest to users. For the rare occasions when
|
are normally of no interest to users. For the rare occasions when
|
you actually have to look at them, enclose them in angle brackets
|
you actually have to look at them, enclose them in angle brackets
|
to avoid the lower-case mapping. For example,
|
to avoid the lower-case mapping. For example,
|
(gdb) print [0]
|
(gdb) print [0]
|
|
|
* Printing an object of class-wide type or dereferencing an
|
* Printing an object of class-wide type or dereferencing an
|
access-to-class-wide value will display all the components of the
|
access-to-class-wide value will display all the components of the
|
object's specific type (as indicated by its run-time tag).
|
object's specific type (as indicated by its run-time tag).
|
Likewise, component selection on such a value will operate on the
|
Likewise, component selection on such a value will operate on the
|
specific type of the object.
|
specific type of the object.
|
|
|
|
|
|
|
File: gdb.info, Node: Stopping Before Main Program, Next: Ada Tasks, Prev: Additions to Ada, Up: Ada
|
File: gdb.info, Node: Stopping Before Main Program, Next: Ada Tasks, Prev: Additions to Ada, Up: Ada
|
|
|
15.4.7.4 Stopping at the Very Beginning
|
15.4.7.4 Stopping at the Very Beginning
|
.......................................
|
.......................................
|
|
|
It is sometimes necessary to debug the program during elaboration, and
|
It is sometimes necessary to debug the program during elaboration, and
|
before reaching the main procedure. As defined in the Ada Reference
|
before reaching the main procedure. As defined in the Ada Reference
|
Manual, the elaboration code is invoked from a procedure called
|
Manual, the elaboration code is invoked from a procedure called
|
`adainit'. To run your program up to the beginning of elaboration,
|
`adainit'. To run your program up to the beginning of elaboration,
|
simply use the following two commands: `tbreak adainit' and `run'.
|
simply use the following two commands: `tbreak adainit' and `run'.
|
|
|
|
|
File: gdb.info, Node: Ada Tasks, Next: Ada Tasks and Core Files, Prev: Stopping Before Main Program, Up: Ada
|
File: gdb.info, Node: Ada Tasks, Next: Ada Tasks and Core Files, Prev: Stopping Before Main Program, Up: Ada
|
|
|
15.4.7.5 Extensions for Ada Tasks
|
15.4.7.5 Extensions for Ada Tasks
|
.................................
|
.................................
|
|
|
Support for Ada tasks is analogous to that for threads (*note
|
Support for Ada tasks is analogous to that for threads (*note
|
Threads::). GDB provides the following task-related commands:
|
Threads::). GDB provides the following task-related commands:
|
|
|
`info tasks'
|
`info tasks'
|
This command shows a list of current Ada tasks, as in the
|
This command shows a list of current Ada tasks, as in the
|
following example:
|
following example:
|
|
|
(gdb) info tasks
|
(gdb) info tasks
|
ID TID P-ID Pri State Name
|
ID TID P-ID Pri State Name
|
1 8088000 0 15 Child Activation Wait main_task
|
1 8088000 0 15 Child Activation Wait main_task
|
2 80a4000 1 15 Accept Statement b
|
2 80a4000 1 15 Accept Statement b
|
3 809a800 1 15 Child Activation Wait a
|
3 809a800 1 15 Child Activation Wait a
|
* 4 80ae800 3 15 Runnable c
|
* 4 80ae800 3 15 Runnable c
|
|
|
In this listing, the asterisk before the last task indicates it to
|
In this listing, the asterisk before the last task indicates it to
|
be the task currently being inspected.
|
be the task currently being inspected.
|
|
|
ID
|
ID
|
Represents GDB's internal task number.
|
Represents GDB's internal task number.
|
|
|
TID
|
TID
|
The Ada task ID.
|
The Ada task ID.
|
|
|
P-ID
|
P-ID
|
The parent's task ID (GDB's internal task number).
|
The parent's task ID (GDB's internal task number).
|
|
|
Pri
|
Pri
|
The base priority of the task.
|
The base priority of the task.
|
|
|
State
|
State
|
Current state of the task.
|
Current state of the task.
|
|
|
`Unactivated'
|
`Unactivated'
|
The task has been created but has not been activated.
|
The task has been created but has not been activated.
|
It cannot be executing.
|
It cannot be executing.
|
|
|
`Runnable'
|
`Runnable'
|
The task is not blocked for any reason known to Ada.
|
The task is not blocked for any reason known to Ada.
|
(It may be waiting for a mutex, though.) It is
|
(It may be waiting for a mutex, though.) It is
|
conceptually "executing" in normal mode.
|
conceptually "executing" in normal mode.
|
|
|
`Terminated'
|
`Terminated'
|
The task is terminated, in the sense of ARM 9.3 (5).
|
The task is terminated, in the sense of ARM 9.3 (5).
|
Any dependents that were waiting on terminate
|
Any dependents that were waiting on terminate
|
alternatives have been awakened and have terminated
|
alternatives have been awakened and have terminated
|
themselves.
|
themselves.
|
|
|
`Child Activation Wait'
|
`Child Activation Wait'
|
The task is waiting for created tasks to complete
|
The task is waiting for created tasks to complete
|
activation.
|
activation.
|
|
|
`Accept Statement'
|
`Accept Statement'
|
The task is waiting on an accept or selective wait
|
The task is waiting on an accept or selective wait
|
statement.
|
statement.
|
|
|
`Waiting on entry call'
|
`Waiting on entry call'
|
The task is waiting on an entry call.
|
The task is waiting on an entry call.
|
|
|
`Async Select Wait'
|
`Async Select Wait'
|
The task is waiting to start the abortable part of an
|
The task is waiting to start the abortable part of an
|
asynchronous select statement.
|
asynchronous select statement.
|
|
|
`Delay Sleep'
|
`Delay Sleep'
|
The task is waiting on a select statement with only a
|
The task is waiting on a select statement with only a
|
delay alternative open.
|
delay alternative open.
|
|
|
`Child Termination Wait'
|
`Child Termination Wait'
|
The task is sleeping having completed a master within
|
The task is sleeping having completed a master within
|
itself, and is waiting for the tasks dependent on that
|
itself, and is waiting for the tasks dependent on that
|
master to become terminated or waiting on a terminate
|
master to become terminated or waiting on a terminate
|
Phase.
|
Phase.
|
|
|
`Wait Child in Term Alt'
|
`Wait Child in Term Alt'
|
The task is sleeping waiting for tasks on terminate
|
The task is sleeping waiting for tasks on terminate
|
alternatives to finish terminating.
|
alternatives to finish terminating.
|
|
|
`Accepting RV with TASKNO'
|
`Accepting RV with TASKNO'
|
The task is accepting a rendez-vous with the task TASKNO.
|
The task is accepting a rendez-vous with the task TASKNO.
|
|
|
Name
|
Name
|
Name of the task in the program.
|
Name of the task in the program.
|
|
|
|
|
`info task TASKNO'
|
`info task TASKNO'
|
This command shows detailled informations on the specified task,
|
This command shows detailled informations on the specified task,
|
as in the following example:
|
as in the following example:
|
(gdb) info tasks
|
(gdb) info tasks
|
ID TID P-ID Pri State Name
|
ID TID P-ID Pri State Name
|
1 8077880 0 15 Child Activation Wait main_task
|
1 8077880 0 15 Child Activation Wait main_task
|
* 2 807c468 1 15 Runnable task_1
|
* 2 807c468 1 15 Runnable task_1
|
(gdb) info task 2
|
(gdb) info task 2
|
Ada Task: 0x807c468
|
Ada Task: 0x807c468
|
Name: task_1
|
Name: task_1
|
Thread: 0x807f378
|
Thread: 0x807f378
|
Parent: 1 (main_task)
|
Parent: 1 (main_task)
|
Base Priority: 15
|
Base Priority: 15
|
State: Runnable
|
State: Runnable
|
|
|
`task'
|
`task'
|
This command prints the ID of the current task.
|
This command prints the ID of the current task.
|
|
|
(gdb) info tasks
|
(gdb) info tasks
|
ID TID P-ID Pri State Name
|
ID TID P-ID Pri State Name
|
1 8077870 0 15 Child Activation Wait main_task
|
1 8077870 0 15 Child Activation Wait main_task
|
* 2 807c458 1 15 Runnable t
|
* 2 807c458 1 15 Runnable t
|
(gdb) task
|
(gdb) task
|
[Current task is 2]
|
[Current task is 2]
|
|
|
`task TASKNO'
|
`task TASKNO'
|
This command is like the `thread THREADNO' command (*note
|
This command is like the `thread THREADNO' command (*note
|
Threads::). It switches the context of debugging from the current
|
Threads::). It switches the context of debugging from the current
|
task to the given task.
|
task to the given task.
|
|
|
(gdb) info tasks
|
(gdb) info tasks
|
ID TID P-ID Pri State Name
|
ID TID P-ID Pri State Name
|
1 8077870 0 15 Child Activation Wait main_task
|
1 8077870 0 15 Child Activation Wait main_task
|
* 2 807c458 1 15 Runnable t
|
* 2 807c458 1 15 Runnable t
|
(gdb) task 1
|
(gdb) task 1
|
[Switching to task 1]
|
[Switching to task 1]
|
#0 0x8067726 in pthread_cond_wait ()
|
#0 0x8067726 in pthread_cond_wait ()
|
(gdb) bt
|
(gdb) bt
|
#0 0x8067726 in pthread_cond_wait ()
|
#0 0x8067726 in pthread_cond_wait ()
|
#1 0x8056714 in system.os_interface.pthread_cond_wait ()
|
#1 0x8056714 in system.os_interface.pthread_cond_wait ()
|
#2 0x805cb63 in system.task_primitives.operations.sleep ()
|
#2 0x805cb63 in system.task_primitives.operations.sleep ()
|
#3 0x806153e in system.tasking.stages.activate_tasks ()
|
#3 0x806153e in system.tasking.stages.activate_tasks ()
|
#4 0x804aacc in un () at un.adb:5
|
#4 0x804aacc in un () at un.adb:5
|
|
|
`break LINESPEC task TASKNO'
|
`break LINESPEC task TASKNO'
|
`break LINESPEC task TASKNO if ...'
|
`break LINESPEC task TASKNO if ...'
|
These commands are like the `break ... thread ...' command (*note
|
These commands are like the `break ... thread ...' command (*note
|
Thread Stops::). LINESPEC specifies source lines, as described in
|
Thread Stops::). LINESPEC specifies source lines, as described in
|
*note Specify Location::.
|
*note Specify Location::.
|
|
|
Use the qualifier `task TASKNO' with a breakpoint command to
|
Use the qualifier `task TASKNO' with a breakpoint command to
|
specify that you only want GDB to stop the program when a
|
specify that you only want GDB to stop the program when a
|
particular Ada task reaches this breakpoint. TASKNO is one of the
|
particular Ada task reaches this breakpoint. TASKNO is one of the
|
numeric task identifiers assigned by GDB, shown in the first
|
numeric task identifiers assigned by GDB, shown in the first
|
column of the `info tasks' display.
|
column of the `info tasks' display.
|
|
|
If you do not specify `task TASKNO' when you set a breakpoint, the
|
If you do not specify `task TASKNO' when you set a breakpoint, the
|
breakpoint applies to _all_ tasks of your program.
|
breakpoint applies to _all_ tasks of your program.
|
|
|
You can use the `task' qualifier on conditional breakpoints as
|
You can use the `task' qualifier on conditional breakpoints as
|
well; in this case, place `task TASKNO' before the breakpoint
|
well; in this case, place `task TASKNO' before the breakpoint
|
condition (before the `if').
|
condition (before the `if').
|
|
|
For example,
|
For example,
|
|
|
(gdb) info tasks
|
(gdb) info tasks
|
ID TID P-ID Pri State Name
|
ID TID P-ID Pri State Name
|
1 140022020 0 15 Child Activation Wait main_task
|
1 140022020 0 15 Child Activation Wait main_task
|
2 140045060 1 15 Accept/Select Wait t2
|
2 140045060 1 15 Accept/Select Wait t2
|
3 140044840 1 15 Runnable t1
|
3 140044840 1 15 Runnable t1
|
* 4 140056040 1 15 Runnable t3
|
* 4 140056040 1 15 Runnable t3
|
(gdb) b 15 task 2
|
(gdb) b 15 task 2
|
Breakpoint 5 at 0x120044cb0: file test_task_debug.adb, line 15.
|
Breakpoint 5 at 0x120044cb0: file test_task_debug.adb, line 15.
|
(gdb) cont
|
(gdb) cont
|
Continuing.
|
Continuing.
|
task # 1 running
|
task # 1 running
|
task # 2 running
|
task # 2 running
|
|
|
Breakpoint 5, test_task_debug () at test_task_debug.adb:15
|
Breakpoint 5, test_task_debug () at test_task_debug.adb:15
|
15 flush;
|
15 flush;
|
(gdb) info tasks
|
(gdb) info tasks
|
ID TID P-ID Pri State Name
|
ID TID P-ID Pri State Name
|
1 140022020 0 15 Child Activation Wait main_task
|
1 140022020 0 15 Child Activation Wait main_task
|
* 2 140045060 1 15 Runnable t2
|
* 2 140045060 1 15 Runnable t2
|
3 140044840 1 15 Runnable t1
|
3 140044840 1 15 Runnable t1
|
4 140056040 1 15 Delay Sleep t3
|
4 140056040 1 15 Delay Sleep t3
|
|
|
|
|
File: gdb.info, Node: Ada Tasks and Core Files, Next: Ada Glitches, Prev: Ada Tasks, Up: Ada
|
File: gdb.info, Node: Ada Tasks and Core Files, Next: Ada Glitches, Prev: Ada Tasks, Up: Ada
|
|
|
15.4.7.6 Tasking Support when Debugging Core Files
|
15.4.7.6 Tasking Support when Debugging Core Files
|
..................................................
|
..................................................
|
|
|
When inspecting a core file, as opposed to debugging a live program,
|
When inspecting a core file, as opposed to debugging a live program,
|
tasking support may be limited or even unavailable, depending on the
|
tasking support may be limited or even unavailable, depending on the
|
platform being used. For instance, on x86-linux, the list of tasks is
|
platform being used. For instance, on x86-linux, the list of tasks is
|
available, but task switching is not supported. On Tru64, however,
|
available, but task switching is not supported. On Tru64, however,
|
task switching will work as usual.
|
task switching will work as usual.
|
|
|
On certain platforms, including Tru64, the debugger needs to perform
|
On certain platforms, including Tru64, the debugger needs to perform
|
some memory writes in order to provide Ada tasking support. When
|
some memory writes in order to provide Ada tasking support. When
|
inspecting a core file, this means that the core file must be opened
|
inspecting a core file, this means that the core file must be opened
|
with read-write privileges, using the command `"set write on"' (*note
|
with read-write privileges, using the command `"set write on"' (*note
|
Patching::). Under these circumstances, you should make a backup copy
|
Patching::). Under these circumstances, you should make a backup copy
|
of the core file before inspecting it with GDB.
|
of the core file before inspecting it with GDB.
|
|
|
|
|
File: gdb.info, Node: Ada Glitches, Prev: Ada Tasks and Core Files, Up: Ada
|
File: gdb.info, Node: Ada Glitches, Prev: Ada Tasks and Core Files, Up: Ada
|
|
|
15.4.7.7 Known Peculiarities of Ada Mode
|
15.4.7.7 Known Peculiarities of Ada Mode
|
........................................
|
........................................
|
|
|
Besides the omissions listed previously (*note Omissions from Ada::),
|
Besides the omissions listed previously (*note Omissions from Ada::),
|
we know of several problems with and limitations of Ada mode in GDB,
|
we know of several problems with and limitations of Ada mode in GDB,
|
some of which will be fixed with planned future releases of the debugger
|
some of which will be fixed with planned future releases of the debugger
|
and the GNU Ada compiler.
|
and the GNU Ada compiler.
|
|
|
* Currently, the debugger has insufficient information to determine
|
* Currently, the debugger has insufficient information to determine
|
whether certain pointers represent pointers to objects or the
|
whether certain pointers represent pointers to objects or the
|
objects themselves. Thus, the user may have to tack an extra
|
objects themselves. Thus, the user may have to tack an extra
|
`.all' after an expression to get it printed properly.
|
`.all' after an expression to get it printed properly.
|
|
|
* Static constants that the compiler chooses not to materialize as
|
* Static constants that the compiler chooses not to materialize as
|
objects in storage are invisible to the debugger.
|
objects in storage are invisible to the debugger.
|
|
|
* Named parameter associations in function argument lists are
|
* Named parameter associations in function argument lists are
|
ignored (the argument lists are treated as positional).
|
ignored (the argument lists are treated as positional).
|
|
|
* Many useful library packages are currently invisible to the
|
* Many useful library packages are currently invisible to the
|
debugger.
|
debugger.
|
|
|
* Fixed-point arithmetic, conversions, input, and output is carried
|
* Fixed-point arithmetic, conversions, input, and output is carried
|
out using floating-point arithmetic, and may give results that
|
out using floating-point arithmetic, and may give results that
|
only approximate those on the host machine.
|
only approximate those on the host machine.
|
|
|
* The GNAT compiler never generates the prefix `Standard' for any of
|
* The GNAT compiler never generates the prefix `Standard' for any of
|
the standard symbols defined by the Ada language. GDB knows about
|
the standard symbols defined by the Ada language. GDB knows about
|
this: it will strip the prefix from names when you use it, and
|
this: it will strip the prefix from names when you use it, and
|
will never look for a name you have so qualified among local
|
will never look for a name you have so qualified among local
|
symbols, nor match against symbols in other packages or
|
symbols, nor match against symbols in other packages or
|
subprograms. If you have defined entities anywhere in your
|
subprograms. If you have defined entities anywhere in your
|
program other than parameters and local variables whose simple
|
program other than parameters and local variables whose simple
|
names match names in `Standard', GNAT's lack of qualification here
|
names match names in `Standard', GNAT's lack of qualification here
|
can cause confusion. When this happens, you can usually resolve
|
can cause confusion. When this happens, you can usually resolve
|
the confusion by qualifying the problematic names with package
|
the confusion by qualifying the problematic names with package
|
`Standard' explicitly.
|
`Standard' explicitly.
|
|
|
Older versions of the compiler sometimes generate erroneous debugging
|
Older versions of the compiler sometimes generate erroneous debugging
|
information, resulting in the debugger incorrectly printing the value
|
information, resulting in the debugger incorrectly printing the value
|
of affected entities. In some cases, the debugger is able to work
|
of affected entities. In some cases, the debugger is able to work
|
around an issue automatically. In other cases, the debugger is able to
|
around an issue automatically. In other cases, the debugger is able to
|
work around the issue, but the work-around has to be specifically
|
work around the issue, but the work-around has to be specifically
|
enabled.
|
enabled.
|
|
|
`set ada trust-PAD-over-XVS on'
|
`set ada trust-PAD-over-XVS on'
|
Configure GDB to strictly follow the GNAT encoding when computing
|
Configure GDB to strictly follow the GNAT encoding when computing
|
the value of Ada entities, particularly when `PAD' and `PAD___XVS'
|
the value of Ada entities, particularly when `PAD' and `PAD___XVS'
|
types are involved (see `ada/exp_dbug.ads' in the GCC sources for
|
types are involved (see `ada/exp_dbug.ads' in the GCC sources for
|
a complete description of the encoding used by the GNAT compiler).
|
a complete description of the encoding used by the GNAT compiler).
|
This is the default.
|
This is the default.
|
|
|
`set ada trust-PAD-over-XVS off'
|
`set ada trust-PAD-over-XVS off'
|
This is related to the encoding using by the GNAT compiler. If
|
This is related to the encoding using by the GNAT compiler. If
|
GDB sometimes prints the wrong value for certain entities,
|
GDB sometimes prints the wrong value for certain entities,
|
changing `ada trust-PAD-over-XVS' to `off' activates a work-around
|
changing `ada trust-PAD-over-XVS' to `off' activates a work-around
|
which may fix the issue. It is always safe to set `ada
|
which may fix the issue. It is always safe to set `ada
|
trust-PAD-over-XVS' to `off', but this incurs a slight performance
|
trust-PAD-over-XVS' to `off', but this incurs a slight performance
|
penalty, so it is recommended to leave this setting to `on' unless
|
penalty, so it is recommended to leave this setting to `on' unless
|
necessary.
|
necessary.
|
|
|
|
|
|
|
File: gdb.info, Node: Unsupported Languages, Prev: Supported Languages, Up: Languages
|
File: gdb.info, Node: Unsupported Languages, Prev: Supported Languages, Up: Languages
|
|
|
15.5 Unsupported Languages
|
15.5 Unsupported Languages
|
==========================
|
==========================
|
|
|
In addition to the other fully-supported programming languages, GDB
|
In addition to the other fully-supported programming languages, GDB
|
also provides a pseudo-language, called `minimal'. It does not
|
also provides a pseudo-language, called `minimal'. It does not
|
represent a real programming language, but provides a set of
|
represent a real programming language, but provides a set of
|
capabilities close to what the C or assembly languages provide. This
|
capabilities close to what the C or assembly languages provide. This
|
should allow most simple operations to be performed while debugging an
|
should allow most simple operations to be performed while debugging an
|
application that uses a language currently not supported by GDB.
|
application that uses a language currently not supported by GDB.
|
|
|
If the language is set to `auto', GDB will automatically select this
|
If the language is set to `auto', GDB will automatically select this
|
language if the current frame corresponds to an unsupported language.
|
language if the current frame corresponds to an unsupported language.
|
|
|
|
|
File: gdb.info, Node: Symbols, Next: Altering, Prev: Languages, Up: Top
|
File: gdb.info, Node: Symbols, Next: Altering, Prev: Languages, Up: Top
|
|
|
16 Examining the Symbol Table
|
16 Examining the Symbol Table
|
*****************************
|
*****************************
|
|
|
The commands described in this chapter allow you to inquire about the
|
The commands described in this chapter allow you to inquire about the
|
symbols (names of variables, functions and types) defined in your
|
symbols (names of variables, functions and types) defined in your
|
program. This information is inherent in the text of your program and
|
program. This information is inherent in the text of your program and
|
does not change as your program executes. GDB finds it in your
|
does not change as your program executes. GDB finds it in your
|
program's symbol table, in the file indicated when you started GDB
|
program's symbol table, in the file indicated when you started GDB
|
(*note Choosing Files: File Options.), or by one of the file-management
|
(*note Choosing Files: File Options.), or by one of the file-management
|
commands (*note Commands to Specify Files: Files.).
|
commands (*note Commands to Specify Files: Files.).
|
|
|
Occasionally, you may need to refer to symbols that contain unusual
|
Occasionally, you may need to refer to symbols that contain unusual
|
characters, which GDB ordinarily treats as word delimiters. The most
|
characters, which GDB ordinarily treats as word delimiters. The most
|
frequent case is in referring to static variables in other source files
|
frequent case is in referring to static variables in other source files
|
(*note Program Variables: Variables.). File names are recorded in
|
(*note Program Variables: Variables.). File names are recorded in
|
object files as debugging symbols, but GDB would ordinarily parse a
|
object files as debugging symbols, but GDB would ordinarily parse a
|
typical file name, like `foo.c', as the three words `foo' `.' `c'. To
|
typical file name, like `foo.c', as the three words `foo' `.' `c'. To
|
allow GDB to recognize `foo.c' as a single symbol, enclose it in single
|
allow GDB to recognize `foo.c' as a single symbol, enclose it in single
|
quotes; for example,
|
quotes; for example,
|
|
|
p 'foo.c'::x
|
p 'foo.c'::x
|
|
|
looks up the value of `x' in the scope of the file `foo.c'.
|
looks up the value of `x' in the scope of the file `foo.c'.
|
|
|
`set case-sensitive on'
|
`set case-sensitive on'
|
`set case-sensitive off'
|
`set case-sensitive off'
|
`set case-sensitive auto'
|
`set case-sensitive auto'
|
Normally, when GDB looks up symbols, it matches their names with
|
Normally, when GDB looks up symbols, it matches their names with
|
case sensitivity determined by the current source language.
|
case sensitivity determined by the current source language.
|
Occasionally, you may wish to control that. The command `set
|
Occasionally, you may wish to control that. The command `set
|
case-sensitive' lets you do that by specifying `on' for
|
case-sensitive' lets you do that by specifying `on' for
|
case-sensitive matches or `off' for case-insensitive ones. If you
|
case-sensitive matches or `off' for case-insensitive ones. If you
|
specify `auto', case sensitivity is reset to the default suitable
|
specify `auto', case sensitivity is reset to the default suitable
|
for the source language. The default is case-sensitive matches
|
for the source language. The default is case-sensitive matches
|
for all languages except for Fortran, for which the default is
|
for all languages except for Fortran, for which the default is
|
case-insensitive matches.
|
case-insensitive matches.
|
|
|
`show case-sensitive'
|
`show case-sensitive'
|
This command shows the current setting of case sensitivity for
|
This command shows the current setting of case sensitivity for
|
symbols lookups.
|
symbols lookups.
|
|
|
`info address SYMBOL'
|
`info address SYMBOL'
|
Describe where the data for SYMBOL is stored. For a register
|
Describe where the data for SYMBOL is stored. For a register
|
variable, this says which register it is kept in. For a
|
variable, this says which register it is kept in. For a
|
non-register local variable, this prints the stack-frame offset at
|
non-register local variable, this prints the stack-frame offset at
|
which the variable is always stored.
|
which the variable is always stored.
|
|
|
Note the contrast with `print &SYMBOL', which does not work at all
|
Note the contrast with `print &SYMBOL', which does not work at all
|
for a register variable, and for a stack local variable prints the
|
for a register variable, and for a stack local variable prints the
|
exact address of the current instantiation of the variable.
|
exact address of the current instantiation of the variable.
|
|
|
`info symbol ADDR'
|
`info symbol ADDR'
|
Print the name of a symbol which is stored at the address ADDR.
|
Print the name of a symbol which is stored at the address ADDR.
|
If no symbol is stored exactly at ADDR, GDB prints the nearest
|
If no symbol is stored exactly at ADDR, GDB prints the nearest
|
symbol and an offset from it:
|
symbol and an offset from it:
|
|
|
(gdb) info symbol 0x54320
|
(gdb) info symbol 0x54320
|
_initialize_vx + 396 in section .text
|
_initialize_vx + 396 in section .text
|
|
|
This is the opposite of the `info address' command. You can use
|
This is the opposite of the `info address' command. You can use
|
it to find out the name of a variable or a function given its
|
it to find out the name of a variable or a function given its
|
address.
|
address.
|
|
|
For dynamically linked executables, the name of executable or
|
For dynamically linked executables, the name of executable or
|
shared library containing the symbol is also printed:
|
shared library containing the symbol is also printed:
|
|
|
(gdb) info symbol 0x400225
|
(gdb) info symbol 0x400225
|
_start + 5 in section .text of /tmp/a.out
|
_start + 5 in section .text of /tmp/a.out
|
(gdb) info symbol 0x2aaaac2811cf
|
(gdb) info symbol 0x2aaaac2811cf
|
__read_nocancel + 6 in section .text of /usr/lib64/libc.so.6
|
__read_nocancel + 6 in section .text of /usr/lib64/libc.so.6
|
|
|
`whatis [ARG]'
|
`whatis [ARG]'
|
Print the data type of ARG, which can be either an expression or a
|
Print the data type of ARG, which can be either an expression or a
|
data type. With no argument, print the data type of `$', the last
|
data type. With no argument, print the data type of `$', the last
|
value in the value history. If ARG is an expression, it is not
|
value in the value history. If ARG is an expression, it is not
|
actually evaluated, and any side-effecting operations (such as
|
actually evaluated, and any side-effecting operations (such as
|
assignments or function calls) inside it do not take place. If
|
assignments or function calls) inside it do not take place. If
|
ARG is a type name, it may be the name of a type or typedef, or
|
ARG is a type name, it may be the name of a type or typedef, or
|
for C code it may have the form `class CLASS-NAME', `struct
|
for C code it may have the form `class CLASS-NAME', `struct
|
STRUCT-TAG', `union UNION-TAG' or `enum ENUM-TAG'. *Note
|
STRUCT-TAG', `union UNION-TAG' or `enum ENUM-TAG'. *Note
|
Expressions: Expressions.
|
Expressions: Expressions.
|
|
|
`ptype [ARG]'
|
`ptype [ARG]'
|
`ptype' accepts the same arguments as `whatis', but prints a
|
`ptype' accepts the same arguments as `whatis', but prints a
|
detailed description of the type, instead of just the name of the
|
detailed description of the type, instead of just the name of the
|
type. *Note Expressions: Expressions.
|
type. *Note Expressions: Expressions.
|
|
|
For example, for this variable declaration:
|
For example, for this variable declaration:
|
|
|
struct complex {double real; double imag;} v;
|
struct complex {double real; double imag;} v;
|
|
|
the two commands give this output:
|
the two commands give this output:
|
|
|
(gdb) whatis v
|
(gdb) whatis v
|
type = struct complex
|
type = struct complex
|
(gdb) ptype v
|
(gdb) ptype v
|
type = struct complex {
|
type = struct complex {
|
double real;
|
double real;
|
double imag;
|
double imag;
|
}
|
}
|
|
|
As with `whatis', using `ptype' without an argument refers to the
|
As with `whatis', using `ptype' without an argument refers to the
|
type of `$', the last value in the value history.
|
type of `$', the last value in the value history.
|
|
|
Sometimes, programs use opaque data types or incomplete
|
Sometimes, programs use opaque data types or incomplete
|
specifications of complex data structure. If the debug
|
specifications of complex data structure. If the debug
|
information included in the program does not allow GDB to display
|
information included in the program does not allow GDB to display
|
a full declaration of the data type, it will say `
|
a full declaration of the data type, it will say `
|
type>'. For example, given these declarations:
|
type>'. For example, given these declarations:
|
|
|
struct foo;
|
struct foo;
|
struct foo *fooptr;
|
struct foo *fooptr;
|
|
|
but no definition for `struct foo' itself, GDB will say:
|
but no definition for `struct foo' itself, GDB will say:
|
|
|
(gdb) ptype foo
|
(gdb) ptype foo
|
$1 =
|
$1 =
|
|
|
"Incomplete type" is C terminology for data types that are not
|
"Incomplete type" is C terminology for data types that are not
|
completely specified.
|
completely specified.
|
|
|
`info types REGEXP'
|
`info types REGEXP'
|
`info types'
|
`info types'
|
Print a brief description of all types whose names match the
|
Print a brief description of all types whose names match the
|
regular expression REGEXP (or all types in your program, if you
|
regular expression REGEXP (or all types in your program, if you
|
supply no argument). Each complete typename is matched as though
|
supply no argument). Each complete typename is matched as though
|
it were a complete line; thus, `i type value' gives information on
|
it were a complete line; thus, `i type value' gives information on
|
all types in your program whose names include the string `value',
|
all types in your program whose names include the string `value',
|
but `i type ^value$' gives information only on types whose complete
|
but `i type ^value$' gives information only on types whose complete
|
name is `value'.
|
name is `value'.
|
|
|
This command differs from `ptype' in two ways: first, like
|
This command differs from `ptype' in two ways: first, like
|
`whatis', it does not print a detailed description; second, it
|
`whatis', it does not print a detailed description; second, it
|
lists all source files where a type is defined.
|
lists all source files where a type is defined.
|
|
|
`info scope LOCATION'
|
`info scope LOCATION'
|
List all the variables local to a particular scope. This command
|
List all the variables local to a particular scope. This command
|
accepts a LOCATION argument--a function name, a source line, or an
|
accepts a LOCATION argument--a function name, a source line, or an
|
address preceded by a `*', and prints all the variables local to
|
address preceded by a `*', and prints all the variables local to
|
the scope defined by that location. (*Note Specify Location::, for
|
the scope defined by that location. (*Note Specify Location::, for
|
details about supported forms of LOCATION.) For example:
|
details about supported forms of LOCATION.) For example:
|
|
|
(gdb) info scope command_line_handler
|
(gdb) info scope command_line_handler
|
Scope for command_line_handler:
|
Scope for command_line_handler:
|
Symbol rl is an argument at stack/frame offset 8, length 4.
|
Symbol rl is an argument at stack/frame offset 8, length 4.
|
Symbol linebuffer is in static storage at address 0x150a18, length 4.
|
Symbol linebuffer is in static storage at address 0x150a18, length 4.
|
Symbol linelength is in static storage at address 0x150a1c, length 4.
|
Symbol linelength is in static storage at address 0x150a1c, length 4.
|
Symbol p is a local variable in register $esi, length 4.
|
Symbol p is a local variable in register $esi, length 4.
|
Symbol p1 is a local variable in register $ebx, length 4.
|
Symbol p1 is a local variable in register $ebx, length 4.
|
Symbol nline is a local variable in register $edx, length 4.
|
Symbol nline is a local variable in register $edx, length 4.
|
Symbol repeat is a local variable at frame offset -8, length 4.
|
Symbol repeat is a local variable at frame offset -8, length 4.
|
|
|
This command is especially useful for determining what data to
|
This command is especially useful for determining what data to
|
collect during a "trace experiment", see *note collect: Tracepoint
|
collect during a "trace experiment", see *note collect: Tracepoint
|
Actions.
|
Actions.
|
|
|
`info source'
|
`info source'
|
Show information about the current source file--that is, the
|
Show information about the current source file--that is, the
|
source file for the function containing the current point of
|
source file for the function containing the current point of
|
execution:
|
execution:
|
* the name of the source file, and the directory containing it,
|
* the name of the source file, and the directory containing it,
|
|
|
* the directory it was compiled in,
|
* the directory it was compiled in,
|
|
|
* its length, in lines,
|
* its length, in lines,
|
|
|
* which programming language it is written in,
|
* which programming language it is written in,
|
|
|
* whether the executable includes debugging information for
|
* whether the executable includes debugging information for
|
that file, and if so, what format the information is in
|
that file, and if so, what format the information is in
|
(e.g., STABS, Dwarf 2, etc.), and
|
(e.g., STABS, Dwarf 2, etc.), and
|
|
|
* whether the debugging information includes information about
|
* whether the debugging information includes information about
|
preprocessor macros.
|
preprocessor macros.
|
|
|
`info sources'
|
`info sources'
|
Print the names of all source files in your program for which
|
Print the names of all source files in your program for which
|
there is debugging information, organized into two lists: files
|
there is debugging information, organized into two lists: files
|
whose symbols have already been read, and files whose symbols will
|
whose symbols have already been read, and files whose symbols will
|
be read when needed.
|
be read when needed.
|
|
|
`info functions'
|
`info functions'
|
Print the names and data types of all defined functions.
|
Print the names and data types of all defined functions.
|
|
|
`info functions REGEXP'
|
`info functions REGEXP'
|
Print the names and data types of all defined functions whose
|
Print the names and data types of all defined functions whose
|
names contain a match for regular expression REGEXP. Thus, `info
|
names contain a match for regular expression REGEXP. Thus, `info
|
fun step' finds all functions whose names include `step'; `info
|
fun step' finds all functions whose names include `step'; `info
|
fun ^step' finds those whose names start with `step'. If a
|
fun ^step' finds those whose names start with `step'. If a
|
function name contains characters that conflict with the regular
|
function name contains characters that conflict with the regular
|
expression language (e.g. `operator*()'), they may be quoted with
|
expression language (e.g. `operator*()'), they may be quoted with
|
a backslash.
|
a backslash.
|
|
|
`info variables'
|
`info variables'
|
Print the names and data types of all variables that are defined
|
Print the names and data types of all variables that are defined
|
outside of functions (i.e. excluding local variables).
|
outside of functions (i.e. excluding local variables).
|
|
|
`info variables REGEXP'
|
`info variables REGEXP'
|
Print the names and data types of all variables (except for local
|
Print the names and data types of all variables (except for local
|
variables) whose names contain a match for regular expression
|
variables) whose names contain a match for regular expression
|
REGEXP.
|
REGEXP.
|
|
|
`info classes'
|
`info classes'
|
`info classes REGEXP'
|
`info classes REGEXP'
|
Display all Objective-C classes in your program, or (with the
|
Display all Objective-C classes in your program, or (with the
|
REGEXP argument) all those matching a particular regular
|
REGEXP argument) all those matching a particular regular
|
expression.
|
expression.
|
|
|
`info selectors'
|
`info selectors'
|
`info selectors REGEXP'
|
`info selectors REGEXP'
|
Display all Objective-C selectors in your program, or (with the
|
Display all Objective-C selectors in your program, or (with the
|
REGEXP argument) all those matching a particular regular
|
REGEXP argument) all those matching a particular regular
|
expression.
|
expression.
|
|
|
Some systems allow individual object files that make up your
|
Some systems allow individual object files that make up your
|
program to be replaced without stopping and restarting your
|
program to be replaced without stopping and restarting your
|
program. For example, in VxWorks you can simply recompile a
|
program. For example, in VxWorks you can simply recompile a
|
defective object file and keep on running. If you are running on
|
defective object file and keep on running. If you are running on
|
one of these systems, you can allow GDB to reload the symbols for
|
one of these systems, you can allow GDB to reload the symbols for
|
automatically relinked modules:
|
automatically relinked modules:
|
|
|
`set symbol-reloading on'
|
`set symbol-reloading on'
|
Replace symbol definitions for the corresponding source file
|
Replace symbol definitions for the corresponding source file
|
when an object file with a particular name is seen again.
|
when an object file with a particular name is seen again.
|
|
|
`set symbol-reloading off'
|
`set symbol-reloading off'
|
Do not replace symbol definitions when encountering object
|
Do not replace symbol definitions when encountering object
|
files of the same name more than once. This is the default
|
files of the same name more than once. This is the default
|
state; if you are not running on a system that permits
|
state; if you are not running on a system that permits
|
automatic relinking of modules, you should leave
|
automatic relinking of modules, you should leave
|
`symbol-reloading' off, since otherwise GDB may discard
|
`symbol-reloading' off, since otherwise GDB may discard
|
symbols when linking large programs, that may contain several
|
symbols when linking large programs, that may contain several
|
modules (from different directories or libraries) with the
|
modules (from different directories or libraries) with the
|
same name.
|
same name.
|
|
|
`show symbol-reloading'
|
`show symbol-reloading'
|
Show the current `on' or `off' setting.
|
Show the current `on' or `off' setting.
|
|
|
`set opaque-type-resolution on'
|
`set opaque-type-resolution on'
|
Tell GDB to resolve opaque types. An opaque type is a type
|
Tell GDB to resolve opaque types. An opaque type is a type
|
declared as a pointer to a `struct', `class', or `union'--for
|
declared as a pointer to a `struct', `class', or `union'--for
|
example, `struct MyType *'--that is used in one source file
|
example, `struct MyType *'--that is used in one source file
|
although the full declaration of `struct MyType' is in another
|
although the full declaration of `struct MyType' is in another
|
source file. The default is on.
|
source file. The default is on.
|
|
|
A change in the setting of this subcommand will not take effect
|
A change in the setting of this subcommand will not take effect
|
until the next time symbols for a file are loaded.
|
until the next time symbols for a file are loaded.
|
|
|
`set opaque-type-resolution off'
|
`set opaque-type-resolution off'
|
Tell GDB not to resolve opaque types. In this case, the type is
|
Tell GDB not to resolve opaque types. In this case, the type is
|
printed as follows:
|
printed as follows:
|
{}
|
{}
|
|
|
`show opaque-type-resolution'
|
`show opaque-type-resolution'
|
Show whether opaque types are resolved or not.
|
Show whether opaque types are resolved or not.
|
|
|
`maint print symbols FILENAME'
|
`maint print symbols FILENAME'
|
`maint print psymbols FILENAME'
|
`maint print psymbols FILENAME'
|
`maint print msymbols FILENAME'
|
`maint print msymbols FILENAME'
|
Write a dump of debugging symbol data into the file FILENAME.
|
Write a dump of debugging symbol data into the file FILENAME.
|
These commands are used to debug the GDB symbol-reading code. Only
|
These commands are used to debug the GDB symbol-reading code. Only
|
symbols with debugging data are included. If you use `maint print
|
symbols with debugging data are included. If you use `maint print
|
symbols', GDB includes all the symbols for which it has already
|
symbols', GDB includes all the symbols for which it has already
|
collected full details: that is, FILENAME reflects symbols for
|
collected full details: that is, FILENAME reflects symbols for
|
only those files whose symbols GDB has read. You can use the
|
only those files whose symbols GDB has read. You can use the
|
command `info sources' to find out which files these are. If you
|
command `info sources' to find out which files these are. If you
|
use `maint print psymbols' instead, the dump shows information
|
use `maint print psymbols' instead, the dump shows information
|
about symbols that GDB only knows partially--that is, symbols
|
about symbols that GDB only knows partially--that is, symbols
|
defined in files that GDB has skimmed, but not yet read
|
defined in files that GDB has skimmed, but not yet read
|
completely. Finally, `maint print msymbols' dumps just the
|
completely. Finally, `maint print msymbols' dumps just the
|
minimal symbol information required for each object file from
|
minimal symbol information required for each object file from
|
which GDB has read some symbols. *Note Commands to Specify Files:
|
which GDB has read some symbols. *Note Commands to Specify Files:
|
Files, for a discussion of how GDB reads symbols (in the
|
Files, for a discussion of how GDB reads symbols (in the
|
description of `symbol-file').
|
description of `symbol-file').
|
|
|
`maint info symtabs [ REGEXP ]'
|
`maint info symtabs [ REGEXP ]'
|
`maint info psymtabs [ REGEXP ]'
|
`maint info psymtabs [ REGEXP ]'
|
List the `struct symtab' or `struct partial_symtab' structures
|
List the `struct symtab' or `struct partial_symtab' structures
|
whose names match REGEXP. If REGEXP is not given, list them all.
|
whose names match REGEXP. If REGEXP is not given, list them all.
|
The output includes expressions which you can copy into a GDB
|
The output includes expressions which you can copy into a GDB
|
debugging this one to examine a particular structure in more
|
debugging this one to examine a particular structure in more
|
detail. For example:
|
detail. For example:
|
|
|
(gdb) maint info psymtabs dwarf2read
|
(gdb) maint info psymtabs dwarf2read
|
{ objfile /home/gnu/build/gdb/gdb
|
{ objfile /home/gnu/build/gdb/gdb
|
((struct objfile *) 0x82e69d0)
|
((struct objfile *) 0x82e69d0)
|
{ psymtab /home/gnu/src/gdb/dwarf2read.c
|
{ psymtab /home/gnu/src/gdb/dwarf2read.c
|
((struct partial_symtab *) 0x8474b10)
|
((struct partial_symtab *) 0x8474b10)
|
readin no
|
readin no
|
fullname (null)
|
fullname (null)
|
text addresses 0x814d3c8 -- 0x8158074
|
text addresses 0x814d3c8 -- 0x8158074
|
globals (* (struct partial_symbol **) 0x8507a08 @ 9)
|
globals (* (struct partial_symbol **) 0x8507a08 @ 9)
|
statics (* (struct partial_symbol **) 0x40e95b78 @ 2882)
|
statics (* (struct partial_symbol **) 0x40e95b78 @ 2882)
|
dependencies (none)
|
dependencies (none)
|
}
|
}
|
}
|
}
|
(gdb) maint info symtabs
|
(gdb) maint info symtabs
|
(gdb)
|
(gdb)
|
We see that there is one partial symbol table whose filename
|
We see that there is one partial symbol table whose filename
|
contains the string `dwarf2read', belonging to the `gdb'
|
contains the string `dwarf2read', belonging to the `gdb'
|
executable; and we see that GDB has not read in any symtabs yet at
|
executable; and we see that GDB has not read in any symtabs yet at
|
all. If we set a breakpoint on a function, that will cause GDB to
|
all. If we set a breakpoint on a function, that will cause GDB to
|
read the symtab for the compilation unit containing that function:
|
read the symtab for the compilation unit containing that function:
|
|
|
(gdb) break dwarf2_psymtab_to_symtab
|
(gdb) break dwarf2_psymtab_to_symtab
|
Breakpoint 1 at 0x814e5da: file /home/gnu/src/gdb/dwarf2read.c,
|
Breakpoint 1 at 0x814e5da: file /home/gnu/src/gdb/dwarf2read.c,
|
line 1574.
|
line 1574.
|
(gdb) maint info symtabs
|
(gdb) maint info symtabs
|
{ objfile /home/gnu/build/gdb/gdb
|
{ objfile /home/gnu/build/gdb/gdb
|
((struct objfile *) 0x82e69d0)
|
((struct objfile *) 0x82e69d0)
|
{ symtab /home/gnu/src/gdb/dwarf2read.c
|
{ symtab /home/gnu/src/gdb/dwarf2read.c
|
((struct symtab *) 0x86c1f38)
|
((struct symtab *) 0x86c1f38)
|
dirname (null)
|
dirname (null)
|
fullname (null)
|
fullname (null)
|
blockvector ((struct blockvector *) 0x86c1bd0) (primary)
|
blockvector ((struct blockvector *) 0x86c1bd0) (primary)
|
linetable ((struct linetable *) 0x8370fa0)
|
linetable ((struct linetable *) 0x8370fa0)
|
debugformat DWARF 2
|
debugformat DWARF 2
|
}
|
}
|
}
|
}
|
(gdb)
|
(gdb)
|
|
|
|
|
File: gdb.info, Node: Altering, Next: GDB Files, Prev: Symbols, Up: Top
|
File: gdb.info, Node: Altering, Next: GDB Files, Prev: Symbols, Up: Top
|
|
|
17 Altering Execution
|
17 Altering Execution
|
*********************
|
*********************
|
|
|
Once you think you have found an error in your program, you might want
|
Once you think you have found an error in your program, you might want
|
to find out for certain whether correcting the apparent error would
|
to find out for certain whether correcting the apparent error would
|
lead to correct results in the rest of the run. You can find the
|
lead to correct results in the rest of the run. You can find the
|
answer by experiment, using the GDB features for altering execution of
|
answer by experiment, using the GDB features for altering execution of
|
the program.
|
the program.
|
|
|
For example, you can store new values into variables or memory
|
For example, you can store new values into variables or memory
|
locations, give your program a signal, restart it at a different
|
locations, give your program a signal, restart it at a different
|
address, or even return prematurely from a function.
|
address, or even return prematurely from a function.
|
|
|
* Menu:
|
* Menu:
|
|
|
* Assignment:: Assignment to variables
|
* Assignment:: Assignment to variables
|
* Jumping:: Continuing at a different address
|
* Jumping:: Continuing at a different address
|
* Signaling:: Giving your program a signal
|
* Signaling:: Giving your program a signal
|
* Returning:: Returning from a function
|
* Returning:: Returning from a function
|
* Calling:: Calling your program's functions
|
* Calling:: Calling your program's functions
|
* Patching:: Patching your program
|
* Patching:: Patching your program
|
|
|
|
|
File: gdb.info, Node: Assignment, Next: Jumping, Up: Altering
|
File: gdb.info, Node: Assignment, Next: Jumping, Up: Altering
|
|
|
17.1 Assignment to Variables
|
17.1 Assignment to Variables
|
============================
|
============================
|
|
|
To alter the value of a variable, evaluate an assignment expression.
|
To alter the value of a variable, evaluate an assignment expression.
|
*Note Expressions: Expressions. For example,
|
*Note Expressions: Expressions. For example,
|
|
|
print x=4
|
print x=4
|
|
|
stores the value 4 into the variable `x', and then prints the value of
|
stores the value 4 into the variable `x', and then prints the value of
|
the assignment expression (which is 4). *Note Using GDB with Different
|
the assignment expression (which is 4). *Note Using GDB with Different
|
Languages: Languages, for more information on operators in supported
|
Languages: Languages, for more information on operators in supported
|
languages.
|
languages.
|
|
|
If you are not interested in seeing the value of the assignment, use
|
If you are not interested in seeing the value of the assignment, use
|
the `set' command instead of the `print' command. `set' is really the
|
the `set' command instead of the `print' command. `set' is really the
|
same as `print' except that the expression's value is not printed and
|
same as `print' except that the expression's value is not printed and
|
is not put in the value history (*note Value History: Value History.).
|
is not put in the value history (*note Value History: Value History.).
|
The expression is evaluated only for its effects.
|
The expression is evaluated only for its effects.
|
|
|
If the beginning of the argument string of the `set' command appears
|
If the beginning of the argument string of the `set' command appears
|
identical to a `set' subcommand, use the `set variable' command instead
|
identical to a `set' subcommand, use the `set variable' command instead
|
of just `set'. This command is identical to `set' except for its lack
|
of just `set'. This command is identical to `set' except for its lack
|
of subcommands. For example, if your program has a variable `width',
|
of subcommands. For example, if your program has a variable `width',
|
you get an error if you try to set a new value with just `set
|
you get an error if you try to set a new value with just `set
|
width=13', because GDB has the command `set width':
|
width=13', because GDB has the command `set width':
|
|
|
(gdb) whatis width
|
(gdb) whatis width
|
type = double
|
type = double
|
(gdb) p width
|
(gdb) p width
|
$4 = 13
|
$4 = 13
|
(gdb) set width=47
|
(gdb) set width=47
|
Invalid syntax in expression.
|
Invalid syntax in expression.
|
|
|
The invalid expression, of course, is `=47'. In order to actually set
|
The invalid expression, of course, is `=47'. In order to actually set
|
the program's variable `width', use
|
the program's variable `width', use
|
|
|
(gdb) set var width=47
|
(gdb) set var width=47
|
|
|
Because the `set' command has many subcommands that can conflict
|
Because the `set' command has many subcommands that can conflict
|
with the names of program variables, it is a good idea to use the `set
|
with the names of program variables, it is a good idea to use the `set
|
variable' command instead of just `set'. For example, if your program
|
variable' command instead of just `set'. For example, if your program
|
has a variable `g', you run into problems if you try to set a new value
|
has a variable `g', you run into problems if you try to set a new value
|
with just `set g=4', because GDB has the command `set gnutarget',
|
with just `set g=4', because GDB has the command `set gnutarget',
|
abbreviated `set g':
|
abbreviated `set g':
|
|
|
(gdb) whatis g
|
(gdb) whatis g
|
type = double
|
type = double
|
(gdb) p g
|
(gdb) p g
|
$1 = 1
|
$1 = 1
|
(gdb) set g=4
|
(gdb) set g=4
|
(gdb) p g
|
(gdb) p g
|
$2 = 1
|
$2 = 1
|
(gdb) r
|
(gdb) r
|
The program being debugged has been started already.
|
The program being debugged has been started already.
|
Start it from the beginning? (y or n) y
|
Start it from the beginning? (y or n) y
|
Starting program: /home/smith/cc_progs/a.out
|
Starting program: /home/smith/cc_progs/a.out
|
"/home/smith/cc_progs/a.out": can't open to read symbols:
|
"/home/smith/cc_progs/a.out": can't open to read symbols:
|
Invalid bfd target.
|
Invalid bfd target.
|
(gdb) show g
|
(gdb) show g
|
The current BFD target is "=4".
|
The current BFD target is "=4".
|
|
|
The program variable `g' did not change, and you silently set the
|
The program variable `g' did not change, and you silently set the
|
`gnutarget' to an invalid value. In order to set the variable `g', use
|
`gnutarget' to an invalid value. In order to set the variable `g', use
|
|
|
(gdb) set var g=4
|
(gdb) set var g=4
|
|
|
GDB allows more implicit conversions in assignments than C; you can
|
GDB allows more implicit conversions in assignments than C; you can
|
freely store an integer value into a pointer variable or vice versa,
|
freely store an integer value into a pointer variable or vice versa,
|
and you can convert any structure to any other structure that is the
|
and you can convert any structure to any other structure that is the
|
same length or shorter.
|
same length or shorter.
|
|
|
To store values into arbitrary places in memory, use the `{...}'
|
To store values into arbitrary places in memory, use the `{...}'
|
construct to generate a value of specified type at a specified address
|
construct to generate a value of specified type at a specified address
|
(*note Expressions: Expressions.). For example, `{int}0x83040' refers
|
(*note Expressions: Expressions.). For example, `{int}0x83040' refers
|
to memory location `0x83040' as an integer (which implies a certain size
|
to memory location `0x83040' as an integer (which implies a certain size
|
and representation in memory), and
|
and representation in memory), and
|
|
|
set {int}0x83040 = 4
|
set {int}0x83040 = 4
|
|
|
stores the value 4 into that memory location.
|
stores the value 4 into that memory location.
|
|
|
|
|
File: gdb.info, Node: Jumping, Next: Signaling, Prev: Assignment, Up: Altering
|
File: gdb.info, Node: Jumping, Next: Signaling, Prev: Assignment, Up: Altering
|
|
|
17.2 Continuing at a Different Address
|
17.2 Continuing at a Different Address
|
======================================
|
======================================
|
|
|
Ordinarily, when you continue your program, you do so at the place where
|
Ordinarily, when you continue your program, you do so at the place where
|
it stopped, with the `continue' command. You can instead continue at
|
it stopped, with the `continue' command. You can instead continue at
|
an address of your own choosing, with the following commands:
|
an address of your own choosing, with the following commands:
|
|
|
`jump LINESPEC'
|
`jump LINESPEC'
|
`jump LOCATION'
|
`jump LOCATION'
|
Resume execution at line LINESPEC or at address given by LOCATION.
|
Resume execution at line LINESPEC or at address given by LOCATION.
|
Execution stops again immediately if there is a breakpoint there.
|
Execution stops again immediately if there is a breakpoint there.
|
*Note Specify Location::, for a description of the different forms
|
*Note Specify Location::, for a description of the different forms
|
of LINESPEC and LOCATION. It is common practice to use the
|
of LINESPEC and LOCATION. It is common practice to use the
|
`tbreak' command in conjunction with `jump'. *Note Setting
|
`tbreak' command in conjunction with `jump'. *Note Setting
|
Breakpoints: Set Breaks.
|
Breakpoints: Set Breaks.
|
|
|
The `jump' command does not change the current stack frame, or the
|
The `jump' command does not change the current stack frame, or the
|
stack pointer, or the contents of any memory location or any
|
stack pointer, or the contents of any memory location or any
|
register other than the program counter. If line LINESPEC is in a
|
register other than the program counter. If line LINESPEC is in a
|
different function from the one currently executing, the results
|
different function from the one currently executing, the results
|
may be bizarre if the two functions expect different patterns of
|
may be bizarre if the two functions expect different patterns of
|
arguments or of local variables. For this reason, the `jump'
|
arguments or of local variables. For this reason, the `jump'
|
command requests confirmation if the specified line is not in the
|
command requests confirmation if the specified line is not in the
|
function currently executing. However, even bizarre results are
|
function currently executing. However, even bizarre results are
|
predictable if you are well acquainted with the machine-language
|
predictable if you are well acquainted with the machine-language
|
code of your program.
|
code of your program.
|
|
|
On many systems, you can get much the same effect as the `jump'
|
On many systems, you can get much the same effect as the `jump'
|
command by storing a new value into the register `$pc'. The difference
|
command by storing a new value into the register `$pc'. The difference
|
is that this does not start your program running; it only changes the
|
is that this does not start your program running; it only changes the
|
address of where it _will_ run when you continue. For example,
|
address of where it _will_ run when you continue. For example,
|
|
|
set $pc = 0x485
|
set $pc = 0x485
|
|
|
makes the next `continue' command or stepping command execute at
|
makes the next `continue' command or stepping command execute at
|
address `0x485', rather than at the address where your program stopped.
|
address `0x485', rather than at the address where your program stopped.
|
*Note Continuing and Stepping: Continuing and Stepping.
|
*Note Continuing and Stepping: Continuing and Stepping.
|
|
|
The most common occasion to use the `jump' command is to back
|
The most common occasion to use the `jump' command is to back
|
up--perhaps with more breakpoints set--over a portion of a program that
|
up--perhaps with more breakpoints set--over a portion of a program that
|
has already executed, in order to examine its execution in more detail.
|
has already executed, in order to examine its execution in more detail.
|
|
|
|
|
File: gdb.info, Node: Signaling, Next: Returning, Prev: Jumping, Up: Altering
|
File: gdb.info, Node: Signaling, Next: Returning, Prev: Jumping, Up: Altering
|
|
|
17.3 Giving your Program a Signal
|
17.3 Giving your Program a Signal
|
=================================
|
=================================
|
|
|
`signal SIGNAL'
|
`signal SIGNAL'
|
Resume execution where your program stopped, but immediately give
|
Resume execution where your program stopped, but immediately give
|
it the signal SIGNAL. SIGNAL can be the name or the number of a
|
it the signal SIGNAL. SIGNAL can be the name or the number of a
|
signal. For example, on many systems `signal 2' and `signal
|
signal. For example, on many systems `signal 2' and `signal
|
SIGINT' are both ways of sending an interrupt signal.
|
SIGINT' are both ways of sending an interrupt signal.
|
|
|
Alternatively, if SIGNAL is zero, continue execution without
|
Alternatively, if SIGNAL is zero, continue execution without
|
giving a signal. This is useful when your program stopped on
|
giving a signal. This is useful when your program stopped on
|
account of a signal and would ordinary see the signal when resumed
|
account of a signal and would ordinary see the signal when resumed
|
with the `continue' command; `signal 0' causes it to resume
|
with the `continue' command; `signal 0' causes it to resume
|
without a signal.
|
without a signal.
|
|
|
`signal' does not repeat when you press a second time after
|
`signal' does not repeat when you press a second time after
|
executing the command.
|
executing the command.
|
|
|
Invoking the `signal' command is not the same as invoking the `kill'
|
Invoking the `signal' command is not the same as invoking the `kill'
|
utility from the shell. Sending a signal with `kill' causes GDB to
|
utility from the shell. Sending a signal with `kill' causes GDB to
|
decide what to do with the signal depending on the signal handling
|
decide what to do with the signal depending on the signal handling
|
tables (*note Signals::). The `signal' command passes the signal
|
tables (*note Signals::). The `signal' command passes the signal
|
directly to your program.
|
directly to your program.
|
|
|
|
|
File: gdb.info, Node: Returning, Next: Calling, Prev: Signaling, Up: Altering
|
File: gdb.info, Node: Returning, Next: Calling, Prev: Signaling, Up: Altering
|
|
|
17.4 Returning from a Function
|
17.4 Returning from a Function
|
==============================
|
==============================
|
|
|
`return'
|
`return'
|
`return EXPRESSION'
|
`return EXPRESSION'
|
You can cancel execution of a function call with the `return'
|
You can cancel execution of a function call with the `return'
|
command. If you give an EXPRESSION argument, its value is used as
|
command. If you give an EXPRESSION argument, its value is used as
|
the function's return value.
|
the function's return value.
|
|
|
When you use `return', GDB discards the selected stack frame (and
|
When you use `return', GDB discards the selected stack frame (and
|
all frames within it). You can think of this as making the discarded
|
all frames within it). You can think of this as making the discarded
|
frame return prematurely. If you wish to specify a value to be
|
frame return prematurely. If you wish to specify a value to be
|
returned, give that value as the argument to `return'.
|
returned, give that value as the argument to `return'.
|
|
|
This pops the selected stack frame (*note Selecting a Frame:
|
This pops the selected stack frame (*note Selecting a Frame:
|
Selection.), and any other frames inside of it, leaving its caller as
|
Selection.), and any other frames inside of it, leaving its caller as
|
the innermost remaining frame. That frame becomes selected. The
|
the innermost remaining frame. That frame becomes selected. The
|
specified value is stored in the registers used for returning values of
|
specified value is stored in the registers used for returning values of
|
functions.
|
functions.
|
|
|
The `return' command does not resume execution; it leaves the
|
The `return' command does not resume execution; it leaves the
|
program stopped in the state that would exist if the function had just
|
program stopped in the state that would exist if the function had just
|
returned. In contrast, the `finish' command (*note Continuing and
|
returned. In contrast, the `finish' command (*note Continuing and
|
Stepping: Continuing and Stepping.) resumes execution until the
|
Stepping: Continuing and Stepping.) resumes execution until the
|
selected stack frame returns naturally.
|
selected stack frame returns naturally.
|
|
|
GDB needs to know how the EXPRESSION argument should be set for the
|
GDB needs to know how the EXPRESSION argument should be set for the
|
inferior. The concrete registers assignment depends on the OS ABI and
|
inferior. The concrete registers assignment depends on the OS ABI and
|
the type being returned by the selected stack frame. For example it is
|
the type being returned by the selected stack frame. For example it is
|
common for OS ABI to return floating point values in FPU registers
|
common for OS ABI to return floating point values in FPU registers
|
while integer values in CPU registers. Still some ABIs return even
|
while integer values in CPU registers. Still some ABIs return even
|
floating point values in CPU registers. Larger integer widths (such as
|
floating point values in CPU registers. Larger integer widths (such as
|
`long long int') also have specific placement rules. GDB already knows
|
`long long int') also have specific placement rules. GDB already knows
|
the OS ABI from its current target so it needs to find out also the
|
the OS ABI from its current target so it needs to find out also the
|
type being returned to make the assignment into the right register(s).
|
type being returned to make the assignment into the right register(s).
|
|
|
Normally, the selected stack frame has debug info. GDB will always
|
Normally, the selected stack frame has debug info. GDB will always
|
use the debug info instead of the implicit type of EXPRESSION when the
|
use the debug info instead of the implicit type of EXPRESSION when the
|
debug info is available. For example, if you type `return -1', and the
|
debug info is available. For example, if you type `return -1', and the
|
function in the current stack frame is declared to return a `long long
|
function in the current stack frame is declared to return a `long long
|
int', GDB transparently converts the implicit `int' value of -1 into a
|
int', GDB transparently converts the implicit `int' value of -1 into a
|
`long long int':
|
`long long int':
|
|
|
Breakpoint 1, func () at gdb.base/return-nodebug.c:29
|
Breakpoint 1, func () at gdb.base/return-nodebug.c:29
|
29 return 31;
|
29 return 31;
|
(gdb) return -1
|
(gdb) return -1
|
Make func return now? (y or n) y
|
Make func return now? (y or n) y
|
#0 0x004004f6 in main () at gdb.base/return-nodebug.c:43
|
#0 0x004004f6 in main () at gdb.base/return-nodebug.c:43
|
43 printf ("result=%lld\n", func ());
|
43 printf ("result=%lld\n", func ());
|
(gdb)
|
(gdb)
|
|
|
However, if the selected stack frame does not have a debug info,
|
However, if the selected stack frame does not have a debug info,
|
e.g., if the function was compiled without debug info, GDB has to find
|
e.g., if the function was compiled without debug info, GDB has to find
|
out the type to return from user. Specifying a different type by
|
out the type to return from user. Specifying a different type by
|
mistake may set the value in different inferior registers than the
|
mistake may set the value in different inferior registers than the
|
caller code expects. For example, typing `return -1' with its implicit
|
caller code expects. For example, typing `return -1' with its implicit
|
type `int' would set only a part of a `long long int' result for a
|
type `int' would set only a part of a `long long int' result for a
|
debug info less function (on 32-bit architectures). Therefore the user
|
debug info less function (on 32-bit architectures). Therefore the user
|
is required to specify the return type by an appropriate cast
|
is required to specify the return type by an appropriate cast
|
explicitly:
|
explicitly:
|
|
|
Breakpoint 2, 0x0040050b in func ()
|
Breakpoint 2, 0x0040050b in func ()
|
(gdb) return -1
|
(gdb) return -1
|
Return value type not available for selected stack frame.
|
Return value type not available for selected stack frame.
|
Please use an explicit cast of the value to return.
|
Please use an explicit cast of the value to return.
|
(gdb) return (long long int) -1
|
(gdb) return (long long int) -1
|
Make selected stack frame return now? (y or n) y
|
Make selected stack frame return now? (y or n) y
|
#0 0x00400526 in main ()
|
#0 0x00400526 in main ()
|
(gdb)
|
(gdb)
|
|
|
|
|
File: gdb.info, Node: Calling, Next: Patching, Prev: Returning, Up: Altering
|
File: gdb.info, Node: Calling, Next: Patching, Prev: Returning, Up: Altering
|
|
|
17.5 Calling Program Functions
|
17.5 Calling Program Functions
|
==============================
|
==============================
|
|
|
`print EXPR'
|
`print EXPR'
|
Evaluate the expression EXPR and display the resulting value.
|
Evaluate the expression EXPR and display the resulting value.
|
EXPR may include calls to functions in the program being debugged.
|
EXPR may include calls to functions in the program being debugged.
|
|
|
`call EXPR'
|
`call EXPR'
|
Evaluate the expression EXPR without displaying `void' returned
|
Evaluate the expression EXPR without displaying `void' returned
|
values.
|
values.
|
|
|
You can use this variant of the `print' command if you want to
|
You can use this variant of the `print' command if you want to
|
execute a function from your program that does not return anything
|
execute a function from your program that does not return anything
|
(a.k.a. "a void function"), but without cluttering the output with
|
(a.k.a. "a void function"), but without cluttering the output with
|
`void' returned values that GDB will otherwise print. If the
|
`void' returned values that GDB will otherwise print. If the
|
result is not void, it is printed and saved in the value history.
|
result is not void, it is printed and saved in the value history.
|
|
|
It is possible for the function you call via the `print' or `call'
|
It is possible for the function you call via the `print' or `call'
|
command to generate a signal (e.g., if there's a bug in the function,
|
command to generate a signal (e.g., if there's a bug in the function,
|
or if you passed it incorrect arguments). What happens in that case is
|
or if you passed it incorrect arguments). What happens in that case is
|
controlled by the `set unwindonsignal' command.
|
controlled by the `set unwindonsignal' command.
|
|
|
Similarly, with a C++ program it is possible for the function you
|
Similarly, with a C++ program it is possible for the function you
|
call via the `print' or `call' command to generate an exception that is
|
call via the `print' or `call' command to generate an exception that is
|
not handled due to the constraints of the dummy frame. In this case,
|
not handled due to the constraints of the dummy frame. In this case,
|
any exception that is raised in the frame, but has an out-of-frame
|
any exception that is raised in the frame, but has an out-of-frame
|
exception handler will not be found. GDB builds a dummy-frame for the
|
exception handler will not be found. GDB builds a dummy-frame for the
|
inferior function call, and the unwinder cannot seek for exception
|
inferior function call, and the unwinder cannot seek for exception
|
handlers outside of this dummy-frame. What happens in that case is
|
handlers outside of this dummy-frame. What happens in that case is
|
controlled by the `set unwind-on-terminating-exception' command.
|
controlled by the `set unwind-on-terminating-exception' command.
|
|
|
`set unwindonsignal'
|
`set unwindonsignal'
|
Set unwinding of the stack if a signal is received while in a
|
Set unwinding of the stack if a signal is received while in a
|
function that GDB called in the program being debugged. If set to
|
function that GDB called in the program being debugged. If set to
|
on, GDB unwinds the stack it created for the call and restores the
|
on, GDB unwinds the stack it created for the call and restores the
|
context to what it was before the call. If set to off (the
|
context to what it was before the call. If set to off (the
|
default), GDB stops in the frame where the signal was received.
|
default), GDB stops in the frame where the signal was received.
|
|
|
`show unwindonsignal'
|
`show unwindonsignal'
|
Show the current setting of stack unwinding in the functions
|
Show the current setting of stack unwinding in the functions
|
called by GDB.
|
called by GDB.
|
|
|
`set unwind-on-terminating-exception'
|
`set unwind-on-terminating-exception'
|
Set unwinding of the stack if a C++ exception is raised, but left
|
Set unwinding of the stack if a C++ exception is raised, but left
|
unhandled while in a function that GDB called in the program being
|
unhandled while in a function that GDB called in the program being
|
debugged. If set to on (the default), GDB unwinds the stack it
|
debugged. If set to on (the default), GDB unwinds the stack it
|
created for the call and restores the context to what it was before
|
created for the call and restores the context to what it was before
|
the call. If set to off, GDB the exception is delivered to the
|
the call. If set to off, GDB the exception is delivered to the
|
default C++ exception handler and the inferior terminated.
|
default C++ exception handler and the inferior terminated.
|
|
|
`show unwind-on-terminating-exception'
|
`show unwind-on-terminating-exception'
|
Show the current setting of stack unwinding in the functions
|
Show the current setting of stack unwinding in the functions
|
called by GDB.
|
called by GDB.
|
|
|
|
|
Sometimes, a function you wish to call is actually a "weak alias"
|
Sometimes, a function you wish to call is actually a "weak alias"
|
for another function. In such case, GDB might not pick up the type
|
for another function. In such case, GDB might not pick up the type
|
information, including the types of the function arguments, which
|
information, including the types of the function arguments, which
|
causes GDB to call the inferior function incorrectly. As a result, the
|
causes GDB to call the inferior function incorrectly. As a result, the
|
called function will function erroneously and may even crash. A
|
called function will function erroneously and may even crash. A
|
solution to that is to use the name of the aliased function instead.
|
solution to that is to use the name of the aliased function instead.
|
|
|
|
|
File: gdb.info, Node: Patching, Prev: Calling, Up: Altering
|
File: gdb.info, Node: Patching, Prev: Calling, Up: Altering
|
|
|
17.6 Patching Programs
|
17.6 Patching Programs
|
======================
|
======================
|
|
|
By default, GDB opens the file containing your program's executable
|
By default, GDB opens the file containing your program's executable
|
code (or the corefile) read-only. This prevents accidental alterations
|
code (or the corefile) read-only. This prevents accidental alterations
|
to machine code; but it also prevents you from intentionally patching
|
to machine code; but it also prevents you from intentionally patching
|
your program's binary.
|
your program's binary.
|
|
|
If you'd like to be able to patch the binary, you can specify that
|
If you'd like to be able to patch the binary, you can specify that
|
explicitly with the `set write' command. For example, you might want
|
explicitly with the `set write' command. For example, you might want
|
to turn on internal debugging flags, or even to make emergency repairs.
|
to turn on internal debugging flags, or even to make emergency repairs.
|
|
|
`set write on'
|
`set write on'
|
`set write off'
|
`set write off'
|
If you specify `set write on', GDB opens executable and core files
|
If you specify `set write on', GDB opens executable and core files
|
for both reading and writing; if you specify `set write off' (the
|
for both reading and writing; if you specify `set write off' (the
|
default), GDB opens them read-only.
|
default), GDB opens them read-only.
|
|
|
If you have already loaded a file, you must load it again (using
|
If you have already loaded a file, you must load it again (using
|
the `exec-file' or `core-file' command) after changing `set
|
the `exec-file' or `core-file' command) after changing `set
|
write', for your new setting to take effect.
|
write', for your new setting to take effect.
|
|
|
`show write'
|
`show write'
|
Display whether executable files and core files are opened for
|
Display whether executable files and core files are opened for
|
writing as well as reading.
|
writing as well as reading.
|
|
|
|
|
File: gdb.info, Node: GDB Files, Next: Targets, Prev: Altering, Up: Top
|
File: gdb.info, Node: GDB Files, Next: Targets, Prev: Altering, Up: Top
|
|
|
18 GDB Files
|
18 GDB Files
|
************
|
************
|
|
|
GDB needs to know the file name of the program to be debugged, both in
|
GDB needs to know the file name of the program to be debugged, both in
|
order to read its symbol table and in order to start your program. To
|
order to read its symbol table and in order to start your program. To
|
debug a core dump of a previous run, you must also tell GDB the name of
|
debug a core dump of a previous run, you must also tell GDB the name of
|
the core dump file.
|
the core dump file.
|
|
|
* Menu:
|
* Menu:
|
|
|
* Files:: Commands to specify files
|
* Files:: Commands to specify files
|
* Separate Debug Files:: Debugging information in separate files
|
* Separate Debug Files:: Debugging information in separate files
|
* Symbol Errors:: Errors reading symbol files
|
* Symbol Errors:: Errors reading symbol files
|
* Data Files:: GDB data files
|
* Data Files:: GDB data files
|
|
|
|
|
File: gdb.info, Node: Files, Next: Separate Debug Files, Up: GDB Files
|
File: gdb.info, Node: Files, Next: Separate Debug Files, Up: GDB Files
|
|
|
18.1 Commands to Specify Files
|
18.1 Commands to Specify Files
|
==============================
|
==============================
|
|
|
You may want to specify executable and core dump file names. The usual
|
You may want to specify executable and core dump file names. The usual
|
way to do this is at start-up time, using the arguments to GDB's
|
way to do this is at start-up time, using the arguments to GDB's
|
start-up commands (*note Getting In and Out of GDB: Invocation.).
|
start-up commands (*note Getting In and Out of GDB: Invocation.).
|
|
|
Occasionally it is necessary to change to a different file during a
|
Occasionally it is necessary to change to a different file during a
|
GDB session. Or you may run GDB and forget to specify a file you want
|
GDB session. Or you may run GDB and forget to specify a file you want
|
to use. Or you are debugging a remote target via `gdbserver' (*note
|
to use. Or you are debugging a remote target via `gdbserver' (*note
|
file: Server.). In these situations the GDB commands to specify new
|
file: Server.). In these situations the GDB commands to specify new
|
files are useful.
|
files are useful.
|
|
|
`file FILENAME'
|
`file FILENAME'
|
Use FILENAME as the program to be debugged. It is read for its
|
Use FILENAME as the program to be debugged. It is read for its
|
symbols and for the contents of pure memory. It is also the
|
symbols and for the contents of pure memory. It is also the
|
program executed when you use the `run' command. If you do not
|
program executed when you use the `run' command. If you do not
|
specify a directory and the file is not found in the GDB working
|
specify a directory and the file is not found in the GDB working
|
directory, GDB uses the environment variable `PATH' as a list of
|
directory, GDB uses the environment variable `PATH' as a list of
|
directories to search, just as the shell does when looking for a
|
directories to search, just as the shell does when looking for a
|
program to run. You can change the value of this variable, for
|
program to run. You can change the value of this variable, for
|
both GDB and your program, using the `path' command.
|
both GDB and your program, using the `path' command.
|
|
|
You can load unlinked object `.o' files into GDB using the `file'
|
You can load unlinked object `.o' files into GDB using the `file'
|
command. You will not be able to "run" an object file, but you
|
command. You will not be able to "run" an object file, but you
|
can disassemble functions and inspect variables. Also, if the
|
can disassemble functions and inspect variables. Also, if the
|
underlying BFD functionality supports it, you could use `gdb
|
underlying BFD functionality supports it, you could use `gdb
|
-write' to patch object files using this technique. Note that GDB
|
-write' to patch object files using this technique. Note that GDB
|
can neither interpret nor modify relocations in this case, so
|
can neither interpret nor modify relocations in this case, so
|
branches and some initialized variables will appear to go to the
|
branches and some initialized variables will appear to go to the
|
wrong place. But this feature is still handy from time to time.
|
wrong place. But this feature is still handy from time to time.
|
|
|
`file'
|
`file'
|
`file' with no argument makes GDB discard any information it has
|
`file' with no argument makes GDB discard any information it has
|
on both executable file and the symbol table.
|
on both executable file and the symbol table.
|
|
|
`exec-file [ FILENAME ]'
|
`exec-file [ FILENAME ]'
|
Specify that the program to be run (but not the symbol table) is
|
Specify that the program to be run (but not the symbol table) is
|
found in FILENAME. GDB searches the environment variable `PATH'
|
found in FILENAME. GDB searches the environment variable `PATH'
|
if necessary to locate your program. Omitting FILENAME means to
|
if necessary to locate your program. Omitting FILENAME means to
|
discard information on the executable file.
|
discard information on the executable file.
|
|
|
`symbol-file [ FILENAME ]'
|
`symbol-file [ FILENAME ]'
|
Read symbol table information from file FILENAME. `PATH' is
|
Read symbol table information from file FILENAME. `PATH' is
|
searched when necessary. Use the `file' command to get both symbol
|
searched when necessary. Use the `file' command to get both symbol
|
table and program to run from the same file.
|
table and program to run from the same file.
|
|
|
`symbol-file' with no argument clears out GDB information on your
|
`symbol-file' with no argument clears out GDB information on your
|
program's symbol table.
|
program's symbol table.
|
|
|
The `symbol-file' command causes GDB to forget the contents of
|
The `symbol-file' command causes GDB to forget the contents of
|
some breakpoints and auto-display expressions. This is because
|
some breakpoints and auto-display expressions. This is because
|
they may contain pointers to the internal data recording symbols
|
they may contain pointers to the internal data recording symbols
|
and data types, which are part of the old symbol table data being
|
and data types, which are part of the old symbol table data being
|
discarded inside GDB.
|
discarded inside GDB.
|
|
|
`symbol-file' does not repeat if you press again after
|
`symbol-file' does not repeat if you press again after
|
executing it once.
|
executing it once.
|
|
|
When GDB is configured for a particular environment, it
|
When GDB is configured for a particular environment, it
|
understands debugging information in whatever format is the
|
understands debugging information in whatever format is the
|
standard generated for that environment; you may use either a GNU
|
standard generated for that environment; you may use either a GNU
|
compiler, or other compilers that adhere to the local conventions.
|
compiler, or other compilers that adhere to the local conventions.
|
Best results are usually obtained from GNU compilers; for example,
|
Best results are usually obtained from GNU compilers; for example,
|
using `GCC' you can generate debugging information for optimized
|
using `GCC' you can generate debugging information for optimized
|
code.
|
code.
|
|
|
For most kinds of object files, with the exception of old SVR3
|
For most kinds of object files, with the exception of old SVR3
|
systems using COFF, the `symbol-file' command does not normally
|
systems using COFF, the `symbol-file' command does not normally
|
read the symbol table in full right away. Instead, it scans the
|
read the symbol table in full right away. Instead, it scans the
|
symbol table quickly to find which source files and which symbols
|
symbol table quickly to find which source files and which symbols
|
are present. The details are read later, one source file at a
|
are present. The details are read later, one source file at a
|
time, as they are needed.
|
time, as they are needed.
|
|
|
The purpose of this two-stage reading strategy is to make GDB
|
The purpose of this two-stage reading strategy is to make GDB
|
start up faster. For the most part, it is invisible except for
|
start up faster. For the most part, it is invisible except for
|
occasional pauses while the symbol table details for a particular
|
occasional pauses while the symbol table details for a particular
|
source file are being read. (The `set verbose' command can turn
|
source file are being read. (The `set verbose' command can turn
|
these pauses into messages if desired. *Note Optional Warnings
|
these pauses into messages if desired. *Note Optional Warnings
|
and Messages: Messages/Warnings.)
|
and Messages: Messages/Warnings.)
|
|
|
We have not implemented the two-stage strategy for COFF yet. When
|
We have not implemented the two-stage strategy for COFF yet. When
|
the symbol table is stored in COFF format, `symbol-file' reads the
|
the symbol table is stored in COFF format, `symbol-file' reads the
|
symbol table data in full right away. Note that "stabs-in-COFF"
|
symbol table data in full right away. Note that "stabs-in-COFF"
|
still does the two-stage strategy, since the debug info is actually
|
still does the two-stage strategy, since the debug info is actually
|
in stabs format.
|
in stabs format.
|
|
|
`symbol-file [ -readnow ] FILENAME'
|
`symbol-file [ -readnow ] FILENAME'
|
`file [ -readnow ] FILENAME'
|
`file [ -readnow ] FILENAME'
|
You can override the GDB two-stage strategy for reading symbol
|
You can override the GDB two-stage strategy for reading symbol
|
tables by using the `-readnow' option with any of the commands that
|
tables by using the `-readnow' option with any of the commands that
|
load symbol table information, if you want to be sure GDB has the
|
load symbol table information, if you want to be sure GDB has the
|
entire symbol table available.
|
entire symbol table available.
|
|
|
`core-file [FILENAME]'
|
`core-file [FILENAME]'
|
`core'
|
`core'
|
Specify the whereabouts of a core dump file to be used as the
|
Specify the whereabouts of a core dump file to be used as the
|
"contents of memory". Traditionally, core files contain only some
|
"contents of memory". Traditionally, core files contain only some
|
parts of the address space of the process that generated them; GDB
|
parts of the address space of the process that generated them; GDB
|
can access the executable file itself for other parts.
|
can access the executable file itself for other parts.
|
|
|
`core-file' with no argument specifies that no core file is to be
|
`core-file' with no argument specifies that no core file is to be
|
used.
|
used.
|
|
|
Note that the core file is ignored when your program is actually
|
Note that the core file is ignored when your program is actually
|
running under GDB. So, if you have been running your program and
|
running under GDB. So, if you have been running your program and
|
you wish to debug a core file instead, you must kill the
|
you wish to debug a core file instead, you must kill the
|
subprocess in which the program is running. To do this, use the
|
subprocess in which the program is running. To do this, use the
|
`kill' command (*note Killing the Child Process: Kill Process.).
|
`kill' command (*note Killing the Child Process: Kill Process.).
|
|
|
`add-symbol-file FILENAME ADDRESS'
|
`add-symbol-file FILENAME ADDRESS'
|
`add-symbol-file FILENAME ADDRESS [ -readnow ]'
|
`add-symbol-file FILENAME ADDRESS [ -readnow ]'
|
`add-symbol-file FILENAME -sSECTION ADDRESS ...'
|
`add-symbol-file FILENAME -sSECTION ADDRESS ...'
|
The `add-symbol-file' command reads additional symbol table
|
The `add-symbol-file' command reads additional symbol table
|
information from the file FILENAME. You would use this command
|
information from the file FILENAME. You would use this command
|
when FILENAME has been dynamically loaded (by some other means)
|
when FILENAME has been dynamically loaded (by some other means)
|
into the program that is running. ADDRESS should be the memory
|
into the program that is running. ADDRESS should be the memory
|
address at which the file has been loaded; GDB cannot figure this
|
address at which the file has been loaded; GDB cannot figure this
|
out for itself. You can additionally specify an arbitrary number
|
out for itself. You can additionally specify an arbitrary number
|
of `-sSECTION ADDRESS' pairs, to give an explicit section name and
|
of `-sSECTION ADDRESS' pairs, to give an explicit section name and
|
base address for that section. You can specify any ADDRESS as an
|
base address for that section. You can specify any ADDRESS as an
|
expression.
|
expression.
|
|
|
The symbol table of the file FILENAME is added to the symbol table
|
The symbol table of the file FILENAME is added to the symbol table
|
originally read with the `symbol-file' command. You can use the
|
originally read with the `symbol-file' command. You can use the
|
`add-symbol-file' command any number of times; the new symbol data
|
`add-symbol-file' command any number of times; the new symbol data
|
thus read keeps adding to the old. To discard all old symbol data
|
thus read keeps adding to the old. To discard all old symbol data
|
instead, use the `symbol-file' command without any arguments.
|
instead, use the `symbol-file' command without any arguments.
|
|
|
Although FILENAME is typically a shared library file, an
|
Although FILENAME is typically a shared library file, an
|
executable file, or some other object file which has been fully
|
executable file, or some other object file which has been fully
|
relocated for loading into a process, you can also load symbolic
|
relocated for loading into a process, you can also load symbolic
|
information from relocatable `.o' files, as long as:
|
information from relocatable `.o' files, as long as:
|
|
|
* the file's symbolic information refers only to linker symbols
|
* the file's symbolic information refers only to linker symbols
|
defined in that file, not to symbols defined by other object
|
defined in that file, not to symbols defined by other object
|
files,
|
files,
|
|
|
* every section the file's symbolic information refers to has
|
* every section the file's symbolic information refers to has
|
actually been loaded into the inferior, as it appears in the
|
actually been loaded into the inferior, as it appears in the
|
file, and
|
file, and
|
|
|
* you can determine the address at which every section was
|
* you can determine the address at which every section was
|
loaded, and provide these to the `add-symbol-file' command.
|
loaded, and provide these to the `add-symbol-file' command.
|
|
|
Some embedded operating systems, like Sun Chorus and VxWorks, can
|
Some embedded operating systems, like Sun Chorus and VxWorks, can
|
load relocatable files into an already running program; such
|
load relocatable files into an already running program; such
|
systems typically make the requirements above easy to meet.
|
systems typically make the requirements above easy to meet.
|
However, it's important to recognize that many native systems use
|
However, it's important to recognize that many native systems use
|
complex link procedures (`.linkonce' section factoring and C++
|
complex link procedures (`.linkonce' section factoring and C++
|
constructor table assembly, for example) that make the
|
constructor table assembly, for example) that make the
|
requirements difficult to meet. In general, one cannot assume
|
requirements difficult to meet. In general, one cannot assume
|
that using `add-symbol-file' to read a relocatable object file's
|
that using `add-symbol-file' to read a relocatable object file's
|
symbolic information will have the same effect as linking the
|
symbolic information will have the same effect as linking the
|
relocatable object file into the program in the normal way.
|
relocatable object file into the program in the normal way.
|
|
|
`add-symbol-file' does not repeat if you press after using
|
`add-symbol-file' does not repeat if you press after using
|
it.
|
it.
|
|
|
`add-symbol-file-from-memory ADDRESS'
|
`add-symbol-file-from-memory ADDRESS'
|
Load symbols from the given ADDRESS in a dynamically loaded object
|
Load symbols from the given ADDRESS in a dynamically loaded object
|
file whose image is mapped directly into the inferior's memory.
|
file whose image is mapped directly into the inferior's memory.
|
For example, the Linux kernel maps a `syscall DSO' into each
|
For example, the Linux kernel maps a `syscall DSO' into each
|
process's address space; this DSO provides kernel-specific code for
|
process's address space; this DSO provides kernel-specific code for
|
some system calls. The argument can be any expression whose
|
some system calls. The argument can be any expression whose
|
evaluation yields the address of the file's shared object file
|
evaluation yields the address of the file's shared object file
|
header. For this command to work, you must have used
|
header. For this command to work, you must have used
|
`symbol-file' or `exec-file' commands in advance.
|
`symbol-file' or `exec-file' commands in advance.
|
|
|
`add-shared-symbol-files LIBRARY-FILE'
|
`add-shared-symbol-files LIBRARY-FILE'
|
`assf LIBRARY-FILE'
|
`assf LIBRARY-FILE'
|
The `add-shared-symbol-files' command can currently be used only
|
The `add-shared-symbol-files' command can currently be used only
|
in the Cygwin build of GDB on MS-Windows OS, where it is an alias
|
in the Cygwin build of GDB on MS-Windows OS, where it is an alias
|
for the `dll-symbols' command (*note Cygwin Native::). GDB
|
for the `dll-symbols' command (*note Cygwin Native::). GDB
|
automatically looks for shared libraries, however if GDB does not
|
automatically looks for shared libraries, however if GDB does not
|
find yours, you can invoke `add-shared-symbol-files'. It takes
|
find yours, you can invoke `add-shared-symbol-files'. It takes
|
one argument: the shared library's file name. `assf' is a
|
one argument: the shared library's file name. `assf' is a
|
shorthand alias for `add-shared-symbol-files'.
|
shorthand alias for `add-shared-symbol-files'.
|
|
|
`section SECTION ADDR'
|
`section SECTION ADDR'
|
The `section' command changes the base address of the named
|
The `section' command changes the base address of the named
|
SECTION of the exec file to ADDR. This can be used if the exec
|
SECTION of the exec file to ADDR. This can be used if the exec
|
file does not contain section addresses, (such as in the `a.out'
|
file does not contain section addresses, (such as in the `a.out'
|
format), or when the addresses specified in the file itself are
|
format), or when the addresses specified in the file itself are
|
wrong. Each section must be changed separately. The `info files'
|
wrong. Each section must be changed separately. The `info files'
|
command, described below, lists all the sections and their
|
command, described below, lists all the sections and their
|
addresses.
|
addresses.
|
|
|
`info files'
|
`info files'
|
`info target'
|
`info target'
|
`info files' and `info target' are synonymous; both print the
|
`info files' and `info target' are synonymous; both print the
|
current target (*note Specifying a Debugging Target: Targets.),
|
current target (*note Specifying a Debugging Target: Targets.),
|
including the names of the executable and core dump files
|
including the names of the executable and core dump files
|
currently in use by GDB, and the files from which symbols were
|
currently in use by GDB, and the files from which symbols were
|
loaded. The command `help target' lists all possible targets
|
loaded. The command `help target' lists all possible targets
|
rather than current ones.
|
rather than current ones.
|
|
|
`maint info sections'
|
`maint info sections'
|
Another command that can give you extra information about program
|
Another command that can give you extra information about program
|
sections is `maint info sections'. In addition to the section
|
sections is `maint info sections'. In addition to the section
|
information displayed by `info files', this command displays the
|
information displayed by `info files', this command displays the
|
flags and file offset of each section in the executable and core
|
flags and file offset of each section in the executable and core
|
dump files. In addition, `maint info sections' provides the
|
dump files. In addition, `maint info sections' provides the
|
following command options (which may be arbitrarily combined):
|
following command options (which may be arbitrarily combined):
|
|
|
`ALLOBJ'
|
`ALLOBJ'
|
Display sections for all loaded object files, including
|
Display sections for all loaded object files, including
|
shared libraries.
|
shared libraries.
|
|
|
`SECTIONS'
|
`SECTIONS'
|
Display info only for named SECTIONS.
|
Display info only for named SECTIONS.
|
|
|
`SECTION-FLAGS'
|
`SECTION-FLAGS'
|
Display info only for sections for which SECTION-FLAGS are
|
Display info only for sections for which SECTION-FLAGS are
|
true. The section flags that GDB currently knows about are:
|
true. The section flags that GDB currently knows about are:
|
`ALLOC'
|
`ALLOC'
|
Section will have space allocated in the process when
|
Section will have space allocated in the process when
|
loaded. Set for all sections except those containing
|
loaded. Set for all sections except those containing
|
debug information.
|
debug information.
|
|
|
`LOAD'
|
`LOAD'
|
Section will be loaded from the file into the child
|
Section will be loaded from the file into the child
|
process memory. Set for pre-initialized code and data,
|
process memory. Set for pre-initialized code and data,
|
clear for `.bss' sections.
|
clear for `.bss' sections.
|
|
|
`RELOC'
|
`RELOC'
|
Section needs to be relocated before loading.
|
Section needs to be relocated before loading.
|
|
|
`READONLY'
|
`READONLY'
|
Section cannot be modified by the child process.
|
Section cannot be modified by the child process.
|
|
|
`CODE'
|
`CODE'
|
Section contains executable code only.
|
Section contains executable code only.
|
|
|
`DATA'
|
`DATA'
|
Section contains data only (no executable code).
|
Section contains data only (no executable code).
|
|
|
`ROM'
|
`ROM'
|
Section will reside in ROM.
|
Section will reside in ROM.
|
|
|
`CONSTRUCTOR'
|
`CONSTRUCTOR'
|
Section contains data for constructor/destructor lists.
|
Section contains data for constructor/destructor lists.
|
|
|
`HAS_CONTENTS'
|
`HAS_CONTENTS'
|
Section is not empty.
|
Section is not empty.
|
|
|
`NEVER_LOAD'
|
`NEVER_LOAD'
|
An instruction to the linker to not output the section.
|
An instruction to the linker to not output the section.
|
|
|
`COFF_SHARED_LIBRARY'
|
`COFF_SHARED_LIBRARY'
|
A notification to the linker that the section contains
|
A notification to the linker that the section contains
|
COFF shared library information.
|
COFF shared library information.
|
|
|
`IS_COMMON'
|
`IS_COMMON'
|
Section contains common symbols.
|
Section contains common symbols.
|
|
|
`set trust-readonly-sections on'
|
`set trust-readonly-sections on'
|
Tell GDB that readonly sections in your object file really are
|
Tell GDB that readonly sections in your object file really are
|
read-only (i.e. that their contents will not change). In that
|
read-only (i.e. that their contents will not change). In that
|
case, GDB can fetch values from these sections out of the object
|
case, GDB can fetch values from these sections out of the object
|
file, rather than from the target program. For some targets
|
file, rather than from the target program. For some targets
|
(notably embedded ones), this can be a significant enhancement to
|
(notably embedded ones), this can be a significant enhancement to
|
debugging performance.
|
debugging performance.
|
|
|
The default is off.
|
The default is off.
|
|
|
`set trust-readonly-sections off'
|
`set trust-readonly-sections off'
|
Tell GDB not to trust readonly sections. This means that the
|
Tell GDB not to trust readonly sections. This means that the
|
contents of the section might change while the program is running,
|
contents of the section might change while the program is running,
|
and must therefore be fetched from the target when needed.
|
and must therefore be fetched from the target when needed.
|
|
|
`show trust-readonly-sections'
|
`show trust-readonly-sections'
|
Show the current setting of trusting readonly sections.
|
Show the current setting of trusting readonly sections.
|
|
|
All file-specifying commands allow both absolute and relative file
|
All file-specifying commands allow both absolute and relative file
|
names as arguments. GDB always converts the file name to an absolute
|
names as arguments. GDB always converts the file name to an absolute
|
file name and remembers it that way.
|
file name and remembers it that way.
|
|
|
GDB supports GNU/Linux, MS-Windows, HP-UX, SunOS, SVr4, Irix, and
|
GDB supports GNU/Linux, MS-Windows, HP-UX, SunOS, SVr4, Irix, and
|
IBM RS/6000 AIX shared libraries.
|
IBM RS/6000 AIX shared libraries.
|
|
|
On MS-Windows GDB must be linked with the Expat library to support
|
On MS-Windows GDB must be linked with the Expat library to support
|
shared libraries. *Note Expat::.
|
shared libraries. *Note Expat::.
|
|
|
GDB automatically loads symbol definitions from shared libraries
|
GDB automatically loads symbol definitions from shared libraries
|
when you use the `run' command, or when you examine a core file.
|
when you use the `run' command, or when you examine a core file.
|
(Before you issue the `run' command, GDB does not understand references
|
(Before you issue the `run' command, GDB does not understand references
|
to a function in a shared library, however--unless you are debugging a
|
to a function in a shared library, however--unless you are debugging a
|
core file).
|
core file).
|
|
|
On HP-UX, if the program loads a library explicitly, GDB
|
On HP-UX, if the program loads a library explicitly, GDB
|
automatically loads the symbols at the time of the `shl_load' call.
|
automatically loads the symbols at the time of the `shl_load' call.
|
|
|
There are times, however, when you may wish to not automatically load
|
There are times, however, when you may wish to not automatically load
|
symbol definitions from shared libraries, such as when they are
|
symbol definitions from shared libraries, such as when they are
|
particularly large or there are many of them.
|
particularly large or there are many of them.
|
|
|
To control the automatic loading of shared library symbols, use the
|
To control the automatic loading of shared library symbols, use the
|
commands:
|
commands:
|
|
|
`set auto-solib-add MODE'
|
`set auto-solib-add MODE'
|
If MODE is `on', symbols from all shared object libraries will be
|
If MODE is `on', symbols from all shared object libraries will be
|
loaded automatically when the inferior begins execution, you
|
loaded automatically when the inferior begins execution, you
|
attach to an independently started inferior, or when the dynamic
|
attach to an independently started inferior, or when the dynamic
|
linker informs GDB that a new library has been loaded. If MODE is
|
linker informs GDB that a new library has been loaded. If MODE is
|
`off', symbols must be loaded manually, using the `sharedlibrary'
|
`off', symbols must be loaded manually, using the `sharedlibrary'
|
command. The default value is `on'.
|
command. The default value is `on'.
|
|
|
If your program uses lots of shared libraries with debug info that
|
If your program uses lots of shared libraries with debug info that
|
takes large amounts of memory, you can decrease the GDB memory
|
takes large amounts of memory, you can decrease the GDB memory
|
footprint by preventing it from automatically loading the symbols
|
footprint by preventing it from automatically loading the symbols
|
from shared libraries. To that end, type `set auto-solib-add off'
|
from shared libraries. To that end, type `set auto-solib-add off'
|
before running the inferior, then load each library whose debug
|
before running the inferior, then load each library whose debug
|
symbols you do need with `sharedlibrary REGEXP', where REGEXP is a
|
symbols you do need with `sharedlibrary REGEXP', where REGEXP is a
|
regular expression that matches the libraries whose symbols you
|
regular expression that matches the libraries whose symbols you
|
want to be loaded.
|
want to be loaded.
|
|
|
`show auto-solib-add'
|
`show auto-solib-add'
|
Display the current autoloading mode.
|
Display the current autoloading mode.
|
|
|
To explicitly load shared library symbols, use the `sharedlibrary'
|
To explicitly load shared library symbols, use the `sharedlibrary'
|
command:
|
command:
|
|
|
`info share REGEX'
|
`info share REGEX'
|
`info sharedlibrary REGEX'
|
`info sharedlibrary REGEX'
|
Print the names of the shared libraries which are currently loaded
|
Print the names of the shared libraries which are currently loaded
|
that match REGEX. If REGEX is omitted then print all shared
|
that match REGEX. If REGEX is omitted then print all shared
|
libraries that are loaded.
|
libraries that are loaded.
|
|
|
`sharedlibrary REGEX'
|
`sharedlibrary REGEX'
|
`share REGEX'
|
`share REGEX'
|
Load shared object library symbols for files matching a Unix
|
Load shared object library symbols for files matching a Unix
|
regular expression. As with files loaded automatically, it only
|
regular expression. As with files loaded automatically, it only
|
loads shared libraries required by your program for a core file or
|
loads shared libraries required by your program for a core file or
|
after typing `run'. If REGEX is omitted all shared libraries
|
after typing `run'. If REGEX is omitted all shared libraries
|
required by your program are loaded.
|
required by your program are loaded.
|
|
|
`nosharedlibrary'
|
`nosharedlibrary'
|
Unload all shared object library symbols. This discards all
|
Unload all shared object library symbols. This discards all
|
symbols that have been loaded from all shared libraries. Symbols
|
symbols that have been loaded from all shared libraries. Symbols
|
from shared libraries that were loaded by explicit user requests
|
from shared libraries that were loaded by explicit user requests
|
are not discarded.
|
are not discarded.
|
|
|
Sometimes you may wish that GDB stops and gives you control when any
|
Sometimes you may wish that GDB stops and gives you control when any
|
of shared library events happen. Use the `set stop-on-solib-events'
|
of shared library events happen. Use the `set stop-on-solib-events'
|
command for this:
|
command for this:
|
|
|
`set stop-on-solib-events'
|
`set stop-on-solib-events'
|
This command controls whether GDB should give you control when the
|
This command controls whether GDB should give you control when the
|
dynamic linker notifies it about some shared library event. The
|
dynamic linker notifies it about some shared library event. The
|
most common event of interest is loading or unloading of a new
|
most common event of interest is loading or unloading of a new
|
shared library.
|
shared library.
|
|
|
`show stop-on-solib-events'
|
`show stop-on-solib-events'
|
Show whether GDB stops and gives you control when shared library
|
Show whether GDB stops and gives you control when shared library
|
events happen.
|
events happen.
|
|
|
Shared libraries are also supported in many cross or remote debugging
|
Shared libraries are also supported in many cross or remote debugging
|
configurations. GDB needs to have access to the target's libraries;
|
configurations. GDB needs to have access to the target's libraries;
|
this can be accomplished either by providing copies of the libraries on
|
this can be accomplished either by providing copies of the libraries on
|
the host system, or by asking GDB to automatically retrieve the
|
the host system, or by asking GDB to automatically retrieve the
|
libraries from the target. If copies of the target libraries are
|
libraries from the target. If copies of the target libraries are
|
provided, they need to be the same as the target libraries, although the
|
provided, they need to be the same as the target libraries, although the
|
copies on the target can be stripped as long as the copies on the host
|
copies on the target can be stripped as long as the copies on the host
|
are not.
|
are not.
|
|
|
For remote debugging, you need to tell GDB where the target
|
For remote debugging, you need to tell GDB where the target
|
libraries are, so that it can load the correct copies--otherwise, it
|
libraries are, so that it can load the correct copies--otherwise, it
|
may try to load the host's libraries. GDB has two variables to specify
|
may try to load the host's libraries. GDB has two variables to specify
|
the search directories for target libraries.
|
the search directories for target libraries.
|
|
|
`set sysroot PATH'
|
`set sysroot PATH'
|
Use PATH as the system root for the program being debugged. Any
|
Use PATH as the system root for the program being debugged. Any
|
absolute shared library paths will be prefixed with PATH; many
|
absolute shared library paths will be prefixed with PATH; many
|
runtime loaders store the absolute paths to the shared library in
|
runtime loaders store the absolute paths to the shared library in
|
the target program's memory. If you use `set sysroot' to find
|
the target program's memory. If you use `set sysroot' to find
|
shared libraries, they need to be laid out in the same way that
|
shared libraries, they need to be laid out in the same way that
|
they are on the target, with e.g. a `/lib' and `/usr/lib' hierarchy
|
they are on the target, with e.g. a `/lib' and `/usr/lib' hierarchy
|
under PATH.
|
under PATH.
|
|
|
If PATH starts with the sequence `remote:', GDB will retrieve the
|
If PATH starts with the sequence `remote:', GDB will retrieve the
|
target libraries from the remote system. This is only supported
|
target libraries from the remote system. This is only supported
|
when using a remote target that supports the `remote get' command
|
when using a remote target that supports the `remote get' command
|
(*note Sending files to a remote system: File Transfer.). The
|
(*note Sending files to a remote system: File Transfer.). The
|
part of PATH following the initial `remote:' (if present) is used
|
part of PATH following the initial `remote:' (if present) is used
|
as system root prefix on the remote file system. (1)
|
as system root prefix on the remote file system. (1)
|
|
|
For targets with an MS-DOS based filesystem, such as MS-Windows and
|
For targets with an MS-DOS based filesystem, such as MS-Windows and
|
SymbianOS, GDB tries prefixing a few variants of the target
|
SymbianOS, GDB tries prefixing a few variants of the target
|
absolute file name with PATH. But first, on Unix hosts, GDB
|
absolute file name with PATH. But first, on Unix hosts, GDB
|
converts all backslash directory separators into forward slashes,
|
converts all backslash directory separators into forward slashes,
|
because the backslash is not a directory separator on Unix:
|
because the backslash is not a directory separator on Unix:
|
|
|
c:\foo\bar.dll => c:/foo/bar.dll
|
c:\foo\bar.dll => c:/foo/bar.dll
|
|
|
Then, GDB attempts prefixing the target file name with PATH, and
|
Then, GDB attempts prefixing the target file name with PATH, and
|
looks for the resulting file name in the host file system:
|
looks for the resulting file name in the host file system:
|
|
|
c:/foo/bar.dll => /path/to/sysroot/c:/foo/bar.dll
|
c:/foo/bar.dll => /path/to/sysroot/c:/foo/bar.dll
|
|
|
If that does not find the shared library, GDB tries removing the
|
If that does not find the shared library, GDB tries removing the
|
`:' character from the drive spec, both for convenience, and, for
|
`:' character from the drive spec, both for convenience, and, for
|
the case of the host file system not supporting file names with
|
the case of the host file system not supporting file names with
|
colons:
|
colons:
|
|
|
c:/foo/bar.dll => /path/to/sysroot/c/foo/bar.dll
|
c:/foo/bar.dll => /path/to/sysroot/c/foo/bar.dll
|
|
|
This makes it possible to have a system root that mirrors a target
|
This makes it possible to have a system root that mirrors a target
|
with more than one drive. E.g., you may want to setup your local
|
with more than one drive. E.g., you may want to setup your local
|
copies of the target system shared libraries like so (note `c' vs
|
copies of the target system shared libraries like so (note `c' vs
|
`z'):
|
`z'):
|
|
|
`/path/to/sysroot/c/sys/bin/foo.dll'
|
`/path/to/sysroot/c/sys/bin/foo.dll'
|
`/path/to/sysroot/c/sys/bin/bar.dll'
|
`/path/to/sysroot/c/sys/bin/bar.dll'
|
`/path/to/sysroot/z/sys/bin/bar.dll'
|
`/path/to/sysroot/z/sys/bin/bar.dll'
|
|
|
and point the system root at `/path/to/sysroot', so that GDB can
|
and point the system root at `/path/to/sysroot', so that GDB can
|
find the correct copies of both `c:\sys\bin\foo.dll', and
|
find the correct copies of both `c:\sys\bin\foo.dll', and
|
`z:\sys\bin\bar.dll'.
|
`z:\sys\bin\bar.dll'.
|
|
|
If that still does not find the shared library, GDB tries removing
|
If that still does not find the shared library, GDB tries removing
|
the whole drive spec from the target file name:
|
the whole drive spec from the target file name:
|
|
|
c:/foo/bar.dll => /path/to/sysroot/foo/bar.dll
|
c:/foo/bar.dll => /path/to/sysroot/foo/bar.dll
|
|
|
This last lookup makes it possible to not care about the drive
|
This last lookup makes it possible to not care about the drive
|
name, if you don't want or need to.
|
name, if you don't want or need to.
|
|
|
The `set solib-absolute-prefix' command is an alias for `set
|
The `set solib-absolute-prefix' command is an alias for `set
|
sysroot'.
|
sysroot'.
|
|
|
You can set the default system root by using the configure-time
|
You can set the default system root by using the configure-time
|
`--with-sysroot' option. If the system root is inside GDB's
|
`--with-sysroot' option. If the system root is inside GDB's
|
configured binary prefix (set with `--prefix' or `--exec-prefix'),
|
configured binary prefix (set with `--prefix' or `--exec-prefix'),
|
then the default system root will be updated automatically if the
|
then the default system root will be updated automatically if the
|
installed GDB is moved to a new location.
|
installed GDB is moved to a new location.
|
|
|
`show sysroot'
|
`show sysroot'
|
Display the current shared library prefix.
|
Display the current shared library prefix.
|
|
|
`set solib-search-path PATH'
|
`set solib-search-path PATH'
|
If this variable is set, PATH is a colon-separated list of
|
If this variable is set, PATH is a colon-separated list of
|
directories to search for shared libraries. `solib-search-path'
|
directories to search for shared libraries. `solib-search-path'
|
is used after `sysroot' fails to locate the library, or if the
|
is used after `sysroot' fails to locate the library, or if the
|
path to the library is relative instead of absolute. If you want
|
path to the library is relative instead of absolute. If you want
|
to use `solib-search-path' instead of `sysroot', be sure to set
|
to use `solib-search-path' instead of `sysroot', be sure to set
|
`sysroot' to a nonexistent directory to prevent GDB from finding
|
`sysroot' to a nonexistent directory to prevent GDB from finding
|
your host's libraries. `sysroot' is preferred; setting it to a
|
your host's libraries. `sysroot' is preferred; setting it to a
|
nonexistent directory may interfere with automatic loading of
|
nonexistent directory may interfere with automatic loading of
|
shared library symbols.
|
shared library symbols.
|
|
|
`show solib-search-path'
|
`show solib-search-path'
|
Display the current shared library search path.
|
Display the current shared library search path.
|
|
|
`set target-file-system-kind KIND'
|
`set target-file-system-kind KIND'
|
Set assumed file system kind for target reported file names.
|
Set assumed file system kind for target reported file names.
|
|
|
Shared library file names as reported by the target system may not
|
Shared library file names as reported by the target system may not
|
make sense as is on the system GDB is running on. For example,
|
make sense as is on the system GDB is running on. For example,
|
when remote debugging a target that has MS-DOS based file system
|
when remote debugging a target that has MS-DOS based file system
|
semantics, from a Unix host, the target may be reporting to GDB a
|
semantics, from a Unix host, the target may be reporting to GDB a
|
list of loaded shared libraries with file names such as
|
list of loaded shared libraries with file names such as
|
`c:\Windows\kernel32.dll'. On Unix hosts, there's no concept of
|
`c:\Windows\kernel32.dll'. On Unix hosts, there's no concept of
|
drive letters, so the `c:\' prefix is not normally understood as
|
drive letters, so the `c:\' prefix is not normally understood as
|
indicating an absolute file name, and neither is the backslash
|
indicating an absolute file name, and neither is the backslash
|
normally considered a directory separator character. In that case,
|
normally considered a directory separator character. In that case,
|
the native file system would interpret this whole absolute file
|
the native file system would interpret this whole absolute file
|
name as a relative file name with no directory components. This
|
name as a relative file name with no directory components. This
|
would make it impossible to point GDB at a copy of the remote
|
would make it impossible to point GDB at a copy of the remote
|
target's shared libraries on the host using `set sysroot', and
|
target's shared libraries on the host using `set sysroot', and
|
impractical with `set solib-search-path'. Setting
|
impractical with `set solib-search-path'. Setting
|
`target-file-system-kind' to `dos-based' tells GDB to interpret
|
`target-file-system-kind' to `dos-based' tells GDB to interpret
|
such file names similarly to how the target would, and to map them
|
such file names similarly to how the target would, and to map them
|
to file names valid on GDB's native file system semantics. The
|
to file names valid on GDB's native file system semantics. The
|
value of KIND can be `"auto"', in addition to one of the supported
|
value of KIND can be `"auto"', in addition to one of the supported
|
file system kinds. In that case, GDB tries to determine the
|
file system kinds. In that case, GDB tries to determine the
|
appropriate file system variant based on the current target's
|
appropriate file system variant based on the current target's
|
operating system (*note Configuring the Current ABI: ABI.). The
|
operating system (*note Configuring the Current ABI: ABI.). The
|
supported file system settings are:
|
supported file system settings are:
|
|
|
`unix'
|
`unix'
|
Instruct GDB to assume the target file system is of Unix
|
Instruct GDB to assume the target file system is of Unix
|
kind. Only file names starting the forward slash (`/')
|
kind. Only file names starting the forward slash (`/')
|
character are considered absolute, and the directory
|
character are considered absolute, and the directory
|
separator character is also the forward slash.
|
separator character is also the forward slash.
|
|
|
`dos-based'
|
`dos-based'
|
Instruct GDB to assume the target file system is DOS based.
|
Instruct GDB to assume the target file system is DOS based.
|
File names starting with either a forward slash, or a drive
|
File names starting with either a forward slash, or a drive
|
letter followed by a colon (e.g., `c:'), are considered
|
letter followed by a colon (e.g., `c:'), are considered
|
absolute, and both the slash (`/') and the backslash (`\\')
|
absolute, and both the slash (`/') and the backslash (`\\')
|
characters are considered directory separators.
|
characters are considered directory separators.
|
|
|
`auto'
|
`auto'
|
Instruct GDB to use the file system kind associated with the
|
Instruct GDB to use the file system kind associated with the
|
target operating system (*note Configuring the Current ABI:
|
target operating system (*note Configuring the Current ABI:
|
ABI.). This is the default.
|
ABI.). This is the default.
|
|
|
---------- Footnotes ----------
|
---------- Footnotes ----------
|
|
|
(1) If you want to specify a local system root using a directory
|
(1) If you want to specify a local system root using a directory
|
that happens to be named `remote:', you need to use some equivalent
|
that happens to be named `remote:', you need to use some equivalent
|
variant of the name like `./remote:'.
|
variant of the name like `./remote:'.
|
|
|
|
|
File: gdb.info, Node: Separate Debug Files, Next: Symbol Errors, Prev: Files, Up: GDB Files
|
File: gdb.info, Node: Separate Debug Files, Next: Symbol Errors, Prev: Files, Up: GDB Files
|
|
|
18.2 Debugging Information in Separate Files
|
18.2 Debugging Information in Separate Files
|
============================================
|
============================================
|
|
|
GDB allows you to put a program's debugging information in a file
|
GDB allows you to put a program's debugging information in a file
|
separate from the executable itself, in a way that allows GDB to find
|
separate from the executable itself, in a way that allows GDB to find
|
and load the debugging information automatically. Since debugging
|
and load the debugging information automatically. Since debugging
|
information can be very large--sometimes larger than the executable
|
information can be very large--sometimes larger than the executable
|
code itself--some systems distribute debugging information for their
|
code itself--some systems distribute debugging information for their
|
executables in separate files, which users can install only when they
|
executables in separate files, which users can install only when they
|
need to debug a problem.
|
need to debug a problem.
|
|
|
GDB supports two ways of specifying the separate debug info file:
|
GDB supports two ways of specifying the separate debug info file:
|
|
|
* The executable contains a "debug link" that specifies the name of
|
* The executable contains a "debug link" that specifies the name of
|
the separate debug info file. The separate debug file's name is
|
the separate debug info file. The separate debug file's name is
|
usually `EXECUTABLE.debug', where EXECUTABLE is the name of the
|
usually `EXECUTABLE.debug', where EXECUTABLE is the name of the
|
corresponding executable file without leading directories (e.g.,
|
corresponding executable file without leading directories (e.g.,
|
`ls.debug' for `/usr/bin/ls'). In addition, the debug link
|
`ls.debug' for `/usr/bin/ls'). In addition, the debug link
|
specifies a 32-bit "Cyclic Redundancy Check" (CRC) checksum for
|
specifies a 32-bit "Cyclic Redundancy Check" (CRC) checksum for
|
the debug file, which GDB uses to validate that the executable and
|
the debug file, which GDB uses to validate that the executable and
|
the debug file came from the same build.
|
the debug file came from the same build.
|
|
|
* The executable contains a "build ID", a unique bit string that is
|
* The executable contains a "build ID", a unique bit string that is
|
also present in the corresponding debug info file. (This is
|
also present in the corresponding debug info file. (This is
|
supported only on some operating systems, notably those which use
|
supported only on some operating systems, notably those which use
|
the ELF format for binary files and the GNU Binutils.) For more
|
the ELF format for binary files and the GNU Binutils.) For more
|
details about this feature, see the description of the `--build-id'
|
details about this feature, see the description of the `--build-id'
|
command-line option in *note Command Line Options:
|
command-line option in *note Command Line Options:
|
(ld.info)Options. The debug info file's name is not specified
|
(ld.info)Options. The debug info file's name is not specified
|
explicitly by the build ID, but can be computed from the build ID,
|
explicitly by the build ID, but can be computed from the build ID,
|
see below.
|
see below.
|
|
|
Depending on the way the debug info file is specified, GDB uses two
|
Depending on the way the debug info file is specified, GDB uses two
|
different methods of looking for the debug file:
|
different methods of looking for the debug file:
|
|
|
* For the "debug link" method, GDB looks up the named file in the
|
* For the "debug link" method, GDB looks up the named file in the
|
directory of the executable file, then in a subdirectory of that
|
directory of the executable file, then in a subdirectory of that
|
directory named `.debug', and finally under the global debug
|
directory named `.debug', and finally under the global debug
|
directory, in a subdirectory whose name is identical to the leading
|
directory, in a subdirectory whose name is identical to the leading
|
directories of the executable's absolute file name.
|
directories of the executable's absolute file name.
|
|
|
* For the "build ID" method, GDB looks in the `.build-id'
|
* For the "build ID" method, GDB looks in the `.build-id'
|
subdirectory of the global debug directory for a file named
|
subdirectory of the global debug directory for a file named
|
`NN/NNNNNNNN.debug', where NN are the first 2 hex characters of
|
`NN/NNNNNNNN.debug', where NN are the first 2 hex characters of
|
the build ID bit string, and NNNNNNNN are the rest of the bit
|
the build ID bit string, and NNNNNNNN are the rest of the bit
|
string. (Real build ID strings are 32 or more hex characters, not
|
string. (Real build ID strings are 32 or more hex characters, not
|
10.)
|
10.)
|
|
|
So, for example, suppose you ask GDB to debug `/usr/bin/ls', which
|
So, for example, suppose you ask GDB to debug `/usr/bin/ls', which
|
has a debug link that specifies the file `ls.debug', and a build ID
|
has a debug link that specifies the file `ls.debug', and a build ID
|
whose value in hex is `abcdef1234'. If the global debug directory is
|
whose value in hex is `abcdef1234'. If the global debug directory is
|
`/usr/lib/debug', then GDB will look for the following debug
|
`/usr/lib/debug', then GDB will look for the following debug
|
information files, in the indicated order:
|
information files, in the indicated order:
|
|
|
- `/usr/lib/debug/.build-id/ab/cdef1234.debug'
|
- `/usr/lib/debug/.build-id/ab/cdef1234.debug'
|
|
|
- `/usr/bin/ls.debug'
|
- `/usr/bin/ls.debug'
|
|
|
- `/usr/bin/.debug/ls.debug'
|
- `/usr/bin/.debug/ls.debug'
|
|
|
- `/usr/lib/debug/usr/bin/ls.debug'.
|
- `/usr/lib/debug/usr/bin/ls.debug'.
|
|
|
You can set the global debugging info directory's name, and view the
|
You can set the global debugging info directory's name, and view the
|
name GDB is currently using.
|
name GDB is currently using.
|
|
|
`set debug-file-directory DIRECTORIES'
|
`set debug-file-directory DIRECTORIES'
|
Set the directories which GDB searches for separate debugging
|
Set the directories which GDB searches for separate debugging
|
information files to DIRECTORY. Multiple directory components can
|
information files to DIRECTORY. Multiple directory components can
|
be set concatenating them by a directory separator.
|
be set concatenating them by a directory separator.
|
|
|
`show debug-file-directory'
|
`show debug-file-directory'
|
Show the directories GDB searches for separate debugging
|
Show the directories GDB searches for separate debugging
|
information files.
|
information files.
|
|
|
|
|
A debug link is a special section of the executable file named
|
A debug link is a special section of the executable file named
|
`.gnu_debuglink'. The section must contain:
|
`.gnu_debuglink'. The section must contain:
|
|
|
* A filename, with any leading directory components removed,
|
* A filename, with any leading directory components removed,
|
followed by a zero byte,
|
followed by a zero byte,
|
|
|
* zero to three bytes of padding, as needed to reach the next
|
* zero to three bytes of padding, as needed to reach the next
|
four-byte boundary within the section, and
|
four-byte boundary within the section, and
|
|
|
* a four-byte CRC checksum, stored in the same endianness used for
|
* a four-byte CRC checksum, stored in the same endianness used for
|
the executable file itself. The checksum is computed on the
|
the executable file itself. The checksum is computed on the
|
debugging information file's full contents by the function given
|
debugging information file's full contents by the function given
|
below, passing zero as the CRC argument.
|
below, passing zero as the CRC argument.
|
|
|
Any executable file format can carry a debug link, as long as it can
|
Any executable file format can carry a debug link, as long as it can
|
contain a section named `.gnu_debuglink' with the contents described
|
contain a section named `.gnu_debuglink' with the contents described
|
above.
|
above.
|
|
|
The build ID is a special section in the executable file (and in
|
The build ID is a special section in the executable file (and in
|
other ELF binary files that GDB may consider). This section is often
|
other ELF binary files that GDB may consider). This section is often
|
named `.note.gnu.build-id', but that name is not mandatory. It
|
named `.note.gnu.build-id', but that name is not mandatory. It
|
contains unique identification for the built files--the ID remains the
|
contains unique identification for the built files--the ID remains the
|
same across multiple builds of the same build tree. The default
|
same across multiple builds of the same build tree. The default
|
algorithm SHA1 produces 160 bits (40 hexadecimal characters) of the
|
algorithm SHA1 produces 160 bits (40 hexadecimal characters) of the
|
content for the build ID string. The same section with an identical
|
content for the build ID string. The same section with an identical
|
value is present in the original built binary with symbols, in its
|
value is present in the original built binary with symbols, in its
|
stripped variant, and in the separate debugging information file.
|
stripped variant, and in the separate debugging information file.
|
|
|
The debugging information file itself should be an ordinary
|
The debugging information file itself should be an ordinary
|
executable, containing a full set of linker symbols, sections, and
|
executable, containing a full set of linker symbols, sections, and
|
debugging information. The sections of the debugging information file
|
debugging information. The sections of the debugging information file
|
should have the same names, addresses, and sizes as the original file,
|
should have the same names, addresses, and sizes as the original file,
|
but they need not contain any data--much like a `.bss' section in an
|
but they need not contain any data--much like a `.bss' section in an
|
ordinary executable.
|
ordinary executable.
|
|
|
The GNU binary utilities (Binutils) package includes the `objcopy'
|
The GNU binary utilities (Binutils) package includes the `objcopy'
|
utility that can produce the separated executable / debugging
|
utility that can produce the separated executable / debugging
|
information file pairs using the following commands:
|
information file pairs using the following commands:
|
|
|
objcopy --only-keep-debug foo foo.debug
|
objcopy --only-keep-debug foo foo.debug
|
strip -g foo
|
strip -g foo
|
|
|
These commands remove the debugging information from the executable
|
These commands remove the debugging information from the executable
|
file `foo' and place it in the file `foo.debug'. You can use the
|
file `foo' and place it in the file `foo.debug'. You can use the
|
first, second or both methods to link the two files:
|
first, second or both methods to link the two files:
|
|
|
* The debug link method needs the following additional command to
|
* The debug link method needs the following additional command to
|
also leave behind a debug link in `foo':
|
also leave behind a debug link in `foo':
|
|
|
objcopy --add-gnu-debuglink=foo.debug foo
|
objcopy --add-gnu-debuglink=foo.debug foo
|
|
|
Ulrich Drepper's `elfutils' package, starting with version 0.53,
|
Ulrich Drepper's `elfutils' package, starting with version 0.53,
|
contains a version of the `strip' command such that the command
|
contains a version of the `strip' command such that the command
|
`strip foo -f foo.debug' has the same functionality as the two
|
`strip foo -f foo.debug' has the same functionality as the two
|
`objcopy' commands and the `ln -s' command above, together.
|
`objcopy' commands and the `ln -s' command above, together.
|
|
|
* Build ID gets embedded into the main executable using `ld
|
* Build ID gets embedded into the main executable using `ld
|
--build-id' or the GCC counterpart `gcc -Wl,--build-id'. Build ID
|
--build-id' or the GCC counterpart `gcc -Wl,--build-id'. Build ID
|
support plus compatibility fixes for debug files separation are
|
support plus compatibility fixes for debug files separation are
|
present in GNU binary utilities (Binutils) package since version
|
present in GNU binary utilities (Binutils) package since version
|
2.18.
|
2.18.
|
|
|
The CRC used in `.gnu_debuglink' is the CRC-32 defined in IEEE 802.3
|
The CRC used in `.gnu_debuglink' is the CRC-32 defined in IEEE 802.3
|
using the polynomial:
|
using the polynomial:
|
|
|
x^32 + x^26 + x^23 + x^22 + x^16 + x^12 + x^11
|
x^32 + x^26 + x^23 + x^22 + x^16 + x^12 + x^11
|
+ x^10 + x^8 + x^7 + x^5 + x^4 + x^2 + x + 1
|
+ x^10 + x^8 + x^7 + x^5 + x^4 + x^2 + x + 1
|
|
|
The function is computed byte at a time, taking the least
|
The function is computed byte at a time, taking the least
|
significant bit of each byte first. The initial pattern `0xffffffff'
|
significant bit of each byte first. The initial pattern `0xffffffff'
|
is used, to ensure leading zeros affect the CRC and the final result is
|
is used, to ensure leading zeros affect the CRC and the final result is
|
inverted to ensure trailing zeros also affect the CRC.
|
inverted to ensure trailing zeros also affect the CRC.
|
|
|
_Note:_ This is the same CRC polynomial as used in handling the
|
_Note:_ This is the same CRC polynomial as used in handling the
|
"Remote Serial Protocol" `qCRC' packet (*note GDB Remote Serial
|
"Remote Serial Protocol" `qCRC' packet (*note GDB Remote Serial
|
Protocol: Remote Protocol.). However in the case of the Remote Serial
|
Protocol: Remote Protocol.). However in the case of the Remote Serial
|
Protocol, the CRC is computed _most_ significant bit first, and the
|
Protocol, the CRC is computed _most_ significant bit first, and the
|
result is not inverted, so trailing zeros have no effect on the CRC
|
result is not inverted, so trailing zeros have no effect on the CRC
|
value.
|
value.
|
|
|
To complete the description, we show below the code of the function
|
To complete the description, we show below the code of the function
|
which produces the CRC used in `.gnu_debuglink'. Inverting the
|
which produces the CRC used in `.gnu_debuglink'. Inverting the
|
initially supplied `crc' argument means that an initial call to this
|
initially supplied `crc' argument means that an initial call to this
|
function passing in zero will start computing the CRC using
|
function passing in zero will start computing the CRC using
|
`0xffffffff'.
|
`0xffffffff'.
|
|
|
unsigned long
|
unsigned long
|
gnu_debuglink_crc32 (unsigned long crc,
|
gnu_debuglink_crc32 (unsigned long crc,
|
unsigned char *buf, size_t len)
|
unsigned char *buf, size_t len)
|
{
|
{
|
static const unsigned long crc32_table[256] =
|
static const unsigned long crc32_table[256] =
|
{
|
{
|
0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419,
|
0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419,
|
0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4,
|
0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4,
|
0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07,
|
0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07,
|
0x90bf1d91, 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de,
|
0x90bf1d91, 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de,
|
0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 0x136c9856,
|
0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 0x136c9856,
|
0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9,
|
0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9,
|
0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4,
|
0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4,
|
0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b,
|
0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b,
|
0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3,
|
0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3,
|
0x45df5c75, 0xdcd60dcf, 0xabd13d59, 0x26d930ac, 0x51de003a,
|
0x45df5c75, 0xdcd60dcf, 0xabd13d59, 0x26d930ac, 0x51de003a,
|
0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599,
|
0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599,
|
0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924,
|
0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924,
|
0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190,
|
0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190,
|
0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f,
|
0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f,
|
0x9fbfe4a5, 0xe8b8d433, 0x7807c9a2, 0x0f00f934, 0x9609a88e,
|
0x9fbfe4a5, 0xe8b8d433, 0x7807c9a2, 0x0f00f934, 0x9609a88e,
|
0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01,
|
0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01,
|
0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed,
|
0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed,
|
0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950,
|
0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950,
|
0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3,
|
0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3,
|
0xfbd44c65, 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2,
|
0xfbd44c65, 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2,
|
0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a,
|
0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a,
|
0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5,
|
0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5,
|
0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, 0xbe0b1010,
|
0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, 0xbe0b1010,
|
0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
|
0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
|
0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17,
|
0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17,
|
0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6,
|
0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6,
|
0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615,
|
0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615,
|
0x73dc1683, 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8,
|
0x73dc1683, 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8,
|
0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, 0xf00f9344,
|
0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, 0xf00f9344,
|
0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb,
|
0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb,
|
0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a,
|
0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a,
|
0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5,
|
0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5,
|
0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1,
|
0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1,
|
0xa6bc5767, 0x3fb506dd, 0x48b2364b, 0xd80d2bda, 0xaf0a1b4c,
|
0xa6bc5767, 0x3fb506dd, 0x48b2364b, 0xd80d2bda, 0xaf0a1b4c,
|
0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef,
|
0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef,
|
0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236,
|
0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236,
|
0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe,
|
0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe,
|
0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31,
|
0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31,
|
0x2cd99e8b, 0x5bdeae1d, 0x9b64c2b0, 0xec63f226, 0x756aa39c,
|
0x2cd99e8b, 0x5bdeae1d, 0x9b64c2b0, 0xec63f226, 0x756aa39c,
|
0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713,
|
0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713,
|
0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b,
|
0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b,
|
0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242,
|
0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242,
|
0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1,
|
0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1,
|
0x18b74777, 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c,
|
0x18b74777, 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c,
|
0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, 0xa00ae278,
|
0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, 0xa00ae278,
|
0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7,
|
0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7,
|
0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, 0x40df0b66,
|
0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, 0x40df0b66,
|
0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
|
0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
|
0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605,
|
0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605,
|
0xcdd70693, 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8,
|
0xcdd70693, 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8,
|
0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b,
|
0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b,
|
0x2d02ef8d
|
0x2d02ef8d
|
};
|
};
|
unsigned char *end;
|
unsigned char *end;
|
|
|
crc = ~crc & 0xffffffff;
|
crc = ~crc & 0xffffffff;
|
for (end = buf + len; buf < end; ++buf)
|
for (end = buf + len; buf < end; ++buf)
|
crc = crc32_table[(crc ^ *buf) & 0xff] ^ (crc >> 8);
|
crc = crc32_table[(crc ^ *buf) & 0xff] ^ (crc >> 8);
|
return ~crc & 0xffffffff;
|
return ~crc & 0xffffffff;
|
}
|
}
|
|
|
This computation does not apply to the "build ID" method.
|
This computation does not apply to the "build ID" method.
|
|
|
|
|
File: gdb.info, Node: Symbol Errors, Next: Data Files, Prev: Separate Debug Files, Up: GDB Files
|
File: gdb.info, Node: Symbol Errors, Next: Data Files, Prev: Separate Debug Files, Up: GDB Files
|
|
|
18.3 Errors Reading Symbol Files
|
18.3 Errors Reading Symbol Files
|
================================
|
================================
|
|
|
While reading a symbol file, GDB occasionally encounters problems, such
|
While reading a symbol file, GDB occasionally encounters problems, such
|
as symbol types it does not recognize, or known bugs in compiler
|
as symbol types it does not recognize, or known bugs in compiler
|
output. By default, GDB does not notify you of such problems, since
|
output. By default, GDB does not notify you of such problems, since
|
they are relatively common and primarily of interest to people
|
they are relatively common and primarily of interest to people
|
debugging compilers. If you are interested in seeing information about
|
debugging compilers. If you are interested in seeing information about
|
ill-constructed symbol tables, you can either ask GDB to print only one
|
ill-constructed symbol tables, you can either ask GDB to print only one
|
message about each such type of problem, no matter how many times the
|
message about each such type of problem, no matter how many times the
|
problem occurs; or you can ask GDB to print more messages, to see how
|
problem occurs; or you can ask GDB to print more messages, to see how
|
many times the problems occur, with the `set complaints' command (*note
|
many times the problems occur, with the `set complaints' command (*note
|
Optional Warnings and Messages: Messages/Warnings.).
|
Optional Warnings and Messages: Messages/Warnings.).
|
|
|
The messages currently printed, and their meanings, include:
|
The messages currently printed, and their meanings, include:
|
|
|
`inner block not inside outer block in SYMBOL'
|
`inner block not inside outer block in SYMBOL'
|
The symbol information shows where symbol scopes begin and end
|
The symbol information shows where symbol scopes begin and end
|
(such as at the start of a function or a block of statements).
|
(such as at the start of a function or a block of statements).
|
This error indicates that an inner scope block is not fully
|
This error indicates that an inner scope block is not fully
|
contained in its outer scope blocks.
|
contained in its outer scope blocks.
|
|
|
GDB circumvents the problem by treating the inner block as if it
|
GDB circumvents the problem by treating the inner block as if it
|
had the same scope as the outer block. In the error message,
|
had the same scope as the outer block. In the error message,
|
SYMBOL may be shown as "`(don't know)'" if the outer block is not a
|
SYMBOL may be shown as "`(don't know)'" if the outer block is not a
|
function.
|
function.
|
|
|
`block at ADDRESS out of order'
|
`block at ADDRESS out of order'
|
The symbol information for symbol scope blocks should occur in
|
The symbol information for symbol scope blocks should occur in
|
order of increasing addresses. This error indicates that it does
|
order of increasing addresses. This error indicates that it does
|
not do so.
|
not do so.
|
|
|
GDB does not circumvent this problem, and has trouble locating
|
GDB does not circumvent this problem, and has trouble locating
|
symbols in the source file whose symbols it is reading. (You can
|
symbols in the source file whose symbols it is reading. (You can
|
often determine what source file is affected by specifying `set
|
often determine what source file is affected by specifying `set
|
verbose on'. *Note Optional Warnings and Messages:
|
verbose on'. *Note Optional Warnings and Messages:
|
Messages/Warnings.)
|
Messages/Warnings.)
|
|
|
`bad block start address patched'
|
`bad block start address patched'
|
The symbol information for a symbol scope block has a start address
|
The symbol information for a symbol scope block has a start address
|
smaller than the address of the preceding source line. This is
|
smaller than the address of the preceding source line. This is
|
known to occur in the SunOS 4.1.1 (and earlier) C compiler.
|
known to occur in the SunOS 4.1.1 (and earlier) C compiler.
|
|
|
GDB circumvents the problem by treating the symbol scope block as
|
GDB circumvents the problem by treating the symbol scope block as
|
starting on the previous source line.
|
starting on the previous source line.
|
|
|
`bad string table offset in symbol N'
|
`bad string table offset in symbol N'
|
Symbol number N contains a pointer into the string table which is
|
Symbol number N contains a pointer into the string table which is
|
larger than the size of the string table.
|
larger than the size of the string table.
|
|
|
GDB circumvents the problem by considering the symbol to have the
|
GDB circumvents the problem by considering the symbol to have the
|
name `foo', which may cause other problems if many symbols end up
|
name `foo', which may cause other problems if many symbols end up
|
with this name.
|
with this name.
|
|
|
`unknown symbol type `0xNN''
|
`unknown symbol type `0xNN''
|
The symbol information contains new data types that GDB does not
|
The symbol information contains new data types that GDB does not
|
yet know how to read. `0xNN' is the symbol type of the
|
yet know how to read. `0xNN' is the symbol type of the
|
uncomprehended information, in hexadecimal.
|
uncomprehended information, in hexadecimal.
|
|
|
GDB circumvents the error by ignoring this symbol information.
|
GDB circumvents the error by ignoring this symbol information.
|
This usually allows you to debug your program, though certain
|
This usually allows you to debug your program, though certain
|
symbols are not accessible. If you encounter such a problem and
|
symbols are not accessible. If you encounter such a problem and
|
feel like debugging it, you can debug `gdb' with itself, breakpoint
|
feel like debugging it, you can debug `gdb' with itself, breakpoint
|
on `complain', then go up to the function `read_dbx_symtab' and
|
on `complain', then go up to the function `read_dbx_symtab' and
|
examine `*bufp' to see the symbol.
|
examine `*bufp' to see the symbol.
|
|
|
`stub type has NULL name'
|
`stub type has NULL name'
|
GDB could not find the full definition for a struct or class.
|
GDB could not find the full definition for a struct or class.
|
|
|
`const/volatile indicator missing (ok if using g++ v1.x), got...'
|
`const/volatile indicator missing (ok if using g++ v1.x), got...'
|
The symbol information for a C++ member function is missing some
|
The symbol information for a C++ member function is missing some
|
information that recent versions of the compiler should have
|
information that recent versions of the compiler should have
|
output for it.
|
output for it.
|
|
|
`info mismatch between compiler and debugger'
|
`info mismatch between compiler and debugger'
|
GDB could not parse a type specification output by the compiler.
|
GDB could not parse a type specification output by the compiler.
|
|
|
|
|
|
|
File: gdb.info, Node: Data Files, Prev: Symbol Errors, Up: GDB Files
|
File: gdb.info, Node: Data Files, Prev: Symbol Errors, Up: GDB Files
|
|
|
18.4 GDB Data Files
|
18.4 GDB Data Files
|
===================
|
===================
|
|
|
GDB will sometimes read an auxiliary data file. These files are kept
|
GDB will sometimes read an auxiliary data file. These files are kept
|
in a directory known as the "data directory".
|
in a directory known as the "data directory".
|
|
|
You can set the data directory's name, and view the name GDB is
|
You can set the data directory's name, and view the name GDB is
|
currently using.
|
currently using.
|
|
|
`set data-directory DIRECTORY'
|
`set data-directory DIRECTORY'
|
Set the directory which GDB searches for auxiliary data files to
|
Set the directory which GDB searches for auxiliary data files to
|
DIRECTORY.
|
DIRECTORY.
|
|
|
`show data-directory'
|
`show data-directory'
|
Show the directory GDB searches for auxiliary data files.
|
Show the directory GDB searches for auxiliary data files.
|
|
|
You can set the default data directory by using the configure-time
|
You can set the default data directory by using the configure-time
|
`--with-gdb-datadir' option. If the data directory is inside GDB's
|
`--with-gdb-datadir' option. If the data directory is inside GDB's
|
configured binary prefix (set with `--prefix' or `--exec-prefix'), then
|
configured binary prefix (set with `--prefix' or `--exec-prefix'), then
|
the default data directory will be updated automatically if the
|
the default data directory will be updated automatically if the
|
installed GDB is moved to a new location.
|
installed GDB is moved to a new location.
|
|
|
|
|
File: gdb.info, Node: Targets, Next: Remote Debugging, Prev: GDB Files, Up: Top
|
File: gdb.info, Node: Targets, Next: Remote Debugging, Prev: GDB Files, Up: Top
|
|
|
19 Specifying a Debugging Target
|
19 Specifying a Debugging Target
|
********************************
|
********************************
|
|
|
A "target" is the execution environment occupied by your program.
|
A "target" is the execution environment occupied by your program.
|
|
|
Often, GDB runs in the same host environment as your program; in
|
Often, GDB runs in the same host environment as your program; in
|
that case, the debugging target is specified as a side effect when you
|
that case, the debugging target is specified as a side effect when you
|
use the `file' or `core' commands. When you need more flexibility--for
|
use the `file' or `core' commands. When you need more flexibility--for
|
example, running GDB on a physically separate host, or controlling a
|
example, running GDB on a physically separate host, or controlling a
|
standalone system over a serial port or a realtime system over a TCP/IP
|
standalone system over a serial port or a realtime system over a TCP/IP
|
connection--you can use the `target' command to specify one of the
|
connection--you can use the `target' command to specify one of the
|
target types configured for GDB (*note Commands for Managing Targets:
|
target types configured for GDB (*note Commands for Managing Targets:
|
Target Commands.).
|
Target Commands.).
|
|
|
It is possible to build GDB for several different "target
|
It is possible to build GDB for several different "target
|
architectures". When GDB is built like that, you can choose one of the
|
architectures". When GDB is built like that, you can choose one of the
|
available architectures with the `set architecture' command.
|
available architectures with the `set architecture' command.
|
|
|
`set architecture ARCH'
|
`set architecture ARCH'
|
This command sets the current target architecture to ARCH. The
|
This command sets the current target architecture to ARCH. The
|
value of ARCH can be `"auto"', in addition to one of the supported
|
value of ARCH can be `"auto"', in addition to one of the supported
|
architectures.
|
architectures.
|
|
|
`show architecture'
|
`show architecture'
|
Show the current target architecture.
|
Show the current target architecture.
|
|
|
`set processor'
|
`set processor'
|
`processor'
|
`processor'
|
These are alias commands for, respectively, `set architecture' and
|
These are alias commands for, respectively, `set architecture' and
|
`show architecture'.
|
`show architecture'.
|
|
|
* Menu:
|
* Menu:
|
|
|
* Active Targets:: Active targets
|
* Active Targets:: Active targets
|
* Target Commands:: Commands for managing targets
|
* Target Commands:: Commands for managing targets
|
* Byte Order:: Choosing target byte order
|
* Byte Order:: Choosing target byte order
|
|
|
|
|
File: gdb.info, Node: Active Targets, Next: Target Commands, Up: Targets
|
File: gdb.info, Node: Active Targets, Next: Target Commands, Up: Targets
|
|
|
19.1 Active Targets
|
19.1 Active Targets
|
===================
|
===================
|
|
|
There are three classes of targets: processes, core files, and
|
There are three classes of targets: processes, core files, and
|
executable files. GDB can work concurrently on up to three active
|
executable files. GDB can work concurrently on up to three active
|
targets, one in each class. This allows you to (for example) start a
|
targets, one in each class. This allows you to (for example) start a
|
process and inspect its activity without abandoning your work on a core
|
process and inspect its activity without abandoning your work on a core
|
file.
|
file.
|
|
|
For example, if you execute `gdb a.out', then the executable file
|
For example, if you execute `gdb a.out', then the executable file
|
`a.out' is the only active target. If you designate a core file as
|
`a.out' is the only active target. If you designate a core file as
|
well--presumably from a prior run that crashed and coredumped--then GDB
|
well--presumably from a prior run that crashed and coredumped--then GDB
|
has two active targets and uses them in tandem, looking first in the
|
has two active targets and uses them in tandem, looking first in the
|
corefile target, then in the executable file, to satisfy requests for
|
corefile target, then in the executable file, to satisfy requests for
|
memory addresses. (Typically, these two classes of target are
|
memory addresses. (Typically, these two classes of target are
|
complementary, since core files contain only a program's read-write
|
complementary, since core files contain only a program's read-write
|
memory--variables and so on--plus machine status, while executable
|
memory--variables and so on--plus machine status, while executable
|
files contain only the program text and initialized data.)
|
files contain only the program text and initialized data.)
|
|
|
When you type `run', your executable file becomes an active process
|
When you type `run', your executable file becomes an active process
|
target as well. When a process target is active, all GDB commands
|
target as well. When a process target is active, all GDB commands
|
requesting memory addresses refer to that target; addresses in an
|
requesting memory addresses refer to that target; addresses in an
|
active core file or executable file target are obscured while the
|
active core file or executable file target are obscured while the
|
process target is active.
|
process target is active.
|
|
|
Use the `core-file' and `exec-file' commands to select a new core
|
Use the `core-file' and `exec-file' commands to select a new core
|
file or executable target (*note Commands to Specify Files: Files.).
|
file or executable target (*note Commands to Specify Files: Files.).
|
To specify as a target a process that is already running, use the
|
To specify as a target a process that is already running, use the
|
`attach' command (*note Debugging an Already-running Process: Attach.).
|
`attach' command (*note Debugging an Already-running Process: Attach.).
|
|
|
|
|
File: gdb.info, Node: Target Commands, Next: Byte Order, Prev: Active Targets, Up: Targets
|
File: gdb.info, Node: Target Commands, Next: Byte Order, Prev: Active Targets, Up: Targets
|
|
|
19.2 Commands for Managing Targets
|
19.2 Commands for Managing Targets
|
==================================
|
==================================
|
|
|
`target TYPE PARAMETERS'
|
`target TYPE PARAMETERS'
|
Connects the GDB host environment to a target machine or process.
|
Connects the GDB host environment to a target machine or process.
|
A target is typically a protocol for talking to debugging
|
A target is typically a protocol for talking to debugging
|
facilities. You use the argument TYPE to specify the type or
|
facilities. You use the argument TYPE to specify the type or
|
protocol of the target machine.
|
protocol of the target machine.
|
|
|
Further PARAMETERS are interpreted by the target protocol, but
|
Further PARAMETERS are interpreted by the target protocol, but
|
typically include things like device names or host names to connect
|
typically include things like device names or host names to connect
|
with, process numbers, and baud rates.
|
with, process numbers, and baud rates.
|
|
|
The `target' command does not repeat if you press again
|
The `target' command does not repeat if you press again
|
after executing the command.
|
after executing the command.
|
|
|
`help target'
|
`help target'
|
Displays the names of all targets available. To display targets
|
Displays the names of all targets available. To display targets
|
currently selected, use either `info target' or `info files'
|
currently selected, use either `info target' or `info files'
|
(*note Commands to Specify Files: Files.).
|
(*note Commands to Specify Files: Files.).
|
|
|
`help target NAME'
|
`help target NAME'
|
Describe a particular target, including any parameters necessary to
|
Describe a particular target, including any parameters necessary to
|
select it.
|
select it.
|
|
|
`set gnutarget ARGS'
|
`set gnutarget ARGS'
|
GDB uses its own library BFD to read your files. GDB knows
|
GDB uses its own library BFD to read your files. GDB knows
|
whether it is reading an "executable", a "core", or a ".o" file;
|
whether it is reading an "executable", a "core", or a ".o" file;
|
however, you can specify the file format with the `set gnutarget'
|
however, you can specify the file format with the `set gnutarget'
|
command. Unlike most `target' commands, with `gnutarget' the
|
command. Unlike most `target' commands, with `gnutarget' the
|
`target' refers to a program, not a machine.
|
`target' refers to a program, not a machine.
|
|
|
_Warning:_ To specify a file format with `set gnutarget', you
|
_Warning:_ To specify a file format with `set gnutarget', you
|
must know the actual BFD name.
|
must know the actual BFD name.
|
|
|
*Note Commands to Specify Files: Files.
|
*Note Commands to Specify Files: Files.
|
|
|
`show gnutarget'
|
`show gnutarget'
|
Use the `show gnutarget' command to display what file format
|
Use the `show gnutarget' command to display what file format
|
`gnutarget' is set to read. If you have not set `gnutarget', GDB
|
`gnutarget' is set to read. If you have not set `gnutarget', GDB
|
will determine the file format for each file automatically, and
|
will determine the file format for each file automatically, and
|
`show gnutarget' displays `The current BDF target is "auto"'.
|
`show gnutarget' displays `The current BDF target is "auto"'.
|
|
|
Here are some common targets (available, or not, depending on the GDB
|
Here are some common targets (available, or not, depending on the GDB
|
configuration):
|
configuration):
|
|
|
`target exec PROGRAM'
|
`target exec PROGRAM'
|
An executable file. `target exec PROGRAM' is the same as
|
An executable file. `target exec PROGRAM' is the same as
|
`exec-file PROGRAM'.
|
`exec-file PROGRAM'.
|
|
|
`target core FILENAME'
|
`target core FILENAME'
|
A core dump file. `target core FILENAME' is the same as
|
A core dump file. `target core FILENAME' is the same as
|
`core-file FILENAME'.
|
`core-file FILENAME'.
|
|
|
`target remote MEDIUM'
|
`target remote MEDIUM'
|
A remote system connected to GDB via a serial line or network
|
A remote system connected to GDB via a serial line or network
|
connection. This command tells GDB to use its own remote protocol
|
connection. This command tells GDB to use its own remote protocol
|
over MEDIUM for debugging. *Note Remote Debugging::.
|
over MEDIUM for debugging. *Note Remote Debugging::.
|
|
|
For example, if you have a board connected to `/dev/ttya' on the
|
For example, if you have a board connected to `/dev/ttya' on the
|
machine running GDB, you could say:
|
machine running GDB, you could say:
|
|
|
target remote /dev/ttya
|
target remote /dev/ttya
|
|
|
`target remote' supports the `load' command. This is only useful
|
`target remote' supports the `load' command. This is only useful
|
if you have some other way of getting the stub to the target
|
if you have some other way of getting the stub to the target
|
system, and you can put it somewhere in memory where it won't get
|
system, and you can put it somewhere in memory where it won't get
|
clobbered by the download.
|
clobbered by the download.
|
|
|
`target sim [SIMARGS] ...'
|
`target sim [SIMARGS] ...'
|
Builtin CPU simulator. GDB includes simulators for most
|
Builtin CPU simulator. GDB includes simulators for most
|
architectures. In general,
|
architectures. In general,
|
target sim
|
target sim
|
load
|
load
|
run
|
run
|
works; however, you cannot assume that a specific memory map,
|
works; however, you cannot assume that a specific memory map,
|
device drivers, or even basic I/O is available, although some
|
device drivers, or even basic I/O is available, although some
|
simulators do provide these. For info about any
|
simulators do provide these. For info about any
|
processor-specific simulator details, see the appropriate section
|
processor-specific simulator details, see the appropriate section
|
in *note Embedded Processors: Embedded Processors.
|
in *note Embedded Processors: Embedded Processors.
|
|
|
|
|
Some configurations may include these targets as well:
|
Some configurations may include these targets as well:
|
|
|
`target nrom DEV'
|
`target nrom DEV'
|
NetROM ROM emulator. This target only supports downloading.
|
NetROM ROM emulator. This target only supports downloading.
|
|
|
|
|
Different targets are available on different configurations of GDB;
|
Different targets are available on different configurations of GDB;
|
your configuration may have more or fewer targets.
|
your configuration may have more or fewer targets.
|
|
|
Many remote targets require you to download the executable's code
|
Many remote targets require you to download the executable's code
|
once you've successfully established a connection. You may wish to
|
once you've successfully established a connection. You may wish to
|
control various aspects of this process.
|
control various aspects of this process.
|
|
|
`set hash'
|
`set hash'
|
This command controls whether a hash mark `#' is displayed while
|
This command controls whether a hash mark `#' is displayed while
|
downloading a file to the remote monitor. If on, a hash mark is
|
downloading a file to the remote monitor. If on, a hash mark is
|
displayed after each S-record is successfully downloaded to the
|
displayed after each S-record is successfully downloaded to the
|
monitor.
|
monitor.
|
|
|
`show hash'
|
`show hash'
|
Show the current status of displaying the hash mark.
|
Show the current status of displaying the hash mark.
|
|
|
`set debug monitor'
|
`set debug monitor'
|
Enable or disable display of communications messages between GDB
|
Enable or disable display of communications messages between GDB
|
and the remote monitor.
|
and the remote monitor.
|
|
|
`show debug monitor'
|
`show debug monitor'
|
Show the current status of displaying communications between GDB
|
Show the current status of displaying communications between GDB
|
and the remote monitor.
|
and the remote monitor.
|
|
|
`load FILENAME'
|
`load FILENAME'
|
Depending on what remote debugging facilities are configured into
|
Depending on what remote debugging facilities are configured into
|
GDB, the `load' command may be available. Where it exists, it is
|
GDB, the `load' command may be available. Where it exists, it is
|
meant to make FILENAME (an executable) available for debugging on
|
meant to make FILENAME (an executable) available for debugging on
|
the remote system--by downloading, or dynamic linking, for example.
|
the remote system--by downloading, or dynamic linking, for example.
|
`load' also records the FILENAME symbol table in GDB, like the
|
`load' also records the FILENAME symbol table in GDB, like the
|
`add-symbol-file' command.
|
`add-symbol-file' command.
|
|
|
If your GDB does not have a `load' command, attempting to execute
|
If your GDB does not have a `load' command, attempting to execute
|
it gets the error message "`You can't do that when your target is
|
it gets the error message "`You can't do that when your target is
|
...'"
|
...'"
|
|
|
The file is loaded at whatever address is specified in the
|
The file is loaded at whatever address is specified in the
|
executable. For some object file formats, you can specify the
|
executable. For some object file formats, you can specify the
|
load address when you link the program; for other formats, like
|
load address when you link the program; for other formats, like
|
a.out, the object file format specifies a fixed address.
|
a.out, the object file format specifies a fixed address.
|
|
|
Depending on the remote side capabilities, GDB may be able to load
|
Depending on the remote side capabilities, GDB may be able to load
|
programs into flash memory.
|
programs into flash memory.
|
|
|
`load' does not repeat if you press again after using it.
|
`load' does not repeat if you press again after using it.
|
|
|
|
|
File: gdb.info, Node: Byte Order, Prev: Target Commands, Up: Targets
|
File: gdb.info, Node: Byte Order, Prev: Target Commands, Up: Targets
|
|
|
19.3 Choosing Target Byte Order
|
19.3 Choosing Target Byte Order
|
===============================
|
===============================
|
|
|
Some types of processors, such as the MIPS, PowerPC, and Renesas SH,
|
Some types of processors, such as the MIPS, PowerPC, and Renesas SH,
|
offer the ability to run either big-endian or little-endian byte
|
offer the ability to run either big-endian or little-endian byte
|
orders. Usually the executable or symbol will include a bit to
|
orders. Usually the executable or symbol will include a bit to
|
designate the endian-ness, and you will not need to worry about which
|
designate the endian-ness, and you will not need to worry about which
|
to use. However, you may still find it useful to adjust GDB's idea of
|
to use. However, you may still find it useful to adjust GDB's idea of
|
processor endian-ness manually.
|
processor endian-ness manually.
|
|
|
`set endian big'
|
`set endian big'
|
Instruct GDB to assume the target is big-endian.
|
Instruct GDB to assume the target is big-endian.
|
|
|
`set endian little'
|
`set endian little'
|
Instruct GDB to assume the target is little-endian.
|
Instruct GDB to assume the target is little-endian.
|
|
|
`set endian auto'
|
`set endian auto'
|
Instruct GDB to use the byte order associated with the executable.
|
Instruct GDB to use the byte order associated with the executable.
|
|
|
`show endian'
|
`show endian'
|
Display GDB's current idea of the target byte order.
|
Display GDB's current idea of the target byte order.
|
|
|
|
|
Note that these commands merely adjust interpretation of symbolic
|
Note that these commands merely adjust interpretation of symbolic
|
data on the host, and that they have absolutely no effect on the target
|
data on the host, and that they have absolutely no effect on the target
|
system.
|
system.
|
|
|
|
|
File: gdb.info, Node: Remote Debugging, Next: Configurations, Prev: Targets, Up: Top
|
File: gdb.info, Node: Remote Debugging, Next: Configurations, Prev: Targets, Up: Top
|
|
|
20 Debugging Remote Programs
|
20 Debugging Remote Programs
|
****************************
|
****************************
|
|
|
If you are trying to debug a program running on a machine that cannot
|
If you are trying to debug a program running on a machine that cannot
|
run GDB in the usual way, it is often useful to use remote debugging.
|
run GDB in the usual way, it is often useful to use remote debugging.
|
For example, you might use remote debugging on an operating system
|
For example, you might use remote debugging on an operating system
|
kernel, or on a small system which does not have a general purpose
|
kernel, or on a small system which does not have a general purpose
|
operating system powerful enough to run a full-featured debugger.
|
operating system powerful enough to run a full-featured debugger.
|
|
|
Some configurations of GDB have special serial or TCP/IP interfaces
|
Some configurations of GDB have special serial or TCP/IP interfaces
|
to make this work with particular debugging targets. In addition, GDB
|
to make this work with particular debugging targets. In addition, GDB
|
comes with a generic serial protocol (specific to GDB, but not specific
|
comes with a generic serial protocol (specific to GDB, but not specific
|
to any particular target system) which you can use if you write the
|
to any particular target system) which you can use if you write the
|
remote stubs--the code that runs on the remote system to communicate
|
remote stubs--the code that runs on the remote system to communicate
|
with GDB.
|
with GDB.
|
|
|
Other remote targets may be available in your configuration of GDB;
|
Other remote targets may be available in your configuration of GDB;
|
use `help target' to list them.
|
use `help target' to list them.
|
|
|
* Menu:
|
* Menu:
|
|
|
* Connecting:: Connecting to a remote target
|
* Connecting:: Connecting to a remote target
|
* File Transfer:: Sending files to a remote system
|
* File Transfer:: Sending files to a remote system
|
* Server:: Using the gdbserver program
|
* Server:: Using the gdbserver program
|
* Remote Configuration:: Remote configuration
|
* Remote Configuration:: Remote configuration
|
* Remote Stub:: Implementing a remote stub
|
* Remote Stub:: Implementing a remote stub
|
|
|
|
|
File: gdb.info, Node: Connecting, Next: File Transfer, Up: Remote Debugging
|
File: gdb.info, Node: Connecting, Next: File Transfer, Up: Remote Debugging
|
|
|
20.1 Connecting to a Remote Target
|
20.1 Connecting to a Remote Target
|
==================================
|
==================================
|
|
|
On the GDB host machine, you will need an unstripped copy of your
|
On the GDB host machine, you will need an unstripped copy of your
|
program, since GDB needs symbol and debugging information. Start up
|
program, since GDB needs symbol and debugging information. Start up
|
GDB as usual, using the name of the local copy of your program as the
|
GDB as usual, using the name of the local copy of your program as the
|
first argument.
|
first argument.
|
|
|
GDB can communicate with the target over a serial line, or over an
|
GDB can communicate with the target over a serial line, or over an
|
IP network using TCP or UDP. In each case, GDB uses the same protocol
|
IP network using TCP or UDP. In each case, GDB uses the same protocol
|
for debugging your program; only the medium carrying the debugging
|
for debugging your program; only the medium carrying the debugging
|
packets varies. The `target remote' command establishes a connection
|
packets varies. The `target remote' command establishes a connection
|
to the target. Its arguments indicate which medium to use:
|
to the target. Its arguments indicate which medium to use:
|
|
|
`target remote SERIAL-DEVICE'
|
`target remote SERIAL-DEVICE'
|
Use SERIAL-DEVICE to communicate with the target. For example, to
|
Use SERIAL-DEVICE to communicate with the target. For example, to
|
use a serial line connected to the device named `/dev/ttyb':
|
use a serial line connected to the device named `/dev/ttyb':
|
|
|
target remote /dev/ttyb
|
target remote /dev/ttyb
|
|
|
If you're using a serial line, you may want to give GDB the
|
If you're using a serial line, you may want to give GDB the
|
`--baud' option, or use the `set remotebaud' command (*note set
|
`--baud' option, or use the `set remotebaud' command (*note set
|
remotebaud: Remote Configuration.) before the `target' command.
|
remotebaud: Remote Configuration.) before the `target' command.
|
|
|
`target remote `HOST:PORT''
|
`target remote `HOST:PORT''
|
`target remote `tcp:HOST:PORT''
|
`target remote `tcp:HOST:PORT''
|
Debug using a TCP connection to PORT on HOST. The HOST may be
|
Debug using a TCP connection to PORT on HOST. The HOST may be
|
either a host name or a numeric IP address; PORT must be a decimal
|
either a host name or a numeric IP address; PORT must be a decimal
|
number. The HOST could be the target machine itself, if it is
|
number. The HOST could be the target machine itself, if it is
|
directly connected to the net, or it might be a terminal server
|
directly connected to the net, or it might be a terminal server
|
which in turn has a serial line to the target.
|
which in turn has a serial line to the target.
|
|
|
For example, to connect to port 2828 on a terminal server named
|
For example, to connect to port 2828 on a terminal server named
|
`manyfarms':
|
`manyfarms':
|
|
|
target remote manyfarms:2828
|
target remote manyfarms:2828
|
|
|
If your remote target is actually running on the same machine as
|
If your remote target is actually running on the same machine as
|
your debugger session (e.g. a simulator for your target running on
|
your debugger session (e.g. a simulator for your target running on
|
the same host), you can omit the hostname. For example, to
|
the same host), you can omit the hostname. For example, to
|
connect to port 1234 on your local machine:
|
connect to port 1234 on your local machine:
|
|
|
target remote :1234
|
target remote :1234
|
Note that the colon is still required here.
|
Note that the colon is still required here.
|
|
|
`target remote `udp:HOST:PORT''
|
`target remote `udp:HOST:PORT''
|
Debug using UDP packets to PORT on HOST. For example, to connect
|
Debug using UDP packets to PORT on HOST. For example, to connect
|
to UDP port 2828 on a terminal server named `manyfarms':
|
to UDP port 2828 on a terminal server named `manyfarms':
|
|
|
target remote udp:manyfarms:2828
|
target remote udp:manyfarms:2828
|
|
|
When using a UDP connection for remote debugging, you should keep
|
When using a UDP connection for remote debugging, you should keep
|
in mind that the `U' stands for "Unreliable". UDP can silently
|
in mind that the `U' stands for "Unreliable". UDP can silently
|
drop packets on busy or unreliable networks, which will cause
|
drop packets on busy or unreliable networks, which will cause
|
havoc with your debugging session.
|
havoc with your debugging session.
|
|
|
`target remote | COMMAND'
|
`target remote | COMMAND'
|
Run COMMAND in the background and communicate with it using a
|
Run COMMAND in the background and communicate with it using a
|
pipe. The COMMAND is a shell command, to be parsed and expanded
|
pipe. The COMMAND is a shell command, to be parsed and expanded
|
by the system's command shell, `/bin/sh'; it should expect remote
|
by the system's command shell, `/bin/sh'; it should expect remote
|
protocol packets on its standard input, and send replies on its
|
protocol packets on its standard input, and send replies on its
|
standard output. You could use this to run a stand-alone simulator
|
standard output. You could use this to run a stand-alone simulator
|
that speaks the remote debugging protocol, to make net connections
|
that speaks the remote debugging protocol, to make net connections
|
using programs like `ssh', or for other similar tricks.
|
using programs like `ssh', or for other similar tricks.
|
|
|
If COMMAND closes its standard output (perhaps by exiting), GDB
|
If COMMAND closes its standard output (perhaps by exiting), GDB
|
will try to send it a `SIGTERM' signal. (If the program has
|
will try to send it a `SIGTERM' signal. (If the program has
|
already exited, this will have no effect.)
|
already exited, this will have no effect.)
|
|
|
|
|
Once the connection has been established, you can use all the usual
|
Once the connection has been established, you can use all the usual
|
commands to examine and change data. The remote program is already
|
commands to examine and change data. The remote program is already
|
running; you can use `step' and `continue', and you do not need to use
|
running; you can use `step' and `continue', and you do not need to use
|
`run'.
|
`run'.
|
|
|
Whenever GDB is waiting for the remote program, if you type the
|
Whenever GDB is waiting for the remote program, if you type the
|
interrupt character (often `Ctrl-c'), GDB attempts to stop the program.
|
interrupt character (often `Ctrl-c'), GDB attempts to stop the program.
|
This may or may not succeed, depending in part on the hardware and the
|
This may or may not succeed, depending in part on the hardware and the
|
serial drivers the remote system uses. If you type the interrupt
|
serial drivers the remote system uses. If you type the interrupt
|
character once again, GDB displays this prompt:
|
character once again, GDB displays this prompt:
|
|
|
Interrupted while waiting for the program.
|
Interrupted while waiting for the program.
|
Give up (and stop debugging it)? (y or n)
|
Give up (and stop debugging it)? (y or n)
|
|
|
If you type `y', GDB abandons the remote debugging session. (If you
|
If you type `y', GDB abandons the remote debugging session. (If you
|
decide you want to try again later, you can use `target remote' again
|
decide you want to try again later, you can use `target remote' again
|
to connect once more.) If you type `n', GDB goes back to waiting.
|
to connect once more.) If you type `n', GDB goes back to waiting.
|
|
|
`detach'
|
`detach'
|
When you have finished debugging the remote program, you can use
|
When you have finished debugging the remote program, you can use
|
the `detach' command to release it from GDB control. Detaching
|
the `detach' command to release it from GDB control. Detaching
|
from the target normally resumes its execution, but the results
|
from the target normally resumes its execution, but the results
|
will depend on your particular remote stub. After the `detach'
|
will depend on your particular remote stub. After the `detach'
|
command, GDB is free to connect to another target.
|
command, GDB is free to connect to another target.
|
|
|
`disconnect'
|
`disconnect'
|
The `disconnect' command behaves like `detach', except that the
|
The `disconnect' command behaves like `detach', except that the
|
target is generally not resumed. It will wait for GDB (this
|
target is generally not resumed. It will wait for GDB (this
|
instance or another one) to connect and continue debugging. After
|
instance or another one) to connect and continue debugging. After
|
the `disconnect' command, GDB is again free to connect to another
|
the `disconnect' command, GDB is again free to connect to another
|
target.
|
target.
|
|
|
`monitor CMD'
|
`monitor CMD'
|
This command allows you to send arbitrary commands directly to the
|
This command allows you to send arbitrary commands directly to the
|
remote monitor. Since GDB doesn't care about the commands it
|
remote monitor. Since GDB doesn't care about the commands it
|
sends like this, this command is the way to extend GDB--you can
|
sends like this, this command is the way to extend GDB--you can
|
add new commands that only the external monitor will understand
|
add new commands that only the external monitor will understand
|
and implement.
|
and implement.
|
|
|
|
|
File: gdb.info, Node: File Transfer, Next: Server, Prev: Connecting, Up: Remote Debugging
|
File: gdb.info, Node: File Transfer, Next: Server, Prev: Connecting, Up: Remote Debugging
|
|
|
20.2 Sending files to a remote system
|
20.2 Sending files to a remote system
|
=====================================
|
=====================================
|
|
|
Some remote targets offer the ability to transfer files over the same
|
Some remote targets offer the ability to transfer files over the same
|
connection used to communicate with GDB. This is convenient for
|
connection used to communicate with GDB. This is convenient for
|
targets accessible through other means, e.g. GNU/Linux systems running
|
targets accessible through other means, e.g. GNU/Linux systems running
|
`gdbserver' over a network interface. For other targets, e.g. embedded
|
`gdbserver' over a network interface. For other targets, e.g. embedded
|
devices with only a single serial port, this may be the only way to
|
devices with only a single serial port, this may be the only way to
|
upload or download files.
|
upload or download files.
|
|
|
Not all remote targets support these commands.
|
Not all remote targets support these commands.
|
|
|
`remote put HOSTFILE TARGETFILE'
|
`remote put HOSTFILE TARGETFILE'
|
Copy file HOSTFILE from the host system (the machine running GDB)
|
Copy file HOSTFILE from the host system (the machine running GDB)
|
to TARGETFILE on the target system.
|
to TARGETFILE on the target system.
|
|
|
`remote get TARGETFILE HOSTFILE'
|
`remote get TARGETFILE HOSTFILE'
|
Copy file TARGETFILE from the target system to HOSTFILE on the
|
Copy file TARGETFILE from the target system to HOSTFILE on the
|
host system.
|
host system.
|
|
|
`remote delete TARGETFILE'
|
`remote delete TARGETFILE'
|
Delete TARGETFILE from the target system.
|
Delete TARGETFILE from the target system.
|
|
|
|
|
|
|
File: gdb.info, Node: Server, Next: Remote Configuration, Prev: File Transfer, Up: Remote Debugging
|
File: gdb.info, Node: Server, Next: Remote Configuration, Prev: File Transfer, Up: Remote Debugging
|
|
|
20.3 Using the `gdbserver' Program
|
20.3 Using the `gdbserver' Program
|
==================================
|
==================================
|
|
|
`gdbserver' is a control program for Unix-like systems, which allows
|
`gdbserver' is a control program for Unix-like systems, which allows
|
you to connect your program with a remote GDB via `target remote'--but
|
you to connect your program with a remote GDB via `target remote'--but
|
without linking in the usual debugging stub.
|
without linking in the usual debugging stub.
|
|
|
`gdbserver' is not a complete replacement for the debugging stubs,
|
`gdbserver' is not a complete replacement for the debugging stubs,
|
because it requires essentially the same operating-system facilities
|
because it requires essentially the same operating-system facilities
|
that GDB itself does. In fact, a system that can run `gdbserver' to
|
that GDB itself does. In fact, a system that can run `gdbserver' to
|
connect to a remote GDB could also run GDB locally! `gdbserver' is
|
connect to a remote GDB could also run GDB locally! `gdbserver' is
|
sometimes useful nevertheless, because it is a much smaller program
|
sometimes useful nevertheless, because it is a much smaller program
|
than GDB itself. It is also easier to port than all of GDB, so you may
|
than GDB itself. It is also easier to port than all of GDB, so you may
|
be able to get started more quickly on a new system by using
|
be able to get started more quickly on a new system by using
|
`gdbserver'. Finally, if you develop code for real-time systems, you
|
`gdbserver'. Finally, if you develop code for real-time systems, you
|
may find that the tradeoffs involved in real-time operation make it
|
may find that the tradeoffs involved in real-time operation make it
|
more convenient to do as much development work as possible on another
|
more convenient to do as much development work as possible on another
|
system, for example by cross-compiling. You can use `gdbserver' to
|
system, for example by cross-compiling. You can use `gdbserver' to
|
make a similar choice for debugging.
|
make a similar choice for debugging.
|
|
|
GDB and `gdbserver' communicate via either a serial line or a TCP
|
GDB and `gdbserver' communicate via either a serial line or a TCP
|
connection, using the standard GDB remote serial protocol.
|
connection, using the standard GDB remote serial protocol.
|
|
|
_Warning:_ `gdbserver' does not have any built-in security. Do
|
_Warning:_ `gdbserver' does not have any built-in security. Do
|
not run `gdbserver' connected to any public network; a GDB
|
not run `gdbserver' connected to any public network; a GDB
|
connection to `gdbserver' provides access to the target system
|
connection to `gdbserver' provides access to the target system
|
with the same privileges as the user running `gdbserver'.
|
with the same privileges as the user running `gdbserver'.
|
|
|
20.3.1 Running `gdbserver'
|
20.3.1 Running `gdbserver'
|
--------------------------
|
--------------------------
|
|
|
Run `gdbserver' on the target system. You need a copy of the program
|
Run `gdbserver' on the target system. You need a copy of the program
|
you want to debug, including any libraries it requires. `gdbserver'
|
you want to debug, including any libraries it requires. `gdbserver'
|
does not need your program's symbol table, so you can strip the program
|
does not need your program's symbol table, so you can strip the program
|
if necessary to save space. GDB on the host system does all the symbol
|
if necessary to save space. GDB on the host system does all the symbol
|
handling.
|
handling.
|
|
|
To use the server, you must tell it how to communicate with GDB; the
|
To use the server, you must tell it how to communicate with GDB; the
|
name of your program; and the arguments for your program. The usual
|
name of your program; and the arguments for your program. The usual
|
syntax is:
|
syntax is:
|
|
|
target> gdbserver COMM PROGRAM [ ARGS ... ]
|
target> gdbserver COMM PROGRAM [ ARGS ... ]
|
|
|
COMM is either a device name (to use a serial line) or a TCP
|
COMM is either a device name (to use a serial line) or a TCP
|
hostname and portnumber. For example, to debug Emacs with the argument
|
hostname and portnumber. For example, to debug Emacs with the argument
|
`foo.txt' and communicate with GDB over the serial port `/dev/com1':
|
`foo.txt' and communicate with GDB over the serial port `/dev/com1':
|
|
|
target> gdbserver /dev/com1 emacs foo.txt
|
target> gdbserver /dev/com1 emacs foo.txt
|
|
|
`gdbserver' waits passively for the host GDB to communicate with it.
|
`gdbserver' waits passively for the host GDB to communicate with it.
|
|
|
To use a TCP connection instead of a serial line:
|
To use a TCP connection instead of a serial line:
|
|
|
target> gdbserver host:2345 emacs foo.txt
|
target> gdbserver host:2345 emacs foo.txt
|
|
|
The only difference from the previous example is the first argument,
|
The only difference from the previous example is the first argument,
|
specifying that you are communicating with the host GDB via TCP. The
|
specifying that you are communicating with the host GDB via TCP. The
|
`host:2345' argument means that `gdbserver' is to expect a TCP
|
`host:2345' argument means that `gdbserver' is to expect a TCP
|
connection from machine `host' to local TCP port 2345. (Currently, the
|
connection from machine `host' to local TCP port 2345. (Currently, the
|
`host' part is ignored.) You can choose any number you want for the
|
`host' part is ignored.) You can choose any number you want for the
|
port number as long as it does not conflict with any TCP ports already
|
port number as long as it does not conflict with any TCP ports already
|
in use on the target system (for example, `23' is reserved for
|
in use on the target system (for example, `23' is reserved for
|
`telnet').(1) You must use the same port number with the host GDB
|
`telnet').(1) You must use the same port number with the host GDB
|
`target remote' command.
|
`target remote' command.
|
|
|
20.3.1.1 Attaching to a Running Program
|
20.3.1.1 Attaching to a Running Program
|
.......................................
|
.......................................
|
|
|
On some targets, `gdbserver' can also attach to running programs. This
|
On some targets, `gdbserver' can also attach to running programs. This
|
is accomplished via the `--attach' argument. The syntax is:
|
is accomplished via the `--attach' argument. The syntax is:
|
|
|
target> gdbserver --attach COMM PID
|
target> gdbserver --attach COMM PID
|
|
|
PID is the process ID of a currently running process. It isn't
|
PID is the process ID of a currently running process. It isn't
|
necessary to point `gdbserver' at a binary for the running process.
|
necessary to point `gdbserver' at a binary for the running process.
|
|
|
You can debug processes by name instead of process ID if your target
|
You can debug processes by name instead of process ID if your target
|
has the `pidof' utility:
|
has the `pidof' utility:
|
|
|
target> gdbserver --attach COMM `pidof PROGRAM`
|
target> gdbserver --attach COMM `pidof PROGRAM`
|
|
|
In case more than one copy of PROGRAM is running, or PROGRAM has
|
In case more than one copy of PROGRAM is running, or PROGRAM has
|
multiple threads, most versions of `pidof' support the `-s' option to
|
multiple threads, most versions of `pidof' support the `-s' option to
|
only return the first process ID.
|
only return the first process ID.
|
|
|
20.3.1.2 Multi-Process Mode for `gdbserver'
|
20.3.1.2 Multi-Process Mode for `gdbserver'
|
...........................................
|
...........................................
|
|
|
When you connect to `gdbserver' using `target remote', `gdbserver'
|
When you connect to `gdbserver' using `target remote', `gdbserver'
|
debugs the specified program only once. When the program exits, or you
|
debugs the specified program only once. When the program exits, or you
|
detach from it, GDB closes the connection and `gdbserver' exits.
|
detach from it, GDB closes the connection and `gdbserver' exits.
|
|
|
If you connect using `target extended-remote', `gdbserver' enters
|
If you connect using `target extended-remote', `gdbserver' enters
|
multi-process mode. When the debugged program exits, or you detach
|
multi-process mode. When the debugged program exits, or you detach
|
from it, GDB stays connected to `gdbserver' even though no program is
|
from it, GDB stays connected to `gdbserver' even though no program is
|
running. The `run' and `attach' commands instruct `gdbserver' to run
|
running. The `run' and `attach' commands instruct `gdbserver' to run
|
or attach to a new program. The `run' command uses `set remote
|
or attach to a new program. The `run' command uses `set remote
|
exec-file' (*note set remote exec-file::) to select the program to run.
|
exec-file' (*note set remote exec-file::) to select the program to run.
|
Command line arguments are supported, except for wildcard expansion and
|
Command line arguments are supported, except for wildcard expansion and
|
I/O redirection (*note Arguments::).
|
I/O redirection (*note Arguments::).
|
|
|
To start `gdbserver' without supplying an initial command to run or
|
To start `gdbserver' without supplying an initial command to run or
|
process ID to attach, use the `--multi' command line option. Then you
|
process ID to attach, use the `--multi' command line option. Then you
|
can connect using `target extended-remote' and start the program you
|
can connect using `target extended-remote' and start the program you
|
want to debug.
|
want to debug.
|
|
|
`gdbserver' does not automatically exit in multi-process mode. You
|
`gdbserver' does not automatically exit in multi-process mode. You
|
can terminate it by using `monitor exit' (*note Monitor Commands for
|
can terminate it by using `monitor exit' (*note Monitor Commands for
|
gdbserver::).
|
gdbserver::).
|
|
|
20.3.1.3 Other Command-Line Arguments for `gdbserver'
|
20.3.1.3 Other Command-Line Arguments for `gdbserver'
|
.....................................................
|
.....................................................
|
|
|
The `--debug' option tells `gdbserver' to display extra status
|
The `--debug' option tells `gdbserver' to display extra status
|
information about the debugging process. The `--remote-debug' option
|
information about the debugging process. The `--remote-debug' option
|
tells `gdbserver' to display remote protocol debug output. These
|
tells `gdbserver' to display remote protocol debug output. These
|
options are intended for `gdbserver' development and for bug reports to
|
options are intended for `gdbserver' development and for bug reports to
|
the developers.
|
the developers.
|
|
|
The `--wrapper' option specifies a wrapper to launch programs for
|
The `--wrapper' option specifies a wrapper to launch programs for
|
debugging. The option should be followed by the name of the wrapper,
|
debugging. The option should be followed by the name of the wrapper,
|
then any command-line arguments to pass to the wrapper, then `--'
|
then any command-line arguments to pass to the wrapper, then `--'
|
indicating the end of the wrapper arguments.
|
indicating the end of the wrapper arguments.
|
|
|
`gdbserver' runs the specified wrapper program with a combined
|
`gdbserver' runs the specified wrapper program with a combined
|
command line including the wrapper arguments, then the name of the
|
command line including the wrapper arguments, then the name of the
|
program to debug, then any arguments to the program. The wrapper runs
|
program to debug, then any arguments to the program. The wrapper runs
|
until it executes your program, and then GDB gains control.
|
until it executes your program, and then GDB gains control.
|
|
|
You can use any program that eventually calls `execve' with its
|
You can use any program that eventually calls `execve' with its
|
arguments as a wrapper. Several standard Unix utilities do this, e.g.
|
arguments as a wrapper. Several standard Unix utilities do this, e.g.
|
`env' and `nohup'. Any Unix shell script ending with `exec "$@"' will
|
`env' and `nohup'. Any Unix shell script ending with `exec "$@"' will
|
also work.
|
also work.
|
|
|
For example, you can use `env' to pass an environment variable to
|
For example, you can use `env' to pass an environment variable to
|
the debugged program, without setting the variable in `gdbserver''s
|
the debugged program, without setting the variable in `gdbserver''s
|
environment:
|
environment:
|
|
|
$ gdbserver --wrapper env LD_PRELOAD=libtest.so -- :2222 ./testprog
|
$ gdbserver --wrapper env LD_PRELOAD=libtest.so -- :2222 ./testprog
|
|
|
20.3.2 Connecting to `gdbserver'
|
20.3.2 Connecting to `gdbserver'
|
--------------------------------
|
--------------------------------
|
|
|
Run GDB on the host system.
|
Run GDB on the host system.
|
|
|
First make sure you have the necessary symbol files. Load symbols
|
First make sure you have the necessary symbol files. Load symbols
|
for your application using the `file' command before you connect. Use
|
for your application using the `file' command before you connect. Use
|
`set sysroot' to locate target libraries (unless your GDB was compiled
|
`set sysroot' to locate target libraries (unless your GDB was compiled
|
with the correct sysroot using `--with-sysroot').
|
with the correct sysroot using `--with-sysroot').
|
|
|
The symbol file and target libraries must exactly match the
|
The symbol file and target libraries must exactly match the
|
executable and libraries on the target, with one exception: the files
|
executable and libraries on the target, with one exception: the files
|
on the host system should not be stripped, even if the files on the
|
on the host system should not be stripped, even if the files on the
|
target system are. Mismatched or missing files will lead to confusing
|
target system are. Mismatched or missing files will lead to confusing
|
results during debugging. On GNU/Linux targets, mismatched or missing
|
results during debugging. On GNU/Linux targets, mismatched or missing
|
files may also prevent `gdbserver' from debugging multi-threaded
|
files may also prevent `gdbserver' from debugging multi-threaded
|
programs.
|
programs.
|
|
|
Connect to your target (*note Connecting to a Remote Target:
|
Connect to your target (*note Connecting to a Remote Target:
|
Connecting.). For TCP connections, you must start up `gdbserver' prior
|
Connecting.). For TCP connections, you must start up `gdbserver' prior
|
to using the `target remote' command. Otherwise you may get an error
|
to using the `target remote' command. Otherwise you may get an error
|
whose text depends on the host system, but which usually looks
|
whose text depends on the host system, but which usually looks
|
something like `Connection refused'. Don't use the `load' command in
|
something like `Connection refused'. Don't use the `load' command in
|
GDB when using `gdbserver', since the program is already on the target.
|
GDB when using `gdbserver', since the program is already on the target.
|
|
|
20.3.3 Monitor Commands for `gdbserver'
|
20.3.3 Monitor Commands for `gdbserver'
|
---------------------------------------
|
---------------------------------------
|
|
|
During a GDB session using `gdbserver', you can use the `monitor'
|
During a GDB session using `gdbserver', you can use the `monitor'
|
command to send special requests to `gdbserver'. Here are the
|
command to send special requests to `gdbserver'. Here are the
|
available commands.
|
available commands.
|
|
|
`monitor help'
|
`monitor help'
|
List the available monitor commands.
|
List the available monitor commands.
|
|
|
`monitor set debug 0'
|
`monitor set debug 0'
|
`monitor set debug 1'
|
`monitor set debug 1'
|
Disable or enable general debugging messages.
|
Disable or enable general debugging messages.
|
|
|
`monitor set remote-debug 0'
|
`monitor set remote-debug 0'
|
`monitor set remote-debug 1'
|
`monitor set remote-debug 1'
|
Disable or enable specific debugging messages associated with the
|
Disable or enable specific debugging messages associated with the
|
remote protocol (*note Remote Protocol::).
|
remote protocol (*note Remote Protocol::).
|
|
|
`monitor set libthread-db-search-path [PATH]'
|
`monitor set libthread-db-search-path [PATH]'
|
When this command is issued, PATH is a colon-separated list of
|
When this command is issued, PATH is a colon-separated list of
|
directories to search for `libthread_db' (*note set
|
directories to search for `libthread_db' (*note set
|
libthread-db-search-path: Threads.). If you omit PATH,
|
libthread-db-search-path: Threads.). If you omit PATH,
|
`libthread-db-search-path' will be reset to an empty list.
|
`libthread-db-search-path' will be reset to an empty list.
|
|
|
`monitor exit'
|
`monitor exit'
|
Tell gdbserver to exit immediately. This command should be
|
Tell gdbserver to exit immediately. This command should be
|
followed by `disconnect' to close the debugging session.
|
followed by `disconnect' to close the debugging session.
|
`gdbserver' will detach from any attached processes and kill any
|
`gdbserver' will detach from any attached processes and kill any
|
processes it created. Use `monitor exit' to terminate `gdbserver'
|
processes it created. Use `monitor exit' to terminate `gdbserver'
|
at the end of a multi-process mode debug session.
|
at the end of a multi-process mode debug session.
|
|
|
|
|
20.3.4 Tracepoints support in `gdbserver'
|
20.3.4 Tracepoints support in `gdbserver'
|
-----------------------------------------
|
-----------------------------------------
|
|
|
On some targets, `gdbserver' supports tracepoints, fast tracepoints and
|
On some targets, `gdbserver' supports tracepoints, fast tracepoints and
|
static tracepoints.
|
static tracepoints.
|
|
|
For fast or static tracepoints to work, a special library called the
|
For fast or static tracepoints to work, a special library called the
|
"in-process agent" (IPA), must be loaded in the inferior process. This
|
"in-process agent" (IPA), must be loaded in the inferior process. This
|
library is built and distributed as an integral part of `gdbserver'.
|
library is built and distributed as an integral part of `gdbserver'.
|
In addition, support for static tracepoints requires building the
|
In addition, support for static tracepoints requires building the
|
in-process agent library with static tracepoints support. At present,
|
in-process agent library with static tracepoints support. At present,
|
the UST (LTTng Userspace Tracer, `http://lttng.org/ust') tracing engine
|
the UST (LTTng Userspace Tracer, `http://lttng.org/ust') tracing engine
|
is supported. This support is automatically available if UST
|
is supported. This support is automatically available if UST
|
development headers are found in the standard include path when
|
development headers are found in the standard include path when
|
`gdbserver' is built, or if `gdbserver' was explicitly configured using
|
`gdbserver' is built, or if `gdbserver' was explicitly configured using
|
`--with-ust' to point at such headers. You can explicitly disable the
|
`--with-ust' to point at such headers. You can explicitly disable the
|
support using `--with-ust=no'.
|
support using `--with-ust=no'.
|
|
|
There are several ways to load the in-process agent in your program:
|
There are several ways to load the in-process agent in your program:
|
|
|
`Specifying it as dependency at link time'
|
`Specifying it as dependency at link time'
|
You can link your program dynamically with the in-process agent
|
You can link your program dynamically with the in-process agent
|
library. On most systems, this is accomplished by adding
|
library. On most systems, this is accomplished by adding
|
`-linproctrace' to the link command.
|
`-linproctrace' to the link command.
|
|
|
`Using the system's preloading mechanisms'
|
`Using the system's preloading mechanisms'
|
You can force loading the in-process agent at startup time by using
|
You can force loading the in-process agent at startup time by using
|
your system's support for preloading shared libraries. Many Unixes
|
your system's support for preloading shared libraries. Many Unixes
|
support the concept of preloading user defined libraries. In most
|
support the concept of preloading user defined libraries. In most
|
cases, you do that by specifying `LD_PRELOAD=libinproctrace.so' in
|
cases, you do that by specifying `LD_PRELOAD=libinproctrace.so' in
|
the environment. See also the description of `gdbserver''s
|
the environment. See also the description of `gdbserver''s
|
`--wrapper' command line option.
|
`--wrapper' command line option.
|
|
|
`Using GDB to force loading the agent at run time'
|
`Using GDB to force loading the agent at run time'
|
On some systems, you can force the inferior to load a shared
|
On some systems, you can force the inferior to load a shared
|
library, by calling a dynamic loader function in the inferior that
|
library, by calling a dynamic loader function in the inferior that
|
takes care of dynamically looking up and loading a shared library.
|
takes care of dynamically looking up and loading a shared library.
|
On most Unix systems, the function is `dlopen'. You'll use the
|
On most Unix systems, the function is `dlopen'. You'll use the
|
`call' command for that. For example:
|
`call' command for that. For example:
|
|
|
(gdb) call dlopen ("libinproctrace.so", ...)
|
(gdb) call dlopen ("libinproctrace.so", ...)
|
|
|
Note that on most Unix systems, for the `dlopen' function to be
|
Note that on most Unix systems, for the `dlopen' function to be
|
available, the program needs to be linked with `-ldl'.
|
available, the program needs to be linked with `-ldl'.
|
|
|
On systems that have a userspace dynamic loader, like most Unix
|
On systems that have a userspace dynamic loader, like most Unix
|
systems, when you connect to `gdbserver' using `target remote', you'll
|
systems, when you connect to `gdbserver' using `target remote', you'll
|
find that the program is stopped at the dynamic loader's entry point,
|
find that the program is stopped at the dynamic loader's entry point,
|
and no shared library has been loaded in the program's address space
|
and no shared library has been loaded in the program's address space
|
yet, including the in-process agent. In that case, before being able
|
yet, including the in-process agent. In that case, before being able
|
to use any of the fast or static tracepoints features, you need to let
|
to use any of the fast or static tracepoints features, you need to let
|
the loader run and load the shared libraries. The simplest way to do
|
the loader run and load the shared libraries. The simplest way to do
|
that is to run the program to the main procedure. E.g., if debugging a
|
that is to run the program to the main procedure. E.g., if debugging a
|
C or C++ program, start `gdbserver' like so:
|
C or C++ program, start `gdbserver' like so:
|
|
|
$ gdbserver :9999 myprogram
|
$ gdbserver :9999 myprogram
|
|
|
Start GDB and connect to `gdbserver' like so, and run to main:
|
Start GDB and connect to `gdbserver' like so, and run to main:
|
|
|
$ gdb myprogram
|
$ gdb myprogram
|
(gdb) target remote myhost:9999
|
(gdb) target remote myhost:9999
|
0x00007f215893ba60 in ?? () from /lib64/ld-linux-x86-64.so.2
|
0x00007f215893ba60 in ?? () from /lib64/ld-linux-x86-64.so.2
|
(gdb) b main
|
(gdb) b main
|
(gdb) continue
|
(gdb) continue
|
|
|
The in-process tracing agent library should now be loaded into the
|
The in-process tracing agent library should now be loaded into the
|
process; you can confirm it with the `info sharedlibrary' command,
|
process; you can confirm it with the `info sharedlibrary' command,
|
which will list `libinproctrace.so' as loaded in the process. You are
|
which will list `libinproctrace.so' as loaded in the process. You are
|
now ready to install fast tracepoints, list static tracepoint markers,
|
now ready to install fast tracepoints, list static tracepoint markers,
|
probe static tracepoints markers, and start tracing.
|
probe static tracepoints markers, and start tracing.
|
|
|
---------- Footnotes ----------
|
---------- Footnotes ----------
|
|
|
(1) If you choose a port number that conflicts with another service,
|
(1) If you choose a port number that conflicts with another service,
|
`gdbserver' prints an error message and exits.
|
`gdbserver' prints an error message and exits.
|
|
|
|
|
File: gdb.info, Node: Remote Configuration, Next: Remote Stub, Prev: Server, Up: Remote Debugging
|
File: gdb.info, Node: Remote Configuration, Next: Remote Stub, Prev: Server, Up: Remote Debugging
|
|
|
20.4 Remote Configuration
|
20.4 Remote Configuration
|
=========================
|
=========================
|
|
|
This section documents the configuration options available when
|
This section documents the configuration options available when
|
debugging remote programs. For the options related to the File I/O
|
debugging remote programs. For the options related to the File I/O
|
extensions of the remote protocol, see *note system-call-allowed:
|
extensions of the remote protocol, see *note system-call-allowed:
|
system.
|
system.
|
|
|
`set remoteaddresssize BITS'
|
`set remoteaddresssize BITS'
|
Set the maximum size of address in a memory packet to the specified
|
Set the maximum size of address in a memory packet to the specified
|
number of bits. GDB will mask off the address bits above that
|
number of bits. GDB will mask off the address bits above that
|
number, when it passes addresses to the remote target. The
|
number, when it passes addresses to the remote target. The
|
default value is the number of bits in the target's address.
|
default value is the number of bits in the target's address.
|
|
|
`show remoteaddresssize'
|
`show remoteaddresssize'
|
Show the current value of remote address size in bits.
|
Show the current value of remote address size in bits.
|
|
|
`set remotebaud N'
|
`set remotebaud N'
|
Set the baud rate for the remote serial I/O to N baud. The value
|
Set the baud rate for the remote serial I/O to N baud. The value
|
is used to set the speed of the serial port used for debugging
|
is used to set the speed of the serial port used for debugging
|
remote targets.
|
remote targets.
|
|
|
`show remotebaud'
|
`show remotebaud'
|
Show the current speed of the remote connection.
|
Show the current speed of the remote connection.
|
|
|
`set remotebreak'
|
`set remotebreak'
|
If set to on, GDB sends a `BREAK' signal to the remote when you
|
If set to on, GDB sends a `BREAK' signal to the remote when you
|
type `Ctrl-c' to interrupt the program running on the remote. If
|
type `Ctrl-c' to interrupt the program running on the remote. If
|
set to off, GDB sends the `Ctrl-C' character instead. The default
|
set to off, GDB sends the `Ctrl-C' character instead. The default
|
is off, since most remote systems expect to see `Ctrl-C' as the
|
is off, since most remote systems expect to see `Ctrl-C' as the
|
interrupt signal.
|
interrupt signal.
|
|
|
`show remotebreak'
|
`show remotebreak'
|
Show whether GDB sends `BREAK' or `Ctrl-C' to interrupt the remote
|
Show whether GDB sends `BREAK' or `Ctrl-C' to interrupt the remote
|
program.
|
program.
|
|
|
`set remoteflow on'
|
`set remoteflow on'
|
`set remoteflow off'
|
`set remoteflow off'
|
Enable or disable hardware flow control (`RTS'/`CTS') on the
|
Enable or disable hardware flow control (`RTS'/`CTS') on the
|
serial port used to communicate to the remote target.
|
serial port used to communicate to the remote target.
|
|
|
`show remoteflow'
|
`show remoteflow'
|
Show the current setting of hardware flow control.
|
Show the current setting of hardware flow control.
|
|
|
`set remotelogbase BASE'
|
`set remotelogbase BASE'
|
Set the base (a.k.a. radix) of logging serial protocol
|
Set the base (a.k.a. radix) of logging serial protocol
|
communications to BASE. Supported values of BASE are: `ascii',
|
communications to BASE. Supported values of BASE are: `ascii',
|
`octal', and `hex'. The default is `ascii'.
|
`octal', and `hex'. The default is `ascii'.
|
|
|
`show remotelogbase'
|
`show remotelogbase'
|
Show the current setting of the radix for logging remote serial
|
Show the current setting of the radix for logging remote serial
|
protocol.
|
protocol.
|
|
|
`set remotelogfile FILE'
|
`set remotelogfile FILE'
|
Record remote serial communications on the named FILE. The
|
Record remote serial communications on the named FILE. The
|
default is not to record at all.
|
default is not to record at all.
|
|
|
`show remotelogfile.'
|
`show remotelogfile.'
|
Show the current setting of the file name on which to record the
|
Show the current setting of the file name on which to record the
|
serial communications.
|
serial communications.
|
|
|
`set remotetimeout NUM'
|
`set remotetimeout NUM'
|
Set the timeout limit to wait for the remote target to respond to
|
Set the timeout limit to wait for the remote target to respond to
|
NUM seconds. The default is 2 seconds.
|
NUM seconds. The default is 2 seconds.
|
|
|
`show remotetimeout'
|
`show remotetimeout'
|
Show the current number of seconds to wait for the remote target
|
Show the current number of seconds to wait for the remote target
|
responses.
|
responses.
|
|
|
`set remote hardware-watchpoint-limit LIMIT'
|
`set remote hardware-watchpoint-limit LIMIT'
|
`set remote hardware-breakpoint-limit LIMIT'
|
`set remote hardware-breakpoint-limit LIMIT'
|
Restrict GDB to using LIMIT remote hardware breakpoint or
|
Restrict GDB to using LIMIT remote hardware breakpoint or
|
watchpoints. A limit of -1, the default, is treated as unlimited.
|
watchpoints. A limit of -1, the default, is treated as unlimited.
|
|
|
`set remote exec-file FILENAME'
|
`set remote exec-file FILENAME'
|
`show remote exec-file'
|
`show remote exec-file'
|
Select the file used for `run' with `target extended-remote'.
|
Select the file used for `run' with `target extended-remote'.
|
This should be set to a filename valid on the target system. If
|
This should be set to a filename valid on the target system. If
|
it is not set, the target will use a default filename (e.g. the
|
it is not set, the target will use a default filename (e.g. the
|
last program run).
|
last program run).
|
|
|
`set remote interrupt-sequence'
|
`set remote interrupt-sequence'
|
Allow the user to select one of `Ctrl-C', a `BREAK' or `BREAK-g'
|
Allow the user to select one of `Ctrl-C', a `BREAK' or `BREAK-g'
|
as the sequence to the remote target in order to interrupt the
|
as the sequence to the remote target in order to interrupt the
|
execution. `Ctrl-C' is a default. Some system prefers `BREAK'
|
execution. `Ctrl-C' is a default. Some system prefers `BREAK'
|
which is high level of serial line for some certain time. Linux
|
which is high level of serial line for some certain time. Linux
|
kernel prefers `BREAK-g', a.k.a Magic SysRq g. It is `BREAK'
|
kernel prefers `BREAK-g', a.k.a Magic SysRq g. It is `BREAK'
|
signal followed by character `g'.
|
signal followed by character `g'.
|
|
|
`show interrupt-sequence'
|
`show interrupt-sequence'
|
Show which of `Ctrl-C', `BREAK' or `BREAK-g' is sent by GDB to
|
Show which of `Ctrl-C', `BREAK' or `BREAK-g' is sent by GDB to
|
interrupt the remote program. `BREAK-g' is BREAK signal followed
|
interrupt the remote program. `BREAK-g' is BREAK signal followed
|
by `g' and also known as Magic SysRq g.
|
by `g' and also known as Magic SysRq g.
|
|
|
`set remote interrupt-on-connect'
|
`set remote interrupt-on-connect'
|
Specify whether interrupt-sequence is sent to remote target when
|
Specify whether interrupt-sequence is sent to remote target when
|
GDB connects to it. This is mostly needed when you debug Linux
|
GDB connects to it. This is mostly needed when you debug Linux
|
kernel. Linux kernel expects `BREAK' followed by `g' which is
|
kernel. Linux kernel expects `BREAK' followed by `g' which is
|
known as Magic SysRq g in order to connect GDB.
|
known as Magic SysRq g in order to connect GDB.
|
|
|
`show interrupt-on-connect'
|
`show interrupt-on-connect'
|
Show whether interrupt-sequence is sent to remote target when GDB
|
Show whether interrupt-sequence is sent to remote target when GDB
|
connects to it.
|
connects to it.
|
|
|
`set tcp auto-retry on'
|
`set tcp auto-retry on'
|
Enable auto-retry for remote TCP connections. This is useful if
|
Enable auto-retry for remote TCP connections. This is useful if
|
the remote debugging agent is launched in parallel with GDB; there
|
the remote debugging agent is launched in parallel with GDB; there
|
is a race condition because the agent may not become ready to
|
is a race condition because the agent may not become ready to
|
accept the connection before GDB attempts to connect. When
|
accept the connection before GDB attempts to connect. When
|
auto-retry is enabled, if the initial attempt to connect fails,
|
auto-retry is enabled, if the initial attempt to connect fails,
|
GDB reattempts to establish the connection using the timeout
|
GDB reattempts to establish the connection using the timeout
|
specified by `set tcp connect-timeout'.
|
specified by `set tcp connect-timeout'.
|
|
|
`set tcp auto-retry off'
|
`set tcp auto-retry off'
|
Do not auto-retry failed TCP connections.
|
Do not auto-retry failed TCP connections.
|
|
|
`show tcp auto-retry'
|
`show tcp auto-retry'
|
Show the current auto-retry setting.
|
Show the current auto-retry setting.
|
|
|
`set tcp connect-timeout SECONDS'
|
`set tcp connect-timeout SECONDS'
|
Set the timeout for establishing a TCP connection to the remote
|
Set the timeout for establishing a TCP connection to the remote
|
target to SECONDS. The timeout affects both polling to retry
|
target to SECONDS. The timeout affects both polling to retry
|
failed connections (enabled by `set tcp auto-retry on') and
|
failed connections (enabled by `set tcp auto-retry on') and
|
waiting for connections that are merely slow to complete, and
|
waiting for connections that are merely slow to complete, and
|
represents an approximate cumulative value.
|
represents an approximate cumulative value.
|
|
|
`show tcp connect-timeout'
|
`show tcp connect-timeout'
|
Show the current connection timeout setting.
|
Show the current connection timeout setting.
|
|
|
The GDB remote protocol autodetects the packets supported by your
|
The GDB remote protocol autodetects the packets supported by your
|
debugging stub. If you need to override the autodetection, you can use
|
debugging stub. If you need to override the autodetection, you can use
|
these commands to enable or disable individual packets. Each packet
|
these commands to enable or disable individual packets. Each packet
|
can be set to `on' (the remote target supports this packet), `off' (the
|
can be set to `on' (the remote target supports this packet), `off' (the
|
remote target does not support this packet), or `auto' (detect remote
|
remote target does not support this packet), or `auto' (detect remote
|
target support for this packet). They all default to `auto'. For more
|
target support for this packet). They all default to `auto'. For more
|
information about each packet, see *note Remote Protocol::.
|
information about each packet, see *note Remote Protocol::.
|
|
|
During normal use, you should not have to use any of these commands.
|
During normal use, you should not have to use any of these commands.
|
If you do, that may be a bug in your remote debugging stub, or a bug in
|
If you do, that may be a bug in your remote debugging stub, or a bug in
|
GDB. You may want to report the problem to the GDB developers.
|
GDB. You may want to report the problem to the GDB developers.
|
|
|
For each packet NAME, the command to enable or disable the packet is
|
For each packet NAME, the command to enable or disable the packet is
|
`set remote NAME-packet'. The available settings are:
|
`set remote NAME-packet'. The available settings are:
|
|
|
Command Name Remote Packet Related Features
|
Command Name Remote Packet Related Features
|
`fetch-register' `p' `info registers'
|
`fetch-register' `p' `info registers'
|
`set-register' `P' `set'
|
`set-register' `P' `set'
|
`binary-download' `X' `load', `set'
|
`binary-download' `X' `load', `set'
|
`read-aux-vector' `qXfer:auxv:read' `info auxv'
|
`read-aux-vector' `qXfer:auxv:read' `info auxv'
|
`symbol-lookup' `qSymbol' Detecting
|
`symbol-lookup' `qSymbol' Detecting
|
multiple threads
|
multiple threads
|
`attach' `vAttach' `attach'
|
`attach' `vAttach' `attach'
|
`verbose-resume' `vCont' Stepping or
|
`verbose-resume' `vCont' Stepping or
|
resuming multiple
|
resuming multiple
|
threads
|
threads
|
`run' `vRun' `run'
|
`run' `vRun' `run'
|
`software-breakpoint'`Z0' `break'
|
`software-breakpoint'`Z0' `break'
|
`hardware-breakpoint'`Z1' `hbreak'
|
`hardware-breakpoint'`Z1' `hbreak'
|
`write-watchpoint' `Z2' `watch'
|
`write-watchpoint' `Z2' `watch'
|
`read-watchpoint' `Z3' `rwatch'
|
`read-watchpoint' `Z3' `rwatch'
|
`access-watchpoint' `Z4' `awatch'
|
`access-watchpoint' `Z4' `awatch'
|
`target-features' `qXfer:features:read' `set architecture'
|
`target-features' `qXfer:features:read' `set architecture'
|
`library-info' `qXfer:libraries:read' `info
|
`library-info' `qXfer:libraries:read' `info
|
sharedlibrary'
|
sharedlibrary'
|
`memory-map' `qXfer:memory-map:read' `info mem'
|
`memory-map' `qXfer:memory-map:read' `info mem'
|
`read-sdata-object' `qXfer:sdata:read' `print $_sdata'
|
`read-sdata-object' `qXfer:sdata:read' `print $_sdata'
|
`read-spu-object' `qXfer:spu:read' `info spu'
|
`read-spu-object' `qXfer:spu:read' `info spu'
|
`write-spu-object' `qXfer:spu:write' `info spu'
|
`write-spu-object' `qXfer:spu:write' `info spu'
|
`read-siginfo-object'`qXfer:siginfo:read' `print $_siginfo'
|
`read-siginfo-object'`qXfer:siginfo:read' `print $_siginfo'
|
`write-siginfo-object'`qXfer:siginfo:write' `set $_siginfo'
|
`write-siginfo-object'`qXfer:siginfo:write' `set $_siginfo'
|
`threads' `qXfer:threads:read' `info threads'
|
`threads' `qXfer:threads:read' `info threads'
|
`get-thread-local- `qGetTLSAddr' Displaying
|
`get-thread-local- `qGetTLSAddr' Displaying
|
storage-address' `__thread'
|
storage-address' `__thread'
|
variables
|
variables
|
`get-thread-information-block-address'`qGetTIBAddr' Display
|
`get-thread-information-block-address'`qGetTIBAddr' Display
|
MS-Windows Thread
|
MS-Windows Thread
|
Information Block.
|
Information Block.
|
`search-memory' `qSearch:memory' `find'
|
`search-memory' `qSearch:memory' `find'
|
`supported-packets' `qSupported' Remote
|
`supported-packets' `qSupported' Remote
|
communications
|
communications
|
parameters
|
parameters
|
`pass-signals' `QPassSignals' `handle SIGNAL'
|
`pass-signals' `QPassSignals' `handle SIGNAL'
|
`hostio-close-packet'`vFile:close' `remote get',
|
`hostio-close-packet'`vFile:close' `remote get',
|
`remote put'
|
`remote put'
|
`hostio-open-packet' `vFile:open' `remote get',
|
`hostio-open-packet' `vFile:open' `remote get',
|
`remote put'
|
`remote put'
|
`hostio-pread-packet'`vFile:pread' `remote get',
|
`hostio-pread-packet'`vFile:pread' `remote get',
|
`remote put'
|
`remote put'
|
`hostio-pwrite-packet'`vFile:pwrite' `remote get',
|
`hostio-pwrite-packet'`vFile:pwrite' `remote get',
|
`remote put'
|
`remote put'
|
`hostio-unlink-packet'`vFile:unlink' `remote delete'
|
`hostio-unlink-packet'`vFile:unlink' `remote delete'
|
`noack-packet' `QStartNoAckMode' Packet
|
`noack-packet' `QStartNoAckMode' Packet
|
acknowledgment
|
acknowledgment
|
`osdata' `qXfer:osdata:read' `info os'
|
`osdata' `qXfer:osdata:read' `info os'
|
`query-attached' `qAttached' Querying remote
|
`query-attached' `qAttached' Querying remote
|
process attach
|
process attach
|
state.
|
state.
|
|
|
|
|
File: gdb.info, Node: Remote Stub, Prev: Remote Configuration, Up: Remote Debugging
|
File: gdb.info, Node: Remote Stub, Prev: Remote Configuration, Up: Remote Debugging
|
|
|
20.5 Implementing a Remote Stub
|
20.5 Implementing a Remote Stub
|
===============================
|
===============================
|
|
|
The stub files provided with GDB implement the target side of the
|
The stub files provided with GDB implement the target side of the
|
communication protocol, and the GDB side is implemented in the GDB
|
communication protocol, and the GDB side is implemented in the GDB
|
source file `remote.c'. Normally, you can simply allow these
|
source file `remote.c'. Normally, you can simply allow these
|
subroutines to communicate, and ignore the details. (If you're
|
subroutines to communicate, and ignore the details. (If you're
|
implementing your own stub file, you can still ignore the details: start
|
implementing your own stub file, you can still ignore the details: start
|
with one of the existing stub files. `sparc-stub.c' is the best
|
with one of the existing stub files. `sparc-stub.c' is the best
|
organized, and therefore the easiest to read.)
|
organized, and therefore the easiest to read.)
|
|
|
To debug a program running on another machine (the debugging
|
To debug a program running on another machine (the debugging
|
"target" machine), you must first arrange for all the usual
|
"target" machine), you must first arrange for all the usual
|
prerequisites for the program to run by itself. For example, for a C
|
prerequisites for the program to run by itself. For example, for a C
|
program, you need:
|
program, you need:
|
|
|
1. A startup routine to set up the C runtime environment; these
|
1. A startup routine to set up the C runtime environment; these
|
usually have a name like `crt0'. The startup routine may be
|
usually have a name like `crt0'. The startup routine may be
|
supplied by your hardware supplier, or you may have to write your
|
supplied by your hardware supplier, or you may have to write your
|
own.
|
own.
|
|
|
2. A C subroutine library to support your program's subroutine calls,
|
2. A C subroutine library to support your program's subroutine calls,
|
notably managing input and output.
|
notably managing input and output.
|
|
|
3. A way of getting your program to the other machine--for example, a
|
3. A way of getting your program to the other machine--for example, a
|
download program. These are often supplied by the hardware
|
download program. These are often supplied by the hardware
|
manufacturer, but you may have to write your own from hardware
|
manufacturer, but you may have to write your own from hardware
|
documentation.
|
documentation.
|
|
|
The next step is to arrange for your program to use a serial port to
|
The next step is to arrange for your program to use a serial port to
|
communicate with the machine where GDB is running (the "host" machine).
|
communicate with the machine where GDB is running (the "host" machine).
|
In general terms, the scheme looks like this:
|
In general terms, the scheme looks like this:
|
|
|
_On the host,_
|
_On the host,_
|
GDB already understands how to use this protocol; when everything
|
GDB already understands how to use this protocol; when everything
|
else is set up, you can simply use the `target remote' command
|
else is set up, you can simply use the `target remote' command
|
(*note Specifying a Debugging Target: Targets.).
|
(*note Specifying a Debugging Target: Targets.).
|
|
|
_On the target,_
|
_On the target,_
|
you must link with your program a few special-purpose subroutines
|
you must link with your program a few special-purpose subroutines
|
that implement the GDB remote serial protocol. The file
|
that implement the GDB remote serial protocol. The file
|
containing these subroutines is called a "debugging stub".
|
containing these subroutines is called a "debugging stub".
|
|
|
On certain remote targets, you can use an auxiliary program
|
On certain remote targets, you can use an auxiliary program
|
`gdbserver' instead of linking a stub into your program. *Note
|
`gdbserver' instead of linking a stub into your program. *Note
|
Using the `gdbserver' Program: Server, for details.
|
Using the `gdbserver' Program: Server, for details.
|
|
|
The debugging stub is specific to the architecture of the remote
|
The debugging stub is specific to the architecture of the remote
|
machine; for example, use `sparc-stub.c' to debug programs on SPARC
|
machine; for example, use `sparc-stub.c' to debug programs on SPARC
|
boards.
|
boards.
|
|
|
These working remote stubs are distributed with GDB:
|
These working remote stubs are distributed with GDB:
|
|
|
`i386-stub.c'
|
`i386-stub.c'
|
For Intel 386 and compatible architectures.
|
For Intel 386 and compatible architectures.
|
|
|
`m68k-stub.c'
|
`m68k-stub.c'
|
For Motorola 680x0 architectures.
|
For Motorola 680x0 architectures.
|
|
|
`sh-stub.c'
|
`sh-stub.c'
|
For Renesas SH architectures.
|
For Renesas SH architectures.
|
|
|
`sparc-stub.c'
|
`sparc-stub.c'
|
For SPARC architectures.
|
For SPARC architectures.
|
|
|
`sparcl-stub.c'
|
`sparcl-stub.c'
|
For Fujitsu SPARCLITE architectures.
|
For Fujitsu SPARCLITE architectures.
|
|
|
|
|
The `README' file in the GDB distribution may list other recently
|
The `README' file in the GDB distribution may list other recently
|
added stubs.
|
added stubs.
|
|
|
* Menu:
|
* Menu:
|
|
|
* Stub Contents:: What the stub can do for you
|
* Stub Contents:: What the stub can do for you
|
* Bootstrapping:: What you must do for the stub
|
* Bootstrapping:: What you must do for the stub
|
* Debug Session:: Putting it all together
|
* Debug Session:: Putting it all together
|
|
|
|
|
File: gdb.info, Node: Stub Contents, Next: Bootstrapping, Up: Remote Stub
|
File: gdb.info, Node: Stub Contents, Next: Bootstrapping, Up: Remote Stub
|
|
|
20.5.1 What the Stub Can Do for You
|
20.5.1 What the Stub Can Do for You
|
-----------------------------------
|
-----------------------------------
|
|
|
The debugging stub for your architecture supplies these three
|
The debugging stub for your architecture supplies these three
|
subroutines:
|
subroutines:
|
|
|
`set_debug_traps'
|
`set_debug_traps'
|
This routine arranges for `handle_exception' to run when your
|
This routine arranges for `handle_exception' to run when your
|
program stops. You must call this subroutine explicitly near the
|
program stops. You must call this subroutine explicitly near the
|
beginning of your program.
|
beginning of your program.
|
|
|
`handle_exception'
|
`handle_exception'
|
This is the central workhorse, but your program never calls it
|
This is the central workhorse, but your program never calls it
|
explicitly--the setup code arranges for `handle_exception' to run
|
explicitly--the setup code arranges for `handle_exception' to run
|
when a trap is triggered.
|
when a trap is triggered.
|
|
|
`handle_exception' takes control when your program stops during
|
`handle_exception' takes control when your program stops during
|
execution (for example, on a breakpoint), and mediates
|
execution (for example, on a breakpoint), and mediates
|
communications with GDB on the host machine. This is where the
|
communications with GDB on the host machine. This is where the
|
communications protocol is implemented; `handle_exception' acts as
|
communications protocol is implemented; `handle_exception' acts as
|
the GDB representative on the target machine. It begins by
|
the GDB representative on the target machine. It begins by
|
sending summary information on the state of your program, then
|
sending summary information on the state of your program, then
|
continues to execute, retrieving and transmitting any information
|
continues to execute, retrieving and transmitting any information
|
GDB needs, until you execute a GDB command that makes your program
|
GDB needs, until you execute a GDB command that makes your program
|
resume; at that point, `handle_exception' returns control to your
|
resume; at that point, `handle_exception' returns control to your
|
own code on the target machine.
|
own code on the target machine.
|
|
|
`breakpoint'
|
`breakpoint'
|
Use this auxiliary subroutine to make your program contain a
|
Use this auxiliary subroutine to make your program contain a
|
breakpoint. Depending on the particular situation, this may be
|
breakpoint. Depending on the particular situation, this may be
|
the only way for GDB to get control. For instance, if your target
|
the only way for GDB to get control. For instance, if your target
|
machine has some sort of interrupt button, you won't need to call
|
machine has some sort of interrupt button, you won't need to call
|
this; pressing the interrupt button transfers control to
|
this; pressing the interrupt button transfers control to
|
`handle_exception'--in effect, to GDB. On some machines, simply
|
`handle_exception'--in effect, to GDB. On some machines, simply
|
receiving characters on the serial port may also trigger a trap;
|
receiving characters on the serial port may also trigger a trap;
|
again, in that situation, you don't need to call `breakpoint' from
|
again, in that situation, you don't need to call `breakpoint' from
|
your own program--simply running `target remote' from the host GDB
|
your own program--simply running `target remote' from the host GDB
|
session gets control.
|
session gets control.
|
|
|
Call `breakpoint' if none of these is true, or if you simply want
|
Call `breakpoint' if none of these is true, or if you simply want
|
to make certain your program stops at a predetermined point for the
|
to make certain your program stops at a predetermined point for the
|
start of your debugging session.
|
start of your debugging session.
|
|
|
|
|
File: gdb.info, Node: Bootstrapping, Next: Debug Session, Prev: Stub Contents, Up: Remote Stub
|
File: gdb.info, Node: Bootstrapping, Next: Debug Session, Prev: Stub Contents, Up: Remote Stub
|
|
|
20.5.2 What You Must Do for the Stub
|
20.5.2 What You Must Do for the Stub
|
------------------------------------
|
------------------------------------
|
|
|
The debugging stubs that come with GDB are set up for a particular chip
|
The debugging stubs that come with GDB are set up for a particular chip
|
architecture, but they have no information about the rest of your
|
architecture, but they have no information about the rest of your
|
debugging target machine.
|
debugging target machine.
|
|
|
First of all you need to tell the stub how to communicate with the
|
First of all you need to tell the stub how to communicate with the
|
serial port.
|
serial port.
|
|
|
`int getDebugChar()'
|
`int getDebugChar()'
|
Write this subroutine to read a single character from the serial
|
Write this subroutine to read a single character from the serial
|
port. It may be identical to `getchar' for your target system; a
|
port. It may be identical to `getchar' for your target system; a
|
different name is used to allow you to distinguish the two if you
|
different name is used to allow you to distinguish the two if you
|
wish.
|
wish.
|
|
|
`void putDebugChar(int)'
|
`void putDebugChar(int)'
|
Write this subroutine to write a single character to the serial
|
Write this subroutine to write a single character to the serial
|
port. It may be identical to `putchar' for your target system; a
|
port. It may be identical to `putchar' for your target system; a
|
different name is used to allow you to distinguish the two if you
|
different name is used to allow you to distinguish the two if you
|
wish.
|
wish.
|
|
|
If you want GDB to be able to stop your program while it is running,
|
If you want GDB to be able to stop your program while it is running,
|
you need to use an interrupt-driven serial driver, and arrange for it
|
you need to use an interrupt-driven serial driver, and arrange for it
|
to stop when it receives a `^C' (`\003', the control-C character).
|
to stop when it receives a `^C' (`\003', the control-C character).
|
That is the character which GDB uses to tell the remote system to stop.
|
That is the character which GDB uses to tell the remote system to stop.
|
|
|
Getting the debugging target to return the proper status to GDB
|
Getting the debugging target to return the proper status to GDB
|
probably requires changes to the standard stub; one quick and dirty way
|
probably requires changes to the standard stub; one quick and dirty way
|
is to just execute a breakpoint instruction (the "dirty" part is that
|
is to just execute a breakpoint instruction (the "dirty" part is that
|
GDB reports a `SIGTRAP' instead of a `SIGINT').
|
GDB reports a `SIGTRAP' instead of a `SIGINT').
|
|
|
Other routines you need to supply are:
|
Other routines you need to supply are:
|
|
|
`void exceptionHandler (int EXCEPTION_NUMBER, void *EXCEPTION_ADDRESS)'
|
`void exceptionHandler (int EXCEPTION_NUMBER, void *EXCEPTION_ADDRESS)'
|
Write this function to install EXCEPTION_ADDRESS in the exception
|
Write this function to install EXCEPTION_ADDRESS in the exception
|
handling tables. You need to do this because the stub does not
|
handling tables. You need to do this because the stub does not
|
have any way of knowing what the exception handling tables on your
|
have any way of knowing what the exception handling tables on your
|
target system are like (for example, the processor's table might
|
target system are like (for example, the processor's table might
|
be in ROM, containing entries which point to a table in RAM).
|
be in ROM, containing entries which point to a table in RAM).
|
EXCEPTION_NUMBER is the exception number which should be changed;
|
EXCEPTION_NUMBER is the exception number which should be changed;
|
its meaning is architecture-dependent (for example, different
|
its meaning is architecture-dependent (for example, different
|
numbers might represent divide by zero, misaligned access, etc).
|
numbers might represent divide by zero, misaligned access, etc).
|
When this exception occurs, control should be transferred directly
|
When this exception occurs, control should be transferred directly
|
to EXCEPTION_ADDRESS, and the processor state (stack, registers,
|
to EXCEPTION_ADDRESS, and the processor state (stack, registers,
|
and so on) should be just as it is when a processor exception
|
and so on) should be just as it is when a processor exception
|
occurs. So if you want to use a jump instruction to reach
|
occurs. So if you want to use a jump instruction to reach
|
EXCEPTION_ADDRESS, it should be a simple jump, not a jump to
|
EXCEPTION_ADDRESS, it should be a simple jump, not a jump to
|
subroutine.
|
subroutine.
|
|
|
For the 386, EXCEPTION_ADDRESS should be installed as an interrupt
|
For the 386, EXCEPTION_ADDRESS should be installed as an interrupt
|
gate so that interrupts are masked while the handler runs. The
|
gate so that interrupts are masked while the handler runs. The
|
gate should be at privilege level 0 (the most privileged level).
|
gate should be at privilege level 0 (the most privileged level).
|
The SPARC and 68k stubs are able to mask interrupts themselves
|
The SPARC and 68k stubs are able to mask interrupts themselves
|
without help from `exceptionHandler'.
|
without help from `exceptionHandler'.
|
|
|
`void flush_i_cache()'
|
`void flush_i_cache()'
|
On SPARC and SPARCLITE only, write this subroutine to flush the
|
On SPARC and SPARCLITE only, write this subroutine to flush the
|
instruction cache, if any, on your target machine. If there is no
|
instruction cache, if any, on your target machine. If there is no
|
instruction cache, this subroutine may be a no-op.
|
instruction cache, this subroutine may be a no-op.
|
|
|
On target machines that have instruction caches, GDB requires this
|
On target machines that have instruction caches, GDB requires this
|
function to make certain that the state of your program is stable.
|
function to make certain that the state of your program is stable.
|
|
|
You must also make sure this library routine is available:
|
You must also make sure this library routine is available:
|
|
|
`void *memset(void *, int, int)'
|
`void *memset(void *, int, int)'
|
This is the standard library function `memset' that sets an area of
|
This is the standard library function `memset' that sets an area of
|
memory to a known value. If you have one of the free versions of
|
memory to a known value. If you have one of the free versions of
|
`libc.a', `memset' can be found there; otherwise, you must either
|
`libc.a', `memset' can be found there; otherwise, you must either
|
obtain it from your hardware manufacturer, or write your own.
|
obtain it from your hardware manufacturer, or write your own.
|
|
|
If you do not use the GNU C compiler, you may need other standard
|
If you do not use the GNU C compiler, you may need other standard
|
library subroutines as well; this varies from one stub to another, but
|
library subroutines as well; this varies from one stub to another, but
|
in general the stubs are likely to use any of the common library
|
in general the stubs are likely to use any of the common library
|
subroutines which `GCC' generates as inline code.
|
subroutines which `GCC' generates as inline code.
|
|
|
|
|
File: gdb.info, Node: Debug Session, Prev: Bootstrapping, Up: Remote Stub
|
File: gdb.info, Node: Debug Session, Prev: Bootstrapping, Up: Remote Stub
|
|
|
20.5.3 Putting it All Together
|
20.5.3 Putting it All Together
|
------------------------------
|
------------------------------
|
|
|
In summary, when your program is ready to debug, you must follow these
|
In summary, when your program is ready to debug, you must follow these
|
steps.
|
steps.
|
|
|
1. Make sure you have defined the supporting low-level routines
|
1. Make sure you have defined the supporting low-level routines
|
(*note What You Must Do for the Stub: Bootstrapping.):
|
(*note What You Must Do for the Stub: Bootstrapping.):
|
`getDebugChar', `putDebugChar',
|
`getDebugChar', `putDebugChar',
|
`flush_i_cache', `memset', `exceptionHandler'.
|
`flush_i_cache', `memset', `exceptionHandler'.
|
|
|
2. Insert these lines near the top of your program:
|
2. Insert these lines near the top of your program:
|
|
|
set_debug_traps();
|
set_debug_traps();
|
breakpoint();
|
breakpoint();
|
|
|
3. For the 680x0 stub only, you need to provide a variable called
|
3. For the 680x0 stub only, you need to provide a variable called
|
`exceptionHook'. Normally you just use:
|
`exceptionHook'. Normally you just use:
|
|
|
void (*exceptionHook)() = 0;
|
void (*exceptionHook)() = 0;
|
|
|
but if before calling `set_debug_traps', you set it to point to a
|
but if before calling `set_debug_traps', you set it to point to a
|
function in your program, that function is called when `GDB'
|
function in your program, that function is called when `GDB'
|
continues after stopping on a trap (for example, bus error). The
|
continues after stopping on a trap (for example, bus error). The
|
function indicated by `exceptionHook' is called with one
|
function indicated by `exceptionHook' is called with one
|
parameter: an `int' which is the exception number.
|
parameter: an `int' which is the exception number.
|
|
|
4. Compile and link together: your program, the GDB debugging stub for
|
4. Compile and link together: your program, the GDB debugging stub for
|
your target architecture, and the supporting subroutines.
|
your target architecture, and the supporting subroutines.
|
|
|
5. Make sure you have a serial connection between your target machine
|
5. Make sure you have a serial connection between your target machine
|
and the GDB host, and identify the serial port on the host.
|
and the GDB host, and identify the serial port on the host.
|
|
|
6. Download your program to your target machine (or get it there by
|
6. Download your program to your target machine (or get it there by
|
whatever means the manufacturer provides), and start it.
|
whatever means the manufacturer provides), and start it.
|
|
|
7. Start GDB on the host, and connect to the target (*note Connecting
|
7. Start GDB on the host, and connect to the target (*note Connecting
|
to a Remote Target: Connecting.).
|
to a Remote Target: Connecting.).
|
|
|
|
|
|
|
File: gdb.info, Node: Configurations, Next: Controlling GDB, Prev: Remote Debugging, Up: Top
|
File: gdb.info, Node: Configurations, Next: Controlling GDB, Prev: Remote Debugging, Up: Top
|
|
|
21 Configuration-Specific Information
|
21 Configuration-Specific Information
|
*************************************
|
*************************************
|
|
|
While nearly all GDB commands are available for all native and cross
|
While nearly all GDB commands are available for all native and cross
|
versions of the debugger, there are some exceptions. This chapter
|
versions of the debugger, there are some exceptions. This chapter
|
describes things that are only available in certain configurations.
|
describes things that are only available in certain configurations.
|
|
|
There are three major categories of configurations: native
|
There are three major categories of configurations: native
|
configurations, where the host and target are the same, embedded
|
configurations, where the host and target are the same, embedded
|
operating system configurations, which are usually the same for several
|
operating system configurations, which are usually the same for several
|
different processor architectures, and bare embedded processors, which
|
different processor architectures, and bare embedded processors, which
|
are quite different from each other.
|
are quite different from each other.
|
|
|
* Menu:
|
* Menu:
|
|
|
* Native::
|
* Native::
|
* Embedded OS::
|
* Embedded OS::
|
* Embedded Processors::
|
* Embedded Processors::
|
* Architectures::
|
* Architectures::
|
|
|
|
|
File: gdb.info, Node: Native, Next: Embedded OS, Up: Configurations
|
File: gdb.info, Node: Native, Next: Embedded OS, Up: Configurations
|
|
|
21.1 Native
|
21.1 Native
|
===========
|
===========
|
|
|
This section describes details specific to particular native
|
This section describes details specific to particular native
|
configurations.
|
configurations.
|
|
|
* Menu:
|
* Menu:
|
|
|
* HP-UX:: HP-UX
|
* HP-UX:: HP-UX
|
* BSD libkvm Interface:: Debugging BSD kernel memory images
|
* BSD libkvm Interface:: Debugging BSD kernel memory images
|
* SVR4 Process Information:: SVR4 process information
|
* SVR4 Process Information:: SVR4 process information
|
* DJGPP Native:: Features specific to the DJGPP port
|
* DJGPP Native:: Features specific to the DJGPP port
|
* Cygwin Native:: Features specific to the Cygwin port
|
* Cygwin Native:: Features specific to the Cygwin port
|
* Hurd Native:: Features specific to GNU Hurd
|
* Hurd Native:: Features specific to GNU Hurd
|
* Neutrino:: Features specific to QNX Neutrino
|
* Neutrino:: Features specific to QNX Neutrino
|
* Darwin:: Features specific to Darwin
|
* Darwin:: Features specific to Darwin
|
|
|
|
|
File: gdb.info, Node: HP-UX, Next: BSD libkvm Interface, Up: Native
|
File: gdb.info, Node: HP-UX, Next: BSD libkvm Interface, Up: Native
|
|
|
21.1.1 HP-UX
|
21.1.1 HP-UX
|
------------
|
------------
|
|
|
On HP-UX systems, if you refer to a function or variable name that
|
On HP-UX systems, if you refer to a function or variable name that
|
begins with a dollar sign, GDB searches for a user or system name
|
begins with a dollar sign, GDB searches for a user or system name
|
first, before it searches for a convenience variable.
|
first, before it searches for a convenience variable.
|
|
|
|
|
File: gdb.info, Node: BSD libkvm Interface, Next: SVR4 Process Information, Prev: HP-UX, Up: Native
|
File: gdb.info, Node: BSD libkvm Interface, Next: SVR4 Process Information, Prev: HP-UX, Up: Native
|
|
|
21.1.2 BSD libkvm Interface
|
21.1.2 BSD libkvm Interface
|
---------------------------
|
---------------------------
|
|
|
BSD-derived systems (FreeBSD/NetBSD/OpenBSD) have a kernel memory
|
BSD-derived systems (FreeBSD/NetBSD/OpenBSD) have a kernel memory
|
interface that provides a uniform interface for accessing kernel virtual
|
interface that provides a uniform interface for accessing kernel virtual
|
memory images, including live systems and crash dumps. GDB uses this
|
memory images, including live systems and crash dumps. GDB uses this
|
interface to allow you to debug live kernels and kernel crash dumps on
|
interface to allow you to debug live kernels and kernel crash dumps on
|
many native BSD configurations. This is implemented as a special `kvm'
|
many native BSD configurations. This is implemented as a special `kvm'
|
debugging target. For debugging a live system, load the currently
|
debugging target. For debugging a live system, load the currently
|
running kernel into GDB and connect to the `kvm' target:
|
running kernel into GDB and connect to the `kvm' target:
|
|
|
(gdb) target kvm
|
(gdb) target kvm
|
|
|
For debugging crash dumps, provide the file name of the crash dump
|
For debugging crash dumps, provide the file name of the crash dump
|
as an argument:
|
as an argument:
|
|
|
(gdb) target kvm /var/crash/bsd.0
|
(gdb) target kvm /var/crash/bsd.0
|
|
|
Once connected to the `kvm' target, the following commands are
|
Once connected to the `kvm' target, the following commands are
|
available:
|
available:
|
|
|
`kvm pcb'
|
`kvm pcb'
|
Set current context from the "Process Control Block" (PCB) address.
|
Set current context from the "Process Control Block" (PCB) address.
|
|
|
`kvm proc'
|
`kvm proc'
|
Set current context from proc address. This command isn't
|
Set current context from proc address. This command isn't
|
available on modern FreeBSD systems.
|
available on modern FreeBSD systems.
|
|
|
|
|
File: gdb.info, Node: SVR4 Process Information, Next: DJGPP Native, Prev: BSD libkvm Interface, Up: Native
|
File: gdb.info, Node: SVR4 Process Information, Next: DJGPP Native, Prev: BSD libkvm Interface, Up: Native
|
|
|
21.1.3 SVR4 Process Information
|
21.1.3 SVR4 Process Information
|
-------------------------------
|
-------------------------------
|
|
|
Many versions of SVR4 and compatible systems provide a facility called
|
Many versions of SVR4 and compatible systems provide a facility called
|
`/proc' that can be used to examine the image of a running process
|
`/proc' that can be used to examine the image of a running process
|
using file-system subroutines. If GDB is configured for an operating
|
using file-system subroutines. If GDB is configured for an operating
|
system with this facility, the command `info proc' is available to
|
system with this facility, the command `info proc' is available to
|
report information about the process running your program, or about any
|
report information about the process running your program, or about any
|
process running on your system. `info proc' works only on SVR4 systems
|
process running on your system. `info proc' works only on SVR4 systems
|
that include the `procfs' code. This includes, as of this writing,
|
that include the `procfs' code. This includes, as of this writing,
|
GNU/Linux, OSF/1 (Digital Unix), Solaris, Irix, and Unixware, but not
|
GNU/Linux, OSF/1 (Digital Unix), Solaris, Irix, and Unixware, but not
|
HP-UX, for example.
|
HP-UX, for example.
|
|
|
`info proc'
|
`info proc'
|
`info proc PROCESS-ID'
|
`info proc PROCESS-ID'
|
Summarize available information about any running process. If a
|
Summarize available information about any running process. If a
|
process ID is specified by PROCESS-ID, display information about
|
process ID is specified by PROCESS-ID, display information about
|
that process; otherwise display information about the program being
|
that process; otherwise display information about the program being
|
debugged. The summary includes the debugged process ID, the
|
debugged. The summary includes the debugged process ID, the
|
command line used to invoke it, its current working directory, and
|
command line used to invoke it, its current working directory, and
|
its executable file's absolute file name.
|
its executable file's absolute file name.
|
|
|
On some systems, PROCESS-ID can be of the form `[PID]/TID' which
|
On some systems, PROCESS-ID can be of the form `[PID]/TID' which
|
specifies a certain thread ID within a process. If the optional
|
specifies a certain thread ID within a process. If the optional
|
PID part is missing, it means a thread from the process being
|
PID part is missing, it means a thread from the process being
|
debugged (the leading `/' still needs to be present, or else GDB
|
debugged (the leading `/' still needs to be present, or else GDB
|
will interpret the number as a process ID rather than a thread ID).
|
will interpret the number as a process ID rather than a thread ID).
|
|
|
`info proc mappings'
|
`info proc mappings'
|
Report the memory address space ranges accessible in the program,
|
Report the memory address space ranges accessible in the program,
|
with information on whether the process has read, write, or
|
with information on whether the process has read, write, or
|
execute access rights to each range. On GNU/Linux systems, each
|
execute access rights to each range. On GNU/Linux systems, each
|
memory range includes the object file which is mapped to that
|
memory range includes the object file which is mapped to that
|
range, instead of the memory access rights to that range.
|
range, instead of the memory access rights to that range.
|
|
|
`info proc stat'
|
`info proc stat'
|
`info proc status'
|
`info proc status'
|
These subcommands are specific to GNU/Linux systems. They show
|
These subcommands are specific to GNU/Linux systems. They show
|
the process-related information, including the user ID and group
|
the process-related information, including the user ID and group
|
ID; how many threads are there in the process; its virtual memory
|
ID; how many threads are there in the process; its virtual memory
|
usage; the signals that are pending, blocked, and ignored; its
|
usage; the signals that are pending, blocked, and ignored; its
|
TTY; its consumption of system and user time; its stack size; its
|
TTY; its consumption of system and user time; its stack size; its
|
`nice' value; etc. For more information, see the `proc' man page
|
`nice' value; etc. For more information, see the `proc' man page
|
(type `man 5 proc' from your shell prompt).
|
(type `man 5 proc' from your shell prompt).
|
|
|
`info proc all'
|
`info proc all'
|
Show all the information about the process described under all of
|
Show all the information about the process described under all of
|
the above `info proc' subcommands.
|
the above `info proc' subcommands.
|
|
|
`set procfs-trace'
|
`set procfs-trace'
|
This command enables and disables tracing of `procfs' API calls.
|
This command enables and disables tracing of `procfs' API calls.
|
|
|
`show procfs-trace'
|
`show procfs-trace'
|
Show the current state of `procfs' API call tracing.
|
Show the current state of `procfs' API call tracing.
|
|
|
`set procfs-file FILE'
|
`set procfs-file FILE'
|
Tell GDB to write `procfs' API trace to the named FILE. GDB
|
Tell GDB to write `procfs' API trace to the named FILE. GDB
|
appends the trace info to the previous contents of the file. The
|
appends the trace info to the previous contents of the file. The
|
default is to display the trace on the standard output.
|
default is to display the trace on the standard output.
|
|
|
`show procfs-file'
|
`show procfs-file'
|
Show the file to which `procfs' API trace is written.
|
Show the file to which `procfs' API trace is written.
|
|
|
`proc-trace-entry'
|
`proc-trace-entry'
|
`proc-trace-exit'
|
`proc-trace-exit'
|
`proc-untrace-entry'
|
`proc-untrace-entry'
|
`proc-untrace-exit'
|
`proc-untrace-exit'
|
These commands enable and disable tracing of entries into and exits
|
These commands enable and disable tracing of entries into and exits
|
from the `syscall' interface.
|
from the `syscall' interface.
|
|
|
`info pidlist'
|
`info pidlist'
|
For QNX Neutrino only, this command displays the list of all the
|
For QNX Neutrino only, this command displays the list of all the
|
processes and all the threads within each process.
|
processes and all the threads within each process.
|
|
|
`info meminfo'
|
`info meminfo'
|
For QNX Neutrino only, this command displays the list of all
|
For QNX Neutrino only, this command displays the list of all
|
mapinfos.
|
mapinfos.
|
|
|
|
|