aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2021-05-08support generating multi-html pages in parallelMike Frysinger15-27/+106
Use the pattern from other projects where we generate the html pages in a dir named the same as the project. So now we have: gas/doc/gas.html - single html page gas/doc/gas/ - multiple html pages This works for projects that have a doc/ subdir already, but gprof & ld require a little tweaking since they generate their docs in their respective toplevels.
2021-05-08generate single html manual page by defaultMike Frysinger15-8/+43
This better matches other GNU projects like autoconf/automake where the html manual is the single page form. We'll support the multi-page form in a follow up change.
2021-05-08sim: add html & pdf stubsMike Frysinger2-0/+13
We stub out the info targets already since we don't provide any.
2021-05-08sim: use htab_eq_stringTom Tromey2-9/+6
This changes the sim to use htab_eq_string from libiberty. sim/common/ChangeLog 2021-05-08 Tom Tromey <tom@tromey.com> * sim-options.c (compare_strings): Remove. (dup_arg_p): Use htab_eq_string.
2021-05-08Don't run personality syscall at configure time; don't check it at allPedro Alves11-204/+22
Currently, in order to tell whether support for disabling address space randomization on Linux is available, GDB checks if the personality syscall works, at configure time. I.e., it does a run test, instead of a compile/link test: AC_RUN_IFELSE([PERSONALITY_TEST], [have_personality=true], [have_personality=false], This is a bit bogus, because the machine the build is done on may not (and is when you consider distro gdbs) be the machine that eventually runs gdb. It would be better if this were a compile/link test instead, and then at runtime, GDB coped with the personality syscall failing. Actually, GDB already copes. One environment where this is problematic is building GDB in a Docker container -- by default, Docker runs the container with seccomp, with a profile that disables the personality syscall. You can tell Docker to use a less restricted seccomp profile, but I think we should just fix it in GDB. "man 2 personality" says: This system call first appeared in Linux 1.1.20 (and thus first in a stable kernel release with Linux 1.2.0); library support was added in glibc 2.3. ... ADDR_NO_RANDOMIZE (since Linux 2.6.12) With this flag set, disable address-space-layout randomization. glibc 2.3 was released in 2002. Linux 2.6.12 was released in 2005. The original patch that added the configure checks was submitted in 2008. The first version of the patch that was submitted to the list called personality from common code: https://sourceware.org/pipermail/gdb-patches/2008-June/058204.html and then was moved to Linux-specific code: https://sourceware.org/pipermail/gdb-patches/2008-June/058209.html Since HAVE_PERSONALITY is only checked in Linux code, and ADDR_NO_RANDOMIZE exists for over 15 years, I propose just completely removing the configure checks. If for some odd reason, some remotely modern system still needs a configure check, then we can revert this commit but drop the AC_RUN_IFELSE in favor of always doing the AC_LINK_IFELSE cross-compile fallback. gdb/ChangeLog: * linux-nat.c (linux_nat_target::supports_disable_randomization): Remove references to HAVE_PERSONALITY. * nat/linux-personality.c: Remove references to HAVE_PERSONALITY. (maybe_disable_address_space_randomization) (~maybe_disable_address_space_randomizatio): Remove references to HAVE_PERSONALITY. * config.in, configure: Regenerate. gdbserver/ChangeLog: * linux-low.cc: (linux_process_target::supports_disable_randomization): Remove reference to HAVE_PERSONALITY. * config.in, configure: Regenerate. gdbsupport/ChangeLog: * common.m4 (personality test): Remove.
2021-05-08Don't include sys/personality.h in linux-low.cc anymorePedro Alves2-7/+5
Lancelot pointed out that since the refactor at: https://sourceware.org/pipermail/gdb-patches/2015-January/120503.html the sys/personality.h include is not needed in linux-low.cc anymore, as it does not call personality directly itself anymore. gdbserver/ChangeLog: * linux-low.cc: Don't include sys/personality.h or define ADDR_NO_RANDOMIZE.
2021-05-07sim: m68hc11: fix up cycle buffer printingMike Frysinger2-5/+8
Make sure the local static buffer is large enough, and simplify the sprintf for merging the fields all into one. This fixes compiler warnings from buf possibly being overflowed.
2021-05-08Automatic date update in version.inGDB Administrator1-1/+1
2021-05-07gdb/guile: perform tilde expansion when sourcing guile scriptsAndrew Burgess4-2/+28
Before this patch: (gdb) source ~/script.scm ERROR: In procedure apply-smob/1: ERROR: In procedure primitive-load-path: Unable to find file "~/script.scm" in load path Error while executing Scheme code. (gdb) This is because the path is not tilde expanded. In contrast, when sourcing a .py or .gdb script the path is tilde expanded. This commit fixes this oversight, and allows the above source command to work as expected. The tilde expansion is done in the generic GDB code before we call the sourcer function for any particular extension language. gdb/ChangeLog: * cli/cli-cmds.c: Add 'gdbsupport/gdb_tilde_expand.h' include. (source_script_with_search): Perform tilde expansion. gdb/testsuite/ChangeLog: * gdb.guile/guile.exp: Add an extra test.
2021-05-07gdb/testsuite: use gdb_test_no_output instead of send_gdbAndrew Burgess2-2/+7
I noticed gdb.base/ptype-offsets.exp failing occasionally, this was due to lines like this in the test script: send_gdb "set print type hex on\n" As this does not match the '(gdb)' prompt that is produced, the prompt would sometimes be matched against the next test, causing the next test to think its output was missing and fail. Fix this by switching to: gdb_test_no_output "set print type hex on" gdb/testsuite/ChangeLog: * gdb.base/ptype-offsets.exp: Replace use of send_gdb with gdb_test_no_output.
2021-05-07gdb: make target_desc_info::filename an std::stringSimon Marchi2-20/+26
To make the management of memory automatic. As to why I chose to make this an std::string and not an std::unique_xmalloc_ptr<char>: some parts of the code consider both a NULL value and an empty string value to mean "no filename". target_desc_info_from_user_p, however, doesn't check for a non-NULL but empty string value. So it seems like having two ways of denoting "no filename" can lead to these kinds of inconsistencies. Using std::string, "no filename" is only represented by an empty value. As a bonus, using an std::string lets us copy target_desc_info objects using the default assignment operator. gdb/ChangeLog: * target-descriptions.c (struct target_desc_info) <filename>: Make std::string. (copy_inferior_target_desc_info): Adjust. (target_desc_info_free): Adjust. (target_find_description): Adjust. (set_tdesc_filename_cmd): Adjust. (show_tdesc_filename_cmd): Adjust. (unset_tdesc_filename_cmd): Adjust. (maint_print_c_tdesc_cmd): Adjust. Change-Id: I4e3a6ad8ccda2b88c202471d4f54249753cad127
2021-05-07gdb: (de-)allocate target_desc_info with new/deleteSimon Marchi2-5/+13
In preparation for using non-POD types in the struct. gdb/ChangeLog: * target-descriptions.c (struct target_desc_info): Initialize fields. (get_tdesc_info): Use new. (target_desc_info_free): Use delete. Change-Id: I10fdaeeae7cdbd7930ae7adeeb13f7f363c67c7a
2021-05-07gdb: change target_desc_info::fetched to boolSimon Marchi2-3/+10
gdb/ChangeLog: * target-descriptions.c (struct target_desc_info) <fetched>: bool. (target_find_description): Adjust. (target_clear_description): Adjust. Change-Id: Ib69e097b38cf270e674f1249105d535a312954e1
2021-05-07gdb: remove target description macrosSimon Marchi2-38/+53
In my opinion, the target_desc_fetched, current_target_desc and target_description_filename macros in target-descriptions.c are not very useful. I don't think it's useful to hide that they operate on the current inferior, as everything currently works under the assumption that the various tdesc commands operate on the current inferior, and I don't see that changing in the foreseeable future. This change also avoids having multiple unnecessary calls to current_inferior and get_tdesc_info per function. gdb/ChangeLog: * target-descriptions.c (struct target_desc_info) <tdesc>: Adjust doc. (target_desc_fetched): Remove. (current_target_desc): Remove. (target_description_filename): Remove. (target_find_description): Adjust. (target_clear_description): Adjust. (target_current_description): Adjust. (set_tdesc_filename_cmd): Adjust. (show_tdesc_filename_cmd): Adjust. (unset_tdesc_filename_cmd): Adjust. (maint_print_c_tdesc_cmd): Adjust. (maint_print_xml_tdesc_cmd): Adjust. Change-Id: Ibfb581490e949c16d59924e2cac633ede5c26c5b
2021-05-07sim: Add bfd include path for common testsuite toolsDimitar Dimitrov4-2/+12
On a host without installed libbfd, this patch fixes the following "make check-sim" errors for both pru cross target, and native x86_64: In file included from ../../../binutils/sim/common/sim-basics.h:131, from testsuite/common/bits32m0.c:13:../../../binutils/sim/../include/gdb/callback.h:55:10: fatal error: bfd.h: No such file or directory 55 | #include "bfd.h" | ^~~~~~~ Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
2021-05-07Add a generic .bss directive for ELF based targets.Nick Clifton4-14/+65
PR 3136 * config/obj-elf.c (elf_pseudo_table): Add entry for .bss. (obj_elf_bss): New function. Change to the .bss section. Support an optional subsection number. (obj_elf_change_section): Call obj_elf_section_change_hook. (obj_elf_section): Likewise. (obj_elf_data): Likewise. (obj_elf_text): Likewise. (obj_elf_struct): Likewise. (obj_elf_subsection): Likewise. (obj_elf_previous): Likewise. * config/obj-elf.h (obj_elf_bss): Prototype. * doc/as.texi (Bss): New node.
2021-05-07gdb: some int to bool conversionAndrew Burgess4-7/+18
Change int parameter to bool in remote_notice_new_inferior (remote.c) and notice_new_inferior (infcmd.c), and update the callers. There should be no user visible changes after this commit. gdb/ChangeLog: * infcmd.c (notice_new_inferior): Change parameter type. * inferior.h (notice_new_inferior): Change parameter type. * remote.c (remote_notice_new_inferior): Change parameter type to bool. Also update type of local variable to bool. (remote_target::update_thread_list): Change type of local variable to bool. (remote_target::process_stop_reply): Pass bool instead of int to remote_notice_new_inferior.
2021-05-07gdb: remove reference to current inferior in target_stack::unpushSimon Marchi2-1/+6
target_stack::unpush needs to get the target beneath the target being unpushed to update the m_top field (which keeps the stratum of the top-most target). It currently does so using target_ops::beneath, which uses the target stack of the current inferior. The target stack of the current inferior is the same as the `this` in the unpush method. Avoid this detour and remove this reference to the current inferior by calling target_ops::find_beneath and passing `this` to find the target beneath `t` in the target stack that is `this`. gdb/ChangeLog: * target.c (target_stack::unpush): Call target_ops::find_beneath to get the target beneath `t`. Change-Id: If9d9661567c5c16f655d270bd2ec9f1b3aa6dadc
2021-05-07gdb: make target_close check that the target isn't pushed in all inferiorsSimon Marchi2-1/+7
The target_close function currently checks that the target to be closed isn't pushed in the current inferior: gdb_assert (!current_inferior ()->target_is_pushed (targ)); Normally, a target is closed when its refcount has dropped to 0, due to not being used in any inferior anymore. I think it would make sense to change that assert to not only check in the current inferior, but to check in all inferiors. It would be quite bad (and a bug) to close a target while it's still pushed in one of the non-current inferiors. gdb/ChangeLog: * target.c (target_close): Check in all inferiors that the target is not pushed. Change-Id: I6e37fc3f3476a0593da1e476604642b2de90f1d5
2021-05-07debuginfod-support.c: Use long-lived debuginfod_clientAaron Merey2-12/+25
Instead of initializing a new debuginfod_client for each query, store the first initialized client for the remainder of the GDB session and use it for every debuginfod query. In conjunction with upcoming changes to libdebuginfod, using one client for all queries will avoid latency caused by unneccesarily setting up TCP connections multiple times. Tested on Fedora 33 x86_64. gdb/ChangeLog: * debuginfod-support.c (debuginfod_init): Remove. (get_debuginfod_client): New function.
2021-05-07Remove streq_hash in favor of htab_eq_stringTom Tromey6-16/+13
Now that libiberty includes htab_eq_string, we can remove the identical function from gdb. gdb/ChangeLog 2021-05-07 Tom Tromey <tom@tromey.com> * breakpoint.c (ambiguous_names_p): Use htab_eq_string. * utils.c (streq_hash): Remove. * utils.h (streq_hash): Don't declare. * completer.c (completion_tracker::discard_completions): Update comment. * ada-lang.c (_initialize_ada_language): Use htab_eq_string.
2021-05-07gdb: re-format Python files using black 21.4b0Simon Marchi84-1835/+2348
Re-format all Python files using black [1] version 21.4b0. The goal is that from now on, we keep all Python files formatted using black. And that we never have to discuss formatting during review (for these files at least) ever again. One change is needed in gdb.python/py-prettyprint.exp, because it matches the string representation of an exception, which shows source code. So the change in formatting must be replicated in the expected regexp. To document our usage of black I plan on adding this to the "GDB Python Coding Standards" wiki page [2]: --8<-- All Python source files under the `gdb/` directory must be formatted using black version 21.4b0. This specific version can be installed using: $ pip3 install 'black == 21.4b0' All you need to do to re-format files is run `black <file/directory>`, and black will re-format any Python file it finds in there. It runs quite fast, so the simplest is to do: $ black gdb/ from the top-level. If you notice that black produces changes unrelated to your patch, it's probably because someone forgot to run it before you. In this case, don't include unrelated hunks in your patch. Push an obvious patch fixing the formatting and rebase your work on top of that. -->8-- Once this is merged, I plan on setting a up an `ignoreRevsFile` config so that git-blame ignores this commit, as described here: https://github.com/psf/black#migrating-your-code-style-without-ruining-git-blame I also plan on working on a git commit hook (checked in the repo) to automatically check the formatting of the Python files on commit. [1] https://pypi.org/project/black/ [2] https://sourceware.org/gdb/wiki/Internals%20GDB-Python-Coding-Standards gdb/ChangeLog: * Re-format all Python files using black. gdb/testsuite/ChangeLog: * Re-format all Python files using black. * gdb.python/py-prettyprint.exp (run_lang_tests): Adjust. Change-Id: I28588a22c2406afd6bc2703774ddfff47cd61919
2021-05-07gdb: add lookup_cmd_exact to simplify a common patternMarco Barisione3-17/+40
In code dealing with commands, there's a pattern repeated a few times of calling lookup_cmd with some speficic arguments and then using strcmp on the returned command to check for an exact match. As a later patch would add a few more similar lines of code, this patch adds a new lookup_cmd_exact function which simplify this use case. gdb/ChangeLog: * cli/cli-decode.c (lookup_cmd_exact): Add. * cli/cli-script.c (do_define_command): Use lookup_cmd_exact. (define_prefix_command): Ditto. * command.h: Add lookup_cmd_exact.
2021-05-07Fix .dwsect generation for XCOFF. Handle .function generated with DWARF on ↵Cl?ment Chigot18-7/+248
XCOFF. gas * config/tc-ppc.c (ppc_function): Update comment for fifth argument. (ppc_frob_symbol): Remove ppc_last_function check. Make sure coff_last_function is reset. Correctly set fsize when not provided in .function. * testsuite/gas/ppc/aix.exp: New tests. * testsuite/gas/ppc/xcoff-function-1-32.d: New test. * testsuite/gas/ppc/xcoff-function-1-64.d: New test. * testsuite/gas/ppc/xcoff-function-1.s: New test. bfd * coff-rs6000.c (xcoff_dwsect_names): Add new DWARF sections. * coffgen.c (coff_pointerize_aux): Handle C_DWARF. (coff_print_symbol): Likewise. * libxcoff.h (XCOFF_DWSECT_NBR_NAMES): Update. gas * config/obj-coff.c (coff_frob_symbol): Don't skip C_DWARF. (coff_adjust_section_syms): Use corrext auxent for C_DWARF. (coff_frob_section): Likewise. * config/obj-coff.h (SA_GET_SECT_SCNLEN, SA_GET_SECT_NRELOC, SA_SET_SECT_SCNLEN, SA_SET_SECT_NRELOC) New defines. (SET_SECTION_RELOCS): Adjust for C_DWARF. * config/tc-ppc.c (ppc_frob_symbol): Don't skip C_DWARF. (ppc_adjust_symtab): Reorder C_DWARF symbols. * testsuite/gas/ppc/aix.exp: New tests. * testsuite/gas/ppc/xcoff-dwsect-2-32.d: New test. * testsuite/gas/ppc/xcoff-dwsect-2-64.d: New test. * testsuite/gas/ppc/xcoff-dwsect-2.s: New test. include * coff/internal.h (C_DWARF): New define. * coff/xcoff.h (SSUBTYP_DWLOC, SSUBTYP_DWFRAME, SSUBTYP_DWMAC): New defines.
2021-05-07Srop readelf's unwind decoder from complaining about x86 binaries.Nick Clifton2-0/+15
* readelf.c (no_processor_specific_unwind): New function. (process_unwind): Use no_processor_specific_unwind for X86 targets.
2021-05-07libiberty: add htab_eq_stringTom Tromey2-0/+10
The libiberty hash table includes a helper function for strings, but no equality function. Consequently, this equality function has been reimplemented a number of times in both the gcc and binutils-gdb source trees. This patch adds the function to the libiberty hash table, as a step toward the goal of removing all the copies. One change to gcc is included here. Normally I would have put this in the next patch, but gensupport.c used the most natural name for its reimplementation of this function, and this can't coexist with the extern function in libiberty. include * hashtab.h (htab_eq_string): Declare. libiberty * hashtab.c (htab_eq_string): New function.
2021-05-07[gdb/symtab] Fix infinite recursion in dwarf2_cu::get_builder()Tom de Vries4-25/+18
With the test-case attached in PR26327, gdb aborts: ... $ gdb -q -batch 447.dealII -ex "b main" Aborted (core dumped) ... when running out of stack due to infinite recursion: ... #8 0x00000000006aaba6 in dwarf2_cu::get_builder (this=0x35e4b40) at src/gdb/dwarf2/read.c:700 #9 0x00000000006aaba6 in dwarf2_cu::get_builder (this=0x22ee2c0) at src/gdb/dwarf2/read.c:700 #10 0x00000000006aaba6 in dwarf2_cu::get_builder (this=0x35e4b40) at src/gdb/dwarf2/read.c:700 #11 0x00000000006aaba6 in dwarf2_cu::get_builder (this=0x22ee2c0) at src/gdb/dwarf2/read.c:700 ... We're recursing in this code in dwarf2_cu::get_builder(): ... /* Otherwise, search ancestors for a valid builder. */ if (ancestor != nullptr) return ancestor->get_builder (); ... due to the fact that the ancestor chain is a cycle. Higher up in the call stack, we find some code that is responsible for triggering this, in new_symbol: ... case DW_TAG_formal_parameter: { /* If we are inside a function, mark this as an argument. If not, we might be looking at an argument to an inlined function when we do not have enough information to show inlined frames; pretend it's a local variable in that case so that the user can still see it. */ struct context_stack *curr = cu->get_builder ()->get_current_context_stack (); if (curr != nullptr && curr->name != nullptr) SYMBOL_IS_ARGUMENT (sym) = 1; ... This is code that was added to support pre-4.1 gcc, to be able to show arguments of inlined functions as locals, in the absense of sufficiently correct debug information. Removing this code (that is, doing SYMBOL_IS_ARGUMENT (sym) = 1 unconditially), fixes the crash. The ancestor variable also seems to have been added specifically to deal with fallout from this code, so remove that as well. Tested on x86_64-linux: - openSUSE Leap 15.2 with gcc 7.5.0, and - openSUSE Tumbleweed with gcc 10.3.0. gdb/ChangeLog: 2021-05-07 Tom de Vries <tdevries@suse.de> PR symtab/26327 * dwarf2/read.c (struct dwarf2_cu): Remove ancestor. (dwarf2_cu::get_builder): Remove ancestor-related code. (new_symbol): Remove code supporting pre-4.1 gcc that show arguments of inlined functions as locals. (follow_die_offset, follow_die_sig_1): Remove setting of ancestor. gdb/doc/ChangeLog: 2021-05-07 Tom de Vries <tdevries@suse.de> PR symtab/26327 * gdb.texinfo (Inline Functions): Update.
2021-05-07x86-64/ELF: clear src_mask for all reloc typesJan Beulich9-67/+119
x86-64 uses rela relocations. The comment next to the field's declaration says "Non-zero values for ELF USE_RELA targets should be viewed with suspicion ..." And indeed the fields being non-zero causes section contents to be accumulated into the final relocated values in addition to the relocations' addends, which is contrary to the ELF spec.
2021-05-07x86: don't mix disp and imm processingJan Beulich2-1/+6
Surely disp processing should access the disp operand, not an imm one. This is not an active issue only because imms and disps are, at the moment, overlapping fields of the same union.
2021-05-07x86: move register check in immediate operand parsingJan Beulich2-7/+13
i386_finalize_immediate() is used for both AT&T and Intel immediate operand handling. Move an AT&T-only check to i386_immediate(), which at the same time allows it to cover other cases as well, giving an overall better / more consistent diagnostic.
2021-05-07x86: minor improvements to optimize_imm()Jan Beulich2-8/+11
- Drop a pointless & where just before it was checked that the respective bits are clear already anyway. - Avoid a not really necessary operand_type_set() and a redundant operand_type_or() / operand_type_and() pair.
2021-05-07When computing section link order for a relocateable link, ignore section sizes.Nick Clifton2-6/+14
* ldelfgen.c (compare_link_order): Ignore section size when performing a relocateable link.
2021-05-07gdb/guile: Have gdbscm_safe_source_script return a unique_ptrAndrew Burgess5-15/+18
Change gdbscm_safe_source_script to return a gdb::unique_xmalloc_ptr<char> instead of a raw char*. Update the users of this function. There should be no user visible change after this commit. gdb/ChangeLog: * guile/guile-internal.h (gdbscm_safe_source_script): Change function return type. * guile/guile.c (gdbscm_source_script): Update to handle change in gdbscm_safe_source_script. * guile/scm-objfile.c (gdbscm_source_objfile_script): Likewise. * guile/scm-safe-call.c (gdbscm_safe_source_script): Change return type.
2021-05-07dwarf: Don't omit second operand of '?' operatorMichael Forney2-3/+11
This is a GNU C extension and is not valid in ISO C. * dwarf.c: Don't omit second operand of '?' operator.
2021-05-07multiple definition warnings from script symbolsAlan Modra3-4/+14
In commit 89753bbf81 I enabled a warning for scripts redefining symbols. The idea was to not warn for symbols defined by shared libraries (the h->u.def.section->output_section != NULL test), but the test failed to take into account absolute symbols. Absolute symbols defined in shared libraries are currently indistinguishable from absolute symbols defined in relocatable objects, at least when only looking at struct bfd_link_hash_entry. So, don't warn for any absolute symbols. * ldexp.c (update_definedness): Don't return false for absolute symbols. * ldmain.c (multiple_definition): Print "warning: " in message when not a hard error.
2021-05-07sim: m32c: clean up various warningsMike Frysinger5-21/+41
A random grab bag of minor fixes to enable -Werror for this port. Check the return values of read & write calls and issue warnings when they fail. Fixup funky pointer math as the compiler doesn't like ++ on void*. Handle short reads with fread().
2021-05-07sim: m32c: fix warnings about mixing code & declsMike Frysinger3-1/+31
Add scope braces to a bunch of the generated sections to avoid compiler warnings about mixing code & variable declarations.
2021-05-07sim: m32c: switch from custom fgets to getlineMike Frysinger5-105/+17
No need to implement this ourselves when POSIX has a nice API.
2021-05-06sim: m68hc11: fix up last warningsMike Frysinger4-105/+113
Change the printf formats a little to fix the last build warnings in here, and then turn on -Werror by default for the arch port.
2021-05-06sim: m68hc11: warn when emul_write failsMike Frysinger2-2/+10
Not sure what we should do here when this fails, so just emit a warning for now to satisfy unused result compiler warnings. We can see if any users actually notice here.
2021-05-07Regenerate bfd-in2.h and libbfd.hAlan Modra3-2/+7
Commit 0b3e14c90283 edited these by hand. * bfd-in2.h: Regenerate. * libbfd.h: Regenerate.
2021-05-07Automatic date update in version.inGDB Administrator1-1/+1
2021-05-07Re: elf: Always append ".COUNT" to local symbolsAlan Modra3-4/+7
Fixes XPASSes on frv-linux. * testsuite/ld-elf/pr27825-1.d: Correct xfail. * testsuite/ld-elf/pr27825-2.d: Likewise.
2021-05-06gdb: make inferior::args a unique_xmalloc_ptrSimon Marchi4-6/+16
Use unique_xmalloc_ptr to avoid manual memory management. gdb/ChangeLog: * inferior.h (class inferior) <args>: Change type to unique_xmalloc_ptr. * inferior.c (inferior::~inferior): Don't free args. * infcmd.c (get_inferior_args): Adjust. (set_inferior_args): Adjust. Change-Id: I96300e59eb2faf2d80660416a8f5694d243a944e
2021-05-06gdbserver/server: make some functions voidTankut Baris Aktemur2-24/+16
The 'handle_v_attach', 'handle_v_run', and 'handle_v_kill' functions' return values are unused. They indicate error/success result by putting packets. Make the functions void. Tested by rebuilding. gdbserver/ChangeLog: 2021-05-06 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> * server.cc (handle_v_attach) (handle_v_run) (handle_v_kill): Make void.
2021-05-06or1k: Support large plt_relocs when generating plt entriesStafford Horne9-39/+248
The current PLT generation code will generate invalid code when the PLT relocation offset exceeds 64k. This fixes the issue by detecting large plt_reloc offsets and generare code sequences to create larger plt relocations. The "large" plt code needs 2 extra instructions to create 32-bit offsets. bfd/ChangeLog: PR 27746 * elf32-or1k.c (PLT_ENTRY_SIZE_LARGE, PLT_MAX_INSN_COUNT, OR1K_ADD, OR1K_ORI): New macros to help with plt creation. (elf_or1k_link_hash_table): New field plt_count. (elf_or1k_link_hash_entry): New field plt_index. (elf_or1k_plt_entry_size): New function. (or1k_write_plt_entry): Update to support variable size PLTs. (or1k_elf_finish_dynamic_sections): Use new or1k_write_plt_entry API. (or1k_elf_finish_dynamic_symbol): Update to write large PLTs when needed. (allocate_dynrelocs): Use elf_or1k_plt_entry_size to account for PLT size. ld/ChangeLog: PR 27746 testsuite/ld-or1k/or1k.exp (or1kplttests): Add tests for linking along with gotha() relocations. testsuite/ld-or1k/gotha1.dd: New file. testsuite/ld-or1k/gotha1.s: New file. testsuite/ld-or1k/gotha2.dd: New file. testsuite/ld-or1k/gotha2.s: New file testsuite/ld-or1k/pltlib.s (x): Define size to avoid link failure.
2021-05-06or1k: Avoid R_OR1K_GOT16 overflow failures in presence of R_OR1K_GOT_AHI16Stafford Horne2-0/+18
Now that we support R_OR1K_GOT_AHI16 we can relax the R_OR1K_GOT16 overflow validation check if the section has R_OR1K_GOT_AHI16. We cannot simple disable R_OR1K_GOT16 overflow validation as there will still be binaries that will have only R_OR1K_GOT16. The R_OR1K_GOT_AHI16 relocation will only be added by GCC when building with the option -mcmodel=large. This assumes that R_OR1K_GOT_AHI16 will come before R_OR1K_GOT16, which is the code pattern that will be emitted by GCC. bfd/ChangeLog: PR 21464 * elf32-or1k.c (or1k_elf_relocate_section): Relax R_OR1K_GOT16 overflow check if we have R_OR1K_GOT_AHI16 followed by R_OR1K_GOT16.
2021-05-06or1k: Implement relocation R_OR1K_GOT_AHI16 for gotha()Stafford Horne14-4/+77
The gotha() relocation mnemonic will be outputted by OpenRISC GCC when using the -mcmodel=large option. This relocation is used along with got() to generate 32-bit GOT offsets. This increases the previous GOT offset limit from the previous 16-bit (64K) limit. This is needed on large binaries where the GOT grows larger than 64k. bfd/ChangeLog: PR 21464 * bfd-in2.h: Add BFD_RELOC_OR1K_GOT_AHI16 relocation. * elf32-or1k.c (or1k_elf_howto_table, or1k_reloc_map): Likewise. (or1k_final_link_relocate, or1k_elf_relocate_section, or1k_elf_check_relocs): Likewise. * libbfd.h (bfd_reloc_code_real_names): Likewise. * reloc.c: Likewise. cpu/ChangeLog: PR 21464 * or1k.opc (or1k_imm16_relocs, parse_reloc): Define parse logic for gotha() relocation. include/ChangeLog: PR 21464 * elf/or1k.h (elf_or1k_reloc_type): Define R_OR1K_GOT_AHI16 number. opcodes/ChangeLog: PR 21464 * or1k-asm.c: Regenerate. gas/ChangeLog: PR 21464 * testsuite/gas/or1k/reloc-1.s: Add test for new relocation. * testsuite/gas/or1k/reloc-1.d: Add test result for new relocation. Cc: Giulio Benetti <giulio.benetti@benettiengineering.com> fixup reloc, add tests
2021-05-06or1k: Fix issue with plt link failure for local callsStafford Horne2-5/+11
When building protobuf we were seeing the assert failure: /home/giuliobenetti/git/upstream/or1k-binutils-2.36.1/host/lib/gcc/or1k-buildroot-linux-uclibc/9.3.0/../../../../or1k-buildroot-linux-uclibc/bin/ld: BFD (GNU Binutils) 2.36.1 assertion fail elf32-or1k.c:2377 /home/giuliobenetti/git/upstream/or1k-binutils-2.36.1/host/lib/gcc/or1k-buildroot-linux-uclibc/9.3.0/../../../../or1k-buildroot-linux-uclibc/bin/ld: BFD (GNU Binutils) 2.36.1 assertion fail elf32-or1k.c:2377 /home/giuliobenetti/git/upstream/or1k-binutils-2.36.1/host/lib/gcc/or1k-buildroot-linux-uclibc/9.3.0/../../../../or1k-buildroot-linux-uclibc/bin/ld: BFD (GNU Binutils) 2.36.1 assertion fail elf32-or1k.c:2377 collect2: error: ld returned 1 exit status This failure happens while writing out PLT entries, there is a check "BFD_ASSERT (h->dynindx != -1)" to confirm all plt entries have dynamic symbol attributes. This was failing for symbols that were "forced_local" in previous linking code. The fix adds logic to or1k_elf_adjust_dynamic_symbol to identify "forced_local" symbols and exclude them from the the PLT. bfd/ChangeLog: PR 27624 * elf32-or1k.c (or1k_elf_adjust_dynamic_symbol): Change condition used to cleanup plt entries to cleanup forced local entries. Cc: Giulio Benetti <giulio.benetti@benettiengineering.com>
2021-05-06gdb/guile: don't try to print location for watchpointsAndrew Burgess4-5/+21
Currently, using the guile API, if a user tries to print a breakpoint object that represents a watchpoint, then GDB will crash. For example: (gdb) guile (use-modules (gdb)) (gdb) guile (define wp1 (make-breakpoint "some_variable" #:type BP_WATCHPOINT #:wp-class WP_WRITE)) (gdb) guile (register-breakpoint! wp1) (gdb) guile (display wp1) (newline) Aborted (core dumped) This turns out to be because GDB calls event_location_to_string on the breakpoints location, and watchpoint breakpoints don't have a location. This commit resolves the crash by just skipping the printing of the location if the breakpoint doesn't have one. Potentially, we could improve on this by printing details about what the watchpoint is watching, however, I'm considering this a possible future enhancement, this commit focuses just on having GDB not crash. gdb/ChangeLog: * guile/scm-breakpoint.c (bpscm_print_breakpoint_smob): Only print breakpoint locations when the breakpoint actually has a location. gdb/testsuite/ChangeLog: * gdb.guile/scm-breakpoint.exp (test_watchpoints): Print the watchpoint object before and after registering it with GDB.