The debugger sometimes prints strange function names for given
addresses. For instance, with the following source code...
4 procedure Foo is
5 A : Integer;
6 begin
7 Do_Nothing (A'Address);
8 end Foo;
... we can see...
(gdb) info line 5
Line 5 of "foo.adb" starts at address 0x4017ca <_ada_foo+6>
and ends at 0x4017d2 <_fu29__system__scalar_values__is_is4+7>.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
_fu29__system__scalar_values__is_is4 is an artificial symbol
generated by the linker, and interferes with the pc-to-symbol
resolution. There isn't much in the general minimal_symbol
data that could help us identify them, so this patch changes
the COFF reader to simply ignore them.
gdb/ChangeLog:
* coffread.c (is_import_fixup_symbol): New function.
(record_minimal_symbol): Use is_import_fixup_symbol to
detect import fixup symbols, and discard them.
gdb/testsuite/ChangeLog:
* gdb.ada/win_fu_syms: New testcase.
GDB currently sends a qTStatus even if the target previously replied
an empty packet to a previous qTStatus. If the target doesn't
recognize the packet, there's no point in trying again.
The machinery we have in place is packet_ok, which has the nice side
effect of forcing one to install a configuration command/knob for the
packet in question, which is often handy when you need to debug
things, and/or emulate a target that doesn't support the packet, or even,
it can be used as workaround for the old broken kgdb's that return error
to qTSTatus instead of an empty packet.
gdb/
2013-03-28 Pedro Alves <palves@redhat.com>
* NEWS (New options): New section.
(New options): Mention set/show remote trace-status-packet.
* remote.c (PACKET_qTStatus): New enumeration value.
(remote_get_trace_status): Skip sending qTStatus if the packet is
disabled. Use packet_ok.
(_initialize_remote): Register a configuration command for
qTStatus packet.
gdb/doc/
2013-03-28 Pedro Alves <palves@redhat.com>
* gdb.texinfo (Remote Configuration) <set remote @var{name}-packet
table>: Add entry for "trace-status".
(compute_symtab_includes): Remove unnecessary forward declaration.
(die_needs_namespace): Add comment marking group of functions for
dwarf2 name computation.
(ppc64_elf_check_relocs): Separate dynrel counts for local syms
into ifunc and non-ifunc.
(dec_dynrel_count): Pass in sym rather than sym_sec. Handle
separate ifunc/non-ifunc dynrel counts.
(allocate_got): Always use reliplt for ifunc.
(allocate_dynrelocs): Likewise.
(ppc64_elf_size_dynamic_sections): Likewise.
(ppc64_elf_layout_multitoc): Likewise.
(ppc64_elf_relocate_section): Likewise.
Currently, "set listsize -1" is supposed to mean "unlimited" source
lines, but, alas, it doesn't actually work:
(gdb) set listsize -1
(gdb) show listsize
Number of source lines gdb will list by default is unlimited.
(gdb) list 1
(gdb) list 1
(gdb) list 1
(gdb) set listsize 10
(gdb) list 1
1 /* Main function for CLI gdb.
2 Copyright (C) 2002-2013 Free Software Foundation, Inc.
3
4 This file is part of GDB.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
10
Before this patch:
http://sourceware.org/ml/gdb-patches/2012-08/msg00367.html
was applied, the "set listsize" command was a var_integer command, and
"unlimited" was set with 0. Internally, var_integer maps 0 to INT_MAX
case var_integer:
{
...
if (val == 0 && c->var_type == var_integer)
val = INT_MAX;
The change in that patch to zuinteger_unlimited command, meant that -1
is left as -1 in the command's control variable (lines_to_list), and
the code in source.c isn't expecting that -- it only expects positive
numbers.
I previously suggested fixing the code and keeping the new behavior,
but I found that "set listsize 0" is currently used in the wild, and
we do have a bunch of other commands where "0" means unlimited, so I'm
thinking that changing this command alone in isolation is not a good
idea.
So I now strongly prefer reverting back the behavior in 7.6 to the
same behavior the command has had since 2006 (0==unlimited, -1=error).
Before that, set listsize -1 would be accepted as unlimited as well.
After 7.6 is out, in mainline, we can get back to reconsidering
changing this command's behavior, if there's a real need for being
able to suppress output. For now, let's play it safe.
The "list line 1 with unlimited listsize" test in list.exp was
originally written years and years ago expecting 0 to mean "no
output", but GDB never actually worked that way, even when the tests
were written, so the tests had been xfailed then. This patch now
adjusts the test to the new behavior, so that the test actually
passes, and the xfail is removed.
gdb/
2013-03-28 Pedro Alves <palves@redhat.com>
PR gdb/15294
* source.c (_initialize_source): Change back "set listsize" to an
integer command.
gdb/testsuite/
2013-03-28 Pedro Alves <palves@redhat.com>
PR gdb/15294
* gdb.base/list.exp (set_listsize): Adjust to accept $arg == 0 to
mean unlimited instead of $arg < 0.
(test_listsize): Remove "listsize of 0 suppresses output" test.
Test that "set listsize 0" ends up with an unlimited listsize.
gdb/doc/
2013-03-28 Pedro Alves <palves@redhat.com>
PR gdb/15294
* gdb.texinfo (List) <set listsize>: Adjust to document that
listsize 0 means no limit, and remove mention of -1.
The previous patch actually wasn't the first time I had to update line
numbers in this file.
This avoids hard coding line numbers, hopefully making the next time a
little easier.
Tested on x86_64 Fedora 17.
gdb/testsuite/
2013-03-28 Pedro Alves <palves@redhat.com>
* gdb.base/list.exp (last_line): New global.
(last_line_re): New global.
(test_listsize, test_list_function, test_list_forward)
(test_repeat_list_command, test_list_range)
(test_list_filename_and_function): Use them.
* gdb.base/list0.c: Comment the last line of the file with "last
line".
The "set listsize -1" test in list.exp can't work correct anymore
nowadays, because the test's source files grew over time, and this
particular test was never updated.
This fixes it in the obvious way.
gdb/testsuite/
2013-03-28 Pedro Alves <palves@redhat.com>
* gdb.base/list.exp (test_listsize): Adjust test to make sure we
list the whole file.
Before the changes starting at
<http://sourceware.org/ml/gdb-patches/2012-08/msg00020.html>, the 'set
listsize' command only accepted "0" as special value, meaning
"unlimited". The testsuite actually tried "set listsize -1" and
expected that to mean unlimited too.
If you tried testing list.exp at the time of that patch above,
you'd get:
(gdb) PASS: gdb.base/list.exp: list line 10 with listsize 100
set listsize 0
(gdb) PASS: gdb.base/list.exp: setting listsize to 0 #6
show listsize
Number of source lines gdb will list by default is unlimited.
(gdb) PASS: gdb.base/list.exp: show listsize unlimited #6
list 1
1 #include "list0.h"
2
...
42 /* Not used for anything */
43 }
(gdb) PASS: gdb.base/list.exp: listsize of 0 suppresses output
set listsize -1
integer 4294967295 out of range
(gdb) PASS: gdb.base/list.exp: setting listsize to -1 #7
show listsize
Number of source lines gdb will list by default is unlimited.
(gdb) PASS: gdb.base/list.exp: show listsize unlimited #7
list 1
1 #include "list0.h"
Notice that "set listsize -1" actually failed with "integer 4294967295
out of range", but we issued a PASS anyway.
(and notice how the "listsize of 0 suppresses output" test passes bogusly too.)
This patch fixes that testsuite problem in the obvious way.
gdb/testsuite/
2013-03-28 Pedro Alves <palves@redhat.com>
* gdb.base/list.exp (set_listsize): Use gdb_test_no_output for
"set listsize".
* tic6x-opcode-table.h: Fix patterns for add, ldnw and xor.
* gas/tic6x/insns16-lsd-unit.s: Correct bit patterns for mvk, add
and xor.
* gas/tic6x/insns16-lsd-unit.d: Update expected output.
(ppc_elf_check_relocs): Separate dynrel counts for local syms
into ifunc and non-ifunc.
(allocate_dynrelocs): Always put ifunc relocs into reliplt.
(ppc_elf_size_dynamic_sections): Likewise.
(ppc_elf_relocate_section): Likewise.
masks for all local ifunc syms.
(allocate_dynrelocs): Don't use htab->relgot for ifunc.
(ppc_elf_size_dynamic_sections): Likewise.
(ppc_elf_relocate_section): Likewise.
The whole readline interface is signed, and works with the 0..INT_MAX
range.
We don't allow setting the size to UINT_MAX directly. The documented
user visible interface is "use 0 for unlimited". The UINT_MAX
representation is an implementation detail we could change, e.g., by
keeping a separate flag for "unlimited", which is actually what the
readline interface does (stifled vs non stifled). Generically
speaking, exposing this detail to clients of the interface may make
our lives complicated when we find the need to extend the range of
some command in the future, and it's better if users
(frontends/scripts) aren't relying on anything but what we tell them
to use for "unlimited". Making values other than 0 error out is the
way to prevent users from using those ranges inappropriately. Quite
related, note:
(gdb) set history size 0xffffffff
integer 4294967295 out of range
But,
(gdb) set history size 0xfffffffe
(gdb) show history size
The size of the command history is unlimited.
(gdb) set history size 0x100000000
integer 4294967296 out of range
If values over INT_MAX are accepted as unlimited, then there's no good
argument for only accepting [INT_MAX..UINT_MAX) as valid "unlimited"
magic numbers, while not accepting [UINT_MAX..inf).
Making the setting's control variable of different type (unsigned int)
of the rest of the related code (int) adds the need to recall that one
variable among all these is unsigned, and that one need to think about
whether these comparisons are signed or unsigned, along with the
promotion/conversion rules. Since this is an easy to forget detail,
this patch renames the variable to at least make it more obvious that
this variable is not one of GNU history's public int variables, which
are all signed. We don't actually need the only code that presently
is affected by this, though, the code that is computing the current
history's length. We can just use GNU history's history_length
instead:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Variable: int history_length
The number of entries currently stored in the history list.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/* Return the history entry which is logically at OFFSET in the history array.
OFFSET is relative to history_base. */
HIST_ENTRY *
history_get (offset)
int offset;
{
int local_index;
local_index = offset - history_base;
return (local_index >= history_length || local_index < 0 || the_history == 0)
? (HIST_ENTRY *)NULL
: the_history[local_index];
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
At the time this code was added (gdb 4.13 ~1994), 'history_length' was
extern, but not documented in readline's GNU history documents, so I
guess it wasn't considered public then and the loop was the
workaround.
One of the warts of GDB choosing 0 to mean unlimited is that "set
history size 0" behaves differently from 'HISTSIZE=0 gdb'. The latter
leaves GDB with no history, while the former means "unlimited"...
$ HISTSIZE=0 ./gdb
...
(gdb) show history size
The size of the command history is 0.
We shouldn't really change what HISTSIZE=0 means, as bash, etc. also
handle 0 as real zero, and zero it's what really makes sense.
gdb/
2013-03-27 Pedro Alves <palves@redhat.com>
* top.c (history_size): Rename to ...
(history_size_setshow_var): ... this. Add comment.
(show_commands): Use readline's 'history_length' instead of
computing the history length by calling history_get in a loop.
(set_history_size_command): Error out for sizes over INT_MAX.
Restore previous history size on invalid size.
(init_history): If HISTSIZE is negative, leave the history size as
zero. Add comments.
(init_main): Adjust.
2013-03-20 Will Newton <will.newton@linaro.org>
* elf32-arm.c (elf32_arm_final_link_relocate): Avoid emitting a
dynamic reloc for symbols with dynindx == -1.
(allocate_dynrelocs_for_symbol): Avoid allocating space for a
dynamic reloc for symbols with dynindx == -1.
2013-03-20 Will Newton <will.newton@linaro.org>
* elf32-arm.c (elf32_arm_final_link_relocate): Avoid emitting a
dynamic reloc for symbols with dynindx == -1.
(allocate_dynrelocs_for_symbol): Avoid allocating space for a
dynamic reloc for symbols with dynindx == -1.
Hyphens are much more common than underscores in command names.
gdb/
2013-03-27 Pedro Alves <palves@redhat.com>
* coff-pe-read.c (_initialize_coff_pe_read): Rename "set debug
coff_pe_read" command to "set debug coff-pe-read".
The "set tcp connect-timeout" variable is unsigned:
/* Timeout period for connections, in seconds. */
static unsigned int tcp_retry_limit = 15;
And used like:
/* Check for timeout. */
if (*polls > tcp_retry_limit * POLL_INTERVAL)
{
errno = ETIMEDOUT;
return -1;
}
Which made me stop and look over why is it that 'polls' is signed.
What I found is there's really no reason.
gdb/
2013-03-26 Pedro Alves <palves@redhat.com>
* ser-tcp.c (wait_for_connect): Make 'polls' parameter unsigned.
(net_open): Make 'polls' local unsigned.
It makes no sense to talk about an "unlimited" address size in this
context.
(gdb) show remoteaddresssize
The maximum size of the address (in bits) in a memory packet is 0.
(gdb) set remoteaddresssize 0
(gdb) show remoteaddresssize
The maximum size of the address (in bits) in a memory packet is unlimited.
"set remoteaddresssize 0" mapping to UINT_MAX means you can't
force gdb through this path twice in the same GDB run:
static CORE_ADDR
remote_address_masked (CORE_ADDR addr)
{
unsigned int address_size = remote_address_size;
/* If "remoteaddresssize" was not set, default to target address size. */
if (!address_size)
address_size = gdbarch_addr_bit (target_gdbarch ());
gdb/
2013-03-26 Pedro Alves <palves@redhat.com>
* remote.c (_initialize_remote): Make "set remoteaddresssize"
a zuinteger command instead of uinteger.
The "set record full insn-number-max" command is an uinteger command.
If the variable that holds the maximum count of logged instructions is
unsigned, it's better if the variable that holds the current number of
logged instructions is also unsigned. Looking over the code, there's
no case the variable could end up negative.
Then, tests like "if (record_full_insn_max_num)" are always true,
because being a uinteger command means that "set record full
insn-number-max 0" is actually mapped to UINT_MAX internally. IOW,
the command's variable is never 0. The checks might make some sense
if 0 wasn't mapped to UINT_MAX, and 0 meant unlimited, but, that's not
how things work.
Tested on x86_64 Fedora 17.
gdb/
2013-03-26 Pedro Alves <palves@redhat.com>
* record-full.c (record_full_insn_num): Make it unsigned.
(record_full_check_insn_num, record_full_message)
(record_full_registers_change, record_full_xfer_partial): Remove
record_full_insn_max_num check (it's always != 0).
(record_full_info, record_full_restore): Use %u as format string.
(): Use %u as format string.
(set_record_full_insn_max_num): Remove record_full_insn_max_num
check (it's always != 0).
It doesn't make sense to request an "unlimited" dcache. You want to
configure the cache with specific lines and length of lines.
It doesn't actually work anyway:
(gdb) set dcache line-size 0
Invalid dcache line size: 4294967295 (must be power of 2).
(gdb) set dcache size 0
(gdb) show dcache size
Number of dcache lines is unlimited.
(gdb) info dcache
Dcache 4294967295 lines of 64 bytes each.
No data cache available.
The code already has guards in place to forbid 0s:
static void
set_dcache_size (char *args, int from_tty,
struct cmd_list_element *c)
{
if (dcache_size == 0)
{
dcache_size = DCACHE_DEFAULT_SIZE;
error (_("Dcache size must be greater than 0."));
}
if (last_cache)
dcache_invalidate (last_cache);
}
static void
set_dcache_line_size (char *args, int from_tty,
struct cmd_list_element *c)
{
if (dcache_line_size < 2
|| (dcache_line_size & (dcache_line_size - 1)) != 0)
{
unsigned d = dcache_line_size;
dcache_line_size = DCACHE_DEFAULT_LINE_SIZE;
error (_("Invalid dcache line size: %u (must be power of 2)."), d);
}
if (last_cache)
dcache_invalidate (last_cache);
}
So we now get:
(gdb) set dcache line-size 0
Invalid dcache line size: 0 (must be power of 2).
(gdb) set dcache size 0
Dcache size must be greater than 0.
gdb/
2013-03-26 Pedro Alves <palves@redhat.com>
* dcache.c (_initialize_dcache): Make the "set dcache line-size"
and "set dcache size" commands zuinteger instead of uinteger.