aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2019-10-29Remove unused includes in infcmd.c and infrun.cSimon Marchi3-12/+5
include-what-you-use reported this: ../../../src/binutils-gdb/gdb/infcmd.c should remove these lines: - #include <signal.h> // lines 22-22 - #include "cli/cli-decode.h" // lines 48-48 - #include "cli/cli-utils.h" // lines 56-56 - #include "event-top.h" // lines 38-38 - #include "infcall.h" // lines 57-57 - #include "parser-defs.h" // lines 39-39 ../../../src/binutils-gdb/gdb/infrun.c should remove these lines: - #include <signal.h> // lines 37-37 - #include "cli/cli-script.h" // lines 31-31 - #include "continuations.h" // lines 54-54 - #include "dictionary.h" // lines 45-45 - #include "gdbsupport/gdb_wait.h" // lines 28-28 - #include "interps.h" // lines 55-55 Remove those includes. Tested by rebuilding, and by quick inspection that the include fields were indeed unnecessary. gdb/ChangeLog: * infcmd.c: Remove includes. * infrun.c: Remove includes. Change-Id: I5e25af54ecd2235960c4127add8f604ddbb19153
2019-10-29Clean up ada-lang.hSimon Marchi3-483/+491
This patch cleans up ada-lang.h: - Some functions just don't exist anymore, remove their declaration - Some functions are implemented in ada-lang.c and only used there, make them static to that file. I moved some functions higher in the file to avoid having to forward-declare them, but the implementations are unchanged. gdb/ChangeLog: * ada-lang.h (GROW_VECT): Move to ada-lang.c. (grow_vect): Remove declaration. (ada_type_of_array): Remove declaration. (ada_update_initial_language): Remove declaration. (ada_fold_name): Remove declaration. (ada_fill_in_ada_prototype): Remove declaration. (user_select_syms): Remove declaration. (get_selections): Remove declaration. (ada_tag_type): Remove declaration. (ada_value_tag): Remove declaration. (ada_is_others_clause): Remove declaration. (ada_in_variant): Remove declaration. (ada_value_struct_elt): Remove declaration. (ada_attribute_name): Remove declaration. (ada_system_address_type): Remove declaration. * ada-lang.c (ada_watch_location_expression): Make static. (GROW_VECT): Move here from ada-lang.h. (grow_vect): Make static. (ada_update_initial_language): Make static. (ada_fold_name): Make static. (ada_type_of_array): Make static. (encoded_ordered_before): Move up. (sort_choices): Move up. (print_signatures): Move up. (ada_print_symbol_signature): Move up. (get_selections): Move up and make static. (user_select_syms): Move up and make static. (ada_value_struct_elt): Move up and make static. (ada_tag_type): Make static. (ada_value_tag): Make static. (ada_is_others_clause): Make static. (ada_in_variant): Make static. (ada_attribute_name): Make static. Change-Id: If0d46ba87d6585ab674c87244068a19e84718fc9
2019-10-29Remove unused includes in ada-*.c filesSimon Marchi4-21/+7
include-what-you-use reports: ../../../src/binutils-gdb/gdb/ada-lang.c should remove these lines: - #include <sys/stat.h> // lines 43-43 - #include <map> // lines 66-66 - #include "c-lang.h" // lines 33-33 - #include "demangle.h" // lines 23-23 - #include "dictionary.h" // lines 47-47 - #include "gdbsupport/gdb_vecs.h" // lines 53-53 - #include "psymtab.h" // lines 58-58 ../../../src/binutils-gdb/gdb/ada-lang.c should remove these lines: - #include <sys/stat.h> // lines 43-43 - #include <map> // lines 66-66 - #include "c-lang.h" // lines 33-33 - #include "demangle.h" // lines 23-23 - #include "dictionary.h" // lines 47-47 - #include "gdbsupport/gdb_vecs.h" // lines 53-53 - #include "psymtab.h" // lines 58-58 ../../../src/binutils-gdb/gdb/ada-valprint.c should remove these lines: - #include "c-lang.h" // lines 31-31 - #include "demangle.h" // lines 26-26 - #include "infcall.h" // lines 32-32 - #include "objfiles.h" // lines 33-33 - #include "symtab.h" // lines 22-22 Remove these includes. Adding an include for gdbarch.h in ada-valprint.c was necessary, because gdbarch_byte_order wouldn't be found anymore. gdb/ChangeLog: * ada-lang.c: Remove includes. * ada-typeprint.c: Remove includes. * ada-valprint.c: Remove includes. Change-Id: I07c2f2237ef0ed5fd9aa855d33711d780794fce2
2019-10-29addrmap: use gdb_static_assert for type size assertionsSimon Marchi2-11/+11
These assertions can be done at compile time instead of at runtime. gdb/ChangeLog: * addrmap.c: Add static assertions of type size, moved from _initialize_addrmap. (_initialize_addrmap): Remove. Change-Id: If089fc5d620a7168bdcdf967c6c4fecd6696b670
2019-10-29Change some arguments to gdb::string_view instead of name+lenChristian Biesinger15-147/+188
Just some code cleanup. This change has a few benefits: - Shorter argument list in the functions - If the caller needs to calculate the string, they no longer need to explicitly call strlen - It is easy to pass std::string to this (done in one place currently) This also updates a couple of places that were passing 0/1 to a bool parameter. gdb/ChangeLog: 2019-10-29 Christian Biesinger <cbiesinger@google.com> * coffread.c (record_minimal_symbol): Update. (process_coff_symbol): Update. * dbxread.c (read_dbx_symtab): Update. * dwarf2read.c (add_partial_symbol): Update. (fixup_go_packaging): Update. (load_partial_dies): Update. (new_symbol): Update. * elfread.c (record_minimal_symbol): Change signature to use gdb::string_view instead of name+len. (elf_symtab_read): Update. (elf_rel_plt_read): Update. * mdebugread.c (parse_partial_symbols): Update. (handle_psymbol_enumerators): Update. (new_symbol): Update. * minsyms.c (minimal_symbol_reader::record_full): Change signature to use gdb::string_view instead of name+len. * minsyms.h (class minimal_symbol_reader) <record_full>: Likewise. * psympriv.h (add_psymbol_to_list): Likewise. * psymtab.c (add_psymbol_to_bcache): Likewise. (add_psymbol_to_list): Likewise. * stabsread.c (define_symbol): Update. * symtab.c (symbol_set_names): Change signature to use gdb::string_view. * symtab.h (SYMBOL_SET_NAMES): Likewise. (symbol_set_names): Likewise. * xcoffread.c (scan_xcoff_symtab): Update. Change-Id: I2675c6865e0368f9c755a1081088a53aa54dda4c
2019-10-29Only make a nullterminated string if we need toChristian Biesinger3-19/+28
As of 7bb43059820c5febb4509b15202a93efde442bc6, we no longer need a nullterminated linkage_name to look up the entry in the hash table. So this patch makes it so we only make the copy if the entry was not found. By auditing all callers of symbol_set_names, I found out that all cases where the string may not be nullterminated already pass true for COPY_NAME. So here, I am documenting that as a requirement and am removing the code that relies on undefined behavior in symbol_set_names (it accessed the string past the provided length to check for nulltermination). Note that the Ada case at the beginning of symbol_set_names was already relying on this. gdb/ChangeLog: 2019-10-29 Christian Biesinger <cbiesinger@google.com> * symtab.h (symbol_set_names): Document that copy_name must be set to true for non-nullterminated strings. * symtab.c (symbol_set_names): Only make a nullterminated copy of linkage_name if the entry was not found and we need to demangle. Change-Id: I183302e1f51483ff6dff0fd5c3b0f32f0f04a5d2
2019-10-29Replace bsearch with a std::lower_bound-based searchChristian Biesinger4-14/+77
This is more type-safe and can be faster due to inlining and avoiding overhead from calling through a function pointer. gdb/ChangeLog: 2019-10-29 Christian Biesinger <cbiesinger@google.com> * Makefile.in (HFILES_NO_SRCDIR): Add gdb_binary_search.h. * dwarf2-frame.c (bsearch_fde_cmp): Update. (dwarf2_frame_find_fde): Replace bsearch with gdb::binary_search. * gdbsupport/gdb_binary_search.h: New file. Change-Id: I07e0a0e333f4062b27fc68d3a3f24881ebc68fd4
2019-10-29Load system gdbinit files from a directoryChristian Biesinger11-22/+235
Adds a configure option --with-system-gdbinit-dir to specify a directory in which to look for gdbinit files. All files in this directory are loaded on startup (subject to -n/-nx as usual) as long as the extension matches a known and enabled scripting language (.gdb/.py/.scm). This also changes get_ext_lang_of_file to support ".gdb" files, similar to get_ext_lang_defn's handling of EXT_LANG_GDB. gdb/ChangeLog: 2019-10-29 Christian Biesinger <cbiesinger@google.com> * NEWS: Mention new --with-system-gdbinit-dir option. * config.in: Regenerate. * configure: Regenerate. * configure.ac: Add new option --with-system-gdbinit-dir. * extension.c (get_ext_lang_of_file): Return extension_language_gdb for a ".gdb" suffix. * main.c (get_init_files): Change system_gdbinit argument to a vector and return the files in SYSTEM_GDBINIT_DIR in addition to SYSTEM_GDBINIT. (captured_main_1): Update. (print_gdb_help): Update. * top.c (print_gdb_configuration): Also print the value of SYSTEM_GDBINIT_DIR. gdb/doc/ChangeLog: 2019-10-29 Christian Biesinger <cbiesinger@google.com> * Makefile.in: Also set SYSTEM_GDBINIT_DIR for the info manual generation. * gdb.texinfo (many sections): Document new --with-system-gdbinit-dir option. Change-Id: If233859ecc21bc6421d589b37cd658a3c7d030f2
2019-10-29When copying pe format files, copy the dos_message array, rather than ↵Andrew Eikum5-16/+43
re-initiialising it. * libcoff-in.h (struct pe_tdata): Add dos_message field. * libcoff.h: Regenerate. * peXXigen.c (_bfd_XXi_only_swap_filehdr_out): Copy the dos_message field rather than initialising it. (_bfd_XX_bfd_copy_private_bfd_data_common): Copy the dos_message field. * peicode.h (pe_mkobject): Initialise the dos_message field. (pe_mkobject_hook): Copy the dos_message field. (pe_bfd_object_p): Copy the dos_message field.
2019-10-29Fix array overrun when disassembling corrupt TIC30 binaries.Nick Clifton2-1/+5
* tic30-dis.c (print_branch): Correct size of operand array.
2019-10-29Fix a potential illegal array access in the D30V disassembler.Nick Clifton2-1/+9
* d30v-dis.c (print_insn): Check that operand index is valid before attempting to access the operands array.
2019-10-29Prevent a left shift by a negative value when disassembling IA64 binaries.Nick Clifton2-3/+11
* ia64-opc.c (locate_opcode_ent): Prevent a negative shift when locating the bit to be tested.
2019-10-29Fix array overruns in the S12Z disassembler.Nick Clifton3-16/+56
* s12z-dis.c (opr_emit_disassembly): Check for illegal register values. (shift_size_table): Use a fixed size defined as S12Z_N_SIZES. (print_insn_s12z): Check for illegal size values.
2019-10-29Fix the size of the dos_message field in the internal_extra_pe_filehdr ↵Andrew Eikum2-1/+6
structure on hosts where sizeof(long) == 8. * coff/internal.h (struct internal_extra_pe_filehdr): Use ints instead of longs to hold dos_message.
2019-10-29Re: Optimise away eh_frame advance_loc 0Alan Modra2-1/+12
If we happen to get the fixed and variable parts of the advance_loc in different frags, bad things happen when subtracting one from a fr_fix of zero. PR 25125 * dw2gencfi.c (output_cfi_insn): Don't allow DW_CFA_advance_loc4 to be placed in a different frag to the rs_cfa.
2019-10-29Automatic date update in version.inGDB Administrator1-1/+1
2019-10-28Add a string_view version of startswithChristian Biesinger2-0/+17
Makes sure that the string is longer than prefix, so that strncmp will do the right thing even if the string is not null-terminated. For use in my string_view conversion patch: https://sourceware.org/ml/gdb-patches/2019-10/msg00030.html https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/125 gdb/ChangeLog: 2019-10-28 Christian Biesinger <cbiesinger@google.com> * gdbsupport/common-utils.h (startswith): Add an overloaded version that takes gdb::string_view arguments. Change-Id: I5389855de2fd70e7065a789a79374b0693651b71
2019-10-28Fix potentially illegal shift and assign operation in CSKY disassembler.Nick Clifton2-2/+7
* csky-dis.c (csky_chars_to_number): Check for a negative count. Use an unsigned integer to construct the return value.
2019-10-28Fix buffer overrun in TIC30 disassembler.Nick Clifton2-7/+27
* tic30-dis.c (OPERAND_BUFFER_LEN): Define. Use as length of operand buffer. Set value to 15 not 13. (get_register_operand): Use OPERAND_BUFFER_LEN. (get_indirect_operand): Likewise. (print_two_operand): Likewise. (print_three_operand): Likewise. (print_oar_insn): Likewise.
2019-10-28Stop potential illegal memory access in the NS32K disassembler.Nick Clifton2-1/+17
* ns32k-dis.c (bit_extract): Add sanitiy check of parameters. (bit_extract_simple): Likewise. (bit_copy): Likewise. (pirnt_insn_ns32k): Ensure that uninitialised elements in the index_offset array are not accessed.
2019-10-28Prevent an illegal memory access in the xgate disassembler.Nick Clifton2-3/+8
* xgate-dis.c (print_insn): Fix decoding of the XGATE_OP_DYA operand.
2019-10-28Automatic date update in version.inGDB Administrator1-1/+1
2019-10-27Automatic date update in version.inGDB Administrator1-1/+1
2019-10-26Add some missing casts to suppress implicit cast warningsJohn David Anglin2-5/+12
PR gas/25121 * config/tc-hppa.c (tc_gen_reloc): Cast some enums to int. (md_assemble): Likewise.
2019-10-26Optimise away eh_frame advance_loc 0Alan Modra3-4/+28
These can be generated when multiple cfi directives are emitted for an instruction and the insn frag is closed off between directives, as happens when listings are enabled. No doubt the advance_loc of zero could be avoided by backtracking over frags in dw2gencfi.c before calling cfi_add_advance_loc, but that seems like more work than cleaning up afterwards as this patch does. Noticed when looking at the testcase in PR25125. PR 25125 * dw2gencfi.c (output_cfi_insn): Don't output DW_CFA_advance_loc+0. * ehopt.c (eh_frame_estimate_size_before_relax): Return -1 for an advance_loc of zero. (eh_frame_relax_frag): Translate fr_subtype of 7 to size -1. (eh_frame_convert_frag): Handle fr_subtype of 7. Abort on unexpected fr_subtype.
2019-10-26[gdb] Fix more typos in comments (2)Tom de Vries108-124/+240
Fix typos in comments. NFC. Tested on x86_64-linux. gdb/ChangeLog: 2019-10-26 Tom de Vries <tdevries@suse.de> * aarch64-linux-tdep.c: Fix typos in comments. * aarch64-tdep.c: Same. * ada-lang.c: Same. * amd64-nat.c: Same. * arc-tdep.c: Same. * arch/aarch64-insn.c: Same. * block.c: Same. * breakpoint.h: Same. * btrace.h: Same. * c-varobj.c: Same. * cli/cli-decode.c: Same. * cli/cli-script.c: Same. * cli/cli-utils.h: Same. * coff-pe-read.c: Same. * coffread.c: Same. * compile/compile-cplus-symbols.c: Same. * compile/compile-object-run.c: Same. * completer.c: Same. * corelow.c: Same. * cp-support.c: Same. * demangle.c: Same. * dwarf-index-write.c: Same. * dwarf2-frame.c: Same. * dwarf2-frame.h: Same. * eval.c: Same. * frame-base.h: Same. * frame.h: Same. * gdbcmd.h: Same. * gdbtypes.h: Same. * gnu-nat.c: Same. * guile/scm-objfile.c: Same. * i386-tdep.c: Same. * i386-tdep.h: Same. * infcall.c: Same. * infcall.h: Same. * linux-nat.c: Same. * m68k-tdep.c: Same. * macroexp.c: Same. * memattr.c: Same. * mi/mi-cmd-disas.c: Same. * mi/mi-getopt.h: Same. * mi/mi-main.c: Same. * minsyms.c: Same. * nat/aarch64-sve-linux-sigcontext.h: Same. * objfiles.h: Same. * ppc-linux-nat.c: Same. * ppc-linux-tdep.c: Same. * ppc-tdep.h: Same. * progspace.h: Same. * prologue-value.h: Same. * python/py-evtregistry.c: Same. * python/py-instruction.h: Same. * record-btrace.c: Same. * record-full.c: Same. * remote.c: Same. * rs6000-tdep.c: Same. * ser-tcp.c: Same. * sol-thread.c: Same. * sparc-sol2-tdep.c: Same. * sparc64-tdep.c: Same. * stabsread.c: Same. * symfile.c: Same. * symtab.h: Same. * target.c: Same. * tracepoint.c: Same. * tui/tui-data.h: Same. * tui/tui-io.c: Same. * tui/tui-win.c: Same. * tui/tui.c: Same. * unittests/rsp-low-selftests.c: Same. * user-regs.h: Same. * utils.c: Same. * utils.h: Same. * valarith.c: Same. * valops.c: Same. * valprint.c: Same. * valprint.h: Same. * value.c: Same. * value.h: Same. * varobj.c: Same. * x86-nat.h: Same. * xtensa-tdep.c: Same. gdb/gdbserver/ChangeLog: 2019-10-26 Tom de Vries <tdevries@suse.de> * linux-aarch64-low.c: Fix typos in comments. * linux-arm-low.c: Same. * linux-low.c: Same. * linux-ppc-low.c: Same. * proc-service.c: Same. * regcache.h: Same. * server.c: Same. * tracepoint.c: Same. * win32-low.c: Same. gdb/stubs/ChangeLog: 2019-10-26 Tom de Vries <tdevries@suse.de> * ia64vms-stub.c: Fix typos in comments. * m32r-stub.c: Same. * m68k-stub.c: Same. * sh-stub.c: Same. gdb/testsuite/ChangeLog: 2019-10-26 Tom de Vries <tdevries@suse.de> * gdb.base/bigcore.c: Fix typos in comments. * gdb.base/ctf-ptype.c: Same. * gdb.base/long_long.c: Same. * gdb.dwarf2/dw2-op-out-param.S: Same. * gdb.python/py-evthreads.c: Same. * gdb.reverse/i387-stack-reverse.c: Same. * gdb.trace/tfile.c: Same. * lib/compiler.c: Same. * lib/compiler.cc: Same. Change-Id: I8573d84a577894270179ae30f46c48d806fc1beb
2019-10-26sort_gnu_build_notes fixAlan Modra2-1/+6
* objcopy.c (sort_gnu_build_notes): Correct sort of deleted note2.
2019-10-26Automatic date update in version.inGDB Administrator1-1/+1
2019-10-25elfedit: Report unknown x86 featureH.J. Lu2-1/+8
Report unknown x86 feature: $ ./elfedit --disable-x86-feature foo a.out elfedit: Error: Unknown x86 feature: foo $ * elfedit.c (elf_x86_feature): Report unknown x86 feature.
2019-10-25elfedit.c: Replace BYTE_PUT with byte_putH.J. Lu2-1/+5
Since BYTE_PUT is defined as #define BYTE_PUT(field, val) byte_put (field, val, sizeof (field)) use byte_put, instead of BYTE_PUT, to put 4-byte bitmask at ptr with "byte_put (ptr, bitmask, 4)", instead of "BYTE_PUT (ptr, bitmask)", to work with "unsigned char *ptr". * elfedit.c (update_gnu_property): Replace BYTE_PUT with byte_put.
2019-10-25Fix find_charset_names.Ali Tamur2-4/+7
The patch f2aec7f6d14 changed the return type of relocate_gdb_directory to std::string, but the change is not reflected in find_charset_names function. (Probably missed because the broken code is behind an #ifdef). gdb/ChangeLog * charset.c (find_charset_names): Reflect API change.
2019-10-25Revert unintentional change in symtab.cChristian Biesinger1-1/+1
In the previous commit, I accidentally changed the wrong line; this reverts it to what it should be. gdb/ChangeLog: 2019-10-25 Christian Biesinger <cbiesinger@google.com> * symtab.c (symbol_set_names): Revert unintentional change in the Ada case. Change-Id: I9abf174927687e74c7435bd4607aab7f248c6e79
2019-10-25Don't make an extra copy + allocation of the demangled nameChristian Biesinger2-25/+21
We can just keep around the malloc()-ed name we got from bfd and free it later. gdb/ChangeLog: 2019-10-25 Christian Biesinger <cbiesinger@google.com> * symtab.c (struct demangled_name_entry): Change demangled name to a unique_xmalloc_ptr<char>, now that we don't allocate it as part of the struct anymore. (symbol_set_names): No longer obstack allocate + copy the demangled name, just store the allocated name from bfd. Change-Id: Ie6ad50e1e1e73509f55d756f0a437897bb93e3b0
2019-10-25Improve objcopy's note mergeing capabilities.Nick Clifton19-425/+985
* objcopy.c (struct merged_note_section): New structure. Used to chain together details of mergeable note sections. (is_merged_note_section): Rename to is_megreable_note_section and return true for note sections that use GNU_BUILD_ATTRS_SECTION_NAME as a prefix. (num_bytes): Delete (objcoopy_internal_note): Add padded_namesz field. (DEBUG_MERGE): New macro. Set to non-zero to enable debugging of the note merging code. (gap_exists): Rename to overlaps_or_adjoins and return TRUE for overlapping notes or adjoining notes. (contained_by, is_deleted_note, is_version_note) (compare_gnu_build_notes, sort_gnu_build_notes): New functions. (merge_gnu_build_notes): Rework. Sort notes into a mergeable order first. Merge them. Then sort them into an ascending address order before writing them out. (copy_object): Handle more than one mergeable note section. * testsuite/binutils-all/note-2-32.d: Update for new merging behaviour. * testsuite/binutils-all/note-2-32.s: Likewise. * testsuite/binutils-all/note-2-64.d: Likewise. * testsuite/binutils-all/note-2-64.s: Likewise. * testsuite/binutils-all/note-3-32.d: Likewise. * testsuite/binutils-all/note-3-32.s: Likewise. * testsuite/binutils-all/note-3-64.d: Likewise. * testsuite/binutils-all/note-3-64.s: Likewise. * testsuite/binutils-all/note-4-32.d: Likewise. * testsuite/binutils-all/note-4-32.s: Likewise. * testsuite/binutils-all/note-4-64.d: Likewise. * testsuite/binutils-all/note-4-64.s: Likewise. * testsuite/binutils-all/note-6-32.s: New test source file. * testsuite/binutils-all/note-6-64.s: New test source file. * testsuite/binutils-all/note-6-32.d: New test driver file. * testsuite/binutils-all/note-6-64.d: New test driver file. * testsuite/binutils-all/objcopy.exp: Run the new test.
2019-10-25Fix potential undefined behaviour in the RX disassembler.Nick Clifton2-1/+6
* rx-dis.c (print_insn_rx): Use parenthesis to ensure correct access to opcodes.op array element.
2019-10-25Allow out-of-order reads of CIEsTom Tromey2-75/+25
Currently gdb has an assertion that requires CIEs to be read in the order in which they appear in the debug info: gdb_assert (n < 1 || cie_table->entries[n - 1]->cie_pointer < cie->cie_pointer); This assertion ensures that the table will be sorted, which is important because it is later searched using bsearch. However, a customer provided an executable that causes this assertion to trigger. This executable causes decode_frame_entry_1 to call decode_frame_entry to find the CIE, resulting in an out-of-order read. I don't know a good way to construct a reproducer, but this can happen if the FDE appears before its CIE. See https://sourceware.org/bugzilla/show_bug.cgi?id=16563 This patch fixes the problem by storing CIEs in an unordered map. The CIE table is discarded after the frame section is parsed, so this seemed both simple and straightforward. gdb/ChangeLog 2019-10-25 Tom Tromey <tromey@adacore.com> * dwarf2-frame.c (dwarf2_cie_table): Now a typedef. (bsearch_cie_cmp, add_cie): Remove. (find_cie): Reimplement. (decode_frame_entry_1, decode_frame_entry): Change type. Update. (dwarf2_build_frame_info): Update. Change-Id: I4a99597fa4b1398a9d105b683a36d992d506485c
2019-10-25gdbserver does not need xstrdupTom Tromey2-12/+4
gdbserver has its own implementation of xstrdup. However, because gdbserver links against libiberty now, I think this is not needed. This patch removes it. gdb/gdbserver/ChangeLog 2019-10-25 Tom Tromey <tromey@adacore.com> * utils.c (xstrdup): Remove. Change-Id: I2aa56d18d0f9af8e70a00dff431d2fda5705a5d5
2019-10-25PR25125, relaxation chooses wrong branch sizeAlan Modra2-4/+13
The patch I made for PR12049 didn't test for a "negative" branch properly. "if (target < address)" ought to have been "if (target < address + fragP->fr_fix)". Rather than making that change, this patch adds fragP->fr_fix into address earlier. The patch also avoids running into a bad interaction with the m68k md_prepare_relax_scan by returning zero growth immediately, since the adjusted target expression would result in a zero "aim". PR gas/25125 PR gas/12049 * write.c (relax_frag): Correct calculation of delta for positive branches where "stretch" would make the branch negative. Return zero immediately in that case. Correct TC_PCREL_ADJUST comment.
2019-10-25[gdb/testsuite] Use -wrap and $gdb_test_name in gdb_test_multiple calls (2)Tom de Vries7-51/+47
Make gdb_test_multiple calls shorter by using new gdb_test_multiple variable $gdb_test_name and new gdb_test_multiple pattern flag -wrap. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2019-10-25 Tom de Vries <tdevries@suse.de> * gdb.reverse/sigall-precsave.exp: Use -wrap and $gdb_test_name in gdb_test_multiple calls. * gdb.reverse/sigall-reverse.exp: Same. * gdb.reverse/solib-precsave.exp: Same. * gdb.reverse/solib-reverse.exp: Same. * gdb.reverse/until-precsave.exp: Same. * gdb.reverse/until-reverse.exp: Same. Change-Id: I67bb327d069dbc439410996bcfe6c7f905b2ca52
2019-10-25PR4499, assign file positions assumes segment offsets increasingAlan Modra6-238/+298
This rewrites much of assign_file_positions_for_non_load_sections to allow objcopy and strip to handle cases like that in PR4499 where program headers were not in their usual position immediately after the ELF file header, and PT_LOAD headers were not sorted by paddr. PR 4499 include/ * elf/internal.h (struct elf_segment_map): Delete header_size. Add no_sort_lma and idx. bfd/ * elf-nacl.c (nacl_modify_segment_map): Set no_sort_lma for all PT_LOAD segments. * elf32-spu.c (spu_elf_modify_segment_map): Likewise on overlay PT_LOAD segments. * elf.c (elf_sort_segments): New function. (assign_file_positions_except_relocs): Use shortcuts to elfheader and elf_tdata. Seek to e_phoff not sizeof_ehdr to write program headers. Move PT_PHDR check.. (assign_file_positions_for_non_load_sections): ..and code setting PT_PHDR p_vaddr and p_paddr, and code setting __ehdr_start value.. (assign_file_positions_for_load_sections): ..to here. Sort PT_LOAD headers. Delete header_pad code. Use actual number of headers rather than allocated in calculating size for program headers. Don't assume program headers follow ELF file header. Simplify pt_load_count code. Only set "off" for PT_LOAD or PT_NOTE in cores. (rewrite_elf_program_header): Set p_vaddr_offset for segments that include file and program headers. (copy_elf_program_header): Likewise, replacing header_size code.
2019-10-25readelf PT_PHDR checkAlan Modra2-5/+16
When PT_PHDR isn't covered by a PT_LOAD header, p_vaddr in PT_PHDR isn't valid but the value might just pass a vaddr test. So test p_offset as well. * readelf.c (process_program_headers): Check PT_PHDR p_offset as well as p_vaddr. Use p_filesz, not p_memsz, in vaddr test.
2019-10-25Automatic date update in version.inGDB Administrator1-1/+1
2019-10-24Call forget_cached_source_info to clear the stale source cacheH.J. Lu2-0/+9
Clear the stale source cache when re-reading symbols. PR gdb/25126 * symfile.c (reread_symbols): Call forget_cached_source_info to clear the stale source cache.
2019-10-24Remove python_has_threads check in configure.acChristian Biesinger3-45/+5
The only use of python_has_threads has been removed in commit 404f29021abaef86a341663444fb069eb1f0282a gdb/ChangeLog: 2019-10-24 Christian Biesinger <cbiesinger@google.com> * configure: Rebuild. * configure.ac: Remove code that sets python_has_threads. Change-Id: I75f1b873562bc2abc6f2db17699a3e82fcfd2de3
2019-10-24Simplify Python checks in configure.acChristian Biesinger4-95/+29
The version checking code is not necessary. It is only used to define HAVE_LIBPYTHON2_6 or HAVE_LIBPYTHON2_7, which is not used anywhere. If a version check is desired, the PY_{MAJOR,MINOR}_VERSION macro from the Python headers can be (and is) used, which does not require updating configure.ac whenever a new Python version is released. gdb/ChangeLog: 2019-10-24 Christian Biesinger <cbiesinger@google.com> * config.in: Regenerate. * configure: Regenerate. * configure.ac: Remove the code that uses sed to get the python version and defines HAVE_LIBPYTHON2_6 / HAVE_LIBPYTHON2_7. Change-Id: I07073870d9040c2bc8519882c8b3c1368edd4513
2019-10-24[gdb/testsuite] Add -wrap pattern flag to gdb_test_multipleTom de Vries3-12/+38
Currently, in order to rewrite: ... gdb_test <command> <pattern> <message> ... using gdb_test_multiple, we get: ... gdb_test_multiple <command> <message> { -re "\[\r\n\]*(?:<pattern>)\[\r\n\]+$gdb_prompt $" { pass $gdb_test_name } } ... Add a '-wrap pattern flag to gdb_test_multiple, that wraps the regexp pattern as gdb_test wraps its message argument. This allows us to rewrite into the more compact: ... gdb_test_multiple <command> <message> { -re -wrap <pattern> { pass $gdb_test_name } } ... Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2019-10-24 Tom de Vries <tdevries@suse.de> * lib/gdb.exp (gdb_test_multiple): Add -wrap pattern flag. * gdb.reverse/step-precsave.exp: Rewrite gdb_test_multiple containing kfail using -wrap pattern flag and convenience variable gdb_test_name. Change-Id: Ie42c97d5ab7acf6db351299ccd23a83540fe6e1a
2019-10-24gdb/python: Return None from Progspace.block_for_pc on errorAndrew Burgess4-5/+25
The documentation for Progspace.block_for_pc says: Return the innermost gdb.Block containing the given pc value. If the block cannot be found for the pc value specified, the function will return None. However, the implementation actually throws an error for invalid addresses, like this: (gdb) python print gdb.current_progspace ().block_for_pc (1) Traceback (most recent call last): File "<string>", line 1, in <module> RuntimeError: Cannot locate object file for block. Error while executing Python code. (gdb) This has been the behaviour since the command was first added (when the documentation was still as above) in this commit: commit f3e9a8177c41893858fce2bdf339dbe90b3a4ef5 Date: Wed Feb 24 21:18:28 2010 +0000 Since that commit the code in question has moved around, but the important parts are largely unchanged. The function in question is now in py-progspace.c:pspy_block_for_pc. Examining the code shows that the real state is more complex than just the function throws an error instead of returning None, instead the real situation is: 1. If we can't find a compilation unit for the $pc value then we throw an error, but 2. If we can find a compilation unit, but can't find a block within the compilation unit for the $pc then return None. I suspect for most users of the Python API this distinction is irrelevant, and I propose that we standardise on one single failure mechanism. Given the function can currently return None in some cases, and is documented to return None on error, I propose we make that the case for all error paths, which is what this patch does. As the Progspace.block_for_pc method is currently untested, I've added some basic tests including for a call with an invalid $pc. This is potentially an API breaking change, though an undocumented part of the API. Also, users should have been checking and handling a None return value anyway, so my hope is that this shouldn't be too disruptive. gdb/ChangeLog: * python/py-progspace.c (pspy_block_for_pc): Return None for all error paths. gdb/testsuite/ChangeLog: * gdb.python/py-progspace.exp: Add tests for the Progspace.block_for_pc method. Change-Id: I9cea8d2132902bcad0013d1fd39080dd5423cc57
2019-10-24Automatic date update in version.inGDB Administrator1-1/+1
2019-10-23Fix opcodes includesTom Tromey9-11/+27
Now that gdb can unconditionally use a -I pointing at the top of the source tree, we can remove the ugly "../opcodes/" formulation that was needed earlier. This patch adds the -I and cleans up these includes. gdb/ChangeLog 2019-10-23 Tom Tromey <tom@tromey.com> * arc-tdep.c: Remove ".." from include. * frv-tdep.c: Remove ".." from include. * lm32-tdep.c: Remove ".." from include. * microblaze-tdep.c: Remove ".." from include. * or1k-tdep.h: Remove ".." from include. * s12z-tdep.c: Remove ".." from include. * Makefile.in (OPCODES_CFLAGS): Add comment. (TOP_CFLAGS): New variable. (INTERNAL_CFLAGS_BASE): Add TOP_CFLAGS. Change-Id: I21428726d55f9fab0c9da90b56f6664f258cf91a
2019-10-23Move readline to the readline/readline subdirectoryTom Tromey152-10492/+15564
readline turns out to be a bit of a stumbling block for the project to move gdbsupport (and then gdbserver) to the top-level. The issue is that readline headers are intended to be included with names like "readline/readline.h". To support this, gdb effectively adds a -I option pointing to the top-level source directory -- but, importantly, this option is not used when the system readline is used. For gdbsupport, a -I option like this would always be needed, but that in turn would break the system readline case. This was PR build/17077, fixed in commit a8a5dbcab8df0b3a9e04745d4fe8d64740acb323. Previously, we had discussed this on the gdb-patches list in terms of removing readline from the tree https://sourceware.org/ml/gdb-patches/2019-09/msg00317.html However, Eli expressed some concerns, and Joel did as well (off-list). Given those concerns, and the fact that a patch-free local readline is relatively new in gdb (it was locally patched for years), I changed my mind and decided to handle this situation by moving the readline sources down a level. That is, upstream readline is now in readline/readline, and the top-level readline directory just contains the minimal configury needed to build that. This fixes the problem because, when gdb unconditionally adds a -I$(top_srcdir), this will not find readline headers. A separate -I will be needed instead, which is exactly what's needed for --with-system-readline. gdb/ChangeLog 2019-10-23 Tom Tromey <tom@tromey.com> * Makefile.in (READLINE_DIR): Update. gdb/doc/ChangeLog 2019-10-23 Tom Tromey <tom@tromey.com> * Makefile.in (READLINE_DIR): Update. readline/ChangeLog 2019-10-23 Tom Tromey <tom@tromey.com> Move old contents to readline/ subdirectory. * aclocal.m4, configure, configure.ac, .gitignore, Makefile.am, Makefile.in, README: New files. Change-Id: Ice156a2ee09ea68722b48f64d97146d7428ea9e4