Alan Modra [Wed, 23 Aug 2017 10:19:29 +0000 (19:49 +0930)]
ppc-opc.c formatting
* ppc-opc.c: Formatting and comment fixes. Move insert and
extract functions earlier, deleting forward declarations.
(insert_nbi, insert_raq, insert_rbx): Expand use of RT_MASK and
RA_MASK.
Alan Modra [Wed, 23 Aug 2017 06:12:12 +0000 (15:42 +0930)]
PR21990, Integer overflow in process_version_sections
This tidies some of the overflow checking when processing verneed
and verdef sections.
PR 21990
* readelf.c (process_version_sections <SHT_GNU_verneed>): Check
for invalid vn_next field before adding to idx. Use unsigned
long for index vars. Move index checks.
<SHT_GNU_verdef>: Likewise for vd_next.
Weimin Pan [Wed, 23 Aug 2017 08:57:37 +0000 (10:57 +0200)]
gdb: SPARC ADI support
The M7 processor supports an Application Data Integrity (ADI) feature
that detects invalid data accesses. When software allocates data, it
chooses a 4-bit version number, sets the version in the upper 4 bits
of the 64-bit pointer to that data, and stores the 4-bit version in
every cacheline of the object. Hardware saves the latter in spare
bits in the cache and memory hierarchy. On each load and store, the
processor compares the upper 4 VA (virtual address) bits to the
cacheline's version. If there is a mismatch, the processor generates a
version mismatch trap which can be either precise or disrupting. The
trap is an error condition which the kernel delivers to the process as
a SIGSEGV signal.
The upper 4 bits of the VA represent a version and are not part of the
true address. The processor clears these bits and sign extends bit 59
to generate the true address.
Note that 32-bit applications cannot use ADI.
This patch adds ADI support in gdb which allows the user to examine
current version tags and assign new version tags in the program. It
also catches and reports precise or disrupting memory corruption
traps.
gdb/ChangeLog:
2017-08-07 Weimin Pan <weimin.pan@oracle.com>
* sparc64-tdep.h: (adi_normalize_address): New export.
* sparc-nat.h: (open_adi_tag_fd): New export.
* sparc64-linux-nat.c: (open_adi_tag_fd): New function.
* sparc64-linux-tdep.c:
(SEGV_ACCADI, SEGV_ADIDERR, SEGV_ADIPERR) New defines.
(sparc64_linux_handle_segmentation_fault): New function.
(sparc64_linux_init_abi): Register
sparc64_linux_handle_segmentation_fault
* sparc64-tdep.c: Include cli-utils.h,gdbcmd.h,auxv.h.
(sparc64_addr_bits_remove): New function.
(sparc64_init_abi): Register sparc64_addr_bits_remove.
(MAX_PROC_NAME_SIZE): New macro.
(AT_ADI_BLKSZ, AT_ADI_NBITS, AT_ADI_UEONADI) New defines.
(sparc64adilist): New variable.
(adi_proc_list): New variable.
(find_adi_info): New function.
(add_adi_info): New function.
(get_adi_info_proc): New function.
(get_adi_info): New function.
(info_adi_command): New function.
(read_maps_entry): New function.
(adi_available): New function.
(adi_normalize_address): New function.
(adi_align_address): New function.
(adi_convert_byte_count): New function.
(adi_tag_fd): New function.
(adi_is_addr_mapped): New function.
(adi_read_versions): New function.
(adi_write_versions): New function.
(adi_print_versions): New function.
(do_examine): New function.
(do_assign): New function.
(adi_examine_command): New function.
(adi_assign_command): New function.
(_initialize_sparc64_adi_tdep): New function.
gdb/doc/ChangeLog:
2017-08-07 Weimin Pan <weimin.pan@oracle.com>
* gdb.texinfo (Architectures): Add new Sparc64 section to document
ADI support.
* NEWS: Add "adi examine" and "adi assign" commands.
gdb/testsuite/ChangeLog:
2017-08-07 Weimin Pan <weimin.pan@oracle.com>
* gdb.arch/sparc64-adi.exp: New file.
* gdb.arch/sparc64-adi.c: New file.
GDB Administrator [Wed, 23 Aug 2017 00:00:48 +0000 (00:00 +0000)]
Automatic date update in version.in
Alan Modra [Tue, 22 Aug 2017 23:28:42 +0000 (08:58 +0930)]
Remove pr19161 test hppa xfail
* testsuite/ld-gc/pr19161.d: Don't xfail hppa.
Alan Modra [Tue, 22 Aug 2017 23:28:08 +0000 (08:58 +0930)]
Make undefined symbols in allocate_dynrelocs dynamic
..if they have dynamic relocs. An undefined symbol in a PIC object
that finds no definition ought to become dynamic in order to support
--allow-shlib-undefined, but there is nothing in the generic ELF
linker code to do this if the reference isn't via the GOT or PLT. (An
initialized function pointer is an example.) So it falls to backend
code to ensure the symbol is made dynamic.
PR 21988
* elf64-ppc.c (ensure_undef_dynamic): Rename from
ensure_undefweak_dynamic. Handle undefined too.
* elf32-ppc.c (ensure_undef_dynamic): Likewise.
* elf32-hppa.c (ensure_undef_dynamic): Likewise.
(allocate_dynrelocs): Discard undefined non-default visibility
relocs first. Make undefined syms dynamic. Tidy goto.
Alan Modra [Tue, 22 Aug 2017 13:00:18 +0000 (22:30 +0930)]
Assemble powerpc vle lsp tests with -a32
-mvle isn't a valid 64-bit option.
* testsuite/gas/ppc/lsp-checks.d: Assemble with -a32.
* testsuite/gas/ppc/lsp.d: Likewise.
Simon Marchi [Tue, 22 Aug 2017 20:09:55 +0000 (22:09 +0200)]
Rename some command functions
This patch renames a few functions implementing CLI commands to follow
the style <command-name>_command, so that they are easier to search for.
gdb/ChangeLog:
* breakpoint.c (breakpoints_info): Rename to ...
(info_breakpoints_command): ... this.
(watchpoints_info): Rename to ...
(info_watchpoints_command): ... this.
(tracepoints_info): Rename to ...
(info_tracepoints_command): ... this.
(_initialize_breakpoint): Adjust.
* dcache.c (dcache_info): Rename to ...
(info_display_command): ... this.
(_initialize_dcache): Adjust.
* frame.h (args_info): Rename to ...
(info_args_command): ... this.
(locals_info): Rename to ...
(info_locals_command): ... this.
* infcmd.c (nofp_registers_info): Rename to ...
(info_registers_command): ... this.
(float_info): Rename to ...
(info_float_command): ... this.
(program_info): Rename to ...
(info_program_command): ... this.
(all_registers_info): Rename to ...
(info_all_registers_command): ... this.
(vector_info): Rename to ...
(info_vector_command): ... this.
(float_info): Rename to ...
(info_float_command): ... this.
(_initialize_infcmd): Adjust.
* inferior.h (term_info): Rename to ...
(info_terminal_command): ... this.
* inflow.c (term_info): Rename to ...
(info_terminal_command): ... this.
(_initialize_inflow): Adjust.
* infrun.c (signals_info): Rename to ...
(info_signals_command): ... this.
(_initialize_infrun): Adjust.
* objc-lang.c (classes_info): Rename to ...
(info_classes_command): ... this.
(selectors_info): Rename to ...
(info_selectors_command): ... this.
(_initialize_objc_language): Adjust.
* printcmd.c (sym_info): Rename to ...
(info_symbol_command): ... this.
(address_info): Rename to ...
(info_address_command): ... this.
(display_info): Rename to ...
(info_display_command): ... this.
(_initialize_printcmd): Adjust.
* reverse.c (bookmarks_info): Rename to ...
(info_breakpoints_command): ... this.
(_initialize_reverse): Adjust.
* ser-go32.c (dos_info): Rename to ...
(info_serial_command): ... this.
(_initialize_ser_dos): Adjust.
* skip.c (skip_info): Rename to ...
(info_skip_command): ... this.
(_initialize_step_skip): Adjust.
* source.c (line_info): Rename to ...
(info_line_command): ... this.
(source_info): Rename to ...
(info_source_command)
* stack.c (frame_info): Rename to ...
(info_frame_command): ... this.
(locals_info): Rename to ...
(info_locals_command): ... this.
(args_info): Rename to ...
(info_args_command): ... this.
(_initialize_stack): Adjust.
* symtab.c (sources_info): Rename to ...
(info_sources_command): ... this.
(variables_info): Rename to ...
(info_variables_command): ... this.
(functions_info): Rename to ...
(info_functions_command): ... this.
(types_info): Rename to ...
(info_types_command): ... this.
(_initialize_symtab): Adjust.
* target.c (target_info): Rename to ...
(info_target_command): ... this.
(initialize_targets): Adjust.
* tracepoint.c (tvariables_info): Rename to ...
(info_tvariables_command): ... this.
(scope_info): Rename to ...
(info_scope_command): ... this.
(trace_dump_actions): Adjust.
(_initialize_tracepoint): Adjust.
H.J. Lu [Tue, 22 Aug 2017 16:41:21 +0000 (09:41 -0700)]
Update PR ld/21964 tests
* testsuite/ld-elf/pr21964-1a.c (foo): Renamed to ...
(foo1): This.
* testsuite/ld-elf/pr21964-1b.c: Rewrite.
* testsuite/ld-elf/pr21964-1c.c: New file.
* testsuite/ld-elf/pr21964-2c.c: Likewise.
* testsuite/ld-elf/pr21964-2a.c (foo): Renamed to ...
(foo1): This.
* testsuite/ld-elf/pr21964-2b.c: Rewrite.
* testsuite/ld-elf/shared.exp: Update PR ld/21964 tests.
Palmer Dabbelt [Tue, 1 Aug 2017 21:13:05 +0000 (14:13 -0700)]
RISC-V: Mark "c.nop" as an alias
This fixes "-M noaliases" disassembly for "c.nop", which is an alias for
"c.addi x0, 0".
opcodes/ChangeLog
2017-08-01 Palmer Dabbelt <palmer@dabbelt.com>
* riscv-opc.c (riscv_opcodes): Mark "c.nop" as an alias.
Pedro Alves [Tue, 22 Aug 2017 13:51:18 +0000 (14:51 +0100)]
Add test for "List actual code around more than one location" change
This adds a test for the "list" command change done in
0d999a6ef0f9
("List actual code around more than one location").
gdb/ChangeLog:
2017-08-22 Pedro Alves <palves@redhat.com>
* gdb.cp/overload.exp (line_range_pattern): New procedure.
(top level): Add "list all overloads" tests.
Tom Tromey [Sun, 20 Aug 2017 04:26:20 +0000 (22:26 -0600)]
Change install_breakpoint to take a std::unique_ptr
This changes install_breakpoint to take a std::unique_ptr rvalue-ref
argument. This makes it clear that install_breakpoint takes ownership
of the pointer, and prevents bugs like the one fixed by the previous
patch.
ChangeLog
2017-08-22 Tom Tromey <tom@tromey.com>
* breakpoint.h (install_breakpoint): Update.
* breakpoint.c (add_solib_catchpoint): Update.
(install_breakpoint): Change argument to a std::unique_ptr.
(create_fork_vfork_event_catchpoint): Use std::unique_ptr.
(create_breakpoint_sal, create_breakpoint): Update.
(watch_command_1, catch_exec_command_1)
(strace_marker_create_breakpoints_sal): Use std::unique_ptr.
(add_to_breakpoint_chain): Change argument to a std::unique_ptr.
Return the breakpoint.
(set_raw_breakpoint_without_location, set_raw_breakpoint)
(new_single_step_breakpoint): Update.
* break-catch-throw.c (handle_gnu_v3_exceptions): Use
std::unique_ptr.
* break-catch-syscall.c (create_syscall_event_catchpoint): Use
std::unique_ptr.
* break-catch-sig.c (create_signal_catchpoint): Use
std::unique_ptr.
* ada-lang.c (create_ada_exception_catchpoint): Use
std::unique_ptr.
Tom Tromey [Sun, 20 Aug 2017 04:15:30 +0000 (22:15 -0600)]
Fix erroneous cleanup use in add_solib_catchpoint
I happened to notice that add_solib_catchpoint allocated the new
catchpoint with "new" but installed a cleanup using "xfree". This
patch fixes the bug by changing the function to use std::unique_ptr
instead.
ChangeLog
2017-08-22 Tom Tromey <tom@tromey.com>
* breakpoint.c (add_solib_catchpoint): Use std::unique_ptr.
Tom Tromey [Sat, 5 Aug 2017 16:40:15 +0000 (10:40 -0600)]
Change psymtab_search_name to return a unique_xmalloc_ptr
This changes psymtab_search_name to return a unique_xmalloc_ptr and
fixes up its one caller. This allows the removal of some cleanups.
ChangeLog
2017-08-22 Tom Tromey <tom@tromey.com>
* psymtab.c (psymtab_search_name): Return a unique_xmalloc_ptr.
(lookup_partial_symbol): Update.
Tom Tromey [Sat, 5 Aug 2017 16:29:56 +0000 (10:29 -0600)]
Change rewrite_source_path to return a unique_xmalloc_ptr
This changes rewrite_source_path to return a unique_xmalloc_ptr and
fixes up the callers. This allows removing some cleanups.
ChangeLog
2017-08-22 Tom Tromey <tom@tromey.com>
* source.h (rewrite_source_path): Return a unique_xmalloc_ptr.
* source.c (rewrite_source_path): Return a unique_xmalloc_ptr.
(find_and_open_source, symtab_to_fullname): Update.
* psymtab.c (psymtab_to_fullname): Update.
Tom Tromey [Thu, 3 Aug 2017 22:53:22 +0000 (16:53 -0600)]
Change gdb_realpath to return a unique_xmalloc_ptr
This changes gdb_realpath to return a unique_xmalloc_ptr and fixes up
the callers. This allows removing some cleanups. This change by
itself caused xfullpath.exp to fail; and attempting to fix that ran
into various problems (like .get() being optimized out); so this patch
also rewrites xfullpath.exp to be a C++ selftest instead.
ChangeLog
2017-08-22 Tom Tromey <tom@tromey.com>
* exec.c (exec_file_attach): Update.
* linux-thread-db.c (try_thread_db_load): Update.
* guile/scm-safe-call.c (gdbscm_safe_source_script): Update.
* utils.c (gdb_realpath): Change return type.
(gdb_realpath_keepfile): Update.
(gdb_realpath_check_trailer, gdb_realpath_tests): New functions.
(_initialize_utils): Register the new self test.
* source.c (openp): Update.
(find_and_open_source): Update.
* nto-tdep.c (nto_find_and_open_solib): Update.
* main.c (set_gdb_data_directory): Update.
(captured_main_1): Update.
* dwarf2read.c (dwarf2_get_dwz_file): Update
(dw2_map_symbol_filenames): Update.
* auto-load.c (auto_load_safe_path_vec_update): Update.
(filename_is_in_auto_load_safe_path_vec): Change type of
"filename_realp".
(auto_load_objfile_script): Update.
(file_is_auto_load_safe): Update. Use std::string.
* utils.h (gdb_realpath): Return a gdb::unique_xmalloc_ptr.
testsuite/ChangeLog
2017-08-22 Tom Tromey <tom@tromey.com>
* gdb.gdb/xfullpath.exp: Remove.
Tom Tromey [Thu, 3 Aug 2017 22:34:56 +0000 (16:34 -0600)]
Change gdb_realpath_keepfile to return a unique_xmalloc_ptr
This changes gdb_realpath_keepfile to return a unique_xmalloc_ptr, and
fixes up the callers.
ChangeLog
2017-08-22 Tom Tromey <tom@tromey.com>
* utils.c (gdb_realpath_keepfile): Return a
gdb::unique_xmalloc_ptr.
* exec.c (exec_file_attach): Update.
* utils.h (gdb_realpath_keepfile): Return a
gdb::unique_xmalloc_ptr.
Tom Tromey [Thu, 3 Aug 2017 22:32:14 +0000 (16:32 -0600)]
Change gdb_abspath to return a unique_xmalloc_ptr
This changes gdb_abspath to return a unique_xmalloc_ptr, and fixes up
the callers. This allows the removal of a cleanup, and also puts
ownership rules into the API, where they belong.
ChangeLog
2017-08-22 Tom Tromey <tom@tromey.com>
* compile/compile.c (compile_file_command): Use
gdb::unique_xmalloc_ptr, std::string.
* utils.c (gdb_abspath): Change return type.
* source.c (openp): Update.
* objfiles.c (allocate_objfile): Update.
* main.c (set_gdb_data_directory): Update.
* utils.h (gdb_abspath): Return a gdb::unique_xmalloc_ptr.
Zhouyi Zhou [Tue, 22 Aug 2017 14:32:19 +0000 (15:32 +0100)]
List actual code around more than one location
With the following C++ code:
int bar() { return 0;}
int bar(int) { return 0; }
GDB behaves as:
(gdb) list bar
file: "overload.cc", line number: 1
file: "overload.cc", line number: 2
It would be better for GDB to list the actual code around those two
locations, not just print the location. Like:
(gdb) list bar
file: "overload.cc", line number: 1
1 int bar() { return 0;}
2 int bar(int) { return 0; }
file: "overload.cc", line number: 2
1 int bar() { return 0;}
2 int bar(int) { return 0; }
That's what this this commit implements.
Tested on x86-64 GNU/Linux.
gdb/ChangeLog:
2017-08-22 Zhouyi Zhou <zhouzhouyi@gmail.com>
* cli-cmds.c (list_commands): List actual code around more than
one location.
John Baldwin [Mon, 21 Aug 2017 16:35:25 +0000 (09:35 -0700)]
Use an array type (lwpid_t[]) for the array of lwp IDs.
gdb/ChangeLog:
* fbsd-nat.c (fbsd_add_threads): Use array type for `lwps'.
John Baldwin [Mon, 21 Aug 2017 16:33:13 +0000 (09:33 -0700)]
Correct earlier ChangeLog entry for fbsd_add_threads.
Alan Modra [Mon, 21 Aug 2017 03:58:06 +0000 (13:28 +0930)]
Make __start/__stop symbols protected visibility
They can't be hidden visibility since apparently people use dlsym to
look them up.
bfd/
PR ld/21964
* elf-bfd.h (SYMBOLIC_BIND): Return TRUE for __start/__stop symbols.
* elflink.c (bfd_elf_define_start_stop): Rewrite.
ld/
PR ld/21964
* testsuite/ld-elf/pr21562a.d: Update for changed start/stop symbols.
* testsuite/ld-elf/pr21562b.d: Likewise.
* testsuite/ld-elf/pr21562c.d: Likewise.
* testsuite/ld-elf/pr21562d.d: Likewise.
* testsuite/ld-elf/pr21562e.d: Likewise.
* testsuite/ld-elf/pr21562f.d: Likewise.
* testsuite/ld-elf/pr21562g.d: Likewise.
* testsuite/ld-elf/pr21562h.d: Likewise.
* testsuite/ld-elf/pr21562i.d: Likewise.
* testsuite/ld-elf/pr21562j.d: Likewise.
* testsuite/ld-elf/pr21562k.d: Likewise.
* testsuite/ld-elf/pr21562l.d: Likewise.
* testsuite/ld-elf/pr21562m.d: Likewise.
* testsuite/ld-elf/pr21562n.d: Likewise.
* testsuite/ld-elf/sizeofa.d: Likewise.
* testsuite/ld-elf/sizeofb.d: Likewise.
* testsuite/ld-elf/startofa.d: Likewise.
* testsuite/ld-elf/startofb.d: Likewise.
* testsuite/ld-gc/pr20022.d: Likewise.
* testsuite/ld-gc/start.d: Likewise.
* testsuite/ld-elf/pr21964-1a.c: New file.
* testsuite/ld-elf/pr21964-1b.c: New file.
* testsuite/ld-elf/pr21964-2a.c: New file.
* testsuite/ld-elf/pr21964-2b.c: New file.
* testsuite/ld-elf/shared.exp: Run PR ld/21964 tests.
Alexander Fedotov [Mon, 21 Aug 2017 12:45:59 +0000 (15:45 +0300)]
[PowerPC VLE] Add LSP (Lightweight Signal Processing) instruction support
include/
* opcode/ppc.h (PPC_OPCODE_LSP): New define.
opcodes/
* ppc-opc.c (insert_evuimm2_ex0): New function.
(extract_evuimm2_ex0): Likewise.
(insert_evuimm4_ex0): Likewise.
(extract_evuimm4_ex0): Likewise.
(insert_evuimm8_ex0): Likewise.
(extract_evuimm8_ex0): Likewise.
(insert_evuimm_lt16): Likewise.
(extract_evuimm_lt16): Likewise.
(insert_rD_rS_even): Likewise.
(extract_rD_rS_even): Likewise.
(insert_off_lsp): Likewise.
(extract_off_lsp): Likewise.
(RD_EVEN): New operand.
(RS_EVEN): Likewise.
(RSQ): Adjust.
(EVUIMM_LT16): New operand.
(HTM_SI): Adjust.
(EVUIMM_2_EX0): New operand.
(EVUIMM_4): Adjust.
(EVUIMM_4_EX0): New operand.
(EVUIMM_8): Adjust.
(EVUIMM_8_EX0): New operand.
(WS): Adjust.
(VX_OFF): New operand.
(VX_LSP): New macro.
(VX_LSP_MASK): Likewise.
(VX_LSP_OFF_MASK): Likewise.
(PPC_OPCODE_LSP): Likewise.
(vle_opcodes): Add LSP opcodes.
* ppc-dis.c (ppc_mopt): Add PPC_OPCODE_LSP flag to "vle" entry.
gas/
* testsuite/gas/ppc/lsp-checks.d,
* testsuite/gas/ppc/lsp-checks.l,
* testsuite/gas/ppc/lsp-checks.s: New test.
* testsuite/gas/ppc/lsp.d,
* testsuite/gas/ppc/lsp.s: New test.
* testsuite/gas/ppc/ppc.exp: Run new tests.
Pedro Alves [Mon, 21 Aug 2017 10:34:32 +0000 (11:34 +0100)]
Handle function aliases better (PR gdb/19487, errno printing)
(Ref: https://sourceware.org/ml/gdb/2017-06/msg00048.html)
This patch improves GDB support for function aliases defined with
__attribute__ alias. For example, in the test added by this commit,
there is no reference to "func_alias" in the debug info at all, only
to "func"'s definition:
$ nm ./testsuite/outputs/gdb.base/symbol-alias/symbol-alias | grep " func"
00000000004005ae t func
00000000004005ae T func_alias
$ readelf -w ./testsuite/outputs/gdb.base/symbol-alias/symbol-alias | grep func -B 1 -A 8
<1><db>: Abbrev Number: 5 (DW_TAG_subprogram)
<dc> DW_AT_name : (indirect string, offset: 0x111): func
<e0> DW_AT_decl_file : 1
<e1> DW_AT_decl_line : 27
<e2> DW_AT_prototyped : 1
<e2> DW_AT_type : <0xf8>
<e6> DW_AT_low_pc : 0x4005ae
<ee> DW_AT_high_pc : 0xb
<f6> DW_AT_frame_base : 1 byte block: 9c (DW_OP_call_frame_cfa)
<f8> DW_AT_GNU_all_call_sites: 1
So all GDB knows about "func_alias" is from the minsym (elf symbol):
(gdb) p func_alias
$1 = {<text variable, no debug info>} 0x4005ae <func>
(gdb) ptype func_alias
type = int ()
(gdb) p func
$2 = {struct S *(void)} 0x4005ae <func>
(gdb) ptype func
type = struct S {
int field1;
int field2;
} *(void)
The result is that calling func_alias from the command line produces
incorrect results.
This is similar (though not exactly the same) to the glibc
errno/__errno_location/__GI___errno_location situation. On glibc,
errno is defined like this:
extern int *__errno_location (void);
#define errno (*__errno_location ())
with __GI___errno_location being an internal alias for
__errno_location. On my system's libc (F23), I do see debug info for
__errno_location, in the form of name vs linkage name:
<1><95a5>: Abbrev Number: 18 (DW_TAG_subprogram)
<95a6> DW_AT_external : 1
<95a6> DW_AT_name : (indirect string, offset: 0x2c26): __errno_location
<95aa> DW_AT_decl_file : 1
<95ab> DW_AT_decl_line : 24
<95ac> DW_AT_linkage_name: (indirect string, offset: 0x2c21): __GI___errno_location
<95b0> DW_AT_prototyped : 1
<95b0> DW_AT_type : <0x9206>
<95b4> DW_AT_low_pc : 0x20f40
<95bc> DW_AT_high_pc : 0x11
<95c4> DW_AT_frame_base : 1 byte block: 9c (DW_OP_call_frame_cfa)
<95c6> DW_AT_GNU_all_call_sites: 1
however that doesn't matter in practice, because GDB doesn't record
demangled names anyway, and so we end up with the exact same situation
covered by the testcase.
So the fix is to make the expression parser find a debug symbol for
the same address as the just-found minsym, when a lookup by name
didn't find a debug symbol by name. We now get:
(gdb) p func_alias
$1 = {struct S *(void)} 0x4005ae <func>
(gdb) p __errno_location
$2 = {int *(void)} 0x7ffff6e92830 <__errno_location>
I've made the test exercise variable aliases too, for completeness.
Those already work correctly, because unlike for function aliases, GCC
emits debug information for variable aliases.
Tested on GNU/Linux.
gdb/ChangeLog:
2017-08-21 Pedro Alves <palves@redhat.com>
PR gdb/19487
* c-exp.y (variable production): Handle function aliases.
* minsyms.c (msymbol_is_text): New function.
* minsyms.h (msymbol_is_text): Declare.
* symtab.c (find_function_alias_target): New function.
* symtab.h (find_function_alias_target): Declare.
gdb/testsuite/ChangeLog:
2017-08-21 Pedro Alves <palves@redhat.com>
PR gdb/19487
* gdb.base/symbol-alias.c: New.
* gdb.base/symbol-alias2.c: New.
* gdb.base/symbol-alias.exp: New.
Pedro Alves [Mon, 21 Aug 2017 10:34:32 +0000 (11:34 +0100)]
Fix type casts losing typedefs and reimplement "whatis" typedef stripping
(Ref: https://sourceware.org/ml/gdb/2017-06/msg00020.html)
Assuming int_t is a typedef to int:
typedef int int_t;
gdb currently loses this expression's typedef:
(gdb) p (int_t) 0
$1 = 0
(gdb) whatis $1
type = int
or:
(gdb) whatis (int_t) 0
type = int
or, to get "whatis" out of the way:
(gdb) maint print type (int_t) 0
...
name 'int'
code 0x8 (TYPE_CODE_INT)
...
This prevents a type printer for "int_t" kicking in, with e.g.:
(gdb) p (int_t) 0
From the manual, we can see that that "whatis (int_t) 0" command
invocation should have printed "type = int_t":
If @var{arg} is a variable or an expression, @code{whatis} prints its
literal type as it is used in the source code. If the type was
defined using a @code{typedef}, @code{whatis} will @emph{not} print
the data type underlying the @code{typedef}.
(...)
If @var{arg} is a type name that was defined using @code{typedef},
@code{whatis} @dfn{unrolls} only one level of that @code{typedef}.
That one-level stripping is currently done here, in
gdb/eval.c:evaluate_subexp_standard, handling OP_TYPE:
...
else if (noside == EVAL_AVOID_SIDE_EFFECTS)
{
struct type *type = exp->elts[pc + 1].type;
/* If this is a typedef, then find its immediate target. We
use check_typedef to resolve stubs, but we ignore its
result because we do not want to dig past all
typedefs. */
check_typedef (type);
if (TYPE_CODE (type) == TYPE_CODE_TYPEDEF)
type = TYPE_TARGET_TYPE (type);
return allocate_value (type);
}
However, this stripping is reachable in both:
#1 - (gdb) whatis (int_t)0 # ARG is an expression with a cast to
# typedef type.
#2 - (gdb) whatis int_t # ARG is a type name.
while only case #2 should strip the typedef. Removing that code from
evaluate_subexp_standard is part of the fix. Instead, we make the
"whatis" command implementation itself strip one level of typedefs
when the command argument is a type name.
We then run into another problem, also fixed by this commit:
value_cast always drops any typedefs of the destination type.
With all that fixed, "whatis (int_t) 0" now works as expected:
(gdb) whatis int_t
type = int
(gdb) whatis (int_t)0
type = int_t
value_cast has many different exit/convertion paths, for handling many
different kinds of casts/conversions, and most of them had to be
tweaked to construct the value of the right "to" type. The new tests
try to exercise most of it, by trying castin of many different
combinations of types. With:
$ make check TESTS="*/whatis-ptype*.exp */gnu_vector.exp */dfp-test.exp"
... due to combinatorial explosion, the testsuite results for the
tests above alone grow like:
- # of expected passes 246
+ # of expected passes 3811
You'll note that the tests exposed one GCC buglet, filed here:
Missing DW_AT_type in DW_TAG_typedef of "typedef of typedef of void"
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81267
gdb/ChangeLog:
2017-08-21 Pedro Alves <palves@redhat.com>
* eval.c (evaluate_subexp_standard) <OP_TYPE>: Don't dig past
typedefs.
* typeprint.c (whatis_exp): If handling "whatis", and expression
is OP_TYPE, strip one typedef level. Otherwise don't strip
typedefs here.
* valops.c (value_cast): Save "to" type before resolving
stubs/typedefs. Use that type as resulting value's type.
gdb/testsuite/ChangeLog:
2017-08-21 Pedro Alves <palves@redhat.com>
* gdb.base/dfp-test.c
(d32_t, d64_t, d128_t, d32_t2, d64_t2, d128_t2, v_d32_t, v_d64_t)
(v_d128_t, v_d32_t2, v_d64_t2, v_d128_t2): New.
* gdb.base/dfp-test.exp: Add whatis/ptype/cast tests.
* gdb.base/gnu_vector.exp: Add whatis/ptype/cast tests.
* gdb.base/whatis-ptype-typedefs.c: New.
* gdb.base/whatis-ptype-typedefs.exp: New.
* gdb.python/py-prettyprint.c (int_type, int_type2): New typedefs.
(an_int, an_int_type, an_int_type2): New globals.
* gdb.python/py-prettyprint.exp (run_lang_tests): Add tests
involving typedefs and cast expressions.
* gdb.python/py-prettyprint.py (class pp_int_typedef): New.
(lookup_typedefs_function): New.
(typedefs_pretty_printers_dict): New.
(top level): Register lookup_typedefs_function in
gdb.pretty_printers.
Hans-Peter Nilsson [Tue, 25 Jul 2017 02:09:32 +0000 (04:09 +0200)]
PR ld/20125, MMIX weak symbols
Weak undefineds with PUSHJ relocs were "lost", causing internal
inconsistencies and an abort.
GDB Administrator [Mon, 21 Aug 2017 00:00:41 +0000 (00:00 +0000)]
Automatic date update in version.in
H.J. Lu [Sun, 20 Aug 2017 13:25:52 +0000 (06:25 -0700)]
Update testsuite/ld-x86-64/plt-main-bnd.dd
2017-08-20 A. Wilcox <awilfox@adelielinux.org>
PR ld/21976
* testsuite/ld-x86-64/plt-main-bnd.dd: Accept '_' in symbol
name.
GDB Administrator [Sun, 20 Aug 2017 00:00:47 +0000 (00:00 +0000)]
Automatic date update in version.in
GDB Administrator [Sat, 19 Aug 2017 00:00:44 +0000 (00:00 +0000)]
Automatic date update in version.in
Tom Tromey [Wed, 16 Aug 2017 05:36:09 +0000 (23:36 -0600)]
Remove save_inferior_ptid
This removes save_inferior_ptid, a cleanup function, in favor of
scoped_restore.
This also fixes a possible (it seems unlikely that it could happen in
practice) memory leak -- save_inferior_ptid should have used
make_cleanup_dtor, because it allocated memory.
I tested this on the buildbot. However, there are two caveats to
this. First, sometimes it seems I misread the results. Second, I
think this patch touches some platforms that can't be tested by the
buildbot. So, extra care seems warranted.
ChangeLog
2017-08-18 Tom Tromey <tom@tromey.com>
Pedro Alves <palves@redhat.com>
* spu-multiarch.c (parse_spufs_run): Use scoped_restore.
* sol-thread.c (sol_thread_resume, sol_thread_wait)
(sol_thread_xfer_partial, rw_common): Use scoped_restore.
* procfs.c (procfs_do_thread_registers): Use scoped_restore.
* proc-service.c (ps_xfer_memory): Use scoped_restore.
* linux-tdep.c (linux_corefile_thread): Remove a cleanup.
(linux_get_siginfo_data): Add "thread" argument. Use
scoped_restore.
* linux-nat.c (linux_child_follow_fork)
(check_stopped_by_watchpoint): Use scoped_restore.
* infrun.c (displaced_step_prepare_throw, write_memory_ptid)
(THREAD_STOPPED_BY, handle_signal_stop): Use scoped_restore.
(restore_inferior_ptid, save_inferior_ptid): Remove.
* btrace.c (btrace_fetch): Use scoped_restore.
* bsd-uthread.c (bsd_uthread_fetch_registers)
(bsd_uthread_store_registers): Use scoped_restore.
* breakpoint.c (reattach_breakpoints, detach_breakpoints): Use
scoped_restore.
* aix-thread.c (aix_thread_resume, aix_thread_wait)
(aix_thread_xfer_partial): Use scoped_restore.
* inferior.h (save_inferior_ptid): Remove.
Yao Qi [Fri, 18 Aug 2017 08:30:12 +0000 (09:30 +0100)]
[ARM] Mark USER_SPECIFIED_MACHINE_TYPE in disassemble_info.flags
opcodes/arm-dis.c:print_insn may update disassemble_info.mach to
bfd_mach_arm_unknown unless USER_SPECIFIED_MACHINE_TYPE is marked.
When default_print_insn is called for the first time,
disassemble_info.mach is correctly set in GDB, but arm-dis.c:print_insn
sets it to bfd_mach_arm_unknown. Then, when default_print_insn is
called again (in a loop), it triggers the assert.
The patch fixes the assert by marking USER_SPECIFIED_MACHINE_TYPE so that
opcodes won't reset disassemble_info.mach.
gdb:
2017-08-18 Yao Qi <yao.qi@linaro.org>
PR tdep/21818
* arm-tdep.c (gdb_print_insn_arm): Mark
USER_SPECIFIED_MACHINE_TYPE if exec_bfd isn't NULL.
Yao Qi [Fri, 18 Aug 2017 08:20:43 +0000 (09:20 +0100)]
GDBserver self tests
This patch uses GDB self test in GDBserver. The self tests are run if
GDBserver is started with option --selftest.
gdb:
2017-08-18 Yao Qi <yao.qi@linaro.org>
* NEWS: Mention GDBserver's new option "--selftest".
* Makefile.in (SFILES): Remove selftest.c, add common/selftest.c.
* selftest.c: Move it to common/selftest.c.
* selftest.h: Move it to common/selftest.h.
* selftest-arch.c (reset): New function.
(tests_with_arch): Call reset.
gdb/gdbserver:
2017-08-18 Yao Qi <yao.qi@linaro.org>
* Makefile.in (OBS): Add selftest.o.
* configure.ac: AC_DEFINE GDB_SELF_TEST if $development.
* configure, config.in: Re-generated.
* server.c: Include common/sefltest.h.
(captured_main): Handle option --selftest.
gdb/testsuite:
2017-08-18 Yao Qi <yao.qi@linaro.org>
* gdb.server/unittest.exp: New.
gdb/doc:
2017-08-18 Yao Qi <yao.qi@linaro.org>
* gdb.texinfo (Server): Document "--selftest".
Yao Qi [Fri, 18 Aug 2017 08:20:43 +0000 (09:20 +0100)]
Remove some GDB specific stuff from selftest.c
The next patch moves selftest.c to common/selftest.c, so that GDBserver
can use it as well. However selftest.c uses something isn't "portable" on
GDB and GDBserver.
First, this patch removes QUIT. I don't expect that we type ctrl-c during
self/unit tests, and each test shouldn't take long time. Secondly, I
replace exception_fprintf and printf_filtered with debug_printf. Verified
that unit tests still catch fails.
gdb:
2017-08-18 Yao Qi <yao.qi@linaro.org>
* selftest.c (run_tests): Don't call QUIT. Call debug_printf
instead of exception_fprintf and printf_filtered.
Yao Qi [Fri, 18 Aug 2017 08:20:43 +0000 (09:20 +0100)]
Put selftests api into selftests namespace
This patch changes register_self_test to selftests::register_test,
and run_self_tests to selftest::run_tests.
gdb:
2017-08-18 Yao Qi <yao.qi@linaro.org>
* selftest.c (register_self_test): Rename it to
selftests::register_test.
(run_self_tests): selftest::run_tests.
* selftest.h: Update declarations.
* selftest-arch.c (register_self_test_foreach_arch): Rename it to
selftests::register_test_foreach_arch.
* selftest-arch.h: Update declaration.
* aarch64-tdep.c: Update.
* arm-tdep.c: Likewise.
* disasm-selftests.c: Likewise.
* dwarf2loc.c: Likewise.
* dwarf2-frame.c: Likewise.
* findvar.c: Likewise.
* gdbarch-selftests.c: Likewise.
* maint.c (maintenance_selftest): Likewise.
* regcache.c: Likewise.
* rust-exp.y: Likewise.
* selftest-arch.c: Likewise.
* unittests/environ-selftests.c: Likewise.
* unittests/function-view-selftests.c: Likewise.
* unittests/offset-type-selftests.c: Likewise.
* unittests/optional-selftests.c: Likewise.
* unittests/scoped_restore-selftests.c: Likewise.
* utils-selftests.c: Likewise.
Nick Clifton [Fri, 18 Aug 2017 07:45:12 +0000 (08:45 +0100)]
Fix buffer overrun parsing a corrupt tekhex binary.
PR binutils/21962
* tekhex.c (getsym): Fix check for source pointer walking off the
end of the input buffer.
GDB Administrator [Fri, 18 Aug 2017 00:00:54 +0000 (00:00 +0000)]
Automatic date update in version.in
Pedro Alves [Thu, 17 Aug 2017 22:45:52 +0000 (23:45 +0100)]
Plug source_command leak
The heap-allocated 'old_source_verbose' local was accidentally left
behind by commit
2ec845e75876 ("More uses of scoped_restore").
Valgrind caught it, like:
==20123== 8 bytes in 1 blocks are definitely lost in loss record 4,609 of 13,785
==20123== at 0x4C2A988: calloc (vg_replace_malloc.c:711)
==20123== by 0x60A2F8: xcalloc (common-utils.c:84)
==20123== by 0x4CDBE5: build_command_line(command_control_type, char const*) (cli-script.c:159)
==20123== by 0x4CDC32: get_command_line(command_control_type, char const*) (cli-script.c:172)
==20123== by 0x5230F1: python_command(char*, int) (python.c:421)
==20123== by 0x4C61AD: do_cfunc(cmd_list_element*, char*, int) (cli-decode.c:106)
==20123== by 0x4C911F: cmd_func(cmd_list_element*, char*, int) (cli-decode.c:1902)
==20123== by 0x7CA79E: execute_command(char*, int) (top.c:650)
==20123== by 0x695A0C: command_handler(char*) (event-top.c:590)
==20123== by 0x7CA33F: read_command_file(_IO_FILE*) (top.c:461)
==20123== by 0x4D0C3A: script_from_file(_IO_FILE*, char const*) (cli-script.c:1584)
==20123== by 0x4C2727: source_script_from_stream(_IO_FILE*, char const*, char const*) (cli-cmds.c:589)
gdb/ChangeLog:
2017-08-17 Pedro Alves <palves@redhat.com>
* cli/cli-cmds.c (source_command): Delete 'old_source_verbose'
local.
Pedro Alves [Thu, 17 Aug 2017 21:53:53 +0000 (22:53 +0100)]
Plug line_header leaks
This plugs a couple leaks introduced by commit
fff8551cf549
("dwarf2read.c: Some C++fycation, use std::vector, std::unique_ptr").
The first problem is that nothing owns the temporary line_header that
handle_DW_AT_stmt_list creates in some cases. Before the commit
mentioned above, the temporary line_header case used to have:
make_cleanup (free_cu_line_header, cu);
and that cleanup was assumed to be run by process_die, after
handle_DW_AT_stmt_list returns and before child DIEs were processed.
The second problem is found in setup_type_unit_groups: that also used
to have a similar make_cleanup call, and ended up with a similar leak
after the commit mentioned above.
Fix both cases by recording in dwarf2_cu whether a line header is
owned by the cu/die, and have process_die explicitly free the
line_header if so, making use of a new RAII object that also replaces
the reset_die_in_process cleanup, while at it.
Thanks to Philippe Waroquiers for noticing the leak and pointing in
the right direction.
gdb/ChangeLog:
2017-08-17 Pedro Alves <palves@redhat.com>
* dwarf2read.c (struct dwarf2_cu) <line_header_die_owner>: New
field.
(reset_die_in_process): Delete, replaced by ...
(process_die_scope): ... this new class. Make it responsible for
freeing cu->line_header too.
(process_die): Use process_die_scope.
(handle_DW_AT_stmt_list): Record the line header's owner CU/DIE in
cu->line_header_die_owner. Don't release the line header if it's
owned by the CU.
(setup_type_unit_groups): Make the CU/DIE own the line header.
Don't release the line header here.
Nick Clifton [Thu, 17 Aug 2017 13:49:01 +0000 (14:49 +0100)]
Add test of V2 GNU build attribute notes.
* testsuite/binutils-all/note-3-64.s: New test. Checks assembly
and decoding of version2 GNU build attribute notes.
* testsuite/binutils-all/note-3-32.s: New test. 32-bit version of
the above test.
* testsuite/binutils-all/note-3-64.d: New test driver.
* testsuite/binutils-all/note-3-32.d: New test driver.
* testsuite/binutils-all/objcopy.exp: Run the new test.
* readelf.c (is_64bit_abs_reloc): Add R_SPARC_64.
Szabolcs Nagy [Thu, 17 Aug 2017 13:48:03 +0000 (14:48 +0100)]
[AArch64] Skip IFUNC relocations in debug sections
Skip IFUNC relocations in debug sections ignored by ld.so.
Fixes the following ld test failures on aarch64:
FAIL: Build libpr18808.so
FAIL: Build libpr18808.so_2
FAIL: Run pr18808
aborting at bfd/elfnn-aarch64.c:4986 in elf64_aarch64_final_link_relocate.
bfd/
PR ld/18808
* elfnn-aarch64.c (elfNN_aarch64_final_link_relocate): Skip IFUNC
relocations in debug sections, change abort to _bfd_error_handler.
Nick Clifton [Thu, 17 Aug 2017 11:13:28 +0000 (12:13 +0100)]
Add new Brazilian Portuguese translation for the ld subdirectory.
* po/pt_BR.po: New Brazilian Portuguese translation.
* configure.ac (ALL_LINGUAS): Add pt_BR.
* configure: Regenerate.
Alex Lindsay [Thu, 17 Aug 2017 10:53:53 +0000 (11:53 +0100)]
Synthetic symbol leak in elf_read_minimal_symbols
Detected this leak with valgrind memcheck:
==30840== 194 bytes in 1 blocks are definitely lost in loss record 9,138 of 10,922
==30840== at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==30840== by 0x80DF82: bfd_malloc (libbfd.c:193)
==30840== by 0x80E12D: bfd_zmalloc (libbfd.c:278)
==30840== by 0x819E80: elf_x86_64_get_synthetic_symtab (elf64-x86-64.c:6835)
==30840== by 0x4F7B01: elf_read_minimal_symbols(objfile*, int, elfinfo const*) (elfread.c:1124)
==30840== by 0x4F7CE7: elf_symfile_read(objfile*, enum_flags<symfile_add_flag>) (elfread.c:1182)
==30840== by 0x7557FC: read_symbols(objfile*, enum_flags<symfile_add_flag>) (symfile.c:861)
==30840== by 0x755EE1: syms_from_objfile_1(objfile*, section_addr_info*, enum_flags<symfile_add_flag>) (symfile.c:1062)
We perform a dynamic allocation in
elf64-x86-64.c:elf_x86_64_get_synthetic_symtab
s = *ret = (asymbol *) bfd_zmalloc (size);
that appear to never get freed.
gdb:
2017-08-17 Alex Lindsay <alexlindsay239@gmail.com>
* elfread.c (elf_read_minimal_symbols): xfree synthsyms.
Ruslan Kabatsayev [Thu, 17 Aug 2017 05:44:37 +0000 (08:44 +0300)]
Mention new TUI Single-Key mode shortcuts for nexti and stepi in NEWS
gdb/ChangeLog:
* NEWS: Mention new shortcuts for nexti and stepi in TUI
Single-Key mode
GDB Administrator [Thu, 17 Aug 2017 00:01:00 +0000 (00:01 +0000)]
Automatic date update in version.in
Ruslan Kabatsayev [Wed, 16 Aug 2017 18:44:29 +0000 (21:44 +0300)]
Add shortcuts for "nexti" and "stepi" commands in Single-Key mode
Currently, "layout asm" is not so useful as "layout src" with Single-Key mode:
you have to use multi-key commands like "ni" and "si" to do single-stepping.
This patch adds, in addition to "next" and "step" commands, corresponding
assembly-level ones - "nexti" and "stepi" - to Single-Key mode, with the
shortcuts of "o" (from "step Over") and "i" (from "Step Into") respectively.
gdb/ChangeLog:
* tui/tui.c (tui_commands): Add "nexti" and "stepi" to the Single-Key
mode command list.
gdb/doc/ChangeLog:
* gdb.texinfo (TUI Single Key Mode): Document the new shortcuts in
Single-Key mode.
GDB Administrator [Wed, 16 Aug 2017 00:13:28 +0000 (00:13 +0000)]
Automatic date update in version.in
Gustavo Romero [Mon, 14 Aug 2017 14:48:04 +0000 (10:48 -0400)]
Add new NT_PPC_* available since Linux 4.8
Add new note types available since Linux 4.8 to elf/common.h and
make the 'readelf' tool aware of it.
include/
* elf/common.h (NT_PPC_TAR): New macro.
(NT_PPC_PPR): Likewise.
(NT_PPC_DSCR): Likewise.
(NT_PPC_EBB): Likewise.
(NT_PPC_PMU): Likewise.
(NT_PPC_TM_CGPR): Likewise.
(NT_PPC_TM_CFPR): Likewise.
(NT_PPC_TM_CVMX): Likewise.
(NT_PPC_TM_CVSX): Likewise.
(NT_PPC_TM_SPR): Likewise.
(NT_PPC_TM_CTAR): Likewise.
(NT_PPC_TM_CPPR): Likewise.
(NT_PPC_TM_CDSCR): Likewise.
binutils/
* readelf.c (get_note_type): Handle PPC note types available
since Linux 4.8.
Stafford Horne [Tue, 15 Aug 2017 21:32:28 +0000 (06:32 +0900)]
Add myself as a write-after-approval GDB maintainer.
gdb/ChangeLog:
* MAINTAINERS (Write After Approval): Add Stafford Horne.
Stafford Horne [Tue, 15 Aug 2017 21:12:45 +0000 (06:12 +0900)]
xtensa: Properly strdup string when building reggroup
I noticed this while looking at the reggroup intializations. It seems
for xtensa the "cpN" reggroup->name is getting assigned to the same text
pointer for each iteration of XTENSA_MAX_COPROCESSOR.
Note, internally reggroup_new() does not do any xstrdup().
gdb/ChangeLog:
2017-08-15 Stafford Horne <shorne@gmail.com>
* xtensa-tdep.c (xtensa_init_reggroups): Use xstrdup for cpname.
Sergio Durigan Junior [Tue, 15 Aug 2017 17:49:18 +0000 (13:49 -0400)]
Fix PR gdb/21954: make 'unset environment' work again
When I made commit
9a6c7d9c021cfeb290d76584db7a01e57e7c3d4e, which
C++-fied gdb/common/environ.[ch], I mistakenly altered the behaviour
of the 'unset environment' command. This command, which should delete
all environment variables, is now resetting the list of variables to
the state they were when GDB was started.
This commit fixes this regression, and also adds a test on
gdb.base/environ.exp which really checks if 'unset environment'
worked.
gdb/ChangeLog:
2017-08-15 Sergio Durigan Junior <sergiodj@redhat.com>
PR gdb/21954
* infcmd.c (unset_environment_command): Use the 'clear' method on
the environment instead of resetting it.
gdb/testsuite/ChangeLog:
2017-08-15 Sergio Durigan Junior <sergiodj@redhat.com>
PR gdb/21954
* gdb.base/environ.exp: Add test to check if 'unset environment'
works.
John Baldwin [Tue, 15 Aug 2017 15:04:23 +0000 (08:04 -0700)]
Fix compile on big-endian platforms in siginfo_t converter.
gdb/ChangeLog:
* fbsd-nat.c (fbsd_convert_siginfo): Fix compile on big-endian
platforms.
Ramana Radhakrishnan [Tue, 15 Aug 2017 12:58:01 +0000 (13:58 +0100)]
[Patch AArch64] Turn lr, fp, ip0 and ip1 into proper aliases
We got a report from the linux-arm-kernel folks about getting spurious
warnings when building the kernel with binutils 2.29. See
https://www.spinics.net/lists/arm-kernel/msg599929.html
which boils down to this testcase.
$> cat /tmp/tst.s
lr .req x30
/tmp/tst.s: Assembler messages:
/tmp/tst.s:1: Warning: ignoring attempt to redefine built-in register 'lr'
Instead let's treat this as a proper alias at startup time thus
avoiding the problem and treating these as proper aliases
rather than new registers. This means that attempts to redefine
the alias with the same "name" will provoke no warning and attempts
to redefine the alias to something else will provoke the above mentioned
warning.
Tested make check-gas and no regressions.
Ok to apply to trunk (and backport to 2.29 branch)?
Regards
Ramana
Andreas Arnez [Mon, 14 Aug 2017 18:31:09 +0000 (20:31 +0200)]
GDB testsuite: Suppress GCC's colored output
Newer GCC versions yield colored diagnostic messages by default, which may
be useful when executing GDB interactively from a terminal. But when run
from a GDB test case, the compiler output is written into gdb.log, where
such escape sequences are usually more inhibiting than helpful to the
evaluation of test results. So this patch suppresses that.
gdb/testsuite/ChangeLog:
* lib/gdb.exp (universal_compile_options): New caching proc.
(gdb_compile): Suppress GCC's coloring of messages.
Tom Tromey [Tue, 11 Jul 2017 12:44:36 +0000 (06:44 -0600)]
Remove BITS_IN_BYTES define
While working on the previous patch, I noticed that BITS_IN_BYTES can be
replaced by HOST_CHAR_BIT, which is used more widely in gdb.
ChangeLog
2017-08-14 Tom Tromey <tom@tromey.com>
* valprint.c (print_octal_chars): Use HOST_CHAR_BIT.
(print_binary_chars): Likewise.
(BITS_IN_BYTES): Remove.
Tom Tromey [Tue, 11 Jul 2017 12:40:40 +0000 (06:40 -0600)]
Fix two regressions in scalar printing
PR gdb/21675 points out a few regressions in scalar printing.
One type of regression is due to not carrying over the old handling of
floating point printing -- where a format like "/d" causes a floating
point number to first be cast to a signed integer. This patch restores
this behavior.
The other regression is a longstanding bug in print_octal_chars: one of
the constants was wrong. This patch fixes the constant and adds static
asserts to help catch this sort of error.
ChangeLog
2017-08-14 Tom Tromey <tom@tromey.com>
PR gdb/21675
* valprint.c (LOW_ZERO): Change value to 034.
(print_octal_chars): Add static_asserts for octal constants.
* printcmd.c (print_scalar_formatted): Add 'd' case.
testsuite/ChangeLog
2017-08-14 Tom Tromey <tom@tromey.com>
PR gdb/21675:
* gdb.base/printcmds.exp (test_radices): New function.
* gdb.dwarf2/var-access.exp: Use p/u, not p/d.
* gdb.base/sizeof.exp (check_valueof): Use p/d.
* lib/gdb.exp (get_integer_valueof): Use p/d.
Tom Tromey [Thu, 3 Aug 2017 23:07:06 +0000 (17:07 -0600)]
Fix memory leak in add_symbol_file_command
I happened to notice that add_symbol_file_command leaks "sect_opts".
This patch fixes the leak by changing sect_opts to be a std::vector.
I had to change the logic in the loop a little bit. Previously, it
was incrementing section_index after completing an entry; but this
changes it to push a new entry when the name is seen.
I believe the argument parsing here is mildly incorrect, in that
nothing checks whether the -s option actually had any arguments.
Maybe gdb can crash if "-s NAME" is given without an argument. I
didn't try to fix this in this patch, but I do have another patch I
can send later that fixes it up.
Regression tested on the buildbot.
ChangeLog
2017-08-11 Tom Tromey <tom@tromey.com>
* symfile.c (add_symbol_file_command): Use std::vector.
Tom Tromey [Fri, 11 Aug 2017 16:14:16 +0000 (10:14 -0600)]
Use std::move in a few places
This patch adds std::move to few spots where it seems to be missing.
Regression tested by the buildbot.
ChangeLog
2017-08-14 Tom Tromey <tom@tromey.com>
* break-catch-throw.c (handle_gnu_v3_exceptions): Use std::move.
* break-catch-syscall.c (create_syscall_event_catchpoint): Use
std::move.
* break-catch-sig.c (create_signal_catchpoint): Use std::move.
Nick Clifton [Mon, 14 Aug 2017 11:09:36 +0000 (12:09 +0100)]
Fix null pointer dereference when parsing a corrupt ELF binary.
PR 21957
* elf.c (setup_group): Check for an empty or very small group
section.
* po/bfd.pot: Regenerate.
GDB Administrator [Mon, 14 Aug 2017 00:01:33 +0000 (00:01 +0000)]
Automatic date update in version.in
Alan Modra [Sun, 13 Aug 2017 23:55:17 +0000 (09:25 +0930)]
PR21441, Unnecessary padding of .eh_frame section
Until all .eh_frame sections have been edited we don't know their
sizes. So it isn't possible to properly decide whether a non-empty
.eh_frame section follows a given section until editing is complete.
bfd/
PR 21441
* elf-eh-frame.c (_bfd_elf_discard_section_eh_frame): Don't add
alignment padding here.
* elflink.c (bfd_elf_discard_info): Add .eh_frame padding here
in a reverse pass over sections.
ld/
PR 21441
* testsuite/ld-x86-64/pr21038a.d: Adjust.
* testsuite/ld-x86-64/pr21038a-now.d: Adjust.
H.J. Lu [Sun, 13 Aug 2017 12:41:37 +0000 (05:41 -0700)]
ld: Restore linker scripts in PR ld/21884 tests
OUTPUT_FORMAT in linker script of PR ld/21884 tests is needed to trigger
PR ld/21884. Restore linker scripts and add nacl versions of the same
tests.
* testsuite/ld-i386/i386.exp: Run pr21884-nacl.
* testsuite/ld-x86-64/x86-64.exp: Likewise.
* testsuite/ld-i386/pr21884.d: Don't run on nacl targets.
* testsuite/ld-x86-64/pr21884.d: Likewise.
* testsuite/ld-i386/pr21884.t: Revert the last change.
* testsuite/ld-x86-64/pr21884.t: Likewise.
* testsuite/ld-i386/pr21884-nacl.d: New file.
* testsuite/ld-i386/pr21884-nacl.t: Likewise.
* testsuite/ld-x86-64/pr21884-nacl.d: Likewise.
* testsuite/ld-x86-64/pr21884-nacl.t: Likewise.
Alan Modra [Sun, 13 Aug 2017 00:04:04 +0000 (09:34 +0930)]
Fix i686-nacl and x86_64-nacl pr21884 failures
OUTPUT_FORMAT in the script results in "./ld-new: target elf32-i386
not found" and similarly for the x86_64 test.
* testsuite/ld-i386/pr21884.t: Remove unneeded format, arch and entry.
* testsuite/ld-x86-64/pr21884.t: Likewise.
GDB Administrator [Sun, 13 Aug 2017 00:00:56 +0000 (00:00 +0000)]
Automatic date update in version.in
Sergio Durigan Junior [Sat, 12 Aug 2017 16:46:03 +0000 (12:46 -0400)]
Fix typo on documentation ("show set startup-with-shell")
The documentation was erroneously saying that there is a command named
"show set startup-with-shell", while the correct version is "show
startup-with-shell". This commit fixes obvious mistake.
gdb/doc/ChangeLog:
2017-08-12 Sergio Durigan Junior <sergiodj@redhat.com>
PR gdb/21925
* gdb.texinfo (Starting) <startup-with-shell>: Fix typo ("show
set...").
Simon Marchi [Sat, 12 Aug 2017 08:33:00 +0000 (10:33 +0200)]
testsuite: Exclude end-of-line characters from get_valueof result
The get_valueof procedure allows tests to conveniently make gdb evaluate
an expression an return the value as a string. However, it includes an
end-of-line character in its result. I stumbled on this when trying to
use that result as part of a regex further in a test.
You can see this for example by adding a puts in
gdb.dwarf2/implref-struct.exp:get_members:
set members [get_valueof "" ${var} ""]
puts "<$members>"
The output is
<{a = 0, b = 1, c = 2}
>
This is because the regex in get_valueof is too greedy, the captured
portion matches anything up to the gdb_prompt, including the end of line
characters. This patch changes it to capture everything but end of line
characters.
The output of the puts becomes:
<{a = 0, b = 1, c = 2}>
I tested this by running gdb.dwarf2/implref-array.exp and
gdb.dwarf2/implref-struct.exp, the two only current users of that
procedure.
gdb/testsuite/ChangeLog:
* lib/gdb.exp (get_valueof): Don't capture end-of-line
characters.
Alan Modra [Sat, 12 Aug 2017 06:57:29 +0000 (16:27 +0930)]
Collision between NT_GNU_BUILD_ATTRIBUTE_OPEN and NT_PPC_VMX
* readelf.c (process_note): Qualify NT_GNU_BUILD_ATTRIBUTE notes
by name data.
GDB Administrator [Sat, 12 Aug 2017 00:00:57 +0000 (00:00 +0000)]
Automatic date update in version.in
H.J. Lu [Fri, 11 Aug 2017 16:32:44 +0000 (09:32 -0700)]
x86: Allocate space for symbol names with symbol table
When synthesizing symbols for PLT entries, allocate space for symbol
names with @plt suffixes together with symbol table so that all memory
is returned when symbol table is freed.
PR binutils/21943
* elf32-i386.c (elf_i386_get_synthetic_symtab): Allocate space
for @plt suffixes first.
* elf64-x86-64.c (elf_x86_64_get_synthetic_symtab): Likewise.
Nick Clifton [Fri, 11 Aug 2017 15:36:28 +0000 (16:36 +0100)]
Add -z globalaudit linker command line option to set the DF_GLOBALAUDIT flag bit in the dynamic tags.
* emultempl/elf32.em (handle_option): Accept the -z globalaudit
command line option.
* lexsup.c (elf_static_list_options): Add -z globalaudit.
* ld.texinfo: Document the support for the new command line
option.
* NEWS: Mention the new feature.
* testsuite/ld-elf/audit.exp: Add a test of the -z globalaudit
command line option.
* testsuite/ld-elf/globalaudit.rd: New file: Expected output from
readelf.
H.J. Lu [Fri, 11 Aug 2017 15:05:00 +0000 (08:05 -0700)]
Add 2 more tests for PR ld/21884
PR ld/21884
* testsuite/ld-i386/i386.exp: Run pr21884.
* testsuite/ld-x86-64/x86-64.exp: Likewise.
* testsuite/ld-i386/pr21884.d: New file.
* testsuite/ld-i386/pr21884.t: Likewise.
* testsuite/ld-x86-64/pr21884.d: Likewise.
* testsuite/ld-x86-64/pr21884.t: Likewise.
H.J. Lu [Fri, 11 Aug 2017 14:41:51 +0000 (07:41 -0700)]
Also disallow global alias of common symbol
We can't create alias of common symbol. Local alias of common symbol has
been disallowed. But global alias of common symbol is disallowed when the
common symbol is seen first and silently dropped otherwise. This patch
disallows alias of common symbol in all cases.
gas/
PR gas/21667
* read.c (pseudo_set): Update error message for alias of common
symbol.
* write.c (write_object_file): Disallow both local and global
aliases of common symbol.
* testsuite/gas/elf/common5a.d: New file.
* testsuite/gas/elf/common5a.l: Likewise.
* testsuite/gas/elf/common5a.s: Likewise.
* testsuite/gas/elf/common5b.d: Likewise.
* testsuite/gas/elf/common5b.l: Likewise.
* testsuite/gas/elf/common5b.s: Likewise.
* testsuite/gas/elf/common5c.d: Likewise.
* testsuite/gas/elf/common5c.s: Likewise.
* testsuite/gas/elf/common5d.d: Likewise.
* testsuite/gas/elf/common5d.s: Likewise.
* testsuite/gas/elf/elf.exp: Run common5a, common5b, common5c
and common5d.
Pedro Alves [Fri, 11 Aug 2017 11:11:28 +0000 (12:11 +0100)]
More gdb/skip.c C++ification
- Make skiplist_entry a class with private data members.
- Move all construction logic to the ctor.
- Make skip_file_p etc be methods of skiplist_entry.
- Use std::list for the skip entries chain. Make the list own its
elements.
- Get rid of the ALL_SKIPLIST_ENTRIES/ALL_SKIPLIST_ENTRIES_SAFE
macros, use range-for / iterators instead.
- function_name_is_marked_for_skip 'function_sal' argument must be
non-NULL, so make it a reference instead.
All skiplist_entry invariants are now controlled by skiplist_entry
methods/internals. Some gdb_asserts disappear for being redundant.
gdb/ChangeLog:
2017-08-11 Pedro Alves <palves@redhat.com>
* infrun.c (process_event_stop_test): Adjust
function_name_is_marked_for_skip call.
* skip.c: Include <list>.
(skiplist_entry): Make it a class with private fields, and
getters/setters.
(skiplist_entry_chain): Delete.
(skiplist_entries): New.
(skiplist_entry_count): Delete.
(highest_skiplist_entry_num): New.
(ALL_SKIPLIST_ENTRIES, ALL_SKIPLIST_ENTRIES_SAFE): Delete.
(add_skiplist_entry): Delete.
(skiplist_entry::skiplist_entry): New.
(skiplist_entry::add_entry): New.
(skip_file_command, skip_function): Adjust.
(compile_skip_regexp): Delete.
(skip_command): Don't compile regexp here. Adjust to use
skiplist_entry::add_entry.
(skip_info): Adjust to use range-for and getters.
(skip_enable_command, skip_disable_command): Adjust to use
range-for and setters.
(skip_delete_command): Adjust to use std::list.
(add_skiplist_entry): Delete.
(skip_file_p): Delete, refactored as ...
(skiplist_entry::do_skip_file_p): ... this new method.
(skip_gfile_p): Delete, refactored as ...
(skiplist_entry::do_gskip_file_p): ... this new method.
(skip_function_p, skip_rfunction_p): Delete, refactored as ...
(skiplist_entry::skip_function_p): ... this new method.
(function_name_is_marked_for_skip): Now returns bool, and takes
the function sal by const reference. Adjust to use range-for and
skiplist_entry methods.
(_initialize_step_skip): Remove references to
skiplist_entry_chain, skiplist_entry_count.
* skip.h (function_name_is_marked_for_skip): Now returns bool, and
takes the function sal by const reference.
Yao Qi [Fri, 11 Aug 2017 08:30:02 +0000 (09:30 +0100)]
Reset *THIS_CACHE in frame_unwind_try_unwinder in case of exception
It is required that unwinder->sniffer should set *this_cache to NULL if
the unwinder is not applicable or exception is thrown, so
78ac5f831692f70b841044961069e50d4ba6a76f adds clear_pointer_cleanup to set
*this_cache to NULL in case of exception in order to fix PR 14100.
https://sourceware.org/ml/gdb-patches/2012-08/msg00075.html
This patch removes that clear_pointer_cleanup, and catch all exception in
the caller of unwinder->sniffer. In case of exception, reset *this_case.
gdb:
2017-08-11 Yao Qi <yao.qi@linaro.org>
* dwarf2-frame.c (clear_pointer_cleanup): Remove.
(dwarf2_frame_cache): Remove reset_cache_cleanup.
(dwarf2_frame_cache):
* frame-unwind.c (frame_unwind_try_unwinder): Catch
RETURN_MASK_ALL and set *this_case to NULL.
* frame-unwind.h: Update comments.
Yao Qi [Fri, 11 Aug 2017 08:30:02 +0000 (09:30 +0100)]
Class-fy dwarf2_frame_state_reg_info
This patch adds dwarf2_frame_state_reg_info ctor, dtor, copy ctor,
assignment operator, and move assignment. This patch also adds unit test
to execute_cfa_program to cover the changes.
gdb:
2017-08-11 Yao Qi <yao.qi@linaro.org>
* dwarf2-frame.c (dwarf2_frame_state_alloc_regs): Remove.
(dwarf2_frame_state_copy_regs): Remove.
(dwarf2_frame_state_free_regs): Remove.
(dwarf2_frame_state::~dwarf2_frame_state): Remove.
(dwarf2_restore_rule): Call method .alloc_regs instead of
dwarf2_frame_state_alloc_regs.
(execute_cfa_program): Likewise. Call dwarf2_frame_state_reg_info
constructor. Call std::move.
(dwarf2_fetch_cfa_info): Don't call dwarf2_frame_state_copy_regs.
(dwarf2_frame_cache): Likewise.
[GDB_SELF_TEST]: Include selftest.h and
selftest-arch.h.
[GDB_SELF_TEST] (execute_cfa_program_test): New function.
(_initialize_dwarf2_frame) [GDB_SELF_TEST]: Register
execute_cfa_program_test.
* dwarf2-frame.h (dwarf2_frame_state_reg_info): Add ctor, dtor,
copy ctor, assignment operator, move assignment.
<alloc_regs>: New method.
<swap>: New method.
(struct dwarf2_frame_state): Delete dtor.
(dwarf2_frame_state_alloc_regs): Remove declaration.
* sparc-tdep.c (sparc_execute_dwarf_cfa_vendor_op): Don't call
dwarf2_frame_state_alloc_regs, use .alloc_regs instead.
Yao Qi [Fri, 11 Aug 2017 08:30:02 +0000 (09:30 +0100)]
Class-fy dwarf2_frame_state
This patch adds ctor and dtor to dwarf2_frame_state, so that we can
remove one cleanup "old_chain".
gdb:
2017-08-11 Yao Qi <yao.qi@linaro.org>
* dwarf2-frame.c (dwarf2_frame_state_free): Remove.
(dwarf2_frame_state::dwarf2_frame_state): New.
(dwarf2_frame_state::~dwarf2_frame_state): New.
(dwarf2_fetch_cfa_info): Update.
(dwarf2_frame_cache): Remove old_chain. Change 'fs' to an object
rather than a pointer. Update code.
* dwarf2-frame.h (struct dwarf2_frame_state): Declare ctor and
dtor.
<data_align, code_align, retaddr_column>: Change them to const.
<armcc_cfa_offsets_sf, armcc_cfa_offsets_reversed>: Change them
to bool.
Yao Qi [Fri, 11 Aug 2017 08:30:02 +0000 (09:30 +0100)]
Move dwarf2_frame_state_reg.exp_len to union .loc
dwarf2_frame_state_reg.exp_len is only used together with .loc.exp, so
it makes more sense to exp_len to the union as well.
gdb:
2017-08-11 Yao Qi <yao.qi@linaro.org>
* dwarf2-frame.h (struct dwarf2_frame_state_reg) <exp_len>: Remove.
<loc.exp>: New field.
* dwarf2-frame.c (execute_cfa_program): Update.
(dwarf2_frame_prev_register): Update.
GDB Administrator [Fri, 11 Aug 2017 00:01:26 +0000 (00:01 +0000)]
Automatic date update in version.in
Pedro Alves [Thu, 10 Aug 2017 13:18:02 +0000 (14:18 +0100)]
Allow gdb::unique_xmalloc_ptr<T[]>
Currently, if you try to use the array version of
gdb::unique_xmalloc_ptr (i.e., std::unique_ptr) in order to have
access to operator[], like:
gdb::unique_xmalloc_ptr<char[]> buf ((char *) xmalloc (10));
return buf[0];
then the build fails, like:
/usr/include/c++/5.3.1/bits/unique_ptr.h: In instantiation of ‘std::unique_ptr<_Tp [], _Dp>::~unique_ptr() [with _Tp = char; _Dp = gdb::xfree_deleter<char []>]’:
main.c:30:61: required from here
/usr/include/c++/5.3.1/bits/unique_ptr.h:484:17: error: no match for call to ‘(std::unique_ptr<char [], gdb::xfree_deleter<char []> >::deleter_type {aka gdb::xfree_deleter<char []>}) (char*&)’
get_deleter()(__ptr);
^
In file included from src/gdb/common/common-defs.h:92:0,
from src/gdb/defs.h:28,
from src/gdb/main.c:20:
src/gdb/common/gdb_unique_ptr.h:34:8: note: candidate: void gdb::xfree_deleter<T>::operator()(T*) const [with T = char []]
void operator() (T *ptr) const { xfree (ptr); }
^
src/gdb/common/gdb_unique_ptr.h:34:8: note: no known conversion for argument 1 from ‘char*’ to ‘char (*)[]’
Makefile:1911: recipe for target 'main.o' failed
make: *** [main.o] Error 1
The problem is that we're missing an xfree_deleter specialization for
arrays.
gdb/ChangeLog:
2017-08-10 Pedro Alves <palves@redhat.com>
* common/gdb_unique_ptr.h (xfree_deleter<T[]>): Define.
Nick Clifton [Thu, 10 Aug 2017 12:17:12 +0000 (13:17 +0100)]
Add support for PE startup files that want to define their own constructor and desctructor sequencing.
* scripttempl/pep.sc: Enclose __CTOR_LIST__, ___CTOR_LIST__,
__DTOR_LIST__ and ___DTOR_LIST__ in PROVIDE statements so that
they can be overrridden by crt input files.
* scripttempl/pe.sc: Likewise.
Nick Clifton [Thu, 10 Aug 2017 10:51:42 +0000 (11:51 +0100)]
Fix memory corruption when assembling an i386 darwin source file.
PR gas/21939
* config/obj-macho.c (obj_mach_o_set_indirect_symbols): Increase
size of indirect_syms array so that it is large enough to hold
every symbol if necessary.
Nick Clifton [Thu, 10 Aug 2017 08:37:36 +0000 (09:37 +0100)]
Fix out of bounds memory access when trying to allocate space for a note of size -1.
PR 21933
* elf.c (elf_read_notes): Check for a note size of -1.
GDB Administrator [Thu, 10 Aug 2017 00:01:40 +0000 (00:01 +0000)]
Automatic date update in version.in
H.J. Lu [Wed, 9 Aug 2017 23:32:30 +0000 (16:32 -0700)]
LD_CLASS: Check .libs/ld-new for linker first
When --enable-shared is used, ./ld-new may be a shell script and the
real linker is .libs/ld-new. We should check .libs/ld-new first.
* testsuite/config/default.exp (LD_CLASS): Check .libs/ld-new
for linker first.
John Baldwin [Wed, 9 Aug 2017 22:24:46 +0000 (15:24 -0700)]
Replace home-grown linked-lists in FreeBSD's native target with STL lists.
FreeBSD's native target uses linked-lists to keep track of pending fork
events and fake vfork done events. Replace the first list with std::list
and the second with std::forward_list.
gdb/ChangeLog:
* fbsd-nat.c (struct fbsd_fork_info): Remove.
(fbsd_pending_children): Use std::list.
(fbsd_remember_child): Likewise.
(fbsd_is_child_pending): Likewise.
(fbsd_pending_vfork_done): Use std::forward_list.
(fbsd_add_vfork_done): Likewise.
(fbsd_is_vfork_done_pending): Likewise.
(fbsd_next_vfork_done): Likewise.
John Baldwin [Wed, 9 Aug 2017 22:24:46 +0000 (15:24 -0700)]
Replace remaining cleanups in fbsd-nat.c.
- Use a custom deleter with std::unique_ptr to free() memory returned
by kinfo_getvmmap().
- Use std::string with string_printf() to generate the pathname of the
procfs 'map' file.
- Use gdb::byte_vector to manage the dynamic buffer for
TARGET_OBJECT_AUXV and the dynamically allocated array of LWP IDs.
gdb/ChangeLog:
* fbsd-nat.c [HAVE_KINFO_GETVMMAP] (struct free_deleter): New.
(fbsd_find_memory_regions): Use free_deleter with std::unique_ptr.
[!HAVE_KINFO_GETVMMAP] (fbsd_find_memory_regions): Use std::string
for `mapfilename'.
(fbsd_xfer_partial): Use gdb::byte_vector.
(fbsd_add_threads): Likewise.
John Baldwin [Wed, 9 Aug 2017 22:24:46 +0000 (15:24 -0700)]
Fix compile in the !HAVE_KINFO_GETVMMAP case.
gdb/ChangeLog:
* fbsd-nat.c: [!HAVE_KINFO_GETVMMAP]: Include <sys/user.h> and
"filestuff.h".
(fbsd_find_memory_regions): Fix `mapfile' initialization.
H.J. Lu [Wed, 9 Aug 2017 22:04:05 +0000 (15:04 -0700)]
Run PR ld/17618 test only with 64-bit ELF linker
PR ld/17618 test requires 64-bit linker to run. Set LD_CLASS to "64bit"
for 64-bit ELF linker and run PR ld/17618 test only if $LD_CLASS is
"64bit". More checks can be added to support 64-bit linkers in non-ELF
format.
* testsuite/config/default.exp (LD_CLASS): New. Set to "64bit"
for 64-bit ELF linker.
* testsuite/ld-x86-64/pr17618.d (#notarget): Removed.
* testsuite/ld-x86-64/x86-64.exp: Run pr17618 only for 64-bit
linker.
Simon Marchi [Wed, 9 Aug 2017 20:16:14 +0000 (22:16 +0200)]
doc: Fix copy-pasto in Z0 packet documentation
The documentation for the cmd_list field of the Z0 packet refers to its
content as a conditional expression, which seems like a copy-paste error
from the cond_list field.
gdb/doc/ChangeLog:
* gdb.texinfo (Packets): Fix Z0 cmd_list doc referring to
conditional expression.
Tom Tromey [Sat, 5 Aug 2017 22:40:56 +0000 (16:40 -0600)]
C++-ify skip.c
I happened to notice that skiplist_entry, in skip.c, contains a
gdb::optional<compiled_regex> -- but that this object's destructor is
never run. This can result in a memory leak.
This patch fixes the bug by applying a bit more C++: changing this
code to use new and delete, and std::unique_ptr; and removing cleanups
in the process.
Built and regression tested on x86-64 Fedora 25.
ChangeLog
2017-08-09 Tom Tromey <tom@tromey.com>
* skip.c (skiplist_entry): New constructor.
(skiplist_entry::enabled, skiplist_entry::function_is_regexp)
(skiplist_entry::file_is_glob): Now bool.
(skiplist_entry::file, skiplist_entry::function): Now
std::string.
(make_skip_entry): Return a unique_ptr. Use new.
(free_skiplist_entry, free_skiplist_entry_cleanup)
(make_free_skiplist_entry_cleanup): Remove.
(skip_command, skip_disable_command, add_skiplist_entry)
(skip_form_bytes, compile_skip_regexp, skip_command, skip_info)
(skip_file_p, skip_gfile_p, skip_function_p, skip_rfunction_p)
(function_name_is_marked_for_skip): Update.
(skip_delete_command): Update. Use delete.
Jiong Wang [Wed, 9 Aug 2017 16:52:54 +0000 (17:52 +0100)]
[ARM] Don't warn on REG_SP when used in CRC32 instructions
According to ARMv8-A architecture manual, REG_SP is allowed in CRC32
instructions in Thumb mode. It is REG_PC that will cause unpredictable
behaviours on both ARM and Thumb.
This patch removes the incorrect warning on Thumb mode.
Meanwhile the disassembler is updated to use format "<bitfield>R" instead of
"<bitfield>S". "<bitfield>S" is not used elsewhere. so I have deleted related
code from the disassembler.
gas/
* config/tc-arm.c (do_crc32_1): Remove warning on REG_SP for thumb_mode.
* testsuite/gas/arm/crc32-armv8-a-bad.d: Update exepcted result.
* testsuite/gas/arm/crc32-armv8-r-bad.d: Likewise.
* testsuite/gas/arm/crc32-armv8-a.d: Likewise.
* testsuite/gas/arm/crc32-armv8-r.d: Likewise.
* testsuite/gas/arm/crc32-armv8-ar-bad.s: Update test case.
* testsuite/gas/arm/crc32-armv8-ar.s: Likewise.
* testsuite/gas/arm/crc32-bad.l: Update expected error message.
opcode/
* arm-dis.c (thumb32_opcodes): Use format 'R' instead of 'S' for
register operands in CRC instructions.
(print_insn_thumb32): Remove "<bitfield>S" support. Updated the
comments.
Jiong Wang [Wed, 9 Aug 2017 16:43:00 +0000 (17:43 +0100)]
[AArch64] Implement gdbarch_core_read_description
Recommit with missing header files added.
gdb/
* aarch64-linux-tdep.c: Include "auxv.h" and "elf/common.h".
(aarch64_linux_core_read_description): New function.
(aarch64_linux_init_abi): Register gdbarch_core_read_description.
Jiong Wang [Wed, 9 Aug 2017 14:51:56 +0000 (15:51 +0100)]
Revert "[AArch64] Implement gdbarch_core_read_description"
This reverts commit
b1a6c1cea365f80b90c0bca795c8d16fa0681560.
Jiong Wang [Wed, 9 Aug 2017 14:37:20 +0000 (15:37 +0100)]
[AArch64] Implement gdbarch_core_read_description
Currently, AArch64 only have one target description which is tdesc_aarch64. So,
we haven't implemented any target description detection mechanism for core file.
This patch is an initial implementation of core_read_description method. Future
features can use this to return selected description.
gdb/
* aarch64-linux-tdep.c (aarch64_linux_core_read_description): New
function.
(aarch64_linux_init_abi): Register gdbarch_core_read_description.
Pedro Alves [Wed, 9 Aug 2017 14:04:32 +0000 (15:04 +0100)]
Make cp_comp_to_string return a gdb::unique_xmalloc_ptr<char>
To help avoid issues like the one fixed by
e88e8651cf34 ("Fix memory
leak in cp-support.c").
gdb/ChangeLog:
2017-08-09 Pedro Alves <palves@redhat.com>
* cp-name-parser.y (cp_comp_to_string): Return a
gdb::unique_xmalloc_ptr<char>.
* cp-support.c (replace_typedefs_qualified_name)
(replace_typedefs): Adjust to use gdb::unique_xmalloc_ptr<char>.
(cp_canonicalize_string_full): Use op= instead of explicit
convertion.
(cp_class_name_from_physname, method_name_from_physname)
(cp_func_name, cp_remove_params): Adjust to use
gdb::unique_xmalloc_ptr<char>.
* cp-support.h (cp_comp_to_string): Return a
gdb::unique_xmalloc_ptr<char>.
* python/py-type.c (typy_lookup_type): Adjust to use
gdb::unique_xmalloc_ptr<char>.
H.J. Lu [Wed, 9 Aug 2017 12:01:55 +0000 (05:01 -0700)]
gdb: Fix build failure with GCC 7
Fix:
/export/gnu/import/git/sources/binutils-gdb/gdb/dwarf2read.c: In function ‘const char* dwarf2_string_attr(die_info*, unsigned int, dwarf2_cu*)’:
/export/gnu/import/git/sources/binutils-gdb/gdb/dwarf2read.c:17626:39: error: enum constant in boolean context [-Werror=int-in-bool-context]
|| attr->form == DW_FORM_string || DW_FORM_GNU_str_index
* dwarf2read.c (dwarf2_string_attr): Fix a typo.
Yao Qi [Wed, 9 Aug 2017 11:39:16 +0000 (12:39 +0100)]
Fix memory leak in cp-support.c
The return value of cp_comp_to_string was never freed, creating a
sizable memory leak detectable with valgrind.
==21225== 8 bytes in 1 blocks are definitely lost in loss record 4,599 of 10,949^M
==21225== at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)^M
==21225== by 0x4C2FDEF: realloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)^M
==21225== by 0x76CB31: d_growable_string_resize (cp-demangle.c:3963)^M
==21225== by 0x76CB31: d_growable_string_init (cp-demangle.c:3942)^M
==21225== by 0x76CB31: cplus_demangle_print (cp-demangle.c:4308)^M
==21225== by 0x4C9535: cp_comp_to_string(demangle_component*, int) (cp-name-parser.y:1972)^M
==21225== by 0x53E1D4: cp_canonicalize_string_full[abi:cxx11](char const*, char const* (*)(type*, void*), void*) (cp-support.c:530)^M
==21225== by 0x53E360: cp_canonicalize_string_no_typedefs[abi:cxx11](char const*) (cp-support.c:548)^M
==21225== by 0x5D51D2: find_linespec_symbols(linespec_state*, VEC_symtab_ptr*, char const*, VEC_symbolp**, VEC_bound_minimal_symbol_d**) (linespec.c:4030)^M
==21225== by 0x5D6CF6: linespec_parse_basic (linespec.c:1907)
==21279== 32 bytes in 1 blocks are definitely lost in loss record 6,066 of 10,947^M
==21279== at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)^M
==21279== by 0x4C2FDEF: realloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)^M
==21279== by 0x76CB31: d_growable_string_resize (cp-demangle.c:3963)^M
==21279== by 0x76CB31: d_growable_string_init (cp-demangle.c:3942)^M
==21279== by 0x76CB31: cplus_demangle_print (cp-demangle.c:4308)^M
==21279== by 0x4C9535: cp_comp_to_string(demangle_component*, int) (cp-name-parser.y:1972)^M
==21279== by 0x53EF14: cp_canonicalize_string[abi:cxx11](char const*) (cp-support.c:569)^M
==21279== by 0x561B75: dwarf2_canonicalize_name(char const*, dwarf2_cu*, obstack*) [clone .isra.210] (dwarf2read.c:20159)
This patch fixes the leak. It is a regression by
2f408ecb.
gdb:
2017-08-09 Alex Lindsay <alexlindsay239@gmail.com>
Yao Qi <yao.qi@linaro.org>
* cp-support.c (cp_canonicalize_string_full): Use
gdb::unique_xmalloc_ptr<char>.
(cp_canonicalize_string): Likewise.
Yao Qi [Wed, 9 Aug 2017 11:27:24 +0000 (12:27 +0100)]
Clean up x86 non-linux GDBserver target descriptions
In GDBserver, only tdesc_i386 and tdesc_amd64 are used. There is no point
of generating these *.dat files (which are used to generate *.c files during
GDBserver build.).
gdb:
2017-08-09 Yao Qi <yao.qi@linaro.org>
* features/Makefile (WHICH): Remove i386/ non-linux stuff.
* regformats/i386/amd64-avx-avx512.dat: Remove.
* regformats/i386/amd64-avx-mpx-avx512-pku.dat: Remove.
* regformats/i386/amd64-avx-mpx.dat:Remove.
* regformats/i386/amd64-avx.dat: Remove.
* regformats/i386/amd64-mpx.dat: Remove.
* regformats/i386/i386-avx-avx512.dat: Remove.
* regformats/i386/i386-avx-mpx-avx512-pku.dat: Remove.
* regformats/i386/i386-avx-mpx.dat: Remove.
* regformats/i386/i386-mmx.dat: Remove.
* regformats/i386/i386-mpx.dat: Remove.
gdb/gdbserver:
2017-08-09 Yao Qi <yao.qi@linaro.org>
* configure.srv (srv_i386_regobj): Remove i386-avx.o,
i386-avx-avx512.o, i386-avx-mpx-avx512-pku.o, i386-mpx.o,
i386-avx-mpx.o and i386-mmx.o.
(srv_amd64_regobj): Remove amd64-avx.o, amd64-avx-avx512.o,
amd64-avx-mpx-avx512-pku.o, amd64-mpx.o and amd64-avx-mpx.o.
(srv_i386_xmlfiles): Remove i386/i386-avx.xml,
i386/i386-avx-avx512.xml, i386/i386-avx-mpx-avx512-pku.xml,
i386/i386-mpx.xml, i386/i386-avx-mpx.xml and i386/i386-mmx.xml.
(srv_amd64_xmlfile):i386/amd64-avx.xml, i386/amd64-avx-avx512.xml,
i386/amd64-avx-mpx-avx512-pku.xml, i386/amd64-mpx.xml,
i386/amd64-avx-mpx.xml.
Yao Qi [Wed, 9 Aug 2017 11:27:23 +0000 (12:27 +0100)]
Remove x32 non-linux target descriptions
x32 non-linux target descriptions are not used in GDB or GDBserver. This
patch removes them.
gdb:
2017-08-09 Yao Qi <yao.qi@linaro.org>
* amd64-tdep.h (tdesc_x32): Remove the declaration.
* amd64-tdep.c: Don't include features/i386/x32*.c.
(_initialize_amd64_tdep): Don't call initialize_tdesc_x32*
functions.
* features/Makefile (WHICH): Remove i386/x32, i386/x32-avx,
and i386/x32-avx-avx512.
(XMLTOC): Remove i386/x32-avx.xml, i386/x32-avx-avx512.xml,
and i386/x32.xml.
* features/i386/x32-avx-avx512.c: Removed.
* features/i386/x32-avx-avx512.xml: Removed.
* features/i386/x32-avx.c: Removed.
* features/i386/x32-avx.xml: Removed.
* features/i386/x32.c: Removed.
* features/i386/x32.xml: Removed.
* regformats/i386/x32-avx-avx512.dat: Removed.
* regformats/i386/x32-avx.dat: Removed.
* regformats/i386/x32.dat: Removed.
gdb/gdbserver:
2017-08-09 Yao Qi <yao.qi@linaro.org>
* configure.srv (srv_amd64_regobj): Remove x32.o, x32-avx.o
and x32-avx-avx512.o.
(srv_amd64_xmlfiles): Remove i386/x32.xml, i386/x32-avx.xml
i386/x32-avx-avx512.xml.
H.J. Lu [Wed, 9 Aug 2017 03:20:43 +0000 (20:20 -0700)]
ld: Require GCC 5 or above for 3 x86 tests
Require GCC 5 or above for 3 x86 tests which fail with GCC 4.9.3.
PR ld/21924
* testsuite/ld-i386/i386.exp: Require GCC 5 or above for
"weakundef1 with PIE" test.
* testsuite/ld-x86-64/tls.exp: Require GCC 5 or above for
"tlsdesc1" and "tlsdesc1 with PIE" tests.
This page took 0.05223 seconds and 4 git commands to generate.