While handling "vFile:pread:" packets, gdbserver would read the
number of bytes requested regardless of whether this would fit
into the reply packet. gdbserver would then return a packet's
worth of data and discard the remainder. When accessing large
binaries GDB (via BFD) routinely makes large "vFile:pread:"
requests, resulting in gdbserver allocating large unnecessary
buffers and reading some portions of the file many times over.
This commit causes gdbserver to limit the number of bytes to be
read to a sensible maximum prior to allocating buffers and reading
data.
gdb/gdbserver/ChangeLog:
* hostio.c (handle_pread): Do not attempt to read more data
than hostio_reply_with_data can fit in a packet.
If a symbol is defined with ".symver foo,foo@VER", the assembler
creates two symbols in the object: one unversioned, and one with
the (non-default) version "VER". If foo is listed in a version
script, gold would then make the first of those symbols the
default version, and would ignore the second symbol as a
duplicate, without making it a non-default version. While this is
arguably reasonable behavior, it doesn't match Gnu ld behavior,
so this patch fixes that by allowing the second definition to
override the first by resetting the "default version" indication.
Several test cases from the Gnu ld testsuite also exposed another
related problem, where a symbol defined with ".symver foo,foo@",
placed into a shared library, is not handled properly by gold.
This patch also fixes that case, binding the symbol to the base
version.
gold/
PR gold/18703
* dynobj.cc (Versions::record_version): Handle symbol defined with
base version.
(Versions::symbol_section_contents): Likewise.
* symtab.h (Symbol::set_is_not_default): New class method.
(Symbol_table::resolve): Add is_default_version parameter.
(Symbol_table::should_override): Likewise.
* resolve.cc (Symbol_table::resolve): Add is_default_version parameter,
and pass to should_override. Adjust all callers and explicit
instantiations.
(Symbol_table::should_override): Add is_default_value parameter;
allow default version in a dynamic object to override existing
definition from same object.
* symtab.cc (Symbol_table::add_from_object): Handle case where same
symbol is defined as unversioned and non-default version in the same
object.
* testsuite/Makefile.am (ver_test_13): New test case.
* testsuite/Makefile.in: Regenerate.
* testsuite/ver_test_4.cc: Add test for symbol with base version.
* testsuite/ver_test_4.sh: Likewise.
* testsuite/ver_test_13.c: New source file.
* testsuite/ver_test_13.script: New version script.
* testsuite/ver_test_13.sh: New test case.
On some older versions of GNU/Linux, gdbserver now fails to build
due to an undefined reference to NT_ARM_VFP. Same issue on Android,
where this macros is undefined until Android API level 21 (Android
5.0 "Lollipop").
This patch modifies linux-aarch32-low.c to define that macros when
not already defined.
gdb/gdbserver/ChangeLog:
* linux-aarch32-low.c (NT_ARM_VFP): Define if not already defined.
2015-08-18 Sandra Loosemore <sandra@codesourcery.com>
gdb/
* remote.c (strprefix): New.
(remote_parse_stop_reply): Use strprefix instead of strncmp
to ensure exact match of keyword.
In commit 18989b3c56 I broke the creation
of gdb's info manual; I added a new section without adding a suitable
menu entry.
This commit adds the missing menu entry and fixes the build of gdb's
info manual.
gdb/doc/ChangeLog:
* gdb.texinfo (GDB Files): Add 'File Caching' menu entry.
This patch done two types of cleanup:
* in aarch64_reloc_got_type and elfNN_aarch64_relocate_section
We don't need those redundant "case" check, as they can be merged
with the "default" which just "break".
* in elfNN_aarch64_gc_sweep_hook and elfNN_aarch64_check_relocs
All TLS local executable relocations and some local dynamic
relocations (those calculate module offset) actually don't need GOT
entry, so remove them from GOT entry counting.
2015-08-18 Jiong Wang <jiong.wang@arm.com>
bfd/
* elfnn-aarch64.c (aarch64_reloc_got_type): Delete useless check.
(elfNN_aarch64_relocate_section): Likewise.
(elfNN_aarch64_gc_sweep_hook): Likewise.
(elfNN_aarch64_check_relocs): Likewise.
This patch adds a new debug flag bfd-cache, which when set to non-zero
produces debugging log messages relating to gdb's bfd cache.
gdb/ChangeLog:
* gdb_bfd.c (debug_bfd_cache): New variable.
(show_bfd_cache_debug): New function.
(gdb_bfd_open): Add debug logging.
(gdb_bfd_ref): Likewise.
(gdb_bfd_unref): Likewise.
(_initialize_gdb_bfd): Add new set/show command.
* NEWS: Mention new command.
gdb/doc/ChangeLog:
* gdb.texinfo (File Caching): Document "set/show debug bfd-cache".
In some rare maintainer cases it is desirable to be able to disable bfd
sharing. This patch adds new commands maintenance set/show commands for
bfd-sharing, allowing gdb's bfd cache to be turned off.
gdb/ChangeLog:
* gdb_bfd.c (bfd_sharing): New variable.
(show_bfd_sharing): New function.
(gdb_bfd_open): Check bfd_sharing variable.
(_initialize_gdb_bfd): Add new set/show command.
* NEWS: Mention new command.
gdb/doc/ChangeLog:
* gdb.texinfo (Maintenance Commands): Move documentation of "main
info bfds" to...
(File Caching): A New section. Outline bfd caching, and add new
description for "main set/show bfd-sharing".
Within gdb open bfd objects are reused where possible if an attempt is
made to reopen a file that is already being debugged. To spot if the on
disc file has changed gdb currently examines the mtime of the file and
compares it to the mtime of the open bfd in the cache.
A problem exists when the on disc file is being rapidly regenerated, as
happens, for example, with automated testing. In some cases the file is
generated so quickly that the mtime appears not to change, while the on
disc file has changed.
This patch extends the bfd cache to also hold the file size of the file,
the inode of the file, and the device id of the file; gdb can then
compare filename, file size, mtime, inode, and device id to determine if
an existing bfd object can be reused.
gdb/ChangeLog:
* gdb_bfd.c (struct gdb_bfd_data): Add size, inode, and device id
field.
(struct gdb_bfd_cache_search): Likewise.
(eq_bfd): Compare the size, inode, and device id fields.
(gdb_bfd_open): Initialise the size, inode, and device id fields.
(gdb_bfd_ref): Likewise.
(gdb_bfd_unref): Likewise.
Markus reported that ASNS breaks target record-btrace. In particular,
the gdb.btrace/multi-thread-step.exp test fails (both with BTS and PT
tracing) with a crash in py-inferior.c:
Program received signal SIGSEGV, Segmentation fault.
0x00000000006aa40d in add_thread_object (tp=0x27d32d0)
at /users/mmetzger/team/gdb/git/gdb/python/py-inferior.c:337
337 entry->next = inf_obj->threads;
My machine doesn't support BTS nor PT, so I missed this...
Disabling ASNS temporarily on x86 until this is addressed.
Tested on x86_64 Fedora 20.
gdb/ChangeLog:
2015-08-18 Pedro Alves <palves@redhat.com>
* linux-nat.c (linux_nat_always_non_stop_p): If the linux_ops
target implements to_always_non_stop_p, call it.
* x86-linux-nat.c (x86_linux_always_non_stop_p): New function.
(x86_linux_create_target): Install it as to_always_non_stop_p
method.
bfd/
* elf64-ppc.c (ppc64_elf_func_desc_adjust): Don't redefine .TOC.
if already defined, and set linker_def.
(ppc64_elf_set_toc): Use .TOC. value if defined other than by
the backend.
ld/
* ldexp.c (exp_fold_tree_1): Clear linker_def on symbol assignment.
In D, all named enums are explicitly scoped (the C++ equivalent of enum class)
so they should be handled as such in the language-specific symbol lookup
routines. However so as to support D compilers that don't emit enums as
DW_AT_enum_class, need to make sure that appropriate checks for
TYPE_DECLARED_CLASS are done.
gdb/ChangeLog
* d-exp.y (type_aggregate_p): New function.
(PrimaryExpression : TypeExp '.' IdentifierExp): Use it.
(classify_inner_name): Likewise.
* d-namespace.c (d_lookup_nested_symbol): Handle TYPE_CODE_ENUM.
One of the build slaves shows this error running explicit.exp:
(gdb) strace -m gdbfoobarbaz
Remote failure reply: E.In-process agent library not loaded in process.
Fast and static tracepoints unavailable.
(gdb) FAIL: gdb.linespec/explicit.exp: strace -m gdbfoobarbaz
There are two big problems with this test:
1) The expected output is actually not what the test is meant to test for.
2) This test should really only run where it is supported.
This is most easily fixed by moving the test to gdb.trace/strace.exp.
gdb/testsuite/ChangeLog
* gdb.linespec/explicit.exp: Move strace test from here ...
* gdb.trace/strace.exp: ... to here.
HJ recently removed trailing space in binutils files, but unfortunately
they return when regenerating files in opcodes. This fixes the regen
process.
* cgen.sh: Trim trailing space from cgen output.
* ia64-gen.c (print_dependency_table): Don't generate trailing space.
(print_dis_table): Likewise.
* opc2c.c (dump_lines): Likewise.
(orig_filename): Warning fix.
* ia64-asmtab.c: Regenerate.
Invoking either of the above commands on an inferior that's not running
triggers the following assert failure:
.../binutils-gdb/gdb/thread.c:514: internal-error: any_thread_of_process: Assertion `pid != 0' failed.
The fix is straightforward. This patch also adds a test to check the
basic functionality of these commands, along with testing this fix in
particular. Tested on x86_64 Linux.
gdb/ChangeLog:
* inferior.c (detach_inferior_command): Don't call
any_thread_of_process when pid is 0.
(kill_inferior_command): Likewise.
gdb/testsuite/ChangeLog:
* gdb.base/kill-detach-inferiors-cmd.exp: New test file.
* gdb.base/kill-detach-inferiors-cmd.c: New test file.
The "source centric" /m option to the disassemble command is often
unhelpful, e.g., in the presence of optimized code.
This patch adds a /s modifier that is better.
For one, /m only prints instructions from the originating source file,
leaving out instructions from e.g., inlined functions from other files.
gdb/ChangeLog:
PR gdb/11833
* NEWS: Document new /s modifier for the disassemble command.
* cli/cli-cmds.c (disassemble_command): Add support for /s.
(_initialize_cli_cmds): Update online docs of disassemble command.
* disasm.c: #include "source.h".
(struct deprecated_dis_line_entry): Renamed from dis_line_entry.
All uses updated.
(dis_line_entry): New struct.
(hash_dis_line_entry, eq_dis_line_entry): New functions.
(allocate_dis_line_table): New functions.
(maybe_add_dis_line_entry, line_has_code_p): New functions.
(dump_insns): New arg end_pc. All callers updated.
(do_mixed_source_and_assembly_deprecated): Renamed from
do_mixed_source_and_assembly. All callers updated.
(do_mixed_source_and_assembly): New function.
(gdb_disassembly): Handle /s (DISASSEMBLY_SOURCE).
* disasm.h (DISASSEMBLY_SOURCE_DEPRECATED): Renamed from
DISASSEMBLY_SOURCE. All uses updated.
(DISASSEMBLY_SOURCE): New macro.
* mi/mi-cmd-disas.c (mi_cmd_disassemble): New modes 4,5.
gdb/doc/ChangeLog:
* gdb.texinfo (Machine Code): Update docs for mixed source/assembly
disassembly.
(GDB/MI Data Manipulation): Update docs for new disassembly modes.
gdb/testsuite/ChangeLog:
* gdb.mi/mi-disassemble.exp: Update.
* gdb.base/disasm-optim.S: New file.
* gdb.base/disasm-optim.c: New file.
* gdb.base/disasm-optim.h: New file.
* gdb.base/disasm-optim.exp: New file.
A recent patch introduced a variable named `typename' into d-exp.y,
and one of the --enable-with-cxx build slaves consequently failed to compile
this. This patch simply adds an underscore into the name to avoid the
reserved word.
gdb/ChangeLog
* d-exp.y (PrimaryExpression : TypeExp '.' IdentifierExp): Rename
`typename' to `type_name' to avoid C++ reserved word.
The locations patch I recently committed contains macro definitions
such as:
This causes an ARI error to be emitted by the server ("Do not use PTR, ISO C
90 implies `void *'"). While this ARI error is bogus in this context,
it is just easiest to squash the error completely by renaming the macro
parameters.
gdb/ChangeLog
* location.c (EL_TYPE, EL_LINESPEC, EL_PROBE, EL_ADDRESS)
(EL_EXPLICIT, EL_STRING): Change macro parameter to "P" to
silence ARI errors.
For some time now, GDB has permitted target-side evaluation of
breakpoint conditions. On targets that support this feature, GDB
may output an "evaluated-by" field into the breakpoint reply.
This patch adds handling for this option, and outputs a default
pattern to optionally recognize (and ignore) this pattern in the
reply.
gdb/testsuite/ChangeLog
* lib/mi-support.exp (mi_make_breakpoint): Add option/handling for
"evaluated-by".
This fixes four ARI warnings found in d-exp.y.
This is comprised of three uses of the && or || at the end of a line, and one
use of sprintf.
gdb/ChangeLog
* d-exp.y (PrimaryExpression : TypeExp '.' IdentifierExp): Use
xstrprintf instead of malloc and sprintf.
(PrimaryExpression : IdentifierExp): Avoid operator at end of line.
(lex_one_token): Likewise.
This tag allows debugging of MIPS position independent executables
and provides access to shared library information.
gdb/gdbserver/
* linux-low.c (get_r_debug): Handle DT_MIPS_RLD_MAP_REL.
gdb/
* solib-svr4.c (read_program_header): Add base_addr argument to
report the runtime address of the segment.
(find_program_interpreter): Update read_program_header call to pass
a NULL pointer for the new argument.
(scan_dyntag): Add ptr_addr argument to report the runtime address
of the tag payload.
(scan_dyntag_auxv): Likewise and use thew new base_addr argument of
read_program_header to get the base address of the dynamic segment.
(elf_locate_base): Update uses of scan_dyntag, scan_dyntag_auxv and
read_program_header.
(elf_locate_base): Scan for and handle DT_MIPS_RLD_MAP_REL.
This makes it so that alternating '.' and identifier tokens are resolved to
symbols as early as possible, which should all the addition of D properties -
such as EXP.sizeof and EXP.typeof - without the shift/reduce conflicts that
would occur in the current parsing strategy.
gdb/ChangeLog
* d-exp.y (%union): Add voidval.
(%token): Add UNKNOWN_NAME as a token to represent an unclassified
name in the lexing stage.
(PostfixExpression): Move symbol completion handling in grammar here
from PrimaryExpression.
(PrimaryExpression): Move routines to handle resolving identifier
tokens in the grammar here from push_expression_name.
(IdentifierExp): Remove the handling of alternating '.' and identifier
tokens.
(TypeExp): Allow TypeExp to be wrapped in parenthesis in the grammar.
(BasicType): Remove C-style typename rules.
(d_type_from_name, d_module_from_name, push_variable)
(push_fieldnames, push_type_name, push_module_name)
(push_expression_name): Remove.
(lex_one_token): Rename from yylex. Replace pstate with par_state.
(token_and_value): New type.
(token_fifo, popping, name_obstack): New globals.
(classify_name): New function.
(classify_inner_name): Likewise.
(yylex): Likewise.
(d_parse): Initialize token_fifo, popping and name_obstack.
In D, there is the notion of modules, and importing from one to the other,
whether it is a basic, selective or renamed import declaration.
module A;
import X;
void foo() {
import Y : bar;
}
If the compiler emits DW_TAG_imported_declaration at the appropriate locations,
then we can make use of what gdb stores in using_direct when performing
nonlocal symbol lookups.
gdb/ChangeLog
* Makefile.in (SFILES): Add d-namespace.c.
(COMMON_OBS): Add d-namespace.o.
* d-lang.c (d_language_defn): Use d_lookup_symbol_nonlocal as the
la_lookup_symbol_nonlocal callback function pointer.
* d-lang.h (d_lookup_symbol_nonlocal): New declaration.
(d_lookup_nested_symbol): New declaration.
* d-namespace.c: New file.
Valgrind shows:
==17026== Invalid write of size 8
==17026== at 0x54AA80: pending_frame_invalidate (py-unwind.c:477)
==17026== by 0x5AB934: do_my_cleanups (cleanups.c:155)
==17026== by 0x5AB9AF: do_cleanups (cleanups.c:177)
==17026== by 0x54B009: pyuw_sniffer (py-unwind.c:606)
==17026== by 0x755DAC: frame_unwind_try_unwinder (frame-unwind.c:105)
==17026== by 0x755EEE: frame_unwind_find_by_frame (frame-unwind.c:160)
==17026== by 0x750FFA: compute_frame_id (frame.c:454)
==17026== by 0x753BD6: get_prev_frame_if_no_cycle (frame.c:1781)
==17026== by 0x754292: get_prev_frame_always_1 (frame.c:1955)
==17026== by 0x7542DA: get_prev_frame_always (frame.c:1971)
==17026== by 0x7547BE: get_prev_frame (frame.c:2213)
==17026== by 0x7532BD: unwind_to_current_frame (frame.c:1450)
==17026== Address 0xd27b570 is 16 bytes inside a block of size 32 free'd
==17026== at 0x4A07577: free (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==17026== by 0x54B276: gdb_Py_DECREF (python-internal.h:185)
==17026== by 0x54B298: py_decref (py-utils.c:34)
==17026== by 0x5AB934: do_my_cleanups (cleanups.c:155)
==17026== by 0x5AB9AF: do_cleanups (cleanups.c:177)
==17026== by 0x54B009: pyuw_sniffer (py-unwind.c:606)
==17026== by 0x755DAC: frame_unwind_try_unwinder (frame-unwind.c:105)
==17026== by 0x755EEE: frame_unwind_find_by_frame (frame-unwind.c:160)
==17026== by 0x750FFA: compute_frame_id (frame.c:454)
==17026== by 0x753BD6: get_prev_frame_if_no_cycle (frame.c:1781)
==17026== by 0x754292: get_prev_frame_always_1 (frame.c:1955)
==17026== by 0x7542DA: get_prev_frame_always (frame.c:1971)
==17026==
Simply invalidate the object before releasing it.
gdb/ChangeLog:
2015-08-13 Pedro Alves <palves@redhat.com>
* python/py-unwind.c (pyuw_sniffer): Install the invalidate
cleanup after the decref cleanup, not before.