The implementation is pretty straightforward, with the only caveat being
that the "src", "cmd", "next" and "prev" entries get delibrately added
to the completion list even when the TUI has not yet been initialized
(i.e. has never been enabled during the session), since invoking the
"focus" command with these arguments already works when the TUI has not
yet been initialized.
gdb/ChangeLog:
* tui/tui-win.c (focus_completer): New static function.
(_initialize_tui_win): Set the completion function of the
"focus" command to focus_completer.
gdb/testsuite/ChangeLog:
* gdb.base/completion.exp: Test the completion of the "focus"
command.
GDB tries to skip prologue for .S files according to .debug_line but it then
places the breakpoint to a location where it is never hit.
This is because #defines in .S files cause prologue skipping which is
completely inappropriate, for s390x:
glibc/sysdeps/unix/syscall-template.S
78:/* This is a "normal" system call stub: if there is an error,
79: it returns -1 and sets errno. */
80:
81:T_PSEUDO (SYSCALL_SYMBOL, SYSCALL_NAME, SYSCALL_NARGS)
82: ret
00000000000f4210 T __select
Line Number Statements:
Extended opcode 2: set Address to 0xf41c8
Advance Line by 80 to 81
Copy
Advance PC by 102 to 0xf422e
Special opcode 6: advance Address by 0 to 0xf422e and Line by 1 to 82
Special opcode 34: advance Address by 2 to 0xf4230 and Line by 1 to 83
Advance PC by 38 to 0xf4256
Extended opcode 1: End of Sequence
Compilation Unit @ offset 0x28b3e0:
<0><28b3eb>: Abbrev Number: 1 (DW_TAG_compile_unit)
<28b3ec> DW_AT_stmt_list : 0x7b439
<28b3f0> DW_AT_low_pc : 0xf41c8
<28b3f8> DW_AT_high_pc : 0xf4256
<28b400> DW_AT_name : ../sysdeps/unix/syscall-template.S
<28b423> DW_AT_comp_dir : /usr/src/debug////////glibc-2.17-c758a686/misc
<28b452> DW_AT_producer : GNU AS 2.23.52.0.1
<28b465> DW_AT_language : 32769 (MIPS assembler)
without debuginfo or with debuginfo and the fix - correct address:
(gdb) b select
Breakpoint 1 at 0xf4210
It is also where .dynsym+.symtab point to:
00000000000f4210 T __select
00000000000f4210 W select
with debuginfo, without the fix:
(gdb) b select
Breakpoint 1 at 0xf41c8: file ../sysdeps/unix/syscall-template.S, line 81.
One part is to behave for asm files similar way like for 'locations_valid':
/* Symtab has been compiled with both optimizations and debug info so that
GDB may stop skipping prologues as variables locations are valid already
at function entry points. */
unsigned int locations_valid : 1;
The other part is to extend the 'locations_valid'-like functionality more.
Both minsym_found and find_function_start_sal need to be patched, otherwise
their addresses do not match and GDB regresses on ppc64:
gdb/ChangeLog
2015-06-26 Jan Kratochvil <jan.kratochvil@redhat.com>
* linespec.c (minsym_found): Reset sal.PC for COMPUNIT_LOCATIONS_VALID
and language_asm..
* symtab.c (find_function_start_sal): Likewise.
gdb/testsuite/ChangeLog
2015-06-26 Jan Kratochvil <jan.kratochvil@redhat.com>
* gdb.arch/amd64-prologue-skip.S: New file.
* gdb.arch/amd64-prologue-skip.exp: New file.
_bfd_elf_assign_file_positions_for_non_load will set the sh_size
field for .shstrtab section. There is need to initialize it in
_bfd_elf_compute_section_file_positions.
* elf.c (_bfd_elf_compute_section_file_positions): Don't
initialize sh_size for .shstrtab here.
Since not all ELF targets support -shared, we limit ld-elf/strtab to
linux and gnu targets.
* ld-elf/strtab.d: Only run on *-*-linux* and *-*-gnu* targets.
This patch uses ELF strtab with GC and suffix merging support to create
ELF .strtab section. There is some small memory overhead to use ELF
strtab:
==14928== HEAP SUMMARY:
==14928== in use at exit: 3,276,318 bytes in 679 blocks
==14928== total heap usage: 1,544 allocs, 865 frees, 15,259,146 bytes allocated
vs.
==14936== HEAP SUMMARY:
==14936== in use at exit: 3,276,318 bytes in 679 blocks
==14936== total heap usage: 1,532 allocs, 853 frees, 15,026,402 bytes allocated
when running:
./ld-new -m elf_x86_64 -o tmpdir/ld-partial.o -r ldgram.o ldlex-wrapper.o lexsup.o ldlang.o mri.o ldctor.o ldmain.o plugin.o ldwrite.o ldexp.o ldemul.o ldver.o ldmisc.o ldfile.o ldcref.o eelf_x86_64.o eelf32_x86_64.o eelf_i386.o eelf_iamcu.o ei386linux.o eelf_l1om.o eelf_k1om.o ldbuildid.o
The results are
[32] .strtab STRTAB 0+ 3beff8 00407a 00 0 0 1
vs
[32] .strtab STRTAB 0+ 3beff8 0041d8 00 0 0 1
It reduces the .strtab size by 350 bytes, about 2%
Saving on libc.so from glibc is much more since libc.so has many alias
symbols with the same suffix. For x32 glibc,
[82] .strtab STRTAB 0+ 81b348 0159e7 00 0 0 1
vs
[82] .strtab STRTAB 0+ 81b8bc 019e72 00 0 0 1
It reduces the .strtab size by 17547 bytes, about 16%.
bfd/
PR gas/18451
* elf-bfd.h (elf_sym_strtab): New.
(elf_link_hash_table): Add strtabcount, strtabsize and
strtab.
(_bfd_elf_stringtab_init): Removed.
* elf.c (_bfd_elf_stringtab_init): Removed.
(_bfd_elf_compute_section_file_positions): Replace
bfd_strtab_hash/_bfd_elf_stringtab_init/_bfd_stringtab_free/
_bfd_stringtab_size with
elf_strtab_hash/_bfd_elf_strtab_init/_bfd_elf_strtab_free/
_bfd_elf_strtab_size. Use _bfd_elf_strtab_add,
_bfd_elf_strtab_finalize and _bfd_elf_strtab_offset to get
st_name.
(swap_out_syms): Likewise.
* elflink.c (elf_final_link_info): Replace bfd_strtab_hash
with elf_strtab_hash. Remove symbuf, symbuf_count,
symbuf_size and shndxbuf_size.
(elf_link_flush_output_syms): Removed.
(elf_link_output_sym): Renamed to ...
(elf_link_output_symstrtab): This. Replace _bfd_stringtab_add
with _bfd_elf_strtab_add. Don't flush symbols to the file nor
swap out symbols.
(elf_link_swap_symbols_out): New.
(elf_link_output_extsym): Replace elf_link_output_sym with
elf_link_output_symstrtab.
(elf_link_input_bfd): Likewise.
(elf_final_link_free): Replace _bfd_stringtab_free with
_bfd_elf_strtab_free. Remove symbuf.
(bfd_elf_final_link): Replace _bfd_elf_stringtab_init with
_bfd_elf_strtab_init. Don't set symbuf, symbuf_count,
symbuf_size nor shndxbuf_size. Initialize strtabsize and
strtab. Initialize symshndxbuf to -1 when number of sections
>= 64K. Replace elf_link_output_sym/elf_link_output_sym with
elf_link_output_symstrtab/elf_link_output_symstrtab. Don't
call elf_link_flush_output_syms. Call _bfd_elf_strtab_finalize
and elf_link_swap_symbols_out. Replace _bfd_stringtab_size
and _bfd_stringtab_emit with _bfd_elf_strtab_size and
_bfd_elf_strtab_emit.
gas/testsuite/
PR gas/18451
* gas/elf/elf.exp: Run strtab.
* gas/elf/strtab.d: New file.
* gas/elf/strtab.s: Likewise.
ld/testsuite/
PR gas/18451
* ld-elf/strtab.d: New file.
* ld-elf/strtab.s: Likewise.
Some parts of solib_find_1 should only operate if the sysroot
is nonempty after processing, but the logic that checked this
happened before trailing slashes were stripped so empty but
non-NULL sysroots were possible. This commit moves the logic
so it correctly notices all empty sysroots.
gdb/ChangeLog:
* solib.c (solib_find_1): Set local variable sysroot to NULL if
it is the empty string after trailing slashes have been stripped.
Commit 2f0c68f23b added an extra @section
.cfi_lsda:
@subsection @code{.cfi_lsda @var{encoding} [, @var{exp}]}
+@section @code{.cfi_lsda @var{encoding} [, @var{exp}]}
@code{.cfi_lsda} defines LSDA and its encoding.
It shouldn't be there.
* doc/as.texinfo (.cfi_lsda): Remove the extra @section.
Valgrind reports memory leaking from build_id_to_debug_bfd:
==7261== 88 bytes in 2 blocks are definitely lost in loss record 31,319 of 35,132
==7261== at 0x4A06BCF: malloc (vg_replace_malloc.c:296)
==7261== by 0x32CA88A9B9: strdup (strdup.c:42)
==7261== by 0xFE62AB: lrealpath (lrealpath.c:88)
==7261== by 0x7F7AD6: build_id_to_debug_bfd (build-id.c:116)
==7261== by 0x7F7BB5: find_separate_debug_file_by_buildid (build-id.c:149)
==7261== by 0x6D9382: elf_symfile_read (elfread.c:1348)
==7261== by 0x777F02: read_symbols (symfile.c:875)
==7261== by 0x778505: syms_from_objfile_1 (symfile.c:1078)
==7261== by 0x778548: syms_from_objfile (symfile.c:1094)
==7261== by 0x778746: symbol_file_add_with_addrs (symfile.c:1191)
==7261== by 0x77893B: symbol_file_add_from_bfd (symfile.c:1280)
==7261== by 0x8E51E3: solib_read_symbols (solib.c:706)
==7261== by 0x8E58AF: solib_add (solib.c:1029)
This occurs because commit 1be5090b in bfd, addressing PR 11983, started
taking a copy of the input filename instead of directly caching it. It
appears that this code was never updated to reflect that API change.
This simple patch creates a cleanup to free the return value for lrealpath.
gdb/ChangeLog
* build-id.c (build_id_to_debug_bfd): Add cleanup to free
return value from lrealpath.
Since the .plt section and DT_PLTGOT are used by prelink to undo
prelinking for dynamic relocations, we must keep them even if there is
no PLT relocation. This patch reverted commit a3747075a.
bfd/
* elf32-i386.c (elf_i386_allocate_dynrelocs): Always allocate
space for the first .plt entry.
(elf_i386_size_dynamic_sections): Always add DT_PLTGOT for .plt
section. Add DT_PLTRELSZ, DT_PLTREL and DT_JMPREL only if
there are PLT relocations.
* elf64-x86-64.c (elf_x86_64_allocate_dynrelocs): Always
allocate space for the first .plt entry.
(elf_x86_64_size_dynamic_sections): Always add DT_PLTGOT for
.plt section. Add DT_PLTRELSZ, DT_PLTREL and DT_JMPREL only if
there are PLT relocations.
ld/testsuite/
* ld-i386/i386.exp: Run pltgot-2 for Linux targets.
* ld-x86-64/x86-64.exp: Likewise.
* ld-i386/pltgot-1.d: Updated.
* ld-x86-64/pltgot-1.d: Likewise.
* ld-i386/pltgot-2.d: New file.
* ld-x86-64/pltgot-2.d: Likewise.
When converting "mov foo@GOTPCREL(%rip), %reg" to "lea foo(%rip), %reg"
with R_X86_64_PC32 relocation, it may overflow if the target section
is more than 2GB away. This patch estimates distance between mov
instruction and the target section. We convert R_X86_64_GOTPCREL to
R_X86_64_PC32 only if their distance is less than 2GB.
PR ld/18591
* elf64-x86-64.c (elf_x86_64_convert_mov_to_lea): Don't convert
R_X86_64_GOTPCREL to R_X86_64_PC32 if it will cause relocation
overflow.
The bfin/msp430 ports already had trace logic set up for reading/writing
cpu registers, albeit using different unrelated levels (core & vpu). Add
a proper register class for these and for other ports.
The default gdb sysroot now sets itself to "target:". This works for
most remote targets, but when using the simulator, this causes problems
as the sim will attempt to search for that path.
Update the remote-sim logic to skip this leading prefix when it is found
so that the sysroot isn't passed in as an invalid value.
linux_get_siginfo_type is installed to many linux gdbarch. This patch
is to move this to a common area linux-tdep.c:linux_init_abi, so that
linux_get_siginfo_type is installed to every linux gdbarch. If some
linux gdbarch needs its own version, please override it in
$ARCH_linux_init_abi. In the testsuite, we enable siginfo related
tests for all linux targets.
gdb:
2015-06-24 Yao Qi <yao.qi@linaro.org>
* aarch64-linux-tdep.c (aarch64_linux_init_abi): Don't call
set_gdbarch_get_siginfo_type.
* amd64-linux-tdep.c (amd64_linux_init_abi_common): Likewise.
* arm-linux-tdep.c (arm_linux_init_abi): Likewise.
* i386-linux-tdep.c (i386_linux_init_abi): Likewise.
* m68klinux-tdep.c (m68k_linux_init_abi): Likewise.
* ppc-linux-tdep.c (ppc_linux_init_abi): Likewise.
* s390-linux-tdep.c (s390_gdbarch_init): Likewise.
* tilegx-linux-tdep.c (tilegx_linux_init_abi): Likewise.
* linux-tdep.c (linux_get_siginfo_type): Change it to static.
(linux_init_abi): Call set_gdbarch_get_siginfo_type.
* linux-tdep.h (linux_get_siginfo_type): Remove the declaration.
gdb/testsuite:
2015-06-24 Yao Qi <yao.qi@linaro.org>
* lib/gdb.exp (supports_get_siginfo_type): Return 1 for all
linux targets.
Both siginfo-obj.exp and siginfo-thread.exp have the same code
checking the support of geting a type of siginfo for a given arch.
This patch is to move these code into a proc supports_get_siginfo_type.
gdb/testsuite:
2015-06-24 Yao Qi <yao.qi@linaro.org>
* lib/gdb.exp (supports_get_siginfo_type): New proc.
* gdb.base/siginfo-obj.exp: Invoke supports_get_siginfo_type.
* gdb.base/siginfo-thread.exp: Likewise.
stdint.h was added to common-defs.h some months ago and should
no longer be included directly by any file.
gdb_assert.h was added to common-defs.h nearly a year ago, but
three includes have crept in since then.
This commit removes all such redundant include directives.
gdb/ChangeLog:
* common/buffer.c (stdint.h): Do not include.
* common/print-utils.c (stdint.h): Likewise.
* compile/compile-c-symbols.c (gdb_assert.h): Likewise.
* compile/compile-c-types.c (gdb_assert.h): Likewise.
* ft32-tdep.c (gdb_assert.h): Likewise.
* guile/scm-utils.c (stdint.h): Likewise.
* i386-linux-tdep.c (stdint.h): Likewise.
* i386-tdep.c (stdint.h): Likewise.
* nat/linux-btrace.c (stdint.h): Likewise.
* nat/linux-btrace.h (stdint.h): Likewise.
* nat/linux-ptrace.c (stdint.h): Likewise.
* nat/mips-linux-watch.h (stdint.h): Likewise.
* ppc-linux-nat.c (stdint.h): Likewise.
* python/python-internal.h (stdint.h): Likewise.
* stub-termcap.c (stdlib.h): Likewise.
* target/target.h (stdint.h): Likewise.
* xtensa-linux-nat.c (stdint.h): Likewise.
gdb/gdbserver/ChangeLog:
* linux-i386-ipa.c (stdint.h): Do not include.
* lynx-i386-low.c (stdint.h): Likewise.
* lynx-ppc-low.c (stdint.h): Likewise.
* mem-break.c (stdint.h): Likewise.
* thread-db.c (stdint.h): Likewise.
* tracepoint.c (stdint.h): Likewise.
* win32-low.c (stdint.h): Likewise.
The test
test_histsize_history_setting "99999999999999999999999999999999999" "unlimited"
was failing on i686 because the condition in init_history() for
determining whether to map a large GDBHISTSIZE value to infinity was
long var = strtol (tmpenv);
if (var > INT_MAX)
history_size = unlimited;
but this condition is never true on i686 because INT_MAX == LONG_MAX.
So in order to properly map large out-of-range values of GDBHISTSIZE to
infinity on targets where LONG_MAX > INT_MAX as well as on i686, we have
to instead change the above condition to
if (var > INT_MAX
|| (var == INT_MAX && errno == ERANGE))
history_size = unlimited;
gdb/ChangeLog:
* top.c (init_history): Look at errno after calling strtol to
properly map large GDBHISTSIZE values to infinity.
This helper macro has largely the same behavior as libiberty's lbasename.
There is a slight nuance related to colons, but it's not clear what the
point of that is, and the code implies that it just wants the basename.
The following patch fixed the assembly / disassembly of the rfebb instruction:
https://sourceware.org/ml/binutils/2015-06/msg00190.html
This patch updates the gdb testsuite to match the new disassembly behavior.
gdb/testsuite/
* gdb.arch/powerpc-power.exp <rfebb>: Fixup test results.
* gdb.arch/powerpc-power.s <rfebb>: Likewise.
Since --trace-debug is for people hacking on the sim sources rather than
people just using the sim, default it to off. This matches the behavior
of other debug knobs we have.
have_ptrace_getregset is a tri-state variable (-1, 0, 1), and we have
some conditions like "if (have_ptrace_getregset)", which is not correct.
I'll explain why it is not correct in the following example. This fix
to this problem to replace the test (have_ptrace_getregset) to test
(have_ptrace_getregset == 1) or (have_ptrace_getregset == -1) etc.
However Doug thinks it hinders readability
https://sourceware.org/ml/gdb-patches/2015-05/msg00692.html so I decide
to add a new enum tribool and change have_ptrace_getregset to it, in
order to make these tests more readable.
have_ptrace_getregset is initialised to -1, and is adjusted to 0 or 1 in
$ARCH_linux_read_description according to the capability of the kernel.
However, it is possible that have_ptrace_getregset is used before it is
set to 0 or 1, which means it is still -1. This is shown below.
(gdb) run
Starting program: gdb/testsuite/gdb.base/break
Breakpoint 2, amd64_linux_fetch_inferior_registers (ops=0xceaa80, regcache=0xe72000, regnum=16) at git/gdb/amd64-linux-nat.c:128
128 {
top?p have_ptrace_getregset
$1 = TRIBOOL_UNKNOWN
top?c
Continuing.
Breakpoint 2, amd64_linux_fetch_inferior_registers (ops=0xceaa80, regcache=0xe72000, regnum=16) at git/gdb/amd64-linux-nat.c:128
128 {
top?c
Continuing.
Breakpoint 1, x86_linux_read_description (ops=0xceaa80) at git/gdb/x86-linux-nat.c:117
117 {
PTRACE_GETREGSET command is used even GDB doesn't know whether
PTRACE_GETREGSET is supported or not. It is wrong, but works on x86.
However it doesn't work on arm-linux if the kernel doesn't support
PTRACE_GETREGSET at all. We'll get:
(gdb) run
Starting program: gdb/testsuite/gdb.base/break
warning: Unable to fetch general register.
PC register is not available
gdb:
2015-06-23 Yao Qi <yao.qi@linaro.org>
* amd64-linux-nat.c (amd64_linux_fetch_inferior_registers):
Check whether have_ptrace_getregset is TRIBOOL_TRUE explicitly.
(amd64_linux_store_inferior_registers): Likewise.
* arm-linux-nat.c (fetch_fpregister): Likewise.
(fetch_fpregs, store_fpregister): Likewise.
(store_fpregister, store_fpregs): Likewise.
(fetch_register, fetch_regs): Likewise.
(store_register, store_regs): Likewise.
(fetch_vfp_regs, store_vfp_regs): Likewise.
(arm_linux_read_description): Check have_ptrace_getregset is
TRIBOOL_UNKNOWN. Set have_ptrace_getregset to TRIBOOL_TRUE
or TRIBOOL_FALSE.
* i386-linux-nat.c (fetch_xstateregs): Check
have_ptrace_getregset is not TRIBOOL_TRUE.
(store_xstateregs): Likewise.
* linux-nat.c (have_ptrace_getregset): Change its type to
enum tribool.
* linux-nat.h (tribool): New enum.
* x86-linux-nat.c (x86_linux_read_description): Use enum tribool.
Check whether have_ptrace_getregset is TRIBOOL_TRUE.
2015-06-23 Jiong Wang <jiong.wang@arm.com>
bfd/
* elfnn-aarch64.c (aarch64_readonly_dynrelocs): New function.
(elfNN_aarch64_size_dynamic_sections): Traverse hash table to check
relocations against read-only sections.
ld/testsuite/
* ld-aarch64/dt_textrel.s: New testcase.
* ld-aarch64/dt_textrel.d: New expectation file.
* ld-aarch64/aarch64-elf.exp: Run new testcase.
ISA 2.07 added a new category called Elemental Memory Barriers that modifies
the sync instruction to accept an additional operand ESYNC. Edmar added
support for this insruction varient here:
https://sourceware.org/ml/binutils/2012-02/msg00221.html
Looking at this closer, I see that the insert_ls() function is misnamed
(since it's attached to the ESYNC operand, not the LS operand) but more
importantly, it is silently modifying the LS operand value behind the
users back when the LS operand is either invalid or is incompatible with
the new ESYNC operand. The ISA 2.07 doc has an Assembler Note that clearly
states that assemblers that support the ESYNC operand should report all
invalid uses of LS and ESYNC. This patch changes the assembler to
error out on invalid and incompatible operand usage.
opcodes/
* ppc-opc.c (insert_ls): Test for invalid LS operands.
(insert_esync): New function.
(LS, WC): Use insert_ls.
(ESYNC): Use insert_esync.
gas/testsuite/
* gas/ppc/e6500.s <sync>: Fix invalid test.
* gas/ppc/e6500.d: Likewise.
include * dis-asm.h (struct disassemble_info): Add stop_vma field.
binuti * objdump.c (disassemble_bytes): Set the stop_vma field in the
disassemble_info structure when disassembling code sections with
-d.
* doc/binutils.texi (objdump): Document the discrepancy between -d
and -D.
opcodes * dis-buf.c (buffer_read_memory): Fail is stop_vma is set and the
requested region lies beyond it.
* bfin-dis.c (print_insn_bfin): Ignore sysop instructions when
looking for 32-bit insns.
* mcore-dis.c (print_insn_mcore): Disable stop_vma when reading
data.
* sh-dis.c (print_insn_sh): Likewise.
* tic6x-dis.c (print_insn_tic6x): Disable stop_vma when reading
blocks of instructions.
* vax-dis.c (print_insn_vax): Check that the requested address
does not clash with the stop_vma.
tests * gas/arm/backslash-at.s: Add extra .byte directives so that the
foo symbol does not appear to point half way through an
instruction.
* gas/arm/backslash-at.d: Update expected disassembly.
* gas/i386/ilp32/x86-64-opcode-inval-intel.d: Likewise.
* gas/i386/ilp32/x86-64-opcode-inval.d: Likewise.
* gas/i386/x86-64-opcode-inval-intel.d: Likewise.
* gas/i386/x86-64-opcode-inval.d: Likewise.
This commit is to add comments on using this board file and the
requirements on localhost.
gdb/testsuite:
2015-06-22 Yao Qi <yao.qi@linaro.org>
* boards/remote-gdbserver-on-localhost.exp: Add comments.
This patch is to let skip_hw_breakpoint_tests and skip_hw_watchpoint_tests
return 0 for aarch64 target, since aarch64 has HW watchpoint and
breakpoint registers.
With this patch applied, about 1560 watchpoint/breakpoint related tests
become enabled on aarch64-linux native testing.
gdb/testsuite:
2015-06-22 Yao Qi <yao.qi@linaro.org>
* lib/gdb.exp (skip_hw_breakpoint_tests): Return 0 for target
aarch64*-*-*.
(skip_hw_watchpoint_tests): Likewise.