aboutsummaryrefslogtreecommitdiff
path: root/gdb
AgeCommit message (Collapse)AuthorFilesLines
2018-11-20NEWS: Document the language choice by 'info [types|functions|variables]|rbreak'.Philippe Waroquiers2-0/+14
gdb/ChangeLog 2018-11-20 Philippe Waroquiers <philippe.waroquiers@skynet.be> * NEWS: Document the language choice done by 'info [types|functions|variables]|rbreak'.
2018-11-20Document language choice in 'info [functions|variables|types]|rbreak' commandsPhilippe Waroquiers2-0/+35
doc/ChangeLog 2018-11-20 Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.texinfo (Examining the Symbol Table): Document language choice for 'info types|functions|variables' commands. (Setting Breakpoints): Document language choice to print the functions in which a breakpoint is set.
2018-11-20Add a test to verify info [functions|variables|types]|rbreak respect ↵Philippe Waroquiers5-0/+238
language_mode. 2018-11-20 Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.ada/info_auto_lang.exp: New testcase. * gdb.ada/info_auto_lang/global_pack.ads: New file. * gdb.ada/info_auto_lang/proc_in_ada.adb: New file. * gdb.ada/info_auto_lang/some_c.c: New file.
2018-11-20Use scoped_switch_to_sym_language_if_auto in symtab.c to switch language.Philippe Waroquiers4-8/+20
Use scoped_switch_to_sym_language_if_auto in treg_matches_sym_type_name to replace the local logic that was doing the same as the new class scoped_switch_to_sym_language_if_auto. Use scoped_switch_to_sym_language_if_auto inside print_symbol_info, so that symbol information is printed in the symbol language when language mode is auto. This modifies the behaviour of the test dw2-case-insensitive.exp, as the function FUNC_lang is now printed with the Fortran syntax (as declared in the .S file). gdb/ChangeLog 2018-11-20 Philippe Waroquiers <philippe.waroquiers@skynet.be> * symtab.c (treg_matches_sym_type_name): Use scoped_switch_to_sym_language_if_auto instead of local logic. (print_symbol_info): Use scoped_switch_to_sym_language_if_auto to switch to SYM language when language mode is auto. gdb/testsuite/ChangeLog 2018-11-20 Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.dwarf2/dw2-case-insensitive.exp: Update due to auto switch to FUNC_lang language syntax.
2018-11-20Add class scoped_switch_to_sym_language_if_auto.Philippe Waroquiers2-0/+39
The class scoped_switch_to_sym_language_if_auto allows to switch in a scope the current language to the language of a symbol when language mode is set to auto. 2018-11-20 Philippe Waroquiers <philippe.waroquiers@skynet.be> * language.h (scoped_switch_to_sym_language_if_auto): New class.
2018-11-20Test case for 'info variables|functions' with minimal symbols.Philippe Waroquiers3-0/+72
2018-11-20 Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.base/info_minsym.c: New file. * gdb.base/info_minsym.exp: New file.
2018-11-20Fix regression 'info variables' does not show minimal symbols.Philippe Waroquiers2-9/+13
12615cba8411c8 Add [-q] [-t TYPEREGEXP] [NAMEREGEXP] args to info [args|functions|locals|variables] introduced a regression that minimal symbols were not listed anymore, due to a wrong condition checking the absence of a type regexp in the loop scanning the minimal symbols. Instead, before entering the loop scanning the minimal symbols, check that we do not have a type regexp, as we will never match a minimal symbol with this type regexp. With the fix in this patch, for this part of the code, we basically go back to the GDB 8.2 logic, with just the addition of && !treg.has_value ()) to 'enter' in the minsym case. This should ensure that at least there is no regression compared to 8.2, when not using the new type matching argument, as there was no treg in 8.2. 2018-11-20 Philippe Waroquiers <philippe.waroquiers@skynet.be> * symtab.c (search_symbols): Properly check absence of type regexp before entering the loop scanning the minimal symbols.
2018-11-20Fix gdb/ChangeLog formatting and datePedro Alves1-25/+28
2018-11-20GDB: S12Z: new function s12z_extract_return_valueJohn Darrington2-1/+64
Make gdb aware of the return values of functions which return in registers. gdb/ChangeLog: * s12z-tdep.c (s12z_extract_return_value): New function. (inv_reg_perm) New array. (s12z_return_value): Populate readbuf if non-null.
2018-11-20Fix previous change in filestuff.cEli Zaretskii2-0/+5
gdb/ChangeLog: * common/filestuff.c (O_NOINHERIT): Define if not defined.
2018-11-20Avoid "Invalid parameter passed to C runtime function" warningEli Zaretskii2-2/+10
This warning was displayed by OutputDebugString on MinGW when GDB was being debugged natively. gdb/ChangeLog: * common/filestuff.c (gdb_fopen_cloexec): Disable use of "e" mode with 'fopen' also if O_CLOEXEC is equal to O_NOINHERIT, to cater to MinGW fixed by Gnulib.
2018-11-20GDB: S12Z: Add assertionJohn Darrington2-0/+5
gdb/ChangeLog: * s12z-tdep.c (s12z_frame_cache): Add an assertion.
2018-11-19Remove displaced_step_inferior_state::nextSimon Marchi2-3/+4
Commit 39a36629f68e ("Use std::forward_list for displaced_step_inferior_states") missed removing the "next" field, while changing the hand-made linked list in favor of std::forward_list. This patch fixes that. gdb/ChangeLog: * infrun.c (displaced_step_inferior_state) <next>: Remove.
2018-11-19Change get_filename_and_charpos to return voidTom Tromey2-12/+6
The return value from get_filename_and_charpos is never used, so this patch changes it to return void. gdb/ChangeLog 2018-11-19 Tom Tromey <tom@tromey.com> * source.c (get_filename_and_charpos): Return void.
2018-11-19Fix inaccuracies in "info skip" helpSimon Marchi2-7/+8
"help info skip" uses "skip info" in its examples, which is not the same (it ends up creating new skips). Also, the Type column that is referred to doesn't exist today. gdb/ChangeLog: * skip.c (_initialize_step_skip): Fix "info skip" help.
2018-11-19Handle TYPE_CODE_PTR when printing Rust typesTom Tromey5-8/+34
This changes the Rust type printers to handle TYPE_CODE_PTR. The current approach is not ideal, because currently the code can't distinguish between mut and const, or between pointers and references. (These are debuginfo deficiencies, for which there are rustc bugs on file.) Meanwhile, this at least clears up the case seen in PR rust/23625. Tested on x86-64 Fedora 28. The nightly compiler gives the best results, but I regression-tested with stable and beta as well. gdb/ChangeLog 2018-11-16 Tom Tromey <tom@tromey.com> PR rust/23625: * rust-lang.c (rust_internal_print_type): Handle TYPE_CODE_PTR. gdb/testsuite/ChangeLog 2018-11-19 Tom Tromey <tom@tromey.com> PR rust/23625: * gdb.rust/simple.exp: Add ptype test. Update expected output. * gdb.rust/expr.exp: Update expected output. Change one test.
2018-11-19Fix gdb.rust/simple.rs for more recent compilersTom Tromey2-1/+5
gdb.rust/simple.exp will fail when run with a recent version of rustc. This patch fixes the test case so that it will continue to run. Tested on x86-64 Fedora 28. I also temporarily backed out the rust-lang.c from commit 098b2108a2b61531c0bc8ea16854f773083a95d7, and verified that this updated test still would have provoked the original bug. gdb/testsuite/ChangeLog 2018-11-19 Tom Tromey <tom@tromey.com> * gdb.rust/simple.rs: Don't initialize empty_enum_value.
2018-11-19Use std::forward_list for displaced_step_inferior_statesSimon Marchi2-45/+44
Use std::forward_list instead of manually implemented list. This simplifies a bit the code, especially around removal. Regtested on the buildbot. There are some failures as always, but I think they are unrelated. gdb/ChangeLog: * infrun.c (displaced_step_inferior_states): Change type to std::forward_list. (get_displaced_stepping_state): Adjust. (displaced_step_in_progress_any_inferior): Adjust. (add_displaced_stepping_state): Adjust. (remove_displaced_stepping_state): Adjust.
2018-11-19GDB: Add ChangeLog entry inadvertently omitted from commit.John Darrington1-0/+6
2018-11-19gdb.base/warning.exp tweaksPedro Alves2-5/+11
#1- Check that the warning is emitted. #2- Avoid overriding INTERNAL_GDBFLAGS, as per documentated in gdb/testsuite/README: ~~~ The testsuite does not override a value provided by the user. ~~~ We don't actually need to tweak INTERNAL_GDBFLAGS, we just need to append out -data-directory to GDBFLAGS, because each passed -data-directory option leads to a call to the warning: $ ./gdb -data-directory=foo -data-directory=bar Warning: foo: No such file or directory. Warning: bar: No such file or directory. [...] gdb/ChangeLog 2018-11-19 Pedro Alves <palves@redhat.com> * gdb.base/warning.exp: Don't override INTERNAL_FLAGS. Use gdb_spawn_with_cmdline_opts instead of gdb_start. Check that we see the expected warning.
2018-11-18Fix ia64-linux-nat.cTom Tromey4-17/+27
PR build/23814 points out that ia64-linux-nat.c will not compile any more. This patch fixes the problem. Thanks to Andreas Schwab for trying the patch. gdb/ChangeLog 2018-11-18 Tom Tromey <tom@tromey.com> PR build/23814: * target-delegates.c: Rebuild. * ia64-linux-nat.c (class ia64_linux_nat_target) <have_steppable_watchpoint>: Use override. Return true, not 1. (ia64_linux_nat_target::can_use_hw_breakpoint): Rename. Remove "self" argument. (ia64_linux_nat_target::low_new_thread): Rename. (class ia64_linux_nat_target) <read_description>: Don't declare. * target.h (struct target_ops) <have_steppable_watchpoint>: Return bool.
2018-11-16Aarch64: Fix segfault when casting dummy callsAlan Hayward6-28/+182
The following will segfault on aarch64 if foo is in another object, was compiled as c++ and has no debug symbols: (gdb) p (int)foo() This is because aarch64_push_dummy_call determines the return type of the function and then does not check for null pointer. A null pointer for the return type means the call has no debug information. For the code to get here, then the call must have been cast, otherwise we'd error out sooner. In the case of a no-debug-info call cast, the return type is the type the user had cast the call to, but we do not have that information available here. However, aarch64_push_dummy_call only requires the return type in order to calculate lang_struct_return. This information is available in the return_method enum. The fix is to simply use this instead. Adds testcase to check calls across objects, with all combinations of c, c++, debug and no debug. gdb/ChangeLog: PR gdb/22736: * aarch64-tdep.c (aarch64_push_dummy_call): Remove lang_struct_return code. gdb/testsuite/ChangeLog: PR gdb/22736: * gdb.cp/infcall-nodebug-lib.c: New test. * gdb.cp/infcall-nodebug-main.c: New test. * gdb.cp/infcall-nodebug.exp: New file.
2018-11-16Pass return_method to _push_dummy_callAlan Hayward53-165/+271
gdb/ChangeLog: * aarch64-tdep.c (aarch64_push_dummy_call): Replace arg with return_method. * alpha-tdep.c (alpha_push_dummy_call): Likewise. * amd64-tdep.c (amd64_push_arguments): Likewise. (amd64_push_dummy_call): Likewise. * amd64-windows-tdep.c (amd64_windows_push_arguments): Likewise. * arc-tdep.c (arc_push_dummy_call): Likewise. * arm-tdep.c (arm_push_dummy_call): Likewise. * avr-tdep.c (avr_push_dummy_call): Likewise. * bfin-tdep.c (bfin_push_dummy_call): Likewise. * cris-tdep.c (cris_push_dummy_call): Likewise. * csky-tdep.c (csky_push_dummy_call): Likewise. * frv-tdep.c (frv_push_dummy_call): Likewise. * gdbarch.c: Regenerate. * gdbarch.h: Regenerate. * gdbarch.sh (gdbarch_push_dummy_call): Replace arg with return_method. * h8300-tdep.c (h8300_push_dummy_call): Likewise. * hppa-tdep.c (hppa32_push_dummy_call): Likewise. (hppa64_push_dummy_call): Likewise. * i386-darwin-tdep.c (i386_darwin_push_dummy_call): Likewise. * i386-tdep.c (i386_push_dummy_call): Likewise. * ia64-tdep.c (ia64_push_dummy_call): Likewise. * infcall.c (call_function_by_hand_dummy): Likewise. * iq2000-tdep.c (iq2000_push_dummy_call): Likewise. * lm32-tdep.c (lm32_push_dummy_call): Likewise. * m32c-tdep.c (m32c_push_dummy_call): Likewise. * m32r-tdep.c (m32r_push_dummy_call): Likewise. * m68hc11-tdep.c (m68hc11_push_dummy_call): Likewise. * m68k-tdep.c (m68k_push_dummy_call): Likewise. * mep-tdep.c (mep_push_dummy_call): Likewise. * mips-tdep.c (mips_eabi_push_dummy_call): Likewise. (mips_n32n64_push_dummy_call): Likewise. (mips_o32_push_dummy_call): Likewise. (mips_o64_push_dummy_call): Likewise. * mn10300-tdep.c (mn10300_push_dummy_call): Likewise. * msp430-tdep.c (msp430_push_dummy_call): Likewise. * nds32-tdep.c (nds32_push_dummy_call): Likewise. * nios2-tdep.c (nios2_push_dummy_call): Likewise. * or1k-tdep.c (or1k_push_dummy_call): Likewise. * ppc-sysv-tdep.c (ppc_sysv_abi_push_dummy_call): Likewise. (ppc64_sysv_abi_push_dummy_call): Likewise. * ppc-tdep.h (ppc_sysv_abi_push_dummy_call): Likewise. (ppc64_sysv_abi_push_dummy_call): Likewise. * riscv-tdep.c (riscv_push_dummy_call): Likewise. * rl78-tdep.c (rl78_push_dummy_call): Likewise. * rs6000-aix-tdep.c (rs6000_push_dummy_call): Likewise. * rs6000-lynx178-tdep.c (rs6000_lynx178_push_dummy_call): Likewise. * rx-tdep.c (rx_push_dummy_call): Likewise. * s390-tdep.c (s390_push_dummy_call): Likewise. * score-tdep.c (score_push_dummy_call): Likewise. * sh-tdep.c (sh_push_dummy_call_fpu): Likewise. (sh_push_dummy_call_nofpu): Likewise. * sparc-tdep.c (sparc32_store_arguments): Likewise. (sparc32_push_dummy_call): Likewise. * sparc64-tdep.c (sparc64_store_arguments): Likewise. (sparc64_push_dummy_call): Likewise. * spu-tdep.c (spu_push_dummy_call): Likewise. * tic6x-tdep.c (tic6x_push_dummy_call): Likewise. * tilegx-tdep.c (tilegx_push_dummy_call): Likewise. * v850-tdep.c (v850_push_dummy_call): Likewise. * vax-tdep.c (vax_push_dummy_call): Likewise. * xstormy16-tdep.c (xstormy16_push_dummy_call): Likewise. * xtensa-tdep.c (xtensa_push_dummy_call): Likewise.
2018-11-16Use enum for return method for dummy callsAlan Hayward4-18/+63
In call_function_by_hand_dummy, struct_return and hidden_first_param_p are used to represent a single concept. Replace with an enum. gdb/ChangeLog: * gdbarch.sh (enum function_call_return_method): Add enum. * gdbarch.h: Regenerate. * infcall.c (call_function_by_hand_dummy): Replace vars with enum.
2018-11-15Move copy_bitwise unittests to own unittest fileJoel Brobecker4-136/+170
Now that copy_bitwise has been made public, and considering that its implementation could move to a different file again in the future, this patch moves its unittest to its own file in gdb/unittests. gdb/ChangeLog: * unittests/copy_bitwise-selftests.c: New file. * utils.c (selftests::bits_to_str, selftests::check_copy_bitwise) (selftests::copy_bitwise_tests): Delete, moving this code to unittests/copy_bitwise-selftests.c instead. (_initialize_utils): Do not register copy_bitwise tests. * Makefile.in (SUBDIR_UNITTESTS_SRCS): Add unittests/copy_bitwise-selftests.c. Tested on x86_64-linux using the official testsuite, but also by verifying that "maintenance selftests" still runs the copy_bitwise tests.
2018-11-14delete ada-lang.c::move_bits, sharing and re-using copy_bitwise insteadJoel Brobecker5-312/+262
This patch deletes ada-lang.c's move_bits function entirely, and replaces all calls to it by calls to copy_bitwise instead. Because the latter function was declared locally inside dwarf2loc.c, this patch also move the function to a common area, and makes it non-static. gdb/ChangeLog: * ada-lang.c (move_bits): Delete. Update all callers to use copy_bitwise instead. * dwarf2loc.c (copy_bitwise, bits_to_str::bits_to_str) (selftests::check_copy_bitwise, selftests::copy_bitwise_tests): Move from here to utils.c. (_initialize_dwarf2loc): Remove call to register copy_bitwise selftests. * utils.h (copy_bitwise): Add declaration. * utils.c (copy_bitwise, bits_to_str::bits_to_str) (selftests::check_copy_bitwise, selftests::copy_bitwise_tests): Moved here from dwarf2loc.c. (_initialize_utils): Register copy_bitwise selftests. Tested on x86_64-linux, no regression. Also tested using AdaCore's testsuite on a collection of small endian and big endian platforms.
2018-11-14RISC-V: Fix unnamed arg alignment in registers.Jim Wilson2-4/+31
For riscv64-linux target, second half of fix for FAIL: gdb.base/gnu_vector.exp: call add_various_floatvecs Unnamed arguments with 2*XLEN alignment are passed in aligned register pairs. gdb/ * riscv-tdep.c (struct riscv_arg_info): New field is_unnamed. (riscv_call_arg_scalar_int): If unnamed arg with twice xlen alignment, then increment next_regnum if odd. (riscv_arg_location): New arg is_unnamed. Set ainfo->is_unnamed. (riscv_push_dummy_call): New local ftype. Call check_typedef to set function type. Pass new arg to riscv_arg_location based on function type. (riscv_return_value): Pass new arg to riscv_arg_location.
2018-11-14RISC-V: Handle vector type alignment.Jim Wilson2-0/+11
For riscv64-linux target, first half of fix for FAIL: gdb.base/gnu_vector.exp: call add_various_floatvecs GCC gives vectors natural aligment based on total size, not element size, bounded by the maximum supported type alignment. gdb/ * riscv-tdep.c (BIGGEST_ALIGNMENT): New. (riscv_type_alignment) <TYPE_CODE_ARRAY>: If TYPE_VECTOR, return min of TYPE_LENGTH and BIGGEST_ALIGNMENT.
2018-11-14RISC-V: Give stack slots same align as XLEN.Jim Wilson2-2/+9
For riscv64-linux target, fixes FAIL: gdb.base/gnu_vector.exp: call add_many_charvecs Ensure that stack slots are always the same alignment as XLEN by rounding up arg align to xlen. gdb/ * riscv-tdep.c (riscv_call_arg_scalar_int): Use std::min when setting len. New local align, set to max of arg align and xlen, and pass to first riscv_assign_stack_location call.
2018-11-12Add completer for skip numbersSimon Marchi4-7/+74
Add completer to various commands that accept skip numbers: - skip enable - skip disable - skip delete - info skip These commands also accept ranges, the completer works for that but is not very smart. It will suggest invalid ranges, for example when doing "2-<TAB>" it will suggest "1", which would not result in a valid range. Also, it will keep suggesting when doing "1-2-<TAB>", even though it's an invalid syntax. A future idea would be to make a re-usable and well-tested completer for numbers and ranges. I think it could at least be re-used for breakpoint and thread numbers (for example with the "enable breakpoints" command). gdb/ChangeLog: * skip.c (complete_skip_number): New function. (_initialize_step_skip): Add completers to some skip commands. gdb/testsuite/ChangeLog: * gdb.base/skip.exp: Add standard_testfile. Add "skip delete" completer tests.
2018-11-09Remove a VEC from remote.cTom Tromey2-30/+32
This removes the VEC from remote_g_packet_data, replacing it with a std::vector. This is a bit odd in that this object is never destroyed, and is obstack-allocated. I believe a gdbarch is never destroyed, so this seemed ok. Tested by the buildbot. gdb/ChangeLog 2018-11-09 Tom Tromey <tom@tromey.com> * remote.c (remote_g_packet_guess_s): Remove typedef and DEF_VEC. (struct remote_g_packet_data): Derive from allocate_on_obstack. <guesses>: Now a std::vector. (remote_g_packet_data_init, register_remote_g_packet_guess): Update. (remote_read_description_p): Update. Return bool. (remote_target::read_description): Update. (struct remote_g_packet_guess): Add constructor.
2018-11-09Return scoped_fd from open_source_file and find_and_open_sourceTom Tromey6-69/+95
This changes open_source_file and find_and_open_source to return scoped_fd, then updates the callers as appropriate, including using scoped_fd::to_file. Tested by the buildbot. gdb/ChangeLog 2018-11-09 Tom Tromey <tom@tromey.com> * common/scoped_fd.h (class scoped_fd): Add move constructor and move assignment operator. * psymtab.c (psymtab_to_fullname): Update. * source.h (open_source_file): Return scoped_fd. (find_and_open_source): Likewise. * source.c (open_source_file): Return scoped_fd. (get_filename_and_charpos): Update. (print_source_lines_base): Update. Use scoped_fd::to_file. (forward_search_command): Likewise. (reverse_search_command): Likewise. (find_and_open_source): Return scoped_fd. * tui/tui-source.c (tui_set_source_content): Update. Use gdb_file_up.
2018-11-09Fix unsigned overflow in minsyms reader.John Baldwin2-2/+8
Use a ssize_t helper variable for the number of bytes to shrink the msymbols obstack rather than relying on unsigned overflow to shrink the size of the obstack. gdb/ChangeLog: * minsyms.c (minimal_symbol_reader::install): Fix unsigned overflow.
2018-11-09[PowerPC] Document requirements for VSX featurePedro Franco de Carvalho2-5/+12
As suggested in https://sourceware.org/ml/gdb-patches/2018-10/msg00510.html, this patch changes the documentation for the VSX tdesc feature to make it clear that the altivec and FPU features are requirements. gdb/doc/ChangeLog: 2018-11-09 Pedro Franco de Carvalho <pedromfc@linux.ibm.com> * gdb.texinfo (PowerPC Features): Document the altivec and fpu requirements for the org.gnu.gdb.power.vsx feature.
2018-11-09Fix a typo in iconv.m4.Hafiz Abid Qadeer2-1/+5
config/ 2018-11-09 Hafiz Abid Qadeer <abidh@codesourcery.com> * iconv.m4 (AM_ICONV_LINK): Don't overwrite CPPFLAGS. Append $INCICONV to it. gdb/ 2018-11-09 Hafiz Abid Qadeer <abidh@codesourcery.com> * configure: Regenerate. binutils/ 2018-11-09 Hafiz Abid Qadeer <abidh@codesourcery.com> * configure: Regenerate. intl/ 2018-11-09 Hafiz Abid Qadeer <abidh@codesourcery.com> * configure: Regenerate.
2018-11-09[gdb/symtab] Fix language of duplicate static minimal symbolTom de Vries6-7/+94
Consider a test-case with source files msym.c: ... static int foo (void) { return 1; } ... and msym_main.c: ... static int foo (void) { return 2; } int main (void) { return 0; } .. compiled as c++ with minimal symbols: ... $ g++ msym_main.c msym.c ... With objdump -x we find the two foo symbols prefixed with their corresponding files in the symbol table: ... 0000000000000000 l df *ABS* 0000000000000000 msym_main.c 00000000004004c7 l F .text 000000000000000b _ZL3foov 0000000000000000 l df *ABS* 0000000000000000 msym.c 00000000004004dd l F .text 000000000000000b _ZL3foov ... However, when we use gdb to print info on foo, both foos are listed, but we get one symbol mangled and one symbol demangled: ... $ gdb ./a.out -batch -ex "info func foo" All functions matching regular expression "foo": Non-debugging symbols: 0x00000000004004c7 foo() 0x00000000004004dd _ZL3foov ... During minimal symbol reading symbol_set_names is called for each symbol. First, it's called with foo from msym.c, an entry is created in per_bfd->demangled_names_hash and symbol_find_demangled_name is called, which has the side effect of setting the language of the symbol to language_cplus. Then, it's called with foo from msym_main.c. Since per_bfd->demangled_names_hash already has an entry for that name, symbol_find_demangled_name is not called, and the language of the symbol remains language_auto. Fix this by doing the symbol_find_demangled_name call unconditionally. Build and reg-tested on x86_64-linux. gdb/ChangeLog: 2018-11-09 Tom de Vries <tdevries@suse.de> * symtab.c (symbol_set_names): Call symbol_find_demangled_name unconditionally, to set the language of the symbol. Manage freeing returned pointer using gdb::unique_xmalloc_ptr. gdb/testsuite/ChangeLog: 2018-11-09 Tom de Vries <tdevries@suse.de> * gdb.base/msym-lang.c: New test. * gdb.base/msym-lang.exp: New file. * gdb.base/msym-lang-main.c: New test.
2018-11-08Capitalize "<TAB>" in require_record_target errorTom Tromey2-1/+5
This changes require_record_target to say "<TAB>" rather than "<tab>". I think capitalizing here is a bit more GNU-ish, based on Emacs usage and one other case in gdb. gdb/ChangeLog 2018-11-08 Tom Tromey <tom@tromey.com> * record.c (require_record_target): Upper-case "<TAB>".
2018-11-08Fix output indentation for "info pretty-printers"Tom Tromey2-1/+6
I noticed that "info pretty-printers" will indent the "objfile" line like: (top-gdb) info pretty-printer global pretty-printers: builtin mpx_bound128 objfile /home/tromey/gdb/build/gdb/gdb pretty-printers: type_lookup_function I think the "objfile" line should be "out-dented", following the same style as the "global" and "progspace" (not shown) lines. This patch implements this. gdb/ChangeLog 2018-11-08 Tom Tromey <tom@tromey.com> * python/lib/gdb/command/pretty_printers.py (InfoPrettyPrinter.invoke): Don't indent "objfile" heading.
2018-11-08Avoid crash when calling warning too earlyTom Tromey5-3/+59
I noticed that if you pass the name of an existing file (not a directory) as the argument to --data-directory, gdb will crash: $ ./gdb -nx --data-directory ./gdb ../../binutils-gdb/gdb/target.c:590:56: runtime error: member call on null pointer of type 'struct target_ops' This was later reported as PR gdb/23838. This happens because warning ends up calling target_supports_terminal_ours, which calls current_top_target, which returns nullptr this early. This fixes the problem by handling this case specially in target_supports_terminal_ours. I also changed target_supports_terminal_ours to return bool. gdb/ChangeLog 2018-11-08 Tom Tromey <tom@tromey.com> PR gdb/23555: PR gdb/23838: * target.h (target_supports_terminal_ours): Return bool. * target.c (target_supports_terminal_ours): Handle case where current_top_target returns nullptr. Return bool. gdb/testsuite/ChangeLog 2018-11-08 Tom Tromey <tom@tromey.com> PR gdb/23555: PR gdb/23838: * gdb.base/warning.exp: New file.
2018-11-08(AArch64) wrong value returned by "finish" for HFAJoel Brobecker2-1/+6
Consider the gdb.ada/array_return.exp testcase, and in particular, consider the following code... type Small_Float_Vector is array (1 .. 2) of Float; function Create_Small_Float_Vector return Small_Float_Vector is begin return (others => 4.25); end Create_Small_Float_Vector; ... which declares a type which is an array with 2 floats in it (floats are 4 bytes on AArch64), trying to get GDB to print the return value from that function does not work: (gdb) fin Run till exit from #0 pck.create_small_float_vector () at /[...]/pck.adb:15 0x000000000000062c in p () at /[...]/p.adb:11 11 Vector := Create_Small_Float_Vector; Value returned is $1 = (4.25, 0.0) ^^^ ||| We expected the value shown to be: (gdb) fin Run till exit from #0 pck.create_small_float_vector () at /[...]/pck.adb:15 0x000000000000062c in p () at /[...]/p.adb:11 11 Vector := Create_Small_Float_Vector; Value returned is $1 = (4.25, 4.25) Because the return type is an HFA, it is returned via the first two SIMD registers. However, what happens is that the current implementation fails to realize that this is an HFA, and therefore fetches the return value from the wrong location. And the reason why it fails to realize this is because it thinks that our array has 8 elements (HFAs have a maximum of 4). Looking at aapcs_is_vfp_call_or_return_candidate_1, where this is determined, we can easily see why (looks like a thinko): | case TYPE_CODE_ARRAY: | [...] | struct type *target_type = TYPE_TARGET_TYPE (type); | int count = aapcs_is_vfp_call_or_return_candidate_1 | (target_type, fundamental_type); | | if (count == -1) | return count; | !! -> | count *= TYPE_LENGTH (type); | return count; Here, we first determine the count for one element of our array, and so we should then be multiplying that count by the number of elements in our array (2 in our case). But instead, we multiply it by the total size (8). As a result, we do not classify the return type as an HFA, and thus pick the wrong location for fetching the return value. gdb/ChangeLog: * aarch64-tdep.c (aapcs_is_vfp_call_or_return_candidate_1): return the correct count for potential HFAs. Tested on aarch64-linux, fixes: array_return.exp: value printed by finish of Create_Small_Float_Vector
2018-11-08x86-64: fix ZMM register state trackingJan Beulich5-14/+54
The three AVX512 state components are entirely independent - one being in its "init state" has no implication whatsoever on either of the other two. Fully separate X86_XSTATE_ZMM_H and X86_XSTATE_ZMM handling, to prevent upper halves of the upper 16 ZMM registers to display as if they were zero (when they aren't) after e.g. VZEROALL/VZEROUPPER.
2018-11-08gdb/riscv: Update test to support targets without FP hardwareAndrew Burgess2-6/+23
Update gdb.arch/riscv-reg-aliases.exp test to support targets without floating point registers. gdb/testsuite/ChangeLog: * gdb.arch/riscv-reg-aliases.exp: Handle targets without floating point hardware.
2018-11-08gdb/riscv: Handle errors while setting the frame idAndrew Burgess2-3/+21
When we connect to a remote target one of the first things GDB does is establish a frame id. If an error is thrown while building this frame id then GDB will disconnect from the target. This can mean that, if the user is attempting to connect to a target that doesn't yet have a program loaded, or the program the user is going to load onto the target doesn't match what is already loaded, or the target is just in some undefined state, then the very first request for a frame id can fail (for example, by trying to load from an invalid memory address), and GDB will disconnect. It is then impossible for the user to connect to the target and load a new program at all. An example of such a session might look like this: Reading symbols from ./gdb/testsuite/outputs/gdb.arch/riscv-reg-aliases/riscv-reg-aliases... (gdb) target remote :37191 Remote debugging using :37191 0x0000000000000100 in ?? () Cannot access memory at address 0x0 (gdb) load You can't do that when your target is `exec' (gdb) info frame /path/to/gdb/gdb/thread.c:93: internal-error: thread_info* inferior_thread(): Assertion `tp' failed. A problem internal to GDB has been detected, further debugging may prove unreliable. Quit this debugging session? (y or n) The solution is to handle errors in riscv_frame_this_id, and leave the this_id variable with its default value, which is the predefined 'outermost' frame. With this fix in place, connecting to the same target now looks like this: (gdb) target remote :37191 Remote debugging using :37191 0x0000000000000100 in ?? () (gdb) info frame Stack level 0, frame at 0x0: pc = 0x100; saved pc = <not saved> Outermost frame: outermost Arglist at unknown address. Locals at unknown address, Previous frame's sp in sp gdb/ChangeLog: * riscv-tdep.c (riscv_insn::decode): Update header comment. (riscv_frame_this_id): Catch errors thrown while building the frame cache, leave the frame id as the default, which is the outer frame id.
2018-11-07(Ada/tasking) fix array or string index out of range warningJoel Brobecker2-6/+14
A recent change in the compiler highlighted a small weakness in the function reading the contents of the Ada Task Control Block (ATCB -- the data that allows us to inspect Ada tasks). As a result, anytime we read it, we started getting some warnings. For instance, using the gdb.ada/tasks.exp testcase... $ gnatmake -g foo.adb $ gdb foo (gdb) b foo.adb:60 Breakpoint 1 at 0x403e07: file foo.adb, line 60. (gdb) run [...] Thread 1 "foo" hit Breakpoint 1, foo () at foo.adb:60 60 for J in Task_List'Range loop -- STOP_HERE ... we can see that the "info tasks" command produces some warnings, followed by the correct output. (gdb) info tasks !! -> warning: array or string index out of range !! -> warning: array or string index out of range !! -> warning: array or string index out of range !! -> warning: array or string index out of range ID TID P-ID Pri State Name * 1 654050 48 Runnable main_task 2 654ef0 1 48 Accept or Select Term task_list(1) 3 658680 1 48 Accept or Select Term task_list(2) 4 65be10 1 48 Accept or Select Term task_list(3) The problem comes from the fact that read_atcb, the function responsible for loading the contents of the ATCB, blindly tries to read some data which is only relevant when a task is waiting for another task on an entry call. A comment in that code's section gives a hint as to how the information is meant to be decoded: /* Let My_ATCB be the Ada task control block of a task calling the entry of another task; then the Task_Id of the called task is in My_ATCB.Entry_Calls (My_ATCB.ATC_Nesting_Level).Called_Task. */ What the comment shows is that, to get the Id of the task being called, one has to go through the entry calls field, which is an array pointer. Up to now, we were lucky that, for tasks that are _not_ waiting on an entry call, its ATCB atc_nesting_level used to be set to 1, and so we were able to silently read some irrelevant data. But a recent change now causes this field to be zero instead, and this triggers the warning, since we are now trying to read outside of the array's range (arrays in Ada often start at index 1, as is the case here). We avoid this issue by simply only reading that data when the data is actually known to be relevant (state == Entry_Caller_Sleep). This, in turn, allows us to simplify a bit the use of the task_info->state field, where we no longer need to check task the task has a state equal to Entry_Caller_Sleep before using this field. Indeed, with this new approach, we now know that, unless task_info->state == Entry_Caller_Sleep, the state is now guaranteed to be zero. In other words, we no longer set task_info->called_task to some random value, forcing to check the task's state first as a way to verify that the data is not random. gdb/ChangeLog: * ada-lang.c (read_atcb): Only set task_info->called_task if task_info->state == Entry_Caller_Sleep. (print_ada_task_info): Do not check task_info->state before checking task_info->called_task. (info_task): Likewise.
2018-11-07ada-tasks.c::read_atcb: start from a cleared ada_task_info resultJoel Brobecker2-10/+11
The purpose of this patch is not to fix a bug per se, but rather to robustify this function to make sure it never returns a struct ada_task_info where some of the fields are left uninitialized. Reading the current implementation, it attempts to methodically set them all one by one: but it's not excluded that a future change might miss something. A memset is cheap and make sure that this function returns repeatable results. This in turns allows us to remove some assignments which have become redundant. gdb/ChangeLog: * ada-tasks.c (read_atcb): Clear task_info before computing the value of each of its fields.
2018-11-07gdb: Guard against NULL dereference in dwarf2_init_integer_typeAndrew Burgess5-7/+141
In this commit: commit eb77c9df9f6d2f7aa644a170280fe31ce080f887 Date: Thu Oct 18 14:04:27 2018 +0100 gdb: Handle ICC's unexpected void return type A potential dereference of a NULL pointer was introduced if a DW_TAG_base_type is missing a DW_AT_name attribute. I have taken this opportunity to fix a slight confusion that existed in the test also added in the above commit, the test had two C variables, declared like this: int var_a = 5; void *var_ptr = &var_a; However, the fake DWARF in the test script declared them like this: void var_a = 5; void *var_ptr = &var_a; This wasn't a problem as the test never uses 'var_a' directly, this only exists so 'var_ptr' can be initialised. However, it seemed worth fixing. I've also added a test for a DW_TAG_base_type with a missing DW_AT_name, as clearly there's not test currently that covers this (the original patch tested cleanly). I can confirm that the new test causes GDB to crash before this patch, and passes with this patch. gdb/ChangeLog: * dwarf2read.c (dwarf2_init_integer_type): Check for name being NULL before dereferencing it. gdb/testsuite/ChangeLog: * gdb.dwarf2/void-type.exp: Rename types, and make var_a an 'int'. * gdb.dwarf2/missing-type-name.exp: New file.
2018-11-06[gdb] Fix gdb crash when reading core fileTom de Vries5-6/+133
Consider the test-case from this patch, compiled with O0. The executable segfaults, and generates a core dump: ... $ ./a.out Segmentation fault (core dumped) ... When loading the core file, limiting stack size to 4MB, gdb crashes: ... $ ulimit -s 4096 $ gdb -batch ./a.out core.saved [New LWP 19379] Segmentation fault (core dumped) ... The crash originates here in linux_vsyscall_range_raw, where we call alloca with phdrs_size == 4194112 (roughly 4MB): ... phdrs = (Elf_Internal_Phdr *) alloca (phdrs_size); ... While for this test-case gdb runs fine with the system default stack limit of 8MB, there are cases reported of 12MB phdrs_size where gdb also crashes with the system default stack limit. Fix this by using xmalloc instead of alloca, which prevents the crash provided the stack limit is at least 112kb. Build and reg-tested on x86_64-linux. 2018-11-06 Tom de Vries <tdevries@suse.de> * linux-tdep.c (linux_vsyscall_range_raw): Use xmalloc to allocate program headers. * gdb.base/many-headers.c: New test. * gdb.base/many-headers.exp: New file.
2018-11-06RISC-V: Force variables to .data for code_elim.Jim Wilson2-0/+10
RISC-V puts a global variable in .sdata by default, which causes the add-symbol-file commands with -s .data to fail as there is no .data section. This fixes 3 testsuite failures. gdb/testsuite/ * gdb.base/code_elim.exp: For riscv, set additional_flags to include -msmall-data-limit=0.
2018-11-06gdb: xtensa: use linux ABI code for uclinuxMax Filippov2-1/+6
gdb/ 2018-11-06 Max Filippov <jcmvbkbc@gmail.com> * configure.tgt (xtensa*-*-linux*): Change to xtensa*-*-*linux* so that it applies to uclinux as well.
2018-11-06ARM: Do not use FP reg when on AAPCSMarius Muench2-0/+9
GDB tries to dereference the frame pointer in arm_scan_prologue as a last resort to create frame information. However, the more recent AAPCS ABI does not make use of a frame pointer. This patch checks whether the specified arm_abi is AAPCS before dereferencing the "frame pointer". If so, just return as efforts to use it for restoring frame information won't work. gdb/ChangeLog 2018-11-06 Marius Muench <marius.muench@eurecom.fr> * arm-tdep.c (arm_scan_prologue): Don't dereference FP reg when on AAPCS.